@dbx-tools/tunnel 0.9.132 → 0.9.138

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.
@@ -1,2 +1,2 @@
1
1
  // GENERATED by assets/build-login-client.ts - DO NOT EDIT.
2
- export const LOGIN_CLIENT_SOURCE = "(()=>{var g=((e)=>typeof require<\"u\"?require:typeof Proxy<\"u\"?new Proxy(e,{get:(t,r)=>(typeof require<\"u\"?require:t)[r]}):e)(function(e){if(typeof require<\"u\")return require.apply(this,arguments);throw Error('Dynamic require of \"'+e+'\" is not supported')});function ie(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{code:t,message:r,toString:()=>t}]))}var x=ie({CHALLENGE_NOT_FOUND:\"Challenge not found\",YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY:\"You are not allowed to register this passkey\",FAILED_TO_VERIFY_REGISTRATION:\"Failed to verify registration\",PASSKEY_NOT_FOUND:\"Passkey not found\",AUTHENTICATION_FAILED:\"Authentication failed\",UNABLE_TO_CREATE_SESSION:\"Unable to create session\",USER_NOT_FOUND:\"User not found\",FAILED_TO_UPDATE_PASSKEY:\"Failed to update passkey\",PREVIOUSLY_REGISTERED:\"Previously registered\",REGISTRATION_CANCELLED:\"Registration cancelled\",AUTH_CANCELLED:\"Auth cancelled\",UNKNOWN_ERROR:\"Unknown error\",SESSION_REQUIRED:\"Passkey registration requires an authenticated session\",RESOLVE_USER_REQUIRED:\"Passkey registration requires either an authenticated session or a resolveUser callback when requireSession is false\",RESOLVED_USER_INVALID:\"Resolved user is invalid\"}),Ke=\"1.7.6\";function L(e){let t=new Uint8Array(e),r=\"\";for(let o of t)r+=String.fromCharCode(o);return btoa(r).replace(/\\+/g,\"-\").replace(/\\//g,\"_\").replace(/=/g,\"\")}function k(e){let t=e.replace(/-/g,\"+\").replace(/_/g,\"/\"),r=(4-t.length%4)%4,n=t.padEnd(t.length+r,\"=\"),o=atob(n),s=new ArrayBuffer(o.length),l=new Uint8Array(s);for(let a=0;a<o.length;a++)l[a]=o.charCodeAt(a);return s}function M(){return Kt.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential===\"function\")}var Kt={stubThis:(e)=>e};function ae(e){let{id:t}=e;return{...e,id:k(t),transports:e.transports}}function ue(e){return e===\"localhost\"||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}class S extends Error{constructor({message:e,code:t,cause:r,name:n}){super(e,{cause:r});Object.defineProperty(this,\"code\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=n??r.name,this.code=t}}function Ge({error:e,options:t}){let{publicKey:r}=t;if(!r)throw Error(\"options was missing required publicKey property\");if(e.name===\"AbortError\"){if(t.signal instanceof AbortSignal)return new S({message:\"Registration ceremony was sent an abort signal\",code:\"ERROR_CEREMONY_ABORTED\",cause:e})}else if(e.name===\"ConstraintError\"){if(r.authenticatorSelection?.requireResidentKey===!0)return new S({message:\"Discoverable credentials were required but no available authenticator supported it\",code:\"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT\",cause:e});else if(t.mediation===\"conditional\"&&r.authenticatorSelection?.userVerification===\"required\")return new S({message:\"User verification was required during automatic registration but it could not be performed\",code:\"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE\",cause:e});else if(r.authenticatorSelection?.userVerification===\"required\")return new S({message:\"User verification was required but no available authenticator supported it\",code:\"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT\",cause:e})}else if(e.name===\"InvalidStateError\")return new S({message:\"The authenticator was previously registered\",code:\"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED\",cause:e});else if(e.name===\"NotAllowedError\")return new S({message:e.message,code:\"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY\",cause:e});else if(e.name===\"NotSupportedError\"){if(r.pubKeyCredParams.filter((o)=>o.type===\"public-key\").length===0)return new S({message:'No entry in pubKeyCredParams was of type \"public-key\"',code:\"ERROR_MALFORMED_PUBKEYCREDPARAMS\",cause:e});return new S({message:\"No available authenticator supported any of the specified pubKeyCredParams algorithms\",code:\"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG\",cause:e})}else if(e.name===\"SecurityError\"){let n=globalThis.location.hostname;if(!ue(n))return new S({message:`${globalThis.location.hostname} is an invalid domain`,code:\"ERROR_INVALID_DOMAIN\",cause:e});else if(r.rp.id!==n)return new S({message:`The RP ID \"${r.rp.id}\" is invalid for this domain`,code:\"ERROR_INVALID_RP_ID\",cause:e})}else if(e.name===\"TypeError\"){if(r.user.id.byteLength<1||r.user.id.byteLength>64)return new S({message:\"User ID was not between 1 and 64 characters\",code:\"ERROR_INVALID_USER_ID_LENGTH\",cause:e})}else if(e.name===\"UnknownError\")return new S({message:\"The authenticator was unable to process the specified options, or could not create a new credential\",code:\"ERROR_AUTHENTICATOR_GENERAL_ERROR\",cause:e});return e}class Ye{constructor(){Object.defineProperty(this,\"controller\",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=Error(\"Cancelling existing WebAuthn API call for new one\");t.name=\"AbortError\",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(\"Manually cancelling existing WebAuthn API call\");e.name=\"AbortError\",this.controller.abort(e),this.controller=void 0}}}var V=new Ye;var Gt=[\"cross-platform\",\"platform\"];function le(e){if(!e)return;if(Gt.indexOf(e)<0)return;return e}async function Je(e){if(!e.optionsJSON&&e.challenge)console.warn(\"startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.\"),e={optionsJSON:e};let{optionsJSON:t,useAutoRegister:r=!1}=e;if(!M())throw Error(\"WebAuthn is not supported in this browser\");let n={...t,challenge:k(t.challenge),user:{...t.user,id:k(t.user.id)},excludeCredentials:t.excludeCredentials?.map(ae)},o={};if(r)o.mediation=\"conditional\";o.publicKey=n,o.signal=V.createNewAbortSignal();let s;try{s=await navigator.credentials.create(o)}catch(E){throw Ge({error:E,options:o})}if(!s)throw Error(\"Registration was not completed\");let{id:l,rawId:a,response:i,type:c}=s,u=void 0;if(typeof i.getTransports===\"function\")u=i.getTransports();let p=void 0;if(typeof i.getPublicKeyAlgorithm===\"function\")try{p=i.getPublicKeyAlgorithm()}catch(E){Se(\"getPublicKeyAlgorithm()\",E)}let h=void 0;if(typeof i.getPublicKey===\"function\")try{let E=i.getPublicKey();if(E!==null)h=L(E)}catch(E){Se(\"getPublicKey()\",E)}let d;if(typeof i.getAuthenticatorData===\"function\")try{d=L(i.getAuthenticatorData())}catch(E){Se(\"getAuthenticatorData()\",E)}return{id:l,rawId:L(a),response:{attestationObject:L(i.attestationObject),clientDataJSON:L(i.clientDataJSON),transports:u,publicKeyAlgorithm:p,publicKey:h,authenticatorData:d},type:c,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:le(s.authenticatorAttachment)}}function Se(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function ze(){if(!M())return Te.stubThis(new Promise((t)=>t(!1)));let e=globalThis.PublicKeyCredential;if(e?.isConditionalMediationAvailable===void 0)return Te.stubThis(new Promise((t)=>t(!1)));return Te.stubThis(e.isConditionalMediationAvailable())}var Te={stubThis:(e)=>e};function $e({error:e,options:t}){let{publicKey:r}=t;if(!r)throw Error(\"options was missing required publicKey property\");if(e.name===\"AbortError\"){if(t.signal instanceof AbortSignal)return new S({message:\"Authentication ceremony was sent an abort signal\",code:\"ERROR_CEREMONY_ABORTED\",cause:e})}else if(e.name===\"NotAllowedError\")return new S({message:e.message,code:\"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY\",cause:e});else if(e.name===\"SecurityError\"){let n=globalThis.location.hostname;if(!ue(n))return new S({message:`${globalThis.location.hostname} is an invalid domain`,code:\"ERROR_INVALID_DOMAIN\",cause:e});else if(r.rpId!==n)return new S({message:`The RP ID \"${r.rpId}\" is invalid for this domain`,code:\"ERROR_INVALID_RP_ID\",cause:e})}else if(e.name===\"UnknownError\")return new S({message:\"The authenticator was unable to process the specified options, or could not create a new assertion signature\",code:\"ERROR_AUTHENTICATOR_GENERAL_ERROR\",cause:e});return e}async function Qe(e){if(!e.optionsJSON&&e.challenge)console.warn(\"startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.\"),e={optionsJSON:e};let{optionsJSON:t,useBrowserAutofill:r=!1,verifyBrowserAutofillInput:n=!0}=e;if(!M())throw Error(\"WebAuthn is not supported in this browser\");let o;if(t.allowCredentials?.length!==0)o=t.allowCredentials?.map(ae);let s={...t,challenge:k(t.challenge),allowCredentials:o},l={};if(r){if(!await ze())throw Error(\"Browser does not support WebAuthn autofill\");if(document.querySelectorAll(\"input[autocomplete$='webauthn']\").length<1&&n)throw Error('No <input> with \"webauthn\" as the only or last value in its `autocomplete` attribute was detected');l.mediation=\"conditional\",s.allowCredentials=[]}l.publicKey=s,l.signal=V.createNewAbortSignal();let a;try{a=await navigator.credentials.get(l)}catch(d){throw $e({error:d,options:l})}if(!a)throw Error(\"Authentication was not completed\");let{id:i,rawId:c,response:u,type:p}=a,h=void 0;if(u.userHandle)h=L(u.userHandle);return{id:i,rawId:L(c),response:{authenticatorData:L(u.authenticatorData),clientDataJSON:L(u.clientDataJSON),signature:L(u.signature),userHandle:h},type:p,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:le(a.authenticatorAttachment)}}var Xe=\"1.7.6\";var Ze=Xe;var Oe=Symbol.for(\"better-auth:broadcast-channel\"),Yt=()=>Math.floor(Date.now()/1000),Jt=class{listeners=new Set;name;constructor(e=\"better-auth.message\"){this.name=e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}post(e){if(typeof window>\"u\")return;try{localStorage.setItem(this.name,JSON.stringify({...e,timestamp:Yt()}))}catch{}}setup(){if(typeof window>\"u\"||typeof window.addEventListener>\"u\")return()=>{};let e=(t)=>{if(t.key!==this.name)return;let r=JSON.parse(t.newValue??\"{}\");if(r?.event!==\"session\"||!r?.data)return;this.listeners.forEach((n)=>n(r))};return window.addEventListener(\"storage\",e),()=>{window.removeEventListener(\"storage\",e)}}};function ce(e=\"better-auth.message\"){if(!globalThis[Oe])globalThis[Oe]=new Jt(e);return globalThis[Oe]}var Q=Symbol(\"clean\");var _=[],X=0,B=null,Ae=4,zt=globalThis.nanostoresGlobal||={epoch:0},$t=()=>{let e,t;while(X<_.length){t=X,X+=Ae;let r=B?.get(_[t]);if(r){if(!r.has(_[t+1]))continue;r.clear()}try{_[t](_[t+1].value,_[t+2],_[t+3])}catch(n){e=n}}if(_.length=X=0,e)throw e};var q=(e)=>{let t=[],r={eq:Object.is,get(){if(!r.lc)r.listen(()=>{})();return r.value},init:e,lc:0,listen(n){return r.lc=t.push(n),()=>{B?.get(n)?.delete(r);for(let s=X;s<_.length;)if(_[s]===n&&_[s+1]===r)_.splice(s,Ae);else s+=Ae;let o=t.indexOf(n);if(~o){if(t.splice(o,1),!--r.lc)r.off()}}},notify(n,o){zt.epoch++;let s=!_.length&&!B;for(let l of t){if(B){let a=B.get(l);if(!a)B.set(l,a=new Set);if(a.has(r))continue;a.add(r)}_.push(l,r,n,B?void 0:o)}if(s)$t()},off(){},set(n){let o=r.value;if(!r.eq(o,n))r.value=n,r.notify(o)},subscribe(n){let o=r.listen(n);return n(r.value),o},value:e};return r[Q]=()=>{t=[],r.lc=0,r.off()},r};var Qt=2;var Xt=5,W=6,fe=10,et=(e,t,r,n)=>{if(e.events=e.events||{},!e.events[r+fe])e.events[r+fe]=n((o)=>{e.events[r].reduceRight((s,l)=>(l(s),s),{shared:{},...o})});return e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let o=e.events[r],s=o.indexOf(t);if(~s){if(o.splice(s,1),!o.length)e.events[r+fe](),delete e.events[r+fe]}}};var we=(e,t)=>et(e,t,Qt,(r)=>{let{set:n,setKey:o}=e;if(e.setKey)e.setKey=(s,l)=>{let a;if(r({abort:()=>{a=!0},changed:s,newValue:{...e.value,[s]:l}}),!a)return o(s,l)};return e.set=(s)=>{let l;if(r({abort:()=>{l=!0},newValue:s}),!l)return n(s)},()=>{e.set=n,e.setKey=o}});var de=1000,K=(e,t)=>et(e,(n)=>{let o=t(n);if(o)e.events[W].push(o)},Xt,(n)=>{let o=e.listen;e.listen=(...l)=>{if(!e.lc&&!e.active)e.active=!0,n();return o(...l)};let s=e.off;e.events[W]=[],e.off=()=>{s(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let l of e.events[W])l();e.events[W]=[]}},de)};{let l=e[Q];e[Q]=()=>{for(let a of e.events[W])a();e.events[W]=[],e.active=!1,l()}}return()=>{e.listen=o,e.off=s}});function ot(e){if(typeof e!==\"object\"||e===null)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function C(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!C(e[r],t[r]))return!1;return!0}if(ot(e)&&ot(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let o of r)if(!(o in t)||!C(e[o],t[o]))return!1;return!0}return!1}function he(e,t){return we(e,({newValue:r,abort:n})=>{if(t(e.value,r))n()})}var _e=Symbol.for(\"better-auth:focus-manager\"),nr=class{listeners=new Set;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setFocused(e){this.listeners.forEach((t)=>t(e))}setup(){if(typeof window>\"u\"||typeof document>\"u\"||typeof window.addEventListener>\"u\")return()=>{};let e=()=>{if(document.visibilityState===\"visible\")this.setFocused(!0)};return document.addEventListener(\"visibilitychange\",e,!1),()=>{document.removeEventListener(\"visibilitychange\",e,!1)}}};function Pe(){if(!globalThis[_e])globalThis[_e]=new nr;return globalThis[_e]}var Le=Symbol.for(\"better-auth:online-manager\"),or=class{listeners=new Set;isOnline=typeof navigator<\"u\"?navigator.onLine:!0;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOnline(e){this.isOnline=e,this.listeners.forEach((t)=>t(e))}setup(){if(typeof window>\"u\"||typeof window.addEventListener>\"u\")return()=>{};let e=()=>this.setOnline(!0),t=()=>this.setOnline(!1);return window.addEventListener(\"online\",e,!1),window.addEventListener(\"offline\",t,!1),()=>{window.removeEventListener(\"online\",e,!1),window.removeEventListener(\"offline\",t,!1)}}};function me(){if(!globalThis[Le])globalThis[Le]=new or;return globalThis[Le]}var sr={proto:/\"(?:_|\\\\u0{2}5[Ff]){2}(?:p|\\\\u0{2}70)(?:r|\\\\u0{2}72)(?:o|\\\\u0{2}6[Ff])(?:t|\\\\u0{2}74)(?:o|\\\\u0{2}6[Ff])(?:_|\\\\u0{2}5[Ff]){2}\"\\s*:/,constructor:/\"(?:c|\\\\u0063)(?:o|\\\\u006[Ff])(?:n|\\\\u006[Ee])(?:s|\\\\u0073)(?:t|\\\\u0074)(?:r|\\\\u0072)(?:u|\\\\u0075)(?:c|\\\\u0063)(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:r|\\\\u0072)\"\\s*:/,protoShort:/\"__proto__\"\\s*:/,constructorShort:/\"constructor\"\\s*:/},ir=/^\\s*[\"[{]|^\\s*-?\\d{1,16}(\\.\\d{1,17})?([Ee][+-]?\\d+)?\\s*$/,st={true:!0,false:!1,null:null,undefined:void 0,nan:NaN,infinity:Number.POSITIVE_INFINITY,\"-infinity\":Number.NEGATIVE_INFINITY},ar=/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:\\.(\\d{1,7}))?(?:Z|([+-])(\\d{2}):(\\d{2}))$/;function ur(e){return e instanceof Date&&!isNaN(e.getTime())}function lr(e){let t=ar.exec(e);if(!t)return null;let[,r,n,o,s,l,a,i,c,u,p]=t,h=new Date(Date.UTC(parseInt(r,10),parseInt(n,10)-1,parseInt(o,10),parseInt(s,10),parseInt(l,10),parseInt(a,10),i?parseInt(i.padEnd(3,\"0\"),10):0));if(c){let d=(parseInt(u,10)*60+parseInt(p,10))*(c===\"+\"?-1:1);h.setUTCMinutes(h.getUTCMinutes()+d)}return ur(h)?h:null}function cr(e,t={}){let{strict:r=!1,warnings:n=!1,reviver:o,parseDates:s=!0}=t;if(typeof e!==\"string\")return e;let l=e.trim(),a=l.toLowerCase();if(a.length<=9&&a in st)return st[a];if(!ir.test(l)){if(r)throw SyntaxError(\"[better-json] Invalid JSON\");return e}if(Object.entries(sr).some(([i,c])=>{let u=c.test(l);if(u&&n)console.warn(`[better-json] Detected potential prototype pollution attempt using ${i} pattern`);return u})&&r)throw Error(\"[better-json] Potential prototype pollution attempt detected\");try{return JSON.parse(l,(c,u)=>{if(c===\"__proto__\"||c===\"constructor\"&&u&&typeof u===\"object\"&&\"prototype\"in u){if(n)console.warn(`[better-json] Dropping \"${c}\" key to prevent prototype pollution`);return}if(s&&typeof u===\"string\"){let p=lr(u);if(p)return p}return o?o(c,u):u})}catch(i){if(r)throw i;return e}}function it(e,t={strict:!0}){return cr(e,t)}var fr=Symbol.for(\"better-auth:auth-query\");function Ee(e){let t=q(e);return Object.defineProperty(t,fr,{value:!0}),t}var dr=()=>typeof window>\"u\";function pr(e,t){return C(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}var Ie=(e,t,r,n)=>{let o=Ee({data:null,error:null,isPending:!0,isRefetching:!1,refetch:(p)=>l(p)});K(o,()=>he(o,pr));let s=0,l=async(p)=>{let h=++s;return new Promise((d)=>{let E=typeof n===\"function\"?n({data:o.get().data,error:o.get().error,isPending:o.get().isPending}):n;r(t,{...E,query:{...E?.query,...p?.query},async onSuccess(f){if(h===s){let R=o.get(),y=R.data!=null&&f.data!=null&&C(R.data,f.data)?R.data:f.data;o.set({data:y,error:null,isPending:!1,isRefetching:!1,refetch:o.value.refetch})}await E?.onSuccess?.(f)},async onError(f){let{request:R}=f,y=typeof R.retry===\"number\"?R.retry:R.retry?.attempts,T=R.retryAttempt||0;if(y&&T<y)return;if(h===s){let b=f.error.status===401;o.set({error:f.error,data:b?null:o.get().data,isPending:!1,isRefetching:!1,refetch:o.value.refetch})}await E?.onError?.(f)},async onRequest(f){if(h===s){let R=o.get();o.set({isPending:R.data===null,data:R.data,error:null,isRefetching:!0,refetch:o.value.refetch})}await E?.onRequest?.(f)}}).catch((f)=>{if(h!==s)return;o.set({error:f,data:o.get().data,isPending:!1,isRefetching:!1,refetch:o.value.refetch})}).finally(()=>{d(void 0)})})};e=Array.isArray(e)?e:[e];let a=!1,i=!1,c=!1,u=()=>{if(a){c=!0;return}a=!0,l().finally(()=>{a=!1;let p=c&&i;if(c=!1,p)u()})};return K(o,()=>{if(dr())return;i=!0;let p=!1,h,d=e.map((E)=>E.listen(()=>{if(p)l();else p=!0,clearTimeout(h),u()}));return h=setTimeout(()=>{p=!0,u()},0),()=>{i=!1;for(let E of d)E();clearTimeout(h)}}),o};var Ue=()=>Math.floor(Date.now()/1000),hr=5;function at(e){let{fetchSession:t,shouldPollSession:r=()=>!0,sessionSignal:n,options:o={}}=e,s=o.sessionOptions?.refetchInterval??0,l=o.sessionOptions?.refetchOnWindowFocus??!0,a=o.sessionOptions?.refetchWhenOffline??!1,i={isInitialized:!1,lastSessionRequest:0},c=()=>a||me().isOnline,u=(b)=>{if(!c())return;if(b?.event===\"storage\"){t();return}if(b?.event===\"poll\"){i.lastSessionRequest=Ue(),t();return}if(b?.event===\"visibilitychange\"){if(Ue()-i.lastSessionRequest<hr)return;i.lastSessionRequest=Ue(),t();return}t()},p=(b)=>{ce().post({event:\"session\",data:{trigger:b},clientId:Math.random().toString(36).substring(7)})},h=()=>{if(s&&s>0)i.pollInterval=setInterval(()=>{if(r())u({event:\"poll\"})},s*1000)},d=()=>{i.unsubscribeBroadcast=ce().subscribe(()=>{u({event:\"storage\"})})},E=()=>{if(!l)return;i.unsubscribeFocus=Pe().subscribe(()=>{u({event:\"visibilitychange\"})})},f=()=>{i.unsubscribeOnline=me().subscribe((b)=>{if(b)u({event:\"visibilitychange\"})})},R=()=>{i.unsubscribeSignal=n.listen(()=>{t()})};return{init:()=>{if(i.isInitialized)return;i.isInitialized=!0,h(),d(),E(),f(),R(),i.cleanupBroadcastSetup=ce().setup(),i.cleanupFocusSetup=Pe().setup(),i.cleanupOnlineSetup=me().setup()},cleanup:()=>{if(!i.isInitialized)return;if(i.pollInterval)clearInterval(i.pollInterval),i.pollInterval=void 0;if(i.unsubscribeBroadcast)i.unsubscribeBroadcast(),i.unsubscribeBroadcast=void 0;if(i.unsubscribeFocus)i.unsubscribeFocus(),i.unsubscribeFocus=void 0;if(i.unsubscribeOnline)i.unsubscribeOnline(),i.unsubscribeOnline=void 0;if(i.unsubscribeSignal)i.unsubscribeSignal(),i.unsubscribeSignal=void 0;if(i.cleanupBroadcastSetup)i.cleanupBroadcastSetup(),i.cleanupBroadcastSetup=void 0;if(i.cleanupFocusSetup)i.cleanupFocusSetup(),i.cleanupFocusSetup=void 0;if(i.cleanupOnlineSetup)i.cleanupOnlineSetup(),i.cleanupOnlineSetup=void 0;i.isInitialized=!1,i.lastSessionRequest=0},triggerRefetch:u,broadcastSessionUpdate:p}}var ye=Object.create(null),ee=(e)=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?ye:globalThis),U=new Proxy(ye,{get(e,t){return ee()[t]??ye[t]},has(e,t){return t in ee()||t in ye},set(e,t,r){let n=ee(!0);return n[t]=r,!0},deleteProperty(e,t){if(!t)return!1;let r=ee(!0);return delete r[t],!0},ownKeys(){let e=ee(!0);return Object.keys(e)}});var mr=U.NODE_ENV??\"\";function D(e,t){if(typeof process<\"u\"&&process.env)return process.env[e]??t;if(typeof Deno<\"u\")return Deno.env.get(e)??t;if(typeof Bun<\"u\")return Bun.env[e]??t;return t}var Er=Object.freeze({get BETTER_AUTH_SECRET(){return D(\"BETTER_AUTH_SECRET\")},get AUTH_SECRET(){return D(\"AUTH_SECRET\")},get BETTER_AUTH_TELEMETRY(){return D(\"BETTER_AUTH_TELEMETRY\")},get BETTER_AUTH_TELEMETRY_ID(){return D(\"BETTER_AUTH_TELEMETRY_ID\")},get NODE_ENV(){return D(\"NODE_ENV\",\"development\")},get PACKAGE_VERSION(){return D(\"PACKAGE_VERSION\",\"0.0.0\")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return D(\"BETTER_AUTH_TELEMETRY_ENDPOINT\",\"\")}});function gr(){let e=Object.getOwnPropertyDescriptor(Error,\"stackTraceLimit\");if(e===void 0)return Object.isExtensible(Error);return Object.prototype.hasOwnProperty.call(e,\"writable\")?e.writable:e.set!==void 0}function Rr(e){let t=e.split(`\n at `);if(t.length<=1)return e;return t.splice(1,1),t.join(`\n at `)}function br(e,t){class r extends e{#e;constructor(...n){if(gr()){let s=Error.stackTraceLimit;Error.stackTraceLimit=0;super(...n);Error.stackTraceLimit=s}else super(...n);let o=Error().stack;if(o)this.#e=Rr(o.replace(/^Error/,this.name))}get errorStack(){return this.#e}}return Object.defineProperty(r.prototype,\"constructor\",{get(){return t},enumerable:!1,configurable:!0}),r}var vr={OK:200,CREATED:201,ACCEPTED:202,NO_CONTENT:204,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,FOUND:302,SEE_OTHER:303,NOT_MODIFIED:304,TEMPORARY_REDIRECT:307,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,\"I'M_A_TEAPOT\":418,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE:431,UNAVAILABLE_FOR_LEGAL_REASONS:451,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511},Sr=class extends Error{status;body;headers;statusCode;constructor(e=\"INTERNAL_SERVER_ERROR\",t=void 0,r={},n=typeof e===\"number\"?e:vr[e]){super(t?.message,t?.cause?{cause:t.cause}:void 0);this.status=e,this.body=t,this.headers=r,this.statusCode=n,this.name=\"APIError\",this.status=e,this.headers=r,this.statusCode=n,this.body=t}};var Tr=br(Sr,Error);var G=class extends Error{constructor(e,t){super(e,t);this.name=\"BetterAuthError\",this.message=e,this.stack=\"\"}};var Or=47;function lt(e){let t=e.length;while(t>0&&e.charCodeAt(t-1)===Or)t--;return t===e.length?e:e.slice(0,t)}function Ar(e){try{return(lt(new URL(e).pathname)||\"/\")!==\"/\"}catch{throw new G(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function wr(e){try{let t=new URL(e);if(t.protocol!==\"http:\"&&t.protocol!==\"https:\")throw new G(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){if(t instanceof G)throw t;throw new G(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}}function re(e,t=\"/api/auth\"){if(wr(e),Ar(e))return e;let r=lt(e);if(!t||t===\"/\")return r;return t=t.startsWith(\"/\")?t:`/${t}`,`${r}${t}`}function ut(e,t){if(!e||e.trim()===\"\")return!1;if(t===\"proto\")return e===\"http\"||e===\"https\";if(t===\"host\"){if([/\\.\\./,/\\0/,/[\\s]/,/^[.]/,/[<>'\"]/,/javascript:/i,/file:/i,/data:/i].some((r)=>r.test(e)))return!1;return/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(e)||/^(\\d{1,3}\\.){3}\\d{1,3}(:[0-9]{1,5})?$/.test(e)||/^\\[[0-9a-fA-F:]+\\](:[0-9]{1,5})?$/.test(e)||/^localhost(:[0-9]{1,5})?$/i.test(e)}return!1}function ct(e,t,r,n,o){if(e)return re(e,t);if(n!==!1){let a=U.BETTER_AUTH_URL||U.NEXT_PUBLIC_BETTER_AUTH_URL||U.PUBLIC_BETTER_AUTH_URL||U.NUXT_PUBLIC_BETTER_AUTH_URL||U.NUXT_PUBLIC_AUTH_URL||(U.BASE_URL!==\"/\"?U.BASE_URL:void 0);if(a)return re(a,t)}let s=r?.headers.get(\"x-forwarded-host\"),l=r?.headers.get(\"x-forwarded-proto\");if(s&&l&&o){if(ut(l,\"proto\")&&ut(s,\"host\"))try{return re(`${l}://${s}`,t)}catch(a){}}if(r){let a=_r(r.url);if(!a)throw new G(\"Could not get origin from request. Please provide a valid base URL.\");return re(a,t)}if(typeof window<\"u\"&&window.location)return re(window.location.origin,t)}function _r(e){try{let t=new URL(e);return t.origin===\"null\"?null:t.origin}catch{return null}}var Pr=[\"javascript:\",\"data:\",\"vbscript:\"];function ft(e){let t;try{t=new URL(e)}catch{return!0}return!Pr.includes(t.protocol)}var dt={id:\"redirect\",name:\"Redirect\",hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&ft(e.data.url)){if(typeof window<\"u\"&&window.location){if(window.location)try{window.location.href=e.data.url}catch{}}}}}};var Lr=()=>typeof window>\"u\",Ir=de;function ht(e,t){if(typeof window>\"u\")return;let r=e.get();if(r.data!==null||t===null)return;e.set({...r,data:t,error:null,isPending:!1})}function pt(e){if(typeof e===\"object\"&&e!==null&&\"data\"in e&&\"error\"in e)return e;return{data:e,error:null}}function Ur(e){if(!e)return null;if(e.session===null&&e.user===null)return null;return e}function Nr(e,t){return C(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}function mt(e,t){let r=q(!1),n,o=0,s=0;r.listen(()=>{s++,o=0});let l=(d)=>u(d),a=Ee({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l});he(a,Nr);let i=async(d,E)=>{let f=a.value;if(a.set({...f,isPending:f.data===null,isRefetching:!0,error:null,refetch:l}),d.aborted)return\"aborted\";try{let R=await e(\"/get-session\",{method:\"GET\",query:E?.query,signal:d});if(d.aborted)return\"aborted\";let{data:y,error:T}=pt(R),b=\"fresh\";if(y?.needsRefresh)try{let m=await e(\"/get-session\",{method:\"POST\",signal:d});if(d.aborted)return\"aborted\";({data:y,error:T}=pt(m))}catch{if(d.aborted)return\"aborted\";b=\"stale\"}if(T){let m=a.value,F=T?.status===401;return a.set({data:F?null:m.data,error:T,isPending:!1,isRefetching:!1,refetch:l}),\"failed\"}let P=Ur(y),A=a.value,I=A.data!=null&&P!=null&&C(A.data,P)?A.data:P;return a.set({data:I,error:null,isPending:!1,isRefetching:!1,refetch:l}),b}catch(R){if(d.aborted)return\"aborted\";let y=a.value;return a.set({data:y.data,error:R,isPending:!1,isRefetching:!1,refetch:l}),\"failed\"}},c=()=>{let d=a.value.data?.session?.expiresAt,E=d instanceof Date?d.getTime():Number.POSITIVE_INFINITY;return Math.min(Date.now()+Ir,E)},u=(d)=>{o=0,n?.cancel();let E=new AbortController,f={cancel:()=>E.abort(),promise:Promise.resolve().then(()=>{if(E.signal.aborted)return\"aborted\";return i(E.signal,d)}),revision:s};n=f;let R=(y)=>{if(n!==f)return;if(n=void 0,y===\"fresh\"&&f.revision===s)o=c()};return f.promise.then(R,()=>R(\"failed\")),f.promise.then(()=>{return})},p=()=>{if(n?.revision===s)return n.promise.then(()=>{return});if(Date.now()<o)return Promise.resolve();return u()},h=()=>{};return K(a,()=>{let d;if(!Lr())d=setTimeout(()=>{p()},0);let E=at({fetchSession:u,shouldPollSession:()=>a.value.data!=null,sessionSignal:r,options:t});return E.init(),h=E.broadcastSessionUpdate,()=>{if(d)clearTimeout(d);E.cleanup()}}),{session:a,$sessionSignal:r,broadcastSessionUpdate:(d)=>h(d)}}function Ne(e){if(e===null||typeof e!==\"object\")return!1;let t=Object.getPrototypeOf(e);if(t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null)return!1;if(Symbol.iterator in e)return!1;if(Symbol.toStringTag in e)return Object.prototype.toString.call(e)===\"[object Module]\";return!0}function Ce(e,t,r=\".\",n){if(!Ne(t))return Ce(e,{},r,n);let o={...t};for(let s of Object.keys(e)){if(s===\"__proto__\"||s===\"constructor\")continue;let l=e[s];if(l===null||l===void 0)continue;if(n&&n(o,s,l,r))continue;if(Array.isArray(l)&&Array.isArray(o[s]))o[s]=[...l,...o[s]];else if(Ne(l)&&Ne(o[s]))o[s]=Ce(l,o[s],(r?`${r}.`:\"\")+s.toString(),n);else o[s]=l}return o}function De(e){return(...t)=>t.reduce((r,n)=>Ce(r,n,\"\",e),{})}var Et=De(),Gs=De((e,t,r)=>{if(e[t]!==void 0&&typeof r===\"function\")return e[t]=r(e[t]),!0}),Ys=De((e,t,r)=>{if(Array.isArray(e[t])&&typeof r===\"function\")return e[t]=r(e[t]),!0});var Cr=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r});this.status=e,this.statusText=t,this.error=r,Error.captureStackTrace(this,this.constructor)}},Dr=async(e,t)=>{let r=t||{},n={onRequest:[t===null||t===void 0?void 0:t.onRequest],onResponse:[t===null||t===void 0?void 0:t.onResponse],onSuccess:[t===null||t===void 0?void 0:t.onSuccess],onError:[t===null||t===void 0?void 0:t.onError],onRetry:[t===null||t===void 0?void 0:t.onRetry]};if(!t||!(t===null||t===void 0?void 0:t.plugins))return{url:e,options:r,hooks:n};for(let u of(t===null||t===void 0?void 0:t.plugins)||[]){var o,s,l,a,i;if(u.init){var c;let p=await((c=u.init)===null||c===void 0?void 0:c.call(u,e.toString(),r));r=p.options||r,e=p.url}n.onRequest.push((o=u.hooks)===null||o===void 0?void 0:o.onRequest),n.onResponse.push((s=u.hooks)===null||s===void 0?void 0:s.onResponse),n.onSuccess.push((l=u.hooks)===null||l===void 0?void 0:l.onSuccess),n.onError.push((a=u.hooks)===null||a===void 0?void 0:a.onError),n.onRetry.push((i=u.hooks)===null||i===void 0?void 0:i.onRetry)}return{url:e,options:r,hooks:n}},yt=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){if(this.options.shouldRetry)return Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t));return Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},xr=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){if(this.options.shouldRetry)return Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t));return Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function kr(e){if(typeof e===\"number\")return new yt({type:\"linear\",attempts:e,delay:1000});switch(e.type){case\"linear\":return new yt(e);case\"exponential\":return new xr(e);default:throw Error(\"Invalid retry strategy\")}}var Mr=[\"get\",\"post\",\"put\",\"patch\",\"delete\"];function ke(e){if(!e.startsWith(\"@\"))return{method:void 0,path:e};let t=e.indexOf(\"/\"),r=e.slice(1,t===-1?void 0:t);if(!Mr.includes(r))return{method:void 0,path:e};return{method:r,path:t===-1?e:e.slice(t+1)}}var Br=(e)=>e===\".\"||e===\"..\",qr=(e)=>e.split(\":\").map((t)=>encodeURIComponent(t)).join(\":\");function Hr(e,t){let r=t.get(e);if(r===void 0)return qr(e);if(Br(r))throw TypeError(\"Path parameters cannot be reserved path segments\");return encodeURIComponent(r)}function Fr(e,t){let{baseURL:r,params:n,query:o}=t||{query:{},params:{},baseURL:\"\"},s=e.startsWith(\"http\")?e.split(\"/\").slice(0,3).join(\"/\"):r||\"\",{path:l}=ke(e);if(l!==e)e=`/${l}`;if(!s.endsWith(\"/\"))s+=\"/\";let[a,i]=e.replace(s,\"\").split(\"?\"),c=new URLSearchParams(i);for(let[h,d]of Object.entries(o||{})){if(d==null)continue;let E;if(typeof d===\"string\")E=d;else if(Array.isArray(d)){for(let f of d)c.append(h,f);continue}else E=JSON.stringify(d);c.set(h,E)}let u=new Map;if(n)if(Array.isArray(n)){let h=a.split(\"/\").filter((d)=>d.startsWith(\":\"));for(let[d,E]of h.entries()){let f=n[d];u.set(E,String(f))}}else for(let[h,d]of Object.entries(n))u.set(`:${h}`,String(d));a=a.split(\"/\").map((h)=>Hr(h,u)).join(\"/\"),a=a.replace(/^\\/+/,\"\");let p=c.toString();if(p=p.length>0?`?${p}`.replace(/\\+/g,\"%20\"):\"\",!s.startsWith(\"http\"))return`${s}${a}${p}`;return new URL(`${a}${p}`,s)}var jr=async(e)=>{let t={},r=async(n)=>typeof n===\"function\"?await n():n;if(e===null||e===void 0?void 0:e.auth){if(e.auth.type===\"Bearer\"){let n=await r(e.auth.token);if(!n)return t;t.authorization=`Bearer ${n}`}else if(e.auth.type===\"Basic\"){let[n,o]=await Promise.all([r(e.auth.username),r(e.auth.password)]);if(!n||!o)return t;t.authorization=`Basic ${btoa(`${n}:${o}`)}`}else if(e.auth.type===\"Custom\"){let[n,o]=await Promise.all([r(e.auth.prefix),r(e.auth.value)]);if(!o)return t;t.authorization=`${n!==null&&n!==void 0?n:\"\"} ${o}`}}return t},Vr=/^application\\/(?:[\\w!#$%&*.^`~-]*\\+)?json(;.+)?$/i;function Wr(e){let t=e.headers.get(\"content-type\"),r=new Set([\"image/svg\",\"application/xml\",\"application/xhtml\",\"application/html\"]);if(!t)return\"json\";let n=t.split(\";\").shift()||\"\";if(Vr.test(n))return\"json\";if(r.has(n)||n.startsWith(\"text/\"))return\"text\";return\"blob\"}function Kr(e){try{return JSON.parse(e),!0}catch(t){return!1}}function vt(e){if(e===void 0)return!1;let t=typeof e;if(t===\"string\"||t===\"number\"||t===\"boolean\"||t===null)return!0;if(t!==\"object\")return!1;if(Array.isArray(e))return!0;if(e.buffer)return!1;return e.constructor&&e.constructor.name===\"Object\"||typeof e.toJSON===\"function\"}function gt(e){try{return JSON.parse(e)}catch(t){return e}}function Rt(e){return typeof e===\"function\"}function Gr(e){if(e===null||e===void 0?void 0:e.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<\"u\"&&Rt(globalThis.fetch))return globalThis.fetch;if(typeof window<\"u\"&&Rt(window.fetch))return window.fetch;throw Error(\"No fetch implementation found\")}function St(...e){let t={};for(let r of e){if(!r)continue;if(r instanceof Headers)r.forEach((n,o)=>{t[o]=n});else{let n=Array.isArray(r)?r:Object.entries(r);for(let[o,s]of n)if(s!==null&&s!==void 0)t[o]=s}}return t}async function Yr(e){let t=new Headers(St(e===null||e===void 0?void 0:e.headers,await jr(e)));if(!t.has(\"content-type\")){let r=Jr(e===null||e===void 0?void 0:e.body);if(r)t.set(\"content-type\",r)}return t}function Jr(e){if(vt(e))return\"application/json\";return null}function zr(e){let t=e.get(\"content-type\");return t?t.split(\";\")[0].trim().toLowerCase():null}function $r(e,t){let{body:r}=e;if(!r)return null;if(!vt(r))return r;if(typeof r===\"string\")return r;if(zr(t)===\"application/x-www-form-urlencoded\")return new URLSearchParams(r).toString();return JSON.stringify(r)}function Qr(e,t){if(t===null||t===void 0?void 0:t.method)return t.method.toUpperCase();let{method:r}=ke(e);if(r)return r.toUpperCase();return(t===null||t===void 0?void 0:t.body)?\"POST\":\"GET\"}function Xr(e,t){let r;if(!(e===null||e===void 0?void 0:e.signal)&&(e===null||e===void 0?void 0:e.timeout))r=setTimeout(()=>t===null||t===void 0?void 0:t.abort(),e===null||e===void 0?void 0:e.timeout);return{abortTimeout:r,clearTimeout:()=>{if(r)clearTimeout(r)}}}var Zr=class e extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2));this.issues=t,Object.setPrototypeOf(this,e.prototype)}};async function ne(e,t){let r=await e[\"~standard\"].validate(t);if(r.issues)throw new Zr(r.issues);return r.value}function oe(e){return oe=typeof Symbol==\"function\"&&typeof Symbol.iterator==\"symbol\"?function(t){return typeof t}:function(t){return t&&typeof Symbol==\"function\"&&t.constructor===Symbol&&t!==Symbol.prototype?\"symbol\":typeof t},oe(e)}function en(e,t){if(oe(e)!=\"object\"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||\"default\");if(oe(n)!=\"object\")return n;throw TypeError(\"@@toPrimitive must return a primitive value.\")}return(t===\"string\"?String:Number)(e)}function tn(e){var t=en(e,\"string\");return oe(t)==\"symbol\"?t:t+\"\"}function rn(e,t,r){return(t=tn(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function bt(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function v(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?bt(Object(r),!0).forEach(function(n){rn(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):bt(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}var xe=async(e,t)=>{var r,n,o;let{hooks:s,url:l,options:a}=await Dr(e,t),i=Gr(a),c=new AbortController,u=(r=a.signal)!==null&&r!==void 0?r:c.signal,p=Fr(l,a),h=await Yr(a),d=$r(a,h),E=Qr(l,a),f=v(v({},a),{},{url:p,headers:h,body:d,method:E,signal:u});for(let w of s.onRequest)if(w){let O=await w(f);if(typeof O===\"object\"&&O!==null)Object.assign(f,O)}if(\"pipeTo\"in f&&typeof f.pipeTo===\"function\"||typeof(t===null||t===void 0||(n=t.body)===null||n===void 0?void 0:n.pipe)===\"function\"){if(!(\"duplex\"in f))f.duplex=\"half\"}let{clearTimeout:R}=Xr(a,c),y=await i(f.url,f);R();let T={response:y,request:f};for(let w of s.onResponse)if(w){var b;let O=await w(v(v({},T),{},{response:(t===null||t===void 0||(b=t.hookOptions)===null||b===void 0?void 0:b.cloneResponse)?y.clone():y}));if(O instanceof Response)y=O;else if(typeof O===\"object\"&&O!==null)y=O.response}if(y.ok){if(f.method===\"HEAD\")return{data:\"\",error:null};let w=Wr(y),O={data:null,response:y,request:f};if(w===\"json\"||w===\"text\"){var P;let j=await y.text();O.data=await((P=f.jsonParser)!==null&&P!==void 0?P:gt)(j)}else O.data=await y[w]();if(f===null||f===void 0?void 0:f.output){if(f.output&&!f.disableValidation)O.data=await ne(f.output,O.data)}for(let j of s.onSuccess)if(j){var A;await j(v(v({},O),{},{response:(t===null||t===void 0||(A=t.hookOptions)===null||A===void 0?void 0:A.cloneResponse)?y.clone():y}))}if(t===null||t===void 0?void 0:t.throw)return O.data;return{data:O.data,error:null}}let I=(o=t===null||t===void 0?void 0:t.jsonParser)!==null&&o!==void 0?o:gt,m=await y.text(),F=Kr(m),Re=F?await I(m):null,Wt={response:y,responseText:m,request:f,error:v(v({},Re),{},{status:y.status,statusText:y.statusText})};for(let w of s.onError)if(w){var be;await w(v(v({},Wt),{},{response:(t===null||t===void 0||(be=t.hookOptions)===null||be===void 0?void 0:be.cloneResponse)?y.clone():y}))}if(t===null||t===void 0?void 0:t.retry){var ve;let w=kr(t.retry),O=(ve=t.retryAttempt)!==null&&ve!==void 0?ve:0;if(await w.shouldAttemptRetry(O,y)){for(let se of s.onRetry)if(se)await se(T);let j=w.getDelay(O);return await new Promise((se)=>setTimeout(se,j)),await xe(e,v(v({},t),{},{retryAttempt:O+1}))}}if(t===null||t===void 0?void 0:t.throw)throw new Cr(y.status,y.statusText,F?Re:m);return{data:null,error:v(v({},Re),{},{status:y.status,statusText:y.statusText})}},nn=(e)=>({id:\"apply-schema\",name:\"Apply Schema\",version:\"1.0.0\",async init(t,r){var n;let o=v(v({},r),e.query!==void 0&&{query:v(v({},e.query),r===null||r===void 0?void 0:r.query)}),s=((n=e.plugins)===null||n===void 0||(n=n.find((c)=>{var u;return((u=c.schema)===null||u===void 0?void 0:u.config)?t.startsWith(c.schema.config.baseURL||\"\")||t.startsWith(c.schema.config.prefix||\"\"):!1}))===null||n===void 0?void 0:n.schema)||e.schema;if(s){var l,a;let c=t;if((l=s.config)===null||l===void 0?void 0:l.prefix){if(c.startsWith(s.config.prefix)){if(c=c.replace(s.config.prefix,\"\"),s.config.baseURL)t=t.replace(s.config.prefix,s.config.baseURL)}}if((a=s.config)===null||a===void 0?void 0:a.baseURL){if(c.startsWith(s.config.baseURL))c=c.replace(s.config.baseURL,\"\")}if(c.startsWith(\"/\")&&c.charAt(1)===\"@\")c=c.substring(1);let u=s.schema[c];if(u){var i;let{method:p,path:h}=ke(c);if(p)t=t.slice(0,t.length-c.length)+h;let d=r===null||r===void 0?void 0:r.headers;if(u.headers&&!(r===null||r===void 0?void 0:r.disableValidation)){let f={};if(r===null||r===void 0?void 0:r.headers){if(r.headers instanceof Headers)r.headers.forEach((T,b)=>{f[b.toLowerCase()]=T});else if(typeof r.headers===\"object\"){for(let[T,b]of Object.entries(r.headers))if(b!==null&&b!==void 0)f[T.toLowerCase()]=b}}let R=await ne(u.headers,f),y={};for(let[T,b]of Object.entries(R))y[T.toLowerCase()]=b;d=y}let E=(i=u.method)!==null&&i!==void 0?i:p;if(o=v(v(v(v({},o),E!==void 0&&{method:E}),u.output!==void 0&&{output:u.output}),d!==void 0&&{headers:d}),!(r===null||r===void 0?void 0:r.disableValidation)){if(u.query){if(o.query=await ne(u.query,r===null||r===void 0?void 0:r.query),o.query!==null&&typeof o.query===\"object\"){let f=v({},e.query);for(let R of Object.keys(f))if((r===null||r===void 0?void 0:r.query)&&Object.prototype.hasOwnProperty.call(r.query,R))f[R]=r.query[R];o.query=v(v({},f),o.query)}}o=v(v({},o),{},{body:u.input?await ne(u.input,r===null||r===void 0?void 0:r.body):r===null||r===void 0?void 0:r.body,params:u.params?await ne(u.params,r===null||r===void 0?void 0:r.params):r===null||r===void 0?void 0:r.params})}return{url:t,options:o}}}return v({url:t},(r!==void 0||e.query!==void 0)&&{options:o})}}),Tt=(e)=>{async function t(r,n){let o=v(v(v({},e),n),{},{headers:St(e===null||e===void 0?void 0:e.headers,n===null||n===void 0?void 0:n.headers),plugins:[...(e===null||e===void 0?void 0:e.plugins)||[],nn(e||{}),...(n===null||n===void 0?void 0:n.plugins)||[]]});if(e===null||e===void 0?void 0:e.catchAllError)try{return await xe(r,o)}catch(s){return{data:null,error:{status:500,statusText:\"Fetch Error\",message:\"Fetch related error. Captured by catchAllError option. See error property for more details.\",error:s}}}return await xe(r,o)}return t};var on=(e)=>{if(typeof process>\"u\")return;let t=e??\"/api/auth\";if(process.env.NEXT_PUBLIC_AUTH_URL)return process.env.NEXT_PUBLIC_AUTH_URL;if(typeof window>\"u\"){if(process.env.NEXTAUTH_URL)try{return process.env.NEXTAUTH_URL}catch{}if(process.env.VERCEL_URL)try{let r=process.env.VERCEL_URL.startsWith(\"http\")?\"\":\"https://\";return`${new URL(`${r}${process.env.VERCEL_URL}`).origin}${t}`}catch{}}},Ot=(e,t)=>{let r=\"credentials\"in Request.prototype,n=ct(e?.baseURL,e?.basePath,void 0,t)??on(e?.basePath)??\"/api/auth\",o=e?.plugins?.flatMap((m)=>m.fetchPlugins).filter((m)=>m!==void 0)||[],s={id:\"lifecycle-hooks\",name:\"lifecycle-hooks\",hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:l,onError:a,onRequest:i,onResponse:c,...u}=e?.fetchOptions||{},p=Tt({baseURL:n,...r?{credentials:\"include\"}:{},method:\"GET\",jsonParser(m){if(!m)return null;return it(m,{strict:!1})},customFetchImpl:fetch,...u,plugins:[s,...u.plugins||[],...e?.disableDefaultFetchPlugins?[]:[dt],...o]}),{$sessionSignal:h,session:d,broadcastSessionUpdate:E}=mt(p,e),f=!1,R=(m)=>{if(f||m===null)return;f=!0,ht(d,m)},y=e?.plugins||[],T={},b={$sessionSignal:h,session:d},P={\"/sign-out\":\"POST\",\"/revoke-sessions\":\"POST\",\"/revoke-other-sessions\":\"POST\",\"/delete-user\":\"POST\"},A=[{signal:\"$sessionSignal\",matcher(m){return m===\"/sign-out\"||m===\"/update-user\"||m===\"/update-session\"||m===\"/sign-up/email\"||m===\"/sign-in/email\"||m===\"/delete-user\"||m===\"/verify-email\"||m===\"/revoke-sessions\"||m===\"/revoke-session\"||m===\"/revoke-other-sessions\"||m===\"/change-email\"||m===\"/change-password\"},callback(m){if(m===\"/sign-out\")E(\"signout\");else if(m===\"/update-user\"||m===\"/update-session\")E(\"updateUser\")}}];for(let m of y){if(m.getAtoms)Object.assign(b,m.getAtoms?.(p));if(m.pathMethods)Object.assign(P,m.pathMethods);if(m.atomListeners)A.push(...m.atomListeners)}let I={notify:(m)=>{b[m].set(!b[m].get())},listen:(m,F)=>{b[m].subscribe(F)},atoms:b};for(let m of y)if(m.getActions)T=Et(m.getActions?.(p,I,e)??{},T);return{get baseURL(){return n},pluginsActions:T,pluginsAtoms:b,pluginPathMethods:P,atomListeners:A,hydrateSession:R,$sessionSignal:h,$fetch:p,$store:I}};function At(e){return typeof e===\"object\"&&e!==null&&\"get\"in e&&typeof e.get===\"function\"&&\"lc\"in e&&typeof e.lc===\"number\"}function wt(e){return e.charAt(0).toUpperCase()+e.slice(1)}var sn=/[\\p{Ll}\\d]+|\\p{Lu}+(?!\\p{Ll})|\\p{Lu}[\\p{Ll}\\d]+|\\p{Lo}+/gu,an=/['\\u2019]/g;function un(e){return e.replace(an,\"\").match(sn)??[]}function _t(e){return un(e).map((t)=>t.toLowerCase()).join(\"-\")}function ln(e,t,r){let n=t[e],{fetchOptions:o,query:s,...l}=r||{};if(n)return n;if(o?.method)return o.method;if(l&&Object.keys(l).length>0)return\"POST\";return\"GET\"}function Pt(e,t,r,n,o){function s(l=[]){return new Proxy(function(){},{get(a,i){if(typeof i!==\"string\")return;if(i===\"then\"||i===\"catch\"||i===\"finally\")return;let c=[...l,i],u=e;for(let p of c)if(u&&typeof u===\"object\"&&p in u)u=u[p];else{u=void 0;break}if(typeof u===\"function\")return u;if(At(u))return u;return s(c)},apply:async(a,i,c)=>{let u=\"/\"+l.map(_t).join(\"/\"),p=c[0]||{},h=c[1]||{},{query:d,fetchOptions:E,...f}=p,R={...h,...E},y=ln(u,r,p);return await t(u,{...R,body:y===\"GET\"?void 0:{...f,...R?.body||{}},query:d||R?.query,method:y,async onSuccess(T){if(await R?.onSuccess?.(T),!o||R.disableSignal)return;let b=o.filter((A)=>A.matcher(u));if(!b.length)return;let P=new Set;for(let A of b){let I=n[A.signal];if(!I)return;if(P.has(A.signal))continue;P.add(A.signal);let m=I.get();setTimeout(()=>{I.set(!m)},10),A.callback?.(u)}}})}})}return s()}function Me(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:n,hydrateSession:o,$fetch:s,atomListeners:l,$store:a}=Ot(e),i={};for(let[c,u]of Object.entries(n))i[`use${wt(c)}`]=u;return Pt({...r,...i,hydrateSession:o,$fetch:s,$store:a},s,t,n,l)}var cn=(e,{$listPasskeys:t,$store:r})=>({signIn:{passkey:async(s,l)=>{let a=await e(\"/passkey/generate-authenticate-options\",{method:\"GET\",throw:!1});if(!a.data)return a;let i=a.data.extensions||s?.extensions?{...a.data.extensions||{},...s?.extensions||{}}:void 0,c;try{c=await Qe({optionsJSON:{...a.data,extensions:i},useBrowserAutofill:s?.autoFill})}catch(u){return{data:null,error:{code:u instanceof S?u.code:\"AUTH_CANCELLED\",message:x.AUTH_CANCELLED.message,status:400,statusText:\"BAD_REQUEST\"}}}try{let{clientExtensionResults:u,...p}=c,h=await e(\"/passkey/verify-authentication\",{body:{response:p},...s?.fetchOptions,...l,method:\"POST\",throw:!1});if(t.set(Math.random()),r.notify(\"$sessionSignal\"),s?.returnWebAuthnResponse)return{...h,webauthn:{response:c,clientExtensionResults:u}};return h}catch(u){return console.error(\"[Better Auth] Error verifying passkey\",u),{data:null,error:{code:\"AUTH_CANCELLED\",message:x.AUTH_CANCELLED.message,status:400,statusText:\"BAD_REQUEST\"}}}}},passkey:{addPasskey:async(s,l)=>{let a=await e(\"/passkey/generate-register-options\",{method:\"GET\",query:{...s?.authenticatorAttachment&&{authenticatorAttachment:s.authenticatorAttachment},...s?.name&&{name:s.name},...s?.context&&{context:s.context}},throw:!1});if(!a.data)return a;try{let i=a.data.extensions||s?.extensions?{...a.data.extensions||{},...s?.extensions||{}}:void 0,c=await Je({optionsJSON:{...a.data,extensions:i},useAutoRegister:s?.useAutoRegister}),{clientExtensionResults:u,...p}=c,h=await e(\"/passkey/verify-registration\",{...s?.fetchOptions,...l,body:{response:p,name:s?.name,...s?.createSession&&{createSession:!0}},method:\"POST\",throw:!1});if(!h.data)return h;if(t.set(Math.random()),h.data.session)r.notify(\"$sessionSignal\");if(s?.returnWebAuthnResponse)return{...h,webauthn:{response:c,clientExtensionResults:u}};return h}catch(i){if(i instanceof S){if(i.code===\"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED\")return{data:null,error:{code:i.code,message:x.PREVIOUSLY_REGISTERED.message,status:400,statusText:\"BAD_REQUEST\"}};if(i.code===\"ERROR_CEREMONY_ABORTED\")return{data:null,error:{code:i.code,message:x.REGISTRATION_CANCELLED.message,status:400,statusText:\"BAD_REQUEST\"}};return{data:null,error:{code:i.code,message:i.message,status:400,statusText:\"BAD_REQUEST\"}}}return{data:null,error:{code:\"UNKNOWN_ERROR\",message:i instanceof Error?i.message:x.UNKNOWN_ERROR.message,status:500,statusText:\"INTERNAL_SERVER_ERROR\"}}}}},$Infer:{}}),Lt=()=>{let e=q();return{id:\"passkey\",version:Ke,$InferServerPlugin:{},getActions:(t,r)=>cn(t,{$listPasskeys:e,$store:r}),getAtoms(t){return{listPasskeys:Ie(e,\"/passkey/list-user-passkeys\",t,{method:\"GET\"}),$listPasskeys:e}},pathMethods:{\"/passkey/register\":\"POST\",\"/passkey/authenticate\":\"POST\"},atomListeners:[{matcher(t){return t===\"/passkey/verify-registration\"||t===\"/passkey/delete-passkey\"||t===\"/passkey/update-passkey\"||t===\"/sign-out\"},signal:\"$listPasskeys\"},{matcher:(t)=>t===\"/passkey/verify-authentication\",signal:\"$sessionSignal\"}],$ERROR_CODES:x}};var It=ie({OTP_EXPIRED:\"OTP expired\",INVALID_OTP:\"Invalid OTP\",TOO_MANY_ATTEMPTS:\"Too many attempts\"});var Be=()=>({id:\"email-otp\",version:Ze,$InferServerPlugin:{},atomListeners:[{matcher:(e)=>e===\"/email-otp/verify-email\"||e===\"/sign-in/email-otp\"||e===\"/email-otp/request-email-change\",signal:\"$sessionSignal\"}],$ERROR_CODES:It});var Y=\"/api/email/auth\";function Mn(){return globalThis.location}function Bn(){return`${Mn()?.origin??\"http://localhost\"}${Y}`}function Ut(e){return Me({baseURL:Bn(),...e?{fetchOptions:{signal:e}}:{},plugins:[Be(),Lt()]})}var Nt=Ut();function qn(e){return typeof e===\"object\"&&e!==null?e:void 0}function Hn(e){let t=qn(e);if(!t||typeof t.authenticated!==\"boolean\"||typeof t.enabled!==\"boolean\"||t.email!==void 0&&typeof t.email!==\"string\"||t.passkeysEnabled!==void 0&&typeof t.passkeysEnabled!==\"boolean\")throw Error(\"Auth status returned an invalid response\");return{authenticated:t.authenticated,enabled:t.enabled,...typeof t.email===\"string\"?{email:t.email}:{},...typeof t.passkeysEnabled===\"boolean\"?{passkeysEnabled:t.passkeysEnabled}:{}}}var J;function Fn(e){return e instanceof DOMException&&e.name===\"AbortError\"}function jn(e){J?.cancel();let t=Symbol(\"passkey-operation\"),r=new AbortController,n=!1,o=()=>{if(J?.id!==t)return;J=void 0,n=!0,r.abort(),V.cancelCeremony()};return J={id:t,cancel:o},{result:e(Ut(r.signal)).then((l)=>!n&&l.error===null).catch((l)=>{if(n||Fn(l))return!1;throw l}).finally(()=>{if(J?.id===t)J=void 0}),cancel:o}}function Ct(e=!1){return jn((t)=>t.signIn.passkey({autoFill:e}))}async function Dt(){let e=await fetch(`${Y}/status`,{credentials:\"include\"});if(!e.ok)throw Error(`Auth status failed with ${e.status}`);return Hn(await e.json())}async function xt(e){return(await Nt.emailOtp.sendVerificationOtp({email:e,type:\"sign-in\"})).error===null}async function kt(e,t,r){return(await Nt.signIn.emailOtp({email:e,otp:t,name:r})).error===null}var He=document.querySelector(\"#email-form\"),Fe=document.querySelector(\"#code-form\"),Ht=document.querySelector(\"#email\"),je=document.querySelector(\"#code\"),Mt=document.querySelector(\"#email-submit\"),Bt=document.querySelector(\"#code-submit\"),Ft=document.querySelector(\"#passkey-submit\"),Vn=document.querySelector(\"#back\"),qt=document.querySelector(\"#msg\"),z=\"\",H,jt=document.body.dataset.returnTo||\"/\";if(window.location.pathname!==Y)jt=`${window.location.pathname}${window.location.search}${window.location.hash}`;function N(e,t=!1){qt.textContent=e,qt.className=`msg${t?\" error\":\"\"}`}function Ve(){let e=H;H=void 0,e?.cancel()}function We(){N(\"Signed in. Loading.\"),window.location.replace(jt)}function Vt(e){Ve();let t=Ct(e);H=t,t.result.then((r)=>{if(H!==t)return;if(H=void 0,r)We();else if(!e)N(\"Unable to sign in with a passkey. Use email recovery instead.\",!0)}).catch(()=>{if(H!==t)return;if(H=void 0,!e)N(\"Unable to sign in with a passkey. Use email recovery instead.\",!0)})}Dt().then(async(e)=>{if(e.authenticated){We();return}if(!e.passkeysEnabled)return;if(Ft.hidden=!1,typeof PublicKeyCredential>\"u\"||typeof PublicKeyCredential.isConditionalMediationAvailable!==\"function\"||!await PublicKeyCredential.isConditionalMediationAvailable())return;Vt(!0)}).catch(()=>{return});Ft.addEventListener(\"click\",()=>{N(\"\"),Vt(!1)});He.addEventListener(\"submit\",(e)=>{if(e.preventDefault(),z=Ht.value.trim(),!z)return;Ve(),Mt.disabled=!0,N(\"Sending.\"),xt(z).then((t)=>{if(!t)throw Error(\"OTP request failed\");He.classList.add(\"hidden\"),Fe.classList.remove(\"hidden\"),je.focus(),N(`If ${z} is authorized, a verification code is on its way.`)}).catch(()=>N(\"Could not send a code. Check the address and try again.\",!0)).finally(()=>{Mt.disabled=!1})});Fe.addEventListener(\"submit\",(e)=>{e.preventDefault();let t=je.value.trim();if(!t)return;Bt.disabled=!0,N(\"Verifying.\"),kt(z,t,z.split(\"@\")[0]||\"User\").then((r)=>{if(!r)throw Error(\"OTP verification failed\");We()}).catch(()=>{N(\"That code was not accepted. Try again.\",!0),Bt.disabled=!1})});Vn.addEventListener(\"click\",()=>{Fe.classList.add(\"hidden\"),He.classList.remove(\"hidden\"),je.value=\"\",N(\"\"),Ht.focus()});window.addEventListener(\"pagehide\",Ve,{once:!0});})();\n";
2
+ export const LOGIN_CLIENT_SOURCE = "(()=>{var Eu=Object.defineProperty;var ku=(e)=>e;function Ou(e,t){this[e]=ku.bind(null,t)}var Rn=(e,t)=>{for(var r in t)Eu(e,r,{get:t[r],enumerable:!0,configurable:!0,set:Ou.bind(t,r)})};var Au=(e,t,r)=>()=>{if(e)try{t=e(e=0)}catch(n){r=[n]}if(r)throw r[0];return t};var w=((e)=>typeof require<\"u\"?require:typeof Proxy<\"u\"?new Proxy(e,{get:(t,r)=>(typeof require<\"u\"?require:t)[r]}):e)(function(e){if(typeof require<\"u\")return require.apply(this,arguments);throw Error('Dynamic require of \"'+e+'\" is not supported')});var Lo={};Rn(Lo,{TextDecoder:()=>Io,TextEncoder:()=>$o,_extend:()=>zr,callbackify:()=>zo,callbackifyOnRejected:()=>$r,debuglog:()=>Kf,default:()=>ap,deprecate:()=>Hf,format:()=>Ar,inherits:()=>Ao,inspect:()=>ve,isArray:()=>Eo,isBoolean:()=>Pr,isBuffer:()=>op,isDate:()=>Or,isError:()=>kt,isFunction:()=>Ot,isNull:()=>Pt,isNullOrUndefined:()=>tp,isNumber:()=>ko,isObject:()=>Ne,isPrimitive:()=>np,isRegExp:()=>Et,isString:()=>Rt,isSymbol:()=>rp,isUndefined:()=>Le,log:()=>Oo,promisify:()=>Ro,types:()=>ep});function Ar(e,...t){if(!Rt(e)){var r=[e];for(var n=0;n<t.length;n++)r.push(ve(t[n]));return r.join(\" \")}var n=0,o=t.length,i=String(e).replace(qf,function(a){if(a===\"%%\")return\"%\";if(n>=o)return a;switch(a){case\"%s\":return String(t[n++]);case\"%d\":return Number(t[n++]);case\"%j\":try{return JSON.stringify(t[n++])}catch(c){return\"[Circular]\"}default:return a}});for(var s=t[n];n<o;s=t[++n])if(Pt(s)||!Ne(s))i+=\" \"+s;else i+=\" \"+ve(s);return i}function Hf(e,t){if(typeof process>\"u\"||process?.noDeprecation===!0)return e;var r=!1;function n(...o){if(!r){if(process.throwDeprecation)throw Error(t);else if(process.traceDeprecation)console.trace(t);else console.error(t);r=!0}return e.apply(this,...o)}return n}function Jf(e,t){var r=ve.styles[t];if(r)return\"\\x1B[\"+ve.colors[r][0]+\"m\"+e+\"\\x1B[\"+ve.colors[r][1]+\"m\";else return e}function Gf(e,t){return e}function Wf(e){var t={};return e.forEach(function(r,n){t[r]=!0}),t}function At(e,t,r){if(e.customInspect&&t&&Ot(t.inspect)&&t.inspect!==ve&&!(t.constructor&&t.constructor.prototype===t)){var n=t.inspect(r,e);if(!Rt(n))n=At(e,n,r);return n}var o=Yf(e,t);if(o)return o;var i=Object.keys(t),s=Wf(i);if(e.showHidden)i=Object.getOwnPropertyNames(t);if(kt(t)&&(i.indexOf(\"message\")>=0||i.indexOf(\"description\")>=0))return Tr(t);if(i.length===0){if(Ot(t)){var a=t.name?\": \"+t.name:\"\";return e.stylize(\"[Function\"+a+\"]\",\"special\")}if(Et(t))return e.stylize(RegExp.prototype.toString.call(t),\"regexp\");if(Or(t))return e.stylize(Date.prototype.toString.call(t),\"date\");if(kt(t))return Tr(t)}var c=\"\",u=!1,l=[\"{\",\"}\"];if(Eo(t))u=!0,l=[\"[\",\"]\"];if(Ot(t)){var p=t.name?\": \"+t.name:\"\";c=\" [Function\"+p+\"]\"}if(Et(t))c=\" \"+RegExp.prototype.toString.call(t);if(Or(t))c=\" \"+Date.prototype.toUTCString.call(t);if(kt(t))c=\" \"+Tr(t);if(i.length===0&&(!u||t.length==0))return l[0]+c+l[1];if(r<0)if(Et(t))return e.stylize(RegExp.prototype.toString.call(t),\"regexp\");else return e.stylize(\"[Object]\",\"special\");e.seen.push(t);var d;if(u)d=Xf(e,t,r,s,i);else d=i.map(function(m){return kr(e,t,r,s,m,u)});return e.seen.pop(),Qf(d,c,l)}function Yf(e,t){if(Le(t))return e.stylize(\"undefined\",\"undefined\");if(Rt(t)){var r=\"'\"+JSON.stringify(t).replace(/^\"|\"$/g,\"\").replace(/'/g,\"\\\\'\").replace(/\\\\\"/g,'\"')+\"'\";return e.stylize(r,\"string\")}if(ko(t))return e.stylize(\"\"+t,\"number\");if(Pr(t))return e.stylize(\"\"+t,\"boolean\");if(Pt(t))return e.stylize(\"null\",\"null\")}function Tr(e){return\"[\"+Error.prototype.toString.call(e)+\"]\"}function Xf(e,t,r,n,o){var i=[];for(var s=0,a=t.length;s<a;++s)if(Po(t,String(s)))i.push(kr(e,t,r,n,String(s),!0));else i.push(\"\");return o.forEach(function(c){if(!c.match(/^\\d+$/))i.push(kr(e,t,r,n,c,!0))}),i}function kr(e,t,r,n,o,i){var s,a,c;if(c=Object.getOwnPropertyDescriptor(t,o)||{value:t[o]},c.get)if(c.set)a=e.stylize(\"[Getter/Setter]\",\"special\");else a=e.stylize(\"[Getter]\",\"special\");else if(c.set)a=e.stylize(\"[Setter]\",\"special\");if(!Po(n,o))s=\"[\"+o+\"]\";if(!a)if(e.seen.indexOf(c.value)<0){if(Pt(r))a=At(e,c.value,null);else a=At(e,c.value,r-1);if(a.indexOf(`\n`)>-1)if(i)a=a.split(`\n`).map(function(u){return\" \"+u}).join(`\n`).slice(2);else a=`\n`+a.split(`\n`).map(function(u){return\" \"+u}).join(`\n`)}else a=e.stylize(\"[Circular]\",\"special\");if(Le(s)){if(i&&o.match(/^\\d+$/))return a;if(s=JSON.stringify(\"\"+o),s.match(/^\"([a-zA-Z_][a-zA-Z_0-9]*)\"$/))s=s.slice(1,-1),s=e.stylize(s,\"name\");else s=s.replace(/'/g,\"\\\\'\").replace(/\\\\\"/g,'\"').replace(/(^\"|\"$)/g,\"'\"),s=e.stylize(s,\"string\")}return s+\": \"+a}function Qf(e,t,r){var n=0,o=e.reduce(function(i,s){if(n++,s.indexOf(`\n`)>=0)n++;return i+s.replace(/\\u001b\\[\\d\\d?m/g,\"\").length+1},0);if(o>60)return r[0]+(t===\"\"?\"\":t+`\n `)+\" \"+e.join(`,\n `)+\" \"+r[1];return r[0]+t+\" \"+e.join(\", \")+\" \"+r[1]}function Eo(e){return Array.isArray(e)}function Pr(e){return typeof e===\"boolean\"}function Pt(e){return e===null}function tp(e){return e==null}function ko(e){return typeof e===\"number\"}function Rt(e){return typeof e===\"string\"}function rp(e){return typeof e===\"symbol\"}function Le(e){return e===void 0}function Et(e){return Ne(e)&&Rr(e)===\"[object RegExp]\"}function Ne(e){return typeof e===\"object\"&&e!==null}function Or(e){return Ne(e)&&Rr(e)===\"[object Date]\"}function kt(e){return Ne(e)&&(Rr(e)===\"[object Error]\"||e instanceof Error)}function Ot(e){return typeof e===\"function\"}function np(e){return e===null||typeof e===\"boolean\"||typeof e===\"number\"||typeof e===\"string\"||typeof e===\"symbol\"||typeof e>\"u\"}function op(e){return e instanceof Buffer}function Rr(e){return Object.prototype.toString.call(e)}function Er(e){return e<10?\"0\"+e.toString(10):e.toString(10)}function sp(){var e=new Date,t=[Er(e.getHours()),Er(e.getMinutes()),Er(e.getSeconds())].join(\":\");return[e.getDate(),ip[e.getMonth()],t].join(\" \")}function Oo(...e){console.log(\"%s - %s\",sp(),Ar.apply(null,e))}function Ao(e,t){if(t)e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}function zr(e,t){if(!t||!Ne(t))return e;var r=Object.keys(t),n=r.length;while(n--)e[r[n]]=t[r[n]];return e}function Po(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function $r(e,t){if(!e){var r=Error(\"Promise was rejected with a falsy value\");r.reason=e,e=r}return t(e)}function zo(e){if(typeof e!==\"function\")throw TypeError('The \"original\" argument must be of type Function');function t(...r){var n=r.pop();if(typeof n!==\"function\")throw TypeError(\"The last argument must be of type Function\");var o=this,i=function(...s){return n.apply(o,...s)};e.apply(this,r).then(function(s){process.nextTick(i.bind(null,null,s))},function(s){process.nextTick($r.bind(null,s,i))})}return Object.setPrototypeOf(t,Object.getPrototypeOf(e)),Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)),t}var qf,Kf,ve,ep=()=>{},ip,Ro,$o,Io,ap;var No=Au(()=>{qf=/%[sdj%]/g;Kf=((e={},t={},r)=>((r=typeof process<\"u\"&&!1)&&(r=r.replace(/[|\\\\{}()[\\]^$+?.]/g,\"\\\\$&\").replace(/\\*/g,\".*\").replace(/,/g,\"$|^\").toUpperCase()),t=new RegExp(\"^\"+r+\"$\",\"i\"),(n)=>{if(n=n.toUpperCase(),!e[n])if(t.test(n))e[n]=function(...o){console.error(\"%s: %s\",n,pid,Ar.apply(null,...o))};else e[n]=function(){};return e[n]}))(),ve=((e)=>(e.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},e.styles={special:\"cyan\",number:\"yellow\",boolean:\"yellow\",undefined:\"grey\",null:\"bold\",string:\"green\",date:\"magenta\",regexp:\"red\"},e.custom=Symbol.for(\"nodejs.util.inspect.custom\"),e))(function(e,t,...r){var n={seen:[],stylize:Gf};if(r.length>=1)n.depth=r[0];if(r.length>=2)n.colors=r[1];if(Pr(t))n.showHidden=t;else if(t)zr(n,t);if(Le(n.showHidden))n.showHidden=!1;if(Le(n.depth))n.depth=2;if(Le(n.colors))n.colors=!1;if(n.colors)n.stylize=Jf;return At(n,e,n.depth)});ip=[\"Jan\",\"Feb\",\"Mar\",\"Apr\",\"May\",\"Jun\",\"Jul\",\"Aug\",\"Sep\",\"Oct\",\"Nov\",\"Dec\"];Ro=((e)=>(e.custom=Symbol.for(\"nodejs.util.promisify.custom\"),e))(function(e){if(typeof e!==\"function\")throw TypeError('The \"original\" argument must be of type Function');if(kCustomPromisifiedSymbol&&e[kCustomPromisifiedSymbol]){var t=e[kCustomPromisifiedSymbol];if(typeof t!==\"function\")throw TypeError('The \"nodejs.util.promisify.custom\" argument must be of type Function');return Object.defineProperty(t,kCustomPromisifiedSymbol,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(...r){var n,o,i=new Promise(function(s,a){n=s,o=a});r.push(function(s,a){if(s)o(s);else n(a)});try{e.apply(this,r)}catch(s){o(s)}return i}if(Object.setPrototypeOf(t,Object.getPrototypeOf(e)),kCustomPromisifiedSymbol)Object.defineProperty(t,kCustomPromisifiedSymbol,{value:t,enumerable:!1,writable:!1,configurable:!0});return Object.defineProperties(t,Object.getOwnPropertyDescriptors(e))});({TextEncoder:$o,TextDecoder:Io}=globalThis),ap={TextEncoder:$o,TextDecoder:Io,promisify:Ro,log:Oo,inherits:Ao,_extend:zr,callbackifyOnRejected:$r,callbackify:zo}});function ft(e){return Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{code:t,message:r,toString:()=>t}]))}var he=ft({CHALLENGE_NOT_FOUND:\"Challenge not found\",YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY:\"You are not allowed to register this passkey\",FAILED_TO_VERIFY_REGISTRATION:\"Failed to verify registration\",PASSKEY_NOT_FOUND:\"Passkey not found\",AUTHENTICATION_FAILED:\"Authentication failed\",UNABLE_TO_CREATE_SESSION:\"Unable to create session\",USER_NOT_FOUND:\"User not found\",FAILED_TO_UPDATE_PASSKEY:\"Failed to update passkey\",PREVIOUSLY_REGISTERED:\"Previously registered\",REGISTRATION_CANCELLED:\"Registration cancelled\",AUTH_CANCELLED:\"Auth cancelled\",UNKNOWN_ERROR:\"Unknown error\",SESSION_REQUIRED:\"Passkey registration requires an authenticated session\",RESOLVE_USER_REQUIRED:\"Passkey registration requires either an authenticated session or a resolveUser callback when requireSession is false\",RESOLVED_USER_INVALID:\"Resolved user is invalid\"}),zn=\"1.7.6\";function J(e){let t=new Uint8Array(e),r=\"\";for(let o of t)r+=String.fromCharCode(o);return btoa(r).replace(/\\+/g,\"-\").replace(/\\//g,\"_\").replace(/=/g,\"\")}function ge(e){let t=e.replace(/-/g,\"+\").replace(/_/g,\"/\"),r=(4-t.length%4)%4,n=t.padEnd(t.length+r,\"=\"),o=atob(n),i=new ArrayBuffer(o.length),s=new Uint8Array(i);for(let a=0;a<o.length;a++)s[a]=o.charCodeAt(a);return i}function ye(){return Pu.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential===\"function\")}var Pu={stubThis:(e)=>e};function pt(e){let{id:t}=e;return{...e,id:ge(t),transports:e.transports}}function dt(e){return e===\"localhost\"||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}class L extends Error{constructor({message:e,code:t,cause:r,name:n}){super(e,{cause:r});Object.defineProperty(this,\"code\",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=n??r.name,this.code=t}}function $n({error:e,options:t}){let{publicKey:r}=t;if(!r)throw Error(\"options was missing required publicKey property\");if(e.name===\"AbortError\"){if(t.signal instanceof AbortSignal)return new L({message:\"Registration ceremony was sent an abort signal\",code:\"ERROR_CEREMONY_ABORTED\",cause:e})}else if(e.name===\"ConstraintError\"){if(r.authenticatorSelection?.requireResidentKey===!0)return new L({message:\"Discoverable credentials were required but no available authenticator supported it\",code:\"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT\",cause:e});else if(t.mediation===\"conditional\"&&r.authenticatorSelection?.userVerification===\"required\")return new L({message:\"User verification was required during automatic registration but it could not be performed\",code:\"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE\",cause:e});else if(r.authenticatorSelection?.userVerification===\"required\")return new L({message:\"User verification was required but no available authenticator supported it\",code:\"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT\",cause:e})}else if(e.name===\"InvalidStateError\")return new L({message:\"The authenticator was previously registered\",code:\"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED\",cause:e});else if(e.name===\"NotAllowedError\")return new L({message:e.message,code:\"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY\",cause:e});else if(e.name===\"NotSupportedError\"){if(r.pubKeyCredParams.filter((o)=>o.type===\"public-key\").length===0)return new L({message:'No entry in pubKeyCredParams was of type \"public-key\"',code:\"ERROR_MALFORMED_PUBKEYCREDPARAMS\",cause:e});return new L({message:\"No available authenticator supported any of the specified pubKeyCredParams algorithms\",code:\"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG\",cause:e})}else if(e.name===\"SecurityError\"){let n=globalThis.location.hostname;if(!dt(n))return new L({message:`${globalThis.location.hostname} is an invalid domain`,code:\"ERROR_INVALID_DOMAIN\",cause:e});else if(r.rp.id!==n)return new L({message:`The RP ID \"${r.rp.id}\" is invalid for this domain`,code:\"ERROR_INVALID_RP_ID\",cause:e})}else if(e.name===\"TypeError\"){if(r.user.id.byteLength<1||r.user.id.byteLength>64)return new L({message:\"User ID was not between 1 and 64 characters\",code:\"ERROR_INVALID_USER_ID_LENGTH\",cause:e})}else if(e.name===\"UnknownError\")return new L({message:\"The authenticator was unable to process the specified options, or could not create a new credential\",code:\"ERROR_AUTHENTICATOR_GENERAL_ERROR\",cause:e});return e}class In{constructor(){Object.defineProperty(this,\"controller\",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=Error(\"Cancelling existing WebAuthn API call for new one\");t.name=\"AbortError\",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(\"Manually cancelling existing WebAuthn API call\");e.name=\"AbortError\",this.controller.abort(e),this.controller=void 0}}}var Pe=new In;var Ru=[\"cross-platform\",\"platform\"];function mt(e){if(!e)return;if(Ru.indexOf(e)<0)return;return e}async function Ln(e){if(!e.optionsJSON&&e.challenge)console.warn(\"startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.\"),e={optionsJSON:e};let{optionsJSON:t,useAutoRegister:r=!1}=e;if(!ye())throw Error(\"WebAuthn is not supported in this browser\");let n={...t,challenge:ge(t.challenge),user:{...t.user,id:ge(t.user.id)},excludeCredentials:t.excludeCredentials?.map(pt)},o={};if(r)o.mediation=\"conditional\";o.publicKey=n,o.signal=Pe.createNewAbortSignal();let i;try{i=await navigator.credentials.create(o)}catch(g){throw $n({error:g,options:o})}if(!i)throw Error(\"Registration was not completed\");let{id:s,rawId:a,response:c,type:u}=i,l=void 0;if(typeof c.getTransports===\"function\")l=c.getTransports();let p=void 0;if(typeof c.getPublicKeyAlgorithm===\"function\")try{p=c.getPublicKeyAlgorithm()}catch(g){or(\"getPublicKeyAlgorithm()\",g)}let d=void 0;if(typeof c.getPublicKey===\"function\")try{let g=c.getPublicKey();if(g!==null)d=J(g)}catch(g){or(\"getPublicKey()\",g)}let m;if(typeof c.getAuthenticatorData===\"function\")try{m=J(c.getAuthenticatorData())}catch(g){or(\"getAuthenticatorData()\",g)}return{id:s,rawId:J(a),response:{attestationObject:J(c.attestationObject),clientDataJSON:J(c.clientDataJSON),transports:l,publicKeyAlgorithm:p,publicKey:d,authenticatorData:m},type:u,clientExtensionResults:i.getClientExtensionResults(),authenticatorAttachment:mt(i.authenticatorAttachment)}}function or(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function Nn(){if(!ye())return ir.stubThis(new Promise((t)=>t(!1)));let e=globalThis.PublicKeyCredential;if(e?.isConditionalMediationAvailable===void 0)return ir.stubThis(new Promise((t)=>t(!1)));return ir.stubThis(e.isConditionalMediationAvailable())}var ir={stubThis:(e)=>e};function Cn({error:e,options:t}){let{publicKey:r}=t;if(!r)throw Error(\"options was missing required publicKey property\");if(e.name===\"AbortError\"){if(t.signal instanceof AbortSignal)return new L({message:\"Authentication ceremony was sent an abort signal\",code:\"ERROR_CEREMONY_ABORTED\",cause:e})}else if(e.name===\"NotAllowedError\")return new L({message:e.message,code:\"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY\",cause:e});else if(e.name===\"SecurityError\"){let n=globalThis.location.hostname;if(!dt(n))return new L({message:`${globalThis.location.hostname} is an invalid domain`,code:\"ERROR_INVALID_DOMAIN\",cause:e});else if(r.rpId!==n)return new L({message:`The RP ID \"${r.rpId}\" is invalid for this domain`,code:\"ERROR_INVALID_RP_ID\",cause:e})}else if(e.name===\"UnknownError\")return new L({message:\"The authenticator was unable to process the specified options, or could not create a new assertion signature\",code:\"ERROR_AUTHENTICATOR_GENERAL_ERROR\",cause:e});return e}async function Zn(e){if(!e.optionsJSON&&e.challenge)console.warn(\"startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.\"),e={optionsJSON:e};let{optionsJSON:t,useBrowserAutofill:r=!1,verifyBrowserAutofillInput:n=!0}=e;if(!ye())throw Error(\"WebAuthn is not supported in this browser\");let o;if(t.allowCredentials?.length!==0)o=t.allowCredentials?.map(pt);let i={...t,challenge:ge(t.challenge),allowCredentials:o},s={};if(r){if(!await Nn())throw Error(\"Browser does not support WebAuthn autofill\");if(document.querySelectorAll(\"input[autocomplete$='webauthn']\").length<1&&n)throw Error('No <input> with \"webauthn\" as the only or last value in its `autocomplete` attribute was detected');s.mediation=\"conditional\",i.allowCredentials=[]}s.publicKey=i,s.signal=Pe.createNewAbortSignal();let a;try{a=await navigator.credentials.get(s)}catch(m){throw Cn({error:m,options:s})}if(!a)throw Error(\"Authentication was not completed\");let{id:c,rawId:u,response:l,type:p}=a,d=void 0;if(l.userHandle)d=J(l.userHandle);return{id:c,rawId:J(u),response:{authenticatorData:J(l.authenticatorData),clientDataJSON:J(l.clientDataJSON),signature:J(l.signature),userHandle:d},type:p,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:mt(a.authenticatorAttachment)}}var Un=\"1.7.6\";var Dn=Un;var sr=Symbol.for(\"better-auth:broadcast-channel\"),zu=()=>Math.floor(Date.now()/1000),$u=class{listeners=new Set;name;constructor(e=\"better-auth.message\"){this.name=e}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}post(e){if(typeof window>\"u\")return;try{localStorage.setItem(this.name,JSON.stringify({...e,timestamp:zu()}))}catch{}}setup(){if(typeof window>\"u\"||typeof window.addEventListener>\"u\")return()=>{};let e=(t)=>{if(t.key!==this.name)return;let r=JSON.parse(t.newValue??\"{}\");if(r?.event!==\"session\"||!r?.data)return;this.listeners.forEach((n)=>n(r))};return window.addEventListener(\"storage\",e),()=>{window.removeEventListener(\"storage\",e)}}};function ht(e=\"better-auth.message\"){if(!globalThis[sr])globalThis[sr]=new $u(e);return globalThis[sr]}var Ve=Symbol(\"clean\");var B=[],qe=0,be=null,ar=4,Iu=globalThis.nanostoresGlobal||={epoch:0},Lu=()=>{let e,t;while(qe<B.length){t=qe,qe+=ar;let r=be?.get(B[t]);if(r){if(!r.has(B[t+1]))continue;r.clear()}try{B[t](B[t+1].value,B[t+2],B[t+3])}catch(n){e=n}}if(B.length=qe=0,e)throw e};var _e=(e)=>{let t=[],r={eq:Object.is,get(){if(!r.lc)r.listen(()=>{})();return r.value},init:e,lc:0,listen(n){return r.lc=t.push(n),()=>{be?.get(n)?.delete(r);for(let i=qe;i<B.length;)if(B[i]===n&&B[i+1]===r)B.splice(i,ar);else i+=ar;let o=t.indexOf(n);if(~o){if(t.splice(o,1),!--r.lc)r.off()}}},notify(n,o){Iu.epoch++;let i=!B.length&&!be;for(let s of t){if(be){let a=be.get(s);if(!a)be.set(s,a=new Set);if(a.has(r))continue;a.add(r)}B.push(s,r,n,be?void 0:o)}if(i)Lu()},off(){},set(n){let o=r.value;if(!r.eq(o,n))r.value=n,r.notify(o)},subscribe(n){let o=r.listen(n);return n(r.value),o},value:e};return r[Ve]=()=>{t=[],r.lc=0,r.off()},r};var Nu=2;var Cu=5,Re=6,gt=10,jn=(e,t,r,n)=>{if(e.events=e.events||{},!e.events[r+gt])e.events[r+gt]=n((o)=>{e.events[r].reduceRight((i,s)=>(s(i),i),{shared:{},...o})});return e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let o=e.events[r],i=o.indexOf(t);if(~i){if(o.splice(i,1),!o.length)e.events[r+gt](),delete e.events[r+gt]}}};var cr=(e,t)=>jn(e,t,Nu,(r)=>{let{set:n,setKey:o}=e;if(e.setKey)e.setKey=(i,s)=>{let a;if(r({abort:()=>{a=!0},changed:i,newValue:{...e.value,[i]:s}}),!a)return o(i,s)};return e.set=(i)=>{let s;if(r({abort:()=>{s=!0},newValue:i}),!s)return n(i)},()=>{e.set=n,e.setKey=o}});var yt=1000,ze=(e,t)=>jn(e,(n)=>{let o=t(n);if(o)e.events[Re].push(o)},Cu,(n)=>{let o=e.listen;e.listen=(...s)=>{if(!e.lc&&!e.active)e.active=!0,n();return o(...s)};let i=e.off;e.events[Re]=[],e.off=()=>{i(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let s of e.events[Re])s();e.events[Re]=[]}},yt)};{let s=e[Ve];e[Ve]=()=>{for(let a of e.events[Re])a();e.events[Re]=[],e.active=!1,s()}}return()=>{e.listen=o,e.off=i}});function Vn(e){if(typeof e!==\"object\"||e===null)return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ce(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!ce(e[r],t[r]))return!1;return!0}if(Vn(e)&&Vn(t)){let r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(let o of r)if(!(o in t)||!ce(e[o],t[o]))return!1;return!0}return!1}function _t(e,t){return cr(e,({newValue:r,abort:n})=>{if(t(e.value,r))n()})}var ur=Symbol.for(\"better-auth:focus-manager\"),Mu=class{listeners=new Set;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setFocused(e){this.listeners.forEach((t)=>t(e))}setup(){if(typeof window>\"u\"||typeof document>\"u\"||typeof window.addEventListener>\"u\")return()=>{};let e=()=>{if(document.visibilityState===\"visible\")this.setFocused(!0)};return document.addEventListener(\"visibilitychange\",e,!1),()=>{document.removeEventListener(\"visibilitychange\",e,!1)}}};function lr(){if(!globalThis[ur])globalThis[ur]=new Mu;return globalThis[ur]}var fr=Symbol.for(\"better-auth:online-manager\"),Fu=class{listeners=new Set;isOnline=typeof navigator<\"u\"?navigator.onLine:!0;subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setOnline(e){this.isOnline=e,this.listeners.forEach((t)=>t(e))}setup(){if(typeof window>\"u\"||typeof window.addEventListener>\"u\")return()=>{};let e=()=>this.setOnline(!0),t=()=>this.setOnline(!1);return window.addEventListener(\"online\",e,!1),window.addEventListener(\"offline\",t,!1),()=>{window.removeEventListener(\"online\",e,!1),window.removeEventListener(\"offline\",t,!1)}}};function xt(){if(!globalThis[fr])globalThis[fr]=new Fu;return globalThis[fr]}var Bu={proto:/\"(?:_|\\\\u0{2}5[Ff]){2}(?:p|\\\\u0{2}70)(?:r|\\\\u0{2}72)(?:o|\\\\u0{2}6[Ff])(?:t|\\\\u0{2}74)(?:o|\\\\u0{2}6[Ff])(?:_|\\\\u0{2}5[Ff]){2}\"\\s*:/,constructor:/\"(?:c|\\\\u0063)(?:o|\\\\u006[Ff])(?:n|\\\\u006[Ee])(?:s|\\\\u0073)(?:t|\\\\u0074)(?:r|\\\\u0072)(?:u|\\\\u0075)(?:c|\\\\u0063)(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:r|\\\\u0072)\"\\s*:/,protoShort:/\"__proto__\"\\s*:/,constructorShort:/\"constructor\"\\s*:/},Vu=/^\\s*[\"[{]|^\\s*-?\\d{1,16}(\\.\\d{1,17})?([Ee][+-]?\\d+)?\\s*$/,qn={true:!0,false:!1,null:null,undefined:void 0,nan:NaN,infinity:Number.POSITIVE_INFINITY,\"-infinity\":Number.NEGATIVE_INFINITY},qu=/^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2})(?:\\.(\\d{1,7}))?(?:Z|([+-])(\\d{2}):(\\d{2}))$/;function Hu(e){return e instanceof Date&&!isNaN(e.getTime())}function Ku(e){let t=qu.exec(e);if(!t)return null;let[,r,n,o,i,s,a,c,u,l,p]=t,d=new Date(Date.UTC(parseInt(r,10),parseInt(n,10)-1,parseInt(o,10),parseInt(i,10),parseInt(s,10),parseInt(a,10),c?parseInt(c.padEnd(3,\"0\"),10):0));if(u){let m=(parseInt(l,10)*60+parseInt(p,10))*(u===\"+\"?-1:1);d.setUTCMinutes(d.getUTCMinutes()+m)}return Hu(d)?d:null}function Ju(e,t={}){let{strict:r=!1,warnings:n=!1,reviver:o,parseDates:i=!0}=t;if(typeof e!==\"string\")return e;let s=e.trim(),a=s.toLowerCase();if(a.length<=9&&a in qn)return qn[a];if(!Vu.test(s)){if(r)throw SyntaxError(\"[better-json] Invalid JSON\");return e}if(Object.entries(Bu).some(([c,u])=>{let l=u.test(s);if(l&&n)console.warn(`[better-json] Detected potential prototype pollution attempt using ${c} pattern`);return l})&&r)throw Error(\"[better-json] Potential prototype pollution attempt detected\");try{return JSON.parse(s,(u,l)=>{if(u===\"__proto__\"||u===\"constructor\"&&l&&typeof l===\"object\"&&\"prototype\"in l){if(n)console.warn(`[better-json] Dropping \"${u}\" key to prevent prototype pollution`);return}if(i&&typeof l===\"string\"){let p=Ku(l);if(p)return p}return o?o(u,l):l})}catch(c){if(r)throw c;return e}}function Hn(e,t={strict:!0}){return Ju(e,t)}var Gu=Symbol.for(\"better-auth:auth-query\");function vt(e){let t=_e(e);return Object.defineProperty(t,Gu,{value:!0}),t}var Wu=()=>typeof window>\"u\";function Yu(e,t){return ce(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}var pr=(e,t,r,n)=>{let o=vt({data:null,error:null,isPending:!0,isRefetching:!1,refetch:(p)=>s(p)});ze(o,()=>_t(o,Yu));let i=0,s=async(p)=>{let d=++i;return new Promise((m)=>{let g=typeof n===\"function\"?n({data:o.get().data,error:o.get().error,isPending:o.get().isPending}):n;r(t,{...g,query:{...g?.query,...p?.query},async onSuccess(h){if(d===i){let v=o.get(),x=v.data!=null&&h.data!=null&&ce(v.data,h.data)?v.data:h.data;o.set({data:x,error:null,isPending:!1,isRefetching:!1,refetch:o.value.refetch})}await g?.onSuccess?.(h)},async onError(h){let{request:v}=h,x=typeof v.retry===\"number\"?v.retry:v.retry?.attempts,O=v.retryAttempt||0;if(x&&O<x)return;if(d===i){let b=h.error.status===401;o.set({error:h.error,data:b?null:o.get().data,isPending:!1,isRefetching:!1,refetch:o.value.refetch})}await g?.onError?.(h)},async onRequest(h){if(d===i){let v=o.get();o.set({isPending:v.data===null,data:v.data,error:null,isRefetching:!0,refetch:o.value.refetch})}await g?.onRequest?.(h)}}).catch((h)=>{if(d!==i)return;o.set({error:h,data:o.get().data,isPending:!1,isRefetching:!1,refetch:o.value.refetch})}).finally(()=>{m(void 0)})})};e=Array.isArray(e)?e:[e];let a=!1,c=!1,u=!1,l=()=>{if(a){u=!0;return}a=!0,s().finally(()=>{a=!1;let p=u&&c;if(u=!1,p)l()})};return ze(o,()=>{if(Wu())return;c=!0;let p=!1,d,m=e.map((g)=>g.listen(()=>{if(p)s();else p=!0,clearTimeout(d),l()}));return d=setTimeout(()=>{p=!0,l()},0),()=>{c=!1;for(let g of m)g();clearTimeout(d)}}),o};var dr=()=>Math.floor(Date.now()/1000),Xu=5;function Kn(e){let{fetchSession:t,shouldPollSession:r=()=>!0,sessionSignal:n,options:o={}}=e,i=o.sessionOptions?.refetchInterval??0,s=o.sessionOptions?.refetchOnWindowFocus??!0,a=o.sessionOptions?.refetchWhenOffline??!1,c={isInitialized:!1,lastSessionRequest:0},u=()=>a||xt().isOnline,l=(b)=>{if(!u())return;if(b?.event===\"storage\"){t();return}if(b?.event===\"poll\"){c.lastSessionRequest=dr(),t();return}if(b?.event===\"visibilitychange\"){if(dr()-c.lastSessionRequest<Xu)return;c.lastSessionRequest=dr(),t();return}t()},p=(b)=>{ht().post({event:\"session\",data:{trigger:b},clientId:Math.random().toString(36).substring(7)})},d=()=>{if(i&&i>0)c.pollInterval=setInterval(()=>{if(r())l({event:\"poll\"})},i*1000)},m=()=>{c.unsubscribeBroadcast=ht().subscribe(()=>{l({event:\"storage\"})})},g=()=>{if(!s)return;c.unsubscribeFocus=lr().subscribe(()=>{l({event:\"visibilitychange\"})})},h=()=>{c.unsubscribeOnline=xt().subscribe((b)=>{if(b)l({event:\"visibilitychange\"})})},v=()=>{c.unsubscribeSignal=n.listen(()=>{t()})};return{init:()=>{if(c.isInitialized)return;c.isInitialized=!0,d(),m(),g(),h(),v(),c.cleanupBroadcastSetup=ht().setup(),c.cleanupFocusSetup=lr().setup(),c.cleanupOnlineSetup=xt().setup()},cleanup:()=>{if(!c.isInitialized)return;if(c.pollInterval)clearInterval(c.pollInterval),c.pollInterval=void 0;if(c.unsubscribeBroadcast)c.unsubscribeBroadcast(),c.unsubscribeBroadcast=void 0;if(c.unsubscribeFocus)c.unsubscribeFocus(),c.unsubscribeFocus=void 0;if(c.unsubscribeOnline)c.unsubscribeOnline(),c.unsubscribeOnline=void 0;if(c.unsubscribeSignal)c.unsubscribeSignal(),c.unsubscribeSignal=void 0;if(c.cleanupBroadcastSetup)c.cleanupBroadcastSetup(),c.cleanupBroadcastSetup=void 0;if(c.cleanupFocusSetup)c.cleanupFocusSetup(),c.cleanupFocusSetup=void 0;if(c.cleanupOnlineSetup)c.cleanupOnlineSetup(),c.cleanupOnlineSetup=void 0;c.isInitialized=!1,c.lastSessionRequest=0},triggerRefetch:l,broadcastSessionUpdate:p}}var wt=Object.create(null),Ke=(e)=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?wt:globalThis),te=new Proxy(wt,{get(e,t){return Ke()[t]??wt[t]},has(e,t){return t in Ke()||t in wt},set(e,t,r){let n=Ke(!0);return n[t]=r,!0},deleteProperty(e,t){if(!t)return!1;let r=Ke(!0);return delete r[t],!0},ownKeys(){let e=Ke(!0);return Object.keys(e)}});var Qu=te.NODE_ENV??\"\";function ue(e,t){if(typeof process<\"u\"&&process.env)return process.env[e]??t;if(typeof Deno<\"u\")return Deno.env.get(e)??t;if(typeof Bun<\"u\")return Bun.env[e]??t;return t}var el=Object.freeze({get BETTER_AUTH_SECRET(){return ue(\"BETTER_AUTH_SECRET\")},get AUTH_SECRET(){return ue(\"AUTH_SECRET\")},get BETTER_AUTH_TELEMETRY(){return ue(\"BETTER_AUTH_TELEMETRY\")},get BETTER_AUTH_TELEMETRY_ID(){return ue(\"BETTER_AUTH_TELEMETRY_ID\")},get NODE_ENV(){return ue(\"NODE_ENV\",\"development\")},get PACKAGE_VERSION(){return ue(\"PACKAGE_VERSION\",\"0.0.0\")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return ue(\"BETTER_AUTH_TELEMETRY_ENDPOINT\",\"\")}});function rl(){let e=Object.getOwnPropertyDescriptor(Error,\"stackTraceLimit\");if(e===void 0)return Object.isExtensible(Error);return Object.prototype.hasOwnProperty.call(e,\"writable\")?e.writable:e.set!==void 0}function nl(e){let t=e.split(`\n at `);if(t.length<=1)return e;return t.splice(1,1),t.join(`\n at `)}function ol(e,t){class r extends e{#e;constructor(...n){if(rl()){let i=Error.stackTraceLimit;Error.stackTraceLimit=0;super(...n);Error.stackTraceLimit=i}else super(...n);let o=Error().stack;if(o)this.#e=nl(o.replace(/^Error/,this.name))}get errorStack(){return this.#e}}return Object.defineProperty(r.prototype,\"constructor\",{get(){return t},enumerable:!1,configurable:!0}),r}var il={OK:200,CREATED:201,ACCEPTED:202,NO_CONTENT:204,MULTIPLE_CHOICES:300,MOVED_PERMANENTLY:301,FOUND:302,SEE_OTHER:303,NOT_MODIFIED:304,TEMPORARY_REDIRECT:307,BAD_REQUEST:400,UNAUTHORIZED:401,PAYMENT_REQUIRED:402,FORBIDDEN:403,NOT_FOUND:404,METHOD_NOT_ALLOWED:405,NOT_ACCEPTABLE:406,PROXY_AUTHENTICATION_REQUIRED:407,REQUEST_TIMEOUT:408,CONFLICT:409,GONE:410,LENGTH_REQUIRED:411,PRECONDITION_FAILED:412,PAYLOAD_TOO_LARGE:413,URI_TOO_LONG:414,UNSUPPORTED_MEDIA_TYPE:415,RANGE_NOT_SATISFIABLE:416,EXPECTATION_FAILED:417,\"I'M_A_TEAPOT\":418,MISDIRECTED_REQUEST:421,UNPROCESSABLE_ENTITY:422,LOCKED:423,FAILED_DEPENDENCY:424,TOO_EARLY:425,UPGRADE_REQUIRED:426,PRECONDITION_REQUIRED:428,TOO_MANY_REQUESTS:429,REQUEST_HEADER_FIELDS_TOO_LARGE:431,UNAVAILABLE_FOR_LEGAL_REASONS:451,INTERNAL_SERVER_ERROR:500,NOT_IMPLEMENTED:501,BAD_GATEWAY:502,SERVICE_UNAVAILABLE:503,GATEWAY_TIMEOUT:504,HTTP_VERSION_NOT_SUPPORTED:505,VARIANT_ALSO_NEGOTIATES:506,INSUFFICIENT_STORAGE:507,LOOP_DETECTED:508,NOT_EXTENDED:510,NETWORK_AUTHENTICATION_REQUIRED:511},sl=class extends Error{status;body;headers;statusCode;constructor(e=\"INTERNAL_SERVER_ERROR\",t=void 0,r={},n=typeof e===\"number\"?e:il[e]){super(t?.message,t?.cause?{cause:t.cause}:void 0);this.status=e,this.body=t,this.headers=r,this.statusCode=n,this.name=\"APIError\",this.status=e,this.headers=r,this.statusCode=n,this.body=t}};var al=ol(sl,Error);var $e=class extends Error{constructor(e,t){super(e,t);this.name=\"BetterAuthError\",this.message=e,this.stack=\"\"}};var cl=47;function Gn(e){let t=e.length;while(t>0&&e.charCodeAt(t-1)===cl)t--;return t===e.length?e:e.slice(0,t)}function ul(e){try{return(Gn(new URL(e).pathname)||\"/\")!==\"/\"}catch{throw new $e(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function ll(e){try{let t=new URL(e);if(t.protocol!==\"http:\"&&t.protocol!==\"https:\")throw new $e(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`)}catch(t){if(t instanceof $e)throw t;throw new $e(`Invalid base URL: ${e}. Please provide a valid base URL.`,{cause:t})}}function Ge(e,t=\"/api/auth\"){if(ll(e),ul(e))return e;let r=Gn(e);if(!t||t===\"/\")return r;return t=t.startsWith(\"/\")?t:`/${t}`,`${r}${t}`}function Jn(e,t){if(!e||e.trim()===\"\")return!1;if(t===\"proto\")return e===\"http\"||e===\"https\";if(t===\"host\"){if([/\\.\\./,/\\0/,/[\\s]/,/^[.]/,/[<>'\"]/,/javascript:/i,/file:/i,/data:/i].some((r)=>r.test(e)))return!1;return/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(e)||/^(\\d{1,3}\\.){3}\\d{1,3}(:[0-9]{1,5})?$/.test(e)||/^\\[[0-9a-fA-F:]+\\](:[0-9]{1,5})?$/.test(e)||/^localhost(:[0-9]{1,5})?$/i.test(e)}return!1}function Wn(e,t,r,n,o){if(e)return Ge(e,t);if(n!==!1){let a=te.BETTER_AUTH_URL||te.NEXT_PUBLIC_BETTER_AUTH_URL||te.PUBLIC_BETTER_AUTH_URL||te.NUXT_PUBLIC_BETTER_AUTH_URL||te.NUXT_PUBLIC_AUTH_URL||(te.BASE_URL!==\"/\"?te.BASE_URL:void 0);if(a)return Ge(a,t)}let i=r?.headers.get(\"x-forwarded-host\"),s=r?.headers.get(\"x-forwarded-proto\");if(i&&s&&o){if(Jn(s,\"proto\")&&Jn(i,\"host\"))try{return Ge(`${s}://${i}`,t)}catch(a){}}if(r){let a=fl(r.url);if(!a)throw new $e(\"Could not get origin from request. Please provide a valid base URL.\");return Ge(a,t)}if(typeof window<\"u\"&&window.location)return Ge(window.location.origin,t)}function fl(e){try{let t=new URL(e);return t.origin===\"null\"?null:t.origin}catch{return null}}var pl=[\"javascript:\",\"data:\",\"vbscript:\"];function Yn(e){let t;try{t=new URL(e)}catch{return!0}return!pl.includes(t.protocol)}var Xn={id:\"redirect\",name:\"Redirect\",hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&Yn(e.data.url)){if(typeof window<\"u\"&&window.location){if(window.location)try{window.location.href=e.data.url}catch{}}}}}};var dl=()=>typeof window>\"u\",ml=yt;function eo(e,t){if(typeof window>\"u\")return;let r=e.get();if(r.data!==null||t===null)return;e.set({...r,data:t,error:null,isPending:!1})}function Qn(e){if(typeof e===\"object\"&&e!==null&&\"data\"in e&&\"error\"in e)return e;return{data:e,error:null}}function hl(e){if(!e)return null;if(e.session===null&&e.user===null)return null;return e}function gl(e,t){return ce(e.data,t.data)&&e.error===t.error&&e.isPending===t.isPending&&e.isRefetching===t.isRefetching&&e.refetch===t.refetch}function to(e,t){let r=_e(!1),n,o=0,i=0;r.listen(()=>{i++,o=0});let s=(m)=>l(m),a=vt({data:null,error:null,isPending:!0,isRefetching:!1,refetch:s});_t(a,gl);let c=async(m,g)=>{let h=a.value;if(a.set({...h,isPending:h.data===null,isRefetching:!0,error:null,refetch:s}),m.aborted)return\"aborted\";try{let v=await e(\"/get-session\",{method:\"GET\",query:g?.query,signal:m});if(m.aborted)return\"aborted\";let{data:x,error:O}=Qn(v),b=\"fresh\";if(x?.needsRefresh)try{let _=await e(\"/get-session\",{method:\"POST\",signal:m});if(m.aborted)return\"aborted\";({data:x,error:O}=Qn(_))}catch{if(m.aborted)return\"aborted\";b=\"stale\"}if(O){let _=a.value,Oe=O?.status===401;return a.set({data:Oe?null:_.data,error:O,isPending:!1,isRefetching:!1,refetch:s}),\"failed\"}let T=hl(x),k=a.value,W=k.data!=null&&T!=null&&ce(k.data,T)?k.data:T;return a.set({data:W,error:null,isPending:!1,isRefetching:!1,refetch:s}),b}catch(v){if(m.aborted)return\"aborted\";let x=a.value;return a.set({data:x.data,error:v,isPending:!1,isRefetching:!1,refetch:s}),\"failed\"}},u=()=>{let m=a.value.data?.session?.expiresAt,g=m instanceof Date?m.getTime():Number.POSITIVE_INFINITY;return Math.min(Date.now()+ml,g)},l=(m)=>{o=0,n?.cancel();let g=new AbortController,h={cancel:()=>g.abort(),promise:Promise.resolve().then(()=>{if(g.signal.aborted)return\"aborted\";return c(g.signal,m)}),revision:i};n=h;let v=(x)=>{if(n!==h)return;if(n=void 0,x===\"fresh\"&&h.revision===i)o=u()};return h.promise.then(v,()=>v(\"failed\")),h.promise.then(()=>{return})},p=()=>{if(n?.revision===i)return n.promise.then(()=>{return});if(Date.now()<o)return Promise.resolve();return l()},d=()=>{};return ze(a,()=>{let m;if(!dl())m=setTimeout(()=>{p()},0);let g=Kn({fetchSession:l,shouldPollSession:()=>a.value.data!=null,sessionSignal:r,options:t});return g.init(),d=g.broadcastSessionUpdate,()=>{if(m)clearTimeout(m);g.cleanup()}}),{session:a,$sessionSignal:r,broadcastSessionUpdate:(m)=>d(m)}}function mr(e){if(e===null||typeof e!==\"object\")return!1;let t=Object.getPrototypeOf(e);if(t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null)return!1;if(Symbol.iterator in e)return!1;if(Symbol.toStringTag in e)return Object.prototype.toString.call(e)===\"[object Module]\";return!0}function hr(e,t,r=\".\",n){if(!mr(t))return hr(e,{},r,n);let o={...t};for(let i of Object.keys(e)){if(i===\"__proto__\"||i===\"constructor\")continue;let s=e[i];if(s===null||s===void 0)continue;if(n&&n(o,i,s,r))continue;if(Array.isArray(s)&&Array.isArray(o[i]))o[i]=[...s,...o[i]];else if(mr(s)&&mr(o[i]))o[i]=hr(s,o[i],(r?`${r}.`:\"\")+i.toString(),n);else o[i]=s}return o}function gr(e){return(...t)=>t.reduce((r,n)=>hr(r,n,\"\",e),{})}var ro=gr(),$g=gr((e,t,r)=>{if(e[t]!==void 0&&typeof r===\"function\")return e[t]=r(e[t]),!0}),Ig=gr((e,t,r)=>{if(Array.isArray(e[t])&&typeof r===\"function\")return e[t]=r(e[t]),!0});var yl=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r});this.status=e,this.statusText=t,this.error=r,Error.captureStackTrace(this,this.constructor)}},bl=async(e,t)=>{let r=t||{},n={onRequest:[t===null||t===void 0?void 0:t.onRequest],onResponse:[t===null||t===void 0?void 0:t.onResponse],onSuccess:[t===null||t===void 0?void 0:t.onSuccess],onError:[t===null||t===void 0?void 0:t.onError],onRetry:[t===null||t===void 0?void 0:t.onRetry]};if(!t||!(t===null||t===void 0?void 0:t.plugins))return{url:e,options:r,hooks:n};for(let l of(t===null||t===void 0?void 0:t.plugins)||[]){var o,i,s,a,c;if(l.init){var u;let p=await((u=l.init)===null||u===void 0?void 0:u.call(l,e.toString(),r));r=p.options||r,e=p.url}n.onRequest.push((o=l.hooks)===null||o===void 0?void 0:o.onRequest),n.onResponse.push((i=l.hooks)===null||i===void 0?void 0:i.onResponse),n.onSuccess.push((s=l.hooks)===null||s===void 0?void 0:s.onSuccess),n.onError.push((a=l.hooks)===null||a===void 0?void 0:a.onError),n.onRetry.push((c=l.hooks)===null||c===void 0?void 0:c.onRetry)}return{url:e,options:r,hooks:n}},no=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){if(this.options.shouldRetry)return Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t));return Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},_l=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){if(this.options.shouldRetry)return Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t));return Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function xl(e){if(typeof e===\"number\")return new no({type:\"linear\",attempts:e,delay:1000});switch(e.type){case\"linear\":return new no(e);case\"exponential\":return new _l(e);default:throw Error(\"Invalid retry strategy\")}}var vl=[\"get\",\"post\",\"put\",\"patch\",\"delete\"];function br(e){if(!e.startsWith(\"@\"))return{method:void 0,path:e};let t=e.indexOf(\"/\"),r=e.slice(1,t===-1?void 0:t);if(!vl.includes(r))return{method:void 0,path:e};return{method:r,path:t===-1?e:e.slice(t+1)}}var wl=(e)=>e===\".\"||e===\"..\",Sl=(e)=>e.split(\":\").map((t)=>encodeURIComponent(t)).join(\":\");function Tl(e,t){let r=t.get(e);if(r===void 0)return Sl(e);if(wl(r))throw TypeError(\"Path parameters cannot be reserved path segments\");return encodeURIComponent(r)}function El(e,t){let{baseURL:r,params:n,query:o}=t||{query:{},params:{},baseURL:\"\"},i=e.startsWith(\"http\")?e.split(\"/\").slice(0,3).join(\"/\"):r||\"\",{path:s}=br(e);if(s!==e)e=`/${s}`;if(!i.endsWith(\"/\"))i+=\"/\";let[a,c]=e.replace(i,\"\").split(\"?\"),u=new URLSearchParams(c);for(let[d,m]of Object.entries(o||{})){if(m==null)continue;let g;if(typeof m===\"string\")g=m;else if(Array.isArray(m)){for(let h of m)u.append(d,h);continue}else g=JSON.stringify(m);u.set(d,g)}let l=new Map;if(n)if(Array.isArray(n)){let d=a.split(\"/\").filter((m)=>m.startsWith(\":\"));for(let[m,g]of d.entries()){let h=n[m];l.set(g,String(h))}}else for(let[d,m]of Object.entries(n))l.set(`:${d}`,String(m));a=a.split(\"/\").map((d)=>Tl(d,l)).join(\"/\"),a=a.replace(/^\\/+/,\"\");let p=u.toString();if(p=p.length>0?`?${p}`.replace(/\\+/g,\"%20\"):\"\",!i.startsWith(\"http\"))return`${i}${a}${p}`;return new URL(`${a}${p}`,i)}var kl=async(e)=>{let t={},r=async(n)=>typeof n===\"function\"?await n():n;if(e===null||e===void 0?void 0:e.auth){if(e.auth.type===\"Bearer\"){let n=await r(e.auth.token);if(!n)return t;t.authorization=`Bearer ${n}`}else if(e.auth.type===\"Basic\"){let[n,o]=await Promise.all([r(e.auth.username),r(e.auth.password)]);if(!n||!o)return t;t.authorization=`Basic ${btoa(`${n}:${o}`)}`}else if(e.auth.type===\"Custom\"){let[n,o]=await Promise.all([r(e.auth.prefix),r(e.auth.value)]);if(!o)return t;t.authorization=`${n!==null&&n!==void 0?n:\"\"} ${o}`}}return t},Ol=/^application\\/(?:[\\w!#$%&*.^`~-]*\\+)?json(;.+)?$/i;function Al(e){let t=e.headers.get(\"content-type\"),r=new Set([\"image/svg\",\"application/xml\",\"application/xhtml\",\"application/html\"]);if(!t)return\"json\";let n=t.split(\";\").shift()||\"\";if(Ol.test(n))return\"json\";if(r.has(n)||n.startsWith(\"text/\"))return\"text\";return\"blob\"}function Pl(e){try{return JSON.parse(e),!0}catch(t){return!1}}function ao(e){if(e===void 0)return!1;let t=typeof e;if(t===\"string\"||t===\"number\"||t===\"boolean\"||t===null)return!0;if(t!==\"object\")return!1;if(Array.isArray(e))return!0;if(e.buffer)return!1;return e.constructor&&e.constructor.name===\"Object\"||typeof e.toJSON===\"function\"}function oo(e){try{return JSON.parse(e)}catch(t){return e}}function io(e){return typeof e===\"function\"}function Rl(e){if(e===null||e===void 0?void 0:e.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<\"u\"&&io(globalThis.fetch))return globalThis.fetch;if(typeof window<\"u\"&&io(window.fetch))return window.fetch;throw Error(\"No fetch implementation found\")}function co(...e){let t={};for(let r of e){if(!r)continue;if(r instanceof Headers)r.forEach((n,o)=>{t[o]=n});else{let n=Array.isArray(r)?r:Object.entries(r);for(let[o,i]of n)if(i!==null&&i!==void 0)t[o]=i}}return t}async function zl(e){let t=new Headers(co(e===null||e===void 0?void 0:e.headers,await kl(e)));if(!t.has(\"content-type\")){let r=$l(e===null||e===void 0?void 0:e.body);if(r)t.set(\"content-type\",r)}return t}function $l(e){if(ao(e))return\"application/json\";return null}function Il(e){let t=e.get(\"content-type\");return t?t.split(\";\")[0].trim().toLowerCase():null}function Ll(e,t){let{body:r}=e;if(!r)return null;if(!ao(r))return r;if(typeof r===\"string\")return r;if(Il(t)===\"application/x-www-form-urlencoded\")return new URLSearchParams(r).toString();return JSON.stringify(r)}function Nl(e,t){if(t===null||t===void 0?void 0:t.method)return t.method.toUpperCase();let{method:r}=br(e);if(r)return r.toUpperCase();return(t===null||t===void 0?void 0:t.body)?\"POST\":\"GET\"}function Cl(e,t){let r;if(!(e===null||e===void 0?void 0:e.signal)&&(e===null||e===void 0?void 0:e.timeout))r=setTimeout(()=>t===null||t===void 0?void 0:t.abort(),e===null||e===void 0?void 0:e.timeout);return{abortTimeout:r,clearTimeout:()=>{if(r)clearTimeout(r)}}}var Zl=class e extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2));this.issues=t,Object.setPrototypeOf(this,e.prototype)}};async function We(e,t){let r=await e[\"~standard\"].validate(t);if(r.issues)throw new Zl(r.issues);return r.value}function Ye(e){return Ye=typeof Symbol==\"function\"&&typeof Symbol.iterator==\"symbol\"?function(t){return typeof t}:function(t){return t&&typeof Symbol==\"function\"&&t.constructor===Symbol&&t!==Symbol.prototype?\"symbol\":typeof t},Ye(e)}function Ul(e,t){if(Ye(e)!=\"object\"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||\"default\");if(Ye(n)!=\"object\")return n;throw TypeError(\"@@toPrimitive must return a primitive value.\")}return(t===\"string\"?String:Number)(e)}function Dl(e){var t=Ul(e,\"string\");return Ye(t)==\"symbol\"?t:t+\"\"}function jl(e,t,r){return(t=Dl(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function so(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?so(Object(r),!0).forEach(function(n){jl(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):so(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}var yr=async(e,t)=>{var r,n,o;let{hooks:i,url:s,options:a}=await bl(e,t),c=Rl(a),u=new AbortController,l=(r=a.signal)!==null&&r!==void 0?r:u.signal,p=El(s,a),d=await zl(a),m=Ll(a,d),g=Nl(s,a),h=S(S({},a),{},{url:p,headers:d,body:m,method:g,signal:l});for(let j of i.onRequest)if(j){let N=await j(h);if(typeof N===\"object\"&&N!==null)Object.assign(h,N)}if(\"pipeTo\"in h&&typeof h.pipeTo===\"function\"||typeof(t===null||t===void 0||(n=t.body)===null||n===void 0?void 0:n.pipe)===\"function\"){if(!(\"duplex\"in h))h.duplex=\"half\"}let{clearTimeout:v}=Cl(a,u),x=await c(h.url,h);v();let O={response:x,request:h};for(let j of i.onResponse)if(j){var b;let N=await j(S(S({},O),{},{response:(t===null||t===void 0||(b=t.hookOptions)===null||b===void 0?void 0:b.cloneResponse)?x.clone():x}));if(N instanceof Response)x=N;else if(typeof N===\"object\"&&N!==null)x=N.response}if(x.ok){if(h.method===\"HEAD\")return{data:\"\",error:null};let j=Al(x),N={data:null,response:x,request:h};if(j===\"json\"||j===\"text\"){var T;let Ae=await x.text();N.data=await((T=h.jsonParser)!==null&&T!==void 0?T:oo)(Ae)}else N.data=await x[j]();if(h===null||h===void 0?void 0:h.output){if(h.output&&!h.disableValidation)N.data=await We(h.output,N.data)}for(let Ae of i.onSuccess)if(Ae){var k;await Ae(S(S({},N),{},{response:(t===null||t===void 0||(k=t.hookOptions)===null||k===void 0?void 0:k.cloneResponse)?x.clone():x}))}if(t===null||t===void 0?void 0:t.throw)return N.data;return{data:N.data,error:null}}let W=(o=t===null||t===void 0?void 0:t.jsonParser)!==null&&o!==void 0?o:oo,_=await x.text(),Oe=Pl(_),tr=Oe?await W(_):null,Tu={response:x,responseText:_,request:h,error:S(S({},tr),{},{status:x.status,statusText:x.statusText})};for(let j of i.onError)if(j){var rr;await j(S(S({},Tu),{},{response:(t===null||t===void 0||(rr=t.hookOptions)===null||rr===void 0?void 0:rr.cloneResponse)?x.clone():x}))}if(t===null||t===void 0?void 0:t.retry){var nr;let j=xl(t.retry),N=(nr=t.retryAttempt)!==null&&nr!==void 0?nr:0;if(await j.shouldAttemptRetry(N,x)){for(let lt of i.onRetry)if(lt)await lt(O);let Ae=j.getDelay(N);return await new Promise((lt)=>setTimeout(lt,Ae)),await yr(e,S(S({},t),{},{retryAttempt:N+1}))}}if(t===null||t===void 0?void 0:t.throw)throw new yl(x.status,x.statusText,Oe?tr:_);return{data:null,error:S(S({},tr),{},{status:x.status,statusText:x.statusText})}},Ml=(e)=>({id:\"apply-schema\",name:\"Apply Schema\",version:\"1.0.0\",async init(t,r){var n;let o=S(S({},r),e.query!==void 0&&{query:S(S({},e.query),r===null||r===void 0?void 0:r.query)}),i=((n=e.plugins)===null||n===void 0||(n=n.find((u)=>{var l;return((l=u.schema)===null||l===void 0?void 0:l.config)?t.startsWith(u.schema.config.baseURL||\"\")||t.startsWith(u.schema.config.prefix||\"\"):!1}))===null||n===void 0?void 0:n.schema)||e.schema;if(i){var s,a;let u=t;if((s=i.config)===null||s===void 0?void 0:s.prefix){if(u.startsWith(i.config.prefix)){if(u=u.replace(i.config.prefix,\"\"),i.config.baseURL)t=t.replace(i.config.prefix,i.config.baseURL)}}if((a=i.config)===null||a===void 0?void 0:a.baseURL){if(u.startsWith(i.config.baseURL))u=u.replace(i.config.baseURL,\"\")}if(u.startsWith(\"/\")&&u.charAt(1)===\"@\")u=u.substring(1);let l=i.schema[u];if(l){var c;let{method:p,path:d}=br(u);if(p)t=t.slice(0,t.length-u.length)+d;let m=r===null||r===void 0?void 0:r.headers;if(l.headers&&!(r===null||r===void 0?void 0:r.disableValidation)){let h={};if(r===null||r===void 0?void 0:r.headers){if(r.headers instanceof Headers)r.headers.forEach((O,b)=>{h[b.toLowerCase()]=O});else if(typeof r.headers===\"object\"){for(let[O,b]of Object.entries(r.headers))if(b!==null&&b!==void 0)h[O.toLowerCase()]=b}}let v=await We(l.headers,h),x={};for(let[O,b]of Object.entries(v))x[O.toLowerCase()]=b;m=x}let g=(c=l.method)!==null&&c!==void 0?c:p;if(o=S(S(S(S({},o),g!==void 0&&{method:g}),l.output!==void 0&&{output:l.output}),m!==void 0&&{headers:m}),!(r===null||r===void 0?void 0:r.disableValidation)){if(l.query){if(o.query=await We(l.query,r===null||r===void 0?void 0:r.query),o.query!==null&&typeof o.query===\"object\"){let h=S({},e.query);for(let v of Object.keys(h))if((r===null||r===void 0?void 0:r.query)&&Object.prototype.hasOwnProperty.call(r.query,v))h[v]=r.query[v];o.query=S(S({},h),o.query)}}o=S(S({},o),{},{body:l.input?await We(l.input,r===null||r===void 0?void 0:r.body):r===null||r===void 0?void 0:r.body,params:l.params?await We(l.params,r===null||r===void 0?void 0:r.params):r===null||r===void 0?void 0:r.params})}return{url:t,options:o}}}return S({url:t},(r!==void 0||e.query!==void 0)&&{options:o})}}),uo=(e)=>{async function t(r,n){let o=S(S(S({},e),n),{},{headers:co(e===null||e===void 0?void 0:e.headers,n===null||n===void 0?void 0:n.headers),plugins:[...(e===null||e===void 0?void 0:e.plugins)||[],Ml(e||{}),...(n===null||n===void 0?void 0:n.plugins)||[]]});if(e===null||e===void 0?void 0:e.catchAllError)try{return await yr(r,o)}catch(i){return{data:null,error:{status:500,statusText:\"Fetch Error\",message:\"Fetch related error. Captured by catchAllError option. See error property for more details.\",error:i}}}return await yr(r,o)}return t};var Fl=(e)=>{if(typeof process>\"u\")return;let t=e??\"/api/auth\";if(process.env.NEXT_PUBLIC_AUTH_URL)return process.env.NEXT_PUBLIC_AUTH_URL;if(typeof window>\"u\"){if(process.env.NEXTAUTH_URL)try{return process.env.NEXTAUTH_URL}catch{}if(process.env.VERCEL_URL)try{let r=process.env.VERCEL_URL.startsWith(\"http\")?\"\":\"https://\";return`${new URL(`${r}${process.env.VERCEL_URL}`).origin}${t}`}catch{}}},lo=(e,t)=>{let r=\"credentials\"in Request.prototype,n=Wn(e?.baseURL,e?.basePath,void 0,t)??Fl(e?.basePath)??\"/api/auth\",o=e?.plugins?.flatMap((_)=>_.fetchPlugins).filter((_)=>_!==void 0)||[],i={id:\"lifecycle-hooks\",name:\"lifecycle-hooks\",hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:s,onError:a,onRequest:c,onResponse:u,...l}=e?.fetchOptions||{},p=uo({baseURL:n,...r?{credentials:\"include\"}:{},method:\"GET\",jsonParser(_){if(!_)return null;return Hn(_,{strict:!1})},customFetchImpl:fetch,...l,plugins:[i,...l.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Xn],...o]}),{$sessionSignal:d,session:m,broadcastSessionUpdate:g}=to(p,e),h=!1,v=(_)=>{if(h||_===null)return;h=!0,eo(m,_)},x=e?.plugins||[],O={},b={$sessionSignal:d,session:m},T={\"/sign-out\":\"POST\",\"/revoke-sessions\":\"POST\",\"/revoke-other-sessions\":\"POST\",\"/delete-user\":\"POST\"},k=[{signal:\"$sessionSignal\",matcher(_){return _===\"/sign-out\"||_===\"/update-user\"||_===\"/update-session\"||_===\"/sign-up/email\"||_===\"/sign-in/email\"||_===\"/delete-user\"||_===\"/verify-email\"||_===\"/revoke-sessions\"||_===\"/revoke-session\"||_===\"/revoke-other-sessions\"||_===\"/change-email\"||_===\"/change-password\"},callback(_){if(_===\"/sign-out\")g(\"signout\");else if(_===\"/update-user\"||_===\"/update-session\")g(\"updateUser\")}}];for(let _ of x){if(_.getAtoms)Object.assign(b,_.getAtoms?.(p));if(_.pathMethods)Object.assign(T,_.pathMethods);if(_.atomListeners)k.push(..._.atomListeners)}let W={notify:(_)=>{b[_].set(!b[_].get())},listen:(_,Oe)=>{b[_].subscribe(Oe)},atoms:b};for(let _ of x)if(_.getActions)O=ro(_.getActions?.(p,W,e)??{},O);return{get baseURL(){return n},pluginsActions:O,pluginsAtoms:b,pluginPathMethods:T,atomListeners:k,hydrateSession:v,$sessionSignal:d,$fetch:p,$store:W}};function fo(e){return typeof e===\"object\"&&e!==null&&\"get\"in e&&typeof e.get===\"function\"&&\"lc\"in e&&typeof e.lc===\"number\"}function po(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Bl=/[\\p{Ll}\\d]+|\\p{Lu}+(?!\\p{Ll})|\\p{Lu}[\\p{Ll}\\d]+|\\p{Lo}+/gu,Vl=/['\\u2019]/g;function ql(e){return e.replace(Vl,\"\").match(Bl)??[]}function mo(e){return ql(e).map((t)=>t.toLowerCase()).join(\"-\")}function Hl(e,t,r){let n=t[e],{fetchOptions:o,query:i,...s}=r||{};if(n)return n;if(o?.method)return o.method;if(s&&Object.keys(s).length>0)return\"POST\";return\"GET\"}function ho(e,t,r,n,o){function i(s=[]){return new Proxy(function(){},{get(a,c){if(typeof c!==\"string\")return;if(c===\"then\"||c===\"catch\"||c===\"finally\")return;let u=[...s,c],l=e;for(let p of u)if(l&&typeof l===\"object\"&&p in l)l=l[p];else{l=void 0;break}if(typeof l===\"function\")return l;if(fo(l))return l;return i(u)},apply:async(a,c,u)=>{let l=\"/\"+s.map(mo).join(\"/\"),p=u[0]||{},d=u[1]||{},{query:m,fetchOptions:g,...h}=p,v={...d,...g},x=Hl(l,r,p);return await t(l,{...v,body:x===\"GET\"?void 0:{...h,...v?.body||{}},query:m||v?.query,method:x,async onSuccess(O){if(await v?.onSuccess?.(O),!o||v.disableSignal)return;let b=o.filter((k)=>k.matcher(l));if(!b.length)return;let T=new Set;for(let k of b){let W=n[k.signal];if(!W)return;if(T.has(k.signal))continue;T.add(k.signal);let _=W.get();setTimeout(()=>{W.set(!_)},10),k.callback?.(l)}}})}})}return i()}function _r(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:n,hydrateSession:o,$fetch:i,atomListeners:s,$store:a}=lo(e),c={};for(let[u,l]of Object.entries(n))c[`use${po(u)}`]=l;return ho({...r,...c,hydrateSession:o,$fetch:i,$store:a},i,t,n,s)}var Kl=(e,{$listPasskeys:t,$store:r})=>({signIn:{passkey:async(i,s)=>{let a=await e(\"/passkey/generate-authenticate-options\",{method:\"GET\",throw:!1});if(!a.data)return a;let c=a.data.extensions||i?.extensions?{...a.data.extensions||{},...i?.extensions||{}}:void 0,u;try{u=await Zn({optionsJSON:{...a.data,extensions:c},useBrowserAutofill:i?.autoFill})}catch(l){return{data:null,error:{code:l instanceof L?l.code:\"AUTH_CANCELLED\",message:he.AUTH_CANCELLED.message,status:400,statusText:\"BAD_REQUEST\"}}}try{let{clientExtensionResults:l,...p}=u,d=await e(\"/passkey/verify-authentication\",{body:{response:p},...i?.fetchOptions,...s,method:\"POST\",throw:!1});if(t.set(Math.random()),r.notify(\"$sessionSignal\"),i?.returnWebAuthnResponse)return{...d,webauthn:{response:u,clientExtensionResults:l}};return d}catch(l){return console.error(\"[Better Auth] Error verifying passkey\",l),{data:null,error:{code:\"AUTH_CANCELLED\",message:he.AUTH_CANCELLED.message,status:400,statusText:\"BAD_REQUEST\"}}}}},passkey:{addPasskey:async(i,s)=>{let a=await e(\"/passkey/generate-register-options\",{method:\"GET\",query:{...i?.authenticatorAttachment&&{authenticatorAttachment:i.authenticatorAttachment},...i?.name&&{name:i.name},...i?.context&&{context:i.context}},throw:!1});if(!a.data)return a;try{let c=a.data.extensions||i?.extensions?{...a.data.extensions||{},...i?.extensions||{}}:void 0,u=await Ln({optionsJSON:{...a.data,extensions:c},useAutoRegister:i?.useAutoRegister}),{clientExtensionResults:l,...p}=u,d=await e(\"/passkey/verify-registration\",{...i?.fetchOptions,...s,body:{response:p,name:i?.name,...i?.createSession&&{createSession:!0}},method:\"POST\",throw:!1});if(!d.data)return d;if(t.set(Math.random()),d.data.session)r.notify(\"$sessionSignal\");if(i?.returnWebAuthnResponse)return{...d,webauthn:{response:u,clientExtensionResults:l}};return d}catch(c){if(c instanceof L){if(c.code===\"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED\")return{data:null,error:{code:c.code,message:he.PREVIOUSLY_REGISTERED.message,status:400,statusText:\"BAD_REQUEST\"}};if(c.code===\"ERROR_CEREMONY_ABORTED\")return{data:null,error:{code:c.code,message:he.REGISTRATION_CANCELLED.message,status:400,statusText:\"BAD_REQUEST\"}};return{data:null,error:{code:c.code,message:c.message,status:400,statusText:\"BAD_REQUEST\"}}}return{data:null,error:{code:\"UNKNOWN_ERROR\",message:c instanceof Error?c.message:he.UNKNOWN_ERROR.message,status:500,statusText:\"INTERNAL_SERVER_ERROR\"}}}}},$Infer:{}}),go=()=>{let e=_e();return{id:\"passkey\",version:zn,$InferServerPlugin:{},getActions:(t,r)=>Kl(t,{$listPasskeys:e,$store:r}),getAtoms(t){return{listPasskeys:pr(e,\"/passkey/list-user-passkeys\",t,{method:\"GET\"}),$listPasskeys:e}},pathMethods:{\"/passkey/register\":\"POST\",\"/passkey/authenticate\":\"POST\"},atomListeners:[{matcher(t){return t===\"/passkey/verify-registration\"||t===\"/passkey/delete-passkey\"||t===\"/passkey/update-passkey\"||t===\"/sign-out\"},signal:\"$listPasskeys\"},{matcher:(t)=>t===\"/passkey/verify-authentication\",signal:\"$sessionSignal\"}],$ERROR_CODES:he}};var yo=ft({OTP_EXPIRED:\"OTP expired\",INVALID_OTP:\"Invalid OTP\",TOO_MANY_ATTEMPTS:\"Too many attempts\"});var xr=()=>({id:\"email-otp\",version:Dn,$InferServerPlugin:{},atomListeners:[{matcher:(e)=>e===\"/email-otp/verify-email\"||e===\"/sign-in/email-otp\"||e===\"/email-otp/request-email-change\",signal:\"$sessionSignal\"}],$ERROR_CODES:yo});var xe=\"/api/email/auth\";function vf(e){return Array.isArray(e)||e instanceof Set||e instanceof Map}function wf(e,t){function r(n,o){if(n==null)return!0;else if(typeof n===\"object\"){if(o?.has(n))return!0;if(o?.add(n),Array.isArray(n))return n.length===0||(o?n.every((s)=>r(s,o)):!1);if(n instanceof Set)return n.size===0||(o?[...n].every((s)=>r(s,o)):!1);if(n instanceof Map)return n.size===0||(o?[...n.values()].every((s)=>r(s,o)):!1);let i=Object.keys(n);if(i.length===0)return!0;else if(o)return i.every((s)=>r(n[s],o));else return!1}else return!1}return r(e,t?.recursive?new Set:void 0)}function Sf(e){return e instanceof Map?e.values():e}function Tf(e){return e!=null&&typeof e!==\"string\"&&!(e instanceof String)&&!(e instanceof RegExp)&&typeof e!==\"function\"&&typeof e[Symbol.iterator]===\"function\"}function bo(...e){let t=[];for(let r of e){if(r==null||vf(r)&&wf(r))continue;t.push(Tf(r)?Sf(r):[r])}return t}function _o(e,t){if(t>0&&Array.isArray(e)){let r=Number.isFinite(t)?t-1:t;return{*[Symbol.iterator](){for(let n of e)yield*_o(n,r)}}}return[e]}function wr(e,t){return z({*[Symbol.iterator](){let r=0;for(let n of e)yield*t(n,r++)}})}function Ef(e,t){return z({*[Symbol.iterator](){let r=0;for(let n of e)yield t(n,r++)}})}function kf(e,t){return Ef(z(e),t)}function xo(e,t){return wr(z(e),function*(r,n){if(t(r,n))yield r})}function Of(...e){return xo(z(...e),(t)=>t!=null)}function Af(e,t){return wr(z(e),function*(r,n){let o=t(r,n);if(Array.isArray(o))yield*o;else yield o})}function Pf(e,...t){let r=z(...t);if(e<1)return r;return wr(r,(n)=>_o(n,e))}function Rf(...e){let t=z(...e);return z({*[Symbol.iterator](){let r=new Set;for(let n of t){if(r.has(n))continue;r.add(n),yield n}}})}function zf(e,...t){let r=z(e);if(t.length===0)return r;return z({*[Symbol.iterator](){yield*r;for(let n of t)if(Array.isArray(n))yield*n;else yield n}})}function $f(e,...t){if(e<=0)return wo;let r=z(...t);return z({*[Symbol.iterator](){let n=0;for(let o of r)if(yield o,++n>=e)return}})}function If(e,...t){let r=Object.keys(e),n=new Map(r.map((s)=>[s,[]])),o=0;for(let s of z(...t)){let a=o++;for(let c of r)if(e[c](s,a)){n.get(c).push(s);break}}let i={};for(let s of r)i[s]=n.get(s);return i}function Lf(e,t){let r=0;for(let n of z(e))if(t(n,r++))return n;return}function Nf(e,t){let r=0,n;for(let o of z(e))if(t(o,r++))n=o;return n}function Cf(e,t){let r=0;for(let n of z(e)){if(t(n,r))return r;r++}return-1}function Zf(e,t){let r=0,n=-1;for(let o of z(e)){if(t(o,r))n=r;r++}return n}function Uf(e,t){let r=0;for(let n of z(e))if(t(n,r++))return!0;return!1}function Df(e,t){let r=0;for(let n of z(e))if(!t(n,r++))return!1;return!0}function jf(e,t){let r=0;for(let n of z(e))t(n,r++)}function Mf(e,...t){let r=z(...t);if(e<0)return vo(r).at(e);let n=0;for(let o of r)if(n++===e)return o;return}function vo(...e){return[...z(...e)]}class Ie{source;buffer;iterator;exhausted;constructor(e,t,r={}){this.source=e;this.buffer=t;this.exhausted=r.exhausted??!1}get caching(){return this.buffer!==void 0}pull(){return this.iterator??=this.source[Symbol.iterator](),this.iterator.next()}*[Symbol.iterator](){if(!this.caching){if(this.exhausted)return;for(let e=this.pull();!e.done;e=this.pull())yield e.value;this.exhausted=!0}else{let e=this.buffer,t=0;for(;;){if(t<e.length){yield e[t++];continue}if(this.exhausted)return;let r=this.pull();if(r.done){this.exhausted=!0;return}e.push(r.value),yield r.value,t++}}}map(e){return kf(this,e)}filter(e){return xo(this,e)}nonNull(){return Of(this)}flatMap(e){return Af(this,e)}flat(e=1){return Pf(e,this)}distinct(){return Rf(this)}concat(...e){return zf(this,...e)}join(...e){let t=bo(this,...e);return t.length===1?this:z(...t)}take(e){return $f(e,this)}group(e){return If(e,this)}cache(){return this.caching?this:new Ie(this,[])}find(e){return Lf(this,e)}findLast(e){return Nf(this,e)}findIndex(e){return Cf(this,e)}findLastIndex(e){return Zf(this,e)}some(e){return Uf(this,e)}every(e){return Df(this,e)}forEach(e){jf(this,e)}at(e){return Mf(e,this)}toArray(){if(this.caching&&this.exhausted)return[...this.buffer];return vo(this)}}var wo=new Ie([],void 0,{exhausted:!0});function z(...e){let t=bo(...e);if(t.length===0)return wo;if(t.length===1){let r=t[0];return r instanceof Ie?r:new Ie(r,void 0)}return new Ie({*[Symbol.iterator](){for(let r of t)yield*r}},void 0)}function Tt(e){if(typeof e===\"boolean\")return e;else if(typeof e===\"string\"){if(e=e.trim().toLowerCase(),e===\"true\"||e==\"t\"||e===\"on\"||e===\"1\"||e===\"yes\"||e===\"y\")return!0;else if(e===\"false\"||e==\"f\"||e===\"off\"||e===\"0\"||e===\"no\"||e===\"n\")return!1}else if(typeof e===\"number\"){if(e===1)return!0;else if(e===0)return!1}return}var Ff=[[1,[\"ms\",\"msec\",\"millisecond\",\"milli\"]],[1000,[\"s\",\"sec\",\"second\"]],[60000,[\"m\",\"min\",\"minute\"]],[3600000,[\"h\",\"hr\",\"hour\"]],[86400000,[\"d\",\"day\"]],[604800000,[\"w\",\"wk\",\"week\"]],[2592000000,[\"mo\",\"mon\",\"month\"]],[31536000000,[\"y\",\"yr\",\"year\"]]],yy=new Map(Ff.flatMap(([e,t])=>t.map((r)=>[r,e])));function Sr(e,t){let r=t?.ttlMs??0,n;return()=>{if(n===void 0||r>0&&Date.now()>=n.expiresAt){let o=e();if(Bf(o)){let i=Promise.resolve(o),s={value:i,expiresAt:1/0};n=s,i.then(()=>{s.expiresAt=Date.now()+r},()=>{if(n===s)n=void 0})}else n={value:o,expiresAt:Date.now()+r}}return n.value}}function Bf(e){if(e!==null){if(e instanceof Promise)return!0;else if(typeof e===\"object\"&&\"then\"in e&&typeof e.then===\"function\")return!0}return!1}var{process:oe,Bun:Ir}=globalThis,Co=oe&&typeof oe.stderr?.write===\"function\"?oe.stderr:void 0,Zo=oe&&typeof oe.stdout?.write===\"function\"?oe.stdout:void 0,$t=[\"debug\",\"info\",\"warn\",\"error\"],Lr=Object.fromEntries($t.map((e,t)=>[e,t])),cp=Object.fromEntries($t.map((e)=>{let t=\"\\x1B[90m\";switch(e){case\"info\":t=\"\\x1B[34m\";break;case\"warn\":t=\"\\x1B[33m\";break;case\"error\":t=\"\\x1B[31m\";break}return[e,t]})),Uo=\"\\x1B[0m\",up=\"info\";async function lp(e,t){let n=e===void 0&&t===void 0?void 0:await Promise.resolve().then(() => (No(),Lo)).catch(()=>{return});return Do(e,t,n)}function Do(e,t,r){let n=Ir!==void 0&&!Tt(Ir.env?.LOG_BUN_CONSOLE_DISABLED)?Ir.inspect:void 0,o=n!==void 0,i=(c,u)=>{if(Array.isArray(c)||typeof c===\"object\"&&c!==null)if(n!==void 0)return n(c,{colors:u,depth:r?.inspect?.defaultOptions?.depth??void 0});else if(r!==void 0)return r.inspect(c,{...r?.inspect?.defaultOptions,colors:!1});else{let l=new WeakSet;return JSON.stringify(c,(p,d)=>{if(typeof d===\"object\"&&d!==null){if(l.has(d))return\"[Circular]\";l.add(d)}if(d instanceof Error){let m=d;return{...Object.fromEntries(Object.entries(m)),name:m.name,message:m.message,stack:m.stack,...m.cause===void 0?{}:{cause:m.cause},...m.errors===void 0?{}:{errors:m.errors}}}return d})}else return String(c)},s=(c)=>{let u=Object.fromEntries($t.map((l)=>{let d=(l===\"warn\"||l===\"error\"?t:e)??t??e,m=dp(c,d,o),{prefix:g,colors:h,resetColors:v}=m(l);return[l,(...O)=>{if(!hp(l,!0))return;if(d!==void 0){let b=g?[g]:[];if(b.push(...O.map((T)=>i(T,h))),v)b.push(Uo);d.write(b.join(\" \")+`\n`)}else{let b=console[l];if(typeof b!==\"function\")b=console.log;if(g)b=b.bind(console,g);b(...O)}}]}));return u.success=u.info,u.start=u.info,u},a=Sr(s);return(c)=>c?s(c):a()}var fp=Sr(async()=>lp(Zo,Co)),zt=Do(Zo,Co);fp().then((e)=>{zt=e},()=>{});function pp(e){let t,r=()=>{if(t?.factory!==zt)t={factory:zt,logger:zt(e)};return t.logger};return Object.fromEntries([...$t,\"success\",\"start\"].map((n)=>[n,(...o)=>r()[n](...o)]))}function dp(e,t,r){let n=globalThis,o=n.window!==void 0&&n.document!==void 0,i=!o?mp(t):!1,s=e?\"[\"+e+\"]\":void 0;return(a)=>{let c=i&&a!==void 0?cp[a]:void 0,u=[!o&&a?a.toUpperCase():void 0,s].filter(Boolean).join(\" \"),l=!1;if(c){let p=r||a===\"info\";if(!p)l=!0;u=p?c+u+Uo:c+u}return{prefix:u,colors:c?!0:!1,resetColors:l}}}function mp(e){if(oe===void 0||typeof e!==\"object\"||e===null)return!1;let{isTTY:t}=e;if(t!==!0)return!1;if(oe.env?.TERM?.toLowerCase()==\"dumb\")return!1;return!0}function jo(e){if(e===void 0||e===null)return;let t=typeof e===\"string\"?e:String(e);for(let r=0;r<2;r++){if(r>0){let n=t.trim().toLowerCase();if(t===n)break;t=n}if(!t)break;else if(t in Lr)return t}return}function Mo(){return jo(oe?.env?.LOG_LEVEL)??up}function hp(e,t){let r=jo(e);if(r===void 0)return t??!1;return Lr[r]>=Lr[Mo()]}var gp=/^(?:[a-z][a-z0-9+.-]*:\\/\\/)?.*\\/([^/.]+)(?:\\.[^/]+)?$/i;function Fo(e){if(!e)return;if(typeof e===\"string\")return e.match(gp)?.[1]??e;return Fo(e.name)}function It(e){let t=Fo(e);return pp(t)}var Sy=Object.freeze({status:\"aborted\"});function f(e,t,r){function n(a,c){if(!a._zod)Object.defineProperty(a,\"_zod\",{value:{def:c,constr:s,traits:new Set},enumerable:!1});if(a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);let u=s.prototype,l=Object.keys(u);for(let p=0;p<l.length;p++){let d=l[p];if(!(d in a))a[d]=u[d].bind(a)}}let o=r?.Parent??Object;class i extends o{}Object.defineProperty(i,\"name\",{value:e});function s(a){var c;let u=r?.Parent?new i:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(s,\"init\",{value:n}),Object.defineProperty(s,Symbol.hasInstance,{value:(a)=>{if(r?.Parent&&a instanceof r.Parent)return!0;return a?._zod?.traits?.has(e)}}),Object.defineProperty(s,\"name\",{value:e}),s}var Ty=Symbol(\"zod_brand\");class ie extends Error{constructor(){super(\"Encountered Promise during synchronous parse. Use .parseAsync() instead.\")}}class Xe extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`);this.name=\"ZodEncodeError\"}}var Lt={};function G(e){if(e)Object.assign(Lt,e);return Lt}function Ct(e){let t=Object.values(e).filter((n)=>typeof n===\"number\");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function Cr(e,t=\"|\"){return e.map((r)=>jr(r)).join(t)}function et(e,t){if(typeof t===\"bigint\")return t.toString();return t}function Zt(e){return{get value(){{let r=e();return Object.defineProperty(this,\"value\",{value:r}),r}throw Error(\"cached value already set\")}}}function Ut(e){return e===null||e===void 0}function Dt(e){let t=e.startsWith(\"^\")?1:0,r=e.endsWith(\"$\")?e.length-1:e.length;return e.slice(t,r)}function Vo(e,t){let r=(e.toString().split(\".\")[1]||\"\").length,n=t.toString(),o=(n.split(\".\")[1]||\"\").length;if(o===0&&/\\d?e-\\d?/.test(n)){let c=n.match(/\\d?e-(\\d?)/);if(c?.[1])o=Number.parseInt(c[1])}let i=r>o?r:o,s=Number.parseInt(e.toFixed(i).replace(\".\",\"\")),a=Number.parseInt(t.toFixed(i).replace(\".\",\"\"));return s%a/10**i}var Bo=Symbol(\"evaluating\");function E(e,t,r){let n=void 0;Object.defineProperty(e,t,{get(){if(n===Bo)return;if(n===void 0)n=Bo,n=r();return n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function we(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function le(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Zr(e){return JSON.stringify(e)}function qo(e){return e.toLowerCase().trim().replace(/[^\\w\\s-]/g,\"\").replace(/[\\s_-]+/g,\"-\").replace(/^-+|-+$/g,\"\")}var Ur=\"captureStackTrace\"in Error?Error.captureStackTrace:(...e)=>{};function Qe(e){return typeof e===\"object\"&&e!==null&&!Array.isArray(e)}var Ho=Zt(()=>{if(typeof navigator<\"u\"&&navigator?.userAgent?.includes(\"Cloudflare\"))return!1;try{return new Function(\"\"),!0}catch(e){return!1}});function Se(e){if(Qe(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;if(typeof t!==\"function\")return!0;let r=t.prototype;if(Qe(r)===!1)return!1;if(Object.prototype.hasOwnProperty.call(r,\"isPrototypeOf\")===!1)return!1;return!0}function Dr(e){if(Se(e))return{...e};if(Array.isArray(e))return[...e];return e}var Ko=new Set([\"string\",\"number\",\"symbol\"]);function fe(e){return e.replace(/[.*+?^${}()|[\\]\\\\]/g,\"\\\\$&\")}function re(e,t,r){let n=new e._zod.constr(t??e._zod.def);if(!t||r?.parent)n._zod.parent=e;return n}function y(e){let t=e;if(!t)return{};if(typeof t===\"string\")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error(\"Cannot specify both `message` and `error` params\");t.error=t.message}if(delete t.message,typeof t.error===\"string\")return{...t,error:()=>t.error};return t}function jr(e){if(typeof e===\"bigint\")return e.toString()+\"n\";if(typeof e===\"string\")return`\"${e}\"`;return`${e}`}function Jo(e){return Object.keys(e).filter((t)=>e[t]._zod.optin===\"optional\"&&e[t]._zod.optout===\"optional\")}var Go={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function xp(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(\".pick() cannot be used on object schemas containing refinements\");let i=le(e._zod.def,{get shape(){let s={};for(let a in t){if(!(a in r.shape))throw Error(`Unrecognized key: \"${a}\"`);if(!t[a])continue;s[a]=r.shape[a]}return we(this,\"shape\",s),s},checks:[]});return re(e,i)}function vp(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(\".omit() cannot be used on object schemas containing refinements\");let i=le(e._zod.def,{get shape(){let s={...e._zod.def.shape};for(let a in t){if(!(a in r.shape))throw Error(`Unrecognized key: \"${a}\"`);if(!t[a])continue;delete s[a]}return we(this,\"shape\",s),s},checks:[]});return re(e,i)}function wp(e,t){if(!Se(t))throw Error(\"Invalid input to extend: expected a plain object\");let r=e._zod.def.checks;if(r&&r.length>0){let i=e._zod.def.shape;for(let s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw Error(\"Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.\")}let o=le(e._zod.def,{get shape(){let i={...e._zod.def.shape,...t};return we(this,\"shape\",i),i}});return re(e,o)}function Sp(e,t){if(!Se(t))throw Error(\"Invalid input to safeExtend: expected a plain object\");let r=le(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return we(this,\"shape\",n),n}});return re(e,r)}function Tp(e,t){let r=le(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return we(this,\"shape\",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return re(e,r)}function Ep(e,t,r){let o=t._zod.def.checks;if(o&&o.length>0)throw Error(\".partial() cannot be used on object schemas containing refinements\");let s=le(t._zod.def,{get shape(){let a=t._zod.def.shape,c={...a};if(r)for(let u in r){if(!(u in a))throw Error(`Unrecognized key: \"${u}\"`);if(!r[u])continue;c[u]=e?new e({type:\"optional\",innerType:a[u]}):a[u]}else for(let u in a)c[u]=e?new e({type:\"optional\",innerType:a[u]}):a[u];return we(this,\"shape\",c),c},checks:[]});return re(t,s)}function kp(e,t,r){let n=le(t._zod.def,{get shape(){let o=t._zod.def.shape,i={...o};if(r)for(let s in r){if(!(s in i))throw Error(`Unrecognized key: \"${s}\"`);if(!r[s])continue;i[s]=new e({type:\"nonoptional\",innerType:o[s]})}else for(let s in o)i[s]=new e({type:\"nonoptional\",innerType:o[s]});return we(this,\"shape\",i),i}});return re(t,n)}function Te(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function pe(e,t){return t.map((r)=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Nt(e){return typeof e===\"string\"?e:e?.message}function ne(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let o=Nt(e.inst?._zod.def?.error?.(e))??Nt(t?.error?.(e))??Nt(r.customError?.(e))??Nt(r.localeError?.(e))??\"Invalid input\";n.message=o}if(delete n.inst,delete n.continue,!t?.reportInput)delete n.input;return n}function jt(e){if(Array.isArray(e))return\"array\";if(typeof e===\"string\")return\"string\";return\"unknown\"}function Wo(e){let t=typeof e;switch(t){case\"number\":return Number.isNaN(e)?\"nan\":\"number\";case\"object\":{if(e===null)return\"null\";if(Array.isArray(e))return\"array\";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&\"constructor\"in r&&r.constructor)return r.constructor.name}}return t}function Ee(...e){let[t,r,n]=e;if(typeof t===\"string\")return{message:t,code:\"custom\",input:r,inst:n};return{...t}}var Yo=(e,t)=>{e.name=\"$ZodError\",Object.defineProperty(e,\"_zod\",{value:e._zod,enumerable:!1}),Object.defineProperty(e,\"issues\",{value:t,enumerable:!1}),e.message=JSON.stringify(t,et,2),Object.defineProperty(e,\"toString\",{value:()=>e.message,enumerable:!1})},Mt=f(\"$ZodError\",Yo),Mr=f(\"$ZodError\",Yo,{Parent:Error});function Xo(e,t=(r)=>r.message){let r={},n=[];for(let o of e.issues)if(o.path.length>0)r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o));else n.push(t(o));return{formErrors:n,fieldErrors:r}}function Qo(e,t=(r)=>r.message){let r={_errors:[]},n=(o)=>{for(let i of o.issues)if(i.code===\"invalid_union\"&&i.errors.length)i.errors.map((s)=>n({issues:s}));else if(i.code===\"invalid_key\")n({issues:i.issues});else if(i.code===\"invalid_element\")n({issues:i.issues});else if(i.path.length===0)r._errors.push(t(i));else{let s=r,a=0;while(a<i.path.length){let c=i.path[a];if(a!==i.path.length-1)s[c]=s[c]||{_errors:[]};else s[c]=s[c]||{_errors:[]},s[c]._errors.push(t(i));s=s[c],a++}}};return n(e),r}var Ft=(e)=>(t,r,n,o)=>{let i=n?Object.assign(n,{async:!1}):{async:!1},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)throw new ie;if(s.issues.length){let a=new(o?.Err??e)(s.issues.map((c)=>ne(c,i,G())));throw Ur(a,o?.callee),a}return s.value};var Bt=(e)=>async(t,r,n,o)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},i);if(s instanceof Promise)s=await s;if(s.issues.length){let a=new(o?.Err??e)(s.issues.map((c)=>ne(c,i,G())));throw Ur(a,o?.callee),a}return s.value};var tt=(e)=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)throw new ie;return i.issues.length?{success:!1,error:new(e??Mt)(i.issues.map((s)=>ne(s,o,G())))}:{success:!0,data:i.value}},ei=tt(Mr),rt=(e)=>async(t,r,n)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},i=t._zod.run({value:r,issues:[]},o);if(i instanceof Promise)i=await i;return i.issues.length?{success:!1,error:new e(i.issues.map((s)=>ne(s,o,G())))}:{success:!0,data:i.value}},ti=rt(Mr),ri=(e)=>(t,r,n)=>{let o=n?Object.assign(n,{direction:\"backward\"}):{direction:\"backward\"};return Ft(e)(t,r,o)};var ni=(e)=>(t,r,n)=>Ft(e)(t,r,n);var oi=(e)=>async(t,r,n)=>{let o=n?Object.assign(n,{direction:\"backward\"}):{direction:\"backward\"};return Bt(e)(t,r,o)};var ii=(e)=>async(t,r,n)=>Bt(e)(t,r,n);var si=(e)=>(t,r,n)=>{let o=n?Object.assign(n,{direction:\"backward\"}):{direction:\"backward\"};return tt(e)(t,r,o)};var ai=(e)=>(t,r,n)=>tt(e)(t,r,n);var ci=(e)=>async(t,r,n)=>{let o=n?Object.assign(n,{direction:\"backward\"}):{direction:\"backward\"};return rt(e)(t,r,o)};var ui=(e)=>async(t,r,n)=>rt(e)(t,r,n);var li=/^[cC][^\\s-]{8,}$/,fi=/^[0-9a-z]+$/,pi=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,di=/^[0-9a-vA-V]{20}$/,mi=/^[A-Za-z0-9]{27}$/,hi=/^[a-zA-Z0-9_-]{21}$/,gi=/^P(?:(\\d+W)|(?!.*W)(?=\\d|T\\d)(\\d+Y)?(\\d+M)?(\\d+D)?(T(?=\\d)(\\d+H)?(\\d+M)?(\\d+([.,]\\d+)?S)?)?)$/;var yi=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Fr=(e)=>{if(!e)return/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)};var bi=/^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$/;var Ap=\"^(\\\\p{Extended_Pictographic}|\\\\p{Emoji_Component})+$\";function _i(){return new RegExp(Ap,\"u\")}var xi=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,vi=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var wi=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\\/([0-9]|[1-2][0-9]|3[0-2])$/,Si=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ti=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Br=/^[A-Za-z0-9_-]*$/;var Ei=/^\\+[1-9]\\d{6,14}$/,ki=\"(?:(?:\\\\d\\\\d[2468][048]|\\\\d\\\\d[13579][26]|\\\\d\\\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\\\d|30)|(?:02)-(?:0[1-9]|1\\\\d|2[0-8])))\",Oi=new RegExp(`^${ki}$`);function Ai(e){return typeof e.precision===\"number\"?e.precision===-1?\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d\":e.precision===0?\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d:[0-5]\\\\d\":`(?:[01]\\\\d|2[0-3]):[0-5]\\\\d:[0-5]\\\\d\\\\.\\\\d{${e.precision}}`:\"(?:[01]\\\\d|2[0-3]):[0-5]\\\\d(?::[0-5]\\\\d(?:\\\\.\\\\d+)?)?\"}function Pi(e){return new RegExp(`^${Ai(e)}$`)}function Ri(e){let t=Ai({precision:e.precision}),r=[\"Z\"];if(e.local)r.push(\"\");if(e.offset)r.push(\"([+-](?:[01]\\\\d|2[0-3]):[0-5]\\\\d)\");let n=`${t}(?:${r.join(\"|\")})`;return new RegExp(`^${ki}T(?:${n})$`)}var zi=(e)=>{let t=e?`[\\\\s\\\\S]{${e?.minimum??0},${e?.maximum??\"\"}}`:\"[\\\\s\\\\S]*\";return new RegExp(`^${t}$`)},$i=/^-?\\d+n?$/,Ii=/^-?\\d+$/,Vr=/^-?\\d+(?:\\.\\d+)?$/,Li=/^(?:true|false)$/i;var Ni=/^[^A-Z]*$/,Ci=/^[^a-z]*$/;var U=f(\"$ZodCheck\",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Zi={number:\"number\",bigint:\"bigint\",object:\"date\"},qr=f(\"$ZodCheckLessThan\",(e,t)=>{U.init(e,t);let r=Zi[typeof t.value];e._zod.onattach.push((n)=>{let o=n._zod.bag,i=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(t.value<i)if(t.inclusive)o.maximum=t.value;else o.exclusiveMaximum=t.value}),e._zod.check=(n)=>{if(t.inclusive?n.value<=t.value:n.value<t.value)return;n.issues.push({origin:r,code:\"too_big\",maximum:typeof t.value===\"object\"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Hr=f(\"$ZodCheckGreaterThan\",(e,t)=>{U.init(e,t);let r=Zi[typeof t.value];e._zod.onattach.push((n)=>{let o=n._zod.bag,i=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(t.value>i)if(t.inclusive)o.minimum=t.value;else o.exclusiveMinimum=t.value}),e._zod.check=(n)=>{if(t.inclusive?n.value>=t.value:n.value>t.value)return;n.issues.push({origin:r,code:\"too_small\",minimum:typeof t.value===\"object\"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ui=f(\"$ZodCheckMultipleOf\",(e,t)=>{U.init(e,t),e._zod.onattach.push((r)=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=(r)=>{if(typeof r.value!==typeof t.value)throw Error(\"Cannot mix number and bigint in multiple_of check.\");if(typeof r.value===\"bigint\"?r.value%t.value===BigInt(0):Vo(r.value,t.value)===0)return;r.issues.push({origin:typeof r.value,code:\"not_multiple_of\",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Di=f(\"$ZodCheckNumberFormat\",(e,t)=>{U.init(e,t),t.format=t.format||\"float64\";let r=t.format?.includes(\"int\"),n=r?\"int\":\"number\",[o,i]=Go[t.format];e._zod.onattach.push((s)=>{let a=s._zod.bag;if(a.format=t.format,a.minimum=o,a.maximum=i,r)a.pattern=Ii}),e._zod.check=(s)=>{let a=s.value;if(r){if(!Number.isInteger(a)){s.issues.push({expected:n,format:t.format,code:\"invalid_type\",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){if(a>0)s.issues.push({input:a,code:\"too_big\",maximum:Number.MAX_SAFE_INTEGER,note:\"Integers must be within the safe integer range.\",inst:e,origin:n,inclusive:!0,continue:!t.abort});else s.issues.push({input:a,code:\"too_small\",minimum:Number.MIN_SAFE_INTEGER,note:\"Integers must be within the safe integer range.\",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}if(a<o)s.issues.push({origin:\"number\",input:a,code:\"too_small\",minimum:o,inclusive:!0,inst:e,continue:!t.abort});if(a>i)s.issues.push({origin:\"number\",input:a,code:\"too_big\",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}});var ji=f(\"$ZodCheckMaxLength\",(e,t)=>{var r;U.init(e,t),(r=e._zod.def).when??(r.when=(n)=>{let o=n.value;return!Ut(o)&&o.length!==void 0}),e._zod.onattach.push((n)=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;if(t.maximum<o)n._zod.bag.maximum=t.maximum}),e._zod.check=(n)=>{let o=n.value;if(o.length<=t.maximum)return;let s=jt(o);n.issues.push({origin:s,code:\"too_big\",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Mi=f(\"$ZodCheckMinLength\",(e,t)=>{var r;U.init(e,t),(r=e._zod.def).when??(r.when=(n)=>{let o=n.value;return!Ut(o)&&o.length!==void 0}),e._zod.onattach.push((n)=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(t.minimum>o)n._zod.bag.minimum=t.minimum}),e._zod.check=(n)=>{let o=n.value;if(o.length>=t.minimum)return;let s=jt(o);n.issues.push({origin:s,code:\"too_small\",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Fi=f(\"$ZodCheckLengthEquals\",(e,t)=>{var r;U.init(e,t),(r=e._zod.def).when??(r.when=(n)=>{let o=n.value;return!Ut(o)&&o.length!==void 0}),e._zod.onattach.push((n)=>{let o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=(n)=>{let o=n.value,i=o.length;if(i===t.length)return;let s=jt(o),a=i>t.length;n.issues.push({origin:s,...a?{code:\"too_big\",maximum:t.length}:{code:\"too_small\",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),nt=f(\"$ZodCheckStringFormat\",(e,t)=>{var r,n;if(U.init(e,t),e._zod.onattach.push((o)=>{let i=o._zod.bag;if(i.format=t.format,t.pattern)i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern)}),t.pattern)(r=e._zod).check??(r.check=(o)=>{if(t.pattern.lastIndex=0,t.pattern.test(o.value))return;o.issues.push({origin:\"string\",code:\"invalid_format\",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})});else(n=e._zod).check??(n.check=()=>{})}),Bi=f(\"$ZodCheckRegex\",(e,t)=>{nt.init(e,t),e._zod.check=(r)=>{if(t.pattern.lastIndex=0,t.pattern.test(r.value))return;r.issues.push({origin:\"string\",code:\"invalid_format\",format:\"regex\",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Vi=f(\"$ZodCheckLowerCase\",(e,t)=>{t.pattern??(t.pattern=Ni),nt.init(e,t)}),qi=f(\"$ZodCheckUpperCase\",(e,t)=>{t.pattern??(t.pattern=Ci),nt.init(e,t)}),Hi=f(\"$ZodCheckIncludes\",(e,t)=>{U.init(e,t);let r=fe(t.includes),n=new RegExp(typeof t.position===\"number\"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push((o)=>{let i=o._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(n)}),e._zod.check=(o)=>{if(o.value.includes(t.includes,t.position))return;o.issues.push({origin:\"string\",code:\"invalid_format\",format:\"includes\",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Ki=f(\"$ZodCheckStartsWith\",(e,t)=>{U.init(e,t);let r=new RegExp(`^${fe(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push((n)=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=(n)=>{if(n.value.startsWith(t.prefix))return;n.issues.push({origin:\"string\",code:\"invalid_format\",format:\"starts_with\",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Ji=f(\"$ZodCheckEndsWith\",(e,t)=>{U.init(e,t);let r=new RegExp(`.*${fe(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push((n)=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=(n)=>{if(n.value.endsWith(t.suffix))return;n.issues.push({origin:\"string\",code:\"invalid_format\",format:\"ends_with\",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var Gi=f(\"$ZodCheckOverwrite\",(e,t)=>{U.init(e,t),e._zod.check=(r)=>{r.value=t.tx(r.value)}});class Kr{constructor(e=[]){if(this.content=[],this.indent=0,this)this.args=e}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e===\"function\"){e(this,{execution:\"sync\"}),e(this,{execution:\"async\"});return}let r=e.split(`\n`).filter((i)=>i),n=Math.min(...r.map((i)=>i.length-i.trimStart().length)),o=r.map((i)=>i.slice(n)).map((i)=>\" \".repeat(this.indent*2)+i);for(let i of o)this.content.push(i)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[\"\"]).map((o)=>` ${o}`)];return new e(...t,n.join(`\n`))}}var Yi={major:4,minor:3,patch:6};var A=f(\"$ZodType\",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Yi;let n=[...e._zod.def.checks??[]];if(e._zod.traits.has(\"$ZodCheck\"))n.unshift(e);for(let o of n)for(let i of o._zod.onattach)i(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(s,a,c)=>{let u=Te(s),l;for(let p of a){if(p._zod.def.when){if(!p._zod.def.when(s))continue}else if(u)continue;let d=s.issues.length,m=p._zod.check(s);if(m instanceof Promise&&c?.async===!1)throw new ie;if(l||m instanceof Promise)l=(l??Promise.resolve()).then(async()=>{if(await m,s.issues.length===d)return;if(!u)u=Te(s,d)});else{if(s.issues.length===d)continue;if(!u)u=Te(s,d)}}if(l)return l.then(()=>s);return s},i=(s,a,c)=>{if(Te(s))return s.aborted=!0,s;let u=o(a,n,c);if(u instanceof Promise){if(c.async===!1)throw new ie;return u.then((l)=>e._zod.parse(l,c))}return e._zod.parse(u,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction===\"backward\"){let u=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});if(u instanceof Promise)return u.then((l)=>i(l,s,a));return i(u,s,a)}let c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new ie;return c.then((u)=>o(u,n,a))}return o(c,n,a)}}E(e,\"~standard\",()=>({validate:(o)=>{try{let i=ei(e,o);return i.success?{value:i.data}:{issues:i.error?.issues}}catch(i){return ti(e,o).then((s)=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:\"zod\",version:1}))}),Kt=f(\"$ZodString\",(e,t)=>{A.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??zi(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(o){}if(typeof r.value===\"string\")return r;return r.issues.push({expected:\"string\",code:\"invalid_type\",input:r.value,inst:e}),r}}),P=f(\"$ZodStringFormat\",(e,t)=>{nt.init(e,t),Kt.init(e,t)}),ss=f(\"$ZodGUID\",(e,t)=>{t.pattern??(t.pattern=yi),P.init(e,t)}),as=f(\"$ZodUUID\",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw Error(`Invalid UUID version: \"${t.version}\"`);t.pattern??(t.pattern=Fr(n))}else t.pattern??(t.pattern=Fr());P.init(e,t)}),cs=f(\"$ZodEmail\",(e,t)=>{t.pattern??(t.pattern=bi),P.init(e,t)}),us=f(\"$ZodURL\",(e,t)=>{P.init(e,t),e._zod.check=(r)=>{try{let n=r.value.trim(),o=new URL(n);if(t.hostname){if(t.hostname.lastIndex=0,!t.hostname.test(o.hostname))r.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid hostname\",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})}if(t.protocol){if(t.protocol.lastIndex=0,!t.protocol.test(o.protocol.endsWith(\":\")?o.protocol.slice(0,-1):o.protocol))r.issues.push({code:\"invalid_format\",format:\"url\",note:\"Invalid protocol\",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})}if(t.normalize)r.value=o.href;else r.value=n;return}catch(n){r.issues.push({code:\"invalid_format\",format:\"url\",input:r.value,inst:e,continue:!t.abort})}}}),ls=f(\"$ZodEmoji\",(e,t)=>{t.pattern??(t.pattern=_i()),P.init(e,t)}),fs=f(\"$ZodNanoID\",(e,t)=>{t.pattern??(t.pattern=hi),P.init(e,t)}),ps=f(\"$ZodCUID\",(e,t)=>{t.pattern??(t.pattern=li),P.init(e,t)}),ds=f(\"$ZodCUID2\",(e,t)=>{t.pattern??(t.pattern=fi),P.init(e,t)}),ms=f(\"$ZodULID\",(e,t)=>{t.pattern??(t.pattern=pi),P.init(e,t)}),hs=f(\"$ZodXID\",(e,t)=>{t.pattern??(t.pattern=di),P.init(e,t)}),gs=f(\"$ZodKSUID\",(e,t)=>{t.pattern??(t.pattern=mi),P.init(e,t)}),ys=f(\"$ZodISODateTime\",(e,t)=>{t.pattern??(t.pattern=Ri(t)),P.init(e,t)}),bs=f(\"$ZodISODate\",(e,t)=>{t.pattern??(t.pattern=Oi),P.init(e,t)}),_s=f(\"$ZodISOTime\",(e,t)=>{t.pattern??(t.pattern=Pi(t)),P.init(e,t)}),xs=f(\"$ZodISODuration\",(e,t)=>{t.pattern??(t.pattern=gi),P.init(e,t)}),vs=f(\"$ZodIPv4\",(e,t)=>{t.pattern??(t.pattern=xi),P.init(e,t),e._zod.bag.format=\"ipv4\"}),ws=f(\"$ZodIPv6\",(e,t)=>{t.pattern??(t.pattern=vi),P.init(e,t),e._zod.bag.format=\"ipv6\",e._zod.check=(r)=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:\"invalid_format\",format:\"ipv6\",input:r.value,inst:e,continue:!t.abort})}}});var Ss=f(\"$ZodCIDRv4\",(e,t)=>{t.pattern??(t.pattern=wi),P.init(e,t)}),Ts=f(\"$ZodCIDRv6\",(e,t)=>{t.pattern??(t.pattern=Si),P.init(e,t),e._zod.check=(r)=>{let n=r.value.split(\"/\");try{if(n.length!==2)throw Error();let[o,i]=n;if(!i)throw Error();let s=Number(i);if(`${s}`!==i)throw Error();if(s<0||s>128)throw Error();new URL(`http://[${o}]`)}catch{r.issues.push({code:\"invalid_format\",format:\"cidrv6\",input:r.value,inst:e,continue:!t.abort})}}});function Es(e){if(e===\"\")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var ks=f(\"$ZodBase64\",(e,t)=>{t.pattern??(t.pattern=Ti),P.init(e,t),e._zod.bag.contentEncoding=\"base64\",e._zod.check=(r)=>{if(Es(r.value))return;r.issues.push({code:\"invalid_format\",format:\"base64\",input:r.value,inst:e,continue:!t.abort})}});function Pp(e){if(!Br.test(e))return!1;let t=e.replace(/[-_]/g,(n)=>n===\"-\"?\"+\":\"/\"),r=t.padEnd(Math.ceil(t.length/4)*4,\"=\");return Es(r)}var Os=f(\"$ZodBase64URL\",(e,t)=>{t.pattern??(t.pattern=Br),P.init(e,t),e._zod.bag.contentEncoding=\"base64url\",e._zod.check=(r)=>{if(Pp(r.value))return;r.issues.push({code:\"invalid_format\",format:\"base64url\",input:r.value,inst:e,continue:!t.abort})}}),As=f(\"$ZodE164\",(e,t)=>{t.pattern??(t.pattern=Ei),P.init(e,t)});function Rp(e,t=null){try{let r=e.split(\".\");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));if(\"typ\"in o&&o?.typ!==\"JWT\")return!1;if(!o.alg)return!1;if(t&&(!(\"alg\"in o)||o.alg!==t))return!1;return!0}catch{return!1}}var Ps=f(\"$ZodJWT\",(e,t)=>{P.init(e,t),e._zod.check=(r)=>{if(Rp(r.value,t.alg))return;r.issues.push({code:\"invalid_format\",format:\"jwt\",input:r.value,inst:e,continue:!t.abort})}});var Gr=f(\"$ZodNumber\",(e,t)=>{A.init(e,t),e._zod.pattern=e._zod.bag.pattern??Vr,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(s){}let o=r.value;if(typeof o===\"number\"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let i=typeof o===\"number\"?Number.isNaN(o)?\"NaN\":!Number.isFinite(o)?\"Infinity\":void 0:void 0;return r.issues.push({expected:\"number\",code:\"invalid_type\",input:o,inst:e,...i?{received:i}:{}}),r}}),Rs=f(\"$ZodNumberFormat\",(e,t)=>{Di.init(e,t),Gr.init(e,t)}),zs=f(\"$ZodBoolean\",(e,t)=>{A.init(e,t),e._zod.pattern=Li,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(i){}let o=r.value;if(typeof o===\"boolean\")return r;return r.issues.push({expected:\"boolean\",code:\"invalid_type\",input:o,inst:e}),r}}),$s=f(\"$ZodBigInt\",(e,t)=>{A.init(e,t),e._zod.pattern=$i,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch(o){}if(typeof r.value===\"bigint\")return r;return r.issues.push({expected:\"bigint\",code:\"invalid_type\",input:r.value,inst:e}),r}});var Is=f(\"$ZodUnknown\",(e,t)=>{A.init(e,t),e._zod.parse=(r)=>r}),Ls=f(\"$ZodNever\",(e,t)=>{A.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:\"never\",code:\"invalid_type\",input:r.value,inst:e}),r)});var Ns=f(\"$ZodDate\",(e,t)=>{A.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch(a){}let o=r.value,i=o instanceof Date;if(i&&!Number.isNaN(o.getTime()))return r;return r.issues.push({expected:\"date\",code:\"invalid_type\",input:o,...i?{received:\"Invalid Date\"}:{},inst:e}),r}});function Xi(e,t,r){if(e.issues.length)t.issues.push(...pe(r,e.issues));t.value[r]=e.value}var Cs=f(\"$ZodArray\",(e,t)=>{A.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:\"array\",code:\"invalid_type\",input:o,inst:e}),r;r.value=Array(o.length);let i=[];for(let s=0;s<o.length;s++){let a=o[s],c=t.element._zod.run({value:a,issues:[]},n);if(c instanceof Promise)i.push(c.then((u)=>Xi(u,r,s)));else Xi(c,r,s)}if(i.length)return Promise.all(i).then(()=>r);return r}});function Ht(e,t,r,n,o){if(e.issues.length){if(o&&!(r in n))return;t.issues.push(...pe(r,e.issues))}if(e.value===void 0){if(r in n)t.value[r]=void 0}else t.value[r]=e.value}function Zs(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(\"$ZodType\"))throw Error(`Invalid element at key \"${n}\": expected a Zod schema`);let r=Jo(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Us(e,t,r,n,o,i){let s=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,l=c.optout===\"optional\";for(let p in t){if(a.has(p))continue;if(u===\"never\"){s.push(p);continue}let d=c.run({value:t[p],issues:[]},n);if(d instanceof Promise)e.push(d.then((m)=>Ht(m,r,p,t,l)));else Ht(d,r,p,t,l)}if(s.length)r.issues.push({code:\"unrecognized_keys\",keys:s,input:t,inst:i});if(!e.length)return r;return Promise.all(e).then(()=>r)}var zp=f(\"$ZodObject\",(e,t)=>{if(A.init(e,t),!Object.getOwnPropertyDescriptor(t,\"shape\")?.get){let a=t.shape;Object.defineProperty(t,\"shape\",{get:()=>{let c={...a};return Object.defineProperty(t,\"shape\",{value:c}),c}})}let n=Zt(()=>Zs(t));E(e._zod,\"propValues\",()=>{let a=t.shape,c={};for(let u in a){let l=a[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let p of l.values)c[u].add(p)}}return c});let o=Qe,i=t.catchall,s;e._zod.parse=(a,c)=>{s??(s=n.value);let u=a.value;if(!o(u))return a.issues.push({expected:\"object\",code:\"invalid_type\",input:u,inst:e}),a;a.value={};let l=[],p=s.shape;for(let d of s.keys){let m=p[d],g=m._zod.optout===\"optional\",h=m._zod.run({value:u[d],issues:[]},c);if(h instanceof Promise)l.push(h.then((v)=>Ht(v,a,d,u,g)));else Ht(h,a,d,u,g)}if(!i)return l.length?Promise.all(l).then(()=>a):a;return Us(l,u,a,c,n.value,e)}}),Ds=f(\"$ZodObjectJIT\",(e,t)=>{zp.init(e,t);let r=e._zod.parse,n=Zt(()=>Zs(t)),o=(d)=>{let m=new Kr([\"shape\",\"payload\",\"ctx\"]),g=n.value,h=(b)=>{let T=Zr(b);return`shape[${T}]._zod.run({ value: input[${T}], issues: [] }, ctx)`};m.write(\"const input = payload.value;\");let v=Object.create(null),x=0;for(let b of g.keys)v[b]=`key_${x++}`;m.write(\"const newResult = {};\");for(let b of g.keys){let T=v[b],k=Zr(b),_=d[b]?._zod?.optout===\"optional\";if(m.write(`const ${T} = ${h(b)};`),_)m.write(`\n if (${T}.issues.length) {\n if (${k} in input) {\n payload.issues = payload.issues.concat(${T}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${k}, ...iss.path] : [${k}]\n })));\n }\n }\n \n if (${T}.value === undefined) {\n if (${k} in input) {\n newResult[${k}] = undefined;\n }\n } else {\n newResult[${k}] = ${T}.value;\n }\n \n `);else m.write(`\n if (${T}.issues.length) {\n payload.issues = payload.issues.concat(${T}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${k}, ...iss.path] : [${k}]\n })));\n }\n \n if (${T}.value === undefined) {\n if (${k} in input) {\n newResult[${k}] = undefined;\n }\n } else {\n newResult[${k}] = ${T}.value;\n }\n \n `)}m.write(\"payload.value = newResult;\"),m.write(\"return payload;\");let O=m.compile();return(b,T)=>O(d,b,T)},i,s=Qe,a=!Lt.jitless,u=a&&Ho.value,l=t.catchall,p;e._zod.parse=(d,m)=>{p??(p=n.value);let g=d.value;if(!s(g))return d.issues.push({expected:\"object\",code:\"invalid_type\",input:g,inst:e}),d;if(a&&u&&m?.async===!1&&m.jitless!==!0){if(!i)i=o(t.shape);if(d=i(d,m),!l)return d;return Us([],g,d,m,p,e)}return r(d,m)}});function Qi(e,t,r,n){for(let i of e)if(i.issues.length===0)return t.value=i.value,t;let o=e.filter((i)=>!Te(i));if(o.length===1)return t.value=o[0].value,o[0];return t.issues.push({code:\"invalid_union\",input:t.value,inst:r,errors:e.map((i)=>i.issues.map((s)=>ne(s,n,G())))}),t}var js=f(\"$ZodUnion\",(e,t)=>{A.init(e,t),E(e._zod,\"optin\",()=>t.options.some((o)=>o._zod.optin===\"optional\")?\"optional\":void 0),E(e._zod,\"optout\",()=>t.options.some((o)=>o._zod.optout===\"optional\")?\"optional\":void 0),E(e._zod,\"values\",()=>{if(t.options.every((o)=>o._zod.values))return new Set(t.options.flatMap((o)=>Array.from(o._zod.values)));return}),E(e._zod,\"pattern\",()=>{if(t.options.every((o)=>o._zod.pattern)){let o=t.options.map((i)=>i._zod.pattern);return new RegExp(`^(${o.map((i)=>Dt(i.source)).join(\"|\")})$`)}return});let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(r)return n(o,i);let s=!1,a=[];for(let c of t.options){let u=c._zod.run({value:o.value,issues:[]},i);if(u instanceof Promise)a.push(u),s=!0;else{if(u.issues.length===0)return u;a.push(u)}}if(!s)return Qi(a,o,e,i);return Promise.all(a).then((c)=>Qi(c,o,e,i))}});var Ms=f(\"$ZodIntersection\",(e,t)=>{A.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,i=t.left._zod.run({value:o,issues:[]},n),s=t.right._zod.run({value:o,issues:[]},n);if(i instanceof Promise||s instanceof Promise)return Promise.all([i,s]).then(([c,u])=>es(r,c,u));return es(r,i,s)}});function Jr(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(Se(e)&&Se(t)){let r=Object.keys(t),n=Object.keys(e).filter((i)=>r.indexOf(i)!==-1),o={...e,...t};for(let i of n){let s=Jr(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],i=t[n],s=Jr(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function es(e,t,r){let n=new Map,o;for(let a of t.issues)if(a.code===\"unrecognized_keys\"){o??(o=a);for(let c of a.keys){if(!n.has(c))n.set(c,{});n.get(c).l=!0}}else e.issues.push(a);for(let a of r.issues)if(a.code===\"unrecognized_keys\")for(let c of a.keys){if(!n.has(c))n.set(c,{});n.get(c).r=!0}else e.issues.push(a);let i=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&o)e.issues.push({...o,keys:i});if(Te(e))return e;let s=Jr(t.value,r.value);if(!s.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}var Fs=f(\"$ZodRecord\",(e,t)=>{A.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Se(o))return r.issues.push({expected:\"record\",code:\"invalid_type\",input:o,inst:e}),r;let i=[],s=t.keyType._zod.values;if(s){r.value={};let a=new Set;for(let u of s)if(typeof u===\"string\"||typeof u===\"number\"||typeof u===\"symbol\"){a.add(typeof u===\"number\"?u.toString():u);let l=t.valueType._zod.run({value:o[u],issues:[]},n);if(l instanceof Promise)i.push(l.then((p)=>{if(p.issues.length)r.issues.push(...pe(u,p.issues));r.value[u]=p.value}));else{if(l.issues.length)r.issues.push(...pe(u,l.issues));r.value[u]=l.value}}let c;for(let u in o)if(!a.has(u))c=c??[],c.push(u);if(c&&c.length>0)r.issues.push({code:\"unrecognized_keys\",input:o,inst:e,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(o)){if(a===\"__proto__\")continue;let c=t.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw Error(\"Async schemas not supported in object keys currently\");if(typeof a===\"string\"&&Vr.test(a)&&c.issues.length){let p=t.keyType._zod.run({value:Number(a),issues:[]},n);if(p instanceof Promise)throw Error(\"Async schemas not supported in object keys currently\");if(p.issues.length===0)c=p}if(c.issues.length){if(t.mode===\"loose\")r.value[a]=o[a];else r.issues.push({code:\"invalid_key\",origin:\"record\",issues:c.issues.map((p)=>ne(p,n,G())),input:a,path:[a],inst:e});continue}let l=t.valueType._zod.run({value:o[a],issues:[]},n);if(l instanceof Promise)i.push(l.then((p)=>{if(p.issues.length)r.issues.push(...pe(a,p.issues));r.value[c.value]=p.value}));else{if(l.issues.length)r.issues.push(...pe(a,l.issues));r.value[c.value]=l.value}}}if(i.length)return Promise.all(i).then(()=>r);return r}});var Bs=f(\"$ZodEnum\",(e,t)=>{A.init(e,t);let r=Ct(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter((o)=>Ko.has(typeof o)).map((o)=>typeof o===\"string\"?fe(o):o.toString()).join(\"|\")})$`),e._zod.parse=(o,i)=>{let s=o.value;if(n.has(s))return o;return o.issues.push({code:\"invalid_value\",values:r,input:s,inst:e}),o}}),Vs=f(\"$ZodLiteral\",(e,t)=>{if(A.init(e,t),t.values.length===0)throw Error(\"Cannot create literal schema with no valid values\");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map((n)=>typeof n===\"string\"?fe(n):n?fe(n.toString()):String(n)).join(\"|\")})$`),e._zod.parse=(n,o)=>{let i=n.value;if(r.has(i))return n;return n.issues.push({code:\"invalid_value\",values:t.values,input:i,inst:e}),n}});var qs=f(\"$ZodTransform\",(e,t)=>{A.init(e,t),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")throw new Xe(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then((s)=>(r.value=s,r));if(o instanceof Promise)throw new ie;return r.value=o,r}});function ts(e,t){if(e.issues.length&&t===void 0)return{issues:[],value:void 0};return e}var Wr=f(\"$ZodOptional\",(e,t)=>{A.init(e,t),e._zod.optin=\"optional\",e._zod.optout=\"optional\",E(e._zod,\"values\",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),E(e._zod,\"pattern\",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Dt(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin===\"optional\"){let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>ts(i,r.value));return ts(o,r.value)}if(r.value===void 0)return r;return t.innerType._zod.run(r,n)}}),Hs=f(\"$ZodExactOptional\",(e,t)=>{Wr.init(e,t),E(e._zod,\"values\",()=>t.innerType._zod.values),E(e._zod,\"pattern\",()=>t.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Ks=f(\"$ZodNullable\",(e,t)=>{A.init(e,t),E(e._zod,\"optin\",()=>t.innerType._zod.optin),E(e._zod,\"optout\",()=>t.innerType._zod.optout),E(e._zod,\"pattern\",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Dt(r.source)}|null)$`):void 0}),E(e._zod,\"values\",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>{if(r.value===null)return r;return t.innerType._zod.run(r,n)}}),Js=f(\"$ZodDefault\",(e,t)=>{A.init(e,t),e._zod.optin=\"optional\",E(e._zod,\"values\",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>rs(i,t));return rs(o,t)}});function rs(e,t){if(e.value===void 0)e.value=t.defaultValue;return e}var Gs=f(\"$ZodPrefault\",(e,t)=>{A.init(e,t),e._zod.optin=\"optional\",E(e._zod,\"values\",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")return t.innerType._zod.run(r,n);if(r.value===void 0)r.value=t.defaultValue;return t.innerType._zod.run(r,n)}}),Ws=f(\"$ZodNonOptional\",(e,t)=>{A.init(e,t),E(e._zod,\"values\",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter((n)=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>ns(i,e));return ns(o,e)}});function ns(e,t){if(!e.issues.length&&e.value===void 0)e.issues.push({code:\"invalid_type\",expected:\"nonoptional\",input:e.value,inst:t});return e}var Ys=f(\"$ZodCatch\",(e,t)=>{A.init(e,t),E(e._zod,\"optin\",()=>t.innerType._zod.optin),E(e._zod,\"optout\",()=>t.innerType._zod.optout),E(e._zod,\"values\",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>{if(r.value=i.value,i.issues.length)r.value=t.catchValue({...r,error:{issues:i.issues.map((s)=>ne(s,n,G()))},input:r.value}),r.issues=[];return r});if(r.value=o.value,o.issues.length)r.value=t.catchValue({...r,error:{issues:o.issues.map((i)=>ne(i,n,G()))},input:r.value}),r.issues=[];return r}});var Xs=f(\"$ZodPipe\",(e,t)=>{A.init(e,t),E(e._zod,\"values\",()=>t.in._zod.values),E(e._zod,\"optin\",()=>t.in._zod.optin),E(e._zod,\"optout\",()=>t.out._zod.optout),E(e._zod,\"propValues\",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction===\"backward\"){let i=t.out._zod.run(r,n);if(i instanceof Promise)return i.then((s)=>qt(s,t.in,n));return qt(i,t.in,n)}let o=t.in._zod.run(r,n);if(o instanceof Promise)return o.then((i)=>qt(i,t.out,n));return qt(o,t.out,n)}});function qt(e,t,r){if(e.issues.length)return e.aborted=!0,e;return t._zod.run({value:e.value,issues:e.issues},r)}var Qs=f(\"$ZodReadonly\",(e,t)=>{A.init(e,t),E(e._zod,\"propValues\",()=>t.innerType._zod.propValues),E(e._zod,\"values\",()=>t.innerType._zod.values),E(e._zod,\"optin\",()=>t.innerType?._zod?.optin),E(e._zod,\"optout\",()=>t.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);if(o instanceof Promise)return o.then(os);return os(o)}});function os(e){return e.value=Object.freeze(e.value),e}var ea=f(\"$ZodCustom\",(e,t)=>{U.init(e,t),A.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=(r)=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then((i)=>is(i,r,n,e));is(o,r,n,e);return}});function is(e,t,r,n){if(!e){let o={code:\"custom\",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};if(n._zod.def.params)o.params=n._zod.def.params;t.issues.push(Ee(o))}}var $p=()=>{let e={string:{unit:\"characters\",verb:\"to have\"},file:{unit:\"bytes\",verb:\"to have\"},array:{unit:\"items\",verb:\"to have\"},set:{unit:\"items\",verb:\"to have\"},map:{unit:\"entries\",verb:\"to have\"}};function t(o){return e[o]??null}let r={regex:\"input\",email:\"email address\",url:\"URL\",emoji:\"emoji\",uuid:\"UUID\",uuidv4:\"UUIDv4\",uuidv6:\"UUIDv6\",nanoid:\"nanoid\",guid:\"GUID\",cuid:\"cuid\",cuid2:\"cuid2\",ulid:\"ULID\",xid:\"XID\",ksuid:\"KSUID\",datetime:\"ISO datetime\",date:\"ISO date\",time:\"ISO time\",duration:\"ISO duration\",ipv4:\"IPv4 address\",ipv6:\"IPv6 address\",mac:\"MAC address\",cidrv4:\"IPv4 range\",cidrv6:\"IPv6 range\",base64:\"base64-encoded string\",base64url:\"base64url-encoded string\",json_string:\"JSON string\",e164:\"E.164 number\",jwt:\"JWT\",template_literal:\"input\"},n={nan:\"NaN\"};return(o)=>{switch(o.code){case\"invalid_type\":{let i=n[o.expected]??o.expected,s=Wo(o.input),a=n[s]??s;return`Invalid input: expected ${i}, received ${a}`}case\"invalid_value\":if(o.values.length===1)return`Invalid input: expected ${jr(o.values[0])}`;return`Invalid option: expected one of ${Cr(o.values,\"|\")}`;case\"too_big\":{let i=o.inclusive?\"<=\":\"<\",s=t(o.origin);if(s)return`Too big: expected ${o.origin??\"value\"} to have ${i}${o.maximum.toString()} ${s.unit??\"elements\"}`;return`Too big: expected ${o.origin??\"value\"} to be ${i}${o.maximum.toString()}`}case\"too_small\":{let i=o.inclusive?\">=\":\">\",s=t(o.origin);if(s)return`Too small: expected ${o.origin} to have ${i}${o.minimum.toString()} ${s.unit}`;return`Too small: expected ${o.origin} to be ${i}${o.minimum.toString()}`}case\"invalid_format\":{let i=o;if(i.format===\"starts_with\")return`Invalid string: must start with \"${i.prefix}\"`;if(i.format===\"ends_with\")return`Invalid string: must end with \"${i.suffix}\"`;if(i.format===\"includes\")return`Invalid string: must include \"${i.includes}\"`;if(i.format===\"regex\")return`Invalid string: must match pattern ${i.pattern}`;return`Invalid ${r[i.format]??o.format}`}case\"not_multiple_of\":return`Invalid number: must be a multiple of ${o.divisor}`;case\"unrecognized_keys\":return`Unrecognized key${o.keys.length>1?\"s\":\"\"}: ${Cr(o.keys,\", \")}`;case\"invalid_key\":return`Invalid key in ${o.origin}`;case\"invalid_union\":return\"Invalid input\";case\"invalid_element\":return`Invalid value in ${o.origin}`;default:return\"Invalid input\"}}};function Yr(){return{localeError:$p()}}var ta,Vy=Symbol(\"ZodOutput\"),qy=Symbol(\"ZodInput\");class ra{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];if(this._map.set(e,r),r&&typeof r===\"object\"&&\"id\"in r)this._idmap.set(r.id,e);return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);if(t&&typeof t===\"object\"&&\"id\"in t)this._idmap.delete(t.id);return this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}function Ip(){return new ra}(ta=globalThis).__zod_globalRegistry??(ta.__zod_globalRegistry=Ip());var ke=globalThis.__zod_globalRegistry;function na(e,t){return new e({type:\"string\",...y(t)})}function oa(e,t){return new e({type:\"string\",coerce:!0,...y(t)})}function ia(e,t){return new e({type:\"string\",format:\"email\",check:\"string_format\",abort:!1,...y(t)})}function Xr(e,t){return new e({type:\"string\",format:\"guid\",check:\"string_format\",abort:!1,...y(t)})}function sa(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,...y(t)})}function aa(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v4\",...y(t)})}function ca(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v6\",...y(t)})}function ua(e,t){return new e({type:\"string\",format:\"uuid\",check:\"string_format\",abort:!1,version:\"v7\",...y(t)})}function la(e,t){return new e({type:\"string\",format:\"url\",check:\"string_format\",abort:!1,...y(t)})}function fa(e,t){return new e({type:\"string\",format:\"emoji\",check:\"string_format\",abort:!1,...y(t)})}function pa(e,t){return new e({type:\"string\",format:\"nanoid\",check:\"string_format\",abort:!1,...y(t)})}function da(e,t){return new e({type:\"string\",format:\"cuid\",check:\"string_format\",abort:!1,...y(t)})}function ma(e,t){return new e({type:\"string\",format:\"cuid2\",check:\"string_format\",abort:!1,...y(t)})}function ha(e,t){return new e({type:\"string\",format:\"ulid\",check:\"string_format\",abort:!1,...y(t)})}function ga(e,t){return new e({type:\"string\",format:\"xid\",check:\"string_format\",abort:!1,...y(t)})}function ya(e,t){return new e({type:\"string\",format:\"ksuid\",check:\"string_format\",abort:!1,...y(t)})}function ba(e,t){return new e({type:\"string\",format:\"ipv4\",check:\"string_format\",abort:!1,...y(t)})}function _a(e,t){return new e({type:\"string\",format:\"ipv6\",check:\"string_format\",abort:!1,...y(t)})}function xa(e,t){return new e({type:\"string\",format:\"cidrv4\",check:\"string_format\",abort:!1,...y(t)})}function va(e,t){return new e({type:\"string\",format:\"cidrv6\",check:\"string_format\",abort:!1,...y(t)})}function wa(e,t){return new e({type:\"string\",format:\"base64\",check:\"string_format\",abort:!1,...y(t)})}function Sa(e,t){return new e({type:\"string\",format:\"base64url\",check:\"string_format\",abort:!1,...y(t)})}function Ta(e,t){return new e({type:\"string\",format:\"e164\",check:\"string_format\",abort:!1,...y(t)})}function Ea(e,t){return new e({type:\"string\",format:\"jwt\",check:\"string_format\",abort:!1,...y(t)})}function ka(e,t){return new e({type:\"string\",format:\"datetime\",check:\"string_format\",offset:!1,local:!1,precision:null,...y(t)})}function Oa(e,t){return new e({type:\"string\",format:\"date\",check:\"string_format\",...y(t)})}function Aa(e,t){return new e({type:\"string\",format:\"time\",check:\"string_format\",precision:null,...y(t)})}function Pa(e,t){return new e({type:\"string\",format:\"duration\",check:\"string_format\",...y(t)})}function Ra(e,t){return new e({type:\"number\",checks:[],...y(t)})}function za(e,t){return new e({type:\"number\",coerce:!0,checks:[],...y(t)})}function $a(e,t){return new e({type:\"number\",check:\"number_format\",abort:!1,format:\"safeint\",...y(t)})}function Ia(e,t){return new e({type:\"boolean\",...y(t)})}function La(e,t){return new e({type:\"boolean\",coerce:!0,...y(t)})}function Na(e,t){return new e({type:\"bigint\",coerce:!0,...y(t)})}function Ca(e){return new e({type:\"unknown\"})}function Za(e,t){return new e({type:\"never\",...y(t)})}function Ua(e,t){return new e({type:\"date\",coerce:!0,...y(t)})}function Ce(e,t){return new qr({check:\"less_than\",...y(t),value:e,inclusive:!1})}function ae(e,t){return new qr({check:\"less_than\",...y(t),value:e,inclusive:!0})}function Ze(e,t){return new Hr({check:\"greater_than\",...y(t),value:e,inclusive:!1})}function Y(e,t){return new Hr({check:\"greater_than\",...y(t),value:e,inclusive:!0})}function ot(e,t){return new Ui({check:\"multiple_of\",...y(t),value:e})}function Jt(e,t){return new ji({check:\"max_length\",...y(t),maximum:e})}function Ue(e,t){return new Mi({check:\"min_length\",...y(t),minimum:e})}function Gt(e,t){return new Fi({check:\"length_equals\",...y(t),length:e})}function Qr(e,t){return new Bi({check:\"string_format\",format:\"regex\",...y(t),pattern:e})}function en(e){return new Vi({check:\"string_format\",format:\"lowercase\",...y(e)})}function tn(e){return new qi({check:\"string_format\",format:\"uppercase\",...y(e)})}function rn(e,t){return new Hi({check:\"string_format\",format:\"includes\",...y(t),includes:e})}function nn(e,t){return new Ki({check:\"string_format\",format:\"starts_with\",...y(t),prefix:e})}function on(e,t){return new Ji({check:\"string_format\",format:\"ends_with\",...y(t),suffix:e})}function de(e){return new Gi({check:\"overwrite\",tx:e})}function sn(e){return de((t)=>t.normalize(e))}function an(){return de((e)=>e.trim())}function cn(){return de((e)=>e.toLowerCase())}function un(){return de((e)=>e.toUpperCase())}function ln(){return de((e)=>qo(e))}function Da(e,t,r){return new e({type:\"array\",element:t,...y(r)})}function ja(e,t,r){return new e({type:\"custom\",check:\"custom\",fn:t,...y(r)})}function Ma(e){let t=Lp((r)=>(r.addIssue=(n)=>{if(typeof n===\"string\")r.issues.push(Ee(n,r.value,t._zod.def));else{let o=n;if(o.fatal)o.continue=!1;o.code??(o.code=\"custom\"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(Ee(o))}},e(r.value,r)));return t}function Lp(e,t){let r=new U({check:\"custom\",...y(t)});return r._zod.check=e,r}function fn(e){let t=e?.target??\"draft-2020-12\";if(t===\"draft-4\")t=\"draft-04\";if(t===\"draft-7\")t=\"draft-07\";return{processors:e.processors??{},metadataRegistry:e?.metadata??ke,target:t,unrepresentable:e?.unrepresentable??\"throw\",override:e?.override??(()=>{}),io:e?.io??\"output\",counter:0,seen:new Map,cycles:e?.cycles??\"ref\",reused:e?.reused??\"inline\",external:e?.external??void 0}}function C(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,i=t.seen.get(e);if(i){if(i.count++,r.schemaPath.includes(e))i.cycle=r.path;return i.schema}let s={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,s);let a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,l);else{let d=s.schema,m=t.processors[o.type];if(!m)throw Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);m(e,t,d,l)}let p=e._zod.parent;if(p){if(!s.ref)s.ref=p;C(p,t,l),t.seen.get(p).isParent=!0}}let c=t.metadataRegistry.get(e);if(c)Object.assign(s.schema,c);if(t.io===\"input\"&&M(e))delete s.schema.examples,delete s.schema.default;if(t.io===\"input\"&&s.schema._prefault)(n=s.schema).default??(n.default=s.schema._prefault);return delete s.schema._prefault,t.seen.get(e).schema}function pn(e,t){let r=e.seen.get(t);if(!r)throw Error(\"Unprocessed schema. This is a bug in Zod.\");let n=new Map;for(let s of e.seen.entries()){let a=e.metadataRegistry.get(s[0])?.id;if(a){let c=n.get(a);if(c&&c!==s[0])throw Error(`Duplicate schema id \"${a}\" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,s[0])}}let o=(s)=>{let a=e.target===\"draft-2020-12\"?\"$defs\":\"definitions\";if(e.external){let p=e.external.registry.get(s[0])?.id,d=e.external.uri??((g)=>g);if(p)return{ref:d(p)};let m=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=m,{defId:m,ref:`${d(\"__shared\")}#/${a}/${m}`}}if(s[1]===r)return{ref:\"#\"};let u=`${\"#\"}/${a}/`,l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+l}},i=(s)=>{if(s[1].schema.$ref)return;let a=s[1],{ref:c,defId:u}=o(s);if(a.def={...a.schema},u)a.defId=u;let l=a.schema;for(let p in l)delete l[p];l.$ref=c};if(e.cycles===\"throw\")for(let s of e.seen.entries()){let a=s[1];if(a.cycle)throw Error(`Cycle detected: #/${a.cycle?.join(\"/\")}/<root>\n\nSet the \\`cycles\\` parameter to \\`\"ref\"\\` to resolve cyclical schemas with defs.`)}for(let s of e.seen.entries()){let a=s[1];if(t===s[0]){i(s);continue}if(e.external){let u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1){if(e.reused===\"ref\"){i(s);continue}}}}function dn(e,t){let r=e.seen.get(t);if(!r)throw Error(\"Unprocessed schema. This is a bug in Zod.\");let n=(s)=>{let a=e.seen.get(s);if(a.ref===null)return;let c=a.def??a.schema,u={...c},l=a.ref;if(a.ref=null,l){n(l);let d=e.seen.get(l),m=d.schema;if(m.$ref&&(e.target===\"draft-07\"||e.target===\"draft-04\"||e.target===\"openapi-3.0\"))c.allOf=c.allOf??[],c.allOf.push(m);else Object.assign(c,m);if(Object.assign(c,u),s._zod.parent===l)for(let h in c){if(h===\"$ref\"||h===\"allOf\")continue;if(!(h in u))delete c[h]}if(m.$ref&&d.def)for(let h in c){if(h===\"$ref\"||h===\"allOf\")continue;if(h in d.def&&JSON.stringify(c[h])===JSON.stringify(d.def[h]))delete c[h]}}let p=s._zod.parent;if(p&&p!==l){n(p);let d=e.seen.get(p);if(d?.schema.$ref){if(c.$ref=d.schema.$ref,d.def)for(let m in c){if(m===\"$ref\"||m===\"allOf\")continue;if(m in d.def&&JSON.stringify(c[m])===JSON.stringify(d.def[m]))delete c[m]}}}e.override({zodSchema:s,jsonSchema:c,path:a.path??[]})};for(let s of[...e.seen.entries()].reverse())n(s[0]);let o={};if(e.target===\"draft-2020-12\")o.$schema=\"https://json-schema.org/draft/2020-12/schema\";else if(e.target===\"draft-07\")o.$schema=\"http://json-schema.org/draft-07/schema#\";else if(e.target===\"draft-04\")o.$schema=\"http://json-schema.org/draft-04/schema#\";else if(e.target===\"openapi-3.0\");if(e.external?.uri){let s=e.external.registry.get(t)?.id;if(!s)throw Error(\"Schema is missing an `id` property\");o.$id=e.external.uri(s)}Object.assign(o,r.def??r.schema);let i=e.external?.defs??{};for(let s of e.seen.entries()){let a=s[1];if(a.def&&a.defId)i[a.defId]=a.def}if(e.external);else if(Object.keys(i).length>0)if(e.target===\"draft-2020-12\")o.$defs=i;else o.definitions=i;try{let s=JSON.parse(JSON.stringify(o));return Object.defineProperty(s,\"~standard\",{value:{...t[\"~standard\"],jsonSchema:{input:it(t,\"input\",e.processors),output:it(t,\"output\",e.processors)}},enumerable:!1,writable:!1}),s}catch(s){throw Error(\"Error converting schema to JSON.\")}}function M(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type===\"transform\")return!0;if(n.type===\"array\")return M(n.element,r);if(n.type===\"set\")return M(n.valueType,r);if(n.type===\"lazy\")return M(n.getter(),r);if(n.type===\"promise\"||n.type===\"optional\"||n.type===\"nonoptional\"||n.type===\"nullable\"||n.type===\"readonly\"||n.type===\"default\"||n.type===\"prefault\")return M(n.innerType,r);if(n.type===\"intersection\")return M(n.left,r)||M(n.right,r);if(n.type===\"record\"||n.type===\"map\")return M(n.keyType,r)||M(n.valueType,r);if(n.type===\"pipe\")return M(n.in,r)||M(n.out,r);if(n.type===\"object\"){for(let o in n.shape)if(M(n.shape[o],r))return!0;return!1}if(n.type===\"union\"){for(let o of n.options)if(M(o,r))return!0;return!1}if(n.type===\"tuple\"){for(let o of n.items)if(M(o,r))return!0;if(n.rest&&M(n.rest,r))return!0;return!1}return!1}var Fa=(e,t={})=>(r)=>{let n=fn({...r,processors:t});return C(e,n),pn(n,e),dn(n,e)},it=(e,t,r={})=>(n)=>{let{libraryOptions:o,target:i}=n??{},s=fn({...o??{},target:i,io:t,processors:r});return C(e,s),pn(s,e),dn(s,e)};var Np={guid:\"uuid\",url:\"uri\",datetime:\"date-time\",json_string:\"json-string\",regex:\"\"},Ba=(e,t,r,n)=>{let o=r;o.type=\"string\";let{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof i===\"number\")o.minLength=i;if(typeof s===\"number\")o.maxLength=s;if(a){if(o.format=Np[a]??a,o.format===\"\")delete o.format;if(a===\"time\")delete o.format}if(u)o.contentEncoding=u;if(c&&c.size>0){let l=[...c];if(l.length===1)o.pattern=l[0].source;else if(l.length>1)o.allOf=[...l.map((p)=>({...t.target===\"draft-07\"||t.target===\"draft-04\"||t.target===\"openapi-3.0\"?{type:\"string\"}:{},pattern:p.source}))]}},Va=(e,t,r,n)=>{let o=r,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=e._zod.bag;if(typeof a===\"string\"&&a.includes(\"int\"))o.type=\"integer\";else o.type=\"number\";if(typeof l===\"number\")if(t.target===\"draft-04\"||t.target===\"openapi-3.0\")o.minimum=l,o.exclusiveMinimum=!0;else o.exclusiveMinimum=l;if(typeof i===\"number\"){if(o.minimum=i,typeof l===\"number\"&&t.target!==\"draft-04\")if(l>=i)delete o.minimum;else delete o.exclusiveMinimum}if(typeof u===\"number\")if(t.target===\"draft-04\"||t.target===\"openapi-3.0\")o.maximum=u,o.exclusiveMaximum=!0;else o.exclusiveMaximum=u;if(typeof s===\"number\"){if(o.maximum=s,typeof u===\"number\"&&t.target!==\"draft-04\")if(u<=s)delete o.maximum;else delete o.exclusiveMaximum}if(typeof c===\"number\")o.multipleOf=c},qa=(e,t,r,n)=>{r.type=\"boolean\"},Ha=(e,t,r,n)=>{if(t.unrepresentable===\"throw\")throw Error(\"BigInt cannot be represented in JSON Schema\")};var Ka=(e,t,r,n)=>{r.not={}};var Ja=(e,t,r,n)=>{},Ga=(e,t,r,n)=>{if(t.unrepresentable===\"throw\")throw Error(\"Date cannot be represented in JSON Schema\")},Wa=(e,t,r,n)=>{let o=e._zod.def,i=Ct(o.entries);if(i.every((s)=>typeof s===\"number\"))r.type=\"number\";if(i.every((s)=>typeof s===\"string\"))r.type=\"string\";r.enum=i},Ya=(e,t,r,n)=>{let o=e._zod.def,i=[];for(let s of o.values)if(s===void 0){if(t.unrepresentable===\"throw\")throw Error(\"Literal `undefined` cannot be represented in JSON Schema\")}else if(typeof s===\"bigint\")if(t.unrepresentable===\"throw\")throw Error(\"BigInt literals cannot be represented in JSON Schema\");else i.push(Number(s));else i.push(s);if(i.length===0);else if(i.length===1){let s=i[0];if(r.type=s===null?\"null\":typeof s,t.target===\"draft-04\"||t.target===\"openapi-3.0\")r.enum=[s];else r.const=s}else{if(i.every((s)=>typeof s===\"number\"))r.type=\"number\";if(i.every((s)=>typeof s===\"string\"))r.type=\"string\";if(i.every((s)=>typeof s===\"boolean\"))r.type=\"boolean\";if(i.every((s)=>s===null))r.type=\"null\";r.enum=i}};var Xa=(e,t,r,n)=>{if(t.unrepresentable===\"throw\")throw Error(\"Custom types cannot be represented in JSON Schema\")};var Qa=(e,t,r,n)=>{if(t.unrepresentable===\"throw\")throw Error(\"Transforms cannot be represented in JSON Schema\")};var ec=(e,t,r,n)=>{let o=r,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;if(typeof s===\"number\")o.minItems=s;if(typeof a===\"number\")o.maxItems=a;o.type=\"array\",o.items=C(i.element,t,{...n,path:[...n.path,\"items\"]})},tc=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type=\"object\",o.properties={};let s=i.shape;for(let u in s)o.properties[u]=C(s[u],t,{...n,path:[...n.path,\"properties\",u]});let a=new Set(Object.keys(s)),c=new Set([...a].filter((u)=>{let l=i.shape[u]._zod;if(t.io===\"input\")return l.optin===void 0;else return l.optout===void 0}));if(c.size>0)o.required=Array.from(c);if(i.catchall?._zod.def.type===\"never\")o.additionalProperties=!1;else if(!i.catchall){if(t.io===\"output\")o.additionalProperties=!1}else if(i.catchall)o.additionalProperties=C(i.catchall,t,{...n,path:[...n.path,\"additionalProperties\"]})},rc=(e,t,r,n)=>{let o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>C(a,t,{...n,path:[...n.path,i?\"oneOf\":\"anyOf\",c]}));if(i)r.oneOf=s;else r.anyOf=s},nc=(e,t,r,n)=>{let o=e._zod.def,i=C(o.left,t,{...n,path:[...n.path,\"allOf\",0]}),s=C(o.right,t,{...n,path:[...n.path,\"allOf\",1]}),a=(u)=>(\"allOf\"in u)&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];r.allOf=c};var oc=(e,t,r,n)=>{let o=r,i=e._zod.def;o.type=\"object\";let s=i.keyType,c=s._zod.bag?.patterns;if(i.mode===\"loose\"&&c&&c.size>0){let l=C(i.valueType,t,{...n,path:[...n.path,\"patternProperties\",\"*\"]});o.patternProperties={};for(let p of c)o.patternProperties[p.source]=l}else{if(t.target===\"draft-07\"||t.target===\"draft-2020-12\")o.propertyNames=C(i.keyType,t,{...n,path:[...n.path,\"propertyNames\"]});o.additionalProperties=C(i.valueType,t,{...n,path:[...n.path,\"additionalProperties\"]})}let u=s._zod.values;if(u){let l=[...u].filter((p)=>typeof p===\"string\"||typeof p===\"number\");if(l.length>0)o.required=l}},ic=(e,t,r,n)=>{let o=e._zod.def,i=C(o.innerType,t,n),s=t.seen.get(e);if(t.target===\"openapi-3.0\")s.ref=o.innerType,r.nullable=!0;else r.anyOf=[i,{type:\"null\"}]},sc=(e,t,r,n)=>{let o=e._zod.def;C(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType},ac=(e,t,r,n)=>{let o=e._zod.def;C(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},cc=(e,t,r,n)=>{let o=e._zod.def;C(o.innerType,t,n);let i=t.seen.get(e);if(i.ref=o.innerType,t.io===\"input\")r._prefault=JSON.parse(JSON.stringify(o.defaultValue))},uc=(e,t,r,n)=>{let o=e._zod.def;C(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{throw Error(\"Dynamic catch values are not supported in JSON Schema\")}r.default=s},lc=(e,t,r,n)=>{let o=e._zod.def,i=t.io===\"input\"?o.in._zod.def.type===\"transform\"?o.out:o.in:o.out;C(i,t,n);let s=t.seen.get(e);s.ref=i},fc=(e,t,r,n)=>{let o=e._zod.def;C(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType,r.readOnly=!0};var mn=(e,t,r,n)=>{let o=e._zod.def;C(o.innerType,t,n);let i=t.seen.get(e);i.ref=o.innerType};var Bp=f(\"ZodISODateTime\",(e,t)=>{ys.init(e,t),I.init(e,t)});function pc(e){return ka(Bp,e)}var Vp=f(\"ZodISODate\",(e,t)=>{bs.init(e,t),I.init(e,t)});function dc(e){return Oa(Vp,e)}var qp=f(\"ZodISOTime\",(e,t)=>{_s.init(e,t),I.init(e,t)});function mc(e){return Aa(qp,e)}var Hp=f(\"ZodISODuration\",(e,t)=>{xs.init(e,t),I.init(e,t)});function hc(e){return Pa(Hp,e)}var bc=(e,t)=>{Mt.init(e,t),e.name=\"ZodError\",Object.defineProperties(e,{format:{value:(r)=>Qo(e,r)},flatten:{value:(r)=>Xo(e,r)},addIssue:{value:(r)=>{e.issues.push(r),e.message=JSON.stringify(e.issues,et,2)}},addIssues:{value:(r)=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,et,2)}},isEmpty:{get(){return e.issues.length===0}}})},vb=f(\"ZodError\",bc),H=f(\"ZodError\",bc,{Parent:Error});var _c=Ft(H),xc=Bt(H),vc=tt(H),wc=rt(H),Sc=ri(H),Tc=ni(H),Ec=oi(H),kc=ii(H),Oc=si(H),Ac=ai(H),Pc=ci(H),Rc=ui(H);var R=f(\"ZodType\",(e,t)=>(A.init(e,t),Object.assign(e[\"~standard\"],{jsonSchema:{input:it(e,\"input\"),output:it(e,\"output\")}}),e.toJSONSchema=Fa(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,\"_def\",{value:t}),e.check=(...r)=>e.clone(le(t,{checks:[...t.checks??[],...r.map((n)=>typeof n===\"function\"?{_zod:{check:n,def:{check:\"custom\"},onattach:[]}}:n)]}),{parent:!0}),e.with=e.check,e.clone=(r,n)=>re(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>_c(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>vc(e,r,n),e.parseAsync=async(r,n)=>xc(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>wc(e,r,n),e.spa=e.safeParseAsync,e.encode=(r,n)=>Sc(e,r,n),e.decode=(r,n)=>Tc(e,r,n),e.encodeAsync=async(r,n)=>Ec(e,r,n),e.decodeAsync=async(r,n)=>kc(e,r,n),e.safeEncode=(r,n)=>Oc(e,r,n),e.safeDecode=(r,n)=>Ac(e,r,n),e.safeEncodeAsync=async(r,n)=>Pc(e,r,n),e.safeDecodeAsync=async(r,n)=>Rc(e,r,n),e.refine=(r,n)=>e.check(Md(r,n)),e.superRefine=(r)=>e.check(Fd(r)),e.overwrite=(r)=>e.check(de(r)),e.optional=()=>Ic(e),e.exactOptional=()=>Ad(e),e.nullable=()=>Lc(e),e.nullish=()=>Ic(Lc(e)),e.nonoptional=(r)=>Ld(e,r),e.array=()=>at(e),e.or=(r)=>bd([e,r]),e.and=(r)=>xd(e,r),e.transform=(r)=>Nc(e,kd(r)),e.default=(r)=>zd(e,r),e.prefault=(r)=>Id(e,r),e.catch=(r)=>Cd(e,r),e.pipe=(r)=>Nc(e,r),e.readonly=()=>Dd(e),e.describe=(r)=>{let n=e.clone();return ke.add(n,{description:r}),n},Object.defineProperty(e,\"description\",{get(){return ke.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return ke.get(e);let n=e.clone();return ke.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=(r)=>r(e),e)),Cc=f(\"_ZodString\",(e,t)=>{Kt.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Ba(e,n,o,i);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(Qr(...n)),e.includes=(...n)=>e.check(rn(...n)),e.startsWith=(...n)=>e.check(nn(...n)),e.endsWith=(...n)=>e.check(on(...n)),e.min=(...n)=>e.check(Ue(...n)),e.max=(...n)=>e.check(Jt(...n)),e.length=(...n)=>e.check(Gt(...n)),e.nonempty=(...n)=>e.check(Ue(1,...n)),e.lowercase=(n)=>e.check(en(n)),e.uppercase=(n)=>e.check(tn(n)),e.trim=()=>e.check(an()),e.normalize=(...n)=>e.check(sn(...n)),e.toLowerCase=()=>e.check(cn()),e.toUpperCase=()=>e.check(un()),e.slugify=()=>e.check(ln())}),yn=f(\"ZodString\",(e,t)=>{Kt.init(e,t),Cc.init(e,t),e.email=(r)=>e.check(ia(Jp,r)),e.url=(r)=>e.check(la(Gp,r)),e.jwt=(r)=>e.check(Ea(ld,r)),e.emoji=(r)=>e.check(fa(Wp,r)),e.guid=(r)=>e.check(Xr(zc,r)),e.uuid=(r)=>e.check(sa(Wt,r)),e.uuidv4=(r)=>e.check(aa(Wt,r)),e.uuidv6=(r)=>e.check(ca(Wt,r)),e.uuidv7=(r)=>e.check(ua(Wt,r)),e.nanoid=(r)=>e.check(pa(Yp,r)),e.guid=(r)=>e.check(Xr(zc,r)),e.cuid=(r)=>e.check(da(Xp,r)),e.cuid2=(r)=>e.check(ma(Qp,r)),e.ulid=(r)=>e.check(ha(ed,r)),e.base64=(r)=>e.check(wa(ad,r)),e.base64url=(r)=>e.check(Sa(cd,r)),e.xid=(r)=>e.check(ga(td,r)),e.ksuid=(r)=>e.check(ya(rd,r)),e.ipv4=(r)=>e.check(ba(nd,r)),e.ipv6=(r)=>e.check(_a(od,r)),e.cidrv4=(r)=>e.check(xa(id,r)),e.cidrv6=(r)=>e.check(va(sd,r)),e.e164=(r)=>e.check(Ta(ud,r)),e.datetime=(r)=>e.check(pc(r)),e.date=(r)=>e.check(dc(r)),e.time=(r)=>e.check(mc(r)),e.duration=(r)=>e.check(hc(r))});function D(e){return na(yn,e)}var I=f(\"ZodStringFormat\",(e,t)=>{P.init(e,t),Cc.init(e,t)}),Jp=f(\"ZodEmail\",(e,t)=>{cs.init(e,t),I.init(e,t)});var zc=f(\"ZodGUID\",(e,t)=>{ss.init(e,t),I.init(e,t)});var Wt=f(\"ZodUUID\",(e,t)=>{as.init(e,t),I.init(e,t)});var Gp=f(\"ZodURL\",(e,t)=>{us.init(e,t),I.init(e,t)});var Wp=f(\"ZodEmoji\",(e,t)=>{ls.init(e,t),I.init(e,t)});var Yp=f(\"ZodNanoID\",(e,t)=>{fs.init(e,t),I.init(e,t)});var Xp=f(\"ZodCUID\",(e,t)=>{ps.init(e,t),I.init(e,t)});var Qp=f(\"ZodCUID2\",(e,t)=>{ds.init(e,t),I.init(e,t)});var ed=f(\"ZodULID\",(e,t)=>{ms.init(e,t),I.init(e,t)});var td=f(\"ZodXID\",(e,t)=>{hs.init(e,t),I.init(e,t)});var rd=f(\"ZodKSUID\",(e,t)=>{gs.init(e,t),I.init(e,t)});var nd=f(\"ZodIPv4\",(e,t)=>{vs.init(e,t),I.init(e,t)});var od=f(\"ZodIPv6\",(e,t)=>{ws.init(e,t),I.init(e,t)});var id=f(\"ZodCIDRv4\",(e,t)=>{Ss.init(e,t),I.init(e,t)});var sd=f(\"ZodCIDRv6\",(e,t)=>{Ts.init(e,t),I.init(e,t)});var ad=f(\"ZodBase64\",(e,t)=>{ks.init(e,t),I.init(e,t)});var cd=f(\"ZodBase64URL\",(e,t)=>{Os.init(e,t),I.init(e,t)});var ud=f(\"ZodE164\",(e,t)=>{As.init(e,t),I.init(e,t)});var ld=f(\"ZodJWT\",(e,t)=>{Ps.init(e,t),I.init(e,t)});var Yt=f(\"ZodNumber\",(e,t)=>{Gr.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Va(e,n,o,i),e.gt=(n,o)=>e.check(Ze(n,o)),e.gte=(n,o)=>e.check(Y(n,o)),e.min=(n,o)=>e.check(Y(n,o)),e.lt=(n,o)=>e.check(Ce(n,o)),e.lte=(n,o)=>e.check(ae(n,o)),e.max=(n,o)=>e.check(ae(n,o)),e.int=(n)=>e.check($c(n)),e.safe=(n)=>e.check($c(n)),e.positive=(n)=>e.check(Ze(0,n)),e.nonnegative=(n)=>e.check(Y(0,n)),e.negative=(n)=>e.check(Ce(0,n)),e.nonpositive=(n)=>e.check(ae(0,n)),e.multipleOf=(n,o)=>e.check(ot(n,o)),e.step=(n,o)=>e.check(ot(n,o)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??\"\").includes(\"int\")||Number.isSafeInteger(r.multipleOf??0.5),e.isFinite=!0,e.format=r.format??null});function Zc(e){return Ra(Yt,e)}var fd=f(\"ZodNumberFormat\",(e,t)=>{Rs.init(e,t),Yt.init(e,t)});function $c(e){return $a(fd,e)}var bn=f(\"ZodBoolean\",(e,t)=>{zs.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qa(e,r,n,o)});function st(e){return Ia(bn,e)}var Uc=f(\"ZodBigInt\",(e,t)=>{$s.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Ha(e,n,o,i),e.gte=(n,o)=>e.check(Y(n,o)),e.min=(n,o)=>e.check(Y(n,o)),e.gt=(n,o)=>e.check(Ze(n,o)),e.gte=(n,o)=>e.check(Y(n,o)),e.min=(n,o)=>e.check(Y(n,o)),e.lt=(n,o)=>e.check(Ce(n,o)),e.lte=(n,o)=>e.check(ae(n,o)),e.max=(n,o)=>e.check(ae(n,o)),e.positive=(n)=>e.check(Ze(BigInt(0),n)),e.negative=(n)=>e.check(Ce(BigInt(0),n)),e.nonpositive=(n)=>e.check(ae(BigInt(0),n)),e.nonnegative=(n)=>e.check(Y(BigInt(0),n)),e.multipleOf=(n,o)=>e.check(ot(n,o));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});var pd=f(\"ZodUnknown\",(e,t)=>{Is.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ja(e,r,n,o)});function hn(){return Ca(pd)}var dd=f(\"ZodNever\",(e,t)=>{Ls.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ka(e,r,n,o)});function md(e){return Za(dd,e)}var Dc=f(\"ZodDate\",(e,t)=>{Ns.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Ga(e,n,o,i),e.min=(n,o)=>e.check(Y(n,o)),e.max=(n,o)=>e.check(ae(n,o));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});var hd=f(\"ZodArray\",(e,t)=>{Cs.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ec(e,r,n,o),e.element=t.element,e.min=(r,n)=>e.check(Ue(r,n)),e.nonempty=(r)=>e.check(Ue(1,r)),e.max=(r,n)=>e.check(Jt(r,n)),e.length=(r,n)=>e.check(Gt(r,n)),e.unwrap=()=>e.element});function at(e,t){return Da(hd,e,t)}var gd=f(\"ZodObject\",(e,t)=>{Ds.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>tc(e,r,n,o),E(e,\"shape\",()=>t.shape),e.keyof=()=>Sd(Object.keys(e._zod.def.shape)),e.catchall=(r)=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:hn()}),e.loose=()=>e.clone({...e._zod.def,catchall:hn()}),e.strict=()=>e.clone({...e._zod.def,catchall:md()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=(r)=>wp(e,r),e.safeExtend=(r)=>Sp(e,r),e.merge=(r)=>Tp(e,r),e.pick=(r)=>xp(e,r),e.omit=(r)=>vp(e,r),e.partial=(...r)=>Ep(jc,e,r[0]),e.required=(...r)=>kp(Mc,e,r[0])});function Z(e,t){let r={type:\"object\",shape:e??{},...y(t)};return new gd(r)}var yd=f(\"ZodUnion\",(e,t)=>{js.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rc(e,r,n,o),e.options=t.options});function bd(e,t){return new yd({type:\"union\",options:e,...y(t)})}var _d=f(\"ZodIntersection\",(e,t)=>{Ms.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nc(e,r,n,o)});function xd(e,t){return new _d({type:\"intersection\",left:e,right:t})}var vd=f(\"ZodRecord\",(e,t)=>{Fs.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>oc(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function wd(e,t,r){return new vd({type:\"record\",keyType:e,valueType:t,...y(r)})}var gn=f(\"ZodEnum\",(e,t)=>{Bs.init(e,t),R.init(e,t),e._zod.processJSONSchema=(n,o,i)=>Wa(e,n,o,i),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let i={};for(let s of n)if(r.has(s))i[s]=t.entries[s];else throw Error(`Key ${s} not found in enum`);return new gn({...t,checks:[],...y(o),entries:i})},e.exclude=(n,o)=>{let i={...t.entries};for(let s of n)if(r.has(s))delete i[s];else throw Error(`Key ${s} not found in enum`);return new gn({...t,checks:[],...y(o),entries:i})}});function Sd(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map((n)=>[n,n])):e;return new gn({type:\"enum\",entries:r,...y(t)})}var Td=f(\"ZodLiteral\",(e,t)=>{Vs.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ya(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,\"value\",{get(){if(t.values.length>1)throw Error(\"This schema contains multiple valid literal values. Use `.values` instead.\");return t.values[0]}})});function ct(e,t){return new Td({type:\"literal\",values:Array.isArray(e)?e:[e],...y(t)})}var Ed=f(\"ZodTransform\",(e,t)=>{qs.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qa(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction===\"backward\")throw new Xe(e.constructor.name);r.addIssue=(i)=>{if(typeof i===\"string\")r.issues.push(Ee(i,r.value,t));else{let s=i;if(s.fatal)s.continue=!1;s.code??(s.code=\"custom\"),s.input??(s.input=r.value),s.inst??(s.inst=e),r.issues.push(Ee(s))}};let o=t.transform(r.value,r);if(o instanceof Promise)return o.then((i)=>(r.value=i,r));return r.value=o,r}});function kd(e){return new Ed({type:\"transform\",transform:e})}var jc=f(\"ZodOptional\",(e,t)=>{Wr.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mn(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ic(e){return new jc({type:\"optional\",innerType:e})}var Od=f(\"ZodExactOptional\",(e,t)=>{Hs.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mn(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ad(e){return new Od({type:\"optional\",innerType:e})}var Pd=f(\"ZodNullable\",(e,t)=>{Ks.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ic(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Lc(e){return new Pd({type:\"nullable\",innerType:e})}var Rd=f(\"ZodDefault\",(e,t)=>{Js.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ac(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function zd(e,t){return new Rd({type:\"default\",innerType:e,get defaultValue(){return typeof t===\"function\"?t():Dr(t)}})}var $d=f(\"ZodPrefault\",(e,t)=>{Gs.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Id(e,t){return new $d({type:\"prefault\",innerType:e,get defaultValue(){return typeof t===\"function\"?t():Dr(t)}})}var Mc=f(\"ZodNonOptional\",(e,t)=>{Ws.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Ld(e,t){return new Mc({type:\"nonoptional\",innerType:e,...y(t)})}var Nd=f(\"ZodCatch\",(e,t)=>{Ys.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>uc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Cd(e,t){return new Nd({type:\"catch\",innerType:e,catchValue:typeof t===\"function\"?t:()=>t})}var Zd=f(\"ZodPipe\",(e,t)=>{Xs.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lc(e,r,n,o),e.in=t.in,e.out=t.out});function Nc(e,t){return new Zd({type:\"pipe\",in:e,out:t})}var Ud=f(\"ZodReadonly\",(e,t)=>{Qs.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Dd(e){return new Ud({type:\"readonly\",innerType:e})}var jd=f(\"ZodCustom\",(e,t)=>{ea.init(e,t),R.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xa(e,r,n,o)});function Md(e,t={}){return ja(jd,e,t)}function Fd(e){return Ma(e)}var Xt={};Rn(Xt,{bigint:()=>Hd,boolean:()=>qd,date:()=>Kd,number:()=>Vd,string:()=>Bd});function Bd(e){return oa(yn,e)}function Vd(e){return za(Yt,e)}function qd(e){return La(bn,e)}function Hd(e){return Na(Uc,e)}function Kd(e){return Ua(Dc,e)}G(Yr());var V=D().trim().min(1),me=D().regex(/^#(?:[\\da-f]{3}|[\\da-f]{6}|[\\da-f]{8})$/i,\"Expected a hex color.\"),ut={icon:{light:\"@dbx-tools/ui/branding/assets/icon-light.svg\",dark:\"@dbx-tools/ui/branding/assets/icon-dark.svg\"},logo:{light:\"@dbx-tools/ui/branding/assets/logo-light.svg\",dark:\"@dbx-tools/ui/branding/assets/logo-dark.svg\"},favicon:\"@dbx-tools/ui/branding/assets/icon-light.svg\"},_n=Z({light:V.describe(\"Asset for light surfaces.\"),dark:V.optional().describe(\"Asset for dark surfaces; light is the fallback.\")}).strict().describe(\"Theme-aware references to one visual asset.\"),Fc=Z({primary:me.default(\"#1B3139\").describe(\"Primary action and identity color.\"),primaryHover:me.default(\"#0E538B\").describe(\"Primary hover or pressed color.\"),accent:me.default(\"#00A972\").describe(\"Secondary accent color.\"),foreground:me.default(\"#1B3139\").describe(\"Default text and mark color.\"),background:me.default(\"#FFFFFF\").describe(\"Default page background.\"),surface:me.default(\"#F9F7F4\").describe(\"Secondary surface background.\"),muted:me.default(\"#618794\").describe(\"Muted text color.\"),border:me.default(\"#E4E2DD\").describe(\"Default border color.\")}).strict().prefault({}),Bc=Z({audience:at(V).default([\"Databricks developers\",\"application engineers\",\"AI agents\"]),tone:at(V).default([\"direct\",\"practical\",\"technical\",\"approachable\"]),principles:at(V).default([\"Lead with the useful outcome.\",\"Prefer concrete examples and accurate technical language.\",\"Keep product claims specific and defensible.\"]),avoid:at(V).default([\"unsupported superlatives\",\"vague AI claims\",\"unnecessary jargon\"])}).strict().prefault({}),Vc=Z({schemaVersion:ct(\"1\").default(\"1\"),name:V.default(\"dbx tools\").describe(\"Canonical display name.\"),shortName:V.default(\"dbx\").describe(\"Compact name for constrained UI.\"),tagline:V.default(\"Practical tools for Databricks builders.\").describe(\"Short product line suitable for a header or metadata.\"),description:V.default(\"Companion packages for Databricks developers building apps, agents, data workflows, and reusable UI.\").describe(\"Plain-language product description.\"),assets:Z({icon:_n.default(ut.icon),logo:_n.default(ut.logo),favicon:V.default(ut.favicon)}).strict().default(ut),colors:Fc,typography:Z({sans:V.default(\"'DM Sans', ui-sans-serif, system-ui, sans-serif\"),mono:V.default(\"'DM Mono', ui-monospace, SFMono-Regular, Menlo, monospace\")}).strict().prefault({}),voice:Bc,links:Z({website:D().url().default(\"https://dbx.tools\"),repository:D().url().optional(),documentation:D().url().default(\"https://docs.dbx.tools/\")}).strict().prefault({}),extensions:wd(V,hn()).default({}).describe(\"Namespaced consumer-specific values that do not belong in the portable core.\")}).strict().describe(\"Portable identity, visual, and voice context for UI, libraries, and LLMs.\");function Jd(e={}){return Vc.parse(e)}var Gd=Jd();var Yd=new URL(\"http://localhost\");var Xd=/^([A-Za-z][A-Za-z0-9+.-]*:\\/\\/)/,Qd=/^\\/+|\\/+$/g;var Me=65535;class er extends URL{constructor(e){super(e)}get scheme(){return this.protocol.slice(0,-1)}set scheme(e){this.protocol=e+\":\"}with(e,t){let r=new er(this);return r[e]=t,new er(r)}withPathAppend(...e){return this.withPathReplace(this.pathname,...e)}withPathReplace(...e){let r=[...e].flatMap((n)=>Array.isArray(n)?n:[n]).map((n)=>n.replace(Qd,\"\")).filter(Boolean).join(\"/\");return this.with(\"pathname\",\"/\"+r)}pathMatches(e){let t=this.pathname;if(t==e)return!0;if(!e.startsWith(\"/\"))e=\"/\"+e;if(t==e)return!0;return t.startsWith(e+\"/\")}}function je(e){if(e instanceof URL)return new er(e);if(e!==null&&typeof e===\"object\"&&\"url\"in e)e=e.url;if(typeof e===\"string\")e=e.trim();if(e)if(e.startsWith(\"/\")||e.startsWith(\"?\")||e.startsWith(\"#\")){let r=xn().toString().slice(0,-1)+e;return je(r)}else if(e.startsWith(\"://\"))e=`https${e}`;else{let n=e.match(Xd)?.[1];if(n){let o=e.slice(n.length);e=`${n}${o||xn().hostname}`}else e=`https://${e}`}else return je(xn());let t=qc(e);return t?je(t):void 0}function xn(){let e=globalThis.window?.location?.origin;if(e&&e!==\"null\"){let t=qc(e);if(t)return t}return new URL(Yd)}function qc(e){if(e&&e.includes(\"://\"))try{return new URL(e)}catch{}return null}var nm=/[vV][0-9]+|[A-Z]?[a-z]+|[0-9]+|[A-Z]+(?![a-z])/g,om=/[a-zA-Z0-9]+/g,im=[(e,t)=>{if(!t.capitalize)return e;let r=e.toLowerCase();if(r===\"ai\")return\"AI\";if(r===\"fs\")return\"FS\";return e},(e,t)=>{if(t.capitalize&&/^v[0-9]+$/.test(e))return`V${e.slice(1)}`;return e}],sm=/^([a-zA-Z][a-zA-Z0-9+.-]*)?:\\/\\/([^\\s/?#][^\\s]*)?$/,am=/^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+)@([a-zA-Z0-9-]+(?:\\.[a-zA-Z0-9-]+)+)$/,Hc={distinct:!1,lowerCase:!1,capitalize:!1,omitUriScheme:!1,omitEmailDomain:!1,camelCase:!0},B_={...Hc,lowerCase:!0,maxLength:1/0,truncateStrategy:\"hash\",truncateHashLength:6,delimiter:\"-\"};function*Kc(e,...t){let r={...Hc,...e},n=r.distinct?new Set:void 0,o=r.camelCase?nm:om;for(let i of t){if(i==null)continue;let s=typeof i===\"string\"?i:String(i);if(!s)continue;if(r.omitUriScheme){let a=s.match(sm);if(a)s=a[2]??\"\"}if(r.omitEmailDomain){let a=s.match(am);if(a)s=a[1]??\"\"}if(!s)continue;for(let a of s.matchAll(o)){let c=a[0];if(r.lowerCase)c=c.toLowerCase();if(r.capitalize)c=um(c);if(!c)continue;for(let u of im)if(c=u(c,r),!c)break;if(!c||n?.has(c))continue;n?.add(c),yield c}}}function Jc(e){if(typeof e!==\"string\")return null;let t=e.trim();return t?t:null}function cm(e,t){let r=[...Kc({lowerCase:!0,capitalize:!0,...t},e)];return r.length>0?r.join(\" \"):e}function um(e){return e?e.charAt(0).toUpperCase()+e.slice(1):e}var q=(e,t)=>ct(e).default(e).describe(t),Xc=Z({profile:q(\"DATABRICKS_CONFIG_PROFILE\",\"Databricks CLI profile environment.\"),host:q(\"DATABRICKS_HOST\",\"Databricks host environment.\"),accountId:q(\"DATABRICKS_ACCOUNT_ID\",\"Databricks account ID environment.\"),workspaceId:q(\"DATABRICKS_WORKSPACE_ID\",\"Databricks workspace ID environment.\"),configFile:q(\"DATABRICKS_CONFIG_FILE\",\"Databricks CLI config file environment.\"),clientId:q(\"DATABRICKS_CLIENT_ID\",\"Databricks OAuth client ID environment.\"),clientSecret:q(\"DATABRICKS_CLIENT_SECRET\",\"Databricks OAuth client secret environment.\"),accessToken:q(\"DATABRICKS_TOKEN\",\"Databricks access token environment.\"),groupId:q(\"DATABRICKS_GROUP_ID\",\"Databricks group ID environment.\"),authType:q(\"DATABRICKS_AUTH_TYPE\",\"Databricks auth type environment.\"),appName:q(\"DATABRICKS_APP_NAME\",\"Databricks App name environment.\"),appPort:q(\"DATABRICKS_APP_PORT\",\"Databricks App port environment.\"),lakebaseEndpoint:q(\"LAKEBASE_ENDPOINT\",\"Lakebase endpoint environment.\")}).strict().describe(\"Canonical Databricks CLI, SDK, Apps, and Lakebase environment names.\"),F=Object.freeze(Xc.parse({})),Qc=Z({postgresRole:q(\"DBX_TOOLS_POSTGRES_ROLE\",\"PostgreSQL assumed-role environment.\")}).strict().describe(\"Canonical dbx-tools PostgreSQL environment names.\"),eu=Object.freeze(Qc.parse({})),tu=D().trim().min(1).regex(/^[A-Za-z0-9._@+-]{1,255}$/,\"PostgreSQL role must contain only letters, numbers, dot, underscore, at, plus, or hyphen.\").describe(\"PostgreSQL role assumed after authentication.\"),wn=Z({postgresRole:tu.optional().describe(\"PostgreSQL role assumed after authentication.\").meta({env:eu.postgresRole})}).strict().describe(\"Shared PostgreSQL session options.\"),dm=wn.safeExtend({postgresRole:wn.shape.postgresRole.meta({env:\"POSTGRES_ROLE\"})}).describe(\"PostgreSQL options resolved through scoped configuration.\"),ru=Xt.number().int().min(1).max(Me).describe(\"TCP port from 1 through 65535.\"),nu=Xt.number().int().min(0).max(Me).describe(\"TCP port from 0 through 65535, where zero requests automatic allocation.\"),ou=D().trim().min(1).refine((e)=>je(e)!==void 0,{message:\"Expected a valid URL or host.\"}).overwrite(_m).describe(\"URL normalized through the shared URL builder.\"),X=(e)=>D().trim().min(1).optional().describe(e),K=(e,t=!0)=>({env:e,flag:t,helpDefault:!1}),mm=Z({profile:X(\"Databricks CLI profile.\").meta(K(F.profile)),host:ou.optional().describe(\"Databricks host.\").meta(K(F.host,!1)),accountId:X(\"Databricks account ID.\").meta(K(F.accountId,!1)),workspaceId:X(\"Databricks workspace ID.\").meta(K(F.workspaceId,!1)),configFile:X(\"Databricks CLI config file.\").meta(K(F.configFile,!1)),clientId:X(\"Databricks OAuth client ID.\").meta(K(F.clientId,!1)),clientSecret:X(\"Databricks OAuth client secret.\").meta(K(F.clientSecret,!1)),accessToken:X(\"Databricks access token.\").meta(K(F.accessToken,!1)),groupId:X(\"Databricks group ID.\").meta(K(F.groupId,!1)),authType:X(\"Databricks authentication type.\").meta(K(F.authType,!1)),appName:X(\"Databricks App name.\").meta(K(F.appName,!1)),appPort:ru.optional().describe(\"Databricks App port.\").meta(K(F.appPort,!1)),lakebaseEndpoint:X(\"Lakebase endpoint.\").meta(K(F.lakebaseEndpoint,!1))}).strict().describe(\"Common Databricks CLI, SDK, Apps, and Lakebase options.\");var hm=(e,t)=>D().trim().min(1).optional().describe(e).meta({env:t,flag:!1}),gm=Z({lakebaseEndpoint:hm(\"Lakebase project, resource path, host, or URL.\",F.lakebaseEndpoint)}).strict().describe(\"Common Lakebase options.\");var ym=Z({scheme:ct(\"tcp\"),host:D().trim().toLowerCase().min(1),port:nu}).strict().describe(\"TCP listener address.\"),bm=Z({scheme:ct(\"unix\"),path:D().trim().min(1)}).strict().describe(\"Unix-domain listener address.\");function _m(e){let t=je(e);if(!t)return e;let r=t.toString();return t.pathname===\"/\"&&!t.search&&!t.hash?r.slice(0,-1):r}var sx=It(\"shared/pattern\");var fx=It(\"shared/token\");function su(e,t){let r=Jc(e),n=Jc(t)?.split(\".\",1)[0],o=n?cm(n):void 0;if(!r)return o;if(!o||r.toLowerCase().endsWith(o.toLowerCase()))return r;return`${r} ${o}`}var Ex=Z({email:D().describe(\"Address to email a one-time code to, if it is authorized.\")}).describe(\"Validated request for an email one-time password.\"),kx=Z({ok:ct(!0).describe(\"Always true for an accepted one-time-password request.\"),retryAfter:Zc().optional().describe(\"Seconds to wait before requesting another code.\")}).describe(\"Accepted one-time-password request result and optional retry delay.\"),Ox=Z({email:D().describe(\"Address that received the one-time code.\"),code:D().describe(\"One-time password submitted to establish a session.\")}).describe(\"Email address and code submitted to establish a session.\"),Ax=Z({ok:st().describe(\"True when the code was accepted and a session was created.\"),retryAfter:Zc().optional().describe(\"Seconds to wait before trying another code.\")}).describe(\"Verification outcome and optional retry delay.\"),Px=Z({ok:st().describe(\"True when the session cookie was cleared.\"),redirectTo:D().describe(\"Validated same-origin destination after logout.\")}).describe(\"Logout outcome plus the validated same-origin destination.\"),Rx=Z({authenticated:st().describe(\"True when the browser holds a valid session.\"),email:D().optional().describe(\"Signed-in address when a session exists.\"),enabled:st().describe(\"True when the passwordless gate is configured.\"),passkeysEnabled:st().optional().describe(\"True when WebAuthn passkeys are available.\"),passkeyNamePrefix:D().optional().describe(\"Configured prefix for humanized passkey display names.\")}).describe(\"Gate availability, session identity, and optional passkey capability.\");function au(){return globalThis.location}function Sm(){return`${au()?.origin??\"http://localhost\"}${xe}`}function cu(e){return _r({baseURL:Sm(),...e?{fetchOptions:{signal:e}}:{},plugins:[xr(),go()]})}var uu=cu();function Tm(e){return typeof e===\"object\"&&e!==null?e:void 0}function Em(e){let t=Tm(e);if(!t||typeof t.authenticated!==\"boolean\"||typeof t.enabled!==\"boolean\"||t.email!==void 0&&typeof t.email!==\"string\"||t.passkeysEnabled!==void 0&&typeof t.passkeysEnabled!==\"boolean\"||t.passkeyNamePrefix!==void 0&&typeof t.passkeyNamePrefix!==\"string\")throw Error(\"Auth status returned an invalid response\");return{authenticated:t.authenticated,enabled:t.enabled,...typeof t.email===\"string\"?{email:t.email}:{},...typeof t.passkeysEnabled===\"boolean\"?{passkeysEnabled:t.passkeysEnabled}:{},...typeof t.passkeyNamePrefix===\"string\"?{passkeyNamePrefix:t.passkeyNamePrefix}:{}}}var Fe;function km(e){return e instanceof DOMException&&e.name===\"AbortError\"}function lu(e){Fe?.cancel();let t=Symbol(\"passkey-operation\"),r=new AbortController,n=!1,o=()=>{if(Fe?.id!==t)return;Fe=void 0,n=!0,r.abort(),Pe.cancelCeremony()};return Fe={id:t,cancel:o},{result:e(cu(r.signal)).then((s)=>!n&&s.error===null).catch((s)=>{if(n||km(s))return!1;throw s}).finally(()=>{if(Fe?.id===t)Fe=void 0}),cancel:o}}function fu(e=!1){return lu((t)=>t.signIn.passkey({autoFill:e}))}function Sn(e){return su(e,au()?.hostname??\"\")}function pu(e){let t=e??Sn();return lu((r)=>r.passkey.addPasskey(t?{name:t}:void 0))}async function du(){let e=await fetch(`${xe}/status`,{credentials:\"include\"});if(!e.ok)throw Error(`Auth status failed with ${e.status}`);return Em(await e.json())}async function mu(e){return(await uu.emailOtp.sendVerificationOtp({email:e,type:\"sign-in\"})).error===null}async function hu(e,t,r){return(await uu.signIn.emailOtp({email:e,otp:t,name:r})).error===null}var Tn=document.querySelector(\"#email-form\"),kn=document.querySelector(\"#code-form\"),_u=document.querySelector(\"#email\"),On=document.querySelector(\"#code\"),gu=document.querySelector(\"#email-submit\"),yu=document.querySelector(\"#code-submit\"),xu=document.querySelector(\"#passkey-submit\"),Om=document.querySelector(\"#create-passkey-option\"),En=document.querySelector(\"#create-passkey\"),Am=document.querySelector(\"#back\"),bu=document.querySelector(\"#msg\"),Be=\"\",vu=!1,Q,wu=document.body.dataset.returnTo||\"/\",Pm=document.body.dataset.passkeyNamePrefix;if(window.location.pathname!==xe)wu=`${window.location.pathname}${window.location.search}${window.location.hash}`;function ee(e,t=!1){bu.textContent=e,bu.className=`msg${t?\" error\":\"\"}`}function An(){let e=Q;Q=void 0,e?.cancel()}function Pn(){ee(\"Signed in. Loading.\"),window.location.replace(wu)}function Su(e){An();let t=fu(e);Q=t,t.result.then((r)=>{if(Q!==t)return;if(Q=void 0,r)Pn();else if(!e)ee(\"Unable to sign in with a passkey. Use email recovery instead.\",!0)}).catch(()=>{if(Q!==t)return;if(Q=void 0,!e)ee(\"Unable to sign in with a passkey. Use email recovery instead.\",!0)})}async function Rm(){if(!vu||!En.checked)return;ee(\"Creating a passkey.\");try{let e=pu(Sn(Pm));if(Q=e,await e.result,Q===e)Q=void 0}catch{Q=void 0}}du().then(async(e)=>{if(e.authenticated){Pn();return}if(!e.passkeysEnabled)return;if(vu=!0,xu.hidden=!1,Om.hidden=!1,typeof PublicKeyCredential>\"u\"||typeof PublicKeyCredential.isConditionalMediationAvailable!==\"function\"||!await PublicKeyCredential.isConditionalMediationAvailable())return;Su(!0)}).catch(()=>{return});xu.addEventListener(\"click\",()=>{ee(\"\"),Su(!1)});Tn.addEventListener(\"submit\",(e)=>{if(e.preventDefault(),Be=_u.value.trim(),!Be)return;An(),gu.disabled=!0,ee(\"Sending.\"),mu(Be).then((t)=>{if(!t)throw Error(\"OTP request failed\");Tn.classList.add(\"hidden\"),kn.classList.remove(\"hidden\"),On.focus(),ee(`If ${Be} is authorized, a verification code is on its way.`)}).catch(()=>ee(\"Could not send a code. Check the address and try again.\",!0)).finally(()=>{gu.disabled=!1})});kn.addEventListener(\"submit\",(e)=>{e.preventDefault();let t=On.value.trim();if(!t)return;yu.disabled=!0,En.disabled=!0,ee(\"Verifying.\"),hu(Be,t,Be.split(\"@\")[0]||\"User\").then(async(r)=>{if(!r)throw Error(\"OTP verification failed\");await Rm(),Pn()}).catch(()=>{ee(\"That code was not accepted. Try again.\",!0),yu.disabled=!1,En.disabled=!1})});Am.addEventListener(\"click\",()=>{kn.classList.add(\"hidden\"),Tn.classList.remove(\"hidden\"),On.value=\"\",ee(\"\"),_u.focus()});window.addEventListener(\"pagehide\",An,{once:!0});})();\n";