@authhero/cloudflare-adapter 2.19.2 → 2.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const mt=require("@authhero/adapter-interfaces"),yt=require("wretch");function _t(t,e){var n={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(n[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,s=Object.getOwnPropertySymbols(t);a<s.length;a++)e.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(t,s[a])&&(n[s[a]]=t[s[a]]);return n}function gt(t,e){var n;return((n=t?._def)===null||n===void 0?void 0:n.typeName)===e}function re(t,e){const n=t.ZodType.prototype[e];t.ZodType.prototype[e]=function(...s){const a=n.apply(this,s);return a._def.openapi=this._def.openapi,a}}function vt(t){if(typeof t.ZodType.prototype.openapi<"u")return;t.ZodType.prototype.openapi=function(a,r){var i,o,c,u,p,k;const T=typeof a=="string"?r:a,S=T??{},{param:E}=S,q=_t(S,["param"]),x=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof a=="string"?{refId:a}:void 0),L=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),q),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||E?{param:Object.assign(Object.assign({},(k=(p=this._def.openapi)===null||p===void 0?void 0:p.metadata)===null||k===void 0?void 0:k.param),E)}:void 0),O=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(x).length>0?{_internal:x}:void 0),Object.keys(L).length>0?{metadata:L}:void 0)}));if(gt(this,"ZodObject")){const j=this.extend;O.extend=function(...W){var Q,ae,we,Se,Te,Ce,Ee;const Oe=j.apply(this,W);return Oe._def.openapi={_internal:{extendedFrom:!((ae=(Q=this._def.openapi)===null||Q===void 0?void 0:Q._internal)===null||ae===void 0)&&ae.refId?{refId:(Se=(we=this._def.openapi)===null||we===void 0?void 0:we._internal)===null||Se===void 0?void 0:Se.refId,schema:this}:(Ce=(Te=this._def.openapi)===null||Te===void 0?void 0:Te._internal)===null||Ce===void 0?void 0:Ce.extendedFrom},metadata:(Ee=Oe._def.openapi)===null||Ee===void 0?void 0:Ee.metadata},Oe}}return O},re(t,"optional"),re(t,"nullable"),re(t,"default"),re(t,"transform"),re(t,"refine");const e=t.ZodObject.prototype.deepPartial;t.ZodObject.prototype.deepPartial=function(){const a=this._def.shape(),r=e.apply(this),i=r._def.shape();return Object.entries(i).forEach(([o,c])=>{var u,p;c._def.openapi=(p=(u=a[o])===null||u===void 0?void 0:u._def)===null||p===void 0?void 0:p.openapi}),r._def.openapi=void 0,r};const n=t.ZodObject.prototype.pick;t.ZodObject.prototype.pick=function(...a){const r=n.apply(this,a);return r._def.openapi=void 0,r};const s=t.ZodObject.prototype.omit;t.ZodObject.prototype.omit=function(...a){const r=s.apply(this,a);return r._def.openapi=void 0,r}}var X=class extends Error{res;status;constructor(t=500,e){super(e?.message,{cause:e?.cause}),this.res=e?.res,this.status=t}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}};new Set(".\\+*[^]$()");var b;(function(t){t.assertEqual=a=>{};function e(a){}t.assertIs=e;function n(a){throw new Error}t.assertNever=n,t.arrayToEnum=a=>{const r={};for(const i of a)r[i]=i;return r},t.getValidEnumValues=a=>{const r=t.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),i={};for(const o of r)i[o]=a[o];return t.objectValues(i)},t.objectValues=a=>t.objectKeys(a).map(function(r){return a[r]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const r=[];for(const i in a)Object.prototype.hasOwnProperty.call(a,i)&&r.push(i);return r},t.find=(a,r)=>{for(const i of a)if(r(i))return i},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function s(a,r=" | "){return a.map(i=>typeof i=="string"?`'${i}'`:i).join(r)}t.joinValues=s,t.jsonStringifyReplacer=(a,r)=>typeof r=="bigint"?r.toString():r})(b||(b={}));var Re;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Re||(Re={}));const h=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),P=t=>{switch(typeof t){case"undefined":return h.undefined;case"string":return h.string;case"number":return Number.isNaN(t)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(t)?h.array:t===null?h.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?h.promise:typeof Map<"u"&&t instanceof Map?h.map:typeof Set<"u"&&t instanceof Set?h.set:typeof Date<"u"&&t instanceof Date?h.date:h.object;default:return h.unknown}},d=b.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Z extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(r){return r.message},s={_errors:[]},a=r=>{for(const i of r.issues)if(i.code==="invalid_union")i.unionErrors.map(a);else if(i.code==="invalid_return_type")a(i.returnTypeError);else if(i.code==="invalid_arguments")a(i.argumentsError);else if(i.path.length===0)s._errors.push(n(i));else{let o=s,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(n(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return a(this),s}static assert(e){if(!(e instanceof Z))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},s=[];for(const a of this.issues)if(a.path.length>0){const r=a.path[0];n[r]=n[r]||[],n[r].push(e(a))}else s.push(e(a));return{formErrors:s,fieldErrors:n}}get formErrors(){return this.flatten()}}Z.create=t=>new Z(t);const pe=(t,e)=>{let n;switch(t.code){case d.invalid_type:t.received===h.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,b.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:n=`Unrecognized key(s) in object: ${b.joinValues(t.keys,", ")}`;break;case d.invalid_union:n="Invalid input";break;case d.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${b.joinValues(t.options)}`;break;case d.invalid_enum_value:n=`Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;break;case d.invalid_arguments:n="Invalid function arguments";break;case d.invalid_return_type:n="Invalid function return type";break;case d.invalid_date:n="Invalid date";break;case d.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:b.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case d.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case d.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case d.custom:n="Invalid input";break;case d.invalid_intersection_types:n="Intersection results could not be merged";break;case d.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case d.not_finite:n="Number must be finite";break;default:n=e.defaultError,b.assertNever(t)}return{message:n}};let bt=pe;function Xe(){return bt}const et=t=>{const{data:e,path:n,errorMaps:s,issueData:a}=t,r=[...n,...a.path||[]],i={...a,path:r};if(a.message!==void 0)return{...a,path:r,message:a.message};let o="";const c=s.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return{...a,path:r,message:o}};function l(t,e){const n=Xe(),s=et({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===pe?void 0:pe].filter(a=>!!a)});t.common.issues.push(s)}class C{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const s=[];for(const a of n){if(a.status==="aborted")return y;a.status==="dirty"&&e.dirty(),s.push(a.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,n){const s=[];for(const a of n){const r=await a.key,i=await a.value;s.push({key:r,value:i})}return C.mergeObjectSync(e,s)}static mergeObjectSync(e,n){const s={};for(const a of n){const{key:r,value:i}=a;if(r.status==="aborted"||i.status==="aborted")return y;r.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof i.value<"u"||a.alwaysSet)&&(s[r.value]=i.value)}return{status:e.value,value:s}}}const y=Object.freeze({status:"aborted"}),te=t=>({status:"dirty",value:t}),N=t=>({status:"valid",value:t}),$e=t=>t.status==="aborted",je=t=>t.status==="dirty",J=t=>t.status==="valid",oe=t=>typeof Promise<"u"&&t instanceof Promise;var f;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(f||(f={}));class D{constructor(e,n,s,a){this._cachedPath=[],this.parent=e,this.data=n,this._path=s,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const He=(t,e)=>{if(J(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Z(t.common.issues);return this._error=n,this._error}}};function g(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:s,description:a}=t;if(e&&(n||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(i,o)=>{const{message:c}=t;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??n??o.defaultError}},description:a}}class v{get description(){return this._def.description}_getType(e){return P(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:P(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new C,ctx:{common:e.parent.common,data:e.data,parsedType:P(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(oe(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const s=this.safeParse(e,n);if(s.success)return s.data;throw s.error}safeParse(e,n){const s={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)},a=this._parseSync({data:e,path:s.path,parent:s});return He(s,a)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:n});return J(s)?{value:s.value}:{issues:n.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(s=>J(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(e,n){const s=await this.safeParseAsync(e,n);if(s.success)return s.data;throw s.error}async safeParseAsync(e,n){const s={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)},a=this._parse({data:e,path:s.path,parent:s}),r=await(oe(a)?a:Promise.resolve(a));return He(s,r)}refine(e,n){const s=a=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,r)=>{const i=e(a),o=()=>r.addIssue({code:d.custom,...s(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,n){return this._refinement((s,a)=>e(s)?!0:(a.addIssue(typeof n=="function"?n(s,a):n),!1))}_refinement(e){return new U({schema:this,typeName:m.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return V.create(this,this._def)}nullable(){return G.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return R.create(this)}promise(){return he.create(this,this._def)}or(e){return de.create([this,e],this._def)}and(e){return ue.create(this,e,this._def)}transform(e){return new U({...g(this._def),schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new ye({...g(this._def),innerType:this,defaultValue:n,typeName:m.ZodDefault})}brand(){return new rt({typeName:m.ZodBranded,type:this,...g(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new _e({...g(this._def),innerType:this,catchValue:n,typeName:m.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return xe.create(this,e)}readonly(){return ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const xt=/^c[^\s-]{8,}$/i,kt=/^[0-9a-z]+$/,wt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,St=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Tt=/^[a-z0-9_-]{21}$/i,Ct=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Et=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ot=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,At="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ae;const Nt=/^(?:(?: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])$/,Rt=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,$t=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,jt=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,It=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Zt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,tt="((\\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])))",Dt=new RegExp(`^${tt}$`);function nt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Lt(t){return new RegExp(`^${nt(t)}$`)}function st(t){let e=`${tt}T${nt(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Pt(t,e){return!!((e==="v4"||!e)&&Nt.test(t)||(e==="v6"||!e)&&$t.test(t))}function Mt(t,e){if(!Ct.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),a=JSON.parse(atob(s));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function Vt(t,e){return!!((e==="v4"||!e)&&Rt.test(t)||(e==="v6"||!e)&&jt.test(t))}class I extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:h.string,received:r.parsedType}),y}const s=new C;let a;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(a=this._getOrReturnCtx(e,a),l(a,{code:d.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),s.dirty());else if(r.kind==="max")e.data.length>r.value&&(a=this._getOrReturnCtx(e,a),l(a,{code:d.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),s.dirty());else if(r.kind==="length"){const i=e.data.length>r.value,o=e.data.length<r.value;(i||o)&&(a=this._getOrReturnCtx(e,a),i?l(a,{code:d.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):o&&l(a,{code:d.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),s.dirty())}else if(r.kind==="email")Ot.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"email",code:d.invalid_string,message:r.message}),s.dirty());else if(r.kind==="emoji")Ae||(Ae=new RegExp(At,"u")),Ae.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"emoji",code:d.invalid_string,message:r.message}),s.dirty());else if(r.kind==="uuid")St.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"uuid",code:d.invalid_string,message:r.message}),s.dirty());else if(r.kind==="nanoid")Tt.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"nanoid",code:d.invalid_string,message:r.message}),s.dirty());else if(r.kind==="cuid")xt.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"cuid",code:d.invalid_string,message:r.message}),s.dirty());else if(r.kind==="cuid2")kt.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"cuid2",code:d.invalid_string,message:r.message}),s.dirty());else if(r.kind==="ulid")wt.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"ulid",code:d.invalid_string,message:r.message}),s.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),l(a,{validation:"url",code:d.invalid_string,message:r.message}),s.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"regex",code:d.invalid_string,message:r.message}),s.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(a=this._getOrReturnCtx(e,a),l(a,{code:d.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),s.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(a=this._getOrReturnCtx(e,a),l(a,{code:d.invalid_string,validation:{startsWith:r.value},message:r.message}),s.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(a=this._getOrReturnCtx(e,a),l(a,{code:d.invalid_string,validation:{endsWith:r.value},message:r.message}),s.dirty()):r.kind==="datetime"?st(r).test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{code:d.invalid_string,validation:"datetime",message:r.message}),s.dirty()):r.kind==="date"?Dt.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{code:d.invalid_string,validation:"date",message:r.message}),s.dirty()):r.kind==="time"?Lt(r).test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{code:d.invalid_string,validation:"time",message:r.message}),s.dirty()):r.kind==="duration"?Et.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"duration",code:d.invalid_string,message:r.message}),s.dirty()):r.kind==="ip"?Pt(e.data,r.version)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"ip",code:d.invalid_string,message:r.message}),s.dirty()):r.kind==="jwt"?Mt(e.data,r.alg)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"jwt",code:d.invalid_string,message:r.message}),s.dirty()):r.kind==="cidr"?Vt(e.data,r.version)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"cidr",code:d.invalid_string,message:r.message}),s.dirty()):r.kind==="base64"?It.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"base64",code:d.invalid_string,message:r.message}),s.dirty()):r.kind==="base64url"?Zt.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"base64url",code:d.invalid_string,message:r.message}),s.dirty()):b.assertNever(r);return{status:s.value,value:e.data}}_regex(e,n,s){return this.refinement(a=>e.test(a),{validation:n,code:d.invalid_string,...f.errToObj(s)})}_addCheck(e){return new I({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...f.errToObj(e)})}url(e){return this._addCheck({kind:"url",...f.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...f.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...f.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...f.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...f.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...f.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...f.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...f.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...f.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...f.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...f.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...f.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...f.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...f.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...f.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...f.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...f.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...f.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...f.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...f.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...f.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...f.errToObj(n)})}nonempty(e){return this.min(1,f.errToObj(e))}trim(){return new I({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new I({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new I({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}I.create=t=>new I({checks:[],typeName:m.ZodString,coerce:t?.coerce??!1,...g(t)});function Bt(t,e){const n=(t.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,a=n>s?n:s,r=Number.parseInt(t.toFixed(a).replace(".","")),i=Number.parseInt(e.toFixed(a).replace(".",""));return r%i/10**a}class Y extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==h.number){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:h.number,received:r.parsedType}),y}let s;const a=new C;for(const r of this._def.checks)r.kind==="int"?b.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="multipleOf"?Bt(e.data,r.value)!==0&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_finite,message:r.message}),a.dirty()):b.assertNever(r);return{status:a.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,f.toString(n))}gt(e,n){return this.setLimit("min",e,!1,f.toString(n))}lte(e,n){return this.setLimit("max",e,!0,f.toString(n))}lt(e,n){return this.setLimit("max",e,!1,f.toString(n))}setLimit(e,n,s,a){return new Y({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:s,message:f.toString(a)}]})}_addCheck(e){return new Y({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:f.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:f.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:f.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:f.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:f.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:f.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:f.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:f.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:f.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(n===null||s.value>n)&&(n=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(n)&&Number.isFinite(e)}}Y.create=t=>new Y({checks:[],typeName:m.ZodNumber,coerce:t?.coerce||!1,...g(t)});class ne extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==h.bigint)return this._getInvalidInput(e);let s;const a=new C;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):b.assertNever(r);return{status:a.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return l(n,{code:d.invalid_type,expected:h.bigint,received:n.parsedType}),y}gte(e,n){return this.setLimit("min",e,!0,f.toString(n))}gt(e,n){return this.setLimit("min",e,!1,f.toString(n))}lte(e,n){return this.setLimit("max",e,!0,f.toString(n))}lt(e,n){return this.setLimit("max",e,!1,f.toString(n))}setLimit(e,n,s,a){return new ne({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:s,message:f.toString(a)}]})}_addCheck(e){return new ne({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:f.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:f.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:f.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:f.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:f.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ne.create=t=>new ne({checks:[],typeName:m.ZodBigInt,coerce:t?.coerce??!1,...g(t)});class me extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.boolean,received:s.parsedType}),y}return N(e.data)}}me.create=t=>new me({typeName:m.ZodBoolean,coerce:t?.coerce||!1,...g(t)});class ce extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:h.date,received:r.parsedType}),y}if(Number.isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_date}),y}const s=new C;let a;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(a=this._getOrReturnCtx(e,a),l(a,{code:d.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),s.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(a=this._getOrReturnCtx(e,a),l(a,{code:d.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),s.dirty()):b.assertNever(r);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ce({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:f.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:f.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}ce.create=t=>new ce({checks:[],coerce:t?.coerce||!1,typeName:m.ZodDate,...g(t)});class Ie extends v{_parse(e){if(this._getType(e)!==h.symbol){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.symbol,received:s.parsedType}),y}return N(e.data)}}Ie.create=t=>new Ie({typeName:m.ZodSymbol,...g(t)});class Ze extends v{_parse(e){if(this._getType(e)!==h.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.undefined,received:s.parsedType}),y}return N(e.data)}}Ze.create=t=>new Ze({typeName:m.ZodUndefined,...g(t)});class De extends v{_parse(e){if(this._getType(e)!==h.null){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.null,received:s.parsedType}),y}return N(e.data)}}De.create=t=>new De({typeName:m.ZodNull,...g(t)});class Le extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return N(e.data)}}Le.create=t=>new Le({typeName:m.ZodAny,...g(t)});class Pe extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return N(e.data)}}Pe.create=t=>new Pe({typeName:m.ZodUnknown,...g(t)});class B extends v{_parse(e){const n=this._getOrReturnCtx(e);return l(n,{code:d.invalid_type,expected:h.never,received:n.parsedType}),y}}B.create=t=>new B({typeName:m.ZodNever,...g(t)});class Me extends v{_parse(e){if(this._getType(e)!==h.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.void,received:s.parsedType}),y}return N(e.data)}}Me.create=t=>new Me({typeName:m.ZodVoid,...g(t)});class R extends v{_parse(e){const{ctx:n,status:s}=this._processInputParams(e),a=this._def;if(n.parsedType!==h.array)return l(n,{code:d.invalid_type,expected:h.array,received:n.parsedType}),y;if(a.exactLength!==null){const i=n.data.length>a.exactLength.value,o=n.data.length<a.exactLength.value;(i||o)&&(l(n,{code:i?d.too_big:d.too_small,minimum:o?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),s.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(l(n,{code:d.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),s.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(l(n,{code:d.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),s.dirty()),n.common.async)return Promise.all([...n.data].map((i,o)=>a.type._parseAsync(new D(n,i,n.path,o)))).then(i=>C.mergeArray(s,i));const r=[...n.data].map((i,o)=>a.type._parseSync(new D(n,i,n.path,o)));return C.mergeArray(s,r)}get element(){return this._def.type}min(e,n){return new R({...this._def,minLength:{value:e,message:f.toString(n)}})}max(e,n){return new R({...this._def,maxLength:{value:e,message:f.toString(n)}})}length(e,n){return new R({...this._def,exactLength:{value:e,message:f.toString(n)}})}nonempty(e){return this.min(1,e)}}R.create=(t,e)=>new R({type:t,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,...g(e)});function ee(t){if(t instanceof w){const e={};for(const n in t.shape){const s=t.shape[n];e[n]=V.create(ee(s))}return new w({...t._def,shape:()=>e})}else return t instanceof R?new R({...t._def,type:ee(t.element)}):t instanceof V?V.create(ee(t.unwrap())):t instanceof G?G.create(ee(t.unwrap())):t instanceof F?F.create(t.items.map(e=>ee(e))):t}class w extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=b.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==h.object){const u=this._getOrReturnCtx(e);return l(u,{code:d.invalid_type,expected:h.object,received:u.parsedType}),y}const{status:s,ctx:a}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof B&&this._def.unknownKeys==="strip"))for(const u in a.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const p=r[u],k=a.data[u];c.push({key:{status:"valid",value:u},value:p._parse(new D(a,k,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof B){const u=this._def.unknownKeys;if(u==="passthrough")for(const p of o)c.push({key:{status:"valid",value:p},value:{status:"valid",value:a.data[p]}});else if(u==="strict")o.length>0&&(l(a,{code:d.unrecognized_keys,keys:o}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const p of o){const k=a.data[p];c.push({key:{status:"valid",value:p},value:u._parse(new D(a,k,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of c){const k=await p.key,T=await p.value;u.push({key:k,value:T,alwaysSet:p.alwaysSet})}return u}).then(u=>C.mergeObjectSync(s,u)):C.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return f.errToObj,new w({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,s)=>{const a=this._def.errorMap?.(n,s).message??s.defaultError;return n.code==="unrecognized_keys"?{message:f.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new w({...this._def,unknownKeys:"strip"})}passthrough(){return new w({...this._def,unknownKeys:"passthrough"})}extend(e){return new w({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new w({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:m.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new w({...this._def,catchall:e})}pick(e){const n={};for(const s of b.objectKeys(e))e[s]&&this.shape[s]&&(n[s]=this.shape[s]);return new w({...this._def,shape:()=>n})}omit(e){const n={};for(const s of b.objectKeys(this.shape))e[s]||(n[s]=this.shape[s]);return new w({...this._def,shape:()=>n})}deepPartial(){return ee(this)}partial(e){const n={};for(const s of b.objectKeys(this.shape)){const a=this.shape[s];e&&!e[s]?n[s]=a:n[s]=a.optional()}return new w({...this._def,shape:()=>n})}required(e){const n={};for(const s of b.objectKeys(this.shape))if(e&&!e[s])n[s]=this.shape[s];else{let r=this.shape[s];for(;r instanceof V;)r=r._def.innerType;n[s]=r}return new w({...this._def,shape:()=>n})}keyof(){return at(b.objectKeys(this.shape))}}w.create=(t,e)=>new w({shape:()=>t,unknownKeys:"strip",catchall:B.create(),typeName:m.ZodObject,...g(e)});w.strictCreate=(t,e)=>new w({shape:()=>t,unknownKeys:"strict",catchall:B.create(),typeName:m.ZodObject,...g(e)});w.lazycreate=(t,e)=>new w({shape:t,unknownKeys:"strip",catchall:B.create(),typeName:m.ZodObject,...g(e)});class de extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s=this._def.options;function a(r){for(const o of r)if(o.result.status==="valid")return o.result;for(const o of r)if(o.result.status==="dirty")return n.common.issues.push(...o.ctx.common.issues),o.result;const i=r.map(o=>new Z(o.ctx.common.issues));return l(n,{code:d.invalid_union,unionErrors:i}),y}if(n.common.async)return Promise.all(s.map(async r=>{const i={...n,common:{...n.common,issues:[]},parent:null};return{result:await r._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(a);{let r;const i=[];for(const c of s){const u={...n,common:{...n.common,issues:[]},parent:null},p=c._parseSync({data:n.data,path:n.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!r&&(r={result:p,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(r)return n.common.issues.push(...r.ctx.common.issues),r.result;const o=i.map(c=>new Z(c));return l(n,{code:d.invalid_union,unionErrors:o}),y}}get options(){return this._def.options}}de.create=(t,e)=>new de({options:t,typeName:m.ZodUnion,...g(e)});function Ve(t,e){const n=P(t),s=P(e);if(t===e)return{valid:!0,data:t};if(n===h.object&&s===h.object){const a=b.objectKeys(e),r=b.objectKeys(t).filter(o=>a.indexOf(o)!==-1),i={...t,...e};for(const o of r){const c=Ve(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(n===h.array&&s===h.array){if(t.length!==e.length)return{valid:!1};const a=[];for(let r=0;r<t.length;r++){const i=t[r],o=e[r],c=Ve(i,o);if(!c.valid)return{valid:!1};a.push(c.data)}return{valid:!0,data:a}}else return n===h.date&&s===h.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class ue extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e),a=(r,i)=>{if($e(r)||$e(i))return y;const o=Ve(r.value,i.value);return o.valid?((je(r)||je(i))&&n.dirty(),{status:n.value,value:o.data}):(l(s,{code:d.invalid_intersection_types}),y)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([r,i])=>a(r,i)):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ue.create=(t,e,n)=>new ue({left:t,right:e,typeName:m.ZodIntersection,...g(n)});class F extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.array)return l(s,{code:d.invalid_type,expected:h.array,received:s.parsedType}),y;if(s.data.length<this._def.items.length)return l(s,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&s.data.length>this._def.items.length&&(l(s,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const r=[...s.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new D(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(r).then(i=>C.mergeArray(n,i)):C.mergeArray(n,r)}get items(){return this._def.items}rest(e){return new F({...this._def,rest:e})}}F.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new F({items:t,typeName:m.ZodTuple,rest:null,...g(e)})};class le extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.object)return l(s,{code:d.invalid_type,expected:h.object,received:s.parsedType}),y;const a=[],r=this._def.keyType,i=this._def.valueType;for(const o in s.data)a.push({key:r._parse(new D(s,o,s.path,o)),value:i._parse(new D(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?C.mergeObjectAsync(n,a):C.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(e,n,s){return n instanceof v?new le({keyType:e,valueType:n,typeName:m.ZodRecord,...g(s)}):new le({keyType:I.create(),valueType:e,typeName:m.ZodRecord,...g(n)})}}class Be extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.map)return l(s,{code:d.invalid_type,expected:h.map,received:s.parsedType}),y;const a=this._def.keyType,r=this._def.valueType,i=[...s.data.entries()].map(([o,c],u)=>({key:a._parse(new D(s,o,s.path,[u,"key"])),value:r._parse(new D(s,c,s.path,[u,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const u=await c.key,p=await c.value;if(u.status==="aborted"||p.status==="aborted")return y;(u.status==="dirty"||p.status==="dirty")&&n.dirty(),o.set(u.value,p.value)}return{status:n.value,value:o}})}else{const o=new Map;for(const c of i){const u=c.key,p=c.value;if(u.status==="aborted"||p.status==="aborted")return y;(u.status==="dirty"||p.status==="dirty")&&n.dirty(),o.set(u.value,p.value)}return{status:n.value,value:o}}}}Be.create=(t,e,n)=>new Be({valueType:e,keyType:t,typeName:m.ZodMap,...g(n)});class se extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.set)return l(s,{code:d.invalid_type,expected:h.set,received:s.parsedType}),y;const a=this._def;a.minSize!==null&&s.data.size<a.minSize.value&&(l(s,{code:d.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&s.data.size>a.maxSize.value&&(l(s,{code:d.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());const r=this._def.valueType;function i(c){const u=new Set;for(const p of c){if(p.status==="aborted")return y;p.status==="dirty"&&n.dirty(),u.add(p.value)}return{status:n.value,value:u}}const o=[...s.data.values()].map((c,u)=>r._parse(new D(s,c,s.path,u)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,n){return new se({...this._def,minSize:{value:e,message:f.toString(n)}})}max(e,n){return new se({...this._def,maxSize:{value:e,message:f.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}se.create=(t,e)=>new se({valueType:t,minSize:null,maxSize:null,typeName:m.ZodSet,...g(e)});class ze extends v{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}ze.create=(t,e)=>new ze({getter:t,typeName:m.ZodLazy,...g(e)});class Fe extends v{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return l(n,{received:n.data,code:d.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}}Fe.create=(t,e)=>new Fe({value:t,typeName:m.ZodLiteral,...g(e)});function at(t,e){return new K({values:t,typeName:m.ZodEnum,...g(e)})}class K extends v{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),s=this._def.values;return l(n,{expected:b.joinValues(s),received:n.parsedType,code:d.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),s=this._def.values;return l(n,{received:n.data,code:d.invalid_enum_value,options:s}),y}return N(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return K.create(e,{...this._def,...n})}exclude(e,n=this._def){return K.create(this.options.filter(s=>!e.includes(s)),{...this._def,...n})}}K.create=at;class Ue extends v{_parse(e){const n=b.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==h.string&&s.parsedType!==h.number){const a=b.objectValues(n);return l(s,{expected:b.joinValues(a),received:s.parsedType,code:d.invalid_type}),y}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=b.objectValues(n);return l(s,{received:s.data,code:d.invalid_enum_value,options:a}),y}return N(e.data)}get enum(){return this._def.values}}Ue.create=(t,e)=>new Ue({values:t,typeName:m.ZodNativeEnum,...g(e)});class he extends v{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==h.promise&&n.common.async===!1)return l(n,{code:d.invalid_type,expected:h.promise,received:n.parsedType}),y;const s=n.parsedType===h.promise?n.data:Promise.resolve(n.data);return N(s.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}}he.create=(t,e)=>new he({type:t,typeName:m.ZodPromise,...g(e)});class U extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===m.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:s}=this._processInputParams(e),a=this._def.effect||null,r={addIssue:i=>{l(s,i),i.fatal?n.abort():n.dirty()},get path(){return s.path}};if(r.addIssue=r.addIssue.bind(r),a.type==="preprocess"){const i=a.transform(s.data,r);if(s.common.async)return Promise.resolve(i).then(async o=>{if(n.value==="aborted")return y;const c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?y:c.status==="dirty"||n.value==="dirty"?te(c.value):c});{if(n.value==="aborted")return y;const o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?y:o.status==="dirty"||n.value==="dirty"?te(o.value):o}}if(a.type==="refinement"){const i=o=>{const c=a.refinement(o,r);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?y:(o.status==="dirty"&&n.dirty(),i(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?y:(o.status==="dirty"&&n.dirty(),i(o.value).then(()=>({status:n.value,value:o.value}))))}if(a.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!J(i))return y;const o=a.transform(i.value,r);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>J(i)?Promise.resolve(a.transform(i.value,r)).then(o=>({status:n.value,value:o})):y);b.assertNever(a)}}U.create=(t,e,n)=>new U({schema:t,typeName:m.ZodEffects,effect:e,...g(n)});U.createWithPreprocess=(t,e,n)=>new U({schema:e,effect:{type:"preprocess",transform:t},typeName:m.ZodEffects,...g(n)});class V extends v{_parse(e){return this._getType(e)===h.undefined?N(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}V.create=(t,e)=>new V({innerType:t,typeName:m.ZodOptional,...g(e)});class G extends v{_parse(e){return this._getType(e)===h.null?N(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}G.create=(t,e)=>new G({innerType:t,typeName:m.ZodNullable,...g(e)});class ye extends v{_parse(e){const{ctx:n}=this._processInputParams(e);let s=n.data;return n.parsedType===h.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}ye.create=(t,e)=>new ye({innerType:t,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...g(e)});class _e extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return oe(a)?a.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Z(s.common.issues)},input:s.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Z(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}_e.create=(t,e)=>new _e({innerType:t,typeName:m.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...g(e)});class qe extends v{_parse(e){if(this._getType(e)!==h.nan){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.nan,received:s.parsedType}),y}return{status:"valid",value:e.data}}}qe.create=t=>new qe({typeName:m.ZodNaN,...g(t)});class rt extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s=n.data;return this._def.type._parse({data:s,path:n.path,parent:n})}unwrap(){return this._def.type}}class xe extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?y:r.status==="dirty"?(n.dirty(),te(r.value)):this._def.out._parseAsync({data:r.value,path:s.path,parent:s})})();{const a=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?y:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:s.path,parent:s})}}static create(e,n){return new xe({in:e,out:n,typeName:m.ZodPipeline})}}class ge extends v{_parse(e){const n=this._def.innerType._parse(e),s=a=>(J(a)&&(a.value=Object.freeze(a.value)),a);return oe(n)?n.then(a=>s(a)):s(n)}unwrap(){return this._def.innerType}}ge.create=(t,e)=>new ge({innerType:t,typeName:m.ZodReadonly,...g(e)});var m;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(m||(m={}));const _=I.create,it=Y.create,ke=me.create;B.create;const A=R.create,$=w.create;de.create;ue.create;F.create;const ot=le.create;K.create;he.create;V.create;G.create;const zt=Object.freeze(Object.defineProperty({__proto__:null,DIRTY:te,INVALID:y,OK:N,ParseStatus:C,Schema:v,ZodAny:Le,ZodArray:R,ZodBigInt:ne,ZodBoolean:me,ZodBranded:rt,ZodCatch:_e,ZodDate:ce,ZodDefault:ye,ZodEffects:U,ZodEnum:K,ZodError:Z,get ZodFirstPartyTypeKind(){return m},ZodIntersection:ue,ZodIssueCode:d,ZodLazy:ze,ZodLiteral:Fe,ZodMap:Be,ZodNaN:qe,ZodNativeEnum:Ue,ZodNever:B,ZodNull:De,ZodNullable:G,ZodNumber:Y,ZodObject:w,ZodOptional:V,ZodParsedType:h,ZodPipeline:xe,ZodPromise:he,ZodReadonly:ge,ZodRecord:le,ZodSchema:v,ZodSet:se,ZodString:I,ZodSymbol:Ie,ZodTransformer:U,ZodTuple:F,ZodType:v,ZodUndefined:Ze,ZodUnion:de,ZodUnknown:Pe,ZodVoid:Me,addIssueToContext:l,array:A,boolean:ke,datetimeRegex:st,defaultErrorMap:pe,getErrorMap:Xe,getParsedType:P,isAborted:$e,isAsync:oe,isDirty:je,isValid:J,makeIssue:et,number:it,object:$,get objectUtil(){return Re},record:ot,string:_,get util(){return b}},Symbol.toStringTag,{value:"Module"}));vt(zt);const Ft=(t,e)=>e.skipDedupe||e.method!=="GET",Ut=(t,e)=>e.method+"@"+t,qt=t=>t.clone(),Wt=({skip:t=Ft,key:e=Ut,resolver:n=qt}={})=>{const s=new Map;return a=>(r,i)=>{if(t(r,i))return a(r,i);const o=e(r,i);if(!s.has(o))s.set(o,[]);else return new Promise((c,u)=>{s.get(o).push([c,u])});try{return a(r,i).then(c=>(s.get(o).forEach(([u])=>u(n(c))),s.delete(o),c)).catch(c=>{throw s.get(o).forEach(([,u])=>u(c)),s.delete(o),c})}catch(c){return s.delete(o),Promise.reject(c)}}},Qt=(t,e)=>t*e,Ht=t=>t&&(t.ok||t.status>=400&&t.status<500),Jt=({delayTimer:t=500,delayRamp:e=Qt,maxAttempts:n=10,until:s=Ht,onRetry:a=null,retryOnNetworkError:r=!1,resolveWithLatestResponse:i=!1,skip:o}={})=>c=>(u,p)=>{let k=0;if(o&&o(u,p))return c(u,p);const T=(S,E)=>Promise.resolve(s(S,E)).then(q=>q?S&&i?S:E?Promise.reject(E):S:(k++,!n||k<=n?new Promise(x=>{const L=e(t,k);setTimeout(()=>{typeof a=="function"?Promise.resolve(a({response:S,error:E,url:u,attempt:k,options:p})).then((O={})=>{var j,W;x(c((j=O&&O.url)!==null&&j!==void 0?j:u,(W=O&&O.options)!==null&&W!==void 0?W:p))}):x(c(u,p))},L)}).then(T).catch(x=>{if(!r)throw x;return T(null,x)}):S&&i?S:Promise.reject(E||new Error("Number of attempts exceeded."))));return c(u,p).then(T).catch(S=>{if(!r)throw S;return T(null,S)})},ve=$({code:it(),message:_()}),Yt=$({message:_()}),Kt=$({emails:A(_()).optional(),http_body:_().optional(),http_url:_().optional(),txt_name:_().optional(),txt_value:_().optional()}),Gt=$({ciphers:A(_()).optional(),early_hints:_().optional(),http2:_().optional(),min_tls_version:_().optional(),tls_1_3:_().optional()}),Xt=$({id:_(),bundle_method:_().optional(),certificate_authority:_(),custom_certificate:_().optional(),custom_csr_id:_().optional(),custom_key:_().optional(),expires_on:_().optional(),hosts:A(_()).optional(),issuer:_().optional(),method:_(),serial_number:_().optional(),settings:Gt.optional(),signature:_().optional(),type:_(),uploaded_on:_().optional(),validation_errors:A(Yt).optional(),validation_records:A(Kt).optional(),wildcard:ke()}),en=$({name:_(),type:_(),value:_()}),tn=$({http_body:_().optional(),http_url:_().optional()}),ct=$({id:_(),ssl:Xt,hostname:_(),custom_metadata:ot(_()).optional(),custom_origin_server:_().optional(),custom_origin_sni:_().optional(),ownership_verification:en.optional(),ownership_verification_http:tn.optional(),status:_(),verification_errors:A(_()).optional(),created_at:_()}),ie=$({errors:A(ve),messages:A(ve),success:ke(),result:ct});$({errors:A(ve),messages:A(ve),success:ke(),result:A(ct)});function H(t){return yt(`https://api.cloudflare.com/client/v4/zones/${t.zoneId}`).headers({"X-Auth-Email":t.authEmail,"X-Auth-Key":t.authKey,"Content-Type":"application/json"}).middlewares([Jt(),Wt()])}function Je(t){const e={},n={};if(!t)return{sslOverrides:e,rest:n};for(const[s,a]of Object.entries(t))s.startsWith("ssl.")?e[s.slice(4)]=a:n[s]=a;return{sslOverrides:e,rest:n}}function Ne(t){const e=[];if(t.ssl.validation_records)for(const s of t.ssl.validation_records)s.txt_name&&s.txt_value&&e.push({name:"txt",record:s.txt_value,domain:s.txt_name});t.ownership_verification&&e.push({name:"txt",record:t.ownership_verification.value,domain:t.ownership_verification.name});const n={...t.domain_metadata||{},"ssl.method":t.ssl.method,"ssl.type":t.ssl.type,"ssl.certificate_authority":t.ssl.certificate_authority};return{custom_domain_id:t.id,domain:t.hostname,primary:t.primary,status:t.status==="active"?"ready":"pending",type:"auth0_managed_certs",verification:{methods:A(mt.verificationMethodsSchema).parse(e)},domain_metadata:n}}function nn(t){return{create:async(e,n)=>{const{sslOverrides:s,rest:a}=Je(n.domain_metadata),{result:r,errors:i,success:o}=ie.parse(await H(t).post({hostname:n.domain,ssl:{method:"txt",type:"dv",...s},custom_metadata:t.enterprise?{tenant_id:e}:void 0},"/custom_hostnames").json());if(!o)throw new Error(JSON.stringify(i));const c=Ne({...r,primary:!1,domain_metadata:a});return await t.customDomainAdapter.create(e,{custom_domain_id:c.custom_domain_id,domain:c.domain,type:c.type,domain_metadata:n.domain_metadata}),c},get:async(e,n)=>{const s=await t.customDomainAdapter.get(e,n);if(!s)throw new X(404);const a=await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(),{result:r,errors:i,success:o}=ie.parse(a);if(!o)throw new X(503,{message:JSON.stringify(i)});if(t.enterprise&&r.custom_metadata?.tenant_id!==e)throw new X(404);return Ne({...s,...r})},getByDomain:async e=>t.customDomainAdapter.getByDomain(e),list:async e=>{const n=await t.customDomainAdapter.list(e);return(await Promise.all(n.map(async a=>{try{const r=await H(t).get(`/custom_hostnames/${encodeURIComponent(a.custom_domain_id)}`).json(),{result:i,success:o}=ie.parse(r);return!o||t.enterprise&&i.custom_metadata?.tenant_id!==e?null:Ne({...a,...i})}catch{return null}}))).filter(a=>a!==null)},remove:async(e,n)=>{if(t.enterprise){const{result:a,success:r}=ie.parse(await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json());if(!r||a.custom_metadata?.tenant_id!==e)throw new X(404)}const s=await H(t).delete(`/custom_hostnames/${encodeURIComponent(n)}`).res();return s.ok&&await t.customDomainAdapter.remove(e,n),s.ok},update:async(e,n,s)=>{const{sslOverrides:a}=Je(s.domain_metadata),r={};if(Object.keys(a).length>0){const i=await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(),{result:o,success:c}=ie.parse(i);if(!c)throw new X(503,{message:"Failed to fetch current custom hostname state"});r.ssl={method:o.ssl.method,type:o.ssl.type,certificate_authority:o.ssl.certificate_authority,...a}}if(Object.keys(r).length>0){const i=await H(t).patch(r,`/custom_hostnames/${encodeURIComponent(n)}`).res();if(!i.ok)throw new X(503,{message:await i.text()})}return t.customDomainAdapter.update(e,n,s)}}}class sn{constructor(e){this.config=e}cache=null;async getCache(){if(this.cache)return this.cache;if(typeof caches>"u")throw new Error("caches API is not available - CloudflareCache should only be used in Cloudflare Workers");return this.config.cacheName?this.cache=await caches.open(this.config.cacheName):this.cache=caches.default,this.cache}getKey(e){return this.config.keyPrefix?`${this.config.keyPrefix}:${e}`:e}createRequest(e){return new Request(`https://cache.internal/${this.getKey(e)}`)}async get(e){try{const n=await this.getCache(),s=this.createRequest(e),a=await n.match(s);if(!a)return null;const r=await a.json();return r.expiresAt&&new Date(r.expiresAt)<new Date?(await this.delete(e),null):r.value}catch(n){return console.error(`CloudflareCache: get error for key ${e}:`,n),null}}async set(e,n,s){try{const a=await this.getCache(),r=s??this.config.defaultTtlSeconds,i=r!==void 0,o=i?Math.max(0,r):0,c={value:n,expiresAt:i?new Date(Date.now()+(o>0?o*1e3:-1)).toISOString():void 0,cachedAt:new Date().toISOString()},u=this.createRequest(e),p={"Content-Type":"application/json"};i&&o>0&&(p["Cache-Control"]=`max-age=${o}`);const k=new Response(JSON.stringify(c),{headers:p});await a.put(u,k)}catch(a){console.error(`CloudflareCache: set error for key ${e}:`,a)}}async delete(e){try{const n=await this.getCache(),s=this.createRequest(e);return await n.delete(s)}catch(n){return console.error(`CloudflareCache: delete error for key ${e}:`,n),!1}}async deleteByPrefix(e){return console.warn("CloudflareCache.deleteByPrefix() is not implemented - Cloudflare Cache API does not support prefix-based deletion"),0}async clear(){console.warn("CloudflareCache.clear() is not implemented - Cloudflare Cache API does not support clearing all entries")}}function an(t={}){const e={defaultTtlSeconds:300,keyPrefix:"authhero",...t};return new sn(e)}const rn="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let dt=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=rn[n[t]&63];return e};async function We(t,e){const n=t.timeout||3e4,s=new AbortController,a=setTimeout(()=>s.abort(),n);try{const r=`https://api.sql.cloudflarestorage.com/api/v1/accounts/${t.accountId}/r2-sql/query/${t.warehouseName}`,i=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.authToken}`},body:JSON.stringify({query:e}),signal:s.signal});if(!i.ok)throw new Error(`R2 SQL query failed: ${i.status} ${i.statusText}`);const o=await i.json();if(!o.success&&o.errors)throw new Error(`R2 SQL error: ${o.errors.join(", ")}`);return o.data||o.result?.data||[]}finally{clearTimeout(a)}}function be(t){return`'${t.replace(/'/g,"''")}'`}function z(t){return`"${t.replace(/"/g,'""')}"`}function ut(t){const e=n=>{if(!n)return"";try{return JSON.parse(n)}catch{return n}};return{type:t.type,date:t.date,description:t.description,ip:t.ip,user_agent:t.user_agent,details:e(t.details),isMobile:!!t.isMobile,user_id:t.user_id,user_name:t.user_name,connection:t.connection,connection_id:t.connection_id,client_id:t.client_id,client_name:t.client_name,audience:t.audience,scope:t.scope,strategy:t.strategy,strategy_type:t.strategy_type,hostname:t.hostname,auth0_client:e(t.auth0_client),log_id:t.id,location_info:t.country_code||t.city_name||t.latitude||t.longitude||t.time_zone||t.continent_code?{country_code:t.country_code||"",city_name:t.city_name||"",latitude:t.latitude||"",longitude:t.longitude||"",time_zone:t.time_zone||"",continent_code:t.continent_code||""}:void 0}}function on(t){return async(e,n)=>{const s=n.log_id||dt(),a={...n,log_id:s};return await cn(t,e,a),a}}async function cn(t,e,n){const s=r=>r?JSON.stringify(r):void 0,a={id:n.log_id,tenant_id:e,type:n.type,date:n.date,description:n.description?.substring(0,256),ip:n.ip,user_agent:n.user_agent,details:s(n.details)?.substring(0,8192),isMobile:n.isMobile?1:0,user_id:n.user_id,user_name:n.user_name,connection:n.connection,connection_id:n.connection_id,client_id:n.client_id,client_name:n.client_name,audience:n.audience,scope:n.scope,strategy:n.strategy,strategy_type:n.strategy_type,hostname:n.hostname,auth0_client:s(n.auth0_client),log_id:n.log_id,country_code:n.location_info?.country_code,city_name:n.location_info?.city_name,latitude:n.location_info?.latitude,longitude:n.location_info?.longitude,time_zone:n.location_info?.time_zone,continent_code:n.location_info?.continent_code};try{if(t.pipelineBinding)await t.pipelineBinding.send([a]);else if(t.pipelineEndpoint){const r=t.timeout||3e4,i=new AbortController,o=setTimeout(()=>i.abort(),r);try{const c=await fetch(t.pipelineEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([a]),signal:i.signal});if(!c.ok)throw new Error(`Pipeline ingestion failed: ${c.status} ${c.statusText}`)}finally{clearTimeout(o)}}else throw new Error("Either pipelineEndpoint or pipelineBinding must be configured")}catch(r){throw console.error("Failed to send log to Pipeline:",r),r}}function dn(t){return async(e,n)=>{const s=t.namespace||"default",a=t.tableName||"logs",r=`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const mt=require("@authhero/adapter-interfaces"),_t=require("wretch");function yt(t,e){var n={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(n[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,s=Object.getOwnPropertySymbols(t);a<s.length;a++)e.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(t,s[a])&&(n[s[a]]=t[s[a]]);return n}function gt(t,e){var n;return((n=t?._def)===null||n===void 0?void 0:n.typeName)===e}function re(t,e){const n=t.ZodType.prototype[e];t.ZodType.prototype[e]=function(...s){const a=n.apply(this,s);return a._def.openapi=this._def.openapi,a}}function vt(t){if(typeof t.ZodType.prototype.openapi<"u")return;t.ZodType.prototype.openapi=function(a,r){var i,o,c,u,p,k;const T=typeof a=="string"?r:a,S=T??{},{param:E}=S,q=yt(S,["param"]),x=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof a=="string"?{refId:a}:void 0),L=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),q),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||E?{param:Object.assign(Object.assign({},(k=(p=this._def.openapi)===null||p===void 0?void 0:p.metadata)===null||k===void 0?void 0:k.param),E)}:void 0),O=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(x).length>0?{_internal:x}:void 0),Object.keys(L).length>0?{metadata:L}:void 0)}));if(gt(this,"ZodObject")){const j=this.extend;O.extend=function(...W){var Q,ae,we,Se,Te,Ce,Ee;const Oe=j.apply(this,W);return Oe._def.openapi={_internal:{extendedFrom:!((ae=(Q=this._def.openapi)===null||Q===void 0?void 0:Q._internal)===null||ae===void 0)&&ae.refId?{refId:(Se=(we=this._def.openapi)===null||we===void 0?void 0:we._internal)===null||Se===void 0?void 0:Se.refId,schema:this}:(Ce=(Te=this._def.openapi)===null||Te===void 0?void 0:Te._internal)===null||Ce===void 0?void 0:Ce.extendedFrom},metadata:(Ee=Oe._def.openapi)===null||Ee===void 0?void 0:Ee.metadata},Oe}}return O},re(t,"optional"),re(t,"nullable"),re(t,"default"),re(t,"transform"),re(t,"refine");const e=t.ZodObject.prototype.deepPartial;t.ZodObject.prototype.deepPartial=function(){const a=this._def.shape(),r=e.apply(this),i=r._def.shape();return Object.entries(i).forEach(([o,c])=>{var u,p;c._def.openapi=(p=(u=a[o])===null||u===void 0?void 0:u._def)===null||p===void 0?void 0:p.openapi}),r._def.openapi=void 0,r};const n=t.ZodObject.prototype.pick;t.ZodObject.prototype.pick=function(...a){const r=n.apply(this,a);return r._def.openapi=void 0,r};const s=t.ZodObject.prototype.omit;t.ZodObject.prototype.omit=function(...a){const r=s.apply(this,a);return r._def.openapi=void 0,r}}var X=class extends Error{res;status;constructor(t=500,e){super(e?.message,{cause:e?.cause}),this.res=e?.res,this.status=t}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}};new Set(".\\+*[^]$()");var b;(function(t){t.assertEqual=a=>{};function e(a){}t.assertIs=e;function n(a){throw new Error}t.assertNever=n,t.arrayToEnum=a=>{const r={};for(const i of a)r[i]=i;return r},t.getValidEnumValues=a=>{const r=t.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),i={};for(const o of r)i[o]=a[o];return t.objectValues(i)},t.objectValues=a=>t.objectKeys(a).map(function(r){return a[r]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const r=[];for(const i in a)Object.prototype.hasOwnProperty.call(a,i)&&r.push(i);return r},t.find=(a,r)=>{for(const i of a)if(r(i))return i},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function s(a,r=" | "){return a.map(i=>typeof i=="string"?`'${i}'`:i).join(r)}t.joinValues=s,t.jsonStringifyReplacer=(a,r)=>typeof r=="bigint"?r.toString():r})(b||(b={}));var Re;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Re||(Re={}));const h=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),P=t=>{switch(typeof t){case"undefined":return h.undefined;case"string":return h.string;case"number":return Number.isNaN(t)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(t)?h.array:t===null?h.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?h.promise:typeof Map<"u"&&t instanceof Map?h.map:typeof Set<"u"&&t instanceof Set?h.set:typeof Date<"u"&&t instanceof Date?h.date:h.object;default:return h.unknown}},d=b.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Z extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(r){return r.message},s={_errors:[]},a=r=>{for(const i of r.issues)if(i.code==="invalid_union")i.unionErrors.map(a);else if(i.code==="invalid_return_type")a(i.returnTypeError);else if(i.code==="invalid_arguments")a(i.argumentsError);else if(i.path.length===0)s._errors.push(n(i));else{let o=s,c=0;for(;c<i.path.length;){const u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(n(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return a(this),s}static assert(e){if(!(e instanceof Z))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},s=[];for(const a of this.issues)if(a.path.length>0){const r=a.path[0];n[r]=n[r]||[],n[r].push(e(a))}else s.push(e(a));return{formErrors:s,fieldErrors:n}}get formErrors(){return this.flatten()}}Z.create=t=>new Z(t);const pe=(t,e)=>{let n;switch(t.code){case d.invalid_type:t.received===h.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case d.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,b.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:n=`Unrecognized key(s) in object: ${b.joinValues(t.keys,", ")}`;break;case d.invalid_union:n="Invalid input";break;case d.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${b.joinValues(t.options)}`;break;case d.invalid_enum_value:n=`Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;break;case d.invalid_arguments:n="Invalid function arguments";break;case d.invalid_return_type:n="Invalid function return type";break;case d.invalid_date:n="Invalid date";break;case d.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:b.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case d.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case d.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case d.custom:n="Invalid input";break;case d.invalid_intersection_types:n="Intersection results could not be merged";break;case d.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case d.not_finite:n="Number must be finite";break;default:n=e.defaultError,b.assertNever(t)}return{message:n}};let bt=pe;function Xe(){return bt}const et=t=>{const{data:e,path:n,errorMaps:s,issueData:a}=t,r=[...n,...a.path||[]],i={...a,path:r};if(a.message!==void 0)return{...a,path:r,message:a.message};let o="";const c=s.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return{...a,path:r,message:o}};function l(t,e){const n=Xe(),s=et({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===pe?void 0:pe].filter(a=>!!a)});t.common.issues.push(s)}class C{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const s=[];for(const a of n){if(a.status==="aborted")return _;a.status==="dirty"&&e.dirty(),s.push(a.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,n){const s=[];for(const a of n){const r=await a.key,i=await a.value;s.push({key:r,value:i})}return C.mergeObjectSync(e,s)}static mergeObjectSync(e,n){const s={};for(const a of n){const{key:r,value:i}=a;if(r.status==="aborted"||i.status==="aborted")return _;r.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof i.value<"u"||a.alwaysSet)&&(s[r.value]=i.value)}return{status:e.value,value:s}}}const _=Object.freeze({status:"aborted"}),te=t=>({status:"dirty",value:t}),N=t=>({status:"valid",value:t}),$e=t=>t.status==="aborted",je=t=>t.status==="dirty",J=t=>t.status==="valid",oe=t=>typeof Promise<"u"&&t instanceof Promise;var f;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(f||(f={}));class D{constructor(e,n,s,a){this._cachedPath=[],this.parent=e,this.data=n,this._path=s,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const He=(t,e)=>{if(J(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Z(t.common.issues);return this._error=n,this._error}}};function g(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:s,description:a}=t;if(e&&(n||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(i,o)=>{const{message:c}=t;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??n??o.defaultError}},description:a}}class v{get description(){return this._def.description}_getType(e){return P(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:P(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new C,ctx:{common:e.parent.common,data:e.data,parsedType:P(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(oe(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const s=this.safeParse(e,n);if(s.success)return s.data;throw s.error}safeParse(e,n){const s={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)},a=this._parseSync({data:e,path:s.path,parent:s});return He(s,a)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:n});return J(s)?{value:s.value}:{issues:n.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(s=>J(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(e,n){const s=await this.safeParseAsync(e,n);if(s.success)return s.data;throw s.error}async safeParseAsync(e,n){const s={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)},a=this._parse({data:e,path:s.path,parent:s}),r=await(oe(a)?a:Promise.resolve(a));return He(s,r)}refine(e,n){const s=a=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(a):n;return this._refinement((a,r)=>{const i=e(a),o=()=>r.addIssue({code:d.custom,...s(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,n){return this._refinement((s,a)=>e(s)?!0:(a.addIssue(typeof n=="function"?n(s,a):n),!1))}_refinement(e){return new U({schema:this,typeName:m.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return V.create(this,this._def)}nullable(){return G.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return R.create(this)}promise(){return he.create(this,this._def)}or(e){return de.create([this,e],this._def)}and(e){return ue.create(this,e,this._def)}transform(e){return new U({...g(this._def),schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new _e({...g(this._def),innerType:this,defaultValue:n,typeName:m.ZodDefault})}brand(){return new rt({typeName:m.ZodBranded,type:this,...g(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new ye({...g(this._def),innerType:this,catchValue:n,typeName:m.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return xe.create(this,e)}readonly(){return ge.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const xt=/^c[^\s-]{8,}$/i,kt=/^[0-9a-z]+$/,wt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,St=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Tt=/^[a-z0-9_-]{21}$/i,Ct=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Et=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ot=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,At="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ae;const Nt=/^(?:(?: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])$/,Rt=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,$t=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,jt=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,It=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Zt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,tt="((\\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])))",Dt=new RegExp(`^${tt}$`);function nt(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Lt(t){return new RegExp(`^${nt(t)}$`)}function st(t){let e=`${tt}T${nt(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Pt(t,e){return!!((e==="v4"||!e)&&Nt.test(t)||(e==="v6"||!e)&&$t.test(t))}function Mt(t,e){if(!Ct.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),a=JSON.parse(atob(s));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function Vt(t,e){return!!((e==="v4"||!e)&&Rt.test(t)||(e==="v6"||!e)&&jt.test(t))}class I extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:h.string,received:r.parsedType}),_}const s=new C;let a;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(a=this._getOrReturnCtx(e,a),l(a,{code:d.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),s.dirty());else if(r.kind==="max")e.data.length>r.value&&(a=this._getOrReturnCtx(e,a),l(a,{code:d.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),s.dirty());else if(r.kind==="length"){const i=e.data.length>r.value,o=e.data.length<r.value;(i||o)&&(a=this._getOrReturnCtx(e,a),i?l(a,{code:d.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):o&&l(a,{code:d.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),s.dirty())}else if(r.kind==="email")Ot.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"email",code:d.invalid_string,message:r.message}),s.dirty());else if(r.kind==="emoji")Ae||(Ae=new RegExp(At,"u")),Ae.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"emoji",code:d.invalid_string,message:r.message}),s.dirty());else if(r.kind==="uuid")St.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"uuid",code:d.invalid_string,message:r.message}),s.dirty());else if(r.kind==="nanoid")Tt.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"nanoid",code:d.invalid_string,message:r.message}),s.dirty());else if(r.kind==="cuid")xt.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"cuid",code:d.invalid_string,message:r.message}),s.dirty());else if(r.kind==="cuid2")kt.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"cuid2",code:d.invalid_string,message:r.message}),s.dirty());else if(r.kind==="ulid")wt.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"ulid",code:d.invalid_string,message:r.message}),s.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),l(a,{validation:"url",code:d.invalid_string,message:r.message}),s.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"regex",code:d.invalid_string,message:r.message}),s.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(a=this._getOrReturnCtx(e,a),l(a,{code:d.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),s.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(a=this._getOrReturnCtx(e,a),l(a,{code:d.invalid_string,validation:{startsWith:r.value},message:r.message}),s.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(a=this._getOrReturnCtx(e,a),l(a,{code:d.invalid_string,validation:{endsWith:r.value},message:r.message}),s.dirty()):r.kind==="datetime"?st(r).test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{code:d.invalid_string,validation:"datetime",message:r.message}),s.dirty()):r.kind==="date"?Dt.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{code:d.invalid_string,validation:"date",message:r.message}),s.dirty()):r.kind==="time"?Lt(r).test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{code:d.invalid_string,validation:"time",message:r.message}),s.dirty()):r.kind==="duration"?Et.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"duration",code:d.invalid_string,message:r.message}),s.dirty()):r.kind==="ip"?Pt(e.data,r.version)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"ip",code:d.invalid_string,message:r.message}),s.dirty()):r.kind==="jwt"?Mt(e.data,r.alg)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"jwt",code:d.invalid_string,message:r.message}),s.dirty()):r.kind==="cidr"?Vt(e.data,r.version)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"cidr",code:d.invalid_string,message:r.message}),s.dirty()):r.kind==="base64"?It.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"base64",code:d.invalid_string,message:r.message}),s.dirty()):r.kind==="base64url"?Zt.test(e.data)||(a=this._getOrReturnCtx(e,a),l(a,{validation:"base64url",code:d.invalid_string,message:r.message}),s.dirty()):b.assertNever(r);return{status:s.value,value:e.data}}_regex(e,n,s){return this.refinement(a=>e.test(a),{validation:n,code:d.invalid_string,...f.errToObj(s)})}_addCheck(e){return new I({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...f.errToObj(e)})}url(e){return this._addCheck({kind:"url",...f.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...f.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...f.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...f.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...f.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...f.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...f.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...f.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...f.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...f.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...f.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...f.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...f.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...f.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...f.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...f.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...f.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...f.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...f.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...f.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...f.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...f.errToObj(n)})}nonempty(e){return this.min(1,f.errToObj(e))}trim(){return new I({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new I({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new I({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}I.create=t=>new I({checks:[],typeName:m.ZodString,coerce:t?.coerce??!1,...g(t)});function Bt(t,e){const n=(t.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,a=n>s?n:s,r=Number.parseInt(t.toFixed(a).replace(".","")),i=Number.parseInt(e.toFixed(a).replace(".",""));return r%i/10**a}class Y extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==h.number){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:h.number,received:r.parsedType}),_}let s;const a=new C;for(const r of this._def.checks)r.kind==="int"?b.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="multipleOf"?Bt(e.data,r.value)!==0&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_finite,message:r.message}),a.dirty()):b.assertNever(r);return{status:a.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,f.toString(n))}gt(e,n){return this.setLimit("min",e,!1,f.toString(n))}lte(e,n){return this.setLimit("max",e,!0,f.toString(n))}lt(e,n){return this.setLimit("max",e,!1,f.toString(n))}setLimit(e,n,s,a){return new Y({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:s,message:f.toString(a)}]})}_addCheck(e){return new Y({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:f.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:f.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:f.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:f.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:f.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:f.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:f.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:f.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:f.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(n===null||s.value>n)&&(n=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(n)&&Number.isFinite(e)}}Y.create=t=>new Y({checks:[],typeName:m.ZodNumber,coerce:t?.coerce||!1,...g(t)});class ne extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==h.bigint)return this._getInvalidInput(e);let s;const a=new C;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):b.assertNever(r);return{status:a.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return l(n,{code:d.invalid_type,expected:h.bigint,received:n.parsedType}),_}gte(e,n){return this.setLimit("min",e,!0,f.toString(n))}gt(e,n){return this.setLimit("min",e,!1,f.toString(n))}lte(e,n){return this.setLimit("max",e,!0,f.toString(n))}lt(e,n){return this.setLimit("max",e,!1,f.toString(n))}setLimit(e,n,s,a){return new ne({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:s,message:f.toString(a)}]})}_addCheck(e){return new ne({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:f.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:f.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:f.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:f.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:f.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ne.create=t=>new ne({checks:[],typeName:m.ZodBigInt,coerce:t?.coerce??!1,...g(t)});class me extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.boolean,received:s.parsedType}),_}return N(e.data)}}me.create=t=>new me({typeName:m.ZodBoolean,coerce:t?.coerce||!1,...g(t)});class ce extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:h.date,received:r.parsedType}),_}if(Number.isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_date}),_}const s=new C;let a;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(a=this._getOrReturnCtx(e,a),l(a,{code:d.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),s.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(a=this._getOrReturnCtx(e,a),l(a,{code:d.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),s.dirty()):b.assertNever(r);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ce({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:f.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:f.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}ce.create=t=>new ce({checks:[],coerce:t?.coerce||!1,typeName:m.ZodDate,...g(t)});class Ie extends v{_parse(e){if(this._getType(e)!==h.symbol){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.symbol,received:s.parsedType}),_}return N(e.data)}}Ie.create=t=>new Ie({typeName:m.ZodSymbol,...g(t)});class Ze extends v{_parse(e){if(this._getType(e)!==h.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.undefined,received:s.parsedType}),_}return N(e.data)}}Ze.create=t=>new Ze({typeName:m.ZodUndefined,...g(t)});class De extends v{_parse(e){if(this._getType(e)!==h.null){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.null,received:s.parsedType}),_}return N(e.data)}}De.create=t=>new De({typeName:m.ZodNull,...g(t)});class Le extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return N(e.data)}}Le.create=t=>new Le({typeName:m.ZodAny,...g(t)});class Pe extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return N(e.data)}}Pe.create=t=>new Pe({typeName:m.ZodUnknown,...g(t)});class B extends v{_parse(e){const n=this._getOrReturnCtx(e);return l(n,{code:d.invalid_type,expected:h.never,received:n.parsedType}),_}}B.create=t=>new B({typeName:m.ZodNever,...g(t)});class Me extends v{_parse(e){if(this._getType(e)!==h.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.void,received:s.parsedType}),_}return N(e.data)}}Me.create=t=>new Me({typeName:m.ZodVoid,...g(t)});class R extends v{_parse(e){const{ctx:n,status:s}=this._processInputParams(e),a=this._def;if(n.parsedType!==h.array)return l(n,{code:d.invalid_type,expected:h.array,received:n.parsedType}),_;if(a.exactLength!==null){const i=n.data.length>a.exactLength.value,o=n.data.length<a.exactLength.value;(i||o)&&(l(n,{code:i?d.too_big:d.too_small,minimum:o?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),s.dirty())}if(a.minLength!==null&&n.data.length<a.minLength.value&&(l(n,{code:d.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),s.dirty()),a.maxLength!==null&&n.data.length>a.maxLength.value&&(l(n,{code:d.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),s.dirty()),n.common.async)return Promise.all([...n.data].map((i,o)=>a.type._parseAsync(new D(n,i,n.path,o)))).then(i=>C.mergeArray(s,i));const r=[...n.data].map((i,o)=>a.type._parseSync(new D(n,i,n.path,o)));return C.mergeArray(s,r)}get element(){return this._def.type}min(e,n){return new R({...this._def,minLength:{value:e,message:f.toString(n)}})}max(e,n){return new R({...this._def,maxLength:{value:e,message:f.toString(n)}})}length(e,n){return new R({...this._def,exactLength:{value:e,message:f.toString(n)}})}nonempty(e){return this.min(1,e)}}R.create=(t,e)=>new R({type:t,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,...g(e)});function ee(t){if(t instanceof w){const e={};for(const n in t.shape){const s=t.shape[n];e[n]=V.create(ee(s))}return new w({...t._def,shape:()=>e})}else return t instanceof R?new R({...t._def,type:ee(t.element)}):t instanceof V?V.create(ee(t.unwrap())):t instanceof G?G.create(ee(t.unwrap())):t instanceof F?F.create(t.items.map(e=>ee(e))):t}class w extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=b.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==h.object){const u=this._getOrReturnCtx(e);return l(u,{code:d.invalid_type,expected:h.object,received:u.parsedType}),_}const{status:s,ctx:a}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof B&&this._def.unknownKeys==="strip"))for(const u in a.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const p=r[u],k=a.data[u];c.push({key:{status:"valid",value:u},value:p._parse(new D(a,k,a.path,u)),alwaysSet:u in a.data})}if(this._def.catchall instanceof B){const u=this._def.unknownKeys;if(u==="passthrough")for(const p of o)c.push({key:{status:"valid",value:p},value:{status:"valid",value:a.data[p]}});else if(u==="strict")o.length>0&&(l(a,{code:d.unrecognized_keys,keys:o}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const p of o){const k=a.data[p];c.push({key:{status:"valid",value:p},value:u._parse(new D(a,k,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of c){const k=await p.key,T=await p.value;u.push({key:k,value:T,alwaysSet:p.alwaysSet})}return u}).then(u=>C.mergeObjectSync(s,u)):C.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return f.errToObj,new w({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,s)=>{const a=this._def.errorMap?.(n,s).message??s.defaultError;return n.code==="unrecognized_keys"?{message:f.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new w({...this._def,unknownKeys:"strip"})}passthrough(){return new w({...this._def,unknownKeys:"passthrough"})}extend(e){return new w({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new w({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:m.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new w({...this._def,catchall:e})}pick(e){const n={};for(const s of b.objectKeys(e))e[s]&&this.shape[s]&&(n[s]=this.shape[s]);return new w({...this._def,shape:()=>n})}omit(e){const n={};for(const s of b.objectKeys(this.shape))e[s]||(n[s]=this.shape[s]);return new w({...this._def,shape:()=>n})}deepPartial(){return ee(this)}partial(e){const n={};for(const s of b.objectKeys(this.shape)){const a=this.shape[s];e&&!e[s]?n[s]=a:n[s]=a.optional()}return new w({...this._def,shape:()=>n})}required(e){const n={};for(const s of b.objectKeys(this.shape))if(e&&!e[s])n[s]=this.shape[s];else{let r=this.shape[s];for(;r instanceof V;)r=r._def.innerType;n[s]=r}return new w({...this._def,shape:()=>n})}keyof(){return at(b.objectKeys(this.shape))}}w.create=(t,e)=>new w({shape:()=>t,unknownKeys:"strip",catchall:B.create(),typeName:m.ZodObject,...g(e)});w.strictCreate=(t,e)=>new w({shape:()=>t,unknownKeys:"strict",catchall:B.create(),typeName:m.ZodObject,...g(e)});w.lazycreate=(t,e)=>new w({shape:t,unknownKeys:"strip",catchall:B.create(),typeName:m.ZodObject,...g(e)});class de extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s=this._def.options;function a(r){for(const o of r)if(o.result.status==="valid")return o.result;for(const o of r)if(o.result.status==="dirty")return n.common.issues.push(...o.ctx.common.issues),o.result;const i=r.map(o=>new Z(o.ctx.common.issues));return l(n,{code:d.invalid_union,unionErrors:i}),_}if(n.common.async)return Promise.all(s.map(async r=>{const i={...n,common:{...n.common,issues:[]},parent:null};return{result:await r._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(a);{let r;const i=[];for(const c of s){const u={...n,common:{...n.common,issues:[]},parent:null},p=c._parseSync({data:n.data,path:n.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!r&&(r={result:p,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(r)return n.common.issues.push(...r.ctx.common.issues),r.result;const o=i.map(c=>new Z(c));return l(n,{code:d.invalid_union,unionErrors:o}),_}}get options(){return this._def.options}}de.create=(t,e)=>new de({options:t,typeName:m.ZodUnion,...g(e)});function Ve(t,e){const n=P(t),s=P(e);if(t===e)return{valid:!0,data:t};if(n===h.object&&s===h.object){const a=b.objectKeys(e),r=b.objectKeys(t).filter(o=>a.indexOf(o)!==-1),i={...t,...e};for(const o of r){const c=Ve(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(n===h.array&&s===h.array){if(t.length!==e.length)return{valid:!1};const a=[];for(let r=0;r<t.length;r++){const i=t[r],o=e[r],c=Ve(i,o);if(!c.valid)return{valid:!1};a.push(c.data)}return{valid:!0,data:a}}else return n===h.date&&s===h.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class ue extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e),a=(r,i)=>{if($e(r)||$e(i))return _;const o=Ve(r.value,i.value);return o.valid?((je(r)||je(i))&&n.dirty(),{status:n.value,value:o.data}):(l(s,{code:d.invalid_intersection_types}),_)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([r,i])=>a(r,i)):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ue.create=(t,e,n)=>new ue({left:t,right:e,typeName:m.ZodIntersection,...g(n)});class F extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.array)return l(s,{code:d.invalid_type,expected:h.array,received:s.parsedType}),_;if(s.data.length<this._def.items.length)return l(s,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_;!this._def.rest&&s.data.length>this._def.items.length&&(l(s,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const r=[...s.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new D(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(r).then(i=>C.mergeArray(n,i)):C.mergeArray(n,r)}get items(){return this._def.items}rest(e){return new F({...this._def,rest:e})}}F.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new F({items:t,typeName:m.ZodTuple,rest:null,...g(e)})};class le extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.object)return l(s,{code:d.invalid_type,expected:h.object,received:s.parsedType}),_;const a=[],r=this._def.keyType,i=this._def.valueType;for(const o in s.data)a.push({key:r._parse(new D(s,o,s.path,o)),value:i._parse(new D(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?C.mergeObjectAsync(n,a):C.mergeObjectSync(n,a)}get element(){return this._def.valueType}static create(e,n,s){return n instanceof v?new le({keyType:e,valueType:n,typeName:m.ZodRecord,...g(s)}):new le({keyType:I.create(),valueType:e,typeName:m.ZodRecord,...g(n)})}}class Be extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.map)return l(s,{code:d.invalid_type,expected:h.map,received:s.parsedType}),_;const a=this._def.keyType,r=this._def.valueType,i=[...s.data.entries()].map(([o,c],u)=>({key:a._parse(new D(s,o,s.path,[u,"key"])),value:r._parse(new D(s,c,s.path,[u,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const u=await c.key,p=await c.value;if(u.status==="aborted"||p.status==="aborted")return _;(u.status==="dirty"||p.status==="dirty")&&n.dirty(),o.set(u.value,p.value)}return{status:n.value,value:o}})}else{const o=new Map;for(const c of i){const u=c.key,p=c.value;if(u.status==="aborted"||p.status==="aborted")return _;(u.status==="dirty"||p.status==="dirty")&&n.dirty(),o.set(u.value,p.value)}return{status:n.value,value:o}}}}Be.create=(t,e,n)=>new Be({valueType:e,keyType:t,typeName:m.ZodMap,...g(n)});class se extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.set)return l(s,{code:d.invalid_type,expected:h.set,received:s.parsedType}),_;const a=this._def;a.minSize!==null&&s.data.size<a.minSize.value&&(l(s,{code:d.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),a.maxSize!==null&&s.data.size>a.maxSize.value&&(l(s,{code:d.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());const r=this._def.valueType;function i(c){const u=new Set;for(const p of c){if(p.status==="aborted")return _;p.status==="dirty"&&n.dirty(),u.add(p.value)}return{status:n.value,value:u}}const o=[...s.data.values()].map((c,u)=>r._parse(new D(s,c,s.path,u)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,n){return new se({...this._def,minSize:{value:e,message:f.toString(n)}})}max(e,n){return new se({...this._def,maxSize:{value:e,message:f.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}se.create=(t,e)=>new se({valueType:t,minSize:null,maxSize:null,typeName:m.ZodSet,...g(e)});class ze extends v{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}ze.create=(t,e)=>new ze({getter:t,typeName:m.ZodLazy,...g(e)});class Fe extends v{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return l(n,{received:n.data,code:d.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:e.data}}get value(){return this._def.value}}Fe.create=(t,e)=>new Fe({value:t,typeName:m.ZodLiteral,...g(e)});function at(t,e){return new K({values:t,typeName:m.ZodEnum,...g(e)})}class K extends v{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),s=this._def.values;return l(n,{expected:b.joinValues(s),received:n.parsedType,code:d.invalid_type}),_}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),s=this._def.values;return l(n,{received:n.data,code:d.invalid_enum_value,options:s}),_}return N(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return K.create(e,{...this._def,...n})}exclude(e,n=this._def){return K.create(this.options.filter(s=>!e.includes(s)),{...this._def,...n})}}K.create=at;class Ue extends v{_parse(e){const n=b.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==h.string&&s.parsedType!==h.number){const a=b.objectValues(n);return l(s,{expected:b.joinValues(a),received:s.parsedType,code:d.invalid_type}),_}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=b.objectValues(n);return l(s,{received:s.data,code:d.invalid_enum_value,options:a}),_}return N(e.data)}get enum(){return this._def.values}}Ue.create=(t,e)=>new Ue({values:t,typeName:m.ZodNativeEnum,...g(e)});class he extends v{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==h.promise&&n.common.async===!1)return l(n,{code:d.invalid_type,expected:h.promise,received:n.parsedType}),_;const s=n.parsedType===h.promise?n.data:Promise.resolve(n.data);return N(s.then(a=>this._def.type.parseAsync(a,{path:n.path,errorMap:n.common.contextualErrorMap})))}}he.create=(t,e)=>new he({type:t,typeName:m.ZodPromise,...g(e)});class U extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===m.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:s}=this._processInputParams(e),a=this._def.effect||null,r={addIssue:i=>{l(s,i),i.fatal?n.abort():n.dirty()},get path(){return s.path}};if(r.addIssue=r.addIssue.bind(r),a.type==="preprocess"){const i=a.transform(s.data,r);if(s.common.async)return Promise.resolve(i).then(async o=>{if(n.value==="aborted")return _;const c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?_:c.status==="dirty"||n.value==="dirty"?te(c.value):c});{if(n.value==="aborted")return _;const o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?_:o.status==="dirty"||n.value==="dirty"?te(o.value):o}}if(a.type==="refinement"){const i=o=>{const c=a.refinement(o,r);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?_:(o.status==="dirty"&&n.dirty(),i(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?_:(o.status==="dirty"&&n.dirty(),i(o.value).then(()=>({status:n.value,value:o.value}))))}if(a.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!J(i))return _;const o=a.transform(i.value,r);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>J(i)?Promise.resolve(a.transform(i.value,r)).then(o=>({status:n.value,value:o})):_);b.assertNever(a)}}U.create=(t,e,n)=>new U({schema:t,typeName:m.ZodEffects,effect:e,...g(n)});U.createWithPreprocess=(t,e,n)=>new U({schema:e,effect:{type:"preprocess",transform:t},typeName:m.ZodEffects,...g(n)});class V extends v{_parse(e){return this._getType(e)===h.undefined?N(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}V.create=(t,e)=>new V({innerType:t,typeName:m.ZodOptional,...g(e)});class G extends v{_parse(e){return this._getType(e)===h.null?N(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}G.create=(t,e)=>new G({innerType:t,typeName:m.ZodNullable,...g(e)});class _e extends v{_parse(e){const{ctx:n}=this._processInputParams(e);let s=n.data;return n.parsedType===h.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}_e.create=(t,e)=>new _e({innerType:t,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...g(e)});class ye extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s={...n,common:{...n.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return oe(a)?a.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Z(s.common.issues)},input:s.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Z(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}ye.create=(t,e)=>new ye({innerType:t,typeName:m.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...g(e)});class qe extends v{_parse(e){if(this._getType(e)!==h.nan){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:h.nan,received:s.parsedType}),_}return{status:"valid",value:e.data}}}qe.create=t=>new qe({typeName:m.ZodNaN,...g(t)});class rt extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s=n.data;return this._def.type._parse({data:s,path:n.path,parent:n})}unwrap(){return this._def.type}}class xe extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?_:r.status==="dirty"?(n.dirty(),te(r.value)):this._def.out._parseAsync({data:r.value,path:s.path,parent:s})})();{const a=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?_:a.status==="dirty"?(n.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:s.path,parent:s})}}static create(e,n){return new xe({in:e,out:n,typeName:m.ZodPipeline})}}class ge extends v{_parse(e){const n=this._def.innerType._parse(e),s=a=>(J(a)&&(a.value=Object.freeze(a.value)),a);return oe(n)?n.then(a=>s(a)):s(n)}unwrap(){return this._def.innerType}}ge.create=(t,e)=>new ge({innerType:t,typeName:m.ZodReadonly,...g(e)});var m;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(m||(m={}));const y=I.create,it=Y.create,ke=me.create;B.create;const A=R.create,$=w.create;de.create;ue.create;F.create;const ot=le.create;K.create;he.create;V.create;G.create;const zt=Object.freeze(Object.defineProperty({__proto__:null,DIRTY:te,INVALID:_,OK:N,ParseStatus:C,Schema:v,ZodAny:Le,ZodArray:R,ZodBigInt:ne,ZodBoolean:me,ZodBranded:rt,ZodCatch:ye,ZodDate:ce,ZodDefault:_e,ZodEffects:U,ZodEnum:K,ZodError:Z,get ZodFirstPartyTypeKind(){return m},ZodIntersection:ue,ZodIssueCode:d,ZodLazy:ze,ZodLiteral:Fe,ZodMap:Be,ZodNaN:qe,ZodNativeEnum:Ue,ZodNever:B,ZodNull:De,ZodNullable:G,ZodNumber:Y,ZodObject:w,ZodOptional:V,ZodParsedType:h,ZodPipeline:xe,ZodPromise:he,ZodReadonly:ge,ZodRecord:le,ZodSchema:v,ZodSet:se,ZodString:I,ZodSymbol:Ie,ZodTransformer:U,ZodTuple:F,ZodType:v,ZodUndefined:Ze,ZodUnion:de,ZodUnknown:Pe,ZodVoid:Me,addIssueToContext:l,array:A,boolean:ke,datetimeRegex:st,defaultErrorMap:pe,getErrorMap:Xe,getParsedType:P,isAborted:$e,isAsync:oe,isDirty:je,isValid:J,makeIssue:et,number:it,object:$,get objectUtil(){return Re},record:ot,string:y,get util(){return b}},Symbol.toStringTag,{value:"Module"}));vt(zt);const Ft=(t,e)=>e.skipDedupe||e.method!=="GET",Ut=(t,e)=>e.method+"@"+t,qt=t=>t.clone(),Wt=({skip:t=Ft,key:e=Ut,resolver:n=qt}={})=>{const s=new Map;return a=>(r,i)=>{if(t(r,i))return a(r,i);const o=e(r,i);if(!s.has(o))s.set(o,[]);else return new Promise((c,u)=>{s.get(o).push([c,u])});try{return a(r,i).then(c=>(s.get(o).forEach(([u])=>u(n(c))),s.delete(o),c)).catch(c=>{throw s.get(o).forEach(([,u])=>u(c)),s.delete(o),c})}catch(c){return s.delete(o),Promise.reject(c)}}},Qt=(t,e)=>t*e,Ht=t=>t&&(t.ok||t.status>=400&&t.status<500),Jt=({delayTimer:t=500,delayRamp:e=Qt,maxAttempts:n=10,until:s=Ht,onRetry:a=null,retryOnNetworkError:r=!1,resolveWithLatestResponse:i=!1,skip:o}={})=>c=>(u,p)=>{let k=0;if(o&&o(u,p))return c(u,p);const T=(S,E)=>Promise.resolve(s(S,E)).then(q=>q?S&&i?S:E?Promise.reject(E):S:(k++,!n||k<=n?new Promise(x=>{const L=e(t,k);setTimeout(()=>{typeof a=="function"?Promise.resolve(a({response:S,error:E,url:u,attempt:k,options:p})).then((O={})=>{var j,W;x(c((j=O&&O.url)!==null&&j!==void 0?j:u,(W=O&&O.options)!==null&&W!==void 0?W:p))}):x(c(u,p))},L)}).then(T).catch(x=>{if(!r)throw x;return T(null,x)}):S&&i?S:Promise.reject(E||new Error("Number of attempts exceeded."))));return c(u,p).then(T).catch(S=>{if(!r)throw S;return T(null,S)})},ve=$({code:it(),message:y()}),Yt=$({message:y()}),Kt=$({emails:A(y()).optional(),http_body:y().optional(),http_url:y().optional(),txt_name:y().optional(),txt_value:y().optional()}),Gt=$({ciphers:A(y()).optional(),early_hints:y().optional(),http2:y().optional(),min_tls_version:y().optional(),tls_1_3:y().optional()}),Xt=$({id:y(),bundle_method:y().optional(),certificate_authority:y(),custom_certificate:y().optional(),custom_csr_id:y().optional(),custom_key:y().optional(),expires_on:y().optional(),hosts:A(y()).optional(),issuer:y().optional(),method:y(),serial_number:y().optional(),settings:Gt.optional(),signature:y().optional(),type:y(),uploaded_on:y().optional(),validation_errors:A(Yt).optional(),validation_records:A(Kt).optional(),wildcard:ke()}),en=$({name:y(),type:y(),value:y()}),tn=$({http_body:y().optional(),http_url:y().optional()}),ct=$({id:y(),ssl:Xt,hostname:y(),custom_metadata:ot(y()).optional(),custom_origin_server:y().optional(),custom_origin_sni:y().optional(),ownership_verification:en.optional(),ownership_verification_http:tn.optional(),status:y(),verification_errors:A(y()).optional(),created_at:y()}),ie=$({errors:A(ve),messages:A(ve),success:ke(),result:ct});$({errors:A(ve),messages:A(ve),success:ke(),result:A(ct)});function H(t){return _t(`https://api.cloudflare.com/client/v4/zones/${t.zoneId}`).headers({"X-Auth-Email":t.authEmail,"X-Auth-Key":t.authKey,"Content-Type":"application/json"}).middlewares([Jt(),Wt()])}function Je(t){const e={},n={};if(!t)return{sslOverrides:e,rest:n};for(const[s,a]of Object.entries(t))s.startsWith("ssl.")?e[s.slice(4)]=a:n[s]=a;return{sslOverrides:e,rest:n}}function Ne(t){const e=[];if(t.ssl.validation_records)for(const s of t.ssl.validation_records)s.txt_name&&s.txt_value&&e.push({name:"txt",record:s.txt_value,domain:s.txt_name});if(t.ownership_verification&&e.push({name:"txt",record:t.ownership_verification.value,domain:t.ownership_verification.name}),t.ownership_verification_http?.http_body&&t.ownership_verification_http?.http_url&&e.push({name:"http",http_body:t.ownership_verification_http.http_body,http_url:t.ownership_verification_http.http_url}),t.ssl.validation_records)for(const s of t.ssl.validation_records)s.http_body&&s.http_url&&e.push({name:"http",http_body:s.http_body,http_url:s.http_url});const n={...t.domain_metadata||{},"ssl.method":t.ssl.method,"ssl.type":t.ssl.type,"ssl.certificate_authority":t.ssl.certificate_authority};return{custom_domain_id:t.id,domain:t.hostname,primary:t.primary,status:t.status==="active"?"ready":"pending",type:"auth0_managed_certs",verification:{methods:A(mt.verificationMethodsSchema).parse(e)},domain_metadata:n}}function nn(t){return{create:async(e,n)=>{const{sslOverrides:s,rest:a}=Je(n.domain_metadata),{result:r,errors:i,success:o}=ie.parse(await H(t).post({hostname:n.domain,ssl:{method:"txt",type:"dv",...s},custom_metadata:t.enterprise?{tenant_id:e}:void 0},"/custom_hostnames").json());if(!o)throw new Error(JSON.stringify(i));const c=Ne({...r,primary:!1,domain_metadata:a});return await t.customDomainAdapter.create(e,{custom_domain_id:c.custom_domain_id,domain:c.domain,type:c.type,domain_metadata:n.domain_metadata}),c},get:async(e,n)=>{const s=await t.customDomainAdapter.get(e,n);if(!s)throw new X(404);const a=await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(),{result:r,errors:i,success:o}=ie.parse(a);if(!o)throw new X(503,{message:JSON.stringify(i)});if(t.enterprise&&r.custom_metadata?.tenant_id!==e)throw new X(404);return Ne({...s,...r})},getByDomain:async e=>t.customDomainAdapter.getByDomain(e),list:async e=>{const n=await t.customDomainAdapter.list(e);return(await Promise.all(n.map(async a=>{try{const r=await H(t).get(`/custom_hostnames/${encodeURIComponent(a.custom_domain_id)}`).json(),{result:i,success:o}=ie.parse(r);return!o||t.enterprise&&i.custom_metadata?.tenant_id!==e?null:Ne({...a,...i})}catch{return null}}))).filter(a=>a!==null)},remove:async(e,n)=>{if(t.enterprise){const{result:a,success:r}=ie.parse(await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json());if(!r||a.custom_metadata?.tenant_id!==e)throw new X(404)}const s=await H(t).delete(`/custom_hostnames/${encodeURIComponent(n)}`).res();return s.ok&&await t.customDomainAdapter.remove(e,n),s.ok},update:async(e,n,s)=>{const{sslOverrides:a}=Je(s.domain_metadata),r={};if(Object.keys(a).length>0){const i=await H(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(),{result:o,success:c}=ie.parse(i);if(!c)throw new X(503,{message:"Failed to fetch current custom hostname state"});r.ssl={method:o.ssl.method,type:o.ssl.type,certificate_authority:o.ssl.certificate_authority,...a}}if(Object.keys(r).length>0){const i=await H(t).patch(r,`/custom_hostnames/${encodeURIComponent(n)}`).res();if(!i.ok)throw new X(503,{message:await i.text()})}return t.customDomainAdapter.update(e,n,s)}}}class sn{constructor(e){this.config=e}cache=null;async getCache(){if(this.cache)return this.cache;if(typeof caches>"u")throw new Error("caches API is not available - CloudflareCache should only be used in Cloudflare Workers");return this.config.cacheName?this.cache=await caches.open(this.config.cacheName):this.cache=caches.default,this.cache}getKey(e){return this.config.keyPrefix?`${this.config.keyPrefix}:${e}`:e}createRequest(e){return new Request(`https://cache.internal/${this.getKey(e)}`)}async get(e){try{const n=await this.getCache(),s=this.createRequest(e),a=await n.match(s);if(!a)return null;const r=await a.json();return r.expiresAt&&new Date(r.expiresAt)<new Date?(await this.delete(e),null):r.value}catch(n){return console.error(`CloudflareCache: get error for key ${e}:`,n),null}}async set(e,n,s){try{const a=await this.getCache(),r=s??this.config.defaultTtlSeconds,i=r!==void 0,o=i?Math.max(0,r):0,c={value:n,expiresAt:i?new Date(Date.now()+(o>0?o*1e3:-1)).toISOString():void 0,cachedAt:new Date().toISOString()},u=this.createRequest(e),p={"Content-Type":"application/json"};i&&o>0&&(p["Cache-Control"]=`max-age=${o}`);const k=new Response(JSON.stringify(c),{headers:p});await a.put(u,k)}catch(a){console.error(`CloudflareCache: set error for key ${e}:`,a)}}async delete(e){try{const n=await this.getCache(),s=this.createRequest(e);return await n.delete(s)}catch(n){return console.error(`CloudflareCache: delete error for key ${e}:`,n),!1}}async deleteByPrefix(e){return console.warn("CloudflareCache.deleteByPrefix() is not implemented - Cloudflare Cache API does not support prefix-based deletion"),0}async clear(){console.warn("CloudflareCache.clear() is not implemented - Cloudflare Cache API does not support clearing all entries")}}function an(t={}){const e={defaultTtlSeconds:300,keyPrefix:"authhero",...t};return new sn(e)}const rn="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let dt=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=rn[n[t]&63];return e};async function We(t,e){const n=t.timeout||3e4,s=new AbortController,a=setTimeout(()=>s.abort(),n);try{const r=`https://api.sql.cloudflarestorage.com/api/v1/accounts/${t.accountId}/r2-sql/query/${t.warehouseName}`,i=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.authToken}`},body:JSON.stringify({query:e}),signal:s.signal});if(!i.ok)throw new Error(`R2 SQL query failed: ${i.status} ${i.statusText}`);const o=await i.json();if(!o.success&&o.errors)throw new Error(`R2 SQL error: ${o.errors.join(", ")}`);return o.data||o.result?.data||[]}finally{clearTimeout(a)}}function be(t){return`'${t.replace(/'/g,"''")}'`}function z(t){return`"${t.replace(/"/g,'""')}"`}function ut(t){const e=n=>{if(!n)return"";try{return JSON.parse(n)}catch{return n}};return{type:t.type,date:t.date,description:t.description,ip:t.ip,user_agent:t.user_agent,details:e(t.details),isMobile:!!t.isMobile,user_id:t.user_id,user_name:t.user_name,connection:t.connection,connection_id:t.connection_id,client_id:t.client_id,client_name:t.client_name,audience:t.audience,scope:t.scope,strategy:t.strategy,strategy_type:t.strategy_type,hostname:t.hostname,auth0_client:e(t.auth0_client),log_id:t.id,location_info:t.country_code||t.city_name||t.latitude||t.longitude||t.time_zone||t.continent_code?{country_code:t.country_code||"",city_name:t.city_name||"",latitude:t.latitude||"",longitude:t.longitude||"",time_zone:t.time_zone||"",continent_code:t.continent_code||""}:void 0}}function on(t){return async(e,n)=>{const s=n.log_id||dt(),a={...n,log_id:s};return await cn(t,e,a),a}}async function cn(t,e,n){const s=r=>r?JSON.stringify(r):void 0,a={id:n.log_id,tenant_id:e,type:n.type,date:n.date,description:n.description?.substring(0,256),ip:n.ip,user_agent:n.user_agent,details:s(n.details)?.substring(0,8192),isMobile:n.isMobile?1:0,user_id:n.user_id,user_name:n.user_name,connection:n.connection,connection_id:n.connection_id,client_id:n.client_id,client_name:n.client_name,audience:n.audience,scope:n.scope,strategy:n.strategy,strategy_type:n.strategy_type,hostname:n.hostname,auth0_client:s(n.auth0_client),log_id:n.log_id,country_code:n.location_info?.country_code,city_name:n.location_info?.city_name,latitude:n.location_info?.latitude,longitude:n.location_info?.longitude,time_zone:n.location_info?.time_zone,continent_code:n.location_info?.continent_code};try{if(t.pipelineBinding)await t.pipelineBinding.send([a]);else if(t.pipelineEndpoint){const r=t.timeout||3e4,i=new AbortController,o=setTimeout(()=>i.abort(),r);try{const c=await fetch(t.pipelineEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([a]),signal:i.signal});if(!c.ok)throw new Error(`Pipeline ingestion failed: ${c.status} ${c.statusText}`)}finally{clearTimeout(o)}}else throw new Error("Either pipelineEndpoint or pipelineBinding must be configured")}catch(r){throw console.error("Failed to send log to Pipeline:",r),r}}function dn(t){return async(e,n)=>{const s=t.namespace||"default",a=t.tableName||"logs",r=`
2
2
  SELECT * FROM ${z(s)}.${z(a)}
3
3
  WHERE tenant_id = ${be(e)}
4
4
  AND id = ${be(n)}
@@ -11,13 +11,13 @@
11
11
  `,L=(await We(t,q)).map(ut);if(!r)return{logs:L,start:0,limit:0,length:0};const O=`
12
12
  SELECT COUNT(*) as count FROM ${z(c)}.${z(u)}
13
13
  WHERE ${k}
14
- `,W=(await We(t,O))[0]?.count||0;return{logs:L,start:S,limit:a,length:Number(W)}}}function fn(){return{async getDaily(){throw new Error("Stats queries are not supported by R2 SQL logs adapter. Use Analytics Engine or Kysely adapter instead.")},async getActiveUsers(){throw new Error("Stats queries are not supported by R2 SQL logs adapter. Use Analytics Engine or Kysely adapter instead.")}}}function lt(t){const e=!!t.pipelineEndpoint,n=!!t.pipelineBinding;if(!e&&!n)throw new Error('R2 SQL logs adapter requires one of: "pipelineEndpoint" or "pipelineBinding"');if(!t.authToken)throw new Error('R2 SQL logs adapter requires "authToken" configuration');if(!t.warehouseName)throw new Error('R2 SQL logs adapter requires "warehouseName" configuration');return{create:on(t),list:hn(t),get:dn(t)}}async function fe(t,e){const n=t.timeout||3e4,s=new AbortController,a=setTimeout(()=>s.abort(),n);try{const r=`https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`,i=await fetch(r,{method:"POST",headers:{"Content-Type":"text/plain",Authorization:`Bearer ${t.apiToken}`},body:e,signal:s.signal});if(!i.ok){const c=await i.text();throw new Error(`Analytics Engine query failed: ${i.status} ${i.statusText} - ${c}`)}const o=await i.json();if(!o.success&&o.errors&&o.errors.length>0)throw new Error(`Analytics Engine error: ${o.errors.map(c=>c.message).join(", ")}`);return o.data||[]}finally{clearTimeout(a)}}function M(t){return`'${t.replace(/'/g,"''").replace(/\\/g,"\\\\")}'`}function Qe(t){return`"${t.replace(/"/g,'""')}"`}function ht(t){const e=a=>{if(a)try{return JSON.parse(a)}catch{return}},n=t.double2||t.timestamp,s=n?new Date(n).toISOString():"";return{log_id:t.blob1,type:t.blob3,date:s,description:t.blob4,ip:t.blob5,user_agent:t.blob6,user_id:t.blob7,user_name:t.blob8,connection:t.blob9,connection_id:t.blob10,client_id:t.blob11,client_name:t.blob12,audience:t.blob13,scope:t.blob14,strategy:t.blob15,strategy_type:t.blob16,hostname:t.blob17,details:e(t.blob18),auth0_client:e(t.blob19),location_info:e(t.blob20),isMobile:t.double1===1}}function pn(t){return async(e,n)=>{const s=n.log_id||dt(),a={...n,log_id:s};return mn(t,e,a),a}}function mn(t,e,n){if(!t.analyticsEngineBinding){console.error("Analytics Engine binding not configured");return}const s=r=>r==null?"":typeof r=="string"?r:JSON.stringify(r),a=(r,i=1024)=>r.substring(0,i);try{t.analyticsEngineBinding.writeDataPoint({blobs:[a(n.log_id),a(e),a(n.type||""),a(n.description||""),a(n.ip||""),a(n.user_agent||""),a(n.user_id||""),a(n.user_name||""),a(n.connection||""),a(n.connection_id||""),a(n.client_id||""),a(n.client_name||""),a(n.audience||""),a(n.scope||""),a(n.strategy||""),a(n.strategy_type||""),a(n.hostname||""),a(s(n.details)),a(s(n.auth0_client)),a(s(n.location_info))],doubles:[n.isMobile?1:0,new Date(n.date).getTime()],indexes:[e.substring(0,96)]})}catch(r){console.error("Failed to write log to Analytics Engine:",r)}}function yn(t){return async(e,n)=>{const s=t.dataset||"authhero_logs",a=`
14
+ `,W=(await We(t,O))[0]?.count||0;return{logs:L,start:S,limit:a,length:Number(W)}}}function fn(){return{async getDaily(){throw new Error("Stats queries are not supported by R2 SQL logs adapter. Use Analytics Engine or Kysely adapter instead.")},async getActiveUsers(){throw new Error("Stats queries are not supported by R2 SQL logs adapter. Use Analytics Engine or Kysely adapter instead.")}}}function lt(t){const e=!!t.pipelineEndpoint,n=!!t.pipelineBinding;if(!e&&!n)throw new Error('R2 SQL logs adapter requires one of: "pipelineEndpoint" or "pipelineBinding"');if(!t.authToken)throw new Error('R2 SQL logs adapter requires "authToken" configuration');if(!t.warehouseName)throw new Error('R2 SQL logs adapter requires "warehouseName" configuration');return{create:on(t),list:hn(t),get:dn(t)}}async function fe(t,e){const n=t.timeout||3e4,s=new AbortController,a=setTimeout(()=>s.abort(),n);try{const r=`https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`,i=await fetch(r,{method:"POST",headers:{"Content-Type":"text/plain",Authorization:`Bearer ${t.apiToken}`},body:e,signal:s.signal});if(!i.ok){const c=await i.text();throw new Error(`Analytics Engine query failed: ${i.status} ${i.statusText} - ${c}`)}const o=await i.json();if(!o.success&&o.errors&&o.errors.length>0)throw new Error(`Analytics Engine error: ${o.errors.map(c=>c.message).join(", ")}`);return o.data||[]}finally{clearTimeout(a)}}function M(t){return`'${t.replace(/'/g,"''").replace(/\\/g,"\\\\")}'`}function Qe(t){return`"${t.replace(/"/g,'""')}"`}function ht(t){const e=a=>{if(a)try{return JSON.parse(a)}catch{return}},n=t.double2||t.timestamp,s=n?new Date(n).toISOString():"";return{log_id:t.blob1,type:t.blob3,date:s,description:t.blob4,ip:t.blob5,user_agent:t.blob6,user_id:t.blob7,user_name:t.blob8,connection:t.blob9,connection_id:t.blob10,client_id:t.blob11,client_name:t.blob12,audience:t.blob13,scope:t.blob14,strategy:t.blob15,strategy_type:t.blob16,hostname:t.blob17,details:e(t.blob18),auth0_client:e(t.blob19),location_info:e(t.blob20),isMobile:t.double1===1}}function pn(t){return async(e,n)=>{const s=n.log_id||dt(),a={...n,log_id:s};return mn(t,e,a),a}}function mn(t,e,n){if(!t.analyticsEngineBinding){console.error("Analytics Engine binding not configured");return}const s=r=>r==null?"":typeof r=="string"?r:JSON.stringify(r),a=(r,i=1024)=>r.substring(0,i);try{t.analyticsEngineBinding.writeDataPoint({blobs:[a(n.log_id),a(e),a(n.type||""),a(n.description||""),a(n.ip||""),a(n.user_agent||""),a(n.user_id||""),a(n.user_name||""),a(n.connection||""),a(n.connection_id||""),a(n.client_id||""),a(n.client_name||""),a(n.audience||""),a(n.scope||""),a(n.strategy||""),a(n.strategy_type||""),a(n.hostname||""),a(s(n.details)),a(s(n.auth0_client)),a(s(n.location_info))],doubles:[n.isMobile?1:0,new Date(n.date).getTime()],indexes:[e.substring(0,96)]})}catch(r){console.error("Failed to write log to Analytics Engine:",r)}}function _n(t){return async(e,n)=>{const s=t.dataset||"authhero_logs",a=`
15
15
  SELECT *
16
16
  FROM ${Qe(s)}
17
17
  WHERE index1 = ${M(e)}
18
18
  AND blob1 = ${M(n)}
19
19
  LIMIT 1
20
- `,r=await fe(t,a);return r.length===0||!r[0]?null:ht(r[0])}}function _n(t){const e={};return(t.match(/(\w+):(\S+)/g)||[]).forEach(s=>{const a=s.indexOf(":"),r=s.substring(0,a),i=s.substring(a+1);r&&i&&(e[r]=i)}),e}function ft(t){return{log_id:"blob1",tenant_id:"blob2",type:"blob3",description:"blob4",ip:"blob5",user_agent:"blob6",user_id:"blob7",user_name:"blob8",connection:"blob9",connection_id:"blob10",client_id:"blob11",client_name:"blob12",audience:"blob13",scope:"blob14",strategy:"blob15",strategy_type:"blob16",hostname:"blob17"}[t]||null}function gn(t){const e=[];for(const[n,s]of Object.entries(t)){const a=ft(n);a&&s&&e.push(`${a} = ${M(s)}`)}return e}function vn(t){if(t==="date")return"double2";const e=ft(t);return e||"timestamp"}function bn(t){return async(e,n={})=>{const{page:s=0,per_page:a=50,include_totals:r=!1,sort:i,q:o}=n,c=t.dataset||"authhero_logs",u=[`index1 = ${M(e)}`];if(o){const O=_n(o);u.push(...gn(O))}const p=u.join(" AND ");let k="ORDER BY timestamp DESC";if(i&&i.sort_by){const O=vn(i.sort_by),j=i.sort_order==="asc"?"ASC":"DESC";k=`ORDER BY ${O} ${j}`}const T=s*a,S=`LIMIT ${a} OFFSET ${T}`,E=`
20
+ `,r=await fe(t,a);return r.length===0||!r[0]?null:ht(r[0])}}function yn(t){const e={};return(t.match(/(\w+):(\S+)/g)||[]).forEach(s=>{const a=s.indexOf(":"),r=s.substring(0,a),i=s.substring(a+1);r&&i&&(e[r]=i)}),e}function ft(t){return{log_id:"blob1",tenant_id:"blob2",type:"blob3",description:"blob4",ip:"blob5",user_agent:"blob6",user_id:"blob7",user_name:"blob8",connection:"blob9",connection_id:"blob10",client_id:"blob11",client_name:"blob12",audience:"blob13",scope:"blob14",strategy:"blob15",strategy_type:"blob16",hostname:"blob17"}[t]||null}function gn(t){const e=[];for(const[n,s]of Object.entries(t)){const a=ft(n);a&&s&&e.push(`${a} = ${M(s)}`)}return e}function vn(t){if(t==="date")return"double2";const e=ft(t);return e||"timestamp"}function bn(t){return async(e,n={})=>{const{page:s=0,per_page:a=50,include_totals:r=!1,sort:i,q:o}=n,c=t.dataset||"authhero_logs",u=[`index1 = ${M(e)}`];if(o){const O=yn(o);u.push(...gn(O))}const p=u.join(" AND ");let k="ORDER BY timestamp DESC";if(i&&i.sort_by){const O=vn(i.sort_by),j=i.sort_order==="asc"?"ASC":"DESC";k=`ORDER BY ${O} ${j}`}const T=s*a,S=`LIMIT ${a} OFFSET ${T}`,E=`
21
21
  SELECT *
22
22
  FROM ${Qe(c)}
23
23
  WHERE ${p}
@@ -49,4 +49,4 @@
49
49
  AND blob3 IN (${r})
50
50
  AND blob7 IS NOT NULL
51
51
  AND blob7 != ''
52
- `,c=(await fe(t,i))[0];return c&&c.count!==void 0&&Number(c.count)||0}}}function pt(t){return t.analyticsEngineBinding||console.warn("Analytics Engine: No binding configured. Logs will not be written to Analytics Engine."),(!t.accountId||!t.apiToken)&&console.warn("Analytics Engine: accountId and apiToken are required for querying logs via SQL API."),{create:pn(t),list:bn(t),get:yn(t)}}function wn(){return{async getGeoInfo(t){try{const e=t["cf-ipcountry"],n=t["cf-ipcity"],s=t["cf-iplatitude"],a=t["cf-iplongitude"],r=t["cf-timezone"],i=t["cf-ipcontinent"];return e?{country_code:e,city_name:n||"",latitude:s||"",longitude:a||"",time_zone:r||"",continent_code:i||""}:null}catch(e){return console.warn("Failed to get geo info from Cloudflare headers:",e),null}}}}function Sn(t){const e={customDomains:nn(t),cache:an({...t.cacheName&&{cacheName:t.cacheName},...t.defaultTtlSeconds!==void 0&&{defaultTtlSeconds:t.defaultTtlSeconds},...t.keyPrefix&&{keyPrefix:t.keyPrefix}}),geo:wn()};return t.r2SqlLogs?e.logs=lt(t.r2SqlLogs):t.analyticsEngineLogs&&(e.logs=pt(t.analyticsEngineLogs)),e}exports.createAnalyticsEngineLogsAdapter=pt;exports.createAnalyticsEngineStatsAdapter=kn;exports.createR2SQLLogsAdapter=lt;exports.createR2SQLStatsAdapter=fn;exports.default=Sn;
52
+ `,c=(await fe(t,i))[0];return c&&c.count!==void 0&&Number(c.count)||0}}}function pt(t){return t.analyticsEngineBinding||console.warn("Analytics Engine: No binding configured. Logs will not be written to Analytics Engine."),(!t.accountId||!t.apiToken)&&console.warn("Analytics Engine: accountId and apiToken are required for querying logs via SQL API."),{create:pn(t),list:bn(t),get:_n(t)}}function wn(){return{async getGeoInfo(t){try{const e=t["cf-ipcountry"],n=t["cf-ipcity"],s=t["cf-iplatitude"],a=t["cf-iplongitude"],r=t["cf-timezone"],i=t["cf-ipcontinent"];return e?{country_code:e,city_name:n||"",latitude:s||"",longitude:a||"",time_zone:r||"",continent_code:i||""}:null}catch(e){return console.warn("Failed to get geo info from Cloudflare headers:",e),null}}}}function Sn(t){const e={customDomains:nn(t),cache:an({...t.cacheName&&{cacheName:t.cacheName},...t.defaultTtlSeconds!==void 0&&{defaultTtlSeconds:t.defaultTtlSeconds},...t.keyPrefix&&{keyPrefix:t.keyPrefix}}),geo:wn()};return t.r2SqlLogs?e.logs=lt(t.r2SqlLogs):t.analyticsEngineLogs&&(e.logs=pt(t.analyticsEngineLogs)),e}exports.createAnalyticsEngineLogsAdapter=pt;exports.createAnalyticsEngineStatsAdapter=kn;exports.createR2SQLLogsAdapter=lt;exports.createR2SQLStatsAdapter=fn;exports.default=Sn;
@@ -58,31 +58,54 @@ declare const customDomainSchema: z.ZodObject<{
58
58
  ]>;
59
59
  origin_domain_name: z.ZodOptional<z.ZodString>;
60
60
  verification: z.ZodOptional<z.ZodObject<{
61
- methods: z.ZodArray<z.ZodObject<{
62
- name: z.ZodLiteral<"txt">;
63
- record: z.ZodString;
64
- domain: z.ZodString;
65
- }, "strip", z.ZodTypeAny, {
66
- name: "txt";
67
- domain: string;
68
- record: string;
69
- }, {
70
- name: "txt";
71
- domain: string;
72
- record: string;
73
- }>, "many">;
61
+ methods: z.ZodArray<z.ZodDiscriminatedUnion<"name", [
62
+ z.ZodObject<{
63
+ name: z.ZodLiteral<"txt">;
64
+ record: z.ZodString;
65
+ domain: z.ZodString;
66
+ }, "strip", z.ZodTypeAny, {
67
+ name: "txt";
68
+ domain: string;
69
+ record: string;
70
+ }, {
71
+ name: "txt";
72
+ domain: string;
73
+ record: string;
74
+ }>,
75
+ z.ZodObject<{
76
+ name: z.ZodLiteral<"http">;
77
+ http_body: z.ZodString;
78
+ http_url: z.ZodString;
79
+ }, "strip", z.ZodTypeAny, {
80
+ name: "http";
81
+ http_body: string;
82
+ http_url: string;
83
+ }, {
84
+ name: "http";
85
+ http_body: string;
86
+ http_url: string;
87
+ }>
88
+ ]>, "many">;
74
89
  }, "strip", z.ZodTypeAny, {
75
- methods: {
90
+ methods: ({
76
91
  name: "txt";
77
92
  domain: string;
78
93
  record: string;
79
- }[];
94
+ } | {
95
+ name: "http";
96
+ http_body: string;
97
+ http_url: string;
98
+ })[];
80
99
  }, {
81
- methods: {
100
+ methods: ({
82
101
  name: "txt";
83
102
  domain: string;
84
103
  record: string;
85
- }[];
104
+ } | {
105
+ name: "http";
106
+ http_body: string;
107
+ http_url: string;
108
+ })[];
86
109
  }>>;
87
110
  tls_policy: z.ZodOptional<z.ZodString>;
88
111
  domain: z.ZodString;
@@ -108,11 +131,15 @@ declare const customDomainSchema: z.ZodObject<{
108
131
  domain: string;
109
132
  custom_domain_id: string;
110
133
  verification?: {
111
- methods: {
134
+ methods: ({
112
135
  name: "txt";
113
136
  domain: string;
114
137
  record: string;
115
- }[];
138
+ } | {
139
+ name: "http";
140
+ http_body: string;
141
+ http_url: string;
142
+ })[];
116
143
  } | undefined;
117
144
  verification_method?: "txt" | undefined;
118
145
  tls_policy?: string | undefined;
@@ -126,11 +153,15 @@ declare const customDomainSchema: z.ZodObject<{
126
153
  domain: string;
127
154
  custom_domain_id: string;
128
155
  verification?: {
129
- methods: {
156
+ methods: ({
130
157
  name: "txt";
131
158
  domain: string;
132
159
  record: string;
133
- }[];
160
+ } | {
161
+ name: "http";
162
+ http_body: string;
163
+ http_url: string;
164
+ })[];
134
165
  } | undefined;
135
166
  verification_method?: "txt" | undefined;
136
167
  tls_policy?: string | undefined;
@@ -150,31 +181,54 @@ declare const customDomainWithTenantIdSchema: z.ZodObject<{
150
181
  ]>;
151
182
  origin_domain_name: z.ZodOptional<z.ZodString>;
152
183
  verification: z.ZodOptional<z.ZodObject<{
153
- methods: z.ZodArray<z.ZodObject<{
154
- name: z.ZodLiteral<"txt">;
155
- record: z.ZodString;
156
- domain: z.ZodString;
157
- }, "strip", z.ZodTypeAny, {
158
- name: "txt";
159
- domain: string;
160
- record: string;
161
- }, {
162
- name: "txt";
163
- domain: string;
164
- record: string;
165
- }>, "many">;
184
+ methods: z.ZodArray<z.ZodDiscriminatedUnion<"name", [
185
+ z.ZodObject<{
186
+ name: z.ZodLiteral<"txt">;
187
+ record: z.ZodString;
188
+ domain: z.ZodString;
189
+ }, "strip", z.ZodTypeAny, {
190
+ name: "txt";
191
+ domain: string;
192
+ record: string;
193
+ }, {
194
+ name: "txt";
195
+ domain: string;
196
+ record: string;
197
+ }>,
198
+ z.ZodObject<{
199
+ name: z.ZodLiteral<"http">;
200
+ http_body: z.ZodString;
201
+ http_url: z.ZodString;
202
+ }, "strip", z.ZodTypeAny, {
203
+ name: "http";
204
+ http_body: string;
205
+ http_url: string;
206
+ }, {
207
+ name: "http";
208
+ http_body: string;
209
+ http_url: string;
210
+ }>
211
+ ]>, "many">;
166
212
  }, "strip", z.ZodTypeAny, {
167
- methods: {
213
+ methods: ({
168
214
  name: "txt";
169
215
  domain: string;
170
216
  record: string;
171
- }[];
217
+ } | {
218
+ name: "http";
219
+ http_body: string;
220
+ http_url: string;
221
+ })[];
172
222
  }, {
173
- methods: {
223
+ methods: ({
174
224
  name: "txt";
175
225
  domain: string;
176
226
  record: string;
177
- }[];
227
+ } | {
228
+ name: "http";
229
+ http_body: string;
230
+ http_url: string;
231
+ })[];
178
232
  }>>;
179
233
  tls_policy: z.ZodOptional<z.ZodString>;
180
234
  domain: z.ZodString;
@@ -203,11 +257,15 @@ declare const customDomainWithTenantIdSchema: z.ZodObject<{
203
257
  custom_domain_id: string;
204
258
  tenant_id: string;
205
259
  verification?: {
206
- methods: {
260
+ methods: ({
207
261
  name: "txt";
208
262
  domain: string;
209
263
  record: string;
210
- }[];
264
+ } | {
265
+ name: "http";
266
+ http_body: string;
267
+ http_url: string;
268
+ })[];
211
269
  } | undefined;
212
270
  verification_method?: "txt" | undefined;
213
271
  tls_policy?: string | undefined;
@@ -222,11 +280,15 @@ declare const customDomainWithTenantIdSchema: z.ZodObject<{
222
280
  custom_domain_id: string;
223
281
  tenant_id: string;
224
282
  verification?: {
225
- methods: {
283
+ methods: ({
226
284
  name: "txt";
227
285
  domain: string;
228
286
  record: string;
229
- }[];
287
+ } | {
288
+ name: "http";
289
+ http_body: string;
290
+ http_url: string;
291
+ })[];
230
292
  } | undefined;
231
293
  verification_method?: "txt" | undefined;
232
294
  tls_policy?: string | undefined;