@authhero/cloudflare-adapter 2.7.6 → 2.8.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 +1,14 @@
1
- "use strict";var ot=Object.defineProperty;var ct=(r,e,t)=>e in r?ot(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var we=(r,e,t)=>ct(r,typeof e!="symbol"?e+"":e,t);const dt=require("@authhero/adapter-interfaces"),ut=require("wretch");function lt(r,e){var t={};for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&e.indexOf(s)<0&&(t[s]=r[s]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(r);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(r,s[n])&&(t[s[n]]=r[s[n]]);return t}function ft(r,e){var t;return((t=r==null?void 0:r._def)===null||t===void 0?void 0:t.typeName)===e}function ie(r,e){const t=r.ZodType.prototype[e];r.ZodType.prototype[e]=function(...s){const n=t.apply(this,s);return n._def.openapi=this._def.openapi,n}}function ht(r){if(typeof r.ZodType.prototype.openapi<"u")return;r.ZodType.prototype.openapi=function(n,a){var i,o,c,u,p,b;const A=typeof n=="string"?a:n,w=A??{},{param:V}=w,Ze=lt(w,["param"]),L=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof n=="string"?{refId:n}:void 0),be=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),Ze),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||V?{param:Object.assign(Object.assign({},(b=(p=this._def.openapi)===null||p===void 0?void 0:p.metadata)===null||b===void 0?void 0:b.param),V)}:void 0),q=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(L).length>0?{_internal:L}:void 0),Object.keys(be).length>0?{metadata:be}:void 0)}));if(ft(this,"ZodObject")){const ne=this.extend;q.extend=function(...ae){var Ee,Ie,$e,Pe,Me,De,Ve;const Le=ne.apply(this,ae);return Le._def.openapi={_internal:{extendedFrom:!((Ie=(Ee=this._def.openapi)===null||Ee===void 0?void 0:Ee._internal)===null||Ie===void 0)&&Ie.refId?{refId:(Pe=($e=this._def.openapi)===null||$e===void 0?void 0:$e._internal)===null||Pe===void 0?void 0:Pe.refId,schema:this}:(De=(Me=this._def.openapi)===null||Me===void 0?void 0:Me._internal)===null||De===void 0?void 0:De.extendedFrom},metadata:(Ve=Le._def.openapi)===null||Ve===void 0?void 0:Ve.metadata},Le}}return q},ie(r,"optional"),ie(r,"nullable"),ie(r,"default"),ie(r,"transform"),ie(r,"refine");const e=r.ZodObject.prototype.deepPartial;r.ZodObject.prototype.deepPartial=function(){const n=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,c])=>{var u,p;c._def.openapi=(p=(u=n[o])===null||u===void 0?void 0:u._def)===null||p===void 0?void 0:p.openapi}),a._def.openapi=void 0,a};const t=r.ZodObject.prototype.pick;r.ZodObject.prototype.pick=function(...n){const a=t.apply(this,n);return a._def.openapi=void 0,a};const s=r.ZodObject.prototype.omit;r.ZodObject.prototype.omit=function(...n){const a=s.apply(this,n);return a._def.openapi=void 0,a}}var G=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});we(this,"res");we(this,"status");this.res=t==null?void 0:t.res,this.status=e}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 x;(function(r){r.assertEqual=n=>{};function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},r.getValidEnumValues=n=>{const a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(const i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Fe;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Fe||(Fe={}));const f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),M=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}},d=x.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"]),pt=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class S 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 t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(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(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return n(this),s}static assert(e){if(!(e instanceof S))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const n of this.issues)if(n.path.length>0){const a=n.path[0];t[a]=t[a]||[],t[a].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}S.create=r=>new S(r);const te=(r,e)=>{let t;switch(r.code){case d.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,x.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(r.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(r.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:x.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case d.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case d.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(r)}return{message:t}};let Qe=te;function mt(r){Qe=r}function Te(){return Qe}const Ce=r=>{const{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.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{...n,path:a,message:o}},yt=[];function l(r,e){const t=Te(),s=Ce({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===te?void 0:te].filter(n=>!!n)});r.common.issues.push(s)}class T{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const n of t){if(n.status==="aborted")return m;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const n of t){const a=await n.key,i=await n.value;s.push({key:a,value:i})}return T.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const n of t){const{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return m;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const m=Object.freeze({status:"aborted"}),Q=r=>({status:"dirty",value:r}),C=r=>({status:"valid",value:r}),qe=r=>r.status==="aborted",We=r=>r.status==="dirty",J=r=>r.status==="valid",oe=r=>typeof Promise<"u"&&r instanceof Promise;var h;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(h||(h={}));class I{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}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 Ge=(r,e)=>{if(J(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new S(r.common.issues);return this._error=t,this._error}}};function _(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>{const{message:c}=r;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??t??o.defaultError}},description:n}}class v{get description(){return this._def.description}_getType(e){return M(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new T,ctx:{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(oe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:(t==null?void 0:t.async)??!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},n=this._parseSync({data:e,path:s.path,parent:s});return Ge(s,n)}"~validate"(e){var s,n;const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:t});return J(a)?{value:a.value}:{issues:t.common.issues}}catch(a){(n=(s=a==null?void 0:a.message)==null?void 0:s.toLowerCase())!=null&&n.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(a=>J(a)?{value:a.value}:{issues:t.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(oe(n)?n:Promise.resolve(n));return Ge(s,a)}refine(e,t){const s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue({code:d.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new N({schema:this,typeName:y.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:t=>this["~validate"](t)}}optional(){return E.create(this,this._def)}nullable(){return F.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return R.create(this)}promise(){return se.create(this,this._def)}or(e){return le.create([this,e],this._def)}and(e){return fe.create(this,e,this._def)}transform(e){return new N({..._(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new _e({..._(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new He({typeName:y.ZodBranded,type:this,..._(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ge({..._(this._def),innerType:this,catchValue:t,typeName:y.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return xe.create(this,e)}readonly(){return ve.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const _t=/^c[^\s-]{8,}$/i,gt=/^[0-9a-z]+$/,vt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,xt=/^[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,kt=/^[a-z0-9_-]{21}$/i,bt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,wt=/^[-+]?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)?)??$/,Tt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ct="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ze;const St=/^(?:(?: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])$/,Ot=/^(?:(?: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])$/,At=/^(([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])$/,Rt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Nt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,et="((\\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])))",Zt=new RegExp(`^${et}$`);function tt(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);const t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Et(r){return new RegExp(`^${tt(r)}$`)}function rt(r){let e=`${et}T${tt(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function It(r,e){return!!((e==="v4"||!e)&&St.test(r)||(e==="v6"||!e)&&At.test(r))}function $t(r,e){if(!bt.test(r))return!1;try{const[t]=r.split(".");if(!t)return!1;const s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||n===null||"typ"in n&&(n==null?void 0:n.typ)!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function Pt(r,e){return!!((e==="v4"||!e)&&Ot.test(r)||(e==="v6"||!e)&&jt.test(r))}class j extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_type,expected:f.string,received:a.parsedType}),m}const s=new T;let n;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?l(n,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(n,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")Tt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"email",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")ze||(ze=new RegExp(Ct,"u")),ze.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"emoji",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")xt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"uuid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")kt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"nanoid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")_t.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")gt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid2",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")vt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ulid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),l(n,{validation:"url",code:d.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"regex",code:d.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?rt(a).test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?Zt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?Et(a).test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?wt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"duration",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?It(e.data,a.version)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ip",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?$t(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"jwt",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?Pt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cidr",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Rt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"base64",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Nt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"base64url",code:d.invalid_string,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:d.invalid_string,...h.errToObj(s)})}_addCheck(e){return new j({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...h.errToObj(e==null?void 0: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==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...h.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...h.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...h.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...h.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...h.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...h.errToObj(t)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new j({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new j({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new j({...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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}j.create=r=>new j({checks:[],typeName:y.ZodString,coerce:(r==null?void 0:r.coerce)??!1,..._(r)});function Mt(r,e){const t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=Number.parseInt(r.toFixed(n).replace(".","")),i=Number.parseInt(e.toFixed(n).replace(".",""));return a%i/10**n}class z 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)!==f.number){const a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_type,expected:f.number,received:a.parsedType}),m}let s;const n=new T;for(const a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?Mt(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_finite,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,s,n){return new z({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:h.toString(n)}]})}_addCheck(e){return new z({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}z.create=r=>new z({checks:[],typeName:y.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,..._(r)});class U 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)!==f.bigint)return this._getInvalidInput(e);let s;const n=new T;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return l(t,{code:d.invalid_type,expected:f.bigint,received:t.parsedType}),m}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,s,n){return new U({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:h.toString(n)}]})}_addCheck(e){return new U({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}U.create=r=>new U({checks:[],typeName:y.ZodBigInt,coerce:(r==null?void 0:r.coerce)??!1,..._(r)});class ce extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.boolean,received:s.parsedType}),m}return C(e.data)}}ce.create=r=>new ce({typeName:y.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,..._(r)});class H extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_type,expected:f.date,received:a.parsedType}),m}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_date}),m}const s=new T;let n;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):x.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new H({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}H.create=r=>new H({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:y.ZodDate,..._(r)});class Se extends v{_parse(e){if(this._getType(e)!==f.symbol){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.symbol,received:s.parsedType}),m}return C(e.data)}}Se.create=r=>new Se({typeName:y.ZodSymbol,..._(r)});class de extends v{_parse(e){if(this._getType(e)!==f.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.undefined,received:s.parsedType}),m}return C(e.data)}}de.create=r=>new de({typeName:y.ZodUndefined,..._(r)});class ue extends v{_parse(e){if(this._getType(e)!==f.null){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.null,received:s.parsedType}),m}return C(e.data)}}ue.create=r=>new ue({typeName:y.ZodNull,..._(r)});class re extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}}re.create=r=>new re({typeName:y.ZodAny,..._(r)});class W extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}}W.create=r=>new W({typeName:y.ZodUnknown,..._(r)});class D extends v{_parse(e){const t=this._getOrReturnCtx(e);return l(t,{code:d.invalid_type,expected:f.never,received:t.parsedType}),m}}D.create=r=>new D({typeName:y.ZodNever,..._(r)});class Oe extends v{_parse(e){if(this._getType(e)!==f.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.void,received:s.parsedType}),m}return C(e.data)}}Oe.create=r=>new Oe({typeName:y.ZodVoid,..._(r)});class R extends v{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==f.array)return l(t,{code:d.invalid_type,expected:f.array,received:t.parsedType}),m;if(n.exactLength!==null){const i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(l(t,{code:i?d.too_big:d.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(l(t,{code:d.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(l(t,{code:d.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new I(t,i,t.path,o)))).then(i=>T.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new I(t,i,t.path,o)));return T.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new R({...this._def,minLength:{value:e,message:h.toString(t)}})}max(e,t){return new R({...this._def,maxLength:{value:e,message:h.toString(t)}})}length(e,t){return new R({...this._def,exactLength:{value:e,message:h.toString(t)}})}nonempty(e){return this.min(1,e)}}R.create=(r,e)=>new R({type:r,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,..._(e)});function X(r){if(r instanceof k){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=E.create(X(s))}return new k({...r._def,shape:()=>e})}else return r instanceof R?new R({...r._def,type:X(r.element)}):r instanceof E?E.create(X(r.unwrap())):r instanceof F?F.create(X(r.unwrap())):r instanceof $?$.create(r.items.map(e=>X(e))):r}class k 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(),t=x.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==f.object){const u=this._getOrReturnCtx(e);return l(u,{code:d.invalid_type,expected:f.object,received:u.parsedType}),m}const{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof D&&this._def.unknownKeys==="strip"))for(const u in n.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const p=a[u],b=n.data[u];c.push({key:{status:"valid",value:u},value:p._parse(new I(n,b,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof D){const u=this._def.unknownKeys;if(u==="passthrough")for(const p of o)c.push({key:{status:"valid",value:p},value:{status:"valid",value:n.data[p]}});else if(u==="strict")o.length>0&&(l(n,{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 b=n.data[p];c.push({key:{status:"valid",value:p},value:u._parse(new I(n,b,n.path,p)),alwaysSet:p in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of c){const b=await p.key,A=await p.value;u.push({key:b,value:A,alwaysSet:p.alwaysSet})}return u}).then(u=>T.mergeObjectSync(s,u)):T.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new k({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var a,i;const n=((i=(a=this._def).errorMap)==null?void 0:i.call(a,t,s).message)??s.defaultError;return t.code==="unrecognized_keys"?{message:h.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new k({...this._def,unknownKeys:"strip"})}passthrough(){return new k({...this._def,unknownKeys:"passthrough"})}extend(e){return new k({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new k({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new k({...this._def,catchall:e})}pick(e){const t={};for(const s of x.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new k({...this._def,shape:()=>t})}omit(e){const t={};for(const s of x.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new k({...this._def,shape:()=>t})}deepPartial(){return X(this)}partial(e){const t={};for(const s of x.objectKeys(this.shape)){const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}return new k({...this._def,shape:()=>t})}required(e){const t={};for(const s of x.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof E;)a=a._def.innerType;t[s]=a}return new k({...this._def,shape:()=>t})}keyof(){return st(x.objectKeys(this.shape))}}k.create=(r,e)=>new k({shape:()=>r,unknownKeys:"strip",catchall:D.create(),typeName:y.ZodObject,..._(e)});k.strictCreate=(r,e)=>new k({shape:()=>r,unknownKeys:"strict",catchall:D.create(),typeName:y.ZodObject,..._(e)});k.lazycreate=(r,e)=>new k({shape:r,unknownKeys:"strip",catchall:D.create(),typeName:y.ZodObject,..._(e)});class le extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new S(o.ctx.common.issues));return l(t,{code:d.invalid_union,unionErrors:i}),m}if(t.common.async)return Promise.all(s.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a;const i=[];for(const c of s){const u={...t,common:{...t.common,issues:[]},parent:null},p=c._parseSync({data:t.data,path:t.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!a&&(a={result:p,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new S(c));return l(t,{code:d.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}}le.create=(r,e)=>new le({options:r,typeName:y.ZodUnion,..._(e)});const P=r=>r instanceof pe?P(r.schema):r instanceof N?P(r.innerType()):r instanceof me?[r.value]:r instanceof B?r.options:r instanceof ye?x.objectValues(r.enum):r instanceof _e?P(r._def.innerType):r instanceof de?[void 0]:r instanceof ue?[null]:r instanceof E?[void 0,...P(r.unwrap())]:r instanceof F?[null,...P(r.unwrap())]:r instanceof He||r instanceof ve?P(r.unwrap()):r instanceof ge?P(r._def.innerType):[];class Ne extends v{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return l(t,{code:d.invalid_type,expected:f.object,received:t.parsedType}),m;const s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(l(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const n=new Map;for(const a of t){const i=P(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new Ne({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,..._(s)})}}function Je(r,e){const t=M(r),s=M(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&s===f.object){const n=x.objectKeys(e),a=x.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=Je(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===f.array&&s===f.array){if(r.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=Je(i,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===f.date&&s===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class fe extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(qe(a)||qe(i))return m;const o=Je(a.value,i.value);return o.valid?((We(a)||We(i))&&t.dirty(),{status:t.value,value:o.data}):(l(s,{code:d.invalid_intersection_types}),m)};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(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}fe.create=(r,e,t)=>new fe({left:r,right:e,typeName:y.ZodIntersection,..._(t)});class $ extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.array)return l(s,{code:d.invalid_type,expected:f.array,received:s.parsedType}),m;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"}),m;!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"}),t.dirty());const a=[...s.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new I(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>T.mergeArray(t,i)):T.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new $({...this._def,rest:e})}}$.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new $({items:r,typeName:y.ZodTuple,rest:null,..._(e)})};class he extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.object)return l(s,{code:d.invalid_type,expected:f.object,received:s.parsedType}),m;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)n.push({key:a._parse(new I(s,o,s.path,o)),value:i._parse(new I(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?T.mergeObjectAsync(t,n):T.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof v?new he({keyType:e,valueType:t,typeName:y.ZodRecord,..._(s)}):new he({keyType:j.create(),valueType:e,typeName:y.ZodRecord,..._(t)})}}class Ae extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.map)return l(s,{code:d.invalid_type,expected:f.map,received:s.parsedType}),m;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],u)=>({key:n._parse(new I(s,o,s.path,[u,"key"])),value:a._parse(new I(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 m;(u.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(u.value,p.value)}return{status:t.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 m;(u.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(u.value,p.value)}return{status:t.value,value:o}}}}Ae.create=(r,e,t)=>new Ae({valueType:e,keyType:r,typeName:y.ZodMap,..._(t)});class Y extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.set)return l(s,{code:d.invalid_type,expected:f.set,received:s.parsedType}),m;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(l(s,{code:d.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(l(s,{code:d.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const u=new Set;for(const p of c){if(p.status==="aborted")return m;p.status==="dirty"&&t.dirty(),u.add(p.value)}return{status:t.value,value:u}}const o=[...s.data.values()].map((c,u)=>a._parse(new I(s,c,s.path,u)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new Y({...this._def,minSize:{value:e,message:h.toString(t)}})}max(e,t){return new Y({...this._def,maxSize:{value:e,message:h.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Y.create=(r,e)=>new Y({valueType:r,minSize:null,maxSize:null,typeName:y.ZodSet,..._(e)});class ee extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return l(t,{code:d.invalid_type,expected:f.function,received:t.parsedType}),m;function s(o,c){return Ce({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Te(),te].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:c}})}function n(o,c){return Ce({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Te(),te].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof se){const o=this;return C(async function(...c){const u=new S([]),p=await o._def.args.parseAsync(c,a).catch(w=>{throw u.addIssue(s(c,w)),u}),b=await Reflect.apply(i,this,p);return await o._def.returns._def.type.parseAsync(b,a).catch(w=>{throw u.addIssue(n(b,w)),u})})}else{const o=this;return C(function(...c){const u=o._def.args.safeParse(c,a);if(!u.success)throw new S([s(c,u.error)]);const p=Reflect.apply(i,this,u.data),b=o._def.returns.safeParse(p,a);if(!b.success)throw new S([n(p,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ee({...this._def,args:$.create(e).rest(W.create())})}returns(e){return new ee({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new ee({args:e||$.create([]).rest(W.create()),returns:t||W.create(),typeName:y.ZodFunction,..._(s)})}}class pe extends v{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}pe.create=(r,e)=>new pe({getter:r,typeName:y.ZodLazy,..._(e)});class me extends v{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}me.create=(r,e)=>new me({value:r,typeName:y.ZodLiteral,..._(e)});function st(r,e){return new B({values:r,typeName:y.ZodEnum,..._(e)})}class B extends v{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{expected:x.joinValues(s),received:t.parsedType,code:d.invalid_type}),m}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{received:t.data,code:d.invalid_enum_value,options:s}),m}return C(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return B.create(e,{...this._def,...t})}exclude(e,t=this._def){return B.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}B.create=st;class ye extends v{_parse(e){const t=x.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==f.string&&s.parsedType!==f.number){const n=x.objectValues(t);return l(s,{expected:x.joinValues(n),received:s.parsedType,code:d.invalid_type}),m}if(this._cache||(this._cache=new Set(x.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const n=x.objectValues(t);return l(s,{received:s.data,code:d.invalid_enum_value,options:n}),m}return C(e.data)}get enum(){return this._def.values}}ye.create=(r,e)=>new ye({values:r,typeName:y.ZodNativeEnum,..._(e)});class se extends v{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return l(t,{code:d.invalid_type,expected:f.promise,received:t.parsedType}),m;const s=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return C(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}se.create=(r,e)=>new se({type:r,typeName:y.ZodPromise,..._(e)});class N extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{l(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return m;const c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?m:c.status==="dirty"||t.value==="dirty"?Q(c.value):c});{if(t.value==="aborted")return m;const o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?m:o.status==="dirty"||t.value==="dirty"?Q(o.value):o}}if(n.type==="refinement"){const i=o=>{const c=n.refinement(o,a);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"?m:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.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 m;const o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>J(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):m);x.assertNever(n)}}N.create=(r,e,t)=>new N({schema:r,typeName:y.ZodEffects,effect:e,..._(t)});N.createWithPreprocess=(r,e,t)=>new N({schema:e,effect:{type:"preprocess",transform:r},typeName:y.ZodEffects,..._(t)});class E extends v{_parse(e){return this._getType(e)===f.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}E.create=(r,e)=>new E({innerType:r,typeName:y.ZodOptional,..._(e)});class F extends v{_parse(e){return this._getType(e)===f.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}F.create=(r,e)=>new F({innerType:r,typeName:y.ZodNullable,..._(e)});class _e extends v{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===f.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}_e.create=(r,e)=>new _e({innerType:r,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});class ge extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return oe(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new S(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new S(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}ge.create=(r,e)=>new ge({innerType:r,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});class je extends v{_parse(e){if(this._getType(e)!==f.nan){const s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.nan,received:s.parsedType}),m}return{status:"valid",value:e.data}}}je.create=r=>new je({typeName:y.ZodNaN,..._(r)});const Dt=Symbol("zod_brand");class He extends v{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class xe extends v{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?m:a.status==="dirty"?(t.dirty(),Q(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?m:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new xe({in:e,out:t,typeName:y.ZodPipeline})}}class ve extends v{_parse(e){const t=this._def.innerType._parse(e),s=n=>(J(n)&&(n.value=Object.freeze(n.value)),n);return oe(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}}ve.create=(r,e)=>new ve({innerType:r,typeName:y.ZodReadonly,..._(e)});function Ke(r,e){const t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function nt(r,e={},t){return r?re.create().superRefine((s,n)=>{const a=r(s);if(a instanceof Promise)return a.then(i=>{if(!i){const o=Ke(e,s),c=o.fatal??t??!0;n.addIssue({code:"custom",...o,fatal:c})}});if(!a){const i=Ke(e,s),o=i.fatal??t??!0;n.addIssue({code:"custom",...i,fatal:o})}}):re.create()}const Vt={object:k.lazycreate};var y;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(y||(y={}));const Lt=(r,e={message:`Input not instance of ${r.name}`})=>nt(t=>t instanceof r,e),g=j.create,Ye=z.create,zt=je.create,Ut=U.create,ke=ce.create,Bt=H.create,Ft=Se.create,qt=de.create,Wt=ue.create,Jt=re.create,Ht=W.create,Yt=D.create,Gt=Oe.create,O=R.create,Z=k.create,Kt=k.strictCreate,Xt=le.create,Qt=Ne.create,er=fe.create,tr=$.create,at=he.create,rr=Ae.create,sr=Y.create,nr=ee.create,ar=pe.create,ir=me.create,or=B.create,cr=ye.create,dr=se.create,Xe=N.create,ur=E.create,lr=F.create,fr=N.createWithPreprocess,hr=xe.create,pr=()=>g().optional(),mr=()=>Ye().optional(),yr=()=>ke().optional(),_r={string:r=>j.create({...r,coerce:!0}),number:r=>z.create({...r,coerce:!0}),boolean:r=>ce.create({...r,coerce:!0}),bigint:r=>U.create({...r,coerce:!0}),date:r=>H.create({...r,coerce:!0})},gr=m,vr=Object.freeze(Object.defineProperty({__proto__:null,BRAND:Dt,DIRTY:Q,EMPTY_PATH:yt,INVALID:m,NEVER:gr,OK:C,ParseStatus:T,Schema:v,ZodAny:re,ZodArray:R,ZodBigInt:U,ZodBoolean:ce,ZodBranded:He,ZodCatch:ge,ZodDate:H,ZodDefault:_e,ZodDiscriminatedUnion:Ne,ZodEffects:N,ZodEnum:B,ZodError:S,get ZodFirstPartyTypeKind(){return y},ZodFunction:ee,ZodIntersection:fe,ZodIssueCode:d,ZodLazy:pe,ZodLiteral:me,ZodMap:Ae,ZodNaN:je,ZodNativeEnum:ye,ZodNever:D,ZodNull:ue,ZodNullable:F,ZodNumber:z,ZodObject:k,ZodOptional:E,ZodParsedType:f,ZodPipeline:xe,ZodPromise:se,ZodReadonly:ve,ZodRecord:he,ZodSchema:v,ZodSet:Y,ZodString:j,ZodSymbol:Se,ZodTransformer:N,ZodTuple:$,ZodType:v,ZodUndefined:de,ZodUnion:le,ZodUnknown:W,ZodVoid:Oe,addIssueToContext:l,any:Jt,array:O,bigint:Ut,boolean:ke,coerce:_r,custom:nt,date:Bt,datetimeRegex:rt,defaultErrorMap:te,discriminatedUnion:Qt,effect:Xe,enum:or,function:nr,getErrorMap:Te,getParsedType:M,instanceof:Lt,intersection:er,isAborted:qe,isAsync:oe,isDirty:We,isValid:J,late:Vt,lazy:ar,literal:ir,makeIssue:Ce,map:rr,nan:zt,nativeEnum:cr,never:Yt,null:Wt,nullable:lr,number:Ye,object:Z,get objectUtil(){return Fe},oboolean:yr,onumber:mr,optional:ur,ostring:pr,pipeline:hr,preprocess:fr,promise:dr,quotelessJson:pt,record:at,set:sr,setErrorMap:mt,strictObject:Kt,string:g,symbol:Ft,transformer:Xe,tuple:tr,undefined:qt,union:Xt,unknown:Ht,get util(){return x},void:Gt},Symbol.toStringTag,{value:"Module"}));ht(vr);const xr=(r,e)=>e.skipDedupe||e.method!=="GET",kr=(r,e)=>e.method+"@"+r,br=r=>r.clone(),wr=({skip:r=xr,key:e=kr,resolver:t=br}={})=>{const s=new Map;return n=>(a,i)=>{if(r(a,i))return n(a,i);const o=e(a,i);if(!s.has(o))s.set(o,[]);else return new Promise((c,u)=>{s.get(o).push([c,u])});try{return n(a,i).then(c=>(s.get(o).forEach(([u])=>u(t(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)}}},Tr=(r,e)=>r*e,Cr=r=>r&&r.ok,Sr=({delayTimer:r=500,delayRamp:e=Tr,maxAttempts:t=10,until:s=Cr,onRetry:n=null,retryOnNetworkError:a=!1,resolveWithLatestResponse:i=!1,skip:o}={})=>c=>(u,p)=>{let b=0;if(o&&o(u,p))return c(u,p);const A=(w,V)=>Promise.resolve(s(w,V)).then(Ze=>Ze?w&&i?w:V?Promise.reject(V):w:(b++,!t||b<=t?new Promise(L=>{const be=e(r,b);setTimeout(()=>{typeof n=="function"?Promise.resolve(n({response:w,error:V,url:u,options:p})).then((q={})=>{var ne,ae;L(c((ne=q&&q.url)!==null&&ne!==void 0?ne:u,(ae=q&&q.options)!==null&&ae!==void 0?ae:p))}):L(c(u,p))},be)}).then(A).catch(L=>{if(!a)throw L;return A(null,L)}):w&&i?w:Promise.reject(V||new Error("Number of attempts exceeded."))));return c(u,p).then(A).catch(w=>{if(!a)throw w;return A(null,w)})},Re=Z({code:Ye(),message:g()}),Or=Z({message:g()}),Ar=Z({emails:O(g()).optional(),http_body:g().optional(),http_url:g().optional(),txt_name:g().optional(),txt_value:g().optional()}),jr=Z({ciphers:O(g()).optional(),early_hints:g().optional(),http2:g().optional(),min_tls_version:g().optional(),tls_1_3:g().optional()}),Rr=Z({id:g(),bundle_method:g().optional(),certificate_authority:g(),custom_certificate:g().optional(),custom_csr_id:g().optional(),custom_key:g().optional(),expires_on:g().optional(),hosts:O(g()).optional(),issuer:g().optional(),method:g(),serial_number:g().optional(),settings:jr.optional(),signature:g().optional(),type:g(),uploaded_on:g().optional(),validation_errors:O(Or).optional(),validation_records:O(Ar).optional(),wildcard:ke()}),Nr=Z({name:g(),type:g(),value:g()}),Zr=Z({http_body:g().optional(),http_url:g().optional()}),it=Z({id:g(),ssl:Rr,hostname:g(),custom_metadata:at(g()).optional(),custom_origin_server:g().optional(),custom_origin_sni:g().optional(),ownership_verification:Nr.optional(),ownership_verification_http:Zr.optional(),status:g(),verification_errors:O(g()).optional(),created_at:g()}),Ue=Z({errors:O(Re),messages:O(Re),success:ke(),result:it}),Er=Z({errors:O(Re),messages:O(Re),success:ke(),result:O(it)});function K(r){return ut(`https://api.cloudflare.com/client/v4/zones/${r.zoneId}`).headers({"X-Auth-Email":r.authEmail,"X-Auth-Key":r.authKey,"Content-Type":"application/json"}).middlewares([Sr(),wr()])}function Be(r){const e=[];if(r.ssl.validation_records)for(const t of r.ssl.validation_records)t.txt_name&&t.txt_value&&e.push({name:"txt",record:t.txt_value,domain:t.txt_name});return r.ownership_verification&&e.push({name:"txt",record:r.ownership_verification.value,domain:r.ownership_verification.name}),{custom_domain_id:r.id,domain:r.hostname,primary:r.primary,status:r.status==="active"?"ready":"pending",type:"auth0_managed_certs",verification:{methods:O(dt.verificationMethodsSchema).parse(e)}}}function Ir(r){return{create:async(e,t)=>{const{result:s,errors:n,success:a}=Ue.parse(await K(r).post({hostname:t.domain,ssl:{method:"txt",type:"dv"},custom_metadata:r.enterprise?{tenant_id:e}:void 0},"/custom_hostnames").json());if(!a)throw new Error(JSON.stringify(n));const i=Be({...s,primary:!1});return await r.customDomainAdapter.create(e,{custom_domain_id:i.custom_domain_id,domain:i.domain,type:i.type}),i},get:async(e,t)=>{var c;const s=await r.customDomainAdapter.get(e,t);if(!s)throw new G(404);const n=await K(r).get(`/custom_hostnames/${encodeURIComponent(t)}`).json(),{result:a,errors:i,success:o}=Ue.parse(n);if(!o)throw new G(503,{message:JSON.stringify(i)});if(r.enterprise&&((c=a.custom_metadata)==null?void 0:c.tenant_id)!==e)throw new G(404);return Be({...s,...a})},getByDomain:async e=>r.customDomainAdapter.getByDomain(e),list:async e=>{const t=await r.customDomainAdapter.list(e),s=await K(r).get("/custom_hostnames").json(),{result:n,errors:a,success:i}=Er.parse(s);if(!i)throw new G(503,{message:JSON.stringify(a)});return n.filter(o=>t.find(c=>c.custom_domain_id===o.id)).filter(o=>{var c;return!(r.enterprise&&((c=o.custom_metadata)==null?void 0:c.tenant_id)!==e)}).map(o=>Be({...t.find(c=>c.custom_domain_id===o.id),...o}))},remove:async(e,t)=>{var n;if(r.enterprise){const{result:a,success:i}=Ue.parse(await K(r).get(`/custom_hostnames/${encodeURIComponent(t)}`).json());if(!i||((n=a.custom_metadata)==null?void 0:n.tenant_id)!==e)throw new G(404)}const s=await K(r).delete(`/custom_hostnames/${encodeURIComponent(t)}`).res();return s.ok&&await r.customDomainAdapter.remove(e,t),s.ok},update:async(e,t,s)=>{const n=await K(r).patch(s,`/custom_hostnames/${encodeURIComponent(t)}`).res();if(!n.ok)throw new G(503,{message:await n.text()});return r.customDomainAdapter.update(e,t,s)}}}class $r{constructor(e){we(this,"cache",null);this.config=e}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 t=await this.getCache(),s=this.createRequest(e),n=await t.match(s);if(!n)return null;const a=await n.json();return a.expiresAt&&new Date(a.expiresAt)<new Date?(await this.delete(e),null):a.value}catch(t){return console.error(`CloudflareCache: get error for key ${e}:`,t),null}}async set(e,t,s){try{const n=await this.getCache(),a=s??this.config.defaultTtlSeconds,i=a!==void 0,o=i?Math.max(0,a):0,c={value:t,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 b=new Response(JSON.stringify(c),{headers:p});await n.put(u,b)}catch(n){console.error(`CloudflareCache: set error for key ${e}:`,n)}}async delete(e){try{const t=await this.getCache(),s=this.createRequest(e);return await t.delete(s)}catch(t){return console.error(`CloudflareCache: delete error for key ${e}:`,t),!1}}async clear(){console.warn("CloudflareCache.clear() is not implemented - Cloudflare Cache API does not support clearing all entries")}}function Pr(r={}){const e={defaultTtlSeconds:300,keyPrefix:"authhero",...r};return new $r(e)}function Mr(r){return{customDomains:Ir(r),cache:Pr({...r.cacheName&&{cacheName:r.cacheName},...r.defaultTtlSeconds!==void 0&&{defaultTtlSeconds:r.defaultTtlSeconds},...r.keyPrefix&&{keyPrefix:r.keyPrefix}})}}module.exports=Mr;
1
+ "use strict";const lt=require("@authhero/adapter-interfaces"),ht=require("wretch");function ft(s,e){var t={};for(var r in s)Object.prototype.hasOwnProperty.call(s,r)&&e.indexOf(r)<0&&(t[r]=s[r]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,r=Object.getOwnPropertySymbols(s);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(s,r[n])&&(t[r[n]]=s[r[n]]);return t}function pt(s,e){var t;return((t=s?._def)===null||t===void 0?void 0:t.typeName)===e}function le(s,e){const t=s.ZodType.prototype[e];s.ZodType.prototype[e]=function(...r){const n=t.apply(this,r);return n._def.openapi=this._def.openapi,n}}function mt(s){if(typeof s.ZodType.prototype.openapi<"u")return;s.ZodType.prototype.openapi=function(n,a){var i,o,c,u,p,b;const C=typeof n=="string"?a:n,w=C??{},{param:Z}=w,de=ft(w,["param"]),M=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof n=="string"?{refId:n}:void 0),J=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),de),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||Z?{param:Object.assign(Object.assign({},(b=(p=this._def.openapi)===null||p===void 0?void 0:p.metadata)===null||b===void 0?void 0:b.param),Z)}:void 0),D=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(M).length>0?{_internal:M}:void 0),Object.keys(J).length>0?{metadata:J}:void 0)}));if(pt(this,"ZodObject")){const ee=this.extend;D.extend=function(...Q){var H,ue,Pe,Me,De,Le,Ve;const ze=ee.apply(this,Q);return ze._def.openapi={_internal:{extendedFrom:!((ue=(H=this._def.openapi)===null||H===void 0?void 0:H._internal)===null||ue===void 0)&&ue.refId?{refId:(Me=(Pe=this._def.openapi)===null||Pe===void 0?void 0:Pe._internal)===null||Me===void 0?void 0:Me.refId,schema:this}:(Le=(De=this._def.openapi)===null||De===void 0?void 0:De._internal)===null||Le===void 0?void 0:Le.extendedFrom},metadata:(Ve=ze._def.openapi)===null||Ve===void 0?void 0:Ve.metadata},ze}}return D},le(s,"optional"),le(s,"nullable"),le(s,"default"),le(s,"transform"),le(s,"refine");const e=s.ZodObject.prototype.deepPartial;s.ZodObject.prototype.deepPartial=function(){const n=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,c])=>{var u,p;c._def.openapi=(p=(u=n[o])===null||u===void 0?void 0:u._def)===null||p===void 0?void 0:p.openapi}),a._def.openapi=void 0,a};const t=s.ZodObject.prototype.pick;s.ZodObject.prototype.pick=function(...n){const a=t.apply(this,n);return a._def.openapi=void 0,a};const r=s.ZodObject.prototype.omit;s.ZodObject.prototype.omit=function(...n){const a=r.apply(this,n);return a._def.openapi=void 0,a}}var te=class extends Error{res;status;constructor(s=500,e){super(e?.message,{cause:e?.cause}),this.res=e?.res,this.status=s}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 x;(function(s){s.assertEqual=n=>{};function e(n){}s.assertIs=e;function t(n){throw new Error}s.assertNever=t,s.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},s.getValidEnumValues=n=>{const a=s.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return s.objectValues(i)},s.objectValues=n=>s.objectKeys(n).map(function(a){return n[a]}),s.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},s.find=(n,a)=>{for(const i of n)if(a(i))return i},s.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function r(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}s.joinValues=r,s.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Fe;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Fe||(Fe={}));const h=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),V=s=>{switch(typeof s){case"undefined":return h.undefined;case"string":return h.string;case"number":return Number.isNaN(s)?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(s)?h.array:s===null?h.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?h.promise:typeof Map<"u"&&s instanceof Map?h.map:typeof Set<"u"&&s instanceof Set?h.set:typeof Date<"u"&&s instanceof Date?h.date:h.object;default:return h.unknown}},d=x.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"]),yt=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");class O extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},r={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)r._errors.push(t(i));else{let o=r,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(t(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return n(this),r}static assert(e){if(!(e instanceof O))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const n of this.issues)if(n.path.length>0){const a=n.path[0];t[a]=t[a]||[],t[a].push(e(n))}else r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}O.create=s=>new O(s);const ie=(s,e)=>{let t;switch(s.code){case d.invalid_type:s.received===h.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,x.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(s.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(s.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(s.options)}, received '${s.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:x.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case d.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="bigint"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case d.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(s)}return{message:t}};let st=ie;function _t(s){st=s}function Oe(){return st}const Ae=s=>{const{data:e,path:t,errorMaps:r,issueData:n}=s,a=[...t,...n.path||[]],i={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let o="";const c=r.filter(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return{...n,path:a,message:o}},gt=[];function l(s,e){const t=Oe(),r=Ae({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===ie?void 0:ie].filter(n=>!!n)});s.common.issues.push(r)}class T{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const n of t){if(n.status==="aborted")return m;n.status==="dirty"&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const n of t){const a=await n.key,i=await n.value;r.push({key:a,value:i})}return T.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const n of t){const{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return m;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(r[a.value]=i.value)}return{status:e.value,value:r}}}const m=Object.freeze({status:"aborted"}),ne=s=>({status:"dirty",value:s}),S=s=>({status:"valid",value:s}),We=s=>s.status==="aborted",Je=s=>s.status==="dirty",K=s=>s.status==="valid",he=s=>typeof Promise<"u"&&s instanceof Promise;var f;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e?.message})(f||(f={}));class ${constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}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 Ge=(s,e)=>{if(K(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new O(s.common.issues);return this._error=t,this._error}}};function _(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:n}=s;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>{const{message:c}=s;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??r??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??t??o.defaultError}},description:n}}class v{get description(){return this._def.description}_getType(e){return V(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new T,ctx:{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(he(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)},n=this._parseSync({data:e,path:r.path,parent:r});return Ge(r,n)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:t});return K(r)?{value:r.value}:{issues:t.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(r=>K(r)?{value:r.value}:{issues:t.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)},n=this._parse({data:e,path:r.path,parent:r}),a=await(he(n)?n:Promise.resolve(n));return Ge(r,a)}refine(e,t){const r=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue({code:d.custom,...r(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,n)=>e(r)?!0:(n.addIssue(typeof t=="function"?t(r,n):t),!1))}_refinement(e){return new N({schema:this,typeName:y.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:t=>this["~validate"](t)}}optional(){return I.create(this,this._def)}nullable(){return W.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return E.create(this)}promise(){return ce.create(this,this._def)}or(e){return ye.create([this,e],this._def)}and(e){return _e.create(this,e,this._def)}transform(e){return new N({..._(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ke({..._(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new Ye({typeName:y.ZodBranded,type:this,..._(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new we({..._(this._def),innerType:this,catchValue:t,typeName:y.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Se.create(this,e)}readonly(){return Te.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const vt=/^c[^\s-]{8,}$/i,xt=/^[0-9a-z]+$/,bt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,kt=/^[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,wt=/^[a-z0-9_-]{21}$/i,Tt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,St=/^[-+]?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)?)??$/,Ct=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ot="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Be;const At=/^(?:(?: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])$/,Et=/^(([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]))$/,Nt=/^(([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])$/,jt=/^([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}(=)?))?$/,rt="((\\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])))",It=new RegExp(`^${rt}$`);function nt(s){let e="[0-5]\\d";s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`);const t=s.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function $t(s){return new RegExp(`^${nt(s)}$`)}function at(s){let e=`${rt}T${nt(s)}`;const t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Pt(s,e){return!!((e==="v4"||!e)&&At.test(s)||(e==="v6"||!e)&&Et.test(s))}function Mt(s,e){if(!Tt.test(s))return!1;try{const[t]=s.split(".");if(!t)return!1;const r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(r));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function Dt(s,e){return!!((e==="v4"||!e)&&Rt.test(s)||(e==="v6"||!e)&&Nt.test(s))}class R extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){const a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_type,expected:h.string,received:a.parsedType}),m}const r=new T;let n;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?l(n,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(n,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")Ct.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"email",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Be||(Be=new RegExp(Ot,"u")),Be.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"emoji",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")kt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"uuid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")wt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"nanoid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")vt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")xt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid2",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")bt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ulid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),l(n,{validation:"url",code:d.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"regex",code:d.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?at(a).test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?It.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?$t(a).test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?St.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"duration",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?Pt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ip",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?Mt(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"jwt",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?Dt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cidr",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?jt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"base64",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?Zt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"base64url",code:d.invalid_string,message:a.message}),r.dirty()):x.assertNever(a);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(n=>e.test(n),{validation:t,code:d.invalid_string,...f.errToObj(r)})}_addCheck(e){return new R({...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,t){return this._addCheck({kind:"regex",regex:e,...f.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...f.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...f.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...f.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...f.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...f.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...f.errToObj(t)})}nonempty(e){return this.min(1,f.errToObj(e))}trim(){return new R({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new R({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new R({...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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}R.create=s=>new R({checks:[],typeName:y.ZodString,coerce:s?.coerce??!1,..._(s)});function Lt(s,e){const t=(s.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,n=t>r?t:r,a=Number.parseInt(s.toFixed(n).replace(".","")),i=Number.parseInt(e.toFixed(n).replace(".",""));return a%i/10**n}class U 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 a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_type,expected:h.number,received:a.parsedType}),m}let r;const n=new T;for(const a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?Lt(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:d.not_finite,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,f.toString(t))}gt(e,t){return this.setLimit("min",e,!1,f.toString(t))}lte(e,t){return this.setLimit("max",e,!0,f.toString(t))}lt(e,t){return this.setLimit("max",e,!1,f.toString(t))}setLimit(e,t,r,n){return new U({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:f.toString(n)}]})}_addCheck(e){return new U({...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,t){return this._addCheck({kind:"multipleOf",value:e,message:f.toString(t)})}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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}U.create=s=>new U({checks:[],typeName:y.ZodNumber,coerce:s?.coerce||!1,..._(s)});class q 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 r;const n=new T;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),l(r,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return l(t,{code:d.invalid_type,expected:h.bigint,received:t.parsedType}),m}gte(e,t){return this.setLimit("min",e,!0,f.toString(t))}gt(e,t){return this.setLimit("min",e,!1,f.toString(t))}lte(e,t){return this.setLimit("max",e,!0,f.toString(t))}lt(e,t){return this.setLimit("max",e,!1,f.toString(t))}setLimit(e,t,r,n){return new q({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:f.toString(n)}]})}_addCheck(e){return new q({...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,t){return this._addCheck({kind:"multipleOf",value:e,message:f.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}q.create=s=>new q({checks:[],typeName:y.ZodBigInt,coerce:s?.coerce??!1,..._(s)});class fe extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:h.boolean,received:r.parsedType}),m}return S(e.data)}}fe.create=s=>new fe({typeName:y.ZodBoolean,coerce:s?.coerce||!1,..._(s)});class G extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){const a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_type,expected:h.date,received:a.parsedType}),m}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_date}),m}const r=new T;let n;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):x.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:f.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:f.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}G.create=s=>new G({checks:[],coerce:s?.coerce||!1,typeName:y.ZodDate,..._(s)});class Re extends v{_parse(e){if(this._getType(e)!==h.symbol){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:h.symbol,received:r.parsedType}),m}return S(e.data)}}Re.create=s=>new Re({typeName:y.ZodSymbol,..._(s)});class pe extends v{_parse(e){if(this._getType(e)!==h.undefined){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:h.undefined,received:r.parsedType}),m}return S(e.data)}}pe.create=s=>new pe({typeName:y.ZodUndefined,..._(s)});class me extends v{_parse(e){if(this._getType(e)!==h.null){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:h.null,received:r.parsedType}),m}return S(e.data)}}me.create=s=>new me({typeName:y.ZodNull,..._(s)});class oe extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return S(e.data)}}oe.create=s=>new oe({typeName:y.ZodAny,..._(s)});class Y extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return S(e.data)}}Y.create=s=>new Y({typeName:y.ZodUnknown,..._(s)});class z extends v{_parse(e){const t=this._getOrReturnCtx(e);return l(t,{code:d.invalid_type,expected:h.never,received:t.parsedType}),m}}z.create=s=>new z({typeName:y.ZodNever,..._(s)});class Ee extends v{_parse(e){if(this._getType(e)!==h.undefined){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:h.void,received:r.parsedType}),m}return S(e.data)}}Ee.create=s=>new Ee({typeName:y.ZodVoid,..._(s)});class E extends v{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==h.array)return l(t,{code:d.invalid_type,expected:h.array,received:t.parsedType}),m;if(n.exactLength!==null){const i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(l(t,{code:i?d.too_big:d.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(l(t,{code:d.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(l(t,{code:d.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new $(t,i,t.path,o)))).then(i=>T.mergeArray(r,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new $(t,i,t.path,o)));return T.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new E({...this._def,minLength:{value:e,message:f.toString(t)}})}max(e,t){return new E({...this._def,maxLength:{value:e,message:f.toString(t)}})}length(e,t){return new E({...this._def,exactLength:{value:e,message:f.toString(t)}})}nonempty(e){return this.min(1,e)}}E.create=(s,e)=>new E({type:s,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,..._(e)});function re(s){if(s instanceof k){const e={};for(const t in s.shape){const r=s.shape[t];e[t]=I.create(re(r))}return new k({...s._def,shape:()=>e})}else return s instanceof E?new E({...s._def,type:re(s.element)}):s instanceof I?I.create(re(s.unwrap())):s instanceof W?W.create(re(s.unwrap())):s instanceof P?P.create(s.items.map(e=>re(e))):s}class k 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(),t=x.objectKeys(e);return this._cached={shape:e,keys:t},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}),m}const{status:r,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof z&&this._def.unknownKeys==="strip"))for(const u in n.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const p=a[u],b=n.data[u];c.push({key:{status:"valid",value:u},value:p._parse(new $(n,b,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof z){const u=this._def.unknownKeys;if(u==="passthrough")for(const p of o)c.push({key:{status:"valid",value:p},value:{status:"valid",value:n.data[p]}});else if(u==="strict")o.length>0&&(l(n,{code:d.unrecognized_keys,keys:o}),r.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 b=n.data[p];c.push({key:{status:"valid",value:p},value:u._parse(new $(n,b,n.path,p)),alwaysSet:p in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const p of c){const b=await p.key,C=await p.value;u.push({key:b,value:C,alwaysSet:p.alwaysSet})}return u}).then(u=>T.mergeObjectSync(r,u)):T.mergeObjectSync(r,c)}get shape(){return this._def.shape()}strict(e){return f.errToObj,new k({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{const n=this._def.errorMap?.(t,r).message??r.defaultError;return t.code==="unrecognized_keys"?{message:f.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new k({...this._def,unknownKeys:"strip"})}passthrough(){return new k({...this._def,unknownKeys:"passthrough"})}extend(e){return new k({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new k({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new k({...this._def,catchall:e})}pick(e){const t={};for(const r of x.objectKeys(e))e[r]&&this.shape[r]&&(t[r]=this.shape[r]);return new k({...this._def,shape:()=>t})}omit(e){const t={};for(const r of x.objectKeys(this.shape))e[r]||(t[r]=this.shape[r]);return new k({...this._def,shape:()=>t})}deepPartial(){return re(this)}partial(e){const t={};for(const r of x.objectKeys(this.shape)){const n=this.shape[r];e&&!e[r]?t[r]=n:t[r]=n.optional()}return new k({...this._def,shape:()=>t})}required(e){const t={};for(const r of x.objectKeys(this.shape))if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof I;)a=a._def.innerType;t[r]=a}return new k({...this._def,shape:()=>t})}keyof(){return it(x.objectKeys(this.shape))}}k.create=(s,e)=>new k({shape:()=>s,unknownKeys:"strip",catchall:z.create(),typeName:y.ZodObject,..._(e)});k.strictCreate=(s,e)=>new k({shape:()=>s,unknownKeys:"strict",catchall:z.create(),typeName:y.ZodObject,..._(e)});k.lazycreate=(s,e)=>new k({shape:s,unknownKeys:"strip",catchall:z.create(),typeName:y.ZodObject,..._(e)});class ye extends v{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function n(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new O(o.ctx.common.issues));return l(t,{code:d.invalid_union,unionErrors:i}),m}if(t.common.async)return Promise.all(r.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a;const i=[];for(const c of r){const u={...t,common:{...t.common,issues:[]},parent:null},p=c._parseSync({data:t.data,path:t.path,parent:u});if(p.status==="valid")return p;p.status==="dirty"&&!a&&(a={result:p,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new O(c));return l(t,{code:d.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}}ye.create=(s,e)=>new ye({options:s,typeName:y.ZodUnion,..._(e)});const L=s=>s instanceof ve?L(s.schema):s instanceof N?L(s.innerType()):s instanceof xe?[s.value]:s instanceof F?s.options:s instanceof be?x.objectValues(s.enum):s instanceof ke?L(s._def.innerType):s instanceof pe?[void 0]:s instanceof me?[null]:s instanceof I?[void 0,...L(s.unwrap())]:s instanceof W?[null,...L(s.unwrap())]:s instanceof Ye||s instanceof Te?L(s.unwrap()):s instanceof we?L(s._def.innerType):[];class $e extends v{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.object)return l(t,{code:d.invalid_type,expected:h.object,received:t.parsedType}),m;const r=this.discriminator,n=t.data[r],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(l(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const n=new Map;for(const a of t){const i=L(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new $e({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,..._(r)})}}function Qe(s,e){const t=V(s),r=V(e);if(s===e)return{valid:!0,data:s};if(t===h.object&&r===h.object){const n=x.objectKeys(e),a=x.objectKeys(s).filter(o=>n.indexOf(o)!==-1),i={...s,...e};for(const o of a){const c=Qe(s[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===h.array&&r===h.array){if(s.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<s.length;a++){const i=s[a],o=e[a],c=Qe(i,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===h.date&&r===h.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class _e extends v{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=(a,i)=>{if(We(a)||We(i))return m;const o=Qe(a.value,i.value);return o.valid?((Je(a)||Je(i))&&t.dirty(),{status:t.value,value:o.data}):(l(r,{code:d.invalid_intersection_types}),m)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}_e.create=(s,e,t)=>new _e({left:s,right:e,typeName:y.ZodIntersection,..._(t)});class P extends v{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==h.array)return l(r,{code:d.invalid_type,expected:h.array,received:r.parsedType}),m;if(r.data.length<this._def.items.length)return l(r,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),m;!this._def.rest&&r.data.length>this._def.items.length&&(l(r,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...r.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new $(r,i,r.path,o)):null}).filter(i=>!!i);return r.common.async?Promise.all(a).then(i=>T.mergeArray(t,i)):T.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new P({...this._def,rest:e})}}P.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new P({items:s,typeName:y.ZodTuple,rest:null,..._(e)})};class ge extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==h.object)return l(r,{code:d.invalid_type,expected:h.object,received:r.parsedType}),m;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in r.data)n.push({key:a._parse(new $(r,o,r.path,o)),value:i._parse(new $(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?T.mergeObjectAsync(t,n):T.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof v?new ge({keyType:e,valueType:t,typeName:y.ZodRecord,..._(r)}):new ge({keyType:R.create(),valueType:e,typeName:y.ZodRecord,..._(t)})}}class Ne extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==h.map)return l(r,{code:d.invalid_type,expected:h.map,received:r.parsedType}),m;const n=this._def.keyType,a=this._def.valueType,i=[...r.data.entries()].map(([o,c],u)=>({key:n._parse(new $(r,o,r.path,[u,"key"])),value:a._parse(new $(r,c,r.path,[u,"value"]))}));if(r.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 m;(u.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(u.value,p.value)}return{status:t.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 m;(u.status==="dirty"||p.status==="dirty")&&t.dirty(),o.set(u.value,p.value)}return{status:t.value,value:o}}}}Ne.create=(s,e,t)=>new Ne({valueType:e,keyType:s,typeName:y.ZodMap,..._(t)});class X extends v{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==h.set)return l(r,{code:d.invalid_type,expected:h.set,received:r.parsedType}),m;const n=this._def;n.minSize!==null&&r.data.size<n.minSize.value&&(l(r,{code:d.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&r.data.size>n.maxSize.value&&(l(r,{code:d.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const u=new Set;for(const p of c){if(p.status==="aborted")return m;p.status==="dirty"&&t.dirty(),u.add(p.value)}return{status:t.value,value:u}}const o=[...r.data.values()].map((c,u)=>a._parse(new $(r,c,r.path,u)));return r.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new X({...this._def,minSize:{value:e,message:f.toString(t)}})}max(e,t){return new X({...this._def,maxSize:{value:e,message:f.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}X.create=(s,e)=>new X({valueType:s,minSize:null,maxSize:null,typeName:y.ZodSet,..._(e)});class ae extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.function)return l(t,{code:d.invalid_type,expected:h.function,received:t.parsedType}),m;function r(o,c){return Ae({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Oe(),ie].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:c}})}function n(o,c){return Ae({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Oe(),ie].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof ce){const o=this;return S(async function(...c){const u=new O([]),p=await o._def.args.parseAsync(c,a).catch(w=>{throw u.addIssue(r(c,w)),u}),b=await Reflect.apply(i,this,p);return await o._def.returns._def.type.parseAsync(b,a).catch(w=>{throw u.addIssue(n(b,w)),u})})}else{const o=this;return S(function(...c){const u=o._def.args.safeParse(c,a);if(!u.success)throw new O([r(c,u.error)]);const p=Reflect.apply(i,this,u.data),b=o._def.returns.safeParse(p,a);if(!b.success)throw new O([n(p,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ae({...this._def,args:P.create(e).rest(Y.create())})}returns(e){return new ae({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new ae({args:e||P.create([]).rest(Y.create()),returns:t||Y.create(),typeName:y.ZodFunction,..._(r)})}}class ve extends v{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ve.create=(s,e)=>new ve({getter:s,typeName:y.ZodLazy,..._(e)});class xe extends v{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}xe.create=(s,e)=>new xe({value:s,typeName:y.ZodLiteral,..._(e)});function it(s,e){return new F({values:s,typeName:y.ZodEnum,..._(e)})}class F extends v{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return l(t,{expected:x.joinValues(r),received:t.parsedType,code:d.invalid_type}),m}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return l(t,{received:t.data,code:d.invalid_enum_value,options:r}),m}return S(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return F.create(e,{...this._def,...t})}exclude(e,t=this._def){return F.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}F.create=it;class be extends v{_parse(e){const t=x.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==h.string&&r.parsedType!==h.number){const n=x.objectValues(t);return l(r,{expected:x.joinValues(n),received:r.parsedType,code:d.invalid_type}),m}if(this._cache||(this._cache=new Set(x.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const n=x.objectValues(t);return l(r,{received:r.data,code:d.invalid_enum_value,options:n}),m}return S(e.data)}get enum(){return this._def.values}}be.create=(s,e)=>new be({values:s,typeName:y.ZodNativeEnum,..._(e)});class ce extends v{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.promise&&t.common.async===!1)return l(t,{code:d.invalid_type,expected:h.promise,received:t.parsedType}),m;const r=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return S(r.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ce.create=(s,e)=>new ce({type:s,typeName:y.ZodPromise,..._(e)});class N extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{l(r,i),i.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(r.data,a);if(r.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return m;const c=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return c.status==="aborted"?m:c.status==="dirty"||t.value==="dirty"?ne(c.value):c});{if(t.value==="aborted")return m;const o=this._def.schema._parseSync({data:i,path:r.path,parent:r});return o.status==="aborted"?m:o.status==="dirty"||t.value==="dirty"?ne(o.value):o}}if(n.type==="refinement"){const i=o=>{const c=n.refinement(o,a);if(r.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(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(r.common.async===!1){const i=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!K(i))return m;const o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(i=>K(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):m);x.assertNever(n)}}N.create=(s,e,t)=>new N({schema:s,typeName:y.ZodEffects,effect:e,..._(t)});N.createWithPreprocess=(s,e,t)=>new N({schema:e,effect:{type:"preprocess",transform:s},typeName:y.ZodEffects,..._(t)});class I extends v{_parse(e){return this._getType(e)===h.undefined?S(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}I.create=(s,e)=>new I({innerType:s,typeName:y.ZodOptional,..._(e)});class W extends v{_parse(e){return this._getType(e)===h.null?S(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}W.create=(s,e)=>new W({innerType:s,typeName:y.ZodNullable,..._(e)});class ke extends v{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===h.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ke.create=(s,e)=>new ke({innerType:s,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});class we extends v{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return he(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new O(r.common.issues)},input:r.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new O(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}we.create=(s,e)=>new we({innerType:s,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});class je extends v{_parse(e){if(this._getType(e)!==h.nan){const r=this._getOrReturnCtx(e);return l(r,{code:d.invalid_type,expected:h.nan,received:r.parsedType}),m}return{status:"valid",value:e.data}}}je.create=s=>new je({typeName:y.ZodNaN,..._(s)});const Vt=Symbol("zod_brand");class Ye extends v{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class Se extends v{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?m:a.status==="dirty"?(t.dirty(),ne(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const n=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return n.status==="aborted"?m:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:r.path,parent:r})}}static create(e,t){return new Se({in:e,out:t,typeName:y.ZodPipeline})}}class Te extends v{_parse(e){const t=this._def.innerType._parse(e),r=n=>(K(n)&&(n.value=Object.freeze(n.value)),n);return he(t)?t.then(n=>r(n)):r(t)}unwrap(){return this._def.innerType}}Te.create=(s,e)=>new Te({innerType:s,typeName:y.ZodReadonly,..._(e)});function Xe(s,e){const t=typeof s=="function"?s(e):typeof s=="string"?{message:s}:s;return typeof t=="string"?{message:t}:t}function ot(s,e={},t){return s?oe.create().superRefine((r,n)=>{const a=s(r);if(a instanceof Promise)return a.then(i=>{if(!i){const o=Xe(e,r),c=o.fatal??t??!0;n.addIssue({code:"custom",...o,fatal:c})}});if(!a){const i=Xe(e,r),o=i.fatal??t??!0;n.addIssue({code:"custom",...i,fatal:o})}}):oe.create()}const zt={object:k.lazycreate};var y;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(y||(y={}));const Bt=(s,e={message:`Input not instance of ${s.name}`})=>ot(t=>t instanceof s,e),g=R.create,Ke=U.create,Ut=je.create,qt=q.create,Ce=fe.create,Ft=G.create,Wt=Re.create,Jt=pe.create,Qt=me.create,Ht=oe.create,Yt=Y.create,Kt=z.create,Gt=Ee.create,A=E.create,j=k.create,Xt=k.strictCreate,es=ye.create,ts=$e.create,ss=_e.create,rs=P.create,ct=ge.create,ns=Ne.create,as=X.create,is=ae.create,os=ve.create,cs=xe.create,ds=F.create,us=be.create,ls=ce.create,et=N.create,hs=I.create,fs=W.create,ps=N.createWithPreprocess,ms=Se.create,ys=()=>g().optional(),_s=()=>Ke().optional(),gs=()=>Ce().optional(),vs={string:(s=>R.create({...s,coerce:!0})),number:(s=>U.create({...s,coerce:!0})),boolean:(s=>fe.create({...s,coerce:!0})),bigint:(s=>q.create({...s,coerce:!0})),date:(s=>G.create({...s,coerce:!0}))},xs=m,bs=Object.freeze(Object.defineProperty({__proto__:null,BRAND:Vt,DIRTY:ne,EMPTY_PATH:gt,INVALID:m,NEVER:xs,OK:S,ParseStatus:T,Schema:v,ZodAny:oe,ZodArray:E,ZodBigInt:q,ZodBoolean:fe,ZodBranded:Ye,ZodCatch:we,ZodDate:G,ZodDefault:ke,ZodDiscriminatedUnion:$e,ZodEffects:N,ZodEnum:F,ZodError:O,get ZodFirstPartyTypeKind(){return y},ZodFunction:ae,ZodIntersection:_e,ZodIssueCode:d,ZodLazy:ve,ZodLiteral:xe,ZodMap:Ne,ZodNaN:je,ZodNativeEnum:be,ZodNever:z,ZodNull:me,ZodNullable:W,ZodNumber:U,ZodObject:k,ZodOptional:I,ZodParsedType:h,ZodPipeline:Se,ZodPromise:ce,ZodReadonly:Te,ZodRecord:ge,ZodSchema:v,ZodSet:X,ZodString:R,ZodSymbol:Re,ZodTransformer:N,ZodTuple:P,ZodType:v,ZodUndefined:pe,ZodUnion:ye,ZodUnknown:Y,ZodVoid:Ee,addIssueToContext:l,any:Ht,array:A,bigint:qt,boolean:Ce,coerce:vs,custom:ot,date:Ft,datetimeRegex:at,defaultErrorMap:ie,discriminatedUnion:ts,effect:et,enum:ds,function:is,getErrorMap:Oe,getParsedType:V,instanceof:Bt,intersection:ss,isAborted:We,isAsync:he,isDirty:Je,isValid:K,late:zt,lazy:os,literal:cs,makeIssue:Ae,map:ns,nan:Ut,nativeEnum:us,never:Kt,null:Qt,nullable:fs,number:Ke,object:j,get objectUtil(){return Fe},oboolean:gs,onumber:_s,optional:hs,ostring:ys,pipeline:ms,preprocess:ps,promise:ls,quotelessJson:yt,record:ct,set:as,setErrorMap:_t,strictObject:Xt,string:g,symbol:Wt,transformer:et,tuple:rs,undefined:Jt,union:es,unknown:Yt,get util(){return x},void:Gt},Symbol.toStringTag,{value:"Module"}));mt(bs);const ks=(s,e)=>e.skipDedupe||e.method!=="GET",ws=(s,e)=>e.method+"@"+s,Ts=s=>s.clone(),Ss=({skip:s=ks,key:e=ws,resolver:t=Ts}={})=>{const r=new Map;return n=>(a,i)=>{if(s(a,i))return n(a,i);const o=e(a,i);if(!r.has(o))r.set(o,[]);else return new Promise((c,u)=>{r.get(o).push([c,u])});try{return n(a,i).then(c=>(r.get(o).forEach(([u])=>u(t(c))),r.delete(o),c)).catch(c=>{throw r.get(o).forEach(([,u])=>u(c)),r.delete(o),c})}catch(c){return r.delete(o),Promise.reject(c)}}},Cs=(s,e)=>s*e,Os=s=>s&&(s.ok||s.status>=400&&s.status<500),As=({delayTimer:s=500,delayRamp:e=Cs,maxAttempts:t=10,until:r=Os,onRetry:n=null,retryOnNetworkError:a=!1,resolveWithLatestResponse:i=!1,skip:o}={})=>c=>(u,p)=>{let b=0;if(o&&o(u,p))return c(u,p);const C=(w,Z)=>Promise.resolve(r(w,Z)).then(de=>de?w&&i?w:Z?Promise.reject(Z):w:(b++,!t||b<=t?new Promise(M=>{const J=e(s,b);setTimeout(()=>{typeof n=="function"?Promise.resolve(n({response:w,error:Z,url:u,attempt:b,options:p})).then((D={})=>{var ee,Q;M(c((ee=D&&D.url)!==null&&ee!==void 0?ee:u,(Q=D&&D.options)!==null&&Q!==void 0?Q:p))}):M(c(u,p))},J)}).then(C).catch(M=>{if(!a)throw M;return C(null,M)}):w&&i?w:Promise.reject(Z||new Error("Number of attempts exceeded."))));return c(u,p).then(C).catch(w=>{if(!a)throw w;return C(null,w)})},Ze=j({code:Ke(),message:g()}),Rs=j({message:g()}),Es=j({emails:A(g()).optional(),http_body:g().optional(),http_url:g().optional(),txt_name:g().optional(),txt_value:g().optional()}),Ns=j({ciphers:A(g()).optional(),early_hints:g().optional(),http2:g().optional(),min_tls_version:g().optional(),tls_1_3:g().optional()}),js=j({id:g(),bundle_method:g().optional(),certificate_authority:g(),custom_certificate:g().optional(),custom_csr_id:g().optional(),custom_key:g().optional(),expires_on:g().optional(),hosts:A(g()).optional(),issuer:g().optional(),method:g(),serial_number:g().optional(),settings:Ns.optional(),signature:g().optional(),type:g(),uploaded_on:g().optional(),validation_errors:A(Rs).optional(),validation_records:A(Es).optional(),wildcard:Ce()}),Zs=j({name:g(),type:g(),value:g()}),Is=j({http_body:g().optional(),http_url:g().optional()}),dt=j({id:g(),ssl:js,hostname:g(),custom_metadata:ct(g()).optional(),custom_origin_server:g().optional(),custom_origin_sni:g().optional(),ownership_verification:Zs.optional(),ownership_verification_http:Is.optional(),status:g(),verification_errors:A(g()).optional(),created_at:g()}),Ue=j({errors:A(Ze),messages:A(Ze),success:Ce(),result:dt}),$s=j({errors:A(Ze),messages:A(Ze),success:Ce(),result:A(dt)});function se(s){return ht(`https://api.cloudflare.com/client/v4/zones/${s.zoneId}`).headers({"X-Auth-Email":s.authEmail,"X-Auth-Key":s.authKey,"Content-Type":"application/json"}).middlewares([As(),Ss()])}function qe(s){const e=[];if(s.ssl.validation_records)for(const t of s.ssl.validation_records)t.txt_name&&t.txt_value&&e.push({name:"txt",record:t.txt_value,domain:t.txt_name});return s.ownership_verification&&e.push({name:"txt",record:s.ownership_verification.value,domain:s.ownership_verification.name}),{custom_domain_id:s.id,domain:s.hostname,primary:s.primary,status:s.status==="active"?"ready":"pending",type:"auth0_managed_certs",verification:{methods:A(lt.verificationMethodsSchema).parse(e)}}}function Ps(s){return{create:async(e,t)=>{const{result:r,errors:n,success:a}=Ue.parse(await se(s).post({hostname:t.domain,ssl:{method:"txt",type:"dv"},custom_metadata:s.enterprise?{tenant_id:e}:void 0},"/custom_hostnames").json());if(!a)throw new Error(JSON.stringify(n));const i=qe({...r,primary:!1});return await s.customDomainAdapter.create(e,{custom_domain_id:i.custom_domain_id,domain:i.domain,type:i.type}),i},get:async(e,t)=>{const r=await s.customDomainAdapter.get(e,t);if(!r)throw new te(404);const n=await se(s).get(`/custom_hostnames/${encodeURIComponent(t)}`).json(),{result:a,errors:i,success:o}=Ue.parse(n);if(!o)throw new te(503,{message:JSON.stringify(i)});if(s.enterprise&&a.custom_metadata?.tenant_id!==e)throw new te(404);return qe({...r,...a})},getByDomain:async e=>s.customDomainAdapter.getByDomain(e),list:async e=>{const t=await s.customDomainAdapter.list(e),r=await se(s).get("/custom_hostnames").json(),{result:n,errors:a,success:i}=$s.parse(r);if(!i)throw new te(503,{message:JSON.stringify(a)});return n.filter(o=>t.find(c=>c.custom_domain_id===o.id)).filter(o=>!(s.enterprise&&o.custom_metadata?.tenant_id!==e)).map(o=>qe({...t.find(c=>c.custom_domain_id===o.id),...o}))},remove:async(e,t)=>{if(s.enterprise){const{result:n,success:a}=Ue.parse(await se(s).get(`/custom_hostnames/${encodeURIComponent(t)}`).json());if(!a||n.custom_metadata?.tenant_id!==e)throw new te(404)}const r=await se(s).delete(`/custom_hostnames/${encodeURIComponent(t)}`).res();return r.ok&&await s.customDomainAdapter.remove(e,t),r.ok},update:async(e,t,r)=>{const n=await se(s).patch(r,`/custom_hostnames/${encodeURIComponent(t)}`).res();if(!n.ok)throw new te(503,{message:await n.text()});return s.customDomainAdapter.update(e,t,r)}}}class Ms{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 t=await this.getCache(),r=this.createRequest(e),n=await t.match(r);if(!n)return null;const a=await n.json();return a.expiresAt&&new Date(a.expiresAt)<new Date?(await this.delete(e),null):a.value}catch(t){return console.error(`CloudflareCache: get error for key ${e}:`,t),null}}async set(e,t,r){try{const n=await this.getCache(),a=r??this.config.defaultTtlSeconds,i=a!==void 0,o=i?Math.max(0,a):0,c={value:t,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 b=new Response(JSON.stringify(c),{headers:p});await n.put(u,b)}catch(n){console.error(`CloudflareCache: set error for key ${e}:`,n)}}async delete(e){try{const t=await this.getCache(),r=this.createRequest(e);return await t.delete(r)}catch(t){return console.error(`CloudflareCache: delete error for key ${e}:`,t),!1}}async clear(){console.warn("CloudflareCache.clear() is not implemented - Cloudflare Cache API does not support clearing all entries")}}function Ds(s={}){const e={defaultTtlSeconds:300,keyPrefix:"authhero",...s};return new Ms(e)}const Ls="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Vs=(s=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(s|=0));for(;s--;)e+=Ls[t[s]&63];return e};async function He(s,e){const t=s.timeout||3e4,r=new AbortController,n=setTimeout(()=>r.abort(),t);try{const a=`https://api.sql.cloudflarestorage.com/api/v1/accounts/${s.accountId}/r2-sql/query/${s.warehouseName}`,i=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s.authToken}`},body:JSON.stringify({query:e}),signal:r.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(n)}}function Ie(s){return`'${s.replace(/'/g,"''")}'`}function B(s){return`"${s.replace(/"/g,'""')}"`}function ut(s){const e=t=>{if(!t)return"";try{return JSON.parse(t)}catch{return t}};return{type:s.type,date:s.date,description:s.description,ip:s.ip,user_agent:s.user_agent,details:e(s.details),isMobile:!!s.isMobile,user_id:s.user_id,user_name:s.user_name,connection:s.connection,connection_id:s.connection_id,client_id:s.client_id,client_name:s.client_name,audience:s.audience,scope:s.scope?s.scope.split(","):void 0,strategy:s.strategy,strategy_type:s.strategy_type,hostname:s.hostname,auth0_client:e(s.auth0_client),log_id:s.id}}function zs(s){return async(e,t)=>{if(console.log("createLog called with config:",s),s.baseAdapter){const a=await s.baseAdapter.create(e,t);return(s.pipelineEndpoint||s.pipelineBinding)&&tt(s,e,a).catch(i=>{console.error("Failed to send log to Pipeline:",i)}),a}const r=t.log_id||Vs(),n={...t,log_id:r};return await tt(s,e,n),console.log("Log sent to Pipeline with ID:",r),n}}async function tt(s,e,t){const r=c=>c?JSON.stringify(c):void 0,n={id:t.log_id,tenant_id:e,type:t.type,date:t.date,description:t.description?.substring(0,256),ip:t.ip,user_agent:t.user_agent,details:r(t.details)?.substring(0,8192),isMobile:t.isMobile?1:0,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?.join(","),strategy:t.strategy,strategy_type:t.strategy_type,hostname:t.hostname,auth0_client:r(t.auth0_client),log_id:t.log_id},a=s.timeout||3e4,i=new AbortController,o=setTimeout(()=>i.abort(),a);try{let c;if(s.pipelineBinding)c=await s.pipelineBinding.fetch("https://pipeline",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([n]),signal:i.signal});else if(s.pipelineEndpoint)c=await fetch(s.pipelineEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([n]),signal:i.signal});else throw new Error("Either pipelineEndpoint or pipelineBinding must be configured");if(!c.ok)throw new Error(`Pipeline ingestion failed: ${c.status} ${c.statusText}`)}finally{clearTimeout(o)}}function Bs(s){return async(e,t)=>{if(s.baseAdapter)return s.baseAdapter.get(e,t);const r=s.namespace||"default",n=s.tableName||"logs",a=`
2
+ SELECT * FROM ${B(r)}.${B(n)}
3
+ WHERE tenant_id = ${Ie(e)}
4
+ AND id = ${Ie(t)}
5
+ LIMIT 1
6
+ `,i=await He(s,a);if(i.length===0)return null;const o=i[0];return o?ut(o):null}}function Us(s){const e={};return(s.match(/(\w+):(\S+)/g)||[]).forEach(r=>{const[n,a]=r.split(":");n&&a&&(e[n]=a)}),e}function qs(s){const e=[];for(const[t,r]of Object.entries(s)){const n=t.replace(/[^a-zA-Z0-9_]/g,"");n&&r&&e.push(`${B(n)} = ${Ie(r)}`)}return e}function Fs(s){return async(e,t={})=>{if(s.baseAdapter)return s.baseAdapter.list(e,t);const{page:r=0,per_page:n=50,include_totals:a=!1,sort:i,q:o}=t,c=s.namespace||"default",u=s.tableName||"logs",p=[`tenant_id = ${Ie(e)}`];if(o){const H=Us(o);p.push(...qs(H))}const b=p.join(" AND ");let C="ORDER BY date DESC";if(i&&i.sort_by){const H=i.sort_by.replace(/[^a-zA-Z0-9_]/g,""),ue=i.sort_order==="asc"?"ASC":"DESC";C=`ORDER BY ${B(H)} ${ue}`}const w=r*n,Z=`LIMIT ${n} OFFSET ${w}`,de=`
7
+ SELECT * FROM ${B(c)}.${B(u)}
8
+ WHERE ${b}
9
+ ${C}
10
+ ${Z}
11
+ `,J=(await He(s,de)).map(ut);if(!a)return{logs:J,start:0,limit:0,length:0};const D=`
12
+ SELECT COUNT(*) as count FROM ${B(c)}.${B(u)}
13
+ WHERE ${b}
14
+ `,Q=(await He(s,D))[0]?.count||0;return{logs:J,start:w,limit:n,length:Number(Q)}}}function Ws(s){const e=!!s.baseAdapter,t=!!s.pipelineEndpoint,r=!!s.pipelineBinding;if(!e&&!t&&!r)throw new Error('R2 SQL logs adapter requires one of: "baseAdapter", "pipelineEndpoint", or "pipelineBinding"');if(!e){if(!s.authToken)throw new Error('R2 SQL logs adapter requires "authToken" configuration');if(!s.warehouseName)throw new Error('R2 SQL logs adapter requires "warehouseName" configuration')}return{create:zs(s),list:Fs(s),get:Bs(s)}}function Js(s){const e={customDomains:Ps(s),cache:Ds({...s.cacheName&&{cacheName:s.cacheName},...s.defaultTtlSeconds!==void 0&&{defaultTtlSeconds:s.defaultTtlSeconds},...s.keyPrefix&&{keyPrefix:s.keyPrefix}})};return s.r2SqlLogs&&(e.logs=Ws(s.r2SqlLogs)),e}module.exports=Js;