@authhero/cloudflare-adapter 2.30.1 → 2.31.1

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.
Files changed (31) hide show
  1. package/dist/cloudflare-adapter.cjs +113 -50
  2. package/dist/cloudflare-adapter.d.ts +274 -1357
  3. package/dist/cloudflare-adapter.mjs +4311 -3430
  4. package/dist/tsconfig.types.tsbuildinfo +1 -0
  5. package/dist/types/analytics-engine-action-executions/actionExecutions.d.ts +8 -0
  6. package/dist/types/analytics-engine-action-executions/index.d.ts +29 -0
  7. package/dist/types/analytics-engine-action-executions/types.d.ts +29 -0
  8. package/dist/types/analytics-engine-logs/analytics.d.ts +3 -0
  9. package/dist/types/analytics-engine-logs/index.d.ts +53 -0
  10. package/dist/types/analytics-engine-logs/list.d.ts +10 -0
  11. package/dist/types/analytics-engine-logs/logs.d.ts +43 -0
  12. package/dist/types/analytics-engine-logs/query.d.ts +23 -0
  13. package/dist/types/analytics-engine-logs/stats.d.ts +6 -0
  14. package/dist/types/analytics-engine-logs/types.d.ts +39 -0
  15. package/dist/types/cache/index.d.ts +44 -0
  16. package/dist/types/code-executor/index.d.ts +106 -0
  17. package/dist/types/code-executor/worker-loader.d.ts +57 -0
  18. package/dist/types/code-executor/worker-template.d.ts +10 -0
  19. package/dist/types/customDomains/index.d.ts +3 -0
  20. package/dist/types/geo/index.d.ts +37 -0
  21. package/dist/types/index.d.ts +31 -0
  22. package/dist/types/r2-sql-logs/index.d.ts +60 -0
  23. package/dist/types/r2-sql-logs/list.d.ts +11 -0
  24. package/dist/types/r2-sql-logs/logs.d.ts +8 -0
  25. package/dist/types/r2-sql-logs/query.d.ts +13 -0
  26. package/dist/types/r2-sql-logs/stats.d.ts +8 -0
  27. package/dist/types/r2-sql-logs/types.d.ts +45 -0
  28. package/dist/types/rate-limit/index.d.ts +30 -0
  29. package/dist/types/types/CloudflareConfig.d.ts +47 -0
  30. package/dist/types/types/CustomDomain.d.ts +185 -0
  31. package/package.json +7 -7
