gemi 0.73.0 → 0.74.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/broadcasting/index.js +1 -1
- package/dist/bun/plugin.js +1 -1
- package/dist/bun/preload.js +1 -1
- package/dist/{chunk-a77h1r8r.js → chunk-0yfgptrq.js} +2 -2
- package/dist/{chunk-a77h1r8r.js.map → chunk-0yfgptrq.js.map} +1 -1
- package/dist/{chunk-g9n3909s.js → chunk-14pybfjk.js} +2 -2
- package/dist/{chunk-g9n3909s.js.map → chunk-14pybfjk.js.map} +1 -1
- package/dist/{chunk-wg1g7qbk.js → chunk-15gc8m24.js} +2 -2
- package/dist/{chunk-wg1g7qbk.js.map → chunk-15gc8m24.js.map} +1 -1
- package/dist/{chunk-g1gbqb9b.js → chunk-17q5kheg.js} +2 -2
- package/dist/{chunk-g1gbqb9b.js.map → chunk-17q5kheg.js.map} +1 -1
- package/dist/{chunk-z8rj43d3.js → chunk-1k0gv92y.js} +2 -2
- package/dist/{chunk-z8rj43d3.js.map → chunk-1k0gv92y.js.map} +1 -1
- package/dist/{chunk-mcf10epc.js → chunk-1rnzaqpm.js} +2 -2
- package/dist/{chunk-mcf10epc.js.map → chunk-1rnzaqpm.js.map} +1 -1
- package/dist/{chunk-d5qv8rny.js → chunk-1x8gzkpq.js} +2 -2
- package/dist/{chunk-d5qv8rny.js.map → chunk-1x8gzkpq.js.map} +1 -1
- package/dist/{chunk-m99atvze.js → chunk-1yr8qejy.js} +2 -2
- package/dist/{chunk-m99atvze.js.map → chunk-1yr8qejy.js.map} +1 -1
- package/dist/{chunk-tdqn1fqd.js → chunk-26rqzgsr.js} +2 -2
- package/dist/{chunk-tdqn1fqd.js.map → chunk-26rqzgsr.js.map} +1 -1
- package/dist/{chunk-9mbdndpk.js → chunk-371tt28q.js} +4 -4
- package/dist/{chunk-9mbdndpk.js.map → chunk-371tt28q.js.map} +1 -1
- package/dist/{chunk-96s7s9vk.js → chunk-3dd2gwrj.js} +2 -2
- package/dist/{chunk-96s7s9vk.js.map → chunk-3dd2gwrj.js.map} +1 -1
- package/dist/{chunk-nnwnj4jb.js → chunk-3eejq348.js} +3 -3
- package/dist/{chunk-nnwnj4jb.js.map → chunk-3eejq348.js.map} +1 -1
- package/dist/{chunk-g9ngr0yr.js → chunk-3nxkn558.js} +2 -2
- package/dist/{chunk-g9ngr0yr.js.map → chunk-3nxkn558.js.map} +1 -1
- package/dist/{chunk-1wmv5pfx.js → chunk-3sdrj0ma.js} +2 -2
- package/dist/{chunk-1wmv5pfx.js.map → chunk-3sdrj0ma.js.map} +1 -1
- package/dist/{chunk-mrrcyw69.js → chunk-407t1q1d.js} +2 -2
- package/dist/{chunk-mrrcyw69.js.map → chunk-407t1q1d.js.map} +1 -1
- package/dist/{chunk-n2m5x0k8.js → chunk-43t1js09.js} +2 -2
- package/dist/{chunk-n2m5x0k8.js.map → chunk-43t1js09.js.map} +1 -1
- package/dist/{chunk-nrfbbc2c.js → chunk-4z5qqq1t.js} +2 -2
- package/dist/{chunk-nrfbbc2c.js.map → chunk-4z5qqq1t.js.map} +1 -1
- package/dist/{chunk-ess09cxa.js → chunk-62pzr6vf.js} +3 -3
- package/dist/{chunk-ess09cxa.js.map → chunk-62pzr6vf.js.map} +1 -1
- package/dist/{chunk-4pbt2n36.js → chunk-7e4rhaqs.js} +2 -2
- package/dist/{chunk-4pbt2n36.js.map → chunk-7e4rhaqs.js.map} +1 -1
- package/dist/{chunk-mnqfa84m.js → chunk-8ef9n5pk.js} +2 -2
- package/dist/{chunk-mnqfa84m.js.map → chunk-8ef9n5pk.js.map} +1 -1
- package/dist/{chunk-p8bgd7vp.js → chunk-8jgj7vdp.js} +2 -2
- package/dist/{chunk-p8bgd7vp.js.map → chunk-8jgj7vdp.js.map} +1 -1
- package/dist/{chunk-mrhqmd89.js → chunk-8rqdeyhv.js} +2 -2
- package/dist/{chunk-mrhqmd89.js.map → chunk-8rqdeyhv.js.map} +1 -1
- package/dist/{chunk-zcg2nj18.js → chunk-8ypzxfvx.js} +2 -2
- package/dist/{chunk-zcg2nj18.js.map → chunk-8ypzxfvx.js.map} +1 -1
- package/dist/{chunk-2ks8sxm6.js → chunk-9ecgk1c5.js} +2 -2
- package/dist/{chunk-2ks8sxm6.js.map → chunk-9ecgk1c5.js.map} +1 -1
- package/dist/{chunk-ygt0r1hh.js → chunk-9gn3x603.js} +1 -1
- package/dist/{chunk-cj7wywny.js → chunk-9h0cz1f0.js} +2 -2
- package/dist/{chunk-cj7wywny.js.map → chunk-9h0cz1f0.js.map} +1 -1
- package/dist/{chunk-kz4dssae.js → chunk-9p5vwn4d.js} +2 -2
- package/dist/{chunk-kz4dssae.js.map → chunk-9p5vwn4d.js.map} +1 -1
- package/dist/{chunk-bshgagpe.js → chunk-9sqw5bjy.js} +2 -2
- package/dist/{chunk-bshgagpe.js.map → chunk-9sqw5bjy.js.map} +1 -1
- package/dist/{chunk-a4wng53r.js → chunk-a1n0thja.js} +2 -2
- package/dist/{chunk-a4wng53r.js.map → chunk-a1n0thja.js.map} +1 -1
- package/dist/{chunk-g1j6bj44.js → chunk-a4xxmmct.js} +2 -2
- package/dist/{chunk-g1j6bj44.js.map → chunk-a4xxmmct.js.map} +1 -1
- package/dist/{chunk-ewtfq0zc.js → chunk-a82m12q4.js} +3 -3
- package/dist/{chunk-ewtfq0zc.js.map → chunk-a82m12q4.js.map} +1 -1
- package/dist/{chunk-rdffbqsq.js → chunk-achgw308.js} +2 -2
- package/dist/{chunk-rdffbqsq.js.map → chunk-achgw308.js.map} +1 -1
- package/dist/{chunk-baav1dfa.js → chunk-bm97dwbp.js} +2 -2
- package/dist/{chunk-baav1dfa.js.map → chunk-bm97dwbp.js.map} +1 -1
- package/dist/{chunk-vta5fnxp.js → chunk-cr2wpeh5.js} +2 -2
- package/dist/{chunk-vta5fnxp.js.map → chunk-cr2wpeh5.js.map} +1 -1
- package/dist/{chunk-yty60qzd.js → chunk-d6dz2706.js} +2 -2
- package/dist/{chunk-yty60qzd.js.map → chunk-d6dz2706.js.map} +1 -1
- package/dist/{chunk-p4ndrnar.js → chunk-dz7b35tn.js} +3 -3
- package/dist/{chunk-p4ndrnar.js.map → chunk-dz7b35tn.js.map} +1 -1
- package/dist/{chunk-ve6v5t13.js → chunk-evbvpfv6.js} +1 -1
- package/dist/{chunk-x6yef8np.js → chunk-f90k29w1.js} +2 -2
- package/dist/{chunk-x6yef8np.js.map → chunk-f90k29w1.js.map} +1 -1
- package/dist/{chunk-d341xmqy.js → chunk-fy2f8sq8.js} +2 -2
- package/dist/{chunk-d341xmqy.js.map → chunk-fy2f8sq8.js.map} +1 -1
- package/dist/{chunk-1g38vvqa.js → chunk-g2hwd2ts.js} +2 -2
- package/dist/{chunk-1g38vvqa.js.map → chunk-g2hwd2ts.js.map} +1 -1
- package/dist/{chunk-e7sjbe2v.js → chunk-gpys09rg.js} +3 -3
- package/dist/{chunk-e7sjbe2v.js.map → chunk-gpys09rg.js.map} +1 -1
- package/dist/{chunk-8vwegd30.js → chunk-j9r5w8xf.js} +2 -2
- package/dist/{chunk-8vwegd30.js.map → chunk-j9r5w8xf.js.map} +1 -1
- package/dist/{chunk-qjrswqwd.js → chunk-jpej3172.js} +2 -2
- package/dist/{chunk-qjrswqwd.js.map → chunk-jpej3172.js.map} +1 -1
- package/dist/chunk-krjkgg9v.js +5 -0
- package/dist/{chunk-cpnxj3jp.js.map → chunk-krjkgg9v.js.map} +1 -1
- package/dist/{chunk-1985hs9y.js → chunk-mc7nbgct.js} +2 -2
- package/dist/{chunk-1985hs9y.js.map → chunk-mc7nbgct.js.map} +1 -1
- package/dist/{chunk-n28jwe5c.js → chunk-msqr4d2d.js} +2 -2
- package/dist/{chunk-n28jwe5c.js.map → chunk-msqr4d2d.js.map} +1 -1
- package/dist/{chunk-vn29fg7p.js → chunk-pjcdekm1.js} +2 -2
- package/dist/{chunk-vn29fg7p.js.map → chunk-pjcdekm1.js.map} +1 -1
- package/dist/{chunk-2aqjpyfn.js → chunk-pjd63e8g.js} +2 -2
- package/dist/{chunk-2aqjpyfn.js.map → chunk-pjd63e8g.js.map} +1 -1
- package/dist/{chunk-qsczv1xt.js → chunk-pp9c3f5m.js} +2 -2
- package/dist/{chunk-qsczv1xt.js.map → chunk-pp9c3f5m.js.map} +1 -1
- package/dist/{chunk-n3d4vv6y.js → chunk-pxfw8dg1.js} +2 -2
- package/dist/{chunk-n3d4vv6y.js.map → chunk-pxfw8dg1.js.map} +1 -1
- package/dist/{chunk-yw8rp9nc.js → chunk-q60vevbt.js} +2 -2
- package/dist/{chunk-yw8rp9nc.js.map → chunk-q60vevbt.js.map} +1 -1
- package/dist/{chunk-ntgp0dqx.js → chunk-qn7rr4bw.js} +2 -2
- package/dist/{chunk-ntgp0dqx.js.map → chunk-qn7rr4bw.js.map} +1 -1
- package/dist/chunk-smr9jn4z.js +19 -0
- package/dist/{chunk-m2j219n1.js.map → chunk-smr9jn4z.js.map} +7 -7
- package/dist/{chunk-6z7mskmy.js → chunk-t20b1xn4.js} +3 -3
- package/dist/{chunk-6z7mskmy.js.map → chunk-t20b1xn4.js.map} +1 -1
- package/dist/{chunk-nzkywxk9.js → chunk-w8jyvdgd.js} +2 -2
- package/dist/{chunk-nzkywxk9.js.map → chunk-w8jyvdgd.js.map} +1 -1
- package/dist/{chunk-sh75zszh.js → chunk-wbxmwzdb.js} +1 -1
- package/dist/{chunk-qcqw9z1t.js → chunk-wtwkzgec.js} +2 -2
- package/dist/{chunk-qcqw9z1t.js.map → chunk-wtwkzgec.js.map} +1 -1
- package/dist/chunk-xrd9xx3c.js +5 -0
- package/dist/{chunk-ndh57kp0.js.map → chunk-xrd9xx3c.js.map} +3 -3
- package/dist/{chunk-aw6qsgnz.js → chunk-yqb9cpkx.js} +2 -2
- package/dist/{chunk-aw6qsgnz.js.map → chunk-yqb9cpkx.js.map} +1 -1
- package/dist/{chunk-j2g3a8tr.js → chunk-ywf0kz71.js} +2 -2
- package/dist/{chunk-j2g3a8tr.js.map → chunk-ywf0kz71.js.map} +1 -1
- package/dist/{chunk-zp2yz0yr.js → chunk-zat41156.js} +3 -3
- package/dist/{chunk-zp2yz0yr.js.map → chunk-zat41156.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/ApiRouter.d.ts.map +1 -1
- package/dist/http/index.js +2 -2
- package/dist/http/index.js.map +1 -1
- package/dist/http/requestDomain.d.ts +3 -0
- package/dist/http/requestDomain.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 +2 -2
- 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/services/router/DomainResolver.d.ts +26 -8
- package/dist/services/router/DomainResolver.d.ts.map +1 -1
- package/dist/services/router/DomainRouter.d.ts.map +1 -1
- package/dist/services/router/config.d.ts +40 -4
- package/dist/services/router/config.d.ts.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-cpnxj3jp.js +0 -5
- package/dist/chunk-m2j219n1.js +0 -19
- package/dist/chunk-ndh57kp0.js +0 -5
- /package/dist/{chunk-ygt0r1hh.js.map → chunk-9gn3x603.js.map} +0 -0
- /package/dist/{chunk-ve6v5t13.js.map → chunk-evbvpfv6.js.map} +0 -0
- /package/dist/{chunk-sh75zszh.js.map → chunk-wbxmwzdb.js.map} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Md as lW,Td as D5}from"./chunk-q60vevbt.js";import{Ke as C5,_d as a$,de as qO}from"./chunk-ngq4n2b3.js";import{$e as mO,Le as kT,Ne as T5,Pe as u4,Qe as vW,Re as ET,Se as xT,Ve as PT,We as _T,Xe as s$,Ye as m4,Ze as t4,_e as BW,af as m1,bf as x0,df as P,ef as mT,ff as qT,gf as HT,if as q1,jf as O0,kf as YT}from"./chunk-xrd9xx3c.js";import{rf as _4,sf as TW,tf as N}from"./chunk-8ypzxfvx.js";import{uf as Z5}from"./chunk-8ef9n5pk.js";import{If as F5,vf as s4,wf as OO,xf as ZO,yf as Y5,zf as X5}from"./chunk-62pzr6vf.js";import{Xf as TO}from"./chunk-achgw308.js";import{ag as i4,fg as h4}from"./chunk-yqb9cpkx.js";import{lg as c4,mg as n}from"./chunk-9p5vwn4d.js";import{pg as K}from"./chunk-zat41156.js";import{qg as u$}from"./chunk-bm97dwbp.js";import{Cg as Pj}from"./chunk-ywf0kz71.js";import{Eg as n4}from"./chunk-7e4rhaqs.js";import{Jg as jW}from"./chunk-1x8gzkpq.js";import{randomBytes as SX}from"crypto";function lO($){return typeof $==="function"&&$.prototype!==void 0}function G1($){return typeof $==="string"?[$]:$}function dO($,O){let Z=O?"attachment":"inline",T=$.replace(/["\\]/g,"").replace(/[^\x20-\x7e]/g,"_");return`${Z}; filename="${T}"; filename*=UTF-8''${encodeURIComponent($)}`}function N5($){return"total"in $&&"partial"in $&&"body"in $}function e$($){return new Response(null,{status:416,headers:{"Accept-Ranges":"bytes","Content-Range":_T($),"Content-Length":"0","Cache-Control":"no-store"}})}async function x5($){if($ instanceof Blob)return{body:$,start:0,end:$.size-1,total:$.size,partial:!1,type:$.type,name:$.name,download:!1,status:200,extraHeaders:{}};if(N5($))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,Z=O instanceof Blob?O:null,T=$.total??Z?.size??-1;return{body:O,start:$.start??0,end:$.end??T-1,total:T,partial:$.partial??!1,type:$.type??Z?.type??"",name:$.name??O?.name,download:$.download??!1,etag:$.etag,lastModified:$.lastModified,status:$.status??200,extraHeaders:$.headers??{}}}async function AT($,O){if($ instanceof Response)return $;if(!$)return new Response("Not found",{status:404});let Z=await x5($),{body:T,start:f,end:j,total:W,partial:z}=Z;if(T instanceof Blob&&"exists"in T&&typeof T.exists==="function"){if(!await T.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(T instanceof Blob){let F=xT(J,W);if(!F)return e$(W);T=T.slice(F.start,F.end+1),f=F.start,j=F.end,z=!0}}}let Y=Boolean(J)&&z,X=Y?206:Z.status,C=new Headers;if(C.set("Accept-Ranges","bytes"),C.set("Content-Type",Z.type||"application/octet-stream"),Y)C.set("Content-Range",PT(f,j,W)),C.set("Content-Length",String(j-f+1));else if(W>=0)C.set("Content-Length",String(W));if(Z.name)C.set("Content-Disposition",dO(Z.name,Z.download));if(Z.etag)C.set("ETag",Z.etag);if(Z.lastModified)C.set("Last-Modified",Z.lastModified.toUTCString());for(let[F,U]of Object.entries(Z.extraHeaders))C.set(F,U);if((O.method??"GET").toUpperCase()==="HEAD"){if(T&&"cancel"in T&&typeof T.cancel==="function")await T.cancel();return new Response(null,{status:X,headers:C})}return new Response(T,{status:X,headers:C})}function GW($){return lO($)}class u{method;handler;methodName;__internal_brand="RouteHandler";middlewares=[];constructor($,O,Z){this.method=$;this.handler=O;this.methodName=Z;this.handler=O,this.methodName=Z,this.method=$}get source(){if(!GW(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(GW(this.handler)){let O=new this.handler;return O[this.methodName].bind(O)()}return this.handler()}middleware($){return this.middlewares=G1($),this}}class KW{url;headers;__internal_brand="ProxyHandler";constructor($,O){this.url=$;this.headers=O}run(){let $=new P,O=$.headers.toJSON();for(let Z of BW($.rawRequest))delete O[Z];return fetch(this.url,{method:$.rawRequest.method,headers:{...O,...this.headers},body:$.rawRequest.body})}}class QW{constructor(...$){return new u(...$)}}class VW extends u{__internal_brand="StreamHandler";async run($){let O=N.getStore(),Z=O?.req?.rawRequest,T=ET(Z?.headers.get("Range"));if(O)O.rangeRequest=T;try{let f=await super.run($);return await AT(f,{range:T,method:Z?.method})}catch(f){if(f instanceof HT)return e$(f.total);throw f}finally{if(O)O.rangeRequest=null}}}class LW{constructor(...$){return new VW(...$)}}class SW{__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 N0{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 SW($)}agent($){return P5($,this)}file($,O){return new QW("GET",$,O)}stream($,O){return new LW("GET",$,O)}proxy($,O={}){return new KW($,O)}}function P5($,O){let Z={stream:new u("POST",$,"stream"),attach:new u("POST",$,"attach"),stop:new u("POST",$,"stop"),upload:new u("POST",$,"upload")};return class extends N0{static __internal_brand="AgentRoute";static controller=$;static handlers=Z;constructor(){super();this.middlewares=[...O?.middlewares??[]]}routes={"/":Z.stream,"/attach":Z.attach,"/stop":Z.stop,"/files":Z.upload};static middleware(f){if(f.stream)Z.stream.middleware(f.stream);if(f.attach)Z.attach.middleware(f.attach);if(f.stop)Z.stop.middleware(f.stop);if(f.upload)Z.upload.middleware(f.upload);return this}}}class wT{method;url;meta;__internal_brand="McpRoute";constructor($,O,Z){this.method=$;this.url=O;this.meta=Z}}class IW{static __brand="McpRouter";routes={};fromApiRoute($,O,Z){return new wT($,O,Z)}}function s($,O){return $.replace(/:([^/]+[*?]?)/g,(Z,T)=>{let f=T.endsWith("?")||T.endsWith("*"),j=f?T.slice(0,-1):T,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 bT 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[Z={}]=O,{search:T={},params:f={},permanent:j,status:W}={params:{},status:307,permanent:!1,...Z},z=new URLSearchParams(T).toString();throw new bT([s($,f)||"/",z.toString()].filter(Boolean).join("?"),W??(j?301:307))}static external($,O=307){throw new bT($,O)}}class MW{kind="redirect";viewPath="REDIRECT";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>({});else if(typeof $==="function")this.handler=$;else{let[O,Z]=$;this.handler=(T)=>{return new O()[Z](T)}}}async run($,O){let{destination:Z,permanent:T=!1,status:f=307}=await this.handler($);if(!Z)throw Error(`Redirect destination is required see ${O}`);return uO.to(Z,{permanent:T,status:f}),{}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}async function vT($,O){if($ instanceof Response)return $;let Z=$ instanceof Blob,T=Z?$:$.file,f=Z?$.name:$.name??$.file?.name,j=(Z?$.type:$.type??$.file?.type)||"",W=Z?!1:$.download??!1,z=Z?200:$.status??200;if(!Z)for(let[J,Y]of Object.entries($.headers??{}))O.set(J,Y);if(T instanceof Blob&&"exists"in T&&typeof T.exists==="function"){if(!await T.exists())return new Response("Not found",{status:404})}if(O.set("Content-Type",j||"application/octet-stream"),T instanceof Blob)O.set("Content-Length",String(T.size));if(f)O.set("Content-Disposition",dO(f,W));return new Response(T instanceof Blob?T.stream():T,{status:z,headers:O})}class NW{kind="file";viewPath="FILE";middlewares=[];featureGates=[];handler;constructor($){if(!$)this.handler=()=>null;else if(typeof $==="function")this.handler=$;else{let[O,Z]=$;this.handler=(T)=>{return new O()[Z](T)}}}async run($,O){let Z=await this.handler($);if(!Z)throw Error(`File route handler must return a file see ${O}`);return{FILE:Z}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class xW{viewPath;middlewares=[];featureGates=[];handler;constructor($,O){this.viewPath=$;if(!O)this.handler=()=>({});else if(typeof O==="function")this.handler=O;else{let[Z,T]=O;this.handler=(f)=>{return new Z()[T](f)}}}async run($,O){let Z=await this.handler($);return{[this.viewPath]:{...Z,breadcrumb:{label:Z?.breadcrumb??"",href:O}}}}middleware($){return this.middlewares=G1($),this}feature($){return this.featureGates=[...this.featureGates,$],this}}class PW{viewPath;children;middlewares=[];featureGates=[];alwaysRuns=!1;handler=()=>({});constructor($,O,Z){this.viewPath=$;if(typeof O==="function")this.handler=O,this.children=class extends B1{routes=Z??{}};else if(Array.isArray(O)){let[T,f]=O;this.handler=(j)=>{return new T()[f](j)},this.children=class extends B1{routes=Z??{}}}else this.children=class extends B1{routes=O},this.handler=()=>({})}async run($,O){let Z=await this.handler($);return{[this.viewPath]:{...Z,breadcrumb:{label:Z?.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 xW($,O)}file($){return new NW($)}redirect($){return new MW($)}layout($,O,Z){return new PW($,O,Z)}}class v0{req;config={};constructor($){this.req=$}run(...$){return{}}static configure($){let O=this;return class extends O{config=$}}}function _5($){return $}function A5(){return{aliases:{},global:[]}}var C$="redirect";function $O($,O="/"){if(typeof $!=="string"||!$.startsWith("/"))return O;if(/[\u0000-\u001f\u007f\\]/.test($)||$.startsWith("//"))return O;try{let Z=new URL($,"http://gemi.invalid");if(Z.origin!=="http://gemi.invalid")return O;let T=`${Z.search}${Z.hash}`.replaceAll("/","%2F"),f=`${Z.pathname}${T}`.replaceAll(":","%3A");return f.startsWith("//")?O:f}catch{return O}}function _W($){let O=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim();return O?O==="https":new URL($.url).protocol==="https:"}function E5($,O=!0){let Z=new URL($.rawRequest.url),T=Z.pathname.replace(/\.(json|og)$/,""),[,f,...j]=T.split("/");if(K(n).supportedLocales.includes(f))T=`/${j.join("/")}`;return O?`${T}${Z.search}`:T}function H5($,O){let Z=(T)=>T.replace(/\/+$/,"")||"/";return Z($)===Z(O)}function sO($,O){let Z=O||K(w).config.signInPath,T=/^[a-z][a-z\d+.-]*:/i.test(Z);if(T?!/^https?:\/\//i.test(Z):!Z.startsWith("/"))throw Error(`\`auth.signInPath\` must be a path like "/auth/sign-in", or an http(s) URL for sign-in hosted elsewhere. Got "${Z}". A route's own \`"auth:<path>"\` cannot carry a URL, because the alias parser splits it on the colon.`);let f=new URL(Z,"http://gemi.invalid");if($?.kind==="view"){let j=E5($,!T);if(T||!H5(new URL(j,f).pathname,f.pathname))f.searchParams.set(C$,j)}return T?f.href:`${f.pathname}${f.search}`}class AW extends v0{async run($){let O=N.getStore(),Z=O.req,T=()=>new q1({redirectTo:sO(Z,$)}),f=Z.cookies.get("access_token"),j=Z.headers.get("access_token"),W=f||j;if(!W)throw T();let z=O.user;if(!z){let J=await K(w).getSession(W,Z.headers.get("User-Agent"));if(!J)throw T();z=J?.user,O.setUser(z)}return{}}}class EW extends v0{async run(...$){let[O="public",Z="864000",...T]=$,f=`${O}, max-age=${Z}${T.length>0?", ":""}${T.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 w5={"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 HW 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 Z={...w5,...this.config.origins[O]};for(let[T,f]of Object.entries(Z))$.ctx().setHeaders(T,f)}return{}}}class D${config;static token="ratelimiter";constructor($){this.config=$}get driver(){return this.config.driver}async consume($,O={}){let Z=O.limit??this.config.limit,T=O.window??this.config.window,f=O.cost??1;if(wW("window",T),wW("limit",Z),!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:Z,window:T*1000,cost:f})}}function wW($,O){if(!Number.isFinite(O)||O<=0)throw Error(`Rate limiter ${$} must be greater than zero, got ${O}`)}class gT extends m1{constructor($){super("Rate limit exceeded");let O={"Content-Type":"application/json",...$?RW($):{}};this.payload={api:{status:429,data:{error:{message:"Rate limit exceeded"}},headers:O},view:{error:{message:"Rate limit exceeded"},status:429,headers:O}}}}class gW extends v0{async run($,O){let Z=b5();if(!Z)return{};let T=await Z.consume(this.key(),{limit:bW($)??this.config.limit,window:bW(O)??this.config.window});if(this.config.headers!==!1){let f=this.req.ctx?.();if(f)for(let[j,W]of Object.entries(RW(T)))f.setHeaders(j,W)}if(!T.allowed)throw new gT(T);return{}}key(){if(this.config.key)return this.config.key(this.req);return`${nO(this.req)}:${this.req.routePath??"*"}`}}function b5(){try{let $=K();return $.bound(D$)?$.make(D$):null}catch{return null}}function nO($){let O=vW($.rawRequest);if(O!==void 0)return O;let Z=$.headers.get("x-forwarded-for");if(Z){let[T]=Z.split(",");if(T?.trim())return T.trim()}return $.headers.get("x-real-ip")?.trim()||"unknown"}function RW($){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 bW($){if($===void 0||$===null||$==="")return;let O=Number($);if(!Number.isFinite(O)||O<=0)return;return O}class kW extends v0{async run(){let $=this.req.cookies.get("csrf_token");if(!$)throw new RT;if(!["POST","PUT","PATCH","DELETE"].includes(this.req.rawRequest.method))return{};if(!Bun.CSRF.verify($,{secret:process.env.SECRET}))throw new RT;return{}}}class RT extends m1{constructor(){super("Invalid CSRF token");this.name="InvalidCSRFTokenError"}payload={api:{status:403,data:{error:"Invalid CSRF token"}},view:{}}}class mW{policiesList={};constructor(){let $=this.register();for(let O of $){let Z=new O;this.policiesList[O.name]=Z}}register(){return[]}}class qW{all($,O){return!0}}import{createHmac as yW,randomBytes as v5}from"crypto";var yT="v2.";function pT($){return $.startsWith(yT)}function pW(){let $=process.env.SECRET;if(!$)throw Error("Signing in needs a secret to mint session tokens with. Set SECRET in the environment.");return $}function cW($){let O=v5(16).toString("hex"),Z=yW("sha256",pW()).update(`${$}:${O}`).digest("hex");return`${yT}${Z}`}function aO($,O){let Z=yW("sha256",pW()).update(`legacy-session:${O}:${$}`).digest("hex");return`${yT}${Z}`}import{randomBytes as iT}from"crypto";class cT extends P{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 C9($){return $}function iW($={}){return{basePath:"/auth",verifyEmail:!0,redirectPath:"/dashboard",signInPath:"/auth/sign-in",sessionExpiresInHours:24,sessionAbsoluteExpiresInHours:672,cookieDomain:null,migrateLegacySession:null,signUpRequest:cT,oauthProviders:{},verifyPassword:async(O,Z)=>await Bun.password.verify(O,Z),hashPassword:async(O)=>await Bun.password.hash(O),generateForgotPasswordToken:async()=>iT(32).toString("hex"),generateEmailVerificationToken:()=>{if(!($.verifyEmail??!0))return"";return iT(32).toString("hex")},generateMagicLinkToken:()=>iT(32).toString("hex"),extendSession:()=>({}),onUserCreated:async()=>{},onSignUp:()=>{},onSignIn:()=>{},onSignOut:()=>{},onForgotPassword:()=>{},onResetPassword:()=>{},onMagicLinkCreated:()=>{}}}function hT($){if($&&typeof $==="object")delete $.password;return $}function g5(){return new Proxy({},{get:($,O)=>lW(O)})}var hW=new WeakMap;function dW($){if($&&typeof $==="object"){for(let O of Object.values($))dW(O);Object.freeze($)}return $}var R5={select:{id:!0,publicId:!0,email:!0,name:!0,locale:!0,globalRole:!0,accounts:{select:{id:!0,publicId:!0,organizationRole:!0,organization:!0}}}},k5=dW({token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:R5});class lT{models;constructor($=g5()){this.models=$}run($){return this.models.User.asSystem($)}sessionSelect(){return k5}transaction($){return this.models.User.transaction($)}withLegacySessionLock($,O){let Z=this.models.User.$connection??ZO(),T=K(TO).connection(Z),f=()=>this.transaction(async()=>{if(T.dialect==="postgres"){let z=`gemi:legacy-session:${$}`;await OO()`SELECT pg_advisory_xact_lock(hashtextextended(${z}, 0))`}return O()});if(T.dialect!=="sqlite"||OO())return f();let W=(hW.get(T)??Promise.resolve()).then(f,f);return hW.set(T,W.catch(()=>{})),W}async createUser($){let O=await this.run(()=>this.models.User.create({data:$}));return hT(O)}async updateUserPassword($){let O=await this.run(()=>this.models.User.update({where:{id:$.id},data:{password:$.password}}));return hT(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 Z=await this.run(()=>this.models.SocialAccount.findFirst({where:{provider:$,providerId:O},include:{user:!0}}));return Z?hT(Z.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:Z}=await this.run(()=>this.models.SocialAccount.updateMany({where:{id:$.id,providerId:$.providerId},data:{providerId:O}}));return Z===1}}function P0($,O,Z,T,f){return m0(O,z6($,O),Z,T,f)}function m0($,O,Z,T,f,j){let W=aT(O,Z,T);if(f&&O!==W)throw RangeError(lz($,O,Z,T,j));return W}function z6($,O){let Z=$[O];if(Z===void 0)throw TypeError(Nf(O));return Z}function W0($){return $!==null&&/object|function/.test(typeof $)}function E0($,O=Map){let Z=new O;return(T,...f)=>{if(Z.has(T))return Z.get(T);let j=$(T,...f);return Z.set(T,j),j}}function T3($){return i1({name:$},1)}function i1($,O){return c0((Z)=>({value:Z,configurable:1,writable:!O}),$)}function J6($){return c0((O)=>({get:O,configurable:1}),$)}function FZ($){return{[Symbol.toStringTag]:{value:$,configurable:1}}}function L$($,O){let Z={},T=$.length;for(let f of O)Z[$[--T]]=f;return Z}function c0($,O,Z){let T={};for(let f in O)T[f]=$(O[f],f,Z);return T}function CO($,O,Z){let T={};for(let f=0;f<O.length;f++){let j=O[f];T[j]=$(j,f,Z)}return T}function m5($,O,Z){let T={};for(let f=0;f<$.length;f++)T[O[f]]=Z[$[f]];return T}function w0($,O){let Z={};for(let T of $)Z[T]=O[T];return Z}function f3($,O){let Z={};for(let T in O)$.has(T)||(Z[T]=O[T]);return Z}function j3($){$={...$};let O=Object.keys($);for(let Z of O)$[Z]===void 0&&delete $[Z];return $}function Y6($,O){for(let Z of O)if(!(Z in $))return 0;return 1}function X6($,O,Z){for(let T of $)if(O[T]!==Z[T])return 0;return 1}function F6($,O,Z){let T={...Z};for(let f=0;f<O;f++)T[$[f]]=0;return T}function b($,...O){return(...Z)=>$(...O,...Z)}function uW($){return $[0].toUpperCase()+$.substring(1)}function DO($){return $.slice().sort()}function ZZ($,O){return String(O).padStart($,"0")}function K1($,O){return Math.sign($-O)}function aT($,O,Z){return Math.min(Math.max($,O),Z)}function j1($,O){return[Math.floor($/O),jO($,O)]}function jO($,O){return($%O+O)%O}function L1($,O){return[CZ($,O),W3($,O)]}function CZ($,O){return Math.trunc($/O)||0}function W3($,O){return $%O||0}function oO($){return Math.abs($%1)===0.5}function C6($,O,Z){let T=0,f=0;for(let z=0;z<=O;z++){let J=$[Z[z]],Y=a0[z],X=q/Y,[C,F]=L1(J,X);T+=F*Y,f+=C}let[j,W]=L1(T,q);return[f+j,W]}function DZ($,O,Z){let T={};for(let f=O;f>=0;f--){let j=a0[f];T[Z[f]]=CZ($,j),$=W3($,j)}return T}function D6($){return $===v?sZ:[]}function U6($){return $===v?MO:[]}function G6($){return $===v?["year","day"]:[]}function B6($){if($!==void 0)return h($)}function K6($){if($!==void 0)return i0($)}function z3($){if($!==void 0)return UO($)}function i0($){return L6(UO($))}function UO($){return V6(A7($))}function J3($){if($==null)throw TypeError("Cannot be null or undefined");return $}function Q6($,O){if(O==null)throw RangeError(Nf($));return O}function z1($){if(!W0($))throw TypeError(hz);return $}function UZ($,O,Z=$){if(typeof O!==$)throw TypeError(LO(Z,O));return O}function V6($,O="number"){if(!Number.isInteger($))throw RangeError(e5(O,$));return $||0}function L6($,O="number"){if($<=0)throw RangeError($7(O,$));return $}function Y3($){if(typeof $=="symbol")throw TypeError(f7);return String($)}function TZ($,O){return W0($)?String($):h($,O)}function GZ($){if(typeof $=="string")return BigInt($);if(typeof $!="bigint")throw TypeError(T7($));return $}function S6($,O="number"){if(typeof $=="bigint")throw TypeError(Z7(O));if($=Number($),!Number.isFinite($))throw RangeError(O7(O,$));return $}function U0($,O){return Math.trunc(S6($,O))||0}function I6($,O){return V6(S6($,O),O)}function sW($,O){return L6(U0($,O),O)}function X3($,O){let[Z,T]=L1(O,q),f=$+Z,j=Math.sign(f);return j&&j===-Math.sign(T)&&(f-=j,T+=j*q),[f,T]}function G$($,O,Z=1){return X3($[0]+O[0]*Z,$[1]+O[1]*Z)}function B$($,O){return X3($[0],$[1]+O)}function g0($,O){return G$(O,$,-1)}function B0($,O){return K1($[0],O[0])||K1($[1],O[1])}function M6($,O,Z){return B0($,O)===-1||B0($,Z)===1}function BZ($,O=1){let Z=BigInt(q/O);return[Number($/Z),Number($%Z)*O]}function K$($,O=1){let Z=q/O,[T,f]=L1($,Z);return[T,f*O]}function N6($,O=1){let[Z,T]=$,f=Math.floor(T/O),j=q/O;return BigInt(Z)*BigInt(j)+BigInt(f)}function R0($,O=1,Z){let[T,f]=$,[j,W]=L1(f,O);return T*(q/O)+(j+(Z?W/O:0))}function F3($,O,Z=j1){let[T,f]=$,[j,W]=Z(f,O);return[T*(q/O)+j,W]}function C3($,O){let Z=$.formatToParts(O),T={};for(let f of Z)T[f.type]=f.value;return T}function D3($){return P0($,"isoYear",FO,XO,1),$.isoYear===FO?P0($,"isoMonth",4,12,1):$.isoYear===XO&&P0($,"isoMonth",1,9,1),$}function Q1($){return J1({...$,...p0,isoHour:12}),$}function J1($){let O=P0($,"isoYear",FO,XO,1),Z=O===FO?1:O===XO?-1:0;return Z&&k0(G0({...$,isoDay:$.isoDay+Z,isoNanosecond:$.isoNanosecond-Z})),$}function k0($){if(!$||M6($,R7,g7))throw RangeError(hZ);return $}function S1($){return C6($,5,u0)[1]}function KZ($){let[O,Z]=j1($,q);return[DZ(Z,5,u0),O]}function x6($){return P6($)[0]}function P6($){return F3($,y0)}function K0($){return S$($.isoYear,$.isoMonth,$.isoDay,$.isoHour,$.isoMinute,$.isoSecond,$.isoMillisecond)}function G0($){let O=K0($);if(O!==void 0){let[Z,T]=L1(O,A0);return[Z,T*o0+($.isoMicrosecond||0)*r1+($.isoNanosecond||0)]}}function U3($,O){let[Z,T]=KZ(S1($)-O);return k0(G0({...$,isoDay:$.isoDay+T,...Z}))}function fZ(...$){return S$(...$)/O2}function S$(...$){let[O,Z]=_6(...$),T=O.valueOf();if(!isNaN(T))return T-Z*A0}function _6($,O=1,Z=1,T=0,f=0,j=0,W=0){let z=$===FO?1:$===XO?-1:0,J=new Date;return J.setUTCHours(T,f,j,W),J.setUTCFullYear($,O-1,Z+z),[J,z]}function M1($,O){let[Z,T]=B$($,O);T<0&&(T+=q,Z-=1);let[f,j]=j1(T,o0),[W,z]=j1(j,r1);return QZ(Z*A0+f,W,z)}function QZ($,O=0,Z=0){let T=Math.ceil(Math.max(0,Math.abs($)-v7)/A0)*Math.sign($),f=new Date($-T*A0);return L$(aZ,[f.getUTCFullYear(),f.getUTCMonth()+1,f.getUTCDate()+T,f.getUTCHours(),f.getUTCMinutes(),f.getUTCSeconds(),f.getUTCMilliseconds(),O,Z])}function A6($){return[$.isoYear,$.isoMonth,$.isoDay]}function E6(){return f1}function G3($,O){switch(O){case 2:return B3($)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function H6($){return B3($)?366:365}function B3($){return $%4==0&&($%100!=0||$%400==0)}function w6($){let[O,Z]=_6($.isoYear,$.isoMonth,$.isoDay);return jO(O.getUTCDay()-Z,7)||7}function b6({isoYear:$}){return $<1?["bce",1-$]:["ce",$]}function q5($){let O=K0($);if(O<m7)return b6($);let Z=C3(hf(Q$),O),{era:T,eraYear:f}=h8(Z,Q$);return[T,f]}function VZ($){return h1($),LZ($,1),$}function h1($){return v6($,1),$}function nW($){return X6(gf,$,v6($))}function v6($,O){let{isoYear:Z}=$,T=P0($,"isoMonth",1,E6(),O);return{isoYear:Z,isoMonth:T,isoDay:P0($,"isoDay",1,G3(Z,T),O)}}function LZ($,O){return L$(u0,[P0($,"isoHour",0,23,O),P0($,"isoMinute",0,59,O),P0($,"isoSecond",0,59,O),P0($,"isoMillisecond",0,999,O),P0($,"isoMicrosecond",0,999,O),P0($,"isoNanosecond",0,999,O)])}function R($){return $===void 0?0:Q2(z1($))}function GO($,O=0){$=h0($);let Z=V2($),T=s7($,O);return[Q2($),T,Z]}function K3($){return V2(h0($))}function g6($){return $=h0($),mf($,9,6,1)}function I$($,O,Z,T=9,f=0,j=4){O=h0(O);let W=mf(O,T,f),z=L3(O),J=xO(O,j),Y=NO(O,T,f,1);return W==null?W=Math.max(Z,Y):q6(W,Y),z=S3(z,Y,1),$&&(J=((X)=>X<4?(X+2)%4:X)(J)),[W,Y,z,J]}function SZ($,O=6,Z){let T=L3($=I3($,XZ)),f=xO($,7),j=NO($,O);return j=Q6(XZ,j),T=S3(T,j,void 0,Z),[j,T,f]}function Q3($){return qf(h0($))}function R6($,O){return V3(h0($),O)}function V3($,O=4){let Z=m6($);return[xO($,4),...k6(NO($,O),Z)]}function k6($,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 S3($,O,Z,T){let f=T?q:a0[O+1];if(f){let j=a0[O];if(f%(($=m0(WO,$,1,f/j-(T?0:1),1))*j))throw RangeError(LO(WO,$))}else $=m0(WO,$,1,Z?1e9:1,1);return $}function m6($){let O=$[nT];if(O!==void 0){if(typeof O!="number"){if(Y3(O)==="auto")return;throw RangeError(LO(nT,O))}O=m0(nT,Math.floor(O),0,9,1)}return O}function h0($){return $===void 0?{}:z1($)}function I3($,O){return typeof $=="string"?{[O]:$}:z1($)}function a($){if($!==void 0){if(W0($))return Object.assign(Object.create(null),$);throw TypeError(hz)}}function IZ($,O){return $&&Object.assign(Object.create(null),$,{overflow:y7[O]})}function M3($,O,Z=9,T=0,f){let j=O[$];if(j===void 0)return f?T:void 0;if(j=Y3(j),j==="auto")return f?T:null;let W=eT[j];if(W===void 0&&(W=w7[j]),W===void 0)throw RangeError(sz($,j,eT));return m0($,W,T,Z,1,IO),W}function l1($,O,Z,T=0){let f=Z[$];if(f===void 0)return T;let j=Y3(f),W=O[j];if(W===void 0)throw RangeError(sz($,j,O));return W}function q6($,O){if(O>$)throw RangeError(M7)}function z0($){return{branding:rZ,epochNanoseconds:$}}function X0($,O,Z){return{branding:C1,calendar:Z,timeZone:O,epochNanoseconds:$}}function o($,O=$.calendar){return{branding:e1,calendar:O,...w0(U2,$)}}function r($,O=$.calendar){return{branding:t1,calendar:O,...w0(Rf,$)}}function p1($,O=$.calendar){return{branding:H$,calendar:O,...w0(Rf,$)}}function jZ($,O=$.calendar){return{branding:w$,calendar:O,...w0(Rf,$)}}function l0($){return{branding:oZ,...w0(D2,$)}}function i($){return{branding:tZ,sign:N1($),...w0(wf,$)}}function y6($){return x6($.epochNanoseconds)}function MZ($){return F3($.epochNanoseconds,o0)[0]}function p6($){return N6($.epochNanoseconds,r1)}function c6($){return N6($.epochNanoseconds)}function i6($){return $.epochNanoseconds}function J0($){return typeof $=="string"?$:h($.id)}function M$($,O){return $===O||J0($)===J0(O)}function h6($,O,Z,T,f){let j=c1(T),[W,z]=((B,Q)=>{let S=Q((B=I3(B,Z3))[B2]),V=u7(B);return V=Q6(Z3,V),[V,S]})(f,$);if(JO(Math.max(W,j),z))return aW(T,W);if(!z)throw RangeError(lZ);let[J,Y,X]=EZ(O,Z,z),C=s3(X),F=HZ(X),U=n3(X),D=F(Y,J,T),G=U(Y,J,D,W);return JO(W,z)?aW(G,W):((B,Q,S,V,x,_,L)=>{let I=N1(B),[A,E]=N3(V,vf(S,B),S,I,x,_,L),Z0=x3(Q,A,E);return B[k[S]]+Z0*I})(G,C(D),W,Y,J,C,F)}function aW($,O){return R0(j0($),a0[O],1)}function N3($,O,Z,T,f,j,W){let z=k[Z],J={...O,[z]:O[z]+T},Y=W($,f,O),X=W($,f,J);return[j(Y),j(X)]}function x3($,O,Z){let T=R0(g0(O,Z));if(!T)throw RangeError(SO);return R0(g0(O,$))/T}function l6($,O){let[Z,T,f]=SZ(O,5,1);return z0(xZ($.epochNanoseconds,Z,T,f,1))}function d6($,O,Z){let{epochNanoseconds:T,timeZone:f,calendar:j}=O,[W,z,J]=SZ(Z);if(W===0&&z===1)return O;let Y=$(f);if(W===6)T=((X,C,F,U)=>{let D=Q0(F,C),[G,B]=X(D),Q=F.epochNanoseconds,S=H0(C,G),V=H0(C,B);if(M6(Q,S,V))throw RangeError(SO);return $8(x3(Q,S,V),U)?V:S})(t6,Y,O,J);else{let X=Y.getOffsetNanosecondsFor(T);T=u1(Y,o6(M1(T,X),W,z,J),X,2,0,1)}return X0(T,f,j)}function u6($,O){return o(o6($,...SZ(O)),$.calendar)}function s6($,O){let[Z,T,f]=SZ(O,5);var j;return l0((j=f,P3($,BO(Z,T),j)[0]))}function n6($,O){let Z=$(O.timeZone),T=Q0(O,Z),[f,j]=t6(T),W=R0(g0(H0(Z,f),H0(Z,j)),uZ,1);if(W<=0)throw RangeError(SO);return W}function a6($,O){let{timeZone:Z,calendar:T}=O,f=((j,W,z)=>H0(W,j(Q0(z,W))))(e6,$(Z),O);return X0(f,Z,T)}function o6($,O,Z,T){return r6($,BO(O,Z),T)}function r6($,O,Z){let[T,f]=P3($,O,Z);return J1({...s1($,f),...T})}function P3($,O,Z){return KZ(I1(S1($),O,Z))}function WZ($){return I1($,dZ,7)}function BO($,O){return a0[$]*O}function t6($){let O=e6($);return[O,s1(O,1)]}function e6($){return b7(6,$)}function y5($,O,Z){let T=Math.min(c1($),6);return x$(PZ(j0($,T),O,Z),T)}function NZ($,O,Z,T,f,j,W,z,J,Y){if(T===0&&f===1)return $;let X=JO(T,z)?wZ(z)&&T<6&&Z>=6?c5:p5:i5,[C,F,U]=X($,O,Z,T,f,j,W,z,J,Y);return U&&T!==7&&(C=((D,G,B,Q,S,V,x,_)=>{let L=N1(D);for(let I=Q+1;I<=B;I++){if(I===7&&B!==7)continue;let A=vf(I,D);A[k[I]]+=L;let E=R0(g0(x(_(S,V,A)),G));if(E&&Math.sign(E)!==L)break;D=A}return D})(C,F,Z,Math.max(6,T),W,z,J,Y)),C}function xZ($,O,Z,T,f){if(O===6){let j=((W)=>W[0]+W[1]/q)($);return[I1(j,Z,T),0]}return PZ($,BO(O,Z),T,f)}function PZ($,O,Z,T){let[f,j]=$;T&&j<0&&(j+=q,f-=1);let[W,z]=j1(I1(j,O,Z),q);return X3(f+W,z)}function I1($,O,Z){return $8($/O,Z)*O}function $8($,O){return o7[O]($)}function p5($,O,Z,T,f,j){let W=N1($),z=j0($),J=xZ(z,T,f,j),Y=g0(z,J),X=Math.sign(J[0]-z[0])===W,C=x$(J,Math.min(Z,6));return[{...$,...C},G$(O,Y),X]}function c5($,O,Z,T,f,j,W,z,J,Y){let X=N1($),C=R0(j0($,5)),F=BO(T,f),U=I1(C,F,j),[D,G]=N3(W,{...$,...bf},6,X,z,J,Y),B=U-R0(g0(D,G)),Q=0;B&&Math.sign(B)!==X?O=B$(D,U):(Q+=X,U=I1(B,F,j),O=B$(G,U));let S=vZ(U);return[{...$,...S,days:$.days+Q},O,Boolean(Q)]}function i5($,O,Z,T,f,j,W,z,J,Y){let X=N1($),C=k[T],F=vf(T,$);T===7&&($={...$,weeks:$.weeks+Math.trunc($.days/7)});let U=CZ($[C],f)*f;F[C]=U;let[D,G]=N3(W,F,T,f*X,z,J,Y),B=U+x3(O,D,G)*X*f,Q=I1(B,f,j),S=Math.sign(Q-B)===X;return F[C]=Q,[F,S?G:D,S]}function _3($,O,Z,T){let[f,j,W,z]=((Y)=>{let X=V3(Y=h0(Y));return[Y.timeZone,...X]})(T),J=f!==void 0;return((Y,X,C,F,U,D)=>{C=PZ(C,U,F,1);let G=X.getOffsetNanosecondsFor(C);return g3(M1(C,G),D)+(Y?d1(WZ(G)):"Z")})(J,O(J?$(f):$$),Z.epochNanoseconds,j,W,z)}function A3($,O,Z){let[T,f,j,W,z,J]=((Y)=>{Y=h0(Y);let X=qf(Y),C=m6(Y),F=a7(Y),U=xO(Y,4),D=NO(Y,4);return[X,n7(Y),F,U,...k6(D,C)]})(Z);return((Y,X,C,F,U,D,G,B,Q,S)=>{F=PZ(F,Q,B,1);let V=Y(C).getOffsetNanosecondsFor(F);return g3(M1(F,V),S)+d1(WZ(V),G)+((x,_)=>_!==1?"["+(_===2?"!":"")+J0(x)+"]":"")(C,D)+R3(X,U)})($,O.calendar,O.timeZone,O.epochNanoseconds,T,f,j,W,z,J)}function E3($,O){let[Z,T,f,j]=((Y)=>(Y=h0(Y),[qf(Y),...V3(Y)]))(O);return W=$.calendar,z=Z,J=j,g3(r6($,f,T),J)+R3(W,z);var W,z,J}function H3($,O){return Z=$.calendar,T=$,f=Q3(O),zZ(T)+R3(Z,f);var Z,T,f}function w3($,O){return O8($.calendar,Z8,$,Q3(O))}function b3($,O){return O8($.calendar,h5,$,Q3(O))}function v3($,O){let[Z,T,f]=R6(O);return j=f,T8(P3($,T,Z)[0],j);var j}function _Z($,O){let[Z,T,f]=R6(O,3);return T>1&&($={...$,...y5($,T,Z)}),((j,W)=>{let{sign:z}=j,J=z===-1?V0(j):j,{hours:Y,minutes:X}=J,[C,F]=F3(j0(J,3),y0,L1);F8(C);let U=k3(F,W),D=W>=0||!z||U;return(z<0?"-":"")+"P"+oW({Y:y1(J.years),M:y1(J.months),W:y1(J.weeks),D:y1(J.days)})+(Y||X||C||D?"T"+oW({H:y1(Y),M:y1(X),S:y1(C,D)+U}):"")})($,f)}function O8($,O,Z,T){let f=J0($),j=T>1||T===0&&f!==v;return T===1?f===v?O(Z):zZ(Z):j?zZ(Z)+f8(f,T===2):O(Z)}function oW($){let O=[];for(let Z in $){let T=$[Z];T&&O.push(T,Z)}return O.join("")}function g3($,O){return zZ($)+"T"+T8($,O)}function zZ($){return Z8($)+"-"+q0($.isoDay)}function Z8($){let{isoYear:O}=$;return(O<0||O>9999?j8(O)+ZZ(6,Math.abs(O)):ZZ(4,O))+"-"+q0($.isoMonth)}function h5($){return q0($.isoMonth)+"-"+q0($.isoDay)}function T8($,O){let Z=[q0($.isoHour),q0($.isoMinute)];return O!==-1&&Z.push(q0($.isoSecond)+((T,f,j,W)=>k3(T*o0+f*r1+j,W))($.isoMillisecond,$.isoMicrosecond,$.isoNanosecond,O)),Z.join(":")}function d1($,O=0){if(O===1)return"";let[Z,T]=j1(Math.abs($),uZ),[f,j]=j1(T,dZ),[W,z]=j1(j,y0);return j8($)+q0(Z)+":"+q0(f)+(W||z?":"+q0(W)+k3(z):"")}function R3($,O){if(O!==1){let Z=J0($);if(O>1||O===0&&Z!==v)return f8(Z,O===2)}return""}function f8($,O){return"["+(O?"!":"")+"u-ca="+$+"]"}function k3($,O){let Z=ZZ(9,$);return Z=O===void 0?Z.replace(e7,""):Z.slice(0,O),Z?"."+Z:""}function j8($){return $<0?"-":"+"}function y1($,O){return $||O?$.toLocaleString("fullwide",{useGrouping:0}):""}function l5($,O){let{epochNanoseconds:Z}=$,T=(O.getOffsetNanosecondsFor?O:O($.timeZone)).getOffsetNanosecondsFor(Z),f=M1(Z,T);return{calendar:$.calendar,...f,offsetNanoseconds:T}}function W8($,O){let Z=Q0(O,$);return{calendar:O.calendar,...w0(U2,Z),offset:d1(Z.offsetNanoseconds),timeZone:O.timeZone}}function u1($,O,Z,T=0,f=0,j,W){if(Z!==void 0&&T===1&&(T===1||W))return U3(O,Z);let z=$.getPossibleInstantsFor(O);if(Z!==void 0&&T!==3){let J=((Y,X,C,F)=>{let U=G0(X);F&&(C=WZ(C));for(let D of Y){let G=R0(g0(D,U));if(F&&(G=WZ(G)),G===C)return D}})(z,O,Z,j);if(J!==void 0)return J;if(T===0)throw RangeError(K7)}return W?G0(O):H0($,O,f,z)}function H0($,O,Z=0,T=$.getPossibleInstantsFor(O)){if(T.length===1)return T[0];if(Z===1)throw RangeError(Q7);if(T.length)return T[Z===3?1:0];let f=G0(O),j=((z,J)=>{let Y=z.getOffsetNanosecondsFor(B$(J,-q));return q3(z.getOffsetNanosecondsFor(B$(J,q))-Y)})($,f),W=j*(Z===2?-1:1);return(T=$.getPossibleInstantsFor(M1(f,W)))[Z===2?0:T.length-1]}function m3($){if(Math.abs($)>=q)throw RangeError(G7);return $}function q3($){if($>q)throw RangeError(B7);return $}function y3($,O,Z){return z0(k0(G$(O.epochNanoseconds,((T)=>{if(C8(T))throw RangeError(S7);return j0(T,5)})($?V0(Z):Z))))}function p3($,O,Z,T,f,j=Object.create(null)){let W=O(T.timeZone),z=$(T.calendar);return{...T,...d3(W,z,T,Z?V0(f):f,j)}}function c3($,O,Z,T,f=Object.create(null)){let{calendar:j}=Z;return o(u3($(j),Z,O?V0(T):T,f),j)}function i3($,O,Z,T,f){let{calendar:j}=Z;return r(AZ($(j),Z,O?V0(T):T,f),j)}function h3($,O,Z,T,f=Object.create(null)){let j=Z.calendar,W=$(j),z=zO(W,Z);O&&(T=bZ(T)),T.sign<0&&(z=W.dateAdd(z,{...Y0,months:1}),z=s1(z,-1));let J=W.dateAdd(z,T,f);return p1(zO(W,J),j)}function l3($,O,Z){return l0(z8(O,$?V0(Z):Z)[0])}function d3($,O,Z,T,f){let j=j0(T,5),W=Z.epochNanoseconds;if(C8(T)){let z=Q0(Z,$);W=G$(H0($,{...AZ(O,z,{...T,...bf},f),...w0(u0,z)}),j)}else W=G$(W,j),R(f);return{epochNanoseconds:k0(W)}}function u3($,O,Z,T){let[f,j]=z8(O,Z);return J1({...AZ($,O,{...Z,...bf,days:Z.days+j},T),...f})}function AZ($,O,Z,T){if(Z.years||Z.months||Z.weeks)return $.dateAdd(O,Z,T);R(T);let f=Z.days+j0(Z,5)[0];return f?Q1(s1(O,f)):O}function zO($,O,Z=1){return s1(O,Z-$.day(O))}function z8($,O){let[Z,T]=j0(O,5),[f,j]=KZ(S1($)+T);return[f,Z+j]}function s1($,O){return O?{...$,...QZ(K0($)+O*A0)}:$}function EZ($,O,Z){let T=$(Z.calendar);return wZ(Z)?[Z,T,O(Z.timeZone)]:[{...Z,...p0},T]}function s3($){return $?i6:G0}function HZ($){return $?b(d3,$):u3}function n3($){return $?b(u5,$):s5}function wZ($){return $&&$.epochNanoseconds}function JO($,O){return $<=6-(wZ(O)?1:0)}function a3($,O,Z,T,f,j,W){let z=$(h0(W).relativeTo),J=Math.max(c1(f),c1(j));if(JO(J,z))return i(N$(((G,B,Q,S)=>{let V=G$(j0(G),j0(B),S?-1:1);if(!Number.isFinite(V[0]))throw RangeError(hZ);return{...Y0,...x$(V,Q)}})(f,j,J,T)));if(!z)throw RangeError(lZ);T&&(j=V0(j));let[Y,X,C]=EZ(O,Z,z),F=HZ(C),U=n3(C),D=F(X,Y,f);return i(U(X,Y,F(X,D,j),J))}function J8($,O,Z,T,f){let j=c1(T),[W,z,J,Y,X]=((L,I,A)=>{L=I3(L,XZ);let E=mf(L),Z0=A(L[B2]),g=L3(L),m=xO(L,7),T0=NO(L);if(E===void 0&&T0===void 0)throw RangeError(I7);return T0==null&&(T0=0),E==null&&(E=Math.max(T0,I)),q6(E,T0),g=S3(g,T0,1),[E,T0,g,m,Z0]})(f,j,$),C=Math.max(j,W);if(!wZ(X)&&C<=6)return i(N$(((L,I,A,E,Z0)=>{let g=xZ(j0(L),A,E,Z0);return{...Y0,...x$(g,I)}})(T,W,z,J,Y)));if(!X)throw RangeError(lZ);let[F,U,D]=EZ(O,Z,X),G=s3(D),B=HZ(D),Q=n3(D),S=B(U,F,T),V=Q(U,F,S,W),x=T.sign,_=N1(V);if(x&&_&&x!==_)throw RangeError(SO);return _&&(V=NZ(V,G(S),W,z,J,Y,U,F,G,B)),i(V)}function Y8($){return $.sign===-1?bZ($):$}function bZ($){return i(V0($))}function V0($){let O={};for(let Z of k)O[Z]=-1*$[Z]||0;return O}function X8($){return!$.sign}function N1($,O=k){let Z=0;for(let T of O){let f=Math.sign($[T]);if(f){if(Z&&Z!==f)throw RangeError(L7);Z=f}}return Z}function N$($){for(let O of H7)m0(O,$[O],-T6,T6,1);return F8(R0(j0($),y0)),$}function F8($){if(!Number.isSafeInteger($))throw RangeError(V7)}function j0($,O=6){return C6($,O,k)}function x$($,O=6){let[Z,T]=$,f=DZ(T,O,k);if(f[k[O]]+=Z*(q/a0[O]),!Number.isFinite(f[k[O]]))throw RangeError(hZ);return f}function vZ($,O=5){return DZ($,O,k)}function C8($){return Boolean(N1($,C2))}function c1($){let O=9;for(;O>0&&!$[k[O]];O--);return O}function d5($,O){return[$,O]}function rW($){let O=Math.floor($/$Z)*$Z;return[O,O+$Z]}function D8($){let O=x1($=TZ($));if(!O)throw RangeError(_0($));let Z;if(O.m)Z=0;else{if(!O.offset)throw RangeError(_0($));Z=P$(O.offset)}return O.timeZone&&e3(O.timeZone,1),z0(U3(VZ(O),Z))}function U8($){let O=x1(h($));if(!O)throw RangeError(_0($));if(O.timeZone)return M8(O,O.offset?P$(O.offset):void 0);if(O.m)throw RangeError(_0($));return x8(O)}function G8($,O){let Z=x1(h($));if(!Z||!Z.timeZone)throw RangeError(_0($));let{offset:T}=Z,f=T?P$(T):void 0,[,j,W]=GO(O);return M8(Z,f,j,W)}function P$($){let O=e3($);if(O===void 0)throw RangeError(_0($));return O}function B8($){let O=x1(h($));if(!O||O.m)throw RangeError(_0($));return o(N8(O))}function gZ($){let O=x1(h($));if(!O||O.m)throw RangeError(_0($));return r(O.p?N8(O):x8(O))}function K8($,O){let Z=r3(h(O));if(Z)return o3(Z),p1(D3(h1(Z)));let T=gZ(O);return p1(zO($(T.calendar),T))}function o3($){if($.calendar!==v)throw RangeError(W1($.calendar))}function Q8($,O){let Z=t3(h(O));if(Z)return o3(Z),jZ(h1(Z));let T=gZ(O),{calendar:f}=T,j=$(f),[W,z,J]=j.h(T),[Y,X]=j.I(W,z),[C,F]=j.N(Y,X,J);return jZ(Q1(j.P(C,F,J)),f)}function V8($){let O,Z=((T)=>{let f=fJ.exec(T);return f?(RZ(f[10]),A8(f)):void 0})(h($));if(!Z){if(Z=x1($),!Z)throw RangeError(_0($));if(!Z.p)throw RangeError(_0($));if(Z.m)throw RangeError(W1("Z"));o3(Z)}if((O=r3($))&&nW(O))throw RangeError(_0($));if((O=t3($))&&nW(O))throw RangeError(_0($));return l0(LZ(Z,1))}function L8($){let O=((Z)=>{let T=zJ.exec(Z);return T?((f)=>{function j(X,C,F){let U=0,D=0;if(F&&([U,J]=j1(J,a0[F])),X!==void 0){if(z)throw RangeError(W1(X));D=((G)=>{let B=parseInt(G);if(!Number.isFinite(B))throw RangeError(W1(G));return B})(X),W=1,C&&(J=$f(C)*(a0[F]/y0),z=1)}return U+D}let W=0,z=0,J=0,Y={...L$(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)]),...DZ(J,2,k)};if(!W)throw RangeError(dz(k));return Of(f[1])<0&&(Y=V0(Y)),Y})(T):void 0})(h($));if(!O)throw RangeError(_0($));return i(N$(O))}function S8($){let O=x1($)||r3($)||t3($);return O?O.calendar:$}function I8($){let O=x1($);return O&&(O.timeZone||O.m&&$$||O.offset)||$}function M8($,O,Z=0,T=0){let f=kZ($.timeZone),j=eZ(f);return X0(u1(j,VZ($),O,Z,T,!j.v,$.m),f,KO($.calendar))}function N8($){return P8(J1(VZ($)))}function x8($){return P8(Q1(h1($)))}function P8($){return{...$,calendar:KO($.calendar)}}function x1($){let O=TJ.exec($);return O?((Z)=>{let T=Z[10],f=(T||"").toUpperCase()==="Z";return{isoYear:_8(Z),isoMonth:parseInt(Z[4]),isoDay:parseInt(Z[5]),...A8(Z.slice(5)),...RZ(Z[16]),p:Boolean(Z[6]),m:f,offset:f?void 0:T}})(O):void 0}function r3($){let O=OJ.exec($);return O?((Z)=>({isoYear:_8(Z),isoMonth:parseInt(Z[4]),isoDay:1,...RZ(Z[5])}))(O):void 0}function t3($){let O=ZJ.exec($);return O?((Z)=>({isoYear:V$,isoMonth:parseInt(Z[1]),isoDay:parseInt(Z[2]),...RZ(Z[3])}))(O):void 0}function e3($,O){let Z=jJ.exec($);return Z?((T,f)=>{let j=T[4]||T[5];if(f&&j)throw RangeError(W1(j));return m3((U$(T[2])*uZ+U$(T[3])*dZ+U$(T[4])*y0+$f(T[5]||""))*Of(T[1]))})(Z,O):void 0}function _8($){let O=Of($[1]),Z=parseInt($[2]||$[3]);if(O<0&&!Z)throw RangeError(W1(-0));return O*Z}function A8($){let O=U$($[3]);return{...KZ($f($[4]||""))[0],isoHour:U$($[1]),isoMinute:U$($[2]),isoSecond:O===60?59:O}}function RZ($){let O,Z,T=[];if($.replace(WJ,(f,j,W)=>{let z=Boolean(j),[J,Y]=W.split("=").reverse();if(Y){if(Y==="u-ca")T.push(J),O||(O=z);else if(z||/[A-Z]/.test(Y))throw RangeError(W1(f))}else{if(Z)throw RangeError(W1(f));Z=J}return""}),T.length>1&&O)throw RangeError(W1($));return{timeZone:Z,calendar:T[0]||v}}function $f($){return parseInt($.padEnd(9,"0"))}function _$($){return new RegExp(`^${$}$`,"i")}function Of($){return $&&$!=="+"?-1:1}function U$($){return $===void 0?0:parseInt($)}function E8($){return kZ(h($))}function kZ($){let O=Zf($);return typeof O=="number"?d1(O):O?((Z)=>{if(YJ.test(Z))throw RangeError(U7);return Z.toLowerCase().split("/").map((T,f)=>(T.length<=3||/\d/.test(T))&&!/etc|yap/.test(T)?T.toUpperCase():T.replace(/baja|dumont|[a-z]+/g,(j,W)=>j.length<=2&&!f||j==="in"||j==="chat"?j.toUpperCase():j.length>2||!W?uW(j).replace(/island|noronha|murdo|rivadavia|urville/,uW):j)).join("/")})($):$$}function tW($){let O=Zf($);return typeof O=="number"?O:O?O.resolvedOptions().timeZone:$$}function Zf($){let O=e3($=$.toUpperCase(),1);return O!==void 0?O:$!==$$?JJ($):void 0}function Tf($,O){return B0($.epochNanoseconds,O.epochNanoseconds)}function ff($,O){return B0($.epochNanoseconds,O.epochNanoseconds)}function H8($,O,Z,T,f,j){let W=$(h0(j).relativeTo),z=Math.max(c1(T),c1(f));if(X6(k,T,f))return 0;if(JO(z,W))return B0(j0(T),j0(f));if(!W)throw RangeError(lZ);let[J,Y,X]=EZ(O,Z,W),C=s3(X),F=HZ(X);return B0(C(F(Y,J,T)),C(F(Y,J,f)))}function jf($,O){return n1($,O)||mZ($,O)}function n1($,O){return K1(K0($),K0(O))}function mZ($,O){return K1(S1($),S1(O))}function w8($,O){return!Tf($,O)}function b8($,O){return!ff($,O)&&!!qZ($.timeZone,O.timeZone)&&M$($.calendar,O.calendar)}function v8($,O){return!jf($,O)&&M$($.calendar,O.calendar)}function g8($,O){return!n1($,O)&&M$($.calendar,O.calendar)}function R8($,O){return!n1($,O)&&M$($.calendar,O.calendar)}function k8($,O){return!n1($,O)&&M$($.calendar,O.calendar)}function m8($,O){return!mZ($,O)}function qZ($,O){if($===O)return 1;let Z=J0($),T=J0(O);if(Z===T)return 1;try{return tW(Z)===tW(T)}catch(f){}}function Wf($,O,Z,T){let f=I$($,a(T),3,5),j=yZ(O.epochNanoseconds,Z.epochNanoseconds,...f);return i($?V0(j):j)}function zf($,O,Z,T,f,j){let W=cZ(T.calendar,f.calendar),z=a(j),[J,Y,X,C]=I$(Z,z,5),F=T.epochNanoseconds,U=f.epochNanoseconds,D=B0(U,F),G;if(D)if(J<6)G=yZ(F,U,J,Y,X,C);else{let B=O(((S,V)=>{if(!qZ(S,V))throw RangeError(rz);return S})(T.timeZone,f.timeZone)),Q=$(W);G=y8(Q,B,T,f,D,J,z),G=NZ(G,U,J,Y,X,C,Q,T,i6,b(d3,B))}else G=Y0;return i(Z?V0(G):G)}function Jf($,O,Z,T,f){let j=cZ(Z.calendar,T.calendar),W=a(f),[z,J,Y,X]=I$(O,W,6),C=G0(Z),F=G0(T),U=B0(F,C),D;if(U)if(z<=6)D=yZ(C,F,z,J,Y,X);else{let G=$(j);D=p8(G,Z,T,U,z,W),D=NZ(D,F,z,J,Y,X,G,Z,G0,u3)}else D=Y0;return i(O?V0(D):D)}function Yf($,O,Z,T,f){let j=cZ(Z.calendar,T.calendar),W=a(f);return q8(O,()=>$(j),Z,T,...I$(O,W,6,9,6),W)}function Xf($,O,Z,T,f){let j=cZ(Z.calendar,T.calendar),W=a(f),z=I$(O,W,9,9,8),J=$(j);return q8(O,()=>J,zO(J,Z),zO(J,T),...z,W)}function q8($,O,Z,T,f,j,W,z,J){let Y=G0(Z),X=G0(T),C;if(B0(X,Y))if(f===6)C=yZ(Y,X,f,j,W,z);else{let F=O();C=F.dateUntil(Z,T,f,J),j===6&&W===1||(C=NZ(C,X,f,j,W,z,F,Z,G0,AZ))}else C=Y0;return i($?V0(C):C)}function Ff($,O,Z,T){let f=a(T),[j,W,z,J]=I$($,f,5,5),Y=I1(Cf(O,Z),BO(W,z),J),X={...Y0,...vZ(Y,j)};return i($?V0(X):X)}function u5($,O,Z,T,f,j){let W=B0(T.epochNanoseconds,Z.epochNanoseconds);return W?f<6?c8(Z.epochNanoseconds,T.epochNanoseconds,f):y8(O,$,Z,T,W,f,j):Y0}function s5($,O,Z,T,f){let j=G0(O),W=G0(Z),z=B0(W,j);return z?T<=6?c8(j,W,T):p8($,O,Z,z,T,f):Y0}function y8($,O,Z,T,f,j,W){let[z,J,Y]=((F,U,D,G)=>{function B(){return I={...s1(V,_++*-G),...S},A=H0(F,I),B0(x,A)===-G}let Q=Q0(U,F),S=w0(u0,Q),V=Q0(D,F),x=D.epochNanoseconds,_=0,L=Cf(Q,V),I,A;if(Math.sign(L)===-G&&_++,B()&&(G===-1||B()))throw RangeError(SO);let E=R0(g0(A,x));return[Q,I,E]})(O,Z,T,f);var X,C;return{...j===6?(X=z,C=J,{...Y0,days:i8(X,C)}):$.dateUntil(z,J,j,W),...vZ(Y)}}function p8($,O,Z,T,f,j){let[W,z,J]=((Y,X,C)=>{let F=X,U=Cf(Y,X);return Math.sign(U)===-C&&(F=s1(X,-C),U+=q*C),[Y,F,U]})(O,Z,T);return{...$.dateUntil(W,z,f,j),...vZ(J)}}function yZ($,O,Z,T,f,j){return{...Y0,...x$(xZ(g0($,O),T,f,j),Z)}}function c8($,O,Z){return{...Y0,...x$(g0($,O),Z)}}function i8($,O){return pZ(K0($),K0(O))}function pZ($,O){return Math.trunc((O-$)/A0)}function Cf($,O){return S1(O)-S1($)}function cZ($,O){if(!M$($,O))throw RangeError(_f);return $}function n5($){function O(f){return((j,W)=>({...h8(j,W),F:j.month,day:parseInt(j.day)}))(C3(Z,f),T)}let Z=hf($),T=JZ($);return{id:$,O:a5(O),B:o5(O)}}function a5($){return E0((O)=>{let Z=K0(O);return $(Z)},WeakMap)}function o5($){let O=$(0).year-k7;return E0((Z)=>{let T,f=S$(Z-O),j=[],W=[];do f+=400*A0;while((T=$(f)).year<=Z);do f+=(1-T.day)*A0,T.year===Z&&(j.push(f),W.push(T.F)),f-=A0;while((T=$(f)).year>=Z);return{k:j.reverse(),C:$2(W.reverse())}})}function h8($,O){let Z,T,f=l8($);if($.era){let j=Y2[O];j!==void 0&&(Z=O==="islamic"?"ah":$.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),Z==="bc"||Z==="b"?Z="bce":Z!=="ad"&&Z!=="a"||(Z="ce"),T=f,f=a8(T,j[Z]||0))}return{era:Z,eraYear:T,year:f}}function l8($){return parseInt($.relatedYear||$.year)}function oT($){let{year:O,F:Z,day:T}=this.O($),{C:f}=this.B(O);return[O,f[Z]+1,T]}function YO($,O=1,Z=1){return this.B($).k[O-1]+(Z-1)*A0}function rO($){let O=$6(this,$),Z=$6(this,$-1),T=O.length;if(T>Z.length){let f=o8(this);if(f<0)return-f;for(let j=0;j<T;j++)if(O[j]!==Z[j])return j+1}}function tO($){return pZ(YO.call(this,$),YO.call(this,$+1))}function eW($,O){let{k:Z}=this.B($),T=O+1,f=Z;return T>Z.length&&(T=1,f=this.B($+1).k),pZ(Z[O-1],f[T-1])}function eO($){return this.B($).k.length}function $6($,O){return Object.keys($.B(O).C)}function d8($){return KO(h($))}function KO($){if(($=$.toLowerCase())!==v&&$!==nZ&&JZ($)!==JZ(hf($).resolvedOptions().calendar))throw RangeError(D7($));return $}function JZ($){return $==="islamicc"&&($="islamic"),$.split("-")[0]}function u8($){return this.R($)[0]}function s8($){return this.R($)[1]}function Df($){let[O]=this.h($);return pZ(this.q(O),K0($))+1}function n8($){let O=FJ.exec($);if(!O)throw RangeError(F7($));return[parseInt(O[1]),Boolean(O[2])]}function YZ($,O,Z){return $+(O||Z&&$>=Z?1:0)}function rT($,O){return $-(O&&$>=O?1:0)}function a8($,O){return(O+$)*(Math.sign(O)||1)||0}function tT($){return Y2[r8($)]}function o8($){return _7[r8($)]}function r8($){return JZ($.id||v)}function t8($,O,Z,T){let f=P1(Z,T,d0,[],j2);if(f.timeZone!==void 0){let j=Z.dateFromFields(f),W=a1(f),z=$(f.timeZone);return{epochNanoseconds:u1(O(z),{...j,...W},f.offset!==void 0?P$(f.offset):void 0),timeZone:z}}return{...Z.dateFromFields(f),...p0}}function e8($,O,Z,T,f,j){let W=P1(Z,f,d0,T2,j2),z=$(W.timeZone),[J,Y,X]=GO(j),C=Z.dateFromFields(W,IZ(j,J)),F=a1(W,J);return X0(u1(O(z),{...C,...F},W.offset!==void 0?P$(W.offset):void 0,Y,X),z,T)}function $z($,O,Z){let T=P1($,O,d0,[],F1),f=R(Z);return o(J1({...$.dateFromFields(T,IZ(Z,f)),...a1(T,f)}))}function Uf($,O,Z,T=[]){let f=P1($,O,d0,T);return $.dateFromFields(f,Z)}function Gf($,O,Z,T){let f=P1($,O,Hf,T);return $.yearMonthFromFields(f,Z)}function Bf($,O,Z,T,f=[]){let j=P1($,Z,d0,f);return O&&j.month!==void 0&&j.monthCode===void 0&&j.year===void 0&&(j.year=V$),$.monthDayFromFields(j,T)}function Oz($,O){let Z=R(O);return l0(a1(n0($,$3,[],1),Z))}function Zz($){let O=n0($,wf);return i(N$({...Y0,...O}))}function P1($,O,Z,T=[],f=[]){return n0(O,[...$.fields(Z),...f].sort(),T)}function n0($,O,Z,T=!Z){let f={},j,W=0;for(let z of O){if(z===j)throw RangeError(j7(z));if(z==="constructor"||z==="__proto__")throw RangeError(xf(z));let J=$[z];if(J!==void 0)W=1,f6[z]&&(J=f6[z](J,z)),f[z]=J;else if(Z){if(Z.includes(z))throw TypeError(Nf(z));f[z]=J2[z]}j=z}if(T&&!W)throw TypeError(dz(O));return f}function a1($,O){return LZ(GJ({...J2,...$}),O)}function Tz($,O,Z,T,f,j){let W=a(j),{calendar:z,timeZone:J}=Z;return X0(((Y,X,C,F,U)=>{let D=QO(Y,C,F,d0,f2,Z2),[G,B,Q]=GO(U,2);return u1(X,{...Y.dateFromFields(D,IZ(U,G)),...a1(D,G)},P$(D.offset),B,Q)})($(z),O(J),T,f,W),J,z)}function fz($,O,Z,T,f){let j=a(f);return o(((W,z,J,Y)=>{let X=QO(W,z,J,d0,F1),C=R(Y);return J1({...W.dateFromFields(X,IZ(Y,C)),...a1(X,C)})})($(O.calendar),Z,T,j))}function jz($,O,Z,T,f){let j=a(f);return((W,z,J,Y)=>{let X=QO(W,z,J,d0);return W.dateFromFields(X,Y)})($(O.calendar),Z,T,j)}function Wz($,O,Z,T,f){let j=a(f);return p1(((W,z,J,Y)=>{let X=QO(W,z,J,Hf);return W.yearMonthFromFields(X,Y)})($(O.calendar),Z,T,j))}function zz($,O,Z,T,f){let j=a(f);return((W,z,J,Y)=>{let X=QO(W,z,J,d0);return W.monthDayFromFields(X,Y)})($(O.calendar),Z,T,j)}function Jz($,O,Z){return l0(((T,f,j)=>{let W=R(j);return a1({...w0($3,T),...n0(f,$3)},W)})($,O,Z))}function Yz($,O){return i((Z=$,T=O,N$({...Z,...n0(T,wf)})));var Z,T}function QO($,O,Z,T,f=[],j=[]){let W=[...$.fields(T),...f].sort(),z=n0(O,W,j),J=n0(Z,W);return z=$.mergeFields(z,J),n0(z,W,[])}function Kf($,O){let Z=P1($,O,z2);return $.monthDayFromFields(Z)}function Qf($,O,Z){let T=P1($,O,W2);return $.yearMonthFromFields(T,Z)}function Xz($,O,Z,T,f){O=w0(Z=$.fields(Z),O),T=n0(T,f=$.fields(f),[]);let j=$.mergeFields(O,T);return j=n0(j,[...Z,...f].sort(),[]),$.dateFromFields(j)}function dT($,O){let{era:Z,eraYear:T,year:f}=O,j=tT($);if(Z!==void 0||T!==void 0){if(Z===void 0||T===void 0)throw TypeError(z7);if(!j)throw RangeError(W7);let W=j[Z];if(W===void 0)throw RangeError(Y7(Z));let z=a8(T,W);if(f!==void 0&&f!==z)throw RangeError(J7);f=z}else if(f===void 0)throw TypeError(X7(j));return f}function uT($,O,Z,T){let{month:f,monthCode:j}=O;if(j!==void 0){let W=((z,J,Y,X)=>{let C=z.U(Y),[F,U]=n8(J),D=YZ(F,U,C);if(U){let G=o8(z);if(G===void 0)throw RangeError(fO);if(G>0){if(D>G)throw RangeError(fO);if(C===void 0){if(X===1)throw RangeError(fO);D--}}else{if(D!==-G)throw RangeError(fO);if(C===void 0&&X===1)throw RangeError(fO)}}return D})($,j,Z,T);if(f!==void 0&&f!==W)throw RangeError(az);f=W,T=1}else if(f===void 0)throw TypeError(C7);return m0("month",f,1,$.L(Z),T)}function O6($,O,Z,T,f){return P0(O,"day",1,$.j(T,Z),f)}function sT($,O,Z,T){let f=0,j=[];for(let W of Z)O[W]!==void 0?f=1:j.push(W);if(Object.assign($,O),f)for(let W of T||j)delete $[W]}function Fz($){return z0(k0(BZ(GZ($))))}function Cz($,O,Z,T,f=v){return X0(k0(BZ(GZ(Z))),O(T),$(f))}function Dz($,O,Z,T,f=0,j=0,W=0,z=0,J=0,Y=0,X=v){return o(J1(VZ(c0(U0,L$(aZ,[O,Z,T,f,j,W,z,J,Y])))),$(X))}function Uz($,O,Z,T,f=v){return r(Q1(h1(c0(U0,{isoYear:O,isoMonth:Z,isoDay:T}))),$(f))}function Gz($,O,Z,T=v,f=1){let j=U0(O),W=U0(Z),z=$(T);return p1(D3(h1({isoYear:j,isoMonth:W,isoDay:U0(f)})),z)}function Bz($,O,Z,T=v,f=V$){let j=U0(O),W=U0(Z),z=$(T);return jZ(Q1(h1({isoYear:U0(f),isoMonth:j,isoDay:W})),z)}function Kz($=0,O=0,Z=0,T=0,f=0,j=0){return l0(LZ(c0(U0,L$(u0,[$,O,Z,T,f,j])),1))}function Qz($=0,O=0,Z=0,T=0,f=0,j=0,W=0,z=0,J=0,Y=0){return i(N$(c0(I6,L$(k,[$,O,Z,T,f,j,W,z,J,Y]))))}function Vf($,O,Z=v){return X0($.epochNanoseconds,O,Z)}function Vz($){return z0($.epochNanoseconds)}function Lf($,O){return o(Q0(O,$))}function Sf($,O){return r(Q0(O,$))}function Lz($,O,Z){return Qf($(O.calendar),Z)}function Sz($,O,Z){return Kf($(O.calendar),Z)}function If($,O){return l0(Q0(O,$))}function Iz($,O,Z,T){let f=((j,W,z,J)=>{let Y=K3(J);return H0(j(W),z,Y)})($,Z,O,T);return X0(k0(f),Z,O.calendar)}function Mz($,O,Z){let T=$(O.calendar);return p1({...O,...Qf(T,Z)})}function Nz($,O,Z){return Kf($(O.calendar),Z)}function xz($,O,Z,T,f){let j=$(f.timeZone),W=f.plainTime,z=W!==void 0?O(W):p0;return X0(H0(Z(j),{...T,...z}),j,T.calendar)}function Pz($,O=p0){return o(J1({...$,...O}))}function _z($,O,Z){return Qf($(O.calendar),Z)}function Az($,O,Z){return Kf($(O.calendar),Z)}function Ez($,O,Z,T){return((f,j,W)=>Xz(f,j,W2,z1(W),MO))($(O.calendar),Z,T)}function Hz($,O,Z,T){return((f,j,W)=>Xz(f,j,z2,z1(W),sZ))($(O.calendar),Z,T)}function wz($,O,Z,T,f){let j=z1(f),W=O(j.plainDate),z=$(j.timeZone);return X0(H0(Z(z),{...W,...T}),z,W.calendar)}function bz($,O){return o(J1({...$,...O}))}function vz($){return z0(k0(K$($,y0)))}function gz($){return z0(k0(K$($,o0)))}function Rz($){return z0(k0(BZ(GZ($),r1)))}function kz($){return z0(k0(BZ(GZ($))))}function mz($,O,Z=p0){let T=O.timeZone,f=$(T),j={...Q0(O,f),...Z};return X0(u1(f,j,j.offsetNanoseconds,2),T,O.calendar)}function qz($,O,Z){let T=O.timeZone,f=$(T),j={...Q0(O,f),...Z},W=iz(O.calendar,Z.calendar);return X0(u1(f,j,j.offsetNanoseconds,2),T,W)}function yz($,O=p0){return o({...$,...O})}function pz($,O){return o({...$,...O},iz($.calendar,O.calendar))}function iZ($,O){return{...$,calendar:O}}function cz($,O){return{...$,timeZone:O}}function iz($,O){if($===O)return $;let Z=J0($),T=J0(O);if(Z===T||Z===v)return O;if(T===v)return $;throw RangeError(_f)}function r5($,O){return(Z)=>Z===v?$:Z===nZ||Z===Q$?Object.assign(Object.create($),{id:Z}):Object.assign(Object.create(O),XJ(Z))}function o1($,O,Z){let T=new Set(Z);return(f)=>(((j,W)=>{for(let z of W)if(z in j)return 1;return 0})(f=f3(T,f),$)||Object.assign(f,O),Z&&(f.timeZone=$$,["full","long"].includes(f.timeStyle)&&(f.timeStyle="medium")),f)}function Y1($,O=Mf){let[Z,,,T]=$;return(f,j=wJ,...W)=>{let z=O(T&&T(...W),f,j,Z),J=z.resolvedOptions();return[z,...t5($,J,W)]}}function Mf($,O,Z,T){if(Z=T(Z),$){if(Z.timeZone!==void 0)throw TypeError(N7);Z.timeZone=$}return new _1(O,Z)}function t5($,O,Z){let[,T,f]=$;return Z.map((j)=>(j.calendar&&((W,z,J)=>{if((J||W!==v)&&W!==z)throw RangeError(_f)})(J0(j.calendar),O.calendar,f),T(j,O)))}function A$($){let O=VO();return M1(O,$.getOffsetNanosecondsFor(O))}function VO(){return K$(Date.now(),o0)}function X1(){return W6||(W6=new _1().resolvedOptions().timeZone)}var e5=($,O)=>`Non-integer ${$}: ${O}`,$7=($,O)=>`Non-positive ${$}: ${O}`,O7=($,O)=>`Non-finite ${$}: ${O}`,Z7=($)=>`Cannot convert bigint to ${$}`,T7=($)=>`Invalid bigint: ${$}`,f7="Cannot convert Symbol to string",hz="Invalid object",lz=($,O,Z,T,f)=>f?lz($,f[O],f[Z],f[T]):LO($,O)+`; must be between ${Z}-${T}`,LO=($,O)=>`Invalid ${$}: ${O}`,Nf=($)=>`Missing ${$}`,xf=($)=>`Invalid field ${$}`,j7=($)=>`Duplicate field ${$}`,dz=($)=>"No valid fields: "+$.join(),uz="Invalid bag",sz=($,O,Z)=>LO($,O)+"; must be "+Object.keys(Z).join(),nz="Cannot use valueOf",Pf="Invalid calling context",W7="Forbidden era/eraYear",z7="Mismatching era/eraYear",J7="Mismatching year/eraYear",Y7=($)=>`Invalid era: ${$}`,X7=($)=>"Missing year"+($?"/era/eraYear":""),F7=($)=>`Invalid monthCode: ${$}`,az="Mismatching month/monthCode",C7="Missing month/monthCode",Z6="Cannot guess year",fO="Invalid leap month",oz="Invalid protocol",SO="Invalid protocol results",_f="Mismatching Calendars",D7=($)=>`Invalid Calendar: ${$}`,rz="Mismatching TimeZones",U7="Forbidden ICU TimeZone",G7="Out-of-bounds offset",B7="Out-of-bounds TimeZone gap",K7="Invalid TimeZone offset",Q7="Ambiguous offset",hZ="Out-of-bounds date",V7="Out-of-bounds duration",L7="Cannot mix duration signs",lZ="Missing relativeTo",S7="Cannot use large units",I7="Required smallestUnit or largestUnit",M7="smallestUnit > largestUnit",_0=($)=>`Cannot parse: ${$}`,W1=($)=>`Invalid substring: ${$}`,tz=($)=>`Cannot format ${$}`,ez="Mismatching types for formatting",N7="Cannot specify TimeZone",$2=b(CO,($,O)=>O),E$=b(CO,($,O,Z)=>Z),q0=b(ZZ,2),eT={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},IO=Object.keys(eT),A0=86400000,O2=1000,r1=1000,o0=1e6,y0=1e9,dZ=60000000000,uZ=3600000000000,q=86400000000000,a0=[1,r1,o0,y0,dZ,uZ,q],F1=IO.slice(0,6),$3=DO(F1),Z2=["offset"],T2=["timeZone"],f2=F1.concat(Z2),j2=f2.concat(T2),O3=["era","eraYear"],x7=O3.concat(["year"]),sZ=["year"],Af=["monthCode"],Ef=["month"].concat(Af),MO=["day"],Hf=Ef.concat(sZ),W2=Af.concat(sZ),d0=MO.concat(Hf),P7=MO.concat(Ef),z2=MO.concat(Af),J2=E$(F1,0),v="iso8601",nZ="gregory",Q$="japanese",Y2={[nZ]:{bce:-1,ce:0},[Q$]:{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}},_7={chinese:13,dangi:13,hebrew:-6},h=b(UZ,"string"),X2=b(UZ,"boolean"),A7=b(UZ,"number"),F2=b(UZ,"function"),k=IO.map(($)=>$+"s"),wf=DO(k),E7=k.slice(0,6),C2=k.slice(6),H7=C2.slice(1),w7=$2(k),Y0=E$(k,0),bf=E$(E7,0),vf=b(F6,k),u0=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],gf=["isoDay","isoMonth","isoYear"],aZ=u0.concat(gf),Rf=DO(gf),D2=DO(u0),U2=DO(aZ),p0=E$(D2,0),b7=b(F6,aZ),_1=Intl.DateTimeFormat,G2="en-GB",kf=1e8,v7=kf*A0,g7=[kf,0],R7=[-kf,0],XO=275760,FO=-271821,k7=1970,V$=1972,f1=12,m7=S$(1868,9,8),q7=E0(q5,WeakMap),XZ="smallestUnit",Z3="unit",WO="roundingIncrement",nT="fractionalSecondDigits",B2="relativeTo",K2={constrain:0,reject:1},y7=Object.keys(K2),p7={compatible:0,reject:1,earlier:2,later:3},c7={reject:0,use:1,prefer:2,ignore:3},i7={auto:0,never:1,critical:2,always:3},h7={auto:0,never:1,critical:2},l7={auto:0,never:1},d7={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},NO=b(M3,XZ),mf=b(M3,"largestUnit"),u7=b(M3,Z3),Q2=b(l1,"overflow",K2),V2=b(l1,"disambiguation",p7),s7=b(l1,"offset",c7),qf=b(l1,"calendarName",i7),n7=b(l1,"timeZoneName",h7),a7=b(l1,"offset",l7),xO=b(l1,"roundingMode",d7),H$="PlainYearMonth",w$="PlainMonthDay",t1="PlainDate",e1="PlainDateTime",oZ="PlainTime",C1="ZonedDateTime",rZ="Instant",tZ="Duration",o7=[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",$Z=5184000,r7=fZ(1847),t7=fZ(new Date().getUTCFullYear()+10),e7=/0+$/,Q0=E0(l5,WeakMap),T6=4294967295,eZ=E0(($)=>{let O=Zf($);return typeof O=="object"?new S2(O):new L2(O||0)});class L2{constructor($){this.v=$}getOffsetNanosecondsFor(){return this.v}getPossibleInstantsFor($){return[U3($,this.v)]}l(){}}class S2{constructor($){this.$=((O)=>{function Z(J){let Y=aT(J,W,z),[X,C]=rW(Y),F=f(X),U=f(C);return F===U?F:T(j(X,C),F,U,J)}function T(J,Y,X,C){let F,U;for(;(C===void 0||(F=C<J[0]?Y:C>=J[1]?X:void 0)===void 0)&&(U=J[1]-J[0]);){let D=J[0]+Math.floor(U/2);O(D)===X?J[1]=D:J[0]=D+1}return F}let f=E0(O),j=E0(d5),W=r7,z=t7;return{G(J){let Y=Z(J-86400),X=Z(J+86400),C=J-Y,F=J-X;if(Y===X)return[C];let U=Z(C);return U===Z(F)?[J-U]:Y>X?[C,F]:[]},V:Z,l(J,Y){let X=aT(J,W,z),[C,F]=rW(X),U=$Z*Y,D=Y<0?()=>F>W||(W=X,0):()=>C<z||(z=X,0);for(;D();){let G=f(C),B=f(F);if(G!==B){let Q=j(C,F);T(Q,G,B);let S=Q[0];if((K1(S,J)||1)===Y)return S}C+=U,F+=U}}}})(((O)=>(Z)=>{let T=C3(O,Z*O2);return fZ(l8(T),parseInt(T.month),parseInt(T.day),parseInt(T.hour),parseInt(T.minute),parseInt(T.second))-Z})($))}getOffsetNanosecondsFor($){return this.$.V(x6($))*y0}getPossibleInstantsFor($){let[O,Z]=[fZ((T=$).isoYear,T.isoMonth,T.isoDay,T.isoHour,T.isoMinute,T.isoSecond),T.isoMillisecond*o0+T.isoMicrosecond*r1+T.isoNanosecond];var T;return this.$.G(O).map((f)=>k0(B$(K$(f,y0),Z)))}l($,O){let[Z,T]=P6($),f=this.$.l(Z+(O>0||T?1:0),O);if(f!==void 0)return K$(f,y0)}}var yf="([+\u2212-])",OZ="(?:[.,](\\d{1,9}))?",I2=`(?:(?:${yf}(\\d{6}))|(\\d{4}))-?(\\d{2})`,pf="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+OZ+")?)?",cf=yf+pf,$J=I2+"-?(\\d{2})(?:[T ]"+pf+"(Z|"+cf+")?)?",M2="\\[(!?)([^\\]]*)\\]",$T=`((?:${M2}){0,9})`,OJ=_$(I2+$T),ZJ=_$("(?:--)?(\\d{2})-?(\\d{2})"+$T),TJ=_$($J+$T),fJ=_$("T?"+pf+"(?:"+cf+")?"+$T),jJ=_$(cf),WJ=new RegExp(M2,"g"),zJ=_$(`${yf}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${OZ}H)?(?:(\\d+)${OZ}M)?(?:(\\d+)${OZ}S)?)?`),JJ=E0(($)=>new _1(G2,{timeZone:$,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),YJ=/^(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$/,XJ=E0(n5),hf=E0(($)=>new _1(G2,{calendar:$,timeZone:$$,era:"short",year:"numeric",month:"short",day:"numeric"})),FJ=/^M(\d{2})(L?)$/,CJ={era:TZ,eraYear:U0,year:U0,month:sW,monthCode:TZ,day:sW},DJ=E$(F1,U0),UJ=E$(k,I6),f6=Object.assign({},CJ,DJ,UJ,{offset:TZ}),GJ=b(m5,F1,u0),j6={dateAdd($,O,Z){let T=R(Z),f,{years:j,months:W,weeks:z,days:J}=O;if(J+=j0(O,5)[0],j||W)f=((Y,X,C,F,U)=>{let[D,G,B]=Y.h(X);if(C){let[Q,S]=Y.I(D,G);D+=C,G=YZ(Q,S,Y.U(D)),G=m0("month",G,1,Y.L(D),U)}return F&&([D,G]=Y._(D,G,F)),B=m0("day",B,1,Y.j(D,G),U),Y.q(D,G,B)})(this,$,j,W,T);else{if(!z&&!J)return $;f=K0($)}return f+=(7*z+J)*A0,Q1(QZ(f))},dateUntil($,O,Z){if(Z<=7){let J=0,Y=i8({...$,...p0},{...O,...p0});return Z===7&&([J,Y]=L1(Y,7)),{...Y0,weeks:J,days:Y}}let T=this.h($),f=this.h(O),[j,W,z]=((J,Y,X,C,F,U,D)=>{let G=F-Y,B=U-X,Q=D-C;if(G||B){let S=Math.sign(G||B),V=J.j(F,U),x=0;if(Math.sign(Q)===-S){let _=V;[F,U]=J._(F,U,-S),G=F-Y,B=U-X,V=J.j(F,U),x=S<0?-_:V}if(Q=D-Math.min(C,V)+x,G){let[_,L]=J.I(Y,X),[I,A]=J.I(F,U);if(B=I-_||Number(A)-Number(L),Math.sign(B)===-S){let E=S<0&&-J.L(F);G=(F-=S)-Y,B=U-YZ(_,L,J.U(F))+(E||J.L(F))}}}return[G,B,Q]})(this,...T,...f);return Z===8&&(W+=this.J(j,T[0]),j=0),{...Y0,years:j,months:W,days:z}},dateFromFields($,O){let Z=R(O),T=dT(this,$),f=uT(this,$,T,Z),j=O6(this,$,f,T,Z);return r(Q1(this.P(T,f,j)),this.id||v)},yearMonthFromFields($,O){let Z=R(O),T=dT(this,$),f=uT(this,$,T,Z);return p1(D3(this.P(T,f,1)),this.id||v)},monthDayFromFields($,O){let Z=R(O),T=!this.id,{monthCode:f,year:j,month:W}=$,z,J,Y,X,C;if(f!==void 0){[z,J]=n8(f),C=z6($,"day");let F=this.N(z,J,C);if(!F)throw RangeError(Z6);if([Y,X]=F,W!==void 0&&W!==X)throw RangeError(az);T&&(X=m0("month",X,1,f1,1),C=m0("day",C,1,G3(j!==void 0?j:Y,X),Z))}else{Y=j===void 0&&T?V$:dT(this,$),X=uT(this,$,Y,Z),C=O6(this,$,X,Y,Z);let F=this.U(Y);J=X===F,z=rT(X,F);let U=this.N(z,J,C);if(!U)throw RangeError(Z6);[Y,X]=U}return jZ(Q1(this.P(Y,X,C)),this.id||v)},fields($){return tT(this)&&$.includes("year")?[...$,...O3]:$},mergeFields($,O){let Z=Object.assign(Object.create(null),$);return sT(Z,O,Ef),tT(this)&&(sT(Z,O,x7),this.id===Q$&&sT(Z,O,P7,O3)),Z},inLeapYear($){let[O]=this.h($);return this.K(O)},monthsInYear($){let[O]=this.h($);return this.L(O)},daysInMonth($){let[O,Z]=this.h($);return this.j(O,Z)},daysInYear($){let[O]=this.h($);return this.X(O)},dayOfYear:Df,era($){return this.ee($)[0]},eraYear($){return this.ee($)[1]},monthCode($){let[O,Z]=this.h($),[T,f]=this.I(O,Z);return((j,W)=>"M"+q0(j)+(W?"L":""))(T,f)},dayOfWeek:w6,daysInWeek(){return 7}},BJ={dayOfYear:Df,h:A6,q:S$},KJ=Object.assign({},BJ,{weekOfYear:u8,yearOfWeek:s8,R($){function O(U){return(7-U<T?7:0)-U}function Z(U){let D=H6(F+U),G=U||1,B=O(jO(J+D*G,7));return X=(D+(B-Y)*G)/7}let T=this.id?1:4,f=w6($),j=this.dayOfYear($),W=jO(f-1,7),z=j-1,J=jO(W-z,7),Y=O(J),X,C=Math.floor((z-Y)/7)+1,F=$.isoYear;return C?C>Z(0)&&(C=1,F++):(C=Z(-1),F--),[C,F,X]}}),QJ={dayOfYear:Df,h:oT,q:YO,weekOfYear:u8,yearOfWeek:s8,R(){return[]}},b$=r5(Object.assign({},j6,KJ,{h:A6,ee($){return this.id===nZ?b6($):this.id===Q$?q7($):[]},I:($,O)=>[O,0],N($,O){if(!O)return[V$,$]},K:B3,U(){},L:E6,J:($)=>$*f1,j:G3,X:H6,P:($,O,Z)=>({isoYear:$,isoMonth:O,isoDay:Z}),q:S$,_:($,O,Z)=>($+=CZ(Z,f1),(O+=W3(Z,f1))<1?($--,O+=f1):O>f1&&($++,O-=f1),[$,O]),year($){return $.isoYear},month($){return $.isoMonth},day:($)=>$.isoDay}),Object.assign({},j6,QJ,{h:oT,ee($){let O=this.O($);return[O.era,O.eraYear]},I($,O){let Z=rO.call(this,$);return[rT(O,Z),Z===O]},N($,O,Z){let[T,f,j]=oT.call(this,{isoYear:V$,isoMonth:f1,isoDay:31}),W=rO.call(this,T),z=f===W;(K1($,rT(f,W))||K1(Number(O),Number(z))||K1(Z,j))===1&&T--;for(let J=0;J<100;J++){let Y=T-J,X=rO.call(this,Y),C=YZ($,O,X);if(O===(C===X)&&Z<=eW.call(this,Y,C))return[Y,C]}},K($){let O=tO.call(this,$);return O>tO.call(this,$-1)&&O>tO.call(this,$+1)},U:rO,L:eO,J($,O){let Z=O+$,T=Math.sign($),f=T<0?-1:0,j=0;for(let W=O;W!==Z;W+=T)j+=eO.call(this,W+f);return j},j:eW,X:tO,P($,O,Z){return QZ(YO.call(this,$,O,Z))},q:YO,_($,O,Z){if(Z){if(O+=Z,!Number.isSafeInteger(O))throw RangeError(hZ);if(Z<0)for(;O<1;)O+=eO.call(this,--$);else{let T;for(;O>(T=eO.call(this,$));)O-=T,$++}}return[$,O]},year($){return this.O($).year},month($){let{year:O,F:Z}=this.O($),{C:T}=this.B(O);return T[Z]+1},day($){return this.O($).day}})),V1="numeric",v$=["timeZoneName"],N2={month:V1,day:V1},lf={year:V1,month:V1},df=Object.assign({},lf,{day:V1}),uf={hour:V1,minute:V1,second:V1},sf=Object.assign({},df,uf),VJ=Object.assign({},sf,{timeZoneName:"short"}),LJ=Object.keys(lf),SJ=Object.keys(N2),IJ=Object.keys(df),MJ=Object.keys(uf),nf=["dateStyle"],NJ=LJ.concat(nf),xJ=SJ.concat(nf),af=IJ.concat(nf,["weekday"]),PO=MJ.concat(["dayPeriod","timeStyle"]),of=af.concat(PO),PJ=of.concat(v$),_J=v$.concat(PO),AJ=v$.concat(af),EJ=v$.concat(["day","weekday"],PO),HJ=v$.concat(["year","weekday"],PO),wJ={},rf=[o1(of,sf),MZ],x2=[o1(PJ,VJ),MZ,0,($,O)=>{let Z=J0($.timeZone);if(O&&J0(O.timeZone)!==Z)throw RangeError(rz);return Z}],tf=[o1(of,sf,v$),K0],ef=[o1(af,df,_J),K0],$j=[o1(PO,uf,AJ),($)=>S1($)/o0],Oj=[o1(NJ,lf,EJ),K0,1],Zj=[o1(xJ,N2,HJ),K0,1],W6;function e0($,O,Z,T,f){function j(...J){if(!(this instanceof j))throw TypeError(Pf);E2(this,O(...J))}function W(J,Y){return Object.defineProperties(function(...X){return J.call(this,z(this),...X)},T3(Y))}function z(J){let Y=D0(J);if(!Y||Y.branding!==$)throw TypeError(Pf);return Y}return Object.defineProperties(j.prototype,{...J6(c0(W,Z)),...i1(c0(W,T)),...FZ("Temporal."+$)}),Object.defineProperties(j,{...i1(f),...T3($)}),[j,(J)=>{let Y=Object.create(j.prototype);return E2(Y,J),Y},z]}function b2($){return $=$.concat("id").sort(),(O)=>{if(!Y6(O,$))throw TypeError(oz);return O}}function m$($){if(D0($)||$.calendar!==void 0||$.timeZone!==void 0)throw TypeError(uz);return $}function OT($,O){let Z={};for(let T in $)Z[T]=({o:f},j)=>{let W=D0(j)||{},{branding:z}=W,J=z===t1||O.includes(z)?W:S0(j);return f[T](J)};return Z}function jj($){let O={};for(let Z in $)O[Z]=(T)=>{let{calendar:f}=T;return(j=f,typeof j=="string"?b$(j):(W=j,Object.assign(Object.create(sJ),{i:W})))[Z](T);var j,W};return O}function b1(){throw TypeError(nz)}function AO({calendar:$}){return typeof $=="string"?new Uj($):$}function P2($,O){if(O=a(O),W0($)){let T=D0($);if(T&&T.branding===w$)return R(O),T;let f=R2($);return Bf(JT(f||v),!f,$,O)}let Z=Q8(b$,$);return R(O),Z}function v2($,O,Z){return T=O.call($,L0(z0(Z))),m3(UO(T));var T}function ZT($,O=y2){let Z=Object.keys(O).sort(),T={};for(let f of Z)T[f]=b(O[f],$,F2($[f]));return T}function y($,O){return typeof $=="string"?eZ($):ZT($,O)}function e($){return y($,fj)}function r0($){if(W0($)){let O=D0($);if(O)switch(O.branding){case rZ:return O;case C1:return z0(O.epochNanoseconds)}}return D8($)}function _2($,O,Z){let T=O.l(r0(Z).epochNanoseconds,$);return T?L0(z0(T)):null}function c($){return W0($)?(D0($)||{}).timeZone||eJ($):((O)=>kZ(I8(h(O))))($)}function A1($,O){if(W0($)){let Z=D0($)||{};switch(Z.branding){case oZ:return R(O),Z;case e1:return R(O),l0(Z);case C1:return R(O),If(e,Z)}return Oz($,O)}return R(O),V8($)}function Wj($){return $===void 0?void 0:A1($)}function g$($,O){if(O=a(O),W0($)){let T=D0($);return T&&T.branding===H$?(R(O),T):Gf(WT(EO($)),$,O)}let Z=K8(b$,$);return R(O),Z}function E1($,O){if(O=a(O),W0($)){let T=D0($)||{};switch(T.branding){case e1:return R(O),T;case t1:return R(O),o({...T,...p0});case C1:return R(O),Lf(e,T)}return $z(zT(EO($)),$,O)}let Z=B8($);return R(O),Z}function S0($,O){if(O=a(O),W0($)){let T=D0($)||{};switch(T.branding){case t1:return R(O),T;case e1:return R(O),r(T);case C1:return R(O),Sf(e,T)}return Uf(zT(EO($)),$,O)}let Z=gZ($);return R(O),Z}function g2($,O,Z){return i0(O.call($,d(r(Z,$))))}function $1($){return(O)=>typeof O=="string"?b$(O):((Z,T)=>{let f=Object.keys(T).sort(),j={};for(let W of f)j[W]=b(T[W],Z,Z[W]);return j})(O,$)}function l($){if(W0($)){let O=D0($);return O&&O.branding===tZ?O:Zz($)}return L8($)}function _O($){if($!==void 0){if(W0($)){let O=D0($)||{};switch(O.branding){case C1:case t1:return O;case e1:return r(O)}let Z=EO($);return{...t8(c,y,zT(Z),$),calendar:Z}}return U8($)}}function EO($){return R2($)||v}function R2($){let{calendar:O}=$;if(O!==void 0)return C0(O)}function C0($){return W0($)?(D0($)||{}).calendar||UY($):((O)=>KO(S8(h(O))))($)}function R$($,O){if(O=a(O),W0($)){let Z=D0($);if(Z&&Z.branding===C1)return GO(O),Z;let T=EO($);return e8(c,y,zT(T),T,$,O)}return G8($,O)}function A2($){return c0((O)=>(Z)=>O(Tj(Z)),$)}function Tj($){return Q0($,e)}function bJ(){let $=_1.prototype,O=Object.getOwnPropertyDescriptors($),Z=Object.getOwnPropertyDescriptors(_1),T=function(f,j={}){if(!(this instanceof T))return new T(f,j);Gj.set(this,((W,z={})=>{let J=new _1(W,z),Y=J.resolvedOptions(),X=Y.locale,C=w0(Object.keys(z),Y),F=E0(RJ),U=(...D)=>{let G,B=D.map((Q,S)=>{let V=D0(Q),x=(V||{}).branding;if(S&&G&&G!==x)throw TypeError(ez);return G=x,V});return G?F(G)(X,C,...B):[J,...D]};return U.u=J,U})(f,j))};for(let f in O){let j=O[f],W=f.startsWith("format")&&vJ(f);typeof j.value=="function"?j.value=f==="constructor"?T:W||gJ(f):W&&(j.get=function(){return W.bind(this)})}return Z.prototype.value=Object.create($,O),Object.defineProperties(T,Z),T}function vJ($){return function(...O){let Z=Gj.get(this),[T,...f]=Z(...O);return T[$](...f)}}function gJ($){return function(...O){return Gj.get(this).u[$](...O)}}function RJ($){let O=kJ[$];if(!O)throw TypeError(tz($));return Y1(O,E0(Mf))}var kJ={Instant:rf,PlainDateTime:tf,PlainDate:ef,PlainTime:$j,PlainYearMonth:Oj,PlainMonthDay:Zj},mJ=Y1(rf),qJ=Y1(x2),yJ=Y1(tf),pJ=Y1(ef),cJ=Y1($j),iJ=Y1(Oj),hJ=Y1(Zj),zj={era:B6,eraYear:z3,year:UO,month:i0,daysInMonth:i0,daysInYear:i0,inLeapYear:X2,monthsInYear:i0},fT={monthCode:h},Jj={day:i0},k2={dayOfWeek:i0,dayOfYear:i0,weekOfYear:K6,yearOfWeek:z3,daysInWeek:i0},m2=Object.assign({},zj,fT,Jj,k2),TT=new WeakMap,D0=TT.get.bind(TT),E2=TT.set.bind(TT),lJ={...OT(zj,[H$]),...OT(k2,[]),...OT(fT,[H$,w$]),...OT(Jj,[w$])},Yj=jj(m2),dJ=jj({...zj,...fT}),uJ=jj({...fT,...Jj}),HO={calendarId:($)=>J0($.calendar)},sJ=c0(($,O)=>function(Z){let{i:T}=this;return $(T[O](d(r(Z,T))))},m2),nJ=CO(($)=>(O)=>O[$],k.concat("sign")),Xj=CO(($,O)=>(Z)=>Z[u0[O]],F1),q2={epochSeconds:y6,epochMilliseconds:MZ,epochMicroseconds:p6,epochNanoseconds:c6},wO=b(f3,new Set(["branding"])),[aJ,k$,oJ]=e0(w$,b(Bz,C0),{...HO,...uJ},{getISOFields:wO,getCalendar:AO,with($,O,Z){return k$(zz(FY,$,this,m$(O),Z))},equals:($,O)=>k8($,P2(O)),toPlainDate($,O){return d(Hz(bO,$,this,O))},toLocaleString($,O,Z){let[T,f]=hJ(O,Z,$);return T.format(f)},toString:b3,toJSON:($)=>b3($),valueOf:b1},{from:($,O)=>k$(P2($,O))}),y2={getOffsetNanosecondsFor:v2,getPossibleInstantsFor($,O,Z){let T=[...O.call($,F0(o(Z,v)))].map((j)=>tJ(j).epochNanoseconds),f=T.length;return f>1&&(T.sort(B0),q3(R0(g0(T[0],T[f-1])))),T}},fj={getOffsetNanosecondsFor:v2},[rJ,L0,tJ]=e0(rZ,Fz,q2,{add:($,O)=>L0(y3(0,$,l(O))),subtract:($,O)=>L0(y3(1,$,l(O))),until:($,O,Z)=>p(Wf(0,$,r0(O),Z)),since:($,O,Z)=>p(Wf(1,$,r0(O),Z)),round:($,O)=>L0(l6($,O)),equals:($,O)=>w8($,r0(O)),toZonedDateTime($,O){let Z=z1(O);return t(Vf($,c(Z.timeZone),C0(Z.calendar)))},toZonedDateTimeISO:($,O)=>t(Vf($,c(O))),toLocaleString($,O,Z){let[T,f]=mJ(O,Z,$);return T.format(f)},toString:($,O)=>_3(c,e,$,O),toJSON:($)=>_3(c,e,$),valueOf:b1},{from:($)=>L0(r0($)),fromEpochSeconds:($)=>L0(vz($)),fromEpochMilliseconds:($)=>L0(gz($)),fromEpochMicroseconds:($)=>L0(Rz($)),fromEpochNanoseconds:($)=>L0(kz($)),compare:($,O)=>Tf(r0($),r0(O))}),[jT,S9]=e0("TimeZone",($)=>{let O=E8($);return{branding:"TimeZone",id:O,o:eZ(O)}},{id:($)=>$.id},{getPossibleInstantsFor:({o:$},O)=>$.getPossibleInstantsFor(E1(O)).map((Z)=>L0(z0(Z))),getOffsetNanosecondsFor:({o:$},O)=>$.getOffsetNanosecondsFor(r0(O).epochNanoseconds),getOffsetStringFor($,O){let Z=r0(O).epochNanoseconds,T=ZT(this,fj).getOffsetNanosecondsFor(Z);return d1(T)},getPlainDateTimeFor($,O,Z=v){let T=r0(O).epochNanoseconds,f=ZT(this,fj).getOffsetNanosecondsFor(T);return F0(o(M1(T,f),C0(Z)))},getInstantFor($,O,Z){let T=E1(O),f=K3(Z),j=ZT(this);return L0(z0(H0(j,T,f)))},getNextTransition:({o:$},O)=>_2(1,$,O),getPreviousTransition:({o:$},O)=>_2(-1,$,O),equals($,O){return!!qZ(this,c(O))},toString:($)=>$.id,toJSON:($)=>$.id},{from($){let O=c($);return typeof O=="string"?new jT(O):O}}),eJ=b2(Object.keys(y2)),[$Y,H1]=e0(oZ,Kz,Xj,{getISOFields:wO,with($,O,Z){return H1(Jz(this,m$(O),Z))},add:($,O)=>H1(l3(0,$,l(O))),subtract:($,O)=>H1(l3(1,$,l(O))),until:($,O,Z)=>p(Ff(0,$,A1(O),Z)),since:($,O,Z)=>p(Ff(1,$,A1(O),Z)),round:($,O)=>H1(s6($,O)),equals:($,O)=>m8($,A1(O)),toZonedDateTime:($,O)=>t(wz(c,S0,y,$,O)),toPlainDateTime:($,O)=>F0(bz($,S0(O))),toLocaleString($,O,Z){let[T,f]=cJ(O,Z,$);return T.format(f)},toString:v3,toJSON:($)=>v3($),valueOf:b1},{from:($,O)=>H1(A1($,O)),compare:($,O)=>mZ(A1($),A1(O))}),[OY,w1,ZY]=e0(H$,b(Gz,C0),{...HO,...dJ},{getISOFields:wO,getCalendar:AO,with($,O,Z){return w1(Wz(XY,$,this,m$(O),Z))},add:($,O,Z)=>w1(h3(H2,0,$,l(O),Z)),subtract:($,O,Z)=>w1(h3(H2,1,$,l(O),Z)),until:($,O,Z)=>p(Xf(w2,0,$,g$(O),Z)),since:($,O,Z)=>p(Xf(w2,1,$,g$(O),Z)),equals:($,O)=>R8($,g$(O)),toPlainDate($,O){return d(Ez(bO,$,this,O))},toLocaleString($,O,Z){let[T,f]=iJ(O,Z,$);return T.format(f)},toString:w3,toJSON:($)=>w3($),valueOf:b1},{from:($,O)=>w1(g$($,O)),compare:($,O)=>n1(g$($),g$(O))}),[TY,F0]=e0(e1,b(Dz,C0),{...HO,...Yj,...Xj},{getISOFields:wO,getCalendar:AO,with($,O,Z){return F0(fz(bO,$,this,m$(O),Z))},withCalendar:($,O)=>F0(iZ($,C0(O))),withPlainDate:($,O)=>F0(pz($,S0(O))),withPlainTime:($,O)=>F0(yz($,Wj(O))),add:($,O,Z)=>F0(c3(O$,0,$,l(O),Z)),subtract:($,O,Z)=>F0(c3(O$,1,$,l(O),Z)),until:($,O,Z)=>p(Jf(t0,0,$,E1(O),Z)),since:($,O,Z)=>p(Jf(t0,1,$,E1(O),Z)),round:($,O)=>F0(u6($,O)),equals:($,O)=>v8($,E1(O)),toZonedDateTime:($,O,Z)=>t(Iz(y,$,c(O),Z)),toPlainDate:($)=>d(r($)),toPlainTime:($)=>H1(l0($)),toPlainYearMonth($){return w1(Mz(WT,$,this))},toPlainMonthDay($){return k$(Nz(JT,$,this))},toLocaleString($,O,Z){let[T,f]=yJ(O,Z,$);return T.format(f)},toString:E3,toJSON:($)=>E3($),valueOf:b1},{from:($,O)=>F0(E1($,O)),compare:($,O)=>jf(E1($),E1(O))}),[fY,d,p2]=e0(t1,b(Uz,C0),{...HO,...Yj},{getISOFields:wO,getCalendar:AO,with($,O,Z){return d(jz(bO,$,this,m$(O),Z))},withCalendar:($,O)=>d(iZ($,C0(O))),add:($,O,Z)=>d(i3(O$,0,$,l(O),Z)),subtract:($,O,Z)=>d(i3(O$,1,$,l(O),Z)),until:($,O,Z)=>p(Yf(t0,0,$,S0(O),Z)),since:($,O,Z)=>p(Yf(t0,1,$,S0(O),Z)),equals:($,O)=>g8($,S0(O)),toZonedDateTime($,O){let Z=!W0(O)||O instanceof jT?{timeZone:O}:O;return t(xz(c,A1,y,$,Z))},toPlainDateTime:($,O)=>F0(Pz($,Wj(O))),toPlainYearMonth($){return w1(_z(WT,$,this))},toPlainMonthDay($){return k$(Az(JT,$,this))},toLocaleString($,O,Z){let[T,f]=pJ(O,Z,$);return T.format(f)},toString:H3,toJSON:($)=>H3($),valueOf:b1},{from:($,O)=>d(S0($,O)),compare:($,O)=>n1(S0($),S0(O))}),Fj={fields($,O,Z){return[...O.call($,Z)]}},c2=Object.assign({dateFromFields($,O,Z,T){return p2(O.call($,Object.assign(Object.create(null),Z),T))}},Fj),i2=Object.assign({yearMonthFromFields($,O,Z,T){return ZY(O.call($,Object.assign(Object.create(null),Z),T))}},Fj),h2=Object.assign({monthDayFromFields($,O,Z,T){return oJ(O.call($,Object.assign(Object.create(null),Z),T))}},Fj),Cj={mergeFields($,O,Z,T){return z1(O.call($,Object.assign(Object.create(null),Z),Object.assign(Object.create(null),T)))}},jY=Object.assign({},c2,Cj),WY=Object.assign({},i2,Cj),zY=Object.assign({},h2,Cj),Dj={dateAdd($,O,Z,T,f){return p2(O.call($,d(r(Z,$)),p(i(T)),f))}},l2=Object.assign({},Dj,{dateUntil($,O,Z,T,f,j){return DY(O.call($,d(r(Z,$)),d(r(T,$)),Object.assign(Object.create(null),j,{largestUnit:IO[f]})))}}),JY=Object.assign({},Dj,{day:g2}),YY=Object.assign({},l2,{day:g2}),WT=$1(i2),zT=$1(c2),JT=$1(h2),XY=$1(WY),bO=$1(jY),FY=$1(zY),O$=$1(Dj),t0=$1(l2),H2=$1(JY),w2=$1(YY),[CY,p,DY]=e0(tZ,Qz,{...nJ,blank:X8},{with:($,O)=>p(Yz($,O)),negated:($)=>p(bZ($)),abs:($)=>p(Y8($)),add:($,O,Z)=>p(a3(_O,t0,y,0,$,l(O),Z)),subtract:($,O,Z)=>p(a3(_O,t0,y,1,$,l(O),Z)),round:($,O)=>p(J8(_O,t0,y,$,O)),total:($,O)=>h6(_O,t0,y,$,O),toLocaleString($,O,Z){return Intl.DurationFormat?new Intl.DurationFormat(O,Z).format(this):_Z($)},toString:_Z,toJSON:($)=>_Z($),valueOf:b1},{from:($)=>p(l($)),compare:($,O,Z)=>H8(_O,O$,y,l($),l(O),Z)}),d2={toString:($)=>$.id,toJSON:($)=>$.id,...lJ,dateAdd:({id:$,o:O},Z,T,f)=>d(r(O.dateAdd(S0(Z),l(T),f),$)),dateUntil:({o:$},O,Z,T)=>p(i($.dateUntil(S0(O),S0(Z),g6(T)))),dateFromFields:({id:$,o:O},Z,T)=>d(Uf(O,Z,T,G6($))),yearMonthFromFields:({id:$,o:O},Z,T)=>w1(Gf(O,Z,T,D6($))),monthDayFromFields:({id:$,o:O},Z,T)=>k$(Bf(O,0,Z,T,U6($))),fields({o:$},O){let Z=new Set(d0),T=[];for(let f of O){if(h(f),!Z.has(f))throw RangeError(xf(f));Z.delete(f),T.push(f)}return $.fields(T)},mergeFields:({o:$},O,Z)=>$.mergeFields(j3(J3(O)),j3(J3(Z)))},[Uj]=e0("Calendar",($)=>{let O=d8($);return{branding:"Calendar",id:O,o:b$(O)}},{id:($)=>$.id},d2,{from($){let O=C0($);return typeof O=="string"?new Uj(O):O}}),UY=b2(Object.keys(d2).slice(4)),[GY,t]=e0(C1,b(Cz,C0,c),{...q2,...HO,...A2(Yj),...A2(Xj),offset:($)=>d1(Tj($).offsetNanoseconds),offsetNanoseconds:($)=>Tj($).offsetNanoseconds,timeZoneId:($)=>J0($.timeZone),hoursInDay:($)=>n6(y,$)},{getISOFields:($)=>W8(e,$),getCalendar:AO,getTimeZone:({timeZone:$})=>typeof $=="string"?new jT($):$,with($,O,Z){return t(Tz(bO,y,$,this,m$(O),Z))},withCalendar:($,O)=>t(iZ($,C0(O))),withTimeZone:($,O)=>t(cz($,c(O))),withPlainDate:($,O)=>t(qz(y,$,S0(O))),withPlainTime:($,O)=>t(mz(y,$,Wj(O))),add:($,O,Z)=>t(p3(O$,y,0,$,l(O),Z)),subtract:($,O,Z)=>t(p3(O$,y,1,$,l(O),Z)),until:($,O,Z)=>p(i(zf(t0,y,0,$,R$(O),Z))),since:($,O,Z)=>p(i(zf(t0,y,1,$,R$(O),Z))),round:($,O)=>t(d6(y,$,O)),startOfDay:($)=>t(a6(y,$)),equals:($,O)=>b8($,R$(O)),toInstant:($)=>L0(Vz($)),toPlainDateTime:($)=>F0(Lf(e,$)),toPlainDate:($)=>d(Sf(e,$)),toPlainTime:($)=>H1(If(e,$)),toPlainYearMonth($){return w1(Lz(WT,$,this))},toPlainMonthDay($){return k$(Sz(JT,$,this))},toLocaleString($,O,Z={}){let[T,f]=qJ(O,Z,$);return T.format(f)},toString:($,O)=>A3(e,$,O),toJSON:($)=>A3(e,$),valueOf:b1},{from:($,O)=>t(R$($,O)),compare:($,O)=>ff(R$($),R$(O))}),BY=Object.defineProperties({},{...FZ("Temporal.Now"),...i1({timeZoneId:()=>X1(),instant:()=>L0(z0(VO())),zonedDateTime:($,O=X1())=>t(X0(VO(),c(O),C0($))),zonedDateTimeISO:($=X1())=>t(X0(VO(),c($),v)),plainDateTime:($,O=X1())=>F0(o(A$(e(c(O))),C0($))),plainDateTimeISO:($=X1())=>F0(o(A$(e(c($))),v)),plainDate:($,O=X1())=>d(r(A$(e(c(O))),C0($))),plainDateISO:($=X1())=>d(r(A$(e(c($))),v)),plainTimeISO:($=X1())=>H1(l0(A$(e(c($)))))})}),q$=Object.defineProperties({},{...FZ("Temporal"),...i1({PlainYearMonth:OY,PlainMonthDay:aJ,PlainDate:fY,PlainTime:$Y,PlainDateTime:TY,ZonedDateTime:GY,Instant:rJ,Calendar:Uj,TimeZone:jT,Duration:CY,Now:BY})}),KY=bJ(),Gj=new WeakMap,QY=Object.defineProperties(Object.create(Intl),i1({DateTimeFormat:KY}));var Bj="intended_url";class Kj extends P{schema={email:{required:"Email is required",string:"Invalid email",email:"Invalid email"},password:{required:"Password is required"}}}class u2 extends P{schema={email:{required:"Email is required",email:"Invalid email"}}}class s2 extends P{schema={password:{required:"Password is required",password:"Invalid password"}}}class $0 extends kT{async me(){let $=await Z$.user();if(!$)throw new mT;return $}async verifyEmail($=new P){let O=await $.input(),{userProvider:Z}=K(w),T=await Z.findUserByVerificationToken(O.get("token"));if(!T)return{email:null};return await Z.verifyUser(T.email),{email:T.email}}async signInWithMagicLink($=new P){let O=K(w),{userProvider:Z}=O,T=$.search.get("token"),f=decodeURIComponent($.search.get("email")).toLowerCase().trim(),j=null;try{j=await Z.findUserMagicLinkToken({email:f,token:T})}catch(z){return console.log(z),{error:JSON.stringify(z)}}if(!j)return{error:"Invalid token"};await Z.verifyUser(f),await Z.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 P){let O=K(w),{userProvider:Z}=O,T=await $.input(),{email:f,pin:j}=T.toJSON(),W=f.toLowerCase().trim();if(!await Z.findUserMagicLinkToken({email:W,pin:j}))throw new x0({pin:["Invalid pin"]});await Z.deleteMagicLinkToken(W),await Z.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 P){let O=K(w),{userProvider:Z}=O,T=await $.input(),{email:f,pin:j}=T.toJSON(),W=f.toLowerCase().trim();if(!await Z.findUserMagicLinkToken({email:W,pin:j}))throw new x0({pin:["Invalid pin"]});await Z.deleteMagicLinkToken(W),await Z.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 Kj){let O=await $.input(),{email:Z,password:T}=O.toJSON(),f=Z.toLowerCase().trim(),j=K(w),W=await j.userProvider.findUserByEmailAddress(f,j.config.verifyEmail);if(!W)throw new x0({invalid_credentials:["Invalid credentials"]});if(!await j.config.verifyPassword(T,W.password))throw new x0({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:Y,...X}=W;return X}async signIn($=new Kj){let O=await $.input(),{email:Z,password:T}=O.toJSON(),f=Z.toLowerCase().trim(),j=K(w),W=await j.userProvider.findUserByEmailAddress(f,j.config.verifyEmail);if(!W)throw new x0({invalid_credentials:["Invalid credentials"]});if(!await j.config.verifyPassword(T,W.password))throw new x0({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:Y,...X}=W;return X}async signUp(){let $=K(w),{userProvider:O,config:Z}=$,T=new Z.signUpRequest,f=await T.input(),{email:j,password:W,name:z,invitationId:J}=f.toJSON(),Y=j.toLowerCase().trim();if(await O.findUserByEmailAddress(Y,!1))throw new x0({email:["Email address already exists"]});let C=await Z.hashPassword(W),F=K(n).detectLocale(T),U;if(J)U=await O.findInvitation(J,Y);let D,G="";if(U)D=await O.transaction(async()=>{await O.deleteInvitationById(J);let B=await O.createUser({email:Y,name:z,password:C,emailVerifiedAt:new Date,locale:F});return await O.createAccount({organizationId:U.organizationId,userId:B.id,organizationRole:U.role}),await Z.onUserCreated(B),B});else G=await Z.generateEmailVerificationToken(Y),D=await O.transaction(async()=>{let B=await O.createUser({email:Y,name:z,password:C,verificationToken:G,locale:F});return await Z.onUserCreated(B),B});return await Z.onSignUp(D,G,T.search.toJSON()),D}async signOut($=new P){let O=$.cookies.get("access_token")??$.headers.get("access_token"),Z=K(w),{config:T}=Z,f=await Z.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 T.extendSession(f.user),await T.onSignOut(f.user);return{}}async forgotPassword($=new u2){let Z=(await $.input()).get("email").toLowerCase().trim(),{userProvider:T,config:f}=K(w),j=await T.findUserByEmailAddress(Z,f.verifyEmail);if(!j)return{};let W=await f.generateForgotPasswordToken(j);return await T.createPasswordResetToken({user:j,token:W}),await f.onForgotPassword(j,W),{}}async resetPassword($=new s2){let{userProvider:O,config:Z}=K(w),T=await $.input(),{password:f,token:j}=T.toJSON(),W=await O.findPasswordResetToken({token:j});if(!W)throw new x0({token:["Invalid token"]});if(q$.Instant.from(W.createdAt.toISOString()).add({hours:24}).until(q$.Now.instant()).sign>=0)throw new x0({token:["Token expired"]});await O.deletePasswordResetToken({token:j});let J=await O.findUserByEmailAddress(W.user.email,Z.verifyEmail);if(!J)throw new x0({email:["User not found"]});let Y=await Z.hashPassword(f);return await O.updateUserPassword({id:J.id,password:Y}),await O.deleteAllUserSessions(J.id),await Z.onResetPassword(J),{}}async changePassword($=new P){let{userProvider:O,config:Z}=K(w),T=await Z$.user(),f=await $.input(),{oldPassword:j,newPassword:W}=f.toJSON(),{password:z}=await O.findUserByEmailAddress(T.email,Z.verifyEmail);if(!await Z.verifyPassword(j,z))throw new x0({oldPassword:["Incorrect password"]});let Y=await Z.hashPassword(W);return await O.updateUserPassword({id:T.id,password:Y}),await O.deleteAllUserSessions(T.id),{}}async oauthRedirect($=new P){let{provider:O}=$.params,Z=K(w).config.oauthProviders[O];if(!Z)throw Error(`Invalid provider: ${O}`);let T=$O($.search.get(C$),"");if(T)$.ctx().setCookie(Bj,encodeURIComponent(T),{httpOnly:!0,sameSite:"Lax",secure:_W($.rawRequest),maxAge:600});return{destination:await Z.getRedirectUrl($)}}async oauthCallback($=new P){let{provider:O}=$.params,Z=K(w),{userProvider:T,config:f}=Z,j=f.oauthProviders[O],{email:W,name:z,username:J,providerId:Y}=await j.onCallback($),X=Y?await T.findUserBySocialAccount(O,Y):null,C="signin";if(!X){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:Y,email:W,name:z,username:J,locale:G});if(B)X=B.user,C=B.action}catch(B){let Q=Y?await T.findUserBySocialAccount(O,Y):null;if(!Q)throw B;X=Q}if(!X)return{session:null}}let F=await Z.createOrUpdateSessionV2({email:X.email,id:X.id});if($.ctx().setCookie("access_token",F.token,K(w).accessTokenCookieOptions($,F.expiresAt)),C==="signup")await f.onSignUp(X,"",$.search.toJSON());else await f.onSignIn(X,$.search.toJSON());let U=$.cookies.get(Bj),D=f.redirectPath;if(U){try{D=$O(decodeURIComponent(U),D)}catch{}$.ctx().setCookie(Bj,"",{maxAge:-1})}return{session:F,redirectTo:D}}async linkOAuthAccount($){let{provider:O,providerId:Z,email:T,name:f,username:j,locale:W}=$,{userProvider:z,config:J}=K(w),Y=(F)=>({provider:O,userId:F,email:T,username:j,providerId:Z,expiresAt:new Date,accessToken:"",refreshToken:""}),X=await z.findUserByEmailAddress(T,!1);if(X){if(!Z)return{user:X,action:"signin"};let F=await z.findSocialAccounts(X.id,O);if(F.some((D)=>D.providerId===Z))return{user:X,action:"signin"};if(F.some((D)=>D.providerId))return console.error(`Authentication error: user ${X.id} is already linked to a different ${O} account`),null;let U=F[0];if(U){if(!await z.claimSocialAccount(U,Z))throw Error(`${O} account link changed concurrently`)}else await z.createSocialAccount(Y(X.id));return{user:X,action:"signin"}}return{user:await z.transaction(async()=>{let F=await z.createUser({email:T,name:f,locale:W,emailVerifiedAt:new Date});if(Z)await z.createSocialAccount(Y(F.id));return await J.onUserCreated(F),F}),action:"signup"}}async createMagicLinkToken($=new P){let Z=(await $.input()).get("email").toLowerCase().trim(),T=K(w),{user:f,pin:j,token:W}=await T.createMagicLinkToken(Z);if(f)return await T.config.onMagicLinkCreated(f,{email:Z,pin:j,token:W}),{email:Z};return{email:null}}}class n2 extends B1{middlewares=["cache:private"];routes={"/:provider":this.view("_Redirect",[$0,"oauthRedirect"]),"/:provider/callback":this.view("auth/OauthCallback",[$0,"oauthCallback"])}}class Qj extends B1{middlewares=["cache:private"];routes={"/sign-in/magic-link":this.view("auth/MagicLinkSignIn",[$0,"signInWithMagicLink"]),"/oauth":n2}}class Vj extends N0{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 N0{middlewares=["cache:private,0,no-store"];routes={"/set-locale/:locale":this.get(async()=>{let O=new P().params.locale;return await K(n).onLocaleChange(O),{locale:O}}),"/translations/:locale/:scope*":this.get(async()=>{let $=new P,O=`/${$.params.scope??""}`,Z=$.params.locale,T=K(n),f=Z??T.detectLocale($),j=T.getPageTranslations(f,O);return $.ctx().setCookie("i18n-locale",f,{expires:new Date(Date.now()+31536000000)}),{[f]:j}})}}class Sj{}class Ij extends Sj{async resize($,O){let{height:Z,width:T,quality:f,fit:j}=O;return await(await YT("The Sharp image optimization driver"))($).resize(T>0?T:void 0,Z>0?Z:void 0,{fit:j}).webp({quality:f>0?f:80,force:!0}).toBuffer()}}function o9($){return $}function a2(){return{driver:new Ij}}class Mj extends N0{routes={"/resize":this.file(async()=>{let $=new P,O=new URL($.rawRequest.url),Z=O.searchParams.get("url"),T=Number(O.searchParams.get("w")),f=Number(O.searchParams.get("h")),j=O.searchParams.get("fit")??"cover",W=Number(O.searchParams.get("q"));if(!Z)return new Response(JSON.stringify({error:"url query parameter is required"}),{headers:{"Content-Type":"application/json"},status:404});let J=`${Z.startsWith("http")?"":`http://localhost:${process.env.PORT||5173}`}${Z}`,Y=await fetch(J);if(!Y.ok)return new Response(JSON.stringify({error:"Image not found",info:J}),{headers:{"Content-Type":"application/json"},status:404});let X=Buffer.from(await Y.arrayBuffer()),C=await K(o2).resize(X,{height:f,width:T,fit:j,quality:W});Y.headers.delete("Content-Type"),Y.headers.delete("Content-Length");let F=new Headers(Y.headers);return F.set("Content-Type","image/webp"),F.set("Content-Length",`${C.byteLength}`),new Response(new Uint8Array(C),{headers:F})})}}class o2{static token="image";driver;constructor($={}){this.driver=$.driver??a2().driver}resize($,O){return this.driver.resize($,O)}}import{mkdir as Nj,readdir as VY,access as LY}from"fs/promises";async function xj($){try{return await LY($),!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`${Pj()}/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 $=`${Pj()}/storage`;if(!await xj($))await Nj($);if(!await xj(this.logsDirPath))await Nj(this.logsDirPath);await this.newLogFile()}async newLogFile(){if(!await xj(this.logsDirPath))await Nj(this.logsDirPath);if(this.isCreatingFile=!0,this.currentLogFilePath){this.writer.flush(),this.writer.end(),this.writer=null;let Z=new File([await Bun.file(this.currentLogFilePath).arrayBuffer()],this.currentLogFilePath.split("/").pop(),{type:"text/plain"});this.config.onLogFileClosed(Z),this.fileSize=0,this.writerSize=0}let O=(await VY(this.logsDirPath)).sort().reverse()[0];if(O){let Z=Bun.file(`${this.logsDirPath}/${O}`);if(Z.size<this.config.maxFileSize)this.currentLogFilePath=`${this.logsDirPath}/${O}`,this.writer=Z.writer(),this.writer.write(await Z.text()),this.writer.write(`
|
|
3
|
+
`),this.writer.flush(),this.fileSize=Z.size}if(!this.writer){let Z=`${new Date(Date.now()).toISOString()}.log`.replaceAll(":","-");this.currentLogFilePath=`${this.logsDirPath}/${Z}`;let T=Bun.file(`${this.logsDirPath}/${Z}`);this.writer=T.writer(),this.fileSize=0,this.writerSize=0}this.isCreatingFile=!1}async log($,O,Z={}){if(!this.isReady)await this.boot();let T=N.getStore(),f={};if(T)f={url:T.req.rawRequest.url,method:T.req.rawRequest.method,headers:T.req.rawRequest.headers,body:T.req.rawRequest.body};let j={timestamp:new Date(Date.now()).toISOString(),env:Bun.env.NODE_ENV,level:$,message:O,metadata:{...f,...Z}},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 _j extends N0{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 SY($){let O=new Map;for(let Z of $)if(typeof Z==="string"){let[T,f=""]=Z.split(":");if(T.startsWith("-")){if(O.has(T.replace("-","")))O.delete(T.replace("-",""))}else O.set(T,f.split(",").filter(Boolean))}else O.set(Z,[]);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 P;return Array.from(SY($).entries()).map(([Z,T])=>{if(typeof Z==="string"){let f=this.aliases[Z];if(f){let j=new f(O);return()=>j.run.call(j,...T)}}else{if(lO(Z)){let f=new Z(O);return f.run.bind(f)}return Z}}).filter(Boolean).reduce((Z,T)=>{return async()=>{return{...await Z(),...await T()}}},()=>Promise.resolve({}))()}}function UC($){return $}function r2(){return{onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{}}}function t2(){return{partialRendering:!0,onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{},onStreamComplete:()=>{}}}function IY($){return"run"in $}function MY($){return Object.hasOwn($,"get")||Object.hasOwn($,"post")||Object.hasOwn($,"put")||Object.hasOwn($,"delete")}function NY($){return Object.hasOwn($,"first")&&Object.hasOwn($,"second")}function xY($){if("__brand"in $)return $.__brand==="ApiRouter";return!1}function PY($){if("__internal_brand"in $)return $.__internal_brand==="ProxyHandler";return!1}function _Y($){if("__internal_brand"in $)return $.__internal_brand==="StreamHandler";return!1}function Aj($,O="",Z=[]){let T={};function f(j,W,z,J,Y){let X=j==="/"?"":j,C=O==="/"?"":O,F=(`${C}${X}`===""?"/":`${C}${X}`).replaceAll("//","/");if(!T[F])T[F]={};T[F][W.toUpperCase()]={exec:z,middleware:[...Z,...J],...Y?{source:Y}:{}},T[F].OPTIONS={exec:()=>{let D=new P().ctx().headers;return new Response(null,{headers:D,status:204})},middleware:[]}}for(let[j,W]of Object.entries($)){if(PY(W)){let z=W;for(let J of["GET","POST","PUT","DELETE"])f(j,J,z.run.bind(z),[]);continue}if(IY(W)){let z=W,J=z.method,Y=z.middlewares,X=z.run.bind(z);if(f(j,J,X,Y,z.source),_Y(W))f(j,"HEAD",X,Y,z.source)}if(MY(W))for(let[z,J]of Object.entries(W)){let Y=J.middlewares,X=J.run.bind(J);f(j,z,X,Y,J.source)}if(xY(W)){let z=new W,J=Aj(z.routes,`${O}${j}`,z.middlewares);for(let[Y,X]of Object.entries(J))T[Y.replaceAll("//","/")]=X}if(NY(W)){let{first:z,second:J}=W;for(let[Y,X]of Object.entries(z)){let C=X.middlewares,F=X.run.bind(X),[U,...D]=j.split("/").reverse();if(!U.startsWith(":"))throw Error("Resource route must end with a dynamic segment");f(D.reverse().join("/"),Y,F,C,X.source)}for(let[Y,X]of Object.entries(J)){let C=X.middlewares,F=X.run.bind(X);f(j,Y,F,C,X.source)}}}return Object.fromEntries(Object.entries(T).sort(([j],[W])=>{let z=j.split("/").length+j.split(":").length,J=W.split("/").length+W.split(":").length;return z-J}))}function XT($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function Ej($,O){if($==="/")return O;if(O==="/")return $;return`${$}${O}`}function Hj($){let O=XT($);return O.length>1?O.replace(/\/$/,""):O}function e2($,O){return O.map((Z)=>({...Z,path:Hj(Ej($,Z.path))}))}function FT($){let O={};for(let[Z,T]of Object.entries($))if("run"in T){let f=T;if("children"in f){let j=new f.children,W=FT(j.routes);for(let[z,{exec:J,middleware:Y,segments:X,features:C}]of Object.entries(W)){let F=Ej(Z,z),U=(D)=>f.run.call(f,D,Z);O[XT(F)]={exec:[U,...J],middleware:[...f.middlewares,...Y],features:[...f.featureGates,...C],viewPath:f.viewPath,segments:[{path:Hj(Z),viewPath:f.viewPath,...f.alwaysRuns?{alwaysRun:!0}:{}},...e2(Z,X)]}}}else{let j=(W)=>f.run.call(f,W,Z);O[XT(Z)]={exec:[j],middleware:f.middlewares,features:f.featureGates,viewPath:f.viewPath,segments:[{path:Hj(Z),viewPath:f.viewPath}]}}}else{let f=new T,j=FT(f.routes);for(let[W,{exec:z,middleware:J,viewPath:Y,segments:X,features:C}]of Object.entries(j)){let F=Ej(Z,W);O[XT(F)]={exec:z,middleware:[...f.middlewares,...J],features:[...f.featureGates,...C],viewPath:Y,segments:e2(Z,X)}}}return Object.fromEntries(Object.entries(O).sort(([Z],[T])=>{let f=Z.split("/").length+Z.split(":").length,j=T.split("/").length+T.split(":").length;return f-j}))}var AY=Object.defineProperty,M=($,O)=>AY($,"name",{value:O,configurable:!0}),c$=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor($,O,Z,T,f,j){this.type=$,this.name=O,this.prefix=Z,this.value=T,this.suffix=f,this.modifier=j}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};M(c$,"Part");var EY=/[$_\p{ID_Start}]/u,HY=/[$_\u200C\u200D\p{ID_Continue}]/u,bj=".*";function $4($,O){return(O?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test($)}M($4,"isASCII");function Rj($,O=!1){let Z=[],T=0;for(;T<$.length;){let f=$[T],j=M(function(W){if(!O)throw TypeError(W);Z.push({type:"INVALID_CHAR",index:T,value:$[T++]})},"ErrorOrInvalid");if(f==="*"){Z.push({type:"ASTERISK",index:T,value:$[T++]});continue}if(f==="+"||f==="?"){Z.push({type:"OTHER_MODIFIER",index:T,value:$[T++]});continue}if(f==="\\"){Z.push({type:"ESCAPED_CHAR",index:T++,value:$[T++]});continue}if(f==="{"){Z.push({type:"OPEN",index:T,value:$[T++]});continue}if(f==="}"){Z.push({type:"CLOSE",index:T,value:$[T++]});continue}if(f===":"){let W="",z=T+1;for(;z<$.length;){let J=$.substr(z,1);if(z===T+1&&EY.test(J)||z!==T+1&&HY.test(J)){W+=$[z++];continue}break}if(!W){j(`Missing parameter name at ${T}`);continue}Z.push({type:"NAME",index:T,value:W}),T=z;continue}if(f==="("){let W=1,z="",J=T+1,Y=!1;if($[J]==="?"){j(`Pattern cannot start with "?" at ${J}`);continue}for(;J<$.length;){if(!$4($[J],!1)){j(`Invalid character '${$[J]}' at ${J}.`),Y=!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}`),Y=!0;break}z+=$[J++]}if(Y)continue;if(W){j(`Unbalanced pattern at ${T}`);continue}if(!z){j(`Missing pattern at ${T}`);continue}Z.push({type:"REGEX",index:T,value:z}),T=J;continue}Z.push({type:"CHAR",index:T,value:$[T++]})}return Z.push({type:"END",index:T,value:""}),Z}M(Rj,"lexer");function kj($,O={}){let Z=Rj($);O.delimiter??="/#?",O.prefixes??="./";let T=`[^${b0(O.delimiter)}]+?`,f=[],j=0,W=0,z="",J=new Set,Y=M((V)=>{if(W<Z.length&&Z[W].type===V)return Z[W++].value},"tryConsume"),X=M(()=>Y("OTHER_MODIFIER")??Y("ASTERISK"),"tryConsumeModifier"),C=M((V)=>{let x=Y(V);if(x!==void 0)return x;let{type:_,index:L}=Z[W];throw TypeError(`Unexpected ${_} at ${L}, expected ${V}`)},"mustConsume"),F=M(()=>{let V="",x;for(;x=Y("CHAR")??Y("ESCAPED_CHAR");)V+=x;return V},"consumeText"),U=M((V)=>V,"DefaultEncodePart"),D=O.encodePart||U,G="",B=M((V)=>{G+=V},"appendToPendingFixedValue"),Q=M(()=>{G.length&&(f.push(new c$(3,"","",D(G),"",3)),G="")},"maybeAddPartFromPendingFixedValue"),S=M((V,x,_,L,I)=>{let A=3;switch(I){case"?":A=1;break;case"*":A=0;break;case"+":A=2;break}if(!x&&!_&&A===3){B(V);return}if(Q(),!x&&!_){if(!V)return;f.push(new c$(3,"","",D(V),"",A));return}let E;_?_==="*"?E=bj:E=_:E=T;let Z0=2;E===T?(Z0=1,E=""):E===bj&&(Z0=0,E="");let g;if(x?g=x:_&&(g=j++),J.has(g))throw TypeError(`Duplicate name '${g}'.`);J.add(g),f.push(new c$(Z0,g,D(V),E,D(L),A))},"addPart");for(;W<Z.length;){let V=Y("CHAR"),x=Y("NAME"),_=Y("REGEX");if(!x&&!_&&(_=Y("ASTERISK")),x||_){let I=V??"";O.prefixes.indexOf(I)===-1&&(B(I),I=""),Q();let A=X();S(I,x,_,"",A);continue}let L=V??Y("ESCAPED_CHAR");if(L){B(L);continue}if(Y("OPEN")){let I=F(),A=Y("NAME"),E=Y("REGEX");!A&&!E&&(E=Y("ASTERISK"));let Z0=F();C("CLOSE");let g=X();S(I,A,E,Z0,g);continue}Q(),C("END")}return f}M(kj,"parse");function b0($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}M(b0,"escapeString");function vj($){return $&&$.ignoreCase?"ui":"u"}M(vj,"flags");function O4($,O,Z){return mj(kj($,Z),O,Z)}M(O4,"stringToRegexp");function T$($){switch($){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}M(T$,"modifierToString");function mj($,O,Z={}){Z.delimiter??="/#?",Z.prefixes??="./",Z.sensitive??=!1,Z.strict??=!1,Z.end??=!0,Z.start??=!0,Z.endsWith="";let T=Z.start?"^":"";for(let z of $){if(z.type===3){z.modifier===3?T+=b0(z.value):T+=`(?:${b0(z.value)})${T$(z.modifier)}`;continue}O&&O.push(z.name);let J=`[^${b0(Z.delimiter)}]+?`,Y=z.value;if(z.type===1?Y=J:z.type===0&&(Y=bj),!z.prefix.length&&!z.suffix.length){z.modifier===3||z.modifier===1?T+=`(${Y})${T$(z.modifier)}`:T+=`((?:${Y})${T$(z.modifier)})`;continue}if(z.modifier===3||z.modifier===1){T+=`(?:${b0(z.prefix)}(${Y})${b0(z.suffix)})`,T+=T$(z.modifier);continue}T+=`(?:${b0(z.prefix)}`,T+=`((?:${Y})(?:`,T+=b0(z.suffix),T+=b0(z.prefix),T+=`(?:${Y}))*)${b0(z.suffix)})`,z.modifier===0&&(T+="?")}let f=`[${b0(Z.endsWith)}]|$`,j=`[${b0(Z.delimiter)}]`;if(Z.end)return Z.strict||(T+=`${j}?`),Z.endsWith.length?T+=`(?=${f})`:T+="$",new RegExp(T,vj(Z));Z.strict||(T+=`(?:${j}(?=${f}))?`);let W=!1;if($.length){let z=$[$.length-1];z.type===3&&z.modifier===3&&(W=Z.delimiter.indexOf(z)>-1)}return W||(T+=`(?=${j}|${f})`),new RegExp(T,vj(Z))}M(mj,"partsToRegexp");var g1={delimiter:"",prefixes:"",sensitive:!0,strict:!0},wY={delimiter:".",prefixes:"",sensitive:!0,strict:!0},bY={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function Z4($,O){return $.length?$[0]==="/"?!0:!O||$.length<2?!1:($[0]=="\\"||$[0]=="{")&&$[1]=="/":!1}M(Z4,"isAbsolutePathname");function qj($,O){return $.startsWith(O)?$.substring(O.length,$.length):$}M(qj,"maybeStripPrefix");function T4($,O){return $.endsWith(O)?$.substr(0,$.length-O.length):$}M(T4,"maybeStripSuffix");function yj($){return!$||$.length<2?!1:$[0]==="["||($[0]==="\\"||$[0]==="{")&&$[1]==="["}M(yj,"treatAsIPv6Hostname");var f4=["ftp","file","http","https","ws","wss"];function pj($){if(!$)return!0;for(let O of f4)if($.test(O))return!0;return!1}M(pj,"isSpecialScheme");function j4($,O){if($=qj($,"#"),O||$==="")return $;let Z=new URL("https://example.com");return Z.hash=$,Z.hash?Z.hash.substring(1,Z.hash.length):""}M(j4,"canonicalizeHash");function W4($,O){if($=qj($,"?"),O||$==="")return $;let Z=new URL("https://example.com");return Z.search=$,Z.search?Z.search.substring(1,Z.search.length):""}M(W4,"canonicalizeSearch");function z4($,O){return O||$===""?$:yj($)?hj($):ij($)}M(z4,"canonicalizeHostname");function J4($,O){if(O||$==="")return $;let Z=new URL("https://example.com");return Z.password=$,Z.password}M(J4,"canonicalizePassword");function Y4($,O){if(O||$==="")return $;let Z=new URL("https://example.com");return Z.username=$,Z.username}M(Y4,"canonicalizeUsername");function X4($,O,Z){if(Z||$==="")return $;if(O&&!f4.includes(O))return new URL(`${O}:${$}`).pathname;let T=$[0]=="/";return $=new URL(T?$:"/-"+$,"https://example.com").pathname,T||($=$.substring(2,$.length)),$}M(X4,"canonicalizePathname");function F4($,O,Z){return cj(O)===$&&($=""),Z||$===""?$:lj($)}M(F4,"canonicalizePort");function C4($,O){return $=T4($,":"),O||$===""?$:CT($)}M(C4,"canonicalizeProtocol");function cj($){switch($){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}M(cj,"defaultPortForProtocol");function CT($){if($==="")return $;if(/^[-+.A-Za-z0-9]*$/.test($))return $.toLowerCase();throw TypeError(`Invalid protocol '${$}'.`)}M(CT,"protocolEncodeCallback");function D4($){if($==="")return $;let O=new URL("https://example.com");return O.username=$,O.username}M(D4,"usernameEncodeCallback");function U4($){if($==="")return $;let O=new URL("https://example.com");return O.password=$,O.password}M(U4,"passwordEncodeCallback");function ij($){if($==="")return $;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test($))throw TypeError(`Invalid hostname '${$}'`);let O=new URL("https://example.com");return O.hostname=$,O.hostname}M(ij,"hostnameEncodeCallback");function hj($){if($==="")return $;if(/[^0-9a-fA-F[\]:]/g.test($))throw TypeError(`Invalid IPv6 hostname '${$}'`);return $.toLowerCase()}M(hj,"ipv6HostnameEncodeCallback");function lj($){if($===""||/^[0-9]*$/.test($)&&parseInt($)<=65535)return $;throw TypeError(`Invalid port '${$}'.`)}M(lj,"portEncodeCallback");function G4($){if($==="")return $;let O=new URL("https://example.com");return O.pathname=$[0]!=="/"?"/-"+$:$,$[0]!=="/"?O.pathname.substring(2,O.pathname.length):O.pathname}M(G4,"standardURLPathnameEncodeCallback");function B4($){return $===""?$:new URL(`data:${$}`).pathname}M(B4,"pathURLPathnameEncodeCallback");function K4($){if($==="")return $;let O=new URL("https://example.com");return O.search=$,O.search.substring(1,O.search.length)}M(K4,"searchEncodeCallback");function Q4($){if($==="")return $;let O=new URL("https://example.com");return O.hash=$,O.hash.substring(1,O.hash.length)}M(Q4,"hashEncodeCallback");var V4=class{#j;#T=[];#O={};#$=0;#f=1;#Y=0;#z=0;#D=0;#U=0;#G=!1;constructor($){this.#j=$}get result(){return this.#O}parse(){for(this.#T=Rj(this.#j,!0);this.#$<this.#T.length;this.#$+=this.#f){if(this.#f=1,this.#T[this.#$].type==="END"){if(this.#z===0){this.#V(),this.#X()?this.#Z(9,1):this.#F()?this.#Z(8,1):this.#Z(7,0);continue}else if(this.#z===2){this.#C(5);continue}this.#Z(10,0);break}if(this.#D>0)if(this.#P())this.#D-=1;else continue;if(this.#x()){this.#D+=1;continue}switch(this.#z){case 0:this.#L()&&this.#C(1);break;case 1:if(this.#L()){this.#E();let $=7,O=1;this.#I()?($=2,O=3):this.#G&&($=2),this.#Z($,O)}break;case 2:this.#K()?this.#C(3):(this.#Q()||this.#F()||this.#X())&&this.#C(5);break;case 3:this.#M()?this.#Z(4,1):this.#K()&&this.#Z(5,1);break;case 4:this.#K()&&this.#Z(5,1);break;case 5:this.#_()?this.#U+=1:this.#A()&&(this.#U-=1),this.#N()&&!this.#U?this.#Z(6,1):this.#Q()?this.#Z(7,0):this.#F()?this.#Z(8,1):this.#X()&&this.#Z(9,1);break;case 6:this.#Q()?this.#Z(7,0):this.#F()?this.#Z(8,1):this.#X()&&this.#Z(9,1);break;case 7:this.#F()?this.#Z(8,1):this.#X()&&this.#Z(9,1);break;case 8:this.#X()&&this.#Z(9,1);break;case 9:break;case 10:break}}this.#O.hostname!==void 0&&this.#O.port===void 0&&(this.#O.port="")}#Z($,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.#S($,O)}#S($,O){this.#z=$,this.#Y=this.#$+O,this.#$+=O,this.#f=0}#V(){this.#$=this.#Y,this.#f=0}#C($){this.#V(),this.#z=$}#B($){return $<0&&($=this.#T.length-$),$<this.#T.length?this.#T[$]:this.#T[this.#T.length-1]}#W($,O){let Z=this.#B($);return Z.value===O&&(Z.type==="CHAR"||Z.type==="ESCAPED_CHAR"||Z.type==="INVALID_CHAR")}#L(){return this.#W(this.#$,":")}#I(){return this.#W(this.#$+1,"/")&&this.#W(this.#$+2,"/")}#K(){return this.#W(this.#$,"@")}#M(){return this.#W(this.#$,":")}#N(){return this.#W(this.#$,":")}#Q(){return this.#W(this.#$,"/")}#F(){if(this.#W(this.#$,"?"))return!0;if(this.#T[this.#$].value!=="?")return!1;let $=this.#B(this.#$-1);return $.type!=="NAME"&&$.type!=="REGEX"&&$.type!=="CLOSE"&&$.type!=="ASTERISK"}#X(){return this.#W(this.#$,"#")}#x(){return this.#T[this.#$].type=="OPEN"}#P(){return this.#T[this.#$].type=="CLOSE"}#_(){return this.#W(this.#$,"[")}#A(){return this.#W(this.#$,"]")}#J(){let $=this.#T[this.#$],O=this.#B(this.#Y).index;return this.#j.substring(O,$.index)}#E(){let $={};Object.assign($,g1),$.encodePart=CT;let O=O4(this.#J(),void 0,$);this.#G=pj(O)}};M(V4,"Parser");var wj=["protocol","username","password","hostname","port","pathname","search","hash"],v1="*";function gj($,O){if(typeof $!="string")throw TypeError("parameter 1 is not of type 'string'.");let Z=new URL($,O);return{protocol:Z.protocol.substring(0,Z.protocol.length-1),username:Z.username,password:Z.password,hostname:Z.hostname,port:Z.port,pathname:Z.pathname,search:Z.search!==""?Z.search.substring(1,Z.search.length):void 0,hash:Z.hash!==""?Z.hash.substring(1,Z.hash.length):void 0}}M(gj,"extractValues");function O1($,O){return O?p$($):$}M(O1,"processBaseURLString");function y$($,O,Z){let T;if(typeof O.baseURL=="string")try{T=new URL(O.baseURL),O.protocol===void 0&&($.protocol=O1(T.protocol.substring(0,T.protocol.length-1),Z)),!Z&&O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.username===void 0&&($.username=O1(T.username,Z)),!Z&&O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.username===void 0&&O.password===void 0&&($.password=O1(T.password,Z)),O.protocol===void 0&&O.hostname===void 0&&($.hostname=O1(T.hostname,Z)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&($.port=O1(T.port,Z)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.pathname===void 0&&($.pathname=O1(T.pathname,Z)),O.protocol===void 0&&O.hostname===void 0&&O.port===void 0&&O.pathname===void 0&&O.search===void 0&&($.search=O1(T.search.substring(1,T.search.length),Z)),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(T.hash.substring(1,T.hash.length),Z))}catch{throw TypeError(`invalid baseURL '${O.baseURL}'.`)}if(typeof O.protocol=="string"&&($.protocol=C4(O.protocol,Z)),typeof O.username=="string"&&($.username=Y4(O.username,Z)),typeof O.password=="string"&&($.password=J4(O.password,Z)),typeof O.hostname=="string"&&($.hostname=z4(O.hostname,Z)),typeof O.port=="string"&&($.port=F4(O.port,$.protocol,Z)),typeof O.pathname=="string"){if($.pathname=O.pathname,T&&!Z4($.pathname,Z)){let f=T.pathname.lastIndexOf("/");f>=0&&($.pathname=O1(T.pathname.substring(0,f+1),Z)+$.pathname)}$.pathname=X4($.pathname,$.protocol,Z)}return typeof O.search=="string"&&($.search=W4(O.search,Z)),typeof O.hash=="string"&&($.hash=j4(O.hash,Z)),$}M(y$,"applyInit");function p$($){return $.replace(/([+*?:{}()\\])/g,"\\$1")}M(p$,"escapePatternString");function L4($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}M(L4,"escapeRegexpString");function S4($,O){O.delimiter??="/#?",O.prefixes??="./",O.sensitive??=!1,O.strict??=!1,O.end??=!0,O.start??=!0,O.endsWith="";let Z=".*",T=`[^${L4(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)}}${T$(z.modifier)}`;continue}let J=z.hasCustomName(),Y=!!z.suffix.length||!!z.prefix.length&&(z.prefix.length!==1||!O.prefixes.includes(z.prefix)),X=W>0?$[W-1]:null,C=W<$.length-1?$[W+1]:null;if(!Y&&J&&z.type===1&&z.modifier===3&&C&&!C.prefix.length&&!C.suffix.length)if(C.type===3){let F=C.value.length>0?C.value[0]:"";Y=f.test(F)}else Y=!C.hasCustomName();if(!Y&&!z.prefix.length&&X&&X.type===3){let F=X.value[X.value.length-1];Y=O.prefixes.includes(F)}Y&&(j+="{"),j+=p$(z.prefix),J&&(j+=`:${z.name}`),z.type===2?j+=`(${z.value})`:z.type===1?J||(j+=`(${T})`):z.type===0&&(!J&&(!X||X.type===3||X.modifier!==3||Y||z.prefix!=="")?j+="*":j+=`(${Z})`),z.type===1&&J&&z.suffix.length&&f.test(z.suffix[0])&&(j+="\\"),j+=p$(z.suffix),Y&&(j+="}"),z.modifier!==3&&(j+=T$(z.modifier))}return j}M(S4,"partsToPattern");var dj=class{#j;#T={};#O={};#$={};#f={};#Y=!1;constructor($={},O,Z){try{let T;if(typeof O=="string"?T=O:Z=O,typeof $=="string"){let z=new V4($);if(z.parse(),$=z.result,T===void 0&&typeof $.protocol!="string")throw TypeError("A base URL must be provided for a relative constructor string.");$.baseURL=T}else{if(!$||typeof $!="object")throw TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(T)throw TypeError("parameter 1 is not of type 'string'.")}typeof Z>"u"&&(Z={ignoreCase:!1});let f={ignoreCase:Z.ignoreCase===!0},j={pathname:v1,protocol:v1,username:v1,password:v1,hostname:v1,port:v1,search:v1,hash:v1};this.#j=y$(j,$,!0),cj(this.#j.protocol)===this.#j.port&&(this.#j.port="");let W;for(W of wj){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=CT;break;case"username":Object.assign(z,g1),z.encodePart=D4;break;case"password":Object.assign(z,g1),z.encodePart=U4;break;case"hostname":Object.assign(z,wY),yj(J)?z.encodePart=hj:z.encodePart=ij;break;case"port":Object.assign(z,g1),z.encodePart=lj;break;case"pathname":pj(this.#T.protocol)?(Object.assign(z,bY,f),z.encodePart=G4):(Object.assign(z,g1,f),z.encodePart=B4);break;case"search":Object.assign(z,g1,f),z.encodePart=K4;break;case"hash":Object.assign(z,g1,f),z.encodePart=Q4;break}try{this.#f[W]=kj(J,z),this.#T[W]=mj(this.#f[W],this.#O[W],z),this.#$[W]=S4(this.#f[W],z),this.#Y=this.#Y||this.#f[W].some((Y)=>Y.type===2)}catch{throw TypeError(`invalid ${W} pattern '${this.#j[W]}'.`)}}}catch(T){throw TypeError(`Failed to construct 'URLPattern': ${T.message}`)}}get[Symbol.toStringTag](){return"URLPattern"}test($={},O){let Z={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"?Z=y$(Z,$,!1):Z=y$(Z,gj($,O),!1)}catch{return!1}let T;for(T of wj)if(!this.#T[T].exec(Z[T]))return!1;return!0}exec($={},O){let Z={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"?Z=y$(Z,$,!1):Z=y$(Z,gj($,O),!1)}catch{return null}let T={};O?T.inputs=[$,O]:T.inputs=[$];let f;for(f of wj){let j=this.#T[f].exec(Z[f]);if(!j)return null;let W={};for(let[z,J]of this.#O[f].entries())if(typeof J=="string"||typeof J=="number"){let Y=j[z+1];W[J]=Y}T[f]={input:Z[f]??"",groups:W}}return T}static compareComponent($,O,Z){let T=M((z,J)=>{for(let Y of["type","modifier","prefix","value","suffix"]){if(z[Y]<J[Y])return-1;if(z[Y]===J[Y])continue;return 1}return 0},"comparePart"),f=new c$(3,"","","","",3),j=new c$(0,"","","","",3),W=M((z,J)=>{let Y=0;for(;Y<Math.min(z.length,J.length);++Y){let X=T(z[Y],J[Y]);if(X)return X}return z.length===J.length?0:T(z[Y]??f,J[Y]??f)},"comparePartList");return!O.#$[$]&&!Z.#$[$]?0:O.#$[$]&&!Z.#$[$]?W(O.#f[$],[j]):!O.#$[$]&&Z.#$[$]?W([j],Z.#f[$]):W(O.#f[$],Z.#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.#Y}};M(dj,"URLPattern");function RO($,O){for(let[Z,T]of Object.entries($)){let f=new dj({pathname:Z});if(f.test({pathname:O}))return{routePath:Z,params:f.exec({pathname:O})?.pathname.groups??{},route:T}}return null}var f$={startIndex:0,carriedViews:[]};function I4($,O){let Z=s($.path,O);return Z.includes("*")?null:Z}function vY($,O){if(!$)return f$;if($.search!==O.search)return f$;let Z=Math.min($.segments.length,O.segments.length-1),T=0;while(T<Z){let f=$.segments[T],j=O.segments[T];if(j.alwaysRun)break;if(f.viewPath!==j.viewPath)break;let W=I4(f,$.params),z=I4(j,O.params);if(W===null||z===null||W!==z)break;T++}if(T===0)return f$;return{startIndex:T,carriedViews:O.segments.slice(0,T).map(({viewPath:f})=>f)}}function gY($,O){let[,Z,...T]=$.split("/");if(!O.includes(Z))return $;let f=`/${T.join("/")}`;return f==="/"?"/":f.replace(/\/$/,"")}function M4($){let{flatViewRoutes:O,supportedLocales:Z,from:T,origin:f,to:j}=$;if(!T)return f$;let W;try{W=new URL(T,f)}catch{return f$}if(W.origin!==f)return f$;let z=RO(O,gY(W.pathname,Z));if(!z)return f$;return vY({segments:z.route.segments,params:z.params,search:W.search},j)}var uj="x-gemi-from";import{createElement as n$,Fragment as TX}from"react";function RY($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function DT($){let O={};for(let[Z,T]of Object.entries($))if("run"in T){let f=T.viewPath;if("children"in T){O[Z]=[f];let j=new T.children,W=DT(j.routes);for(let[z,J]of Object.entries(W)){let Y=Z==="/"?z:`${Z}${z}`,X=z==="/"&&Z!=="/"?Z:Y;O[X]=[f,...J]}if(O[Z].length===1)delete O[Z]}else O[Z]=[f]}else{let f=new T,j=DT(f.routes);for(let[W,z]of Object.entries(j)){let J=Z==="/"?W:`${Z}${W}`,Y=W==="/"&&Z!=="/"?Z:J;O[Y]=z}}return Object.fromEntries(Object.entries(O).map(([Z,T])=>[RY(Z),T]))}function UT($){let O=[];for(let[Z,T]of Object.entries($))if("run"in T){let f=T.viewPath;if(f==="__")continue;if(f==="REDIRECT")continue;if(f==="FILE")continue;if("children"in T){let j=new T.children,W=UT(j.routes);O.push([f,W])}else O.push([f,[]])}else{let f=new T,j=UT(f.routes);O.push(...j)}return O}function sj($){let O=[];for(let[Z,T]of $)O.push(Z,...sj(T).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=N.getStore();if(O)return O.locale??$.detectLocale(O.req);return $.defaultLocale}static setLocale($=i$.locale()){let O=this.getFacadeRoot(),Z=$;if(!O.supportedLocales.includes($))Z=O.defaultLocale;let T=N.getStore();return T.setCookie("i18n-locale",Z,{expires:new Date(Date.now()+31536000000),secure:!1,httpOnly:!1}),T.setLocale(Z),Z}}class nj{id;static token="kernel.id";constructor($=crypto.randomUUID()){this.id=$}}var kY=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),mY=new Set(["svg","math"]);function N4($){return $===32||$===9||$===10||$===12||$===13}function x4($){return $>=65&&$<=90||$>=97&&$<=122}function GT($){return $>=65&&$<=90?$+32:$}function P4(){let $="data",O="",Z=!1,T="",f=0,j=0,W=!1,z=0,J=0,Y=()=>$==="data"&&z===0&&J===0,X=()=>{if(!Z&&kY.has(O)){$="rawText",T=`</${O}`,f=0,O="";return}if($="data",O==="template")if(Z)z=Math.max(0,z-1);else z+=1;else if(mY.has(O)){if(Z)J=Math.max(0,J-1);else if(!W)J+=1}O=""},C=(F)=>{switch($){case"data":if(F===60)$="tagOpen";return;case"tagOpen":if(F===33)$="bang",j=0;else if(F===47)$="endTagOpen";else if(x4(F))$="tagName",Z=!1,W=!1,O=String.fromCharCode(GT(F));else if(F===63)$="bogus";else if(F===60)$="tagOpen";else $="data";return;case"endTagOpen":if(x4(F))$="tagName",Z=!0,W=!1,O=String.fromCharCode(GT(F));else if(F===62)$="data";else $="bogus";return;case"tagName":if(N4(F)||F===47)$="inTag",W=F===47;else if(F===62)X();else O+=String.fromCharCode(GT(F));return;case"inTag":if(F===62){X();return}if(W=F===47,F===34)$="attrDouble";else if(F===39)$="attrSingle";return;case"attrDouble":if(F===34)$="inTag";W=!1;return;case"attrSingle":if(F===39)$="inTag";W=!1;return;case"bang":if(F===45){if(j+=1,j===2)$="comment",j=0}else if(F===62)$="data";else $="bogus";return;case"bogus":if(F===62)$="data";return;case"comment":if(F===45)j=j<2?j+1:2;else if(F===62&&j>=2)$="data",j=0;else j=0;return;case"rawText":{if(f<T.length){if(GT(F)===T.charCodeAt(f))f+=1;else f=F===60?1:0;return}if(F===62)$="data",O="";else if(N4(F)||F===47)$="inTag",O="";else f=F===60?1:0;return}}};return{scanToInsertionPoint(F){for(let U=0;U<F.length;U++){if(Y())return U;C(F[U])}return F.length},write(F){for(let U=0;U<F.length;U++)C(F[U])},isSafe:Y}}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 qY($){return`<script>(self.__GEMI_STREAM__=self.__GEMI_STREAM__||[]).push(${j$([$.path,$.variantKey,$.data])})</script>`}function yY($){return`<script>(self.__GEMI_DICT__=self.__GEMI_DICT__||[]).push(${j$([$.id,$.locale,$.strings])})</script>`}function aj($,O,Z={},T){let f=new TextEncoder,j=[],W=!1,z=!1,J=()=>{if(z)return;z=!0,Z.onClose?.()};O.onSettle((D)=>{if(D.status!=="resolved")return;j.push(qY(D))}),T?.onUse((D)=>{j.push(yY(D))});let Y=$.getReader(),X=P4(),C=(D,G)=>{D.enqueue(G),Z.onChunk?.(G)},F=(D)=>{while(j.length>0){let G=f.encode(j.shift());X.write(G),C(D,G)}},U=(D,G)=>{if(j.length===0){X.write(G),C(D,G);return}let B=X.scanToInsertionPoint(G);if(B>0)C(D,G.subarray(0,B));if(X.isSafe())F(D);let Q=G.subarray(B);if(Q.length>0)X.write(Q),C(D,Q)};return new ReadableStream({async pull(D){let G;try{G=await Y.read()}catch(S){throw J(),S}let{done:B,value:Q}=G;if(B){F(D),D.close(),J();return}if(!W){if(W=!0,X.write(Q),C(D,Q),Z.onShell?.(),X.isSafe())F(D);return}U(D,Q)},cancel(D){return J(),Y.cancel(D)}})}var pY=/bot|crawler|spider|crawling|slurp|bingpreview|mediapartners|headless|lighthouse|prerender|facebookexternalhit|whatsapp|telegram|discord|twitterbot|linkedinbot/i;function BT($){if(!$)return!1;return pY.test($)}async function A4($,O=()=>{}){let Z=N.getStore(),T=Z?.req??null,f=null;if(T?.rawRequest?.url)try{f=new URL(T.rawRequest.url).pathname}catch{f=null}return{user:Z?.user??null,attributes:await cY($,O),request:{path:f,routePath:T?.routePath??null,locale:Z?.locale??null},anonymousId:_4(),isBot:BT(T?.rawRequest?.headers?.get("user-agent")??null),now:new Date}}function E4($){return{user:$.user??null,attributes:$.attributes??{},request:{path:null,routePath:null,locale:null},anonymousId:$.subjectId??null,isBot:!1,now:new Date}}async function cY($,O){if(!$.context)return{};try{let Z=N.getStore();return await $.context(Z?.req??null)??{}}catch(Z){return O(`The \`context\` hook in app/config/features.ts threw; evaluating with no attributes. ${Z instanceof Error?Z.message:String(Z)}`),{}}}function H4($,O){return`${$}:${O}`}function oj($){let O=new Bun.CryptoHasher("sha1").update($).digest("hex"),Z=Number.parseInt(O.slice(0,8),16);return Math.floor(Z/4294967296*1e4)}function w4($,O){if(O>=100)return!0;if(O<=0)return!1;return $<Math.round(O*100)}function b4($,O,Z,T){if(T.unavailable)return{value:!1,reason:"unavailable"};if(T.active!==!0)return{value:!1,reason:"inactive"};if(O.when){let j;try{j=O.when(Z)}catch(W){return T.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(Z.isBot)return{value:!1,reason:"bot"};let f=hY($,O,Z,T.buckets);return w4(f,O.rollout)?{value:!0,reason:"rollout"}:{value:!1,reason:"excluded"}}function iY($){let O=$.user?.publicId??$.user?.id;if(O!==void 0&&O!==null)return String(O);return $.anonymousId??""}function hY($,O,Z,T){let f=H4(O.salt??$,iY(Z));if(!T)return oj(f);let j=T.get(f);if(j!==void 0)return j;let W=oj(f);return T.set(f,W),W}class v4 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 rj{source;declared;ttlMs;warn;snapshot=null;inflight=null;lastFailureLoggedAt=0;generation=0;lastError=null;retryAfter=0;constructor($,O,Z,T=()=>{}){this.source=$;this.declared=O;this.ttlMs=Z;this.warn=T}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 v4(this.lastError);return O}peek(){return this.snapshot}async load(){try{let $=await this.source.load(),{active:O,audit:Z}=this.readRows($);return this.snapshot={active:O,audit:Z,loadedAt:Date.now(),unavailable:!1},this.generation++,this.lastError=null,this.retryAfter=0,this.snapshot}catch($){return this.handleFailure($)}}readRows($){let O=new Map,Z=new Map;for(let T of $??[]){let f=typeof T?.key==="string"?T.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,T.active===!0);let j=lY(T);if(j)Z.set(f,j)}return{active:O,audit:Z}}handleFailure($){let O=$ instanceof Error?$.message:String($),Z=Date.now();if(this.lastError=$,this.retryAfter=Z+this.ttlMs,Z-this.lastFailureLoggedAt>=this.ttlMs)this.lastFailureLoggedAt=Z,this.warn(`Could not load feature switches: ${O}`);if(this.snapshot)return this.snapshot;return this.snapshot={active:new Map,audit:new Map,loadedAt:Z,unavailable:!0},this.snapshot}}function lY($){let O={},Z=$.updatedBy;if(typeof Z==="string")O.updatedBy=Z;else if(Z===null)O.updatedBy=null;let T=$.updatedAt;if(T instanceof Date||typeof T==="string"||typeof T==="number"){let f=T instanceof Date?T:new Date(T);if(!Number.isNaN(f.getTime()))O.updatedAt=f}return"updatedBy"in O||"updatedAt"in O?O:null}class dY{}class uY 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 tj 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 g4 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 R4{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 rj($.source,this.declared,Math.max(0,$.ttl)*1000,this.log)}declarations(){return this.declared}async list(){let{active:$,audit:O,unavailable:Z}=await this.switches();return{unavailable:Z,features:Object.entries(this.declared).map(([T,f])=>({key:T,describe:f.describe,rollout:f.rollout,targeted:f.when!==void 0,serverOnly:f.serverOnly,salt:f.salt,active:$.get(T),...O.get(T)}))}}async refresh(){if(!this.config.enabled)return;if(Object.keys(this.declared).length===0)return;await this.store.refresh()}async invalidate(){try{if(this.config.enabled&&Object.keys(this.declared).length>0)await this.store.invalidate()}finally{N.getStore()?.featureEvaluations?.clear()}}async set($,O,Z={}){if(typeof $!=="string"||!Object.hasOwn(this.declared,$))throw new g4(String($));if(typeof O!=="boolean")throw TypeError(`Features.set("${$}", \u2026) takes a boolean, not ${O===null?"null":typeof O}.`);let T=sY(Z.actor),f=this.config.source;if(typeof f.write!=="function")throw new tj(f.constructor?.name||"an anonymous source");let{actorRecorded:j}=await f.write($,O,{actor:T});if(T!==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 R4(this,E4($))}async evaluateIn($,O,Z){let T=this.memoFor(O),f=T?.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=b4($,j,O,{active:W,unavailable:z,buckets:Z,warn:this.log});return T?.set($,J),this.notify($,J,O),J}async evaluateAllIn($,O,Z){let T={};for(let[f,j]of Object.entries(this.declared)){if(Z.clientOnly&&j.serverOnly)continue;T[f]=(await this.evaluateIn(f,$,O)).value}return T}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 $=N.getStore();if($?.featureContext)return $.featureContext;let O=await A4(this.config,this.log);if($)$.featureContext=O;return O}memoFor($){let O=N.getStore();if(!O||O.featureContext!==$)return null;return O.featureEvaluations??=new Map,O.featureEvaluations}requestBuckets(){let $=N.getStore();if(!$)return new Map;return $.featureBuckets??=new Map,$.featureBuckets}notify($,O,Z){if(!this.config.onEvaluate)return;try{this.config.onEvaluate($,O,Z)}catch(T){this.log(`The \`onEvaluate\` hook in app/config/features.ts threw for "${$}". ${T instanceof Error?T.message:String(T)}`)}}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 sY($){if($===void 0||$===null)return null;if(typeof $==="string"){if($.length>0)return $}else if(typeof $==="object"){let{publicId:O,id:Z}=$;if(typeof O==="string"&&O.length>0)return O;if(typeof Z==="string"&&Z.length>0||typeof Z==="number")return String(Z)}throw TypeError("Features.set() was given an `actor` that identifies nobody. Pass a string, or a user with a `publicId` or an `id`.")}function k4($){return Object.fromEntries(Object.entries($).filter(([,O])=>{return O!==null&&O!==void 0}))}var nY=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((Z)=>Z.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(),(Z)=>({path:Z.path,variantKey:Z.variantKey,startedAt:Z.startedAt,settledAt:Z.settledAt,status:Z.status,source:Z.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 Z=($.settledAt??0)-$.startedAt,T=$.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 (${Z}ms, resolved ${O}) could not overlap the others. It still streamed. If the query belongs on this route, \`Query.prefetch("${$.patternPath}"${T})\` 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={},Z="render"){let T=O.params??{},f=new URLSearchParams(k4(O.search??{}));f.delete("json"),f.sort();let j=s($,T),W=f.toString(),z=this.keyFor(j,W),J=this.entries.get(z);if(J)return J;let Y;if(Z==="render"&&this.renderStartedAt!==null){let U=Math.round(performance.now()-this.renderStartedAt);if(U>nY)Y=U}let X,C=new Promise((U)=>{X=U}),F={path:j,patternPath:$,variantKey:W,lateBy:Y,status:"pending",promise:C,source:Z,startedAt:this.elapsed()};return this.entries.set(z,F),this.fetcher($,T,f).then((U)=>{F.status="resolved",F.data=U},(U)=>{F.status="rejected",F.error=U}).then(()=>{if(F.settledAt=this.elapsed(),this.maybeLogLateDiscovery(F),F.status==="rejected"&&this.failListener)this.failListener(F);if(this.settleListener)this.settleListener(F);else this.settledBacklog.push(F);X()}),F}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,Z]of this.entries){if(Z.status!=="resolved")continue;this.shipped.add(O),$[Z.path]??={},$[Z.path][Z.variantKey]=Z.data}return $}onSettle($){this.settleListener=(Z)=>{if(this.shipped.has(this.keyFor(Z.path,Z.variantKey)))return;$(Z)};let O=this.settledBacklog;this.settledBacklog=[];for(let Z of O)this.settleListener(Z)}}class W$ extends Error{path;variantKey;status;body;constructor($,O,Z,T){super(typeof T?.message==="string"?T.message:`Request to /api${$} failed with status ${Z}`);this.path=$;this.variantKey=O;this.status=Z;this.body=T;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 ej(){return{status:403,error:{message:"Forbidden"}}}function kO($){let O=u$.getStore();return(Z,T,f)=>{let j=new URL($.url).origin,W=[s(Z,T),f.toString()].filter((X)=>X.length>0).join("?"),z=new Request(`${j}/${W}`,{headers:$.headers}),J=m4($);if(J)s$(z,J);let Y=new P(z,T);return u$.run(O,()=>N.run(Y,async()=>{try{let X=await K(s0).dispatchers(J).api.getRouteData(Z);if(X instanceof Response){let C=await X.json().catch(()=>null);if(!X.ok)throw new W$(s(Z,T),f.toString(),X.status,C);return C}return X}catch(X){if(X instanceof W$)throw X;let C=new W$(s(Z,T),f.toString(),500,{message:X instanceof Error?X.message:String(X)});throw C.cause=X,C}}))}}var aY=new Set(["script","style","template","title"]),oY=/\shidden([\s=/]|$)/i,rY=/"[^"]*"|'[^']*'/g;function tY($){let O=0,Z=0,T=0,f=0;while(f<$.length){let j=$.indexOf("<",f),W=j===-1?$.length:j;if(W>f){let C=$.slice(f,W).replace(/\s+/g,"").length;if(T>0)Z+=C;else O+=C}if(j===-1)break;if($.startsWith("<!--",j)){let C=$.indexOf("-->",j+4);f=C===-1?$.length:C+3;continue}let z=$.indexOf(">",j);if(z===-1)break;let J=$.slice(j+1,z);f=z+1;let Y=/^\/?([a-zA-Z][a-zA-Z0-9-]*)/.exec(J)?.[1]?.toLowerCase();if(!Y)continue;let X=J.startsWith("/");if(!X&&aY.has(Y)&&!J.endsWith("/")){let C=$.indexOf(`</${Y}`,f);f=C===-1?$.length:C;continue}if(Y!=="div")continue;if(X){if(T>0)T-=1}else if(T>0)T+=1;else if(oY.test(J.replace(rY,'""')))T=1}return{shellChars:O,deferredChars:Z}}var eY=1000,$X=64;function OX($){return $>=1000?`${($/1000).toFixed(1)} kB`:`${$} chars`}function ZX($,O){if(O.deferredChars<eY)return null;if(O.shellChars>=$X)return null;return`[gemi] GET ${$} streams ${OX(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 q4($=console.warn){let O=new Set;return{shouldObserve(Z){return!O.has(Z)},report(Z,T){if(O.has(Z))return;let f=ZX(Z,T);if(!f)return;O.add(Z),$(f)}}}function y4(){let $=new TextDecoder,O="";return{onChunk(Z){O+=$.decode(Z,{stream:!0})},measure(){return O+=$.decode(),tY(O)}}}function p4($,O,Z=1e4,T){let f=new TextEncoder,j=()=>{};return new ReadableStream({start(W){let z=!1,J=(X)=>{if(z)return;z=!0,clearTimeout(Y);try{W.close()}catch{}T?.({aborted:X})};j=J,W.enqueue(f.encode(`${JSON.stringify($)}
|
|
5
|
+
`)),O.onSettle((X)=>{if(z||X.status!=="resolved")return;W.enqueue(f.encode(`${JSON.stringify([X.path,X.variantKey,X.data])}
|
|
6
|
+
`))});let Y=setTimeout(()=>J(!0),Z);O.allSettled().then(()=>J(!1),()=>J(!1))},cancel(){j(!1)}})}var fX=async()=>(await import("./chunk-t20b1xn4.js")).default,$W,OW=async(...$)=>{return $W??=import("react-dom/server.browser").catch((O)=>{throw $W=void 0,O}),(await $W).renderToReadableStream(...$)},jX=1e4,WX=`
|
|
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 zX($,O,Z){let T=`${Z==="italic"?"italic,":""}wght@${Z==="italic"?"1,":""}${O}`,W=(await(await fetch(`https://fonts.googleapis.com/css2?family=${$}:${T}&display=swap`,{headers:{"User-Agent":"Mozilla/5.0 Firefox/1.0"}})).text()).match(/url\(([^)]+)\)/)?.[1];return await fetch(W).then((z)=>z.arrayBuffer())}var fW="/assets";function JX($){return $===fW||$.startsWith(`${fW}/`)}function YX($){let O=$.filter(JX);if(O.length>0){let Z=O.length>1;throw Error(`View route path${Z?"s":""} ${O.map((T)=>`"${T}"`).join(", ")} use${Z?"":"s"} the reserved "${fW}" prefix. The client build output is served from there before the router runs, so the route would never match. Mount it somewhere else.`)}}function XX($){let O=K(s0).resolver;return{...$.domain,root:O.root,origin:O.publicOrigin($.rawRequest)}}function ZW($){let{status:O=400,error:Z}=$;return new Response(Z?.message,{...$,status:O})}function FX($){let{status:O=400,data:Z,directive:T,headers:f}=$;return new Response(JSON.stringify({data:Z,directive:T}),{headers:f,status:O})}class yO{static token="router.view";flatViewRoutes={};routeManifest={};clientRouteManifest={};componentTree=[];flatComponentTree=[];root=null;shellReporter=q4();preloadCache=new WeakMap;hooks;partialRendering;constructor($){let O=t2();this.partialRendering=$.partialRendering??O.partialRendering,this.hooks={onRequestStart:$.onRequestStart??O.onRequestStart,onRequestEnd:$.onRequestEnd??O.onRequestEnd,onRequestFail:$.onRequestFail??O.onRequestFail,onStreamComplete:$.onStreamComplete??O.onStreamComplete};let Z={"/":$.rootRouter,"/auth":Qj};this.flatViewRoutes=FT(Z),YX(Object.keys(this.flatViewRoutes)),this.routeManifest=DT(Z),this.clientRouteManifest=Object.fromEntries(Object.entries(this.routeManifest).filter(([,T])=>T.at(-1)!=="FILE")),this.componentTree=UT(Z),this.flatComponentTree=sj(this.componentTree),this.root=$.root}async passesFeatureGates($){let O=K(h$);for(let Z of $)if(!await O.enabled(Z))return!1;return!0}async onRequestEnd($){return TW(),await this.hooks.onRequestEnd($)}completeStream($,O){let Z=(T)=>{R1.error(T?.message??'Error in "onStreamComplete" event handler',{err:JSON.stringify(T)})};try{Promise.resolve(this.hooks.onStreamComplete($,O)).catch(Z)}catch(T){Z(T)}}modulePreloadLinks($){let{clientEntry:O,modulePreloadManifest:Z,views:T,routeKey:f}=$,j=()=>{let J=new Set(O?.preload??[]);for(let Y of T)for(let X of Z?.[Y]??[])J.add(X);return[...J].map((Y)=>n$("link",{key:`modulepreload:${Y}`,rel:"modulepreload",href:Y}))};if(!Z)return j();let W=this.preloadCache.get(Z);if(!W||W.clientEntry!==O)W={clientEntry:O,byRoute:new Map},this.preloadCache.set(Z,W);let z=W.byRoute.get(f);if(!z)z=j(),W.byRoute.set(f,z);return z}async render($){let{req:O,runInRequestScope:Z,csrfTokenHMAC:T,currentPathName:f,headers:j,i18n:W,params:z,pathname:J,serverQueries:Y,userAgent:X,noStream:C,url:F,user:U,viewData:D,breadcrumbs:G,urlLocaleSegment:B,meta:Q,isOgRequest:S,appId:V,features:x}=$,_=J.replace(`/${B}`,""),L={kind:"view",data:{meta:Q,pageData:{[_]:D},__csrf:T.toString("base64"),prefetchedData:{},i18n:W,auth:{user:U},routeManifest:this.clientRouteManifest,breadcrumbs:G,router:{urlLocaleSegment:B,pathname:f,params:z,currentPath:J,searchParams:F.search,is404:!f?!0:!1,domain:O.domain?XX(O):null},appId:V,features:x,componentTree:[["404",[]],...this.componentTree]},head:{}},I=this.root,A=this.routeManifest[f];return async(E)=>{let{bootstrapModules:Z0=[],loaders:g,getStyles:m,viewImportMap:T0,cssManifest:NT,ogMap:pO,viewModules:z$,clientEntry:T1,modulePreloadManifest:k1,assetBase:f0}=E,r$=T1?[]:Z0,cO=(M0)=>[M0,`window.loaders=${g}`,...T1?[`import(${JSON.stringify(T1.module)}).catch(function(e){setTimeout(function(){throw e})})`]:[]].join(";");if(S){let M0=null,X$=null;for(let F$ of A??[])if(typeof pO[F$]==="function")X$=F$,M0=pO[F$];if(!M0)return new Response("Not found",{status:404});let G5=Object.values(L.data.pageData)[0];try{await OW(n$(M0,G5[X$]),{onError:()=>{}})}catch(F$){let{fonts:B5,...K5}=F$.satoriOptions,Q5=await Promise.all(B5.map((hO)=>{return zX(hO.name,hO.weight,hO.style).then((M5)=>({...hO,data:M5}))})),UW=new Headers(j);UW.set("Content-Type","image/png");let[V5,L5]=await Promise.all([fX(),YT("Rendering an OG image")]),S5=await V5(F$.jsx,{...K5,fonts:Q5}),I5=await L5(Buffer.from(S5)).png({compressionLevel:0,effort:10}).toBuffer();return new Response(new Uint8Array(I5),{headers:UW})}return new Response("data")}if(L.data.cssManifest=NT,L.data.modulePreloadManifest=k1??{},f0&&f0!=="/")L.data.assetBase=f0;let J$=this.modulePreloadLinks({clientEntry:T1,modulePreloadManifest:k1,views:A??["404"],routeKey:f??"404"}),t$=await m(A);L.data.prefetchedData=Y.snapshotResolved(),Y.markRenderStart();let U1=new AbortController,iO=setTimeout(()=>U1.abort(),jX),H=BT(X)||C,I0=Bun.env.NODE_ENV!=="production"&&!H&&f&&this.shellReporter.shouldObserve(f)?y4():null,Y$=h4();try{let M0=await OW(n$(TX,{children:[...J$,...t$,n$("script",{key:"theme-script",dangerouslySetInnerHTML:{__html:WX}}),n$(I,{data:L.data,viewImportMap:T0,viewModules:z$,serverQueries:Y,dictionarySink:Y$,key:"root"})]}),{bootstrapScriptContent:cO(`window.__GEMI_DATA__ = ${j$(L.data)}`),bootstrapModules:r$,signal:U1.signal,...H?{progressiveChunkSize:Number.MAX_SAFE_INTEGER}:{},onError(X$){if(Bun.env.NODE_ENV!=="production")console.error(X$)}});if(M0.allReady.catch(()=>{}).finally(()=>clearTimeout(iO)),H)await M0.allReady.catch(()=>{});return new Response(aj(M0,Y,{onShell:H?void 0:()=>Y.markShell(),onChunk:I0?.onChunk,onClose:()=>Z(()=>{if(this.completeStream(O,Y.summarize(U1.signal.aborted)),I0)this.shellReporter.report(f,I0.measure())})},Y$),{status:!f?404:200,headers:j})}catch(M0){if(clearTimeout(iO),Bun.env.NODE_ENV==="production")throw Z(()=>this.completeStream(O,Y.summarize(U1.signal.aborted))),M0;let X$=await OW(n$("div"),{bootstrapScriptContent:cO(`window.error= ${j$(M0.message)}; window.stack_trace=${j$(M0.stack)};window.__GEMI_DATA__ = ${j$(L.data)}`),bootstrapModules:Bun.env.NODE_ENV==="development"?["/render-error.js",...r$]:r$});return new Response(aj(X$,Y,{onClose:()=>Z(()=>this.completeStream(O,Y.summarize(U1.signal.aborted)))}),{status:!f?404:200,headers:j})}}}async handleViewRequest($,O){let Z=new URL($.url),T=Z.pathname.endsWith(".json"),f=Z.pathname.endsWith(".og"),j=Z.pathname.replace(".json","").replace(".og",""),[,W,...z]=j.split("/"),J=`/${z.join("/")}`,Y=null,X=null,C=K(n);if(!C.supportedLocales.includes(W))J=j;else Y=W,X=W;let U=X===null&&RO(this.flatViewRoutes,J)!==null;if(C.isLocaleAware&&!f&&X===null&&!U){let L=c4(W,C.supportedLocales,C.defaultLocale);if(L){let I=z.length?`/${z.join("/")}`:"";return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${L}${I}${T?".json":""}${Z.search}`}})}}if(C.isLocaleAware&&!f){let L=K(n).detectLocale(new P($,{},"view",J));if(X===null&&L!==C.defaultLocale){let I=Z.pathname==="/"?"":Z.pathname;return new Response("",{status:302,headers:{"Cache-Control":"private, no-cache, no-store, max-age=0, must-revalidate",Location:`/${L}${I}${Z.search}`}})}}J=J.replace("//","/");let D=[],G=[],B=null,Q={},S=null,V=!1,x=[];try{let L=RO(this.flatViewRoutes,J);if(L){if(B=L.routePath,Q=L.params,D=L.route.exec,G=L.route.middleware,x=L.route.features,V=G.includes("no-stream"),T&&this.partialRendering){let I=$.headers.get(uj),A=M4({flatViewRoutes:this.flatViewRoutes,supportedLocales:K(n).supportedLocales,from:I,origin:Z.origin,to:{segments:L.route.segments,params:Q,search:Z.search}});if(A.startIndex>0)D=D.slice(A.startIndex),S={from:I,carriedViews:A.carriedViews}}}}catch(L){throw L}let _=new P($,Q,"view",B);return this.hooks.onRequestStart(_),await N.run(_,async()=>{let L=null,I=N.getStore(),A=u$.getStore(),E=(m)=>u$.run(A,()=>N.runWith(I,m));I.serverQueries=new l$(kO($));let Z0=new Set;if(I.serverQueries.onQueryFail((m)=>{Z0.add(m.error);try{E(()=>Promise.resolve(this.hooks.onRequestFail(g,m.error)).catch(()=>{}))}catch{}}),X){let m=X.replaceAll("/","");i$.setLocale(m)}else i$.setLocale();let g=I.req;TW();try{let m=!1;try{await K(gO).runMiddleware(G)}catch(H){if(!a$(H))throw H;m=!0}if(m||x.length>0&&!await this.passesFeatureGates(x))B=null,D=[],g.routePath="";let T0=K(n),NT=T0.isEnabled,pO=T0.isLocaleAware,z$={};if(pO){let H=null;if(X)H=X.replaceAll("/",""),I.setLocale(H);else H=T0.detectLocale(new P($,g.params)),I.setLocale(H);let I0=NT?T0.getPageTranslations(H,g.routePath):{};z$={supportedLocales:T0.supportedLocales,currentLocale:H,dictionary:{[H]:I0},defaultLocale:T0.defaultLocale}}await i4(z$.currentLocale??"");let T1;try{T1=await Promise.all(D.map((H)=>H(g)))}catch(H){if(!a$(H))throw H;B=null,D=[],g.routePath="",T1=[]}let{cookies:k1,headers:f0}=I;L={data:T1,cookies:k1,headers:f0,user:I.user,prefetchedData:I.serverQueries.snapshotResolved(),currentPathName:B,params:g.params,urlLocaleSegment:Y,meta:I.renderMeta(),appId:K(nj).id,features:await K(h$).forClient()};let{params:r$,user:cO}=L,J$={},t$={};for(let H of T1??[]){let[I0,Y$]=Object.entries(H)?.[0]??[];if(!I0||!Y$)continue;t$[`${I0}:${B}`]=Y$.breadcrumb,J$[I0]=Y$}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 vT(U1,f0)}if(T){f0.set("Content-Type","application/x-ndjson; charset=utf-8"),f0.append("Vary",uj),k1.forEach((I0)=>f0.append("Set-Cookie",I0.toString())),await this.hooks.onRequestEnd(g);let H={meta:S&&!I.metadata.touched?null:L.meta,data:{[J]:J$},breadcrumbs:t$,prefetchedData:I.serverQueries.snapshotResolved(),i18n:z$,features:L.features,is404:!B,appId:L.appId,partial:S};return new Response(p4(H,I.serverQueries,void 0,({aborted:I0})=>E(()=>this.completeStream(g,I.serverQueries.summarize(I0)))),{headers:f0})}if(f0.set("Content-Type","text/html; charset=utf-8"),!V)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:E,csrfTokenHMAC:Buffer.from(""),currentPathName:B,headers:f0,i18n:z$,params:r$,pathname:Z.pathname,serverQueries:I.serverQueries,userAgent:$.headers.get("user-agent"),noStream:V,url:Z,user:cO,viewData:J$,breadcrumbs:t$,urlLocaleSegment:Y,meta:L.meta,appId:L.appId,features:L.features,isOgRequest:f})}catch(m){if(m.kind===mO)if(T)return FX(m.payload.viewData??m.payload.api);else return ZW(m.payload.view);if(!Z0.has(m))this.hooks.onRequestFail(g,m);if(qO(m))return console.error(m),T?d$():ZW(ej());if(m instanceof W$&&m.status===403)return T?d$():ZW(ej());throw m}},O)}}function WW(){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 a4 extends N0{routes={"/api-routes":this.get(()=>{let $=K(QT).flatRoutes,O=[];for(let[Z,T]of Object.entries($))for(let[f,j]of Object.entries(T)){let{exec:W,middleware:z}=j;O.push({path:Z,method:f,middleware:z})}return O}),"/view-routes":this.get(()=>{let $=K(yO).flatViewRoutes,O=[];for(let[Z,{middleware:T,viewPath:f}]of Object.entries($))O.push({path:Z,method:"GET",viewPath:f,middleware:T});return O})}}var KT="access_token";function CX($,O){let Z=$.body.getReader(),T=!1,f=()=>{if(T)return;T=!0;try{O()}catch(W){console.error(W)}},j=new ReadableStream({async pull(W){let z;try{z=await Z.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 Z.cancel(W)}finally{f()}}},{highWaterMark:0});return new Response(j,{status:$.status,statusText:$.statusText,headers:$.headers})}function l4($){let{status:O=400,data:Z,headers:T}=$,f=new Headers({"Content-Type":"application/json",...T});if(!f.has("Cache-Control"))f.set("Cache-Control","no-store");return new Response(JSON.stringify(Z),{status:O,headers:f})}function d4($,O,Z){let T=[];O?.forEach((W,z)=>T.push([z,W]));let f=[...typeof O?.getSetCookie==="function"?O.getSetCookie():[],...Array.from(Z??[])];if(T.length===0&&f.length===0)return $;let j=(W)=>{for(let[z,J]of T){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 QT{static token="router.api";flatRoutes={};onRequestStart;onRequestEnd;onRequestFail;constructor($){let O=r2();this.onRequestStart=$.onRequestStart??O.onRequestStart,this.onRequestEnd=$.onRequestEnd??O.onRequestEnd,this.onRequestFail=$.onRequestFail??O.onRequestFail,this.flatRoutes=Aj({"/":$.rootRouter,"/auth":Vj,"/__gemi__/services/i18n":Lj,"/__gemi__/services/logs":_j,"/__gemi__/services/image":Mj,"/__gemi__/debug":a4})}getRouteHandlerAndParams($){let O=new URL($.url),Z=n4(O.pathname),T={},f;for(let[j]of Object.entries(this.flatRoutes))try{let W=new URLPattern({pathname:j});if(W.test({pathname:Z})){f=j,T=W.exec({pathname:Z})?.pathname.groups;break}}catch(W){console.error(W)}return{params:T,path:f}}async runRouteMiddleware($,O){let T=this.flatRoutes[$][O.rawRequest.method].middleware;try{await K(gO).runMiddleware(T)}catch(f){if(f.kind===mO)return l4(f.payload.api);else{if(a$(f))return WW();if(this.onRequestFail(O,f),console.error(f),qO(f))return d$();throw f}}}async getRouteData($){let O=this.flatRoutes[$],Z=N.getStore(),T=O[Z.req.rawRequest.method].exec??(()=>Promise.resolve({})),f={};try{f=await T()}catch(j){if(j.kind===mO)return l4(j.payload.api);if(a$(j))return WW();if(this.onRequestFail(Z.req,j),console.error(j),qO(j))return d$();throw j}return f}isFrameworkRoute($){return $.startsWith("/__gemi__")}async endRequest($,O,Z){let T=async()=>{try{if(!this.isFrameworkRoute(Z))await this.onRequestEnd(O)}catch(f){R1.error(f?.message??'Error in "onRequestEnd" event handler',{err:JSON.stringify(f)})}finally{$.destroy()}};if(!$.hasPendingWork()){await T();return}$.whenIdle().then(T).catch((f)=>{console.error(f)})}isOpenEndedBody($,O){return $.method!=="HEAD"&&O.body!==null&&!O.headers.has("Content-Length")}async handleApiRequest($,O){let{params:Z,path:T}=this.getRouteHandlerAndParams($),f=this.flatRoutes[T];if(!f||!f[$.method])return new Response(JSON.stringify({error:{message:"Not found"}}),{status:404});let j=new P($,Z,"api",T);if(!this.isFrameworkRoute(T))this.onRequestStart(j);return await N.run(j,async()=>{let W=N.getStore(),z=!1,J=async()=>{z=!0,await this.endRequest(W,j,T)};try{let Y=K(n);if(Y.isEnabled){let D=Y.detectLocale(j);W.setLocale(D)}W.setRequest(j);let X=await this.runRouteMiddleware(T,j);if(X instanceof Response){let D=d4(X,W.headers,W.cookies);return await J(),D}let C=await this.getRouteData(T),F=W.headers,U=W.cookies;if(C instanceof Response){let D=d4(C,F,U);if(this.isOpenEndedBody($,D)){let G=CX(D,()=>this.endRequest(W,j,T));return z=!0,G}return await J(),D}return F.set("Content-Type","application/json"),U.forEach((D)=>F.append("Set-Cookie",D.toString())),await J(),new Response(JSON.stringify(C),{headers:F})}catch(Y){if(!z)try{await J()}catch(X){console.error(X)}throw Y}},O)}async dispatchAs($,O,Z,T){let f=new URL($.rawRequest.url).origin,j=new URL(`${f}/api${Z}`),W=`/api${Z.split(/[?#]/)[0]}`;if(!Z.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: "${Z}" 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(KT);if(J)z.set("Cookie",`${KT}=${J}`);let Y=$.headers.get(KT);if(Y)z.set(KT,Y);let X=$.headers.get("User-Agent");if(X)z.set("User-Agent",X);let C;if(T instanceof FormData)C=T;else if(T!==void 0)z.set("Content-Type","application/json"),C=JSON.stringify(T);let F=new Request(j,{method:O,headers:z,body:C});if(u4(F,nO($)),$.domain)s$(F,$.domain);return N.exit(()=>s4.exit(()=>this.handleApiRequest(F)))}}import{timingSafeEqual as DX}from"crypto";var LT="",YW="*",UX=60000,GX=1e4,zW=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,VT=16,o4=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,JW="x-forwarded-host";function r4($){return $.startsWith(":")}function XW($,O){if($===null)return!1;let Z=Buffer.from($,"utf8"),T=Buffer.from(O,"utf8");return Z.length===T.length&&DX(Z,T)}function BX($){if(!$)return null;if($===!0)return{header:JW,secret:null};return{header:($.hostHeader??JW).toLowerCase(),secret:$.secret?{header:$.secret.header.toLowerCase(),value:$.secret.value}:null}}function KX($){if(!$||$===!0)return;let{hostHeader:O,secret:Z}=$;if(O!==void 0&&(typeof O!=="string"||!o4.test(O)))throw Error(`\`route.domains.trustProxy.hostHeader\` must be a single header name, e.g. "x-forwarded-host". Got ${JSON.stringify(O)}.`);if(!Z)return;if(typeof Z.header!=="string"||!o4.test(Z.header))throw Error(`\`route.domains.trustProxy.secret.header\` must be a header name. Got "${Z.header}".`);if(Z.header.toLowerCase()===(O??JW).toLowerCase())throw Error("`route.domains.trustProxy.secret.header` names the same header as `hostHeader`; the secret needs a header of its own.");if(typeof Z.value!=="string"||Z.value.length<VT)throw Error(`\`route.domains.trustProxy.secret.value\` must be at least ${VT} characters. A guessable one lets any client name its own host.`)}function Z1($){if(!$)return null;try{return new URL(`http://${$.trim()}`).hostname.toLowerCase().replace(/\.$/,"")||null}catch{return null}}function QX($){try{let O=new URL(`http://${$.trim()}`),Z=O.hostname.toLowerCase().replace(/\.$/,"");return Z?O.port?`${Z}:${O.port}`:Z:null}catch{return null}}function VX($){let O=Z1($.root),Z=$.root?.trim().toLowerCase().replace(/\.$/,"");if(!O||O!==Z||!O.split(".").every((j)=>zW.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<VT)throw Error(`\`route.domains.ask.secret\` must be at least ${VT} characters. A guessable one is worse than leaving \`ask\` out.`);KX($.trustProxy);let T=new Set,f=null;for(let j of $.groups??[]){let{subdomain:W}=j;if(T.has(W))throw Error(`\`route.domains\` declares the subdomain "${W}" twice.`);if(T.add(W),r4(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)=>zW.test(z)))throw Error(`"${W}" is not a valid subdomain.`)}if($.custom&&!T.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 FW{root;hostTrust;fixed=new Map;param=null;custom;cacheTtlMs;cache=new Map;inFlight=new Map;askSecret;proxySecretHeader;constructor($){VX($),this.root=Z1($.root),this.hostTrust=BX($.trustProxy);for(let O of $.groups??[])if(r4(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??UX,this.askSecret=$.ask?.secret??null,this.proxySecretHeader=this.hostTrust?.secret?.header??null}forwardedHost($){let O=this.hostTrust;if(!O)return null;if(O.secret&&!XW($.headers.get(O.secret.header),O.secret.value))return null;return $.headers.get(O.header)?.split(",")[0]?.trim()||null}hostOf($){return Z1(this.forwardedHost($))??Z1(new URL($.url).host)}publicOrigin($){let O=new URL($.url),Z=$.headers.get("x-forwarded-proto")?.split(",")[0]?.trim(),T=Z==="http"||Z==="https"?Z:O.protocol.replace(/:$/,""),f=this.forwardedHost($),j=f&&Z1(f)?QX(f):null;return`${T}://${j??O.host}`}async resolve($){let O=this.hostOf($);if(!O)return null;let Z=await this.match(O,$);if(Z)return Z;if(this.custom?.fallback&&!this.isUnderRoot(O))return{host:O,group:YW,params:{},custom:!0};return null}async allows($,O){let Z=Z1($);return Z?await this.match(Z,O)!==null:!1}isUnderRoot($){return $===this.root||$.endsWith(`.${this.root}`)}async match($,O){if($===this.root)return{host:$,group:LT,params:{},custom:!1};if($.endsWith(`.${this.root}`)){let T=$.slice(0,-(this.root.length+1)),f=this.fixed.get(T);if(f)return{host:$,group:f.subdomain,params:{},custom:!1};if(this.param&&zW.test(T)){let j={[this.param.name]:T};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 Z=await this.resolveCustom($);return Z?{host:$,group:this.custom.group,params:Z,custom:!0}:null}async resolveCustom($){let O=Date.now(),Z=this.cache.get($);if(Z&&Z.expiresAt>O)return this.cache.delete($),this.cache.set($,Z),Z.value;let T=this.inFlight.get($);if(T)return T;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>=GX)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=Z1($);if(O)this.cache.delete(O)}}}var LX="/__gemi__/domains/ask";class s0{static token="router.domains";resolver;acceptsCustomDomains;groups=new Map;constructor($,O){this.groups.set(LT,$);let{domains:Z}=O;if(this.acceptsCustomDomains=Boolean(Z?.custom),!Z){this.resolver=null;return}this.resolver=new FW(Z);let T=(f)=>({api:f.api?new QT({...O.api,...f.api}):$.api,view:f.view?new yO({...O.view,...f.view}):$.view});for(let f of Z.groups??[])this.groups.set(f.subdomain,T(f));if(Z.custom?.fallback)this.groups.set(YW,T(Z.custom.fallback))}async route($){if(!this.resolver)return this.dispatchers(null);if(this.resolver.proxySecretHeader)t4($,this.resolver.proxySecretHeader);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!==LX)return null;if(!XW(O.searchParams.get("secret"),this.resolver.askSecret))return null;let Z=O.searchParams.get("domain"),T=Z?await this.resolver.allows(Z,$):!1;return new Response(null,{status:T?200:404})}dispatchers($){return this.groups.get($?.group??LT)}viewDispatchers(){return Array.from(new Set(Array.from(this.groups.values(),($)=>$.view)))}}function e4($){let O=new Date($??0).getTime();return Number.isFinite(O)?O:0}var $5=600000;function O5($,O){return[aO($,O),aO($,O-1)]}class w{static token="auth";config;provider;constructor($={},O=new lT){this.config=Z5(iW($),$),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 Z=O==="root"?K(s0).resolver?.root:Z1(O);if(!Z)throw Error('`auth.cookieDomain` is "root", but `route.domains` is not configured.');let T=$.domain?.host??Z1(new URL($.rawRequest.url).host);return T===Z||T?.endsWith(`.${Z}`)?Z:void 0}async getSession($,O){if(!$)return null;if(!pT($))return this.config.migrateLegacySession?this.convertLegacySession($,O,this.config.migrateLegacySession):null;let Z=await this.userProvider.findSession({token:$,userAgent:O});if(!Z?.user)return null;let T=Date.now(),f=e4(Z.expiresAt),j=e4(Z.absoluteExpiresAt);if(f<=T||j<=T)return await this.userProvider.deleteSession({token:$}),null;let z=await this.slideSession(Z,T);return z.user.extension=await this.config.extendSession(z.user),z}async convertLegacySession($,O,Z){let T=N.getStore()?.req;if(!T)return null;let f=Date.now(),j=Math.floor(f/$5),W=null,z=await this.userProvider.findSession({token:$,userAgent:O});if(z?.user){if(!await Z(z,{token:$,req:T,userAgent:O}))return null;let Y=aO($,j),X=z.user.id;if(await this.userProvider.withLegacySessionLock($,async()=>{if(!await this.userProvider.claimLegacySession({token:$}))return!1;return await this.userProvider.createSessionV2({token:Y,userId:X,userAgent:O,...this.freshLifetime(f)}),!0}))W=Y}if(!W){for(let Y of O5($,j))if((await this.userProvider.findSession({token:Y,userAgent:O}))?.user){W=Y;break}}if(!W)return null;let J=await this.getSession(W,O);if(J)T.ctx().setCookie("access_token",W,this.accessTokenCookieOptions(T,new Date(J.expiresAt)));return J}async revokeSession($,O){if(!$)return await this.userProvider.deleteSession({token:$}),null;if(pT($)||!this.config.migrateLegacySession){let f=await this.userProvider.findSession({token:$,userAgent:O});return await this.userProvider.deleteSession({token:$}),f}let Z=Math.floor(Date.now()/$5),T=O5($,Z);return this.userProvider.withLegacySessionLock($,async()=>{let f=await this.userProvider.findSession({token:$,userAgent:O});for(let j of T){if(f?.user)break;f=await this.userProvider.findSession({token:j,userAgent:O})}await this.userProvider.deleteSession({token:$});for(let j of T)await this.userProvider.deleteSession({token:j});return f})}requestCarryingCookie($){let O=N.getStore()?.req;return O?.cookies.get("access_token")===$?O:null}async slideSession($,O){let Z=this.config.sessionExpiresInHours*3600000;if(new Date($.expiresAt).getTime()-O>=Z/2)return $;let T=new Date(Math.min(O+Z,new Date($.absoluteExpiresAt).getTime())),f=await this.userProvider.updateSession({token:$.token,expiresAt:T}),j=this.requestCarryingCookie($.token);if(j)j.ctx().setCookie("access_token",$.token,this.accessTokenCookieOptions(j,T));if(!f)return $;return{...$,expiresAt:f.expiresAt??T}}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 Z=await this.createOrUpdateSession({email:$,id:O.id}),T=new P;if(T.ctx().setCookie("access_token",Z.token,this.accessTokenCookieOptions(T,Z.expiresAt)),Z?.user)Z.user.extension=await this.config.extendSession(Z.user);return Z}catch(O){console.log(O)}}async createOrUpdateSessionV2($){let O=await this.createOrUpdateSession($),Z=null;if(O?.user)Z=await this.config.extendSession(O.user),O.user.extension=Z;return O}async createOrUpdateSession($){let O=new P,Z=$.id??(await this.userProvider.findUserByEmailAddress($.email,!1))?.id;if(!Z)throw new q1;let T=Bun.env.NODE_ENV==="development"?"local":O.headers.get("User-Agent"),f=cW(Z),j=await this.userProvider.createSessionV2({token:f,userId:Z,userAgent:T,...this.freshLifetime(Date.now())}),W=await this.userProvider.findSession({token:f,userAgent:T??""});return W?.user?W:j}async createMagicLinkToken($){let O=await this.userProvider.findUserByEmailAddress($,!1);if(O){await this.userProvider.deleteMagicLinkToken($);let Z=await this.config.generateMagicLinkToken($),T=(Number.parseInt(SX(4).toString("hex"),16)%1e6).toString().padStart(6,"0");return await this.userProvider.createMagicLinkToken({email:$,token:Z,pin:T}),{user:O,email:$,pin:T,token:Z}}return{}}}import{AsyncLocalStorage as IX}from"async_hooks";class CW{config;static token="broadcast";publishCb;context=new IX;constructor($){this.config=$}get channels(){return this.config.channels}onPublish($){this.publishCb=$}publish(...$){let[O,Z,T]=$;this.publishCb(O,Z,T)}async handleMessage($,O){let Z=JSON.parse(O);if(Z.type==="subscribe"){let T=Object.entries(this.channels).sort(([f],[j])=>f.length-j.length);for(let[f,j]of T){let W=new URLPattern({pathname:f});if(W.test({pathname:Z.topic})){let z=W.exec({pathname:Z.topic})?.pathname.groups,J=new j;if(await J.subscribe.call(J,z))$.subscribe(Z.topic);break}}}if(Z.type==="broadcast")$.publish(Z.topic,JSON.stringify({topic:Z.topic,data:Z.payload}));if(Z.type==="unsubscribe")$.unsubscribe(Z.topic)}run($,O){let Z=T5($.get("Cookie"));this.context.run({headers:$,cookies:Z},O)}}class ST extends O0{static getFacadeAccessor(){return CW}static channel($,O){let Z=this.getFacadeRoot(),T=Z.channels[$];if(!T)return console.error(`Channel ${$} not found`),{publish:()=>{}};let f=new T;return{publish:(j,W=!1)=>{let z=s($,O);Z.publish(z,JSON.stringify({topic:z,data:f.publish(j)}),W)}}}}class Z$ extends O0{static getFacadeAccessor(){return w}static async user(){let $=N.getStore(),O=ST.getFacadeRoot().context.getStore(),Z="",T="";if($?.req)Z=$.req.cookies.get("access_token"),T=$.req.headers.get("User-Agent");if(O?.cookies)T=O.headers.get("User-Agent"),Z=O.cookies.get("access_token");let f=$?.user;if(!f)f=(await this.getFacadeRoot().getSession(Z,T))?.user,$?.setUser(f);if(f)return f;throw new q1({redirectTo:sO($?.req,this.getFacadeRoot().config.signInPath)})}static intendedUrl($){let O=N.getStore()?.req;return $O(O?.search.get(C$),$??this.getFacadeRoot().config.redirectPath)}static async guard($){let O=await Z$.user();if(!await $(O))throw new qT}static async guardSafe($){let O=await Z$.user();try{return await $(O)}catch(Z){return!1}}static async authenticate($){return await this.getFacadeRoot().authenticate($)}static async createMagicLink($){return await this.getFacadeRoot().createMagicLinkToken($)}}class IT{static ensure($,O={}){let Z=N.getStore();if(Z.req.kind==="api")throw Error("Query.prefetch() cannot be called from an API request");return Z.serverQueries??=new l$(kO(Z.req.rawRequest)),Z.serverQueries.ensure($,O,"prefetch")}static async instant($,...O){let Z=IT.ensure($,O[0]);if(await Z.promise,Z.status==="rejected")throw Z.error;return Z.data}static prefetch($,...O){IT.ensure($,O[0])}static noPrefetch(){let $=N.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 f5($,O,Z="/"){let T=new URL($.origin),f=O.host?O.host:O.subdomain?`${O.subdomain}.${$.root}`:$.root,j=new URL(Z.startsWith("/")?Z:`/${Z}`,T),W=MX(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 MX($){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 j5{static absolute($,...O){return`${process.env.HOST_NAME}${s(String($),O[0]??{})}`}static relative($,...O){return s(String($),O[0]??{})}static forDomain($,O,...Z){let T=K(s0).resolver;if(!T)throw Error("`Url.forDomain` needs `route.domains` to be configured.");let f=N.getStore()?.req?.rawRequest,j=f?T.publicOrigin(f):process.env.HOST_NAME;if(!j)throw Error("`Url.forDomain` outside a request needs `HOST_NAME` for the protocol.");return f5({root:T.root,origin:j},$,s(String(O),Z[0]??{}))}}class W5{name="Meta";static description($){N.getStore().metadata.description($)}static title($){N.getStore().metadata.title($)}static openGraph($){N.getStore().metadata.openGraph($)}}var NX={set($,O,Z){N.getStore().setCookie($,O,Z)},setIfAbsent($,O,Z){if(N.getStore().req.cookies.has($))return!1;return N.getStore().setCookie($,O,Z),!0},delete($,O){N.getStore().deleteCookie($,O)}};class DW{config;static token="redis";instance=null;constructor($={}){this.config=$}get client(){return this.instance??=new(xX())(this.config.url,this.config.options)}set client($){this.instance=$}}function xX(){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 D1 extends O0{static getFacadeAccessor(){return DW}static get client(){return this.getFacadeRoot().client}static get($){return D1.client.get($)}static set($,O){return D1.client.set($,O)}static del(...$){return D1.client.del(...$)}static exists($){return D1.client.exists($)}static incr($){return D1.client.incr($)}static expire($,O){return D1.client.expire($,O)}static ttl($){return D1.client.ttl($)}}class z5 extends O0{static getFacadeAccessor(){return D$}static consume($,O={}){return this.getFacadeRoot().consume($,O)}}class J5 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,Z){return this.getFacadeRoot().set($,O,Z)}static refresh(){return this.getFacadeRoot().refresh()}static invalidate(){return this.getFacadeRoot().invalidate()}}class MT{bound;constructor($){this.bound=$}get name(){return this.bound??ZO()}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,Z=this.connection(O);return F5(Z.sql,(T)=>Y5(O,()=>$(T)),{slowTransactionThreshold:Z.config.slowTransactionThreshold,connection:O})}async schema(){let $=this.connection(),{introspect:O}=await import("./chunk-evbvpfv6.js");return O(this.handle()??$.sql,$.dialect)}run($,O){let Z=this.connection(),{text:T,values:f}=D5($,C5(Z.dialect),O);return(this.handle()??Z.sql).unsafe(T,f)}handle(){let $=OO();if($===void 0)return;return ZO()===this.name?$:void 0}connection($=this.name){return X5($),K(TO).connection($)}}var o$=new MT;class U5 extends O0{static getFacadeAccessor(){return TO}static connection($){return new MT($)}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,AT as kc,N0 as lc,wT as mc,IW as nc,uO as oc,vT as pc,B1 as qc,v0 as rc,_5 as sc,A5 as tc,yT as uc,pT as vc,cW as wc,C9 as xc,iW as yc,k5 as zc,lT as Ac,CW as Bc,ST as Cc,Z$ as Dc,i$ as Ec,IT as Fc,j5 as Gc,vO as Hc,R1 as Ic,W5 as Jc,NX as Kc,DW as Lc,D1 as Mc,D$ as Nc,z5 as Oc,H4 as Pc,oj as Qc,w4 as Rc,b4 as Sc,iY as Tc,v4 as Uc,rj as Vc,dY as Wc,uY as Xc,tj as Yc,g4 as Zc,R4 as _c,h$ as $c,J5 as ad,MT as bd,U5 as cd,Sj as dd,Ij as ed,o9 as fd,a2 as gd,o2 as hd,gO as id,UC as jd,r2 as kd,t2 as ld,dj as md,nj as nd,d$ as od,ej as pd,fW as qd,JX as rd,ZW as sd,FX as td,yO as ud,gT as vd,gW as wd,nO as xd,WW as yd,l4 as zd,d4 as Ad,QT as Bd,s0 as Cd,w as Dd,AW as Ed,EW as Fd,HW as Gd,kW as Hd,mW as Id,qW as Jd};
|
|
18
|
+
|
|
19
|
+
//# debugId=A6EAD930B44BE5F664756E2164756E21
|