gemi 0.72.1 → 0.73.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/index.js +2 -2
- package/dist/ai/index.js.map +1 -1
- package/dist/app/index.js +1 -1
- package/dist/auth/AuthController.d.ts.map +1 -1
- package/dist/auth/AuthManager.d.ts +33 -2
- package/dist/auth/AuthManager.d.ts.map +1 -1
- package/dist/auth/UserProvider.d.ts +34 -0
- package/dist/auth/UserProvider.d.ts.map +1 -1
- package/dist/auth/config.d.ts +2 -0
- package/dist/auth/config.d.ts.map +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/bun/plugin.js +1 -1
- package/dist/bun/preload.js +1 -1
- package/dist/{chunk-p7tbab19.js → chunk-1985hs9y.js} +3 -3
- package/dist/{chunk-p7tbab19.js.map → chunk-1985hs9y.js.map} +1 -1
- package/dist/{chunk-zz0t0pwk.js → chunk-1g38vvqa.js} +2 -2
- package/dist/{chunk-zz0t0pwk.js.map → chunk-1g38vvqa.js.map} +1 -1
- package/dist/{chunk-2a2qd22n.js → chunk-1wmv5pfx.js} +2 -2
- package/dist/{chunk-2a2qd22n.js.map → chunk-1wmv5pfx.js.map} +1 -1
- package/dist/{chunk-ebdtwzzr.js → chunk-2aqjpyfn.js} +2 -2
- package/dist/{chunk-ebdtwzzr.js.map → chunk-2aqjpyfn.js.map} +1 -1
- package/dist/{chunk-wtyn66c0.js → chunk-2ks8sxm6.js} +2 -2
- package/dist/{chunk-wtyn66c0.js.map → chunk-2ks8sxm6.js.map} +1 -1
- package/dist/{chunk-ryynt7wx.js → chunk-4pbt2n36.js} +2 -2
- package/dist/{chunk-ryynt7wx.js.map → chunk-4pbt2n36.js.map} +1 -1
- package/dist/{chunk-47589yz8.js → chunk-6z7mskmy.js} +3 -3
- package/dist/{chunk-47589yz8.js.map → chunk-6z7mskmy.js.map} +1 -1
- package/dist/{chunk-awjqnh2x.js → chunk-8vwegd30.js} +2 -2
- package/dist/{chunk-awjqnh2x.js.map → chunk-8vwegd30.js.map} +1 -1
- package/dist/{chunk-3g94pe6x.js → chunk-96s7s9vk.js} +2 -2
- package/dist/{chunk-3g94pe6x.js.map → chunk-96s7s9vk.js.map} +1 -1
- package/dist/{chunk-wxahf19j.js → chunk-9mbdndpk.js} +4 -4
- package/dist/{chunk-wxahf19j.js.map → chunk-9mbdndpk.js.map} +1 -1
- package/dist/{chunk-drrxkg9v.js → chunk-a4wng53r.js} +2 -2
- package/dist/{chunk-drrxkg9v.js.map → chunk-a4wng53r.js.map} +1 -1
- package/dist/{chunk-3w80kmxr.js → chunk-a77h1r8r.js} +2 -2
- package/dist/{chunk-3w80kmxr.js.map → chunk-a77h1r8r.js.map} +1 -1
- package/dist/{chunk-jgn1jyys.js → chunk-aw6qsgnz.js} +2 -2
- package/dist/{chunk-jgn1jyys.js.map → chunk-aw6qsgnz.js.map} +1 -1
- package/dist/{chunk-mt1776nd.js → chunk-baav1dfa.js} +2 -2
- package/dist/{chunk-mt1776nd.js.map → chunk-baav1dfa.js.map} +1 -1
- package/dist/{chunk-vt9tm0xx.js → chunk-bshgagpe.js} +2 -2
- package/dist/{chunk-vt9tm0xx.js.map → chunk-bshgagpe.js.map} +1 -1
- package/dist/{chunk-wa5emk60.js → chunk-cj7wywny.js} +2 -2
- package/dist/{chunk-wa5emk60.js.map → chunk-cj7wywny.js.map} +1 -1
- package/dist/chunk-cpnxj3jp.js +5 -0
- package/dist/{chunk-cvm5sm4m.js.map → chunk-cpnxj3jp.js.map} +1 -1
- package/dist/{chunk-gf3y4k0r.js → chunk-d341xmqy.js} +2 -2
- package/dist/{chunk-gf3y4k0r.js.map → chunk-d341xmqy.js.map} +1 -1
- package/dist/{chunk-5fxqzs72.js → chunk-d5qv8rny.js} +2 -2
- package/dist/{chunk-3zv572s2.js.map → chunk-d5qv8rny.js.map} +1 -1
- package/dist/{chunk-bt9rjc80.js → chunk-e7sjbe2v.js} +3 -3
- package/dist/{chunk-bt9rjc80.js.map → chunk-e7sjbe2v.js.map} +1 -1
- package/dist/{chunk-sbeszmmp.js → chunk-ess09cxa.js} +3 -3
- package/dist/{chunk-sbeszmmp.js.map → chunk-ess09cxa.js.map} +1 -1
- package/dist/{chunk-544va0er.js → chunk-ewtfq0zc.js} +3 -3
- package/dist/{chunk-544va0er.js.map → chunk-ewtfq0zc.js.map} +1 -1
- package/dist/{chunk-b53j44zv.js → chunk-g1gbqb9b.js} +2 -2
- package/dist/{chunk-b53j44zv.js.map → chunk-g1gbqb9b.js.map} +1 -1
- package/dist/{chunk-qm16ep90.js → chunk-g1j6bj44.js} +2 -2
- package/dist/{chunk-qm16ep90.js.map → chunk-g1j6bj44.js.map} +1 -1
- package/dist/{chunk-x3jwa5mx.js → chunk-g9n3909s.js} +2 -2
- package/dist/{chunk-x3jwa5mx.js.map → chunk-g9n3909s.js.map} +1 -1
- package/dist/{chunk-c6z9f6cp.js → chunk-g9ngr0yr.js} +2 -2
- package/dist/{chunk-c6z9f6cp.js.map → chunk-g9ngr0yr.js.map} +1 -1
- package/dist/{chunk-25a65e4r.js → chunk-j2g3a8tr.js} +2 -2
- package/dist/{chunk-25a65e4r.js.map → chunk-j2g3a8tr.js.map} +1 -1
- package/dist/{chunk-tfsbtz0j.js → chunk-kz4dssae.js} +2 -2
- package/dist/{chunk-tfsbtz0j.js.map → chunk-kz4dssae.js.map} +1 -1
- package/dist/chunk-m2j219n1.js +19 -0
- package/dist/{chunk-vqxpknyg.js.map → chunk-m2j219n1.js.map} +6 -6
- package/dist/{chunk-ak7jma5c.js → chunk-m99atvze.js} +2 -2
- package/dist/{chunk-ak7jma5c.js.map → chunk-m99atvze.js.map} +1 -1
- package/dist/{chunk-zkpwb3fp.js → chunk-mcf10epc.js} +2 -2
- package/dist/{chunk-zkpwb3fp.js.map → chunk-mcf10epc.js.map} +1 -1
- package/dist/{chunk-xh65fgg1.js → chunk-mnqfa84m.js} +2 -2
- package/dist/{chunk-xh65fgg1.js.map → chunk-mnqfa84m.js.map} +1 -1
- package/dist/{chunk-b2bpwb1d.js → chunk-mrhqmd89.js} +2 -2
- package/dist/{chunk-b2bpwb1d.js.map → chunk-mrhqmd89.js.map} +1 -1
- package/dist/{chunk-n74re6da.js → chunk-mrrcyw69.js} +2 -2
- package/dist/{chunk-n74re6da.js.map → chunk-mrrcyw69.js.map} +1 -1
- package/dist/{chunk-t2t2qcj4.js → chunk-n28jwe5c.js} +2 -2
- package/dist/{chunk-t2t2qcj4.js.map → chunk-n28jwe5c.js.map} +1 -1
- package/dist/{chunk-0j8v3dd3.js → chunk-n2m5x0k8.js} +2 -2
- package/dist/{chunk-0j8v3dd3.js.map → chunk-n2m5x0k8.js.map} +1 -1
- package/dist/{chunk-ps59yj5b.js → chunk-n3d4vv6y.js} +2 -2
- package/dist/{chunk-ps59yj5b.js.map → chunk-n3d4vv6y.js.map} +1 -1
- package/dist/chunk-ndh57kp0.js +5 -0
- package/dist/{chunk-t48gchew.js.map → chunk-ndh57kp0.js.map} +5 -5
- package/dist/{chunk-gjanfny1.js → chunk-nnwnj4jb.js} +3 -3
- package/dist/{chunk-gjanfny1.js.map → chunk-nnwnj4jb.js.map} +1 -1
- package/dist/{chunk-sm8h95v3.js → chunk-nrfbbc2c.js} +2 -2
- package/dist/{chunk-sm8h95v3.js.map → chunk-nrfbbc2c.js.map} +1 -1
- package/dist/{chunk-yvkm7qya.js → chunk-ntgp0dqx.js} +2 -2
- package/dist/{chunk-yvkm7qya.js.map → chunk-ntgp0dqx.js.map} +1 -1
- package/dist/{chunk-akbawnmg.js → chunk-nzkywxk9.js} +2 -2
- package/dist/{chunk-akbawnmg.js.map → chunk-nzkywxk9.js.map} +1 -1
- package/dist/{chunk-44j2dckn.js → chunk-p4ndrnar.js} +3 -3
- package/dist/{chunk-44j2dckn.js.map → chunk-p4ndrnar.js.map} +1 -1
- package/dist/{chunk-rnbgw55r.js → chunk-p8bgd7vp.js} +2 -2
- package/dist/{chunk-rnbgw55r.js.map → chunk-p8bgd7vp.js.map} +1 -1
- package/dist/{chunk-88qvsv9w.js → chunk-qcqw9z1t.js} +2 -2
- package/dist/{chunk-88qvsv9w.js.map → chunk-qcqw9z1t.js.map} +1 -1
- package/dist/{chunk-qcpar2xh.js → chunk-qjrswqwd.js} +2 -2
- package/dist/{chunk-qcpar2xh.js.map → chunk-qjrswqwd.js.map} +1 -1
- package/dist/{chunk-yt96ny9v.js → chunk-qsczv1xt.js} +2 -2
- package/dist/{chunk-yt96ny9v.js.map → chunk-qsczv1xt.js.map} +1 -1
- package/dist/chunk-rdffbqsq.js +5 -0
- package/dist/{chunk-xkt6pnv3.js.map → chunk-rdffbqsq.js.map} +5 -5
- package/dist/{chunk-bjr740m4.js → chunk-sh75zszh.js} +1 -1
- package/dist/{chunk-gkedmh5f.js → chunk-tdqn1fqd.js} +2 -2
- package/dist/{chunk-gkedmh5f.js.map → chunk-tdqn1fqd.js.map} +1 -1
- package/dist/{chunk-r4t5a213.js → chunk-ve6v5t13.js} +1 -1
- package/dist/{chunk-8dvntsme.js → chunk-vn29fg7p.js} +2 -2
- package/dist/{chunk-8dvntsme.js.map → chunk-vn29fg7p.js.map} +1 -1
- package/dist/{chunk-w316w188.js → chunk-vta5fnxp.js} +2 -2
- package/dist/{chunk-w316w188.js.map → chunk-vta5fnxp.js.map} +1 -1
- package/dist/{chunk-385exk8p.js → chunk-wg1g7qbk.js} +2 -2
- package/dist/{chunk-385exk8p.js.map → chunk-wg1g7qbk.js.map} +1 -1
- package/dist/{chunk-4yj86ds2.js → chunk-x6yef8np.js} +2 -2
- package/dist/{chunk-4yj86ds2.js.map → chunk-x6yef8np.js.map} +1 -1
- package/dist/{chunk-ejspccjb.js → chunk-ygt0r1hh.js} +1 -1
- package/dist/{chunk-3zv572s2.js → chunk-yty60qzd.js} +2 -2
- package/dist/{chunk-5fxqzs72.js.map → chunk-yty60qzd.js.map} +1 -1
- package/dist/{chunk-gn0vhf9n.js → chunk-yw8rp9nc.js} +2 -2
- package/dist/{chunk-gn0vhf9n.js.map → chunk-yw8rp9nc.js.map} +1 -1
- package/dist/{chunk-ev1pe2ry.js → chunk-z8rj43d3.js} +2 -2
- package/dist/{chunk-ev1pe2ry.js.map → chunk-z8rj43d3.js.map} +1 -1
- package/dist/{chunk-z99bj1mv.js → chunk-zcg2nj18.js} +2 -2
- package/dist/{chunk-z99bj1mv.js.map → chunk-zcg2nj18.js.map} +1 -1
- package/dist/{chunk-26n9365a.js → chunk-zp2yz0yr.js} +3 -3
- package/dist/{chunk-26n9365a.js.map → chunk-zp2yz0yr.js.map} +1 -1
- 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/HttpRequest.d.ts +6 -1
- package/dist/http/HttpRequest.d.ts.map +1 -1
- package/dist/http/index.d.ts +1 -0
- 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/http/validate.d.ts +12 -0
- package/dist/http/validate.d.ts.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 +1 -1
- package/dist/kernel/index.js +2 -2
- package/dist/kernel/index.js.map +1 -1
- package/dist/orm/index.js +3 -3
- package/dist/orm/index.js.map +1 -1
- package/dist/server/index.js +2 -2
- package/dist/server/index.js.map +1 -1
- package/dist/services/index.js +2 -2
- package/dist/services/index.js.map +1 -1
- package/dist/services/queue/work.js +2 -2
- package/dist/services/queue/work.js.map +1 -1
- package/dist/support/index.js +2 -2
- package/dist/support/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-cvm5sm4m.js +0 -5
- package/dist/chunk-t48gchew.js +0 -5
- package/dist/chunk-vqxpknyg.js +0 -19
- package/dist/chunk-xkt6pnv3.js +0 -5
- /package/dist/{chunk-bjr740m4.js.map → chunk-sh75zszh.js.map} +0 -0
- /package/dist/{chunk-r4t5a213.js.map → chunk-ve6v5t13.js.map} +0 -0
- /package/dist/{chunk-ejspccjb.js.map → chunk-ygt0r1hh.js.map} +0 -0
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
"import type { HttpRequest } from \"../http/HttpRequest\";\nimport type { Dictionary } from \"./Dictionary\";\nimport type { TranslationConfig } from \"./config\";\nimport { resolveLocale } from \"./resolveLocale\";\n\nexport class Translator {\n static token = \"translator\";\n\n translations = {};\n isEnabled = false;\n\n constructor(public config: Required<TranslationConfig>) {\n const translations = {};\n\n for (const [route, dicArray] of Object.entries(this.config.prefetch)) {\n for (const locale of this.config.supportedLocales) {\n if (!translations[locale]) {\n translations[locale] = {};\n }\n translations[locale][route] = {};\n for (const dic of dicArray) {\n translations[locale][route][dic.name] = {};\n for (const [key, value] of Object.entries(dic.dictionary)) {\n this.isEnabled = true;\n translations[locale][route][dic.name][key] = value[locale];\n }\n }\n }\n }\n this.translations = translations;\n }\n\n /**\n * Whether the app does locale-aware routing and rendering at all.\n *\n * `isEnabled` only means the legacy `prefetch` config has dictionaries to\n * serve. An app on `defineDictionary` has an empty `prefetch` and declares\n * its locales through `supportedLocales` alone, so gating on `isEnabled`\n * leaves it without locale detection or a locale URL prefix. Both the render\n * path and the redirect read this, because when they disagreed a migrated app\n * rendered a non-default locale at `/` with no redirect and no `Vary` — one\n * cache fill away from serving that document to everyone.\n */\n get isLocaleAware(): boolean {\n return this.isEnabled || this.config.supportedLocales.length > 0;\n }\n\n get supportedLocales(): string[] {\n return this.config.supportedLocales;\n }\n\n get defaultLocale(): string {\n return this.config.defaultLocale;\n }\n\n get components(): Record<string, Dictionary<any>> {\n return this.config.components;\n }\n\n onLocaleChange(locale: string): Promise<void> | void {\n return this.config.onLocaleChange(locale);\n }\n\n detectLocale(req: HttpRequest<any, any>) {\n const fallbackLocale =\n this.config.defaultLocale ?? this.config.supportedLocales[0] ?? \"en-US\";\n const resolve = (tag: string | null | undefined) =>\n resolveLocale(tag, this.config.supportedLocales, this.config.defaultLocale);\n\n const detectedLocale = resolve(this.config.detectLocale(req));\n if (detectedLocale) {\n return detectedLocale;\n }\n\n const previousLocale = resolve(req.cookies.get(\"i18n-locale\"));\n if (previousLocale) {\n return previousLocale;\n }\n\n // Entries are in the browser's preference order; the first one the app can\n // serve, even by language alone (`de-AT` → `de-DE`), wins.\n const acceptLanguage = req.headers.get(\"accept-language\") ?? \"\";\n for (const entry of acceptLanguage.split(\",\")) {\n const locale = resolve(entry);\n if (locale) {\n return locale;\n }\n }\n\n return fallbackLocale;\n }\n\n getPageTranslations(locale: string, scope: string) {\n if (this.translations[locale][scope]) {\n return this.translations[locale][scope];\n }\n return {};\n }\n}\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": ";AAGA,IAAM,EAAa,sCAEZ,SAAS,CAAe,CAAC,EAA0B,CACxD,OAAO,EAAW,KAAK,CAAO,EAGhC,SAAS,CAAU,CAAC,EAAqB,CACvC,OAAO,EAAI,MAAM,MAAM,EAAE,GAAG,YAAY,EAYnC,SAAS,CAAa,CAC3B,EACA,EACA,EACe,CAEf,IAAM,EAAM,GAAW,MAAM,GAAG,EAAE,GAAG,KAAK,EAC1C,GAAI,CAAC,GAAO,CAAC,EAAgB,CAAG,EAC9B,OAAO,KAGT,IAAM,EAAa,EAAI,WAAW,IAAK,GAAG,EAAE,YAAY,EAClD,EAAQ,EAAiB,KAAK,CAAC,IAAM,EAAE,YAAY,IAAM,CAAU,EACzE,GAAI,EACF,OAAO,EAGT,IAAM,EAAW,EAAW,CAAG,EACzB,EAAe,EAAiB,OAAO,CAAC,IAAM,EAAW,CAAC,IAAM,CAAQ,EAC9E,GAAI,EAAa,SAAW,EAC1B,OAAO,KAET,GAAI,GAAiB,EAAa,SAAS,CAAa,EACtD,OAAO,EAET,OAAO,EAAa,GC1Cf,MAAM,CAAW,CAMH,aALZ,OAAQ,aAEf,aAAe,CAAC,EAChB,UAAY,GAEZ,WAAW,CAAQ,EAAqC,CAArC,cACjB,IAAM,EAAe,CAAC,EAEtB,QAAY,EAAO,KAAa,OAAO,QAAQ,KAAK,OAAO,QAAQ,EACjE,QAAW,KAAU,KAAK,OAAO,iBAAkB,CACjD,GAAI,CAAC,EAAa,GAChB,EAAa,GAAU,CAAC,EAE1B,EAAa,GAAQ,GAAS,CAAC,EAC/B,QAAW,KAAO,EAAU,CAC1B,EAAa,GAAQ,GAAO,EAAI,MAAQ,CAAC,EACzC,QAAY,EAAK,KAAU,OAAO,QAAQ,EAAI,UAAU,EACtD,KAAK,UAAY,GACjB,EAAa,GAAQ,GAAO,EAAI,MAAM,GAAO,EAAM,IAK3D,KAAK,aAAe,KAclB,cAAa,EAAY,CAC3B,OAAO,KAAK,WAAa,KAAK,OAAO,iBAAiB,OAAS,KAG7D,iBAAgB,EAAa,CAC/B,OAAO,KAAK,OAAO,oBAGjB,cAAa,EAAW,CAC1B,OAAO,KAAK,OAAO,iBAGjB,WAAU,EAAoC,CAChD,OAAO,KAAK,OAAO,WAGrB,cAAc,CAAC,EAAsC,CACnD,OAAO,KAAK,OAAO,eAAe,CAAM,EAG1C,YAAY,CAAC,EAA4B,CACvC,IAAM,EACJ,KAAK,OAAO,eAAiB,KAAK,OAAO,iBAAiB,IAAM,QAC5D,EAAU,CAAC,IACf,EAAc,EAAK,KAAK,OAAO,iBAAkB,KAAK,OAAO,aAAa,EAEtE,EAAiB,EAAQ,KAAK,OAAO,aAAa,CAAG,CAAC,EAC5D,GAAI,EACF,OAAO,EAGT,IAAM,EAAiB,EAAQ,EAAI,QAAQ,IAAI,aAAa,CAAC,EAC7D,GAAI,EACF,OAAO,EAKT,IAAM,EAAiB,EAAI,QAAQ,IAAI,iBAAiB,GAAK,GAC7D,QAAW,KAAS,EAAe,MAAM,GAAG,EAAG,CAC7C,IAAM,EAAS,EAAQ,CAAK,EAC5B,GAAI,EACF,OAAO,EAIX,OAAO,EAGT,mBAAmB,CAAC,EAAgB,EAAe,CACjD,GAAI,KAAK,aAAa,GAAQ,GAC5B,OAAO,KAAK,aAAa,GAAQ,GAEnC,MAAO,CAAC,EAEZ",
|
|
9
|
-
"debugId": "
|
|
9
|
+
"debugId": "3ADC849B058C169664756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Md as yW,Td as z5}from"./chunk-yw8rp9nc.js";import{Ke as W5,_d as a$,de as qO}from"./chunk-ngq4n2b3.js";import{$e as N0,Le as gZ,Ne as r4,Pe as c4,Qe as _W,Re as PZ,Se as IZ,Ve as xZ,We as NZ,Xe as s$,Ye as b4,Ze as mO,_e as m1,bf as E,cf as RZ,df as kZ,ef as _Z,gf as q1,hf as O0,if as CZ}from"./chunk-ndh57kp0.js";import{pf as V4,qf as OW,rf as x}from"./chunk-zcg2nj18.js";import{sf as o4}from"./chunk-mnqfa84m.js";import{Gf as j5,tf as i4,uf as OO,vf as TO,wf as Z5,xf as f5}from"./chunk-ess09cxa.js";import{Vf as ZO}from"./chunk-rdffbqsq.js";import{_f as m4,dg as q4}from"./chunk-aw6qsgnz.js";import{jg as k4,kg as n}from"./chunk-kz4dssae.js";import{ng as K}from"./chunk-zp2yz0yr.js";import{og as u$}from"./chunk-baav1dfa.js";import{Ag as xj}from"./chunk-j2g3a8tr.js";import{Cg as h4}from"./chunk-4pbt2n36.js";import{Hg as ZW}from"./chunk-d5qv8rny.js";import{randomBytes as DF}from"crypto";function lO($){return typeof $==="function"&&$.prototype!==void 0}function G1($){return typeof $==="string"?[$]:$}function dO($,O){let T=O?"attachment":"inline",Z=$.replace(/["\\]/g,"").replace(/[^\x20-\x7e]/g,"_");return`${T}; filename="${Z}"; filename*=UTF-8''${encodeURIComponent($)}`}function L5($){return"total"in $&&"partial"in $&&"body"in $}function e$($){return new Response(null,{status:416,headers:{"Accept-Ranges":"bytes","Content-Range":NZ($),"Content-Length":"0","Cache-Control":"no-store"}})}async function Q5($){if($ instanceof Blob)return{body:$,start:0,end:$.size-1,total:$.size,partial:!1,type:$.type,name:$.name,download:!1,status:200,extraHeaders:{}};if(L5($))return{body:$.body,start:$.start,end:$.end,total:$.total,partial:$.partial,type:$.type,name:$.name,download:!1,etag:$.etag,lastModified:$.lastModified,status:200,extraHeaders:{}};let O=$.file,T=O instanceof Blob?O:null,Z=$.total??T?.size??-1;return{body:O,start:$.start??0,end:$.end??Z-1,total:Z,partial:$.partial??!1,type:$.type??T?.type??"",name:$.name??O?.name,download:$.download??!1,etag:$.etag,lastModified:$.lastModified,status:$.status??200,extraHeaders:$.headers??{}}}async function EZ($,O){if($ instanceof Response)return $;if(!$)return new Response("Not found",{status:404});let T=await Q5($),{body:Z,start:f,end:j,total:W,partial:z}=T;if(Z instanceof Blob&&"exists"in Z&&typeof Z.exists==="function"){if(!await Z.exists())return new Response("Not found",{status:404})}let{range:J}=O;if(J){if(W<=0)return e$(Math.max(W,0));if(!z){if(Z instanceof Blob){let Y=IZ(J,W);if(!Y)return e$(W);Z=Z.slice(Y.start,Y.end+1),f=Y.start,j=Y.end,z=!0}}}let C=Boolean(J)&&z,F=C?206:T.status,D=new Headers;if(D.set("Accept-Ranges","bytes"),D.set("Content-Type",T.type||"application/octet-stream"),C)D.set("Content-Range",xZ(f,j,W)),D.set("Content-Length",String(j-f+1));else if(W>=0)D.set("Content-Length",String(W));if(T.name)D.set("Content-Disposition",dO(T.name,T.download));if(T.etag)D.set("ETag",T.etag);if(T.lastModified)D.set("Last-Modified",T.lastModified.toUTCString());for(let[Y,U]of Object.entries(T.extraHeaders))D.set(Y,U);if((O.method??"GET").toUpperCase()==="HEAD"){if(Z&&"cancel"in Z&&typeof Z.cancel==="function")await Z.cancel();return new Response(null,{status:F,headers:D})}return new Response(Z,{status:F,headers:D})}function YW($){return lO($)}class u{method;handler;methodName;__internal_brand="RouteHandler";middlewares=[];constructor($,O,T){this.method=$;this.handler=O;this.methodName=T;this.handler=O,this.methodName=T,this.method=$}get source(){if(!YW(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(YW(this.handler)){let O=new this.handler;return O[this.methodName].bind(O)()}return this.handler()}middleware($){return this.middlewares=G1($),this}}class DW{url;headers;__internal_brand="ProxyHandler";constructor($,O){this.url=$;this.headers=O}run(){let $=new E;return fetch(this.url,{method:$.rawRequest.method,headers:{...$.headers.toJSON(),...this.headers},body:$.rawRequest.body})}}class XW{constructor(...$){return new u(...$)}}class UW extends u{__internal_brand="StreamHandler";async run($){let O=x.getStore(),T=O?.req?.rawRequest,Z=PZ(T?.headers.get("Range"));if(O)O.rangeRequest=Z;try{let f=await super.run($);return await EZ(f,{range:Z,method:T?.method})}catch(f){if(f instanceof _Z)return e$(f.total);throw f}finally{if(O)O.rangeRequest=null}}}class GW{constructor(...$){return new UW(...$)}}class BW{__internal_brand="ResourceRoutes";first;second;constructor($){this.first={get:new u("GET",$,"list"),post:new u("POST",$,"store")},this.second={get:new u("GET",$,"show"),put:new u("PUT",$,"update"),delete:new u("DELETE",$,"delete")}}middleware($){if($.list)this.first.get.middleware($.list);if($.store)this.first.post.middleware($.store);if($.show)this.second.get.middleware($.show);if($.update)this.second.put.middleware($.update);if($.delete)this.second.delete.middleware($.delete);return this}}class x0{static __brand="ApiRouter";routes={};middlewares=[];middleware($){}get($,O){return new u("GET",$,O)}post($,O){return new u("POST",$,O)}put($,O){return new u("PUT",$,O)}patch($,O){return new u("PATCH",$,O)}delete($,O){return new u("DELETE",$,O)}resource($){return new BW($)}agent($){return S5($,this)}file($,O){return new XW("GET",$,O)}stream($,O){return new GW("GET",$,O)}proxy($,O={}){return new DW($,O)}}function S5($,O){let T={stream:new u("POST",$,"stream"),attach:new u("POST",$,"attach"),stop:new u("POST",$,"stop"),upload:new u("POST",$,"upload")};return class extends x0{static __internal_brand="AgentRoute";static controller=$;static handlers=T;constructor(){super();this.middlewares=[...O?.middlewares??[]]}routes={"/":T.stream,"/attach":T.attach,"/stop":T.stop,"/files":T.upload};static middleware(f){if(f.stream)T.stream.middleware(f.stream);if(f.attach)T.attach.middleware(f.attach);if(f.stop)T.stop.middleware(f.stop);if(f.upload)T.upload.middleware(f.upload);return this}}}class AZ{method;url;meta;__internal_brand="McpRoute";constructor($,O,T){this.method=$;this.url=O;this.meta=T}}class KW{static __brand="McpRouter";routes={};fromApiRoute($,O,T){return new AZ($,O,T)}}function s($,O){return $.replace(/:([^/]+[*?]?)/g,(T,Z)=>{let f=Z.endsWith("?")||Z.endsWith("*"),j=f?Z.slice(0,-1):Z,W=O[j];if(W===void 0){if(f)return"";if(import.meta.env.DEV)throw Error(`Missing parameter: ${j}`);console.error(`Missing parameter: ${j} in URL: ${$}`)}return String(W)}).replace(/\/\//g,"/").replace(/\/$/,"")}class HZ extends m1{constructor($,O=307){super("Redirect error");this.name="RedirectError",this.payload={api:{status:200,data:{},directive:{kind:"Redirect",path:$}},view:{status:O,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:$}}}}}class uO{static to($,...O){let[T={}]=O,{search:Z={},params:f={},permanent:j,status:W}={params:{},status:307,permanent:!1,...T},z=new URLSearchParams(Z).toString();throw new HZ([s($,f)||"/",z.toString()].filter(Boolean).join("?"),W??(j?301:307))}static external($,O=307){throw new HZ($,O)}}class LW{kind="redirect";viewPath="REDIRECT";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>({});else if(typeof $==="function")this.handler=$;else{let[O,T]=$;this.handler=(Z)=>{return new O()[T](Z)}}}async run($,O){let{destination:T,permanent:Z=!1,status:f=307}=await this.handler($);if(!T)throw Error(`Redirect destination is required see ${O}`);return uO.to(T,{permanent:Z,status:f}),{}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}async function wZ($,O){if($ instanceof Response)return $;let T=$ instanceof Blob,Z=T?$:$.file,f=T?$.name:$.name??$.file?.name,j=(T?$.type:$.type??$.file?.type)||"",W=T?!1:$.download??!1,z=T?200:$.status??200;if(!T)for(let[J,C]of Object.entries($.headers??{}))O.set(J,C);if(Z instanceof Blob&&"exists"in Z&&typeof Z.exists==="function"){if(!await Z.exists())return new Response("Not found",{status:404})}if(O.set("Content-Type",j||"application/octet-stream"),Z instanceof Blob)O.set("Content-Length",String(Z.size));if(f)O.set("Content-Disposition",dO(f,W));return new Response(Z instanceof Blob?Z.stream():Z,{status:z,headers:O})}class QW{kind="file";viewPath="FILE";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>null;else if(typeof $==="function")this.handler=$;else{let[O,T]=$;this.handler=(Z)=>{return new O()[T](Z)}}}async run($,O){let T=await this.handler($);if(!T)throw Error(`File route handler must return a file see ${O}`);return{FILE:T}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class SW{viewPath;middlewares=[];featureGates=[];handler;constructor($,O){this.viewPath=$;if(!O)this.handler=()=>({});else if(typeof O==="function")this.handler=O;else{let[T,Z]=O;this.handler=(f)=>{return new T()[Z](f)}}}async run($,O){let T=await this.handler($);return{[this.viewPath]:{...T,breadcrumb:{label:T?.breadcrumb??"",href:O}}}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class MW{viewPath;children;middlewares=[];featureGates=[];alwaysRuns=!1;handler=()=>({});constructor($,O,T){this.viewPath=$;if(typeof O==="function")this.handler=O,this.children=class extends B1{routes=T??{}};else if(Array.isArray(O)){let[Z,f]=O;this.handler=(j)=>{return new Z()[f](j)},this.children=class extends B1{routes=T??{}}}else this.children=class extends B1{routes=O},this.handler=()=>({})}async run($,O){let T=await this.handler($);return{[this.viewPath]:{...T,breadcrumb:{label:T?.breadcrumb??"",href:O}}}}alwaysRun(){return this.alwaysRuns=!0,this}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class B1{middlewares=[];featureGates=[];routes={};view($,O){return new SW($,O)}file($){return new QW($)}redirect($){return new LW($)}layout($,O,T){return new MW($,O,T)}}class v0{req;config={};constructor($){this.req=$}run(...$){return{}}static configure($){let O=this;return class extends O{config=$}}}function M5($){return $}function V5(){return{aliases:{},global:[]}}var D$="redirect";function $O($,O="/"){if(typeof $!=="string"||!$.startsWith("/"))return O;if(/[\u0000-\u001f\u007f\\]/.test($)||$.startsWith("//"))return O;try{let T=new URL($,"http://gemi.invalid");if(T.origin!=="http://gemi.invalid")return O;let Z=`${T.search}${T.hash}`.replaceAll("/","%2F"),f=`${T.pathname}${Z}`.replaceAll(":","%3A");return f.startsWith("//")?O:f}catch{return O}}function VW($){let O=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();return O?O==="https":new URL($.url).protocol==="https:"}function I5($,O=!0){let T=new URL($.rawRequest.url),Z=T.pathname.replace(/\.(json|og)$/,""),[,f,...j]=Z.split("/");if(K(n).supportedLocales.includes(f))Z=`/${j.join("/")}`;return O?`${Z}${T.search}`:Z}function x5($,O){let T=(Z)=>Z.replace(/\/+$/,"")||"/";return T($)===T(O)}function sO($,O){let T=O||K(w).config.signInPath,Z=/^[a-z][a-z\d+.-]*:/i.test(T);if(Z?!/^https?:\/\//i.test(T):!T.startsWith("/"))throw Error(`\`auth.signInPath\` must be a path like "/auth/sign-in", or an http(s) URL for sign-in hosted elsewhere. Got "${T}". A route's own \`"auth:<path>"\` cannot carry a URL, because the alias parser splits it on the colon.`);let f=new URL(T,"http://gemi.invalid");if($?.kind==="view"){let j=I5($,!Z);if(Z||!x5(new URL(j,f).pathname,f.pathname))f.searchParams.set(D$,j)}return Z?f.href:`${f.pathname}${f.search}`}class IW extends v0{async run($){let O=x.getStore(),T=O.req,Z=()=>new q1({redirectTo:sO(T,$)}),f=T.cookies.get("access_token"),j=T.headers.get("access_token"),W=f||j;if(!W)throw Z();let z=O.user;if(!z){let J=await K(w).getSession(W,T.headers.get("User-Agent"));if(!J)throw Z();z=J?.user,O.setUser(z)}return{}}}class xW extends v0{async run(...$){let[O="public",T="864000",...Z]=$,f=`${O}, max-age=${T}${Z.length>0?", ":""}${Z.join(", ")}`;if($.length===0)f="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="public")f="public, max-age=864000, stale-while-revalidate=300, stale-if-error=600";if($.length===1&&$[0]==="private")f="private, max-age=0, stale-while-revalidate=300, stale-if-error=600";if(this.req.rawRequest.method==="GET")this.req.ctx().setHeaders("Cache-Control",f);return{}}}var N5={"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 NW extends v0{config={origins:{"":{"Access-Control-Allow-Methods":"GET, HEAD, POST, PUT, DELETE, OPTIONS","Access-Control-Allow-Headers":"Content-Type, Authorization, X-Requested-With","Access-Control-Allow-Credentials":"true"}}};run(){let $=this.req,O=$.rawRequest.headers.get("Origin");if(this.config.origins[O]){$.ctx().setHeaders("Access-Control-Allow-Origin",O);let T={...N5,...this.config.origins[O]};for(let[Z,f]of Object.entries(T))$.ctx().setHeaders(Z,f)}return{}}}class X${config;static token="ratelimiter";constructor($){this.config=$}get driver(){return this.config.driver}async consume($,O={}){let T=O.limit??this.config.limit,Z=O.window??this.config.window,f=O.cost??1;if(EW("window",Z),EW("limit",T),!Number.isFinite(f)||f<0)throw Error(`Rate limiter cost must be zero or greater, got ${f}`);return await this.config.driver.consume({key:$,limit:T,window:Z*1000,cost:f})}}function EW($,O){if(!Number.isFinite(O)||O<=0)throw Error(`Rate limiter ${$} must be greater than zero, got ${O}`)}class bZ extends m1{constructor($){super("Rate limit exceeded");let O={"Content-Type":"application/json",...$?HW($):{}};this.payload={api:{status:429,data:{error:{message:"Rate limit exceeded"}},headers:O},view:{error:{message:"Rate limit exceeded"},status:429,headers:O}}}}class AW extends v0{async run($,O){let T=E5();if(!T)return{};let Z=await T.consume(this.key(),{limit:PW($)??this.config.limit,window:PW(O)??this.config.window});if(this.config.headers!==!1){let f=this.req.ctx?.();if(f)for(let[j,W]of Object.entries(HW(Z)))f.setHeaders(j,W)}if(!Z.allowed)throw new bZ(Z);return{}}key(){if(this.config.key)return this.config.key(this.req);return`${nO(this.req)}:${this.req.routePath??"*"}`}}function E5(){try{let $=K();return $.bound(X$)?$.make(X$):null}catch{return null}}function nO($){let O=_W($.rawRequest);if(O!==void 0)return O;let T=$.headers.get("x-forwarded-for");if(T){let[Z]=T.split(",");if(Z?.trim())return Z.trim()}return $.headers.get("x-real-ip")?.trim()||"unknown"}function HW($){let O={"X-RateLimit-Limit":String($.limit),"X-RateLimit-Remaining":String($.remaining),"X-RateLimit-Reset":String(Math.ceil($.resetAt/1000))};if(!$.allowed)O["Retry-After"]=String(Math.max(1,Math.ceil($.retryAfter/1000)));return O}function PW($){if($===void 0||$===null||$==="")return;let O=Number($);if(!Number.isFinite(O)||O<=0)return;return O}class wW extends v0{async run(){let $=this.req.cookies.get("csrf_token");if(!$)throw new vZ;if(!["POST","PUT","PATCH","DELETE"].includes(this.req.rawRequest.method))return{};if(!Bun.CSRF.verify($,{secret:process.env.SECRET}))throw new vZ;return{}}}class vZ extends m1{constructor(){super("Invalid CSRF token");this.name="InvalidCSRFTokenError"}payload={api:{status:403,data:{error:"Invalid CSRF token"}},view:{}}}class bW{policiesList={};constructor(){let $=this.register();for(let O of $){let T=new O;this.policiesList[O.name]=T}}register(){return[]}}class vW{all($,O){return!0}}import{createHmac as gW,randomBytes as P5}from"crypto";var mZ="v2.";function qZ($){return $.startsWith(mZ)}function RW(){let $=process.env.SECRET;if(!$)throw Error("Signing in needs a secret to mint session tokens with. Set SECRET in the environment.");return $}function kW($){let O=P5(16).toString("hex"),T=gW("sha256",RW()).update(`${$}:${O}`).digest("hex");return`${mZ}${T}`}function aO($,O){let T=gW("sha256",RW()).update(`legacy-session:${O}:${$}`).digest("hex");return`${mZ}${T}`}import{randomBytes as pZ}from"crypto";class yZ extends E{schema={name:{string:"Invalid name",required:"Name is required","min:2":"Name must be at least 3 characters"},email:{string:"Invalid email",required:"Email is required",email:"Invalid email"},password:{"min:8":"Password must be at least 9 characters"}}}function TD($){return $}function mW($={}){return{basePath:"/auth",verifyEmail:!0,redirectPath:"/dashboard",signInPath:"/auth/sign-in",sessionExpiresInHours:24,sessionAbsoluteExpiresInHours:672,cookieDomain:null,migrateLegacySession:null,signUpRequest:yZ,oauthProviders:{},verifyPassword:async(O,T)=>await Bun.password.verify(O,T),hashPassword:async(O)=>await Bun.password.hash(O),generateForgotPasswordToken:async()=>pZ(32).toString("hex"),generateEmailVerificationToken:()=>{if(!($.verifyEmail??!0))return"";return pZ(32).toString("hex")},generateMagicLinkToken:()=>pZ(32).toString("hex"),extendSession:()=>({}),onUserCreated:async()=>{},onSignUp:()=>{},onSignIn:()=>{},onSignOut:()=>{},onForgotPassword:()=>{},onResetPassword:()=>{},onMagicLinkCreated:()=>{}}}function cZ($){if($&&typeof $==="object")delete $.password;return $}function _5(){return new Proxy({},{get:($,O)=>yW(O)})}var qW=new WeakMap;function pW($){if($&&typeof $==="object"){for(let O of Object.values($))pW(O);Object.freeze($)}return $}var A5={select:{id:!0,publicId:!0,email:!0,name:!0,locale:!0,globalRole:!0,accounts:{select:{id:!0,publicId:!0,organizationRole:!0,organization:!0}}}},H5=pW({token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:A5});class iZ{models;constructor($=_5()){this.models=$}run($){return this.models.User.asSystem($)}sessionSelect(){return H5}transaction($){return this.models.User.transaction($)}withLegacySessionLock($,O){let T=this.models.User.$connection??TO(),Z=K(ZO).connection(T),f=()=>this.transaction(async()=>{if(Z.dialect==="postgres"){let z=`gemi:legacy-session:${$}`;await OO()`SELECT pg_advisory_xact_lock(hashtextextended(${z}, 0))`}return O()});if(Z.dialect!=="sqlite"||OO())return f();let W=(qW.get(Z)??Promise.resolve()).then(f,f);return qW.set(Z,W.catch(()=>{})),W}async createUser($){let O=await this.run(()=>this.models.User.create({data:$}));return cZ(O)}async updateUserPassword($){let O=await this.run(()=>this.models.User.update({where:{id:$.id},data:{password:$.password}}));return cZ(O)}async findUserByEmailAddress($,O){return await this.run(()=>this.models.User.findUnique({where:O?{email:$,emailVerifiedAt:{not:null}}:{email:$}}))}async findUserByVerificationToken($){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(O){return console.error("findSession failed:",O),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:O}=await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}));return O>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($){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($,O){return await this.run(()=>this.models.OrganizationInvitation.findFirst({where:{publicId:$,email:O}}))}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($){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 deleteMagicLinkToken($){await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{email:$}}))}async createSocialAccount($){return await this.run(()=>this.models.SocialAccount.create({data:$}))}async findUserBySocialAccount($,O){if(!O)return null;let T=await this.run(()=>this.models.SocialAccount.findFirst({where:{provider:$,providerId:O},include:{user:!0}}));return T?cZ(T.user):null}async findSocialAccounts($,O){return await this.run(()=>this.models.SocialAccount.findMany({where:{userId:$,provider:O},orderBy:{id:"asc"}}))}async claimSocialAccount($,O){let{count:T}=await this.run(()=>this.models.SocialAccount.updateMany({where:{id:$.id,providerId:$.providerId},data:{providerId:O}}));return T===1}}import{timingSafeEqual as CF}from"crypto";function E0($,O,T,Z,f){return m0(O,T6($,O),T,Z,f)}function m0($,O,T,Z,f,j){let W=sZ(O,T,Z);if(f&&O!==W)throw RangeError(yz($,O,T,Z,j));return W}function T6($,O){let T=$[O];if(T===void 0)throw TypeError(Vf(O));return T}function W0($){return $!==null&&/object|function/.test(typeof $)}function A0($,O=Map){let T=new O;return(Z,...f)=>{if(T.has(Z))return T.get(Z);let j=$(Z,...f);return T.set(Z,j),j}}function O3($){return i1({name:$},1)}function i1($,O){return c0((T)=>({value:T,configurable:1,writable:!O}),$)}function Z6($){return c0((O)=>({get:O,configurable:1}),$)}function YT($){return{[Symbol.toStringTag]:{value:$,configurable:1}}}function S$($,O){let T={},Z=$.length;for(let f of O)T[$[--Z]]=f;return T}function c0($,O,T){let Z={};for(let f in O)Z[f]=$(O[f],f,T);return Z}function DO($,O,T){let Z={};for(let f=0;f<O.length;f++){let j=O[f];Z[j]=$(j,f,T)}return Z}function w5($,O,T){let Z={};for(let f=0;f<$.length;f++)Z[O[f]]=T[$[f]];return Z}function w0($,O){let T={};for(let Z of $)T[Z]=O[Z];return T}function T3($,O){let T={};for(let Z in O)$.has(Z)||(T[Z]=O[Z]);return T}function Z3($){$={...$};let O=Object.keys($);for(let T of O)$[T]===void 0&&delete $[T];return $}function f6($,O){for(let T of O)if(!(T in $))return 0;return 1}function j6($,O,T){for(let Z of $)if(O[Z]!==T[Z])return 0;return 1}function W6($,O,T){let Z={...T};for(let f=0;f<O;f++)Z[$[f]]=0;return Z}function b($,...O){return(...T)=>$(...O,...T)}function cW($){return $[0].toUpperCase()+$.substring(1)}function XO($){return $.slice().sort()}function TT($,O){return String(O).padStart($,"0")}function K1($,O){return Math.sign($-O)}function sZ($,O,T){return Math.min(Math.max($,O),T)}function j1($,O){return[Math.floor($/O),jO($,O)]}function jO($,O){return($%O+O)%O}function S1($,O){return[DT($,O),f3($,O)]}function DT($,O){return Math.trunc($/O)||0}function f3($,O){return $%O||0}function oO($){return Math.abs($%1)===0.5}function z6($,O,T){let Z=0,f=0;for(let z=0;z<=O;z++){let J=$[T[z]],C=a0[z],F=q/C,[D,Y]=S1(J,F);Z+=Y*C,f+=D}let[j,W]=S1(Z,q);return[f+j,W]}function XT($,O,T){let Z={};for(let f=O;f>=0;f--){let j=a0[f];Z[T[f]]=DT($,j),$=f3($,j)}return Z}function J6($){return $===v?sT:[]}function C6($){return $===v?IO:[]}function F6($){return $===v?["year","day"]:[]}function Y6($){if($!==void 0)return h($)}function D6($){if($!==void 0)return i0($)}function j3($){if($!==void 0)return UO($)}function i0($){return G6(UO($))}function UO($){return U6(V7($))}function W3($){if($==null)throw TypeError("Cannot be null or undefined");return $}function X6($,O){if(O==null)throw RangeError(Vf($));return O}function z1($){if(!W0($))throw TypeError(qz);return $}function UT($,O,T=$){if(typeof O!==$)throw TypeError(SO(T,O));return O}function U6($,O="number"){if(!Number.isInteger($))throw RangeError(s5(O,$));return $||0}function G6($,O="number"){if($<=0)throw RangeError(n5(O,$));return $}function z3($){if(typeof $=="symbol")throw TypeError(t5);return String($)}function ZT($,O){return W0($)?String($):h($,O)}function GT($){if(typeof $=="string")return BigInt($);if(typeof $!="bigint")throw TypeError(r5($));return $}function B6($,O="number"){if(typeof $=="bigint")throw TypeError(o5(O));if($=Number($),!Number.isFinite($))throw RangeError(a5(O,$));return $}function U0($,O){return Math.trunc(B6($,O))||0}function K6($,O){return U6(B6($,O),O)}function iW($,O){return G6(U0($,O),O)}function J3($,O){let[T,Z]=S1(O,q),f=$+T,j=Math.sign(f);return j&&j===-Math.sign(Z)&&(f-=j,Z+=j*q),[f,Z]}function G$($,O,T=1){return J3($[0]+O[0]*T,$[1]+O[1]*T)}function B$($,O){return J3($[0],$[1]+O)}function g0($,O){return G$(O,$,-1)}function B0($,O){return K1($[0],O[0])||K1($[1],O[1])}function L6($,O,T){return B0($,O)===-1||B0($,T)===1}function BT($,O=1){let T=BigInt(q/O);return[Number($/T),Number($%T)*O]}function K$($,O=1){let T=q/O,[Z,f]=S1($,T);return[Z,f*O]}function Q6($,O=1){let[T,Z]=$,f=Math.floor(Z/O),j=q/O;return BigInt(T)*BigInt(j)+BigInt(f)}function R0($,O=1,T){let[Z,f]=$,[j,W]=S1(f,O);return Z*(q/O)+(j+(T?W/O:0))}function C3($,O,T=j1){let[Z,f]=$,[j,W]=T(f,O);return[Z*(q/O)+j,W]}function F3($,O){let T=$.formatToParts(O),Z={};for(let f of T)Z[f.type]=f.value;return Z}function Y3($){return E0($,"isoYear",YO,FO,1),$.isoYear===YO?E0($,"isoMonth",4,12,1):$.isoYear===FO&&E0($,"isoMonth",1,9,1),$}function L1($){return J1({...$,...p0,isoHour:12}),$}function J1($){let O=E0($,"isoYear",YO,FO,1),T=O===YO?1:O===FO?-1:0;return T&&k0(G0({...$,isoDay:$.isoDay+T,isoNanosecond:$.isoNanosecond-T})),$}function k0($){if(!$||L6($,A7,_7))throw RangeError(hT);return $}function M1($){return z6($,5,u0)[1]}function KT($){let[O,T]=j1($,q);return[XT(T,5,u0),O]}function S6($){return M6($)[0]}function M6($){return C3($,y0)}function K0($){return M$($.isoYear,$.isoMonth,$.isoDay,$.isoHour,$.isoMinute,$.isoSecond,$.isoMillisecond)}function G0($){let O=K0($);if(O!==void 0){let[T,Z]=S1(O,_0);return[T,Z*o0+($.isoMicrosecond||0)*r1+($.isoNanosecond||0)]}}function D3($,O){let[T,Z]=KT(M1($)-O);return k0(G0({...$,isoDay:$.isoDay+Z,...T}))}function fT(...$){return M$(...$)/oz}function M$(...$){let[O,T]=V6(...$),Z=O.valueOf();if(!isNaN(Z))return Z-T*_0}function V6($,O=1,T=1,Z=0,f=0,j=0,W=0){let z=$===YO?1:$===FO?-1:0,J=new Date;return J.setUTCHours(Z,f,j,W),J.setUTCFullYear($,O-1,T+z),[J,z]}function I1($,O){let[T,Z]=B$($,O);Z<0&&(Z+=q,T-=1);let[f,j]=j1(Z,o0),[W,z]=j1(j,r1);return LT(T*_0+f,W,z)}function LT($,O=0,T=0){let Z=Math.ceil(Math.max(0,Math.abs($)-P7)/_0)*Math.sign($),f=new Date($-Z*_0);return S$(aT,[f.getUTCFullYear(),f.getUTCMonth()+1,f.getUTCDate()+Z,f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds(),f.getUTCMilliseconds(),O,T])}function I6($){return[$.isoYear,$.isoMonth,$.isoDay]}function x6(){return f1}function X3($,O){switch(O){case 2:return U3($)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function N6($){return U3($)?366:365}function U3($){return $%4==0&&($%100!=0||$%400==0)}function E6($){let[O,T]=V6($.isoYear,$.isoMonth,$.isoDay);return jO(O.getUTCDay()-T,7)||7}function P6({isoYear:$}){return $<1?["bce",1-$]:["ce",$]}function b5($){let O=K0($);if(O<w7)return P6($);let T=F3(pf(L$),O),{era:Z,eraYear:f}=q8(T,L$);return[Z,f]}function QT($){return h1($),ST($,1),$}function h1($){return _6($,1),$}function hW($){return j6(bf,$,_6($))}function _6($,O){let{isoYear:T}=$,Z=E0($,"isoMonth",1,x6(),O);return{isoYear:T,isoMonth:Z,isoDay:E0($,"isoDay",1,X3(T,Z),O)}}function ST($,O){return S$(u0,[E0($,"isoHour",0,23,O),E0($,"isoMinute",0,59,O),E0($,"isoSecond",0,59,O),E0($,"isoMillisecond",0,999,O),E0($,"isoMicrosecond",0,999,O),E0($,"isoNanosecond",0,999,O)])}function R($){return $===void 0?0:X2(z1($))}function GO($,O=0){$=h0($);let T=U2($),Z=c7($,O);return[X2($),Z,T]}function G3($){return U2(h0($))}function A6($){return $=h0($),Rf($,9,6,1)}function V$($,O,T,Z=9,f=0,j=4){O=h0(O);let W=Rf(O,Z,f),z=L3(O),J=NO(O,j),C=xO(O,Z,f,1);return W==null?W=Math.max(T,C):v6(W,C),z=Q3(z,C,1),$&&(J=((F)=>F<4?(F+2)%4:F)(J)),[W,C,z,J]}function MT($,O=6,T){let Z=L3($=S3($,FT)),f=NO($,7),j=xO($,O);return j=X6(FT,j),Z=Q3(Z,j,void 0,T),[j,Z,f]}function B3($){return kf(h0($))}function H6($,O){return K3(h0($),O)}function K3($,O=4){let T=b6($);return[NO($,4),...w6(xO($,O),T)]}function w6($,O){return $!=null?[a0[$],$<4?9-3*$:-1]:[O===void 0?1:10**(9-O),O]}function L3($){let O=$[WO];return O===void 0?1:U0(O,WO)}function Q3($,O,T,Z){let f=Z?q:a0[O+1];if(f){let j=a0[O];if(f%(($=m0(WO,$,1,f/j-(Z?0:1),1))*j))throw RangeError(SO(WO,$))}else $=m0(WO,$,1,T?1e9:1,1);return $}function b6($){let O=$[uZ];if(O!==void 0){if(typeof O!="number"){if(z3(O)==="auto")return;throw RangeError(SO(uZ,O))}O=m0(uZ,Math.floor(O),0,9,1)}return O}function h0($){return $===void 0?{}:z1($)}function S3($,O){return typeof $=="string"?{[O]:$}:z1($)}function a($){if($!==void 0){if(W0($))return Object.assign(Object.create(null),$);throw TypeError(qz)}}function VT($,O){return $&&Object.assign(Object.create(null),$,{overflow:v7[O]})}function M3($,O,T=9,Z=0,f){let j=O[$];if(j===void 0)return f?Z:void 0;if(j=z3(j),j==="auto")return f?Z:null;let W=rZ[j];if(W===void 0&&(W=N7[j]),W===void 0)throw RangeError(iz($,j,rZ));return m0($,W,Z,T,1,VO),W}function l1($,O,T,Z=0){let f=T[$];if(f===void 0)return Z;let j=z3(f),W=O[j];if(W===void 0)throw RangeError(iz($,j,O));return W}function v6($,O){if(O>$)throw RangeError(K7)}function z0($){return{branding:rT,epochNanoseconds:$}}function F0($,O,T){return{branding:D1,calendar:T,timeZone:O,epochNanoseconds:$}}function o($,O=$.calendar){return{branding:e1,calendar:O,...w0(C2,$)}}function r($,O=$.calendar){return{branding:t1,calendar:O,...w0(vf,$)}}function p1($,O=$.calendar){return{branding:H$,calendar:O,...w0(vf,$)}}function jT($,O=$.calendar){return{branding:w$,calendar:O,...w0(vf,$)}}function l0($){return{branding:oT,...w0(J2,$)}}function i($){return{branding:tT,sign:x1($),...w0(Af,$)}}function g6($){return S6($.epochNanoseconds)}function IT($){return C3($.epochNanoseconds,o0)[0]}function R6($){return Q6($.epochNanoseconds,r1)}function k6($){return Q6($.epochNanoseconds)}function m6($){return $.epochNanoseconds}function J0($){return typeof $=="string"?$:h($.id)}function I$($,O){return $===O||J0($)===J0(O)}function q6($,O,T,Z,f){let j=c1(Z),[W,z]=((B,L)=>{let M=L((B=S3(B,$3))[Y2]),Q=p7(B);return Q=X6($3,Q),[Q,M]})(f,$);if(JO(Math.max(W,j),z))return lW(Z,W);if(!z)throw RangeError(lT);let[J,C,F]=AT(O,T,z),D=d3(F),Y=HT(F),U=u3(F),X=Y(C,J,Z),G=U(C,J,X,W);return JO(W,z)?lW(G,W):((B,L,M,Q,N,P,S)=>{let V=x1(B),[_,A]=V3(Q,wf(M,B),M,V,N,P,S),T0=I3(L,_,A);return B[k[M]]+T0*V})(G,D(X),W,C,J,D,Y)}function lW($,O){return R0(j0($),a0[O],1)}function V3($,O,T,Z,f,j,W){let z=k[T],J={...O,[z]:O[z]+Z},C=W($,f,O),F=W($,f,J);return[j(C),j(F)]}function I3($,O,T){let Z=R0(g0(O,T));if(!Z)throw RangeError(MO);return R0(g0(O,$))/Z}function y6($,O){let[T,Z,f]=MT(O,5,1);return z0(NT($.epochNanoseconds,T,Z,f,1))}function p6($,O,T){let{epochNanoseconds:Z,timeZone:f,calendar:j}=O,[W,z,J]=MT(T);if(W===0&&z===1)return O;let C=$(f);if(W===6)Z=((F,D,Y,U)=>{let X=L0(Y,D),[G,B]=F(X),L=Y.epochNanoseconds,M=H0(D,G),Q=H0(D,B);if(L6(L,M,Q))throw RangeError(MO);return a6(I3(L,M,Q),U)?Q:M})(s6,C,O,J);else{let F=C.getOffsetNanosecondsFor(Z);Z=u1(C,d6(I1(Z,F),W,z,J),F,2,0,1)}return F0(Z,f,j)}function c6($,O){return o(d6($,...MT(O)),$.calendar)}function i6($,O){let[T,Z,f]=MT(O,5);var j;return l0((j=f,x3($,BO(T,Z),j)[0]))}function h6($,O){let T=$(O.timeZone),Z=L0(O,T),[f,j]=s6(Z),W=R0(g0(H0(T,f),H0(T,j)),uT,1);if(W<=0)throw RangeError(MO);return W}function l6($,O){let{timeZone:T,calendar:Z}=O,f=((j,W,z)=>H0(W,j(L0(z,W))))(n6,$(T),O);return F0(f,T,Z)}function d6($,O,T,Z){return u6($,BO(O,T),Z)}function u6($,O,T){let[Z,f]=x3($,O,T);return J1({...s1($,f),...Z})}function x3($,O,T){return KT(V1(M1($),O,T))}function WT($){return V1($,dT,7)}function BO($,O){return a0[$]*O}function s6($){let O=n6($);return[O,s1(O,1)]}function n6($){return E7(6,$)}function v5($,O,T){let Z=Math.min(c1($),6);return N$(ET(j0($,Z),O,T),Z)}function xT($,O,T,Z,f,j,W,z,J,C){if(Z===0&&f===1)return $;let F=JO(Z,z)?wT(z)&&Z<6&&T>=6?R5:g5:k5,[D,Y,U]=F($,O,T,Z,f,j,W,z,J,C);return U&&Z!==7&&(D=((X,G,B,L,M,Q,N,P)=>{let S=x1(X);for(let V=L+1;V<=B;V++){if(V===7&&B!==7)continue;let _=wf(V,X);_[k[V]]+=S;let A=R0(g0(N(P(M,Q,_)),G));if(A&&Math.sign(A)!==S)break;X=_}return X})(D,Y,T,Math.max(6,Z),W,z,J,C)),D}function NT($,O,T,Z,f){if(O===6){let j=((W)=>W[0]+W[1]/q)($);return[V1(j,T,Z),0]}return ET($,BO(O,T),Z,f)}function ET($,O,T,Z){let[f,j]=$;Z&&j<0&&(j+=q,f-=1);let[W,z]=j1(V1(j,O,T),q);return J3(f+W,z)}function V1($,O,T){return a6($/O,T)*O}function a6($,O){return l7[O]($)}function g5($,O,T,Z,f,j){let W=x1($),z=j0($),J=NT(z,Z,f,j),C=g0(z,J),F=Math.sign(J[0]-z[0])===W,D=N$(J,Math.min(T,6));return[{...$,...D},G$(O,C),F]}function R5($,O,T,Z,f,j,W,z,J,C){let F=x1($),D=R0(j0($,5)),Y=BO(Z,f),U=V1(D,Y,j),[X,G]=V3(W,{...$,...Hf},6,F,z,J,C),B=U-R0(g0(X,G)),L=0;B&&Math.sign(B)!==F?O=B$(X,U):(L+=F,U=V1(B,Y,j),O=B$(G,U));let M=vT(U);return[{...$,...M,days:$.days+L},O,Boolean(L)]}function k5($,O,T,Z,f,j,W,z,J,C){let F=x1($),D=k[Z],Y=wf(Z,$);Z===7&&($={...$,weeks:$.weeks+Math.trunc($.days/7)});let U=DT($[D],f)*f;Y[D]=U;let[X,G]=V3(W,Y,Z,f*F,z,J,C),B=U+I3(O,X,G)*F*f,L=V1(B,f,j),M=Math.sign(L-B)===F;return Y[D]=L,[Y,M?G:X,M]}function N3($,O,T,Z){let[f,j,W,z]=((C)=>{let F=K3(C=h0(C));return[C.timeZone,...F]})(Z),J=f!==void 0;return((C,F,D,Y,U,X)=>{D=ET(D,U,Y,1);let G=F.getOffsetNanosecondsFor(D);return b3(I1(D,G),X)+(C?d1(WT(G)):"Z")})(J,O(J?$(f):$$),T.epochNanoseconds,j,W,z)}function E3($,O,T){let[Z,f,j,W,z,J]=((C)=>{C=h0(C);let F=kf(C),D=b6(C),Y=h7(C),U=NO(C,4),X=xO(C,4);return[F,i7(C),Y,U,...w6(X,D)]})(T);return((C,F,D,Y,U,X,G,B,L,M)=>{Y=ET(Y,L,B,1);let Q=C(D).getOffsetNanosecondsFor(Y);return b3(I1(Y,Q),M)+d1(WT(Q),G)+((N,P)=>P!==1?"["+(P===2?"!":"")+J0(N)+"]":"")(D,X)+v3(F,U)})($,O.calendar,O.timeZone,O.epochNanoseconds,Z,f,j,W,z,J)}function P3($,O){let[T,Z,f,j]=((C)=>(C=h0(C),[kf(C),...K3(C)]))(O);return W=$.calendar,z=T,J=j,b3(u6($,f,Z),J)+v3(W,z);var W,z,J}function _3($,O){return T=$.calendar,Z=$,f=B3(O),zT(Z)+v3(T,f);var T,Z,f}function A3($,O){return o6($.calendar,r6,$,B3(O))}function H3($,O){return o6($.calendar,m5,$,B3(O))}function w3($,O){let[T,Z,f]=H6(O);return j=f,t6(x3($,Z,T)[0],j);var j}function PT($,O){let[T,Z,f]=H6(O,3);return Z>1&&($={...$,...v5($,Z,T)}),((j,W)=>{let{sign:z}=j,J=z===-1?Q0(j):j,{hours:C,minutes:F}=J,[D,Y]=C3(j0(J,3),y0,S1);W8(D);let U=g3(Y,W),X=W>=0||!z||U;return(z<0?"-":"")+"P"+dW({Y:y1(J.years),M:y1(J.months),W:y1(J.weeks),D:y1(J.days)})+(C||F||D||X?"T"+dW({H:y1(C),M:y1(F),S:y1(D,X)+U}):"")})($,f)}function o6($,O,T,Z){let f=J0($),j=Z>1||Z===0&&f!==v;return Z===1?f===v?O(T):zT(T):j?zT(T)+e6(f,Z===2):O(T)}function dW($){let O=[];for(let T in $){let Z=$[T];Z&&O.push(Z,T)}return O.join("")}function b3($,O){return zT($)+"T"+t6($,O)}function zT($){return r6($)+"-"+q0($.isoDay)}function r6($){let{isoYear:O}=$;return(O<0||O>9999?$8(O)+TT(6,Math.abs(O)):TT(4,O))+"-"+q0($.isoMonth)}function m5($){return q0($.isoMonth)+"-"+q0($.isoDay)}function t6($,O){let T=[q0($.isoHour),q0($.isoMinute)];return O!==-1&&T.push(q0($.isoSecond)+((Z,f,j,W)=>g3(Z*o0+f*r1+j,W))($.isoMillisecond,$.isoMicrosecond,$.isoNanosecond,O)),T.join(":")}function d1($,O=0){if(O===1)return"";let[T,Z]=j1(Math.abs($),uT),[f,j]=j1(Z,dT),[W,z]=j1(j,y0);return $8($)+q0(T)+":"+q0(f)+(W||z?":"+q0(W)+g3(z):"")}function v3($,O){if(O!==1){let T=J0($);if(O>1||O===0&&T!==v)return e6(T,O===2)}return""}function e6($,O){return"["+(O?"!":"")+"u-ca="+$+"]"}function g3($,O){let T=TT(9,$);return T=O===void 0?T.replace(s7,""):T.slice(0,O),T?"."+T:""}function $8($){return $<0?"-":"+"}function y1($,O){return $||O?$.toLocaleString("fullwide",{useGrouping:0}):""}function q5($,O){let{epochNanoseconds:T}=$,Z=(O.getOffsetNanosecondsFor?O:O($.timeZone)).getOffsetNanosecondsFor(T),f=I1(T,Z);return{calendar:$.calendar,...f,offsetNanoseconds:Z}}function O8($,O){let T=L0(O,$);return{calendar:O.calendar,...w0(C2,T),offset:d1(T.offsetNanoseconds),timeZone:O.timeZone}}function u1($,O,T,Z=0,f=0,j,W){if(T!==void 0&&Z===1&&(Z===1||W))return D3(O,T);let z=$.getPossibleInstantsFor(O);if(T!==void 0&&Z!==3){let J=((C,F,D,Y)=>{let U=G0(F);Y&&(D=WT(D));for(let X of C){let G=R0(g0(X,U));if(Y&&(G=WT(G)),G===D)return X}})(z,O,T,j);if(J!==void 0)return J;if(Z===0)throw RangeError(Y7)}return W?G0(O):H0($,O,f,z)}function H0($,O,T=0,Z=$.getPossibleInstantsFor(O)){if(Z.length===1)return Z[0];if(T===1)throw RangeError(D7);if(Z.length)return Z[T===3?1:0];let f=G0(O),j=((z,J)=>{let C=z.getOffsetNanosecondsFor(B$(J,-q));return k3(z.getOffsetNanosecondsFor(B$(J,q))-C)})($,f),W=j*(T===2?-1:1);return(Z=$.getPossibleInstantsFor(I1(f,W)))[T===2?0:Z.length-1]}function R3($){if(Math.abs($)>=q)throw RangeError(C7);return $}function k3($){if($>q)throw RangeError(F7);return $}function m3($,O,T){return z0(k0(G$(O.epochNanoseconds,((Z)=>{if(z8(Z))throw RangeError(G7);return j0(Z,5)})($?Q0(T):T))))}function q3($,O,T,Z,f,j=Object.create(null)){let W=O(Z.timeZone),z=$(Z.calendar);return{...Z,...h3(W,z,Z,T?Q0(f):f,j)}}function y3($,O,T,Z,f=Object.create(null)){let{calendar:j}=T;return o(l3($(j),T,O?Q0(Z):Z,f),j)}function p3($,O,T,Z,f){let{calendar:j}=T;return r(_T($(j),T,O?Q0(Z):Z,f),j)}function c3($,O,T,Z,f=Object.create(null)){let j=T.calendar,W=$(j),z=zO(W,T);O&&(Z=bT(Z)),Z.sign<0&&(z=W.dateAdd(z,{...C0,months:1}),z=s1(z,-1));let J=W.dateAdd(z,Z,f);return p1(zO(W,J),j)}function i3($,O,T){return l0(T8(O,$?Q0(T):T)[0])}function h3($,O,T,Z,f){let j=j0(Z,5),W=T.epochNanoseconds;if(z8(Z)){let z=L0(T,$);W=G$(H0($,{..._T(O,z,{...Z,...Hf},f),...w0(u0,z)}),j)}else W=G$(W,j),R(f);return{epochNanoseconds:k0(W)}}function l3($,O,T,Z){let[f,j]=T8(O,T);return J1({..._T($,O,{...T,...Hf,days:T.days+j},Z),...f})}function _T($,O,T,Z){if(T.years||T.months||T.weeks)return $.dateAdd(O,T,Z);R(Z);let f=T.days+j0(T,5)[0];return f?L1(s1(O,f)):O}function zO($,O,T=1){return s1(O,T-$.day(O))}function T8($,O){let[T,Z]=j0(O,5),[f,j]=KT(M1($)+Z);return[f,T+j]}function s1($,O){return O?{...$,...LT(K0($)+O*_0)}:$}function AT($,O,T){let Z=$(T.calendar);return wT(T)?[T,Z,O(T.timeZone)]:[{...T,...p0},Z]}function d3($){return $?m6:G0}function HT($){return $?b(h3,$):l3}function u3($){return $?b(p5,$):c5}function wT($){return $&&$.epochNanoseconds}function JO($,O){return $<=6-(wT(O)?1:0)}function s3($,O,T,Z,f,j,W){let z=$(h0(W).relativeTo),J=Math.max(c1(f),c1(j));if(JO(J,z))return i(x$(((G,B,L,M)=>{let Q=G$(j0(G),j0(B),M?-1:1);if(!Number.isFinite(Q[0]))throw RangeError(hT);return{...C0,...N$(Q,L)}})(f,j,J,Z)));if(!z)throw RangeError(lT);Z&&(j=Q0(j));let[C,F,D]=AT(O,T,z),Y=HT(D),U=u3(D),X=Y(F,C,f);return i(U(F,C,Y(F,X,j),J))}function Z8($,O,T,Z,f){let j=c1(Z),[W,z,J,C,F]=((S,V,_)=>{S=S3(S,FT);let A=Rf(S),T0=_(S[Y2]),g=L3(S),m=NO(S,7),Z0=xO(S);if(A===void 0&&Z0===void 0)throw RangeError(B7);return Z0==null&&(Z0=0),A==null&&(A=Math.max(Z0,V)),v6(A,Z0),g=Q3(g,Z0,1),[A,Z0,g,m,T0]})(f,j,$),D=Math.max(j,W);if(!wT(F)&&D<=6)return i(x$(((S,V,_,A,T0)=>{let g=NT(j0(S),_,A,T0);return{...C0,...N$(g,V)}})(Z,W,z,J,C)));if(!F)throw RangeError(lT);let[Y,U,X]=AT(O,T,F),G=d3(X),B=HT(X),L=u3(X),M=B(U,Y,Z),Q=L(U,Y,M,W),N=Z.sign,P=x1(Q);if(N&&P&&N!==P)throw RangeError(MO);return P&&(Q=xT(Q,G(M),W,z,J,C,U,Y,G,B)),i(Q)}function f8($){return $.sign===-1?bT($):$}function bT($){return i(Q0($))}function Q0($){let O={};for(let T of k)O[T]=-1*$[T]||0;return O}function j8($){return!$.sign}function x1($,O=k){let T=0;for(let Z of O){let f=Math.sign($[Z]);if(f){if(T&&T!==f)throw RangeError(U7);T=f}}return T}function x$($){for(let O of x7)m0(O,$[O],-tW,tW,1);return W8(R0(j0($),y0)),$}function W8($){if(!Number.isSafeInteger($))throw RangeError(X7)}function j0($,O=6){return z6($,O,k)}function N$($,O=6){let[T,Z]=$,f=XT(Z,O,k);if(f[k[O]]+=T*(q/a0[O]),!Number.isFinite(f[k[O]]))throw RangeError(hT);return f}function vT($,O=5){return XT($,O,k)}function z8($){return Boolean(x1($,z2))}function c1($){let O=9;for(;O>0&&!$[k[O]];O--);return O}function y5($,O){return[$,O]}function uW($){let O=Math.floor($/$T)*$T;return[O,O+$T]}function J8($){let O=N1($=ZT($));if(!O)throw RangeError(P0($));let T;if(O.m)T=0;else{if(!O.offset)throw RangeError(P0($));T=E$(O.offset)}return O.timeZone&&r3(O.timeZone,1),z0(D3(QT(O),T))}function C8($){let O=N1(h($));if(!O)throw RangeError(P0($));if(O.timeZone)return L8(O,O.offset?E$(O.offset):void 0);if(O.m)throw RangeError(P0($));return S8(O)}function F8($,O){let T=N1(h($));if(!T||!T.timeZone)throw RangeError(P0($));let{offset:Z}=T,f=Z?E$(Z):void 0,[,j,W]=GO(O);return L8(T,f,j,W)}function E$($){let O=r3($);if(O===void 0)throw RangeError(P0($));return O}function Y8($){let O=N1(h($));if(!O||O.m)throw RangeError(P0($));return o(Q8(O))}function gT($){let O=N1(h($));if(!O||O.m)throw RangeError(P0($));return r(O.p?Q8(O):S8(O))}function D8($,O){let T=a3(h(O));if(T)return n3(T),p1(Y3(h1(T)));let Z=gT(O);return p1(zO($(Z.calendar),Z))}function n3($){if($.calendar!==v)throw RangeError(W1($.calendar))}function X8($,O){let T=o3(h(O));if(T)return n3(T),jT(h1(T));let Z=gT(O),{calendar:f}=Z,j=$(f),[W,z,J]=j.h(Z),[C,F]=j.I(W,z),[D,Y]=j.N(C,F,J);return jT(L1(j.P(D,Y,J)),f)}function U8($){let O,T=((Z)=>{let f=t7.exec(Z);return f?(RT(f[10]),I8(f)):void 0})(h($));if(!T){if(T=N1($),!T)throw RangeError(P0($));if(!T.p)throw RangeError(P0($));if(T.m)throw RangeError(W1("Z"));n3(T)}if((O=a3($))&&hW(O))throw RangeError(P0($));if((O=o3($))&&hW(O))throw RangeError(P0($));return l0(ST(T,1))}function G8($){let O=((T)=>{let Z=OJ.exec(T);return Z?((f)=>{function j(F,D,Y){let U=0,X=0;if(Y&&([U,J]=j1(J,a0[Y])),F!==void 0){if(z)throw RangeError(W1(F));X=((G)=>{let B=parseInt(G);if(!Number.isFinite(B))throw RangeError(W1(G));return B})(F),W=1,D&&(J=t3(D)*(a0[Y]/y0),z=1)}return U+X}let W=0,z=0,J=0,C={...S$(k,[j(f[2]),j(f[3]),j(f[4]),j(f[5]),j(f[6],f[7],5),j(f[8],f[9],4),j(f[10],f[11],3)]),...XT(J,2,k)};if(!W)throw RangeError(pz(k));return e3(f[1])<0&&(C=Q0(C)),C})(Z):void 0})(h($));if(!O)throw RangeError(P0($));return i(x$(O))}function B8($){let O=N1($)||a3($)||o3($);return O?O.calendar:$}function K8($){let O=N1($);return O&&(O.timeZone||O.m&&$$||O.offset)||$}function L8($,O,T=0,Z=0){let f=kT($.timeZone),j=eT(f);return F0(u1(j,QT($),O,T,Z,!j.v,$.m),f,KO($.calendar))}function Q8($){return M8(J1(QT($)))}function S8($){return M8(L1(h1($)))}function M8($){return{...$,calendar:KO($.calendar)}}function N1($){let O=r7.exec($);return O?((T)=>{let Z=T[10],f=(Z||"").toUpperCase()==="Z";return{isoYear:V8(T),isoMonth:parseInt(T[4]),isoDay:parseInt(T[5]),...I8(T.slice(5)),...RT(T[16]),p:Boolean(T[6]),m:f,offset:f?void 0:Z}})(O):void 0}function a3($){let O=a7.exec($);return O?((T)=>({isoYear:V8(T),isoMonth:parseInt(T[4]),isoDay:1,...RT(T[5])}))(O):void 0}function o3($){let O=o7.exec($);return O?((T)=>({isoYear:Q$,isoMonth:parseInt(T[1]),isoDay:parseInt(T[2]),...RT(T[3])}))(O):void 0}function r3($,O){let T=e7.exec($);return T?((Z,f)=>{let j=Z[4]||Z[5];if(f&&j)throw RangeError(W1(j));return R3((U$(Z[2])*uT+U$(Z[3])*dT+U$(Z[4])*y0+t3(Z[5]||""))*e3(Z[1]))})(T,O):void 0}function V8($){let O=e3($[1]),T=parseInt($[2]||$[3]);if(O<0&&!T)throw RangeError(W1(-0));return O*T}function I8($){let O=U$($[3]);return{...KT(t3($[4]||""))[0],isoHour:U$($[1]),isoMinute:U$($[2]),isoSecond:O===60?59:O}}function RT($){let O,T,Z=[];if($.replace($J,(f,j,W)=>{let z=Boolean(j),[J,C]=W.split("=").reverse();if(C){if(C==="u-ca")Z.push(J),O||(O=z);else if(z||/[A-Z]/.test(C))throw RangeError(W1(f))}else{if(T)throw RangeError(W1(f));T=J}return""}),Z.length>1&&O)throw RangeError(W1($));return{timeZone:T,calendar:Z[0]||v}}function t3($){return parseInt($.padEnd(9,"0"))}function P$($){return new RegExp(`^${$}$`,"i")}function e3($){return $&&$!=="+"?-1:1}function U$($){return $===void 0?0:parseInt($)}function x8($){return kT(h($))}function kT($){let O=$f($);return typeof O=="number"?d1(O):O?((T)=>{if(ZJ.test(T))throw RangeError(J7);return T.toLowerCase().split("/").map((Z,f)=>(Z.length<=3||/\d/.test(Z))&&!/etc|yap/.test(Z)?Z.toUpperCase():Z.replace(/baja|dumont|[a-z]+/g,(j,W)=>j.length<=2&&!f||j==="in"||j==="chat"?j.toUpperCase():j.length>2||!W?cW(j).replace(/island|noronha|murdo|rivadavia|urville/,cW):j)).join("/")})($):$$}function sW($){let O=$f($);return typeof O=="number"?O:O?O.resolvedOptions().timeZone:$$}function $f($){let O=r3($=$.toUpperCase(),1);return O!==void 0?O:$!==$$?TJ($):void 0}function Of($,O){return B0($.epochNanoseconds,O.epochNanoseconds)}function Tf($,O){return B0($.epochNanoseconds,O.epochNanoseconds)}function N8($,O,T,Z,f,j){let W=$(h0(j).relativeTo),z=Math.max(c1(Z),c1(f));if(j6(k,Z,f))return 0;if(JO(z,W))return B0(j0(Z),j0(f));if(!W)throw RangeError(lT);let[J,C,F]=AT(O,T,W),D=d3(F),Y=HT(F);return B0(D(Y(C,J,Z)),D(Y(C,J,f)))}function Zf($,O){return n1($,O)||mT($,O)}function n1($,O){return K1(K0($),K0(O))}function mT($,O){return K1(M1($),M1(O))}function E8($,O){return!Of($,O)}function P8($,O){return!Tf($,O)&&!!qT($.timeZone,O.timeZone)&&I$($.calendar,O.calendar)}function _8($,O){return!Zf($,O)&&I$($.calendar,O.calendar)}function A8($,O){return!n1($,O)&&I$($.calendar,O.calendar)}function H8($,O){return!n1($,O)&&I$($.calendar,O.calendar)}function w8($,O){return!n1($,O)&&I$($.calendar,O.calendar)}function b8($,O){return!mT($,O)}function qT($,O){if($===O)return 1;let T=J0($),Z=J0(O);if(T===Z)return 1;try{return sW(T)===sW(Z)}catch(f){}}function ff($,O,T,Z){let f=V$($,a(Z),3,5),j=yT(O.epochNanoseconds,T.epochNanoseconds,...f);return i($?Q0(j):j)}function jf($,O,T,Z,f,j){let W=cT(Z.calendar,f.calendar),z=a(j),[J,C,F,D]=V$(T,z,5),Y=Z.epochNanoseconds,U=f.epochNanoseconds,X=B0(U,Y),G;if(X)if(J<6)G=yT(Y,U,J,C,F,D);else{let B=O(((M,Q)=>{if(!qT(M,Q))throw RangeError(uz);return M})(Z.timeZone,f.timeZone)),L=$(W);G=g8(L,B,Z,f,X,J,z),G=xT(G,U,J,C,F,D,L,Z,m6,b(h3,B))}else G=C0;return i(T?Q0(G):G)}function Wf($,O,T,Z,f){let j=cT(T.calendar,Z.calendar),W=a(f),[z,J,C,F]=V$(O,W,6),D=G0(T),Y=G0(Z),U=B0(Y,D),X;if(U)if(z<=6)X=yT(D,Y,z,J,C,F);else{let G=$(j);X=R8(G,T,Z,U,z,W),X=xT(X,Y,z,J,C,F,G,T,G0,l3)}else X=C0;return i(O?Q0(X):X)}function zf($,O,T,Z,f){let j=cT(T.calendar,Z.calendar),W=a(f);return v8(O,()=>$(j),T,Z,...V$(O,W,6,9,6),W)}function Jf($,O,T,Z,f){let j=cT(T.calendar,Z.calendar),W=a(f),z=V$(O,W,9,9,8),J=$(j);return v8(O,()=>J,zO(J,T),zO(J,Z),...z,W)}function v8($,O,T,Z,f,j,W,z,J){let C=G0(T),F=G0(Z),D;if(B0(F,C))if(f===6)D=yT(C,F,f,j,W,z);else{let Y=O();D=Y.dateUntil(T,Z,f,J),j===6&&W===1||(D=xT(D,F,f,j,W,z,Y,T,G0,_T))}else D=C0;return i($?Q0(D):D)}function Cf($,O,T,Z){let f=a(Z),[j,W,z,J]=V$($,f,5,5),C=V1(Ff(O,T),BO(W,z),J),F={...C0,...vT(C,j)};return i($?Q0(F):F)}function p5($,O,T,Z,f,j){let W=B0(Z.epochNanoseconds,T.epochNanoseconds);return W?f<6?k8(T.epochNanoseconds,Z.epochNanoseconds,f):g8(O,$,T,Z,W,f,j):C0}function c5($,O,T,Z,f){let j=G0(O),W=G0(T),z=B0(W,j);return z?Z<=6?k8(j,W,Z):R8($,O,T,z,Z,f):C0}function g8($,O,T,Z,f,j,W){let[z,J,C]=((Y,U,X,G)=>{function B(){return V={...s1(Q,P++*-G),...M},_=H0(Y,V),B0(N,_)===-G}let L=L0(U,Y),M=w0(u0,L),Q=L0(X,Y),N=X.epochNanoseconds,P=0,S=Ff(L,Q),V,_;if(Math.sign(S)===-G&&P++,B()&&(G===-1||B()))throw RangeError(MO);let A=R0(g0(_,N));return[L,V,A]})(O,T,Z,f);var F,D;return{...j===6?(F=z,D=J,{...C0,days:m8(F,D)}):$.dateUntil(z,J,j,W),...vT(C)}}function R8($,O,T,Z,f,j){let[W,z,J]=((C,F,D)=>{let Y=F,U=Ff(C,F);return Math.sign(U)===-D&&(Y=s1(F,-D),U+=q*D),[C,Y,U]})(O,T,Z);return{...$.dateUntil(W,z,f,j),...vT(J)}}function yT($,O,T,Z,f,j){return{...C0,...N$(NT(g0($,O),Z,f,j),T)}}function k8($,O,T){return{...C0,...N$(g0($,O),T)}}function m8($,O){return pT(K0($),K0(O))}function pT($,O){return Math.trunc((O-$)/_0)}function Ff($,O){return M1(O)-M1($)}function cT($,O){if(!I$($,O))throw RangeError(Nf);return $}function i5($){function O(f){return((j,W)=>({...q8(j,W),F:j.month,day:parseInt(j.day)}))(F3(T,f),Z)}let T=pf($),Z=JT($);return{id:$,O:h5(O),B:l5(O)}}function h5($){return A0((O)=>{let T=K0(O);return $(T)},WeakMap)}function l5($){let O=$(0).year-H7;return A0((T)=>{let Z,f=M$(T-O),j=[],W=[];do f+=400*_0;while((Z=$(f)).year<=T);do f+=(1-Z.day)*_0,Z.year===T&&(j.push(f),W.push(Z.F)),f-=_0;while((Z=$(f)).year>=T);return{k:j.reverse(),C:az(W.reverse())}})}function q8($,O){let T,Z,f=y8($);if($.era){let j=f2[O];j!==void 0&&(T=O==="islamic"?"ah":$.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),T==="bc"||T==="b"?T="bce":T!=="ad"&&T!=="a"||(T="ce"),Z=f,f=l8(Z,j[T]||0))}return{era:T,eraYear:Z,year:f}}function y8($){return parseInt($.relatedYear||$.year)}function nZ($){let{year:O,F:T,day:Z}=this.O($),{C:f}=this.B(O);return[O,f[T]+1,Z]}function CO($,O=1,T=1){return this.B($).k[O-1]+(T-1)*_0}function rO($){let O=aW(this,$),T=aW(this,$-1),Z=O.length;if(Z>T.length){let f=d8(this);if(f<0)return-f;for(let j=0;j<Z;j++)if(O[j]!==T[j])return j+1}}function tO($){return pT(CO.call(this,$),CO.call(this,$+1))}function nW($,O){let{k:T}=this.B($),Z=O+1,f=T;return Z>T.length&&(Z=1,f=this.B($+1).k),pT(T[O-1],f[Z-1])}function eO($){return this.B($).k.length}function aW($,O){return Object.keys($.B(O).C)}function p8($){return KO(h($))}function KO($){if(($=$.toLowerCase())!==v&&$!==nT&&JT($)!==JT(pf($).resolvedOptions().calendar))throw RangeError(z7($));return $}function JT($){return $==="islamicc"&&($="islamic"),$.split("-")[0]}function c8($){return this.R($)[0]}function i8($){return this.R($)[1]}function Yf($){let[O]=this.h($);return pT(this.q(O),K0($))+1}function h8($){let O=jJ.exec($);if(!O)throw RangeError(j7($));return[parseInt(O[1]),Boolean(O[2])]}function CT($,O,T){return $+(O||T&&$>=T?1:0)}function aZ($,O){return $-(O&&$>=O?1:0)}function l8($,O){return(O+$)*(Math.sign(O)||1)||0}function oZ($){return f2[u8($)]}function d8($){return M7[u8($)]}function u8($){return JT($.id||v)}function s8($,O,T,Z){let f=E1(T,Z,d0,[],$2);if(f.timeZone!==void 0){let j=T.dateFromFields(f),W=a1(f),z=$(f.timeZone);return{epochNanoseconds:u1(O(z),{...j,...W},f.offset!==void 0?E$(f.offset):void 0),timeZone:z}}return{...T.dateFromFields(f),...p0}}function n8($,O,T,Z,f,j){let W=E1(T,f,d0,tz,$2),z=$(W.timeZone),[J,C,F]=GO(j),D=T.dateFromFields(W,VT(j,J)),Y=a1(W,J);return F0(u1(O(z),{...D,...Y},W.offset!==void 0?E$(W.offset):void 0,C,F),z,Z)}function a8($,O,T){let Z=E1($,O,d0,[],Y1),f=R(T);return o(J1({...$.dateFromFields(Z,VT(T,f)),...a1(Z,f)}))}function Df($,O,T,Z=[]){let f=E1($,O,d0,Z);return $.dateFromFields(f,T)}function Xf($,O,T,Z){let f=E1($,O,_f,Z);return $.yearMonthFromFields(f,T)}function Uf($,O,T,Z,f=[]){let j=E1($,T,d0,f);return O&&j.month!==void 0&&j.monthCode===void 0&&j.year===void 0&&(j.year=Q$),$.monthDayFromFields(j,Z)}function o8($,O){let T=R(O);return l0(a1(n0($,tZ,[],1),T))}function r8($){let O=n0($,Af);return i(x$({...C0,...O}))}function E1($,O,T,Z=[],f=[]){return n0(O,[...$.fields(T),...f].sort(),Z)}function n0($,O,T,Z=!T){let f={},j,W=0;for(let z of O){if(z===j)throw RangeError(e5(z));if(z==="constructor"||z==="__proto__")throw RangeError(If(z));let J=$[z];if(J!==void 0)W=1,eW[z]&&(J=eW[z](J,z)),f[z]=J;else if(T){if(T.includes(z))throw TypeError(Vf(z));f[z]=Z2[z]}j=z}if(Z&&!W)throw TypeError(pz(O));return f}function a1($,O){return ST(CJ({...Z2,...$}),O)}function t8($,O,T,Z,f,j){let W=a(j),{calendar:z,timeZone:J}=T;return F0(((C,F,D,Y,U)=>{let X=LO(C,D,Y,d0,ez,rz),[G,B,L]=GO(U,2);return u1(F,{...C.dateFromFields(X,VT(U,G)),...a1(X,G)},E$(X.offset),B,L)})($(z),O(J),Z,f,W),J,z)}function e8($,O,T,Z,f){let j=a(f);return o(((W,z,J,C)=>{let F=LO(W,z,J,d0,Y1),D=R(C);return J1({...W.dateFromFields(F,VT(C,D)),...a1(F,D)})})($(O.calendar),T,Z,j))}function $z($,O,T,Z,f){let j=a(f);return((W,z,J,C)=>{let F=LO(W,z,J,d0);return W.dateFromFields(F,C)})($(O.calendar),T,Z,j)}function Oz($,O,T,Z,f){let j=a(f);return p1(((W,z,J,C)=>{let F=LO(W,z,J,_f);return W.yearMonthFromFields(F,C)})($(O.calendar),T,Z,j))}function Tz($,O,T,Z,f){let j=a(f);return((W,z,J,C)=>{let F=LO(W,z,J,d0);return W.monthDayFromFields(F,C)})($(O.calendar),T,Z,j)}function Zz($,O,T){return l0(((Z,f,j)=>{let W=R(j);return a1({...w0(tZ,Z),...n0(f,tZ)},W)})($,O,T))}function fz($,O){return i((T=$,Z=O,x$({...T,...n0(Z,Af)})));var T,Z}function LO($,O,T,Z,f=[],j=[]){let W=[...$.fields(Z),...f].sort(),z=n0(O,W,j),J=n0(T,W);return z=$.mergeFields(z,J),n0(z,W,[])}function Gf($,O){let T=E1($,O,T2);return $.monthDayFromFields(T)}function Bf($,O,T){let Z=E1($,O,O2);return $.yearMonthFromFields(Z,T)}function jz($,O,T,Z,f){O=w0(T=$.fields(T),O),Z=n0(Z,f=$.fields(f),[]);let j=$.mergeFields(O,Z);return j=n0(j,[...T,...f].sort(),[]),$.dateFromFields(j)}function hZ($,O){let{era:T,eraYear:Z,year:f}=O,j=oZ($);if(T!==void 0||Z!==void 0){if(T===void 0||Z===void 0)throw TypeError(O7);if(!j)throw RangeError($7);let W=j[T];if(W===void 0)throw RangeError(Z7(T));let z=l8(Z,W);if(f!==void 0&&f!==z)throw RangeError(T7);f=z}else if(f===void 0)throw TypeError(f7(j));return f}function lZ($,O,T,Z){let{month:f,monthCode:j}=O;if(j!==void 0){let W=((z,J,C,F)=>{let D=z.U(C),[Y,U]=h8(J),X=CT(Y,U,D);if(U){let G=d8(z);if(G===void 0)throw RangeError(fO);if(G>0){if(X>G)throw RangeError(fO);if(D===void 0){if(F===1)throw RangeError(fO);X--}}else{if(X!==-G)throw RangeError(fO);if(D===void 0&&F===1)throw RangeError(fO)}}return X})($,j,T,Z);if(f!==void 0&&f!==W)throw RangeError(lz);f=W,Z=1}else if(f===void 0)throw TypeError(W7);return m0("month",f,1,$.L(T),Z)}function oW($,O,T,Z,f){return E0(O,"day",1,$.j(Z,T),f)}function dZ($,O,T,Z){let f=0,j=[];for(let W of T)O[W]!==void 0?f=1:j.push(W);if(Object.assign($,O),f)for(let W of Z||j)delete $[W]}function Wz($){return z0(k0(BT(GT($))))}function zz($,O,T,Z,f=v){return F0(k0(BT(GT(T))),O(Z),$(f))}function Jz($,O,T,Z,f=0,j=0,W=0,z=0,J=0,C=0,F=v){return o(J1(QT(c0(U0,S$(aT,[O,T,Z,f,j,W,z,J,C])))),$(F))}function Cz($,O,T,Z,f=v){return r(L1(h1(c0(U0,{isoYear:O,isoMonth:T,isoDay:Z}))),$(f))}function Fz($,O,T,Z=v,f=1){let j=U0(O),W=U0(T),z=$(Z);return p1(Y3(h1({isoYear:j,isoMonth:W,isoDay:U0(f)})),z)}function Yz($,O,T,Z=v,f=Q$){let j=U0(O),W=U0(T),z=$(Z);return jT(L1(h1({isoYear:U0(f),isoMonth:j,isoDay:W})),z)}function Dz($=0,O=0,T=0,Z=0,f=0,j=0){return l0(ST(c0(U0,S$(u0,[$,O,T,Z,f,j])),1))}function Xz($=0,O=0,T=0,Z=0,f=0,j=0,W=0,z=0,J=0,C=0){return i(x$(c0(K6,S$(k,[$,O,T,Z,f,j,W,z,J,C]))))}function Kf($,O,T=v){return F0($.epochNanoseconds,O,T)}function Uz($){return z0($.epochNanoseconds)}function Lf($,O){return o(L0(O,$))}function Qf($,O){return r(L0(O,$))}function Gz($,O,T){return Bf($(O.calendar),T)}function Bz($,O,T){return Gf($(O.calendar),T)}function Sf($,O){return l0(L0(O,$))}function Kz($,O,T,Z){let f=((j,W,z,J)=>{let C=G3(J);return H0(j(W),z,C)})($,T,O,Z);return F0(k0(f),T,O.calendar)}function Lz($,O,T){let Z=$(O.calendar);return p1({...O,...Bf(Z,T)})}function Qz($,O,T){return Gf($(O.calendar),T)}function Sz($,O,T,Z,f){let j=$(f.timeZone),W=f.plainTime,z=W!==void 0?O(W):p0;return F0(H0(T(j),{...Z,...z}),j,Z.calendar)}function Mz($,O=p0){return o(J1({...$,...O}))}function Vz($,O,T){return Bf($(O.calendar),T)}function Iz($,O,T){return Gf($(O.calendar),T)}function xz($,O,T,Z){return((f,j,W)=>jz(f,j,O2,z1(W),IO))($(O.calendar),T,Z)}function Nz($,O,T,Z){return((f,j,W)=>jz(f,j,T2,z1(W),sT))($(O.calendar),T,Z)}function Ez($,O,T,Z,f){let j=z1(f),W=O(j.plainDate),z=$(j.timeZone);return F0(H0(T(z),{...W,...Z}),z,W.calendar)}function Pz($,O){return o(J1({...$,...O}))}function _z($){return z0(k0(K$($,y0)))}function Az($){return z0(k0(K$($,o0)))}function Hz($){return z0(k0(BT(GT($),r1)))}function wz($){return z0(k0(BT(GT($))))}function bz($,O,T=p0){let Z=O.timeZone,f=$(Z),j={...L0(O,f),...T};return F0(u1(f,j,j.offsetNanoseconds,2),Z,O.calendar)}function vz($,O,T){let Z=O.timeZone,f=$(Z),j={...L0(O,f),...T},W=mz(O.calendar,T.calendar);return F0(u1(f,j,j.offsetNanoseconds,2),Z,W)}function gz($,O=p0){return o({...$,...O})}function Rz($,O){return o({...$,...O},mz($.calendar,O.calendar))}function iT($,O){return{...$,calendar:O}}function kz($,O){return{...$,timeZone:O}}function mz($,O){if($===O)return $;let T=J0($),Z=J0(O);if(T===Z||T===v)return O;if(Z===v)return $;throw RangeError(Nf)}function d5($,O){return(T)=>T===v?$:T===nT||T===L$?Object.assign(Object.create($),{id:T}):Object.assign(Object.create(O),fJ(T))}function o1($,O,T){let Z=new Set(T);return(f)=>(((j,W)=>{for(let z of W)if(z in j)return 1;return 0})(f=T3(Z,f),$)||Object.assign(f,O),T&&(f.timeZone=$$,["full","long"].includes(f.timeStyle)&&(f.timeStyle="medium")),f)}function C1($,O=Mf){let[T,,,Z]=$;return(f,j=NJ,...W)=>{let z=O(Z&&Z(...W),f,j,T),J=z.resolvedOptions();return[z,...u5($,J,W)]}}function Mf($,O,T,Z){if(T=Z(T),$){if(T.timeZone!==void 0)throw TypeError(L7);T.timeZone=$}return new P1(O,T)}function u5($,O,T){let[,Z,f]=$;return T.map((j)=>(j.calendar&&((W,z,J)=>{if((J||W!==v)&&W!==z)throw RangeError(Nf)})(J0(j.calendar),O.calendar,f),Z(j,O)))}function _$($){let O=QO();return I1(O,$.getOffsetNanosecondsFor(O))}function QO(){return K$(Date.now(),o0)}function F1(){return O6||(O6=new P1().resolvedOptions().timeZone)}var s5=($,O)=>`Non-integer ${$}: ${O}`,n5=($,O)=>`Non-positive ${$}: ${O}`,a5=($,O)=>`Non-finite ${$}: ${O}`,o5=($)=>`Cannot convert bigint to ${$}`,r5=($)=>`Invalid bigint: ${$}`,t5="Cannot convert Symbol to string",qz="Invalid object",yz=($,O,T,Z,f)=>f?yz($,f[O],f[T],f[Z]):SO($,O)+`; must be between ${T}-${Z}`,SO=($,O)=>`Invalid ${$}: ${O}`,Vf=($)=>`Missing ${$}`,If=($)=>`Invalid field ${$}`,e5=($)=>`Duplicate field ${$}`,pz=($)=>"No valid fields: "+$.join(),cz="Invalid bag",iz=($,O,T)=>SO($,O)+"; must be "+Object.keys(T).join(),hz="Cannot use valueOf",xf="Invalid calling context",$7="Forbidden era/eraYear",O7="Mismatching era/eraYear",T7="Mismatching year/eraYear",Z7=($)=>`Invalid era: ${$}`,f7=($)=>"Missing year"+($?"/era/eraYear":""),j7=($)=>`Invalid monthCode: ${$}`,lz="Mismatching month/monthCode",W7="Missing month/monthCode",rW="Cannot guess year",fO="Invalid leap month",dz="Invalid protocol",MO="Invalid protocol results",Nf="Mismatching Calendars",z7=($)=>`Invalid Calendar: ${$}`,uz="Mismatching TimeZones",J7="Forbidden ICU TimeZone",C7="Out-of-bounds offset",F7="Out-of-bounds TimeZone gap",Y7="Invalid TimeZone offset",D7="Ambiguous offset",hT="Out-of-bounds date",X7="Out-of-bounds duration",U7="Cannot mix duration signs",lT="Missing relativeTo",G7="Cannot use large units",B7="Required smallestUnit or largestUnit",K7="smallestUnit > largestUnit",P0=($)=>`Cannot parse: ${$}`,W1=($)=>`Invalid substring: ${$}`,sz=($)=>`Cannot format ${$}`,nz="Mismatching types for formatting",L7="Cannot specify TimeZone",az=b(DO,($,O)=>O),A$=b(DO,($,O,T)=>T),q0=b(TT,2),rZ={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},VO=Object.keys(rZ),_0=86400000,oz=1000,r1=1000,o0=1e6,y0=1e9,dT=60000000000,uT=3600000000000,q=86400000000000,a0=[1,r1,o0,y0,dT,uT,q],Y1=VO.slice(0,6),tZ=XO(Y1),rz=["offset"],tz=["timeZone"],ez=Y1.concat(rz),$2=ez.concat(tz),eZ=["era","eraYear"],Q7=eZ.concat(["year"]),sT=["year"],Ef=["monthCode"],Pf=["month"].concat(Ef),IO=["day"],_f=Pf.concat(sT),O2=Ef.concat(sT),d0=IO.concat(_f),S7=IO.concat(Pf),T2=IO.concat(Ef),Z2=A$(Y1,0),v="iso8601",nT="gregory",L$="japanese",f2={[nT]:{bce:-1,ce:0},[L$]:{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}},M7={chinese:13,dangi:13,hebrew:-6},h=b(UT,"string"),j2=b(UT,"boolean"),V7=b(UT,"number"),W2=b(UT,"function"),k=VO.map(($)=>$+"s"),Af=XO(k),I7=k.slice(0,6),z2=k.slice(6),x7=z2.slice(1),N7=az(k),C0=A$(k,0),Hf=A$(I7,0),wf=b(W6,k),u0=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],bf=["isoDay","isoMonth","isoYear"],aT=u0.concat(bf),vf=XO(bf),J2=XO(u0),C2=XO(aT),p0=A$(J2,0),E7=b(W6,aT),P1=Intl.DateTimeFormat,F2="en-GB",gf=1e8,P7=gf*_0,_7=[gf,0],A7=[-gf,0],FO=275760,YO=-271821,H7=1970,Q$=1972,f1=12,w7=M$(1868,9,8),b7=A0(b5,WeakMap),FT="smallestUnit",$3="unit",WO="roundingIncrement",uZ="fractionalSecondDigits",Y2="relativeTo",D2={constrain:0,reject:1},v7=Object.keys(D2),g7={compatible:0,reject:1,earlier:2,later:3},R7={reject:0,use:1,prefer:2,ignore:3},k7={auto:0,never:1,critical:2,always:3},m7={auto:0,never:1,critical:2},q7={auto:0,never:1},y7={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},xO=b(M3,FT),Rf=b(M3,"largestUnit"),p7=b(M3,$3),X2=b(l1,"overflow",D2),U2=b(l1,"disambiguation",g7),c7=b(l1,"offset",R7),kf=b(l1,"calendarName",k7),i7=b(l1,"timeZoneName",m7),h7=b(l1,"offset",q7),NO=b(l1,"roundingMode",y7),H$="PlainYearMonth",w$="PlainMonthDay",t1="PlainDate",e1="PlainDateTime",oT="PlainTime",D1="ZonedDateTime",rT="Instant",tT="Duration",l7=[Math.floor,($)=>oO($)?Math.floor($):Math.round($),Math.ceil,($)=>oO($)?Math.ceil($):Math.round($),Math.trunc,($)=>oO($)?Math.trunc($)||0:Math.round($),($)=>$<0?Math.floor($):Math.ceil($),($)=>Math.sign($)*Math.round(Math.abs($))||0,($)=>oO($)?($=Math.trunc($)||0)+$%2:Math.round($)],$$="UTC",$T=5184000,d7=fT(1847),u7=fT(new Date().getUTCFullYear()+10),s7=/0+$/,L0=A0(q5,WeakMap),tW=4294967295,eT=A0(($)=>{let O=$f($);return typeof O=="object"?new B2(O):new G2(O||0)});class G2{constructor($){this.v=$}getOffsetNanosecondsFor(){return this.v}getPossibleInstantsFor($){return[D3($,this.v)]}l(){}}class B2{constructor($){this.$=((O)=>{function T(J){let C=sZ(J,W,z),[F,D]=uW(C),Y=f(F),U=f(D);return Y===U?Y:Z(j(F,D),Y,U,J)}function Z(J,C,F,D){let Y,U;for(;(D===void 0||(Y=D<J[0]?C:D>=J[1]?F:void 0)===void 0)&&(U=J[1]-J[0]);){let X=J[0]+Math.floor(U/2);O(X)===F?J[1]=X:J[0]=X+1}return Y}let f=A0(O),j=A0(y5),W=d7,z=u7;return{G(J){let C=T(J-86400),F=T(J+86400),D=J-C,Y=J-F;if(C===F)return[D];let U=T(D);return U===T(Y)?[J-U]:C>F?[D,Y]:[]},V:T,l(J,C){let F=sZ(J,W,z),[D,Y]=uW(F),U=$T*C,X=C<0?()=>Y>W||(W=F,0):()=>D<z||(z=F,0);for(;X();){let G=f(D),B=f(Y);if(G!==B){let L=j(D,Y);Z(L,G,B);let M=L[0];if((K1(M,J)||1)===C)return M}D+=U,Y+=U}}}})(((O)=>(T)=>{let Z=F3(O,T*oz);return fT(y8(Z),parseInt(Z.month),parseInt(Z.day),parseInt(Z.hour),parseInt(Z.minute),parseInt(Z.second))-T})($))}getOffsetNanosecondsFor($){return this.$.V(S6($))*y0}getPossibleInstantsFor($){let[O,T]=[fT((Z=$).isoYear,Z.isoMonth,Z.isoDay,Z.isoHour,Z.isoMinute,Z.isoSecond),Z.isoMillisecond*o0+Z.isoMicrosecond*r1+Z.isoNanosecond];var Z;return this.$.G(O).map((f)=>k0(B$(K$(f,y0),T)))}l($,O){let[T,Z]=M6($),f=this.$.l(T+(O>0||Z?1:0),O);if(f!==void 0)return K$(f,y0)}}var mf="([+\u2212-])",OT="(?:[.,](\\d{1,9}))?",K2=`(?:(?:${mf}(\\d{6}))|(\\d{4}))-?(\\d{2})`,qf="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+OT+")?)?",yf=mf+qf,n7=K2+"-?(\\d{2})(?:[T ]"+qf+"(Z|"+yf+")?)?",L2="\\[(!?)([^\\]]*)\\]",$Z=`((?:${L2}){0,9})`,a7=P$(K2+$Z),o7=P$("(?:--)?(\\d{2})-?(\\d{2})"+$Z),r7=P$(n7+$Z),t7=P$("T?"+qf+"(?:"+yf+")?"+$Z),e7=P$(yf),$J=new RegExp(L2,"g"),OJ=P$(`${mf}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${OT}H)?(?:(\\d+)${OT}M)?(?:(\\d+)${OT}S)?)?`),TJ=A0(($)=>new P1(F2,{timeZone:$,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),ZJ=/^(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$/,fJ=A0(i5),pf=A0(($)=>new P1(F2,{calendar:$,timeZone:$$,era:"short",year:"numeric",month:"short",day:"numeric"})),jJ=/^M(\d{2})(L?)$/,WJ={era:ZT,eraYear:U0,year:U0,month:iW,monthCode:ZT,day:iW},zJ=A$(Y1,U0),JJ=A$(k,K6),eW=Object.assign({},WJ,zJ,JJ,{offset:ZT}),CJ=b(w5,Y1,u0),$6={dateAdd($,O,T){let Z=R(T),f,{years:j,months:W,weeks:z,days:J}=O;if(J+=j0(O,5)[0],j||W)f=((C,F,D,Y,U)=>{let[X,G,B]=C.h(F);if(D){let[L,M]=C.I(X,G);X+=D,G=CT(L,M,C.U(X)),G=m0("month",G,1,C.L(X),U)}return Y&&([X,G]=C._(X,G,Y)),B=m0("day",B,1,C.j(X,G),U),C.q(X,G,B)})(this,$,j,W,Z);else{if(!z&&!J)return $;f=K0($)}return f+=(7*z+J)*_0,L1(LT(f))},dateUntil($,O,T){if(T<=7){let J=0,C=m8({...$,...p0},{...O,...p0});return T===7&&([J,C]=S1(C,7)),{...C0,weeks:J,days:C}}let Z=this.h($),f=this.h(O),[j,W,z]=((J,C,F,D,Y,U,X)=>{let G=Y-C,B=U-F,L=X-D;if(G||B){let M=Math.sign(G||B),Q=J.j(Y,U),N=0;if(Math.sign(L)===-M){let P=Q;[Y,U]=J._(Y,U,-M),G=Y-C,B=U-F,Q=J.j(Y,U),N=M<0?-P:Q}if(L=X-Math.min(D,Q)+N,G){let[P,S]=J.I(C,F),[V,_]=J.I(Y,U);if(B=V-P||Number(_)-Number(S),Math.sign(B)===-M){let A=M<0&&-J.L(Y);G=(Y-=M)-C,B=U-CT(P,S,J.U(Y))+(A||J.L(Y))}}}return[G,B,L]})(this,...Z,...f);return T===8&&(W+=this.J(j,Z[0]),j=0),{...C0,years:j,months:W,days:z}},dateFromFields($,O){let T=R(O),Z=hZ(this,$),f=lZ(this,$,Z,T),j=oW(this,$,f,Z,T);return r(L1(this.P(Z,f,j)),this.id||v)},yearMonthFromFields($,O){let T=R(O),Z=hZ(this,$),f=lZ(this,$,Z,T);return p1(Y3(this.P(Z,f,1)),this.id||v)},monthDayFromFields($,O){let T=R(O),Z=!this.id,{monthCode:f,year:j,month:W}=$,z,J,C,F,D;if(f!==void 0){[z,J]=h8(f),D=T6($,"day");let Y=this.N(z,J,D);if(!Y)throw RangeError(rW);if([C,F]=Y,W!==void 0&&W!==F)throw RangeError(lz);Z&&(F=m0("month",F,1,f1,1),D=m0("day",D,1,X3(j!==void 0?j:C,F),T))}else{C=j===void 0&&Z?Q$:hZ(this,$),F=lZ(this,$,C,T),D=oW(this,$,F,C,T);let Y=this.U(C);J=F===Y,z=aZ(F,Y);let U=this.N(z,J,D);if(!U)throw RangeError(rW);[C,F]=U}return jT(L1(this.P(C,F,D)),this.id||v)},fields($){return oZ(this)&&$.includes("year")?[...$,...eZ]:$},mergeFields($,O){let T=Object.assign(Object.create(null),$);return dZ(T,O,Pf),oZ(this)&&(dZ(T,O,Q7),this.id===L$&&dZ(T,O,S7,eZ)),T},inLeapYear($){let[O]=this.h($);return this.K(O)},monthsInYear($){let[O]=this.h($);return this.L(O)},daysInMonth($){let[O,T]=this.h($);return this.j(O,T)},daysInYear($){let[O]=this.h($);return this.X(O)},dayOfYear:Yf,era($){return this.ee($)[0]},eraYear($){return this.ee($)[1]},monthCode($){let[O,T]=this.h($),[Z,f]=this.I(O,T);return((j,W)=>"M"+q0(j)+(W?"L":""))(Z,f)},dayOfWeek:E6,daysInWeek(){return 7}},FJ={dayOfYear:Yf,h:I6,q:M$},YJ=Object.assign({},FJ,{weekOfYear:c8,yearOfWeek:i8,R($){function O(U){return(7-U<Z?7:0)-U}function T(U){let X=N6(Y+U),G=U||1,B=O(jO(J+X*G,7));return F=(X+(B-C)*G)/7}let Z=this.id?1:4,f=E6($),j=this.dayOfYear($),W=jO(f-1,7),z=j-1,J=jO(W-z,7),C=O(J),F,D=Math.floor((z-C)/7)+1,Y=$.isoYear;return D?D>T(0)&&(D=1,Y++):(D=T(-1),Y--),[D,Y,F]}}),DJ={dayOfYear:Yf,h:nZ,q:CO,weekOfYear:c8,yearOfWeek:i8,R(){return[]}},b$=d5(Object.assign({},$6,YJ,{h:I6,ee($){return this.id===nT?P6($):this.id===L$?b7($):[]},I:($,O)=>[O,0],N($,O){if(!O)return[Q$,$]},K:U3,U(){},L:x6,J:($)=>$*f1,j:X3,X:N6,P:($,O,T)=>({isoYear:$,isoMonth:O,isoDay:T}),q:M$,_:($,O,T)=>($+=DT(T,f1),(O+=f3(T,f1))<1?($--,O+=f1):O>f1&&($++,O-=f1),[$,O]),year($){return $.isoYear},month($){return $.isoMonth},day:($)=>$.isoDay}),Object.assign({},$6,DJ,{h:nZ,ee($){let O=this.O($);return[O.era,O.eraYear]},I($,O){let T=rO.call(this,$);return[aZ(O,T),T===O]},N($,O,T){let[Z,f,j]=nZ.call(this,{isoYear:Q$,isoMonth:f1,isoDay:31}),W=rO.call(this,Z),z=f===W;(K1($,aZ(f,W))||K1(Number(O),Number(z))||K1(T,j))===1&&Z--;for(let J=0;J<100;J++){let C=Z-J,F=rO.call(this,C),D=CT($,O,F);if(O===(D===F)&&T<=nW.call(this,C,D))return[C,D]}},K($){let O=tO.call(this,$);return O>tO.call(this,$-1)&&O>tO.call(this,$+1)},U:rO,L:eO,J($,O){let T=O+$,Z=Math.sign($),f=Z<0?-1:0,j=0;for(let W=O;W!==T;W+=Z)j+=eO.call(this,W+f);return j},j:nW,X:tO,P($,O,T){return LT(CO.call(this,$,O,T))},q:CO,_($,O,T){if(T){if(O+=T,!Number.isSafeInteger(O))throw RangeError(hT);if(T<0)for(;O<1;)O+=eO.call(this,--$);else{let Z;for(;O>(Z=eO.call(this,$));)O-=Z,$++}}return[$,O]},year($){return this.O($).year},month($){let{year:O,F:T}=this.O($),{C:Z}=this.B(O);return Z[T]+1},day($){return this.O($).day}})),Q1="numeric",v$=["timeZoneName"],Q2={month:Q1,day:Q1},cf={year:Q1,month:Q1},hf=Object.assign({},cf,{day:Q1}),lf={hour:Q1,minute:Q1,second:Q1},df=Object.assign({},hf,lf),XJ=Object.assign({},df,{timeZoneName:"short"}),UJ=Object.keys(cf),GJ=Object.keys(Q2),BJ=Object.keys(hf),KJ=Object.keys(lf),uf=["dateStyle"],LJ=UJ.concat(uf),QJ=GJ.concat(uf),sf=BJ.concat(uf,["weekday"]),EO=KJ.concat(["dayPeriod","timeStyle"]),nf=sf.concat(EO),SJ=nf.concat(v$),MJ=v$.concat(EO),VJ=v$.concat(sf),IJ=v$.concat(["day","weekday"],EO),xJ=v$.concat(["year","weekday"],EO),NJ={},af=[o1(nf,df),IT],S2=[o1(SJ,XJ),IT,0,($,O)=>{let T=J0($.timeZone);if(O&&J0(O.timeZone)!==T)throw RangeError(uz);return T}],of=[o1(nf,df,v$),K0],rf=[o1(sf,hf,MJ),K0],tf=[o1(EO,lf,VJ),($)=>M1($)/o0],ef=[o1(LJ,cf,IJ),K0,1],$j=[o1(QJ,Q2,xJ),K0,1],O6;function e0($,O,T,Z,f){function j(...J){if(!(this instanceof j))throw TypeError(xf);x2(this,O(...J))}function W(J,C){return Object.defineProperties(function(...F){return J.call(this,z(this),...F)},O3(C))}function z(J){let C=X0(J);if(!C||C.branding!==$)throw TypeError(xf);return C}return Object.defineProperties(j.prototype,{...Z6(c0(W,T)),...i1(c0(W,Z)),...YT("Temporal."+$)}),Object.defineProperties(j,{...i1(f),...O3($)}),[j,(J)=>{let C=Object.create(j.prototype);return x2(C,J),C},z]}function P2($){return $=$.concat("id").sort(),(O)=>{if(!f6(O,$))throw TypeError(dz);return O}}function m$($){if(X0($)||$.calendar!==void 0||$.timeZone!==void 0)throw TypeError(cz);return $}function OZ($,O){let T={};for(let Z in $)T[Z]=({o:f},j)=>{let W=X0(j)||{},{branding:z}=W,J=z===t1||O.includes(z)?W:M0(j);return f[Z](J)};return T}function Zj($){let O={};for(let T in $)O[T]=(Z)=>{let{calendar:f}=Z;return(j=f,typeof j=="string"?b$(j):(W=j,Object.assign(Object.create(cJ),{i:W})))[T](Z);var j,W};return O}function b1(){throw TypeError(hz)}function _O({calendar:$}){return typeof $=="string"?new Dj($):$}function M2($,O){if(O=a(O),W0($)){let Z=X0($);if(Z&&Z.branding===w$)return R(O),Z;let f=H2($);return Uf(JZ(f||v),!f,$,O)}let T=X8(b$,$);return R(O),T}function _2($,O,T){return Z=O.call($,S0(z0(T))),R3(UO(Z));var Z}function TZ($,O=g2){let T=Object.keys(O).sort(),Z={};for(let f of T)Z[f]=b(O[f],$,W2($[f]));return Z}function y($,O){return typeof $=="string"?eT($):TZ($,O)}function e($){return y($,Tj)}function r0($){if(W0($)){let O=X0($);if(O)switch(O.branding){case rT:return O;case D1:return z0(O.epochNanoseconds)}}return J8($)}function V2($,O,T){let Z=O.l(r0(T).epochNanoseconds,$);return Z?S0(z0(Z)):null}function c($){return W0($)?(X0($)||{}).timeZone||sJ($):((O)=>kT(K8(h(O))))($)}function _1($,O){if(W0($)){let T=X0($)||{};switch(T.branding){case oT:return R(O),T;case e1:return R(O),l0(T);case D1:return R(O),Sf(e,T)}return o8($,O)}return R(O),U8($)}function fj($){return $===void 0?void 0:_1($)}function g$($,O){if(O=a(O),W0($)){let Z=X0($);return Z&&Z.branding===H$?(R(O),Z):Xf(WZ(AO($)),$,O)}let T=D8(b$,$);return R(O),T}function A1($,O){if(O=a(O),W0($)){let Z=X0($)||{};switch(Z.branding){case e1:return R(O),Z;case t1:return R(O),o({...Z,...p0});case D1:return R(O),Lf(e,Z)}return a8(zZ(AO($)),$,O)}let T=Y8($);return R(O),T}function M0($,O){if(O=a(O),W0($)){let Z=X0($)||{};switch(Z.branding){case t1:return R(O),Z;case e1:return R(O),r(Z);case D1:return R(O),Qf(e,Z)}return Df(zZ(AO($)),$,O)}let T=gT($);return R(O),T}function A2($,O,T){return i0(O.call($,d(r(T,$))))}function $1($){return(O)=>typeof O=="string"?b$(O):((T,Z)=>{let f=Object.keys(Z).sort(),j={};for(let W of f)j[W]=b(Z[W],T,T[W]);return j})(O,$)}function l($){if(W0($)){let O=X0($);return O&&O.branding===tT?O:r8($)}return G8($)}function PO($){if($!==void 0){if(W0($)){let O=X0($)||{};switch(O.branding){case D1:case t1:return O;case e1:return r(O)}let T=AO($);return{...s8(c,y,zZ(T),$),calendar:T}}return C8($)}}function AO($){return H2($)||v}function H2($){let{calendar:O}=$;if(O!==void 0)return D0(O)}function D0($){return W0($)?(X0($)||{}).calendar||JC($):((O)=>KO(B8(h(O))))($)}function R$($,O){if(O=a(O),W0($)){let T=X0($);if(T&&T.branding===D1)return GO(O),T;let Z=AO($);return n8(c,y,zZ(Z),Z,$,O)}return F8($,O)}function I2($){return c0((O)=>(T)=>O(Oj(T)),$)}function Oj($){return L0($,e)}function EJ(){let $=P1.prototype,O=Object.getOwnPropertyDescriptors($),T=Object.getOwnPropertyDescriptors(P1),Z=function(f,j={}){if(!(this instanceof Z))return new Z(f,j);Xj.set(this,((W,z={})=>{let J=new P1(W,z),C=J.resolvedOptions(),F=C.locale,D=w0(Object.keys(z),C),Y=A0(AJ),U=(...X)=>{let G,B=X.map((L,M)=>{let Q=X0(L),N=(Q||{}).branding;if(M&&G&&G!==N)throw TypeError(nz);return G=N,Q});return G?Y(G)(F,D,...B):[J,...X]};return U.u=J,U})(f,j))};for(let f in O){let j=O[f],W=f.startsWith("format")&&PJ(f);typeof j.value=="function"?j.value=f==="constructor"?Z:W||_J(f):W&&(j.get=function(){return W.bind(this)})}return T.prototype.value=Object.create($,O),Object.defineProperties(Z,T),Z}function PJ($){return function(...O){let T=Xj.get(this),[Z,...f]=T(...O);return Z[$](...f)}}function _J($){return function(...O){return Xj.get(this).u[$](...O)}}function AJ($){let O=HJ[$];if(!O)throw TypeError(sz($));return C1(O,A0(Mf))}var HJ={Instant:af,PlainDateTime:of,PlainDate:rf,PlainTime:tf,PlainYearMonth:ef,PlainMonthDay:$j},wJ=C1(af),bJ=C1(S2),vJ=C1(of),gJ=C1(rf),RJ=C1(tf),kJ=C1(ef),mJ=C1($j),jj={era:Y6,eraYear:j3,year:UO,month:i0,daysInMonth:i0,daysInYear:i0,inLeapYear:j2,monthsInYear:i0},fZ={monthCode:h},Wj={day:i0},w2={dayOfWeek:i0,dayOfYear:i0,weekOfYear:D6,yearOfWeek:j3,daysInWeek:i0},b2=Object.assign({},jj,fZ,Wj,w2),ZZ=new WeakMap,X0=ZZ.get.bind(ZZ),x2=ZZ.set.bind(ZZ),qJ={...OZ(jj,[H$]),...OZ(w2,[]),...OZ(fZ,[H$,w$]),...OZ(Wj,[w$])},zj=Zj(b2),yJ=Zj({...jj,...fZ}),pJ=Zj({...fZ,...Wj}),HO={calendarId:($)=>J0($.calendar)},cJ=c0(($,O)=>function(T){let{i:Z}=this;return $(Z[O](d(r(T,Z))))},b2),iJ=DO(($)=>(O)=>O[$],k.concat("sign")),Jj=DO(($,O)=>(T)=>T[u0[O]],Y1),v2={epochSeconds:g6,epochMilliseconds:IT,epochMicroseconds:R6,epochNanoseconds:k6},wO=b(T3,new Set(["branding"])),[hJ,k$,lJ]=e0(w$,b(Yz,D0),{...HO,...pJ},{getISOFields:wO,getCalendar:_O,with($,O,T){return k$(Tz(jC,$,this,m$(O),T))},equals:($,O)=>w8($,M2(O)),toPlainDate($,O){return d(Nz(bO,$,this,O))},toLocaleString($,O,T){let[Z,f]=mJ(O,T,$);return Z.format(f)},toString:H3,toJSON:($)=>H3($),valueOf:b1},{from:($,O)=>k$(M2($,O))}),g2={getOffsetNanosecondsFor:_2,getPossibleInstantsFor($,O,T){let Z=[...O.call($,Y0(o(T,v)))].map((j)=>uJ(j).epochNanoseconds),f=Z.length;return f>1&&(Z.sort(B0),k3(R0(g0(Z[0],Z[f-1])))),Z}},Tj={getOffsetNanosecondsFor:_2},[dJ,S0,uJ]=e0(rT,Wz,v2,{add:($,O)=>S0(m3(0,$,l(O))),subtract:($,O)=>S0(m3(1,$,l(O))),until:($,O,T)=>p(ff(0,$,r0(O),T)),since:($,O,T)=>p(ff(1,$,r0(O),T)),round:($,O)=>S0(y6($,O)),equals:($,O)=>E8($,r0(O)),toZonedDateTime($,O){let T=z1(O);return t(Kf($,c(T.timeZone),D0(T.calendar)))},toZonedDateTimeISO:($,O)=>t(Kf($,c(O))),toLocaleString($,O,T){let[Z,f]=wJ(O,T,$);return Z.format(f)},toString:($,O)=>N3(c,e,$,O),toJSON:($)=>N3(c,e,$),valueOf:b1},{from:($)=>S0(r0($)),fromEpochSeconds:($)=>S0(_z($)),fromEpochMilliseconds:($)=>S0(Az($)),fromEpochMicroseconds:($)=>S0(Hz($)),fromEpochNanoseconds:($)=>S0(wz($)),compare:($,O)=>Of(r0($),r0(O))}),[jZ,YD]=e0("TimeZone",($)=>{let O=x8($);return{branding:"TimeZone",id:O,o:eT(O)}},{id:($)=>$.id},{getPossibleInstantsFor:({o:$},O)=>$.getPossibleInstantsFor(A1(O)).map((T)=>S0(z0(T))),getOffsetNanosecondsFor:({o:$},O)=>$.getOffsetNanosecondsFor(r0(O).epochNanoseconds),getOffsetStringFor($,O){let T=r0(O).epochNanoseconds,Z=TZ(this,Tj).getOffsetNanosecondsFor(T);return d1(Z)},getPlainDateTimeFor($,O,T=v){let Z=r0(O).epochNanoseconds,f=TZ(this,Tj).getOffsetNanosecondsFor(Z);return Y0(o(I1(Z,f),D0(T)))},getInstantFor($,O,T){let Z=A1(O),f=G3(T),j=TZ(this);return S0(z0(H0(j,Z,f)))},getNextTransition:({o:$},O)=>V2(1,$,O),getPreviousTransition:({o:$},O)=>V2(-1,$,O),equals($,O){return!!qT(this,c(O))},toString:($)=>$.id,toJSON:($)=>$.id},{from($){let O=c($);return typeof O=="string"?new jZ(O):O}}),sJ=P2(Object.keys(g2)),[nJ,H1]=e0(oT,Dz,Jj,{getISOFields:wO,with($,O,T){return H1(Zz(this,m$(O),T))},add:($,O)=>H1(i3(0,$,l(O))),subtract:($,O)=>H1(i3(1,$,l(O))),until:($,O,T)=>p(Cf(0,$,_1(O),T)),since:($,O,T)=>p(Cf(1,$,_1(O),T)),round:($,O)=>H1(i6($,O)),equals:($,O)=>b8($,_1(O)),toZonedDateTime:($,O)=>t(Ez(c,M0,y,$,O)),toPlainDateTime:($,O)=>Y0(Pz($,M0(O))),toLocaleString($,O,T){let[Z,f]=RJ(O,T,$);return Z.format(f)},toString:w3,toJSON:($)=>w3($),valueOf:b1},{from:($,O)=>H1(_1($,O)),compare:($,O)=>mT(_1($),_1(O))}),[aJ,w1,oJ]=e0(H$,b(Fz,D0),{...HO,...yJ},{getISOFields:wO,getCalendar:_O,with($,O,T){return w1(Oz(fC,$,this,m$(O),T))},add:($,O,T)=>w1(c3(N2,0,$,l(O),T)),subtract:($,O,T)=>w1(c3(N2,1,$,l(O),T)),until:($,O,T)=>p(Jf(E2,0,$,g$(O),T)),since:($,O,T)=>p(Jf(E2,1,$,g$(O),T)),equals:($,O)=>H8($,g$(O)),toPlainDate($,O){return d(xz(bO,$,this,O))},toLocaleString($,O,T){let[Z,f]=kJ(O,T,$);return Z.format(f)},toString:A3,toJSON:($)=>A3($),valueOf:b1},{from:($,O)=>w1(g$($,O)),compare:($,O)=>n1(g$($),g$(O))}),[rJ,Y0]=e0(e1,b(Jz,D0),{...HO,...zj,...Jj},{getISOFields:wO,getCalendar:_O,with($,O,T){return Y0(e8(bO,$,this,m$(O),T))},withCalendar:($,O)=>Y0(iT($,D0(O))),withPlainDate:($,O)=>Y0(Rz($,M0(O))),withPlainTime:($,O)=>Y0(gz($,fj(O))),add:($,O,T)=>Y0(y3(O$,0,$,l(O),T)),subtract:($,O,T)=>Y0(y3(O$,1,$,l(O),T)),until:($,O,T)=>p(Wf(t0,0,$,A1(O),T)),since:($,O,T)=>p(Wf(t0,1,$,A1(O),T)),round:($,O)=>Y0(c6($,O)),equals:($,O)=>_8($,A1(O)),toZonedDateTime:($,O,T)=>t(Kz(y,$,c(O),T)),toPlainDate:($)=>d(r($)),toPlainTime:($)=>H1(l0($)),toPlainYearMonth($){return w1(Lz(WZ,$,this))},toPlainMonthDay($){return k$(Qz(JZ,$,this))},toLocaleString($,O,T){let[Z,f]=vJ(O,T,$);return Z.format(f)},toString:P3,toJSON:($)=>P3($),valueOf:b1},{from:($,O)=>Y0(A1($,O)),compare:($,O)=>Zf(A1($),A1(O))}),[tJ,d,R2]=e0(t1,b(Cz,D0),{...HO,...zj},{getISOFields:wO,getCalendar:_O,with($,O,T){return d($z(bO,$,this,m$(O),T))},withCalendar:($,O)=>d(iT($,D0(O))),add:($,O,T)=>d(p3(O$,0,$,l(O),T)),subtract:($,O,T)=>d(p3(O$,1,$,l(O),T)),until:($,O,T)=>p(zf(t0,0,$,M0(O),T)),since:($,O,T)=>p(zf(t0,1,$,M0(O),T)),equals:($,O)=>A8($,M0(O)),toZonedDateTime($,O){let T=!W0(O)||O instanceof jZ?{timeZone:O}:O;return t(Sz(c,_1,y,$,T))},toPlainDateTime:($,O)=>Y0(Mz($,fj(O))),toPlainYearMonth($){return w1(Vz(WZ,$,this))},toPlainMonthDay($){return k$(Iz(JZ,$,this))},toLocaleString($,O,T){let[Z,f]=gJ(O,T,$);return Z.format(f)},toString:_3,toJSON:($)=>_3($),valueOf:b1},{from:($,O)=>d(M0($,O)),compare:($,O)=>n1(M0($),M0(O))}),Cj={fields($,O,T){return[...O.call($,T)]}},k2=Object.assign({dateFromFields($,O,T,Z){return R2(O.call($,Object.assign(Object.create(null),T),Z))}},Cj),m2=Object.assign({yearMonthFromFields($,O,T,Z){return oJ(O.call($,Object.assign(Object.create(null),T),Z))}},Cj),q2=Object.assign({monthDayFromFields($,O,T,Z){return lJ(O.call($,Object.assign(Object.create(null),T),Z))}},Cj),Fj={mergeFields($,O,T,Z){return z1(O.call($,Object.assign(Object.create(null),T),Object.assign(Object.create(null),Z)))}},eJ=Object.assign({},k2,Fj),$C=Object.assign({},m2,Fj),OC=Object.assign({},q2,Fj),Yj={dateAdd($,O,T,Z,f){return R2(O.call($,d(r(T,$)),p(i(Z)),f))}},y2=Object.assign({},Yj,{dateUntil($,O,T,Z,f,j){return zC(O.call($,d(r(T,$)),d(r(Z,$)),Object.assign(Object.create(null),j,{largestUnit:VO[f]})))}}),TC=Object.assign({},Yj,{day:A2}),ZC=Object.assign({},y2,{day:A2}),WZ=$1(m2),zZ=$1(k2),JZ=$1(q2),fC=$1($C),bO=$1(eJ),jC=$1(OC),O$=$1(Yj),t0=$1(y2),N2=$1(TC),E2=$1(ZC),[WC,p,zC]=e0(tT,Xz,{...iJ,blank:j8},{with:($,O)=>p(fz($,O)),negated:($)=>p(bT($)),abs:($)=>p(f8($)),add:($,O,T)=>p(s3(PO,t0,y,0,$,l(O),T)),subtract:($,O,T)=>p(s3(PO,t0,y,1,$,l(O),T)),round:($,O)=>p(Z8(PO,t0,y,$,O)),total:($,O)=>q6(PO,t0,y,$,O),toLocaleString($,O,T){return Intl.DurationFormat?new Intl.DurationFormat(O,T).format(this):PT($)},toString:PT,toJSON:($)=>PT($),valueOf:b1},{from:($)=>p(l($)),compare:($,O,T)=>N8(PO,O$,y,l($),l(O),T)}),p2={toString:($)=>$.id,toJSON:($)=>$.id,...qJ,dateAdd:({id:$,o:O},T,Z,f)=>d(r(O.dateAdd(M0(T),l(Z),f),$)),dateUntil:({o:$},O,T,Z)=>p(i($.dateUntil(M0(O),M0(T),A6(Z)))),dateFromFields:({id:$,o:O},T,Z)=>d(Df(O,T,Z,F6($))),yearMonthFromFields:({id:$,o:O},T,Z)=>w1(Xf(O,T,Z,J6($))),monthDayFromFields:({id:$,o:O},T,Z)=>k$(Uf(O,0,T,Z,C6($))),fields({o:$},O){let T=new Set(d0),Z=[];for(let f of O){if(h(f),!T.has(f))throw RangeError(If(f));T.delete(f),Z.push(f)}return $.fields(Z)},mergeFields:({o:$},O,T)=>$.mergeFields(Z3(W3(O)),Z3(W3(T)))},[Dj]=e0("Calendar",($)=>{let O=p8($);return{branding:"Calendar",id:O,o:b$(O)}},{id:($)=>$.id},p2,{from($){let O=D0($);return typeof O=="string"?new Dj(O):O}}),JC=P2(Object.keys(p2).slice(4)),[CC,t]=e0(D1,b(zz,D0,c),{...v2,...HO,...I2(zj),...I2(Jj),offset:($)=>d1(Oj($).offsetNanoseconds),offsetNanoseconds:($)=>Oj($).offsetNanoseconds,timeZoneId:($)=>J0($.timeZone),hoursInDay:($)=>h6(y,$)},{getISOFields:($)=>O8(e,$),getCalendar:_O,getTimeZone:({timeZone:$})=>typeof $=="string"?new jZ($):$,with($,O,T){return t(t8(bO,y,$,this,m$(O),T))},withCalendar:($,O)=>t(iT($,D0(O))),withTimeZone:($,O)=>t(kz($,c(O))),withPlainDate:($,O)=>t(vz(y,$,M0(O))),withPlainTime:($,O)=>t(bz(y,$,fj(O))),add:($,O,T)=>t(q3(O$,y,0,$,l(O),T)),subtract:($,O,T)=>t(q3(O$,y,1,$,l(O),T)),until:($,O,T)=>p(i(jf(t0,y,0,$,R$(O),T))),since:($,O,T)=>p(i(jf(t0,y,1,$,R$(O),T))),round:($,O)=>t(p6(y,$,O)),startOfDay:($)=>t(l6(y,$)),equals:($,O)=>P8($,R$(O)),toInstant:($)=>S0(Uz($)),toPlainDateTime:($)=>Y0(Lf(e,$)),toPlainDate:($)=>d(Qf(e,$)),toPlainTime:($)=>H1(Sf(e,$)),toPlainYearMonth($){return w1(Gz(WZ,$,this))},toPlainMonthDay($){return k$(Bz(JZ,$,this))},toLocaleString($,O,T={}){let[Z,f]=bJ(O,T,$);return Z.format(f)},toString:($,O)=>E3(e,$,O),toJSON:($)=>E3(e,$),valueOf:b1},{from:($,O)=>t(R$($,O)),compare:($,O)=>Tf(R$($),R$(O))}),FC=Object.defineProperties({},{...YT("Temporal.Now"),...i1({timeZoneId:()=>F1(),instant:()=>S0(z0(QO())),zonedDateTime:($,O=F1())=>t(F0(QO(),c(O),D0($))),zonedDateTimeISO:($=F1())=>t(F0(QO(),c($),v)),plainDateTime:($,O=F1())=>Y0(o(_$(e(c(O))),D0($))),plainDateTimeISO:($=F1())=>Y0(o(_$(e(c($))),v)),plainDate:($,O=F1())=>d(r(_$(e(c(O))),D0($))),plainDateISO:($=F1())=>d(r(_$(e(c($))),v)),plainTimeISO:($=F1())=>H1(l0(_$(e(c($)))))})}),q$=Object.defineProperties({},{...YT("Temporal"),...i1({PlainYearMonth:aJ,PlainMonthDay:hJ,PlainDate:tJ,PlainTime:nJ,PlainDateTime:rJ,ZonedDateTime:CC,Instant:dJ,Calendar:Dj,TimeZone:jZ,Duration:WC,Now:FC})}),YC=EJ(),Xj=new WeakMap,DC=Object.defineProperties(Object.create(Intl),i1({DateTimeFormat:YC}));var Uj="intended_url";class Gj extends E{schema={email:{required:"Email is required",string:"Invalid email",email:"Invalid email"},password:{required:"Password is required"}}}class c2 extends E{schema={email:{required:"Email is required",email:"Invalid email"}}}class i2 extends E{schema={password:{required:"Password is required",password:"Invalid password"}}}class $0 extends gZ{async me(){let $=await T$.user();if(!$)throw new RZ;return $}async verifyEmail($=new E){let O=await $.input(),{userProvider:T}=K(w),Z=await T.findUserByVerificationToken(O.get("token"));if(!Z)return{email:null};return await T.verifyUser(Z.email),{email:Z.email}}async signInWithMagicLink($=new E){let O=K(w),{userProvider:T}=O,Z=$.search.get("token"),f=decodeURIComponent($.search.get("email")).toLowerCase().trim(),j=null;try{j=await T.findUserMagicLinkToken({email:f,token:Z})}catch(z){return console.log(z),{error:JSON.stringify(z)}}if(!j)return{error:"Invalid token"};await T.verifyUser(f),await T.deleteMagicLinkToken(f);let W=await O.createOrUpdateSession({email:f});return $.ctx().setCookie("access_token",W.token,K(w).accessTokenCookieOptions($,W.expiresAt)),await O.config.onSignIn(W,$.search.toJSON()),{session:W}}async signInWithPinV2($=new E){let O=K(w),{userProvider:T}=O,Z=await $.input(),{email:f,pin:j}=Z.toJSON(),W=f.toLowerCase().trim();if(!await T.findUserMagicLinkToken({email:W,pin:j}))throw new N0({pin:["Invalid pin"]});await T.deleteMagicLinkToken(W),await T.verifyUser(W);let J=await O.createOrUpdateSessionV2({email:W});return $.ctx().setCookie("access_token",J.token,K(w).accessTokenCookieOptions($,J.expiresAt)),await O.config.onSignIn(J,$.search.toJSON()),J}async signInWithPin($=new E){let O=K(w),{userProvider:T}=O,Z=await $.input(),{email:f,pin:j}=Z.toJSON(),W=f.toLowerCase().trim();if(!await T.findUserMagicLinkToken({email:W,pin:j}))throw new N0({pin:["Invalid pin"]});await T.deleteMagicLinkToken(W),await T.verifyUser(W);let J=await O.createOrUpdateSession({email:W});return $.ctx().setCookie("access_token",J.token,K(w).accessTokenCookieOptions($,J.expiresAt)),await O.config.onSignIn(J,$.search.toJSON()),{session:J}}async signInV2($=new Gj){let O=await $.input(),{email:T,password:Z}=O.toJSON(),f=T.toLowerCase().trim(),j=K(w),W=await j.userProvider.findUserByEmailAddress(f,j.config.verifyEmail);if(!W)throw new N0({invalid_credentials:["Invalid credentials"]});if(!await j.config.verifyPassword(Z,W.password))throw new N0({invalid_credentials:["Invalid credentials"]});let J=await j.createOrUpdateSessionV2({email:W.email,id:W.id});$.ctx().setCookie("access_token",J.token,K(w).accessTokenCookieOptions($,J.expiresAt)),await j.config.onSignIn(W,$.search.toJSON());let{password:C,...F}=W;return F}async signIn($=new Gj){let O=await $.input(),{email:T,password:Z}=O.toJSON(),f=T.toLowerCase().trim(),j=K(w),W=await j.userProvider.findUserByEmailAddress(f,j.config.verifyEmail);if(!W)throw new N0({invalid_credentials:["Invalid credentials"]});if(!await j.config.verifyPassword(Z,W.password))throw new N0({invalid_credentials:["Invalid credentials"]});let J=await j.createOrUpdateSession({email:W.email,id:W.id});$.ctx().setCookie("access_token",J.token,K(w).accessTokenCookieOptions($,J.expiresAt)),await j.config.onSignIn(W,$.search.toJSON());let{password:C,...F}=W;return F}async signUp(){let $=K(w),{userProvider:O,config:T}=$,Z=new T.signUpRequest,f=await Z.input(),{email:j,password:W,name:z,invitationId:J}=f.toJSON(),C=j.toLowerCase().trim();if(await O.findUserByEmailAddress(C,!1))throw new N0({email:["Email address already exists"]});let D=await T.hashPassword(W),Y=K(n).detectLocale(Z),U;if(J)U=await O.findInvitation(J,C);let X,G="";if(U)X=await O.transaction(async()=>{await O.deleteInvitationById(J);let B=await O.createUser({email:C,name:z,password:D,emailVerifiedAt:new Date,locale:Y});return await O.createAccount({organizationId:U.organizationId,userId:B.id,organizationRole:U.role}),await T.onUserCreated(B),B});else G=await T.generateEmailVerificationToken(C),X=await O.transaction(async()=>{let B=await O.createUser({email:C,name:z,password:D,verificationToken:G,locale:Y});return await T.onUserCreated(B),B});return await T.onSignUp(X,G,Z.search.toJSON()),X}async signOut($=new E){let O=$.cookies.get("access_token")??$.headers.get("access_token"),T=K(w),{config:Z}=T,f=await T.revokeSession(O,$.headers.get("User-Agent"));if($.ctx().setCookie("access_token","",K(w).accessTokenCookieOptions($,new Date(0))),K(w).cookieDomain($))$.ctx().setCookie("access_token","",{...K(w).accessTokenCookieOptions($,new Date(0)),domain:void 0});if(f?.user)f.user.extension=await Z.extendSession(f.user),await Z.onSignOut(f.user);return{}}async forgotPassword($=new c2){let T=(await $.input()).get("email").toLowerCase().trim(),{userProvider:Z,config:f}=K(w),j=await Z.findUserByEmailAddress(T,f.verifyEmail);if(!j)return{};let W=await f.generateForgotPasswordToken(j);return await Z.createPasswordResetToken({user:j,token:W}),await f.onForgotPassword(j,W),{}}async resetPassword($=new i2){let{userProvider:O,config:T}=K(w),Z=await $.input(),{password:f,token:j}=Z.toJSON(),W=await O.findPasswordResetToken({token:j});if(!W)throw new N0({token:["Invalid token"]});if(q$.Instant.from(W.createdAt.toISOString()).add({hours:24}).until(q$.Now.instant()).sign>=0)throw new N0({token:["Token expired"]});await O.deletePasswordResetToken({token:j});let J=await O.findUserByEmailAddress(W.user.email,T.verifyEmail);if(!J)throw new N0({email:["User not found"]});let C=await T.hashPassword(f);return await O.updateUserPassword({id:J.id,password:C}),await O.deleteAllUserSessions(J.id),await T.onResetPassword(J),{}}async changePassword($=new E){let{userProvider:O,config:T}=K(w),Z=await T$.user(),f=await $.input(),{oldPassword:j,newPassword:W}=f.toJSON(),{password:z}=await O.findUserByEmailAddress(Z.email,T.verifyEmail);if(!await T.verifyPassword(j,z))throw new N0({oldPassword:["Incorrect password"]});let C=await T.hashPassword(W);return await O.updateUserPassword({id:Z.id,password:C}),await O.deleteAllUserSessions(Z.id),{}}async oauthRedirect($=new E){let{provider:O}=$.params,T=K(w).config.oauthProviders[O];if(!T)throw Error(`Invalid provider: ${O}`);let Z=$O($.search.get(D$),"");if(Z)$.ctx().setCookie(Uj,encodeURIComponent(Z),{httpOnly:!0,sameSite:"Lax",secure:VW($.rawRequest),maxAge:600});return{destination:await T.getRedirectUrl($)}}async oauthCallback($=new E){let{provider:O}=$.params,T=K(w),{userProvider:Z,config:f}=T,j=f.oauthProviders[O],{email:W,name:z,username:J,providerId:C}=await j.onCallback($),F=C?await Z.findUserBySocialAccount(O,C):null,D="signin";if(!F){if(!W)return console.error("Authentication error: No email returned from OAuth provider callback"),{session:null};let G=K(n).detectLocale($);try{let B=await this.linkOAuthAccount({provider:O,providerId:C,email:W,name:z,username:J,locale:G});if(B)F=B.user,D=B.action}catch(B){let L=C?await Z.findUserBySocialAccount(O,C):null;if(!L)throw B;F=L}if(!F)return{session:null}}let Y=await T.createOrUpdateSessionV2({email:F.email,id:F.id});if($.ctx().setCookie("access_token",Y.token,K(w).accessTokenCookieOptions($,Y.expiresAt)),D==="signup")await f.onSignUp(F,"",$.search.toJSON());else await f.onSignIn(F,$.search.toJSON());let U=$.cookies.get(Uj),X=f.redirectPath;if(U){try{X=$O(decodeURIComponent(U),X)}catch{}$.ctx().setCookie(Uj,"",{maxAge:-1})}return{session:Y,redirectTo:X}}async linkOAuthAccount($){let{provider:O,providerId:T,email:Z,name:f,username:j,locale:W}=$,{userProvider:z,config:J}=K(w),C=(Y)=>({provider:O,userId:Y,email:Z,username:j,providerId:T,expiresAt:new Date,accessToken:"",refreshToken:""}),F=await z.findUserByEmailAddress(Z,!1);if(F){if(!T)return{user:F,action:"signin"};let Y=await z.findSocialAccounts(F.id,O);if(Y.some((X)=>X.providerId===T))return{user:F,action:"signin"};if(Y.some((X)=>X.providerId))return console.error(`Authentication error: user ${F.id} is already linked to a different ${O} account`),null;let U=Y[0];if(U){if(!await z.claimSocialAccount(U,T))throw Error(`${O} account link changed concurrently`)}else await z.createSocialAccount(C(F.id));return{user:F,action:"signin"}}return{user:await z.transaction(async()=>{let Y=await z.createUser({email:Z,name:f,locale:W,emailVerifiedAt:new Date});if(T)await z.createSocialAccount(C(Y.id));return await J.onUserCreated(Y),Y}),action:"signup"}}async createMagicLinkToken($=new E){let T=(await $.input()).get("email").toLowerCase().trim(),Z=K(w),{user:f,pin:j,token:W}=await Z.createMagicLinkToken(T);if(f)return await Z.config.onMagicLinkCreated(f,{email:T,pin:j,token:W}),{email:T};return{email:null}}}class h2 extends B1{middlewares=["cache:private"];routes={"/:provider":this.view("_Redirect",[$0,"oauthRedirect"]),"/:provider/callback":this.view("auth/OauthCallback",[$0,"oauthCallback"])}}class Bj extends B1{middlewares=["cache:private"];routes={"/sign-in/magic-link":this.view("auth/MagicLinkSignIn",[$0,"signInWithMagicLink"]),"/oauth":h2}}class Kj extends x0{middlewares=["cache:private"];routes={"/sign-in":this.post($0,"signIn"),"/sign-in-v2":this.post($0,"signInV2"),"/sign-up":this.post($0,"signUp"),"/sign-out":this.post($0,"signOut"),"/forgot-password":this.post($0,"forgotPassword"),"/reset-password":this.post($0,"resetPassword"),"/change-password":this.post($0,"changePassword"),"/verify-email":this.post($0,"verifyEmail"),"/me":this.get($0,"me").middleware(["auth"]),"/magic-link":this.post($0,"createMagicLinkToken"),"/sign-in-with-pin":this.post($0,"signInWithPin"),"/sign-in-with-pin-v2":this.post($0,"signInWithPinV2")}}class Lj extends x0{middlewares=["cache:private,0,no-store"];routes={"/set-locale/:locale":this.get(async()=>{let O=new E().params.locale;return await K(n).onLocaleChange(O),{locale:O}}),"/translations/:locale/:scope*":this.get(async()=>{let $=new E,O=`/${$.params.scope??""}`,T=$.params.locale,Z=K(n),f=T??Z.detectLocale($),j=Z.getPageTranslations(f,O);return $.ctx().setCookie("i18n-locale",f,{expires:new Date(Date.now()+31536000000)}),{[f]:j}})}}class Qj{}class Sj extends Qj{async resize($,O){let{height:T,width:Z,quality:f,fit:j}=O;return await(await CZ("The Sharp image optimization driver"))($).resize(Z>0?Z:void 0,T>0?T:void 0,{fit:j}).webp({quality:f>0?f:80,force:!0}).toBuffer()}}function pD($){return $}function l2(){return{driver:new Sj}}class Mj extends x0{routes={"/resize":this.file(async()=>{let $=new E,O=new URL($.rawRequest.url),T=O.searchParams.get("url"),Z=Number(O.searchParams.get("w")),f=Number(O.searchParams.get("h")),j=O.searchParams.get("fit")??"cover",W=Number(O.searchParams.get("q"));if(!T)return new Response(JSON.stringify({error:"url query parameter is required"}),{headers:{"Content-Type":"application/json"},status:404});let J=`${T.startsWith("http")?"":`http://localhost:${process.env.PORT||5173}`}${T}`,C=await fetch(J);if(!C.ok)return new Response(JSON.stringify({error:"Image not found",info:J}),{headers:{"Content-Type":"application/json"},status:404});let F=Buffer.from(await C.arrayBuffer()),D=await K(d2).resize(F,{height:f,width:Z,fit:j,quality:W});C.headers.delete("Content-Type"),C.headers.delete("Content-Length");let Y=new Headers(C.headers);return Y.set("Content-Type","image/webp"),Y.set("Content-Length",`${D.byteLength}`),new Response(new Uint8Array(D),{headers:Y})})}}class d2{static token="image";driver;constructor($={}){this.driver=$.driver??l2().driver}resize($,O){return this.driver.resize($,O)}}import{mkdir as Vj,readdir as XC,access as UC}from"fs/promises";async function Ij($){try{return await UC($),!0}catch{return!1}}class vO{config;static token="log";writer;isReady=!1;flushTimeout;fileSize=0;writerSize=0;isCreatingFile=!1;bootPromise=null;currentLogFilePath;get logsDirPath(){return`${xj()}/storage/logs`}constructor($){this.config=$}boot(){if(!this.bootPromise)this.bootPromise=this.createStorage().catch(($)=>{console.error("Log storage unavailable, file logging disabled",$)}).then(()=>{this.isReady=!0});return this.bootPromise}async createStorage(){let $=`${xj()}/storage`;if(!await Ij($))await Vj($);if(!await Ij(this.logsDirPath))await Vj(this.logsDirPath);await this.newLogFile()}async newLogFile(){if(!await Ij(this.logsDirPath))await Vj(this.logsDirPath);if(this.isCreatingFile=!0,this.currentLogFilePath){this.writer.flush(),this.writer.end(),this.writer=null;let T=new File([await Bun.file(this.currentLogFilePath).arrayBuffer()],this.currentLogFilePath.split("/").pop(),{type:"text/plain"});this.config.onLogFileClosed(T),this.fileSize=0,this.writerSize=0}let O=(await XC(this.logsDirPath)).sort().reverse()[0];if(O){let T=Bun.file(`${this.logsDirPath}/${O}`);if(T.size<this.config.maxFileSize)this.currentLogFilePath=`${this.logsDirPath}/${O}`,this.writer=T.writer(),this.writer.write(await T.text()),this.writer.write(`
|
|
3
|
+
`),this.writer.flush(),this.fileSize=T.size}if(!this.writer){let T=`${new Date(Date.now()).toISOString()}.log`.replaceAll(":","-");this.currentLogFilePath=`${this.logsDirPath}/${T}`;let Z=Bun.file(`${this.logsDirPath}/${T}`);this.writer=Z.writer(),this.fileSize=0,this.writerSize=0}this.isCreatingFile=!1}async log($,O,T={}){if(!this.isReady)await this.boot();let Z=x.getStore(),f={};if(Z)f={url:Z.req.rawRequest.url,method:Z.req.rawRequest.method,headers:Z.req.rawRequest.headers,body:Z.req.rawRequest.body};let j={timestamp:new Date(Date.now()).toISOString(),env:Bun.env.NODE_ENV,level:$,message:O,metadata:{...f,...T}},W="";try{W=JSON.stringify(j)}catch(z){console.log("Error parsing log object",z)}try{let z=this.config.onLogCreated(j);if(z instanceof Promise)z.catch((J)=>console.error("Error in onLogCreated",J))}catch(z){console.error("Error in onLogCreated",z)}if(!this.writer)return;this.writerSize+=W.length,this.fileSize+=W.length;try{this.writer.write(W),this.writer.write(`
|
|
4
|
+
`),this.tryFlush()}catch(z){console.error("Error writing log",z)}}async tryFlush(){if(this.fileSize>this.config.maxFileSize){if(!this.isCreatingFile)await this.newLogFile()}if(this.writerSize>this.config.maxFileSize/2)await this.writer.flush(),this.writerSize=0,await this.newLogFile();else clearTimeout(this.flushTimeout),this.flushTimeout=setTimeout(async()=>{await this.writer.flush(),this.writerSize=0},100)}}class Nj extends x0{middlewares=["cache:private,0"];routes={"/live":this.get(async()=>{let $=Bun.file(K(vO).currentLogFilePath);return new Response(await $.text(),{headers:{"Content-Type":"text/plain"}})})}}function GC($){let O=new Map;for(let T of $)if(typeof T==="string"){let[Z,f=""]=T.split(":");if(Z.startsWith("-")){if(O.has(Z.replace("-","")))O.delete(Z.replace("-",""))}else O.set(Z,f.split(",").filter(Boolean))}else O.set(T,[]);return O}class gO{config;static token="middleware";constructor($){this.config=$}get aliases(){return this.config.aliases}assertGlobalMiddleware(){for(let $ of this.config.global){if(typeof $!=="string")continue;let[O]=$.split(":");if(O.startsWith("-"))throw Error(`Global middleware "${$}" cancels an alias, but nothing is inherited into the global list. Remove it.`);if(!this.aliases[O])throw Error(`Global middleware "${O}" 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 O=new E;return Array.from(GC($).entries()).map(([T,Z])=>{if(typeof T==="string"){let f=this.aliases[T];if(f){let j=new f(O);return()=>j.run.call(j,...Z)}}else{if(lO(T)){let f=new T(O);return f.run.bind(f)}return T}}).filter(Boolean).reduce((T,Z)=>{return async()=>{return{...await T(),...await Z()}}},()=>Promise.resolve({}))()}}function fX($){return $}function u2(){return{onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{}}}function s2(){return{partialRendering:!0,onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{},onStreamComplete:()=>{}}}function BC($){return"run"in $}function KC($){return Object.hasOwn($,"get")||Object.hasOwn($,"post")||Object.hasOwn($,"put")||Object.hasOwn($,"delete")}function LC($){return Object.hasOwn($,"first")&&Object.hasOwn($,"second")}function QC($){if("__brand"in $)return $.__brand==="ApiRouter";return!1}function SC($){if("__internal_brand"in $)return $.__internal_brand==="ProxyHandler";return!1}function MC($){if("__internal_brand"in $)return $.__internal_brand==="StreamHandler";return!1}function Ej($,O="",T=[]){let Z={};function f(j,W,z,J,C){let F=j==="/"?"":j,D=O==="/"?"":O,Y=(`${D}${F}`===""?"/":`${D}${F}`).replaceAll("//","/");if(!Z[Y])Z[Y]={};Z[Y][W.toUpperCase()]={exec:z,middleware:[...T,...J],...C?{source:C}:{}},Z[Y].OPTIONS={exec:()=>{let X=new E().ctx().headers;return new Response(null,{headers:X,status:204})},middleware:[]}}for(let[j,W]of Object.entries($)){if(SC(W)){let z=W;for(let J of["GET","POST","PUT","DELETE"])f(j,J,z.run.bind(z),[]);continue}if(BC(W)){let z=W,J=z.method,C=z.middlewares,F=z.run.bind(z);if(f(j,J,F,C,z.source),MC(W))f(j,"HEAD",F,C,z.source)}if(KC(W))for(let[z,J]of Object.entries(W)){let C=J.middlewares,F=J.run.bind(J);f(j,z,F,C,J.source)}if(QC(W)){let z=new W,J=Ej(z.routes,`${O}${j}`,z.middlewares);for(let[C,F]of Object.entries(J))Z[C.replaceAll("//","/")]=F}if(LC(W)){let{first:z,second:J}=W;for(let[C,F]of Object.entries(z)){let D=F.middlewares,Y=F.run.bind(F),[U,...X]=j.split("/").reverse();if(!U.startsWith(":"))throw Error("Resource route must end with a dynamic segment");f(X.reverse().join("/"),C,Y,D,F.source)}for(let[C,F]of Object.entries(J)){let D=F.middlewares,Y=F.run.bind(F);f(j,C,Y,D,F.source)}}}return Object.fromEntries(Object.entries(Z).sort(([j],[W])=>{let z=j.split("/").length+j.split(":").length,J=W.split("/").length+W.split(":").length;return z-J}))}function FZ($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function Pj($,O){if($==="/")return O;if(O==="/")return $;return`${$}${O}`}function _j($){let O=FZ($);return O.length>1?O.replace(/\/$/,""):O}function n2($,O){return O.map((T)=>({...T,path:_j(Pj($,T.path))}))}function YZ($){let O={};for(let[T,Z]of Object.entries($))if("run"in Z){let f=Z;if("children"in f){let j=new f.children,W=YZ(j.routes);for(let[z,{exec:J,middleware:C,segments:F,features:D}]of Object.entries(W)){let Y=Pj(T,z),U=(X)=>f.run.call(f,X,T);O[FZ(Y)]={exec:[U,...J],middleware:[...f.middlewares,...C],features:[...f.featureGates,...D],viewPath:f.viewPath,segments:[{path:_j(T),viewPath:f.viewPath,...f.alwaysRuns?{alwaysRun:!0}:{}},...n2(T,F)]}}}else{let j=(W)=>f.run.call(f,W,T);O[FZ(T)]={exec:[j],middleware:f.middlewares,features:f.featureGates,viewPath:f.viewPath,segments:[{path:_j(T),viewPath:f.viewPath}]}}}else{let f=new Z,j=YZ(f.routes);for(let[W,{exec:z,middleware:J,viewPath:C,segments:F,features:D}]of Object.entries(j)){let Y=Pj(T,W);O[FZ(Y)]={exec:z,middleware:[...f.middlewares,...J],features:[...f.featureGates,...D],viewPath:C,segments:n2(T,F)}}}return Object.fromEntries(Object.entries(O).sort(([T],[Z])=>{let f=T.split("/").length+T.split(":").length,j=Z.split("/").length+Z.split(":").length;return f-j}))}var VC=Object.defineProperty,I=($,O)=>VC($,"name",{value:O,configurable:!0}),c$=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor($,O,T,Z,f,j){this.type=$,this.name=O,this.prefix=T,this.value=Z,this.suffix=f,this.modifier=j}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};I(c$,"Part");var IC=/[$_\p{ID_Start}]/u,xC=/[$_\u200C\u200D\p{ID_Continue}]/u,Hj=".*";function a2($,O){return(O?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test($)}I(a2,"isASCII");function vj($,O=!1){let T=[],Z=0;for(;Z<$.length;){let f=$[Z],j=I(function(W){if(!O)throw TypeError(W);T.push({type:"INVALID_CHAR",index:Z,value:$[Z++]})},"ErrorOrInvalid");if(f==="*"){T.push({type:"ASTERISK",index:Z,value:$[Z++]});continue}if(f==="+"||f==="?"){T.push({type:"OTHER_MODIFIER",index:Z,value:$[Z++]});continue}if(f==="\\"){T.push({type:"ESCAPED_CHAR",index:Z++,value:$[Z++]});continue}if(f==="{"){T.push({type:"OPEN",index:Z,value:$[Z++]});continue}if(f==="}"){T.push({type:"CLOSE",index:Z,value:$[Z++]});continue}if(f===":"){let W="",z=Z+1;for(;z<$.length;){let J=$.substr(z,1);if(z===Z+1&&IC.test(J)||z!==Z+1&&xC.test(J)){W+=$[z++];continue}break}if(!W){j(`Missing parameter name at ${Z}`);continue}T.push({type:"NAME",index:Z,value:W}),Z=z;continue}if(f==="("){let W=1,z="",J=Z+1,C=!1;if($[J]==="?"){j(`Pattern cannot start with "?" at ${J}`);continue}for(;J<$.length;){if(!a2($[J],!1)){j(`Invalid character '${$[J]}' at ${J}.`),C=!0;break}if($[J]==="\\"){z+=$[J++]+$[J++];continue}if($[J]===")"){if(W--,W===0){J++;break}}else if($[J]==="("&&(W++,$[J+1]!=="?")){j(`Capturing groups are not allowed at ${J}`),C=!0;break}z+=$[J++]}if(C)continue;if(W){j(`Unbalanced pattern at ${Z}`);continue}if(!z){j(`Missing pattern at ${Z}`);continue}T.push({type:"REGEX",index:Z,value:z}),Z=J;continue}T.push({type:"CHAR",index:Z,value:$[Z++]})}return T.push({type:"END",index:Z,value:""}),T}I(vj,"lexer");function gj($,O={}){let T=vj($);O.delimiter??="/#?",O.prefixes??="./";let Z=`[^${b0(O.delimiter)}]+?`,f=[],j=0,W=0,z="",J=new Set,C=I((Q)=>{if(W<T.length&&T[W].type===Q)return T[W++].value},"tryConsume"),F=I(()=>C("OTHER_MODIFIER")??C("ASTERISK"),"tryConsumeModifier"),D=I((Q)=>{let N=C(Q);if(N!==void 0)return N;let{type:P,index:S}=T[W];throw TypeError(`Unexpected ${P} at ${S}, expected ${Q}`)},"mustConsume"),Y=I(()=>{let Q="",N;for(;N=C("CHAR")??C("ESCAPED_CHAR");)Q+=N;return Q},"consumeText"),U=I((Q)=>Q,"DefaultEncodePart"),X=O.encodePart||U,G="",B=I((Q)=>{G+=Q},"appendToPendingFixedValue"),L=I(()=>{G.length&&(f.push(new c$(3,"","",X(G),"",3)),G="")},"maybeAddPartFromPendingFixedValue"),M=I((Q,N,P,S,V)=>{let _=3;switch(V){case"?":_=1;break;case"*":_=0;break;case"+":_=2;break}if(!N&&!P&&_===3){B(Q);return}if(L(),!N&&!P){if(!Q)return;f.push(new c$(3,"","",X(Q),"",_));return}let A;P?P==="*"?A=Hj:A=P:A=Z;let T0=2;A===Z?(T0=1,A=""):A===Hj&&(T0=0,A="");let g;if(N?g=N:P&&(g=j++),J.has(g))throw TypeError(`Duplicate name '${g}'.`);J.add(g),f.push(new c$(T0,g,X(Q),A,X(S),_))},"addPart");for(;W<T.length;){let Q=C("CHAR"),N=C("NAME"),P=C("REGEX");if(!N&&!P&&(P=C("ASTERISK")),N||P){let V=Q??"";O.prefixes.indexOf(V)===-1&&(B(V),V=""),L();let _=F();M(V,N,P,"",_);continue}let S=Q??C("ESCAPED_CHAR");if(S){B(S);continue}if(C("OPEN")){let V=Y(),_=C("NAME"),A=C("REGEX");!_&&!A&&(A=C("ASTERISK"));let T0=Y();D("CLOSE");let g=F();M(V,_,A,T0,g);continue}L(),D("END")}return f}I(gj,"parse");function b0($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}I(b0,"escapeString");function wj($){return $&&$.ignoreCase?"ui":"u"}I(wj,"flags");function o2($,O,T){return Rj(gj($,T),O,T)}I(o2,"stringToRegexp");function Z$($){switch($){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}I(Z$,"modifierToString");function Rj($,O,T={}){T.delimiter??="/#?",T.prefixes??="./",T.sensitive??=!1,T.strict??=!1,T.end??=!0,T.start??=!0,T.endsWith="";let Z=T.start?"^":"";for(let z of $){if(z.type===3){z.modifier===3?Z+=b0(z.value):Z+=`(?:${b0(z.value)})${Z$(z.modifier)}`;continue}O&&O.push(z.name);let J=`[^${b0(T.delimiter)}]+?`,C=z.value;if(z.type===1?C=J:z.type===0&&(C=Hj),!z.prefix.length&&!z.suffix.length){z.modifier===3||z.modifier===1?Z+=`(${C})${Z$(z.modifier)}`:Z+=`((?:${C})${Z$(z.modifier)})`;continue}if(z.modifier===3||z.modifier===1){Z+=`(?:${b0(z.prefix)}(${C})${b0(z.suffix)})`,Z+=Z$(z.modifier);continue}Z+=`(?:${b0(z.prefix)}`,Z+=`((?:${C})(?:`,Z+=b0(z.suffix),Z+=b0(z.prefix),Z+=`(?:${C}))*)${b0(z.suffix)})`,z.modifier===0&&(Z+="?")}let f=`[${b0(T.endsWith)}]|$`,j=`[${b0(T.delimiter)}]`;if(T.end)return T.strict||(Z+=`${j}?`),T.endsWith.length?Z+=`(?=${f})`:Z+="$",new RegExp(Z,wj(T));T.strict||(Z+=`(?:${j}(?=${f}))?`);let W=!1;if($.length){let z=$[$.length-1];z.type===3&&z.modifier===3&&(W=T.delimiter.indexOf(z)>-1)}return W||(Z+=`(?=${j}|${f})`),new RegExp(Z,wj(T))}I(Rj,"partsToRegexp");var g1={delimiter:"",prefixes:"",sensitive:!0,strict:!0},NC={delimiter:".",prefixes:"",sensitive:!0,strict:!0},EC={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function r2($,O){return $.length?$[0]==="/"?!0:!O||$.length<2?!1:($[0]=="\\"||$[0]=="{")&&$[1]=="/":!1}I(r2,"isAbsolutePathname");function kj($,O){return $.startsWith(O)?$.substring(O.length,$.length):$}I(kj,"maybeStripPrefix");function t2($,O){return $.endsWith(O)?$.substr(0,$.length-O.length):$}I(t2,"maybeStripSuffix");function mj($){return!$||$.length<2?!1:$[0]==="["||($[0]==="\\"||$[0]==="{")&&$[1]==="["}I(mj,"treatAsIPv6Hostname");var e2=["ftp","file","http","https","ws","wss"];function qj($){if(!$)return!0;for(let O of e2)if($.test(O))return!0;return!1}I(qj,"isSpecialScheme");function $4($,O){if($=kj($,"#"),O||$==="")return $;let T=new URL("https://example.com");return T.hash=$,T.hash?T.hash.substring(1,T.hash.length):""}I($4,"canonicalizeHash");function O4($,O){if($=kj($,"?"),O||$==="")return $;let T=new URL("https://example.com");return T.search=$,T.search?T.search.substring(1,T.search.length):""}I(O4,"canonicalizeSearch");function T4($,O){return O||$===""?$:mj($)?cj($):pj($)}I(T4,"canonicalizeHostname");function Z4($,O){if(O||$==="")return $;let T=new URL("https://example.com");return T.password=$,T.password}I(Z4,"canonicalizePassword");function f4($,O){if(O||$==="")return $;let T=new URL("https://example.com");return T.username=$,T.username}I(f4,"canonicalizeUsername");function j4($,O,T){if(T||$==="")return $;if(O&&!e2.includes(O))return new URL(`${O}:${$}`).pathname;let Z=$[0]=="/";return $=new URL(Z?$:"/-"+$,"https://example.com").pathname,Z||($=$.substring(2,$.length)),$}I(j4,"canonicalizePathname");function W4($,O,T){return yj(O)===$&&($=""),T||$===""?$:ij($)}I(W4,"canonicalizePort");function z4($,O){return $=t2($,":"),O||$===""?$:DZ($)}I(z4,"canonicalizeProtocol");function yj($){switch($){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}I(yj,"defaultPortForProtocol");function DZ($){if($==="")return $;if(/^[-+.A-Za-z0-9]*$/.test($))return $.toLowerCase();throw TypeError(`Invalid protocol '${$}'.`)}I(DZ,"protocolEncodeCallback");function J4($){if($==="")return $;let O=new URL("https://example.com");return O.username=$,O.username}I(J4,"usernameEncodeCallback");function C4($){if($==="")return $;let O=new URL("https://example.com");return O.password=$,O.password}I(C4,"passwordEncodeCallback");function pj($){if($==="")return $;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test($))throw TypeError(`Invalid hostname '${$}'`);let O=new URL("https://example.com");return O.hostname=$,O.hostname}I(pj,"hostnameEncodeCallback");function cj($){if($==="")return $;if(/[^0-9a-fA-F[\]:]/g.test($))throw TypeError(`Invalid IPv6 hostname '${$}'`);return $.toLowerCase()}I(cj,"ipv6HostnameEncodeCallback");function ij($){if($===""||/^[0-9]*$/.test($)&&parseInt($)<=65535)return $;throw TypeError(`Invalid port '${$}'.`)}I(ij,"portEncodeCallback");function F4($){if($==="")return $;let O=new URL("https://example.com");return O.pathname=$[0]!=="/"?"/-"+$:$,$[0]!=="/"?O.pathname.substring(2,O.pathname.length):O.pathname}I(F4,"standardURLPathnameEncodeCallback");function Y4($){return $===""?$:new URL(`data:${$}`).pathname}I(Y4,"pathURLPathnameEncodeCallback");function D4($){if($==="")return $;let O=new URL("https://example.com");return O.search=$,O.search.substring(1,O.search.length)}I(D4,"searchEncodeCallback");function X4($){if($==="")return $;let O=new URL("https://example.com");return O.hash=$,O.hash.substring(1,O.hash.length)}I(X4,"hashEncodeCallback");var U4=class{#j;#Z=[];#O={};#$=0;#f=1;#C=0;#z=0;#X=0;#U=0;#G=!1;constructor($){this.#j=$}get result(){return this.#O}parse(){for(this.#Z=vj(this.#j,!0);this.#$<this.#Z.length;this.#$+=this.#f){if(this.#f=1,this.#Z[this.#$].type==="END"){if(this.#z===0){this.#Q(),this.#F()?this.#T(9,1):this.#Y()?this.#T(8,1):this.#T(7,0);continue}else if(this.#z===2){this.#D(5);continue}this.#T(10,0);break}if(this.#X>0)if(this.#E())this.#X-=1;else continue;if(this.#N()){this.#X+=1;continue}switch(this.#z){case 0:this.#S()&&this.#D(1);break;case 1:if(this.#S()){this.#A();let $=7,O=1;this.#V()?($=2,O=3):this.#G&&($=2),this.#T($,O)}break;case 2:this.#K()?this.#D(3):(this.#L()||this.#Y()||this.#F())&&this.#D(5);break;case 3:this.#I()?this.#T(4,1):this.#K()&&this.#T(5,1);break;case 4:this.#K()&&this.#T(5,1);break;case 5:this.#P()?this.#U+=1:this.#_()&&(this.#U-=1),this.#x()&&!this.#U?this.#T(6,1):this.#L()?this.#T(7,0):this.#Y()?this.#T(8,1):this.#F()&&this.#T(9,1);break;case 6:this.#L()?this.#T(7,0):this.#Y()?this.#T(8,1):this.#F()&&this.#T(9,1);break;case 7:this.#Y()?this.#T(8,1):this.#F()&&this.#T(9,1);break;case 8:this.#F()&&this.#T(9,1);break;case 9:break;case 10:break}}this.#O.hostname!==void 0&&this.#O.port===void 0&&(this.#O.port="")}#T($,O){switch(this.#z){case 0:break;case 1:this.#O.protocol=this.#J();break;case 2:break;case 3:this.#O.username=this.#J();break;case 4:this.#O.password=this.#J();break;case 5:this.#O.hostname=this.#J();break;case 6:this.#O.port=this.#J();break;case 7:this.#O.pathname=this.#J();break;case 8:this.#O.search=this.#J();break;case 9:this.#O.hash=this.#J();break;case 10:break}this.#z!==0&&$!==10&&([1,2,3,4].includes(this.#z)&&[6,7,8,9].includes($)&&(this.#O.hostname??=""),[1,2,3,4,5,6].includes(this.#z)&&[8,9].includes($)&&(this.#O.pathname??=this.#G?"/":""),[1,2,3,4,5,6,7].includes(this.#z)&&$===9&&(this.#O.search??="")),this.#M($,O)}#M($,O){this.#z=$,this.#C=this.#$+O,this.#$+=O,this.#f=0}#Q(){this.#$=this.#C,this.#f=0}#D($){this.#Q(),this.#z=$}#B($){return $<0&&($=this.#Z.length-$),$<this.#Z.length?this.#Z[$]:this.#Z[this.#Z.length-1]}#W($,O){let T=this.#B($);return T.value===O&&(T.type==="CHAR"||T.type==="ESCAPED_CHAR"||T.type==="INVALID_CHAR")}#S(){return this.#W(this.#$,":")}#V(){return this.#W(this.#$+1,"/")&&this.#W(this.#$+2,"/")}#K(){return this.#W(this.#$,"@")}#I(){return this.#W(this.#$,":")}#x(){return this.#W(this.#$,":")}#L(){return this.#W(this.#$,"/")}#Y(){if(this.#W(this.#$,"?"))return!0;if(this.#Z[this.#$].value!=="?")return!1;let $=this.#B(this.#$-1);return $.type!=="NAME"&&$.type!=="REGEX"&&$.type!=="CLOSE"&&$.type!=="ASTERISK"}#F(){return this.#W(this.#$,"#")}#N(){return this.#Z[this.#$].type=="OPEN"}#E(){return this.#Z[this.#$].type=="CLOSE"}#P(){return this.#W(this.#$,"[")}#_(){return this.#W(this.#$,"]")}#J(){let $=this.#Z[this.#$],O=this.#B(this.#C).index;return this.#j.substring(O,$.index)}#A(){let $={};Object.assign($,g1),$.encodePart=DZ;let O=o2(this.#J(),void 0,$);this.#G=qj(O)}};I(U4,"Parser");var Aj=["protocol","username","password","hostname","port","pathname","search","hash"],v1="*";function bj($,O){if(typeof $!="string")throw TypeError("parameter 1 is not of type 'string'.");let T=new URL($,O);return{protocol:T.protocol.substring(0,T.protocol.length-1),username:T.username,password:T.password,hostname:T.hostname,port:T.port,pathname:T.pathname,search:T.search!==""?T.search.substring(1,T.search.length):void 0,hash:T.hash!==""?T.hash.substring(1,T.hash.length):void 0}}I(bj,"extractValues");function O1($,O){return O?p$($):$}I(O1,"processBaseURLString");function y$($,O,T){let Z;if(typeof O.baseURL=="string")try{Z=new URL(O.baseURL),O.protocol===void 0&&($.protocol=O1(Z.protocol.substring(0,Z.protocol.length-1),T)),!T&&O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.username===void 0&&($.username=O1(Z.username,T)),!T&&O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.username===void 0&&O.password===void 0&&($.password=O1(Z.password,T)),O.protocol===void 0&&O.hostname===void 0&&($.hostname=O1(Z.hostname,T)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&($.port=O1(Z.port,T)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.pathname===void 0&&($.pathname=O1(Z.pathname,T)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.pathname===void 0&&O.search===void 0&&($.search=O1(Z.search.substring(1,Z.search.length),T)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.pathname===void 0&&O.search===void 0&&O.hash===void 0&&($.hash=O1(Z.hash.substring(1,Z.hash.length),T))}catch{throw TypeError(`invalid baseURL '${O.baseURL}'.`)}if(typeof O.protocol=="string"&&($.protocol=z4(O.protocol,T)),typeof O.username=="string"&&($.username=f4(O.username,T)),typeof O.password=="string"&&($.password=Z4(O.password,T)),typeof O.hostname=="string"&&($.hostname=T4(O.hostname,T)),typeof O.port=="string"&&($.port=W4(O.port,$.protocol,T)),typeof O.pathname=="string"){if($.pathname=O.pathname,Z&&!r2($.pathname,T)){let f=Z.pathname.lastIndexOf("/");f>=0&&($.pathname=O1(Z.pathname.substring(0,f+1),T)+$.pathname)}$.pathname=j4($.pathname,$.protocol,T)}return typeof O.search=="string"&&($.search=O4(O.search,T)),typeof O.hash=="string"&&($.hash=$4(O.hash,T)),$}I(y$,"applyInit");function p$($){return $.replace(/([+*?:{}()\\])/g,"\\$1")}I(p$,"escapePatternString");function G4($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}I(G4,"escapeRegexpString");function B4($,O){O.delimiter??="/#?",O.prefixes??="./",O.sensitive??=!1,O.strict??=!1,O.end??=!0,O.start??=!0,O.endsWith="";let T=".*",Z=`[^${G4(O.delimiter)}]+?`,f=/[$_\u200C\u200D\p{ID_Continue}]/u,j="";for(let W=0;W<$.length;++W){let z=$[W];if(z.type===3){if(z.modifier===3){j+=p$(z.value);continue}j+=`{${p$(z.value)}}${Z$(z.modifier)}`;continue}let J=z.hasCustomName(),C=!!z.suffix.length||!!z.prefix.length&&(z.prefix.length!==1||!O.prefixes.includes(z.prefix)),F=W>0?$[W-1]:null,D=W<$.length-1?$[W+1]:null;if(!C&&J&&z.type===1&&z.modifier===3&&D&&!D.prefix.length&&!D.suffix.length)if(D.type===3){let Y=D.value.length>0?D.value[0]:"";C=f.test(Y)}else C=!D.hasCustomName();if(!C&&!z.prefix.length&&F&&F.type===3){let Y=F.value[F.value.length-1];C=O.prefixes.includes(Y)}C&&(j+="{"),j+=p$(z.prefix),J&&(j+=`:${z.name}`),z.type===2?j+=`(${z.value})`:z.type===1?J||(j+=`(${Z})`):z.type===0&&(!J&&(!F||F.type===3||F.modifier!==3||C||z.prefix!=="")?j+="*":j+=`(${T})`),z.type===1&&J&&z.suffix.length&&f.test(z.suffix[0])&&(j+="\\"),j+=p$(z.suffix),C&&(j+="}"),z.modifier!==3&&(j+=Z$(z.modifier))}return j}I(B4,"partsToPattern");var hj=class{#j;#Z={};#O={};#$={};#f={};#C=!1;constructor($={},O,T){try{let Z;if(typeof O=="string"?Z=O:T=O,typeof $=="string"){let z=new U4($);if(z.parse(),$=z.result,Z===void 0&&typeof $.protocol!="string")throw TypeError("A base URL must be provided for a relative constructor string.");$.baseURL=Z}else{if(!$||typeof $!="object")throw TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(Z)throw TypeError("parameter 1 is not of type 'string'.")}typeof T>"u"&&(T={ignoreCase:!1});let f={ignoreCase:T.ignoreCase===!0},j={pathname:v1,protocol:v1,username:v1,password:v1,hostname:v1,port:v1,search:v1,hash:v1};this.#j=y$(j,$,!0),yj(this.#j.protocol)===this.#j.port&&(this.#j.port="");let W;for(W of Aj){if(!(W in this.#j))continue;let z={},J=this.#j[W];switch(this.#O[W]=[],W){case"protocol":Object.assign(z,g1),z.encodePart=DZ;break;case"username":Object.assign(z,g1),z.encodePart=J4;break;case"password":Object.assign(z,g1),z.encodePart=C4;break;case"hostname":Object.assign(z,NC),mj(J)?z.encodePart=cj:z.encodePart=pj;break;case"port":Object.assign(z,g1),z.encodePart=ij;break;case"pathname":qj(this.#Z.protocol)?(Object.assign(z,EC,f),z.encodePart=F4):(Object.assign(z,g1,f),z.encodePart=Y4);break;case"search":Object.assign(z,g1,f),z.encodePart=D4;break;case"hash":Object.assign(z,g1,f),z.encodePart=X4;break}try{this.#f[W]=gj(J,z),this.#Z[W]=Rj(this.#f[W],this.#O[W],z),this.#$[W]=B4(this.#f[W],z),this.#C=this.#C||this.#f[W].some((C)=>C.type===2)}catch{throw TypeError(`invalid ${W} pattern '${this.#j[W]}'.`)}}}catch(Z){throw TypeError(`Failed to construct 'URLPattern': ${Z.message}`)}}get[Symbol.toStringTag](){return"URLPattern"}test($={},O){let T={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&O)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return!1;try{typeof $=="object"?T=y$(T,$,!1):T=y$(T,bj($,O),!1)}catch{return!1}let Z;for(Z of Aj)if(!this.#Z[Z].exec(T[Z]))return!1;return!0}exec($={},O){let T={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&O)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return;try{typeof $=="object"?T=y$(T,$,!1):T=y$(T,bj($,O),!1)}catch{return null}let Z={};O?Z.inputs=[$,O]:Z.inputs=[$];let f;for(f of Aj){let j=this.#Z[f].exec(T[f]);if(!j)return null;let W={};for(let[z,J]of this.#O[f].entries())if(typeof J=="string"||typeof J=="number"){let C=j[z+1];W[J]=C}Z[f]={input:T[f]??"",groups:W}}return Z}static compareComponent($,O,T){let Z=I((z,J)=>{for(let C of["type","modifier","prefix","value","suffix"]){if(z[C]<J[C])return-1;if(z[C]===J[C])continue;return 1}return 0},"comparePart"),f=new c$(3,"","","","",3),j=new c$(0,"","","","",3),W=I((z,J)=>{let C=0;for(;C<Math.min(z.length,J.length);++C){let F=Z(z[C],J[C]);if(F)return F}return z.length===J.length?0:Z(z[C]??f,J[C]??f)},"comparePartList");return!O.#$[$]&&!T.#$[$]?0:O.#$[$]&&!T.#$[$]?W(O.#f[$],[j]):!O.#$[$]&&T.#$[$]?W([j],T.#f[$]):W(O.#f[$],T.#f[$])}get protocol(){return this.#$.protocol}get username(){return this.#$.username}get password(){return this.#$.password}get hostname(){return this.#$.hostname}get port(){return this.#$.port}get pathname(){return this.#$.pathname}get search(){return this.#$.search}get hash(){return this.#$.hash}get hasRegExpGroups(){return this.#C}};I(hj,"URLPattern");function RO($,O){for(let[T,Z]of Object.entries($)){let f=new hj({pathname:T});if(f.test({pathname:O}))return{routePath:T,params:f.exec({pathname:O})?.pathname.groups??{},route:Z}}return null}var f$={startIndex:0,carriedViews:[]};function K4($,O){let T=s($.path,O);return T.includes("*")?null:T}function PC($,O){if(!$)return f$;if($.search!==O.search)return f$;let T=Math.min($.segments.length,O.segments.length-1),Z=0;while(Z<T){let f=$.segments[Z],j=O.segments[Z];if(j.alwaysRun)break;if(f.viewPath!==j.viewPath)break;let W=K4(f,$.params),z=K4(j,O.params);if(W===null||z===null||W!==z)break;Z++}if(Z===0)return f$;return{startIndex:Z,carriedViews:O.segments.slice(0,Z).map(({viewPath:f})=>f)}}function _C($,O){let[,T,...Z]=$.split("/");if(!O.includes(T))return $;let f=`/${Z.join("/")}`;return f==="/"?"/":f.replace(/\/$/,"")}function L4($){let{flatViewRoutes:O,supportedLocales:T,from:Z,origin:f,to:j}=$;if(!Z)return f$;let W;try{W=new URL(Z,f)}catch{return f$}if(W.origin!==f)return f$;let z=RO(O,_C(W.pathname,T));if(!z)return f$;return PC({segments:z.route.segments,params:z.params,search:W.search},j)}var lj="x-gemi-from";import{createElement as n$,Fragment as rC}from"react";function AC($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function XZ($){let O={};for(let[T,Z]of Object.entries($))if("run"in Z){let f=Z.viewPath;if("children"in Z){O[T]=[f];let j=new Z.children,W=XZ(j.routes);for(let[z,J]of Object.entries(W)){let C=T==="/"?z:`${T}${z}`,F=z==="/"&&T!=="/"?T:C;O[F]=[f,...J]}if(O[T].length===1)delete O[T]}else O[T]=[f]}else{let f=new Z,j=XZ(f.routes);for(let[W,z]of Object.entries(j)){let J=T==="/"?W:`${T}${W}`,C=W==="/"&&T!=="/"?T:J;O[C]=z}}return Object.fromEntries(Object.entries(O).map(([T,Z])=>[AC(T),Z]))}function UZ($){let O=[];for(let[T,Z]of Object.entries($))if("run"in Z){let f=Z.viewPath;if(f==="__")continue;if(f==="REDIRECT")continue;if(f==="FILE")continue;if("children"in Z){let j=new Z.children,W=UZ(j.routes);O.push([f,W])}else O.push([f,[]])}else{let f=new Z,j=UZ(f.routes);O.push(...j)}return O}function dj($){let O=[];for(let[T,Z]of $)O.push(T,...dj(Z).flat());return Array.from(new Set(O))}class R1 extends O0{static getFacadeAccessor(){return vO}static debug($,O){this.getFacadeRoot().log("debug",$,O)}static info($,O){this.getFacadeRoot().log("info",$,O)}static notice($,O){this.getFacadeRoot().log("notice",$,O)}static warning($,O){this.getFacadeRoot().log("warning",$,O)}static error($,O){this.getFacadeRoot().log("error",$,O)}static critical($,O){this.getFacadeRoot().log("critical",$,O)}static alert($,O){this.getFacadeRoot().log("alert",$,O)}static emergency($,O){this.getFacadeRoot().log("emergency",$,O)}}class i$ extends O0{static getFacadeAccessor(){return n}static getSupportedLocales(){return this.getFacadeRoot().supportedLocales}static getDefaultLocale(){return this.getFacadeRoot().defaultLocale}static locale(){let $=this.getFacadeRoot(),O=x.getStore();if(O)return O.locale??$.detectLocale(O.req);return $.defaultLocale}static setLocale($=i$.locale()){let O=this.getFacadeRoot(),T=$;if(!O.supportedLocales.includes($))T=O.defaultLocale;let Z=x.getStore();return Z.setCookie("i18n-locale",T,{expires:new Date(Date.now()+31536000000),secure:!1,httpOnly:!1}),Z.setLocale(T),T}}class uj{id;static token="kernel.id";constructor($=crypto.randomUUID()){this.id=$}}var HC=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),wC=new Set(["svg","math"]);function Q4($){return $===32||$===9||$===10||$===12||$===13}function S4($){return $>=65&&$<=90||$>=97&&$<=122}function GZ($){return $>=65&&$<=90?$+32:$}function M4(){let $="data",O="",T=!1,Z="",f=0,j=0,W=!1,z=0,J=0,C=()=>$==="data"&&z===0&&J===0,F=()=>{if(!T&&HC.has(O)){$="rawText",Z=`</${O}`,f=0,O="";return}if($="data",O==="template")if(T)z=Math.max(0,z-1);else z+=1;else if(wC.has(O)){if(T)J=Math.max(0,J-1);else if(!W)J+=1}O=""},D=(Y)=>{switch($){case"data":if(Y===60)$="tagOpen";return;case"tagOpen":if(Y===33)$="bang",j=0;else if(Y===47)$="endTagOpen";else if(S4(Y))$="tagName",T=!1,W=!1,O=String.fromCharCode(GZ(Y));else if(Y===63)$="bogus";else if(Y===60)$="tagOpen";else $="data";return;case"endTagOpen":if(S4(Y))$="tagName",T=!0,W=!1,O=String.fromCharCode(GZ(Y));else if(Y===62)$="data";else $="bogus";return;case"tagName":if(Q4(Y)||Y===47)$="inTag",W=Y===47;else if(Y===62)F();else O+=String.fromCharCode(GZ(Y));return;case"inTag":if(Y===62){F();return}if(W=Y===47,Y===34)$="attrDouble";else if(Y===39)$="attrSingle";return;case"attrDouble":if(Y===34)$="inTag";W=!1;return;case"attrSingle":if(Y===39)$="inTag";W=!1;return;case"bang":if(Y===45){if(j+=1,j===2)$="comment",j=0}else if(Y===62)$="data";else $="bogus";return;case"bogus":if(Y===62)$="data";return;case"comment":if(Y===45)j=j<2?j+1:2;else if(Y===62&&j>=2)$="data",j=0;else j=0;return;case"rawText":{if(f<Z.length){if(GZ(Y)===Z.charCodeAt(f))f+=1;else f=Y===60?1:0;return}if(Y===62)$="data",O="";else if(Q4(Y)||Y===47)$="inTag",O="";else f=Y===60?1:0;return}}};return{scanToInsertionPoint(Y){for(let U=0;U<Y.length;U++){if(C())return U;D(Y[U])}return Y.length},write(Y){for(let U=0;U<Y.length;U++)D(Y[U])},isSafe:C}}function j$($){let O=JSON.stringify($);if(O===void 0)return"undefined";return O.replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function bC($){return`<script>(self.__GEMI_STREAM__=self.__GEMI_STREAM__||[]).push(${j$([$.path,$.variantKey,$.data])})</script>`}function vC($){return`<script>(self.__GEMI_DICT__=self.__GEMI_DICT__||[]).push(${j$([$.id,$.locale,$.strings])})</script>`}function sj($,O,T={},Z){let f=new TextEncoder,j=[],W=!1,z=!1,J=()=>{if(z)return;z=!0,T.onClose?.()};O.onSettle((X)=>{if(X.status!=="resolved")return;j.push(bC(X))}),Z?.onUse((X)=>{j.push(vC(X))});let C=$.getReader(),F=M4(),D=(X,G)=>{X.enqueue(G),T.onChunk?.(G)},Y=(X)=>{while(j.length>0){let G=f.encode(j.shift());F.write(G),D(X,G)}},U=(X,G)=>{if(j.length===0){F.write(G),D(X,G);return}let B=F.scanToInsertionPoint(G);if(B>0)D(X,G.subarray(0,B));if(F.isSafe())Y(X);let L=G.subarray(B);if(L.length>0)F.write(L),D(X,L)};return new ReadableStream({async pull(X){let G;try{G=await C.read()}catch(M){throw J(),M}let{done:B,value:L}=G;if(B){Y(X),X.close(),J();return}if(!W){if(W=!0,F.write(L),D(X,L),T.onShell?.(),F.isSafe())Y(X);return}U(X,L)},cancel(X){return J(),C.cancel(X)}})}var gC=/bot|crawler|spider|crawling|slurp|bingpreview|mediapartners|headless|lighthouse|prerender|facebookexternalhit|whatsapp|telegram|discord|twitterbot|linkedinbot/i;function BZ($){if(!$)return!1;return gC.test($)}async function I4($,O=()=>{}){let T=x.getStore(),Z=T?.req??null,f=null;if(Z?.rawRequest?.url)try{f=new URL(Z.rawRequest.url).pathname}catch{f=null}return{user:T?.user??null,attributes:await RC($,O),request:{path:f,routePath:Z?.routePath??null,locale:T?.locale??null},anonymousId:V4(),isBot:BZ(Z?.rawRequest?.headers?.get("user-agent")??null),now:new Date}}function x4($){return{user:$.user??null,attributes:$.attributes??{},request:{path:null,routePath:null,locale:null},anonymousId:$.subjectId??null,isBot:!1,now:new Date}}async function RC($,O){if(!$.context)return{};try{let T=x.getStore();return await $.context(T?.req??null)??{}}catch(T){return O(`The \`context\` hook in app/config/features.ts threw; evaluating with no attributes. ${T instanceof Error?T.message:String(T)}`),{}}}function N4($,O){return`${$}:${O}`}function nj($){let O=new Bun.CryptoHasher("sha1").update($).digest("hex"),T=Number.parseInt(O.slice(0,8),16);return Math.floor(T/4294967296*1e4)}function E4($,O){if(O>=100)return!0;if(O<=0)return!1;return $<Math.round(O*100)}function P4($,O,T,Z){if(Z.unavailable)return{value:!1,reason:"unavailable"};if(Z.active!==!0)return{value:!1,reason:"inactive"};if(O.when){let j;try{j=O.when(T)}catch(W){return Z.warn?.(`The \`when\` for feature "${$}" threw; treating it as off. ${W instanceof Error?W.message:String(W)}`),{value:!1,reason:"error"}}if(typeof j==="boolean")return{value:j,reason:"attributed"}}if(O.rollout===void 0)return{value:!0,reason:"on"};if(T.isBot)return{value:!1,reason:"bot"};let f=mC($,O,T,Z.buckets);return E4(f,O.rollout)?{value:!0,reason:"rollout"}:{value:!1,reason:"excluded"}}function kC($){let O=$.user?.publicId??$.user?.id;if(O!==void 0&&O!==null)return String(O);return $.anonymousId??""}function mC($,O,T,Z){let f=N4(O.salt??$,kC(T));if(!Z)return nj(f);let j=Z.get(f);if(j!==void 0)return j;let W=nj(f);return Z.set(f,W),W}class _4 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 aj{source;declared;ttlMs;warn;snapshot=null;inflight=null;lastFailureLoggedAt=0;generation=0;lastError=null;retryAfter=0;constructor($,O,T,Z=()=>{}){this.source=$;this.declared=O;this.ttlMs=T;this.warn=Z}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,O=await this.refresh();if(this.generation===$)throw new _4(this.lastError);return O}peek(){return this.snapshot}async load(){try{let $=await this.source.load(),{active:O,audit:T}=this.readRows($);return this.snapshot={active:O,audit:T,loadedAt:Date.now(),unavailable:!1},this.generation++,this.lastError=null,this.retryAfter=0,this.snapshot}catch($){return this.handleFailure($)}}readRows($){let O=new Map,T=new Map;for(let Z of $??[]){let f=typeof Z?.key==="string"?Z.key:null;if(!f){this.warn("Ignoring a feature row with no `key`.");continue}if(!(f in this.declared)){this.warn(`Feature row "${f}" is not declared in app/features, so it is ignored. Delete the row, or declare the feature.`);continue}O.set(f,Z.active===!0);let j=qC(Z);if(j)T.set(f,j)}return{active:O,audit:T}}handleFailure($){let O=$ instanceof Error?$.message:String($),T=Date.now();if(this.lastError=$,this.retryAfter=T+this.ttlMs,T-this.lastFailureLoggedAt>=this.ttlMs)this.lastFailureLoggedAt=T,this.warn(`Could not load feature switches: ${O}`);if(this.snapshot)return this.snapshot;return this.snapshot={active:new Map,audit:new Map,loadedAt:T,unavailable:!0},this.snapshot}}function qC($){let O={},T=$.updatedBy;if(typeof T==="string")O.updatedBy=T;else if(T===null)O.updatedBy=null;let Z=$.updatedAt;if(Z instanceof Date||typeof Z==="string"||typeof Z==="number"){let f=Z instanceof Date?Z:new Date(Z);if(!Number.isNaN(f.getTime()))O.updatedAt=f}return"updatedBy"in O||"updatedAt"in O?O:null}class yC{}class pC 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 oj 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 A4 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 H4{manager;ctx;constructor($,O){this.manager=$;this.ctx=O}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 h${config;log;static token="features";store;declared;warnedAboutSize=!1;warnedAboutActor=!1;constructor($,O=()=>{}){this.config=$;this.log=O;this.declared=$.features??{},this.store=new aj($.source,this.declared,Math.max(0,$.ttl)*1000,this.log)}declarations(){return this.declared}async list(){let{active:$,audit:O,unavailable:T}=await this.switches();return{unavailable:T,features:Object.entries(this.declared).map(([Z,f])=>({key:Z,describe:f.describe,rollout:f.rollout,targeted:f.when!==void 0,serverOnly:f.serverOnly,salt:f.salt,active:$.get(Z),...O.get(Z)}))}}async refresh(){if(!this.config.enabled)return;if(Object.keys(this.declared).length===0)return;await this.store.refresh()}async invalidate(){try{if(this.config.enabled&&Object.keys(this.declared).length>0)await this.store.invalidate()}finally{x.getStore()?.featureEvaluations?.clear()}}async set($,O,T={}){if(typeof $!=="string"||!Object.hasOwn(this.declared,$))throw new A4(String($));if(typeof O!=="boolean")throw TypeError(`Features.set("${$}", \u2026) takes a boolean, not ${O===null?"null":typeof O}.`);let Z=cC(T.actor),f=this.config.source;if(typeof f.write!=="function")throw new oj(f.constructor?.name||"an anonymous source");let{actorRecorded:j}=await f.write($,O,{actor:Z});if(Z!==null&&!j&&!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 O=await this.requestContext();return await this.evaluateIn($,O,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(),O=await this.evaluateAllIn($,this.requestBuckets(),{clientOnly:!0});return this.warnIfOversized(Object.keys(O).length),O}for($){return new H4(this,x4($))}async evaluateIn($,O,T){let Z=this.memoFor(O),f=Z?.get($);if(f)return f;let j=this.declared[$];if(!j)return{value:!1,reason:"undeclared"};let{active:W,unavailable:z}=await this.switchFor($),J=P4($,j,O,{active:W,unavailable:z,buckets:T,warn:this.log});return Z?.set($,J),this.notify($,J,O),J}async evaluateAllIn($,O,T){let Z={};for(let[f,j]of Object.entries(this.declared)){if(T.clientOnly&&j.serverOnly)continue;Z[f]=(await this.evaluateIn(f,$,O)).value}return Z}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 O=await this.store.get();return{active:O.active.get($),unavailable:O.unavailable}}async requestContext(){let $=x.getStore();if($?.featureContext)return $.featureContext;let O=await I4(this.config,this.log);if($)$.featureContext=O;return O}memoFor($){let O=x.getStore();if(!O||O.featureContext!==$)return null;return O.featureEvaluations??=new Map,O.featureEvaluations}requestBuckets(){let $=x.getStore();if(!$)return new Map;return $.featureBuckets??=new Map,$.featureBuckets}notify($,O,T){if(!this.config.onEvaluate)return;try{this.config.onEvaluate($,O,T)}catch(Z){this.log(`The \`onEvaluate\` hook in app/config/features.ts threw for "${$}". ${Z instanceof Error?Z.message:String(Z)}`)}}warnIfOversized($){if(this.warnedAboutSize||$<=this.config.maxClientFlags)return;this.warnedAboutSize=!0,this.log(`${$} client-visible features are embedded in every document. Mark the ones only the server reads with \`serverOnly: true\` to keep them out of the payload.`)}}function cC($){if($===void 0||$===null)return null;if(typeof $==="string"){if($.length>0)return $}else if(typeof $==="object"){let{publicId:O,id:T}=$;if(typeof O==="string"&&O.length>0)return O;if(typeof T==="string"&&T.length>0||typeof T==="number")return String(T)}throw TypeError("Features.set() was given an `actor` that identifies nobody. Pass a string, or a user with a `publicId` or an `id`.")}function w4($){return Object.fromEntries(Object.entries($).filter(([,O])=>{return O!==null&&O!==void 0}))}var iC=50;class l${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($,O){return[$,O].filter((T)=>T.length>0).join("?")}markRenderStart(){if(this.renderStartedAt===null)this.renderStartedAt=performance.now()}markShell(){if(this.shellAt===null)this.shellAt=this.elapsed()}summarize($){let O=this.elapsed();return{shellAt:this.shellAt??O,settledAt:O,aborted:$,queries:Array.from(this.entries.values(),(T)=>({path:T.path,variantKey:T.variantKey,startedAt:T.startedAt,settledAt:T.settledAt,status:T.status,source:T.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 O="";try{let f=JSON.stringify($.data)?.length??0;O=f>=1024?`${(f/1024).toFixed(1)} kB`:`${f} B`}catch{O="an unserializable payload"}let T=($.settledAt??0)-$.startedAt,Z=$.variantKey?`, { search: ${JSON.stringify(Object.fromEntries(new URLSearchParams($.variantKey)))} }`:"";console.warn(`[gemi] useQuery("${$.patternPath}") was discovered ${$.lateBy}ms into the `+`server render \u2014 under a suspended segment, so its fetch (${T}ms, resolved ${O}) could not overlap the others. It still streamed. If the query belongs on this route, \`Query.prefetch("${$.patternPath}"${Z})\` in the view `+"handler starts it at request time \u2014 but note prefetched data is also re-fetched and "+`streamed into every client-side navigation payload for the route, even when the client already holds it, so weigh that bandwidth against the ${O}. 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($,O){return this.entries.get(this.keyFor($,O))}ensure($,O={},T="render"){let Z=O.params??{},f=new URLSearchParams(w4(O.search??{}));f.delete("json"),f.sort();let j=s($,Z),W=f.toString(),z=this.keyFor(j,W),J=this.entries.get(z);if(J)return J;let C;if(T==="render"&&this.renderStartedAt!==null){let U=Math.round(performance.now()-this.renderStartedAt);if(U>iC)C=U}let F,D=new Promise((U)=>{F=U}),Y={path:j,patternPath:$,variantKey:W,lateBy:C,status:"pending",promise:D,source:T,startedAt:this.elapsed()};return this.entries.set(z,Y),this.fetcher($,Z,f).then((U)=>{Y.status="resolved",Y.data=U},(U)=>{Y.status="rejected",Y.error=U}).then(()=>{if(Y.settledAt=this.elapsed(),this.maybeLogLateDiscovery(Y),Y.status==="rejected"&&this.failListener)this.failListener(Y);if(this.settleListener)this.settleListener(Y);else this.settledBacklog.push(Y);F()}),Y}async allSettled(){let $=0;while($!==this.entries.size)$=this.entries.size,await Promise.all(Array.from(this.entries.values(),(O)=>O.promise))}snapshotResolved(){let $={};for(let[O,T]of this.entries){if(T.status!=="resolved")continue;this.shipped.add(O),$[T.path]??={},$[T.path][T.variantKey]=T.data}return $}onSettle($){this.settleListener=(T)=>{if(this.shipped.has(this.keyFor(T.path,T.variantKey)))return;$(T)};let O=this.settledBacklog;this.settledBacklog=[];for(let T of O)this.settleListener(T)}}class W$ extends Error{path;variantKey;status;body;constructor($,O,T,Z){super(typeof Z?.message==="string"?Z.message:`Request to /api${$} failed with status ${T}`);this.path=$;this.variantKey=O;this.status=T;this.body=Z;this.name="QueryError"}}function d$(){let $=JSON.stringify({error:{message:"Forbidden"}});return new Response($,{status:403,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}function rj(){return{status:403,error:{message:"Forbidden"}}}function kO($){let O=u$.getStore();return(T,Z,f)=>{let j=new URL($.url).origin,W=[s(T,Z),f.toString()].filter((F)=>F.length>0).join("?"),z=new Request(`${j}/${W}`,{headers:$.headers}),J=b4($);if(J)s$(z,J);let C=new E(z,Z);return u$.run(O,()=>x.run(C,async()=>{try{let F=await K(s0).dispatchers(J).api.getRouteData(T);if(F instanceof Response){let D=await F.json().catch(()=>null);if(!F.ok)throw new W$(s(T,Z),f.toString(),F.status,D);return D}return F}catch(F){if(F instanceof W$)throw F;let D=new W$(s(T,Z),f.toString(),500,{message:F instanceof Error?F.message:String(F)});throw D.cause=F,D}}))}}var hC=new Set(["script","style","template","title"]),lC=/\shidden([\s=/]|$)/i,dC=/"[^"]*"|'[^']*'/g;function uC($){let O=0,T=0,Z=0,f=0;while(f<$.length){let j=$.indexOf("<",f),W=j===-1?$.length:j;if(W>f){let D=$.slice(f,W).replace(/\s+/g,"").length;if(Z>0)T+=D;else O+=D}if(j===-1)break;if($.startsWith("<!--",j)){let D=$.indexOf("-->",j+4);f=D===-1?$.length:D+3;continue}let z=$.indexOf(">",j);if(z===-1)break;let J=$.slice(j+1,z);f=z+1;let C=/^\/?([a-zA-Z][a-zA-Z0-9-]*)/.exec(J)?.[1]?.toLowerCase();if(!C)continue;let F=J.startsWith("/");if(!F&&hC.has(C)&&!J.endsWith("/")){let D=$.indexOf(`</${C}`,f);f=D===-1?$.length:D;continue}if(C!=="div")continue;if(F){if(Z>0)Z-=1}else if(Z>0)Z+=1;else if(lC.test(J.replace(dC,'""')))Z=1}return{shellChars:O,deferredChars:T}}var sC=1000,nC=64;function aC($){return $>=1000?`${($/1000).toFixed(1)} kB`:`${$} chars`}function oC($,O){if(O.deferredChars<sC)return null;if(O.shellChars>=nC)return null;return`[gemi] GET ${$} streams ${aC(O.deferredChars)} of its `+`content behind reveal scripts \u2014 a no-JS visitor sees ~${O.shellChars} chars. If this is a public/content route, add "no-stream" to its middleware.`}function v4($=console.warn){let O=new Set;return{shouldObserve(T){return!O.has(T)},report(T,Z){if(O.has(T))return;let f=oC(T,Z);if(!f)return;O.add(T),$(f)}}}function g4(){let $=new TextDecoder,O="";return{onChunk(T){O+=$.decode(T,{stream:!0})},measure(){return O+=$.decode(),uC(O)}}}function R4($,O,T=1e4,Z){let f=new TextEncoder,j=()=>{};return new ReadableStream({start(W){let z=!1,J=(F)=>{if(z)return;z=!0,clearTimeout(C);try{W.close()}catch{}Z?.({aborted:F})};j=J,W.enqueue(f.encode(`${JSON.stringify($)}
|
|
5
|
+
`)),O.onSettle((F)=>{if(z||F.status!=="resolved")return;W.enqueue(f.encode(`${JSON.stringify([F.path,F.variantKey,F.data])}
|
|
6
|
+
`))});let C=setTimeout(()=>J(!0),T);O.allSettled().then(()=>J(!1),()=>J(!1))},cancel(){j(!1)}})}var tC=async()=>(await import("./chunk-6z7mskmy.js")).default,tj,ej=async(...$)=>{return tj??=import("react-dom/server.browser").catch((O)=>{throw tj=void 0,O}),(await tj).renderToReadableStream(...$)},eC=1e4,$F=`
|
|
7
|
+
!function(){try{var d=document.documentElement,c=d.classList;
|
|
8
|
+
c.remove('light','dark');
|
|
9
|
+
var e=localStorage.getItem('theme');
|
|
10
|
+
if('system'===e||(!e&&'system'===defaultTheme)){
|
|
11
|
+
var t='(prefers-color-scheme: dark)',m=window.matchMedia(t);
|
|
12
|
+
if(m.media!==t||m.matches){d.style.colorScheme='dark';c.add('dark')}
|
|
13
|
+
else{d.style.colorScheme='light';c.add('light')}
|
|
14
|
+
}else if(e){
|
|
15
|
+
c.add(e||'')
|
|
16
|
+
}}catch(e){}}()
|
|
17
|
+
`;async function OF($,O,T){let Z=`${T==="italic"?"italic,":""}wght@${T==="italic"?"1,":""}${O}`,W=(await(await fetch(`https://fonts.googleapis.com/css2?family=${$}:${Z}&display=swap`,{headers:{"User-Agent":"Mozilla/5.0 Firefox/1.0"}})).text()).match(/url\(([^)]+)\)/)?.[1];return await fetch(W).then((z)=>z.arrayBuffer())}var TW="/assets";function TF($){return $===TW||$.startsWith(`${TW}/`)}function ZF($){let O=$.filter(TF);if(O.length>0){let T=O.length>1;throw Error(`View route path${T?"s":""} ${O.map((Z)=>`"${Z}"`).join(", ")} use${T?"":"s"} the reserved "${TW}" prefix. The client build output is served from there before the router runs, so the route would never match. Mount it somewhere else.`)}}function fF($){let O=K(s0).resolver;return{...$.domain,root:O.root,origin:O.publicOrigin($.rawRequest)}}function $W($){let{status:O=400,error:T}=$;return new Response(T?.message,{...$,status:O})}function jF($){let{status:O=400,data:T,directive:Z,headers:f}=$;return new Response(JSON.stringify({data:T,directive:Z}),{headers:f,status:O})}class yO{static token="router.view";flatViewRoutes={};routeManifest={};clientRouteManifest={};componentTree=[];flatComponentTree=[];root=null;shellReporter=v4();preloadCache=new WeakMap;hooks;partialRendering;constructor($){let O=s2();this.partialRendering=$.partialRendering??O.partialRendering,this.hooks={onRequestStart:$.onRequestStart??O.onRequestStart,onRequestEnd:$.onRequestEnd??O.onRequestEnd,onRequestFail:$.onRequestFail??O.onRequestFail,onStreamComplete:$.onStreamComplete??O.onStreamComplete};let T={"/":$.rootRouter,"/auth":Bj};this.flatViewRoutes=YZ(T),ZF(Object.keys(this.flatViewRoutes)),this.routeManifest=XZ(T),this.clientRouteManifest=Object.fromEntries(Object.entries(this.routeManifest).filter(([,Z])=>Z.at(-1)!=="FILE")),this.componentTree=UZ(T),this.flatComponentTree=dj(this.componentTree),this.root=$.root}async passesFeatureGates($){let O=K(h$);for(let T of $)if(!await O.enabled(T))return!1;return!0}async onRequestEnd($){return OW(),await this.hooks.onRequestEnd($)}completeStream($,O){let T=(Z)=>{R1.error(Z?.message??'Error in "onStreamComplete" event handler',{err:JSON.stringify(Z)})};try{Promise.resolve(this.hooks.onStreamComplete($,O)).catch(T)}catch(Z){T(Z)}}modulePreloadLinks($){let{clientEntry:O,modulePreloadManifest:T,views:Z,routeKey:f}=$,j=()=>{let J=new Set(O?.preload??[]);for(let C of Z)for(let F of T?.[C]??[])J.add(F);return[...J].map((C)=>n$("link",{key:`modulepreload:${C}`,rel:"modulepreload",href:C}))};if(!T)return j();let W=this.preloadCache.get(T);if(!W||W.clientEntry!==O)W={clientEntry:O,byRoute:new Map},this.preloadCache.set(T,W);let z=W.byRoute.get(f);if(!z)z=j(),W.byRoute.set(f,z);return z}async render($){let{req:O,runInRequestScope:T,csrfTokenHMAC:Z,currentPathName:f,headers:j,i18n:W,params:z,pathname:J,serverQueries:C,userAgent:F,noStream:D,url:Y,user:U,viewData:X,breadcrumbs:G,urlLocaleSegment:B,meta:L,isOgRequest:M,appId:Q,features:N}=$,P=J.replace(`/${B}`,""),S={kind:"view",data:{meta:L,pageData:{[P]:X},__csrf:Z.toString("base64"),prefetchedData:{},i18n:W,auth:{user:U},routeManifest:this.clientRouteManifest,breadcrumbs:G,router:{urlLocaleSegment:B,pathname:f,params:z,currentPath:J,searchParams:Y.search,is404:!f?!0:!1,domain:O.domain?fF(O):null},appId:Q,features:N,componentTree:[["404",[]],...this.componentTree]},head:{}},V=this.root,_=this.routeManifest[f];return async(A)=>{let{bootstrapModules:T0=[],loaders:g,getStyles:m,viewImportMap:Z0,cssManifest:VZ,ogMap:pO,viewModules:z$,clientEntry:Z1,modulePreloadManifest:k1,assetBase:f0}=A,r$=Z1?[]:T0,cO=(I0)=>[I0,`window.loaders=${g}`,...Z1?[`import(${JSON.stringify(Z1.module)}).catch(function(e){setTimeout(function(){throw e})})`]:[]].join(";");if(M){let I0=null,F$=null;for(let Y$ of _??[])if(typeof pO[Y$]==="function")F$=Y$,I0=pO[Y$];if(!I0)return new Response("Not found",{status:404});let C5=Object.values(S.data.pageData)[0];try{await ej(n$(I0,C5[F$]),{onError:()=>{}})}catch(Y$){let{fonts:F5,...Y5}=Y$.satoriOptions,D5=await Promise.all(F5.map((hO)=>{return OF(hO.name,hO.weight,hO.style).then((K5)=>({...hO,data:K5}))})),FW=new Headers(j);FW.set("Content-Type","image/png");let[X5,U5]=await Promise.all([tC(),CZ("Rendering an OG image")]),G5=await X5(Y$.jsx,{...Y5,fonts:D5}),B5=await U5(Buffer.from(G5)).png({compressionLevel:0,effort:10}).toBuffer();return new Response(new Uint8Array(B5),{headers:FW})}return new Response("data")}if(S.data.cssManifest=VZ,S.data.modulePreloadManifest=k1??{},f0&&f0!=="/")S.data.assetBase=f0;let J$=this.modulePreloadLinks({clientEntry:Z1,modulePreloadManifest:k1,views:_??["404"],routeKey:f??"404"}),t$=await m(_);S.data.prefetchedData=C.snapshotResolved(),C.markRenderStart();let U1=new AbortController,iO=setTimeout(()=>U1.abort(),eC),H=BZ(F)||D,V0=Bun.env.NODE_ENV!=="production"&&!H&&f&&this.shellReporter.shouldObserve(f)?g4():null,C$=q4();try{let I0=await ej(n$(rC,{children:[...J$,...t$,n$("script",{key:"theme-script",dangerouslySetInnerHTML:{__html:$F}}),n$(V,{data:S.data,viewImportMap:Z0,viewModules:z$,serverQueries:C,dictionarySink:C$,key:"root"})]}),{bootstrapScriptContent:cO(`window.__GEMI_DATA__ = ${j$(S.data)}`),bootstrapModules:r$,signal:U1.signal,...H?{progressiveChunkSize:Number.MAX_SAFE_INTEGER}:{},onError(F$){if(Bun.env.NODE_ENV!=="production")console.error(F$)}});if(I0.allReady.catch(()=>{}).finally(()=>clearTimeout(iO)),H)await I0.allReady.catch(()=>{});return new Response(sj(I0,C,{onShell:H?void 0:()=>C.markShell(),onChunk:V0?.onChunk,onClose:()=>T(()=>{if(this.completeStream(O,C.summarize(U1.signal.aborted)),V0)this.shellReporter.report(f,V0.measure())})},C$),{status:!f?404:200,headers:j})}catch(I0){if(clearTimeout(iO),Bun.env.NODE_ENV==="production")throw T(()=>this.completeStream(O,C.summarize(U1.signal.aborted))),I0;let F$=await ej(n$("div"),{bootstrapScriptContent:cO(`window.error= ${j$(I0.message)}; window.stack_trace=${j$(I0.stack)};window.__GEMI_DATA__ = ${j$(S.data)}`),bootstrapModules:Bun.env.NODE_ENV==="development"?["/render-error.js",...r$]:r$});return new Response(sj(F$,C,{onClose:()=>T(()=>this.completeStream(O,C.summarize(U1.signal.aborted)))}),{status:!f?404:200,headers:j})}}}async handleViewRequest($,O){let T=new URL($.url),Z=T.pathname.endsWith(".json"),f=T.pathname.endsWith(".og"),j=T.pathname.replace(".json","").replace(".og",""),[,W,...z]=j.split("/"),J=`/${z.join("/")}`,C=null,F=null,D=K(n);if(!D.supportedLocales.includes(W))J=j;else C=W,F=W;let U=F===null&&RO(this.flatViewRoutes,J)!==null;if(D.isLocaleAware&&!f&&F===null&&!U){let S=k4(W,D.supportedLocales,D.defaultLocale);if(S){let V=z.length?`/${z.join("/")}`:"";return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${S}${V}${Z?".json":""}${T.search}`}})}}if(D.isLocaleAware&&!f){let S=K(n).detectLocale(new E($,{},"view",J));if(F===null&&S!==D.defaultLocale){let V=T.pathname==="/"?"":T.pathname;return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${S}${V}${T.search}`}})}}J=J.replace("//","/");let X=[],G=[],B=null,L={},M=null,Q=!1,N=[];try{let S=RO(this.flatViewRoutes,J);if(S){if(B=S.routePath,L=S.params,X=S.route.exec,G=S.route.middleware,N=S.route.features,Q=G.includes("no-stream"),Z&&this.partialRendering){let V=$.headers.get(lj),_=L4({flatViewRoutes:this.flatViewRoutes,supportedLocales:K(n).supportedLocales,from:V,origin:T.origin,to:{segments:S.route.segments,params:L,search:T.search}});if(_.startIndex>0)X=X.slice(_.startIndex),M={from:V,carriedViews:_.carriedViews}}}}catch(S){throw S}let P=new E($,L,"view",B);return this.hooks.onRequestStart(P),await x.run(P,async()=>{let S=null,V=x.getStore(),_=u$.getStore(),A=(m)=>u$.run(_,()=>x.runWith(V,m));V.serverQueries=new l$(kO($));let T0=new Set;if(V.serverQueries.onQueryFail((m)=>{T0.add(m.error);try{A(()=>Promise.resolve(this.hooks.onRequestFail(g,m.error)).catch(()=>{}))}catch{}}),F){let m=F.replaceAll("/","");i$.setLocale(m)}else i$.setLocale();let g=V.req;OW();try{let m=!1;try{await K(gO).runMiddleware(G)}catch(H){if(!a$(H))throw H;m=!0}if(m||N.length>0&&!await this.passesFeatureGates(N))B=null,X=[],g.routePath="";let Z0=K(n),VZ=Z0.isEnabled,pO=Z0.isLocaleAware,z$={};if(pO){let H=null;if(F)H=F.replaceAll("/",""),V.setLocale(H);else H=Z0.detectLocale(new E($,g.params)),V.setLocale(H);let V0=VZ?Z0.getPageTranslations(H,g.routePath):{};z$={supportedLocales:Z0.supportedLocales,currentLocale:H,dictionary:{[H]:V0},defaultLocale:Z0.defaultLocale}}await m4(z$.currentLocale??"");let Z1;try{Z1=await Promise.all(X.map((H)=>H(g)))}catch(H){if(!a$(H))throw H;B=null,X=[],g.routePath="",Z1=[]}let{cookies:k1,headers:f0}=V;S={data:Z1,cookies:k1,headers:f0,user:V.user,prefetchedData:V.serverQueries.snapshotResolved(),currentPathName:B,params:g.params,urlLocaleSegment:C,meta:V.renderMeta(),appId:K(uj).id,features:await K(h$).forClient()};let{params:r$,user:cO}=S,J$={},t$={};for(let H of Z1??[]){let[V0,C$]=Object.entries(H)?.[0]??[];if(!V0||!C$)continue;t$[`${V0}:${B}`]=C$.breadcrumb,J$[V0]=C$}let U1=J$.FILE;if(U1){for(let H of k1)f0.append("Set-Cookie",H.toString());try{await this.onRequestEnd(g)}catch(H){R1.error(H?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(H)})}return await wZ(U1,f0)}if(Z){f0.set("Content-Type","application/x-ndjson; charset=utf-8"),f0.append("Vary",lj),k1.forEach((V0)=>f0.append("Set-Cookie",V0.toString())),await this.hooks.onRequestEnd(g);let H={meta:M&&!V.metadata.touched?null:S.meta,data:{[J]:J$},breadcrumbs:t$,prefetchedData:V.serverQueries.snapshotResolved(),i18n:z$,features:S.features,is404:!B,appId:S.appId,partial:M};return new Response(R4(H,V.serverQueries,void 0,({aborted:V0})=>A(()=>this.completeStream(g,V.serverQueries.summarize(V0)))),{headers:f0})}if(f0.set("Content-Type","text/html; charset=utf-8"),!Q)f0.append("Vary","User-Agent");for(let H of k1)f0.append("Set-Cookie",H.toString());let iO=Bun.CSRF.generate(process.env.SECRET);f0.append("Set-Cookie",`csrf_token=${iO}; HttpOnly; Secure; SameSite=Strict; Expires=${new Date(Date.now()+86400000).toUTCString()}`);try{await this.onRequestEnd(g)}catch(H){R1.error(H?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(H)})}return await this.render({req:g,runInRequestScope:A,csrfTokenHMAC:Buffer.from(""),currentPathName:B,headers:f0,i18n:z$,params:r$,pathname:T.pathname,serverQueries:V.serverQueries,userAgent:$.headers.get("user-agent"),noStream:Q,url:T,user:cO,viewData:J$,breadcrumbs:t$,urlLocaleSegment:C,meta:S.meta,appId:S.appId,features:S.features,isOgRequest:f})}catch(m){if(m.kind===mO)if(Z)return jF(m.payload.viewData??m.payload.api);else return $W(m.payload.view);if(!T0.has(m))this.hooks.onRequestFail(g,m);if(qO(m))return console.error(m),Z?d$():$W(rj());if(m instanceof W$&&m.status===403)return Z?d$():$W(rj());throw m}},O)}}function fW(){let $=JSON.stringify({error:{message:"Not found"}});return new Response($,{status:404,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}class l4 extends x0{routes={"/api-routes":this.get(()=>{let $=K(LZ).flatRoutes,O=[];for(let[T,Z]of Object.entries($))for(let[f,j]of Object.entries(Z)){let{exec:W,middleware:z}=j;O.push({path:T,method:f,middleware:z})}return O}),"/view-routes":this.get(()=>{let $=K(yO).flatViewRoutes,O=[];for(let[T,{middleware:Z,viewPath:f}]of Object.entries($))O.push({path:T,method:"GET",viewPath:f,middleware:Z});return O})}}var KZ="access_token";function WF($,O){let T=$.body.getReader(),Z=!1,f=()=>{if(Z)return;Z=!0;try{O()}catch(W){console.error(W)}},j=new ReadableStream({async pull(W){let z;try{z=await T.read()}catch(J){f(),W.error(J);return}if(z.done){f();try{W.close()}catch{}return}try{W.enqueue(z.value)}catch{}},async cancel(W){try{await T.cancel(W)}finally{f()}}},{highWaterMark:0});return new Response(j,{status:$.status,statusText:$.statusText,headers:$.headers})}function y4($){let{status:O=400,data:T,headers:Z}=$,f=new Headers({"Content-Type":"application/json",...Z});if(!f.has("Cache-Control"))f.set("Cache-Control","no-store");return new Response(JSON.stringify(T),{status:O,headers:f})}function p4($,O,T){let Z=[];O?.forEach((W,z)=>Z.push([z,W]));let f=[...typeof O?.getSetCookie==="function"?O.getSetCookie():[],...Array.from(T??[])];if(Z.length===0&&f.length===0)return $;let j=(W)=>{for(let[z,J]of Z){if(z.toLowerCase()==="set-cookie")continue;if(!W.has(z))W.set(z,J)}for(let z of f)W.append("Set-Cookie",z)};try{return j($.headers),$}catch{let W=new Headers($.headers);return j(W),new Response($.body,{status:$.status,statusText:$.statusText,headers:W})}}class LZ{static token="router.api";flatRoutes={};onRequestStart;onRequestEnd;onRequestFail;constructor($){let O=u2();this.onRequestStart=$.onRequestStart??O.onRequestStart,this.onRequestEnd=$.onRequestEnd??O.onRequestEnd,this.onRequestFail=$.onRequestFail??O.onRequestFail,this.flatRoutes=Ej({"/":$.rootRouter,"/auth":Kj,"/__gemi__/services/i18n":Lj,"/__gemi__/services/logs":Nj,"/__gemi__/services/image":Mj,"/__gemi__/debug":l4})}getRouteHandlerAndParams($){let O=new URL($.url),T=h4(O.pathname),Z={},f;for(let[j]of Object.entries(this.flatRoutes))try{let W=new URLPattern({pathname:j});if(W.test({pathname:T})){f=j,Z=W.exec({pathname:T})?.pathname.groups;break}}catch(W){console.error(W)}return{params:Z,path:f}}async runRouteMiddleware($,O){let Z=this.flatRoutes[$][O.rawRequest.method].middleware;try{await K(gO).runMiddleware(Z)}catch(f){if(f.kind===mO)return y4(f.payload.api);else{if(a$(f))return fW();if(this.onRequestFail(O,f),console.error(f),qO(f))return d$();throw f}}}async getRouteData($){let O=this.flatRoutes[$],T=x.getStore(),Z=O[T.req.rawRequest.method].exec??(()=>Promise.resolve({})),f={};try{f=await Z()}catch(j){if(j.kind===mO)return y4(j.payload.api);if(a$(j))return fW();if(this.onRequestFail(T.req,j),console.error(j),qO(j))return d$();throw j}return f}isFrameworkRoute($){return $.startsWith("/__gemi__")}async endRequest($,O,T){let Z=async()=>{try{if(!this.isFrameworkRoute(T))await this.onRequestEnd(O)}catch(f){R1.error(f?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(f)})}finally{$.destroy()}};if(!$.hasPendingWork()){await Z();return}$.whenIdle().then(Z).catch((f)=>{console.error(f)})}isOpenEndedBody($,O){return $.method!=="HEAD"&&O.body!==null&&!O.headers.has("Content-Length")}async handleApiRequest($,O){let{params:T,path:Z}=this.getRouteHandlerAndParams($),f=this.flatRoutes[Z];if(!f||!f[$.method])return new Response(JSON.stringify({error:{message:"Not found"}}),{status:404});let j=new E($,T,"api",Z);if(!this.isFrameworkRoute(Z))this.onRequestStart(j);return await x.run(j,async()=>{let W=x.getStore(),z=!1,J=async()=>{z=!0,await this.endRequest(W,j,Z)};try{let C=K(n);if(C.isEnabled){let X=C.detectLocale(j);W.setLocale(X)}W.setRequest(j);let F=await this.runRouteMiddleware(Z,j);if(F instanceof Response){let X=p4(F,W.headers,W.cookies);return await J(),X}let D=await this.getRouteData(Z),Y=W.headers,U=W.cookies;if(D instanceof Response){let X=p4(D,Y,U);if(this.isOpenEndedBody($,X)){let G=WF(X,()=>this.endRequest(W,j,Z));return z=!0,G}return await J(),X}return Y.set("Content-Type","application/json"),U.forEach((X)=>Y.append("Set-Cookie",X.toString())),await J(),new Response(JSON.stringify(D),{headers:Y})}catch(C){if(!z)try{await J()}catch(F){console.error(F)}throw C}},O)}async dispatchAs($,O,T,Z){let f=new URL($.rawRequest.url).origin,j=new URL(`${f}/api${T}`),W=`/api${T.split(/[?#]/)[0]}`;if(!T.startsWith("/")||j.origin!==f||j.pathname!==W||j.hash!==""||j.pathname.startsWith("/api/__gemi__")||j.pathname==="/api/auth"||j.pathname.startsWith("/api/auth/"))throw Error(`dispatchAs: "${T}" is not an app api path. Pass the route's own path, without "/api", with every param encoded.`);let z=new Headers,J=$.cookies.get(KZ);if(J)z.set("Cookie",`${KZ}=${J}`);let C=$.headers.get(KZ);if(C)z.set(KZ,C);let F=$.headers.get("User-Agent");if(F)z.set("User-Agent",F);let D;if(Z instanceof FormData)D=Z;else if(Z!==void 0)z.set("Content-Type","application/json"),D=JSON.stringify(Z);let Y=new Request(j,{method:O,headers:z,body:D});if(c4(Y,nO($)),$.domain)s$(Y,$.domain);return x.exit(()=>i4.exit(()=>this.handleApiRequest(Y)))}}var WW="",d4="*";var jW=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;function u4($){return $.startsWith(":")}function T1($){if(!$)return null;try{return new URL(`http://${$.trim()}`).hostname.toLowerCase().replace(/\.$/,"")||null}catch{return null}}function zF($){try{let O=new URL(`http://${$.trim()}`),T=O.hostname.toLowerCase().replace(/\.$/,"");return T?O.port?`${T}:${O.port}`:T:null}catch{return null}}function JF($){let O=T1($.root),T=$.root?.trim().toLowerCase().replace(/\.$/,"");if(!O||O!==T||!O.split(".").every((j)=>jW.test(j)))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<16)throw Error("`route.domains.ask.secret` must be at least 16 characters. A guessable one is worse than leaving `ask` out.");let Z=new Set,f=null;for(let j of $.groups??[]){let{subdomain:W}=j;if(Z.has(W))throw Error(`\`route.domains\` declares the subdomain "${W}" twice.`);if(Z.add(W),u4(W)){if(!/^:[A-Za-z_][A-Za-z0-9_]*$/.test(W))throw Error(`"${W}" is not a valid param subdomain. It must be a single \`:name\` label.`);if(f)throw Error(`\`route.domains\` declares two param subdomains, "${f.subdomain}" and "${W}"; a host could match either.`);f=j;continue}if(j.exists)throw Error(`The subdomain "${W}" is fixed, so \`exists\` has no param to check. It only applies to a \`:param\` subdomain.`);if(!W.split(".").every((z)=>jW.test(z)))throw Error(`"${W}" is not a valid subdomain.`)}if($.custom&&!Z.has($.custom.group))throw Error(`\`route.domains.custom.group\` is "${$.custom.group}", but no group declares that subdomain.`);if($.ask&&f&&!f.exists)throw Error(`\`route.domains.ask\` is set, so "${f.subdomain}" needs an \`exists\` to say which tenants are real. Without one every host under the root would be approved for a certificate.`)}class zW{root;trustProxy;fixed=new Map;param=null;custom;cacheTtlMs;cache=new Map;inFlight=new Map;askSecret;constructor($){JF($),this.root=T1($.root),this.trustProxy=$.trustProxy??!1;for(let O of $.groups??[])if(u4(O.subdomain))this.param={...O,name:O.subdomain.slice(1)};else this.fixed.set(O.subdomain.toLowerCase(),O);this.custom=$.custom??null,this.cacheTtlMs=this.custom?.cacheTtlMs??60000,this.askSecret=$.ask?.secret??null}hostOf($){if(this.trustProxy){let O=$.headers.get("x-forwarded-host")?.split(",")[0],T=T1(O);if(T)return T}return T1(new URL($.url).host)}publicOrigin($){let O=new URL($.url),T=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),Z=T==="http"||T==="https"?T:O.protocol.replace(/:$/,"");if(!this.trustProxy)return`${Z}://${O.host}`;let f=$.headers.get("x-forwarded-host")?.split(",")[0]?.trim(),j=f&&T1(f)?zF(f):null;return`${Z}://${j??O.host}`}async resolve($){let O=this.hostOf($);if(!O)return null;let T=await this.match(O,$);if(T)return T;if(this.custom?.fallback&&!this.isUnderRoot(O))return{host:O,group:"*",params:{},custom:!0};return null}async allows($,O){let T=T1($);return T?await this.match(T,O)!==null:!1}isUnderRoot($){return $===this.root||$.endsWith(`.${this.root}`)}async match($,O){if($===this.root)return{host:$,group:"",params:{},custom:!1};if($.endsWith(`.${this.root}`)){let Z=$.slice(0,-(this.root.length+1)),f=this.fixed.get(Z);if(f)return{host:$,group:f.subdomain,params:{},custom:!1};if(this.param&&jW.test(Z)){let j={[this.param.name]:Z};if(this.param.exists&&!await this.param.exists(j,O))return null;return{host:$,group:this.param.subdomain,params:j,custom:!1}}return null}if(!this.custom)return null;let T=await this.resolveCustom($);return T?{host:$,group:this.custom.group,params:T,custom:!0}:null}async resolveCustom($){let O=Date.now(),T=this.cache.get($);if(T&&T.expiresAt>O)return this.cache.delete($),this.cache.set($,T),T.value;let Z=this.inFlight.get($);if(Z)return Z;let f=(async()=>await this.custom.resolve($)??null)();this.inFlight.set($,f);let j;try{j=await f}finally{this.inFlight.delete($)}if(this.cacheTtlMs>0){if(this.cache.size>=1e4)this.cache.delete(this.cache.keys().next().value);this.cache.delete($),this.cache.set($,{value:j,expiresAt:Date.now()+this.cacheTtlMs})}return j}forget($){if($===void 0)this.cache.clear();else{let O=T1($);if(O)this.cache.delete(O)}}}var FF="/__gemi__/domains/ask";function YF($,O){if($===null)return!1;let T=Buffer.from($,"utf8"),Z=Buffer.from(O,"utf8");return T.length===Z.length&&CF(T,Z)}class s0{static token="router.domains";resolver;acceptsCustomDomains;groups=new Map;constructor($,O){this.groups.set(WW,$);let{domains:T}=O;if(this.acceptsCustomDomains=Boolean(T?.custom),!T){this.resolver=null;return}this.resolver=new zW(T);let Z=(f)=>({api:f.api?new LZ({...O.api,...f.api}):$.api,view:f.view?new yO({...O.view,...f.view}):$.view});for(let f of T.groups??[])this.groups.set(f.subdomain,Z(f));if(T.custom?.fallback)this.groups.set(d4,Z(T.custom.fallback))}async route($){if(!this.resolver)return this.dispatchers(null);let O=await this.resolver.resolve($);if(!O)return null;return s$($,O),this.dispatchers(O)}async ask($){if(!this.resolver?.askSecret||$.method!=="GET")return null;let O=new URL($.url);if(O.pathname!==FF)return null;if(!YF(O.searchParams.get("secret"),this.resolver.askSecret))return null;let T=O.searchParams.get("domain"),Z=T?await this.resolver.allows(T,$):!1;return new Response(null,{status:Z?200:404})}dispatchers($){return this.groups.get($?.group??WW)}viewDispatchers(){return Array.from(new Set(Array.from(this.groups.values(),($)=>$.view)))}}function s4($){let O=new Date($??0).getTime();return Number.isFinite(O)?O:0}var n4=600000;function a4($,O){return[aO($,O),aO($,O-1)]}class w{static token="auth";config;provider;constructor($={},O=new iZ){this.config=o4(mW($),$),this.provider=O}get userProvider(){return this.provider}accessTokenCookieOptions($,O){return{expires:O,secure:this.publicOrigin($).startsWith("https://"),httpOnly:!0,domain:this.cookieDomain($)}}publicOrigin($){let O=K().bound(s0)?K(s0).resolver:null;return O?O.publicOrigin($.rawRequest):new URL($.rawRequest.url).origin}cookieDomain($){let O=this.config.cookieDomain;if(!O)return;let T=O==="root"?K(s0).resolver?.root:T1(O);if(!T)throw Error('`auth.cookieDomain` is "root", but `route.domains` is not configured.');let Z=$.domain?.host??T1(new URL($.rawRequest.url).host);return Z===T||Z?.endsWith(`.${T}`)?T:void 0}async getSession($,O){if(!$)return null;if(!qZ($))return this.config.migrateLegacySession?this.convertLegacySession($,O,this.config.migrateLegacySession):null;let T=await this.userProvider.findSession({token:$,userAgent:O});if(!T?.user)return null;let Z=Date.now(),f=s4(T.expiresAt),j=s4(T.absoluteExpiresAt);if(f<=Z||j<=Z)return await this.userProvider.deleteSession({token:$}),null;let z=await this.slideSession(T,Z);return z.user.extension=await this.config.extendSession(z.user),z}async convertLegacySession($,O,T){let Z=x.getStore()?.req;if(!Z)return null;let f=Date.now(),j=Math.floor(f/n4),W=null,z=await this.userProvider.findSession({token:$,userAgent:O});if(z?.user){if(!await T(z,{token:$,req:Z,userAgent:O}))return null;let C=aO($,j),F=z.user.id;if(await this.userProvider.withLegacySessionLock($,async()=>{if(!await this.userProvider.claimLegacySession({token:$}))return!1;return await this.userProvider.createSessionV2({token:C,userId:F,userAgent:O,...this.freshLifetime(f)}),!0}))W=C}if(!W){for(let C of a4($,j))if((await this.userProvider.findSession({token:C,userAgent:O}))?.user){W=C;break}}if(!W)return null;let J=await this.getSession(W,O);if(J)Z.ctx().setCookie("access_token",W,this.accessTokenCookieOptions(Z,new Date(J.expiresAt)));return J}async revokeSession($,O){if(!$)return await this.userProvider.deleteSession({token:$}),null;if(qZ($)||!this.config.migrateLegacySession){let f=await this.userProvider.findSession({token:$,userAgent:O});return await this.userProvider.deleteSession({token:$}),f}let T=Math.floor(Date.now()/n4),Z=a4($,T);return this.userProvider.withLegacySessionLock($,async()=>{let f=await this.userProvider.findSession({token:$,userAgent:O});for(let j of Z){if(f?.user)break;f=await this.userProvider.findSession({token:j,userAgent:O})}await this.userProvider.deleteSession({token:$});for(let j of Z)await this.userProvider.deleteSession({token:j});return f})}requestCarryingCookie($){let O=x.getStore()?.req;return O?.cookies.get("access_token")===$?O:null}async slideSession($,O){let T=this.config.sessionExpiresInHours*3600000;if(new Date($.expiresAt).getTime()-O>=T/2)return $;let Z=new Date(Math.min(O+T,new Date($.absoluteExpiresAt).getTime())),f=await this.userProvider.updateSession({token:$.token,expiresAt:Z}),j=this.requestCarryingCookie($.token);if(j)j.ctx().setCookie("access_token",$.token,this.accessTokenCookieOptions(j,Z));if(!f)return $;return{...$,expiresAt:f.expiresAt??Z}}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 O=await this.userProvider.findUserByEmailAddress($,!1);if(!O)throw Error(`User not found with email: ${$}`);let T=await this.createOrUpdateSession({email:$,id:O.id}),Z=new E;if(Z.ctx().setCookie("access_token",T.token,this.accessTokenCookieOptions(Z,T.expiresAt)),T?.user)T.user.extension=await this.config.extendSession(T.user);return T}catch(O){console.log(O)}}async createOrUpdateSessionV2($){let O=await this.createOrUpdateSession($),T=null;if(O?.user)T=await this.config.extendSession(O.user),O.user.extension=T;return O}async createOrUpdateSession($){let O=new E,T=$.id??(await this.userProvider.findUserByEmailAddress($.email,!1))?.id;if(!T)throw new q1;let Z=Bun.env.NODE_ENV==="development"?"local":O.headers.get("User-Agent"),f=kW(T),j=await this.userProvider.createSessionV2({token:f,userId:T,userAgent:Z,...this.freshLifetime(Date.now())}),W=await this.userProvider.findSession({token:f,userAgent:Z??""});return W?.user?W:j}async createMagicLinkToken($){let O=await this.userProvider.findUserByEmailAddress($,!1);if(O){await this.userProvider.deleteMagicLinkToken($);let T=await this.config.generateMagicLinkToken($),Z=(Number.parseInt(DF(4).toString("hex"),16)%1e6).toString().padStart(6,"0");return await this.userProvider.createMagicLinkToken({email:$,token:T,pin:Z}),{user:O,email:$,pin:Z,token:T}}return{}}}import{AsyncLocalStorage as XF}from"async_hooks";class JW{config;static token="broadcast";publishCb;context=new XF;constructor($){this.config=$}get channels(){return this.config.channels}onPublish($){this.publishCb=$}publish(...$){let[O,T,Z]=$;this.publishCb(O,T,Z)}async handleMessage($,O){let T=JSON.parse(O);if(T.type==="subscribe"){let Z=Object.entries(this.channels).sort(([f],[j])=>f.length-j.length);for(let[f,j]of Z){let W=new URLPattern({pathname:f});if(W.test({pathname:T.topic})){let z=W.exec({pathname:T.topic})?.pathname.groups,J=new j;if(await J.subscribe.call(J,z))$.subscribe(T.topic);break}}}if(T.type==="broadcast")$.publish(T.topic,JSON.stringify({topic:T.topic,data:T.payload}));if(T.type==="unsubscribe")$.unsubscribe(T.topic)}run($,O){let T=r4($.get("Cookie"));this.context.run({headers:$,cookies:T},O)}}class QZ extends O0{static getFacadeAccessor(){return JW}static channel($,O){let T=this.getFacadeRoot(),Z=T.channels[$];if(!Z)return console.error(`Channel ${$} not found`),{publish:()=>{}};let f=new Z;return{publish:(j,W=!1)=>{let z=s($,O);T.publish(z,JSON.stringify({topic:z,data:f.publish(j)}),W)}}}}class T$ extends O0{static getFacadeAccessor(){return w}static async user(){let $=x.getStore(),O=QZ.getFacadeRoot().context.getStore(),T="",Z="";if($?.req)T=$.req.cookies.get("access_token"),Z=$.req.headers.get("User-Agent");if(O?.cookies)Z=O.headers.get("User-Agent"),T=O.cookies.get("access_token");let f=$?.user;if(!f)f=(await this.getFacadeRoot().getSession(T,Z))?.user,$?.setUser(f);if(f)return f;throw new q1({redirectTo:sO($?.req,this.getFacadeRoot().config.signInPath)})}static intendedUrl($){let O=x.getStore()?.req;return $O(O?.search.get(D$),$??this.getFacadeRoot().config.redirectPath)}static async guard($){let O=await T$.user();if(!await $(O))throw new kZ}static async guardSafe($){let O=await T$.user();try{return await $(O)}catch(T){return!1}}static async authenticate($){return await this.getFacadeRoot().authenticate($)}static async createMagicLink($){return await this.getFacadeRoot().createMagicLinkToken($)}}class SZ{static ensure($,O={}){let T=x.getStore();if(T.req.kind==="api")throw Error("Query.prefetch() cannot be called from an API request");return T.serverQueries??=new l$(kO(T.req.rawRequest)),T.serverQueries.ensure($,O,"prefetch")}static async instant($,...O){let T=SZ.ensure($,O[0]);if(await T.promise,T.status==="rejected")throw T.error;return T.data}static prefetch($,...O){SZ.ensure($,O[0])}static noPrefetch(){let $=x.getStore();if($.req.kind==="api")throw Error("Query.noPrefetch() cannot be called from an API request");$.serverQueries??=new l$(kO($.req.rawRequest)),$.serverQueries.muteDiscoveryHints()}}function t4($,O,T="/"){let Z=new URL($.origin),f=O.host?O.host:O.subdomain?`${O.subdomain}.${$.root}`:$.root,j=new URL(T.startsWith("/")?T:`/${T}`,Z),W=UF(f);if(!W)throw Error(`"${f}" 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(j.hostname=W.hostname,W.port)j.port=W.port;return j.toString()}function UF($){try{let O=new URL(`http://${$.trim()}`);return O.host===$.trim().toLowerCase()&&O.pathname==="/"?{hostname:O.hostname,port:O.port}:null}catch{return null}}class e4{static absolute($,...O){return`${process.env.HOST_NAME}${s(String($),O[0]??{})}`}static relative($,...O){return s(String($),O[0]??{})}static forDomain($,O,...T){let Z=K(s0).resolver;if(!Z)throw Error("`Url.forDomain` needs `route.domains` to be configured.");let f=x.getStore()?.req?.rawRequest,j=f?Z.publicOrigin(f):process.env.HOST_NAME;if(!j)throw Error("`Url.forDomain` outside a request needs `HOST_NAME` for the protocol.");return t4({root:Z.root,origin:j},$,s(String(O),T[0]??{}))}}class $5{name="Meta";static description($){x.getStore().metadata.description($)}static title($){x.getStore().metadata.title($)}static openGraph($){x.getStore().metadata.openGraph($)}}var GF={set($,O,T){x.getStore().setCookie($,O,T)},setIfAbsent($,O,T){if(x.getStore().req.cookies.has($))return!1;return x.getStore().setCookie($,O,T),!0},delete($,O){x.getStore().deleteCookie($,O)}};class CW{config;static token="redis";instance=null;constructor($={}){this.config=$}get client(){return this.instance??=new(BF())(this.config.url,this.config.options)}set client($){this.instance=$}}function BF(){let $=globalThis.Bun?.RedisClient;if(typeof $!=="function")throw Error("Redis requires Bun's built-in Redis client, which this runtime does not provide. Run the app under Bun, or bind your own client for the 'redis' token.");return $}class X1 extends O0{static getFacadeAccessor(){return CW}static get client(){return this.getFacadeRoot().client}static get($){return X1.client.get($)}static set($,O){return X1.client.set($,O)}static del(...$){return X1.client.del(...$)}static exists($){return X1.client.exists($)}static incr($){return X1.client.incr($)}static expire($,O){return X1.client.expire($,O)}static ttl($){return X1.client.ttl($)}}class O5 extends O0{static getFacadeAccessor(){return X$}static consume($,O={}){return this.getFacadeRoot().consume($,O)}}class T5 extends O0{static getFacadeAccessor(){return h$}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($,O,T){return this.getFacadeRoot().set($,O,T)}static refresh(){return this.getFacadeRoot().refresh()}static invalidate(){return this.getFacadeRoot().invalidate()}}class MZ{bound;constructor($){this.bound=$}get name(){return this.bound??TO()}get sql(){return this.connection().sql}get dialect(){return this.connection().dialect}async query($){return await this.run($,"query")}async execute($){let O=await this.run($,"execute");return Number(O?.count??0)}async transaction($){let O=this.name,T=this.connection(O);return j5(T.sql,(Z)=>Z5(O,()=>$(Z)),{slowTransactionThreshold:T.config.slowTransactionThreshold,connection:O})}async schema(){let $=this.connection(),{introspect:O}=await import("./chunk-ve6v5t13.js");return O(this.handle()??$.sql,$.dialect)}run($,O){let T=this.connection(),{text:Z,values:f}=z5($,W5(T.dialect),O);return(this.handle()??T.sql).unsafe(Z,f)}handle(){let $=OO();if($===void 0)return;return TO()===this.name?$:void 0}connection($=this.name){return f5($),K(ZO).connection($)}}var o$=new MZ;class J5 extends O0{static getFacadeAccessor(){return ZO}static connection($){return new MZ($)}static get sql(){return o$.sql}static get dialect(){return o$.dialect}static query($){return o$.query($)}static execute($){return o$.execute($)}static transaction($){return o$.transaction($)}static schema(){return o$.schema()}static close(){return this.getFacadeRoot().close()}}export{G1 as ic,e$ as jc,EZ as kc,x0 as lc,AZ as mc,KW as nc,uO as oc,wZ as pc,B1 as qc,v0 as rc,M5 as sc,V5 as tc,mZ as uc,qZ as vc,kW as wc,TD as xc,mW as yc,H5 as zc,iZ as Ac,JW as Bc,QZ as Cc,T$ as Dc,i$ as Ec,SZ as Fc,e4 as Gc,vO as Hc,R1 as Ic,$5 as Jc,GF as Kc,CW as Lc,X1 as Mc,X$ as Nc,O5 as Oc,N4 as Pc,nj as Qc,E4 as Rc,P4 as Sc,kC as Tc,_4 as Uc,aj as Vc,yC as Wc,pC as Xc,oj as Yc,A4 as Zc,H4 as _c,h$ as $c,T5 as ad,MZ as bd,J5 as cd,Qj as dd,Sj as ed,pD as fd,l2 as gd,d2 as hd,gO as id,fX as jd,u2 as kd,s2 as ld,hj as md,uj as nd,d$ as od,rj as pd,TW as qd,TF as rd,$W as sd,jF as td,yO as ud,bZ as vd,AW as wd,nO as xd,fW as yd,y4 as zd,p4 as Ad,LZ as Bd,s0 as Cd,w as Dd,IW as Ed,xW as Fd,NW as Gd,wW as Hd,bW as Id,vW as Jd};
|
|
18
|
+
|
|
19
|
+
//# debugId=4A5BBC079811DFDF64756E2164756E21
|