gemi 0.135.0 → 0.136.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/{chunk-n68a4r72.js → chunk-04tkpna8.js} +1 -1
- package/dist/{chunk-rhjh79np.js → chunk-3dpmkxp7.js} +2 -2
- package/dist/{chunk-rhjh79np.js.map → chunk-3dpmkxp7.js.map} +1 -1
- package/dist/{chunk-sxcxmwbt.js → chunk-3gx7wcrt.js} +1 -1
- package/dist/{chunk-e2tjw0qx.js → chunk-541s0vkt.js} +2 -2
- package/dist/{chunk-e2tjw0qx.js.map → chunk-541s0vkt.js.map} +3 -3
- package/dist/{chunk-6hstj70n.js → chunk-t8xs9ptb.js} +1 -1
- package/dist/facades/index.js +1 -1
- package/dist/http/index.js +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/kernel/index.js +1 -1
- package/dist/server/index.js +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/router/serverQueryFetcher.d.ts.map +1 -1
- package/package.json +1 -1
- /package/dist/{chunk-n68a4r72.js.map → chunk-04tkpna8.js.map} +0 -0
- /package/dist/{chunk-sxcxmwbt.js.map → chunk-3gx7wcrt.js.map} +0 -0
- /package/dist/{chunk-6hstj70n.js.map → chunk-t8xs9ptb.js.map} +0 -0
|
@@ -10,7 +10,7 @@ ${Z}</sitemapindex>
|
|
|
10
10
|
`)));return pW(G,{url:j.url})}function S8($){return $===void 0?[]:typeof $==="string"?[$]:$}function W6($,Z){if(/[\r\n]/.test(Z))throw TypeError(`Robots: the ${$} value ${JSON.stringify(Z)} has a line break in it.`);return`${$}: ${Z}
|
|
11
11
|
`}function cW($){let Z=[];for(let W of $.rules??[]){let Y=S8(W.userAgent);if(Y.length===0)throw TypeError("Robots: a rule needs at least one userAgent.");let j=Y.map((X)=>W6("User-agent",X)).join(""),z=[...S8(W.allow).map((X)=>["Allow",X]),...S8(W.disallow).map((X)=>["Disallow",X])];for(let[X,G]of z){if(!G.startsWith("/")&&!G.startsWith("*"))throw TypeError(`Robots: ${X} "${G}" must start with "/" or "*".`);j+=W6(X,G)}if(z.length===0)j+=`Disallow:
|
|
12
12
|
`;if(W.crawlDelay!==void 0){if(!Number.isFinite(W.crawlDelay)||W.crawlDelay<0)throw TypeError(`Robots: crawlDelay ${W.crawlDelay} is not a number of seconds.`);j+=W6("Crawl-delay",String(W.crawlDelay))}Z.push(j)}let J=($.sitemaps??[]).map((W)=>{let Y;try{Y=new URL(W)}catch{throw TypeError(`Robots: sitemap "${W}" is not an absolute URL.`)}return W6("Sitemap",Y.href)});if(J.length>0)Z.push(J.join(""));return Z.join(`
|
|
13
|
-
`)}function KF($,Z={}){let J=new Headers(Z.headers);if(!J.has("content-type"))J.set("content-type","text/plain; charset=utf-8");return new Response(cW($),{status:200,headers:J})}var dW={response:KF,text:cW,parse:pW,fetch:QF};import{createHmac as uW,randomBytes as FF}from"crypto";var E8="v2.";function f8($){return $.startsWith(E8)}function zZ(){let $=process.env.SECRET;if(!$)throw Error("Signing in needs a secret to mint session tokens with. Set SECRET in the environment.");return $}function lW($){let Z=FF(16).toString("hex"),J=uW("sha256",zZ()).update(`${$}:${Z}`).digest("hex");return`${E8}${J}`}function Y6($,Z){let J=uW("sha256",zZ()).update(`legacy-session:${Z}:${$}`).digest("hex");return`${E8}${J}`}import{createHash as OF,createHmac as DF,randomInt as UF,timingSafeEqual as nW}from"crypto";function iW($,Z){return Math.floor($/Z)*Z}function BF($,Z){if(Z<=0)return 0;return Math.min(1,Math.max(0,(Z-$)/Z))}function b8($,Z,J,W){return Z*BF(J,W)+$}function VF($){let{current:Z,previous:J,elapsed:W,window:Y,limit:j,cost:z}=$,X=j-z;if(X<0)return Y;let G=Math.max(0,Y-W);if(J>0){let K=Y*(1-(X-Z)/J);if(K<=Y)return Math.max(0,Math.ceil(K-W))}if(Z<=X)return G;if(Z<=0)return G;let Q=Y*(1-X/Z);return G+Math.max(0,Math.ceil(Q))}function sW($){let{allowed:Z,current:J,previous:W,now:Y,elapsed:j,window:z,limit:X,cost:G}=$;if(Z){let K=b8(J,W,j,z);return{allowed:!0,limit:X,remaining:Math.max(0,Math.floor(X-K)),resetAt:Y-j+z,retryAfter:0}}let Q=VF({current:J,previous:W,elapsed:j,window:z,limit:X,cost:G});return{allowed:!1,limit:X,remaining:0,resetAt:Y+Q,retryAfter:Q}}class R8{}class w8 extends R8{buckets=new Map;maxKeys;constructor($={}){super();this.maxKeys=Math.max(1,$.maxKeys??1e5)}consume($){let{key:Z,limit:J,window:W}=$,Y=$.cost??1,j=Date.now(),z=iW(j,W),X=j-z,G=this.roll(Z,W,z);G.limit=J;let K=b8(G.current,G.previous,X,W)+Y<=J;if(K)G.current+=Y;if(this.buckets.delete(Z),this.buckets.set(Z,G),this.buckets.size>this.maxKeys)this.evict(j);return sW({allowed:K,current:G.current,previous:G.previous,now:j,elapsed:X,window:W,limit:J,cost:Y})}clear(){this.buckets.clear()}get size(){return this.buckets.size}roll($,Z,J){let W=this.buckets.get($);if(!W||W.window!==Z)return{window:Z,limit:0,windowStart:J,current:0,previous:0};if(W.windowStart===J)return W;if(W.windowStart+Z===J)return W.previous=W.current,W.current=0,W.windowStart=J,W;return W.previous=0,W.current=0,W.windowStart=J,W}evict($){for(let[W,Y]of this.buckets)if($-Y.windowStart>=Y.window*2)this.buckets.delete(W);let Z=this.maxKeys-Math.floor(this.maxKeys/10);if(this.buckets.size<=Z)return;let J=[...this.buckets].map(([W,Y],j)=>({key:W,order:j,spent:Y.limit>0?(Y.current+Y.previous)/Y.limit:0}));J.sort((W,Y)=>W.spent-Y.spent||W.order-Y.order);for(let{key:W}of J){if(this.buckets.size<=Z)break;this.buckets.delete(W)}}}var rW="h1.";function j6($,Z,J){let W=DF("sha256",zZ()).update(`gemi:one-time:${$}:${Z}:${J}`).digest("hex");return`${rW}${W}`}function eZ($,Z,J,W){let Y=typeof W==="string"?W:"",j=typeof J==="string"?J:"",z=j.startsWith(rW),X=j6($,Z,Y),G=Buffer.from(z?X:Y),Q=Buffer.from(j);if(G.length!==Q.length||Y===""||j==="")return nW(G,G),!1;return nW(G,Q)}function tW($){let Z="";for(let J=0;J<$;J++)Z+=String(UF(0,10));return Z}var eW=320;function $3($){if(typeof $!=="string")return null;let Z=$.trim();if(Z===""||Z.length>eW)return null;return Z.toLowerCase()}function z6($){if(typeof $!=="string")return null;let Z=$.trim();if(Z.length>eW)return null;let J=Z.toLowerCase();if(J.length<3||J.length>254||!/^[^\s@]+@[^\s@]+$/.test(J))return null;return J}var oW=null;function $5(){try{let $=L();if(typeof $?.bound==="function"&&$.bound(z1))return $.make(z1)}catch{}return oW??=new z1({driver:new w8,limit:1000,window:60}),oW}function aW($){return $.length<=64?$:`sha256:${OF("sha256").update($).digest("hex")}`}async function XZ($,Z,J,W){let Y=$5(),j=[[`auth:code-${$}:ip:${aW(JZ(J))}`,W.perIp]];if(Z!==null)j.push([`auth:code-${$}:email:${aW(Z)}`,W.perEmail]);for(let[z,X]of j){if(!X)continue;let[G,Q]=X,K=await Y.consume(z,{limit:G,window:Q});if(!K.allowed)throw new i1(K)}}async function Z5($,Z,J,W=10){let Y=Math.max(86400,Math.ceil(W*60*(J+1)));return(await $5().consume(`auth:code-attempt:${$}:${Z}`,{limit:J,window:Y})).allowed}import{randomBytes as q8}from"crypto";class k8 extends C{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 X6($,Z,J,W=1/0){if(!Number.isInteger(Z)||Z<J||Z>W){let Y=W===1/0?`an integer of at least ${J}`:`an integer from ${J} to ${W}`;throw Error(`auth.emailCode.${$} must be ${Y}, got ${Z}`)}}function LF($={}){for(let Z of["password","magicLink"]){let J=$?.[Z];if(J!==void 0&&typeof J!=="boolean")throw Error(`auth.${Z} must be true or false, got ${JSON.stringify(J)}`)}}function y8($={}){let Z=$.length??6,J=$.expiresInMinutes??10,W=$.linkExpiresInMinutes??10080,Y=$.maxAttempts??5;return X6("length",Z,4,12),X6("expiresInMinutes",J,1),X6("linkExpiresInMinutes",W,1),X6("maxAttempts",Y,1),{enabled:$.enabled??!1,createUser:$.createUser??!1,length:Z,expiresInMinutes:J,linkExpiresInMinutes:W,maxAttempts:Y,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:j,code:z})=>{if(Bun.env.NODE_ENV!=="production")console.info(`[gemi] email code for ${j}: ${z} (set auth.emailCode.send to deliver it)`)})}}async function HF($,Z){if(typeof Z!=="string"||Z==="")return!1;try{return await Bun.password.verify($,Z)}catch{return!1}}function J5($){if(!$)return null;if(typeof $.getRedirectUrl==="function")return{provider:$};let{provider:Z,feature:J}=$;return{provider:Z,...J!==void 0?{feature:J}:{}}}function W5($){for(let[Z,J]of Object.entries($??{})){if(typeof J?.getRedirectUrl==="function")continue;let W=J;if(typeof W?.provider?.getRedirectUrl!=="function")throw Error(`auth.oauthProviders.${Z} must be an OAuthProvider, or { provider, feature } with an OAuthProvider.`);if(W.feature!==void 0&&(typeof W.feature!=="string"||W.feature===""))throw Error(`auth.oauthProviders.${Z}.feature must be a feature key from app/features.`)}}function xI($){return $}function Y5($={}){return LF($),{basePath:"/auth",verifyEmail:!0,password:!0,magicLink:!0,redirectPath:"/dashboard",signInPath:"/auth/sign-in",sessionExpiresInHours:24,sessionAbsoluteExpiresInHours:672,cookieDomain:null,migrateLegacySession:null,signUpRequest:k8,oauthProviders:{},oauthFailurePath:null,oauthCompleteProfilePath:null,connections:{},connectionStore:null,onConnected:()=>{},verifyPassword:HF,hashPassword:async(Z)=>await Bun.password.hash(Z),generateForgotPasswordToken:async()=>q8(32).toString("hex"),generateEmailVerificationToken:()=>{if(!($.verifyEmail??!0))return"";return q8(32).toString("hex")},generateMagicLinkToken:()=>q8(32).toString("hex"),extendSession:()=>({}),onUserCreated:async()=>{},onSignUp:()=>{},onSignIn:()=>{},onSignOut:()=>{},onForgotPassword:()=>{},onResetPassword:()=>{},onMagicLinkCreated:()=>{},emailCode:y8($.emailCode),generateCode:()=>{return},onAuthenticated:()=>{}}}var IF=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),PF=new Set(["svg","math"]);function j5($){return $===32||$===9||$===10||$===12||$===13}function z5($){return $>=65&&$<=90||$>=97&&$<=122}function G6($){return $>=65&&$<=90?$+32:$}function X5(){let $="data",Z="",J=!1,W="",Y=0,j=0,z=!1,X=0,G=0,Q=()=>$==="data"&&X===0&&G===0,K=()=>{if(!J&&IF.has(Z)){$="rawText",W=`</${Z}`,Y=0,Z="";return}if($="data",Z==="template")if(J)X=Math.max(0,X-1);else X+=1;else if(PF.has(Z)){if(J)G=Math.max(0,G-1);else if(!z)G+=1}Z=""},B=(F)=>{switch($){case"data":if(F===60)$="tagOpen";return;case"tagOpen":if(F===33)$="bang",j=0;else if(F===47)$="endTagOpen";else if(z5(F))$="tagName",J=!1,z=!1,Z=String.fromCharCode(G6(F));else if(F===63)$="bogus";else if(F===60)$="tagOpen";else $="data";return;case"endTagOpen":if(z5(F))$="tagName",J=!0,z=!1,Z=String.fromCharCode(G6(F));else if(F===62)$="data";else $="bogus";return;case"tagName":if(j5(F)||F===47)$="inTag",z=F===47;else if(F===62)K();else Z+=String.fromCharCode(G6(F));return;case"inTag":if(F===62){K();return}if(z=F===47,F===34)$="attrDouble";else if(F===39)$="attrSingle";return;case"attrDouble":if(F===34)$="inTag";z=!1;return;case"attrSingle":if(F===39)$="inTag";z=!1;return;case"bang":if(F===45){if(j+=1,j===2)$="comment",j=0}else if(F===62)$="data";else $="bogus";return;case"bogus":if(F===62)$="data";return;case"comment":if(F===45)j=j<2?j+1:2;else if(F===62&&j>=2)$="data",j=0;else j=0;return;case"rawText":{if(Y<W.length){if(G6(F)===W.charCodeAt(Y))Y+=1;else Y=F===60?1:0;return}if(F===62)$="data",Z="";else if(j5(F)||F===47)$="inTag",Z="";else Y=F===60?1:0;return}}};return{scanToInsertionPoint(F){for(let D=0;D<F.length;D++){if(Q())return D;B(F[D])}return F.length},write(F){for(let D=0;D<F.length;D++)B(F[D])},isSafe:Q}}function _1($){let Z=JSON.stringify($);if(Z===void 0)return"undefined";return Z.replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function TF($){return`<script>(self.__GEMI_STREAM__=self.__GEMI_STREAM__||[]).push(${_1([$.path,$.variantKey,$.data])})</script>`}function MF($){return`<script>(self.__GEMI_DICT__=self.__GEMI_DICT__||[]).push(${_1([$.id,$.locale,$.strings])})</script>`}function v8($,Z,J={},W){let Y=new TextEncoder,j=[],z=!1,X=!1,G=()=>{if(X)return;X=!0,J.onClose?.()};Z.onSettle((V)=>{if(V.status!=="resolved")return;j.push(TF(V))}),W?.onUse((V)=>{j.push(MF(V))});let Q=$.getReader(),K=X5(),B=(V,O)=>{V.enqueue(O),J.onChunk?.(O)},F=(V)=>{while(j.length>0){let O=Y.encode(j.shift());K.write(O),B(V,O)}},D=(V,O)=>{if(j.length===0){K.write(O),B(V,O);return}let U=K.scanToInsertionPoint(O);if(U>0)B(V,O.subarray(0,U));if(K.isSafe())F(V);let H=O.subarray(U);if(H.length>0)K.write(H),B(V,H)};return new ReadableStream({async pull(V){let O;try{O=await Q.read()}catch(T){throw G(),T}let{done:U,value:H}=O;if(U){F(V),V.close(),G();return}if(!z){if(z=!0,K.write(H),B(V,H),J.onShell?.(),K.isSafe())F(V);return}D(V,H)},cancel(V){return G(),Q.cancel(V)}})}var NF=/bot|crawler|spider|crawling|slurp|bingpreview|mediapartners|headless|lighthouse|prerender|facebookexternalhit|whatsapp|telegram|discord|twitterbot|linkedinbot/i;function Q6($){if(!$)return!1;return NF.test($)}async function Q5($,Z=()=>{}){let J=N.getStore(),W=J?.req??null,Y=null;if(W?.rawRequest?.url)try{Y=new URL(W.rawRequest.url).pathname}catch{Y=null}return{user:J?.user??null,attributes:await _F($,Z),request:{path:Y,routePath:W?.routePath??null,locale:J?.locale??null},anonymousId:G5(),isBot:Q6(W?.rawRequest?.headers?.get("user-agent")??null),now:new Date}}function K5($){return{user:$.user??null,attributes:$.attributes??{},request:{path:null,routePath:null,locale:null},anonymousId:$.subjectId??null,isBot:!1,now:new Date}}async function _F($,Z){if(!$.context)return{};try{let J=N.getStore();return await $.context(J?.req??null)??{}}catch(J){return Z(`The \`context\` hook in app/config/features.ts threw; evaluating with no attributes. ${J instanceof Error?J.message:String(J)}`),{}}}function F5($,Z){return`${$}:${Z}`}function g8($){let Z=new Bun.CryptoHasher("sha1").update($).digest("hex"),J=Number.parseInt(Z.slice(0,8),16);return Math.floor(J/4294967296*1e4)}function B5($,Z){if(Z>=100)return!0;if(Z<=0)return!1;return $<Math.round(Z*100)}function V5($,Z,J,W){if(W.unavailable)return{value:!1,reason:"unavailable"};if(W.active!==!0)return{value:!1,reason:"inactive"};if(Z.when){let j;try{j=Z.when(J)}catch(z){return W.warn?.(`The \`when\` for feature "${$}" threw; treating it as off. ${z instanceof Error?z.message:String(z)}`),{value:!1,reason:"error"}}if(typeof j==="boolean")return{value:j,reason:"attributed"}}if(Z.rollout===void 0)return{value:!0,reason:"on"};if(J.isBot)return{value:!1,reason:"bot"};let Y=CF($,Z,J,W.buckets);return B5(Y,Z.rollout)?{value:!0,reason:"rollout"}:{value:!1,reason:"excluded"}}function xF($){let Z=$.user?.publicId??$.user?.id;if(Z!==void 0&&Z!==null)return String(Z);return $.anonymousId??""}function CF($,Z,J,W){let Y=F5(Z.salt??$,xF(J));if(!W)return g8(Y);let j=W.get(Y);if(j!==void 0)return j;let z=g8(Y);return W.set(Y,z),z}class O5 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 m8{source;declared;ttlMs;warn;snapshot=null;inflight=null;lastFailureLoggedAt=0;generation=0;lastError=null;retryAfter=0;constructor($,Z,J,W=()=>{}){this.source=$;this.declared=Z;this.ttlMs=J;this.warn=W}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 O5(this.lastError);return Z}peek(){return this.snapshot}async load(){try{let $=await this.source.load(),{active:Z,audit:J}=this.readRows($);return this.snapshot={active:Z,audit:J,loadedAt:Date.now(),unavailable:!1},this.generation++,this.lastError=null,this.retryAfter=0,this.snapshot}catch($){return this.handleFailure($)}}readRows($){let Z=new Map,J=new Map;for(let W of $??[]){let Y=typeof W?.key==="string"?W.key:null;if(!Y){this.warn("Ignoring a feature row with no `key`.");continue}if(!(Y in this.declared)){this.warn(`Feature row "${Y}" is not declared in app/features, so it is ignored. Delete the row, or declare the feature.`);continue}Z.set(Y,W.active===!0);let j=SF(W);if(j)J.set(Y,j)}return{active:Z,audit:J}}handleFailure($){let Z=$ instanceof Error?$.message:String($),J=Date.now();if(this.lastError=$,this.retryAfter=J+this.ttlMs,J-this.lastFailureLoggedAt>=this.ttlMs)this.lastFailureLoggedAt=J,this.warn(`Could not load feature switches: ${Z}`);if(this.snapshot)return this.snapshot;return this.snapshot={active:new Map,audit:new Map,loadedAt:J,unavailable:!0},this.snapshot}}function SF($){let Z={},J=$.updatedBy;if(typeof J==="string")Z.updatedBy=J;else if(J===null)Z.updatedBy=null;let W=$.updatedAt;if(W instanceof Date||typeof W==="string"||typeof W==="number"){let Y=W instanceof Date?W:new Date(W);if(!Number.isNaN(Y.getTime()))Z.updatedAt=Y}return"updatedBy"in Z||"updatedAt"in Z?Z:null}class AF{}class EF 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 h8 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 D5 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 U5{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 s1{config;log;static token="features";store;declared;warnedAboutSize=!1;warnedAboutActor=!1;constructor($,Z=()=>{}){this.config=$;this.log=Z;this.declared=$.features??{},this.store=new m8($.source,this.declared,Math.max(0,$.ttl)*1000,this.log)}declarations(){return this.declared}async list(){let{active:$,audit:Z,unavailable:J}=await this.switches();return{unavailable:J,features:Object.entries(this.declared).map(([W,Y])=>({key:W,describe:Y.describe,rollout:Y.rollout,targeted:Y.when!==void 0,serverOnly:Y.serverOnly,salt:Y.salt,active:$.get(W),...Z.get(W)}))}}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,J={}){if(typeof $!=="string"||!Object.hasOwn(this.declared,$))throw new D5(String($));if(typeof Z!=="boolean")throw TypeError(`Features.set("${$}", \u2026) takes a boolean, not ${Z===null?"null":typeof Z}.`);let W=fF(J.actor),Y=this.config.source;if(typeof Y.write!=="function")throw new h8(Y.constructor?.name||"an anonymous source");let{actorRecorded:j}=await Y.write($,Z,{actor:W});if(W!==null&&!j&&!this.warnedAboutActor)this.warnedAboutActor=!0,this.log('Features.set() was given an actor, but the feature source has nowhere to record it. For the database source, add a nullable `updatedBy String?` column to the feature flag model to keep "last changed by".');await this.invalidate()}async enabled($){return(await this.explain($)).value}async explain($){let 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 U5(this,K5($))}async evaluateIn($,Z,J){let W=this.memoFor(Z),Y=W?.get($);if(Y)return Y;let j=this.declared[$];if(!j)return{value:!1,reason:"undeclared"};let{active:z,unavailable:X}=await this.switchFor($),G=V5($,j,Z,{active:z,unavailable:X,buckets:J,warn:this.log});return W?.set($,G),this.notify($,G,Z),G}async evaluateAllIn($,Z,J){let W={};for(let[Y,j]of Object.entries(this.declared)){if(J.clientOnly&&j.serverOnly)continue;W[Y]=(await this.evaluateIn(Y,$,Z)).value}return W}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 Q5(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,J){if(!this.config.onEvaluate)return;try{this.config.onEvaluate($,Z,J)}catch(W){this.log(`The \`onEvaluate\` hook in app/config/features.ts threw for "${$}". ${W instanceof Error?W.message:String(W)}`)}}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 fF($){if($===void 0||$===null)return null;if(typeof $==="string"){if($.length>0)return $}else if(typeof $==="object"){let{publicId:Z,id:J}=$;if(typeof Z==="string"&&Z.length>0)return Z;if(typeof J==="string"&&J.length>0||typeof J==="number")return String(J)}throw TypeError("Features.set() was given an `actor` that identifies nobody. Pass a string, or a user with a `publicId` or an `id`.")}async function L5($){if($===void 0)return!0;return await L(s1).enabled($)}async function GZ($,Z){if(typeof Z!=="string"||!Object.hasOwn($,Z))return null;let J=J5($[Z]);if(!J||!await L5(J.feature))return null;return J.provider}async function H5($){let Z=[];for(let J of Object.keys($))if(await GZ($,J))Z.push(J);return Z}function p8($){if($&&typeof $==="object")delete $.password;return $}function bF(){return new Proxy({},{get:($,Z)=>P5(Z)})}var I5=new WeakMap;function T5($){if($&&typeof $==="object"){for(let Z of Object.values($))T5(Z);Object.freeze($)}return $}var RF={select:{id:!0,publicId:!0,email:!0,name:!0,locale:!0,globalRole:!0,accounts:{select:{id:!0,publicId:!0,organizationRole:!0,organization:!0}}}},wF=T5({token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:RF});class c8{models;constructor($=bF()){this.models=$}run($){return this.models.User.asSystem($)}sessionSelect(){return wF}transaction($){return this.models.User.transaction($)}withLegacySessionLock($,Z){let J=this.models.User.$connection??x1(),W=L(C1).connection(J),Y=()=>this.transaction(async()=>{if(W.dialect==="postgres"){let X=`gemi:legacy-session:${$}`;await i0()`SELECT pg_advisory_xact_lock(hashtextextended(${X}, 0))`}return Z()});if(W.dialect!=="sqlite"||i0())return Y();let z=(I5.get(W)??Promise.resolve()).then(Y,Y);return I5.set(W,z.catch(()=>{})),z}async createUser($){let Z=await this.run(()=>this.models.User.create({data:$}));return p8(Z)}async updateUserPassword($){let Z=await this.run(()=>this.models.User.update({where:{id:$.id},data:{password:$.password}}));return p8(Z)}async findUserByEmailAddress($,Z){return await this.run(()=>this.models.User.findUnique({where:Z?{email:$,emailVerifiedAt:{not:null}}:{email:$}}))}async findUserByVerificationToken($){if(typeof $!=="string"||$==="")return null;return await this.run(()=>this.models.User.findFirst({where:{verificationToken:$}}))}async verifyUser($){return await this.run(()=>this.models.User.update({where:{email:$},data:{emailVerifiedAt:new Date}}))}async createSession($){return await this.run(()=>this.models.Session.create({data:$,include:{user:!0}}))}async createSessionV2($){return await this.run(()=>this.models.Session.create({data:$,select:this.sessionSelect()}))}async findSession($){if(!$.token)return null;try{return await this.run(()=>this.models.Session.findUnique({where:{token:$.token},select:this.sessionSelect()}))}catch(Z){return console.error("findSession failed:",Z),null}}async updateSession($){return await this.run(()=>this.models.Session.update({where:{token:$.token},data:{expiresAt:$.expiresAt},select:this.sessionSelect()}))}async deleteSession($){if(!$.token)return;await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}))}async claimLegacySession($){if(!$.token)return!1;let{count:Z}=await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}));return Z>0}async deleteAllUserSessions($){await this.run(()=>this.models.Session.deleteMany({where:{userId:$}}))}async createPasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.create({data:{token:$.token,user:{connect:{id:$.user.id}}}}))}async findPasswordResetToken($){if(typeof $.token!=="string"||$.token==="")return null;return await this.run(()=>this.models.PasswordResetToken.findUnique({where:{token:$.token},include:{user:!0}}))}async deletePasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.delete({where:{token:$.token}}))}async findInvitation($,Z){if(typeof $!=="string"||typeof Z!=="string")return null;return await this.run(()=>this.models.OrganizationInvitation.findFirst({where:{publicId:$,email:Z}}))}async deleteInvitationById($){await this.run(()=>this.models.OrganizationInvitation.delete({where:{publicId:$}}))}async createAccount($){return await this.run(()=>this.models.Account.create({data:{userId:$.userId,organizationId:$.organizationId,organizationRole:$.organizationRole}}))}async createMagicLinkToken($){return await this.run(()=>this.models.MagicLinkToken.create({data:{email:$.email,token:$.token,pin:$.pin}}))}async findUserMagicLinkToken($){let Z=(J)=>typeof J==="string"&&J!=="";if(!Z($.email))return null;if($.token!==void 0&&!Z($.token))return null;if($.token===void 0&&!Z($.pin))return null;return await this.run(()=>$.token?this.models.MagicLinkToken.findUnique({where:{token_email:{token:$.token,email:$.email}}}):this.models.MagicLinkToken.findUnique({where:{pin_email:{pin:$.pin,email:$.email}}}))}async findMagicLinkTokenByEmail($){return await this.run(()=>this.models.MagicLinkToken.findFirst({where:{email:$},orderBy:{id:"desc"}}))}async claimMagicLinkToken($){let{count:Z}=await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{id:$}}));return Z===1}async deleteMagicLinkToken($){await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{email:$}}))}async createSocialAccount($){return await this.run(()=>this.models.SocialAccount.create({data:$}))}async findUserBySocialAccount($,Z){if(!Z)return null;let J=await this.run(()=>this.models.SocialAccount.findFirst({where:{provider:$,providerId:Z},include:{user:!0}}));return J?p8(J.user):null}async findSocialAccounts($,Z){return await this.run(()=>this.models.SocialAccount.findMany({where:{userId:$,provider:Z},orderBy:{id:"asc"}}))}async claimSocialAccount($,Z){let{count:J}=await this.run(()=>this.models.SocialAccount.updateMany({where:{id:$.id,providerId:$.providerId},data:{providerId:Z}}));return J===1}}import{randomBytes as vO}from"crypto";function w0($,Z,J,W,Y){return s0(Z,v5($,Z),J,W,Y)}function s0($,Z,J,W,Y,j){let z=s8(Z,J,W);if(Y&&Z!==z)throw RangeError(Pz($,Z,J,W,j));return z}function v5($,Z){let J=$[Z];if(J===void 0)throw TypeError(M2(Z));return J}function O0($){return $!==null&&/object|function/.test(typeof $)}function y0($,Z=Map){let J=new Z;return(W,...Y)=>{if(J.has(W))return J.get(W);let j=$(W,...Y);return J.set(W,j),j}}function ZJ($){return N$({name:$},1)}function N$($,Z){return r0((J)=>({value:J,configurable:1,writable:!Z}),$)}function g5($){return r0((Z)=>({get:Z,configurable:1}),$)}function x6($){return{[Symbol.toStringTag]:{value:$,configurable:1}}}function DZ($,Z){let J={},W=$.length;for(let Y of Z)J[$[--W]]=Y;return J}function r0($,Z,J){let W={};for(let Y in Z)W[Y]=$(Z[Y],Y,J);return W}function Q3($,Z,J){let W={};for(let Y=0;Y<Z.length;Y++){let j=Z[Y];W[j]=$(j,Y,J)}return W}function kF($,Z,J){let W={};for(let Y=0;Y<$.length;Y++)W[Z[Y]]=J[$[Y]];return W}function g0($,Z){let J={};for(let W of $)J[W]=Z[W];return J}function JJ($,Z){let J={};for(let W in Z)$.has(W)||(J[W]=Z[W]);return J}function WJ($){$={...$};let Z=Object.keys($);for(let J of Z)$[J]===void 0&&delete $[J];return $}function m5($,Z){for(let J of Z)if(!(J in $))return 0;return 1}function h5($,Z,J){for(let W of $)if(Z[W]!==J[W])return 0;return 1}function p5($,Z,J){let W={...J};for(let Y=0;Y<Z;Y++)W[$[Y]]=0;return W}function R($,...Z){return(...J)=>$(...Z,...J)}function M5($){return $[0].toUpperCase()+$.substring(1)}function K3($){return $.slice().sort()}function U6($,Z){return String(Z).padStart($,"0")}function n1($,Z){return Math.sign($-Z)}function s8($,Z,J){return Math.min(Math.max($,Z),J)}function A1($,Z){return[Math.floor($/Z),J3($,Z)]}function J3($,Z){return($%Z+Z)%Z}function r1($,Z){return[C6($,Z),YJ($,Z)]}function C6($,Z){return Math.trunc($/Z)||0}function YJ($,Z){return $%Z||0}function K6($){return Math.abs($%1)===0.5}function c5($,Z,J){let W=0,Y=0;for(let X=0;X<=Z;X++){let G=$[J[X]],Q=G1[X],K=c/Q,[B,F]=r1(G,K);W+=F*Q,Y+=B}let[j,z]=r1(W,c);return[Y+j,z]}function S6($,Z,J){let W={};for(let Y=Z;Y>=0;Y--){let j=G1[Y];W[J[Y]]=C6($,j),$=YJ($,j)}return W}function d5($){return $===w?X4:[]}function u5($){return $===w?P3:[]}function l5($){return $===w?["year","day"]:[]}function i5($){if($!==void 0)return e($)}function s5($){if($!==void 0)return t0($)}function jJ($){if($!==void 0)return F3($)}function t0($){return a5(F3($))}function F3($){return o5(xB($))}function zJ($){if($==null)throw TypeError("Cannot be null or undefined");return $}function n5($,Z){if(Z==null)throw RangeError(M2($));return Z}function f1($){if(!O0($))throw TypeError(Iz);return $}function A6($,Z,J=$){if(typeof Z!==$)throw TypeError(L3(J,Z));return Z}function o5($,Z="number"){if(!Number.isInteger($))throw RangeError(aF(Z,$));return $||0}function a5($,Z="number"){if($<=0)throw RangeError(rF(Z,$));return $}function XJ($){if(typeof $=="symbol")throw TypeError(ZB);return String($)}function L6($,Z){return O0($)?String($):e($,Z)}function E6($){if(typeof $=="string")return BigInt($);if(typeof $!="bigint")throw TypeError($B($));return $}function r5($,Z="number"){if(typeof $=="bigint")throw TypeError(eF(Z));if($=Number($),!Number.isFinite($))throw RangeError(tF(Z,$));return $}function _0($,Z){return Math.trunc(r5($,Z))||0}function t5($,Z){return o5(r5($,Z),Z)}function N5($,Z){return a5(_0($,Z),Z)}function GJ($,Z){let[J,W]=r1(Z,c),Y=$+J,j=Math.sign(Y);return j&&j===-Math.sign(W)&&(Y-=j,W+=j*c),[Y,W]}function KZ($,Z,J=1){return GJ($[0]+Z[0]*J,$[1]+Z[1]*J)}function FZ($,Z){return GJ($[0],$[1]+Z)}function c0($,Z){return KZ(Z,$,-1)}function C0($,Z){return n1($[0],Z[0])||n1($[1],Z[1])}function e5($,Z,J){return C0($,Z)===-1||C0($,J)===1}function f6($,Z=1){let J=BigInt(c/Z);return[Number($/J),Number($%J)*Z]}function BZ($,Z=1){let J=c/Z,[W,Y]=r1($,J);return[W,Y*Z]}function $Y($,Z=1){let[J,W]=$,Y=Math.floor(W/Z),j=c/Z;return BigInt(J)*BigInt(j)+BigInt(Y)}function d0($,Z=1,J){let[W,Y]=$,[j,z]=r1(Y,Z);return W*(c/Z)+(j+(J?z/Z:0))}function QJ($,Z,J=A1){let[W,Y]=$,[j,z]=J(Y,Z);return[W*(c/Z)+j,z]}function KJ($,Z){let J=$.formatToParts(Z),W={};for(let Y of J)W[Y.type]=Y.value;return W}function FJ($){return w0($,"isoYear",G3,X3,1),$.isoYear===G3?w0($,"isoMonth",4,12,1):$.isoYear===X3&&w0($,"isoMonth",1,9,1),$}function o1($){return b1({...$,...a0,isoHour:12}),$}function b1($){let Z=w0($,"isoYear",G3,X3,1),J=Z===G3?1:Z===X3?-1:0;return J&&u0(x0({...$,isoDay:$.isoDay+J,isoNanosecond:$.isoNanosecond-J})),$}function u0($){if(!$||e5($,RB,bB))throw RangeError(W4);return $}function t1($){return c5($,5,J1)[1]}function b6($){let[Z,J]=A1($,c);return[S6(J,5,J1),Z]}function ZY($){return JY($)[0]}function JY($){return QJ($,o0)}function S0($){return UZ($.isoYear,$.isoMonth,$.isoDay,$.isoHour,$.isoMinute,$.isoSecond,$.isoMillisecond)}function x0($){let Z=S0($);if(Z!==void 0){let[J,W]=r1(Z,q0);return[J,W*Q1+($.isoMicrosecond||0)*R$+($.isoNanosecond||0)]}}function BJ($,Z){let[J,W]=b6(t1($)-Z);return u0(x0({...$,isoDay:$.isoDay+W,...J}))}function H6(...$){return UZ(...$)/bz}function UZ(...$){let[Z,J]=WY(...$),W=Z.valueOf();if(!isNaN(W))return W-J*q0}function WY($,Z=1,J=1,W=0,Y=0,j=0,z=0){let X=$===G3?1:$===X3?-1:0,G=new Date;return G.setUTCHours(W,Y,j,z),G.setUTCFullYear($,Z-1,J+X),[G,X]}function $$($,Z){let[J,W]=FZ($,Z);W<0&&(W+=c,J-=1);let[Y,j]=A1(W,Q1),[z,X]=A1(j,R$);return R6(J*q0+Y,z,X)}function R6($,Z=0,J=0){let W=Math.ceil(Math.max(0,Math.abs($)-fB)/q0)*Math.sign($),Y=new Date($-W*q0);return DZ(Q4,[Y.getUTCFullYear(),Y.getUTCMonth()+1,Y.getUTCDate()+W,Y.getUTCHours(),Y.getUTCMinutes(),Y.getUTCSeconds(),Y.getUTCMilliseconds(),Z,J])}function YY($){return[$.isoYear,$.isoMonth,$.isoDay]}function jY(){return S1}function VJ($,Z){switch(Z){case 2:return OJ($)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function zY($){return OJ($)?366:365}function OJ($){return $%4==0&&($%100!=0||$%400==0)}function XY($){let[Z,J]=WY($.isoYear,$.isoMonth,$.isoDay);return J3(Z.getUTCDay()-J,7)||7}function GY({isoYear:$}){return $<1?["bce",1-$]:["ce",$]}function qF($){let Z=S0($);if(Z<kB)return GY($);let J=KJ(h2(VZ),Z),{era:W,eraYear:Y}=Ij(J,VZ);return[W,Y]}function w6($){return _$($),k6($,1),$}function _$($){return QY($,1),$}function _5($){return h5(R2,$,QY($))}function QY($,Z){let{isoYear:J}=$,W=w0($,"isoMonth",1,jY(),Z);return{isoYear:J,isoMonth:W,isoDay:w0($,"isoDay",1,VJ(J,W),Z)}}function k6($,Z){return DZ(J1,[w0($,"isoHour",0,23,Z),w0($,"isoMinute",0,59,Z),w0($,"isoSecond",0,59,Z),w0($,"isoMillisecond",0,999,Z),w0($,"isoMicrosecond",0,999,Z),w0($,"isoNanosecond",0,999,Z)])}function y($){return $===void 0?0:nz(f1($))}function B3($,Z=0){$=e0($);let J=oz($),W=uB($,Z);return[nz($),W,J]}function DJ($){return oz(e0($))}function KY($){return $=e0($),q2($,9,6,1)}function LZ($,Z,J,W=9,Y=0,j=4){Z=e0(Z);let z=q2(Z,W,Y),X=HJ(Z),G=M3(Z,j),Q=T3(Z,W,Y,1);return z==null?z=Math.max(J,Q):OY(z,Q),X=IJ(X,Q,1),$&&(G=((K)=>K<4?(K+2)%4:K)(G)),[z,Q,X,G]}function q6($,Z=6,J){let W=HJ($=PJ($,_6)),Y=M3($,7),j=T3($,Z);return j=n5(_6,j),W=IJ(W,j,void 0,J),[j,W,Y]}function UJ($){return y2(e0($))}function FY($,Z){return LJ(e0($),Z)}function LJ($,Z=4){let J=VY($);return[M3($,4),...BY(T3($,Z),J)]}function BY($,Z){return $!=null?[G1[$],$<4?9-3*$:-1]:[Z===void 0?1:10**(9-Z),Z]}function HJ($){let Z=$[W3];return Z===void 0?1:_0(Z,W3)}function IJ($,Z,J,W){let Y=W?c:G1[Z+1];if(Y){let j=G1[Z];if(Y%(($=s0(W3,$,1,Y/j-(W?0:1),1))*j))throw RangeError(L3(W3,$))}else $=s0(W3,$,1,J?1e9:1,1);return $}function VY($){let Z=$[i8];if(Z!==void 0){if(typeof Z!="number"){if(XJ(Z)==="auto")return;throw RangeError(L3(i8,Z))}Z=s0(i8,Math.floor(Z),0,9,1)}return Z}function e0($){return $===void 0?{}:f1($)}function PJ($,Z){return typeof $=="string"?{[Z]:$}:f1($)}function z0($){if($!==void 0){if(O0($))return Object.assign(Object.create(null),$);throw TypeError(Iz)}}function y6($,Z){return $&&Object.assign(Object.create(null),$,{overflow:yB[Z]})}function TJ($,Z,J=9,W=0,Y){let j=Z[$];if(j===void 0)return Y?W:void 0;if(j=XJ(j),j==="auto")return Y?W:null;let z=r8[j];if(z===void 0&&(z=AB[j]),z===void 0)throw RangeError(Nz($,j,r8));return s0($,z,W,J,1,I3),z}function x$($,Z,J,W=0){let Y=J[$];if(Y===void 0)return W;let j=XJ(Y),z=Z[j];if(z===void 0)throw RangeError(Nz($,j,Z));return z}function OY($,Z){if(Z>$)throw RangeError(PB)}function D0($){return{branding:F4,epochNanoseconds:$}}function I0($,Z,J){return{branding:q1,calendar:J,timeZone:Z,epochNanoseconds:$}}function X0($,Z=$.calendar){return{branding:k$,calendar:Z,...g0(uz,$)}}function G0($,Z=$.calendar){return{branding:w$,calendar:Z,...g0(w2,$)}}function T$($,Z=$.calendar){return{branding:xZ,calendar:Z,...g0(w2,$)}}function I6($,Z=$.calendar){return{branding:CZ,calendar:Z,...g0(w2,$)}}function $1($){return{branding:K4,...g0(dz,$)}}function n($){return{branding:B4,sign:Z$($),...g0(E2,$)}}function DY($){return ZY($.epochNanoseconds)}function v6($){return QJ($.epochNanoseconds,Q1)[0]}function UY($){return $Y($.epochNanoseconds,R$)}function LY($){return $Y($.epochNanoseconds)}function HY($){return $.epochNanoseconds}function L0($){return typeof $=="string"?$:e($.id)}function HZ($,Z){return $===Z||L0($)===L0(Z)}function IY($,Z,J,W,Y){let j=M$(W),[z,X]=((U,H)=>{let T=H((U=PJ(U,$J))[iz]),I=dB(U);return I=n5($J,I),[I,T]})(Y,$);if(j3(Math.max(z,j),X))return x5(W,z);if(!X)throw RangeError(Y4);let[G,Q,K]=d6(Z,J,X),B=lJ(K),F=u6(K),D=iJ(K),V=F(Q,G,W),O=D(Q,G,V,z);return j3(z,X)?x5(O,z):((U,H,T,I,x,A,f)=>{let S=Z$(U),[M,P]=MJ(I,b2(T,U),T,S,x,A,f),k=NJ(H,M,P);return U[g[T]]+k*S})(O,B(V),z,Q,G,B,F)}function x5($,Z){return d0(V0($),G1[Z],1)}function MJ($,Z,J,W,Y,j,z){let X=g[J],G={...Z,[X]:Z[X]+W},Q=z($,Y,Z),K=z($,Y,G);return[j(Q),j(K)]}function NJ($,Z,J){let W=d0(c0(Z,J));if(!W)throw RangeError(H3);return d0(c0(Z,$))/W}function PY($,Z){let[J,W,Y]=q6(Z,5,1);return D0(m6($.epochNanoseconds,J,W,Y,1))}function TY($,Z,J){let{epochNanoseconds:W,timeZone:Y,calendar:j}=Z,[z,X,G]=q6(J);if(z===0&&X===1)return Z;let Q=$(Y);if(z===6)W=((K,B,F,D)=>{let V=A0(F,B),[O,U]=K(V),H=F.epochNanoseconds,T=v0(B,O),I=v0(B,U);if(e5(H,T,I))throw RangeError(H3);return fY(NJ(H,T,I),D)?I:T})(AY,Q,Z,G);else{let K=Q.getOffsetNanosecondsFor(W);W=S$(Q,CY($$(W,K),z,X,G),K,2,0,1)}return I0(W,Y,j)}function MY($,Z){return X0(CY($,...q6(Z)),$.calendar)}function NY($,Z){let[J,W,Y]=q6(Z,5);var j;return $1((j=Y,_J($,V3(J,W),j)[0]))}function _Y($,Z){let J=$(Z.timeZone),W=A0(Z,J),[Y,j]=AY(W),z=d0(c0(v0(J,Y),v0(J,j)),z4,1);if(z<=0)throw RangeError(H3);return z}function xY($,Z){let{timeZone:J,calendar:W}=Z,Y=((j,z,X)=>v0(z,j(A0(X,z))))(EY,$(J),Z);return I0(Y,J,W)}function CY($,Z,J,W){return SY($,V3(Z,J),W)}function SY($,Z,J){let[W,Y]=_J($,Z,J);return b1({...A$($,Y),...W})}function _J($,Z,J){return b6(e1(t1($),Z,J))}function P6($){return e1($,j4,7)}function V3($,Z){return G1[$]*Z}function AY($){let Z=EY($);return[Z,A$(Z,1)]}function EY($){return EB(6,$)}function yF($,Z,J){let W=Math.min(M$($),6);return PZ(h6(V0($,W),Z,J),W)}function g6($,Z,J,W,Y,j,z,X,G,Q){if(W===0&&Y===1)return $;let K=j3(W,X)?l6(X)&&W<6&&J>=6?gF:vF:mF,[B,F,D]=K($,Z,J,W,Y,j,z,X,G,Q);return D&&W!==7&&(B=((V,O,U,H,T,I,x,A)=>{let f=Z$(V);for(let S=H+1;S<=U;S++){if(S===7&&U!==7)continue;let M=b2(S,V);M[g[S]]+=f;let P=d0(c0(x(A(T,I,M)),O));if(P&&Math.sign(P)!==f)break;V=M}return V})(B,F,J,Math.max(6,W),z,X,G,Q)),B}function m6($,Z,J,W,Y){if(Z===6){let j=((z)=>z[0]+z[1]/c)($);return[e1(j,J,W),0]}return h6($,V3(Z,J),W,Y)}function h6($,Z,J,W){let[Y,j]=$;W&&j<0&&(j+=c,Y-=1);let[z,X]=A1(e1(j,Z,J),c);return GJ(Y+z,X)}function e1($,Z,J){return fY($/Z,J)*Z}function fY($,Z){return sB[Z]($)}function vF($,Z,J,W,Y,j){let z=Z$($),X=V0($),G=m6(X,W,Y,j),Q=c0(X,G),K=Math.sign(G[0]-X[0])===z,B=PZ(G,Math.min(J,6));return[{...$,...B},KZ(Z,Q),K]}function gF($,Z,J,W,Y,j,z,X,G,Q){let K=Z$($),B=d0(V0($,5)),F=V3(W,Y),D=e1(B,F,j),[V,O]=MJ(z,{...$,...f2},6,K,X,G,Q),U=D-d0(c0(V,O)),H=0;U&&Math.sign(U)!==K?Z=FZ(V,D):(H+=K,D=e1(U,F,j),Z=FZ(O,D));let T=s6(D);return[{...$,...T,days:$.days+H},Z,Boolean(H)]}function mF($,Z,J,W,Y,j,z,X,G,Q){let K=Z$($),B=g[W],F=b2(W,$);W===7&&($={...$,weeks:$.weeks+Math.trunc($.days/7)});let D=C6($[B],Y)*Y;F[B]=D;let[V,O]=MJ(z,F,W,Y*K,X,G,Q),U=D+NJ(Z,V,O)*K*Y,H=e1(U,Y,j),T=Math.sign(H-U)===K;return F[B]=H,[F,T?O:V,T]}function xJ($,Z,J,W){let[Y,j,z,X]=((Q)=>{let K=LJ(Q=e0(Q));return[Q.timeZone,...K]})(W),G=Y!==void 0;return((Q,K,B,F,D,V)=>{B=h6(B,D,F,1);let O=K.getOffsetNanosecondsFor(B);return RJ($$(B,O),V)+(Q?C$(P6(O)):"Z")})(G,Z(G?$(Y):q$),J.epochNanoseconds,j,z,X)}function CJ($,Z,J){let[W,Y,j,z,X,G]=((Q)=>{Q=e0(Q);let K=y2(Q),B=VY(Q),F=iB(Q),D=M3(Q,4),V=T3(Q,4);return[K,lB(Q),F,D,...BY(V,B)]})(J);return((Q,K,B,F,D,V,O,U,H,T)=>{F=h6(F,H,U,1);let I=Q(B).getOffsetNanosecondsFor(F);return RJ($$(F,I),T)+C$(P6(I),O)+((x,A)=>A!==1?"["+(A===2?"!":"")+L0(x)+"]":"")(B,V)+wJ(K,D)})($,Z.calendar,Z.timeZone,Z.epochNanoseconds,W,Y,j,z,X,G)}function SJ($,Z){let[J,W,Y,j]=((Q)=>(Q=e0(Q),[y2(Q),...LJ(Q)]))(Z);return z=$.calendar,X=J,G=j,RJ(SY($,Y,W),G)+wJ(z,X);var z,X,G}function AJ($,Z){return J=$.calendar,W=$,Y=UJ(Z),T6(W)+wJ(J,Y);var J,W,Y}function EJ($,Z){return bY($.calendar,RY,$,UJ(Z))}function fJ($,Z){return bY($.calendar,hF,$,UJ(Z))}function bJ($,Z){let[J,W,Y]=FY(Z);return j=Y,wY(_J($,W,J)[0],j);var j}function p6($,Z){let[J,W,Y]=FY(Z,3);return W>1&&($={...$,...yF($,W,J)}),((j,z)=>{let{sign:X}=j,G=X===-1?E0(j):j,{hours:Q,minutes:K}=G,[B,F]=QJ(V0(G,3),o0,r1);pY(B);let D=kJ(F,z),V=z>=0||!X||D;return(X<0?"-":"")+"P"+C5({Y:P$(G.years),M:P$(G.months),W:P$(G.weeks),D:P$(G.days)})+(Q||K||B||V?"T"+C5({H:P$(Q),M:P$(K),S:P$(B,V)+D}):"")})($,Y)}function bY($,Z,J,W){let Y=L0($),j=W>1||W===0&&Y!==w;return W===1?Y===w?Z(J):T6(J):j?T6(J)+kY(Y,W===2):Z(J)}function C5($){let Z=[];for(let J in $){let W=$[J];W&&Z.push(W,J)}return Z.join("")}function RJ($,Z){return T6($)+"T"+wY($,Z)}function T6($){return RY($)+"-"+n0($.isoDay)}function RY($){let{isoYear:Z}=$;return(Z<0||Z>9999?qY(Z)+U6(6,Math.abs(Z)):U6(4,Z))+"-"+n0($.isoMonth)}function hF($){return n0($.isoMonth)+"-"+n0($.isoDay)}function wY($,Z){let J=[n0($.isoHour),n0($.isoMinute)];return Z!==-1&&J.push(n0($.isoSecond)+((W,Y,j,z)=>kJ(W*Q1+Y*R$+j,z))($.isoMillisecond,$.isoMicrosecond,$.isoNanosecond,Z)),J.join(":")}function C$($,Z=0){if(Z===1)return"";let[J,W]=A1(Math.abs($),z4),[Y,j]=A1(W,j4),[z,X]=A1(j,o0);return qY($)+n0(J)+":"+n0(Y)+(z||X?":"+n0(z)+kJ(X):"")}function wJ($,Z){if(Z!==1){let J=L0($);if(Z>1||Z===0&&J!==w)return kY(J,Z===2)}return""}function kY($,Z){return"["+(Z?"!":"")+"u-ca="+$+"]"}function kJ($,Z){let J=U6(9,$);return J=Z===void 0?J.replace(aB,""):J.slice(0,Z),J?"."+J:""}function qY($){return $<0?"-":"+"}function P$($,Z){return $||Z?$.toLocaleString("fullwide",{useGrouping:0}):""}function pF($,Z){let{epochNanoseconds:J}=$,W=(Z.getOffsetNanosecondsFor?Z:Z($.timeZone)).getOffsetNanosecondsFor(J),Y=$$(J,W);return{calendar:$.calendar,...Y,offsetNanoseconds:W}}function yY($,Z){let J=A0(Z,$);return{calendar:Z.calendar,...g0(uz,J),offset:C$(J.offsetNanoseconds),timeZone:Z.timeZone}}function S$($,Z,J,W=0,Y=0,j,z){if(J!==void 0&&W===1&&(W===1||z))return BJ(Z,J);let X=$.getPossibleInstantsFor(Z);if(J!==void 0&&W!==3){let G=((Q,K,B,F)=>{let D=x0(K);F&&(B=P6(B));for(let V of Q){let O=d0(c0(V,D));if(F&&(O=P6(O)),O===B)return V}})(X,Z,J,j);if(G!==void 0)return G;if(W===0)throw RangeError(OB)}return z?x0(Z):v0($,Z,Y,X)}function v0($,Z,J=0,W=$.getPossibleInstantsFor(Z)){if(W.length===1)return W[0];if(J===1)throw RangeError(DB);if(W.length)return W[J===3?1:0];let Y=x0(Z),j=((X,G)=>{let Q=X.getOffsetNanosecondsFor(FZ(G,-c));return yJ(X.getOffsetNanosecondsFor(FZ(G,c))-Q)})($,Y),z=j*(J===2?-1:1);return(W=$.getPossibleInstantsFor($$(Y,z)))[J===2?0:W.length-1]}function qJ($){if(Math.abs($)>=c)throw RangeError(BB);return $}function yJ($){if($>c)throw RangeError(VB);return $}function vJ($,Z,J){return D0(u0(KZ(Z.epochNanoseconds,((W)=>{if(cY(W))throw RangeError(HB);return V0(W,5)})($?E0(J):J))))}function gJ($,Z,J,W,Y,j=Object.create(null)){let z=Z(W.timeZone),X=$(W.calendar);return{...W,...dJ(z,X,W,J?E0(Y):Y,j)}}function mJ($,Z,J,W,Y=Object.create(null)){let{calendar:j}=J;return X0(uJ($(j),J,Z?E0(W):W,Y),j)}function hJ($,Z,J,W,Y){let{calendar:j}=J;return G0(c6($(j),J,Z?E0(W):W,Y),j)}function pJ($,Z,J,W,Y=Object.create(null)){let j=J.calendar,z=$(j),X=Y3(z,J);Z&&(W=i6(W)),W.sign<0&&(X=z.dateAdd(X,{...H0,months:1}),X=A$(X,-1));let G=z.dateAdd(X,W,Y);return T$(Y3(z,G),j)}function cJ($,Z,J){return $1(vY(Z,$?E0(J):J)[0])}function dJ($,Z,J,W,Y){let j=V0(W,5),z=J.epochNanoseconds;if(cY(W)){let X=A0(J,$);z=KZ(v0($,{...c6(Z,X,{...W,...f2},Y),...g0(J1,X)}),j)}else z=KZ(z,j),y(Y);return{epochNanoseconds:u0(z)}}function uJ($,Z,J,W){let[Y,j]=vY(Z,J);return b1({...c6($,Z,{...J,...f2,days:J.days+j},W),...Y})}function c6($,Z,J,W){if(J.years||J.months||J.weeks)return $.dateAdd(Z,J,W);y(W);let Y=J.days+V0(J,5)[0];return Y?o1(A$(Z,Y)):Z}function Y3($,Z,J=1){return A$(Z,J-$.day(Z))}function vY($,Z){let[J,W]=V0(Z,5),[Y,j]=b6(t1($)+W);return[Y,J+j]}function A$($,Z){return Z?{...$,...R6(S0($)+Z*q0)}:$}function d6($,Z,J){let W=$(J.calendar);return l6(J)?[J,W,Z(J.timeZone)]:[{...J,...a0},W]}function lJ($){return $?HY:x0}function u6($){return $?R(dJ,$):uJ}function iJ($){return $?R(dF,$):uF}function l6($){return $&&$.epochNanoseconds}function j3($,Z){return $<=6-(l6(Z)?1:0)}function sJ($,Z,J,W,Y,j,z){let X=$(e0(z).relativeTo),G=Math.max(M$(Y),M$(j));if(j3(G,X))return n(IZ(((O,U,H,T)=>{let I=KZ(V0(O),V0(U),T?-1:1);if(!Number.isFinite(I[0]))throw RangeError(W4);return{...H0,...PZ(I,H)}})(Y,j,G,W)));if(!X)throw RangeError(Y4);W&&(j=E0(j));let[Q,K,B]=d6(Z,J,X),F=u6(B),D=iJ(B),V=F(K,Q,Y);return n(D(K,Q,F(K,V,j),G))}function gY($,Z,J,W,Y){let j=M$(W),[z,X,G,Q,K]=((f,S,M)=>{f=PJ(f,_6);let P=q2(f),k=M(f[iz]),m=HJ(f),h1=M3(f,7),J0=T3(f);if(P===void 0&&J0===void 0)throw RangeError(IB);return J0==null&&(J0=0),P==null&&(P=Math.max(J0,S)),OY(P,J0),m=IJ(m,J0,1),[P,J0,m,h1,k]})(Y,j,$),B=Math.max(j,z);if(!l6(K)&&B<=6)return n(IZ(((f,S,M,P,k)=>{let m=m6(V0(f),M,P,k);return{...H0,...PZ(m,S)}})(W,z,X,G,Q)));if(!K)throw RangeError(Y4);let[F,D,V]=d6(Z,J,K),O=lJ(V),U=u6(V),H=iJ(V),T=U(D,F,W),I=H(D,F,T,z),x=W.sign,A=Z$(I);if(x&&A&&x!==A)throw RangeError(H3);return A&&(I=g6(I,O(T),z,X,G,Q,D,F,O,U)),n(I)}function mY($){return $.sign===-1?i6($):$}function i6($){return n(E0($))}function E0($){let Z={};for(let J of g)Z[J]=-1*$[J]||0;return Z}function hY($){return!$.sign}function Z$($,Z=g){let J=0;for(let W of Z){let Y=Math.sign($[W]);if(Y){if(J&&J!==Y)throw RangeError(LB);J=Y}}return J}function IZ($){for(let Z of SB)s0(Z,$[Z],-w5,w5,1);return pY(d0(V0($),o0)),$}function pY($){if(!Number.isSafeInteger($))throw RangeError(UB)}function V0($,Z=6){return c5($,Z,g)}function PZ($,Z=6){let[J,W]=$,Y=S6(W,Z,g);if(Y[g[Z]]+=J*(c/G1[Z]),!Number.isFinite(Y[g[Z]]))throw RangeError(W4);return Y}function s6($,Z=5){return S6($,Z,g)}function cY($){return Boolean(Z$($,cz))}function M$($){let Z=9;for(;Z>0&&!$[g[Z]];Z--);return Z}function cF($,Z){return[$,Z]}function S5($){let Z=Math.floor($/O6)*O6;return[Z,Z+O6]}function dY($){let Z=J$($=L6($));if(!Z)throw RangeError(k0($));let J;if(Z.m)J=0;else{if(!Z.offset)throw RangeError(k0($));J=TZ(Z.offset)}return Z.timeZone&&rJ(Z.timeZone,1),D0(BJ(w6(Z),J))}function uY($){let Z=J$(e($));if(!Z)throw RangeError(k0($));if(Z.timeZone)return eY(Z,Z.offset?TZ(Z.offset):void 0);if(Z.m)throw RangeError(k0($));return Zj(Z)}function lY($,Z){let J=J$(e($));if(!J||!J.timeZone)throw RangeError(k0($));let{offset:W}=J,Y=W?TZ(W):void 0,[,j,z]=B3(Z);return eY(J,Y,j,z)}function TZ($){let Z=rJ($);if(Z===void 0)throw RangeError(k0($));return Z}function iY($){let Z=J$(e($));if(!Z||Z.m)throw RangeError(k0($));return X0($j(Z))}function n6($){let Z=J$(e($));if(!Z||Z.m)throw RangeError(k0($));return G0(Z.p?$j(Z):Zj(Z))}function sY($,Z){let J=oJ(e(Z));if(J)return nJ(J),T$(FJ(_$(J)));let W=n6(Z);return T$(Y3($(W.calendar),W))}function nJ($){if($.calendar!==w)throw RangeError(E1($.calendar))}function nY($,Z){let J=aJ(e(Z));if(J)return nJ(J),I6(_$(J));let W=n6(Z),{calendar:Y}=W,j=$(Y),[z,X,G]=j.h(W),[Q,K]=j.I(z,X),[B,F]=j.N(Q,K,G);return I6(o1(j.P(B,F,G)),Y)}function oY($){let Z,J=((W)=>{let Y=ZV.exec(W);return Y?(o6(Y[10]),Yj(Y)):void 0})(e($));if(!J){if(J=J$($),!J)throw RangeError(k0($));if(!J.p)throw RangeError(k0($));if(J.m)throw RangeError(E1("Z"));nJ(J)}if((Z=oJ($))&&_5(Z))throw RangeError(k0($));if((Z=aJ($))&&_5(Z))throw RangeError(k0($));return $1(k6(J,1))}function aY($){let Z=((J)=>{let W=YV.exec(J);return W?((Y)=>{function j(K,B,F){let D=0,V=0;if(F&&([D,G]=A1(G,G1[F])),K!==void 0){if(X)throw RangeError(E1(K));V=((O)=>{let U=parseInt(O);if(!Number.isFinite(U))throw RangeError(E1(O));return U})(K),z=1,B&&(G=tJ(B)*(G1[F]/o0),X=1)}return D+V}let z=0,X=0,G=0,Q={...DZ(g,[j(Y[2]),j(Y[3]),j(Y[4]),j(Y[5]),j(Y[6],Y[7],5),j(Y[8],Y[9],4),j(Y[10],Y[11],3)]),...S6(G,2,g)};if(!z)throw RangeError(Tz(g));return eJ(Y[1])<0&&(Q=E0(Q)),Q})(W):void 0})(e($));if(!Z)throw RangeError(k0($));return n(IZ(Z))}function rY($){let Z=J$($)||oJ($)||aJ($);return Z?Z.calendar:$}function tY($){let Z=J$($);return Z&&(Z.timeZone||Z.m&&q$||Z.offset)||$}function eY($,Z,J=0,W=0){let Y=a6($.timeZone),j=V4(Y);return I0(S$(j,w6($),Z,J,W,!j.v,$.m),Y,O3($.calendar))}function $j($){return Jj(b1(w6($)))}function Zj($){return Jj(o1(_$($)))}function Jj($){return{...$,calendar:O3($.calendar)}}function J$($){let Z=$V.exec($);return Z?((J)=>{let W=J[10],Y=(W||"").toUpperCase()==="Z";return{isoYear:Wj(J),isoMonth:parseInt(J[4]),isoDay:parseInt(J[5]),...Yj(J.slice(5)),...o6(J[16]),p:Boolean(J[6]),m:Y,offset:Y?void 0:W}})(Z):void 0}function oJ($){let Z=tB.exec($);return Z?((J)=>({isoYear:Wj(J),isoMonth:parseInt(J[4]),isoDay:1,...o6(J[5])}))(Z):void 0}function aJ($){let Z=eB.exec($);return Z?((J)=>({isoYear:OZ,isoMonth:parseInt(J[1]),isoDay:parseInt(J[2]),...o6(J[3])}))(Z):void 0}function rJ($,Z){let J=JV.exec($);return J?((W,Y)=>{let j=W[4]||W[5];if(Y&&j)throw RangeError(E1(j));return qJ((QZ(W[2])*z4+QZ(W[3])*j4+QZ(W[4])*o0+tJ(W[5]||""))*eJ(W[1]))})(J,Z):void 0}function Wj($){let Z=eJ($[1]),J=parseInt($[2]||$[3]);if(Z<0&&!J)throw RangeError(E1(-0));return Z*J}function Yj($){let Z=QZ($[3]);return{...b6(tJ($[4]||""))[0],isoHour:QZ($[1]),isoMinute:QZ($[2]),isoSecond:Z===60?59:Z}}function o6($){let Z,J,W=[];if($.replace(WV,(Y,j,z)=>{let X=Boolean(j),[G,Q]=z.split("=").reverse();if(Q){if(Q==="u-ca")W.push(G),Z||(Z=X);else if(X||/[A-Z]/.test(Q))throw RangeError(E1(Y))}else{if(J)throw RangeError(E1(Y));J=G}return""}),W.length>1&&Z)throw RangeError(E1($));return{timeZone:J,calendar:W[0]||w}}function tJ($){return parseInt($.padEnd(9,"0"))}function MZ($){return new RegExp(`^${$}$`,"i")}function eJ($){return $&&$!=="+"?-1:1}function QZ($){return $===void 0?0:parseInt($)}function jj($){return a6(e($))}function a6($){let Z=$2($);return typeof Z=="number"?C$(Z):Z?((J)=>{if(zV.test(J))throw RangeError(FB);return J.toLowerCase().split("/").map((W,Y)=>(W.length<=3||/\d/.test(W))&&!/etc|yap/.test(W)?W.toUpperCase():W.replace(/baja|dumont|[a-z]+/g,(j,z)=>j.length<=2&&!Y||j==="in"||j==="chat"?j.toUpperCase():j.length>2||!z?M5(j).replace(/island|noronha|murdo|rivadavia|urville/,M5):j)).join("/")})($):q$}function A5($){let Z=$2($);return typeof Z=="number"?Z:Z?Z.resolvedOptions().timeZone:q$}function $2($){let Z=rJ($=$.toUpperCase(),1);return Z!==void 0?Z:$!==q$?jV($):void 0}function Z2($,Z){return C0($.epochNanoseconds,Z.epochNanoseconds)}function J2($,Z){return C0($.epochNanoseconds,Z.epochNanoseconds)}function zj($,Z,J,W,Y,j){let z=$(e0(j).relativeTo),X=Math.max(M$(W),M$(Y));if(h5(g,W,Y))return 0;if(j3(X,z))return C0(V0(W),V0(Y));if(!z)throw RangeError(Y4);let[G,Q,K]=d6(Z,J,z),B=lJ(K),F=u6(K);return C0(B(F(Q,G,W)),B(F(Q,G,Y)))}function W2($,Z){return E$($,Z)||r6($,Z)}function E$($,Z){return n1(S0($),S0(Z))}function r6($,Z){return n1(t1($),t1(Z))}function Xj($,Z){return!Z2($,Z)}function Gj($,Z){return!J2($,Z)&&!!t6($.timeZone,Z.timeZone)&&HZ($.calendar,Z.calendar)}function Qj($,Z){return!W2($,Z)&&HZ($.calendar,Z.calendar)}function Kj($,Z){return!E$($,Z)&&HZ($.calendar,Z.calendar)}function Fj($,Z){return!E$($,Z)&&HZ($.calendar,Z.calendar)}function Bj($,Z){return!E$($,Z)&&HZ($.calendar,Z.calendar)}function Vj($,Z){return!r6($,Z)}function t6($,Z){if($===Z)return 1;let J=L0($),W=L0(Z);if(J===W)return 1;try{return A5(J)===A5(W)}catch(Y){}}function Y2($,Z,J,W){let Y=LZ($,z0(W),3,5),j=e6(Z.epochNanoseconds,J.epochNanoseconds,...Y);return n($?E0(j):j)}function j2($,Z,J,W,Y,j){let z=Z4(W.calendar,Y.calendar),X=z0(j),[G,Q,K,B]=LZ(J,X,5),F=W.epochNanoseconds,D=Y.epochNanoseconds,V=C0(D,F),O;if(V)if(G<6)O=e6(F,D,G,Q,K,B);else{let U=Z(((T,I)=>{if(!t6(T,I))throw RangeError(Sz);return T})(W.timeZone,Y.timeZone)),H=$(z);O=Dj(H,U,W,Y,V,G,X),O=g6(O,D,G,Q,K,B,H,W,HY,R(dJ,U))}else O=H0;return n(J?E0(O):O)}function z2($,Z,J,W,Y){let j=Z4(J.calendar,W.calendar),z=z0(Y),[X,G,Q,K]=LZ(Z,z,6),B=x0(J),F=x0(W),D=C0(F,B),V;if(D)if(X<=6)V=e6(B,F,X,G,Q,K);else{let O=$(j);V=Uj(O,J,W,D,X,z),V=g6(V,F,X,G,Q,K,O,J,x0,uJ)}else V=H0;return n(Z?E0(V):V)}function X2($,Z,J,W,Y){let j=Z4(J.calendar,W.calendar),z=z0(Y);return Oj(Z,()=>$(j),J,W,...LZ(Z,z,6,9,6),z)}function G2($,Z,J,W,Y){let j=Z4(J.calendar,W.calendar),z=z0(Y),X=LZ(Z,z,9,9,8),G=$(j);return Oj(Z,()=>G,Y3(G,J),Y3(G,W),...X,z)}function Oj($,Z,J,W,Y,j,z,X,G){let Q=x0(J),K=x0(W),B;if(C0(K,Q))if(Y===6)B=e6(Q,K,Y,j,z,X);else{let F=Z();B=F.dateUntil(J,W,Y,G),j===6&&z===1||(B=g6(B,K,Y,j,z,X,F,J,x0,c6))}else B=H0;return n($?E0(B):B)}function Q2($,Z,J,W){let Y=z0(W),[j,z,X,G]=LZ($,Y,5,5),Q=e1(K2(Z,J),V3(z,X),G),K={...H0,...s6(Q,j)};return n($?E0(K):K)}function dF($,Z,J,W,Y,j){let z=C0(W.epochNanoseconds,J.epochNanoseconds);return z?Y<6?Lj(J.epochNanoseconds,W.epochNanoseconds,Y):Dj(Z,$,J,W,z,Y,j):H0}function uF($,Z,J,W,Y){let j=x0(Z),z=x0(J),X=C0(z,j);return X?W<=6?Lj(j,z,W):Uj($,Z,J,X,W,Y):H0}function Dj($,Z,J,W,Y,j,z){let[X,G,Q]=((F,D,V,O)=>{function U(){return S={...A$(I,A++*-O),...T},M=v0(F,S),C0(x,M)===-O}let H=A0(D,F),T=g0(J1,H),I=A0(V,F),x=V.epochNanoseconds,A=0,f=K2(H,I),S,M;if(Math.sign(f)===-O&&A++,U()&&(O===-1||U()))throw RangeError(H3);let P=d0(c0(M,x));return[H,S,P]})(Z,J,W,Y);var K,B;return{...j===6?(K=X,B=G,{...H0,days:Hj(K,B)}):$.dateUntil(X,G,j,z),...s6(Q)}}function Uj($,Z,J,W,Y,j){let[z,X,G]=((Q,K,B)=>{let F=K,D=K2(Q,K);return Math.sign(D)===-B&&(F=A$(K,-B),D+=c*B),[Q,F,D]})(Z,J,W);return{...$.dateUntil(z,X,Y,j),...s6(G)}}function e6($,Z,J,W,Y,j){return{...H0,...PZ(m6(c0($,Z),W,Y,j),J)}}function Lj($,Z,J){return{...H0,...PZ(c0($,Z),J)}}function Hj($,Z){return $4(S0($),S0(Z))}function $4($,Z){return Math.trunc((Z-$)/q0)}function K2($,Z){return t1(Z)-t1($)}function Z4($,Z){if(!HZ($,Z))throw RangeError(x2);return $}function lF($){function Z(Y){return((j,z)=>({...Ij(j,z),F:j.month,day:parseInt(j.day)}))(KJ(J,Y),W)}let J=h2($),W=M6($);return{id:$,O:iF(Z),B:sF(Z)}}function iF($){return y0((Z)=>{let J=S0(Z);return $(J)},WeakMap)}function sF($){let Z=$(0).year-wB;return y0((J)=>{let W,Y=UZ(J-Z),j=[],z=[];do Y+=400*q0;while((W=$(Y)).year<=J);do Y+=(1-W.day)*q0,W.year===J&&(j.push(Y),z.push(W.F)),Y-=q0;while((W=$(Y)).year>=J);return{k:j.reverse(),C:fz(z.reverse())}})}function Ij($,Z){let J,W,Y=Pj($);if($.era){let j=mz[Z];j!==void 0&&(J=Z==="islamic"?"ah":$.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),J==="bc"||J==="b"?J="bce":J!=="ad"&&J!=="a"||(J="ce"),W=Y,Y=xj(W,j[J]||0))}return{era:J,eraYear:W,year:Y}}function Pj($){return parseInt($.relatedYear||$.year)}function n8($){let{year:Z,F:J,day:W}=this.O($),{C:Y}=this.B(Z);return[Z,Y[J]+1,W]}function z3($,Z=1,J=1){return this.B($).k[Z-1]+(J-1)*q0}function F6($){let Z=f5(this,$),J=f5(this,$-1),W=Z.length;if(W>J.length){let Y=Cj(this);if(Y<0)return-Y;for(let j=0;j<W;j++)if(Z[j]!==J[j])return j+1}}function B6($){return $4(z3.call(this,$),z3.call(this,$+1))}function E5($,Z){let{k:J}=this.B($),W=Z+1,Y=J;return W>J.length&&(W=1,Y=this.B($+1).k),$4(J[Z-1],Y[W-1])}function V6($){return this.B($).k.length}function f5($,Z){return Object.keys($.B(Z).C)}function Tj($){return O3(e($))}function O3($){if(($=$.toLowerCase())!==w&&$!==G4&&M6($)!==M6(h2($).resolvedOptions().calendar))throw RangeError(KB($));return $}function M6($){return $==="islamicc"&&($="islamic"),$.split("-")[0]}function Mj($){return this.R($)[0]}function Nj($){return this.R($)[1]}function F2($){let[Z]=this.h($);return $4(this.q(Z),S0($))+1}function _j($){let Z=GV.exec($);if(!Z)throw RangeError(GB($));return[parseInt(Z[1]),Boolean(Z[2])]}function N6($,Z,J){return $+(Z||J&&$>=J?1:0)}function o8($,Z){return $-(Z&&$>=Z?1:0)}function xj($,Z){return(Z+$)*(Math.sign(Z)||1)||0}function a8($){return mz[Sj($)]}function Cj($){return _B[Sj($)]}function Sj($){return M6($.id||w)}function Aj($,Z,J,W){let Y=W$(J,W,Z1,[],qz);if(Y.timeZone!==void 0){let j=J.dateFromFields(Y),z=f$(Y),X=$(Y.timeZone);return{epochNanoseconds:S$(Z(X),{...j,...z},Y.offset!==void 0?TZ(Y.offset):void 0),timeZone:X}}return{...J.dateFromFields(Y),...a0}}function Ej($,Z,J,W,Y,j){let z=W$(J,Y,Z1,wz,qz),X=$(z.timeZone),[G,Q,K]=B3(j),B=J.dateFromFields(z,y6(j,G)),F=f$(z,G);return I0(S$(Z(X),{...B,...F},z.offset!==void 0?TZ(z.offset):void 0,Q,K),X,W)}function fj($,Z,J){let W=W$($,Z,Z1,[],k1),Y=y(J);return X0(b1({...$.dateFromFields(W,y6(J,Y)),...f$(W,Y)}))}function B2($,Z,J,W=[]){let Y=W$($,Z,Z1,W);return $.dateFromFields(Y,J)}function V2($,Z,J,W){let Y=W$($,Z,A2,W);return $.yearMonthFromFields(Y,J)}function O2($,Z,J,W,Y=[]){let j=W$($,J,Z1,Y);return Z&&j.month!==void 0&&j.monthCode===void 0&&j.year===void 0&&(j.year=OZ),$.monthDayFromFields(j,W)}function bj($,Z){let J=y(Z);return $1(f$(X1($,t8,[],1),J))}function Rj($){let Z=X1($,E2);return n(IZ({...H0,...Z}))}function W$($,Z,J,W=[],Y=[]){return X1(Z,[...$.fields(J),...Y].sort(),W)}function X1($,Z,J,W=!J){let Y={},j,z=0;for(let X of Z){if(X===j)throw RangeError(JB(X));if(X==="constructor"||X==="__proto__")throw RangeError(N2(X));let G=$[X];if(G!==void 0)z=1,k5[X]&&(G=k5[X](G,X)),Y[X]=G;else if(J){if(J.includes(X))throw TypeError(M2(X));Y[X]=gz[X]}j=X}if(W&&!z)throw TypeError(Tz(Z));return Y}function f$($,Z){return k6(BV({...gz,...$}),Z)}function wj($,Z,J,W,Y,j){let z=z0(j),{calendar:X,timeZone:G}=J;return I0(((Q,K,B,F,D)=>{let V=D3(Q,B,F,Z1,kz,Rz),[O,U,H]=B3(D,2);return S$(K,{...Q.dateFromFields(V,y6(D,O)),...f$(V,O)},TZ(V.offset),U,H)})($(X),Z(G),W,Y,z),G,X)}function kj($,Z,J,W,Y){let j=z0(Y);return X0(((z,X,G,Q)=>{let K=D3(z,X,G,Z1,k1),B=y(Q);return b1({...z.dateFromFields(K,y6(Q,B)),...f$(K,B)})})($(Z.calendar),J,W,j))}function qj($,Z,J,W,Y){let j=z0(Y);return((z,X,G,Q)=>{let K=D3(z,X,G,Z1);return z.dateFromFields(K,Q)})($(Z.calendar),J,W,j)}function yj($,Z,J,W,Y){let j=z0(Y);return T$(((z,X,G,Q)=>{let K=D3(z,X,G,A2);return z.yearMonthFromFields(K,Q)})($(Z.calendar),J,W,j))}function vj($,Z,J,W,Y){let j=z0(Y);return((z,X,G,Q)=>{let K=D3(z,X,G,Z1);return z.monthDayFromFields(K,Q)})($(Z.calendar),J,W,j)}function gj($,Z,J){return $1(((W,Y,j)=>{let z=y(j);return f$({...g0(t8,W),...X1(Y,t8)},z)})($,Z,J))}function mj($,Z){return n((J=$,W=Z,IZ({...J,...X1(W,E2)})));var J,W}function D3($,Z,J,W,Y=[],j=[]){let z=[...$.fields(W),...Y].sort(),X=X1(Z,z,j),G=X1(J,z);return X=$.mergeFields(X,G),X1(X,z,[])}function D2($,Z){let J=W$($,Z,vz);return $.monthDayFromFields(J)}function U2($,Z,J){let W=W$($,Z,yz);return $.yearMonthFromFields(W,J)}function hj($,Z,J,W,Y){Z=g0(J=$.fields(J),Z),W=X1(W,Y=$.fields(Y),[]);let j=$.mergeFields(Z,W);return j=X1(j,[...J,...Y].sort(),[]),$.dateFromFields(j)}function d8($,Z){let{era:J,eraYear:W,year:Y}=Z,j=a8($);if(J!==void 0||W!==void 0){if(J===void 0||W===void 0)throw TypeError(YB);if(!j)throw RangeError(WB);let z=j[J];if(z===void 0)throw RangeError(zB(J));let X=xj(W,z);if(Y!==void 0&&Y!==X)throw RangeError(jB);Y=X}else if(Y===void 0)throw TypeError(XB(j));return Y}function u8($,Z,J,W){let{month:Y,monthCode:j}=Z;if(j!==void 0){let z=((X,G,Q,K)=>{let B=X.U(Q),[F,D]=_j(G),V=N6(F,D,B);if(D){let O=Cj(X);if(O===void 0)throw RangeError(Z3);if(O>0){if(V>O)throw RangeError(Z3);if(B===void 0){if(K===1)throw RangeError(Z3);V--}}else{if(V!==-O)throw RangeError(Z3);if(B===void 0&&K===1)throw RangeError(Z3)}}return V})($,j,J,W);if(Y!==void 0&&Y!==z)throw RangeError(xz);Y=z,W=1}else if(Y===void 0)throw TypeError(QB);return s0("month",Y,1,$.L(J),W)}function b5($,Z,J,W,Y){return w0(Z,"day",1,$.j(W,J),Y)}function l8($,Z,J,W){let Y=0,j=[];for(let z of J)Z[z]!==void 0?Y=1:j.push(z);if(Object.assign($,Z),Y)for(let z of W||j)delete $[z]}function pj($){return D0(u0(f6(E6($))))}function cj($,Z,J,W,Y=w){return I0(u0(f6(E6(J))),Z(W),$(Y))}function dj($,Z,J,W,Y=0,j=0,z=0,X=0,G=0,Q=0,K=w){return X0(b1(w6(r0(_0,DZ(Q4,[Z,J,W,Y,j,z,X,G,Q])))),$(K))}function uj($,Z,J,W,Y=w){return G0(o1(_$(r0(_0,{isoYear:Z,isoMonth:J,isoDay:W}))),$(Y))}function lj($,Z,J,W=w,Y=1){let j=_0(Z),z=_0(J),X=$(W);return T$(FJ(_$({isoYear:j,isoMonth:z,isoDay:_0(Y)})),X)}function ij($,Z,J,W=w,Y=OZ){let j=_0(Z),z=_0(J),X=$(W);return I6(o1(_$({isoYear:_0(Y),isoMonth:j,isoDay:z})),X)}function sj($=0,Z=0,J=0,W=0,Y=0,j=0){return $1(k6(r0(_0,DZ(J1,[$,Z,J,W,Y,j])),1))}function nj($=0,Z=0,J=0,W=0,Y=0,j=0,z=0,X=0,G=0,Q=0){return n(IZ(r0(t5,DZ(g,[$,Z,J,W,Y,j,z,X,G,Q]))))}function L2($,Z,J=w){return I0($.epochNanoseconds,Z,J)}function oj($){return D0($.epochNanoseconds)}function H2($,Z){return X0(A0(Z,$))}function I2($,Z){return G0(A0(Z,$))}function aj($,Z,J){return U2($(Z.calendar),J)}function rj($,Z,J){return D2($(Z.calendar),J)}function P2($,Z){return $1(A0(Z,$))}function tj($,Z,J,W){let Y=((j,z,X,G)=>{let Q=DJ(G);return v0(j(z),X,Q)})($,J,Z,W);return I0(u0(Y),J,Z.calendar)}function ej($,Z,J){let W=$(Z.calendar);return T$({...Z,...U2(W,J)})}function $z($,Z,J){return D2($(Z.calendar),J)}function Zz($,Z,J,W,Y){let j=$(Y.timeZone),z=Y.plainTime,X=z!==void 0?Z(z):a0;return I0(v0(J(j),{...W,...X}),j,W.calendar)}function Jz($,Z=a0){return X0(b1({...$,...Z}))}function Wz($,Z,J){return U2($(Z.calendar),J)}function Yz($,Z,J){return D2($(Z.calendar),J)}function jz($,Z,J,W){return((Y,j,z)=>hj(Y,j,yz,f1(z),P3))($(Z.calendar),J,W)}function zz($,Z,J,W){return((Y,j,z)=>hj(Y,j,vz,f1(z),X4))($(Z.calendar),J,W)}function Xz($,Z,J,W,Y){let j=f1(Y),z=Z(j.plainDate),X=$(j.timeZone);return I0(v0(J(X),{...z,...W}),X,z.calendar)}function Gz($,Z){return X0(b1({...$,...Z}))}function Qz($){return D0(u0(BZ($,o0)))}function Kz($){return D0(u0(BZ($,Q1)))}function Fz($){return D0(u0(f6(E6($),R$)))}function Bz($){return D0(u0(f6(E6($))))}function Vz($,Z,J=a0){let W=Z.timeZone,Y=$(W),j={...A0(Z,Y),...J};return I0(S$(Y,j,j.offsetNanoseconds,2),W,Z.calendar)}function Oz($,Z,J){let W=Z.timeZone,Y=$(W),j={...A0(Z,Y),...J},z=Hz(Z.calendar,J.calendar);return I0(S$(Y,j,j.offsetNanoseconds,2),W,z)}function Dz($,Z=a0){return X0({...$,...Z})}function Uz($,Z){return X0({...$,...Z},Hz($.calendar,Z.calendar))}function J4($,Z){return{...$,calendar:Z}}function Lz($,Z){return{...$,timeZone:Z}}function Hz($,Z){if($===Z)return $;let J=L0($),W=L0(Z);if(J===W||J===w)return Z;if(W===w)return $;throw RangeError(x2)}function nF($,Z){return(J)=>J===w?$:J===G4||J===VZ?Object.assign(Object.create($),{id:J}):Object.assign(Object.create(Z),XV(J))}function b$($,Z,J){let W=new Set(J);return(Y)=>(((j,z)=>{for(let X of z)if(X in j)return 1;return 0})(Y=JJ(W,Y),$)||Object.assign(Y,Z),J&&(Y.timeZone=q$,["full","long"].includes(Y.timeStyle)&&(Y.timeStyle="medium")),Y)}function R1($,Z=T2){let[J,,,W]=$;return(Y,j=AV,...z)=>{let X=Z(W&&W(...z),Y,j,J),G=X.resolvedOptions();return[X,...oF($,G,z)]}}function T2($,Z,J,W){if(J=W(J),$){if(J.timeZone!==void 0)throw TypeError(TB);J.timeZone=$}return new Y$(Z,J)}function oF($,Z,J){let[,W,Y]=$;return J.map((j)=>(j.calendar&&((z,X,G)=>{if((G||z!==w)&&z!==X)throw RangeError(x2)})(L0(j.calendar),Z.calendar,Y),W(j,Z)))}function NZ($){let Z=U3();return $$(Z,$.getOffsetNanosecondsFor(Z))}function U3(){return BZ(Date.now(),Q1)}function w1(){return y5||(y5=new Y$().resolvedOptions().timeZone)}var aF=($,Z)=>`Non-integer ${$}: ${Z}`,rF=($,Z)=>`Non-positive ${$}: ${Z}`,tF=($,Z)=>`Non-finite ${$}: ${Z}`,eF=($)=>`Cannot convert bigint to ${$}`,$B=($)=>`Invalid bigint: ${$}`,ZB="Cannot convert Symbol to string",Iz="Invalid object",Pz=($,Z,J,W,Y)=>Y?Pz($,Y[Z],Y[J],Y[W]):L3($,Z)+`; must be between ${J}-${W}`,L3=($,Z)=>`Invalid ${$}: ${Z}`,M2=($)=>`Missing ${$}`,N2=($)=>`Invalid field ${$}`,JB=($)=>`Duplicate field ${$}`,Tz=($)=>"No valid fields: "+$.join(),Mz="Invalid bag",Nz=($,Z,J)=>L3($,Z)+"; must be "+Object.keys(J).join(),_z="Cannot use valueOf",_2="Invalid calling context",WB="Forbidden era/eraYear",YB="Mismatching era/eraYear",jB="Mismatching year/eraYear",zB=($)=>`Invalid era: ${$}`,XB=($)=>"Missing year"+($?"/era/eraYear":""),GB=($)=>`Invalid monthCode: ${$}`,xz="Mismatching month/monthCode",QB="Missing month/monthCode",R5="Cannot guess year",Z3="Invalid leap month",Cz="Invalid protocol",H3="Invalid protocol results",x2="Mismatching Calendars",KB=($)=>`Invalid Calendar: ${$}`,Sz="Mismatching TimeZones",FB="Forbidden ICU TimeZone",BB="Out-of-bounds offset",VB="Out-of-bounds TimeZone gap",OB="Invalid TimeZone offset",DB="Ambiguous offset",W4="Out-of-bounds date",UB="Out-of-bounds duration",LB="Cannot mix duration signs",Y4="Missing relativeTo",HB="Cannot use large units",IB="Required smallestUnit or largestUnit",PB="smallestUnit > largestUnit",k0=($)=>`Cannot parse: ${$}`,E1=($)=>`Invalid substring: ${$}`,Az=($)=>`Cannot format ${$}`,Ez="Mismatching types for formatting",TB="Cannot specify TimeZone",fz=R(Q3,($,Z)=>Z),_Z=R(Q3,($,Z,J)=>J),n0=R(U6,2),r8={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},I3=Object.keys(r8),q0=86400000,bz=1000,R$=1000,Q1=1e6,o0=1e9,j4=60000000000,z4=3600000000000,c=86400000000000,G1=[1,R$,Q1,o0,j4,z4,c],k1=I3.slice(0,6),t8=K3(k1),Rz=["offset"],wz=["timeZone"],kz=k1.concat(Rz),qz=kz.concat(wz),e8=["era","eraYear"],MB=e8.concat(["year"]),X4=["year"],C2=["monthCode"],S2=["month"].concat(C2),P3=["day"],A2=S2.concat(X4),yz=C2.concat(X4),Z1=P3.concat(A2),NB=P3.concat(S2),vz=P3.concat(C2),gz=_Z(k1,0),w="iso8601",G4="gregory",VZ="japanese",mz={[G4]:{bce:-1,ce:0},[VZ]:{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}},_B={chinese:13,dangi:13,hebrew:-6},e=R(A6,"string"),hz=R(A6,"boolean"),xB=R(A6,"number"),pz=R(A6,"function"),g=I3.map(($)=>$+"s"),E2=K3(g),CB=g.slice(0,6),cz=g.slice(6),SB=cz.slice(1),AB=fz(g),H0=_Z(g,0),f2=_Z(CB,0),b2=R(p5,g),J1=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],R2=["isoDay","isoMonth","isoYear"],Q4=J1.concat(R2),w2=K3(R2),dz=K3(J1),uz=K3(Q4),a0=_Z(dz,0),EB=R(p5,Q4),Y$=Intl.DateTimeFormat,lz="en-GB",k2=1e8,fB=k2*q0,bB=[k2,0],RB=[-k2,0],X3=275760,G3=-271821,wB=1970,OZ=1972,S1=12,kB=UZ(1868,9,8),qB=y0(qF,WeakMap),_6="smallestUnit",$J="unit",W3="roundingIncrement",i8="fractionalSecondDigits",iz="relativeTo",sz={constrain:0,reject:1},yB=Object.keys(sz),vB={compatible:0,reject:1,earlier:2,later:3},gB={reject:0,use:1,prefer:2,ignore:3},mB={auto:0,never:1,critical:2,always:3},hB={auto:0,never:1,critical:2},pB={auto:0,never:1},cB={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},T3=R(TJ,_6),q2=R(TJ,"largestUnit"),dB=R(TJ,$J),nz=R(x$,"overflow",sz),oz=R(x$,"disambiguation",vB),uB=R(x$,"offset",gB),y2=R(x$,"calendarName",mB),lB=R(x$,"timeZoneName",hB),iB=R(x$,"offset",pB),M3=R(x$,"roundingMode",cB),xZ="PlainYearMonth",CZ="PlainMonthDay",w$="PlainDate",k$="PlainDateTime",K4="PlainTime",q1="ZonedDateTime",F4="Instant",B4="Duration",sB=[Math.floor,($)=>K6($)?Math.floor($):Math.round($),Math.ceil,($)=>K6($)?Math.ceil($):Math.round($),Math.trunc,($)=>K6($)?Math.trunc($)||0:Math.round($),($)=>$<0?Math.floor($):Math.ceil($),($)=>Math.sign($)*Math.round(Math.abs($))||0,($)=>K6($)?($=Math.trunc($)||0)+$%2:Math.round($)],q$="UTC",O6=5184000,nB=H6(1847),oB=H6(new Date().getUTCFullYear()+10),aB=/0+$/,A0=y0(pF,WeakMap),w5=4294967295,V4=y0(($)=>{let Z=$2($);return typeof Z=="object"?new rz(Z):new az(Z||0)});class az{constructor($){this.v=$}getOffsetNanosecondsFor(){return this.v}getPossibleInstantsFor($){return[BJ($,this.v)]}l(){}}class rz{constructor($){this.$=((Z)=>{function J(G){let Q=s8(G,z,X),[K,B]=S5(Q),F=Y(K),D=Y(B);return F===D?F:W(j(K,B),F,D,G)}function W(G,Q,K,B){let F,D;for(;(B===void 0||(F=B<G[0]?Q:B>=G[1]?K:void 0)===void 0)&&(D=G[1]-G[0]);){let V=G[0]+Math.floor(D/2);Z(V)===K?G[1]=V:G[0]=V+1}return F}let Y=y0(Z),j=y0(cF),z=nB,X=oB;return{G(G){let Q=J(G-86400),K=J(G+86400),B=G-Q,F=G-K;if(Q===K)return[B];let D=J(B);return D===J(F)?[G-D]:Q>K?[B,F]:[]},V:J,l(G,Q){let K=s8(G,z,X),[B,F]=S5(K),D=O6*Q,V=Q<0?()=>F>z||(z=K,0):()=>B<X||(X=K,0);for(;V();){let O=Y(B),U=Y(F);if(O!==U){let H=j(B,F);W(H,O,U);let T=H[0];if((n1(T,G)||1)===Q)return T}B+=D,F+=D}}}})(((Z)=>(J)=>{let W=KJ(Z,J*bz);return H6(Pj(W),parseInt(W.month),parseInt(W.day),parseInt(W.hour),parseInt(W.minute),parseInt(W.second))-J})($))}getOffsetNanosecondsFor($){return this.$.V(ZY($))*o0}getPossibleInstantsFor($){let[Z,J]=[H6((W=$).isoYear,W.isoMonth,W.isoDay,W.isoHour,W.isoMinute,W.isoSecond),W.isoMillisecond*Q1+W.isoMicrosecond*R$+W.isoNanosecond];var W;return this.$.G(Z).map((Y)=>u0(FZ(BZ(Y,o0),J)))}l($,Z){let[J,W]=JY($),Y=this.$.l(J+(Z>0||W?1:0),Z);if(Y!==void 0)return BZ(Y,o0)}}var v2="([+\u2212-])",D6="(?:[.,](\\d{1,9}))?",tz=`(?:(?:${v2}(\\d{6}))|(\\d{4}))-?(\\d{2})`,g2="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+D6+")?)?",m2=v2+g2,rB=tz+"-?(\\d{2})(?:[T ]"+g2+"(Z|"+m2+")?)?",ez="\\[(!?)([^\\]]*)\\]",O4=`((?:${ez}){0,9})`,tB=MZ(tz+O4),eB=MZ("(?:--)?(\\d{2})-?(\\d{2})"+O4),$V=MZ(rB+O4),ZV=MZ("T?"+g2+"(?:"+m2+")?"+O4),JV=MZ(m2),WV=new RegExp(ez,"g"),YV=MZ(`${v2}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${D6}H)?(?:(\\d+)${D6}M)?(?:(\\d+)${D6}S)?)?`),jV=y0(($)=>new Y$(lz,{timeZone:$,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),zV=/^(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$/,XV=y0(lF),h2=y0(($)=>new Y$(lz,{calendar:$,timeZone:q$,era:"short",year:"numeric",month:"short",day:"numeric"})),GV=/^M(\d{2})(L?)$/,QV={era:L6,eraYear:_0,year:_0,month:N5,monthCode:L6,day:N5},KV=_Z(k1,_0),FV=_Z(g,t5),k5=Object.assign({},QV,KV,FV,{offset:L6}),BV=R(kF,k1,J1),q5={dateAdd($,Z,J){let W=y(J),Y,{years:j,months:z,weeks:X,days:G}=Z;if(G+=V0(Z,5)[0],j||z)Y=((Q,K,B,F,D)=>{let[V,O,U]=Q.h(K);if(B){let[H,T]=Q.I(V,O);V+=B,O=N6(H,T,Q.U(V)),O=s0("month",O,1,Q.L(V),D)}return F&&([V,O]=Q._(V,O,F)),U=s0("day",U,1,Q.j(V,O),D),Q.q(V,O,U)})(this,$,j,z,W);else{if(!X&&!G)return $;Y=S0($)}return Y+=(7*X+G)*q0,o1(R6(Y))},dateUntil($,Z,J){if(J<=7){let G=0,Q=Hj({...$,...a0},{...Z,...a0});return J===7&&([G,Q]=r1(Q,7)),{...H0,weeks:G,days:Q}}let W=this.h($),Y=this.h(Z),[j,z,X]=((G,Q,K,B,F,D,V)=>{let O=F-Q,U=D-K,H=V-B;if(O||U){let T=Math.sign(O||U),I=G.j(F,D),x=0;if(Math.sign(H)===-T){let A=I;[F,D]=G._(F,D,-T),O=F-Q,U=D-K,I=G.j(F,D),x=T<0?-A:I}if(H=V-Math.min(B,I)+x,O){let[A,f]=G.I(Q,K),[S,M]=G.I(F,D);if(U=S-A||Number(M)-Number(f),Math.sign(U)===-T){let P=T<0&&-G.L(F);O=(F-=T)-Q,U=D-N6(A,f,G.U(F))+(P||G.L(F))}}}return[O,U,H]})(this,...W,...Y);return J===8&&(z+=this.J(j,W[0]),j=0),{...H0,years:j,months:z,days:X}},dateFromFields($,Z){let J=y(Z),W=d8(this,$),Y=u8(this,$,W,J),j=b5(this,$,Y,W,J);return G0(o1(this.P(W,Y,j)),this.id||w)},yearMonthFromFields($,Z){let J=y(Z),W=d8(this,$),Y=u8(this,$,W,J);return T$(FJ(this.P(W,Y,1)),this.id||w)},monthDayFromFields($,Z){let J=y(Z),W=!this.id,{monthCode:Y,year:j,month:z}=$,X,G,Q,K,B;if(Y!==void 0){[X,G]=_j(Y),B=v5($,"day");let F=this.N(X,G,B);if(!F)throw RangeError(R5);if([Q,K]=F,z!==void 0&&z!==K)throw RangeError(xz);W&&(K=s0("month",K,1,S1,1),B=s0("day",B,1,VJ(j!==void 0?j:Q,K),J))}else{Q=j===void 0&&W?OZ:d8(this,$),K=u8(this,$,Q,J),B=b5(this,$,K,Q,J);let F=this.U(Q);G=K===F,X=o8(K,F);let D=this.N(X,G,B);if(!D)throw RangeError(R5);[Q,K]=D}return I6(o1(this.P(Q,K,B)),this.id||w)},fields($){return a8(this)&&$.includes("year")?[...$,...e8]:$},mergeFields($,Z){let J=Object.assign(Object.create(null),$);return l8(J,Z,S2),a8(this)&&(l8(J,Z,MB),this.id===VZ&&l8(J,Z,NB,e8)),J},inLeapYear($){let[Z]=this.h($);return this.K(Z)},monthsInYear($){let[Z]=this.h($);return this.L(Z)},daysInMonth($){let[Z,J]=this.h($);return this.j(Z,J)},daysInYear($){let[Z]=this.h($);return this.X(Z)},dayOfYear:F2,era($){return this.ee($)[0]},eraYear($){return this.ee($)[1]},monthCode($){let[Z,J]=this.h($),[W,Y]=this.I(Z,J);return((j,z)=>"M"+n0(j)+(z?"L":""))(W,Y)},dayOfWeek:XY,daysInWeek(){return 7}},VV={dayOfYear:F2,h:YY,q:UZ},OV=Object.assign({},VV,{weekOfYear:Mj,yearOfWeek:Nj,R($){function Z(D){return(7-D<W?7:0)-D}function J(D){let V=zY(F+D),O=D||1,U=Z(J3(G+V*O,7));return K=(V+(U-Q)*O)/7}let W=this.id?1:4,Y=XY($),j=this.dayOfYear($),z=J3(Y-1,7),X=j-1,G=J3(z-X,7),Q=Z(G),K,B=Math.floor((X-Q)/7)+1,F=$.isoYear;return B?B>J(0)&&(B=1,F++):(B=J(-1),F--),[B,F,K]}}),DV={dayOfYear:F2,h:n8,q:z3,weekOfYear:Mj,yearOfWeek:Nj,R(){return[]}},SZ=nF(Object.assign({},q5,OV,{h:YY,ee($){return this.id===G4?GY($):this.id===VZ?qB($):[]},I:($,Z)=>[Z,0],N($,Z){if(!Z)return[OZ,$]},K:OJ,U(){},L:jY,J:($)=>$*S1,j:VJ,X:zY,P:($,Z,J)=>({isoYear:$,isoMonth:Z,isoDay:J}),q:UZ,_:($,Z,J)=>($+=C6(J,S1),(Z+=YJ(J,S1))<1?($--,Z+=S1):Z>S1&&($++,Z-=S1),[$,Z]),year($){return $.isoYear},month($){return $.isoMonth},day:($)=>$.isoDay}),Object.assign({},q5,DV,{h:n8,ee($){let Z=this.O($);return[Z.era,Z.eraYear]},I($,Z){let J=F6.call(this,$);return[o8(Z,J),J===Z]},N($,Z,J){let[W,Y,j]=n8.call(this,{isoYear:OZ,isoMonth:S1,isoDay:31}),z=F6.call(this,W),X=Y===z;(n1($,o8(Y,z))||n1(Number(Z),Number(X))||n1(J,j))===1&&W--;for(let G=0;G<100;G++){let Q=W-G,K=F6.call(this,Q),B=N6($,Z,K);if(Z===(B===K)&&J<=E5.call(this,Q,B))return[Q,B]}},K($){let Z=B6.call(this,$);return Z>B6.call(this,$-1)&&Z>B6.call(this,$+1)},U:F6,L:V6,J($,Z){let J=Z+$,W=Math.sign($),Y=W<0?-1:0,j=0;for(let z=Z;z!==J;z+=W)j+=V6.call(this,z+Y);return j},j:E5,X:B6,P($,Z,J){return R6(z3.call(this,$,Z,J))},q:z3,_($,Z,J){if(J){if(Z+=J,!Number.isSafeInteger(Z))throw RangeError(W4);if(J<0)for(;Z<1;)Z+=V6.call(this,--$);else{let W;for(;Z>(W=V6.call(this,$));)Z-=W,$++}}return[$,Z]},year($){return this.O($).year},month($){let{year:Z,F:J}=this.O($),{C:W}=this.B(Z);return W[J]+1},day($){return this.O($).day}})),a1="numeric",AZ=["timeZoneName"],$X={month:a1,day:a1},p2={year:a1,month:a1},c2=Object.assign({},p2,{day:a1}),d2={hour:a1,minute:a1,second:a1},u2=Object.assign({},c2,d2),UV=Object.assign({},u2,{timeZoneName:"short"}),LV=Object.keys(p2),HV=Object.keys($X),IV=Object.keys(c2),PV=Object.keys(d2),l2=["dateStyle"],TV=LV.concat(l2),MV=HV.concat(l2),i2=IV.concat(l2,["weekday"]),N3=PV.concat(["dayPeriod","timeStyle"]),s2=i2.concat(N3),NV=s2.concat(AZ),_V=AZ.concat(N3),xV=AZ.concat(i2),CV=AZ.concat(["day","weekday"],N3),SV=AZ.concat(["year","weekday"],N3),AV={},n2=[b$(s2,u2),v6],ZX=[b$(NV,UV),v6,0,($,Z)=>{let J=L0($.timeZone);if(Z&&L0(Z.timeZone)!==J)throw RangeError(Sz);return J}],o2=[b$(s2,u2,AZ),S0],a2=[b$(i2,c2,_V),S0],r2=[b$(N3,d2,xV),($)=>t1($)/Q1],t2=[b$(TV,p2,CV),S0,1],e2=[b$(MV,$X,SV),S0,1],y5;function B1($,Z,J,W,Y){function j(...G){if(!(this instanceof j))throw TypeError(_2);jX(this,Z(...G))}function z(G,Q){return Object.defineProperties(function(...K){return G.call(this,X(this),...K)},ZJ(Q))}function X(G){let Q=M0(G);if(!Q||Q.branding!==$)throw TypeError(_2);return Q}return Object.defineProperties(j.prototype,{...g5(r0(z,J)),...N$(r0(z,W)),...x6("Temporal."+$)}),Object.defineProperties(j,{...N$(Y),...ZJ($)}),[j,(G)=>{let Q=Object.create(j.prototype);return jX(Q,G),Q},X]}function GX($){return $=$.concat("id").sort(),(Z)=>{if(!m5(Z,$))throw TypeError(Cz);return Z}}function RZ($){if(M0($)||$.calendar!==void 0||$.timeZone!==void 0)throw TypeError(Mz);return $}function D4($,Z){let J={};for(let W in $)J[W]=({o:Y},j)=>{let z=M0(j)||{},{branding:X}=z,G=X===w$||Z.includes(X)?z:b0(j);return Y[W](G)};return J}function J7($){let Z={};for(let J in $)Z[J]=(W)=>{let{calendar:Y}=W;return(j=Y,typeof j=="string"?SZ(j):(z=j,Object.assign(Object.create(uV),{i:z})))[J](W);var j,z};return Z}function Q$(){throw TypeError(_z)}function x3({calendar:$}){return typeof $=="string"?new F7($):$}function JX($,Z){if(Z=z0(Z),O0($)){let W=M0($);if(W&&W.branding===CZ)return y(Z),W;let Y=FX($);return O2(M4(Y||w),!Y,$,Z)}let J=nY(SZ,$);return y(Z),J}function QX($,Z,J){return W=Z.call($,f0(D0(J))),qJ(F3(W));var W}function U4($,Z=DX){let J=Object.keys(Z).sort(),W={};for(let Y of J)W[Y]=R(Z[Y],$,pz($[Y]));return W}function d($,Z){return typeof $=="string"?V4($):U4($,Z)}function K0($){return d($,Z7)}function K1($){if(O0($)){let Z=M0($);if(Z)switch(Z.branding){case F4:return Z;case q1:return D0(Z.epochNanoseconds)}}return dY($)}function WX($,Z,J){let W=Z.l(K1(J).epochNanoseconds,$);return W?f0(D0(W)):null}function i($){return O0($)?(M0($)||{}).timeZone||aV($):((Z)=>a6(tY(e(Z))))($)}function j$($,Z){if(O0($)){let J=M0($)||{};switch(J.branding){case K4:return y(Z),J;case k$:return y(Z),$1(J);case q1:return y(Z),P2(K0,J)}return bj($,Z)}return y(Z),oY($)}function W7($){return $===void 0?void 0:j$($)}function EZ($,Z){if(Z=z0(Z),O0($)){let W=M0($);return W&&W.branding===xZ?(y(Z),W):V2(P4(C3($)),$,Z)}let J=sY(SZ,$);return y(Z),J}function z$($,Z){if(Z=z0(Z),O0($)){let W=M0($)||{};switch(W.branding){case k$:return y(Z),W;case w$:return y(Z),X0({...W,...a0});case q1:return y(Z),H2(K0,W)}return fj(T4(C3($)),$,Z)}let J=iY($);return y(Z),J}function b0($,Z){if(Z=z0(Z),O0($)){let W=M0($)||{};switch(W.branding){case w$:return y(Z),W;case k$:return y(Z),G0(W);case q1:return y(Z),I2(K0,W)}return B2(T4(C3($)),$,Z)}let J=n6($);return y(Z),J}function KX($,Z,J){return t0(Z.call($,Z0(G0(J,$))))}function V1($){return(Z)=>typeof Z=="string"?SZ(Z):((J,W)=>{let Y=Object.keys(W).sort(),j={};for(let z of Y)j[z]=R(W[z],J,J[z]);return j})(Z,$)}function $0($){if(O0($)){let Z=M0($);return Z&&Z.branding===B4?Z:Rj($)}return aY($)}function _3($){if($!==void 0){if(O0($)){let Z=M0($)||{};switch(Z.branding){case q1:case w$:return Z;case k$:return G0(Z)}let J=C3($);return{...Aj(i,d,T4(J),$),calendar:J}}return uY($)}}function C3($){return FX($)||w}function FX($){let{calendar:Z}=$;if(Z!==void 0)return T0(Z)}function T0($){return O0($)?(M0($)||{}).calendar||FO($):((Z)=>O3(rY(e(Z))))($)}function fZ($,Z){if(Z=z0(Z),O0($)){let J=M0($);if(J&&J.branding===q1)return B3(Z),J;let W=C3($);return Ej(i,d,T4(W),W,$,Z)}return lY($,Z)}function YX($){return r0((Z)=>(J)=>Z($7(J)),$)}function $7($){return A0($,K0)}function EV(){let $=Y$.prototype,Z=Object.getOwnPropertyDescriptors($),J=Object.getOwnPropertyDescriptors(Y$),W=function(Y,j={}){if(!(this instanceof W))return new W(Y,j);B7.set(this,((z,X={})=>{let G=new Y$(z,X),Q=G.resolvedOptions(),K=Q.locale,B=g0(Object.keys(X),Q),F=y0(RV),D=(...V)=>{let O,U=V.map((H,T)=>{let I=M0(H),x=(I||{}).branding;if(T&&O&&O!==x)throw TypeError(Ez);return O=x,I});return O?F(O)(K,B,...U):[G,...V]};return D.u=G,D})(Y,j))};for(let Y in Z){let j=Z[Y],z=Y.startsWith("format")&&fV(Y);typeof j.value=="function"?j.value=Y==="constructor"?W:z||bV(Y):z&&(j.get=function(){return z.bind(this)})}return J.prototype.value=Object.create($,Z),Object.defineProperties(W,J),W}function fV($){return function(...Z){let J=B7.get(this),[W,...Y]=J(...Z);return W[$](...Y)}}function bV($){return function(...Z){return B7.get(this).u[$](...Z)}}function RV($){let Z=wV[$];if(!Z)throw TypeError(Az($));return R1(Z,y0(T2))}var wV={Instant:n2,PlainDateTime:o2,PlainDate:a2,PlainTime:r2,PlainYearMonth:t2,PlainMonthDay:e2},kV=R1(n2),qV=R1(ZX),yV=R1(o2),vV=R1(a2),gV=R1(r2),mV=R1(t2),hV=R1(e2),Y7={era:i5,eraYear:jJ,year:F3,month:t0,daysInMonth:t0,daysInYear:t0,inLeapYear:hz,monthsInYear:t0},H4={monthCode:e},j7={day:t0},BX={dayOfWeek:t0,dayOfYear:t0,weekOfYear:s5,yearOfWeek:jJ,daysInWeek:t0},VX=Object.assign({},Y7,H4,j7,BX),L4=new WeakMap,M0=L4.get.bind(L4),jX=L4.set.bind(L4),pV={...D4(Y7,[xZ]),...D4(BX,[]),...D4(H4,[xZ,CZ]),...D4(j7,[CZ])},z7=J7(VX),cV=J7({...Y7,...H4}),dV=J7({...H4,...j7}),S3={calendarId:($)=>L0($.calendar)},uV=r0(($,Z)=>function(J){let{i:W}=this;return $(W[Z](Z0(G0(J,W))))},VX),lV=Q3(($)=>(Z)=>Z[$],g.concat("sign")),X7=Q3(($,Z)=>(J)=>J[J1[Z]],k1),OX={epochSeconds:DY,epochMilliseconds:v6,epochMicroseconds:UY,epochNanoseconds:LY},A3=R(JJ,new Set(["branding"])),[iV,bZ,sV]=B1(CZ,R(ij,T0),{...S3,...dV},{getISOFields:A3,getCalendar:x3,with($,Z,J){return bZ(vj(GO,$,this,RZ(Z),J))},equals:($,Z)=>Bj($,JX(Z)),toPlainDate($,Z){return Z0(zz(E3,$,this,Z))},toLocaleString($,Z,J){let[W,Y]=hV(Z,J,$);return W.format(Y)},toString:fJ,toJSON:($)=>fJ($),valueOf:Q$},{from:($,Z)=>bZ(JX($,Z))}),DX={getOffsetNanosecondsFor:QX,getPossibleInstantsFor($,Z,J){let W=[...Z.call($,P0(X0(J,w)))].map((j)=>oV(j).epochNanoseconds),Y=W.length;return Y>1&&(W.sort(C0),yJ(d0(c0(W[0],W[Y-1])))),W}},Z7={getOffsetNanosecondsFor:QX},[nV,f0,oV]=B1(F4,pj,OX,{add:($,Z)=>f0(vJ(0,$,$0(Z))),subtract:($,Z)=>f0(vJ(1,$,$0(Z))),until:($,Z,J)=>u(Y2(0,$,K1(Z),J)),since:($,Z,J)=>u(Y2(1,$,K1(Z),J)),round:($,Z)=>f0(PY($,Z)),equals:($,Z)=>Xj($,K1(Z)),toZonedDateTime($,Z){let J=f1(Z);return Q0(L2($,i(J.timeZone),T0(J.calendar)))},toZonedDateTimeISO:($,Z)=>Q0(L2($,i(Z))),toLocaleString($,Z,J){let[W,Y]=kV(Z,J,$);return W.format(Y)},toString:($,Z)=>xJ(i,K0,$,Z),toJSON:($)=>xJ(i,K0,$),valueOf:Q$},{from:($)=>f0(K1($)),fromEpochSeconds:($)=>f0(Qz($)),fromEpochMilliseconds:($)=>f0(Kz($)),fromEpochMicroseconds:($)=>f0(Fz($)),fromEpochNanoseconds:($)=>f0(Bz($)),compare:($,Z)=>Z2(K1($),K1(Z))}),[I4,WP]=B1("TimeZone",($)=>{let Z=jj($);return{branding:"TimeZone",id:Z,o:V4(Z)}},{id:($)=>$.id},{getPossibleInstantsFor:({o:$},Z)=>$.getPossibleInstantsFor(z$(Z)).map((J)=>f0(D0(J))),getOffsetNanosecondsFor:({o:$},Z)=>$.getOffsetNanosecondsFor(K1(Z).epochNanoseconds),getOffsetStringFor($,Z){let J=K1(Z).epochNanoseconds,W=U4(this,Z7).getOffsetNanosecondsFor(J);return C$(W)},getPlainDateTimeFor($,Z,J=w){let W=K1(Z).epochNanoseconds,Y=U4(this,Z7).getOffsetNanosecondsFor(W);return P0(X0($$(W,Y),T0(J)))},getInstantFor($,Z,J){let W=z$(Z),Y=DJ(J),j=U4(this);return f0(D0(v0(j,W,Y)))},getNextTransition:({o:$},Z)=>WX(1,$,Z),getPreviousTransition:({o:$},Z)=>WX(-1,$,Z),equals($,Z){return!!t6(this,i(Z))},toString:($)=>$.id,toJSON:($)=>$.id},{from($){let Z=i($);return typeof Z=="string"?new I4(Z):Z}}),aV=GX(Object.keys(DX)),[rV,X$]=B1(K4,sj,X7,{getISOFields:A3,with($,Z,J){return X$(gj(this,RZ(Z),J))},add:($,Z)=>X$(cJ(0,$,$0(Z))),subtract:($,Z)=>X$(cJ(1,$,$0(Z))),until:($,Z,J)=>u(Q2(0,$,j$(Z),J)),since:($,Z,J)=>u(Q2(1,$,j$(Z),J)),round:($,Z)=>X$(NY($,Z)),equals:($,Z)=>Vj($,j$(Z)),toZonedDateTime:($,Z)=>Q0(Xz(i,b0,d,$,Z)),toPlainDateTime:($,Z)=>P0(Gz($,b0(Z))),toLocaleString($,Z,J){let[W,Y]=gV(Z,J,$);return W.format(Y)},toString:bJ,toJSON:($)=>bJ($),valueOf:Q$},{from:($,Z)=>X$(j$($,Z)),compare:($,Z)=>r6(j$($),j$(Z))}),[tV,G$,eV]=B1(xZ,R(lj,T0),{...S3,...cV},{getISOFields:A3,getCalendar:x3,with($,Z,J){return G$(yj(XO,$,this,RZ(Z),J))},add:($,Z,J)=>G$(pJ(zX,0,$,$0(Z),J)),subtract:($,Z,J)=>G$(pJ(zX,1,$,$0(Z),J)),until:($,Z,J)=>u(G2(XX,0,$,EZ(Z),J)),since:($,Z,J)=>u(G2(XX,1,$,EZ(Z),J)),equals:($,Z)=>Fj($,EZ(Z)),toPlainDate($,Z){return Z0(jz(E3,$,this,Z))},toLocaleString($,Z,J){let[W,Y]=mV(Z,J,$);return W.format(Y)},toString:EJ,toJSON:($)=>EJ($),valueOf:Q$},{from:($,Z)=>G$(EZ($,Z)),compare:($,Z)=>E$(EZ($),EZ(Z))}),[$O,P0]=B1(k$,R(dj,T0),{...S3,...z7,...X7},{getISOFields:A3,getCalendar:x3,with($,Z,J){return P0(kj(E3,$,this,RZ(Z),J))},withCalendar:($,Z)=>P0(J4($,T0(Z))),withPlainDate:($,Z)=>P0(Uz($,b0(Z))),withPlainTime:($,Z)=>P0(Dz($,W7(Z))),add:($,Z,J)=>P0(mJ(y$,0,$,$0(Z),J)),subtract:($,Z,J)=>P0(mJ(y$,1,$,$0(Z),J)),until:($,Z,J)=>u(z2(F1,0,$,z$(Z),J)),since:($,Z,J)=>u(z2(F1,1,$,z$(Z),J)),round:($,Z)=>P0(MY($,Z)),equals:($,Z)=>Qj($,z$(Z)),toZonedDateTime:($,Z,J)=>Q0(tj(d,$,i(Z),J)),toPlainDate:($)=>Z0(G0($)),toPlainTime:($)=>X$($1($)),toPlainYearMonth($){return G$(ej(P4,$,this))},toPlainMonthDay($){return bZ($z(M4,$,this))},toLocaleString($,Z,J){let[W,Y]=yV(Z,J,$);return W.format(Y)},toString:SJ,toJSON:($)=>SJ($),valueOf:Q$},{from:($,Z)=>P0(z$($,Z)),compare:($,Z)=>W2(z$($),z$(Z))}),[ZO,Z0,UX]=B1(w$,R(uj,T0),{...S3,...z7},{getISOFields:A3,getCalendar:x3,with($,Z,J){return Z0(qj(E3,$,this,RZ(Z),J))},withCalendar:($,Z)=>Z0(J4($,T0(Z))),add:($,Z,J)=>Z0(hJ(y$,0,$,$0(Z),J)),subtract:($,Z,J)=>Z0(hJ(y$,1,$,$0(Z),J)),until:($,Z,J)=>u(X2(F1,0,$,b0(Z),J)),since:($,Z,J)=>u(X2(F1,1,$,b0(Z),J)),equals:($,Z)=>Kj($,b0(Z)),toZonedDateTime($,Z){let J=!O0(Z)||Z instanceof I4?{timeZone:Z}:Z;return Q0(Zz(i,j$,d,$,J))},toPlainDateTime:($,Z)=>P0(Jz($,W7(Z))),toPlainYearMonth($){return G$(Wz(P4,$,this))},toPlainMonthDay($){return bZ(Yz(M4,$,this))},toLocaleString($,Z,J){let[W,Y]=vV(Z,J,$);return W.format(Y)},toString:AJ,toJSON:($)=>AJ($),valueOf:Q$},{from:($,Z)=>Z0(b0($,Z)),compare:($,Z)=>E$(b0($),b0(Z))}),G7={fields($,Z,J){return[...Z.call($,J)]}},LX=Object.assign({dateFromFields($,Z,J,W){return UX(Z.call($,Object.assign(Object.create(null),J),W))}},G7),HX=Object.assign({yearMonthFromFields($,Z,J,W){return eV(Z.call($,Object.assign(Object.create(null),J),W))}},G7),IX=Object.assign({monthDayFromFields($,Z,J,W){return sV(Z.call($,Object.assign(Object.create(null),J),W))}},G7),Q7={mergeFields($,Z,J,W){return f1(Z.call($,Object.assign(Object.create(null),J),Object.assign(Object.create(null),W)))}},JO=Object.assign({},LX,Q7),WO=Object.assign({},HX,Q7),YO=Object.assign({},IX,Q7),K7={dateAdd($,Z,J,W,Y){return UX(Z.call($,Z0(G0(J,$)),u(n(W)),Y))}},PX=Object.assign({},K7,{dateUntil($,Z,J,W,Y,j){return KO(Z.call($,Z0(G0(J,$)),Z0(G0(W,$)),Object.assign(Object.create(null),j,{largestUnit:I3[Y]})))}}),jO=Object.assign({},K7,{day:KX}),zO=Object.assign({},PX,{day:KX}),P4=V1(HX),T4=V1(LX),M4=V1(IX),XO=V1(WO),E3=V1(JO),GO=V1(YO),y$=V1(K7),F1=V1(PX),zX=V1(jO),XX=V1(zO),[QO,u,KO]=B1(B4,nj,{...lV,blank:hY},{with:($,Z)=>u(mj($,Z)),negated:($)=>u(i6($)),abs:($)=>u(mY($)),add:($,Z,J)=>u(sJ(_3,F1,d,0,$,$0(Z),J)),subtract:($,Z,J)=>u(sJ(_3,F1,d,1,$,$0(Z),J)),round:($,Z)=>u(gY(_3,F1,d,$,Z)),total:($,Z)=>IY(_3,F1,d,$,Z),toLocaleString($,Z,J){return Intl.DurationFormat?new Intl.DurationFormat(Z,J).format(this):p6($)},toString:p6,toJSON:($)=>p6($),valueOf:Q$},{from:($)=>u($0($)),compare:($,Z,J)=>zj(_3,y$,d,$0($),$0(Z),J)}),TX={toString:($)=>$.id,toJSON:($)=>$.id,...pV,dateAdd:({id:$,o:Z},J,W,Y)=>Z0(G0(Z.dateAdd(b0(J),$0(W),Y),$)),dateUntil:({o:$},Z,J,W)=>u(n($.dateUntil(b0(Z),b0(J),KY(W)))),dateFromFields:({id:$,o:Z},J,W)=>Z0(B2(Z,J,W,l5($))),yearMonthFromFields:({id:$,o:Z},J,W)=>G$(V2(Z,J,W,d5($))),monthDayFromFields:({id:$,o:Z},J,W)=>bZ(O2(Z,0,J,W,u5($))),fields({o:$},Z){let J=new Set(Z1),W=[];for(let Y of Z){if(e(Y),!J.has(Y))throw RangeError(N2(Y));J.delete(Y),W.push(Y)}return $.fields(W)},mergeFields:({o:$},Z,J)=>$.mergeFields(WJ(zJ(Z)),WJ(zJ(J)))},[F7]=B1("Calendar",($)=>{let Z=Tj($);return{branding:"Calendar",id:Z,o:SZ(Z)}},{id:($)=>$.id},TX,{from($){let Z=T0($);return typeof Z=="string"?new F7(Z):Z}}),FO=GX(Object.keys(TX).slice(4)),[BO,Q0]=B1(q1,R(cj,T0,i),{...OX,...S3,...YX(z7),...YX(X7),offset:($)=>C$($7($).offsetNanoseconds),offsetNanoseconds:($)=>$7($).offsetNanoseconds,timeZoneId:($)=>L0($.timeZone),hoursInDay:($)=>_Y(d,$)},{getISOFields:($)=>yY(K0,$),getCalendar:x3,getTimeZone:({timeZone:$})=>typeof $=="string"?new I4($):$,with($,Z,J){return Q0(wj(E3,d,$,this,RZ(Z),J))},withCalendar:($,Z)=>Q0(J4($,T0(Z))),withTimeZone:($,Z)=>Q0(Lz($,i(Z))),withPlainDate:($,Z)=>Q0(Oz(d,$,b0(Z))),withPlainTime:($,Z)=>Q0(Vz(d,$,W7(Z))),add:($,Z,J)=>Q0(gJ(y$,d,0,$,$0(Z),J)),subtract:($,Z,J)=>Q0(gJ(y$,d,1,$,$0(Z),J)),until:($,Z,J)=>u(n(j2(F1,d,0,$,fZ(Z),J))),since:($,Z,J)=>u(n(j2(F1,d,1,$,fZ(Z),J))),round:($,Z)=>Q0(TY(d,$,Z)),startOfDay:($)=>Q0(xY(d,$)),equals:($,Z)=>Gj($,fZ(Z)),toInstant:($)=>f0(oj($)),toPlainDateTime:($)=>P0(H2(K0,$)),toPlainDate:($)=>Z0(I2(K0,$)),toPlainTime:($)=>X$(P2(K0,$)),toPlainYearMonth($){return G$(aj(P4,$,this))},toPlainMonthDay($){return bZ(rj(M4,$,this))},toLocaleString($,Z,J={}){let[W,Y]=qV(Z,J,$);return W.format(Y)},toString:($,Z)=>CJ(K0,$,Z),toJSON:($)=>CJ(K0,$),valueOf:Q$},{from:($,Z)=>Q0(fZ($,Z)),compare:($,Z)=>J2(fZ($),fZ(Z))}),VO=Object.defineProperties({},{...x6("Temporal.Now"),...N$({timeZoneId:()=>w1(),instant:()=>f0(D0(U3())),zonedDateTime:($,Z=w1())=>Q0(I0(U3(),i(Z),T0($))),zonedDateTimeISO:($=w1())=>Q0(I0(U3(),i($),w)),plainDateTime:($,Z=w1())=>P0(X0(NZ(K0(i(Z))),T0($))),plainDateTimeISO:($=w1())=>P0(X0(NZ(K0(i($))),w)),plainDate:($,Z=w1())=>Z0(G0(NZ(K0(i(Z))),T0($))),plainDateISO:($=w1())=>Z0(G0(NZ(K0(i($))),w)),plainTimeISO:($=w1())=>X$($1(NZ(K0(i($)))))})}),wZ=Object.defineProperties({},{...x6("Temporal"),...N$({PlainYearMonth:tV,PlainMonthDay:iV,PlainDate:ZO,PlainTime:rV,PlainDateTime:$O,ZonedDateTime:BO,Instant:nV,Calendar:F7,TimeZone:I4,Duration:QO,Now:VO})}),OO=EV(),B7=new WeakMap,DO=Object.defineProperties(Object.create(Intl),N$({DateTimeFormat:OO}));var N4="x-gemi-socket";var QP="gemi.v1",MX="/__gemi/socket",KP=/^[A-Za-z0-9_-]{1,32}$/,FP={Normal:1000,UnsupportedData:1003,PolicyViolation:1008,Restart:1012,TryAgainLater:1013,Revoked:4001};function DP($){return $}function NX(){return{driver:"memory",redis:{},maxEventBytes:16384,warnEventBytes:4096,path:MX,allowedOrigins:[],maxConnectionsPerProcess:1e4,maxConnectionsPerIp:100,maxConnectionsPerUser:50,maxChannelsPerSocket:50,maxInboundMessageBytes:16384,backpressureLimit:1048576,idleTimeout:120,heartbeatMs:25000,subscribeRate:{limit:300,windowMs:60000}}}import{hkdfSync as UO,randomBytes as LO}from"crypto";function HO($=process.env.SECRET){if(!$)return"gemi:bc:";return`gemi:bc:${Buffer.from(UO("sha256",$,"gemi","gemi.broadcast.prefix",4)).toString("hex")}:`}var IO="__control",V7=250,PO=1e4,TO=15000;class O7{config;prefix;controlChannel;instanceId=LO(9).toString("base64url");subscribeTimeoutMs;healthCheckMs;publisher=null;subscriber=null;ready=null;deliver=null;hooks;wanted=new Set;active=new Set;chains=new Map;connectedOnce=!1;reconnectAttempt=0;reconnectTimer=null;healthTimer=null;closed=!1;constructor($={}){this.config=$;this.prefix=$.prefix??HO(),this.controlChannel=this.prefix+IO,this.subscribeTimeoutMs=$.subscribeTimeoutMs??5000,this.healthCheckMs=$.healthCheckMs??30000}get connected(){return this.subscriber!==null&&this.ready===null}publish($,Z){return this.send(this.prefix+$,Z)}async revoke($){this.hooks?.onRevoke?.($);let Z={op:"revoke",from:this.instanceId,r:$};try{await this.send(this.controlChannel,JSON.stringify(Z))}catch(J){throw Error(`The broadcast revocation ${JSON.stringify($)} could not reach the other instances.`,{cause:J})}}async start($,Z){this.closed=!1,this.deliver=$,this.hooks=Z,this.connectSubscriber(),this.startHealthCheck();try{await this.whenReady()}catch{console.warn("[gemi] Broadcast: Redis is not reachable yet; sockets get events once it is.")}}topicAdded($){return this.wanted.add($),this.sync($,!0)}topicRemoved($){return this.wanted.delete($),this.sync($,!1)}async close(){if(this.closed=!0,this.deliver=null,this.hooks=void 0,this.reconnectTimer)clearTimeout(this.reconnectTimer);if(this.reconnectTimer=null,this.healthTimer)clearInterval(this.healthTimer);this.healthTimer=null;let $=[this.subscriber,this.publisher];this.subscriber=null,this.publisher=null,this.ready=null,this.wanted.clear(),this.active.clear(),this.chains.clear();for(let Z of $){if(!Z)continue;Z.onclose=null;try{Z.close()}catch{}}}async send($,Z){let J=this.publisherClient();try{await J.publish($,Z)}catch{if(this.closed)throw Error("The broadcast driver is closed.");this.dropPublisher(J),await this.publisherClient().publish($,Z)}}dropPublisher($){if(this.publisher!==$)return;this.publisher=null,$.onclose=null;try{$.close()}catch{}}publisherClient(){if(this.publisher)return this.publisher;let $=this.createClient("publisher");return $.onclose=()=>{if(this.publisher===$)this.publisher=null},this.publisher=$,$}createClient($){if(this.config.createClient)return this.config.createClient($);let Z=globalThis.Bun?.RedisClient;if(typeof Z!=="function")throw Error("The redis broadcast driver needs Bun's built-in Redis client. Run the app under Bun.");let J=$==="subscriber"?{...this.config.options,autoReconnect:!1}:{...this.config.options};return new Z(this.config.url,J)}connectSubscriber(){if(this.closed||this.ready)return;let $;try{$=this.createClient("subscriber")}catch(J){console.error("[gemi] Broadcast: the Redis subscriber could not be created.",J),this.scheduleReconnect();return}this.subscriber=$,this.active.clear(),$.onclose=()=>this.lost($);let Z=f3((async()=>{await $.connect(),await $.subscribe(this.controlChannel,this.onMessage);let J=[...this.wanted];if(await Promise.all(J.map((W)=>$.subscribe(this.prefix+W,this.onMessage))),this.subscriber!==$)throw Error("Replaced.");for(let W of J)this.active.add(W);return $})(),TO,"connect");this.ready=Z,Z.then(()=>{if(this.subscriber!==$)return;this.ready=null,this.reconnectAttempt=0;for(let J of this.active)if(!this.wanted.has(J))this.sync(J,!1).catch(()=>{});if(this.connectedOnce)this.hooks?.onGap?.();this.connectedOnce=!0},(J)=>{if(this.subscriber!==$||this.closed)return;console.warn(`[gemi] Broadcast: the Redis subscriber could not connect (${_X(J)}); retrying.`),this.drop($)})}lost($){if(this.subscriber!==$||this.closed)return;if(this.ready===null)console.warn("[gemi] Broadcast: the Redis subscriber connection dropped; reconnecting.");this.drop($)}drop($){if(this.subscriber!==$)return;this.subscriber=null,this.ready=null,this.active.clear(),$.onclose=null;try{$.close()}catch{}this.scheduleReconnect()}scheduleReconnect(){if(this.closed||this.reconnectTimer)return;let $=Math.min(PO,V7*2**this.reconnectAttempt);this.reconnectAttempt=Math.min(this.reconnectAttempt+1,16);let Z=Math.max(V7,Math.floor(Math.random()*$));this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connectSubscriber()},Z),this.reconnectTimer.unref?.()}startHealthCheck(){if(this.healthCheckMs<=0||this.healthTimer)return;this.healthTimer=setInterval(()=>{let $=this.subscriber;if(!$||this.ready)return;f3($.ping(),this.subscribeTimeoutMs,"ping").catch((Z)=>{if(this.subscriber!==$)return;console.warn(`[gemi] Broadcast: the Redis subscriber did not answer a ping (${_X(Z)}); reconnecting.`),this.drop($)})},this.healthCheckMs),this.healthTimer.unref?.()}async whenReady(){if(this.closed)throw Error("The broadcast driver is closed.");let $=Date.now()+this.subscribeTimeoutMs;for(;;){if(this.subscriber&&!this.ready)return this.subscriber;let Z=$-Date.now();if(Z<=0)throw Error("Redis did not answer in time.");let J=this.ready??MO(Math.min(Z,V7));await f3(J,Z,"subscribe").catch((W)=>{if(Date.now()>=$)throw W})}}sync($,Z){let W=(this.chains.get($)??Promise.resolve()).catch(()=>{}).then(()=>this.reconcile($,Z));this.chains.set($,W);let Y=()=>{if(this.chains.get($)===W)this.chains.delete($)};return W.then(Y,Y),W}async reconcile($,Z){if(!this.wanted.has($)){if(!this.active.has($)||!this.connected)return;let Y=this.subscriber;this.active.delete($);try{await f3(Y.unsubscribe(this.prefix+$),this.subscribeTimeoutMs,"unsubscribe")}catch(j){if(this.subscriber===Y)this.drop(Y);throw j}return}if(!Z)return;let W=await this.whenReady();if(!this.wanted.has($)||this.active.has($))return;try{await f3(W.subscribe(this.prefix+$,this.onMessage),this.subscribeTimeoutMs,"subscribe")}catch(Y){if(this.subscriber===W)this.drop(W);throw Y}if(this.subscriber===W)this.active.add($)}onMessage=($,Z)=>{if(Z===this.controlChannel){this.onControl($);return}if(!Z.startsWith(this.prefix))return;this.deliver?.(Z.slice(this.prefix.length),$)};onControl($){let Z;try{Z=JSON.parse($)}catch{return}if(Z?.op!=="revoke"||Z.from===this.instanceId)return;let J=Z.r;if(J&&typeof J.user==="string")this.hooks?.onRevoke?.({user:J.user});else if(J&&typeof J.topic==="string")this.hooks?.onRevoke?.({topic:J.topic})}}function f3($,Z,J){let W;return Promise.race([$,new Promise((Y,j)=>{W=setTimeout(()=>j(Error(`Redis ${J} timed out after ${Z} ms.`)),Z)})]).finally(()=>clearTimeout(W))}function MO($){return new Promise((Z)=>setTimeout(Z,$))}function _X($){return $ instanceof Error?$.message:String($)}import{createHmac as NO,hkdfSync as _O,randomBytes as xX}from"crypto";function CX($){return NO("sha256",xO()).update($).digest("base64url").slice(0,22)}var _4=null;function xO(){let $=process.env.SECRET||void 0;if(_4&&_4.secret===$)return _4.key;let Z=$?Buffer.from(_O("sha256",$,"gemi","gemi.broadcast.socket-tag",32)):xX(32);return _4={secret:$,key:Z},Z}function PP(){return xX(16).toString("base64url")}var CO=/^[A-Za-z0-9_-]{8,64}$/;function D7($){return typeof $==="string"&&CO.test($)}function SX($,Z,J,W){let Y={op:"ev",t:$,ev:Z};if(J!==void 0)Y.d=J;if(W)Y.x=W;return JSON.stringify(Y)}class EX extends Error{bytes;limit;constructor($,Z,J){super(`The broadcast "${J}" is ${$} bytes, over the limit of ${Z}. Send ids and a change hint, and let the client fetch the data over HTTP; or raise maxEventBytes in app/config/broadcast.ts.`);this.bytes=$;this.limit=Z;this.name="BroadcastPayloadTooLargeError"}}class m0{options;static token="broadcast";config;driver;warnedAboutSize=new Set;started=!1;hooks;channelRouter;constructor($={},Z={}){this.options=Z;this.config=O1(NX(),$),this.driver=EO(this.config,Z.application)}get channels(){if(this.channelRouter===void 0)this.channelRouter=this.options.channels?new this.options.channels:null;return this.channelRouter}to($,...Z){return new b3(this,x4($,Z[0]),null)}toUser($){return new b3(this,{topic:e$($),pattern:F0},null)}toOthers($){return new fX(this,AO($))}broadcastEvent($){let Z=$.broadcastOn(),J=Array.isArray(Z)?Z:[Z],W=$.broadcastAs(),Y=$.broadcastWith(),j=J.map((z)=>this.prepare(x4(z,void 0),W,Y,null));for(let{sent:z,frame:X}of j)this.hand(z,X)}send($,Z,J,W){let{sent:Y,frame:j}=this.prepare($,Z,J,W);this.hand(Y,j)}prepare($,Z,J,W){t9(Z);let Y;try{Y=SX($.topic,Z,J,W?CX(W):null)}catch(z){throw TypeError(`The broadcast "${Z}" could not be encoded. Payloads must be JSON.`,{cause:z})}return this.checkSize(Z,Y),{sent:{topic:$.topic,...$.pattern?{pattern:$.pattern}:{},event:Z,data:JSON.parse(Y).d,...W?{except:W}:{}},frame:Y}}hand($,Z){kZ(()=>this.publish($,Z))}publish($,Z){let J=(W)=>console.error(`[gemi] The broadcast "${$.event}" on "${$.topic}" could not be published.`,W);try{let W=this.driver.publish($.topic,Z);if(W&&typeof W.catch==="function")W.catch(J)}catch(W){J(W)}}get isStarted(){return this.started}async start($,Z){if(this.started)throw Error("The broadcast driver was already started in this process.");this.started=!0,this.hooks=Z;try{await this.driver.start($,Z)}catch(J){throw this.started=!1,this.hooks=void 0,J}}topicAdded($){return this.driver.topicAdded?.($)}topicRemoved($){return this.driver.topicRemoved?.($)}async close(){this.started=!1,this.hooks=void 0,await this.driver.close()}revoke($){let Z=SO($);kZ(()=>this.sendRevocation(Z))}sendRevocation($){let Z=(J)=>console.error("[gemi] A broadcast revocation could not be sent.",J);try{if(typeof this.driver.revoke==="function"){let J=this.driver.revoke($);if(J&&typeof J.catch==="function")J.catch(Z);return}this.hooks?.onRevoke?.($)}catch(J){Z(J)}}checkSize($,Z){let J=Buffer.byteLength(Z,"utf8");if(J>this.config.maxEventBytes)throw new EX(J,this.config.maxEventBytes,$);let W=this.config.warnEventBytes;if(W!==!1&&J>W&&!this.warnedAboutSize.has($))this.warnedAboutSize.add($),console.warn(`[gemi] The broadcast "${$}" is ${J} bytes, over ${W}. Broadcasts are change hints: send ids and let the client fetch the data over HTTP. Warned once per event name.`)}}class b3{manager;target;except;constructor($,Z,J){this.manager=$;this.target=Z;this.except=J}emit($,...Z){this.manager.send(this.target,$,Z[0],this.except)}}class fX{manager;except;constructor($,Z){this.manager=$;this.except=Z}to($,...Z){return new b3(this.manager,x4($,Z[0]),this.except)}toUser($){return new b3(this.manager,{topic:e$($),pattern:F0},this.except)}}function x4($,Z){if(r9($))return{topic:K8($.topic),...$.pattern?{pattern:$.pattern}:{}};if(Z!==void 0||$.includes(":"))return{topic:aZ($,Z??{}),pattern:$};if($===F0)throw new p('"user" is not a topic: the "user" channel resolves to user.<id> per subscriber. Emit with Broadcast.toUser(user).');return{topic:K8($)}}function SO($){if($&&typeof $==="object"&&"user"in $)return{user:e$($.user).slice(F0.length+1)};if($&&typeof $==="object"&&"channel"in $)return{topic:x4($.channel,$.params).topic};throw new p("Broadcast.revoke takes { user } or { channel }.")}function AO($){if($===null||$===void 0)return null;if(typeof $==="string")return D7($)?$:null;let J=($ instanceof Request?$.headers:("rawRequest"in $)?$.rawRequest.headers:$.headers)?.get(N4);return D7(J)?J:null}function EO($,Z){let J=$.driver;if(J===void 0||J==="memory")return new AX;if(J==="redis"){let W=Z?.config.get("redis",{})??{},Y=$.redis??{};return new O7({url:Y.url??W.url??process.env.REDIS_URL,options:Y.options??W.options,prefix:Y.prefix,subscribeTimeoutMs:Y.subscribeTimeoutMs,healthCheckMs:Y.healthCheckMs})}if(typeof J==="function"){if(!Z)throw Error("A broadcast driver factory needs the application to be called with.");return J(Z)}if(typeof J==="object"&&J!==null&&typeof J.publish==="function")return J;throw Error(`Unknown broadcast driver "${String(J)}" in app/config/broadcast.ts. Use "memory" or "redis", or pass a BroadcastDriver.`)}class U7 extends Error{code;constructor($,Z=`OAuth callback failed: ${$}`){super(Z);this.name="OAuthCallbackError",this.code=$}}class fO{linkByEmail=!0;createUsers=!0;createUsersWithoutEmail=!1}import{createHash as L7,createHmac as bO,randomBytes as bX,timingSafeEqual as kX}from"crypto";var w3=600,C4="gemi_oauth",RO=`__Host-${C4}`;function qZ($,Z=C4){if(Z===C4)return $?RO:C4;return $?`__Host-${Z}`:Z}function R3($){return $.toString("base64url")}function qX($){return bO("sha256",zZ()).update(`gemi-oauth-state:${$}`).digest()}function RX($,Z){let J=L7("sha256").update($).digest(),W=L7("sha256").update(Z).digest();return kX(J,W)&&$.length===Z.length}function S4($,Z=Date.now(),J={}){let W=R3(bX(32)),Y=R3(bX(32)),j=wO(Y),z={provider:$,state:W,codeVerifier:Y,expiresAt:Z+w3*1000,...J.subject!==void 0?{subject:J.subject}:{},...J.returnTo!==void 0?{returnTo:J.returnTo}:{}};return{state:W,codeVerifier:Y,codeChallenge:j,cookieValue:kO(z)}}function wO($){return R3(L7("sha256").update($).digest())}function kO($){let Z=R3(Buffer.from(JSON.stringify($)));return`${Z}.${R3(qX(Z))}`}function qO($){if(typeof $!=="string"||$==="")return null;let Z=$.indexOf(".");if(Z<=0||Z!==$.lastIndexOf("."))return null;let J=$.slice(0,Z),W=Buffer.from($.slice(Z+1),"base64url"),Y=qX(J);if(W.length!==Y.length||!kX(W,Y))return null;try{let j=JSON.parse(Buffer.from(J,"base64url").toString("utf8"));if(typeof j?.provider!=="string"||typeof j?.state!=="string"||typeof j?.codeVerifier!=="string"||typeof j?.expiresAt!=="number"||j.subject!==void 0&&typeof j.subject!=="string"||j.returnTo!==void 0&&typeof j.returnTo!=="string")return null;return j}catch{return null}}var K$=new Map,wX=1e4;function yO($,Z,J){if(K$.size>=wX){for(let[W,Y]of K$)if(Y<=J)K$.delete(W);while(K$.size>=wX){let W=K$.keys().next().value;if(W===void 0)break;K$.delete(W)}}K$.set($,Z)}function A4($){let Z=$.now??Date.now();if(!$.cookieValue||!$.returnedState)return{ok:!1,reason:"missing_state"};let J=qO($.cookieValue);if(!J)return{ok:!1,reason:"invalid_state"};let W=RX(J.state,$.returnedState),Y=RX(J.provider,$.provider);if(!W||!Y)return{ok:!1,reason:"invalid_state"};if(J.expiresAt<=Z)return{ok:!1,reason:"expired_state"};if(K$.has(J.state))return{ok:!1,reason:"invalid_state"};return yO(J.state,J.expiresAt,Z),{ok:!0,payload:J}}var H7=new WeakMap;function gO($){let Z=H7.get($);if(!Z)Z=$(vO(32).toString("hex")),H7.set($,Z),Z.catch(()=>H7.delete($));return Z}async function I7($,Z,J){if(typeof J==="string"&&J!=="")return await $.verifyPassword(Z,J);try{await $.verifyPassword(Z,await gO($.hashPassword))}catch{}return!1}async function v$($,Z){let J=Z.user??Z.session?.user;if(!J||!$.onAuthenticated)return;let{password:W,...Y}=J;await $.onAuthenticated({...Z,user:Y})}class T7 extends Error{}function P7($){return typeof $==="string"&&$!==""?$:null}function yX($){return $3($)}var mO=256;function vX($){return typeof $==="string"&&$!==""&&$.length<=mO?$:null}var E4="intended_url";function mX($){if($.cookies.get(E4))$.ctx().setCookie(E4,"",{maxAge:-1})}function gX($){let Z=$.cookies.get(E4);if(!Z)return null;mX($);try{return j1(decodeURIComponent(Z),"")||null}catch{return null}}class M7 extends C{schema={email:{required:"Email is required",string:"Invalid email",email:"Invalid email"},password:{required:"Password is required"}}}class hX extends C{schema={email:{required:"Email is required",email:"Invalid email"}}}class pX extends C{schema={password:{required:"Password is required",password:"Invalid password"}}}function y1($){if(L(E).config[$]===!1)throw new Y0("Not found",{status:404})}class o extends tZ{async me(){let $=await R0.user();if(!$)throw new A8;return $}async verifyEmail($=new C){y1("password");let Z=await $.input(),{userProvider:J}=L(E),W=P7(Z.get("token"));if(!W)return{email:null};let Y=await J.findUserByVerificationToken(W);if(!Y)return{email:null};return await J.verifyUser(Y.email),{email:Y.email}}async signInWithMagicLink($=new C){let Z=L(E),{userProvider:J}=Z,W=P7($.search.get("token")),Y=null;try{Y=$3(decodeURIComponent($.search.get("email")??""))}catch{}if(await XZ("link",null,$,{perIp:Z.config.emailCode.verifyLimit.perIp}),!Y||!W||!await Z.verifyMagicLinkToken(Y,W))return{error:"Invalid token"};await J.verifyUser(Y);let j=await Z.createOrUpdateSession({email:Y});return $.ctx().setCookie("access_token",j.token,L(E).accessTokenCookieOptions($,j.expiresAt)),await Z.config.onSignIn(j,$.search.toJSON()),await v$(Z.config,{session:j,isNewUser:!1,method:"magic-link",req:$}),{session:j}}async verifyPinRequest($){y1("magicLink");let Z=L(E),J=await $.input(),{email:W,pin:Y}=J.toJSON(),j=$3(W),z=vX(Y);if(await XZ("verify",j,$,Z.config.emailCode.verifyLimit),!j||!z)throw new h({pin:["Invalid pin"]});let X=await Z.verifyOneTimeCode(j,z);if(X.status==="too_many_attempts")throw new h({pin:["Too many attempts"]});if(X.status!=="ok")throw new h({pin:["Invalid pin"]});return await Z.userProvider.verifyUser(j),j}async signInWithPinV2($=new C){let Z=L(E),J=await this.verifyPinRequest($),W=await Z.createOrUpdateSessionV2({email:J});return $.ctx().setCookie("access_token",W.token,L(E).accessTokenCookieOptions($,W.expiresAt)),await Z.config.onSignIn(W,$.search.toJSON()),await v$(Z.config,{session:W,isNewUser:!1,method:"magic-link",req:$}),W}async signInWithPin($=new C){let Z=L(E),J=await this.verifyPinRequest($),W=await Z.createOrUpdateSession({email:J});return $.ctx().setCookie("access_token",W.token,L(E).accessTokenCookieOptions($,W.expiresAt)),await Z.config.onSignIn(W,$.search.toJSON()),await v$(Z.config,{session:W,isNewUser:!1,method:"magic-link",req:$}),{session:W}}async signInV2($=new M7){y1("password");let Z=await $.input(),{email:J,password:W}=Z.toJSON(),Y=J.toLowerCase().trim(),j=L(E),z=await j.userProvider.findUserByEmailAddress(Y,j.config.verifyEmail),X=typeof W==="string"&&await I7(j.config,W,z?.password);if(!z||!X)throw new h({invalid_credentials:["Invalid credentials"]});let G=await j.createOrUpdateSessionV2({email:z.email,id:z.id});$.ctx().setCookie("access_token",G.token,L(E).accessTokenCookieOptions($,G.expiresAt)),await j.config.onSignIn(z,$.search.toJSON()),await v$(j.config,{session:G,user:z,isNewUser:!1,method:"password",req:$});let{password:Q,...K}=z;return K}async signIn($=new M7){y1("password");let Z=await $.input(),{email:J,password:W}=Z.toJSON(),Y=J.toLowerCase().trim(),j=L(E),z=await j.userProvider.findUserByEmailAddress(Y,j.config.verifyEmail),X=typeof W==="string"&&await I7(j.config,W,z?.password);if(!z||!X)throw new h({invalid_credentials:["Invalid credentials"]});let G=await j.createOrUpdateSession({email:z.email,id:z.id});$.ctx().setCookie("access_token",G.token,L(E).accessTokenCookieOptions($,G.expiresAt)),await j.config.onSignIn(z,$.search.toJSON()),await v$(j.config,{session:G,user:z,isNewUser:!1,method:"password",req:$});let{password:Q,...K}=z;return K}async signUp(){y1("password");let $=L(E),{userProvider:Z,config:J}=$,W=new J.signUpRequest,Y=await W.input(),{email:j,password:z,name:X,invitationId:G}=Y.toJSON(),Q=yX(j);if(!Q)throw new h({email:["Invalid email"]});if(z!=null&&typeof z!=="string")throw new h({password:["Invalid password"]});if(G!=null&&typeof G!=="string")throw new h({invitationId:["Invalid invitation"]});if(await Z.findUserByEmailAddress(Q,!1))throw new h({email:["Email address already exists"]});let B=await J.hashPassword(z),F=L(s).detectLocale(W),D;if(G)D=await Z.findInvitation(G,Q);let V,O="";if(D)V=await Z.transaction(async()=>{await Z.deleteInvitationById(G);let U=await Z.createUser({email:Q,name:X,password:B,emailVerifiedAt:new Date,locale:F});return await Z.createAccount({organizationId:D.organizationId,userId:U.id,organizationRole:D.role}),await J.onUserCreated(U),U});else O=await J.generateEmailVerificationToken(Q),V=await Z.transaction(async()=>{let U=await Z.createUser({email:Q,name:X,password:B,verificationToken:O,locale:F});return await J.onUserCreated(U),U});return await J.onSignUp(V,O,W.search.toJSON()),V}async signOut($=new C){let Z=O$($),J=L(E),{config:W}=J,Y=await J.revokeSession(Z,$.headers.get("User-Agent"));if($.ctx().setCookie("access_token","",L(E).accessTokenCookieOptions($,new Date(0))),L(E).cookieDomain($))$.ctx().setCookie("access_token","",{...L(E).accessTokenCookieOptions($,new Date(0)),domain:void 0});if(Y?.user)hO(Y.user),Y.user.extension=await W.extendSession(Y.user),await W.onSignOut(Y.user);return{}}async forgotPassword($=new hX){y1("password");let Z=await $.input(),J=yX(Z.get("email"));if(!J)return{};let{userProvider:W,config:Y}=L(E),j=await W.findUserByEmailAddress(J,Y.verifyEmail);if(!j)return{};let z=await Y.generateForgotPasswordToken(j);return await W.createPasswordResetToken({user:j,token:z}),await Y.onForgotPassword(j,z),{}}async resetPassword($=new pX){y1("password");let{userProvider:Z,config:J}=L(E),W=await $.input(),{password:Y,token:j}=W.toJSON(),z=P7(j),X=z?await Z.findPasswordResetToken({token:z}):null;if(!X)throw new h({token:["Invalid token"]});if(wZ.Instant.from(X.createdAt.toISOString()).add({hours:24}).until(wZ.Now.instant()).sign>=0)throw new h({token:["Token expired"]});await Z.deletePasswordResetToken({token:z});let Q=await Z.findUserByEmailAddress(X.user.email,J.verifyEmail);if(!Q)throw new h({email:["User not found"]});let K=await J.hashPassword(Y);return await Z.updateUserPassword({id:Q.id,password:K}),await Z.deleteAllUserSessions(Q.id),await J.onResetPassword(Q),{}}async changePassword($=new C){y1("password");let{userProvider:Z,config:J}=L(E),W=await R0.user(),Y=await $.input(),{oldPassword:j,newPassword:z}=Y.toJSON();if(typeof z!=="string")throw new h({newPassword:["Invalid password"]});let X=await Z.findUserByEmailAddress(W.email,J.verifyEmail);if(!(typeof j==="string"&&await I7(J,j,X?.password)))throw new h({oldPassword:["Incorrect password"]});let Q=await J.hashPassword(z);return await Z.updateUserPassword({id:W.id,password:Q}),await Z.deleteAllUserSessions(W.id),{}}async oauthRedirect($=new C){let{provider:Z}=$.params,J=L(E).config.oauthProviders,W=Object.hasOwn(J,Z),Y=await GZ(J,Z);if(!Y){if(W)throw new Y0("Not found",{status:404});throw Error(`Invalid provider: ${Z}`)}let j=ZZ($.rawRequest),z=j1($.search.get(Y1),"");if(z)$.ctx().setCookie(E4,encodeURIComponent(z),{httpOnly:!0,sameSite:"Lax",secure:j,maxAge:600});else mX($);let{state:X,codeChallenge:G,cookieValue:Q}=S4(Z);return $.ctx().setCookie(qZ(j),Q,{httpOnly:!0,sameSite:"Lax",secure:j,maxAge:w3}),{destination:await Y.getRedirectUrl($,{state:X,codeChallenge:G,codeChallengeMethod:"S256"})}}async oauthCallback($=new C){let{provider:Z}=$.params,J=L(E),{userProvider:W,config:Y}=J,j=Object.hasOwn(Y.oauthProviders,Z),z=await GZ(Y.oauthProviders,Z);if(j&&!z)throw new Y0("Not found",{status:404});let X=ZZ($.rawRequest),G=qZ(X),Q=$.cookies.get(G);if(Q!==void 0&&Q!==null)$.ctx().setCookie(G,"",{httpOnly:!0,sameSite:"Lax",secure:X,maxAge:-1});if(!z)return this.oauthFailure($,"unknown_provider");let K=$.search.get("error");if(K)return this.oauthFailure($,/^[a-z0-9_]{1,64}$/.test(K)?K:"provider_error");let B=A4({provider:Z,cookieValue:Q,returnedState:$.search.get("state")});if("reason"in B)return console.error(`Authentication error: OAuth callback refused (${B.reason})`),this.oauthFailure($,B.reason);if(!$.search.get("code"))return this.oauthFailure($,"missing_code");let F;try{F=await z.onCallback($,{state:B.payload.state,codeVerifier:B.payload.codeVerifier})}catch(P){if(P instanceof U7)return this.oauthFailure($,P.code);return console.error("Authentication error: OAuth provider callback failed",P),this.oauthFailure($,"provider_error")}let{name:D,username:V,providerId:O,emailVerified:U}=F??{},H=typeof F?.email==="string"?F.email:void 0,T=H?z6(H):null,I=O?await W.findUserBySocialAccount(Z,O):null,x="signin",A=!I&&!T&&!H&&!!O&&z.createUsersWithoutEmail===!0;if(!I&&A){if(z.createUsers===!1)return console.error(`Authentication error: a ${Z} sign-in is not linked to a user, and ${Z} does not create users`),this.oauthFailure($,"signup_disabled");try{I=await this.createOAuthUserWithoutEmail({provider:Z,providerId:O,name:D,username:V,locale:L(s).detectLocale($)}),x="signup"}catch(P){let k=await W.findUserBySocialAccount(Z,O);if(!k)throw P;I=k}}if(!I){if(!T)return console.error("Authentication error: No usable email returned from OAuth provider callback"),this.oauthFailure($,H?"invalid_email":O?"missing_email":"no_identity");if(U===!1)return console.error("Authentication error: OAuth provider returned an unverified email"),this.oauthFailure($,"email_not_verified");let P=L(s).detectLocale($);try{let k=await this.linkOAuthAccount({provider:Z,providerId:O,email:T,rawEmail:H,name:D,username:V,locale:P,linkExisting:z.linkByEmail!==!1,createUser:z.createUsers!==!1});if(k==="account_exists")return console.error(`Authentication error: a ${Z} sign-in matched an existing user by email, and ${Z} does not link by email`),this.oauthFailure($,"account_exists");if(k==="signup_disabled")return console.error(`Authentication error: a ${Z} sign-in is not linked to a user, and ${Z} does not create users`),this.oauthFailure($,"signup_disabled");if(k)I=k.user,x=k.action}catch(k){let m=O?await W.findUserBySocialAccount(Z,O):null;if(!m)throw k;I=m}if(!I)return this.oauthFailure($,"account_conflict")}let f=await J.createOrUpdateSessionV2({email:I.email,id:I.id});if($.ctx().setCookie("access_token",f.token,L(E).accessTokenCookieOptions($,f.expiresAt)),x==="signup")await Y.onSignUp(I,"",$.search.toJSON());else await Y.onSignIn(I,$.search.toJSON());await v$(J.config,{session:f,user:I,isNewUser:x==="signup",method:"oauth",req:$});let S=gX($)??Y.redirectPath,M=Y.oauthCompleteProfilePath?j1(Y.oauthCompleteProfilePath,""):"";if(M&&!I.email){let P=new URL(M,"http://gemi.invalid");P.searchParams.set(Y1,S),S=`${P.pathname}${P.search}${P.hash}`}return{session:f,redirectTo:S}}async createOAuthUserWithoutEmail($){let{userProvider:Z,config:J}=L(E);return await Z.transaction(async()=>{let W=await Z.createUser({email:null,name:$.name??$.username??"",locale:$.locale});return await Z.createSocialAccount({provider:$.provider,providerId:$.providerId,userId:W.id,username:$.username,expiresAt:new Date,accessToken:"",refreshToken:""}),await J.onUserCreated(W),W})}oauthFailure($,Z){let J=gX($),W=L(E).config.oauthFailurePath;if(W){let Y=j1(W,"");if(Y){let j=new URL(Y,"http://gemi.invalid");if(j.searchParams.set("error",Z),J)j.searchParams.set(Y1,J);M1.external(`${j.pathname}${j.search}${j.hash}`)}else console.error(`auth.oauthFailurePath must be a same-origin path, got ${JSON.stringify(W)}`)}return{session:null,error:Z,redirectTo:J}}async linkOAuthAccount($){let{provider:Z,providerId:J,email:W,rawEmail:Y,name:j,username:z,locale:X}=$,{userProvider:G,config:Q}=L(E),K=(V)=>({provider:Z,userId:V,email:W,username:z,providerId:J,expiresAt:new Date,accessToken:"",refreshToken:""}),B=await G.findUserByEmailAddress(W,!1),F=Y?.trim();if(!B&&F&&F!==W)B=await G.findUserByEmailAddress(F,!1);if(B){if($.linkExisting===!1)return"account_exists";if(!J)return{user:B,action:"signin"};let V=await G.findSocialAccounts(B.id,Z);if(V.some((U)=>U.providerId===J))return{user:B,action:"signin"};if(V.some((U)=>U.providerId))return console.error(`Authentication error: user ${B.id} is already linked to a different ${Z} account`),null;let O=V[0];if(O){if(!await G.claimSocialAccount(O,J))throw Error(`${Z} account link changed concurrently`)}else await G.createSocialAccount(K(B.id));return{user:B,action:"signin"}}if($.createUser===!1)return"signup_disabled";return{user:await G.transaction(async()=>{let V=await G.createUser({email:W,name:j,locale:X,emailVerifiedAt:new Date});if(J)await G.createSocialAccount(K(V.id));return await Q.onUserCreated(V),V}),action:"signup"}}async createMagicLinkToken($=new C){y1("magicLink");let Z=await $.input(),J=$3(Z.get("email")),W=L(E),{uniformMagicLinkResponse:Y,requestLimit:j}=W.config.emailCode;if(await XZ("request",J,$,j),!J)return{email:null};let{user:z,pin:X,token:G}=await W.createMagicLinkToken(J);if(z)return await W.config.onMagicLinkCreated(z,{email:J,pin:X,token:G}),{email:J};return{email:Y?J:null}}async requestEmailCode($=new C){let Z=L(E),J=Z.config.emailCode;if(!J.enabled)throw new Y0("Not found",{status:404});let W=await $.input(),Y=z6(W.get("email"));if(await XZ("request",Y,$,J.requestLimit),!Y)throw new h({email:["Invalid email"]});let j=await Z.userProvider.findUserByEmailAddress(Y,!1);if(j||J.createUser){let{pin:z,token:X}=await Z.issueOneTimeCode(Y,J.length);await J.send({email:Y,code:z,token:X,isNewUser:!j,req:$})}return{ok:!0}}async verifyEmailCode($=new C){let Z=L(E),{userProvider:J,config:W}=Z;if(!W.emailCode.enabled)throw new Y0("Not found",{status:404});let Y=await $.input(),{email:j,code:z,name:X}=Y.toJSON(),G=z6(j),Q=vX(z);if(await XZ("verify",G,$,W.emailCode.verifyLimit),!G||!Q)throw new h({code:["invalid_code"]});let K=await Z.verifyOneTimeCode(G,Q,{claim:!1});if(K.status==="too_many_attempts")throw new h({code:["too_many_attempts"]});if(K.status!=="ok")throw new h({code:["invalid_code"]});let B=K.row,F=await J.findUserByEmailAddress(G,!1),D=!1;if(F){if(!await J.claimMagicLinkToken(B.id))throw new h({code:["invalid_code"]});await J.verifyUser(G)}else if(W.emailCode.createUser){let O=L(s).detectLocale($);try{F=await J.transaction(async()=>{if(!await J.claimMagicLinkToken(B.id))throw new T7;let U=await J.createUser({email:G,name:typeof X==="string"?X.trim():"",emailVerifiedAt:new Date,locale:O});return await W.onUserCreated(U),U}),D=!0}catch(U){if(U instanceof T7)throw new h({code:["invalid_code"]});throw U}}else throw await J.claimMagicLinkToken(B.id),new h({code:["invalid_code"]});let V=await Z.createOrUpdateSessionV2({email:G,id:F.id});return $.ctx().setCookie("access_token",V.token,L(E).accessTokenCookieOptions($,V.expiresAt)),await W.onSignIn(V,$.search.toJSON()),await v$(Z.config,{session:V,isNewUser:D,method:"email-code",req:$}),{session:V,isNewUser:D}}}function hO($){try{let Z=$?.id;if(Z===void 0||Z===null)return;let J=L();if(typeof J?.bound!=="function"||!J.bound(m0))return;J.make(m0).revoke({user:{id:Z}})}catch(Z){console.error("[gemi] Revoking the signed-out user's sockets failed:",Z)}}var cX="gemi_oauth_connection";class f4 extends tZ{async connect($=new C){let Z=String($.params.provider??""),W=L(k3).providers[Z],Y=await R0.user(),j=j1($.search.get(Y1),"");if(!W)return this.finish(j,Z,"unknown_provider");let z=ZZ($.rawRequest),{state:X,codeChallenge:G,cookieValue:Q}=S4(dX(Z),Date.now(),{subject:String(Y.id),...j?{returnTo:j}:{}});return $.ctx().setCookie(qZ(z,cX),Q,{httpOnly:!0,sameSite:"Lax",secure:z,maxAge:w3}),M1.external(W.authorizationUrl({state:X,codeChallenge:G,redirectUri:uX($,Z,W.config.redirectUri)})),{destination:"/"}}async callback($=new C){let Z=String($.params.provider??""),J=L(k3),W=await R0.user(),Y=ZZ($.rawRequest),j=qZ(Y,cX),z=$.cookies.get(j);if(z!==void 0&&z!==null)$.ctx().setCookie(j,"",{httpOnly:!0,sameSite:"Lax",secure:Y,maxAge:-1});let X=A4({provider:dX(Z),cookieValue:z,returnedState:$.search.get("state")}),G="payload"in X?X.payload.returnTo??"":"",Q=J.providers[Z];if(!Q)return this.finish(G,Z,"unknown_provider");let K=$.search.get("error");if(K)return this.finish(G,Z,/^[a-z0-9_]{1,64}$/.test(K)?K:"provider_error");if("reason"in X)return console.error(`OAuth connection refused (${X.reason})`),this.finish(G,Z,X.reason);if(X.payload.subject!==String(W.id))return this.finish(G,Z,"user_mismatch");let B=$.search.get("code");if(!B)return this.finish(G,Z,"missing_code");try{let F=await Q.exchangeCode({code:B,codeVerifier:X.payload.codeVerifier,redirectUri:uX($,Z,Q.config.redirectUri)}),D=await J.save(W,Z,F);await L(E).config.onConnected({user:W,provider:Z,connection:D,profile:F.profile??null,req:$})}catch(F){if(F instanceof lX)return console.error(`OAuth connection to ${Z} failed: ${F.message}`),this.finish(G,Z,F.providerError??F.code);throw F}return this.finish(G,Z)}finish($,Z,J){let W=$||j1(L(E).config.redirectPath,"/"),Y=new URL(W,"http://gemi.invalid");if(Y.searchParams.set("connection",Z),J)Y.searchParams.set("connection_error",J);throw M1.external(`${Y.pathname}${Y.search}${Y.hash}`),Error("unreachable: Redirect.external throws")}}function dX($){return`connection:${$}`}function uX($,Z,J){if(J)return J;return`${q3()??new URL($.rawRequest.url).origin}/auth/connections/${encodeURIComponent(Z)}/callback`}class iX extends N1{middlewares=["cache:private"];routes={"/:provider":this.view("_Redirect",[o,"oauthRedirect"]),"/:provider/callback":this.view("auth/OauthCallback",[o,"oauthCallback"])}}class sX extends N1{middlewares=["cache:private"];routes={"/:provider":this.redirect([f4,"connect"]).middleware(["auth"]),"/:provider/callback":this.redirect([f4,"callback"]).middleware([t3,"auth"])}}class N7 extends N1{middlewares=["cache:private"];routes={"/sign-in/magic-link":this.view("auth/MagicLinkSignIn",[o,"signInWithMagicLink"]),"/oauth":iX,"/connections":sX}}class _7 extends N0{middlewares=["cache:private"];routes={"/sign-in":this.post(o,"signIn"),"/sign-in-v2":this.post(o,"signInV2"),"/sign-up":this.post(o,"signUp"),"/sign-out":this.post(o,"signOut"),"/forgot-password":this.post(o,"forgotPassword"),"/reset-password":this.post(o,"resetPassword"),"/change-password":this.post(o,"changePassword"),"/verify-email":this.post(o,"verifyEmail"),"/me":this.get(o,"me").middleware(["auth"]),"/magic-link":this.post(o,"createMagicLinkToken"),"/sign-in-with-pin":this.post(o,"signInWithPin"),"/sign-in-with-pin-v2":this.post(o,"signInWithPinV2"),"/email-code":this.post(o,"requestEmailCode"),"/email-code/verify":this.post(o,"verifyEmailCode")}}class x7 extends N0{middlewares=["cache:private,0,no-store"];routes={"/set-locale/:locale":this.get(async()=>{let Z=new C().params.locale;return await L(s).onLocaleChange(Z),{locale:Z}}),"/translations/:locale/:scope*":this.get(async()=>{let $=new C,Z=`/${$.params.scope??""}`,J=$.params.locale,W=L(s),Y=J??W.detectLocale($),j=W.getPageTranslations(Y,Z);return $.ctx().setCookie("i18n-locale",Y,{expires:new Date(Date.now()+31536000000)}),{[Y]:j}})}}class C7{}class S7 extends C7{async resize($,Z){let{height:J,width:W,quality:Y,fit:j}=Z;return await(await b4("The Sharp image optimization driver"))($).resize(W>0?W:void 0,J>0?J:void 0,{fit:j}).webp({quality:Y>0?Y:80,force:!0}).toBuffer()}}function fT($){return $}function nX(){return{driver:new S7}}class A7 extends N0{routes={"/resize":this.file(async()=>{let $=new C,Z=new URL($.rawRequest.url),J=Z.searchParams.get("url"),W=Number(Z.searchParams.get("w")),Y=Number(Z.searchParams.get("h")),j=Z.searchParams.get("fit")??"cover",z=Number(Z.searchParams.get("q"));if(!J)return new Response(JSON.stringify({error:"url query parameter is required"}),{headers:{"Content-Type":"application/json"},status:404});let G=`${J.startsWith("http")?"":`http://localhost:${process.env.PORT||5173}`}${J}`,Q=await fetch(G);if(!Q.ok)return new Response(JSON.stringify({error:"Image not found",info:G}),{headers:{"Content-Type":"application/json"},status:404});let K=Buffer.from(await Q.arrayBuffer()),B=await L(oX).resize(K,{height:Y,width:W,fit:j,quality:z});Q.headers.delete("Content-Type"),Q.headers.delete("Content-Length");let F=new Headers(Q.headers);return F.set("Content-Type","image/webp"),F.set("Content-Length",`${B.byteLength}`),new Response(new Uint8Array(B),{headers:F})})}}class oX{static token="image";driver;constructor($={}){this.driver=$.driver??nX().driver}resize($,Z){return this.driver.resize($,Z)}}class E7 extends N0{middlewares=["cache:private,0"];routes={"/live":this.get(async()=>{let $=Bun.file(L(aX).currentLogFilePath);return new Response(await $.text(),{headers:{"Content-Type":"text/plain"}})})}}function hT($){return $}function rX(){return{onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{}}}function tX(){return{partialRendering:!0,localeRouting:"prefix",onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{},onStreamComplete:()=>{}}}function pO($){return"run"in $}function cO($){return Object.hasOwn($,"get")||Object.hasOwn($,"post")||Object.hasOwn($,"put")||Object.hasOwn($,"patch")||Object.hasOwn($,"delete")}function dO($){return Object.hasOwn($,"first")&&Object.hasOwn($,"second")}function uO($){if("__brand"in $)return $.__brand==="ApiRouter";return!1}function lO($){if("__internal_brand"in $)return $.__internal_brand==="ProxyHandler";return!1}function eX($){if("__internal_brand"in $)return $.__internal_brand==="StreamHandler";return!1}function f7($,Z="",J=[]){let W={};function Y(j,z,X,G,Q){let K=j==="/"?"":j,B=Z==="/"?"":Z,F=(`${B}${K}`===""?"/":`${B}${K}`).replaceAll("//","/");if(!W[F])W[F]={};W[F][z.toUpperCase()]={exec:X,middleware:[...J,...G],...Q?{source:Q}:{}},W[F].OPTIONS={exec:()=>{let V=new C().ctx().headers;return new Response(null,{headers:V,status:204})},middleware:[]}}for(let[j,z]of Object.entries($)){if(lO(z)){let X=z;for(let G of["GET","POST","PUT","DELETE"])Y(j,G,X.run.bind(X),X.middlewares);continue}if(pO(z)){let X=z,G=X.method,Q=X.middlewares,K=X.run.bind(X);if(Y(j,G,K,Q,X.source),eX(z))Y(j,"HEAD",K,Q,X.source)}if(cO(z))for(let[X,G]of Object.entries(z)){let Q=G,K=Q.middlewares,B=Q.run.bind(Q);if(Y(j,X,B,K,Q.source),X==="get"&&eX(Q))Y(j,"HEAD",B,K,Q.source)}if(uO(z)){let X=new z,G=f7(X.routes,`${Z}${j}`,X.middlewares);for(let[Q,K]of Object.entries(G))W[Q.replaceAll("//","/")]=K}if(dO(z)){let{first:X,second:G}=z;for(let[Q,K]of Object.entries(X)){let B=K.middlewares,F=K.run.bind(K),[D,...V]=j.split("/").reverse();if(!D.startsWith(":"))throw Error("Resource route must end with a dynamic segment");Y(V.reverse().join("/"),Q,F,B,K.source)}for(let[Q,K]of Object.entries(G)){let B=K.middlewares,F=K.run.bind(K);Y(j,Q,F,B,K.source)}}}return Object.fromEntries(Object.entries(W).sort(([j],[z])=>{let X=j.split("/").length+j.split(":").length,G=z.split("/").length+z.split(":").length;return X-G}))}function R4($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function b7($,Z){if($==="/")return Z;if(Z==="/")return $;return`${$}${Z}`}function R7($){let Z=R4($);return Z.length>1?Z.replace(/\/$/,""):Z}function $G($,Z){return Z.map((J)=>({...J,path:R7(b7($,J.path))}))}function w4($){let Z={};for(let[J,W]of Object.entries($))if("run"in W){let Y=W;if("children"in Y){let j=new Y.children,z=w4(j.routes);for(let[X,{exec:G,middleware:Q,segments:K,features:B,static:F}]of Object.entries(z)){let D=b7(J,X),V=(O)=>Y.run.call(Y,O,J);Z[R4(D)]={exec:[V,...G],middleware:[...Y.middlewares,...Q],features:[...Y.featureGates,...B],viewPath:Y.viewPath,segments:[{path:R7(J),viewPath:Y.viewPath,...Y.alwaysRuns?{alwaysRun:!0}:{}},...$G(J,K)],...F?{static:F}:{}}}}else{let j=(z)=>Y.run.call(Y,z,J);Z[R4(J)]={exec:[j],middleware:Y.middlewares,features:Y.featureGates,viewPath:Y.viewPath,segments:[{path:R7(J),viewPath:Y.viewPath}],..."staticOptions"in Y&&Y.staticOptions?{static:Y.staticOptions}:{}}}}else{let Y=new W,j=w4(Y.routes);for(let[z,{exec:X,middleware:G,viewPath:Q,segments:K,features:B,static:F}]of Object.entries(j)){let D=b7(J,z);Z[R4(D)]={exec:X,middleware:[...Y.middlewares,...G],features:[...Y.featureGates,...B],viewPath:Q,segments:$G(J,K),...F?{static:F}:{}}}}return Object.fromEntries(Object.entries(Z).sort(([J],[W])=>{let Y=J.split("/").length+J.split(":").length,j=W.split("/").length+W.split(":").length;return Y-j}))}var iO=Object.defineProperty,_=($,Z)=>iO($,"name",{value:Z,configurable:!0}),gZ=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor($,Z,J,W,Y,j){this.type=$,this.name=Z,this.prefix=J,this.value=W,this.suffix=Y,this.modifier=j}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};_(gZ,"Part");var sO=/[$_\p{ID_Start}]/u,nO=/[$_\u200C\u200D\p{ID_Continue}]/u,k7=".*";function ZG($,Z){return(Z?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test($)}_(ZG,"isASCII");function v7($,Z=!1){let J=[],W=0;for(;W<$.length;){let Y=$[W],j=_(function(z){if(!Z)throw TypeError(z);J.push({type:"INVALID_CHAR",index:W,value:$[W++]})},"ErrorOrInvalid");if(Y==="*"){J.push({type:"ASTERISK",index:W,value:$[W++]});continue}if(Y==="+"||Y==="?"){J.push({type:"OTHER_MODIFIER",index:W,value:$[W++]});continue}if(Y==="\\"){J.push({type:"ESCAPED_CHAR",index:W++,value:$[W++]});continue}if(Y==="{"){J.push({type:"OPEN",index:W,value:$[W++]});continue}if(Y==="}"){J.push({type:"CLOSE",index:W,value:$[W++]});continue}if(Y===":"){let z="",X=W+1;for(;X<$.length;){let G=$.substr(X,1);if(X===W+1&&sO.test(G)||X!==W+1&&nO.test(G)){z+=$[X++];continue}break}if(!z){j(`Missing parameter name at ${W}`);continue}J.push({type:"NAME",index:W,value:z}),W=X;continue}if(Y==="("){let z=1,X="",G=W+1,Q=!1;if($[G]==="?"){j(`Pattern cannot start with "?" at ${G}`);continue}for(;G<$.length;){if(!ZG($[G],!1)){j(`Invalid character '${$[G]}' at ${G}.`),Q=!0;break}if($[G]==="\\"){X+=$[G++]+$[G++];continue}if($[G]===")"){if(z--,z===0){G++;break}}else if($[G]==="("&&(z++,$[G+1]!=="?")){j(`Capturing groups are not allowed at ${G}`),Q=!0;break}X+=$[G++]}if(Q)continue;if(z){j(`Unbalanced pattern at ${W}`);continue}if(!X){j(`Missing pattern at ${W}`);continue}J.push({type:"REGEX",index:W,value:X}),W=G;continue}J.push({type:"CHAR",index:W,value:$[W++]})}return J.push({type:"END",index:W,value:""}),J}_(v7,"lexer");function g7($,Z={}){let J=v7($);Z.delimiter??="/#?",Z.prefixes??="./";let W=`[^${h0(Z.delimiter)}]+?`,Y=[],j=0,z=0,X="",G=new Set,Q=_((I)=>{if(z<J.length&&J[z].type===I)return J[z++].value},"tryConsume"),K=_(()=>Q("OTHER_MODIFIER")??Q("ASTERISK"),"tryConsumeModifier"),B=_((I)=>{let x=Q(I);if(x!==void 0)return x;let{type:A,index:f}=J[z];throw TypeError(`Unexpected ${A} at ${f}, expected ${I}`)},"mustConsume"),F=_(()=>{let I="",x;for(;x=Q("CHAR")??Q("ESCAPED_CHAR");)I+=x;return I},"consumeText"),D=_((I)=>I,"DefaultEncodePart"),V=Z.encodePart||D,O="",U=_((I)=>{O+=I},"appendToPendingFixedValue"),H=_(()=>{O.length&&(Y.push(new gZ(3,"","",V(O),"",3)),O="")},"maybeAddPartFromPendingFixedValue"),T=_((I,x,A,f,S)=>{let M=3;switch(S){case"?":M=1;break;case"*":M=0;break;case"+":M=2;break}if(!x&&!A&&M===3){U(I);return}if(H(),!x&&!A){if(!I)return;Y.push(new gZ(3,"","",V(I),"",M));return}let P;A?A==="*"?P=k7:P=A:P=W;let k=2;P===W?(k=1,P=""):P===k7&&(k=0,P="");let m;if(x?m=x:A&&(m=j++),G.has(m))throw TypeError(`Duplicate name '${m}'.`);G.add(m),Y.push(new gZ(k,m,V(I),P,V(f),M))},"addPart");for(;z<J.length;){let I=Q("CHAR"),x=Q("NAME"),A=Q("REGEX");if(!x&&!A&&(A=Q("ASTERISK")),x||A){let S=I??"";Z.prefixes.indexOf(S)===-1&&(U(S),S=""),H();let M=K();T(S,x,A,"",M);continue}let f=I??Q("ESCAPED_CHAR");if(f){U(f);continue}if(Q("OPEN")){let S=F(),M=Q("NAME"),P=Q("REGEX");!M&&!P&&(P=Q("ASTERISK"));let k=F();B("CLOSE");let m=K();T(S,M,P,k,m);continue}H(),B("END")}return Y}_(g7,"parse");function h0($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}_(h0,"escapeString");function q7($){return $&&$.ignoreCase?"ui":"u"}_(q7,"flags");function JG($,Z,J){return m7(g7($,J),Z,J)}_(JG,"stringToRegexp");function g$($){switch($){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}_(g$,"modifierToString");function m7($,Z,J={}){J.delimiter??="/#?",J.prefixes??="./",J.sensitive??=!1,J.strict??=!1,J.end??=!0,J.start??=!0,J.endsWith="";let W=J.start?"^":"";for(let X of $){if(X.type===3){X.modifier===3?W+=h0(X.value):W+=`(?:${h0(X.value)})${g$(X.modifier)}`;continue}Z&&Z.push(X.name);let G=`[^${h0(J.delimiter)}]+?`,Q=X.value;if(X.type===1?Q=G:X.type===0&&(Q=k7),!X.prefix.length&&!X.suffix.length){X.modifier===3||X.modifier===1?W+=`(${Q})${g$(X.modifier)}`:W+=`((?:${Q})${g$(X.modifier)})`;continue}if(X.modifier===3||X.modifier===1){W+=`(?:${h0(X.prefix)}(${Q})${h0(X.suffix)})`,W+=g$(X.modifier);continue}W+=`(?:${h0(X.prefix)}`,W+=`((?:${Q})(?:`,W+=h0(X.suffix),W+=h0(X.prefix),W+=`(?:${Q}))*)${h0(X.suffix)})`,X.modifier===0&&(W+="?")}let Y=`[${h0(J.endsWith)}]|$`,j=`[${h0(J.delimiter)}]`;if(J.end)return J.strict||(W+=`${j}?`),J.endsWith.length?W+=`(?=${Y})`:W+="$",new RegExp(W,q7(J));J.strict||(W+=`(?:${j}(?=${Y}))?`);let z=!1;if($.length){let X=$[$.length-1];X.type===3&&X.modifier===3&&(z=J.delimiter.indexOf(X)>-1)}return z||(W+=`(?=${j}|${Y})`),new RegExp(W,q7(J))}_(m7,"partsToRegexp");var B$={delimiter:"",prefixes:"",sensitive:!0,strict:!0},oO={delimiter:".",prefixes:"",sensitive:!0,strict:!0},aO={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function WG($,Z){return $.length?$[0]==="/"?!0:!Z||$.length<2?!1:($[0]=="\\"||$[0]=="{")&&$[1]=="/":!1}_(WG,"isAbsolutePathname");function h7($,Z){return $.startsWith(Z)?$.substring(Z.length,$.length):$}_(h7,"maybeStripPrefix");function YG($,Z){return $.endsWith(Z)?$.substr(0,$.length-Z.length):$}_(YG,"maybeStripSuffix");function p7($){return!$||$.length<2?!1:$[0]==="["||($[0]==="\\"||$[0]==="{")&&$[1]==="["}_(p7,"treatAsIPv6Hostname");var jG=["ftp","file","http","https","ws","wss"];function c7($){if(!$)return!0;for(let Z of jG)if($.test(Z))return!0;return!1}_(c7,"isSpecialScheme");function zG($,Z){if($=h7($,"#"),Z||$==="")return $;let J=new URL("https://example.com");return J.hash=$,J.hash?J.hash.substring(1,J.hash.length):""}_(zG,"canonicalizeHash");function XG($,Z){if($=h7($,"?"),Z||$==="")return $;let J=new URL("https://example.com");return J.search=$,J.search?J.search.substring(1,J.search.length):""}_(XG,"canonicalizeSearch");function GG($,Z){return Z||$===""?$:p7($)?l7($):u7($)}_(GG,"canonicalizeHostname");function QG($,Z){if(Z||$==="")return $;let J=new URL("https://example.com");return J.password=$,J.password}_(QG,"canonicalizePassword");function KG($,Z){if(Z||$==="")return $;let J=new URL("https://example.com");return J.username=$,J.username}_(KG,"canonicalizeUsername");function FG($,Z,J){if(J||$==="")return $;if(Z&&!jG.includes(Z))return new URL(`${Z}:${$}`).pathname;let W=$[0]=="/";return $=new URL(W?$:"/-"+$,"https://example.com").pathname,W||($=$.substring(2,$.length)),$}_(FG,"canonicalizePathname");function BG($,Z,J){return d7(Z)===$&&($=""),J||$===""?$:i7($)}_(BG,"canonicalizePort");function VG($,Z){return $=YG($,":"),Z||$===""?$:k4($)}_(VG,"canonicalizeProtocol");function d7($){switch($){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}_(d7,"defaultPortForProtocol");function k4($){if($==="")return $;if(/^[-+.A-Za-z0-9]*$/.test($))return $.toLowerCase();throw TypeError(`Invalid protocol '${$}'.`)}_(k4,"protocolEncodeCallback");function OG($){if($==="")return $;let Z=new URL("https://example.com");return Z.username=$,Z.username}_(OG,"usernameEncodeCallback");function DG($){if($==="")return $;let Z=new URL("https://example.com");return Z.password=$,Z.password}_(DG,"passwordEncodeCallback");function u7($){if($==="")return $;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test($))throw TypeError(`Invalid hostname '${$}'`);let Z=new URL("https://example.com");return Z.hostname=$,Z.hostname}_(u7,"hostnameEncodeCallback");function l7($){if($==="")return $;if(/[^0-9a-fA-F[\]:]/g.test($))throw TypeError(`Invalid IPv6 hostname '${$}'`);return $.toLowerCase()}_(l7,"ipv6HostnameEncodeCallback");function i7($){if($===""||/^[0-9]*$/.test($)&&parseInt($)<=65535)return $;throw TypeError(`Invalid port '${$}'.`)}_(i7,"portEncodeCallback");function UG($){if($==="")return $;let Z=new URL("https://example.com");return Z.pathname=$[0]!=="/"?"/-"+$:$,$[0]!=="/"?Z.pathname.substring(2,Z.pathname.length):Z.pathname}_(UG,"standardURLPathnameEncodeCallback");function LG($){return $===""?$:new URL(`data:${$}`).pathname}_(LG,"pathURLPathnameEncodeCallback");function HG($){if($==="")return $;let Z=new URL("https://example.com");return Z.search=$,Z.search.substring(1,Z.search.length)}_(HG,"searchEncodeCallback");function IG($){if($==="")return $;let Z=new URL("https://example.com");return Z.hash=$,Z.hash.substring(1,Z.hash.length)}_(IG,"hashEncodeCallback");var PG=class{#j;#W=[];#Z={};#$=0;#Y=1;#Q=0;#X=0;#V=0;#O=0;#D=!1;constructor($){this.#j=$}get result(){return this.#Z}parse(){for(this.#W=v7(this.#j,!0);this.#$<this.#W.length;this.#$+=this.#Y){if(this.#Y=1,this.#W[this.#$].type==="END"){if(this.#X===0){this.#I(),this.#K()?this.#J(9,1):this.#F()?this.#J(8,1):this.#J(7,0);continue}else if(this.#X===2){this.#B(5);continue}this.#J(10,0);break}if(this.#V>0)if(this.#C())this.#V-=1;else continue;if(this.#x()){this.#V+=1;continue}switch(this.#X){case 0:this.#P()&&this.#B(1);break;case 1:if(this.#P()){this.#E();let $=7,Z=1;this.#M()?($=2,Z=3):this.#D&&($=2),this.#J($,Z)}break;case 2:this.#L()?this.#B(3):(this.#H()||this.#F()||this.#K())&&this.#B(5);break;case 3:this.#N()?this.#J(4,1):this.#L()&&this.#J(5,1);break;case 4:this.#L()&&this.#J(5,1);break;case 5:this.#S()?this.#O+=1:this.#A()&&(this.#O-=1),this.#_()&&!this.#O?this.#J(6,1):this.#H()?this.#J(7,0):this.#F()?this.#J(8,1):this.#K()&&this.#J(9,1);break;case 6:this.#H()?this.#J(7,0):this.#F()?this.#J(8,1):this.#K()&&this.#J(9,1);break;case 7:this.#F()?this.#J(8,1):this.#K()&&this.#J(9,1);break;case 8:this.#K()&&this.#J(9,1);break;case 9:break;case 10:break}}this.#Z.hostname!==void 0&&this.#Z.port===void 0&&(this.#Z.port="")}#J($,Z){switch(this.#X){case 0:break;case 1:this.#Z.protocol=this.#G();break;case 2:break;case 3:this.#Z.username=this.#G();break;case 4:this.#Z.password=this.#G();break;case 5:this.#Z.hostname=this.#G();break;case 6:this.#Z.port=this.#G();break;case 7:this.#Z.pathname=this.#G();break;case 8:this.#Z.search=this.#G();break;case 9:this.#Z.hash=this.#G();break;case 10:break}this.#X!==0&&$!==10&&([1,2,3,4].includes(this.#X)&&[6,7,8,9].includes($)&&(this.#Z.hostname??=""),[1,2,3,4,5,6].includes(this.#X)&&[8,9].includes($)&&(this.#Z.pathname??=this.#D?"/":""),[1,2,3,4,5,6,7].includes(this.#X)&&$===9&&(this.#Z.search??="")),this.#T($,Z)}#T($,Z){this.#X=$,this.#Q=this.#$+Z,this.#$+=Z,this.#Y=0}#I(){this.#$=this.#Q,this.#Y=0}#B($){this.#I(),this.#X=$}#U($){return $<0&&($=this.#W.length-$),$<this.#W.length?this.#W[$]:this.#W[this.#W.length-1]}#z($,Z){let J=this.#U($);return J.value===Z&&(J.type==="CHAR"||J.type==="ESCAPED_CHAR"||J.type==="INVALID_CHAR")}#P(){return this.#z(this.#$,":")}#M(){return this.#z(this.#$+1,"/")&&this.#z(this.#$+2,"/")}#L(){return this.#z(this.#$,"@")}#N(){return this.#z(this.#$,":")}#_(){return this.#z(this.#$,":")}#H(){return this.#z(this.#$,"/")}#F(){if(this.#z(this.#$,"?"))return!0;if(this.#W[this.#$].value!=="?")return!1;let $=this.#U(this.#$-1);return $.type!=="NAME"&&$.type!=="REGEX"&&$.type!=="CLOSE"&&$.type!=="ASTERISK"}#K(){return this.#z(this.#$,"#")}#x(){return this.#W[this.#$].type=="OPEN"}#C(){return this.#W[this.#$].type=="CLOSE"}#S(){return this.#z(this.#$,"[")}#A(){return this.#z(this.#$,"]")}#G(){let $=this.#W[this.#$],Z=this.#U(this.#Q).index;return this.#j.substring(Z,$.index)}#E(){let $={};Object.assign($,B$),$.encodePart=k4;let Z=JG(this.#G(),void 0,$);this.#D=c7(Z)}};_(PG,"Parser");var w7=["protocol","username","password","hostname","port","pathname","search","hash"],F$="*";function y7($,Z){if(typeof $!="string")throw TypeError("parameter 1 is not of type 'string'.");let J=new URL($,Z);return{protocol:J.protocol.substring(0,J.protocol.length-1),username:J.username,password:J.password,hostname:J.hostname,port:J.port,pathname:J.pathname,search:J.search!==""?J.search.substring(1,J.search.length):void 0,hash:J.hash!==""?J.hash.substring(1,J.hash.length):void 0}}_(y7,"extractValues");function D1($,Z){return Z?vZ($):$}_(D1,"processBaseURLString");function yZ($,Z,J){let W;if(typeof Z.baseURL=="string")try{W=new URL(Z.baseURL),Z.protocol===void 0&&($.protocol=D1(W.protocol.substring(0,W.protocol.length-1),J)),!J&&Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.username===void 0&&($.username=D1(W.username,J)),!J&&Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.username===void 0&&Z.password===void 0&&($.password=D1(W.password,J)),Z.protocol===void 0&&Z.hostname===void 0&&($.hostname=D1(W.hostname,J)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&($.port=D1(W.port,J)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&($.pathname=D1(W.pathname,J)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&Z.search===void 0&&($.search=D1(W.search.substring(1,W.search.length),J)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&Z.search===void 0&&Z.hash===void 0&&($.hash=D1(W.hash.substring(1,W.hash.length),J))}catch{throw TypeError(`invalid baseURL '${Z.baseURL}'.`)}if(typeof Z.protocol=="string"&&($.protocol=VG(Z.protocol,J)),typeof Z.username=="string"&&($.username=KG(Z.username,J)),typeof Z.password=="string"&&($.password=QG(Z.password,J)),typeof Z.hostname=="string"&&($.hostname=GG(Z.hostname,J)),typeof Z.port=="string"&&($.port=BG(Z.port,$.protocol,J)),typeof Z.pathname=="string"){if($.pathname=Z.pathname,W&&!WG($.pathname,J)){let Y=W.pathname.lastIndexOf("/");Y>=0&&($.pathname=D1(W.pathname.substring(0,Y+1),J)+$.pathname)}$.pathname=FG($.pathname,$.protocol,J)}return typeof Z.search=="string"&&($.search=XG(Z.search,J)),typeof Z.hash=="string"&&($.hash=zG(Z.hash,J)),$}_(yZ,"applyInit");function vZ($){return $.replace(/([+*?:{}()\\])/g,"\\$1")}_(vZ,"escapePatternString");function TG($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}_(TG,"escapeRegexpString");function MG($,Z){Z.delimiter??="/#?",Z.prefixes??="./",Z.sensitive??=!1,Z.strict??=!1,Z.end??=!0,Z.start??=!0,Z.endsWith="";let J=".*",W=`[^${TG(Z.delimiter)}]+?`,Y=/[$_\u200C\u200D\p{ID_Continue}]/u,j="";for(let z=0;z<$.length;++z){let X=$[z];if(X.type===3){if(X.modifier===3){j+=vZ(X.value);continue}j+=`{${vZ(X.value)}}${g$(X.modifier)}`;continue}let G=X.hasCustomName(),Q=!!X.suffix.length||!!X.prefix.length&&(X.prefix.length!==1||!Z.prefixes.includes(X.prefix)),K=z>0?$[z-1]:null,B=z<$.length-1?$[z+1]:null;if(!Q&&G&&X.type===1&&X.modifier===3&&B&&!B.prefix.length&&!B.suffix.length)if(B.type===3){let F=B.value.length>0?B.value[0]:"";Q=Y.test(F)}else Q=!B.hasCustomName();if(!Q&&!X.prefix.length&&K&&K.type===3){let F=K.value[K.value.length-1];Q=Z.prefixes.includes(F)}Q&&(j+="{"),j+=vZ(X.prefix),G&&(j+=`:${X.name}`),X.type===2?j+=`(${X.value})`:X.type===1?G||(j+=`(${W})`):X.type===0&&(!G&&(!K||K.type===3||K.modifier!==3||Q||X.prefix!=="")?j+="*":j+=`(${J})`),X.type===1&&G&&X.suffix.length&&Y.test(X.suffix[0])&&(j+="\\"),j+=vZ(X.suffix),Q&&(j+="}"),X.modifier!==3&&(j+=g$(X.modifier))}return j}_(MG,"partsToPattern");var s7=class{#j;#W={};#Z={};#$={};#Y={};#Q=!1;constructor($={},Z,J){try{let W;if(typeof Z=="string"?W=Z:J=Z,typeof $=="string"){let X=new PG($);if(X.parse(),$=X.result,W===void 0&&typeof $.protocol!="string")throw TypeError("A base URL must be provided for a relative constructor string.");$.baseURL=W}else{if(!$||typeof $!="object")throw TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(W)throw TypeError("parameter 1 is not of type 'string'.")}typeof J>"u"&&(J={ignoreCase:!1});let Y={ignoreCase:J.ignoreCase===!0},j={pathname:F$,protocol:F$,username:F$,password:F$,hostname:F$,port:F$,search:F$,hash:F$};this.#j=yZ(j,$,!0),d7(this.#j.protocol)===this.#j.port&&(this.#j.port="");let z;for(z of w7){if(!(z in this.#j))continue;let X={},G=this.#j[z];switch(this.#Z[z]=[],z){case"protocol":Object.assign(X,B$),X.encodePart=k4;break;case"username":Object.assign(X,B$),X.encodePart=OG;break;case"password":Object.assign(X,B$),X.encodePart=DG;break;case"hostname":Object.assign(X,oO),p7(G)?X.encodePart=l7:X.encodePart=u7;break;case"port":Object.assign(X,B$),X.encodePart=i7;break;case"pathname":c7(this.#W.protocol)?(Object.assign(X,aO,Y),X.encodePart=UG):(Object.assign(X,B$,Y),X.encodePart=LG);break;case"search":Object.assign(X,B$,Y),X.encodePart=HG;break;case"hash":Object.assign(X,B$,Y),X.encodePart=IG;break}try{this.#Y[z]=g7(G,X),this.#W[z]=m7(this.#Y[z],this.#Z[z],X),this.#$[z]=MG(this.#Y[z],X),this.#Q=this.#Q||this.#Y[z].some((Q)=>Q.type===2)}catch{throw TypeError(`invalid ${z} pattern '${this.#j[z]}'.`)}}}catch(W){throw TypeError(`Failed to construct 'URLPattern': ${W.message}`)}}get[Symbol.toStringTag](){return"URLPattern"}test($={},Z){let J={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&Z)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return!1;try{typeof $=="object"?J=yZ(J,$,!1):J=yZ(J,y7($,Z),!1)}catch{return!1}let W;for(W of w7)if(!this.#W[W].exec(J[W]))return!1;return!0}exec($={},Z){let J={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&Z)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return;try{typeof $=="object"?J=yZ(J,$,!1):J=yZ(J,y7($,Z),!1)}catch{return null}let W={};Z?W.inputs=[$,Z]:W.inputs=[$];let Y;for(Y of w7){let j=this.#W[Y].exec(J[Y]);if(!j)return null;let z={};for(let[X,G]of this.#Z[Y].entries())if(typeof G=="string"||typeof G=="number"){let Q=j[X+1];z[G]=Q}W[Y]={input:J[Y]??"",groups:z}}return W}static compareComponent($,Z,J){let W=_((X,G)=>{for(let Q of["type","modifier","prefix","value","suffix"]){if(X[Q]<G[Q])return-1;if(X[Q]===G[Q])continue;return 1}return 0},"comparePart"),Y=new gZ(3,"","","","",3),j=new gZ(0,"","","","",3),z=_((X,G)=>{let Q=0;for(;Q<Math.min(X.length,G.length);++Q){let K=W(X[Q],G[Q]);if(K)return K}return X.length===G.length?0:W(X[Q]??Y,G[Q]??Y)},"comparePartList");return!Z.#$[$]&&!J.#$[$]?0:Z.#$[$]&&!J.#$[$]?z(Z.#Y[$],[j]):!Z.#$[$]&&J.#$[$]?z([j],J.#Y[$]):z(Z.#Y[$],J.#Y[$])}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.#Q}};_(s7,"URLPattern");function y3($,Z){for(let[J,W]of Object.entries($)){let Y=new s7({pathname:J});if(Y.test({pathname:Z}))return{routePath:J,params:Y.exec({pathname:Z})?.pathname.groups??{},route:W}}return null}var m$={startIndex:0,carriedViews:[]};function NG($,Z){let J=B0($.path,Z);return J.includes("*")?null:J}function rO($,Z){if(!$)return m$;if($.search!==Z.search)return m$;let J=Math.min($.segments.length,Z.segments.length-1),W=0;while(W<J){let Y=$.segments[W],j=Z.segments[W];if(j.alwaysRun)break;if(Y.viewPath!==j.viewPath)break;let z=NG(Y,$.params),X=NG(j,Z.params);if(z===null||X===null||z!==X)break;W++}if(W===0)return m$;return{startIndex:W,carriedViews:Z.segments.slice(0,W).map(({viewPath:Y})=>Y)}}function tO($,Z){let[,J,...W]=$.split("/");if(!Z.includes(J))return $;let Y=`/${W.join("/")}`;return Y==="/"?"/":Y.replace(/\/$/,"")}function _G($){let{flatViewRoutes:Z,supportedLocales:J,from:W,origin:Y,to:j}=$;if(!W)return m$;let z;try{z=new URL(W,Y)}catch{return m$}if(z.origin!==Y)return m$;let X=y3(Z,tO(z.pathname,J));if(!X)return m$;return rO({segments:X.route.segments,params:X.params,search:z.search},j)}var n7="x-gemi-from";import{createElement as g1,Fragment as dG}from"react";function eO($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function q4($){let Z={};for(let[J,W]of Object.entries($))if("run"in W){let Y=W.viewPath;if("children"in W){Z[J]=[Y];let j=new W.children,z=q4(j.routes);for(let[X,G]of Object.entries(z)){let Q=J==="/"?X:`${J}${X}`,K=X==="/"&&J!=="/"?J:Q;Z[K]=[Y,...G]}if(Z[J].length===1)delete Z[J]}else Z[J]=[Y]}else{let Y=new W,j=q4(Y.routes);for(let[z,X]of Object.entries(j)){let G=J==="/"?z:`${J}${z}`,Q=z==="/"&&J!=="/"?J:G;Z[Q]=X}}return Object.fromEntries(Object.entries(Z).map(([J,W])=>[eO(J),W]))}function y4($,Z){let[J,W]=Z,Y=$.find(([j])=>j===J);if(!Y){$.push([J,[...W]]);return}for(let j of W)y4(Y[1],j)}function v4($){let Z=[];for(let[J,W]of Object.entries($))if("run"in W){let Y=W.viewPath;if(Y==="__")continue;if(Y==="REDIRECT")continue;if(Y==="FILE")continue;if("children"in W){let j=new W.children,z=v4(j.routes);y4(Z,[Y,z])}else y4(Z,[Y,[]])}else{let Y=new W,j=v4(Y.routes);for(let z of j)y4(Z,z)}return Z}function o7($){let Z=[];for(let[J,W]of $)Z.push(J,...o7(W).flat());return Array.from(new Set(Z))}class V$ extends v{static getFacadeAccessor(){return s}static getSupportedLocales(){return this.getFacadeRoot().supportedLocales}static getDefaultLocale(){return this.getFacadeRoot().defaultLocale}static locale(){let $=this.getFacadeRoot(),Z=N.getStore();if(Z)return Z.locale??$.detectLocale(Z.req);return $.defaultLocale}static timeZone(){return this.getFacadeRoot().detectTimeZone(N.getStore()?.req)}static formatter($={}){return this.getFacadeRoot().formatter($.locale??V$.locale(),$.timeZone??V$.timeZone())}static setLocale($=V$.locale(),Z={}){let J=this.getFacadeRoot(),W=$;if(!J.supportedLocales.includes($))W=J.defaultLocale;let Y=N.getStore();if(Z.cookie!==!1)Y.setCookie("i18n-locale",W,{expires:new Date(Date.now()+31536000000),secure:!1,httpOnly:!1});return Y.setLocale(W),W}}class a7{id;static token="kernel.id";constructor($=crypto.randomUUID()){this.id=$}}function xG($){return Object.fromEntries(Object.entries($).filter(([,Z])=>{return Z!==null&&Z!==void 0}))}var $D=50;class mZ{fetcher;entries=new Map;settleListener=null;failListener=null;shellAt=null;settledBacklog=[];shipped=new Set;requestStartedAt=performance.now();renderStartedAt=null;discoveryHintsMuted=!1;constructor($){this.fetcher=$}elapsed(){return Math.round(performance.now()-this.requestStartedAt)}keyFor($,Z){return[$,Z].filter((J)=>J.length>0).join("?")}markRenderStart(){if(this.renderStartedAt===null)this.renderStartedAt=performance.now()}markShell(){if(this.shellAt===null)this.shellAt=this.elapsed()}summarize($){let Z=this.elapsed();return{shellAt:this.shellAt??Z,settledAt:Z,aborted:$,queries:Array.from(this.entries.values(),(J)=>({path:J.path,variantKey:J.variantKey,startedAt:J.startedAt,settledAt:J.settledAt,status:J.status,source:J.source}))}}onQueryFail($){this.failListener=$}muteDiscoveryHints(){this.discoveryHintsMuted=!0}maybeLogLateDiscovery($){if(!$.lateBy||this.discoveryHintsMuted)return;if($.status!=="resolved")return;if(Bun.env.NODE_ENV==="production")return;let Z="";try{let Y=JSON.stringify($.data)?.length??0;Z=Y>=1024?`${(Y/1024).toFixed(1)} kB`:`${Y} B`}catch{Z="an unserializable payload"}let J=($.settledAt??0)-$.startedAt,W=$.variantKey?`, { search: ${JSON.stringify(Object.fromEntries(new URLSearchParams($.variantKey)))} }`:"";console.warn(`[gemi] useQuery("${$.patternPath}") was discovered ${$.lateBy}ms into the `+`server render \u2014 under a suspended segment, so its fetch (${J}ms, resolved ${Z}) could not overlap the others. It still streamed. If the query belongs on this route, \`Query.prefetch("${$.patternPath}"${W})\` in the view `+"handler starts it at request time \u2014 but note prefetched data is also re-fetched and "+`streamed into every client-side navigation payload for the route, even when the client already holds it, so weigh that bandwidth against the ${Z}. If the data is only needed conditionally (a closed popover, a hidden tab), \`{ lazy: true }\` + \`trigger()\` avoids running it here at all. \`Query.noPrefetch()\` in the handler marks the omission intentional and silences this hint for the route.`)}read($,Z){return this.entries.get(this.keyFor($,Z))}ensure($,Z={},J="render"){let W=Z.params??{},Y=new URLSearchParams(xG(Z.search??{}));Y.delete("json"),Y.sort();let j=B0($,W),z=Y.toString(),X=this.keyFor(j,z),G=this.entries.get(X);if(G)return G;let Q;if(J==="render"&&this.renderStartedAt!==null){let D=Math.round(performance.now()-this.renderStartedAt);if(D>$D)Q=D}let K,B=new Promise((D)=>{K=D}),F={path:j,patternPath:$,variantKey:z,lateBy:Q,status:"pending",promise:B,source:J,startedAt:this.elapsed()};return this.entries.set(X,F),this.fetcher($,W,Y).then((D)=>{F.status="resolved",F.data=D},(D)=>{F.status="rejected",F.error=D}).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);K()}),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,J]of this.entries){if(J.status!=="resolved")continue;this.shipped.add(Z),$[J.path]??={},$[J.path][J.variantKey]=J.data}return $}onSettle($){this.settleListener=(J)=>{if(this.shipped.has(this.keyFor(J.path,J.variantKey)))return;$(J)};let Z=this.settledBacklog;this.settledBacklog=[];for(let J of Z)this.settleListener(J)}}class v1 extends Error{path;variantKey;status;body;retryAfter;constructor($,Z,J,W,Y){super(typeof W?.message==="string"?W.message:`Request to /api${$} failed with status ${J}`);this.path=$;this.variantKey=Z;this.status=J;this.body=W;this.retryAfter=Y;this.name="QueryError"}}function hZ(){let $=JSON.stringify({error:l1("permission","Forbidden",403)});return new Response($,{status:403,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}function r7(){return{status:403,error:{message:"Forbidden"}}}function v3($){let Z=pZ.getStore();return(J,W,Y)=>{let j=new URL($.url).origin,z=[B0(J,W),Y.toString()].filter((K)=>K.length>0).join("?"),X=new Request(`${j}/${z}`,{headers:$.headers,signal:$.signal}),G=CG($);if(G)cZ(X,G);let Q=new C(X,W);return pZ.run(Z,()=>N.run(Q,async()=>{try{let K=await L(W1).dispatchers(G).api.getRouteData(J);if($Z(K)){if(!K.ok)throw new v1(B0(J,W),Y.toString(),K.status,K.body);return K.body}if(K instanceof Response){let B=await K.json().catch(()=>null);if(!K.ok)throw new v1(B0(J,W),Y.toString(),K.status,B);return B}return K}catch(K){if(K instanceof v1)throw K;let B=new v1(B0(J,W),Y.toString(),500,{message:K instanceof Error?K.message:String(K)});throw B.cause=K,B}}))}}var ZD=new Set(["script","style","template","title"]),JD=/\shidden([\s=/]|$)/i,WD=/"[^"]*"|'[^']*'/g;function YD($){let Z=0,J=0,W=0,Y=0;while(Y<$.length){let j=$.indexOf("<",Y),z=j===-1?$.length:j;if(z>Y){let B=$.slice(Y,z).replace(/\s+/g,"").length;if(W>0)J+=B;else Z+=B}if(j===-1)break;if($.startsWith("<!--",j)){let B=$.indexOf("-->",j+4);Y=B===-1?$.length:B+3;continue}let X=$.indexOf(">",j);if(X===-1)break;let G=$.slice(j+1,X);Y=X+1;let Q=/^\/?([a-zA-Z][a-zA-Z0-9-]*)/.exec(G)?.[1]?.toLowerCase();if(!Q)continue;let K=G.startsWith("/");if(!K&&ZD.has(Q)&&!G.endsWith("/")){let B=$.indexOf(`</${Q}`,Y);Y=B===-1?$.length:B;continue}if(Q!=="div")continue;if(K){if(W>0)W-=1}else if(W>0)W+=1;else if(JD.test(G.replace(WD,'""')))W=1}return{shellChars:Z,deferredChars:J}}var jD=1000,zD=64;function XD($){return $>=1000?`${($/1000).toFixed(1)} kB`:`${$} chars`}function GD($,Z){if(Z.deferredChars<jD)return null;if(Z.shellChars>=zD)return null;return`[gemi] GET ${$} streams ${XD(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 SG($=console.warn){let Z=new Set;return{shouldObserve(J){return!Z.has(J)},report(J,W){if(Z.has(J))return;let Y=GD(J,W);if(!Y)return;Z.add(J),$(Y)}}}function AG(){let $=new TextDecoder,Z="";return{onChunk(J){Z+=$.decode(J,{stream:!0})},measure(){return Z+=$.decode(),YD(Z)}}}function EG($,Z,J=1e4,W){let Y=new TextEncoder,j=()=>{};return new ReadableStream({start(z){let X=!1,G=(K)=>{if(X)return;X=!0,clearTimeout(Q);try{z.close()}catch{}W?.({aborted:K})};j=G,z.enqueue(Y.encode(`${JSON.stringify($)}
|
|
13
|
+
`)}function KF($,Z={}){let J=new Headers(Z.headers);if(!J.has("content-type"))J.set("content-type","text/plain; charset=utf-8");return new Response(cW($),{status:200,headers:J})}var dW={response:KF,text:cW,parse:pW,fetch:QF};import{createHmac as uW,randomBytes as FF}from"crypto";var E8="v2.";function f8($){return $.startsWith(E8)}function zZ(){let $=process.env.SECRET;if(!$)throw Error("Signing in needs a secret to mint session tokens with. Set SECRET in the environment.");return $}function lW($){let Z=FF(16).toString("hex"),J=uW("sha256",zZ()).update(`${$}:${Z}`).digest("hex");return`${E8}${J}`}function Y6($,Z){let J=uW("sha256",zZ()).update(`legacy-session:${Z}:${$}`).digest("hex");return`${E8}${J}`}import{createHash as OF,createHmac as DF,randomInt as UF,timingSafeEqual as nW}from"crypto";function iW($,Z){return Math.floor($/Z)*Z}function BF($,Z){if(Z<=0)return 0;return Math.min(1,Math.max(0,(Z-$)/Z))}function b8($,Z,J,W){return Z*BF(J,W)+$}function VF($){let{current:Z,previous:J,elapsed:W,window:Y,limit:j,cost:z}=$,X=j-z;if(X<0)return Y;let G=Math.max(0,Y-W);if(J>0){let K=Y*(1-(X-Z)/J);if(K<=Y)return Math.max(0,Math.ceil(K-W))}if(Z<=X)return G;if(Z<=0)return G;let Q=Y*(1-X/Z);return G+Math.max(0,Math.ceil(Q))}function sW($){let{allowed:Z,current:J,previous:W,now:Y,elapsed:j,window:z,limit:X,cost:G}=$;if(Z){let K=b8(J,W,j,z);return{allowed:!0,limit:X,remaining:Math.max(0,Math.floor(X-K)),resetAt:Y-j+z,retryAfter:0}}let Q=VF({current:J,previous:W,elapsed:j,window:z,limit:X,cost:G});return{allowed:!1,limit:X,remaining:0,resetAt:Y+Q,retryAfter:Q}}class R8{}class w8 extends R8{buckets=new Map;maxKeys;constructor($={}){super();this.maxKeys=Math.max(1,$.maxKeys??1e5)}consume($){let{key:Z,limit:J,window:W}=$,Y=$.cost??1,j=Date.now(),z=iW(j,W),X=j-z,G=this.roll(Z,W,z);G.limit=J;let K=b8(G.current,G.previous,X,W)+Y<=J;if(K)G.current+=Y;if(this.buckets.delete(Z),this.buckets.set(Z,G),this.buckets.size>this.maxKeys)this.evict(j);return sW({allowed:K,current:G.current,previous:G.previous,now:j,elapsed:X,window:W,limit:J,cost:Y})}clear(){this.buckets.clear()}get size(){return this.buckets.size}roll($,Z,J){let W=this.buckets.get($);if(!W||W.window!==Z)return{window:Z,limit:0,windowStart:J,current:0,previous:0};if(W.windowStart===J)return W;if(W.windowStart+Z===J)return W.previous=W.current,W.current=0,W.windowStart=J,W;return W.previous=0,W.current=0,W.windowStart=J,W}evict($){for(let[W,Y]of this.buckets)if($-Y.windowStart>=Y.window*2)this.buckets.delete(W);let Z=this.maxKeys-Math.floor(this.maxKeys/10);if(this.buckets.size<=Z)return;let J=[...this.buckets].map(([W,Y],j)=>({key:W,order:j,spent:Y.limit>0?(Y.current+Y.previous)/Y.limit:0}));J.sort((W,Y)=>W.spent-Y.spent||W.order-Y.order);for(let{key:W}of J){if(this.buckets.size<=Z)break;this.buckets.delete(W)}}}var rW="h1.";function j6($,Z,J){let W=DF("sha256",zZ()).update(`gemi:one-time:${$}:${Z}:${J}`).digest("hex");return`${rW}${W}`}function eZ($,Z,J,W){let Y=typeof W==="string"?W:"",j=typeof J==="string"?J:"",z=j.startsWith(rW),X=j6($,Z,Y),G=Buffer.from(z?X:Y),Q=Buffer.from(j);if(G.length!==Q.length||Y===""||j==="")return nW(G,G),!1;return nW(G,Q)}function tW($){let Z="";for(let J=0;J<$;J++)Z+=String(UF(0,10));return Z}var eW=320;function $3($){if(typeof $!=="string")return null;let Z=$.trim();if(Z===""||Z.length>eW)return null;return Z.toLowerCase()}function z6($){if(typeof $!=="string")return null;let Z=$.trim();if(Z.length>eW)return null;let J=Z.toLowerCase();if(J.length<3||J.length>254||!/^[^\s@]+@[^\s@]+$/.test(J))return null;return J}var oW=null;function $5(){try{let $=L();if(typeof $?.bound==="function"&&$.bound(z1))return $.make(z1)}catch{}return oW??=new z1({driver:new w8,limit:1000,window:60}),oW}function aW($){return $.length<=64?$:`sha256:${OF("sha256").update($).digest("hex")}`}async function XZ($,Z,J,W){let Y=$5(),j=[[`auth:code-${$}:ip:${aW(JZ(J))}`,W.perIp]];if(Z!==null)j.push([`auth:code-${$}:email:${aW(Z)}`,W.perEmail]);for(let[z,X]of j){if(!X)continue;let[G,Q]=X,K=await Y.consume(z,{limit:G,window:Q});if(!K.allowed)throw new i1(K)}}async function Z5($,Z,J,W=10){let Y=Math.max(86400,Math.ceil(W*60*(J+1)));return(await $5().consume(`auth:code-attempt:${$}:${Z}`,{limit:J,window:Y})).allowed}import{randomBytes as q8}from"crypto";class k8 extends C{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 X6($,Z,J,W=1/0){if(!Number.isInteger(Z)||Z<J||Z>W){let Y=W===1/0?`an integer of at least ${J}`:`an integer from ${J} to ${W}`;throw Error(`auth.emailCode.${$} must be ${Y}, got ${Z}`)}}function LF($={}){for(let Z of["password","magicLink"]){let J=$?.[Z];if(J!==void 0&&typeof J!=="boolean")throw Error(`auth.${Z} must be true or false, got ${JSON.stringify(J)}`)}}function y8($={}){let Z=$.length??6,J=$.expiresInMinutes??10,W=$.linkExpiresInMinutes??10080,Y=$.maxAttempts??5;return X6("length",Z,4,12),X6("expiresInMinutes",J,1),X6("linkExpiresInMinutes",W,1),X6("maxAttempts",Y,1),{enabled:$.enabled??!1,createUser:$.createUser??!1,length:Z,expiresInMinutes:J,linkExpiresInMinutes:W,maxAttempts:Y,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:j,code:z})=>{if(Bun.env.NODE_ENV!=="production")console.info(`[gemi] email code for ${j}: ${z} (set auth.emailCode.send to deliver it)`)})}}async function HF($,Z){if(typeof Z!=="string"||Z==="")return!1;try{return await Bun.password.verify($,Z)}catch{return!1}}function J5($){if(!$)return null;if(typeof $.getRedirectUrl==="function")return{provider:$};let{provider:Z,feature:J}=$;return{provider:Z,...J!==void 0?{feature:J}:{}}}function W5($){for(let[Z,J]of Object.entries($??{})){if(typeof J?.getRedirectUrl==="function")continue;let W=J;if(typeof W?.provider?.getRedirectUrl!=="function")throw Error(`auth.oauthProviders.${Z} must be an OAuthProvider, or { provider, feature } with an OAuthProvider.`);if(W.feature!==void 0&&(typeof W.feature!=="string"||W.feature===""))throw Error(`auth.oauthProviders.${Z}.feature must be a feature key from app/features.`)}}function xI($){return $}function Y5($={}){return LF($),{basePath:"/auth",verifyEmail:!0,password:!0,magicLink:!0,redirectPath:"/dashboard",signInPath:"/auth/sign-in",sessionExpiresInHours:24,sessionAbsoluteExpiresInHours:672,cookieDomain:null,migrateLegacySession:null,signUpRequest:k8,oauthProviders:{},oauthFailurePath:null,oauthCompleteProfilePath:null,connections:{},connectionStore:null,onConnected:()=>{},verifyPassword:HF,hashPassword:async(Z)=>await Bun.password.hash(Z),generateForgotPasswordToken:async()=>q8(32).toString("hex"),generateEmailVerificationToken:()=>{if(!($.verifyEmail??!0))return"";return q8(32).toString("hex")},generateMagicLinkToken:()=>q8(32).toString("hex"),extendSession:()=>({}),onUserCreated:async()=>{},onSignUp:()=>{},onSignIn:()=>{},onSignOut:()=>{},onForgotPassword:()=>{},onResetPassword:()=>{},onMagicLinkCreated:()=>{},emailCode:y8($.emailCode),generateCode:()=>{return},onAuthenticated:()=>{}}}var IF=new Set(["script","style","textarea","title","xmp","iframe","noembed","noframes","noscript"]),PF=new Set(["svg","math"]);function j5($){return $===32||$===9||$===10||$===12||$===13}function z5($){return $>=65&&$<=90||$>=97&&$<=122}function G6($){return $>=65&&$<=90?$+32:$}function X5(){let $="data",Z="",J=!1,W="",Y=0,j=0,z=!1,X=0,G=0,Q=()=>$==="data"&&X===0&&G===0,K=()=>{if(!J&&IF.has(Z)){$="rawText",W=`</${Z}`,Y=0,Z="";return}if($="data",Z==="template")if(J)X=Math.max(0,X-1);else X+=1;else if(PF.has(Z)){if(J)G=Math.max(0,G-1);else if(!z)G+=1}Z=""},B=(F)=>{switch($){case"data":if(F===60)$="tagOpen";return;case"tagOpen":if(F===33)$="bang",j=0;else if(F===47)$="endTagOpen";else if(z5(F))$="tagName",J=!1,z=!1,Z=String.fromCharCode(G6(F));else if(F===63)$="bogus";else if(F===60)$="tagOpen";else $="data";return;case"endTagOpen":if(z5(F))$="tagName",J=!0,z=!1,Z=String.fromCharCode(G6(F));else if(F===62)$="data";else $="bogus";return;case"tagName":if(j5(F)||F===47)$="inTag",z=F===47;else if(F===62)K();else Z+=String.fromCharCode(G6(F));return;case"inTag":if(F===62){K();return}if(z=F===47,F===34)$="attrDouble";else if(F===39)$="attrSingle";return;case"attrDouble":if(F===34)$="inTag";z=!1;return;case"attrSingle":if(F===39)$="inTag";z=!1;return;case"bang":if(F===45){if(j+=1,j===2)$="comment",j=0}else if(F===62)$="data";else $="bogus";return;case"bogus":if(F===62)$="data";return;case"comment":if(F===45)j=j<2?j+1:2;else if(F===62&&j>=2)$="data",j=0;else j=0;return;case"rawText":{if(Y<W.length){if(G6(F)===W.charCodeAt(Y))Y+=1;else Y=F===60?1:0;return}if(F===62)$="data",Z="";else if(j5(F)||F===47)$="inTag",Z="";else Y=F===60?1:0;return}}};return{scanToInsertionPoint(F){for(let D=0;D<F.length;D++){if(Q())return D;B(F[D])}return F.length},write(F){for(let D=0;D<F.length;D++)B(F[D])},isSafe:Q}}function _1($){let Z=JSON.stringify($);if(Z===void 0)return"undefined";return Z.replace(/</g,"\\u003c").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function TF($){return`<script>(self.__GEMI_STREAM__=self.__GEMI_STREAM__||[]).push(${_1([$.path,$.variantKey,$.data])})</script>`}function MF($){return`<script>(self.__GEMI_DICT__=self.__GEMI_DICT__||[]).push(${_1([$.id,$.locale,$.strings])})</script>`}function v8($,Z,J={},W){let Y=new TextEncoder,j=[],z=!1,X=!1,G=()=>{if(X)return;X=!0,J.onClose?.()};Z.onSettle((V)=>{if(V.status!=="resolved")return;j.push(TF(V))}),W?.onUse((V)=>{j.push(MF(V))});let Q=$.getReader(),K=X5(),B=(V,O)=>{V.enqueue(O),J.onChunk?.(O)},F=(V)=>{while(j.length>0){let O=Y.encode(j.shift());K.write(O),B(V,O)}},D=(V,O)=>{if(j.length===0){K.write(O),B(V,O);return}let U=K.scanToInsertionPoint(O);if(U>0)B(V,O.subarray(0,U));if(K.isSafe())F(V);let H=O.subarray(U);if(H.length>0)K.write(H),B(V,H)};return new ReadableStream({async pull(V){let O;try{O=await Q.read()}catch(T){throw G(),T}let{done:U,value:H}=O;if(U){F(V),V.close(),G();return}if(!z){if(z=!0,K.write(H),B(V,H),J.onShell?.(),K.isSafe())F(V);return}D(V,H)},cancel(V){return G(),Q.cancel(V)}})}var NF=/bot|crawler|spider|crawling|slurp|bingpreview|mediapartners|headless|lighthouse|prerender|facebookexternalhit|whatsapp|telegram|discord|twitterbot|linkedinbot/i;function Q6($){if(!$)return!1;return NF.test($)}async function Q5($,Z=()=>{}){let J=N.getStore(),W=J?.req??null,Y=null;if(W?.rawRequest?.url)try{Y=new URL(W.rawRequest.url).pathname}catch{Y=null}return{user:J?.user??null,attributes:await _F($,Z),request:{path:Y,routePath:W?.routePath??null,locale:J?.locale??null},anonymousId:G5(),isBot:Q6(W?.rawRequest?.headers?.get("user-agent")??null),now:new Date}}function K5($){return{user:$.user??null,attributes:$.attributes??{},request:{path:null,routePath:null,locale:null},anonymousId:$.subjectId??null,isBot:!1,now:new Date}}async function _F($,Z){if(!$.context)return{};try{let J=N.getStore();return await $.context(J?.req??null)??{}}catch(J){return Z(`The \`context\` hook in app/config/features.ts threw; evaluating with no attributes. ${J instanceof Error?J.message:String(J)}`),{}}}function F5($,Z){return`${$}:${Z}`}function g8($){let Z=new Bun.CryptoHasher("sha1").update($).digest("hex"),J=Number.parseInt(Z.slice(0,8),16);return Math.floor(J/4294967296*1e4)}function B5($,Z){if(Z>=100)return!0;if(Z<=0)return!1;return $<Math.round(Z*100)}function V5($,Z,J,W){if(W.unavailable)return{value:!1,reason:"unavailable"};if(W.active!==!0)return{value:!1,reason:"inactive"};if(Z.when){let j;try{j=Z.when(J)}catch(z){return W.warn?.(`The \`when\` for feature "${$}" threw; treating it as off. ${z instanceof Error?z.message:String(z)}`),{value:!1,reason:"error"}}if(typeof j==="boolean")return{value:j,reason:"attributed"}}if(Z.rollout===void 0)return{value:!0,reason:"on"};if(J.isBot)return{value:!1,reason:"bot"};let Y=CF($,Z,J,W.buckets);return B5(Y,Z.rollout)?{value:!0,reason:"rollout"}:{value:!1,reason:"excluded"}}function xF($){let Z=$.user?.publicId??$.user?.id;if(Z!==void 0&&Z!==null)return String(Z);return $.anonymousId??""}function CF($,Z,J,W){let Y=F5(Z.salt??$,xF(J));if(!W)return g8(Y);let j=W.get(Y);if(j!==void 0)return j;let z=g8(Y);return W.set(Y,z),z}class O5 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 m8{source;declared;ttlMs;warn;snapshot=null;inflight=null;lastFailureLoggedAt=0;generation=0;lastError=null;retryAfter=0;constructor($,Z,J,W=()=>{}){this.source=$;this.declared=Z;this.ttlMs=J;this.warn=W}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 O5(this.lastError);return Z}peek(){return this.snapshot}async load(){try{let $=await this.source.load(),{active:Z,audit:J}=this.readRows($);return this.snapshot={active:Z,audit:J,loadedAt:Date.now(),unavailable:!1},this.generation++,this.lastError=null,this.retryAfter=0,this.snapshot}catch($){return this.handleFailure($)}}readRows($){let Z=new Map,J=new Map;for(let W of $??[]){let Y=typeof W?.key==="string"?W.key:null;if(!Y){this.warn("Ignoring a feature row with no `key`.");continue}if(!(Y in this.declared)){this.warn(`Feature row "${Y}" is not declared in app/features, so it is ignored. Delete the row, or declare the feature.`);continue}Z.set(Y,W.active===!0);let j=SF(W);if(j)J.set(Y,j)}return{active:Z,audit:J}}handleFailure($){let Z=$ instanceof Error?$.message:String($),J=Date.now();if(this.lastError=$,this.retryAfter=J+this.ttlMs,J-this.lastFailureLoggedAt>=this.ttlMs)this.lastFailureLoggedAt=J,this.warn(`Could not load feature switches: ${Z}`);if(this.snapshot)return this.snapshot;return this.snapshot={active:new Map,audit:new Map,loadedAt:J,unavailable:!0},this.snapshot}}function SF($){let Z={},J=$.updatedBy;if(typeof J==="string")Z.updatedBy=J;else if(J===null)Z.updatedBy=null;let W=$.updatedAt;if(W instanceof Date||typeof W==="string"||typeof W==="number"){let Y=W instanceof Date?W:new Date(W);if(!Number.isNaN(Y.getTime()))Z.updatedAt=Y}return"updatedBy"in Z||"updatedAt"in Z?Z:null}class AF{}class EF 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 h8 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 D5 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 U5{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 s1{config;log;static token="features";store;declared;warnedAboutSize=!1;warnedAboutActor=!1;constructor($,Z=()=>{}){this.config=$;this.log=Z;this.declared=$.features??{},this.store=new m8($.source,this.declared,Math.max(0,$.ttl)*1000,this.log)}declarations(){return this.declared}async list(){let{active:$,audit:Z,unavailable:J}=await this.switches();return{unavailable:J,features:Object.entries(this.declared).map(([W,Y])=>({key:W,describe:Y.describe,rollout:Y.rollout,targeted:Y.when!==void 0,serverOnly:Y.serverOnly,salt:Y.salt,active:$.get(W),...Z.get(W)}))}}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,J={}){if(typeof $!=="string"||!Object.hasOwn(this.declared,$))throw new D5(String($));if(typeof Z!=="boolean")throw TypeError(`Features.set("${$}", \u2026) takes a boolean, not ${Z===null?"null":typeof Z}.`);let W=fF(J.actor),Y=this.config.source;if(typeof Y.write!=="function")throw new h8(Y.constructor?.name||"an anonymous source");let{actorRecorded:j}=await Y.write($,Z,{actor:W});if(W!==null&&!j&&!this.warnedAboutActor)this.warnedAboutActor=!0,this.log('Features.set() was given an actor, but the feature source has nowhere to record it. For the database source, add a nullable `updatedBy String?` column to the feature flag model to keep "last changed by".');await this.invalidate()}async enabled($){return(await this.explain($)).value}async explain($){let 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 U5(this,K5($))}async evaluateIn($,Z,J){let W=this.memoFor(Z),Y=W?.get($);if(Y)return Y;let j=this.declared[$];if(!j)return{value:!1,reason:"undeclared"};let{active:z,unavailable:X}=await this.switchFor($),G=V5($,j,Z,{active:z,unavailable:X,buckets:J,warn:this.log});return W?.set($,G),this.notify($,G,Z),G}async evaluateAllIn($,Z,J){let W={};for(let[Y,j]of Object.entries(this.declared)){if(J.clientOnly&&j.serverOnly)continue;W[Y]=(await this.evaluateIn(Y,$,Z)).value}return W}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 Q5(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,J){if(!this.config.onEvaluate)return;try{this.config.onEvaluate($,Z,J)}catch(W){this.log(`The \`onEvaluate\` hook in app/config/features.ts threw for "${$}". ${W instanceof Error?W.message:String(W)}`)}}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 fF($){if($===void 0||$===null)return null;if(typeof $==="string"){if($.length>0)return $}else if(typeof $==="object"){let{publicId:Z,id:J}=$;if(typeof Z==="string"&&Z.length>0)return Z;if(typeof J==="string"&&J.length>0||typeof J==="number")return String(J)}throw TypeError("Features.set() was given an `actor` that identifies nobody. Pass a string, or a user with a `publicId` or an `id`.")}async function L5($){if($===void 0)return!0;return await L(s1).enabled($)}async function GZ($,Z){if(typeof Z!=="string"||!Object.hasOwn($,Z))return null;let J=J5($[Z]);if(!J||!await L5(J.feature))return null;return J.provider}async function H5($){let Z=[];for(let J of Object.keys($))if(await GZ($,J))Z.push(J);return Z}function p8($){if($&&typeof $==="object")delete $.password;return $}function bF(){return new Proxy({},{get:($,Z)=>P5(Z)})}var I5=new WeakMap;function T5($){if($&&typeof $==="object"){for(let Z of Object.values($))T5(Z);Object.freeze($)}return $}var RF={select:{id:!0,publicId:!0,email:!0,name:!0,locale:!0,globalRole:!0,accounts:{select:{id:!0,publicId:!0,organizationRole:!0,organization:!0}}}},wF=T5({token:!0,expiresAt:!0,absoluteExpiresAt:!0,updatedAt:!0,location:!0,userAgent:!0,user:RF});class c8{models;constructor($=bF()){this.models=$}run($){return this.models.User.asSystem($)}sessionSelect(){return wF}transaction($){return this.models.User.transaction($)}withLegacySessionLock($,Z){let J=this.models.User.$connection??x1(),W=L(C1).connection(J),Y=()=>this.transaction(async()=>{if(W.dialect==="postgres"){let X=`gemi:legacy-session:${$}`;await i0()`SELECT pg_advisory_xact_lock(hashtextextended(${X}, 0))`}return Z()});if(W.dialect!=="sqlite"||i0())return Y();let z=(I5.get(W)??Promise.resolve()).then(Y,Y);return I5.set(W,z.catch(()=>{})),z}async createUser($){let Z=await this.run(()=>this.models.User.create({data:$}));return p8(Z)}async updateUserPassword($){let Z=await this.run(()=>this.models.User.update({where:{id:$.id},data:{password:$.password}}));return p8(Z)}async findUserByEmailAddress($,Z){return await this.run(()=>this.models.User.findUnique({where:Z?{email:$,emailVerifiedAt:{not:null}}:{email:$}}))}async findUserByVerificationToken($){if(typeof $!=="string"||$==="")return null;return await this.run(()=>this.models.User.findFirst({where:{verificationToken:$}}))}async verifyUser($){return await this.run(()=>this.models.User.update({where:{email:$},data:{emailVerifiedAt:new Date}}))}async createSession($){return await this.run(()=>this.models.Session.create({data:$,include:{user:!0}}))}async createSessionV2($){return await this.run(()=>this.models.Session.create({data:$,select:this.sessionSelect()}))}async findSession($){if(!$.token)return null;try{return await this.run(()=>this.models.Session.findUnique({where:{token:$.token},select:this.sessionSelect()}))}catch(Z){return console.error("findSession failed:",Z),null}}async updateSession($){return await this.run(()=>this.models.Session.update({where:{token:$.token},data:{expiresAt:$.expiresAt},select:this.sessionSelect()}))}async deleteSession($){if(!$.token)return;await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}))}async claimLegacySession($){if(!$.token)return!1;let{count:Z}=await this.run(()=>this.models.Session.deleteMany({where:{token:$.token}}));return Z>0}async deleteAllUserSessions($){await this.run(()=>this.models.Session.deleteMany({where:{userId:$}}))}async createPasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.create({data:{token:$.token,user:{connect:{id:$.user.id}}}}))}async findPasswordResetToken($){if(typeof $.token!=="string"||$.token==="")return null;return await this.run(()=>this.models.PasswordResetToken.findUnique({where:{token:$.token},include:{user:!0}}))}async deletePasswordResetToken($){return await this.run(()=>this.models.PasswordResetToken.delete({where:{token:$.token}}))}async findInvitation($,Z){if(typeof $!=="string"||typeof Z!=="string")return null;return await this.run(()=>this.models.OrganizationInvitation.findFirst({where:{publicId:$,email:Z}}))}async deleteInvitationById($){await this.run(()=>this.models.OrganizationInvitation.delete({where:{publicId:$}}))}async createAccount($){return await this.run(()=>this.models.Account.create({data:{userId:$.userId,organizationId:$.organizationId,organizationRole:$.organizationRole}}))}async createMagicLinkToken($){return await this.run(()=>this.models.MagicLinkToken.create({data:{email:$.email,token:$.token,pin:$.pin}}))}async findUserMagicLinkToken($){let Z=(J)=>typeof J==="string"&&J!=="";if(!Z($.email))return null;if($.token!==void 0&&!Z($.token))return null;if($.token===void 0&&!Z($.pin))return null;return await this.run(()=>$.token?this.models.MagicLinkToken.findUnique({where:{token_email:{token:$.token,email:$.email}}}):this.models.MagicLinkToken.findUnique({where:{pin_email:{pin:$.pin,email:$.email}}}))}async findMagicLinkTokenByEmail($){return await this.run(()=>this.models.MagicLinkToken.findFirst({where:{email:$},orderBy:{id:"desc"}}))}async claimMagicLinkToken($){let{count:Z}=await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{id:$}}));return Z===1}async deleteMagicLinkToken($){await this.run(()=>this.models.MagicLinkToken.deleteMany({where:{email:$}}))}async createSocialAccount($){return await this.run(()=>this.models.SocialAccount.create({data:$}))}async findUserBySocialAccount($,Z){if(!Z)return null;let J=await this.run(()=>this.models.SocialAccount.findFirst({where:{provider:$,providerId:Z},include:{user:!0}}));return J?p8(J.user):null}async findSocialAccounts($,Z){return await this.run(()=>this.models.SocialAccount.findMany({where:{userId:$,provider:Z},orderBy:{id:"asc"}}))}async claimSocialAccount($,Z){let{count:J}=await this.run(()=>this.models.SocialAccount.updateMany({where:{id:$.id,providerId:$.providerId},data:{providerId:Z}}));return J===1}}import{randomBytes as vO}from"crypto";function w0($,Z,J,W,Y){return s0(Z,v5($,Z),J,W,Y)}function s0($,Z,J,W,Y,j){let z=s8(Z,J,W);if(Y&&Z!==z)throw RangeError(Pz($,Z,J,W,j));return z}function v5($,Z){let J=$[Z];if(J===void 0)throw TypeError(M2(Z));return J}function O0($){return $!==null&&/object|function/.test(typeof $)}function y0($,Z=Map){let J=new Z;return(W,...Y)=>{if(J.has(W))return J.get(W);let j=$(W,...Y);return J.set(W,j),j}}function ZJ($){return N$({name:$},1)}function N$($,Z){return r0((J)=>({value:J,configurable:1,writable:!Z}),$)}function g5($){return r0((Z)=>({get:Z,configurable:1}),$)}function x6($){return{[Symbol.toStringTag]:{value:$,configurable:1}}}function DZ($,Z){let J={},W=$.length;for(let Y of Z)J[$[--W]]=Y;return J}function r0($,Z,J){let W={};for(let Y in Z)W[Y]=$(Z[Y],Y,J);return W}function Q3($,Z,J){let W={};for(let Y=0;Y<Z.length;Y++){let j=Z[Y];W[j]=$(j,Y,J)}return W}function kF($,Z,J){let W={};for(let Y=0;Y<$.length;Y++)W[Z[Y]]=J[$[Y]];return W}function g0($,Z){let J={};for(let W of $)J[W]=Z[W];return J}function JJ($,Z){let J={};for(let W in Z)$.has(W)||(J[W]=Z[W]);return J}function WJ($){$={...$};let Z=Object.keys($);for(let J of Z)$[J]===void 0&&delete $[J];return $}function m5($,Z){for(let J of Z)if(!(J in $))return 0;return 1}function h5($,Z,J){for(let W of $)if(Z[W]!==J[W])return 0;return 1}function p5($,Z,J){let W={...J};for(let Y=0;Y<Z;Y++)W[$[Y]]=0;return W}function R($,...Z){return(...J)=>$(...Z,...J)}function M5($){return $[0].toUpperCase()+$.substring(1)}function K3($){return $.slice().sort()}function U6($,Z){return String(Z).padStart($,"0")}function n1($,Z){return Math.sign($-Z)}function s8($,Z,J){return Math.min(Math.max($,Z),J)}function A1($,Z){return[Math.floor($/Z),J3($,Z)]}function J3($,Z){return($%Z+Z)%Z}function r1($,Z){return[C6($,Z),YJ($,Z)]}function C6($,Z){return Math.trunc($/Z)||0}function YJ($,Z){return $%Z||0}function K6($){return Math.abs($%1)===0.5}function c5($,Z,J){let W=0,Y=0;for(let X=0;X<=Z;X++){let G=$[J[X]],Q=G1[X],K=c/Q,[B,F]=r1(G,K);W+=F*Q,Y+=B}let[j,z]=r1(W,c);return[Y+j,z]}function S6($,Z,J){let W={};for(let Y=Z;Y>=0;Y--){let j=G1[Y];W[J[Y]]=C6($,j),$=YJ($,j)}return W}function d5($){return $===w?X4:[]}function u5($){return $===w?P3:[]}function l5($){return $===w?["year","day"]:[]}function i5($){if($!==void 0)return e($)}function s5($){if($!==void 0)return t0($)}function jJ($){if($!==void 0)return F3($)}function t0($){return a5(F3($))}function F3($){return o5(xB($))}function zJ($){if($==null)throw TypeError("Cannot be null or undefined");return $}function n5($,Z){if(Z==null)throw RangeError(M2($));return Z}function f1($){if(!O0($))throw TypeError(Iz);return $}function A6($,Z,J=$){if(typeof Z!==$)throw TypeError(L3(J,Z));return Z}function o5($,Z="number"){if(!Number.isInteger($))throw RangeError(aF(Z,$));return $||0}function a5($,Z="number"){if($<=0)throw RangeError(rF(Z,$));return $}function XJ($){if(typeof $=="symbol")throw TypeError(ZB);return String($)}function L6($,Z){return O0($)?String($):e($,Z)}function E6($){if(typeof $=="string")return BigInt($);if(typeof $!="bigint")throw TypeError($B($));return $}function r5($,Z="number"){if(typeof $=="bigint")throw TypeError(eF(Z));if($=Number($),!Number.isFinite($))throw RangeError(tF(Z,$));return $}function _0($,Z){return Math.trunc(r5($,Z))||0}function t5($,Z){return o5(r5($,Z),Z)}function N5($,Z){return a5(_0($,Z),Z)}function GJ($,Z){let[J,W]=r1(Z,c),Y=$+J,j=Math.sign(Y);return j&&j===-Math.sign(W)&&(Y-=j,W+=j*c),[Y,W]}function KZ($,Z,J=1){return GJ($[0]+Z[0]*J,$[1]+Z[1]*J)}function FZ($,Z){return GJ($[0],$[1]+Z)}function c0($,Z){return KZ(Z,$,-1)}function C0($,Z){return n1($[0],Z[0])||n1($[1],Z[1])}function e5($,Z,J){return C0($,Z)===-1||C0($,J)===1}function f6($,Z=1){let J=BigInt(c/Z);return[Number($/J),Number($%J)*Z]}function BZ($,Z=1){let J=c/Z,[W,Y]=r1($,J);return[W,Y*Z]}function $Y($,Z=1){let[J,W]=$,Y=Math.floor(W/Z),j=c/Z;return BigInt(J)*BigInt(j)+BigInt(Y)}function d0($,Z=1,J){let[W,Y]=$,[j,z]=r1(Y,Z);return W*(c/Z)+(j+(J?z/Z:0))}function QJ($,Z,J=A1){let[W,Y]=$,[j,z]=J(Y,Z);return[W*(c/Z)+j,z]}function KJ($,Z){let J=$.formatToParts(Z),W={};for(let Y of J)W[Y.type]=Y.value;return W}function FJ($){return w0($,"isoYear",G3,X3,1),$.isoYear===G3?w0($,"isoMonth",4,12,1):$.isoYear===X3&&w0($,"isoMonth",1,9,1),$}function o1($){return b1({...$,...a0,isoHour:12}),$}function b1($){let Z=w0($,"isoYear",G3,X3,1),J=Z===G3?1:Z===X3?-1:0;return J&&u0(x0({...$,isoDay:$.isoDay+J,isoNanosecond:$.isoNanosecond-J})),$}function u0($){if(!$||e5($,RB,bB))throw RangeError(W4);return $}function t1($){return c5($,5,J1)[1]}function b6($){let[Z,J]=A1($,c);return[S6(J,5,J1),Z]}function ZY($){return JY($)[0]}function JY($){return QJ($,o0)}function S0($){return UZ($.isoYear,$.isoMonth,$.isoDay,$.isoHour,$.isoMinute,$.isoSecond,$.isoMillisecond)}function x0($){let Z=S0($);if(Z!==void 0){let[J,W]=r1(Z,q0);return[J,W*Q1+($.isoMicrosecond||0)*R$+($.isoNanosecond||0)]}}function BJ($,Z){let[J,W]=b6(t1($)-Z);return u0(x0({...$,isoDay:$.isoDay+W,...J}))}function H6(...$){return UZ(...$)/bz}function UZ(...$){let[Z,J]=WY(...$),W=Z.valueOf();if(!isNaN(W))return W-J*q0}function WY($,Z=1,J=1,W=0,Y=0,j=0,z=0){let X=$===G3?1:$===X3?-1:0,G=new Date;return G.setUTCHours(W,Y,j,z),G.setUTCFullYear($,Z-1,J+X),[G,X]}function $$($,Z){let[J,W]=FZ($,Z);W<0&&(W+=c,J-=1);let[Y,j]=A1(W,Q1),[z,X]=A1(j,R$);return R6(J*q0+Y,z,X)}function R6($,Z=0,J=0){let W=Math.ceil(Math.max(0,Math.abs($)-fB)/q0)*Math.sign($),Y=new Date($-W*q0);return DZ(Q4,[Y.getUTCFullYear(),Y.getUTCMonth()+1,Y.getUTCDate()+W,Y.getUTCHours(),Y.getUTCMinutes(),Y.getUTCSeconds(),Y.getUTCMilliseconds(),Z,J])}function YY($){return[$.isoYear,$.isoMonth,$.isoDay]}function jY(){return S1}function VJ($,Z){switch(Z){case 2:return OJ($)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function zY($){return OJ($)?366:365}function OJ($){return $%4==0&&($%100!=0||$%400==0)}function XY($){let[Z,J]=WY($.isoYear,$.isoMonth,$.isoDay);return J3(Z.getUTCDay()-J,7)||7}function GY({isoYear:$}){return $<1?["bce",1-$]:["ce",$]}function qF($){let Z=S0($);if(Z<kB)return GY($);let J=KJ(h2(VZ),Z),{era:W,eraYear:Y}=Ij(J,VZ);return[W,Y]}function w6($){return _$($),k6($,1),$}function _$($){return QY($,1),$}function _5($){return h5(R2,$,QY($))}function QY($,Z){let{isoYear:J}=$,W=w0($,"isoMonth",1,jY(),Z);return{isoYear:J,isoMonth:W,isoDay:w0($,"isoDay",1,VJ(J,W),Z)}}function k6($,Z){return DZ(J1,[w0($,"isoHour",0,23,Z),w0($,"isoMinute",0,59,Z),w0($,"isoSecond",0,59,Z),w0($,"isoMillisecond",0,999,Z),w0($,"isoMicrosecond",0,999,Z),w0($,"isoNanosecond",0,999,Z)])}function y($){return $===void 0?0:nz(f1($))}function B3($,Z=0){$=e0($);let J=oz($),W=uB($,Z);return[nz($),W,J]}function DJ($){return oz(e0($))}function KY($){return $=e0($),q2($,9,6,1)}function LZ($,Z,J,W=9,Y=0,j=4){Z=e0(Z);let z=q2(Z,W,Y),X=HJ(Z),G=M3(Z,j),Q=T3(Z,W,Y,1);return z==null?z=Math.max(J,Q):OY(z,Q),X=IJ(X,Q,1),$&&(G=((K)=>K<4?(K+2)%4:K)(G)),[z,Q,X,G]}function q6($,Z=6,J){let W=HJ($=PJ($,_6)),Y=M3($,7),j=T3($,Z);return j=n5(_6,j),W=IJ(W,j,void 0,J),[j,W,Y]}function UJ($){return y2(e0($))}function FY($,Z){return LJ(e0($),Z)}function LJ($,Z=4){let J=VY($);return[M3($,4),...BY(T3($,Z),J)]}function BY($,Z){return $!=null?[G1[$],$<4?9-3*$:-1]:[Z===void 0?1:10**(9-Z),Z]}function HJ($){let Z=$[W3];return Z===void 0?1:_0(Z,W3)}function IJ($,Z,J,W){let Y=W?c:G1[Z+1];if(Y){let j=G1[Z];if(Y%(($=s0(W3,$,1,Y/j-(W?0:1),1))*j))throw RangeError(L3(W3,$))}else $=s0(W3,$,1,J?1e9:1,1);return $}function VY($){let Z=$[i8];if(Z!==void 0){if(typeof Z!="number"){if(XJ(Z)==="auto")return;throw RangeError(L3(i8,Z))}Z=s0(i8,Math.floor(Z),0,9,1)}return Z}function e0($){return $===void 0?{}:f1($)}function PJ($,Z){return typeof $=="string"?{[Z]:$}:f1($)}function z0($){if($!==void 0){if(O0($))return Object.assign(Object.create(null),$);throw TypeError(Iz)}}function y6($,Z){return $&&Object.assign(Object.create(null),$,{overflow:yB[Z]})}function TJ($,Z,J=9,W=0,Y){let j=Z[$];if(j===void 0)return Y?W:void 0;if(j=XJ(j),j==="auto")return Y?W:null;let z=r8[j];if(z===void 0&&(z=AB[j]),z===void 0)throw RangeError(Nz($,j,r8));return s0($,z,W,J,1,I3),z}function x$($,Z,J,W=0){let Y=J[$];if(Y===void 0)return W;let j=XJ(Y),z=Z[j];if(z===void 0)throw RangeError(Nz($,j,Z));return z}function OY($,Z){if(Z>$)throw RangeError(PB)}function D0($){return{branding:F4,epochNanoseconds:$}}function I0($,Z,J){return{branding:q1,calendar:J,timeZone:Z,epochNanoseconds:$}}function X0($,Z=$.calendar){return{branding:k$,calendar:Z,...g0(uz,$)}}function G0($,Z=$.calendar){return{branding:w$,calendar:Z,...g0(w2,$)}}function T$($,Z=$.calendar){return{branding:xZ,calendar:Z,...g0(w2,$)}}function I6($,Z=$.calendar){return{branding:CZ,calendar:Z,...g0(w2,$)}}function $1($){return{branding:K4,...g0(dz,$)}}function n($){return{branding:B4,sign:Z$($),...g0(E2,$)}}function DY($){return ZY($.epochNanoseconds)}function v6($){return QJ($.epochNanoseconds,Q1)[0]}function UY($){return $Y($.epochNanoseconds,R$)}function LY($){return $Y($.epochNanoseconds)}function HY($){return $.epochNanoseconds}function L0($){return typeof $=="string"?$:e($.id)}function HZ($,Z){return $===Z||L0($)===L0(Z)}function IY($,Z,J,W,Y){let j=M$(W),[z,X]=((U,H)=>{let T=H((U=PJ(U,$J))[iz]),I=dB(U);return I=n5($J,I),[I,T]})(Y,$);if(j3(Math.max(z,j),X))return x5(W,z);if(!X)throw RangeError(Y4);let[G,Q,K]=d6(Z,J,X),B=lJ(K),F=u6(K),D=iJ(K),V=F(Q,G,W),O=D(Q,G,V,z);return j3(z,X)?x5(O,z):((U,H,T,I,x,A,f)=>{let S=Z$(U),[M,P]=MJ(I,b2(T,U),T,S,x,A,f),k=NJ(H,M,P);return U[g[T]]+k*S})(O,B(V),z,Q,G,B,F)}function x5($,Z){return d0(V0($),G1[Z],1)}function MJ($,Z,J,W,Y,j,z){let X=g[J],G={...Z,[X]:Z[X]+W},Q=z($,Y,Z),K=z($,Y,G);return[j(Q),j(K)]}function NJ($,Z,J){let W=d0(c0(Z,J));if(!W)throw RangeError(H3);return d0(c0(Z,$))/W}function PY($,Z){let[J,W,Y]=q6(Z,5,1);return D0(m6($.epochNanoseconds,J,W,Y,1))}function TY($,Z,J){let{epochNanoseconds:W,timeZone:Y,calendar:j}=Z,[z,X,G]=q6(J);if(z===0&&X===1)return Z;let Q=$(Y);if(z===6)W=((K,B,F,D)=>{let V=A0(F,B),[O,U]=K(V),H=F.epochNanoseconds,T=v0(B,O),I=v0(B,U);if(e5(H,T,I))throw RangeError(H3);return fY(NJ(H,T,I),D)?I:T})(AY,Q,Z,G);else{let K=Q.getOffsetNanosecondsFor(W);W=S$(Q,CY($$(W,K),z,X,G),K,2,0,1)}return I0(W,Y,j)}function MY($,Z){return X0(CY($,...q6(Z)),$.calendar)}function NY($,Z){let[J,W,Y]=q6(Z,5);var j;return $1((j=Y,_J($,V3(J,W),j)[0]))}function _Y($,Z){let J=$(Z.timeZone),W=A0(Z,J),[Y,j]=AY(W),z=d0(c0(v0(J,Y),v0(J,j)),z4,1);if(z<=0)throw RangeError(H3);return z}function xY($,Z){let{timeZone:J,calendar:W}=Z,Y=((j,z,X)=>v0(z,j(A0(X,z))))(EY,$(J),Z);return I0(Y,J,W)}function CY($,Z,J,W){return SY($,V3(Z,J),W)}function SY($,Z,J){let[W,Y]=_J($,Z,J);return b1({...A$($,Y),...W})}function _J($,Z,J){return b6(e1(t1($),Z,J))}function P6($){return e1($,j4,7)}function V3($,Z){return G1[$]*Z}function AY($){let Z=EY($);return[Z,A$(Z,1)]}function EY($){return EB(6,$)}function yF($,Z,J){let W=Math.min(M$($),6);return PZ(h6(V0($,W),Z,J),W)}function g6($,Z,J,W,Y,j,z,X,G,Q){if(W===0&&Y===1)return $;let K=j3(W,X)?l6(X)&&W<6&&J>=6?gF:vF:mF,[B,F,D]=K($,Z,J,W,Y,j,z,X,G,Q);return D&&W!==7&&(B=((V,O,U,H,T,I,x,A)=>{let f=Z$(V);for(let S=H+1;S<=U;S++){if(S===7&&U!==7)continue;let M=b2(S,V);M[g[S]]+=f;let P=d0(c0(x(A(T,I,M)),O));if(P&&Math.sign(P)!==f)break;V=M}return V})(B,F,J,Math.max(6,W),z,X,G,Q)),B}function m6($,Z,J,W,Y){if(Z===6){let j=((z)=>z[0]+z[1]/c)($);return[e1(j,J,W),0]}return h6($,V3(Z,J),W,Y)}function h6($,Z,J,W){let[Y,j]=$;W&&j<0&&(j+=c,Y-=1);let[z,X]=A1(e1(j,Z,J),c);return GJ(Y+z,X)}function e1($,Z,J){return fY($/Z,J)*Z}function fY($,Z){return sB[Z]($)}function vF($,Z,J,W,Y,j){let z=Z$($),X=V0($),G=m6(X,W,Y,j),Q=c0(X,G),K=Math.sign(G[0]-X[0])===z,B=PZ(G,Math.min(J,6));return[{...$,...B},KZ(Z,Q),K]}function gF($,Z,J,W,Y,j,z,X,G,Q){let K=Z$($),B=d0(V0($,5)),F=V3(W,Y),D=e1(B,F,j),[V,O]=MJ(z,{...$,...f2},6,K,X,G,Q),U=D-d0(c0(V,O)),H=0;U&&Math.sign(U)!==K?Z=FZ(V,D):(H+=K,D=e1(U,F,j),Z=FZ(O,D));let T=s6(D);return[{...$,...T,days:$.days+H},Z,Boolean(H)]}function mF($,Z,J,W,Y,j,z,X,G,Q){let K=Z$($),B=g[W],F=b2(W,$);W===7&&($={...$,weeks:$.weeks+Math.trunc($.days/7)});let D=C6($[B],Y)*Y;F[B]=D;let[V,O]=MJ(z,F,W,Y*K,X,G,Q),U=D+NJ(Z,V,O)*K*Y,H=e1(U,Y,j),T=Math.sign(H-U)===K;return F[B]=H,[F,T?O:V,T]}function xJ($,Z,J,W){let[Y,j,z,X]=((Q)=>{let K=LJ(Q=e0(Q));return[Q.timeZone,...K]})(W),G=Y!==void 0;return((Q,K,B,F,D,V)=>{B=h6(B,D,F,1);let O=K.getOffsetNanosecondsFor(B);return RJ($$(B,O),V)+(Q?C$(P6(O)):"Z")})(G,Z(G?$(Y):q$),J.epochNanoseconds,j,z,X)}function CJ($,Z,J){let[W,Y,j,z,X,G]=((Q)=>{Q=e0(Q);let K=y2(Q),B=VY(Q),F=iB(Q),D=M3(Q,4),V=T3(Q,4);return[K,lB(Q),F,D,...BY(V,B)]})(J);return((Q,K,B,F,D,V,O,U,H,T)=>{F=h6(F,H,U,1);let I=Q(B).getOffsetNanosecondsFor(F);return RJ($$(F,I),T)+C$(P6(I),O)+((x,A)=>A!==1?"["+(A===2?"!":"")+L0(x)+"]":"")(B,V)+wJ(K,D)})($,Z.calendar,Z.timeZone,Z.epochNanoseconds,W,Y,j,z,X,G)}function SJ($,Z){let[J,W,Y,j]=((Q)=>(Q=e0(Q),[y2(Q),...LJ(Q)]))(Z);return z=$.calendar,X=J,G=j,RJ(SY($,Y,W),G)+wJ(z,X);var z,X,G}function AJ($,Z){return J=$.calendar,W=$,Y=UJ(Z),T6(W)+wJ(J,Y);var J,W,Y}function EJ($,Z){return bY($.calendar,RY,$,UJ(Z))}function fJ($,Z){return bY($.calendar,hF,$,UJ(Z))}function bJ($,Z){let[J,W,Y]=FY(Z);return j=Y,wY(_J($,W,J)[0],j);var j}function p6($,Z){let[J,W,Y]=FY(Z,3);return W>1&&($={...$,...yF($,W,J)}),((j,z)=>{let{sign:X}=j,G=X===-1?E0(j):j,{hours:Q,minutes:K}=G,[B,F]=QJ(V0(G,3),o0,r1);pY(B);let D=kJ(F,z),V=z>=0||!X||D;return(X<0?"-":"")+"P"+C5({Y:P$(G.years),M:P$(G.months),W:P$(G.weeks),D:P$(G.days)})+(Q||K||B||V?"T"+C5({H:P$(Q),M:P$(K),S:P$(B,V)+D}):"")})($,Y)}function bY($,Z,J,W){let Y=L0($),j=W>1||W===0&&Y!==w;return W===1?Y===w?Z(J):T6(J):j?T6(J)+kY(Y,W===2):Z(J)}function C5($){let Z=[];for(let J in $){let W=$[J];W&&Z.push(W,J)}return Z.join("")}function RJ($,Z){return T6($)+"T"+wY($,Z)}function T6($){return RY($)+"-"+n0($.isoDay)}function RY($){let{isoYear:Z}=$;return(Z<0||Z>9999?qY(Z)+U6(6,Math.abs(Z)):U6(4,Z))+"-"+n0($.isoMonth)}function hF($){return n0($.isoMonth)+"-"+n0($.isoDay)}function wY($,Z){let J=[n0($.isoHour),n0($.isoMinute)];return Z!==-1&&J.push(n0($.isoSecond)+((W,Y,j,z)=>kJ(W*Q1+Y*R$+j,z))($.isoMillisecond,$.isoMicrosecond,$.isoNanosecond,Z)),J.join(":")}function C$($,Z=0){if(Z===1)return"";let[J,W]=A1(Math.abs($),z4),[Y,j]=A1(W,j4),[z,X]=A1(j,o0);return qY($)+n0(J)+":"+n0(Y)+(z||X?":"+n0(z)+kJ(X):"")}function wJ($,Z){if(Z!==1){let J=L0($);if(Z>1||Z===0&&J!==w)return kY(J,Z===2)}return""}function kY($,Z){return"["+(Z?"!":"")+"u-ca="+$+"]"}function kJ($,Z){let J=U6(9,$);return J=Z===void 0?J.replace(aB,""):J.slice(0,Z),J?"."+J:""}function qY($){return $<0?"-":"+"}function P$($,Z){return $||Z?$.toLocaleString("fullwide",{useGrouping:0}):""}function pF($,Z){let{epochNanoseconds:J}=$,W=(Z.getOffsetNanosecondsFor?Z:Z($.timeZone)).getOffsetNanosecondsFor(J),Y=$$(J,W);return{calendar:$.calendar,...Y,offsetNanoseconds:W}}function yY($,Z){let J=A0(Z,$);return{calendar:Z.calendar,...g0(uz,J),offset:C$(J.offsetNanoseconds),timeZone:Z.timeZone}}function S$($,Z,J,W=0,Y=0,j,z){if(J!==void 0&&W===1&&(W===1||z))return BJ(Z,J);let X=$.getPossibleInstantsFor(Z);if(J!==void 0&&W!==3){let G=((Q,K,B,F)=>{let D=x0(K);F&&(B=P6(B));for(let V of Q){let O=d0(c0(V,D));if(F&&(O=P6(O)),O===B)return V}})(X,Z,J,j);if(G!==void 0)return G;if(W===0)throw RangeError(OB)}return z?x0(Z):v0($,Z,Y,X)}function v0($,Z,J=0,W=$.getPossibleInstantsFor(Z)){if(W.length===1)return W[0];if(J===1)throw RangeError(DB);if(W.length)return W[J===3?1:0];let Y=x0(Z),j=((X,G)=>{let Q=X.getOffsetNanosecondsFor(FZ(G,-c));return yJ(X.getOffsetNanosecondsFor(FZ(G,c))-Q)})($,Y),z=j*(J===2?-1:1);return(W=$.getPossibleInstantsFor($$(Y,z)))[J===2?0:W.length-1]}function qJ($){if(Math.abs($)>=c)throw RangeError(BB);return $}function yJ($){if($>c)throw RangeError(VB);return $}function vJ($,Z,J){return D0(u0(KZ(Z.epochNanoseconds,((W)=>{if(cY(W))throw RangeError(HB);return V0(W,5)})($?E0(J):J))))}function gJ($,Z,J,W,Y,j=Object.create(null)){let z=Z(W.timeZone),X=$(W.calendar);return{...W,...dJ(z,X,W,J?E0(Y):Y,j)}}function mJ($,Z,J,W,Y=Object.create(null)){let{calendar:j}=J;return X0(uJ($(j),J,Z?E0(W):W,Y),j)}function hJ($,Z,J,W,Y){let{calendar:j}=J;return G0(c6($(j),J,Z?E0(W):W,Y),j)}function pJ($,Z,J,W,Y=Object.create(null)){let j=J.calendar,z=$(j),X=Y3(z,J);Z&&(W=i6(W)),W.sign<0&&(X=z.dateAdd(X,{...H0,months:1}),X=A$(X,-1));let G=z.dateAdd(X,W,Y);return T$(Y3(z,G),j)}function cJ($,Z,J){return $1(vY(Z,$?E0(J):J)[0])}function dJ($,Z,J,W,Y){let j=V0(W,5),z=J.epochNanoseconds;if(cY(W)){let X=A0(J,$);z=KZ(v0($,{...c6(Z,X,{...W,...f2},Y),...g0(J1,X)}),j)}else z=KZ(z,j),y(Y);return{epochNanoseconds:u0(z)}}function uJ($,Z,J,W){let[Y,j]=vY(Z,J);return b1({...c6($,Z,{...J,...f2,days:J.days+j},W),...Y})}function c6($,Z,J,W){if(J.years||J.months||J.weeks)return $.dateAdd(Z,J,W);y(W);let Y=J.days+V0(J,5)[0];return Y?o1(A$(Z,Y)):Z}function Y3($,Z,J=1){return A$(Z,J-$.day(Z))}function vY($,Z){let[J,W]=V0(Z,5),[Y,j]=b6(t1($)+W);return[Y,J+j]}function A$($,Z){return Z?{...$,...R6(S0($)+Z*q0)}:$}function d6($,Z,J){let W=$(J.calendar);return l6(J)?[J,W,Z(J.timeZone)]:[{...J,...a0},W]}function lJ($){return $?HY:x0}function u6($){return $?R(dJ,$):uJ}function iJ($){return $?R(dF,$):uF}function l6($){return $&&$.epochNanoseconds}function j3($,Z){return $<=6-(l6(Z)?1:0)}function sJ($,Z,J,W,Y,j,z){let X=$(e0(z).relativeTo),G=Math.max(M$(Y),M$(j));if(j3(G,X))return n(IZ(((O,U,H,T)=>{let I=KZ(V0(O),V0(U),T?-1:1);if(!Number.isFinite(I[0]))throw RangeError(W4);return{...H0,...PZ(I,H)}})(Y,j,G,W)));if(!X)throw RangeError(Y4);W&&(j=E0(j));let[Q,K,B]=d6(Z,J,X),F=u6(B),D=iJ(B),V=F(K,Q,Y);return n(D(K,Q,F(K,V,j),G))}function gY($,Z,J,W,Y){let j=M$(W),[z,X,G,Q,K]=((f,S,M)=>{f=PJ(f,_6);let P=q2(f),k=M(f[iz]),m=HJ(f),h1=M3(f,7),J0=T3(f);if(P===void 0&&J0===void 0)throw RangeError(IB);return J0==null&&(J0=0),P==null&&(P=Math.max(J0,S)),OY(P,J0),m=IJ(m,J0,1),[P,J0,m,h1,k]})(Y,j,$),B=Math.max(j,z);if(!l6(K)&&B<=6)return n(IZ(((f,S,M,P,k)=>{let m=m6(V0(f),M,P,k);return{...H0,...PZ(m,S)}})(W,z,X,G,Q)));if(!K)throw RangeError(Y4);let[F,D,V]=d6(Z,J,K),O=lJ(V),U=u6(V),H=iJ(V),T=U(D,F,W),I=H(D,F,T,z),x=W.sign,A=Z$(I);if(x&&A&&x!==A)throw RangeError(H3);return A&&(I=g6(I,O(T),z,X,G,Q,D,F,O,U)),n(I)}function mY($){return $.sign===-1?i6($):$}function i6($){return n(E0($))}function E0($){let Z={};for(let J of g)Z[J]=-1*$[J]||0;return Z}function hY($){return!$.sign}function Z$($,Z=g){let J=0;for(let W of Z){let Y=Math.sign($[W]);if(Y){if(J&&J!==Y)throw RangeError(LB);J=Y}}return J}function IZ($){for(let Z of SB)s0(Z,$[Z],-w5,w5,1);return pY(d0(V0($),o0)),$}function pY($){if(!Number.isSafeInteger($))throw RangeError(UB)}function V0($,Z=6){return c5($,Z,g)}function PZ($,Z=6){let[J,W]=$,Y=S6(W,Z,g);if(Y[g[Z]]+=J*(c/G1[Z]),!Number.isFinite(Y[g[Z]]))throw RangeError(W4);return Y}function s6($,Z=5){return S6($,Z,g)}function cY($){return Boolean(Z$($,cz))}function M$($){let Z=9;for(;Z>0&&!$[g[Z]];Z--);return Z}function cF($,Z){return[$,Z]}function S5($){let Z=Math.floor($/O6)*O6;return[Z,Z+O6]}function dY($){let Z=J$($=L6($));if(!Z)throw RangeError(k0($));let J;if(Z.m)J=0;else{if(!Z.offset)throw RangeError(k0($));J=TZ(Z.offset)}return Z.timeZone&&rJ(Z.timeZone,1),D0(BJ(w6(Z),J))}function uY($){let Z=J$(e($));if(!Z)throw RangeError(k0($));if(Z.timeZone)return eY(Z,Z.offset?TZ(Z.offset):void 0);if(Z.m)throw RangeError(k0($));return Zj(Z)}function lY($,Z){let J=J$(e($));if(!J||!J.timeZone)throw RangeError(k0($));let{offset:W}=J,Y=W?TZ(W):void 0,[,j,z]=B3(Z);return eY(J,Y,j,z)}function TZ($){let Z=rJ($);if(Z===void 0)throw RangeError(k0($));return Z}function iY($){let Z=J$(e($));if(!Z||Z.m)throw RangeError(k0($));return X0($j(Z))}function n6($){let Z=J$(e($));if(!Z||Z.m)throw RangeError(k0($));return G0(Z.p?$j(Z):Zj(Z))}function sY($,Z){let J=oJ(e(Z));if(J)return nJ(J),T$(FJ(_$(J)));let W=n6(Z);return T$(Y3($(W.calendar),W))}function nJ($){if($.calendar!==w)throw RangeError(E1($.calendar))}function nY($,Z){let J=aJ(e(Z));if(J)return nJ(J),I6(_$(J));let W=n6(Z),{calendar:Y}=W,j=$(Y),[z,X,G]=j.h(W),[Q,K]=j.I(z,X),[B,F]=j.N(Q,K,G);return I6(o1(j.P(B,F,G)),Y)}function oY($){let Z,J=((W)=>{let Y=ZV.exec(W);return Y?(o6(Y[10]),Yj(Y)):void 0})(e($));if(!J){if(J=J$($),!J)throw RangeError(k0($));if(!J.p)throw RangeError(k0($));if(J.m)throw RangeError(E1("Z"));nJ(J)}if((Z=oJ($))&&_5(Z))throw RangeError(k0($));if((Z=aJ($))&&_5(Z))throw RangeError(k0($));return $1(k6(J,1))}function aY($){let Z=((J)=>{let W=YV.exec(J);return W?((Y)=>{function j(K,B,F){let D=0,V=0;if(F&&([D,G]=A1(G,G1[F])),K!==void 0){if(X)throw RangeError(E1(K));V=((O)=>{let U=parseInt(O);if(!Number.isFinite(U))throw RangeError(E1(O));return U})(K),z=1,B&&(G=tJ(B)*(G1[F]/o0),X=1)}return D+V}let z=0,X=0,G=0,Q={...DZ(g,[j(Y[2]),j(Y[3]),j(Y[4]),j(Y[5]),j(Y[6],Y[7],5),j(Y[8],Y[9],4),j(Y[10],Y[11],3)]),...S6(G,2,g)};if(!z)throw RangeError(Tz(g));return eJ(Y[1])<0&&(Q=E0(Q)),Q})(W):void 0})(e($));if(!Z)throw RangeError(k0($));return n(IZ(Z))}function rY($){let Z=J$($)||oJ($)||aJ($);return Z?Z.calendar:$}function tY($){let Z=J$($);return Z&&(Z.timeZone||Z.m&&q$||Z.offset)||$}function eY($,Z,J=0,W=0){let Y=a6($.timeZone),j=V4(Y);return I0(S$(j,w6($),Z,J,W,!j.v,$.m),Y,O3($.calendar))}function $j($){return Jj(b1(w6($)))}function Zj($){return Jj(o1(_$($)))}function Jj($){return{...$,calendar:O3($.calendar)}}function J$($){let Z=$V.exec($);return Z?((J)=>{let W=J[10],Y=(W||"").toUpperCase()==="Z";return{isoYear:Wj(J),isoMonth:parseInt(J[4]),isoDay:parseInt(J[5]),...Yj(J.slice(5)),...o6(J[16]),p:Boolean(J[6]),m:Y,offset:Y?void 0:W}})(Z):void 0}function oJ($){let Z=tB.exec($);return Z?((J)=>({isoYear:Wj(J),isoMonth:parseInt(J[4]),isoDay:1,...o6(J[5])}))(Z):void 0}function aJ($){let Z=eB.exec($);return Z?((J)=>({isoYear:OZ,isoMonth:parseInt(J[1]),isoDay:parseInt(J[2]),...o6(J[3])}))(Z):void 0}function rJ($,Z){let J=JV.exec($);return J?((W,Y)=>{let j=W[4]||W[5];if(Y&&j)throw RangeError(E1(j));return qJ((QZ(W[2])*z4+QZ(W[3])*j4+QZ(W[4])*o0+tJ(W[5]||""))*eJ(W[1]))})(J,Z):void 0}function Wj($){let Z=eJ($[1]),J=parseInt($[2]||$[3]);if(Z<0&&!J)throw RangeError(E1(-0));return Z*J}function Yj($){let Z=QZ($[3]);return{...b6(tJ($[4]||""))[0],isoHour:QZ($[1]),isoMinute:QZ($[2]),isoSecond:Z===60?59:Z}}function o6($){let Z,J,W=[];if($.replace(WV,(Y,j,z)=>{let X=Boolean(j),[G,Q]=z.split("=").reverse();if(Q){if(Q==="u-ca")W.push(G),Z||(Z=X);else if(X||/[A-Z]/.test(Q))throw RangeError(E1(Y))}else{if(J)throw RangeError(E1(Y));J=G}return""}),W.length>1&&Z)throw RangeError(E1($));return{timeZone:J,calendar:W[0]||w}}function tJ($){return parseInt($.padEnd(9,"0"))}function MZ($){return new RegExp(`^${$}$`,"i")}function eJ($){return $&&$!=="+"?-1:1}function QZ($){return $===void 0?0:parseInt($)}function jj($){return a6(e($))}function a6($){let Z=$2($);return typeof Z=="number"?C$(Z):Z?((J)=>{if(zV.test(J))throw RangeError(FB);return J.toLowerCase().split("/").map((W,Y)=>(W.length<=3||/\d/.test(W))&&!/etc|yap/.test(W)?W.toUpperCase():W.replace(/baja|dumont|[a-z]+/g,(j,z)=>j.length<=2&&!Y||j==="in"||j==="chat"?j.toUpperCase():j.length>2||!z?M5(j).replace(/island|noronha|murdo|rivadavia|urville/,M5):j)).join("/")})($):q$}function A5($){let Z=$2($);return typeof Z=="number"?Z:Z?Z.resolvedOptions().timeZone:q$}function $2($){let Z=rJ($=$.toUpperCase(),1);return Z!==void 0?Z:$!==q$?jV($):void 0}function Z2($,Z){return C0($.epochNanoseconds,Z.epochNanoseconds)}function J2($,Z){return C0($.epochNanoseconds,Z.epochNanoseconds)}function zj($,Z,J,W,Y,j){let z=$(e0(j).relativeTo),X=Math.max(M$(W),M$(Y));if(h5(g,W,Y))return 0;if(j3(X,z))return C0(V0(W),V0(Y));if(!z)throw RangeError(Y4);let[G,Q,K]=d6(Z,J,z),B=lJ(K),F=u6(K);return C0(B(F(Q,G,W)),B(F(Q,G,Y)))}function W2($,Z){return E$($,Z)||r6($,Z)}function E$($,Z){return n1(S0($),S0(Z))}function r6($,Z){return n1(t1($),t1(Z))}function Xj($,Z){return!Z2($,Z)}function Gj($,Z){return!J2($,Z)&&!!t6($.timeZone,Z.timeZone)&&HZ($.calendar,Z.calendar)}function Qj($,Z){return!W2($,Z)&&HZ($.calendar,Z.calendar)}function Kj($,Z){return!E$($,Z)&&HZ($.calendar,Z.calendar)}function Fj($,Z){return!E$($,Z)&&HZ($.calendar,Z.calendar)}function Bj($,Z){return!E$($,Z)&&HZ($.calendar,Z.calendar)}function Vj($,Z){return!r6($,Z)}function t6($,Z){if($===Z)return 1;let J=L0($),W=L0(Z);if(J===W)return 1;try{return A5(J)===A5(W)}catch(Y){}}function Y2($,Z,J,W){let Y=LZ($,z0(W),3,5),j=e6(Z.epochNanoseconds,J.epochNanoseconds,...Y);return n($?E0(j):j)}function j2($,Z,J,W,Y,j){let z=Z4(W.calendar,Y.calendar),X=z0(j),[G,Q,K,B]=LZ(J,X,5),F=W.epochNanoseconds,D=Y.epochNanoseconds,V=C0(D,F),O;if(V)if(G<6)O=e6(F,D,G,Q,K,B);else{let U=Z(((T,I)=>{if(!t6(T,I))throw RangeError(Sz);return T})(W.timeZone,Y.timeZone)),H=$(z);O=Dj(H,U,W,Y,V,G,X),O=g6(O,D,G,Q,K,B,H,W,HY,R(dJ,U))}else O=H0;return n(J?E0(O):O)}function z2($,Z,J,W,Y){let j=Z4(J.calendar,W.calendar),z=z0(Y),[X,G,Q,K]=LZ(Z,z,6),B=x0(J),F=x0(W),D=C0(F,B),V;if(D)if(X<=6)V=e6(B,F,X,G,Q,K);else{let O=$(j);V=Uj(O,J,W,D,X,z),V=g6(V,F,X,G,Q,K,O,J,x0,uJ)}else V=H0;return n(Z?E0(V):V)}function X2($,Z,J,W,Y){let j=Z4(J.calendar,W.calendar),z=z0(Y);return Oj(Z,()=>$(j),J,W,...LZ(Z,z,6,9,6),z)}function G2($,Z,J,W,Y){let j=Z4(J.calendar,W.calendar),z=z0(Y),X=LZ(Z,z,9,9,8),G=$(j);return Oj(Z,()=>G,Y3(G,J),Y3(G,W),...X,z)}function Oj($,Z,J,W,Y,j,z,X,G){let Q=x0(J),K=x0(W),B;if(C0(K,Q))if(Y===6)B=e6(Q,K,Y,j,z,X);else{let F=Z();B=F.dateUntil(J,W,Y,G),j===6&&z===1||(B=g6(B,K,Y,j,z,X,F,J,x0,c6))}else B=H0;return n($?E0(B):B)}function Q2($,Z,J,W){let Y=z0(W),[j,z,X,G]=LZ($,Y,5,5),Q=e1(K2(Z,J),V3(z,X),G),K={...H0,...s6(Q,j)};return n($?E0(K):K)}function dF($,Z,J,W,Y,j){let z=C0(W.epochNanoseconds,J.epochNanoseconds);return z?Y<6?Lj(J.epochNanoseconds,W.epochNanoseconds,Y):Dj(Z,$,J,W,z,Y,j):H0}function uF($,Z,J,W,Y){let j=x0(Z),z=x0(J),X=C0(z,j);return X?W<=6?Lj(j,z,W):Uj($,Z,J,X,W,Y):H0}function Dj($,Z,J,W,Y,j,z){let[X,G,Q]=((F,D,V,O)=>{function U(){return S={...A$(I,A++*-O),...T},M=v0(F,S),C0(x,M)===-O}let H=A0(D,F),T=g0(J1,H),I=A0(V,F),x=V.epochNanoseconds,A=0,f=K2(H,I),S,M;if(Math.sign(f)===-O&&A++,U()&&(O===-1||U()))throw RangeError(H3);let P=d0(c0(M,x));return[H,S,P]})(Z,J,W,Y);var K,B;return{...j===6?(K=X,B=G,{...H0,days:Hj(K,B)}):$.dateUntil(X,G,j,z),...s6(Q)}}function Uj($,Z,J,W,Y,j){let[z,X,G]=((Q,K,B)=>{let F=K,D=K2(Q,K);return Math.sign(D)===-B&&(F=A$(K,-B),D+=c*B),[Q,F,D]})(Z,J,W);return{...$.dateUntil(z,X,Y,j),...s6(G)}}function e6($,Z,J,W,Y,j){return{...H0,...PZ(m6(c0($,Z),W,Y,j),J)}}function Lj($,Z,J){return{...H0,...PZ(c0($,Z),J)}}function Hj($,Z){return $4(S0($),S0(Z))}function $4($,Z){return Math.trunc((Z-$)/q0)}function K2($,Z){return t1(Z)-t1($)}function Z4($,Z){if(!HZ($,Z))throw RangeError(x2);return $}function lF($){function Z(Y){return((j,z)=>({...Ij(j,z),F:j.month,day:parseInt(j.day)}))(KJ(J,Y),W)}let J=h2($),W=M6($);return{id:$,O:iF(Z),B:sF(Z)}}function iF($){return y0((Z)=>{let J=S0(Z);return $(J)},WeakMap)}function sF($){let Z=$(0).year-wB;return y0((J)=>{let W,Y=UZ(J-Z),j=[],z=[];do Y+=400*q0;while((W=$(Y)).year<=J);do Y+=(1-W.day)*q0,W.year===J&&(j.push(Y),z.push(W.F)),Y-=q0;while((W=$(Y)).year>=J);return{k:j.reverse(),C:fz(z.reverse())}})}function Ij($,Z){let J,W,Y=Pj($);if($.era){let j=mz[Z];j!==void 0&&(J=Z==="islamic"?"ah":$.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),J==="bc"||J==="b"?J="bce":J!=="ad"&&J!=="a"||(J="ce"),W=Y,Y=xj(W,j[J]||0))}return{era:J,eraYear:W,year:Y}}function Pj($){return parseInt($.relatedYear||$.year)}function n8($){let{year:Z,F:J,day:W}=this.O($),{C:Y}=this.B(Z);return[Z,Y[J]+1,W]}function z3($,Z=1,J=1){return this.B($).k[Z-1]+(J-1)*q0}function F6($){let Z=f5(this,$),J=f5(this,$-1),W=Z.length;if(W>J.length){let Y=Cj(this);if(Y<0)return-Y;for(let j=0;j<W;j++)if(Z[j]!==J[j])return j+1}}function B6($){return $4(z3.call(this,$),z3.call(this,$+1))}function E5($,Z){let{k:J}=this.B($),W=Z+1,Y=J;return W>J.length&&(W=1,Y=this.B($+1).k),$4(J[Z-1],Y[W-1])}function V6($){return this.B($).k.length}function f5($,Z){return Object.keys($.B(Z).C)}function Tj($){return O3(e($))}function O3($){if(($=$.toLowerCase())!==w&&$!==G4&&M6($)!==M6(h2($).resolvedOptions().calendar))throw RangeError(KB($));return $}function M6($){return $==="islamicc"&&($="islamic"),$.split("-")[0]}function Mj($){return this.R($)[0]}function Nj($){return this.R($)[1]}function F2($){let[Z]=this.h($);return $4(this.q(Z),S0($))+1}function _j($){let Z=GV.exec($);if(!Z)throw RangeError(GB($));return[parseInt(Z[1]),Boolean(Z[2])]}function N6($,Z,J){return $+(Z||J&&$>=J?1:0)}function o8($,Z){return $-(Z&&$>=Z?1:0)}function xj($,Z){return(Z+$)*(Math.sign(Z)||1)||0}function a8($){return mz[Sj($)]}function Cj($){return _B[Sj($)]}function Sj($){return M6($.id||w)}function Aj($,Z,J,W){let Y=W$(J,W,Z1,[],qz);if(Y.timeZone!==void 0){let j=J.dateFromFields(Y),z=f$(Y),X=$(Y.timeZone);return{epochNanoseconds:S$(Z(X),{...j,...z},Y.offset!==void 0?TZ(Y.offset):void 0),timeZone:X}}return{...J.dateFromFields(Y),...a0}}function Ej($,Z,J,W,Y,j){let z=W$(J,Y,Z1,wz,qz),X=$(z.timeZone),[G,Q,K]=B3(j),B=J.dateFromFields(z,y6(j,G)),F=f$(z,G);return I0(S$(Z(X),{...B,...F},z.offset!==void 0?TZ(z.offset):void 0,Q,K),X,W)}function fj($,Z,J){let W=W$($,Z,Z1,[],k1),Y=y(J);return X0(b1({...$.dateFromFields(W,y6(J,Y)),...f$(W,Y)}))}function B2($,Z,J,W=[]){let Y=W$($,Z,Z1,W);return $.dateFromFields(Y,J)}function V2($,Z,J,W){let Y=W$($,Z,A2,W);return $.yearMonthFromFields(Y,J)}function O2($,Z,J,W,Y=[]){let j=W$($,J,Z1,Y);return Z&&j.month!==void 0&&j.monthCode===void 0&&j.year===void 0&&(j.year=OZ),$.monthDayFromFields(j,W)}function bj($,Z){let J=y(Z);return $1(f$(X1($,t8,[],1),J))}function Rj($){let Z=X1($,E2);return n(IZ({...H0,...Z}))}function W$($,Z,J,W=[],Y=[]){return X1(Z,[...$.fields(J),...Y].sort(),W)}function X1($,Z,J,W=!J){let Y={},j,z=0;for(let X of Z){if(X===j)throw RangeError(JB(X));if(X==="constructor"||X==="__proto__")throw RangeError(N2(X));let G=$[X];if(G!==void 0)z=1,k5[X]&&(G=k5[X](G,X)),Y[X]=G;else if(J){if(J.includes(X))throw TypeError(M2(X));Y[X]=gz[X]}j=X}if(W&&!z)throw TypeError(Tz(Z));return Y}function f$($,Z){return k6(BV({...gz,...$}),Z)}function wj($,Z,J,W,Y,j){let z=z0(j),{calendar:X,timeZone:G}=J;return I0(((Q,K,B,F,D)=>{let V=D3(Q,B,F,Z1,kz,Rz),[O,U,H]=B3(D,2);return S$(K,{...Q.dateFromFields(V,y6(D,O)),...f$(V,O)},TZ(V.offset),U,H)})($(X),Z(G),W,Y,z),G,X)}function kj($,Z,J,W,Y){let j=z0(Y);return X0(((z,X,G,Q)=>{let K=D3(z,X,G,Z1,k1),B=y(Q);return b1({...z.dateFromFields(K,y6(Q,B)),...f$(K,B)})})($(Z.calendar),J,W,j))}function qj($,Z,J,W,Y){let j=z0(Y);return((z,X,G,Q)=>{let K=D3(z,X,G,Z1);return z.dateFromFields(K,Q)})($(Z.calendar),J,W,j)}function yj($,Z,J,W,Y){let j=z0(Y);return T$(((z,X,G,Q)=>{let K=D3(z,X,G,A2);return z.yearMonthFromFields(K,Q)})($(Z.calendar),J,W,j))}function vj($,Z,J,W,Y){let j=z0(Y);return((z,X,G,Q)=>{let K=D3(z,X,G,Z1);return z.monthDayFromFields(K,Q)})($(Z.calendar),J,W,j)}function gj($,Z,J){return $1(((W,Y,j)=>{let z=y(j);return f$({...g0(t8,W),...X1(Y,t8)},z)})($,Z,J))}function mj($,Z){return n((J=$,W=Z,IZ({...J,...X1(W,E2)})));var J,W}function D3($,Z,J,W,Y=[],j=[]){let z=[...$.fields(W),...Y].sort(),X=X1(Z,z,j),G=X1(J,z);return X=$.mergeFields(X,G),X1(X,z,[])}function D2($,Z){let J=W$($,Z,vz);return $.monthDayFromFields(J)}function U2($,Z,J){let W=W$($,Z,yz);return $.yearMonthFromFields(W,J)}function hj($,Z,J,W,Y){Z=g0(J=$.fields(J),Z),W=X1(W,Y=$.fields(Y),[]);let j=$.mergeFields(Z,W);return j=X1(j,[...J,...Y].sort(),[]),$.dateFromFields(j)}function d8($,Z){let{era:J,eraYear:W,year:Y}=Z,j=a8($);if(J!==void 0||W!==void 0){if(J===void 0||W===void 0)throw TypeError(YB);if(!j)throw RangeError(WB);let z=j[J];if(z===void 0)throw RangeError(zB(J));let X=xj(W,z);if(Y!==void 0&&Y!==X)throw RangeError(jB);Y=X}else if(Y===void 0)throw TypeError(XB(j));return Y}function u8($,Z,J,W){let{month:Y,monthCode:j}=Z;if(j!==void 0){let z=((X,G,Q,K)=>{let B=X.U(Q),[F,D]=_j(G),V=N6(F,D,B);if(D){let O=Cj(X);if(O===void 0)throw RangeError(Z3);if(O>0){if(V>O)throw RangeError(Z3);if(B===void 0){if(K===1)throw RangeError(Z3);V--}}else{if(V!==-O)throw RangeError(Z3);if(B===void 0&&K===1)throw RangeError(Z3)}}return V})($,j,J,W);if(Y!==void 0&&Y!==z)throw RangeError(xz);Y=z,W=1}else if(Y===void 0)throw TypeError(QB);return s0("month",Y,1,$.L(J),W)}function b5($,Z,J,W,Y){return w0(Z,"day",1,$.j(W,J),Y)}function l8($,Z,J,W){let Y=0,j=[];for(let z of J)Z[z]!==void 0?Y=1:j.push(z);if(Object.assign($,Z),Y)for(let z of W||j)delete $[z]}function pj($){return D0(u0(f6(E6($))))}function cj($,Z,J,W,Y=w){return I0(u0(f6(E6(J))),Z(W),$(Y))}function dj($,Z,J,W,Y=0,j=0,z=0,X=0,G=0,Q=0,K=w){return X0(b1(w6(r0(_0,DZ(Q4,[Z,J,W,Y,j,z,X,G,Q])))),$(K))}function uj($,Z,J,W,Y=w){return G0(o1(_$(r0(_0,{isoYear:Z,isoMonth:J,isoDay:W}))),$(Y))}function lj($,Z,J,W=w,Y=1){let j=_0(Z),z=_0(J),X=$(W);return T$(FJ(_$({isoYear:j,isoMonth:z,isoDay:_0(Y)})),X)}function ij($,Z,J,W=w,Y=OZ){let j=_0(Z),z=_0(J),X=$(W);return I6(o1(_$({isoYear:_0(Y),isoMonth:j,isoDay:z})),X)}function sj($=0,Z=0,J=0,W=0,Y=0,j=0){return $1(k6(r0(_0,DZ(J1,[$,Z,J,W,Y,j])),1))}function nj($=0,Z=0,J=0,W=0,Y=0,j=0,z=0,X=0,G=0,Q=0){return n(IZ(r0(t5,DZ(g,[$,Z,J,W,Y,j,z,X,G,Q]))))}function L2($,Z,J=w){return I0($.epochNanoseconds,Z,J)}function oj($){return D0($.epochNanoseconds)}function H2($,Z){return X0(A0(Z,$))}function I2($,Z){return G0(A0(Z,$))}function aj($,Z,J){return U2($(Z.calendar),J)}function rj($,Z,J){return D2($(Z.calendar),J)}function P2($,Z){return $1(A0(Z,$))}function tj($,Z,J,W){let Y=((j,z,X,G)=>{let Q=DJ(G);return v0(j(z),X,Q)})($,J,Z,W);return I0(u0(Y),J,Z.calendar)}function ej($,Z,J){let W=$(Z.calendar);return T$({...Z,...U2(W,J)})}function $z($,Z,J){return D2($(Z.calendar),J)}function Zz($,Z,J,W,Y){let j=$(Y.timeZone),z=Y.plainTime,X=z!==void 0?Z(z):a0;return I0(v0(J(j),{...W,...X}),j,W.calendar)}function Jz($,Z=a0){return X0(b1({...$,...Z}))}function Wz($,Z,J){return U2($(Z.calendar),J)}function Yz($,Z,J){return D2($(Z.calendar),J)}function jz($,Z,J,W){return((Y,j,z)=>hj(Y,j,yz,f1(z),P3))($(Z.calendar),J,W)}function zz($,Z,J,W){return((Y,j,z)=>hj(Y,j,vz,f1(z),X4))($(Z.calendar),J,W)}function Xz($,Z,J,W,Y){let j=f1(Y),z=Z(j.plainDate),X=$(j.timeZone);return I0(v0(J(X),{...z,...W}),X,z.calendar)}function Gz($,Z){return X0(b1({...$,...Z}))}function Qz($){return D0(u0(BZ($,o0)))}function Kz($){return D0(u0(BZ($,Q1)))}function Fz($){return D0(u0(f6(E6($),R$)))}function Bz($){return D0(u0(f6(E6($))))}function Vz($,Z,J=a0){let W=Z.timeZone,Y=$(W),j={...A0(Z,Y),...J};return I0(S$(Y,j,j.offsetNanoseconds,2),W,Z.calendar)}function Oz($,Z,J){let W=Z.timeZone,Y=$(W),j={...A0(Z,Y),...J},z=Hz(Z.calendar,J.calendar);return I0(S$(Y,j,j.offsetNanoseconds,2),W,z)}function Dz($,Z=a0){return X0({...$,...Z})}function Uz($,Z){return X0({...$,...Z},Hz($.calendar,Z.calendar))}function J4($,Z){return{...$,calendar:Z}}function Lz($,Z){return{...$,timeZone:Z}}function Hz($,Z){if($===Z)return $;let J=L0($),W=L0(Z);if(J===W||J===w)return Z;if(W===w)return $;throw RangeError(x2)}function nF($,Z){return(J)=>J===w?$:J===G4||J===VZ?Object.assign(Object.create($),{id:J}):Object.assign(Object.create(Z),XV(J))}function b$($,Z,J){let W=new Set(J);return(Y)=>(((j,z)=>{for(let X of z)if(X in j)return 1;return 0})(Y=JJ(W,Y),$)||Object.assign(Y,Z),J&&(Y.timeZone=q$,["full","long"].includes(Y.timeStyle)&&(Y.timeStyle="medium")),Y)}function R1($,Z=T2){let[J,,,W]=$;return(Y,j=AV,...z)=>{let X=Z(W&&W(...z),Y,j,J),G=X.resolvedOptions();return[X,...oF($,G,z)]}}function T2($,Z,J,W){if(J=W(J),$){if(J.timeZone!==void 0)throw TypeError(TB);J.timeZone=$}return new Y$(Z,J)}function oF($,Z,J){let[,W,Y]=$;return J.map((j)=>(j.calendar&&((z,X,G)=>{if((G||z!==w)&&z!==X)throw RangeError(x2)})(L0(j.calendar),Z.calendar,Y),W(j,Z)))}function NZ($){let Z=U3();return $$(Z,$.getOffsetNanosecondsFor(Z))}function U3(){return BZ(Date.now(),Q1)}function w1(){return y5||(y5=new Y$().resolvedOptions().timeZone)}var aF=($,Z)=>`Non-integer ${$}: ${Z}`,rF=($,Z)=>`Non-positive ${$}: ${Z}`,tF=($,Z)=>`Non-finite ${$}: ${Z}`,eF=($)=>`Cannot convert bigint to ${$}`,$B=($)=>`Invalid bigint: ${$}`,ZB="Cannot convert Symbol to string",Iz="Invalid object",Pz=($,Z,J,W,Y)=>Y?Pz($,Y[Z],Y[J],Y[W]):L3($,Z)+`; must be between ${J}-${W}`,L3=($,Z)=>`Invalid ${$}: ${Z}`,M2=($)=>`Missing ${$}`,N2=($)=>`Invalid field ${$}`,JB=($)=>`Duplicate field ${$}`,Tz=($)=>"No valid fields: "+$.join(),Mz="Invalid bag",Nz=($,Z,J)=>L3($,Z)+"; must be "+Object.keys(J).join(),_z="Cannot use valueOf",_2="Invalid calling context",WB="Forbidden era/eraYear",YB="Mismatching era/eraYear",jB="Mismatching year/eraYear",zB=($)=>`Invalid era: ${$}`,XB=($)=>"Missing year"+($?"/era/eraYear":""),GB=($)=>`Invalid monthCode: ${$}`,xz="Mismatching month/monthCode",QB="Missing month/monthCode",R5="Cannot guess year",Z3="Invalid leap month",Cz="Invalid protocol",H3="Invalid protocol results",x2="Mismatching Calendars",KB=($)=>`Invalid Calendar: ${$}`,Sz="Mismatching TimeZones",FB="Forbidden ICU TimeZone",BB="Out-of-bounds offset",VB="Out-of-bounds TimeZone gap",OB="Invalid TimeZone offset",DB="Ambiguous offset",W4="Out-of-bounds date",UB="Out-of-bounds duration",LB="Cannot mix duration signs",Y4="Missing relativeTo",HB="Cannot use large units",IB="Required smallestUnit or largestUnit",PB="smallestUnit > largestUnit",k0=($)=>`Cannot parse: ${$}`,E1=($)=>`Invalid substring: ${$}`,Az=($)=>`Cannot format ${$}`,Ez="Mismatching types for formatting",TB="Cannot specify TimeZone",fz=R(Q3,($,Z)=>Z),_Z=R(Q3,($,Z,J)=>J),n0=R(U6,2),r8={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},I3=Object.keys(r8),q0=86400000,bz=1000,R$=1000,Q1=1e6,o0=1e9,j4=60000000000,z4=3600000000000,c=86400000000000,G1=[1,R$,Q1,o0,j4,z4,c],k1=I3.slice(0,6),t8=K3(k1),Rz=["offset"],wz=["timeZone"],kz=k1.concat(Rz),qz=kz.concat(wz),e8=["era","eraYear"],MB=e8.concat(["year"]),X4=["year"],C2=["monthCode"],S2=["month"].concat(C2),P3=["day"],A2=S2.concat(X4),yz=C2.concat(X4),Z1=P3.concat(A2),NB=P3.concat(S2),vz=P3.concat(C2),gz=_Z(k1,0),w="iso8601",G4="gregory",VZ="japanese",mz={[G4]:{bce:-1,ce:0},[VZ]:{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}},_B={chinese:13,dangi:13,hebrew:-6},e=R(A6,"string"),hz=R(A6,"boolean"),xB=R(A6,"number"),pz=R(A6,"function"),g=I3.map(($)=>$+"s"),E2=K3(g),CB=g.slice(0,6),cz=g.slice(6),SB=cz.slice(1),AB=fz(g),H0=_Z(g,0),f2=_Z(CB,0),b2=R(p5,g),J1=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],R2=["isoDay","isoMonth","isoYear"],Q4=J1.concat(R2),w2=K3(R2),dz=K3(J1),uz=K3(Q4),a0=_Z(dz,0),EB=R(p5,Q4),Y$=Intl.DateTimeFormat,lz="en-GB",k2=1e8,fB=k2*q0,bB=[k2,0],RB=[-k2,0],X3=275760,G3=-271821,wB=1970,OZ=1972,S1=12,kB=UZ(1868,9,8),qB=y0(qF,WeakMap),_6="smallestUnit",$J="unit",W3="roundingIncrement",i8="fractionalSecondDigits",iz="relativeTo",sz={constrain:0,reject:1},yB=Object.keys(sz),vB={compatible:0,reject:1,earlier:2,later:3},gB={reject:0,use:1,prefer:2,ignore:3},mB={auto:0,never:1,critical:2,always:3},hB={auto:0,never:1,critical:2},pB={auto:0,never:1},cB={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},T3=R(TJ,_6),q2=R(TJ,"largestUnit"),dB=R(TJ,$J),nz=R(x$,"overflow",sz),oz=R(x$,"disambiguation",vB),uB=R(x$,"offset",gB),y2=R(x$,"calendarName",mB),lB=R(x$,"timeZoneName",hB),iB=R(x$,"offset",pB),M3=R(x$,"roundingMode",cB),xZ="PlainYearMonth",CZ="PlainMonthDay",w$="PlainDate",k$="PlainDateTime",K4="PlainTime",q1="ZonedDateTime",F4="Instant",B4="Duration",sB=[Math.floor,($)=>K6($)?Math.floor($):Math.round($),Math.ceil,($)=>K6($)?Math.ceil($):Math.round($),Math.trunc,($)=>K6($)?Math.trunc($)||0:Math.round($),($)=>$<0?Math.floor($):Math.ceil($),($)=>Math.sign($)*Math.round(Math.abs($))||0,($)=>K6($)?($=Math.trunc($)||0)+$%2:Math.round($)],q$="UTC",O6=5184000,nB=H6(1847),oB=H6(new Date().getUTCFullYear()+10),aB=/0+$/,A0=y0(pF,WeakMap),w5=4294967295,V4=y0(($)=>{let Z=$2($);return typeof Z=="object"?new rz(Z):new az(Z||0)});class az{constructor($){this.v=$}getOffsetNanosecondsFor(){return this.v}getPossibleInstantsFor($){return[BJ($,this.v)]}l(){}}class rz{constructor($){this.$=((Z)=>{function J(G){let Q=s8(G,z,X),[K,B]=S5(Q),F=Y(K),D=Y(B);return F===D?F:W(j(K,B),F,D,G)}function W(G,Q,K,B){let F,D;for(;(B===void 0||(F=B<G[0]?Q:B>=G[1]?K:void 0)===void 0)&&(D=G[1]-G[0]);){let V=G[0]+Math.floor(D/2);Z(V)===K?G[1]=V:G[0]=V+1}return F}let Y=y0(Z),j=y0(cF),z=nB,X=oB;return{G(G){let Q=J(G-86400),K=J(G+86400),B=G-Q,F=G-K;if(Q===K)return[B];let D=J(B);return D===J(F)?[G-D]:Q>K?[B,F]:[]},V:J,l(G,Q){let K=s8(G,z,X),[B,F]=S5(K),D=O6*Q,V=Q<0?()=>F>z||(z=K,0):()=>B<X||(X=K,0);for(;V();){let O=Y(B),U=Y(F);if(O!==U){let H=j(B,F);W(H,O,U);let T=H[0];if((n1(T,G)||1)===Q)return T}B+=D,F+=D}}}})(((Z)=>(J)=>{let W=KJ(Z,J*bz);return H6(Pj(W),parseInt(W.month),parseInt(W.day),parseInt(W.hour),parseInt(W.minute),parseInt(W.second))-J})($))}getOffsetNanosecondsFor($){return this.$.V(ZY($))*o0}getPossibleInstantsFor($){let[Z,J]=[H6((W=$).isoYear,W.isoMonth,W.isoDay,W.isoHour,W.isoMinute,W.isoSecond),W.isoMillisecond*Q1+W.isoMicrosecond*R$+W.isoNanosecond];var W;return this.$.G(Z).map((Y)=>u0(FZ(BZ(Y,o0),J)))}l($,Z){let[J,W]=JY($),Y=this.$.l(J+(Z>0||W?1:0),Z);if(Y!==void 0)return BZ(Y,o0)}}var v2="([+\u2212-])",D6="(?:[.,](\\d{1,9}))?",tz=`(?:(?:${v2}(\\d{6}))|(\\d{4}))-?(\\d{2})`,g2="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+D6+")?)?",m2=v2+g2,rB=tz+"-?(\\d{2})(?:[T ]"+g2+"(Z|"+m2+")?)?",ez="\\[(!?)([^\\]]*)\\]",O4=`((?:${ez}){0,9})`,tB=MZ(tz+O4),eB=MZ("(?:--)?(\\d{2})-?(\\d{2})"+O4),$V=MZ(rB+O4),ZV=MZ("T?"+g2+"(?:"+m2+")?"+O4),JV=MZ(m2),WV=new RegExp(ez,"g"),YV=MZ(`${v2}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${D6}H)?(?:(\\d+)${D6}M)?(?:(\\d+)${D6}S)?)?`),jV=y0(($)=>new Y$(lz,{timeZone:$,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),zV=/^(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$/,XV=y0(lF),h2=y0(($)=>new Y$(lz,{calendar:$,timeZone:q$,era:"short",year:"numeric",month:"short",day:"numeric"})),GV=/^M(\d{2})(L?)$/,QV={era:L6,eraYear:_0,year:_0,month:N5,monthCode:L6,day:N5},KV=_Z(k1,_0),FV=_Z(g,t5),k5=Object.assign({},QV,KV,FV,{offset:L6}),BV=R(kF,k1,J1),q5={dateAdd($,Z,J){let W=y(J),Y,{years:j,months:z,weeks:X,days:G}=Z;if(G+=V0(Z,5)[0],j||z)Y=((Q,K,B,F,D)=>{let[V,O,U]=Q.h(K);if(B){let[H,T]=Q.I(V,O);V+=B,O=N6(H,T,Q.U(V)),O=s0("month",O,1,Q.L(V),D)}return F&&([V,O]=Q._(V,O,F)),U=s0("day",U,1,Q.j(V,O),D),Q.q(V,O,U)})(this,$,j,z,W);else{if(!X&&!G)return $;Y=S0($)}return Y+=(7*X+G)*q0,o1(R6(Y))},dateUntil($,Z,J){if(J<=7){let G=0,Q=Hj({...$,...a0},{...Z,...a0});return J===7&&([G,Q]=r1(Q,7)),{...H0,weeks:G,days:Q}}let W=this.h($),Y=this.h(Z),[j,z,X]=((G,Q,K,B,F,D,V)=>{let O=F-Q,U=D-K,H=V-B;if(O||U){let T=Math.sign(O||U),I=G.j(F,D),x=0;if(Math.sign(H)===-T){let A=I;[F,D]=G._(F,D,-T),O=F-Q,U=D-K,I=G.j(F,D),x=T<0?-A:I}if(H=V-Math.min(B,I)+x,O){let[A,f]=G.I(Q,K),[S,M]=G.I(F,D);if(U=S-A||Number(M)-Number(f),Math.sign(U)===-T){let P=T<0&&-G.L(F);O=(F-=T)-Q,U=D-N6(A,f,G.U(F))+(P||G.L(F))}}}return[O,U,H]})(this,...W,...Y);return J===8&&(z+=this.J(j,W[0]),j=0),{...H0,years:j,months:z,days:X}},dateFromFields($,Z){let J=y(Z),W=d8(this,$),Y=u8(this,$,W,J),j=b5(this,$,Y,W,J);return G0(o1(this.P(W,Y,j)),this.id||w)},yearMonthFromFields($,Z){let J=y(Z),W=d8(this,$),Y=u8(this,$,W,J);return T$(FJ(this.P(W,Y,1)),this.id||w)},monthDayFromFields($,Z){let J=y(Z),W=!this.id,{monthCode:Y,year:j,month:z}=$,X,G,Q,K,B;if(Y!==void 0){[X,G]=_j(Y),B=v5($,"day");let F=this.N(X,G,B);if(!F)throw RangeError(R5);if([Q,K]=F,z!==void 0&&z!==K)throw RangeError(xz);W&&(K=s0("month",K,1,S1,1),B=s0("day",B,1,VJ(j!==void 0?j:Q,K),J))}else{Q=j===void 0&&W?OZ:d8(this,$),K=u8(this,$,Q,J),B=b5(this,$,K,Q,J);let F=this.U(Q);G=K===F,X=o8(K,F);let D=this.N(X,G,B);if(!D)throw RangeError(R5);[Q,K]=D}return I6(o1(this.P(Q,K,B)),this.id||w)},fields($){return a8(this)&&$.includes("year")?[...$,...e8]:$},mergeFields($,Z){let J=Object.assign(Object.create(null),$);return l8(J,Z,S2),a8(this)&&(l8(J,Z,MB),this.id===VZ&&l8(J,Z,NB,e8)),J},inLeapYear($){let[Z]=this.h($);return this.K(Z)},monthsInYear($){let[Z]=this.h($);return this.L(Z)},daysInMonth($){let[Z,J]=this.h($);return this.j(Z,J)},daysInYear($){let[Z]=this.h($);return this.X(Z)},dayOfYear:F2,era($){return this.ee($)[0]},eraYear($){return this.ee($)[1]},monthCode($){let[Z,J]=this.h($),[W,Y]=this.I(Z,J);return((j,z)=>"M"+n0(j)+(z?"L":""))(W,Y)},dayOfWeek:XY,daysInWeek(){return 7}},VV={dayOfYear:F2,h:YY,q:UZ},OV=Object.assign({},VV,{weekOfYear:Mj,yearOfWeek:Nj,R($){function Z(D){return(7-D<W?7:0)-D}function J(D){let V=zY(F+D),O=D||1,U=Z(J3(G+V*O,7));return K=(V+(U-Q)*O)/7}let W=this.id?1:4,Y=XY($),j=this.dayOfYear($),z=J3(Y-1,7),X=j-1,G=J3(z-X,7),Q=Z(G),K,B=Math.floor((X-Q)/7)+1,F=$.isoYear;return B?B>J(0)&&(B=1,F++):(B=J(-1),F--),[B,F,K]}}),DV={dayOfYear:F2,h:n8,q:z3,weekOfYear:Mj,yearOfWeek:Nj,R(){return[]}},SZ=nF(Object.assign({},q5,OV,{h:YY,ee($){return this.id===G4?GY($):this.id===VZ?qB($):[]},I:($,Z)=>[Z,0],N($,Z){if(!Z)return[OZ,$]},K:OJ,U(){},L:jY,J:($)=>$*S1,j:VJ,X:zY,P:($,Z,J)=>({isoYear:$,isoMonth:Z,isoDay:J}),q:UZ,_:($,Z,J)=>($+=C6(J,S1),(Z+=YJ(J,S1))<1?($--,Z+=S1):Z>S1&&($++,Z-=S1),[$,Z]),year($){return $.isoYear},month($){return $.isoMonth},day:($)=>$.isoDay}),Object.assign({},q5,DV,{h:n8,ee($){let Z=this.O($);return[Z.era,Z.eraYear]},I($,Z){let J=F6.call(this,$);return[o8(Z,J),J===Z]},N($,Z,J){let[W,Y,j]=n8.call(this,{isoYear:OZ,isoMonth:S1,isoDay:31}),z=F6.call(this,W),X=Y===z;(n1($,o8(Y,z))||n1(Number(Z),Number(X))||n1(J,j))===1&&W--;for(let G=0;G<100;G++){let Q=W-G,K=F6.call(this,Q),B=N6($,Z,K);if(Z===(B===K)&&J<=E5.call(this,Q,B))return[Q,B]}},K($){let Z=B6.call(this,$);return Z>B6.call(this,$-1)&&Z>B6.call(this,$+1)},U:F6,L:V6,J($,Z){let J=Z+$,W=Math.sign($),Y=W<0?-1:0,j=0;for(let z=Z;z!==J;z+=W)j+=V6.call(this,z+Y);return j},j:E5,X:B6,P($,Z,J){return R6(z3.call(this,$,Z,J))},q:z3,_($,Z,J){if(J){if(Z+=J,!Number.isSafeInteger(Z))throw RangeError(W4);if(J<0)for(;Z<1;)Z+=V6.call(this,--$);else{let W;for(;Z>(W=V6.call(this,$));)Z-=W,$++}}return[$,Z]},year($){return this.O($).year},month($){let{year:Z,F:J}=this.O($),{C:W}=this.B(Z);return W[J]+1},day($){return this.O($).day}})),a1="numeric",AZ=["timeZoneName"],$X={month:a1,day:a1},p2={year:a1,month:a1},c2=Object.assign({},p2,{day:a1}),d2={hour:a1,minute:a1,second:a1},u2=Object.assign({},c2,d2),UV=Object.assign({},u2,{timeZoneName:"short"}),LV=Object.keys(p2),HV=Object.keys($X),IV=Object.keys(c2),PV=Object.keys(d2),l2=["dateStyle"],TV=LV.concat(l2),MV=HV.concat(l2),i2=IV.concat(l2,["weekday"]),N3=PV.concat(["dayPeriod","timeStyle"]),s2=i2.concat(N3),NV=s2.concat(AZ),_V=AZ.concat(N3),xV=AZ.concat(i2),CV=AZ.concat(["day","weekday"],N3),SV=AZ.concat(["year","weekday"],N3),AV={},n2=[b$(s2,u2),v6],ZX=[b$(NV,UV),v6,0,($,Z)=>{let J=L0($.timeZone);if(Z&&L0(Z.timeZone)!==J)throw RangeError(Sz);return J}],o2=[b$(s2,u2,AZ),S0],a2=[b$(i2,c2,_V),S0],r2=[b$(N3,d2,xV),($)=>t1($)/Q1],t2=[b$(TV,p2,CV),S0,1],e2=[b$(MV,$X,SV),S0,1],y5;function B1($,Z,J,W,Y){function j(...G){if(!(this instanceof j))throw TypeError(_2);jX(this,Z(...G))}function z(G,Q){return Object.defineProperties(function(...K){return G.call(this,X(this),...K)},ZJ(Q))}function X(G){let Q=M0(G);if(!Q||Q.branding!==$)throw TypeError(_2);return Q}return Object.defineProperties(j.prototype,{...g5(r0(z,J)),...N$(r0(z,W)),...x6("Temporal."+$)}),Object.defineProperties(j,{...N$(Y),...ZJ($)}),[j,(G)=>{let Q=Object.create(j.prototype);return jX(Q,G),Q},X]}function GX($){return $=$.concat("id").sort(),(Z)=>{if(!m5(Z,$))throw TypeError(Cz);return Z}}function RZ($){if(M0($)||$.calendar!==void 0||$.timeZone!==void 0)throw TypeError(Mz);return $}function D4($,Z){let J={};for(let W in $)J[W]=({o:Y},j)=>{let z=M0(j)||{},{branding:X}=z,G=X===w$||Z.includes(X)?z:b0(j);return Y[W](G)};return J}function J7($){let Z={};for(let J in $)Z[J]=(W)=>{let{calendar:Y}=W;return(j=Y,typeof j=="string"?SZ(j):(z=j,Object.assign(Object.create(uV),{i:z})))[J](W);var j,z};return Z}function Q$(){throw TypeError(_z)}function x3({calendar:$}){return typeof $=="string"?new F7($):$}function JX($,Z){if(Z=z0(Z),O0($)){let W=M0($);if(W&&W.branding===CZ)return y(Z),W;let Y=FX($);return O2(M4(Y||w),!Y,$,Z)}let J=nY(SZ,$);return y(Z),J}function QX($,Z,J){return W=Z.call($,f0(D0(J))),qJ(F3(W));var W}function U4($,Z=DX){let J=Object.keys(Z).sort(),W={};for(let Y of J)W[Y]=R(Z[Y],$,pz($[Y]));return W}function d($,Z){return typeof $=="string"?V4($):U4($,Z)}function K0($){return d($,Z7)}function K1($){if(O0($)){let Z=M0($);if(Z)switch(Z.branding){case F4:return Z;case q1:return D0(Z.epochNanoseconds)}}return dY($)}function WX($,Z,J){let W=Z.l(K1(J).epochNanoseconds,$);return W?f0(D0(W)):null}function i($){return O0($)?(M0($)||{}).timeZone||aV($):((Z)=>a6(tY(e(Z))))($)}function j$($,Z){if(O0($)){let J=M0($)||{};switch(J.branding){case K4:return y(Z),J;case k$:return y(Z),$1(J);case q1:return y(Z),P2(K0,J)}return bj($,Z)}return y(Z),oY($)}function W7($){return $===void 0?void 0:j$($)}function EZ($,Z){if(Z=z0(Z),O0($)){let W=M0($);return W&&W.branding===xZ?(y(Z),W):V2(P4(C3($)),$,Z)}let J=sY(SZ,$);return y(Z),J}function z$($,Z){if(Z=z0(Z),O0($)){let W=M0($)||{};switch(W.branding){case k$:return y(Z),W;case w$:return y(Z),X0({...W,...a0});case q1:return y(Z),H2(K0,W)}return fj(T4(C3($)),$,Z)}let J=iY($);return y(Z),J}function b0($,Z){if(Z=z0(Z),O0($)){let W=M0($)||{};switch(W.branding){case w$:return y(Z),W;case k$:return y(Z),G0(W);case q1:return y(Z),I2(K0,W)}return B2(T4(C3($)),$,Z)}let J=n6($);return y(Z),J}function KX($,Z,J){return t0(Z.call($,Z0(G0(J,$))))}function V1($){return(Z)=>typeof Z=="string"?SZ(Z):((J,W)=>{let Y=Object.keys(W).sort(),j={};for(let z of Y)j[z]=R(W[z],J,J[z]);return j})(Z,$)}function $0($){if(O0($)){let Z=M0($);return Z&&Z.branding===B4?Z:Rj($)}return aY($)}function _3($){if($!==void 0){if(O0($)){let Z=M0($)||{};switch(Z.branding){case q1:case w$:return Z;case k$:return G0(Z)}let J=C3($);return{...Aj(i,d,T4(J),$),calendar:J}}return uY($)}}function C3($){return FX($)||w}function FX($){let{calendar:Z}=$;if(Z!==void 0)return T0(Z)}function T0($){return O0($)?(M0($)||{}).calendar||FO($):((Z)=>O3(rY(e(Z))))($)}function fZ($,Z){if(Z=z0(Z),O0($)){let J=M0($);if(J&&J.branding===q1)return B3(Z),J;let W=C3($);return Ej(i,d,T4(W),W,$,Z)}return lY($,Z)}function YX($){return r0((Z)=>(J)=>Z($7(J)),$)}function $7($){return A0($,K0)}function EV(){let $=Y$.prototype,Z=Object.getOwnPropertyDescriptors($),J=Object.getOwnPropertyDescriptors(Y$),W=function(Y,j={}){if(!(this instanceof W))return new W(Y,j);B7.set(this,((z,X={})=>{let G=new Y$(z,X),Q=G.resolvedOptions(),K=Q.locale,B=g0(Object.keys(X),Q),F=y0(RV),D=(...V)=>{let O,U=V.map((H,T)=>{let I=M0(H),x=(I||{}).branding;if(T&&O&&O!==x)throw TypeError(Ez);return O=x,I});return O?F(O)(K,B,...U):[G,...V]};return D.u=G,D})(Y,j))};for(let Y in Z){let j=Z[Y],z=Y.startsWith("format")&&fV(Y);typeof j.value=="function"?j.value=Y==="constructor"?W:z||bV(Y):z&&(j.get=function(){return z.bind(this)})}return J.prototype.value=Object.create($,Z),Object.defineProperties(W,J),W}function fV($){return function(...Z){let J=B7.get(this),[W,...Y]=J(...Z);return W[$](...Y)}}function bV($){return function(...Z){return B7.get(this).u[$](...Z)}}function RV($){let Z=wV[$];if(!Z)throw TypeError(Az($));return R1(Z,y0(T2))}var wV={Instant:n2,PlainDateTime:o2,PlainDate:a2,PlainTime:r2,PlainYearMonth:t2,PlainMonthDay:e2},kV=R1(n2),qV=R1(ZX),yV=R1(o2),vV=R1(a2),gV=R1(r2),mV=R1(t2),hV=R1(e2),Y7={era:i5,eraYear:jJ,year:F3,month:t0,daysInMonth:t0,daysInYear:t0,inLeapYear:hz,monthsInYear:t0},H4={monthCode:e},j7={day:t0},BX={dayOfWeek:t0,dayOfYear:t0,weekOfYear:s5,yearOfWeek:jJ,daysInWeek:t0},VX=Object.assign({},Y7,H4,j7,BX),L4=new WeakMap,M0=L4.get.bind(L4),jX=L4.set.bind(L4),pV={...D4(Y7,[xZ]),...D4(BX,[]),...D4(H4,[xZ,CZ]),...D4(j7,[CZ])},z7=J7(VX),cV=J7({...Y7,...H4}),dV=J7({...H4,...j7}),S3={calendarId:($)=>L0($.calendar)},uV=r0(($,Z)=>function(J){let{i:W}=this;return $(W[Z](Z0(G0(J,W))))},VX),lV=Q3(($)=>(Z)=>Z[$],g.concat("sign")),X7=Q3(($,Z)=>(J)=>J[J1[Z]],k1),OX={epochSeconds:DY,epochMilliseconds:v6,epochMicroseconds:UY,epochNanoseconds:LY},A3=R(JJ,new Set(["branding"])),[iV,bZ,sV]=B1(CZ,R(ij,T0),{...S3,...dV},{getISOFields:A3,getCalendar:x3,with($,Z,J){return bZ(vj(GO,$,this,RZ(Z),J))},equals:($,Z)=>Bj($,JX(Z)),toPlainDate($,Z){return Z0(zz(E3,$,this,Z))},toLocaleString($,Z,J){let[W,Y]=hV(Z,J,$);return W.format(Y)},toString:fJ,toJSON:($)=>fJ($),valueOf:Q$},{from:($,Z)=>bZ(JX($,Z))}),DX={getOffsetNanosecondsFor:QX,getPossibleInstantsFor($,Z,J){let W=[...Z.call($,P0(X0(J,w)))].map((j)=>oV(j).epochNanoseconds),Y=W.length;return Y>1&&(W.sort(C0),yJ(d0(c0(W[0],W[Y-1])))),W}},Z7={getOffsetNanosecondsFor:QX},[nV,f0,oV]=B1(F4,pj,OX,{add:($,Z)=>f0(vJ(0,$,$0(Z))),subtract:($,Z)=>f0(vJ(1,$,$0(Z))),until:($,Z,J)=>u(Y2(0,$,K1(Z),J)),since:($,Z,J)=>u(Y2(1,$,K1(Z),J)),round:($,Z)=>f0(PY($,Z)),equals:($,Z)=>Xj($,K1(Z)),toZonedDateTime($,Z){let J=f1(Z);return Q0(L2($,i(J.timeZone),T0(J.calendar)))},toZonedDateTimeISO:($,Z)=>Q0(L2($,i(Z))),toLocaleString($,Z,J){let[W,Y]=kV(Z,J,$);return W.format(Y)},toString:($,Z)=>xJ(i,K0,$,Z),toJSON:($)=>xJ(i,K0,$),valueOf:Q$},{from:($)=>f0(K1($)),fromEpochSeconds:($)=>f0(Qz($)),fromEpochMilliseconds:($)=>f0(Kz($)),fromEpochMicroseconds:($)=>f0(Fz($)),fromEpochNanoseconds:($)=>f0(Bz($)),compare:($,Z)=>Z2(K1($),K1(Z))}),[I4,WP]=B1("TimeZone",($)=>{let Z=jj($);return{branding:"TimeZone",id:Z,o:V4(Z)}},{id:($)=>$.id},{getPossibleInstantsFor:({o:$},Z)=>$.getPossibleInstantsFor(z$(Z)).map((J)=>f0(D0(J))),getOffsetNanosecondsFor:({o:$},Z)=>$.getOffsetNanosecondsFor(K1(Z).epochNanoseconds),getOffsetStringFor($,Z){let J=K1(Z).epochNanoseconds,W=U4(this,Z7).getOffsetNanosecondsFor(J);return C$(W)},getPlainDateTimeFor($,Z,J=w){let W=K1(Z).epochNanoseconds,Y=U4(this,Z7).getOffsetNanosecondsFor(W);return P0(X0($$(W,Y),T0(J)))},getInstantFor($,Z,J){let W=z$(Z),Y=DJ(J),j=U4(this);return f0(D0(v0(j,W,Y)))},getNextTransition:({o:$},Z)=>WX(1,$,Z),getPreviousTransition:({o:$},Z)=>WX(-1,$,Z),equals($,Z){return!!t6(this,i(Z))},toString:($)=>$.id,toJSON:($)=>$.id},{from($){let Z=i($);return typeof Z=="string"?new I4(Z):Z}}),aV=GX(Object.keys(DX)),[rV,X$]=B1(K4,sj,X7,{getISOFields:A3,with($,Z,J){return X$(gj(this,RZ(Z),J))},add:($,Z)=>X$(cJ(0,$,$0(Z))),subtract:($,Z)=>X$(cJ(1,$,$0(Z))),until:($,Z,J)=>u(Q2(0,$,j$(Z),J)),since:($,Z,J)=>u(Q2(1,$,j$(Z),J)),round:($,Z)=>X$(NY($,Z)),equals:($,Z)=>Vj($,j$(Z)),toZonedDateTime:($,Z)=>Q0(Xz(i,b0,d,$,Z)),toPlainDateTime:($,Z)=>P0(Gz($,b0(Z))),toLocaleString($,Z,J){let[W,Y]=gV(Z,J,$);return W.format(Y)},toString:bJ,toJSON:($)=>bJ($),valueOf:Q$},{from:($,Z)=>X$(j$($,Z)),compare:($,Z)=>r6(j$($),j$(Z))}),[tV,G$,eV]=B1(xZ,R(lj,T0),{...S3,...cV},{getISOFields:A3,getCalendar:x3,with($,Z,J){return G$(yj(XO,$,this,RZ(Z),J))},add:($,Z,J)=>G$(pJ(zX,0,$,$0(Z),J)),subtract:($,Z,J)=>G$(pJ(zX,1,$,$0(Z),J)),until:($,Z,J)=>u(G2(XX,0,$,EZ(Z),J)),since:($,Z,J)=>u(G2(XX,1,$,EZ(Z),J)),equals:($,Z)=>Fj($,EZ(Z)),toPlainDate($,Z){return Z0(jz(E3,$,this,Z))},toLocaleString($,Z,J){let[W,Y]=mV(Z,J,$);return W.format(Y)},toString:EJ,toJSON:($)=>EJ($),valueOf:Q$},{from:($,Z)=>G$(EZ($,Z)),compare:($,Z)=>E$(EZ($),EZ(Z))}),[$O,P0]=B1(k$,R(dj,T0),{...S3,...z7,...X7},{getISOFields:A3,getCalendar:x3,with($,Z,J){return P0(kj(E3,$,this,RZ(Z),J))},withCalendar:($,Z)=>P0(J4($,T0(Z))),withPlainDate:($,Z)=>P0(Uz($,b0(Z))),withPlainTime:($,Z)=>P0(Dz($,W7(Z))),add:($,Z,J)=>P0(mJ(y$,0,$,$0(Z),J)),subtract:($,Z,J)=>P0(mJ(y$,1,$,$0(Z),J)),until:($,Z,J)=>u(z2(F1,0,$,z$(Z),J)),since:($,Z,J)=>u(z2(F1,1,$,z$(Z),J)),round:($,Z)=>P0(MY($,Z)),equals:($,Z)=>Qj($,z$(Z)),toZonedDateTime:($,Z,J)=>Q0(tj(d,$,i(Z),J)),toPlainDate:($)=>Z0(G0($)),toPlainTime:($)=>X$($1($)),toPlainYearMonth($){return G$(ej(P4,$,this))},toPlainMonthDay($){return bZ($z(M4,$,this))},toLocaleString($,Z,J){let[W,Y]=yV(Z,J,$);return W.format(Y)},toString:SJ,toJSON:($)=>SJ($),valueOf:Q$},{from:($,Z)=>P0(z$($,Z)),compare:($,Z)=>W2(z$($),z$(Z))}),[ZO,Z0,UX]=B1(w$,R(uj,T0),{...S3,...z7},{getISOFields:A3,getCalendar:x3,with($,Z,J){return Z0(qj(E3,$,this,RZ(Z),J))},withCalendar:($,Z)=>Z0(J4($,T0(Z))),add:($,Z,J)=>Z0(hJ(y$,0,$,$0(Z),J)),subtract:($,Z,J)=>Z0(hJ(y$,1,$,$0(Z),J)),until:($,Z,J)=>u(X2(F1,0,$,b0(Z),J)),since:($,Z,J)=>u(X2(F1,1,$,b0(Z),J)),equals:($,Z)=>Kj($,b0(Z)),toZonedDateTime($,Z){let J=!O0(Z)||Z instanceof I4?{timeZone:Z}:Z;return Q0(Zz(i,j$,d,$,J))},toPlainDateTime:($,Z)=>P0(Jz($,W7(Z))),toPlainYearMonth($){return G$(Wz(P4,$,this))},toPlainMonthDay($){return bZ(Yz(M4,$,this))},toLocaleString($,Z,J){let[W,Y]=vV(Z,J,$);return W.format(Y)},toString:AJ,toJSON:($)=>AJ($),valueOf:Q$},{from:($,Z)=>Z0(b0($,Z)),compare:($,Z)=>E$(b0($),b0(Z))}),G7={fields($,Z,J){return[...Z.call($,J)]}},LX=Object.assign({dateFromFields($,Z,J,W){return UX(Z.call($,Object.assign(Object.create(null),J),W))}},G7),HX=Object.assign({yearMonthFromFields($,Z,J,W){return eV(Z.call($,Object.assign(Object.create(null),J),W))}},G7),IX=Object.assign({monthDayFromFields($,Z,J,W){return sV(Z.call($,Object.assign(Object.create(null),J),W))}},G7),Q7={mergeFields($,Z,J,W){return f1(Z.call($,Object.assign(Object.create(null),J),Object.assign(Object.create(null),W)))}},JO=Object.assign({},LX,Q7),WO=Object.assign({},HX,Q7),YO=Object.assign({},IX,Q7),K7={dateAdd($,Z,J,W,Y){return UX(Z.call($,Z0(G0(J,$)),u(n(W)),Y))}},PX=Object.assign({},K7,{dateUntil($,Z,J,W,Y,j){return KO(Z.call($,Z0(G0(J,$)),Z0(G0(W,$)),Object.assign(Object.create(null),j,{largestUnit:I3[Y]})))}}),jO=Object.assign({},K7,{day:KX}),zO=Object.assign({},PX,{day:KX}),P4=V1(HX),T4=V1(LX),M4=V1(IX),XO=V1(WO),E3=V1(JO),GO=V1(YO),y$=V1(K7),F1=V1(PX),zX=V1(jO),XX=V1(zO),[QO,u,KO]=B1(B4,nj,{...lV,blank:hY},{with:($,Z)=>u(mj($,Z)),negated:($)=>u(i6($)),abs:($)=>u(mY($)),add:($,Z,J)=>u(sJ(_3,F1,d,0,$,$0(Z),J)),subtract:($,Z,J)=>u(sJ(_3,F1,d,1,$,$0(Z),J)),round:($,Z)=>u(gY(_3,F1,d,$,Z)),total:($,Z)=>IY(_3,F1,d,$,Z),toLocaleString($,Z,J){return Intl.DurationFormat?new Intl.DurationFormat(Z,J).format(this):p6($)},toString:p6,toJSON:($)=>p6($),valueOf:Q$},{from:($)=>u($0($)),compare:($,Z,J)=>zj(_3,y$,d,$0($),$0(Z),J)}),TX={toString:($)=>$.id,toJSON:($)=>$.id,...pV,dateAdd:({id:$,o:Z},J,W,Y)=>Z0(G0(Z.dateAdd(b0(J),$0(W),Y),$)),dateUntil:({o:$},Z,J,W)=>u(n($.dateUntil(b0(Z),b0(J),KY(W)))),dateFromFields:({id:$,o:Z},J,W)=>Z0(B2(Z,J,W,l5($))),yearMonthFromFields:({id:$,o:Z},J,W)=>G$(V2(Z,J,W,d5($))),monthDayFromFields:({id:$,o:Z},J,W)=>bZ(O2(Z,0,J,W,u5($))),fields({o:$},Z){let J=new Set(Z1),W=[];for(let Y of Z){if(e(Y),!J.has(Y))throw RangeError(N2(Y));J.delete(Y),W.push(Y)}return $.fields(W)},mergeFields:({o:$},Z,J)=>$.mergeFields(WJ(zJ(Z)),WJ(zJ(J)))},[F7]=B1("Calendar",($)=>{let Z=Tj($);return{branding:"Calendar",id:Z,o:SZ(Z)}},{id:($)=>$.id},TX,{from($){let Z=T0($);return typeof Z=="string"?new F7(Z):Z}}),FO=GX(Object.keys(TX).slice(4)),[BO,Q0]=B1(q1,R(cj,T0,i),{...OX,...S3,...YX(z7),...YX(X7),offset:($)=>C$($7($).offsetNanoseconds),offsetNanoseconds:($)=>$7($).offsetNanoseconds,timeZoneId:($)=>L0($.timeZone),hoursInDay:($)=>_Y(d,$)},{getISOFields:($)=>yY(K0,$),getCalendar:x3,getTimeZone:({timeZone:$})=>typeof $=="string"?new I4($):$,with($,Z,J){return Q0(wj(E3,d,$,this,RZ(Z),J))},withCalendar:($,Z)=>Q0(J4($,T0(Z))),withTimeZone:($,Z)=>Q0(Lz($,i(Z))),withPlainDate:($,Z)=>Q0(Oz(d,$,b0(Z))),withPlainTime:($,Z)=>Q0(Vz(d,$,W7(Z))),add:($,Z,J)=>Q0(gJ(y$,d,0,$,$0(Z),J)),subtract:($,Z,J)=>Q0(gJ(y$,d,1,$,$0(Z),J)),until:($,Z,J)=>u(n(j2(F1,d,0,$,fZ(Z),J))),since:($,Z,J)=>u(n(j2(F1,d,1,$,fZ(Z),J))),round:($,Z)=>Q0(TY(d,$,Z)),startOfDay:($)=>Q0(xY(d,$)),equals:($,Z)=>Gj($,fZ(Z)),toInstant:($)=>f0(oj($)),toPlainDateTime:($)=>P0(H2(K0,$)),toPlainDate:($)=>Z0(I2(K0,$)),toPlainTime:($)=>X$(P2(K0,$)),toPlainYearMonth($){return G$(aj(P4,$,this))},toPlainMonthDay($){return bZ(rj(M4,$,this))},toLocaleString($,Z,J={}){let[W,Y]=qV(Z,J,$);return W.format(Y)},toString:($,Z)=>CJ(K0,$,Z),toJSON:($)=>CJ(K0,$),valueOf:Q$},{from:($,Z)=>Q0(fZ($,Z)),compare:($,Z)=>J2(fZ($),fZ(Z))}),VO=Object.defineProperties({},{...x6("Temporal.Now"),...N$({timeZoneId:()=>w1(),instant:()=>f0(D0(U3())),zonedDateTime:($,Z=w1())=>Q0(I0(U3(),i(Z),T0($))),zonedDateTimeISO:($=w1())=>Q0(I0(U3(),i($),w)),plainDateTime:($,Z=w1())=>P0(X0(NZ(K0(i(Z))),T0($))),plainDateTimeISO:($=w1())=>P0(X0(NZ(K0(i($))),w)),plainDate:($,Z=w1())=>Z0(G0(NZ(K0(i(Z))),T0($))),plainDateISO:($=w1())=>Z0(G0(NZ(K0(i($))),w)),plainTimeISO:($=w1())=>X$($1(NZ(K0(i($)))))})}),wZ=Object.defineProperties({},{...x6("Temporal"),...N$({PlainYearMonth:tV,PlainMonthDay:iV,PlainDate:ZO,PlainTime:rV,PlainDateTime:$O,ZonedDateTime:BO,Instant:nV,Calendar:F7,TimeZone:I4,Duration:QO,Now:VO})}),OO=EV(),B7=new WeakMap,DO=Object.defineProperties(Object.create(Intl),N$({DateTimeFormat:OO}));var N4="x-gemi-socket";var QP="gemi.v1",MX="/__gemi/socket",KP=/^[A-Za-z0-9_-]{1,32}$/,FP={Normal:1000,UnsupportedData:1003,PolicyViolation:1008,Restart:1012,TryAgainLater:1013,Revoked:4001};function DP($){return $}function NX(){return{driver:"memory",redis:{},maxEventBytes:16384,warnEventBytes:4096,path:MX,allowedOrigins:[],maxConnectionsPerProcess:1e4,maxConnectionsPerIp:100,maxConnectionsPerUser:50,maxChannelsPerSocket:50,maxInboundMessageBytes:16384,backpressureLimit:1048576,idleTimeout:120,heartbeatMs:25000,subscribeRate:{limit:300,windowMs:60000}}}import{hkdfSync as UO,randomBytes as LO}from"crypto";function HO($=process.env.SECRET){if(!$)return"gemi:bc:";return`gemi:bc:${Buffer.from(UO("sha256",$,"gemi","gemi.broadcast.prefix",4)).toString("hex")}:`}var IO="__control",V7=250,PO=1e4,TO=15000;class O7{config;prefix;controlChannel;instanceId=LO(9).toString("base64url");subscribeTimeoutMs;healthCheckMs;publisher=null;subscriber=null;ready=null;deliver=null;hooks;wanted=new Set;active=new Set;chains=new Map;connectedOnce=!1;reconnectAttempt=0;reconnectTimer=null;healthTimer=null;closed=!1;constructor($={}){this.config=$;this.prefix=$.prefix??HO(),this.controlChannel=this.prefix+IO,this.subscribeTimeoutMs=$.subscribeTimeoutMs??5000,this.healthCheckMs=$.healthCheckMs??30000}get connected(){return this.subscriber!==null&&this.ready===null}publish($,Z){return this.send(this.prefix+$,Z)}async revoke($){this.hooks?.onRevoke?.($);let Z={op:"revoke",from:this.instanceId,r:$};try{await this.send(this.controlChannel,JSON.stringify(Z))}catch(J){throw Error(`The broadcast revocation ${JSON.stringify($)} could not reach the other instances.`,{cause:J})}}async start($,Z){this.closed=!1,this.deliver=$,this.hooks=Z,this.connectSubscriber(),this.startHealthCheck();try{await this.whenReady()}catch{console.warn("[gemi] Broadcast: Redis is not reachable yet; sockets get events once it is.")}}topicAdded($){return this.wanted.add($),this.sync($,!0)}topicRemoved($){return this.wanted.delete($),this.sync($,!1)}async close(){if(this.closed=!0,this.deliver=null,this.hooks=void 0,this.reconnectTimer)clearTimeout(this.reconnectTimer);if(this.reconnectTimer=null,this.healthTimer)clearInterval(this.healthTimer);this.healthTimer=null;let $=[this.subscriber,this.publisher];this.subscriber=null,this.publisher=null,this.ready=null,this.wanted.clear(),this.active.clear(),this.chains.clear();for(let Z of $){if(!Z)continue;Z.onclose=null;try{Z.close()}catch{}}}async send($,Z){let J=this.publisherClient();try{await J.publish($,Z)}catch{if(this.closed)throw Error("The broadcast driver is closed.");this.dropPublisher(J),await this.publisherClient().publish($,Z)}}dropPublisher($){if(this.publisher!==$)return;this.publisher=null,$.onclose=null;try{$.close()}catch{}}publisherClient(){if(this.publisher)return this.publisher;let $=this.createClient("publisher");return $.onclose=()=>{if(this.publisher===$)this.publisher=null},this.publisher=$,$}createClient($){if(this.config.createClient)return this.config.createClient($);let Z=globalThis.Bun?.RedisClient;if(typeof Z!=="function")throw Error("The redis broadcast driver needs Bun's built-in Redis client. Run the app under Bun.");let J=$==="subscriber"?{...this.config.options,autoReconnect:!1}:{...this.config.options};return new Z(this.config.url,J)}connectSubscriber(){if(this.closed||this.ready)return;let $;try{$=this.createClient("subscriber")}catch(J){console.error("[gemi] Broadcast: the Redis subscriber could not be created.",J),this.scheduleReconnect();return}this.subscriber=$,this.active.clear(),$.onclose=()=>this.lost($);let Z=f3((async()=>{await $.connect(),await $.subscribe(this.controlChannel,this.onMessage);let J=[...this.wanted];if(await Promise.all(J.map((W)=>$.subscribe(this.prefix+W,this.onMessage))),this.subscriber!==$)throw Error("Replaced.");for(let W of J)this.active.add(W);return $})(),TO,"connect");this.ready=Z,Z.then(()=>{if(this.subscriber!==$)return;this.ready=null,this.reconnectAttempt=0;for(let J of this.active)if(!this.wanted.has(J))this.sync(J,!1).catch(()=>{});if(this.connectedOnce)this.hooks?.onGap?.();this.connectedOnce=!0},(J)=>{if(this.subscriber!==$||this.closed)return;console.warn(`[gemi] Broadcast: the Redis subscriber could not connect (${_X(J)}); retrying.`),this.drop($)})}lost($){if(this.subscriber!==$||this.closed)return;if(this.ready===null)console.warn("[gemi] Broadcast: the Redis subscriber connection dropped; reconnecting.");this.drop($)}drop($){if(this.subscriber!==$)return;this.subscriber=null,this.ready=null,this.active.clear(),$.onclose=null;try{$.close()}catch{}this.scheduleReconnect()}scheduleReconnect(){if(this.closed||this.reconnectTimer)return;let $=Math.min(PO,V7*2**this.reconnectAttempt);this.reconnectAttempt=Math.min(this.reconnectAttempt+1,16);let Z=Math.max(V7,Math.floor(Math.random()*$));this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connectSubscriber()},Z),this.reconnectTimer.unref?.()}startHealthCheck(){if(this.healthCheckMs<=0||this.healthTimer)return;this.healthTimer=setInterval(()=>{let $=this.subscriber;if(!$||this.ready)return;f3($.ping(),this.subscribeTimeoutMs,"ping").catch((Z)=>{if(this.subscriber!==$)return;console.warn(`[gemi] Broadcast: the Redis subscriber did not answer a ping (${_X(Z)}); reconnecting.`),this.drop($)})},this.healthCheckMs),this.healthTimer.unref?.()}async whenReady(){if(this.closed)throw Error("The broadcast driver is closed.");let $=Date.now()+this.subscribeTimeoutMs;for(;;){if(this.subscriber&&!this.ready)return this.subscriber;let Z=$-Date.now();if(Z<=0)throw Error("Redis did not answer in time.");let J=this.ready??MO(Math.min(Z,V7));await f3(J,Z,"subscribe").catch((W)=>{if(Date.now()>=$)throw W})}}sync($,Z){let W=(this.chains.get($)??Promise.resolve()).catch(()=>{}).then(()=>this.reconcile($,Z));this.chains.set($,W);let Y=()=>{if(this.chains.get($)===W)this.chains.delete($)};return W.then(Y,Y),W}async reconcile($,Z){if(!this.wanted.has($)){if(!this.active.has($)||!this.connected)return;let Y=this.subscriber;this.active.delete($);try{await f3(Y.unsubscribe(this.prefix+$),this.subscribeTimeoutMs,"unsubscribe")}catch(j){if(this.subscriber===Y)this.drop(Y);throw j}return}if(!Z)return;let W=await this.whenReady();if(!this.wanted.has($)||this.active.has($))return;try{await f3(W.subscribe(this.prefix+$,this.onMessage),this.subscribeTimeoutMs,"subscribe")}catch(Y){if(this.subscriber===W)this.drop(W);throw Y}if(this.subscriber===W)this.active.add($)}onMessage=($,Z)=>{if(Z===this.controlChannel){this.onControl($);return}if(!Z.startsWith(this.prefix))return;this.deliver?.(Z.slice(this.prefix.length),$)};onControl($){let Z;try{Z=JSON.parse($)}catch{return}if(Z?.op!=="revoke"||Z.from===this.instanceId)return;let J=Z.r;if(J&&typeof J.user==="string")this.hooks?.onRevoke?.({user:J.user});else if(J&&typeof J.topic==="string")this.hooks?.onRevoke?.({topic:J.topic})}}function f3($,Z,J){let W;return Promise.race([$,new Promise((Y,j)=>{W=setTimeout(()=>j(Error(`Redis ${J} timed out after ${Z} ms.`)),Z)})]).finally(()=>clearTimeout(W))}function MO($){return new Promise((Z)=>setTimeout(Z,$))}function _X($){return $ instanceof Error?$.message:String($)}import{createHmac as NO,hkdfSync as _O,randomBytes as xX}from"crypto";function CX($){return NO("sha256",xO()).update($).digest("base64url").slice(0,22)}var _4=null;function xO(){let $=process.env.SECRET||void 0;if(_4&&_4.secret===$)return _4.key;let Z=$?Buffer.from(_O("sha256",$,"gemi","gemi.broadcast.socket-tag",32)):xX(32);return _4={secret:$,key:Z},Z}function PP(){return xX(16).toString("base64url")}var CO=/^[A-Za-z0-9_-]{8,64}$/;function D7($){return typeof $==="string"&&CO.test($)}function SX($,Z,J,W){let Y={op:"ev",t:$,ev:Z};if(J!==void 0)Y.d=J;if(W)Y.x=W;return JSON.stringify(Y)}class EX extends Error{bytes;limit;constructor($,Z,J){super(`The broadcast "${J}" is ${$} bytes, over the limit of ${Z}. Send ids and a change hint, and let the client fetch the data over HTTP; or raise maxEventBytes in app/config/broadcast.ts.`);this.bytes=$;this.limit=Z;this.name="BroadcastPayloadTooLargeError"}}class m0{options;static token="broadcast";config;driver;warnedAboutSize=new Set;started=!1;hooks;channelRouter;constructor($={},Z={}){this.options=Z;this.config=O1(NX(),$),this.driver=EO(this.config,Z.application)}get channels(){if(this.channelRouter===void 0)this.channelRouter=this.options.channels?new this.options.channels:null;return this.channelRouter}to($,...Z){return new b3(this,x4($,Z[0]),null)}toUser($){return new b3(this,{topic:e$($),pattern:F0},null)}toOthers($){return new fX(this,AO($))}broadcastEvent($){let Z=$.broadcastOn(),J=Array.isArray(Z)?Z:[Z],W=$.broadcastAs(),Y=$.broadcastWith(),j=J.map((z)=>this.prepare(x4(z,void 0),W,Y,null));for(let{sent:z,frame:X}of j)this.hand(z,X)}send($,Z,J,W){let{sent:Y,frame:j}=this.prepare($,Z,J,W);this.hand(Y,j)}prepare($,Z,J,W){t9(Z);let Y;try{Y=SX($.topic,Z,J,W?CX(W):null)}catch(z){throw TypeError(`The broadcast "${Z}" could not be encoded. Payloads must be JSON.`,{cause:z})}return this.checkSize(Z,Y),{sent:{topic:$.topic,...$.pattern?{pattern:$.pattern}:{},event:Z,data:JSON.parse(Y).d,...W?{except:W}:{}},frame:Y}}hand($,Z){kZ(()=>this.publish($,Z))}publish($,Z){let J=(W)=>console.error(`[gemi] The broadcast "${$.event}" on "${$.topic}" could not be published.`,W);try{let W=this.driver.publish($.topic,Z);if(W&&typeof W.catch==="function")W.catch(J)}catch(W){J(W)}}get isStarted(){return this.started}async start($,Z){if(this.started)throw Error("The broadcast driver was already started in this process.");this.started=!0,this.hooks=Z;try{await this.driver.start($,Z)}catch(J){throw this.started=!1,this.hooks=void 0,J}}topicAdded($){return this.driver.topicAdded?.($)}topicRemoved($){return this.driver.topicRemoved?.($)}async close(){this.started=!1,this.hooks=void 0,await this.driver.close()}revoke($){let Z=SO($);kZ(()=>this.sendRevocation(Z))}sendRevocation($){let Z=(J)=>console.error("[gemi] A broadcast revocation could not be sent.",J);try{if(typeof this.driver.revoke==="function"){let J=this.driver.revoke($);if(J&&typeof J.catch==="function")J.catch(Z);return}this.hooks?.onRevoke?.($)}catch(J){Z(J)}}checkSize($,Z){let J=Buffer.byteLength(Z,"utf8");if(J>this.config.maxEventBytes)throw new EX(J,this.config.maxEventBytes,$);let W=this.config.warnEventBytes;if(W!==!1&&J>W&&!this.warnedAboutSize.has($))this.warnedAboutSize.add($),console.warn(`[gemi] The broadcast "${$}" is ${J} bytes, over ${W}. Broadcasts are change hints: send ids and let the client fetch the data over HTTP. Warned once per event name.`)}}class b3{manager;target;except;constructor($,Z,J){this.manager=$;this.target=Z;this.except=J}emit($,...Z){this.manager.send(this.target,$,Z[0],this.except)}}class fX{manager;except;constructor($,Z){this.manager=$;this.except=Z}to($,...Z){return new b3(this.manager,x4($,Z[0]),this.except)}toUser($){return new b3(this.manager,{topic:e$($),pattern:F0},this.except)}}function x4($,Z){if(r9($))return{topic:K8($.topic),...$.pattern?{pattern:$.pattern}:{}};if(Z!==void 0||$.includes(":"))return{topic:aZ($,Z??{}),pattern:$};if($===F0)throw new p('"user" is not a topic: the "user" channel resolves to user.<id> per subscriber. Emit with Broadcast.toUser(user).');return{topic:K8($)}}function SO($){if($&&typeof $==="object"&&"user"in $)return{user:e$($.user).slice(F0.length+1)};if($&&typeof $==="object"&&"channel"in $)return{topic:x4($.channel,$.params).topic};throw new p("Broadcast.revoke takes { user } or { channel }.")}function AO($){if($===null||$===void 0)return null;if(typeof $==="string")return D7($)?$:null;let J=($ instanceof Request?$.headers:("rawRequest"in $)?$.rawRequest.headers:$.headers)?.get(N4);return D7(J)?J:null}function EO($,Z){let J=$.driver;if(J===void 0||J==="memory")return new AX;if(J==="redis"){let W=Z?.config.get("redis",{})??{},Y=$.redis??{};return new O7({url:Y.url??W.url??process.env.REDIS_URL,options:Y.options??W.options,prefix:Y.prefix,subscribeTimeoutMs:Y.subscribeTimeoutMs,healthCheckMs:Y.healthCheckMs})}if(typeof J==="function"){if(!Z)throw Error("A broadcast driver factory needs the application to be called with.");return J(Z)}if(typeof J==="object"&&J!==null&&typeof J.publish==="function")return J;throw Error(`Unknown broadcast driver "${String(J)}" in app/config/broadcast.ts. Use "memory" or "redis", or pass a BroadcastDriver.`)}class U7 extends Error{code;constructor($,Z=`OAuth callback failed: ${$}`){super(Z);this.name="OAuthCallbackError",this.code=$}}class fO{linkByEmail=!0;createUsers=!0;createUsersWithoutEmail=!1}import{createHash as L7,createHmac as bO,randomBytes as bX,timingSafeEqual as kX}from"crypto";var w3=600,C4="gemi_oauth",RO=`__Host-${C4}`;function qZ($,Z=C4){if(Z===C4)return $?RO:C4;return $?`__Host-${Z}`:Z}function R3($){return $.toString("base64url")}function qX($){return bO("sha256",zZ()).update(`gemi-oauth-state:${$}`).digest()}function RX($,Z){let J=L7("sha256").update($).digest(),W=L7("sha256").update(Z).digest();return kX(J,W)&&$.length===Z.length}function S4($,Z=Date.now(),J={}){let W=R3(bX(32)),Y=R3(bX(32)),j=wO(Y),z={provider:$,state:W,codeVerifier:Y,expiresAt:Z+w3*1000,...J.subject!==void 0?{subject:J.subject}:{},...J.returnTo!==void 0?{returnTo:J.returnTo}:{}};return{state:W,codeVerifier:Y,codeChallenge:j,cookieValue:kO(z)}}function wO($){return R3(L7("sha256").update($).digest())}function kO($){let Z=R3(Buffer.from(JSON.stringify($)));return`${Z}.${R3(qX(Z))}`}function qO($){if(typeof $!=="string"||$==="")return null;let Z=$.indexOf(".");if(Z<=0||Z!==$.lastIndexOf("."))return null;let J=$.slice(0,Z),W=Buffer.from($.slice(Z+1),"base64url"),Y=qX(J);if(W.length!==Y.length||!kX(W,Y))return null;try{let j=JSON.parse(Buffer.from(J,"base64url").toString("utf8"));if(typeof j?.provider!=="string"||typeof j?.state!=="string"||typeof j?.codeVerifier!=="string"||typeof j?.expiresAt!=="number"||j.subject!==void 0&&typeof j.subject!=="string"||j.returnTo!==void 0&&typeof j.returnTo!=="string")return null;return j}catch{return null}}var K$=new Map,wX=1e4;function yO($,Z,J){if(K$.size>=wX){for(let[W,Y]of K$)if(Y<=J)K$.delete(W);while(K$.size>=wX){let W=K$.keys().next().value;if(W===void 0)break;K$.delete(W)}}K$.set($,Z)}function A4($){let Z=$.now??Date.now();if(!$.cookieValue||!$.returnedState)return{ok:!1,reason:"missing_state"};let J=qO($.cookieValue);if(!J)return{ok:!1,reason:"invalid_state"};let W=RX(J.state,$.returnedState),Y=RX(J.provider,$.provider);if(!W||!Y)return{ok:!1,reason:"invalid_state"};if(J.expiresAt<=Z)return{ok:!1,reason:"expired_state"};if(K$.has(J.state))return{ok:!1,reason:"invalid_state"};return yO(J.state,J.expiresAt,Z),{ok:!0,payload:J}}var H7=new WeakMap;function gO($){let Z=H7.get($);if(!Z)Z=$(vO(32).toString("hex")),H7.set($,Z),Z.catch(()=>H7.delete($));return Z}async function I7($,Z,J){if(typeof J==="string"&&J!=="")return await $.verifyPassword(Z,J);try{await $.verifyPassword(Z,await gO($.hashPassword))}catch{}return!1}async function v$($,Z){let J=Z.user??Z.session?.user;if(!J||!$.onAuthenticated)return;let{password:W,...Y}=J;await $.onAuthenticated({...Z,user:Y})}class T7 extends Error{}function P7($){return typeof $==="string"&&$!==""?$:null}function yX($){return $3($)}var mO=256;function vX($){return typeof $==="string"&&$!==""&&$.length<=mO?$:null}var E4="intended_url";function mX($){if($.cookies.get(E4))$.ctx().setCookie(E4,"",{maxAge:-1})}function gX($){let Z=$.cookies.get(E4);if(!Z)return null;mX($);try{return j1(decodeURIComponent(Z),"")||null}catch{return null}}class M7 extends C{schema={email:{required:"Email is required",string:"Invalid email",email:"Invalid email"},password:{required:"Password is required"}}}class hX extends C{schema={email:{required:"Email is required",email:"Invalid email"}}}class pX extends C{schema={password:{required:"Password is required",password:"Invalid password"}}}function y1($){if(L(E).config[$]===!1)throw new Y0("Not found",{status:404})}class o extends tZ{async me(){let $=await R0.user();if(!$)throw new A8;return $}async verifyEmail($=new C){y1("password");let Z=await $.input(),{userProvider:J}=L(E),W=P7(Z.get("token"));if(!W)return{email:null};let Y=await J.findUserByVerificationToken(W);if(!Y)return{email:null};return await J.verifyUser(Y.email),{email:Y.email}}async signInWithMagicLink($=new C){let Z=L(E),{userProvider:J}=Z,W=P7($.search.get("token")),Y=null;try{Y=$3(decodeURIComponent($.search.get("email")??""))}catch{}if(await XZ("link",null,$,{perIp:Z.config.emailCode.verifyLimit.perIp}),!Y||!W||!await Z.verifyMagicLinkToken(Y,W))return{error:"Invalid token"};await J.verifyUser(Y);let j=await Z.createOrUpdateSession({email:Y});return $.ctx().setCookie("access_token",j.token,L(E).accessTokenCookieOptions($,j.expiresAt)),await Z.config.onSignIn(j,$.search.toJSON()),await v$(Z.config,{session:j,isNewUser:!1,method:"magic-link",req:$}),{session:j}}async verifyPinRequest($){y1("magicLink");let Z=L(E),J=await $.input(),{email:W,pin:Y}=J.toJSON(),j=$3(W),z=vX(Y);if(await XZ("verify",j,$,Z.config.emailCode.verifyLimit),!j||!z)throw new h({pin:["Invalid pin"]});let X=await Z.verifyOneTimeCode(j,z);if(X.status==="too_many_attempts")throw new h({pin:["Too many attempts"]});if(X.status!=="ok")throw new h({pin:["Invalid pin"]});return await Z.userProvider.verifyUser(j),j}async signInWithPinV2($=new C){let Z=L(E),J=await this.verifyPinRequest($),W=await Z.createOrUpdateSessionV2({email:J});return $.ctx().setCookie("access_token",W.token,L(E).accessTokenCookieOptions($,W.expiresAt)),await Z.config.onSignIn(W,$.search.toJSON()),await v$(Z.config,{session:W,isNewUser:!1,method:"magic-link",req:$}),W}async signInWithPin($=new C){let Z=L(E),J=await this.verifyPinRequest($),W=await Z.createOrUpdateSession({email:J});return $.ctx().setCookie("access_token",W.token,L(E).accessTokenCookieOptions($,W.expiresAt)),await Z.config.onSignIn(W,$.search.toJSON()),await v$(Z.config,{session:W,isNewUser:!1,method:"magic-link",req:$}),{session:W}}async signInV2($=new M7){y1("password");let Z=await $.input(),{email:J,password:W}=Z.toJSON(),Y=J.toLowerCase().trim(),j=L(E),z=await j.userProvider.findUserByEmailAddress(Y,j.config.verifyEmail),X=typeof W==="string"&&await I7(j.config,W,z?.password);if(!z||!X)throw new h({invalid_credentials:["Invalid credentials"]});let G=await j.createOrUpdateSessionV2({email:z.email,id:z.id});$.ctx().setCookie("access_token",G.token,L(E).accessTokenCookieOptions($,G.expiresAt)),await j.config.onSignIn(z,$.search.toJSON()),await v$(j.config,{session:G,user:z,isNewUser:!1,method:"password",req:$});let{password:Q,...K}=z;return K}async signIn($=new M7){y1("password");let Z=await $.input(),{email:J,password:W}=Z.toJSON(),Y=J.toLowerCase().trim(),j=L(E),z=await j.userProvider.findUserByEmailAddress(Y,j.config.verifyEmail),X=typeof W==="string"&&await I7(j.config,W,z?.password);if(!z||!X)throw new h({invalid_credentials:["Invalid credentials"]});let G=await j.createOrUpdateSession({email:z.email,id:z.id});$.ctx().setCookie("access_token",G.token,L(E).accessTokenCookieOptions($,G.expiresAt)),await j.config.onSignIn(z,$.search.toJSON()),await v$(j.config,{session:G,user:z,isNewUser:!1,method:"password",req:$});let{password:Q,...K}=z;return K}async signUp(){y1("password");let $=L(E),{userProvider:Z,config:J}=$,W=new J.signUpRequest,Y=await W.input(),{email:j,password:z,name:X,invitationId:G}=Y.toJSON(),Q=yX(j);if(!Q)throw new h({email:["Invalid email"]});if(z!=null&&typeof z!=="string")throw new h({password:["Invalid password"]});if(G!=null&&typeof G!=="string")throw new h({invitationId:["Invalid invitation"]});if(await Z.findUserByEmailAddress(Q,!1))throw new h({email:["Email address already exists"]});let B=await J.hashPassword(z),F=L(s).detectLocale(W),D;if(G)D=await Z.findInvitation(G,Q);let V,O="";if(D)V=await Z.transaction(async()=>{await Z.deleteInvitationById(G);let U=await Z.createUser({email:Q,name:X,password:B,emailVerifiedAt:new Date,locale:F});return await Z.createAccount({organizationId:D.organizationId,userId:U.id,organizationRole:D.role}),await J.onUserCreated(U),U});else O=await J.generateEmailVerificationToken(Q),V=await Z.transaction(async()=>{let U=await Z.createUser({email:Q,name:X,password:B,verificationToken:O,locale:F});return await J.onUserCreated(U),U});return await J.onSignUp(V,O,W.search.toJSON()),V}async signOut($=new C){let Z=O$($),J=L(E),{config:W}=J,Y=await J.revokeSession(Z,$.headers.get("User-Agent"));if($.ctx().setCookie("access_token","",L(E).accessTokenCookieOptions($,new Date(0))),L(E).cookieDomain($))$.ctx().setCookie("access_token","",{...L(E).accessTokenCookieOptions($,new Date(0)),domain:void 0});if(Y?.user)hO(Y.user),Y.user.extension=await W.extendSession(Y.user),await W.onSignOut(Y.user);return{}}async forgotPassword($=new hX){y1("password");let Z=await $.input(),J=yX(Z.get("email"));if(!J)return{};let{userProvider:W,config:Y}=L(E),j=await W.findUserByEmailAddress(J,Y.verifyEmail);if(!j)return{};let z=await Y.generateForgotPasswordToken(j);return await W.createPasswordResetToken({user:j,token:z}),await Y.onForgotPassword(j,z),{}}async resetPassword($=new pX){y1("password");let{userProvider:Z,config:J}=L(E),W=await $.input(),{password:Y,token:j}=W.toJSON(),z=P7(j),X=z?await Z.findPasswordResetToken({token:z}):null;if(!X)throw new h({token:["Invalid token"]});if(wZ.Instant.from(X.createdAt.toISOString()).add({hours:24}).until(wZ.Now.instant()).sign>=0)throw new h({token:["Token expired"]});await Z.deletePasswordResetToken({token:z});let Q=await Z.findUserByEmailAddress(X.user.email,J.verifyEmail);if(!Q)throw new h({email:["User not found"]});let K=await J.hashPassword(Y);return await Z.updateUserPassword({id:Q.id,password:K}),await Z.deleteAllUserSessions(Q.id),await J.onResetPassword(Q),{}}async changePassword($=new C){y1("password");let{userProvider:Z,config:J}=L(E),W=await R0.user(),Y=await $.input(),{oldPassword:j,newPassword:z}=Y.toJSON();if(typeof z!=="string")throw new h({newPassword:["Invalid password"]});let X=await Z.findUserByEmailAddress(W.email,J.verifyEmail);if(!(typeof j==="string"&&await I7(J,j,X?.password)))throw new h({oldPassword:["Incorrect password"]});let Q=await J.hashPassword(z);return await Z.updateUserPassword({id:W.id,password:Q}),await Z.deleteAllUserSessions(W.id),{}}async oauthRedirect($=new C){let{provider:Z}=$.params,J=L(E).config.oauthProviders,W=Object.hasOwn(J,Z),Y=await GZ(J,Z);if(!Y){if(W)throw new Y0("Not found",{status:404});throw Error(`Invalid provider: ${Z}`)}let j=ZZ($.rawRequest),z=j1($.search.get(Y1),"");if(z)$.ctx().setCookie(E4,encodeURIComponent(z),{httpOnly:!0,sameSite:"Lax",secure:j,maxAge:600});else mX($);let{state:X,codeChallenge:G,cookieValue:Q}=S4(Z);return $.ctx().setCookie(qZ(j),Q,{httpOnly:!0,sameSite:"Lax",secure:j,maxAge:w3}),{destination:await Y.getRedirectUrl($,{state:X,codeChallenge:G,codeChallengeMethod:"S256"})}}async oauthCallback($=new C){let{provider:Z}=$.params,J=L(E),{userProvider:W,config:Y}=J,j=Object.hasOwn(Y.oauthProviders,Z),z=await GZ(Y.oauthProviders,Z);if(j&&!z)throw new Y0("Not found",{status:404});let X=ZZ($.rawRequest),G=qZ(X),Q=$.cookies.get(G);if(Q!==void 0&&Q!==null)$.ctx().setCookie(G,"",{httpOnly:!0,sameSite:"Lax",secure:X,maxAge:-1});if(!z)return this.oauthFailure($,"unknown_provider");let K=$.search.get("error");if(K)return this.oauthFailure($,/^[a-z0-9_]{1,64}$/.test(K)?K:"provider_error");let B=A4({provider:Z,cookieValue:Q,returnedState:$.search.get("state")});if("reason"in B)return console.error(`Authentication error: OAuth callback refused (${B.reason})`),this.oauthFailure($,B.reason);if(!$.search.get("code"))return this.oauthFailure($,"missing_code");let F;try{F=await z.onCallback($,{state:B.payload.state,codeVerifier:B.payload.codeVerifier})}catch(P){if(P instanceof U7)return this.oauthFailure($,P.code);return console.error("Authentication error: OAuth provider callback failed",P),this.oauthFailure($,"provider_error")}let{name:D,username:V,providerId:O,emailVerified:U}=F??{},H=typeof F?.email==="string"?F.email:void 0,T=H?z6(H):null,I=O?await W.findUserBySocialAccount(Z,O):null,x="signin",A=!I&&!T&&!H&&!!O&&z.createUsersWithoutEmail===!0;if(!I&&A){if(z.createUsers===!1)return console.error(`Authentication error: a ${Z} sign-in is not linked to a user, and ${Z} does not create users`),this.oauthFailure($,"signup_disabled");try{I=await this.createOAuthUserWithoutEmail({provider:Z,providerId:O,name:D,username:V,locale:L(s).detectLocale($)}),x="signup"}catch(P){let k=await W.findUserBySocialAccount(Z,O);if(!k)throw P;I=k}}if(!I){if(!T)return console.error("Authentication error: No usable email returned from OAuth provider callback"),this.oauthFailure($,H?"invalid_email":O?"missing_email":"no_identity");if(U===!1)return console.error("Authentication error: OAuth provider returned an unverified email"),this.oauthFailure($,"email_not_verified");let P=L(s).detectLocale($);try{let k=await this.linkOAuthAccount({provider:Z,providerId:O,email:T,rawEmail:H,name:D,username:V,locale:P,linkExisting:z.linkByEmail!==!1,createUser:z.createUsers!==!1});if(k==="account_exists")return console.error(`Authentication error: a ${Z} sign-in matched an existing user by email, and ${Z} does not link by email`),this.oauthFailure($,"account_exists");if(k==="signup_disabled")return console.error(`Authentication error: a ${Z} sign-in is not linked to a user, and ${Z} does not create users`),this.oauthFailure($,"signup_disabled");if(k)I=k.user,x=k.action}catch(k){let m=O?await W.findUserBySocialAccount(Z,O):null;if(!m)throw k;I=m}if(!I)return this.oauthFailure($,"account_conflict")}let f=await J.createOrUpdateSessionV2({email:I.email,id:I.id});if($.ctx().setCookie("access_token",f.token,L(E).accessTokenCookieOptions($,f.expiresAt)),x==="signup")await Y.onSignUp(I,"",$.search.toJSON());else await Y.onSignIn(I,$.search.toJSON());await v$(J.config,{session:f,user:I,isNewUser:x==="signup",method:"oauth",req:$});let S=gX($)??Y.redirectPath,M=Y.oauthCompleteProfilePath?j1(Y.oauthCompleteProfilePath,""):"";if(M&&!I.email){let P=new URL(M,"http://gemi.invalid");P.searchParams.set(Y1,S),S=`${P.pathname}${P.search}${P.hash}`}return{session:f,redirectTo:S}}async createOAuthUserWithoutEmail($){let{userProvider:Z,config:J}=L(E);return await Z.transaction(async()=>{let W=await Z.createUser({email:null,name:$.name??$.username??"",locale:$.locale});return await Z.createSocialAccount({provider:$.provider,providerId:$.providerId,userId:W.id,username:$.username,expiresAt:new Date,accessToken:"",refreshToken:""}),await J.onUserCreated(W),W})}oauthFailure($,Z){let J=gX($),W=L(E).config.oauthFailurePath;if(W){let Y=j1(W,"");if(Y){let j=new URL(Y,"http://gemi.invalid");if(j.searchParams.set("error",Z),J)j.searchParams.set(Y1,J);M1.external(`${j.pathname}${j.search}${j.hash}`)}else console.error(`auth.oauthFailurePath must be a same-origin path, got ${JSON.stringify(W)}`)}return{session:null,error:Z,redirectTo:J}}async linkOAuthAccount($){let{provider:Z,providerId:J,email:W,rawEmail:Y,name:j,username:z,locale:X}=$,{userProvider:G,config:Q}=L(E),K=(V)=>({provider:Z,userId:V,email:W,username:z,providerId:J,expiresAt:new Date,accessToken:"",refreshToken:""}),B=await G.findUserByEmailAddress(W,!1),F=Y?.trim();if(!B&&F&&F!==W)B=await G.findUserByEmailAddress(F,!1);if(B){if($.linkExisting===!1)return"account_exists";if(!J)return{user:B,action:"signin"};let V=await G.findSocialAccounts(B.id,Z);if(V.some((U)=>U.providerId===J))return{user:B,action:"signin"};if(V.some((U)=>U.providerId))return console.error(`Authentication error: user ${B.id} is already linked to a different ${Z} account`),null;let O=V[0];if(O){if(!await G.claimSocialAccount(O,J))throw Error(`${Z} account link changed concurrently`)}else await G.createSocialAccount(K(B.id));return{user:B,action:"signin"}}if($.createUser===!1)return"signup_disabled";return{user:await G.transaction(async()=>{let V=await G.createUser({email:W,name:j,locale:X,emailVerifiedAt:new Date});if(J)await G.createSocialAccount(K(V.id));return await Q.onUserCreated(V),V}),action:"signup"}}async createMagicLinkToken($=new C){y1("magicLink");let Z=await $.input(),J=$3(Z.get("email")),W=L(E),{uniformMagicLinkResponse:Y,requestLimit:j}=W.config.emailCode;if(await XZ("request",J,$,j),!J)return{email:null};let{user:z,pin:X,token:G}=await W.createMagicLinkToken(J);if(z)return await W.config.onMagicLinkCreated(z,{email:J,pin:X,token:G}),{email:J};return{email:Y?J:null}}async requestEmailCode($=new C){let Z=L(E),J=Z.config.emailCode;if(!J.enabled)throw new Y0("Not found",{status:404});let W=await $.input(),Y=z6(W.get("email"));if(await XZ("request",Y,$,J.requestLimit),!Y)throw new h({email:["Invalid email"]});let j=await Z.userProvider.findUserByEmailAddress(Y,!1);if(j||J.createUser){let{pin:z,token:X}=await Z.issueOneTimeCode(Y,J.length);await J.send({email:Y,code:z,token:X,isNewUser:!j,req:$})}return{ok:!0}}async verifyEmailCode($=new C){let Z=L(E),{userProvider:J,config:W}=Z;if(!W.emailCode.enabled)throw new Y0("Not found",{status:404});let Y=await $.input(),{email:j,code:z,name:X}=Y.toJSON(),G=z6(j),Q=vX(z);if(await XZ("verify",G,$,W.emailCode.verifyLimit),!G||!Q)throw new h({code:["invalid_code"]});let K=await Z.verifyOneTimeCode(G,Q,{claim:!1});if(K.status==="too_many_attempts")throw new h({code:["too_many_attempts"]});if(K.status!=="ok")throw new h({code:["invalid_code"]});let B=K.row,F=await J.findUserByEmailAddress(G,!1),D=!1;if(F){if(!await J.claimMagicLinkToken(B.id))throw new h({code:["invalid_code"]});await J.verifyUser(G)}else if(W.emailCode.createUser){let O=L(s).detectLocale($);try{F=await J.transaction(async()=>{if(!await J.claimMagicLinkToken(B.id))throw new T7;let U=await J.createUser({email:G,name:typeof X==="string"?X.trim():"",emailVerifiedAt:new Date,locale:O});return await W.onUserCreated(U),U}),D=!0}catch(U){if(U instanceof T7)throw new h({code:["invalid_code"]});throw U}}else throw await J.claimMagicLinkToken(B.id),new h({code:["invalid_code"]});let V=await Z.createOrUpdateSessionV2({email:G,id:F.id});return $.ctx().setCookie("access_token",V.token,L(E).accessTokenCookieOptions($,V.expiresAt)),await W.onSignIn(V,$.search.toJSON()),await v$(Z.config,{session:V,isNewUser:D,method:"email-code",req:$}),{session:V,isNewUser:D}}}function hO($){try{let Z=$?.id;if(Z===void 0||Z===null)return;let J=L();if(typeof J?.bound!=="function"||!J.bound(m0))return;J.make(m0).revoke({user:{id:Z}})}catch(Z){console.error("[gemi] Revoking the signed-out user's sockets failed:",Z)}}var cX="gemi_oauth_connection";class f4 extends tZ{async connect($=new C){let Z=String($.params.provider??""),W=L(k3).providers[Z],Y=await R0.user(),j=j1($.search.get(Y1),"");if(!W)return this.finish(j,Z,"unknown_provider");let z=ZZ($.rawRequest),{state:X,codeChallenge:G,cookieValue:Q}=S4(dX(Z),Date.now(),{subject:String(Y.id),...j?{returnTo:j}:{}});return $.ctx().setCookie(qZ(z,cX),Q,{httpOnly:!0,sameSite:"Lax",secure:z,maxAge:w3}),M1.external(W.authorizationUrl({state:X,codeChallenge:G,redirectUri:uX($,Z,W.config.redirectUri)})),{destination:"/"}}async callback($=new C){let Z=String($.params.provider??""),J=L(k3),W=await R0.user(),Y=ZZ($.rawRequest),j=qZ(Y,cX),z=$.cookies.get(j);if(z!==void 0&&z!==null)$.ctx().setCookie(j,"",{httpOnly:!0,sameSite:"Lax",secure:Y,maxAge:-1});let X=A4({provider:dX(Z),cookieValue:z,returnedState:$.search.get("state")}),G="payload"in X?X.payload.returnTo??"":"",Q=J.providers[Z];if(!Q)return this.finish(G,Z,"unknown_provider");let K=$.search.get("error");if(K)return this.finish(G,Z,/^[a-z0-9_]{1,64}$/.test(K)?K:"provider_error");if("reason"in X)return console.error(`OAuth connection refused (${X.reason})`),this.finish(G,Z,X.reason);if(X.payload.subject!==String(W.id))return this.finish(G,Z,"user_mismatch");let B=$.search.get("code");if(!B)return this.finish(G,Z,"missing_code");try{let F=await Q.exchangeCode({code:B,codeVerifier:X.payload.codeVerifier,redirectUri:uX($,Z,Q.config.redirectUri)}),D=await J.save(W,Z,F);await L(E).config.onConnected({user:W,provider:Z,connection:D,profile:F.profile??null,req:$})}catch(F){if(F instanceof lX)return console.error(`OAuth connection to ${Z} failed: ${F.message}`),this.finish(G,Z,F.providerError??F.code);throw F}return this.finish(G,Z)}finish($,Z,J){let W=$||j1(L(E).config.redirectPath,"/"),Y=new URL(W,"http://gemi.invalid");if(Y.searchParams.set("connection",Z),J)Y.searchParams.set("connection_error",J);throw M1.external(`${Y.pathname}${Y.search}${Y.hash}`),Error("unreachable: Redirect.external throws")}}function dX($){return`connection:${$}`}function uX($,Z,J){if(J)return J;return`${q3()??new URL($.rawRequest.url).origin}/auth/connections/${encodeURIComponent(Z)}/callback`}class iX extends N1{middlewares=["cache:private"];routes={"/:provider":this.view("_Redirect",[o,"oauthRedirect"]),"/:provider/callback":this.view("auth/OauthCallback",[o,"oauthCallback"])}}class sX extends N1{middlewares=["cache:private"];routes={"/:provider":this.redirect([f4,"connect"]).middleware(["auth"]),"/:provider/callback":this.redirect([f4,"callback"]).middleware([t3,"auth"])}}class N7 extends N1{middlewares=["cache:private"];routes={"/sign-in/magic-link":this.view("auth/MagicLinkSignIn",[o,"signInWithMagicLink"]),"/oauth":iX,"/connections":sX}}class _7 extends N0{middlewares=["cache:private"];routes={"/sign-in":this.post(o,"signIn"),"/sign-in-v2":this.post(o,"signInV2"),"/sign-up":this.post(o,"signUp"),"/sign-out":this.post(o,"signOut"),"/forgot-password":this.post(o,"forgotPassword"),"/reset-password":this.post(o,"resetPassword"),"/change-password":this.post(o,"changePassword"),"/verify-email":this.post(o,"verifyEmail"),"/me":this.get(o,"me").middleware(["auth"]),"/magic-link":this.post(o,"createMagicLinkToken"),"/sign-in-with-pin":this.post(o,"signInWithPin"),"/sign-in-with-pin-v2":this.post(o,"signInWithPinV2"),"/email-code":this.post(o,"requestEmailCode"),"/email-code/verify":this.post(o,"verifyEmailCode")}}class x7 extends N0{middlewares=["cache:private,0,no-store"];routes={"/set-locale/:locale":this.get(async()=>{let Z=new C().params.locale;return await L(s).onLocaleChange(Z),{locale:Z}}),"/translations/:locale/:scope*":this.get(async()=>{let $=new C,Z=`/${$.params.scope??""}`,J=$.params.locale,W=L(s),Y=J??W.detectLocale($),j=W.getPageTranslations(Y,Z);return $.ctx().setCookie("i18n-locale",Y,{expires:new Date(Date.now()+31536000000)}),{[Y]:j}})}}class C7{}class S7 extends C7{async resize($,Z){let{height:J,width:W,quality:Y,fit:j}=Z;return await(await b4("The Sharp image optimization driver"))($).resize(W>0?W:void 0,J>0?J:void 0,{fit:j}).webp({quality:Y>0?Y:80,force:!0}).toBuffer()}}function fT($){return $}function nX(){return{driver:new S7}}class A7 extends N0{routes={"/resize":this.file(async()=>{let $=new C,Z=new URL($.rawRequest.url),J=Z.searchParams.get("url"),W=Number(Z.searchParams.get("w")),Y=Number(Z.searchParams.get("h")),j=Z.searchParams.get("fit")??"cover",z=Number(Z.searchParams.get("q"));if(!J)return new Response(JSON.stringify({error:"url query parameter is required"}),{headers:{"Content-Type":"application/json"},status:404});let G=`${J.startsWith("http")?"":`http://localhost:${process.env.PORT||5173}`}${J}`,Q=await fetch(G);if(!Q.ok)return new Response(JSON.stringify({error:"Image not found",info:G}),{headers:{"Content-Type":"application/json"},status:404});let K=Buffer.from(await Q.arrayBuffer()),B=await L(oX).resize(K,{height:Y,width:W,fit:j,quality:z});Q.headers.delete("Content-Type"),Q.headers.delete("Content-Length");let F=new Headers(Q.headers);return F.set("Content-Type","image/webp"),F.set("Content-Length",`${B.byteLength}`),new Response(new Uint8Array(B),{headers:F})})}}class oX{static token="image";driver;constructor($={}){this.driver=$.driver??nX().driver}resize($,Z){return this.driver.resize($,Z)}}class E7 extends N0{middlewares=["cache:private,0"];routes={"/live":this.get(async()=>{let $=Bun.file(L(aX).currentLogFilePath);return new Response(await $.text(),{headers:{"Content-Type":"text/plain"}})})}}function hT($){return $}function rX(){return{onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{}}}function tX(){return{partialRendering:!0,localeRouting:"prefix",onRequestStart:()=>{},onRequestEnd:()=>{},onRequestFail:()=>{},onStreamComplete:()=>{}}}function pO($){return"run"in $}function cO($){return Object.hasOwn($,"get")||Object.hasOwn($,"post")||Object.hasOwn($,"put")||Object.hasOwn($,"patch")||Object.hasOwn($,"delete")}function dO($){return Object.hasOwn($,"first")&&Object.hasOwn($,"second")}function uO($){if("__brand"in $)return $.__brand==="ApiRouter";return!1}function lO($){if("__internal_brand"in $)return $.__internal_brand==="ProxyHandler";return!1}function eX($){if("__internal_brand"in $)return $.__internal_brand==="StreamHandler";return!1}function f7($,Z="",J=[]){let W={};function Y(j,z,X,G,Q){let K=j==="/"?"":j,B=Z==="/"?"":Z,F=(`${B}${K}`===""?"/":`${B}${K}`).replaceAll("//","/");if(!W[F])W[F]={};W[F][z.toUpperCase()]={exec:X,middleware:[...J,...G],...Q?{source:Q}:{}},W[F].OPTIONS={exec:()=>{let V=new C().ctx().headers;return new Response(null,{headers:V,status:204})},middleware:[]}}for(let[j,z]of Object.entries($)){if(lO(z)){let X=z;for(let G of["GET","POST","PUT","DELETE"])Y(j,G,X.run.bind(X),X.middlewares);continue}if(pO(z)){let X=z,G=X.method,Q=X.middlewares,K=X.run.bind(X);if(Y(j,G,K,Q,X.source),eX(z))Y(j,"HEAD",K,Q,X.source)}if(cO(z))for(let[X,G]of Object.entries(z)){let Q=G,K=Q.middlewares,B=Q.run.bind(Q);if(Y(j,X,B,K,Q.source),X==="get"&&eX(Q))Y(j,"HEAD",B,K,Q.source)}if(uO(z)){let X=new z,G=f7(X.routes,`${Z}${j}`,X.middlewares);for(let[Q,K]of Object.entries(G))W[Q.replaceAll("//","/")]=K}if(dO(z)){let{first:X,second:G}=z;for(let[Q,K]of Object.entries(X)){let B=K.middlewares,F=K.run.bind(K),[D,...V]=j.split("/").reverse();if(!D.startsWith(":"))throw Error("Resource route must end with a dynamic segment");Y(V.reverse().join("/"),Q,F,B,K.source)}for(let[Q,K]of Object.entries(G)){let B=K.middlewares,F=K.run.bind(K);Y(j,Q,F,B,K.source)}}}return Object.fromEntries(Object.entries(W).sort(([j],[z])=>{let X=j.split("/").length+j.split(":").length,G=z.split("/").length+z.split(":").length;return X-G}))}function R4($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function b7($,Z){if($==="/")return Z;if(Z==="/")return $;return`${$}${Z}`}function R7($){let Z=R4($);return Z.length>1?Z.replace(/\/$/,""):Z}function $G($,Z){return Z.map((J)=>({...J,path:R7(b7($,J.path))}))}function w4($){let Z={};for(let[J,W]of Object.entries($))if("run"in W){let Y=W;if("children"in Y){let j=new Y.children,z=w4(j.routes);for(let[X,{exec:G,middleware:Q,segments:K,features:B,static:F}]of Object.entries(z)){let D=b7(J,X),V=(O)=>Y.run.call(Y,O,J);Z[R4(D)]={exec:[V,...G],middleware:[...Y.middlewares,...Q],features:[...Y.featureGates,...B],viewPath:Y.viewPath,segments:[{path:R7(J),viewPath:Y.viewPath,...Y.alwaysRuns?{alwaysRun:!0}:{}},...$G(J,K)],...F?{static:F}:{}}}}else{let j=(z)=>Y.run.call(Y,z,J);Z[R4(J)]={exec:[j],middleware:Y.middlewares,features:Y.featureGates,viewPath:Y.viewPath,segments:[{path:R7(J),viewPath:Y.viewPath}],..."staticOptions"in Y&&Y.staticOptions?{static:Y.staticOptions}:{}}}}else{let Y=new W,j=w4(Y.routes);for(let[z,{exec:X,middleware:G,viewPath:Q,segments:K,features:B,static:F}]of Object.entries(j)){let D=b7(J,z);Z[R4(D)]={exec:X,middleware:[...Y.middlewares,...G],features:[...Y.featureGates,...B],viewPath:Q,segments:$G(J,K),...F?{static:F}:{}}}}return Object.fromEntries(Object.entries(Z).sort(([J],[W])=>{let Y=J.split("/").length+J.split(":").length,j=W.split("/").length+W.split(":").length;return Y-j}))}var iO=Object.defineProperty,_=($,Z)=>iO($,"name",{value:Z,configurable:!0}),gZ=class{type=3;name="";prefix="";value="";suffix="";modifier=3;constructor($,Z,J,W,Y,j){this.type=$,this.name=Z,this.prefix=J,this.value=W,this.suffix=Y,this.modifier=j}hasCustomName(){return this.name!==""&&typeof this.name!="number"}};_(gZ,"Part");var sO=/[$_\p{ID_Start}]/u,nO=/[$_\u200C\u200D\p{ID_Continue}]/u,k7=".*";function ZG($,Z){return(Z?/^[\x00-\xFF]*$/:/^[\x00-\x7F]*$/).test($)}_(ZG,"isASCII");function v7($,Z=!1){let J=[],W=0;for(;W<$.length;){let Y=$[W],j=_(function(z){if(!Z)throw TypeError(z);J.push({type:"INVALID_CHAR",index:W,value:$[W++]})},"ErrorOrInvalid");if(Y==="*"){J.push({type:"ASTERISK",index:W,value:$[W++]});continue}if(Y==="+"||Y==="?"){J.push({type:"OTHER_MODIFIER",index:W,value:$[W++]});continue}if(Y==="\\"){J.push({type:"ESCAPED_CHAR",index:W++,value:$[W++]});continue}if(Y==="{"){J.push({type:"OPEN",index:W,value:$[W++]});continue}if(Y==="}"){J.push({type:"CLOSE",index:W,value:$[W++]});continue}if(Y===":"){let z="",X=W+1;for(;X<$.length;){let G=$.substr(X,1);if(X===W+1&&sO.test(G)||X!==W+1&&nO.test(G)){z+=$[X++];continue}break}if(!z){j(`Missing parameter name at ${W}`);continue}J.push({type:"NAME",index:W,value:z}),W=X;continue}if(Y==="("){let z=1,X="",G=W+1,Q=!1;if($[G]==="?"){j(`Pattern cannot start with "?" at ${G}`);continue}for(;G<$.length;){if(!ZG($[G],!1)){j(`Invalid character '${$[G]}' at ${G}.`),Q=!0;break}if($[G]==="\\"){X+=$[G++]+$[G++];continue}if($[G]===")"){if(z--,z===0){G++;break}}else if($[G]==="("&&(z++,$[G+1]!=="?")){j(`Capturing groups are not allowed at ${G}`),Q=!0;break}X+=$[G++]}if(Q)continue;if(z){j(`Unbalanced pattern at ${W}`);continue}if(!X){j(`Missing pattern at ${W}`);continue}J.push({type:"REGEX",index:W,value:X}),W=G;continue}J.push({type:"CHAR",index:W,value:$[W++]})}return J.push({type:"END",index:W,value:""}),J}_(v7,"lexer");function g7($,Z={}){let J=v7($);Z.delimiter??="/#?",Z.prefixes??="./";let W=`[^${h0(Z.delimiter)}]+?`,Y=[],j=0,z=0,X="",G=new Set,Q=_((I)=>{if(z<J.length&&J[z].type===I)return J[z++].value},"tryConsume"),K=_(()=>Q("OTHER_MODIFIER")??Q("ASTERISK"),"tryConsumeModifier"),B=_((I)=>{let x=Q(I);if(x!==void 0)return x;let{type:A,index:f}=J[z];throw TypeError(`Unexpected ${A} at ${f}, expected ${I}`)},"mustConsume"),F=_(()=>{let I="",x;for(;x=Q("CHAR")??Q("ESCAPED_CHAR");)I+=x;return I},"consumeText"),D=_((I)=>I,"DefaultEncodePart"),V=Z.encodePart||D,O="",U=_((I)=>{O+=I},"appendToPendingFixedValue"),H=_(()=>{O.length&&(Y.push(new gZ(3,"","",V(O),"",3)),O="")},"maybeAddPartFromPendingFixedValue"),T=_((I,x,A,f,S)=>{let M=3;switch(S){case"?":M=1;break;case"*":M=0;break;case"+":M=2;break}if(!x&&!A&&M===3){U(I);return}if(H(),!x&&!A){if(!I)return;Y.push(new gZ(3,"","",V(I),"",M));return}let P;A?A==="*"?P=k7:P=A:P=W;let k=2;P===W?(k=1,P=""):P===k7&&(k=0,P="");let m;if(x?m=x:A&&(m=j++),G.has(m))throw TypeError(`Duplicate name '${m}'.`);G.add(m),Y.push(new gZ(k,m,V(I),P,V(f),M))},"addPart");for(;z<J.length;){let I=Q("CHAR"),x=Q("NAME"),A=Q("REGEX");if(!x&&!A&&(A=Q("ASTERISK")),x||A){let S=I??"";Z.prefixes.indexOf(S)===-1&&(U(S),S=""),H();let M=K();T(S,x,A,"",M);continue}let f=I??Q("ESCAPED_CHAR");if(f){U(f);continue}if(Q("OPEN")){let S=F(),M=Q("NAME"),P=Q("REGEX");!M&&!P&&(P=Q("ASTERISK"));let k=F();B("CLOSE");let m=K();T(S,M,P,k,m);continue}H(),B("END")}return Y}_(g7,"parse");function h0($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}_(h0,"escapeString");function q7($){return $&&$.ignoreCase?"ui":"u"}_(q7,"flags");function JG($,Z,J){return m7(g7($,J),Z,J)}_(JG,"stringToRegexp");function g$($){switch($){case 0:return"*";case 1:return"?";case 2:return"+";case 3:return""}}_(g$,"modifierToString");function m7($,Z,J={}){J.delimiter??="/#?",J.prefixes??="./",J.sensitive??=!1,J.strict??=!1,J.end??=!0,J.start??=!0,J.endsWith="";let W=J.start?"^":"";for(let X of $){if(X.type===3){X.modifier===3?W+=h0(X.value):W+=`(?:${h0(X.value)})${g$(X.modifier)}`;continue}Z&&Z.push(X.name);let G=`[^${h0(J.delimiter)}]+?`,Q=X.value;if(X.type===1?Q=G:X.type===0&&(Q=k7),!X.prefix.length&&!X.suffix.length){X.modifier===3||X.modifier===1?W+=`(${Q})${g$(X.modifier)}`:W+=`((?:${Q})${g$(X.modifier)})`;continue}if(X.modifier===3||X.modifier===1){W+=`(?:${h0(X.prefix)}(${Q})${h0(X.suffix)})`,W+=g$(X.modifier);continue}W+=`(?:${h0(X.prefix)}`,W+=`((?:${Q})(?:`,W+=h0(X.suffix),W+=h0(X.prefix),W+=`(?:${Q}))*)${h0(X.suffix)})`,X.modifier===0&&(W+="?")}let Y=`[${h0(J.endsWith)}]|$`,j=`[${h0(J.delimiter)}]`;if(J.end)return J.strict||(W+=`${j}?`),J.endsWith.length?W+=`(?=${Y})`:W+="$",new RegExp(W,q7(J));J.strict||(W+=`(?:${j}(?=${Y}))?`);let z=!1;if($.length){let X=$[$.length-1];X.type===3&&X.modifier===3&&(z=J.delimiter.indexOf(X)>-1)}return z||(W+=`(?=${j}|${Y})`),new RegExp(W,q7(J))}_(m7,"partsToRegexp");var B$={delimiter:"",prefixes:"",sensitive:!0,strict:!0},oO={delimiter:".",prefixes:"",sensitive:!0,strict:!0},aO={delimiter:"/",prefixes:"/",sensitive:!0,strict:!0};function WG($,Z){return $.length?$[0]==="/"?!0:!Z||$.length<2?!1:($[0]=="\\"||$[0]=="{")&&$[1]=="/":!1}_(WG,"isAbsolutePathname");function h7($,Z){return $.startsWith(Z)?$.substring(Z.length,$.length):$}_(h7,"maybeStripPrefix");function YG($,Z){return $.endsWith(Z)?$.substr(0,$.length-Z.length):$}_(YG,"maybeStripSuffix");function p7($){return!$||$.length<2?!1:$[0]==="["||($[0]==="\\"||$[0]==="{")&&$[1]==="["}_(p7,"treatAsIPv6Hostname");var jG=["ftp","file","http","https","ws","wss"];function c7($){if(!$)return!0;for(let Z of jG)if($.test(Z))return!0;return!1}_(c7,"isSpecialScheme");function zG($,Z){if($=h7($,"#"),Z||$==="")return $;let J=new URL("https://example.com");return J.hash=$,J.hash?J.hash.substring(1,J.hash.length):""}_(zG,"canonicalizeHash");function XG($,Z){if($=h7($,"?"),Z||$==="")return $;let J=new URL("https://example.com");return J.search=$,J.search?J.search.substring(1,J.search.length):""}_(XG,"canonicalizeSearch");function GG($,Z){return Z||$===""?$:p7($)?l7($):u7($)}_(GG,"canonicalizeHostname");function QG($,Z){if(Z||$==="")return $;let J=new URL("https://example.com");return J.password=$,J.password}_(QG,"canonicalizePassword");function KG($,Z){if(Z||$==="")return $;let J=new URL("https://example.com");return J.username=$,J.username}_(KG,"canonicalizeUsername");function FG($,Z,J){if(J||$==="")return $;if(Z&&!jG.includes(Z))return new URL(`${Z}:${$}`).pathname;let W=$[0]=="/";return $=new URL(W?$:"/-"+$,"https://example.com").pathname,W||($=$.substring(2,$.length)),$}_(FG,"canonicalizePathname");function BG($,Z,J){return d7(Z)===$&&($=""),J||$===""?$:i7($)}_(BG,"canonicalizePort");function VG($,Z){return $=YG($,":"),Z||$===""?$:k4($)}_(VG,"canonicalizeProtocol");function d7($){switch($){case"ws":case"http":return"80";case"wws":case"https":return"443";case"ftp":return"21";default:return""}}_(d7,"defaultPortForProtocol");function k4($){if($==="")return $;if(/^[-+.A-Za-z0-9]*$/.test($))return $.toLowerCase();throw TypeError(`Invalid protocol '${$}'.`)}_(k4,"protocolEncodeCallback");function OG($){if($==="")return $;let Z=new URL("https://example.com");return Z.username=$,Z.username}_(OG,"usernameEncodeCallback");function DG($){if($==="")return $;let Z=new URL("https://example.com");return Z.password=$,Z.password}_(DG,"passwordEncodeCallback");function u7($){if($==="")return $;if(/[\t\n\r #%/:<>?@[\]^\\|]/g.test($))throw TypeError(`Invalid hostname '${$}'`);let Z=new URL("https://example.com");return Z.hostname=$,Z.hostname}_(u7,"hostnameEncodeCallback");function l7($){if($==="")return $;if(/[^0-9a-fA-F[\]:]/g.test($))throw TypeError(`Invalid IPv6 hostname '${$}'`);return $.toLowerCase()}_(l7,"ipv6HostnameEncodeCallback");function i7($){if($===""||/^[0-9]*$/.test($)&&parseInt($)<=65535)return $;throw TypeError(`Invalid port '${$}'.`)}_(i7,"portEncodeCallback");function UG($){if($==="")return $;let Z=new URL("https://example.com");return Z.pathname=$[0]!=="/"?"/-"+$:$,$[0]!=="/"?Z.pathname.substring(2,Z.pathname.length):Z.pathname}_(UG,"standardURLPathnameEncodeCallback");function LG($){return $===""?$:new URL(`data:${$}`).pathname}_(LG,"pathURLPathnameEncodeCallback");function HG($){if($==="")return $;let Z=new URL("https://example.com");return Z.search=$,Z.search.substring(1,Z.search.length)}_(HG,"searchEncodeCallback");function IG($){if($==="")return $;let Z=new URL("https://example.com");return Z.hash=$,Z.hash.substring(1,Z.hash.length)}_(IG,"hashEncodeCallback");var PG=class{#j;#W=[];#Z={};#$=0;#Y=1;#Q=0;#X=0;#V=0;#O=0;#D=!1;constructor($){this.#j=$}get result(){return this.#Z}parse(){for(this.#W=v7(this.#j,!0);this.#$<this.#W.length;this.#$+=this.#Y){if(this.#Y=1,this.#W[this.#$].type==="END"){if(this.#X===0){this.#I(),this.#K()?this.#J(9,1):this.#F()?this.#J(8,1):this.#J(7,0);continue}else if(this.#X===2){this.#B(5);continue}this.#J(10,0);break}if(this.#V>0)if(this.#C())this.#V-=1;else continue;if(this.#x()){this.#V+=1;continue}switch(this.#X){case 0:this.#P()&&this.#B(1);break;case 1:if(this.#P()){this.#E();let $=7,Z=1;this.#M()?($=2,Z=3):this.#D&&($=2),this.#J($,Z)}break;case 2:this.#L()?this.#B(3):(this.#H()||this.#F()||this.#K())&&this.#B(5);break;case 3:this.#N()?this.#J(4,1):this.#L()&&this.#J(5,1);break;case 4:this.#L()&&this.#J(5,1);break;case 5:this.#S()?this.#O+=1:this.#A()&&(this.#O-=1),this.#_()&&!this.#O?this.#J(6,1):this.#H()?this.#J(7,0):this.#F()?this.#J(8,1):this.#K()&&this.#J(9,1);break;case 6:this.#H()?this.#J(7,0):this.#F()?this.#J(8,1):this.#K()&&this.#J(9,1);break;case 7:this.#F()?this.#J(8,1):this.#K()&&this.#J(9,1);break;case 8:this.#K()&&this.#J(9,1);break;case 9:break;case 10:break}}this.#Z.hostname!==void 0&&this.#Z.port===void 0&&(this.#Z.port="")}#J($,Z){switch(this.#X){case 0:break;case 1:this.#Z.protocol=this.#G();break;case 2:break;case 3:this.#Z.username=this.#G();break;case 4:this.#Z.password=this.#G();break;case 5:this.#Z.hostname=this.#G();break;case 6:this.#Z.port=this.#G();break;case 7:this.#Z.pathname=this.#G();break;case 8:this.#Z.search=this.#G();break;case 9:this.#Z.hash=this.#G();break;case 10:break}this.#X!==0&&$!==10&&([1,2,3,4].includes(this.#X)&&[6,7,8,9].includes($)&&(this.#Z.hostname??=""),[1,2,3,4,5,6].includes(this.#X)&&[8,9].includes($)&&(this.#Z.pathname??=this.#D?"/":""),[1,2,3,4,5,6,7].includes(this.#X)&&$===9&&(this.#Z.search??="")),this.#T($,Z)}#T($,Z){this.#X=$,this.#Q=this.#$+Z,this.#$+=Z,this.#Y=0}#I(){this.#$=this.#Q,this.#Y=0}#B($){this.#I(),this.#X=$}#U($){return $<0&&($=this.#W.length-$),$<this.#W.length?this.#W[$]:this.#W[this.#W.length-1]}#z($,Z){let J=this.#U($);return J.value===Z&&(J.type==="CHAR"||J.type==="ESCAPED_CHAR"||J.type==="INVALID_CHAR")}#P(){return this.#z(this.#$,":")}#M(){return this.#z(this.#$+1,"/")&&this.#z(this.#$+2,"/")}#L(){return this.#z(this.#$,"@")}#N(){return this.#z(this.#$,":")}#_(){return this.#z(this.#$,":")}#H(){return this.#z(this.#$,"/")}#F(){if(this.#z(this.#$,"?"))return!0;if(this.#W[this.#$].value!=="?")return!1;let $=this.#U(this.#$-1);return $.type!=="NAME"&&$.type!=="REGEX"&&$.type!=="CLOSE"&&$.type!=="ASTERISK"}#K(){return this.#z(this.#$,"#")}#x(){return this.#W[this.#$].type=="OPEN"}#C(){return this.#W[this.#$].type=="CLOSE"}#S(){return this.#z(this.#$,"[")}#A(){return this.#z(this.#$,"]")}#G(){let $=this.#W[this.#$],Z=this.#U(this.#Q).index;return this.#j.substring(Z,$.index)}#E(){let $={};Object.assign($,B$),$.encodePart=k4;let Z=JG(this.#G(),void 0,$);this.#D=c7(Z)}};_(PG,"Parser");var w7=["protocol","username","password","hostname","port","pathname","search","hash"],F$="*";function y7($,Z){if(typeof $!="string")throw TypeError("parameter 1 is not of type 'string'.");let J=new URL($,Z);return{protocol:J.protocol.substring(0,J.protocol.length-1),username:J.username,password:J.password,hostname:J.hostname,port:J.port,pathname:J.pathname,search:J.search!==""?J.search.substring(1,J.search.length):void 0,hash:J.hash!==""?J.hash.substring(1,J.hash.length):void 0}}_(y7,"extractValues");function D1($,Z){return Z?vZ($):$}_(D1,"processBaseURLString");function yZ($,Z,J){let W;if(typeof Z.baseURL=="string")try{W=new URL(Z.baseURL),Z.protocol===void 0&&($.protocol=D1(W.protocol.substring(0,W.protocol.length-1),J)),!J&&Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.username===void 0&&($.username=D1(W.username,J)),!J&&Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.username===void 0&&Z.password===void 0&&($.password=D1(W.password,J)),Z.protocol===void 0&&Z.hostname===void 0&&($.hostname=D1(W.hostname,J)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&($.port=D1(W.port,J)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&($.pathname=D1(W.pathname,J)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&Z.search===void 0&&($.search=D1(W.search.substring(1,W.search.length),J)),Z.protocol===void 0&&Z.hostname===void 0&&Z.port===void 0&&Z.pathname===void 0&&Z.search===void 0&&Z.hash===void 0&&($.hash=D1(W.hash.substring(1,W.hash.length),J))}catch{throw TypeError(`invalid baseURL '${Z.baseURL}'.`)}if(typeof Z.protocol=="string"&&($.protocol=VG(Z.protocol,J)),typeof Z.username=="string"&&($.username=KG(Z.username,J)),typeof Z.password=="string"&&($.password=QG(Z.password,J)),typeof Z.hostname=="string"&&($.hostname=GG(Z.hostname,J)),typeof Z.port=="string"&&($.port=BG(Z.port,$.protocol,J)),typeof Z.pathname=="string"){if($.pathname=Z.pathname,W&&!WG($.pathname,J)){let Y=W.pathname.lastIndexOf("/");Y>=0&&($.pathname=D1(W.pathname.substring(0,Y+1),J)+$.pathname)}$.pathname=FG($.pathname,$.protocol,J)}return typeof Z.search=="string"&&($.search=XG(Z.search,J)),typeof Z.hash=="string"&&($.hash=zG(Z.hash,J)),$}_(yZ,"applyInit");function vZ($){return $.replace(/([+*?:{}()\\])/g,"\\$1")}_(vZ,"escapePatternString");function TG($){return $.replace(/([.+*?^${}()[\]|/\\])/g,"\\$1")}_(TG,"escapeRegexpString");function MG($,Z){Z.delimiter??="/#?",Z.prefixes??="./",Z.sensitive??=!1,Z.strict??=!1,Z.end??=!0,Z.start??=!0,Z.endsWith="";let J=".*",W=`[^${TG(Z.delimiter)}]+?`,Y=/[$_\u200C\u200D\p{ID_Continue}]/u,j="";for(let z=0;z<$.length;++z){let X=$[z];if(X.type===3){if(X.modifier===3){j+=vZ(X.value);continue}j+=`{${vZ(X.value)}}${g$(X.modifier)}`;continue}let G=X.hasCustomName(),Q=!!X.suffix.length||!!X.prefix.length&&(X.prefix.length!==1||!Z.prefixes.includes(X.prefix)),K=z>0?$[z-1]:null,B=z<$.length-1?$[z+1]:null;if(!Q&&G&&X.type===1&&X.modifier===3&&B&&!B.prefix.length&&!B.suffix.length)if(B.type===3){let F=B.value.length>0?B.value[0]:"";Q=Y.test(F)}else Q=!B.hasCustomName();if(!Q&&!X.prefix.length&&K&&K.type===3){let F=K.value[K.value.length-1];Q=Z.prefixes.includes(F)}Q&&(j+="{"),j+=vZ(X.prefix),G&&(j+=`:${X.name}`),X.type===2?j+=`(${X.value})`:X.type===1?G||(j+=`(${W})`):X.type===0&&(!G&&(!K||K.type===3||K.modifier!==3||Q||X.prefix!=="")?j+="*":j+=`(${J})`),X.type===1&&G&&X.suffix.length&&Y.test(X.suffix[0])&&(j+="\\"),j+=vZ(X.suffix),Q&&(j+="}"),X.modifier!==3&&(j+=g$(X.modifier))}return j}_(MG,"partsToPattern");var s7=class{#j;#W={};#Z={};#$={};#Y={};#Q=!1;constructor($={},Z,J){try{let W;if(typeof Z=="string"?W=Z:J=Z,typeof $=="string"){let X=new PG($);if(X.parse(),$=X.result,W===void 0&&typeof $.protocol!="string")throw TypeError("A base URL must be provided for a relative constructor string.");$.baseURL=W}else{if(!$||typeof $!="object")throw TypeError("parameter 1 is not of type 'string' and cannot convert to dictionary.");if(W)throw TypeError("parameter 1 is not of type 'string'.")}typeof J>"u"&&(J={ignoreCase:!1});let Y={ignoreCase:J.ignoreCase===!0},j={pathname:F$,protocol:F$,username:F$,password:F$,hostname:F$,port:F$,search:F$,hash:F$};this.#j=yZ(j,$,!0),d7(this.#j.protocol)===this.#j.port&&(this.#j.port="");let z;for(z of w7){if(!(z in this.#j))continue;let X={},G=this.#j[z];switch(this.#Z[z]=[],z){case"protocol":Object.assign(X,B$),X.encodePart=k4;break;case"username":Object.assign(X,B$),X.encodePart=OG;break;case"password":Object.assign(X,B$),X.encodePart=DG;break;case"hostname":Object.assign(X,oO),p7(G)?X.encodePart=l7:X.encodePart=u7;break;case"port":Object.assign(X,B$),X.encodePart=i7;break;case"pathname":c7(this.#W.protocol)?(Object.assign(X,aO,Y),X.encodePart=UG):(Object.assign(X,B$,Y),X.encodePart=LG);break;case"search":Object.assign(X,B$,Y),X.encodePart=HG;break;case"hash":Object.assign(X,B$,Y),X.encodePart=IG;break}try{this.#Y[z]=g7(G,X),this.#W[z]=m7(this.#Y[z],this.#Z[z],X),this.#$[z]=MG(this.#Y[z],X),this.#Q=this.#Q||this.#Y[z].some((Q)=>Q.type===2)}catch{throw TypeError(`invalid ${z} pattern '${this.#j[z]}'.`)}}}catch(W){throw TypeError(`Failed to construct 'URLPattern': ${W.message}`)}}get[Symbol.toStringTag](){return"URLPattern"}test($={},Z){let J={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&Z)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return!1;try{typeof $=="object"?J=yZ(J,$,!1):J=yZ(J,y7($,Z),!1)}catch{return!1}let W;for(W of w7)if(!this.#W[W].exec(J[W]))return!1;return!0}exec($={},Z){let J={pathname:"",protocol:"",username:"",password:"",hostname:"",port:"",search:"",hash:""};if(typeof $!="string"&&Z)throw TypeError("parameter 1 is not of type 'string'.");if(typeof $>"u")return;try{typeof $=="object"?J=yZ(J,$,!1):J=yZ(J,y7($,Z),!1)}catch{return null}let W={};Z?W.inputs=[$,Z]:W.inputs=[$];let Y;for(Y of w7){let j=this.#W[Y].exec(J[Y]);if(!j)return null;let z={};for(let[X,G]of this.#Z[Y].entries())if(typeof G=="string"||typeof G=="number"){let Q=j[X+1];z[G]=Q}W[Y]={input:J[Y]??"",groups:z}}return W}static compareComponent($,Z,J){let W=_((X,G)=>{for(let Q of["type","modifier","prefix","value","suffix"]){if(X[Q]<G[Q])return-1;if(X[Q]===G[Q])continue;return 1}return 0},"comparePart"),Y=new gZ(3,"","","","",3),j=new gZ(0,"","","","",3),z=_((X,G)=>{let Q=0;for(;Q<Math.min(X.length,G.length);++Q){let K=W(X[Q],G[Q]);if(K)return K}return X.length===G.length?0:W(X[Q]??Y,G[Q]??Y)},"comparePartList");return!Z.#$[$]&&!J.#$[$]?0:Z.#$[$]&&!J.#$[$]?z(Z.#Y[$],[j]):!Z.#$[$]&&J.#$[$]?z([j],J.#Y[$]):z(Z.#Y[$],J.#Y[$])}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.#Q}};_(s7,"URLPattern");function y3($,Z){for(let[J,W]of Object.entries($)){let Y=new s7({pathname:J});if(Y.test({pathname:Z}))return{routePath:J,params:Y.exec({pathname:Z})?.pathname.groups??{},route:W}}return null}var m$={startIndex:0,carriedViews:[]};function NG($,Z){let J=B0($.path,Z);return J.includes("*")?null:J}function rO($,Z){if(!$)return m$;if($.search!==Z.search)return m$;let J=Math.min($.segments.length,Z.segments.length-1),W=0;while(W<J){let Y=$.segments[W],j=Z.segments[W];if(j.alwaysRun)break;if(Y.viewPath!==j.viewPath)break;let z=NG(Y,$.params),X=NG(j,Z.params);if(z===null||X===null||z!==X)break;W++}if(W===0)return m$;return{startIndex:W,carriedViews:Z.segments.slice(0,W).map(({viewPath:Y})=>Y)}}function tO($,Z){let[,J,...W]=$.split("/");if(!Z.includes(J))return $;let Y=`/${W.join("/")}`;return Y==="/"?"/":Y.replace(/\/$/,"")}function _G($){let{flatViewRoutes:Z,supportedLocales:J,from:W,origin:Y,to:j}=$;if(!W)return m$;let z;try{z=new URL(W,Y)}catch{return m$}if(z.origin!==Y)return m$;let X=y3(Z,tO(z.pathname,J));if(!X)return m$;return rO({segments:X.route.segments,params:X.params,search:z.search},j)}var n7="x-gemi-from";import{createElement as g1,Fragment as dG}from"react";function eO($){return $.replace(/\([^)]*\)/g,"").replace(/\/\//g,"/")}function q4($){let Z={};for(let[J,W]of Object.entries($))if("run"in W){let Y=W.viewPath;if("children"in W){Z[J]=[Y];let j=new W.children,z=q4(j.routes);for(let[X,G]of Object.entries(z)){let Q=J==="/"?X:`${J}${X}`,K=X==="/"&&J!=="/"?J:Q;Z[K]=[Y,...G]}if(Z[J].length===1)delete Z[J]}else Z[J]=[Y]}else{let Y=new W,j=q4(Y.routes);for(let[z,X]of Object.entries(j)){let G=J==="/"?z:`${J}${z}`,Q=z==="/"&&J!=="/"?J:G;Z[Q]=X}}return Object.fromEntries(Object.entries(Z).map(([J,W])=>[eO(J),W]))}function y4($,Z){let[J,W]=Z,Y=$.find(([j])=>j===J);if(!Y){$.push([J,[...W]]);return}for(let j of W)y4(Y[1],j)}function v4($){let Z=[];for(let[J,W]of Object.entries($))if("run"in W){let Y=W.viewPath;if(Y==="__")continue;if(Y==="REDIRECT")continue;if(Y==="FILE")continue;if("children"in W){let j=new W.children,z=v4(j.routes);y4(Z,[Y,z])}else y4(Z,[Y,[]])}else{let Y=new W,j=v4(Y.routes);for(let z of j)y4(Z,z)}return Z}function o7($){let Z=[];for(let[J,W]of $)Z.push(J,...o7(W).flat());return Array.from(new Set(Z))}class V$ extends v{static getFacadeAccessor(){return s}static getSupportedLocales(){return this.getFacadeRoot().supportedLocales}static getDefaultLocale(){return this.getFacadeRoot().defaultLocale}static locale(){let $=this.getFacadeRoot(),Z=N.getStore();if(Z)return Z.locale??$.detectLocale(Z.req);return $.defaultLocale}static timeZone(){return this.getFacadeRoot().detectTimeZone(N.getStore()?.req)}static formatter($={}){return this.getFacadeRoot().formatter($.locale??V$.locale(),$.timeZone??V$.timeZone())}static setLocale($=V$.locale(),Z={}){let J=this.getFacadeRoot(),W=$;if(!J.supportedLocales.includes($))W=J.defaultLocale;let Y=N.getStore();if(Z.cookie!==!1)Y.setCookie("i18n-locale",W,{expires:new Date(Date.now()+31536000000),secure:!1,httpOnly:!1});return Y.setLocale(W),W}}class a7{id;static token="kernel.id";constructor($=crypto.randomUUID()){this.id=$}}function xG($){return Object.fromEntries(Object.entries($).filter(([,Z])=>{return Z!==null&&Z!==void 0}))}var $D=50;class mZ{fetcher;entries=new Map;settleListener=null;failListener=null;shellAt=null;settledBacklog=[];shipped=new Set;requestStartedAt=performance.now();renderStartedAt=null;discoveryHintsMuted=!1;constructor($){this.fetcher=$}elapsed(){return Math.round(performance.now()-this.requestStartedAt)}keyFor($,Z){return[$,Z].filter((J)=>J.length>0).join("?")}markRenderStart(){if(this.renderStartedAt===null)this.renderStartedAt=performance.now()}markShell(){if(this.shellAt===null)this.shellAt=this.elapsed()}summarize($){let Z=this.elapsed();return{shellAt:this.shellAt??Z,settledAt:Z,aborted:$,queries:Array.from(this.entries.values(),(J)=>({path:J.path,variantKey:J.variantKey,startedAt:J.startedAt,settledAt:J.settledAt,status:J.status,source:J.source}))}}onQueryFail($){this.failListener=$}muteDiscoveryHints(){this.discoveryHintsMuted=!0}maybeLogLateDiscovery($){if(!$.lateBy||this.discoveryHintsMuted)return;if($.status!=="resolved")return;if(Bun.env.NODE_ENV==="production")return;let Z="";try{let Y=JSON.stringify($.data)?.length??0;Z=Y>=1024?`${(Y/1024).toFixed(1)} kB`:`${Y} B`}catch{Z="an unserializable payload"}let J=($.settledAt??0)-$.startedAt,W=$.variantKey?`, { search: ${JSON.stringify(Object.fromEntries(new URLSearchParams($.variantKey)))} }`:"";console.warn(`[gemi] useQuery("${$.patternPath}") was discovered ${$.lateBy}ms into the `+`server render \u2014 under a suspended segment, so its fetch (${J}ms, resolved ${Z}) could not overlap the others. It still streamed. If the query belongs on this route, \`Query.prefetch("${$.patternPath}"${W})\` in the view `+"handler starts it at request time \u2014 but note prefetched data is also re-fetched and "+`streamed into every client-side navigation payload for the route, even when the client already holds it, so weigh that bandwidth against the ${Z}. If the data is only needed conditionally (a closed popover, a hidden tab), \`{ lazy: true }\` + \`trigger()\` avoids running it here at all. \`Query.noPrefetch()\` in the handler marks the omission intentional and silences this hint for the route.`)}read($,Z){return this.entries.get(this.keyFor($,Z))}ensure($,Z={},J="render"){let W=Z.params??{},Y=new URLSearchParams(xG(Z.search??{}));Y.delete("json"),Y.sort();let j=B0($,W),z=Y.toString(),X=this.keyFor(j,z),G=this.entries.get(X);if(G)return G;let Q;if(J==="render"&&this.renderStartedAt!==null){let D=Math.round(performance.now()-this.renderStartedAt);if(D>$D)Q=D}let K,B=new Promise((D)=>{K=D}),F={path:j,patternPath:$,variantKey:z,lateBy:Q,status:"pending",promise:B,source:J,startedAt:this.elapsed()};return this.entries.set(X,F),this.fetcher($,W,Y).then((D)=>{F.status="resolved",F.data=D},(D)=>{F.status="rejected",F.error=D}).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);K()}),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,J]of this.entries){if(J.status!=="resolved")continue;this.shipped.add(Z),$[J.path]??={},$[J.path][J.variantKey]=J.data}return $}onSettle($){this.settleListener=(J)=>{if(this.shipped.has(this.keyFor(J.path,J.variantKey)))return;$(J)};let Z=this.settledBacklog;this.settledBacklog=[];for(let J of Z)this.settleListener(J)}}class v1 extends Error{path;variantKey;status;body;retryAfter;constructor($,Z,J,W,Y){super(typeof W?.message==="string"?W.message:`Request to /api${$} failed with status ${J}`);this.path=$;this.variantKey=Z;this.status=J;this.body=W;this.retryAfter=Y;this.name="QueryError"}}function hZ(){let $=JSON.stringify({error:l1("permission","Forbidden",403)});return new Response($,{status:403,headers:{"Content-Type":"application/json","Content-Length":String(Buffer.byteLength($)),"Cache-Control":"no-store"}})}function r7(){return{status:403,error:{message:"Forbidden"}}}function v3($){let Z=pZ.getStore();return(J,W,Y)=>{let j=new URL($.url).origin,z=[B0(J,W),Y.toString()].filter((K)=>K.length>0).join("?"),X=new Request(`${j}/${z}`,{headers:$.headers,signal:$.signal}),G=CG($);if(G)cZ(X,G);let Q=new C(X,W);return pZ.run(Z,()=>N.run(Q,async()=>{try{let K=L(W1).dispatchers(G).api,B=await K.runRouteMiddleware(J,Q)??await K.getRouteData(J);if($Z(B)){if(!B.ok)throw new v1(B0(J,W),Y.toString(),B.status,B.body);return B.body}if(B instanceof Response){let F=await B.json().catch(()=>null);if(!B.ok)throw new v1(B0(J,W),Y.toString(),B.status,F);return F}return B}catch(K){if(K instanceof v1)throw K;let B=new v1(B0(J,W),Y.toString(),500,{message:K instanceof Error?K.message:String(K)});throw B.cause=K,B}}))}}var ZD=new Set(["script","style","template","title"]),JD=/\shidden([\s=/]|$)/i,WD=/"[^"]*"|'[^']*'/g;function YD($){let Z=0,J=0,W=0,Y=0;while(Y<$.length){let j=$.indexOf("<",Y),z=j===-1?$.length:j;if(z>Y){let B=$.slice(Y,z).replace(/\s+/g,"").length;if(W>0)J+=B;else Z+=B}if(j===-1)break;if($.startsWith("<!--",j)){let B=$.indexOf("-->",j+4);Y=B===-1?$.length:B+3;continue}let X=$.indexOf(">",j);if(X===-1)break;let G=$.slice(j+1,X);Y=X+1;let Q=/^\/?([a-zA-Z][a-zA-Z0-9-]*)/.exec(G)?.[1]?.toLowerCase();if(!Q)continue;let K=G.startsWith("/");if(!K&&ZD.has(Q)&&!G.endsWith("/")){let B=$.indexOf(`</${Q}`,Y);Y=B===-1?$.length:B;continue}if(Q!=="div")continue;if(K){if(W>0)W-=1}else if(W>0)W+=1;else if(JD.test(G.replace(WD,'""')))W=1}return{shellChars:Z,deferredChars:J}}var jD=1000,zD=64;function XD($){return $>=1000?`${($/1000).toFixed(1)} kB`:`${$} chars`}function GD($,Z){if(Z.deferredChars<jD)return null;if(Z.shellChars>=zD)return null;return`[gemi] GET ${$} streams ${XD(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 SG($=console.warn){let Z=new Set;return{shouldObserve(J){return!Z.has(J)},report(J,W){if(Z.has(J))return;let Y=GD(J,W);if(!Y)return;Z.add(J),$(Y)}}}function AG(){let $=new TextDecoder,Z="";return{onChunk(J){Z+=$.decode(J,{stream:!0})},measure(){return Z+=$.decode(),YD(Z)}}}function EG($,Z,J=1e4,W){let Y=new TextEncoder,j=()=>{};return new ReadableStream({start(z){let X=!1,G=(K)=>{if(X)return;X=!0,clearTimeout(Q);try{z.close()}catch{}W?.({aborted:K})};j=G,z.enqueue(Y.encode(`${JSON.stringify($)}
|
|
14
14
|
`)),Z.onSettle((K)=>{if(X||K.status!=="resolved")return;z.enqueue(Y.encode(`${JSON.stringify([K.path,K.variantKey,K.data])}
|
|
15
15
|
`))});let Q=setTimeout(()=>G(!0),J);Z.allSettled().then(()=>G(!1),()=>G(!1))},cancel(){j(!1)}})}import{Fragment as fM,createContext as QD,createElement as bM,lazy as RM,use as wM,useContext as kM}from"react";function fG($){return{islands:[],render:$,instances:new WeakMap,count:0}}var g3="gemi-slot",bG="data-slot",RG="data-gemi-slot";var KD=Symbol.for("gemi.staticRender"),wG=globalThis[KD]??=QD(null);import{createHash as gG}from"crypto";var t7='var r=document,i=window,a=history;i.__gemi_nav?.d();var L=new AbortController,h=(t,e,n,s)=>t.addEventListener(e,n,{signal:L.signal,...s}),q=i.__gemi_nav={d:()=>L.abort()},v=(t,e)=>{if(!t.g)t.g=1,import(e.s).then((n)=>{if(t.isConnected)t.r=n.h(t,n.m[e.e])}).catch((n)=>console.error(n))},D=(t)=>{let e=t.getElementById("gemi-islands");return e?JSON.parse(e.textContent):{i:[]}},R=(t,e)=>{for(let n of t.querySelectorAll("gemi-island")){let s=e.i[n.dataset.island];if(!s||n.o)continue;if(s.l=="eager")v(n,s);else if(s.l=="idle"||!i.IntersectionObserver||!n.children.length)(i.requestIdleCallback||setTimeout)(()=>v(n,s));else{let l=new IntersectionObserver((m)=>{if(m.some((d)=>d.isIntersecting))l.disconnect(),v(n,s)});for(let m of n.children)l.observe(m)}}},O=\'meta[name="gemi-static"]\',A="style:not([data-gemi-fonts])",T=A+",link[rel=stylesheet]",K=`head>${A},body>${A},link[rel=stylesheet]`,I=\'meta[name]:not([name=viewport]),meta[property],link[rel~=canonical],link[rel~=alternate],link[rel~=icon],link[rel=preload][as=font],style[data-gemi-fonts],script[type="application/ld+json"]\',w=(t)=>t.querySelector(O)?.content,C=(t)=>[...t.querySelectorAll(K)].map((e)=>e.outerHTML).join(),c=(t)=>t.href.split("#")[0],p=r.createElement("div");p.setAttribute("aria-live","polite");p.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap";r.body.append(p);var _=(t)=>{q.p={url:location.href,title:r.title,initial:t},r.dispatchEvent(new CustomEvent("gemi:page-load",{detail:q.p}))},f=new Map,k=(t)=>{let e=f.get(t);if(!e||Date.now()-e[0]>30000){let n=fetch(t,{headers:{accept:"text/html","x-gemi-navigate":"1"},signal:AbortSignal.timeout(1e4)}).then((s)=>{if(!s.ok||!/^text\\/html/.test(s.headers.get("content-type"))||new URL(s.url||t).origin!=location.origin)throw s;return s.text().then((l)=>[s.url||t,l])});e=[Date.now(),n],n.catch(()=>f.get(t)==e&&f.delete(t))}if(f.delete(t),f.set(t,e),f.size>10)f.delete(f.keys().next().value);return e[1]},M=(t)=>{let e=t.target.closest?.("a[href]"),n=e?.getAttribute("target");if(!e||n&&n!="_self"||e.hasAttribute("download")||/(^|\\s)external(\\s|$)/i.test(e.getAttribute("rel"))||e.closest("[data-gemi-reload]"))return;let s=new URL(e.getAttribute("href"),r.baseURI);if(s.origin==location.origin&&!(s.href.includes("#")&&c(s)==c(location)))return s},y={},U=()=>Math.random().toString(36).slice(2),E=()=>a.state?.g||a.replaceState({...a.state,g:U()},""),P=c(location),b=0,N=(t)=>{if(!t.hasAttribute("tabindex"))t.setAttribute("tabindex","-1"),t.addEventListener("blur",()=>t.removeAttribute("tabindex"),{once:!0});t.focus({preventScroll:!0})},Y=(t)=>{let e=r.body,n=t.body,s=D(t),l=r.documentElement;r.title=t.title;for(let o of["lang","dir"]){let u=t.documentElement.getAttribute(o);if(u==null)l.removeAttribute(o);else l.setAttribute(o,u)}for(let o of r.head.querySelectorAll(I))o.remove();let m=new Set([...r.querySelectorAll("link[rel=modulepreload]")].map((o)=>o.getAttribute("href")));r.head.append(...t.head.querySelectorAll(I),...[...t.head.querySelectorAll("link[rel=modulepreload]")].filter((o)=>!m.has(o.getAttribute("href"))));let d=new Map([...e.querySelectorAll("[data-gemi-persist]")].map((o)=>[o.dataset.gemiPersist,o])),g=[...n.querySelectorAll("[data-gemi-persist]")].map((o)=>[o,d.get(o.dataset.gemiPersist)]).filter((o)=>o[1]);for(let o of[...e.querySelectorAll("gemi-island")].reverse())if(o.o=1,!g.some((u)=>u[1].contains(o)))try{o.r?.unmount()}catch(u){console.error(u)}for(let[o,u]of g)o.replaceWith(u);for(let o of[...e.childNodes])if(!o.matches?.(T))o.remove();for(let o of[...n.children])if(o.matches(T))o.remove();for(let o of[...e.attributes])e.removeAttribute(o.name);for(let o of n.attributes)e.setAttribute(o.name,o.value);e.append(...n.childNodes,p),R(e,s)},H=async(t,e)=>{let n=++b,s=!e&&y[a.state?.g];a.scrollRestoration="manual";try{let[l,m]=await k(c(t));if(n!=b)return;let d=new DOMParser().parseFromString(m,"text/html");if(w(d)==null||w(d)!=w(r)||C(d)!=C(r))throw 0;if(e){let o=new URL(l);o.hash=t.hash,a.pushState({g:U()},"",o.href)}P=c(location),Y(d);let g=e&&t.hash&&r.getElementById(decodeURIComponent(t.hash.slice(1)));if(g)g.scrollIntoView({behavior:"instant"});else i.scrollTo({left:s?.[0]||0,top:s?.[1]||0,behavior:"instant"});if(e)N(g||r.querySelector("h1")||r.querySelector("main")||r.body);p.textContent=r.title,_(!1)}catch{if(n!=b)return;if(e)location.assign(t.href);else location.reload()}};h(r,"click",(t)=>{if(t.defaultPrevented||t.button||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let e=M(t);if(e&&r.dispatchEvent(new CustomEvent("gemi:before-navigate",{cancelable:!0,detail:{url:e.href}})))t.preventDefault(),E(),y[a.state.g]=[i.scrollX,i.scrollY],H(e,1)});h(i,"popstate",()=>{if(b++,c(location)==P){let t=y[a.state?.g];if(t)i.scrollTo({left:t[0],top:t[1],behavior:"instant"})}else if(a.state?.g)H(new URL(location.href),0);else location.reload()});h(i,"hashchange",E);h(i,"scroll",()=>a.state?.g&&(y[a.state.g]=[i.scrollX,i.scrollY]),{passive:!0});var S,x=(t)=>{if(r.querySelector(O)?.dataset.prefetch=="none"||navigator.connection?.saveData)return;let e=M(t);if(e&&c(e)!=c(location))k(c(e))};h(r,"pointerover",(t)=>{clearTimeout(S),S=setTimeout(()=>x(t),65)});h(r,"pointerout",()=>clearTimeout(S));h(r,"focusin",x);h(r,"touchstart",x,{passive:!0});E();R(r,D(r));_(!0);';import{createHash as FD}from"crypto";import{existsSync as qG,readFileSync as BD}from"fs";import{join as J9}from"path";var yG=".script",VD=[".ts",".js"],OD="document-scripts.json",vG="data-gemi-script",DD=/^[A-Za-z0-9_-]+(\/[A-Za-z0-9_-]+)*$/;function UD($){if(typeof $!=="string"||!DD.test($))throw Error(`A static view's \`script\` is a path under app/views without the ".script.ts" suffix, e.g. "site/clicks". Got ${JSON.stringify($)}.`)}function LD($,Z){for(let J of VD){let W=J9($,"views",`${Z}${yG}${J}`);if(qG(W))return W}return null}async function kG($){let Z=await Bun.build({entrypoints:[$],target:"browser",format:"iife",minify:!0,throw:!1});if(!Z.success||!Z.outputs[0]){let W=Z.logs.map((Y)=>String(Y)).join(`
|
|
16
16
|
`);throw Error(`The document script ${$} does not bundle.
|
|
@@ -119,4 +119,4 @@ data: ${JSON.stringify(Z)}
|
|
|
119
119
|
"deadline_at" BIGINT${W}
|
|
120
120
|
)`,`CREATE INDEX IF NOT EXISTS "${Z}_subject_created_at_idx" ON "${Z}"("subject", "created_at")`,`CREATE INDEX IF NOT EXISTS "${Z}_status_deadline_at_idx" ON "${Z}"("status", "deadline_at")`]}var yQ=191,vQ=30000;class t4 extends Error{id;constructor($){super(`No run has the id ${$}.`);this.id=$;this.name="RunNotFoundError"}}class e4 extends Error{code;data;constructor($,Z={}){super($,Z.cause===void 0?void 0:{cause:Z.cause});this.name="RunFailure",this.code=Z.code,this.data=Z.data}}class k9{options;static token="runs";store;config;ownFeed=null;constructor($={},Z={}){this.options=Z;this.config=O1(wQ(),$),this.store=KU(this.config.store,Z.application)}get feed(){if(this.options.feed)return this.options.feed;if(this.options.application)return this.options.application.make(dZ);return this.ownFeed??=new dZ,this.ownFeed}channel($){return`gemi:run:${$}`}async create($){hQ("kind",$.kind);let Z=$.id??`run_${crypto.randomUUID().replaceAll("-","")}`;hQ("id",Z);let J=await this.store.create({id:Z,kind:$.kind,subject:$.subject??null,owner:$.owner??null,meta:$.meta??null,status:$.start?"running":"pending",deadlineMs:$.deadline===void 0||$.deadline===null?null:c$($.deadline)});return await this.publish(J),J}async get($){return await this.store.get($)}list($={}){return this.store.list($)}start($){return this.change($,["pending"],{status:"running"})}async progress($,Z){return QU(Z),this.change($,L1,{status:"running",progress:Z})}complete($,Z){return this.change($,L1,{status:"completed",result:Z===void 0?null:Z})}fail($,Z){return this.change($,L1,{status:"failed",error:mQ(Z)})}cancel($,Z){return this.change($,L1,{status:"cancelled",error:{message:Z??"The run was cancelled.",code:"cancelled"}})}async execute($,Z){let J=this.feed.subscribe(this.channel($));try{await J.ready();let W=await this.start($)??await this.store.get($);if(!W)throw new t4($);if(H1(W.status))return W;let Y=new AbortController,j=this.watch($,W,J,Y),z={id:$,record:W,signal:Y.signal,progress:async(G)=>{if(Y.signal.aborted)return;await this.progress($,G)}},X;try{let G=await Z(z);X=await this.complete($,G)}catch(G){if(!(G instanceof e4)&&!Y.signal.aborted)console.error(`[gemi] Run ${$} failed.`,G);X=await this.change($,L1,{status:"failed",error:G instanceof e4?mQ(G):{message:"The run failed.",code:"error"}})}finally{Y.abort(),J.close(),await j}return X??await this.store.get($)??W}finally{J.close()}}async wait($,Z={}){let{signal:J}=Z;J?.throwIfAborted();let W=Z.timeout===void 0?1/0:Date.now()+c$(Z.timeout),Y=this.feed.subscribe(this.channel($),{signal:J});try{await Y.ready();let j=await this.store.get($);if(!j)throw new t4($);let z=null;for(;;){if(H1(j.status))return j;J?.throwIfAborted();let X=await this.untilDeadline(j);if(X!==null&&X<=0){j=await this.expire($)??await this.store.get($)??j;continue}let G=W-Date.now();if(G<=0)return j;if(z??=Y.isClosed?new Promise(()=>{}):Y.next(),await gQ(z,Math.min(G,X??1/0,vQ),J))z=null;j=await this.store.get($)??j}}finally{Y.close()}}async*subscribe($,Z={}){let J=this.feed.subscribe(this.channel($),{signal:Z.signal});try{await J.ready();let W=await this.store.get($);if(!W)throw new t4($);if(yield W,H1(W.status))return;for await(let Y of J){let j=GU(Y,$)??await this.store.get($);if(!j||j.version<=W.version)continue;if(W=j,yield W,H1(W.status))return}}finally{J.close()}}stream($,Z,J={}){return this.feed.stream($,this.channel(Z),J)}cursor($){return this.feed.cursor(this.channel($))}async sweep(){let $=await this.now(),Z=0;for(let J of await this.store.overdue($,this.config.sweepLimit))if(await this.expire(J.id))Z++;return Z}async prune($){let Z=c$($);return await this.store.prune?.(Z)??0}async close(){await this.ownFeed?.close(),this.ownFeed=null}now(){return this.store.now?this.store.now():Promise.resolve(Date.now())}async untilDeadline($){if($.deadlineAt===null)return null;return $.deadlineAt-await this.now()}async expire($){let Z=await this.store.get($);if(!Z||H1(Z.status))return null;let J=await this.untilDeadline(Z);if(J===null||J>0)return null;return this.change($,L1,{status:"timed_out",error:{message:"The run passed its deadline.",code:"deadline"}})}async watch($,Z,J,W){let Y=new Promise((z)=>{if(W.signal.aborted)z("ended");W.signal.addEventListener("abort",()=>z("ended"),{once:!0})}),j=null;try{for(;;){if(W.signal.aborted)return;if(H1(Z.status)){W.abort();return}let z=await this.untilDeadline(Z);if(z!==null&&z<=0){Z=await this.expire($)??await this.store.get($)??Z;continue}j??=J.next();let X=await Promise.race([Y,gQ(j,Math.min(z??1/0,vQ))]);if(X==="ended")return;if(X)j=null;Z=await this.store.get($)??Z}}catch(z){console.error(`[gemi] Run ${$}: could not follow the run for a cancel.`,z)}}async change($,Z,J){let W=await this.store.transition($,Z,J);if(W)await this.publish(W);return W}async publish($){try{await this.feed.publish(this.channel($.id),$)}catch(Z){console.error(`[gemi] Run ${$.id}: could not publish its change.`,Z)}}}function gQ($,Z,J){return new Promise((W,Y)=>{let j=Number.isFinite(Z)?setTimeout(()=>G(!1),Math.max(0,Z)):null,z=()=>{X(),Y(J.reason)},X=()=>{if(j)clearTimeout(j);J?.removeEventListener("abort",z)},G=(Q)=>{X(),W(Q)};J?.addEventListener("abort",z,{once:!0}),$.then(()=>G(!0),()=>G(!0))})}function GU($,Z){if($.type!=="change")return null;let J=$.data;if(!J||typeof J!=="object"||J.id!==Z||typeof J.version!=="number")return null;return J}function mQ($){if(typeof $==="string")return{message:$};if($ instanceof e4)return{message:$.message,...$.code!==void 0?{code:$.code}:{},...$.data!==void 0?{data:$.data}:{}};if($ instanceof Error)return{message:$.message};return $}function hQ($,Z){if(typeof Z!=="string"||Z===""||Z.length>yQ)throw TypeError(`A run's ${$} is a string of 1 to ${yQ} characters; got ${JSON.stringify(Z)}.`)}function QU($){let{fraction:Z}=$;if(Z!==void 0&&!(Number.isFinite(Z)&&Z>=0&&Z<=1))throw RangeError(`A run's progress fraction is between 0 and 1; got ${Z}.`)}function KU($,Z){if($==="memory")return new E9;if($==="database"||typeof $==="function"){if(!Z&&($==="database"||$.length>0))throw Error("The runs store needs the application it belongs to, and this RunManager was built without one. Pass { application }.");if($==="database"){let J=Z.make(C1).connection();return new w9(J)}return $(Z)}if(typeof $==="string")throw Error(`Unknown runs store "${$}". The runs slice's store is "memory", "database", a RunStore, or a function returning one.`);return $}class pQ extends v{static getFacadeAccessor(){return k9}static create($){return this.getFacadeRoot().create($)}static get($){return this.getFacadeRoot().get($)}static list($){return this.getFacadeRoot().list($)}static start($){return this.getFacadeRoot().start($)}static progress($,Z){return this.getFacadeRoot().progress($,Z)}static complete($,Z){return this.getFacadeRoot().complete($,Z)}static fail($,Z){return this.getFacadeRoot().fail($,Z)}static cancel($,Z){return this.getFacadeRoot().cancel($,Z)}static execute($,Z){return this.getFacadeRoot().execute($,Z)}static wait($,Z){return this.getFacadeRoot().wait($,Z)}static subscribe($,Z){return this.getFacadeRoot().subscribe($,Z)}static stream($,Z,J){return this.getFacadeRoot().stream($,Z,J)}static cursor($){return this.getFacadeRoot().cursor($)}static channel($){return this.getFacadeRoot().channel($)}static sweep(){return this.getFacadeRoot().sweep()}static prune($){return this.getFacadeRoot().prune($)}}class cQ extends v{static getFacadeAccessor(){return s1}static enabled($){return this.getFacadeRoot().enabled($)}static all(){return this.getFacadeRoot().forClient()}static explain($){return this.getFacadeRoot().explain($)}static for($){return this.getFacadeRoot().for($)}static list(){return this.getFacadeRoot().list()}static set($,Z,J){return this.getFacadeRoot().set($,Z,J)}static refresh(){return this.getFacadeRoot().refresh()}static invalidate(){return this.getFacadeRoot().invalidate()}}class $8{bound;constructor($){this.bound=$}get name(){return this.bound??x1()}get sql(){return this.connection().sql}get dialect(){return this.connection().dialect}async query($){return await this.run($,"query")}async execute($){let Z=await this.run($,"execute");return Number(Z?.count??0)}async transaction($){let Z=this.name,J=this.connection(Z);return lQ(J.sql,(W)=>dQ(Z,()=>$(W)),{slowTransactionThreshold:J.config.slowTransactionThreshold,connection:Z})}async schema(){let $=this.connection(),{introspect:Z}=await import("./chunk-1awxdnb6.js");return Z(this.handle()??$.sql,$.dialect)}run($,Z){let J=this.connection(),{text:W,values:Y}=sQ($,iQ(J.dialect),Z);return(this.handle()??J.sql).unsafe(W,Y)}handle(){let $=i0();if($===void 0)return;return x1()===this.name?$:void 0}connection($=this.name){return uQ($),L(C1).connection($)}}var uZ=new $8;class nQ extends v{static getFacadeAccessor(){return C1}static connection($){return new $8($)}static get sql(){return uZ.sql}static get dialect(){return uZ.dialect}static query($){return uZ.query($)}static execute($){return uZ.execute($)}static transaction($){return uZ.transaction($)}static schema(){return uZ.schema()}static close(){return this.getFacadeRoot().close()}}export{l0 as Od,sZ as Pd,j8 as Qd,r$ as Rd,oZ as Sd,N0 as Td,s3 as Ud,E8 as Vd,f8 as Wd,lW as Xd,i1 as Yd,z1 as Zd,t as _d,NW as $d,JZ as ae,iW as be,sW as ce,R8 as de,w8 as ee,j6 as fe,eZ as ge,LF as he,xI as ie,Y5 as je,F5 as ke,g8 as le,B5 as me,V5 as ne,xF as oe,O5 as pe,m8 as qe,AF as re,EF as se,h8 as te,D5 as ue,U5 as ve,s1 as we,L5 as xe,wF as ye,c8 as ze,L8 as Ae,t3 as Be,M1 as Ce,U$ as De,NK as Ee,D8 as Fe,N1 as Ge,V$ as He,i4 as Ie,jQ as Je,zQ as Ke,iD as Le,m1 as Me,zx as Ne,XQ as Oe,U9 as Pe,L9 as Qe,I9 as Re,KQ as Se,BQ as Te,VQ as Ue,DQ as Ve,LQ as We,HQ as Xe,kx as Ye,IQ as Ze,s4 as _e,P9 as $e,T9 as af,M9 as bf,n4 as cf,dZ as df,fQ as ef,bQ as ff,p as gf,aZ as hf,N4 as if,QP as jf,KP as kf,FP as lf,DP as mf,NX as nf,O7 as of,CX as pf,PP as qf,EX as rf,m0 as sf,b3 as tf,fX as uf,RQ as vf,VC as wf,A9 as xf,L1 as yf,H1 as zf,E9 as Af,w9 as Bf,XU as Cf,t4 as Df,e4 as Ef,k9 as Ff,pQ as Gf,cQ as Hf,$8 as If,nQ as Jf,U7 as Kf,fO as Lf,C7 as Mf,S7 as Nf,fT as Of,nX as Pf,oX as Qf,n3 as Rf,c1 as Sf,hT as Tf,rX as Uf,tX as Vf,a7 as Wf,hZ as Xf,r7 as Yf,pM as Zf,oM as _f,aM as $f,K9 as ag,SD as bg,G9 as cg,fD as dg,h3 as eg,F9 as fg,nG as gg,oG as hg,h4 as ig,W1 as jg,E as kg,R0 as lg,o3 as mg,YW as ng,LK as og,ZW as pg,zW as qg,F8 as rg,B8 as sg,V8 as tg,XW as ug,_K as vg,xK as wg,OW as xg,UW as yg,HW as zg,xW as Ag,CW as Bg,SW as Cg,P8 as Dg,bK as Eg,j0 as Fg,gW as Gg,jZ as Hg,dW as Ig};
|
|
121
121
|
|
|
122
|
-
//# debugId=
|
|
122
|
+
//# debugId=B65CF732B4A69BAD64756E2164756E21
|