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