@@ -1,69 +1,132 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const st=require("@authhero/adapter-interfaces"),Et=require("wretch");function Ct(t,e){var n={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(n[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(t);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(t,s[r])&&(n[s[r]]=t[s[r]]);return n}function Tt(t,e){var n;return((n=t?._def)===null||n===void 0?void 0:n.typeName)===e}function ce(t,e){const n=t.ZodType.prototype[e];t.ZodType.prototype[e]=function(...s){const r=n.apply(this,s);return r._def.openapi=this._def.openapi,r}}function At(t){if(typeof t.ZodType.prototype.openapi<"u")return;t.ZodType.prototype.openapi=function(r,a){var i,o,c,d,f,x;const T=typeof r=="string"?a:r,E=T??{},{param:A}=E,M=Ct(E,["param"]),k=Object.assign(Object.assign({},(i=this._def.openapi)===null||i===void 0?void 0:i._internal),typeof r=="string"?{refId:r}:void 0),P=Object.assign(Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o.metadata),M),!((d=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||d===void 0)&&d.param||A?{param:Object.assign(Object.assign({},(x=(f=this._def.openapi)===null||f===void 0?void 0:f.metadata)===null||x===void 0?void 0:x.param),A)}:void 0),O=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(k).length>0?{_internal:k}:void 0),Object.keys(P).length>0?{metadata:P}:void 0)}));if(Tt(this,"ZodObject")){const w=this.extend;O.extend=function(...S){var R,q,Ee,Ce,Te,Ae,Oe;const Ne=w.apply(this,S);return Ne._def.openapi={_internal:{extendedFrom:!((q=(R=this._def.openapi)===null||R===void 0?void 0:R._internal)===null||q===void 0)&&q.refId?{refId:(Ce=(Ee=this._def.openapi)===null||Ee===void 0?void 0:Ee._internal)===null||Ce===void 0?void 0:Ce.refId,schema:this}:(Ae=(Te=this._def.openapi)===null||Te===void 0?void 0:Te._internal)===null||Ae===void 0?void 0:Ae.extendedFrom},metadata:(Oe=Ne._def.openapi)===null||Oe===void 0?void 0:Oe.metadata},Ne}}return O},ce(t,"optional"),ce(t,"nullable"),ce(t,"default"),ce(t,"transform"),ce(t,"refine");const e=t.ZodObject.prototype.deepPartial;t.ZodObject.prototype.deepPartial=function(){const r=this._def.shape(),a=e.apply(this),i=a._def.shape();return Object.entries(i).forEach(([o,c])=>{var d,f;c._def.openapi=(f=(d=r[o])===null||d===void 0?void 0:d._def)===null||f===void 0?void 0:f.openapi}),a._def.openapi=void 0,a};const n=t.ZodObject.prototype.pick;t.ZodObject.prototype.pick=function(...r){const a=n.apply(this,r);return a._def.openapi=void 0,a};const s=t.ZodObject.prototype.omit;t.ZodObject.prototype.omit=function(...r){const a=s.apply(this,r);return a._def.openapi=void 0,a}}var ne=class extends Error{res;status;constructor(t=500,e){super(e?.message,{cause:e?.cause}),this.res=e?.res,this.status=t}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}};new Set(".\\+*[^]$()");var b;(function(t){t.assertEqual=r=>{};function e(r){}t.assertIs=e;function n(r){throw new Error}t.assertNever=n,t.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},t.getValidEnumValues=r=>{const a=t.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return t.objectValues(i)},t.objectValues=r=>t.objectKeys(r).map(function(a){return r[a]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},t.find=(r,a)=>{for(const i of r)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=s,t.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(b||(b={}));var Ie;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(Ie||(Ie={}));const h=b.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),V=t=>{switch(typeof t){case"undefined":return h.undefined;case"string":return h.string;case"number":return Number.isNaN(t)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(t)?h.array:t===null?h.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?h.promise:typeof Map<"u"&&t instanceof Map?h.map:typeof Set<"u"&&t instanceof Set?h.set:typeof Date<"u"&&t instanceof Date?h.date:h.object;default:return h.unknown}},u=b.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class U extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(a){return a.message},s={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)s._errors.push(n(i));else{let o=s,c=0;for(;c<i.path.length;){const d=i.path[c];c===i.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(n(i))):o[d]=o[d]||{_errors:[]},o=o[d],c++}}};return r(this),s}static assert(e){if(!(e instanceof U))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},s=[];for(const r of this.issues)if(r.path.length>0){const a=r.path[0];n[a]=n[a]||[],n[a].push(e(r))}else s.push(e(r));return{formErrors:s,fieldErrors:n}}get formErrors(){return this.flatten()}}U.create=t=>new U(t);const ye=(t,e)=>{let n;switch(t.code){case u.invalid_type:t.received===h.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case u.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,b.jsonStringifyReplacer)}`;break;case u.unrecognized_keys:n=`Unrecognized key(s) in object: ${b.joinValues(t.keys,", ")}`;break;case u.invalid_union:n="Invalid input";break;case u.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${b.joinValues(t.options)}`;break;case u.invalid_enum_value:n=`Invalid enum value. Expected ${b.joinValues(t.options)}, received '${t.received}'`;break;case u.invalid_arguments:n="Invalid function arguments";break;case u.invalid_return_type:n="Invalid function return type";break;case u.invalid_date:n="Invalid date";break;case u.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:b.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case u.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case u.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case u.custom:n="Invalid input";break;case u.invalid_intersection_types:n="Intersection results could not be merged";break;case u.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case u.not_finite:n="Number must be finite";break;default:n=e.defaultError,b.assertNever(t)}return{message:n}};let Ot=ye;function rt(){return Ot}const at=t=>{const{data:e,path:n,errorMaps:s,issueData:r}=t,a=[...n,...r.path||[]],i={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let o="";const c=s.filter(d=>!!d).slice().reverse();for(const d of c)o=d(i,{data:e,defaultError:o}).message;return{...r,path:a,message:o}};function l(t,e){const n=rt(),s=at({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===ye?void 0:ye].filter(r=>!!r)});t.common.issues.push(s)}class ${constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const s=[];for(const r of n){if(r.status==="aborted")return y;r.status==="dirty"&&e.dirty(),s.push(r.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,n){const s=[];for(const r of n){const a=await r.key,i=await r.value;s.push({key:a,value:i})}return $.mergeObjectSync(e,s)}static mergeObjectSync(e,n){const s={};for(const r of n){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return y;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const y=Object.freeze({status:"aborted"}),re=t=>({status:"dirty",value:t}),D=t=>({status:"valid",value:t}),je=t=>t.status==="aborted",De=t=>t.status==="dirty",K=t=>t.status==="valid",ue=t=>typeof Promise<"u"&&t instanceof Promise;var p;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}));class F{constructor(e,n,s,r){this._cachedPath=[],this.parent=e,this.data=n,this._path=s,this._key=r}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 Qe=(t,e)=>{if(K(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new U(t.common.issues);return this._error=n,this._error}}};function _(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:s,description:r}=t;if(e&&(n||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(i,o)=>{const{message:c}=t;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??n??o.defaultError}},description:r}}class v{get description(){return this._def.description}_getType(e){return V(e.data)}_getOrReturnCtx(e,n){return n||{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 $,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 n=this._parse(e);if(ue(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const s=this.safeParse(e,n);if(s.success)return s.data;throw s.error}safeParse(e,n){const s={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)},r=this._parseSync({data:e,path:s.path,parent:s});return Qe(s,r)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:n});return K(s)?{value:s.value}:{issues:n.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(s=>K(s)?{value:s.value}:{issues:n.common.issues})}async parseAsync(e,n){const s=await this.safeParseAsync(e,n);if(s.success)return s.data;throw s.error}async safeParseAsync(e,n){const s={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)},r=this._parse({data:e,path:s.path,parent:s}),a=await(ue(r)?r:Promise.resolve(r));return Qe(s,a)}refine(e,n){const s=r=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(r):n;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue({code:u.custom,...s(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,n){return this._refinement((s,r)=>e(s)?!0:(r.addIssue(typeof n=="function"?n(s,r):n),!1))}_refinement(e){return new Q({schema:this,typeName:m.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return z.create(this,this._def)}nullable(){return te.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return L.create(this)}promise(){return me.create(this,this._def)}or(e){return he.create([this,e],this._def)}and(e){return fe.create(this,e,this._def)}transform(e){return new Q({..._(this._def),schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new _e({..._(this._def),innerType:this,defaultValue:n,typeName:m.ZodDefault})}brand(){return new ut({typeName:m.ZodBranded,type:this,..._(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new ve({..._(this._def),innerType:this,catchValue:n,typeName:m.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return we.create(this,e)}readonly(){return be.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Nt=/^c[^\s-]{8,}$/i,$t=/^[0-9a-z]+$/,Rt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,It=/^[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,jt=/^[a-z0-9_-]{21}$/i,Dt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Lt=/^[-+]?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)?)??$/,Zt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Mt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let $e;const Pt=/^(?:(?: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])$/,Bt=/^(?:(?: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])$/,Ut=/^(([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]))$/,Ft=/^(([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])$/,qt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Vt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,it="((\\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(`^${it}$`);function ot(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function Wt(t){return new RegExp(`^${ot(t)}$`)}function ct(t){let e=`${it}T${ot(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Jt(t,e){return!!((e==="v4"||!e)&&Pt.test(t)||(e==="v6"||!e)&&Ut.test(t))}function Ht(t,e){if(!Dt.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(s));return!(typeof r!="object"||r===null||"typ"in r&&r?.typ!=="JWT"||!r.alg||e&&r.alg!==e)}catch{return!1}}function Qt(t,e){return!!((e==="v4"||!e)&&Bt.test(t)||(e==="v6"||!e)&&Ft.test(t))}class B 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:u.invalid_type,expected:h.string,received:a.parsedType}),y}const s=new $;let r;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:u.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&&(r=this._getOrReturnCtx(e,r),l(r,{code:u.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)&&(r=this._getOrReturnCtx(e,r),i?l(r,{code:u.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(r,{code:u.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")Zt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"email",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")$e||($e=new RegExp(Mt,"u")),$e.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"emoji",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")It.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"uuid",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")jt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"nanoid",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")Nt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cuid",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")$t.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cuid2",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")Rt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"ulid",code:u.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),l(r,{validation:"url",code:u.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"regex",code:u.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)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.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)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?ct(a).test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?zt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?Wt(a).test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:u.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Lt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"duration",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?Jt(e.data,a.version)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"ip",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?Ht(e.data,a.alg)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"jwt",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?Qt(e.data,a.version)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cidr",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?qt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"base64",code:u.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Vt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"base64url",code:u.invalid_string,message:a.message}),s.dirty()):b.assertNever(a);return{status:s.value,value:e.data}}_regex(e,n,s){return this.refinement(r=>e.test(r),{validation:n,code:u.invalid_string,...p.errToObj(s)})}_addCheck(e){return new B({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...p.errToObj(e)})}url(e){return this._addCheck({kind:"url",...p.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...p.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...p.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...p.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...p.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...p.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...p.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...p.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...p.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...p.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...p.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...p.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,...p.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,...p.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...p.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...p.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...p.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...p.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...p.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...p.errToObj(n)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new B({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new B({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new B({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}B.create=t=>new B({checks:[],typeName:m.ZodString,coerce:t?.coerce??!1,..._(t)});function Yt(t,e){const n=(t.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,r=n>s?n:s,a=Number.parseInt(t.toFixed(r).replace(".","")),i=Number.parseInt(e.toFixed(r).replace(".",""));return a%i/10**r}class X 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:u.invalid_type,expected:h.number,received:a.parsedType}),y}let s;const r=new $;for(const a of this._def.checks)a.kind==="int"?b.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?Yt(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:u.not_finite,message:a.message}),r.dirty()):b.assertNever(a);return{status:r.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,p.toString(n))}gt(e,n){return this.setLimit("min",e,!1,p.toString(n))}lte(e,n){return this.setLimit("max",e,!0,p.toString(n))}lt(e,n){return this.setLimit("max",e,!1,p.toString(n))}setLimit(e,n,s,r){return new X({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:s,message:p.toString(r)}]})}_addCheck(e){return new X({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:p.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:p.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:p.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:p.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:p.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&b.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(n===null||s.value>n)&&(n=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(n)&&Number.isFinite(e)}}X.create=t=>new X({checks:[],typeName:m.ZodNumber,coerce:t?.coerce||!1,..._(t)});class ae extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==h.bigint)return this._getInvalidInput(e);let s;const r=new $;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:u.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),l(s,{code:u.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):b.assertNever(a);return{status:r.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:h.bigint,received:n.parsedType}),y}gte(e,n){return this.setLimit("min",e,!0,p.toString(n))}gt(e,n){return this.setLimit("min",e,!1,p.toString(n))}lte(e,n){return this.setLimit("max",e,!0,p.toString(n))}lt(e,n){return this.setLimit("max",e,!1,p.toString(n))}setLimit(e,n,s,r){return new ae({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:s,message:p.toString(r)}]})}_addCheck(e){return new ae({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:p.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:p.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:p.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:p.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ae.create=t=>new ae({checks:[],typeName:m.ZodBigInt,coerce:t?.coerce??!1,..._(t)});class ge extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:h.boolean,received:s.parsedType}),y}return D(e.data)}}ge.create=t=>new ge({typeName:m.ZodBoolean,coerce:t?.coerce||!1,..._(t)});class le 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:u.invalid_type,expected:h.date,received:a.parsedType}),y}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:u.invalid_date}),y}const s=new $;let r;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:u.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:u.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):b.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new le({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}le.create=t=>new le({checks:[],coerce:t?.coerce||!1,typeName:m.ZodDate,..._(t)});class Le extends v{_parse(e){if(this._getType(e)!==h.symbol){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:h.symbol,received:s.parsedType}),y}return D(e.data)}}Le.create=t=>new Le({typeName:m.ZodSymbol,..._(t)});class Ze extends v{_parse(e){if(this._getType(e)!==h.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:h.undefined,received:s.parsedType}),y}return D(e.data)}}Ze.create=t=>new Ze({typeName:m.ZodUndefined,..._(t)});class Me extends v{_parse(e){if(this._getType(e)!==h.null){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:h.null,received:s.parsedType}),y}return D(e.data)}}Me.create=t=>new Me({typeName:m.ZodNull,..._(t)});class Pe extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return D(e.data)}}Pe.create=t=>new Pe({typeName:m.ZodAny,..._(t)});class Be extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return D(e.data)}}Be.create=t=>new Be({typeName:m.ZodUnknown,..._(t)});class W extends v{_parse(e){const n=this._getOrReturnCtx(e);return l(n,{code:u.invalid_type,expected:h.never,received:n.parsedType}),y}}W.create=t=>new W({typeName:m.ZodNever,..._(t)});class Ue extends v{_parse(e){if(this._getType(e)!==h.undefined){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:h.void,received:s.parsedType}),y}return D(e.data)}}Ue.create=t=>new Ue({typeName:m.ZodVoid,..._(t)});class L extends v{_parse(e){const{ctx:n,status:s}=this._processInputParams(e),r=this._def;if(n.parsedType!==h.array)return l(n,{code:u.invalid_type,expected:h.array,received:n.parsedType}),y;if(r.exactLength!==null){const i=n.data.length>r.exactLength.value,o=n.data.length<r.exactLength.value;(i||o)&&(l(n,{code:i?u.too_big:u.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&n.data.length<r.minLength.value&&(l(n,{code:u.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&n.data.length>r.maxLength.value&&(l(n,{code:u.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),n.common.async)return Promise.all([...n.data].map((i,o)=>r.type._parseAsync(new F(n,i,n.path,o)))).then(i=>$.mergeArray(s,i));const a=[...n.data].map((i,o)=>r.type._parseSync(new F(n,i,n.path,o)));return $.mergeArray(s,a)}get element(){return this._def.type}min(e,n){return new L({...this._def,minLength:{value:e,message:p.toString(n)}})}max(e,n){return new L({...this._def,maxLength:{value:e,message:p.toString(n)}})}length(e,n){return new L({...this._def,exactLength:{value:e,message:p.toString(n)}})}nonempty(e){return this.min(1,e)}}L.create=(t,e)=>new L({type:t,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,..._(e)});function se(t){if(t instanceof C){const e={};for(const n in t.shape){const s=t.shape[n];e[n]=z.create(se(s))}return new C({...t._def,shape:()=>e})}else return t instanceof L?new L({...t._def,type:se(t.element)}):t instanceof z?z.create(se(t.unwrap())):t instanceof te?te.create(se(t.unwrap())):t instanceof H?H.create(t.items.map(e=>se(e))):t}class C extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=b.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==h.object){const d=this._getOrReturnCtx(e);return l(d,{code:u.invalid_type,expected:h.object,received:d.parsedType}),y}const{status:s,ctx:r}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof W&&this._def.unknownKeys==="strip"))for(const d in r.data)i.includes(d)||o.push(d);const c=[];for(const d of i){const f=a[d],x=r.data[d];c.push({key:{status:"valid",value:d},value:f._parse(new F(r,x,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof W){const d=this._def.unknownKeys;if(d==="passthrough")for(const f of o)c.push({key:{status:"valid",value:f},value:{status:"valid",value:r.data[f]}});else if(d==="strict")o.length>0&&(l(r,{code:u.unrecognized_keys,keys:o}),s.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const f of o){const x=r.data[f];c.push({key:{status:"valid",value:f},value:d._parse(new F(r,x,r.path,f)),alwaysSet:f in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const d=[];for(const f of c){const x=await f.key,T=await f.value;d.push({key:x,value:T,alwaysSet:f.alwaysSet})}return d}).then(d=>$.mergeObjectSync(s,d)):$.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new C({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,s)=>{const r=this._def.errorMap?.(n,s).message??s.defaultError;return n.code==="unrecognized_keys"?{message:p.errToObj(e).message??r}:{message:r}}}:{}})}strip(){return new C({...this._def,unknownKeys:"strip"})}passthrough(){return new C({...this._def,unknownKeys:"passthrough"})}extend(e){return new C({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new C({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:m.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new C({...this._def,catchall:e})}pick(e){const n={};for(const s of b.objectKeys(e))e[s]&&this.shape[s]&&(n[s]=this.shape[s]);return new C({...this._def,shape:()=>n})}omit(e){const n={};for(const s of b.objectKeys(this.shape))e[s]||(n[s]=this.shape[s]);return new C({...this._def,shape:()=>n})}deepPartial(){return se(this)}partial(e){const n={};for(const s of b.objectKeys(this.shape)){const r=this.shape[s];e&&!e[s]?n[s]=r:n[s]=r.optional()}return new C({...this._def,shape:()=>n})}required(e){const n={};for(const s of b.objectKeys(this.shape))if(e&&!e[s])n[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof z;)a=a._def.innerType;n[s]=a}return new C({...this._def,shape:()=>n})}keyof(){return dt(b.objectKeys(this.shape))}}C.create=(t,e)=>new C({shape:()=>t,unknownKeys:"strip",catchall:W.create(),typeName:m.ZodObject,..._(e)});C.strictCreate=(t,e)=>new C({shape:()=>t,unknownKeys:"strict",catchall:W.create(),typeName:m.ZodObject,..._(e)});C.lazycreate=(t,e)=>new C({shape:t,unknownKeys:"strip",catchall:W.create(),typeName:m.ZodObject,..._(e)});class he extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s=this._def.options;function r(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 n.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new U(o.ctx.common.issues));return l(n,{code:u.invalid_union,unionErrors:i}),y}if(n.common.async)return Promise.all(s.map(async a=>{const i={...n,common:{...n.common,issues:[]},parent:null};return{result:await a._parseAsync({data:n.data,path:n.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const c of s){const d={...n,common:{...n.common,issues:[]},parent:null},f=c._parseSync({data:n.data,path:n.path,parent:d});if(f.status==="valid")return f;f.status==="dirty"&&!a&&(a={result:f,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(a)return n.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new U(c));return l(n,{code:u.invalid_union,unionErrors:o}),y}}get options(){return this._def.options}}he.create=(t,e)=>new he({options:t,typeName:m.ZodUnion,..._(e)});function Fe(t,e){const n=V(t),s=V(e);if(t===e)return{valid:!0,data:t};if(n===h.object&&s===h.object){const r=b.objectKeys(e),a=b.objectKeys(t).filter(o=>r.indexOf(o)!==-1),i={...t,...e};for(const o of a){const c=Fe(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(n===h.array&&s===h.array){if(t.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<t.length;a++){const i=t[a],o=e[a],c=Fe(i,o);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===h.date&&s===h.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class fe extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e),r=(a,i)=>{if(je(a)||je(i))return y;const o=Fe(a.value,i.value);return o.valid?((De(a)||De(i))&&n.dirty(),{status:n.value,value:o.data}):(l(s,{code:u.invalid_intersection_types}),y)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>r(a,i)):r(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=(t,e,n)=>new fe({left:t,right:e,typeName:m.ZodIntersection,..._(n)});class H extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.array)return l(s,{code:u.invalid_type,expected:h.array,received:s.parsedType}),y;if(s.data.length<this._def.items.length)return l(s,{code:u.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&s.data.length>this._def.items.length&&(l(s,{code:u.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const a=[...s.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new F(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>$.mergeArray(n,i)):$.mergeArray(n,a)}get items(){return this._def.items}rest(e){return new H({...this._def,rest:e})}}H.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new H({items:t,typeName:m.ZodTuple,rest:null,..._(e)})};class pe extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.object)return l(s,{code:u.invalid_type,expected:h.object,received:s.parsedType}),y;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)r.push({key:a._parse(new F(s,o,s.path,o)),value:i._parse(new F(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?$.mergeObjectAsync(n,r):$.mergeObjectSync(n,r)}get element(){return this._def.valueType}static create(e,n,s){return n instanceof v?new pe({keyType:e,valueType:n,typeName:m.ZodRecord,..._(s)}):new pe({keyType:B.create(),valueType:e,typeName:m.ZodRecord,..._(n)})}}class qe extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.map)return l(s,{code:u.invalid_type,expected:h.map,received:s.parsedType}),y;const r=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],d)=>({key:r._parse(new F(s,o,s.path,[d,"key"])),value:a._parse(new F(s,c,s.path,[d,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const d=await c.key,f=await c.value;if(d.status==="aborted"||f.status==="aborted")return y;(d.status==="dirty"||f.status==="dirty")&&n.dirty(),o.set(d.value,f.value)}return{status:n.value,value:o}})}else{const o=new Map;for(const c of i){const d=c.key,f=c.value;if(d.status==="aborted"||f.status==="aborted")return y;(d.status==="dirty"||f.status==="dirty")&&n.dirty(),o.set(d.value,f.value)}return{status:n.value,value:o}}}}qe.create=(t,e,n)=>new qe({valueType:e,keyType:t,typeName:m.ZodMap,..._(n)});class ie extends v{_parse(e){const{status:n,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.set)return l(s,{code:u.invalid_type,expected:h.set,received:s.parsedType}),y;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(l(s,{code:u.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),n.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(l(s,{code:u.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),n.dirty());const a=this._def.valueType;function i(c){const d=new Set;for(const f of c){if(f.status==="aborted")return y;f.status==="dirty"&&n.dirty(),d.add(f.value)}return{status:n.value,value:d}}const o=[...s.data.values()].map((c,d)=>a._parse(new F(s,c,s.path,d)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,n){return new ie({...this._def,minSize:{value:e,message:p.toString(n)}})}max(e,n){return new ie({...this._def,maxSize:{value:e,message:p.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}ie.create=(t,e)=>new ie({valueType:t,minSize:null,maxSize:null,typeName:m.ZodSet,..._(e)});class Ve extends v{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Ve.create=(t,e)=>new Ve({getter:t,typeName:m.ZodLazy,..._(e)});class ze extends v{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return l(n,{received:n.data,code:u.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}}ze.create=(t,e)=>new ze({value:t,typeName:m.ZodLiteral,..._(e)});function dt(t,e){return new ee({values:t,typeName:m.ZodEnum,..._(e)})}class ee extends v{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),s=this._def.values;return l(n,{expected:b.joinValues(s),received:n.parsedType,code:u.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),s=this._def.values;return l(n,{received:n.data,code:u.invalid_enum_value,options:s}),y}return D(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return ee.create(e,{...this._def,...n})}exclude(e,n=this._def){return ee.create(this.options.filter(s=>!e.includes(s)),{...this._def,...n})}}ee.create=dt;class We extends v{_parse(e){const n=b.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==h.string&&s.parsedType!==h.number){const r=b.objectValues(n);return l(s,{expected:b.joinValues(r),received:s.parsedType,code:u.invalid_type}),y}if(this._cache||(this._cache=new Set(b.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const r=b.objectValues(n);return l(s,{received:s.data,code:u.invalid_enum_value,options:r}),y}return D(e.data)}get enum(){return this._def.values}}We.create=(t,e)=>new We({values:t,typeName:m.ZodNativeEnum,..._(e)});class me extends v{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==h.promise&&n.common.async===!1)return l(n,{code:u.invalid_type,expected:h.promise,received:n.parsedType}),y;const s=n.parsedType===h.promise?n.data:Promise.resolve(n.data);return D(s.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}me.create=(t,e)=>new me({type:t,typeName:m.ZodPromise,..._(e)});class Q extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===m.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:s}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{l(s,i),i.fatal?n.abort():n.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(n.value==="aborted")return y;const c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?y:c.status==="dirty"||n.value==="dirty"?re(c.value):c});{if(n.value==="aborted")return y;const o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?y:o.status==="dirty"||n.value==="dirty"?re(o.value):o}}if(r.type==="refinement"){const i=o=>{const c=r.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"?y:(o.status==="dirty"&&n.dirty(),i(o.value),{status:n.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?y:(o.status==="dirty"&&n.dirty(),i(o.value).then(()=>({status:n.value,value:o.value}))))}if(r.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!K(i))return y;const o=r.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>K(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:n.value,value:o})):y);b.assertNever(r)}}Q.create=(t,e,n)=>new Q({schema:t,typeName:m.ZodEffects,effect:e,..._(n)});Q.createWithPreprocess=(t,e,n)=>new Q({schema:e,effect:{type:"preprocess",transform:t},typeName:m.ZodEffects,..._(n)});class z extends v{_parse(e){return this._getType(e)===h.undefined?D(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}z.create=(t,e)=>new z({innerType:t,typeName:m.ZodOptional,..._(e)});class te extends v{_parse(e){return this._getType(e)===h.null?D(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}te.create=(t,e)=>new te({innerType:t,typeName:m.ZodNullable,..._(e)});class _e extends v{_parse(e){const{ctx:n}=this._processInputParams(e);let s=n.data;return n.parsedType===h.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}_e.create=(t,e)=>new _e({innerType:t,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});class ve extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s={...n,common:{...n.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ue(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new U(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new U(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}ve.create=(t,e)=>new ve({innerType:t,typeName:m.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});class Je extends v{_parse(e){if(this._getType(e)!==h.nan){const s=this._getOrReturnCtx(e);return l(s,{code:u.invalid_type,expected:h.nan,received:s.parsedType}),y}return{status:"valid",value:e.data}}}Je.create=t=>new Je({typeName:m.ZodNaN,..._(t)});class ut extends v{_parse(e){const{ctx:n}=this._processInputParams(e),s=n.data;return this._def.type._parse({data:s,path:n.path,parent:n})}unwrap(){return this._def.type}}class we extends v{_parse(e){const{status:n,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"?y:a.status==="dirty"?(n.dirty(),re(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{const r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?y:r.status==="dirty"?(n.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(e,n){return new we({in:e,out:n,typeName:m.ZodPipeline})}}class be extends v{_parse(e){const n=this._def.innerType._parse(e),s=r=>(K(r)&&(r.value=Object.freeze(r.value)),r);return ue(n)?n.then(r=>s(r)):s(n)}unwrap(){return this._def.innerType}}be.create=(t,e)=>new be({innerType:t,typeName:m.ZodReadonly,..._(e)});var m;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(m||(m={}));const g=B.create,lt=X.create,Se=ge.create;W.create;const j=L.create,Z=C.create;he.create;fe.create;H.create;const ht=pe.create;ee.create;me.create;z.create;te.create;const Gt=Object.freeze(Object.defineProperty({__proto__:null,DIRTY:re,INVALID:y,OK:D,ParseStatus:$,Schema:v,ZodAny:Pe,ZodArray:L,ZodBigInt:ae,ZodBoolean:ge,ZodBranded:ut,ZodCatch:ve,ZodDate:le,ZodDefault:_e,ZodEffects:Q,ZodEnum:ee,ZodError:U,get ZodFirstPartyTypeKind(){return m},ZodIntersection:fe,ZodIssueCode:u,ZodLazy:Ve,ZodLiteral:ze,ZodMap:qe,ZodNaN:Je,ZodNativeEnum:We,ZodNever:W,ZodNull:Me,ZodNullable:te,ZodNumber:X,ZodObject:C,ZodOptional:z,ZodParsedType:h,ZodPipeline:we,ZodPromise:me,ZodReadonly:be,ZodRecord:pe,ZodSchema:v,ZodSet:ie,ZodString:B,ZodSymbol:Le,ZodTransformer:Q,ZodTuple:H,ZodType:v,ZodUndefined:Ze,ZodUnion:he,ZodUnknown:Be,ZodVoid:Ue,addIssueToContext:l,array:j,boolean:Se,datetimeRegex:ct,defaultErrorMap:ye,getErrorMap:rt,getParsedType:V,isAborted:je,isAsync:ue,isDirty:De,isValid:K,makeIssue:at,number:lt,object:Z,get objectUtil(){return Ie},record:ht,string:g,get util(){return b}},Symbol.toStringTag,{value:"Module"}));At(Gt);const Kt=(t,e)=>e.skipDedupe||e.method!=="GET",Xt=(t,e)=>e.method+"@"+t,en=t=>t.clone(),tn=({skip:t=Kt,key:e=Xt,resolver:n=en}={})=>{const s=new Map;return r=>(a,i)=>{if(t(a,i))return r(a,i);const o=e(a,i);if(!s.has(o))s.set(o,[]);else return new Promise((c,d)=>{s.get(o).push([c,d])});try{return r(a,i).then(c=>(s.get(o).forEach(([d])=>d(n(c))),s.delete(o),c)).catch(c=>{throw s.get(o).forEach(([,d])=>d(c)),s.delete(o),c})}catch(c){return s.delete(o),Promise.reject(c)}}},nn=(t,e)=>t*e,sn=t=>t&&(t.ok||t.status>=400&&t.status<500),rn=({delayTimer:t=500,delayRamp:e=nn,maxAttempts:n=10,until:s=sn,onRetry:r=null,retryOnNetworkError:a=!1,resolveWithLatestResponse:i=!1,skip:o}={})=>c=>(d,f)=>{let x=0;if(o&&o(d,f))return c(d,f);const T=(E,A)=>Promise.resolve(s(E,A)).then(M=>M?E&&i?E:A?Promise.reject(A):E:(x++,!n||x<=n?new Promise(k=>{const P=e(t,x);setTimeout(()=>{typeof r=="function"?Promise.resolve(r({response:E,error:A,url:d,attempt:x,options:f})).then((O={})=>{var w,S;k(c((w=O&&O.url)!==null&&w!==void 0?w:d,(S=O&&O.options)!==null&&S!==void 0?S:f))}):k(c(d,f))},P)}).then(T).catch(k=>{if(!a)throw k;return T(null,k)}):E&&i?E:Promise.reject(A||new Error("Number of attempts exceeded."))));return c(d,f).then(T).catch(E=>{if(!a)throw E;return T(null,E)})},xe=Z({code:lt(),message:g()}),an=Z({message:g()}),on=Z({emails:j(g()).optional(),http_body:g().optional(),http_url:g().optional(),txt_name:g().optional(),txt_value:g().optional()}),cn=Z({ciphers:j(g()).optional(),early_hints:g().optional(),http2:g().optional(),min_tls_version:g().optional(),tls_1_3:g().optional()}),dn=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:j(g()).optional(),issuer:g().optional(),method:g(),serial_number:g().optional(),settings:cn.optional(),signature:g().optional(),type:g(),uploaded_on:g().optional(),validation_errors:j(an).optional(),validation_records:j(on).optional(),wildcard:Se()}),un=Z({name:g(),type:g(),value:g()}),ln=Z({http_body:g().optional(),http_url:g().optional()}),ft=Z({id:g(),ssl:dn,hostname:g(),custom_metadata:ht(g()).optional(),custom_origin_server:g().optional(),custom_origin_sni:g().optional(),ownership_verification:un.optional(),ownership_verification_http:ln.optional(),status:g(),verification_errors:j(g()).optional(),created_at:g()}),de=Z({errors:j(xe),messages:j(xe),success:Se(),result:ft});Z({errors:j(xe),messages:j(xe),success:Se(),result:j(ft)});function Y(t){return Et(`https://api.cloudflare.com/client/v4/zones/${t.zoneId}`).headers({"X-Auth-Email":t.authEmail,"X-Auth-Key":t.authKey,"Content-Type":"application/json"}).middlewares([rn(),tn()])}function Ye(t){const e={},n={};if(!t)return{sslOverrides:e,rest:n};for(const[s,r]of Object.entries(t))s.startsWith("ssl.")?e[s.slice(4)]=r:n[s]=r;return{sslOverrides:e,rest:n}}function Re(t){const e=[];if(t.ssl.validation_records)for(const s of t.ssl.validation_records)s.txt_name&&s.txt_value&&e.push({name:"txt",record:s.txt_value,domain:s.txt_name});if(t.ownership_verification&&e.push({name:"txt",record:t.ownership_verification.value,domain:t.ownership_verification.name}),t.ownership_verification_http?.http_body&&t.ownership_verification_http?.http_url&&e.push({name:"http",http_body:t.ownership_verification_http.http_body,http_url:t.ownership_verification_http.http_url}),t.ssl.validation_records)for(const s of t.ssl.validation_records)s.http_body&&s.http_url&&e.push({name:"http",http_body:s.http_body,http_url:s.http_url});const n={...t.domain_metadata||{},"ssl.method":t.ssl.method,"ssl.type":t.ssl.type,"ssl.certificate_authority":t.ssl.certificate_authority};return{custom_domain_id:t.id,domain:t.hostname,primary:t.primary,status:t.status==="active"?"ready":"pending",type:"auth0_managed_certs",verification:{methods:j(st.verificationMethodsSchema).parse(e)},domain_metadata:n}}function hn(t){return{create:async(e,n)=>{const{sslOverrides:s,rest:r}=Ye(n.domain_metadata),{result:a,errors:i,success:o}=de.parse(await Y(t).post({hostname:n.domain,ssl:{method:"txt",type:"dv",...s},custom_metadata:t.enterprise?{tenant_id:e}:void 0},"/custom_hostnames").json());if(!o)throw new Error(JSON.stringify(i));const c=Re({...a,primary:!1,domain_metadata:r});return await t.customDomainAdapter.create(e,{custom_domain_id:c.custom_domain_id,domain:c.domain,type:c.type,domain_metadata:n.domain_metadata}),c},get:async(e,n)=>{const s=await t.customDomainAdapter.get(e,n);if(!s)throw new ne(404);const r=await Y(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(),{result:a,errors:i,success:o}=de.parse(r);if(!o)throw new ne(503,{message:JSON.stringify(i)});if(t.enterprise&&a.custom_metadata?.tenant_id!==e)throw new ne(404);return Re({...s,...a})},getByDomain:async e=>t.customDomainAdapter.getByDomain(e),list:async e=>{const n=await t.customDomainAdapter.list(e);return(await Promise.all(n.map(async r=>{try{const a=await Y(t).get(`/custom_hostnames/${encodeURIComponent(r.custom_domain_id)}`).json(),{result:i,success:o}=de.parse(a);return!o||t.enterprise&&i.custom_metadata?.tenant_id!==e?null:Re({...r,...i})}catch{return null}}))).filter(r=>r!==null)},remove:async(e,n)=>{if(t.enterprise){const{result:r,success:a}=de.parse(await Y(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json());if(!a||r.custom_metadata?.tenant_id!==e)throw new ne(404)}const s=await Y(t).delete(`/custom_hostnames/${encodeURIComponent(n)}`).res();return s.ok&&await t.customDomainAdapter.remove(e,n),s.ok},update:async(e,n,s)=>{const{sslOverrides:r}=Ye(s.domain_metadata),a={};if(Object.keys(r).length>0){const i=await Y(t).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(),{result:o,success:c}=de.parse(i);if(!c)throw new ne(503,{message:"Failed to fetch current custom hostname state"});a.ssl={method:o.ssl.method,type:o.ssl.type,certificate_authority:o.ssl.certificate_authority,...r}}if(Object.keys(a).length>0){const i=await Y(t).patch(a,`/custom_hostnames/${encodeURIComponent(n)}`).res();if(!i.ok)throw new ne(503,{message:await i.text()})}return t.customDomainAdapter.update(e,n,s)}}}class fn{constructor(e){this.config=e}config;cache=null;async getCache(){if(this.cache)return this.cache;if(typeof caches>"u")throw new Error("caches API is not available - CloudflareCache should only be used in Cloudflare Workers");return this.config.cacheName?this.cache=await caches.open(this.config.cacheName):this.cache=caches.default,this.cache}getKey(e){return this.config.keyPrefix?`${this.config.keyPrefix}:${e}`:e}createRequest(e){return new Request(`https://cache.internal/${this.getKey(e)}`)}async get(e){try{const n=await this.getCache(),s=this.createRequest(e),r=await n.match(s);if(!r)return null;const a=await r.text();if(!a)return await this.delete(e),null;let i;try{i=JSON.parse(a)}catch{return await this.delete(e),null}return i.expiresAt&&new Date(i.expiresAt)<new Date?(await this.delete(e),null):i.value}catch(n){return console.error(`CloudflareCache: get error for key ${e}:`,n),null}}async set(e,n,s){try{const r=await this.getCache(),a=s??this.config.defaultTtlSeconds,i=a!==void 0,o=i?Math.max(0,a):0,c={value:n,expiresAt:i?new Date(Date.now()+(o>0?o*1e3:-1)).toISOString():void 0,cachedAt:new Date().toISOString()},d=this.createRequest(e),f={"Content-Type":"application/json"};i&&o>0&&(f["Cache-Control"]=`max-age=${o}`);const x=new Response(JSON.stringify(c),{headers:f});await r.put(d,x)}catch(r){console.error(`CloudflareCache: set error for key ${e}:`,r)}}async delete(e){try{const n=await this.getCache(),s=this.createRequest(e);return await n.delete(s)}catch(n){return console.error(`CloudflareCache: delete error for key ${e}:`,n),!1}}async deleteByPrefix(e){return console.warn("CloudflareCache.deleteByPrefix() is not implemented - Cloudflare Cache API does not support prefix-based deletion"),0}async clear(){console.warn("CloudflareCache.clear() is not implemented - Cloudflare Cache API does not support clearing all entries")}}function pn(t={}){const e={defaultTtlSeconds:300,keyPrefix:"authhero",...t};return new fn(e)}let mn="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",pt=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=mn[n[t]&63];return e};async function He(t,e){const n=t.timeout||3e4,s=new AbortController,r=setTimeout(()=>s.abort(),n);try{const a=`https://api.sql.cloudflarestorage.com/api/v1/accounts/${t.accountId}/r2-sql/query/${t.warehouseName}`,i=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.authToken}`},body:JSON.stringify({query:e}),signal:s.signal});if(!i.ok)throw new Error(`R2 SQL query failed: ${i.status} ${i.statusText}`);const o=await i.json();if(!o.success&&o.errors)throw new Error(`R2 SQL error: ${o.errors.join(", ")}`);return o.data||o.result?.data||[]}finally{clearTimeout(r)}}function ke(t){return`'${t.replace(/'/g,"''")}'`}function J(t){return`"${t.replace(/"/g,'""')}"`}function mt(t){const e=n=>{if(!n)return"";try{return JSON.parse(n)}catch{return n}};return{type:t.type,date:t.date,description:t.description,ip:t.ip,user_agent:t.user_agent,details:e(t.details),isMobile:!!t.isMobile,user_id:t.user_id,user_name:t.user_name,connection:t.connection,connection_id:t.connection_id,client_id:t.client_id,client_name:t.client_name,audience:t.audience,scope:t.scope,strategy:t.strategy,strategy_type:t.strategy_type,hostname:t.hostname,auth0_client:e(t.auth0_client),log_id:t.id,location_info:t.country_code||t.city_name||t.latitude||t.longitude||t.time_zone||t.continent_code?{country_code:t.country_code||"",city_name:t.city_name||"",latitude:t.latitude||"",longitude:t.longitude||"",time_zone:t.time_zone||"",continent_code:t.continent_code||""}:void 0}}function yn(t){return async(e,n)=>{const s=n.log_id||pt(),r={...n,log_id:s};return await gn(t,e,r),r}}async function gn(t,e,n){const s=a=>a?JSON.stringify(a):void 0,r={id:n.log_id,tenant_id:e,type:n.type,date:n.date,description:n.description?.substring(0,256),ip:n.ip,user_agent:n.user_agent,details:s(n.details)?.substring(0,8192),isMobile:n.isMobile?1:0,user_id:n.user_id,user_name:n.user_name,connection:n.connection,connection_id:n.connection_id,client_id:n.client_id,client_name:n.client_name,audience:n.audience,scope:n.scope,strategy:n.strategy,strategy_type:n.strategy_type,hostname:n.hostname,auth0_client:s(n.auth0_client),log_id:n.log_id,country_code:n.location_info?.country_code,city_name:n.location_info?.city_name,latitude:n.location_info?.latitude,longitude:n.location_info?.longitude,time_zone:n.location_info?.time_zone,continent_code:n.location_info?.continent_code};try{if(t.pipelineBinding)await t.pipelineBinding.send([r]);else if(t.pipelineEndpoint){const a=t.timeout||3e4,i=new AbortController,o=setTimeout(()=>i.abort(),a);try{const c=await fetch(t.pipelineEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([r]),signal:i.signal});if(!c.ok)throw new Error(`Pipeline ingestion failed: ${c.status} ${c.statusText}`)}finally{clearTimeout(o)}}else throw new Error("Either pipelineEndpoint or pipelineBinding must be configured")}catch(a){throw console.error("Failed to send log to Pipeline:",a),a}}function _n(t){return async(e,n)=>{const s=t.namespace||"default",r=t.tableName||"logs",a=`
2
- SELECT * FROM ${J(s)}.${J(r)}
3
- WHERE tenant_id = ${ke(e)}
4
- AND id = ${ke(n)}
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Ot=require("@authhero/adapter-interfaces"),xr=require("wretch");function ne(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]]);return n}const Mr={ZodAny:"any",ZodArray:"array",ZodBigInt:"bigint",ZodBoolean:"boolean",ZodDefault:"default",ZodPrefault:"prefault",ZodTransform:"transform",ZodEnum:"enum",ZodIntersection:"intersection",ZodLazy:"lazy",ZodLiteral:"literal",ZodNever:"never",ZodNull:"null",ZodNullable:"nullable",ZodNumber:"number",ZodNonOptional:"nonoptional",ZodObject:"object",ZodOptional:"optional",ZodPipe:"pipe",ZodReadonly:"readonly",ZodRecord:"record",ZodString:"string",ZodTuple:"tuple",ZodType:"type",ZodUnion:"union",ZodDiscriminatedUnion:"union",ZodUnknown:"unknown",ZodVoid:"void",ZodDate:"date",ZodTemplateLiteral:"template_literal"};function U(e,t){return(Array.isArray(t)?t:[t]).some(r=>{var o;const s=((o=e?.def)===null||o===void 0?void 0:o.type)===Mr[r];return r==="ZodDiscriminatedUnion"?s&&"discriminator"in e.def:s})}function Y(e){return e&&"def"in e}let Lr=class{constructor(){this._map=new Map,this._idmap=new Map}add(t,...n){const r=n[0];if(this._map.set(t,r),r&&typeof r=="object"&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};return delete r.id,{...r,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}};function Ur(){return new Lr}function Ie(e){return e===void 0}function Fr(e,t){const n={};return Object.entries(e).forEach(([r,o])=>{t.some(s=>s===r)||(n[r]=o)}),n}function Te(e,t){const n={};return Object.entries(e).forEach(([r,o])=>{t(o,r)||(n[r]=o)}),n}const rt=Ur();class B{static collectMetadata(t,n){const r=this.getMetadataFromRegistry(t),o=Object.assign(Object.assign({},r?._internal),n?._internal),s=Object.assign(Object.assign({},r?.param),n?.param),i=Object.assign(Object.assign(Object.assign(Object.assign({},Object.keys(o).length>0?{_internal:o}:{}),r),n),Object.keys(s).length>0?{param:s}:{});if(U(t,["ZodOptional","ZodNullable","ZodDefault","ZodPrefault","ZodReadonly","ZodNonOptional"])&&Y(t._zod.def.innerType))return this.collectMetadata(t._zod.def.innerType,i);if(U(t,"ZodPipe")){const a=t._zod.def.in,c=t._zod.def.out;if(U(a,"ZodTransform")&&Y(c))return this.collectMetadata(c,i);if(Y(a))return this.collectMetadata(a,i)}return i}static getMetadata(t){return this.collectMetadata(t)}static getOpenApiMetadata(t){const n=this.collectMetadata(t),r=n??{},{_internal:o}=r;return ne(r,["_internal"])}static getInternalMetadata(t){var n;return(n=this.collectMetadata(t))===null||n===void 0?void 0:n._internal}static getParamMetadata(t){const n=this.collectMetadata(t);return Object.assign(Object.assign({},n),{param:Object.assign(Object.assign({},n?.description?{description:n.description}:{}),n?.param)})}static buildSchemaMetadata(t){return Te(Fr(t,["param","_internal"]),Ie)}static buildParameterMetadata(t){return Te(t,Ie)}static applySchemaMetadata(t,n){return Te(Object.assign(Object.assign({},t),this.buildSchemaMetadata(n)),Ie)}static getRefId(t){var n;return(n=this.getInternalMetadata(t))===null||n===void 0?void 0:n.refId}static unwrapChained(t){return this.unwrapUntil(t)}static getDefaultValue(t){var n;const r=(n=this.unwrapUntil(t,"ZodDefault"))!==null&&n!==void 0?n:this.unwrapUntil(t,"ZodPrefault");return r?._zod.def.defaultValue}static unwrapUntil(t,n){if(n&&U(t,n))return t;if(U(t,["ZodOptional","ZodNullable","ZodDefault","ZodPrefault","ZodReadonly","ZodNonOptional"])&&Y(t._zod.def.innerType))return this.unwrapUntil(t._zod.def.innerType,n);if(U(t,"ZodPipe")){const r=t._zod.def.in,o=t._zod.def.out;if(U(r,"ZodTransform")&&Y(o))return this.unwrapUntil(o,n);if(Y(r))return this.unwrapUntil(r,n)}return n?void 0:t}static getMetadataFromInternalRegistry(t){return rt.get(t)}static getMetadataFromRegistry(t){const n=this.getMetadataFromInternalRegistry(t),r=t.meta();if(!n)return r;const{_internal:o}=n,s=ne(n,["_internal"]),i=r??{},{id:a,title:c}=i,u=ne(i,["id","title"]);return Object.assign(Object.assign(Object.assign({_internal:Object.assign(Object.assign({},a?{refId:a}:{}),o)},s),c?{description:c}:{}),u)}static setMetadataInRegistry(t,n){rt.add(t,n)}}function L(e,t){const n=e[t];typeof n=="function"&&(e[t]=function(...r){const o=n.apply(this,r),s=B.getMetadataFromRegistry(this);return s&&B.setMetadataInRegistry(o,s),o})}function Jr(e){typeof e.ZodType.prototype.openapi<"u"||(e.ZodType.prototype.openapi=function(...t){const{refId:n,metadata:r,options:o}=Br(...t),s=r??{},{param:i}=s,a=ne(s,["param"]),c=B.getMetadataFromRegistry(this),u=c??{},{_internal:d}=u,p=ne(u,["_internal"]),h=Object.assign(Object.assign(Object.assign({},d),o),n?{refId:n}:void 0),f=Object.assign(Object.assign(Object.assign({},p),a),p?.param||i?{param:Object.assign(Object.assign({},p?.param),i)}:void 0),m=new this.constructor(this._def);function Z(O){B.setMetadataInRegistry(O,Object.assign(Object.assign({},Object.keys(h).length>0?{_internal:h}:void 0),f))}if(Z(m),U(m,"ZodLazy")&&Z(this),U(m,"ZodObject")){const O=B.getMetadataFromRegistry(m),I=m.extend;m.extend=function(...v){const _=I.apply(m,v),w=O??{},{_internal:A}=w,de=ne(w,["_internal"]);return B.setMetadataInRegistry(_,{_internal:{extendedFrom:A?.refId?{refId:A.refId,schema:m}:A?.extendedFrom}}),_.openapi(de)},L(m,"catchall")}L(m,"optional"),L(m,"nullable"),L(m,"default"),L(m,"transform"),L(m,"refine"),L(m,"length"),L(m,"min"),L(m,"max");const y=m.meta;return m.meta=function(...O){const I=y.apply(this,O);if(O[0]){const v=B.getMetadataFromInternalRegistry(this);v&&B.setMetadataInRegistry(I,Object.assign(Object.assign({},v),O[0]))}return I},m})}function Br(e,t,n){return typeof e=="string"?{refId:e,metadata:t,options:n}:{refId:void 0,metadata:e,options:t}}var Q=class extends Error{res;status;constructor(e=500,t){super(t?.message,{cause:t?.cause}),this.res=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 ot;function l(e,t,n){function r(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const u=i.prototype,d=Object.keys(u);for(let p=0;p<d.length;p++){const h=d[p];h in a||(a[h]=u[h].bind(a))}}const o=n?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(a){var c;const u=n?.Parent?new s:this;r(u,a),(c=u._zod).deferred??(c.deferred=[]);for(const d of u._zod.deferred)d();return u}return Object.defineProperty(i,"init",{value:r}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}class re extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class It extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(ot=globalThis).__zod_globalConfig??(ot.__zod_globalConfig={});const ge=globalThis.__zod_globalConfig;function x(e){return e&&Object.assign(ge,e),ge}function Tt(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function st(e,t="|"){return e.map(n=>Nt(n)).join(t)}function Ae(e,t){return typeof t=="bigint"?t.toString():t}function Be(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function qe(e){return e==null}function We(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function qr(e,t){const n=e/t,r=Math.round(n),o=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}const it=Symbol("evaluating");function $(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==it)return r===void 0&&(r=it,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function K(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function W(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function at(e){return JSON.stringify(e)}function Wr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Zt="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function _e(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Vr=Be(()=>{if(ge.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function oe(e){if(_e(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(_e(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function At(e){return oe(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const Gr=new Set(["string","number","symbol"]);function ke(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function J(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function g(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Nt(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Kr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Hr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Yr(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const s=W(e._zod.def,{get shape(){const i={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(i[a]=n.shape[a])}return K(this,"shape",i),i},checks:[]});return J(e,s)}function Qr(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=W(e._zod.def,{get shape(){const i={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete i[a]}return K(this,"shape",i),i},checks:[]});return J(e,s)}function Xr(e,t){if(!oe(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const s=e._zod.def.shape;for(const i in t)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const o=W(e._zod.def,{get shape(){const s={...e._zod.def.shape,...t};return K(this,"shape",s),s}});return J(e,o)}function eo(e,t){if(!oe(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=W(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return K(this,"shape",r),r}});return J(e,n)}function to(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=W(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return K(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return J(e,n)}function no(e,t,n){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const i=W(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const u in n){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=e?new e({type:"optional",innerType:a[u]}):a[u])}else for(const u in a)c[u]=e?new e({type:"optional",innerType:a[u]}):a[u];return K(this,"shape",c),c},checks:[]});return J(t,i)}function ro(e,t,n){const r=W(t._zod.def,{get shape(){const o=t._zod.def.shape,s={...o};if(n)for(const i in n){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);n[i]&&(s[i]=new e({type:"nonoptional",innerType:o[i]}))}else for(const i in o)s[i]=new e({type:"nonoptional",innerType:o[i]});return K(this,"shape",s),s}});return J(t,r)}function X(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function oo(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ee(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function pe(e){return typeof e=="string"?e:e?.message}function F(e,t,n){const r=e.message?e.message:pe(e.inst?._zod.def?.error?.(e))??pe(t?.error?.(e))??pe(n.customError?.(e))??pe(n.localeError?.(e))??"Invalid input",{inst:o,continue:s,input:i,...a}=e;return a.path??(a.path=[]),a.message=r,t?.reportInput&&(a.input=i),a}function Ve(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function so(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function ce(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}const Ct=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ae,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},jt=l("$ZodError",Ct),Pt=l("$ZodError",Ct,{Parent:Error});function Rt(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Dt(e,t=n=>n.message){const n={_errors:[]},r=(o,s=[])=>{for(const i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>r({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")r({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")r({issues:i.issues},[...s,...i.path]);else{const a=[...s,...i.path];if(a.length===0)n._errors.push(t(i));else{let c=n,u=0;for(;u<a.length;){const d=a[u];u===a.length-1?(c[d]=c[d]||{_errors:[]},c[d]._errors.push(t(i))):c[d]=c[d]||{_errors:[]},c=c[d],u++}}}};return r(e),n}const Ge=e=>(t,n,r,o)=>{const s=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise)throw new re;if(i.issues.length){const a=new(o?.Err??e)(i.issues.map(c=>F(c,s,x())));throw Zt(a,o?.callee),a}return i.value},Ke=e=>async(t,n,r,o)=>{const s=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){const a=new(o?.Err??e)(i.issues.map(c=>F(c,s,x())));throw Zt(a,o?.callee),a}return i.value},Se=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise)throw new re;return s.issues.length?{success:!1,error:new(e??jt)(s.issues.map(i=>F(i,o,x())))}:{success:!0,data:s.value}},io=Se(Pt),ze=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>F(i,o,x())))}:{success:!0,data:s.value}},ao=ze(Pt),co=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Ge(e)(t,n,o)},uo=e=>(t,n,r)=>Ge(e)(t,n,r),lo=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Ke(e)(t,n,o)},po=e=>async(t,n,r)=>Ke(e)(t,n,r),fo=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Se(e)(t,n,o)},ho=e=>(t,n,r)=>Se(e)(t,n,r),mo=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return ze(e)(t,n,o)},go=e=>async(t,n,r)=>ze(e)(t,n,r),_o=/^[cC][0-9a-z]{6,}$/,yo=/^[0-9a-z]+$/,bo=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,vo=/^[0-9a-vA-V]{20}$/,wo=/^[A-Za-z0-9]{27}$/,$o=/^[a-zA-Z0-9_-]{21}$/,ko=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,So=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ct=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,zo=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Eo="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Oo(){return new RegExp(Eo,"u")}const Io=/^(?:(?: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])$/,To=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Zo=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Ao=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,No=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,xt=/^[A-Za-z0-9_-]*$/,Co=/^https?$/,jo=/^\+[1-9]\d{6,14}$/,Mt="(?:(?:\\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])))",Po=new RegExp(`^${Mt}$`);function Lt(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Ro(e){return new RegExp(`^${Lt(e)}$`)}function Do(e){const t=Lt({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${Mt}T(?:${r})$`)}const xo=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Mo=/^-?\d+$/,Ut=/^-?\d+(?:\.\d+)?$/,Lo=/^(?:true|false)$/i,Uo=/^[^A-Z]*$/,Fo=/^[^a-z]*$/,P=l("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ft={number:"number",bigint:"bigint",object:"date"},Jt=l("$ZodCheckLessThan",(e,t)=>{P.init(e,t);const n=Ft[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Bt=l("$ZodCheckGreaterThan",(e,t)=>{P.init(e,t);const n=Ft[typeof t.value];e._zod.onattach.push(r=>{const o=r._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Jo=l("$ZodCheckMultipleOf",(e,t)=>{P.init(e,t),e._zod.onattach.push(n=>{var r;(r=n._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):qr(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Bo=l("$ZodCheckNumberFormat",(e,t)=>{P.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,s]=Hr[t.format];e._zod.onattach.push(i=>{const a=i._zod.bag;a.format=t.format,a.minimum=o,a.maximum=s,n&&(a.pattern=Mo)}),e._zod.check=i=>{const a=i.value;if(n){if(!Number.isInteger(a)){i.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}}),qo=l("$ZodCheckMaxLength",(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!qe(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(r._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const o=r.value;if(o.length<=t.maximum)return;const i=Ve(o);r.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Wo=l("$ZodCheckMinLength",(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!qe(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(r._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const o=r.value;if(o.length>=t.minimum)return;const i=Ve(o);r.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Vo=l("$ZodCheckLengthEquals",(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=r=>{const o=r.value;return!qe(o)&&o.length!==void 0}),e._zod.onattach.push(r=>{const o=r._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=r=>{const o=r.value,s=o.length;if(s===t.length)return;const i=Ve(o),a=s>t.length;r.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Ee=l("$ZodCheckStringFormat",(e,t)=>{var n,r;P.init(e,t),e._zod.onattach.push(o=>{const s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Go=l("$ZodCheckRegex",(e,t)=>{Ee.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ko=l("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Uo),Ee.init(e,t)}),Ho=l("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Fo),Ee.init(e,t)}),Yo=l("$ZodCheckIncludes",(e,t)=>{P.init(e,t);const n=ke(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(o=>{const s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(r)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Qo=l("$ZodCheckStartsWith",(e,t)=>{P.init(e,t);const n=new RegExp(`^${ke(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Xo=l("$ZodCheckEndsWith",(e,t)=>{P.init(e,t);const n=new RegExp(`.*${ke(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(r=>{const o=r._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(n)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),es=l("$ZodCheckOverwrite",(e,t)=>{P.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class ts{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
2
+ `).filter(i=>i),o=Math.min(...r.map(i=>i.length-i.trimStart().length)),s=r.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(const i of s)this.content.push(i)}compile(){const t=Function,n=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...n,o.join(`
3
+ `))}}const ns={major:4,minor:4,patch:3},E=l("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=ns;const r=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&r.unshift(e);for(const o of r)for(const s of o._zod.onattach)s(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(i,a,c)=>{let u=X(i),d;for(const p of a){if(p._zod.def.when){if(oo(i)||!p._zod.def.when(i))continue}else if(u)continue;const h=i.issues.length,f=p._zod.check(i);if(f instanceof Promise&&c?.async===!1)throw new re;if(d||f instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await f,i.issues.length!==h&&(u||(u=X(i,h)))});else{if(i.issues.length===h)continue;u||(u=X(i,h))}}return d?d.then(()=>i):i},s=(i,a,c)=>{if(X(i))return i.aborted=!0,i;const u=o(a,r,c);if(u instanceof Promise){if(c.async===!1)throw new re;return u.then(d=>e._zod.parse(d,c))}return e._zod.parse(u,c)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction==="backward"){const u=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(d=>s(d,i,a)):s(u,i,a)}const c=e._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new re;return c.then(u=>o(u,r,a))}return o(c,r,a)}}$(e,"~standard",()=>({validate:o=>{try{const s=io(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return ao(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),He=l("$ZodString",(e,t)=>{E.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??xo(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),k=l("$ZodStringFormat",(e,t)=>{Ee.init(e,t),He.init(e,t)}),rs=l("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=So),k.init(e,t)}),os=l("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ct(r))}else t.pattern??(t.pattern=ct());k.init(e,t)}),ss=l("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=zo),k.init(e,t)}),is=l("$ZodURL",(e,t)=>{k.init(e,t),e._zod.check=n=>{try{const r=n.value.trim();if(!t.normalize&&t.protocol?.source===Co.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const o=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=o.href:n.value=r;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),as=l("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Oo()),k.init(e,t)}),cs=l("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=$o),k.init(e,t)}),us=l("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=_o),k.init(e,t)}),ls=l("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=yo),k.init(e,t)}),ds=l("$ZodULID",(e,t)=>{t.pattern??(t.pattern=bo),k.init(e,t)}),ps=l("$ZodXID",(e,t)=>{t.pattern??(t.pattern=vo),k.init(e,t)}),fs=l("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=wo),k.init(e,t)}),hs=l("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Do(t)),k.init(e,t)}),ms=l("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Po),k.init(e,t)}),gs=l("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Ro(t)),k.init(e,t)}),_s=l("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ko),k.init(e,t)}),ys=l("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Io),k.init(e,t),e._zod.bag.format="ipv4"}),bs=l("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=To),k.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),vs=l("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Zo),k.init(e,t)}),ws=l("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Ao),k.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(r.length!==2)throw new Error;const[o,s]=r;if(!s)throw new Error;const i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function qt(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const $s=l("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=No),k.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{qt(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function ks(e){if(!xt.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return qt(n)}const Ss=l("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=xt),k.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{ks(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),zs=l("$ZodE164",(e,t)=>{t.pattern??(t.pattern=jo),k.init(e,t)});function Es(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Os=l("$ZodJWT",(e,t)=>{k.init(e,t),e._zod.check=n=>{Es(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Wt=l("$ZodNumber",(e,t)=>{E.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ut,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),n}}),Is=l("$ZodNumberFormat",(e,t)=>{Bo.init(e,t),Wt.init(e,t)}),Ts=l("$ZodBoolean",(e,t)=>{E.init(e,t),e._zod.pattern=Lo,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),Zs=l("$ZodUnknown",(e,t)=>{E.init(e,t),e._zod.parse=n=>n}),As=l("$ZodNever",(e,t)=>{E.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function ut(e,t,n){e.issues.length&&t.issues.push(...ee(n,e.issues)),t.value[n]=e.value}const Ns=l("$ZodArray",(e,t)=>{E.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const s=[];for(let i=0;i<o.length;i++){const a=o[i],c=t.element._zod.run({value:a,issues:[]},r);c instanceof Promise?s.push(c.then(u=>ut(u,n,i))):ut(c,n,i)}return s.length?Promise.all(s).then(()=>n):n}});function ye(e,t,n,r,o,s){const i=n in r;if(e.issues.length){if(o&&s&&!i)return;t.issues.push(...ee(n,e.issues))}if(!i&&!o){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?i&&(t.value[n]=void 0):t.value[n]=e.value}function Vt(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const n=Kr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Gt(e,t,n,r,o,s){const i=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,d=c.optin==="optional",p=c.optout==="optional";for(const h in t){if(h==="__proto__"||a.has(h))continue;if(u==="never"){i.push(h);continue}const f=c.run({value:t[h],issues:[]},r);f instanceof Promise?e.push(f.then(m=>ye(m,n,h,t,d,p))):ye(f,n,h,t,d,p)}return i.length&&n.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:s}),e.length?Promise.all(e).then(()=>n):n}const Cs=l("$ZodObject",(e,t)=>{if(E.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const r=Be(()=>Vt(t));$(e._zod,"propValues",()=>{const a=t.shape,c={};for(const u in a){const d=a[u]._zod;if(d.values){c[u]??(c[u]=new Set);for(const p of d.values)c[u].add(p)}}return c});const o=_e,s=t.catchall;let i;e._zod.parse=(a,c)=>{i??(i=r.value);const u=a.value;if(!o(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),a;a.value={};const d=[],p=i.shape;for(const h of i.keys){const f=p[h],m=f._zod.optin==="optional",Z=f._zod.optout==="optional",y=f._zod.run({value:u[h],issues:[]},c);y instanceof Promise?d.push(y.then(O=>ye(O,a,h,u,m,Z))):ye(y,a,h,u,m,Z)}return s?Gt(d,u,a,c,r.value,e):d.length?Promise.all(d).then(()=>a):a}}),js=l("$ZodObjectJIT",(e,t)=>{Cs.init(e,t);const n=e._zod.parse,r=Be(()=>Vt(t)),o=h=>{const f=new ts(["shape","payload","ctx"]),m=r.value,Z=v=>{const _=at(v);return`shape[${_}]._zod.run({ value: input[${_}], issues: [] }, ctx)`};f.write("const input = payload.value;");const y=Object.create(null);let O=0;for(const v of m.keys)y[v]=`key_${O++}`;f.write("const newResult = {};");for(const v of m.keys){const _=y[v],w=at(v),A=h[v],de=A?._zod?.optin==="optional",Dr=A?._zod?.optout==="optional";f.write(`const ${_} = ${Z(v)};`),de&&Dr?f.write(`
4
+ if (${_}.issues.length) {
5
+ if (${w} in input) {
6
+ payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
7
+ ...iss,
8
+ path: iss.path ? [${w}, ...iss.path] : [${w}]
9
+ })));
10
+ }
11
+ }
12
+
13
+ if (${_}.value === undefined) {
14
+ if (${w} in input) {
15
+ newResult[${w}] = undefined;
16
+ }
17
+ } else {
18
+ newResult[${w}] = ${_}.value;
19
+ }
20
+
21
+ `):de?f.write(`
22
+ if (${_}.issues.length) {
23
+ payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
24
+ ...iss,
25
+ path: iss.path ? [${w}, ...iss.path] : [${w}]
26
+ })));
27
+ }
28
+
29
+ if (${_}.value === undefined) {
30
+ if (${w} in input) {
31
+ newResult[${w}] = undefined;
32
+ }
33
+ } else {
34
+ newResult[${w}] = ${_}.value;
35
+ }
36
+
37
+ `):f.write(`
38
+ const ${_}_present = ${w} in input;
39
+ if (${_}.issues.length) {
40
+ payload.issues = payload.issues.concat(${_}.issues.map(iss => ({
41
+ ...iss,
42
+ path: iss.path ? [${w}, ...iss.path] : [${w}]
43
+ })));
44
+ }
45
+ if (!${_}_present && !${_}.issues.length) {
46
+ payload.issues.push({
47
+ code: "invalid_type",
48
+ expected: "nonoptional",
49
+ input: undefined,
50
+ path: [${w}]
51
+ });
52
+ }
53
+
54
+ if (${_}_present) {
55
+ if (${_}.value === undefined) {
56
+ newResult[${w}] = undefined;
57
+ } else {
58
+ newResult[${w}] = ${_}.value;
59
+ }
60
+ }
61
+
62
+ `)}f.write("payload.value = newResult;"),f.write("return payload;");const I=f.compile();return(v,_)=>I(h,v,_)};let s;const i=_e,a=!ge.jitless,u=a&&Vr.value,d=t.catchall;let p;e._zod.parse=(h,f)=>{p??(p=r.value);const m=h.value;return i(m)?a&&u&&f?.async===!1&&f.jitless!==!0?(s||(s=o(t.shape)),h=s(h,f),d?Gt([],m,h,f,p,e):h):n(h,f):(h.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),h)}});function lt(e,t,n,r){for(const s of e)if(s.issues.length===0)return t.value=s.value,t;const o=e.filter(s=>!X(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(s=>s.issues.map(i=>F(i,r,x())))}),t)}const Ps=l("$ZodUnion",(e,t)=>{E.init(e,t),$(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),$(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),$(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),$(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){const r=t.options.map(o=>o._zod.pattern);return new RegExp(`^(${r.map(o=>We(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let s=!1;const i=[];for(const a of t.options){const c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>lt(a,r,e,o)):lt(i,r,e,o)}}),Rs=l("$ZodIntersection",(e,t)=>{E.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,s=t.left._zod.run({value:o,issues:[]},r),i=t.right._zod.run({value:o,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>dt(n,c,u)):dt(n,s,i)}});function Ne(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(oe(e)&&oe(t)){const n=Object.keys(t),r=Object.keys(e).filter(s=>n.indexOf(s)!==-1),o={...e,...t};for(const s of r){const i=Ne(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],s=t[r],i=Ne(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[r,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function dt(e,t,n){const r=new Map;let o;for(const a of t.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)r.has(c)||r.set(c,{}),r.get(c).r=!0;else e.issues.push(a);const s=[...r].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&o&&e.issues.push({...o,keys:s}),X(e))return e;const i=Ne(t.value,n.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const Ds=l("$ZodRecord",(e,t)=>{E.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!oe(o))return n.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),n;const s=[],i=t.keyType._zod.values;if(i){n.value={};const a=new Set;for(const u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);const d=t.keyType._zod.run({value:u,issues:[]},r);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(f=>F(f,r,x())),input:u,path:[u],inst:e});continue}const p=d.value,h=t.valueType._zod.run({value:o[u],issues:[]},r);h instanceof Promise?s.push(h.then(f=>{f.issues.length&&n.issues.push(...ee(u,f.issues)),n.value[p]=f.value})):(h.issues.length&&n.issues.push(...ee(u,h.issues)),n.value[p]=h.value)}let c;for(const u in o)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(o)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},r);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Ut.test(a)&&c.issues.length){const p=t.keyType._zod.run({value:Number(a),issues:[]},r);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(c=p)}if(c.issues.length){t.mode==="loose"?n.value[a]=o[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(p=>F(p,r,x())),input:a,path:[a],inst:e});continue}const d=t.valueType._zod.run({value:o[a],issues:[]},r);d instanceof Promise?s.push(d.then(p=>{p.issues.length&&n.issues.push(...ee(a,p.issues)),n.value[c.value]=p.value})):(d.issues.length&&n.issues.push(...ee(a,d.issues)),n.value[c.value]=d.value)}}return s.length?Promise.all(s).then(()=>n):n}}),xs=l("$ZodEnum",(e,t)=>{E.init(e,t);const n=Tt(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(o=>Gr.has(typeof o)).map(o=>typeof o=="string"?ke(o):o.toString()).join("|")})$`),e._zod.parse=(o,s)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:n,input:i,inst:e}),o}}),Ms=l("$ZodTransform",(e,t)=>{E.init(e,t),e._zod.optin="optional",e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new It(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(n.value=i,n.fallback=!0,n));if(o instanceof Promise)throw new re;return n.value=o,n.fallback=!0,n}});function pt(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const Kt=l("$ZodOptional",(e,t)=>{E.init(e,t),e._zod.optin="optional",e._zod.optout="optional",$(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),$(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${We(n.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(t.innerType._zod.optin==="optional"){const o=n.value,s=t.innerType._zod.run(n,r);return s instanceof Promise?s.then(i=>pt(i,o)):pt(s,o)}return n.value===void 0?n:t.innerType._zod.run(n,r)}}),Ls=l("$ZodExactOptional",(e,t)=>{Kt.init(e,t),$(e._zod,"values",()=>t.innerType._zod.values),$(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Us=l("$ZodNullable",(e,t)=>{E.init(e,t),$(e._zod,"optin",()=>t.innerType._zod.optin),$(e._zod,"optout",()=>t.innerType._zod.optout),$(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${We(n.source)}|null)$`):void 0}),$(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),Fs=l("$ZodDefault",(e,t)=>{E.init(e,t),e._zod.optin="optional",$(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>ft(s,t)):ft(o,t)}});function ft(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Js=l("$ZodPrefault",(e,t)=>{E.init(e,t),e._zod.optin="optional",$(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Bs=l("$ZodNonOptional",(e,t)=>{E.init(e,t),$(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(r=>r!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>ht(s,e)):ht(o,e)}});function ht(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const qs=l("$ZodCatch",(e,t)=>{E.init(e,t),e._zod.optin="optional",$(e._zod,"optout",()=>t.innerType._zod.optout),$(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(s=>(n.value=s.value,s.issues.length&&(n.value=t.catchValue({...n,error:{issues:s.issues.map(i=>F(i,r,x()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=o.value,o.issues.length&&(n.value=t.catchValue({...n,error:{issues:o.issues.map(s=>F(s,r,x()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),Ws=l("$ZodPipe",(e,t)=>{E.init(e,t),$(e._zod,"values",()=>t.in._zod.values),$(e._zod,"optin",()=>t.in._zod.optin),$(e._zod,"optout",()=>t.out._zod.optout),$(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const s=t.out._zod.run(n,r);return s instanceof Promise?s.then(i=>fe(i,t.in,r)):fe(s,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>fe(s,t.out,r)):fe(o,t.out,r)}});function fe(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const Vs=l("$ZodReadonly",(e,t)=>{E.init(e,t),$(e._zod,"propValues",()=>t.innerType._zod.propValues),$(e._zod,"values",()=>t.innerType._zod.values),$(e._zod,"optin",()=>t.innerType?._zod?.optin),$(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(mt):mt(o)}});function mt(e){return e.value=Object.freeze(e.value),e}const Gs=l("$ZodCustom",(e,t)=>{P.init(e,t),E.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(s=>gt(s,n,r,e));gt(o,n,r,e)}});function gt(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(ce(o))}}const Ks=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(o){return e[o]??null}const n={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};return o=>{switch(o.code){case"invalid_type":{const s=r[o.expected]??o.expected,i=so(o.input),a=r[i]??i;return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${Nt(o.values[0])}`:`Invalid option: expected one of ${st(o.values,"|")}`;case"too_big":{const s=o.inclusive?"<=":"<",i=t(o.origin);return i?`Too big: expected ${o.origin??"value"} to have ${s}${o.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${s}${o.maximum.toString()}`}case"too_small":{const s=o.inclusive?">=":">",i=t(o.origin);return i?`Too small: expected ${o.origin} to have ${s}${o.minimum.toString()} ${i.unit}`:`Too small: expected ${o.origin} to be ${s}${o.minimum.toString()}`}case"invalid_format":{const s=o;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${n[s.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${st(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(i=>`'${i}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function Hs(){return{localeError:Ks()}}var _t;class Ys{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Ht(){return new Ys}(_t=globalThis).__zod_globalRegistry??(_t.__zod_globalRegistry=Ht());const te=globalThis.__zod_globalRegistry;function Qs(e,t){return new e({type:"string",...g(t)})}function Xs(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...g(t)})}function yt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...g(t)})}function ei(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...g(t)})}function ti(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...g(t)})}function ni(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...g(t)})}function ri(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...g(t)})}function oi(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...g(t)})}function si(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...g(t)})}function ii(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...g(t)})}function ai(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...g(t)})}function ci(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...g(t)})}function ui(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...g(t)})}function li(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...g(t)})}function di(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...g(t)})}function pi(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...g(t)})}function fi(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...g(t)})}function hi(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...g(t)})}function mi(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...g(t)})}function gi(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...g(t)})}function _i(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...g(t)})}function yi(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...g(t)})}function bi(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...g(t)})}function vi(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...g(t)})}function wi(e,t){return new e({type:"string",format:"date",check:"string_format",...g(t)})}function $i(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...g(t)})}function ki(e,t){return new e({type:"string",format:"duration",check:"string_format",...g(t)})}function Si(e,t){return new e({type:"number",checks:[],...g(t)})}function zi(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...g(t)})}function Ei(e,t){return new e({type:"boolean",...g(t)})}function Oi(e){return new e({type:"unknown"})}function Ii(e,t){return new e({type:"never",...g(t)})}function Ce(e,t){return new Jt({check:"less_than",...g(t),value:e,inclusive:!1})}function he(e,t){return new Jt({check:"less_than",...g(t),value:e,inclusive:!0})}function je(e,t){return new Bt({check:"greater_than",...g(t),value:e,inclusive:!1})}function me(e,t){return new Bt({check:"greater_than",...g(t),value:e,inclusive:!0})}function Pe(e,t){return new Jo({check:"multiple_of",...g(t),value:e})}function Ye(e,t){return new qo({check:"max_length",...g(t),maximum:e})}function ue(e,t){return new Wo({check:"min_length",...g(t),minimum:e})}function Qe(e,t){return new Vo({check:"length_equals",...g(t),length:e})}function Yt(e,t){return new Go({check:"string_format",format:"regex",...g(t),pattern:e})}function Qt(e){return new Ko({check:"string_format",format:"lowercase",...g(e)})}function Xt(e){return new Ho({check:"string_format",format:"uppercase",...g(e)})}function en(e,t){return new Yo({check:"string_format",format:"includes",...g(t),includes:e})}function tn(e,t){return new Qo({check:"string_format",format:"starts_with",...g(t),prefix:e})}function nn(e,t){return new Xo({check:"string_format",format:"ends_with",...g(t),suffix:e})}function H(e){return new es({check:"overwrite",tx:e})}function rn(e){return H(t=>t.normalize(e))}function on(){return H(e=>e.trim())}function sn(){return H(e=>e.toLowerCase())}function an(){return H(e=>e.toUpperCase())}function cn(){return H(e=>Wr(e))}function Ti(e,t,n){return new e({type:"array",element:t,...g(n)})}function Zi(e,t,n){return new e({type:"custom",check:"custom",fn:t,...g(n)})}function Ai(e,t){const n=Ni(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(ce(o,r.value,n._zod.def));else{const s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=r.value),s.inst??(s.inst=n),s.continue??(s.continue=!n._zod.def.abort),r.issues.push(ce(s))}},e(r.value,r)),t);return n}function Ni(e,t){const n=new P({check:"custom",...g(t)});return n._zod.check=e,n}function un(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??te,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function T(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,n.schemaPath.includes(e)&&(s.cycle=n.path),s.schema;const i={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,i);const a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{const d={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,d);else{const h=i.schema,f=t.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,h,d)}const p=e._zod.parent;p&&(i.ref||(i.ref=p),T(p,t,d),t.seen.get(p).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),t.io==="input"&&C(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((r=i.schema).default??(r.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function ln(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=new Map;for(const i of e.seen.entries()){const a=e.metadataRegistry.get(i[0])?.id;if(a){const c=r.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,i[0])}}const o=i=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const p=e.external.registry.get(i[0])?.id,h=e.external.uri??(m=>m);if(p)return{ref:h(p)};const f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${h("__shared")}#/${a}/${f}`}}if(i[1]===n)return{ref:"#"};const u=`#/${a}/`,d=i[1].schema.id??`__schema${e.counter++}`;return{defId:d,ref:u+d}},s=i=>{if(i[1].schema.$ref)return;const a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);const d=a.schema;for(const p in d)delete d[p];d.$ref=c};if(e.cycles==="throw")for(const i of e.seen.entries()){const a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
63
+
64
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const a=i[1];if(t===i[0]){s(i);continue}if(e.external){const u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&e.reused==="ref"){s(i);continue}}}function dn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=a=>{const c=e.seen.get(a);if(c.ref===null)return;const u=c.def??c.schema,d={...u},p=c.ref;if(c.ref=null,p){r(p);const f=e.seen.get(p),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):Object.assign(u,m),Object.assign(u,d),a._zod.parent===p)for(const y in u)y==="$ref"||y==="allOf"||y in d||delete u[y];if(m.$ref&&f.def)for(const y in u)y==="$ref"||y==="allOf"||y in f.def&&JSON.stringify(u[y])===JSON.stringify(f.def[y])&&delete u[y]}const h=a._zod.parent;if(h&&h!==p){r(h);const f=e.seen.get(h);if(f?.schema.$ref&&(u.$ref=f.schema.$ref,f.def))for(const m in u)m==="$ref"||m==="allOf"||m in f.def&&JSON.stringify(u[m])===JSON.stringify(f.def[m])&&delete u[m]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(const a of[...e.seen.entries()].reverse())r(a[0]);const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Object.assign(o,n.def??n.schema);const s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;const i=e.external?.defs??{};for(const a of e.seen.entries()){const c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,i[c.defId]=c.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:be(t,"input",e.processors),output:be(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function C(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return C(r.element,n);if(r.type==="set")return C(r.valueType,n);if(r.type==="lazy")return C(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault")return C(r.innerType,n);if(r.type==="intersection")return C(r.left,n)||C(r.right,n);if(r.type==="record"||r.type==="map")return C(r.keyType,n)||C(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:C(r.in,n)||C(r.out,n);if(r.type==="object"){for(const o in r.shape)if(C(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(C(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(C(o,n))return!0;return!!(r.rest&&C(r.rest,n))}return!1}const Ci=(e,t={})=>n=>{const r=un({...n,processors:t});return T(e,r),ln(r,e),dn(r,e)},be=(e,t,n={})=>r=>{const{libraryOptions:o,target:s}=r??{},i=un({...o??{},target:s,io:t,processors:n});return T(e,i),ln(i,e),dn(i,e)},ji={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Pi=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=e._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=ji[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const d=[...c];d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},Ri=(e,t,n,r)=>{const o=n,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:d}=e._zod.bag;typeof a=="string"&&a.includes("int")?o.type="integer":o.type="number";const p=typeof d=="number"&&d>=(s??Number.NEGATIVE_INFINITY),h=typeof u=="number"&&u<=(i??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";p?f?(o.minimum=d,o.exclusiveMinimum=!0):o.exclusiveMinimum=d:typeof s=="number"&&(o.minimum=s),h?f?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:typeof i=="number"&&(o.maximum=i),typeof c=="number"&&(o.multipleOf=c)},Di=(e,t,n,r)=>{n.type="boolean"},xi=(e,t,n,r)=>{n.not={}},Mi=(e,t,n,r)=>{},Li=(e,t,n,r)=>{const o=e._zod.def,s=Tt(o.entries);s.every(i=>typeof i=="number")&&(n.type="number"),s.every(i=>typeof i=="string")&&(n.type="string"),n.enum=s},Ui=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Fi=(e,t,n,r)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},Ji=(e,t,n,r)=>{const o=n,s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=T(s.element,t,{...r,path:[...r.path,"items"]})},Bi=(e,t,n,r)=>{const o=n,s=e._zod.def;o.type="object",o.properties={};const i=s.shape;for(const u in i)o.properties[u]=T(i[u],t,{...r,path:[...r.path,"properties",u]});const a=new Set(Object.keys(i)),c=new Set([...a].filter(u=>{const d=s.shape[u]._zod;return t.io==="input"?d.optin===void 0:d.optout===void 0}));c.size>0&&(o.required=Array.from(c)),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=T(s.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},qi=(e,t,n,r)=>{const o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>T(a,t,{...r,path:[...r.path,s?"oneOf":"anyOf",c]}));s?n.oneOf=i:n.anyOf=i},Wi=(e,t,n,r)=>{const o=e._zod.def,s=T(o.left,t,{...r,path:[...r.path,"allOf",0]}),i=T(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];n.allOf=c},Vi=(e,t,n,r)=>{const o=n,s=e._zod.def;o.type="object";const i=s.keyType,c=i._zod.bag?.patterns;if(s.mode==="loose"&&c&&c.size>0){const d=T(s.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const p of c)o.patternProperties[p.source]=d}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(o.propertyNames=T(s.keyType,t,{...r,path:[...r.path,"propertyNames"]})),o.additionalProperties=T(s.valueType,t,{...r,path:[...r.path,"additionalProperties"]});const u=i._zod.values;if(u){const d=[...u].filter(p=>typeof p=="string"||typeof p=="number");d.length>0&&(o.required=d)}},Gi=(e,t,n,r)=>{const o=e._zod.def,s=T(o.innerType,t,r),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,n.nullable=!0):n.anyOf=[s,{type:"null"}]},Ki=(e,t,n,r)=>{const o=e._zod.def;T(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},Hi=(e,t,n,r)=>{const o=e._zod.def;T(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.default=JSON.parse(JSON.stringify(o.defaultValue))},Yi=(e,t,n,r)=>{const o=e._zod.def;T(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Qi=(e,t,n,r)=>{const o=e._zod.def;T(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=i},Xi=(e,t,n,r)=>{const o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;T(i,t,r);const a=t.seen.get(e);a.ref=i},ea=(e,t,n,r)=>{const o=e._zod.def;T(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType,n.readOnly=!0},pn=(e,t,n,r)=>{const o=e._zod.def;T(o.innerType,t,r);const s=t.seen.get(e);s.ref=o.innerType},fn=l("ZodISODateTime",(e,t)=>{hs.init(e,t),S.init(e,t)});function ta(e){return vi(fn,e)}const hn=l("ZodISODate",(e,t)=>{ms.init(e,t),S.init(e,t)});function na(e){return wi(hn,e)}const mn=l("ZodISOTime",(e,t)=>{gs.init(e,t),S.init(e,t)});function ra(e){return $i(mn,e)}const gn=l("ZodISODuration",(e,t)=>{_s.init(e,t),S.init(e,t)});function oa(e){return ki(gn,e)}const sa=(e,t)=>{jt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>Dt(e,n)},flatten:{value:n=>Rt(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,Ae,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,Ae,2)}},isEmpty:{get(){return e.issues.length===0}}})},D=l("ZodError",sa,{Parent:Error}),_n=Ge(D),yn=Ke(D),bn=Se(D),vn=ze(D),wn=co(D),$n=uo(D),kn=lo(D),Sn=po(D),zn=fo(D),En=ho(D),On=mo(D),In=go(D),bt=new WeakMap;function le(e,t,n){const r=Object.getPrototypeOf(e);let o=bt.get(r);if(o||(o=new Set,bt.set(r,o)),!o.has(t)){o.add(t);for(const s in n){const i=n[s];Object.defineProperty(r,s,{configurable:!0,enumerable:!1,get(){const a=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}const z=l("ZodType",(e,t)=>(E.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:be(e,"input"),output:be(e,"output")}}),e.toJSONSchema=Ci(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,r)=>_n(e,n,r,{callee:e.parse}),e.safeParse=(n,r)=>bn(e,n,r),e.parseAsync=async(n,r)=>yn(e,n,r,{callee:e.parseAsync}),e.safeParseAsync=async(n,r)=>vn(e,n,r),e.spa=e.safeParseAsync,e.encode=(n,r)=>wn(e,n,r),e.decode=(n,r)=>$n(e,n,r),e.encodeAsync=async(n,r)=>kn(e,n,r),e.decodeAsync=async(n,r)=>Sn(e,n,r),e.safeEncode=(n,r)=>zn(e,n,r),e.safeDecode=(n,r)=>En(e,n,r),e.safeEncodeAsync=async(n,r)=>On(e,n,r),e.safeDecodeAsync=async(n,r)=>In(e,n,r),le(e,"ZodType",{check(...n){const r=this.def;return this.clone(W(r,{checks:[...r.checks??[],...n.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,r){return J(this,n,r)},brand(){return this},register(n,r){return n.add(this,r),this},refine(n,r){return this.check(kr(n,r))},superRefine(n,r){return this.check(Sr(n,r))},overwrite(n){return this.check(H(n))},optional(){return Le(this)},exactOptional(){return lr(this)},nullable(){return Ue(this)},nullish(){return Le(Ue(this))},nonoptional(n){return gr(this,n)},array(){return j(this)},or(n){return nr([this,n])},and(n){return or(this,n)},transform(n){return Fe(this,cr(n))},default(n){return fr(this,n)},prefault(n){return mr(this,n)},catch(n){return yr(this,n)},pipe(n){return Fe(this,n)},readonly(){return wr(this)},describe(n){const r=this.clone();return te.add(r,{description:n}),r},meta(...n){if(n.length===0)return te.get(this);const r=this.clone();return te.add(r,n[0]),r},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return te.get(e)?.description},configurable:!0}),e)),Xe=l("_ZodString",(e,t)=>{He.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Pi(e,r,o);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,le(e,"_ZodString",{regex(...r){return this.check(Yt(...r))},includes(...r){return this.check(en(...r))},startsWith(...r){return this.check(tn(...r))},endsWith(...r){return this.check(nn(...r))},min(...r){return this.check(ue(...r))},max(...r){return this.check(Ye(...r))},length(...r){return this.check(Qe(...r))},nonempty(...r){return this.check(ue(1,...r))},lowercase(r){return this.check(Qt(r))},uppercase(r){return this.check(Xt(r))},trim(){return this.check(on())},normalize(...r){return this.check(rn(...r))},toLowerCase(){return this.check(sn())},toUpperCase(){return this.check(an())},slugify(){return this.check(cn())}})}),Tn=l("ZodString",(e,t)=>{He.init(e,t),Xe.init(e,t),e.email=n=>e.check(Xs(Zn,n)),e.url=n=>e.check(oi(An,n)),e.jwt=n=>e.check(bi(Wn,n)),e.emoji=n=>e.check(si(Nn,n)),e.guid=n=>e.check(yt(Re,n)),e.uuid=n=>e.check(ei(ae,n)),e.uuidv4=n=>e.check(ti(ae,n)),e.uuidv6=n=>e.check(ni(ae,n)),e.uuidv7=n=>e.check(ri(ae,n)),e.nanoid=n=>e.check(ii(Cn,n)),e.guid=n=>e.check(yt(Re,n)),e.cuid=n=>e.check(ai(jn,n)),e.cuid2=n=>e.check(ci(Pn,n)),e.ulid=n=>e.check(ui(Rn,n)),e.base64=n=>e.check(gi(Jn,n)),e.base64url=n=>e.check(_i(Bn,n)),e.xid=n=>e.check(li(Dn,n)),e.ksuid=n=>e.check(di(xn,n)),e.ipv4=n=>e.check(pi(Mn,n)),e.ipv6=n=>e.check(fi(Ln,n)),e.cidrv4=n=>e.check(hi(Un,n)),e.cidrv6=n=>e.check(mi(Fn,n)),e.e164=n=>e.check(yi(qn,n)),e.datetime=n=>e.check(ta(n)),e.date=n=>e.check(na(n)),e.time=n=>e.check(ra(n)),e.duration=n=>e.check(oa(n))});function b(e){return Qs(Tn,e)}const S=l("ZodStringFormat",(e,t)=>{k.init(e,t),Xe.init(e,t)}),Zn=l("ZodEmail",(e,t)=>{ss.init(e,t),S.init(e,t)}),Re=l("ZodGUID",(e,t)=>{rs.init(e,t),S.init(e,t)}),ae=l("ZodUUID",(e,t)=>{os.init(e,t),S.init(e,t)}),An=l("ZodURL",(e,t)=>{is.init(e,t),S.init(e,t)}),Nn=l("ZodEmoji",(e,t)=>{as.init(e,t),S.init(e,t)}),Cn=l("ZodNanoID",(e,t)=>{cs.init(e,t),S.init(e,t)}),jn=l("ZodCUID",(e,t)=>{us.init(e,t),S.init(e,t)}),Pn=l("ZodCUID2",(e,t)=>{ls.init(e,t),S.init(e,t)}),Rn=l("ZodULID",(e,t)=>{ds.init(e,t),S.init(e,t)}),Dn=l("ZodXID",(e,t)=>{ps.init(e,t),S.init(e,t)}),xn=l("ZodKSUID",(e,t)=>{fs.init(e,t),S.init(e,t)}),Mn=l("ZodIPv4",(e,t)=>{ys.init(e,t),S.init(e,t)}),Ln=l("ZodIPv6",(e,t)=>{bs.init(e,t),S.init(e,t)}),Un=l("ZodCIDRv4",(e,t)=>{vs.init(e,t),S.init(e,t)}),Fn=l("ZodCIDRv6",(e,t)=>{ws.init(e,t),S.init(e,t)}),Jn=l("ZodBase64",(e,t)=>{$s.init(e,t),S.init(e,t)}),Bn=l("ZodBase64URL",(e,t)=>{Ss.init(e,t),S.init(e,t)}),qn=l("ZodE164",(e,t)=>{zs.init(e,t),S.init(e,t)}),Wn=l("ZodJWT",(e,t)=>{Os.init(e,t),S.init(e,t)}),et=l("ZodNumber",(e,t)=>{Wt.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Ri(e,r,o),le(e,"ZodNumber",{gt(r,o){return this.check(je(r,o))},gte(r,o){return this.check(me(r,o))},min(r,o){return this.check(me(r,o))},lt(r,o){return this.check(Ce(r,o))},lte(r,o){return this.check(he(r,o))},max(r,o){return this.check(he(r,o))},int(r){return this.check(De(r))},safe(r){return this.check(De(r))},positive(r){return this.check(je(0,r))},nonnegative(r){return this.check(me(0,r))},negative(r){return this.check(Ce(0,r))},nonpositive(r){return this.check(he(0,r))},multipleOf(r,o){return this.check(Pe(r,o))},step(r,o){return this.check(Pe(r,o))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Vn(e){return Si(et,e)}const Gn=l("ZodNumberFormat",(e,t)=>{Is.init(e,t),et.init(e,t)});function De(e){return zi(Gn,e)}const Kn=l("ZodBoolean",(e,t)=>{Ts.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Di(e,n,r)});function Oe(e){return Ei(Kn,e)}const Hn=l("ZodUnknown",(e,t)=>{Zs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Mi()});function xe(){return Oi(Hn)}const Yn=l("ZodNever",(e,t)=>{As.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>xi(e,n,r)});function Qn(e){return Ii(Yn,e)}const Xn=l("ZodArray",(e,t)=>{Ns.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ji(e,n,r,o),e.element=t.element,le(e,"ZodArray",{min(n,r){return this.check(ue(n,r))},nonempty(n){return this.check(ue(1,n))},max(n,r){return this.check(Ye(n,r))},length(n,r){return this.check(Qe(n,r))},unwrap(){return this.element}})});function j(e,t){return Ti(Xn,e,t)}const er=l("ZodObject",(e,t)=>{js.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bi(e,n,r,o),$(e,"shape",()=>t.shape),le(e,"ZodObject",{keyof(){return ir(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:xe()})},loose(){return this.clone({...this._zod.def,catchall:xe()})},strict(){return this.clone({...this._zod.def,catchall:Qn()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return Xr(this,n)},safeExtend(n){return eo(this,n)},merge(n){return to(this,n)},pick(n){return Yr(this,n)},omit(n){return Qr(this,n)},partial(...n){return no(tt,this,n[0])},required(...n){return ro(nt,this,n[0])}})});function M(e,t){const n={type:"object",shape:e??{},...g(t)};return new er(n)}const tr=l("ZodUnion",(e,t)=>{Ps.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qi(e,n,r,o),e.options=t.options});function nr(e,t){return new tr({type:"union",options:e,...g(t)})}const rr=l("ZodIntersection",(e,t)=>{Rs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wi(e,n,r,o)});function or(e,t){return new rr({type:"intersection",left:e,right:t})}const Me=l("ZodRecord",(e,t)=>{Ds.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Vi(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function sr(e,t,n){return!t||!t._zod?new Me({type:"record",keyType:b(),valueType:e,...g(t)}):new Me({type:"record",keyType:e,valueType:t,...g(n)})}const ve=l("ZodEnum",(e,t)=>{xs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(r,o,s)=>Li(e,r,o),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const s={};for(const i of r)if(n.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new ve({...t,checks:[],...g(o),entries:s})},e.exclude=(r,o)=>{const s={...t.entries};for(const i of r)if(n.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new ve({...t,checks:[],...g(o),entries:s})}});function ir(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new ve({type:"enum",entries:n,...g(t)})}const ar=l("ZodTransform",(e,t)=>{Ms.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fi(e,n),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new It(e.constructor.name);n.addIssue=s=>{if(typeof s=="string")n.issues.push(ce(s,n.value,t));else{const i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=n.value),i.inst??(i.inst=e),n.issues.push(ce(i))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(s=>(n.value=s,n.fallback=!0,n)):(n.value=o,n.fallback=!0,n)}});function cr(e){return new ar({type:"transform",transform:e})}const tt=l("ZodOptional",(e,t)=>{Kt.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>pn(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Le(e){return new tt({type:"optional",innerType:e})}const ur=l("ZodExactOptional",(e,t)=>{Ls.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>pn(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function lr(e){return new ur({type:"optional",innerType:e})}const dr=l("ZodNullable",(e,t)=>{Us.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Gi(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ue(e){return new dr({type:"nullable",innerType:e})}const pr=l("ZodDefault",(e,t)=>{Fs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Hi(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function fr(e,t){return new pr({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():At(t)}})}const hr=l("ZodPrefault",(e,t)=>{Js.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Yi(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function mr(e,t){return new hr({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():At(t)}})}const nt=l("ZodNonOptional",(e,t)=>{Bs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ki(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function gr(e,t){return new nt({type:"nonoptional",innerType:e,...g(t)})}const _r=l("ZodCatch",(e,t)=>{qs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Qi(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function yr(e,t){return new _r({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const br=l("ZodPipe",(e,t)=>{Ws.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Xi(e,n,r,o),e.in=t.in,e.out=t.out});function Fe(e,t){return new br({type:"pipe",in:e,out:t})}const vr=l("ZodReadonly",(e,t)=>{Vs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ea(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function wr(e){return new vr({type:"readonly",innerType:e})}const $r=l("ZodCustom",(e,t)=>{Gs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ui(e,n)});function kr(e,t={}){return Zi($r,e,t)}function Sr(e,t){return Ai(e,t)}x(Hs());const ia=Object.freeze(Object.defineProperty({__proto__:null,ZodArray:Xn,ZodBase64:Jn,ZodBase64URL:Bn,ZodBoolean:Kn,ZodCIDRv4:Un,ZodCIDRv6:Fn,ZodCUID:jn,ZodCUID2:Pn,ZodCatch:_r,ZodCustom:$r,ZodDefault:pr,ZodE164:qn,ZodEmail:Zn,ZodEmoji:Nn,ZodEnum:ve,ZodExactOptional:ur,ZodGUID:Re,ZodIPv4:Mn,ZodIPv6:Ln,ZodISODate:hn,ZodISODateTime:fn,ZodISODuration:gn,ZodISOTime:mn,ZodIntersection:rr,ZodJWT:Wn,ZodKSUID:xn,ZodNanoID:Cn,ZodNever:Yn,ZodNonOptional:nt,ZodNullable:dr,ZodNumber:et,ZodNumberFormat:Gn,ZodObject:er,ZodOptional:tt,ZodPipe:br,ZodPrefault:hr,ZodReadonly:vr,ZodRealError:D,ZodRecord:Me,ZodString:Tn,ZodStringFormat:S,ZodTransform:ar,ZodType:z,ZodULID:Rn,ZodURL:An,ZodUUID:ae,ZodUnion:tr,ZodUnknown:Hn,ZodXID:Dn,_ZodString:Xe,_default:fr,array:j,boolean:Oe,catch:yr,clone:J,config:x,decode:$n,decodeAsync:Sn,encode:wn,encodeAsync:kn,endsWith:nn,enum:ir,exactOptional:lr,flattenError:Rt,formatError:Dt,globalRegistry:te,gt:je,gte:me,includes:en,int:De,intersection:or,length:Qe,lowercase:Qt,lt:Ce,lte:he,maxLength:Ye,minLength:ue,multipleOf:Pe,never:Qn,nonoptional:gr,normalize:rn,nullable:Ue,number:Vn,object:M,optional:Le,overwrite:H,parse:_n,parseAsync:yn,pipe:Fe,prefault:mr,readonly:wr,record:sr,refine:kr,regex:Yt,registry:Ht,safeDecode:En,safeDecodeAsync:In,safeEncode:zn,safeEncodeAsync:On,safeParse:bn,safeParseAsync:vn,slugify:cn,startsWith:tn,string:b,superRefine:Sr,toLowerCase:sn,toUpperCase:an,transform:cr,trim:on,union:nr,unknown:xe,uppercase:Xt},Symbol.toStringTag,{value:"Module"}));Jr(ia);const aa=(e,t)=>t.skipDedupe||t.method!=="GET",ca=(e,t)=>t.method+"@"+e,ua=e=>e.clone(),la=({skip:e=aa,key:t=ca,resolver:n=ua}={})=>{const r=new Map;return o=>(s,i)=>{if(e(s,i))return o(s,i);const a=t(s,i);if(!r.has(a))r.set(a,[]);else return new Promise((c,u)=>{r.get(a).push([c,u])});try{return o(s,i).then(c=>(r.get(a).forEach(([u])=>u(n(c))),r.delete(a),c)).catch(c=>{throw r.get(a).forEach(([,u])=>u(c)),r.delete(a),c})}catch(c){return r.delete(a),Promise.reject(c)}}},da=(e,t)=>e*t,pa=e=>e&&(e.ok||e.status>=400&&e.status<500),fa=({delayTimer:e=500,delayRamp:t=da,maxAttempts:n=10,until:r=pa,onRetry:o=null,retryOnNetworkError:s=!1,resolveWithLatestResponse:i=!1,skip:a}={})=>c=>(u,d)=>{let p=0;if(a&&a(u,d))return c(u,d);const h=(f,m)=>Promise.resolve(r(f,m)).then(Z=>Z?f&&i?f:m?Promise.reject(m):f:(p++,!n||p<=n?new Promise(y=>{const O=t(e,p);setTimeout(()=>{typeof o=="function"?Promise.resolve(o({response:f,error:m,url:u,attempt:p,options:d})).then((I={})=>{var v,_;y(c((v=I&&I.url)!==null&&v!==void 0?v:u,(_=I&&I.options)!==null&&_!==void 0?_:d))}):y(c(u,d))},O)}).then(h).catch(y=>{if(!s)throw y;return h(null,y)}):f&&i?f:Promise.reject(m||new Error("Number of attempts exceeded."))));return c(u,d).then(h).catch(f=>{if(!s)throw f;return h(null,f)})},we=M({code:Vn(),message:b()}),ha=M({message:b()}),ma=M({emails:j(b()).optional(),http_body:b().optional(),http_url:b().optional(),txt_name:b().optional(),txt_value:b().optional()}),ga=M({ciphers:j(b()).optional(),early_hints:b().optional(),http2:b().optional(),min_tls_version:b().optional(),tls_1_3:b().optional()}),_a=M({id:b(),bundle_method:b().optional(),certificate_authority:b(),custom_certificate:b().optional(),custom_csr_id:b().optional(),custom_key:b().optional(),expires_on:b().optional(),hosts:j(b()).optional(),issuer:b().optional(),method:b(),serial_number:b().optional(),settings:ga.optional(),signature:b().optional(),type:b(),uploaded_on:b().optional(),validation_errors:j(ha).optional(),validation_records:j(ma).optional(),wildcard:Oe()}),ya=M({name:b(),type:b(),value:b()}),ba=M({http_body:b().optional(),http_url:b().optional()}),zr=M({id:b(),ssl:_a,hostname:b(),custom_metadata:sr(b(),b()).optional(),custom_origin_server:b().optional(),custom_origin_sni:b().optional(),ownership_verification:ya.optional(),ownership_verification_http:ba.optional(),status:b(),verification_errors:j(b()).optional(),created_at:b()}),ie=M({errors:j(we),messages:j(we),success:Oe(),result:zr});M({errors:j(we),messages:j(we),success:Oe(),result:j(zr)});function V(e){return xr(`https://api.cloudflare.com/client/v4/zones/${e.zoneId}`).headers({"X-Auth-Email":e.authEmail,"X-Auth-Key":e.authKey,"Content-Type":"application/json"}).middlewares([fa(),la()])}function vt(e){const t={},n={};if(!e)return{sslOverrides:t,rest:n};for(const[r,o]of Object.entries(e))r.startsWith("ssl.")?t[r.slice(4)]=o:n[r]=o;return{sslOverrides:t,rest:n}}function Ze(e){const t=[];if(e.ssl.validation_records)for(const r of e.ssl.validation_records)r.txt_name&&r.txt_value&&t.push({name:"txt",record:r.txt_value,domain:r.txt_name});if(e.ownership_verification&&t.push({name:"txt",record:e.ownership_verification.value,domain:e.ownership_verification.name}),e.ownership_verification_http?.http_body&&e.ownership_verification_http?.http_url&&t.push({name:"http",http_body:e.ownership_verification_http.http_body,http_url:e.ownership_verification_http.http_url}),e.ssl.validation_records)for(const r of e.ssl.validation_records)r.http_body&&r.http_url&&t.push({name:"http",http_body:r.http_body,http_url:r.http_url});const n={...e.domain_metadata||{},"ssl.method":e.ssl.method,"ssl.type":e.ssl.type,"ssl.certificate_authority":e.ssl.certificate_authority};return{custom_domain_id:e.id,domain:e.hostname,primary:e.primary,status:e.status==="active"?"ready":"pending",type:"auth0_managed_certs",verification:{methods:j(Ot.verificationMethodsSchema).parse(t)},domain_metadata:n}}function va(e){return{create:async(t,n)=>{const{sslOverrides:r,rest:o}=vt(n.domain_metadata),{result:s,errors:i,success:a}=ie.parse(await V(e).post({hostname:n.domain,ssl:{method:"txt",type:"dv",...r},custom_metadata:e.enterprise?{tenant_id:t}:void 0},"/custom_hostnames").json());if(!a)throw new Error(JSON.stringify(i));const c=Ze({...s,primary:!1,domain_metadata:o});return await e.customDomainAdapter.create(t,{custom_domain_id:c.custom_domain_id,domain:c.domain,type:c.type,domain_metadata:n.domain_metadata}),c},get:async(t,n)=>{const r=await e.customDomainAdapter.get(t,n);if(!r)throw new Q(404);const o=await V(e).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(),{result:s,errors:i,success:a}=ie.parse(o);if(!a)throw new Q(503,{message:JSON.stringify(i)});if(e.enterprise&&s.custom_metadata?.tenant_id!==t)throw new Q(404);return Ze({...r,...s})},getByDomain:async t=>e.customDomainAdapter.getByDomain(t),list:async t=>{const n=await e.customDomainAdapter.list(t);return(await Promise.all(n.map(async o=>{try{const s=await V(e).get(`/custom_hostnames/${encodeURIComponent(o.custom_domain_id)}`).json(),{result:i,success:a}=ie.parse(s);return!a||e.enterprise&&i.custom_metadata?.tenant_id!==t?null:Ze({...o,...i})}catch{return null}}))).filter(o=>o!==null)},remove:async(t,n)=>{if(e.enterprise){const{result:o,success:s}=ie.parse(await V(e).get(`/custom_hostnames/${encodeURIComponent(n)}`).json());if(!s||o.custom_metadata?.tenant_id!==t)throw new Q(404)}const r=await V(e).delete(`/custom_hostnames/${encodeURIComponent(n)}`).res();return r.ok&&await e.customDomainAdapter.remove(t,n),r.ok},update:async(t,n,r)=>{const{sslOverrides:o}=vt(r.domain_metadata),s={};if(Object.keys(o).length>0){const i=await V(e).get(`/custom_hostnames/${encodeURIComponent(n)}`).json(),{result:a,success:c}=ie.parse(i);if(!c)throw new Q(503,{message:"Failed to fetch current custom hostname state"});s.ssl={method:a.ssl.method,type:a.ssl.type,certificate_authority:a.ssl.certificate_authority,...o}}if(Object.keys(s).length>0){const i=await V(e).patch(s,`/custom_hostnames/${encodeURIComponent(n)}`).res();if(!i.ok)throw new Q(503,{message:await i.text()})}return e.customDomainAdapter.update(t,n,r)}}}class wa{constructor(t){this.config=t}config;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(t){return this.config.keyPrefix?`${this.config.keyPrefix}:${t}`:t}createRequest(t){return new Request(`https://cache.internal/${this.getKey(t)}`)}async get(t){try{const n=await this.getCache(),r=this.createRequest(t),o=await n.match(r);if(!o)return null;const s=await o.text();if(!s)return await this.delete(t),null;let i;try{i=JSON.parse(s)}catch{return await this.delete(t),null}return i.expiresAt&&new Date(i.expiresAt)<new Date?(await this.delete(t),null):i.value}catch(n){return console.error(`CloudflareCache: get error for key ${t}:`,n),null}}async set(t,n,r){try{const o=await this.getCache(),s=r??this.config.defaultTtlSeconds,i=s!==void 0,a=i?Math.max(0,s):0,c={value:n,expiresAt:i?new Date(Date.now()+(a>0?a*1e3:-1)).toISOString():void 0,cachedAt:new Date().toISOString()},u=this.createRequest(t),d={"Content-Type":"application/json"};i&&a>0&&(d["Cache-Control"]=`max-age=${a}`);const p=new Response(JSON.stringify(c),{headers:d});await o.put(u,p)}catch(o){console.error(`CloudflareCache: set error for key ${t}:`,o)}}async delete(t){try{const n=await this.getCache(),r=this.createRequest(t);return await n.delete(r)}catch(n){return console.error(`CloudflareCache: delete error for key ${t}:`,n),!1}}async deleteByPrefix(t){return console.warn("CloudflareCache.deleteByPrefix() is not implemented - Cloudflare Cache API does not support prefix-based deletion"),0}async clear(){console.warn("CloudflareCache.clear() is not implemented - Cloudflare Cache API does not support clearing all entries")}}function $a(e={}){const t={defaultTtlSeconds:300,keyPrefix:"authhero",...e};return new wa(t)}let ka="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",Er=(e=21)=>{let t="",n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=ka[n[e]&63];return t};async function Je(e,t){const n=e.timeout||3e4,r=new AbortController,o=setTimeout(()=>r.abort(),n);try{const s=`https://api.sql.cloudflarestorage.com/api/v1/accounts/${e.accountId}/r2-sql/query/${e.warehouseName}`,i=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.authToken}`},body:JSON.stringify({query:t}),signal:r.signal});if(!i.ok)throw new Error(`R2 SQL query failed: ${i.status} ${i.statusText}`);const a=await i.json();if(!a.success&&a.errors)throw new Error(`R2 SQL error: ${a.errors.join(", ")}`);return a.data||a.result?.data||[]}finally{clearTimeout(o)}}function $e(e){return`'${e.replace(/'/g,"''")}'`}function q(e){return`"${e.replace(/"/g,'""')}"`}function Or(e){const t=n=>{if(!n)return"";try{return JSON.parse(n)}catch{return n}};return{type:e.type,date:e.date,description:e.description,ip:e.ip,user_agent:e.user_agent,details:t(e.details),isMobile:!!e.isMobile,user_id:e.user_id,user_name:e.user_name,connection:e.connection,connection_id:e.connection_id,client_id:e.client_id,client_name:e.client_name,audience:e.audience,scope:e.scope,strategy:e.strategy,strategy_type:e.strategy_type,hostname:e.hostname,auth0_client:t(e.auth0_client),log_id:e.id,location_info:e.country_code||e.city_name||e.latitude||e.longitude||e.time_zone||e.continent_code?{country_code:e.country_code||"",city_name:e.city_name||"",latitude:e.latitude||"",longitude:e.longitude||"",time_zone:e.time_zone||"",continent_code:e.continent_code||""}:void 0}}function Sa(e){return async(t,n)=>{const r=n.log_id||Er(),o={...n,log_id:r};return await za(e,t,o),o}}async function za(e,t,n){const r=s=>s?JSON.stringify(s):void 0,o={id:n.log_id,tenant_id:t,type:n.type,date:n.date,description:n.description?.substring(0,256),ip:n.ip,user_agent:n.user_agent,details:r(n.details)?.substring(0,8192),isMobile:n.isMobile?1:0,user_id:n.user_id,user_name:n.user_name,connection:n.connection,connection_id:n.connection_id,client_id:n.client_id,client_name:n.client_name,audience:n.audience,scope:n.scope,strategy:n.strategy,strategy_type:n.strategy_type,hostname:n.hostname,auth0_client:r(n.auth0_client),log_id:n.log_id,country_code:n.location_info?.country_code,city_name:n.location_info?.city_name,latitude:n.location_info?.latitude,longitude:n.location_info?.longitude,time_zone:n.location_info?.time_zone,continent_code:n.location_info?.continent_code};try{if(e.pipelineBinding)await e.pipelineBinding.send([o]);else if(e.pipelineEndpoint){const s=e.timeout||3e4,i=new AbortController,a=setTimeout(()=>i.abort(),s);try{const c=await fetch(e.pipelineEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify([o]),signal:i.signal});if(!c.ok)throw new Error(`Pipeline ingestion failed: ${c.status} ${c.statusText}`)}finally{clearTimeout(a)}}else throw new Error("Either pipelineEndpoint or pipelineBinding must be configured")}catch(s){throw console.error("Failed to send log to Pipeline:",s),s}}function Ea(e){return async(t,n)=>{const r=e.namespace||"default",o=e.tableName||"logs",s=`
65
+ SELECT * FROM ${q(r)}.${q(o)}
66
+ WHERE tenant_id = ${$e(t)}
67
+ AND id = ${$e(n)}
5
68
  LIMIT 1
6
- `,i=await He(t,a);if(i.length===0)return null;const o=i[0];return o?mt(o):null}}function vn(t){const e={};return(t.match(/(\w+):(\S+)/g)||[]).forEach(s=>{const[r,a]=s.split(":");r&&a&&(e[r]=a)}),e}function bn(t){const e=[];for(const[n,s]of Object.entries(t)){const r=n.replace(/[^a-zA-Z0-9_]/g,"");r&&s&&e.push(`${J(r)} = ${ke(s)}`)}return e}function xn(t){return async(e,n={})=>{const{page:s=0,per_page:r=50,include_totals:a=!1,sort:i,q:o}=n,c=t.namespace||"default",d=t.tableName||"logs",f=[`tenant_id = ${ke(e)}`];if(o){const R=vn(o);f.push(...bn(R))}const x=f.join(" AND ");let T="ORDER BY date DESC";if(i&&i.sort_by){const R=i.sort_by.replace(/[^a-zA-Z0-9_]/g,""),q=i.sort_order==="asc"?"ASC":"DESC";T=`ORDER BY ${J(R)} ${q}`}const E=s*r,A=`LIMIT ${r} OFFSET ${E}`,M=`
7
- SELECT * FROM ${J(c)}.${J(d)}
8
- WHERE ${x}
9
- ${T}
10
- ${A}
11
- `,P=(await He(t,M)).map(mt);if(!a)return{logs:P,start:0,limit:0,length:0};const O=`
12
- SELECT COUNT(*) as count FROM ${J(c)}.${J(d)}
13
- WHERE ${x}
14
- `,S=(await He(t,O))[0]?.count||0;return{logs:P,start:E,limit:r,length:Number(S)}}}function kn(){return{async getDaily(){throw new Error("Stats queries are not supported by R2 SQL logs adapter. Use Analytics Engine or Kysely adapter instead.")},async getActiveUsers(){throw new Error("Stats queries are not supported by R2 SQL logs adapter. Use Analytics Engine or Kysely adapter instead.")}}}function yt(t){const e=!!t.pipelineEndpoint,n=!!t.pipelineBinding;if(!e&&!n)throw new Error('R2 SQL logs adapter requires one of: "pipelineEndpoint" or "pipelineBinding"');if(!t.authToken)throw new Error('R2 SQL logs adapter requires "authToken" configuration');if(!t.warehouseName)throw new Error('R2 SQL logs adapter requires "warehouseName" configuration');return{create:yn(t),list:xn(t),get:_n(t)}}async function oe(t,e){const n=t.timeout||3e4,s=new AbortController,r=setTimeout(()=>s.abort(),n);try{const a=`https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`,i=await fetch(a,{method:"POST",headers:{"Content-Type":"text/plain",Authorization:`Bearer ${t.apiToken}`},body:e,signal:s.signal});if(!i.ok){const c=await i.text();throw new Error(`Analytics Engine query failed: ${i.status} ${i.statusText} - ${c}`)}const o=await i.json();if(!o.success&&o.errors&&o.errors.length>0)throw new Error(`Analytics Engine error: ${o.errors.map(c=>c.message).join(", ")}`);return o.data||[]}finally{clearTimeout(r)}}function N(t){return`'${t.replace(/'/g,"''").replace(/\\/g,"\\\\")}'`}function I(t){return`"${t.replace(/"/g,'""')}"`}function gt(t){const e=r=>{if(r)try{return JSON.parse(r)}catch{return}},n=t.double2||t.timestamp,s=n?new Date(n).toISOString():"";return{log_id:t.blob1,type:t.blob3,date:s,description:t.blob4,ip:t.blob5,user_agent:t.blob6,user_id:t.blob7,user_name:t.blob8,connection:t.blob9,connection_id:t.blob10,client_id:t.blob11,client_name:t.blob12,audience:t.blob13,scope:t.blob14,strategy:t.blob15,strategy_type:t.blob16,hostname:t.blob17,details:e(t.blob18),auth0_client:e(t.blob19),location_info:e(t.blob20),isMobile:t.double1===1}}function wn(t){return async(e,n)=>{const s=n.log_id||pt(),r={...n,log_id:s};return Sn(t,e,r),r}}function Sn(t,e,n){if(!t.analyticsEngineBinding){console.error("Analytics Engine binding not configured");return}const s=a=>a==null?"":typeof a=="string"?a:JSON.stringify(a),r=(a,i=1024)=>a.substring(0,i);try{t.analyticsEngineBinding.writeDataPoint({blobs:[r(n.log_id),r(e),r(n.type||""),r(n.description||""),r(n.ip||""),r(n.user_agent||""),r(n.user_id||""),r(n.user_name||""),r(n.connection||""),r(n.connection_id||""),r(n.client_id||""),r(n.client_name||""),r(n.audience||""),r(n.scope||""),r(n.strategy||""),r(n.strategy_type||""),r(n.hostname||""),r(s(n.details)),r(s(n.auth0_client)),r(s(n.location_info))],doubles:[n.isMobile?1:0,new Date(n.date).getTime()],indexes:[e.substring(0,96)]})}catch(a){console.error("Failed to write log to Analytics Engine:",a)}}function En(t){return async(e,n)=>{const s=t.dataset||"authhero_logs",r=`
69
+ `,i=await Je(e,s);if(i.length===0)return null;const a=i[0];return a?Or(a):null}}function Oa(e){const t={};return(e.match(/(\w+):(\S+)/g)||[]).forEach(r=>{const[o,s]=r.split(":");o&&s&&(t[o]=s)}),t}function Ia(e){const t=[];for(const[n,r]of Object.entries(e)){const o=n.replace(/[^a-zA-Z0-9_]/g,"");o&&r&&t.push(`${q(o)} = ${$e(r)}`)}return t}function Ta(e){return async(t,n={})=>{const{page:r=0,per_page:o=50,include_totals:s=!1,sort:i,q:a}=n,c=e.namespace||"default",u=e.tableName||"logs",d=[`tenant_id = ${$e(t)}`];if(a){const w=Oa(a);d.push(...Ia(w))}const p=d.join(" AND ");let h="ORDER BY date DESC";if(i&&i.sort_by){const w=i.sort_by.replace(/[^a-zA-Z0-9_]/g,""),A=i.sort_order==="asc"?"ASC":"DESC";h=`ORDER BY ${q(w)} ${A}`}const f=r*o,m=`LIMIT ${o} OFFSET ${f}`,Z=`
70
+ SELECT * FROM ${q(c)}.${q(u)}
71
+ WHERE ${p}
72
+ ${h}
73
+ ${m}
74
+ `,O=(await Je(e,Z)).map(Or);if(!s)return{logs:O,start:0,limit:0,length:0};const I=`
75
+ SELECT COUNT(*) as count FROM ${q(c)}.${q(u)}
76
+ WHERE ${p}
77
+ `,_=(await Je(e,I))[0]?.count||0;return{logs:O,start:f,limit:o,length:Number(_)}}}function Za(){return{async getDaily(){throw new Error("Stats queries are not supported by R2 SQL logs adapter. Use Analytics Engine or Kysely adapter instead.")},async getActiveUsers(){throw new Error("Stats queries are not supported by R2 SQL logs adapter. Use Analytics Engine or Kysely adapter instead.")}}}function Ir(e){const t=!!e.pipelineEndpoint,n=!!e.pipelineBinding;if(!t&&!n)throw new Error('R2 SQL logs adapter requires one of: "pipelineEndpoint" or "pipelineBinding"');if(!e.authToken)throw new Error('R2 SQL logs adapter requires "authToken" configuration');if(!e.warehouseName)throw new Error('R2 SQL logs adapter requires "warehouseName" configuration');return{create:Sa(e),list:Ta(e),get:Ea(e)}}async function se(e,t){const n=e.timeout||3e4,r=new AbortController,o=setTimeout(()=>r.abort(),n);try{const s=`https://api.cloudflare.com/client/v4/accounts/${e.accountId}/analytics_engine/sql`,i=await fetch(s,{method:"POST",headers:{"Content-Type":"text/plain",Authorization:`Bearer ${e.apiToken}`},body:t,signal:r.signal});if(!i.ok){const c=await i.text();throw new Error(`Analytics Engine query failed: ${i.status} ${i.statusText} - ${c}`)}const a=await i.json();if(!a.success&&a.errors&&a.errors.length>0)throw new Error(`Analytics Engine error: ${a.errors.map(c=>c.message).join(", ")}`);return a.data||[]}finally{clearTimeout(o)}}function N(e){return`'${e.replace(/'/g,"''").replace(/\\/g,"\\\\")}'`}function R(e){return`"${e.replace(/"/g,'""')}"`}function Tr(e){const t=o=>{if(o)try{return JSON.parse(o)}catch{return}},n=e.double2||e.timestamp,r=n?new Date(n).toISOString():"";return{log_id:e.blob1,type:e.blob3,date:r,description:e.blob4,ip:e.blob5,user_agent:e.blob6,user_id:e.blob7,user_name:e.blob8,connection:e.blob9,connection_id:e.blob10,client_id:e.blob11,client_name:e.blob12,audience:e.blob13,scope:e.blob14,strategy:e.blob15,strategy_type:e.blob16,hostname:e.blob17,details:t(e.blob18),auth0_client:t(e.blob19),location_info:t(e.blob20),isMobile:e.double1===1}}function Aa(e){return async(t,n)=>{const r=n.log_id||Er(),o={...n,log_id:r};return Na(e,t,o),o}}function Na(e,t,n){if(!e.analyticsEngineBinding){console.error("Analytics Engine binding not configured");return}const r=s=>s==null?"":typeof s=="string"?s:JSON.stringify(s),o=(s,i=1024)=>s.substring(0,i);try{e.analyticsEngineBinding.writeDataPoint({blobs:[o(n.log_id),o(t),o(n.type||""),o(n.description||""),o(n.ip||""),o(n.user_agent||""),o(n.user_id||""),o(n.user_name||""),o(n.connection||""),o(n.connection_id||""),o(n.client_id||""),o(n.client_name||""),o(n.audience||""),o(n.scope||""),o(n.strategy||""),o(n.strategy_type||""),o(n.hostname||""),o(r(n.details)),o(r(n.auth0_client)),o(r(n.location_info))],doubles:[n.isMobile?1:0,new Date(n.date).getTime()],indexes:[t.substring(0,96)]})}catch(s){console.error("Failed to write log to Analytics Engine:",s)}}function Ca(e){return async(t,n)=>{const r=e.dataset||"authhero_logs",o=`
15
78
  SELECT *
16
- FROM ${I(s)}
17
- WHERE index1 = ${N(e)}
79
+ FROM ${R(r)}
80
+ WHERE index1 = ${N(t)}
18
81
  AND blob1 = ${N(n)}
19
82
  LIMIT 1
20
- `,a=await oe(t,r);return a.length===0||!a[0]?null:gt(a[0])}}function Cn(t){const e={},n=/(\w+):(?:"([^"]*)"|(\S+))/g;let s;for(;(s=n.exec(t))!==null;){const r=s[1],a=s[2]!==void 0?s[2]:s[3];!r||a===void 0||(e[r]||(e[r]=[]),e[r].push(a))}return e}function _t(t){return{log_id:"blob1",tenant_id:"blob2",type:"blob3",description:"blob4",ip:"blob5",user_agent:"blob6",user_id:"blob7",user_name:"blob8",connection:"blob9",connection_id:"blob10",client_id:"blob11",client_name:"blob12",audience:"blob13",scope:"blob14",strategy:"blob15",strategy_type:"blob16",hostname:"blob17"}[t]||null}function Tn(t){const e=[];for(const[n,s]of Object.entries(t)){const r=s.filter(i=>i!=="");if(r.length===0)continue;if(n==="success"){const i=[],o=new Set;for(const c of r)o.has(c)||(o.add(c),c==="true"?i.push("blob3 LIKE 's%'"):c==="false"&&i.push("blob3 LIKE 'f%'"));i.length>0&&e.push(`(${i.join(" OR ")})`);continue}const a=_t(n);if(a)if(r.length===1)e.push(`${a} = ${N(r[0])}`);else{const i=r.map(o=>N(o)).join(", ");e.push(`${a} IN (${i})`)}}return e}function An(t){if(t==="date")return"double2";const e=_t(t);return e||"timestamp"}function On(t){return async(e,n={})=>{const{page:s=0,per_page:r=50,include_totals:a=!1,sort:i,q:o,from_date:c,to_date:d}=n,f=t.dataset||"authhero_logs",x=[`index1 = ${N(e)}`];if(o){const S=Cn(o);x.push(...Tn(S))}typeof c=="number"&&Number.isFinite(c)&&x.push(`double2 >= ${Math.floor(c)*1e3}`),typeof d=="number"&&Number.isFinite(d)&&x.push(`double2 <= ${Math.floor(d)*1e3}`);const T=x.join(" AND ");let E="ORDER BY timestamp DESC";if(i&&i.sort_by){const S=An(i.sort_by),R=i.sort_order==="asc"?"ASC":"DESC";E=`ORDER BY ${S} ${R}`}const A=s*r,M=`LIMIT ${r} OFFSET ${A}`,k=`
83
+ `,s=await se(e,o);return s.length===0||!s[0]?null:Tr(s[0])}}function ja(e){const t={},n=/(\w+):(?:"([^"]*)"|(\S+))/g;let r;for(;(r=n.exec(e))!==null;){const o=r[1],s=r[2]!==void 0?r[2]:r[3];!o||s===void 0||(t[o]||(t[o]=[]),t[o].push(s))}return t}function Zr(e){return{log_id:"blob1",tenant_id:"blob2",type:"blob3",description:"blob4",ip:"blob5",user_agent:"blob6",user_id:"blob7",user_name:"blob8",connection:"blob9",connection_id:"blob10",client_id:"blob11",client_name:"blob12",audience:"blob13",scope:"blob14",strategy:"blob15",strategy_type:"blob16",hostname:"blob17"}[e]||null}function Pa(e){const t=[];for(const[n,r]of Object.entries(e)){const o=r.filter(i=>i!=="");if(o.length===0)continue;if(n==="success"){const i=[],a=new Set;for(const c of o)a.has(c)||(a.add(c),c==="true"?i.push("blob3 LIKE 's%'"):c==="false"&&i.push("blob3 LIKE 'f%'"));i.length>0&&t.push(`(${i.join(" OR ")})`);continue}const s=Zr(n);if(s)if(o.length===1)t.push(`${s} = ${N(o[0])}`);else{const i=o.map(a=>N(a)).join(", ");t.push(`${s} IN (${i})`)}}return t}function Ra(e){if(e==="date")return"double2";const t=Zr(e);return t||"timestamp"}function Da(e){return async(t,n={})=>{const{page:r=0,per_page:o=50,include_totals:s=!1,sort:i,q:a,from_date:c,to_date:u}=n,d=e.dataset||"authhero_logs",p=[`index1 = ${N(t)}`];if(a){const _=ja(a);p.push(...Pa(_))}typeof c=="number"&&Number.isFinite(c)&&p.push(`double2 >= ${Math.floor(c)*1e3}`),typeof u=="number"&&Number.isFinite(u)&&p.push(`double2 <= ${Math.floor(u)*1e3}`);const h=p.join(" AND ");let f="ORDER BY timestamp DESC";if(i&&i.sort_by){const _=Ra(i.sort_by),w=i.sort_order==="asc"?"ASC":"DESC";f=`ORDER BY ${_} ${w}`}const m=r*o,Z=`LIMIT ${o} OFFSET ${m}`,y=`
21
84
  SELECT *
22
- FROM ${I(f)}
23
- WHERE ${T}
24
- ${E}
25
- ${M}
26
- `,O=(await oe(t,k)).map(gt);if(!a)return{logs:O,start:0,limit:0,length:0};const w=`
85
+ FROM ${R(d)}
86
+ WHERE ${h}
87
+ ${f}
88
+ ${Z}
89
+ `,I=(await se(e,y)).map(Tr);if(!s)return{logs:I,start:0,limit:0,length:0};const v=`
27
90
  SELECT count() as count
28
- FROM ${I(f)}
29
- WHERE ${T}
30
- `;try{const R=(await oe(t,w))[0]?.count||0;return{logs:O,start:A,limit:r,length:Number(R)}}catch{return{logs:O,start:A,limit:r,length:O.length}}}}const Ge=["s"],Nn=["pwd_leak"];function Ke(t){return`${t.slice(0,4)}-${t.slice(4,6)}-${t.slice(6,8)}`}function Xe(t){return t.toISOString().split("T")[0]}function $n(t){const e=t.dataset||"authhero_logs";return{async getDaily(n,s={}){const{from:r,to:a}=s,i=new Date,o=new Date(i);o.setDate(o.getDate()-30);const c=r?Ke(r):Xe(o),d=a?Ke(a):Xe(i),f=new Date(`${c}T00:00:00Z`).getTime(),x=new Date(`${d}T23:59:59.999Z`).getTime(),T=Ge.map(k=>N(k)).join(", "),E=Nn.map(k=>N(k)).join(", "),A=`
91
+ FROM ${R(d)}
92
+ WHERE ${h}
93
+ `;try{const w=(await se(e,v))[0]?.count||0;return{logs:I,start:m,limit:o,length:Number(w)}}catch{return{logs:I,start:m,limit:o,length:I.length}}}}const wt=["s"],xa=["pwd_leak"];function $t(e){return`${e.slice(0,4)}-${e.slice(4,6)}-${e.slice(6,8)}`}function kt(e){return e.toISOString().split("T")[0]}function Ma(e){const t=e.dataset||"authhero_logs";return{async getDaily(n,r={}){const{from:o,to:s}=r,i=new Date,a=new Date(i);a.setDate(a.getDate()-30);const c=o?$t(o):kt(a),u=s?$t(s):kt(i),d=new Date(`${c}T00:00:00Z`).getTime(),p=new Date(`${u}T23:59:59.999Z`).getTime(),h=wt.map(y=>N(y)).join(", "),f=xa.map(y=>N(y)).join(", "),m=`
31
94
  SELECT
32
95
  toDate(toDateTime(double2 / 1000)) AS date,
33
- SUM(CASE WHEN blob3 IN (${T}) THEN 1 ELSE 0 END) AS logins,
96
+ SUM(CASE WHEN blob3 IN (${h}) THEN 1 ELSE 0 END) AS logins,
34
97
  SUM(CASE WHEN blob3 = 'ss' THEN 1 ELSE 0 END) AS signups,
35
- SUM(CASE WHEN blob3 IN (${E}) THEN 1 ELSE 0 END) AS leaked_passwords,
98
+ SUM(CASE WHEN blob3 IN (${f}) THEN 1 ELSE 0 END) AS leaked_passwords,
36
99
  MIN(double2) AS first_event,
37
100
  MAX(double2) AS last_event
38
- FROM "${e}"
101
+ FROM "${t}"
39
102
  WHERE index1 = ${N(n)}
40
- AND double2 >= ${f}
41
- AND double2 <= ${x}
103
+ AND double2 >= ${d}
104
+ AND double2 <= ${p}
42
105
  GROUP BY date
43
106
  ORDER BY date ASC
44
- `;return(await oe(t,A)).map(k=>({date:String(k.date),logins:Number(k.logins)||0,signups:Number(k.signups)||0,leaked_passwords:Number(k.leaked_passwords)||0,created_at:k.first_event?new Date(Number(k.first_event)).toISOString():new Date().toISOString(),updated_at:k.last_event?new Date(Number(k.last_event)).toISOString():new Date().toISOString()}))},async getActiveUsers(n){const s=new Date;s.setDate(s.getDate()-30);const r=s.getTime(),a=Ge.map(d=>N(d)).join(", "),i=`
107
+ `;return(await se(e,m)).map(y=>({date:String(y.date),logins:Number(y.logins)||0,signups:Number(y.signups)||0,leaked_passwords:Number(y.leaked_passwords)||0,created_at:y.first_event?new Date(Number(y.first_event)).toISOString():new Date().toISOString(),updated_at:y.last_event?new Date(Number(y.last_event)).toISOString():new Date().toISOString()}))},async getActiveUsers(n){const r=new Date;r.setDate(r.getDate()-30);const o=r.getTime(),s=wt.map(u=>N(u)).join(", "),i=`
45
108
  SELECT COUNT(DISTINCT blob7) AS count
46
- FROM "${e}"
109
+ FROM "${t}"
47
110
  WHERE index1 = ${N(n)}
48
- AND double2 >= ${r}
49
- AND blob3 IN (${a})
111
+ AND double2 >= ${o}
112
+ AND blob3 IN (${s})
50
113
  AND blob7 IS NOT NULL
51
114
  AND blob7 != ''
52
- `,c=(await oe(t,i))[0];return c&&c.count!==void 0&&Number(c.count)||0}}}const Rn={"active-users":["s","seacft"],logins:["s","f","fp"],signups:["ss","fs"],"refresh-tokens":["seacft","fertft"],sessions:["slo"]},In={connection:"blob9",client_id:"blob11",user_type:"blob16",event:"blob3"},jn={connection:"blob9",client_id:"blob11",user_type:"blob16",user_id:"blob7"},Dn={"active-users":{expr:"count(DISTINCT blob7)",alias:"active_users",type:"UInt64"},logins:{expr:"count()",alias:"logins",type:"UInt64"},signups:{expr:"count()",alias:"signups",type:"UInt64"},"refresh-tokens":{expr:"count()",alias:"refresh_tokens",type:"UInt64"},sessions:{expr:"count()",alias:"sessions",type:"UInt64"}};function Ln(t,e){const n=`toDateTime(intDiv(double2, 1000), ${N(e)})`;switch(t){case"hour":return`toStartOfHour(${n})`;case"week":return`toStartOfWeek(${n})`;case"month":return`toStartOfMonth(${n})`;default:return`toStartOfDay(${n})`}}function Zn(t){return t==="hour"?"DateTime":"Date"}function Mn(t,e,n){const s=new Date(t.from).getTime(),r=new Date(t.to).getTime(),a=n.map(o=>N(o)).join(", "),i=[`index1 = ${N(e)}`,`double2 >= ${s}`,`double2 < ${r}`,`blob3 IN (${a})`];for(const[o,c]of Object.entries(jn)){const d=t.filters[o];if(d&&d.length>0){const f=d.map(x=>N(x)).join(", ");i.push(`${c} IN (${f})`)}}return i.join(" AND ")}function Pn(t,e,n){if(t.order_by){const s=t.order_by.startsWith("-"),r=s?t.order_by.slice(1):t.order_by;return`${I(r)} ${s?"DESC":"ASC"}`}return e.length>0?e[0]==="time"?`${I("time")} ASC`:`${I(n)} DESC`:`${I(n)} DESC`}function vt(t){const e=t.dataset||"authhero_logs";return{async query(n,s,r){const a=Rn[s],i=Dn[s],o=[],c=[];for(const w of r.group_by)if(w==="time"){const S=Ln(r.interval,r.tz);o.push(`${S} AS ${I("time")}`),c.push({name:"time",type:Zn(r.interval)})}else{const S=In[w];o.push(`${S} AS ${I(w)}`),c.push({name:w,type:"String"})}c.push({name:i.alias,type:i.type});const d=[...o,`${i.expr} AS ${I(i.alias)}`],f=r.group_by.length?`GROUP BY ${r.group_by.map(w=>I(w==="time"?"time":w)).join(", ")}`:"",x=r.group_by.map(w=>w==="time"?"time":w),T=Pn(r,x,i.alias),E=`
53
- SELECT ${d.join(", ")}
54
- FROM ${I(e)}
55
- WHERE ${Mn(r,n,a)}
56
- ${f}
57
- ORDER BY ${T}
58
- LIMIT ${Math.max(0,r.limit)} OFFSET ${Math.max(0,r.offset)}
115
+ `,c=(await se(e,i))[0];return c&&c.count!==void 0&&Number(c.count)||0}}}const La={"active-users":["s","seacft"],logins:["s","f","fp"],signups:["ss","fs"],"refresh-tokens":["seacft","fertft"],sessions:["slo"]},Ua={connection:"blob9",client_id:"blob11",user_type:"blob16",event:"blob3"},Fa={connection:"blob9",client_id:"blob11",user_type:"blob16",user_id:"blob7"},Ja={"active-users":{expr:"count(DISTINCT blob7)",alias:"active_users",type:"UInt64"},logins:{expr:"count()",alias:"logins",type:"UInt64"},signups:{expr:"count()",alias:"signups",type:"UInt64"},"refresh-tokens":{expr:"count()",alias:"refresh_tokens",type:"UInt64"},sessions:{expr:"count()",alias:"sessions",type:"UInt64"}};function Ba(e,t){const n=`toDateTime(intDiv(double2, 1000), ${N(t)})`;switch(e){case"hour":return`toStartOfHour(${n})`;case"week":return`toStartOfWeek(${n})`;case"month":return`toStartOfMonth(${n})`;default:return`toStartOfDay(${n})`}}function qa(e){return e==="hour"?"DateTime":"Date"}function Wa(e,t,n){const r=new Date(e.from).getTime(),o=new Date(e.to).getTime(),s=n.map(a=>N(a)).join(", "),i=[`index1 = ${N(t)}`,`double2 >= ${r}`,`double2 < ${o}`,`blob3 IN (${s})`];for(const[a,c]of Object.entries(Fa)){const u=e.filters[a];if(u&&u.length>0){const d=u.map(p=>N(p)).join(", ");i.push(`${c} IN (${d})`)}}return i.join(" AND ")}function Va(e,t,n){if(e.order_by){const r=e.order_by.startsWith("-"),o=r?e.order_by.slice(1):e.order_by;return`${R(o)} ${r?"DESC":"ASC"}`}return t.length>0?t[0]==="time"?`${R("time")} ASC`:`${R(n)} DESC`:`${R(n)} DESC`}function Ar(e){const t=e.dataset||"authhero_logs";return{async query(n,r,o){const s=La[r],i=Ja[r],a=[],c=[];for(const v of o.group_by)if(v==="time"){const _=Ba(o.interval,o.tz);a.push(`${_} AS ${R("time")}`),c.push({name:"time",type:qa(o.interval)})}else{const _=Ua[v];a.push(`${_} AS ${R(v)}`),c.push({name:v,type:"String"})}c.push({name:i.alias,type:i.type});const u=[...a,`${i.expr} AS ${R(i.alias)}`],d=o.group_by.length?`GROUP BY ${o.group_by.map(v=>R(v==="time"?"time":v)).join(", ")}`:"",p=o.group_by.map(v=>v==="time"?"time":v),h=Va(o,p,i.alias),f=`
116
+ SELECT ${u.join(", ")}
117
+ FROM ${R(t)}
118
+ WHERE ${Wa(o,n,s)}
119
+ ${d}
120
+ ORDER BY ${h}
121
+ LIMIT ${Math.max(0,o.limit)} OFFSET ${Math.max(0,o.offset)}
59
122
  FORMAT JSON
60
- `,A=`https://api.cloudflare.com/client/v4/accounts/${t.accountId}/analytics_engine/sql`,M=t.timeout||3e4,k=new AbortController,P=setTimeout(()=>k.abort(),M),O=Date.now();try{const w=await fetch(A,{method:"POST",headers:{"Content-Type":"text/plain",Authorization:`Bearer ${t.apiToken}`},body:E,signal:k.signal});if(!w.ok){const q=await w.text();throw new Error(`Analytics Engine query failed: ${w.status} ${w.statusText} - ${q}`)}const S=await w.json();if(S.success===!1&&S.errors?.length)throw new Error(`Analytics Engine error: ${S.errors.map(q=>q.message).join(", ")}`);const R=S.data??[];return{meta:S.meta??c,data:R,rows:S.rows??R.length,rows_before_limit_at_least:S.rows_before_limit_at_least??R.length,statistics:{elapsed:(Date.now()-O)/1e3}}}finally{clearTimeout(P)}}}}function bt(t){return t.analyticsEngineBinding||console.warn("Analytics Engine: No binding configured. Logs will not be written to Analytics Engine."),(!t.accountId||!t.apiToken)&&console.warn("Analytics Engine: accountId and apiToken are required for querying logs via SQL API."),{create:wn(t),list:On(t),get:En(t)}}const Bn="authhero_action_executions",Un=1024,et="[truncated]";function tt(t){if(!(typeof t!="string"||t.length===0))try{return JSON.parse(t)}catch{return}}function Fn(t){const e=st.actionExecutionStatusSchema.safeParse(t);return e.success?e.data:"unspecified"}function G(t,e=Un){return t.length<=e?t:`${t.substring(0,e-et.length)}${et}`}function nt(t){return t==null?"":JSON.stringify(t)}function qn(t){const e=typeof t.blob6=="string"&&t.blob6.length>0?t.blob6:typeof t.double1=="number"?new Date(t.double1).toISOString():"",n=typeof t.blob7=="string"&&t.blob7.length>0?t.blob7:e;return{id:typeof t.blob1=="string"?t.blob1:"",tenant_id:typeof t.index1=="string"?t.index1:"",trigger_id:typeof t.blob2=="string"?t.blob2:"",status:Fn(t.blob3),results:tt(t.blob4)??[],logs:tt(t.blob5),created_at:e,updated_at:n}}function Vn(t){return async(e,n)=>{const s=Date.now(),r=new Date(s).toISOString(),a={id:n.id,tenant_id:e,trigger_id:n.trigger_id,status:n.status,results:n.results,logs:n.logs,created_at:r,updated_at:r};return zn(t,e,a,s),a}}function zn(t,e,n,s){if(!t.analyticsEngineBinding){console.error("Analytics Engine action_executions binding not configured; skipping write");return}try{t.analyticsEngineBinding.writeDataPoint({blobs:[G(n.id),G(n.trigger_id),G(n.status),G(nt(n.results)),G(nt(n.logs)),G(n.created_at),G(n.updated_at)],doubles:[s],indexes:[e.substring(0,96)]})}catch(r){console.error("Failed to write action_execution to Analytics Engine:",r)}}function Wn(t){return async(e,n)=>{const s=t.dataset||Bn,r=`
123
+ `,m=`https://api.cloudflare.com/client/v4/accounts/${e.accountId}/analytics_engine/sql`,Z=e.timeout||3e4,y=new AbortController,O=setTimeout(()=>y.abort(),Z),I=Date.now();try{const v=await fetch(m,{method:"POST",headers:{"Content-Type":"text/plain",Authorization:`Bearer ${e.apiToken}`},body:f,signal:y.signal});if(!v.ok){const A=await v.text();throw new Error(`Analytics Engine query failed: ${v.status} ${v.statusText} - ${A}`)}const _=await v.json();if(_.success===!1&&_.errors?.length)throw new Error(`Analytics Engine error: ${_.errors.map(A=>A.message).join(", ")}`);const w=_.data??[];return{meta:_.meta??c,data:w,rows:_.rows??w.length,rows_before_limit_at_least:_.rows_before_limit_at_least??w.length,statistics:{elapsed:(Date.now()-I)/1e3}}}finally{clearTimeout(O)}}}}function Nr(e){return e.analyticsEngineBinding||console.warn("Analytics Engine: No binding configured. Logs will not be written to Analytics Engine."),(!e.accountId||!e.apiToken)&&console.warn("Analytics Engine: accountId and apiToken are required for querying logs via SQL API."),{create:Aa(e),list:Da(e),get:Ca(e)}}const Ga="authhero_action_executions",Ka=1024,St="[truncated]";function zt(e){if(!(typeof e!="string"||e.length===0))try{return JSON.parse(e)}catch{return}}function Ha(e){const t=Ot.actionExecutionStatusSchema.safeParse(e);return t.success?t.data:"unspecified"}function G(e,t=Ka){return e.length<=t?e:`${e.substring(0,t-St.length)}${St}`}function Et(e){return e==null?"":JSON.stringify(e)}function Ya(e){const t=typeof e.blob6=="string"&&e.blob6.length>0?e.blob6:typeof e.double1=="number"?new Date(e.double1).toISOString():"",n=typeof e.blob7=="string"&&e.blob7.length>0?e.blob7:t;return{id:typeof e.blob1=="string"?e.blob1:"",tenant_id:typeof e.index1=="string"?e.index1:"",trigger_id:typeof e.blob2=="string"?e.blob2:"",status:Ha(e.blob3),results:zt(e.blob4)??[],logs:zt(e.blob5),created_at:t,updated_at:n}}function Qa(e){return async(t,n)=>{const r=Date.now(),o=new Date(r).toISOString(),s={id:n.id,tenant_id:t,trigger_id:n.trigger_id,status:n.status,results:n.results,logs:n.logs,created_at:o,updated_at:o};return Xa(e,t,s,r),s}}function Xa(e,t,n,r){if(!e.analyticsEngineBinding){console.error("Analytics Engine action_executions binding not configured; skipping write");return}try{e.analyticsEngineBinding.writeDataPoint({blobs:[G(n.id),G(n.trigger_id),G(n.status),G(Et(n.results)),G(Et(n.logs)),G(n.created_at),G(n.updated_at)],doubles:[r],indexes:[t.substring(0,96)]})}catch(o){console.error("Failed to write action_execution to Analytics Engine:",o)}}function ec(e){return async(t,n)=>{const r=e.dataset||Ga,o=`
61
124
  SELECT *
62
- FROM ${I(s)}
63
- WHERE index1 = ${N(e)}
125
+ FROM ${R(r)}
126
+ WHERE index1 = ${N(t)}
64
127
  AND blob1 = ${N(n)}
65
128
  LIMIT 1
66
- `,a=await oe(t,r);return a.length===0||!a[0]?null:qn(a[0])}}function xt(t){return t.analyticsEngineBinding||console.warn("Analytics Engine: No action_executions binding configured. Executions will not be written."),(!t.accountId||!t.apiToken)&&console.warn("Analytics Engine: accountId and apiToken are required to read action_executions via the SQL API."),{create:Vn(t),get:Wn(t)}}function Jn(){return{async getGeoInfo(t){try{const e=t["cf-ipcountry"],n=t["cf-ipcity"],s=t["cf-iplatitude"],r=t["cf-iplongitude"],a=t["cf-timezone"],i=t["cf-ipcontinent"];return e?{country_code:e,city_name:n||"",latitude:s||"",longitude:r||"",time_zone:a||"",continent_code:i||""}:null}catch(e){return console.warn("Failed to get geo info from Cloudflare headers:",e),null}}}}class Hn{constructor(e){this.bindings=e}bindings;async consume(e,n){const s=this.bindings[e];if(!s)return{allowed:!0};try{const{success:r}=await s.limit({key:n});return{allowed:r}}catch(r){return console.error(`CloudflareRateLimit: limit() error for scope ${e}:`,r),{allowed:!0}}}}function kt(t){if(!(!t||!Object.keys(t).some(n=>t[n])))return new Hn(t)}function wt(t){return`// Auto-generated AuthHero code hook worker
129
+ `,s=await se(e,o);return s.length===0||!s[0]?null:Ya(s[0])}}function Cr(e){return e.analyticsEngineBinding||console.warn("Analytics Engine: No action_executions binding configured. Executions will not be written."),(!e.accountId||!e.apiToken)&&console.warn("Analytics Engine: accountId and apiToken are required to read action_executions via the SQL API."),{create:Qa(e),get:ec(e)}}function tc(){return{async getGeoInfo(e){try{const t=e["cf-ipcountry"],n=e["cf-ipcity"],r=e["cf-iplatitude"],o=e["cf-iplongitude"],s=e["cf-timezone"],i=e["cf-ipcontinent"];return t?{country_code:t,city_name:n||"",latitude:r||"",longitude:o||"",time_zone:s||"",continent_code:i||""}:null}catch(t){return console.warn("Failed to get geo info from Cloudflare headers:",t),null}}}}class nc{constructor(t){this.bindings=t}bindings;async consume(t,n){const r=this.bindings[t];if(!r)return{allowed:!0};try{const{success:o}=await r.limit({key:n});return{allowed:o}}catch(o){return console.error(`CloudflareRateLimit: limit() error for scope ${t}:`,o),{allowed:!0}}}}function jr(e){if(!(!e||!Object.keys(e).some(n=>e[n])))return new nc(e)}function Pr(e){return`// Auto-generated AuthHero code hook worker
67
130
 
68
131
  const fnNames = {
69
132
  "post-user-login": "onExecutePostLogin",
@@ -112,7 +175,7 @@ function createRecordingApiProxy(triggerId) {
112
175
 
113
176
  // --- User code begins ---
114
177
  const exports = {};
115
- ${t}
178
+ ${e}
116
179
  // --- User code ends ---
117
180
 
118
181
  export default {
@@ -166,9 +229,9 @@ export default {
166
229
  }
167
230
  },
168
231
  };
169
- `}class St{config;constructor(e){this.config=e}async execute(e){const n=Date.now();if(!e.hookCodeId)return{success:!1,error:"DispatchNamespaceCodeExecutor requires hookCodeId",durationMs:Date.now()-n,apiCalls:[]};const s=`hook-${e.hookCodeId}`,r=JSON.stringify({triggerId:e.triggerId,event:e.event});try{let a;if(this.config.dispatcher)a=await this.config.dispatcher.get(s,{},{limits:{cpuMs:e.cpuLimitMs??5e3}}).fetch(new Request("https://hook.internal/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:r}));else if(this.config.dispatchUrl)a=await fetch(`${this.config.dispatchUrl}/${s}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiToken}`},body:r});else return{success:!1,error:"No dispatcher binding or dispatchUrl configured",durationMs:Date.now()-n,apiCalls:[]};if(!a.ok){const o=await a.text();return{success:!1,error:`Worker invocation failed (${a.status}): ${o}`,durationMs:Date.now()-n,apiCalls:[]}}return{...await a.json(),durationMs:Date.now()-n}}catch(a){return{success:!1,error:a instanceof Error?a.message:String(a),durationMs:Date.now()-n,apiCalls:[]}}}async deploy(e,n){const s=`hook-${e}`,r=wt(n),a=`https://api.cloudflare.com/client/v4/accounts/${this.config.accountId}/workers/dispatch/namespaces/${this.config.dispatchNamespace}/scripts/${s}`,i=JSON.stringify({main_module:"index.js",compatibility_date:this.config.compatibilityDate??"2024-11-20"}),o=new FormData;o.append("metadata",new Blob([i],{type:"application/json"})),o.append("index.js",new Blob([r],{type:"application/javascript+module"}),"index.js");const c=await fetch(a,{method:"PUT",headers:{Authorization:`Bearer ${this.config.apiToken}`},body:o});if(!c.ok){const d=await c.text();throw new Error(`Failed to deploy hook worker ${s}: ${c.status} ${d}`)}}async remove(e){const n=`hook-${e}`,s=`https://api.cloudflare.com/client/v4/accounts/${this.config.accountId}/workers/dispatch/namespaces/${this.config.dispatchNamespace}/scripts/${n}`,r=await fetch(s,{method:"DELETE",headers:{Authorization:`Bearer ${this.config.apiToken}`}});if(!r.ok&&r.status!==404){const a=await r.text();throw new Error(`Failed to remove hook worker ${n}: ${r.status} ${a}`)}}}const Qn=St,Yn={"post-user-login":"onExecutePostLogin","credentials-exchange":"onExecuteCredentialsExchange","pre-user-registration":"onExecutePreUserRegistration","post-user-registration":"onExecutePostUserRegistration"},Gn={"post-user-login":{accessToken:["setCustomClaim"],idToken:["setCustomClaim"],access:["deny"],prompt:["render"],redirect:["sendUserTo"]},"credentials-exchange":{accessToken:["setCustomClaim"],idToken:["setCustomClaim"],access:["deny"]},"pre-user-registration":{user:["setUserMetadata","setLinkedTo"],access:["deny"]},"post-user-registration":{}};async function Kn(t){const e=new TextEncoder().encode(t),n=await crypto.subtle.digest("SHA-256",e),s=new Uint8Array(n);let r="";for(const a of s)r+=a.toString(16).padStart(2,"0");return r}function Xn(t){return`
170
- const TRIGGER_FN_NAMES = ${JSON.stringify(Yn)};
171
- const API_SHAPES = ${JSON.stringify(Gn)};
232
+ `}class Rr{config;constructor(t){this.config=t}async execute(t){const n=Date.now();if(!t.hookCodeId)return{success:!1,error:"DispatchNamespaceCodeExecutor requires hookCodeId",durationMs:Date.now()-n,apiCalls:[]};const r=`hook-${t.hookCodeId}`,o=JSON.stringify({triggerId:t.triggerId,event:t.event});try{let s;if(this.config.dispatcher)s=await this.config.dispatcher.get(r,{},{limits:{cpuMs:t.cpuLimitMs??5e3}}).fetch(new Request("https://hook.internal/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:o}));else if(this.config.dispatchUrl)s=await fetch(`${this.config.dispatchUrl}/${r}`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.config.apiToken}`},body:o});else return{success:!1,error:"No dispatcher binding or dispatchUrl configured",durationMs:Date.now()-n,apiCalls:[]};if(!s.ok){const a=await s.text();return{success:!1,error:`Worker invocation failed (${s.status}): ${a}`,durationMs:Date.now()-n,apiCalls:[]}}return{...await s.json(),durationMs:Date.now()-n}}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s),durationMs:Date.now()-n,apiCalls:[]}}}async deploy(t,n){const r=`hook-${t}`,o=Pr(n),s=`https://api.cloudflare.com/client/v4/accounts/${this.config.accountId}/workers/dispatch/namespaces/${this.config.dispatchNamespace}/scripts/${r}`,i=JSON.stringify({main_module:"index.js",compatibility_date:this.config.compatibilityDate??"2024-11-20"}),a=new FormData;a.append("metadata",new Blob([i],{type:"application/json"})),a.append("index.js",new Blob([o],{type:"application/javascript+module"}),"index.js");const c=await fetch(s,{method:"PUT",headers:{Authorization:`Bearer ${this.config.apiToken}`},body:a});if(!c.ok){const u=await c.text();throw new Error(`Failed to deploy hook worker ${r}: ${c.status} ${u}`)}}async remove(t){const n=`hook-${t}`,r=`https://api.cloudflare.com/client/v4/accounts/${this.config.accountId}/workers/dispatch/namespaces/${this.config.dispatchNamespace}/scripts/${n}`,o=await fetch(r,{method:"DELETE",headers:{Authorization:`Bearer ${this.config.apiToken}`}});if(!o.ok&&o.status!==404){const s=await o.text();throw new Error(`Failed to remove hook worker ${n}: ${o.status} ${s}`)}}}const rc=Rr,oc={"post-user-login":"onExecutePostLogin","credentials-exchange":"onExecuteCredentialsExchange","pre-user-registration":"onExecutePreUserRegistration","post-user-registration":"onExecutePostUserRegistration"},sc={"post-user-login":{accessToken:["setCustomClaim"],idToken:["setCustomClaim"],access:["deny"],prompt:["render"],redirect:["sendUserTo"]},"credentials-exchange":{accessToken:["setCustomClaim"],idToken:["setCustomClaim"],access:["deny"]},"pre-user-registration":{user:["setUserMetadata","setLinkedTo"],access:["deny"]},"post-user-registration":{}};async function ic(e){const t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t),r=new Uint8Array(n);let o="";for(const s of r)o+=s.toString(16).padStart(2,"0");return o}function ac(e){return`
233
+ const TRIGGER_FN_NAMES = ${JSON.stringify(oc)};
234
+ const API_SHAPES = ${JSON.stringify(sc)};
172
235
  const MAX_LOG_ENTRIES = 50;
173
236
  const MAX_LOG_LENGTH = 500;
174
237
 
@@ -212,7 +275,7 @@ function createCapturingConsole(logs) {
212
275
  // The local \`console\` shadows the global so user code's console.* calls are captured.
213
276
  function loadUserExports(console) {
214
277
  const exports = {};
215
- ${t}
278
+ ${e}
216
279
  return exports;
217
280
  }
218
281
 
@@ -266,4 +329,4 @@ export default {
266
329
  }
267
330
  },
268
331
  };
269
- `}class es{loader;compatibilityDate;constructor(e){this.loader=e.loader,this.compatibilityDate=e.compatibilityDate||"2025-01-01"}async execute(e){const n=Date.now();try{const s=Xn(e.code),r={compatibilityDate:this.compatibilityDate,mainModule:"hook.js",modules:{"hook.js":s}},a=e.hookCodeId?`${e.hookCodeId}-${await Kn(e.code)}`:null;return await(await(a?this.loader.get(a,async()=>r):this.loader.load(r)).getEntrypoint().fetch(new Request("https://hook/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:e.event,triggerId:e.triggerId})}))).json()}catch(s){return{success:!1,error:s instanceof Error?s.message:String(s),durationMs:Date.now()-n,apiCalls:[]}}}}function ts(t){const e={customDomains:hn(t),cache:pn({...t.cacheName&&{cacheName:t.cacheName},...t.defaultTtlSeconds!==void 0&&{defaultTtlSeconds:t.defaultTtlSeconds},...t.keyPrefix&&{keyPrefix:t.keyPrefix}}),geo:Jn()};t.r2SqlLogs?e.logs=yt(t.r2SqlLogs):t.analyticsEngineLogs&&(e.logs=bt(t.analyticsEngineLogs)),t.analyticsEngineLogs&&(e.analytics=vt(t.analyticsEngineLogs)),t.analyticsEngineActionExecutions&&(e.actionExecutions=xt(t.analyticsEngineActionExecutions));const n=kt(t.rateLimitBindings);return n&&(e.rateLimit=n),e}exports.CloudflareCodeExecutor=Qn;exports.DispatchNamespaceCodeExecutor=St;exports.WorkerLoaderCodeExecutor=es;exports.createAnalyticsEngineActionExecutionsAdapter=xt;exports.createAnalyticsEngineAnalyticsAdapter=vt;exports.createAnalyticsEngineLogsAdapter=bt;exports.createAnalyticsEngineStatsAdapter=$n;exports.createCloudflareRateLimitAdapter=kt;exports.createR2SQLLogsAdapter=yt;exports.createR2SQLStatsAdapter=kn;exports.default=ts;exports.generateWorkerScript=wt;
332
+ `}class cc{loader;compatibilityDate;constructor(t){this.loader=t.loader,this.compatibilityDate=t.compatibilityDate||"2025-01-01"}async execute(t){const n=Date.now();try{const r=ac(t.code),o={compatibilityDate:this.compatibilityDate,mainModule:"hook.js",modules:{"hook.js":r}},s=t.hookCodeId?`${t.hookCodeId}-${await ic(t.code)}`:null;return await(await(s?this.loader.get(s,async()=>o):this.loader.load(o)).getEntrypoint().fetch(new Request("https://hook/execute",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({event:t.event,triggerId:t.triggerId})}))).json()}catch(r){return{success:!1,error:r instanceof Error?r.message:String(r),durationMs:Date.now()-n,apiCalls:[]}}}}function uc(e){const t={customDomains:va(e),cache:$a({...e.cacheName&&{cacheName:e.cacheName},...e.defaultTtlSeconds!==void 0&&{defaultTtlSeconds:e.defaultTtlSeconds},...e.keyPrefix&&{keyPrefix:e.keyPrefix}}),geo:tc()};e.r2SqlLogs?t.logs=Ir(e.r2SqlLogs):e.analyticsEngineLogs&&(t.logs=Nr(e.analyticsEngineLogs)),e.analyticsEngineLogs&&(t.analytics=Ar(e.analyticsEngineLogs)),e.analyticsEngineActionExecutions&&(t.actionExecutions=Cr(e.analyticsEngineActionExecutions));const n=jr(e.rateLimitBindings);return n&&(t.rateLimit=n),t}exports.CloudflareCodeExecutor=rc;exports.DispatchNamespaceCodeExecutor=Rr;exports.WorkerLoaderCodeExecutor=cc;exports.createAnalyticsEngineActionExecutionsAdapter=Cr;exports.createAnalyticsEngineAnalyticsAdapter=Ar;exports.createAnalyticsEngineLogsAdapter=Nr;exports.createAnalyticsEngineStatsAdapter=Ma;exports.createCloudflareRateLimitAdapter=jr;exports.createR2SQLLogsAdapter=Ir;exports.createR2SQLStatsAdapter=Za;exports.default=uc;exports.generateWorkerScript=Pr;