@skyramp/testbot-core 0.13.2-v3.481 → 0.13.2-v3.482
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/VERSION.json +1 -1
- package/dist/data-safety-worker.js +23 -23
- package/dist/main.js +496 -493
- package/dist/post.js +147 -147
- package/dist/runner-client.cjs +134 -134
- package/dist/shared-environment-test.cjs +3 -3
- package/dist/shared-environment-test.d.cts +28 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";var He=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var It=Object.getOwnPropertyNames;var Ct=Object.prototype.hasOwnProperty;var at=(r,e)=>{for(var t in e)He(r,t,{get:e[t],enumerable:!0})},jt=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of It(e))!Ct.call(r,n)&&n!==t&&He(r,n,{get:()=>e[n],enumerable:!(s=Et(e,n))||s.enumerable});return r};var Nt=r=>jt(He({},"__esModule",{value:!0}),r);var Qr={};at(Qr,{renderDeliveredSharedTest:()=>Ot,sharedEnvironmentTest:()=>Kr});module.exports=Nt(Qr);var Q=require("node:fs"),Rt=require("node:crypto"),Ee=require("node:path"),At=require("node:test"),Le=require("node:assert");var bt=require("node:crypto");var h={};at(h,{BRAND:()=>ar,DIRTY:()=>X,EMPTY_PATH:()=>Zt,INVALID:()=>y,NEVER:()=>qr,OK:()=>A,ParseStatus:()=>R,Schema:()=>_,ZodAny:()=>Y,ZodArray:()=>W,ZodBigInt:()=>te,ZodBoolean:()=>re,ZodBranded:()=>Ce,ZodCatch:()=>pe,ZodDate:()=>se,ZodDefault:()=>fe,ZodDiscriminatedUnion:()=>Ze,ZodEffects:()=>D,ZodEnum:()=>ue,ZodError:()=>C,ZodFirstPartyTypeKind:()=>g,ZodFunction:()=>Me,ZodIntersection:()=>oe,ZodIssueCode:()=>d,ZodLazy:()=>ce,ZodLiteral:()=>de,ZodMap:()=>Te,ZodNaN:()=>Oe,ZodNativeEnum:()=>le,ZodNever:()=>Z,ZodNull:()=>ae,ZodNullable:()=>V,ZodNumber:()=>ee,ZodObject:()=>j,ZodOptional:()=>P,ZodParsedType:()=>f,ZodPipeline:()=>je,ZodPromise:()=>K,ZodReadonly:()=>he,ZodRecord:()=>Ue,ZodSchema:()=>_,ZodSet:()=>Se,ZodString:()=>G,ZodSymbol:()=>ke,ZodTransformer:()=>D,ZodTuple:()=>z,ZodType:()=>_,ZodUndefined:()=>ne,ZodUnion:()=>ie,ZodUnknown:()=>B,ZodVoid:()=>we,addIssueToContext:()=>l,any:()=>hr,array:()=>vr,bigint:()=>dr,boolean:()=>yt,coerce:()=>Lr,custom:()=>pt,date:()=>ur,datetimeRegex:()=>lt,defaultErrorMap:()=>H,discriminatedUnion:()=>kr,effect:()=>Pr,enum:()=>Cr,function:()=>Ar,getErrorMap:()=>_e,getParsedType:()=>M,instanceof:()=>or,intersection:()=>wr,isAborted:()=>$e,isAsync:()=>xe,isDirty:()=>De,isValid:()=>J,late:()=>ir,lazy:()=>Er,literal:()=>Ir,makeIssue:()=>Ie,map:()=>Or,nan:()=>cr,nativeEnum:()=>jr,never:()=>yr,null:()=>pr,nullable:()=>Dr,number:()=>mt,object:()=>_r,objectUtil:()=>Fe,oboolean:()=>Vr,onumber:()=>zr,optional:()=>$r,ostring:()=>Mr,pipeline:()=>Ur,preprocess:()=>Zr,promise:()=>Nr,quotelessJson:()=>Pt,record:()=>Sr,set:()=>Rr,setErrorMap:()=>Dt,strictObject:()=>xr,string:()=>ht,symbol:()=>lr,transformer:()=>Pr,tuple:()=>Tr,undefined:()=>fr,union:()=>br,unknown:()=>mr,util:()=>x,void:()=>gr});var x;(function(r){r.assertEqual=n=>{};function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{let a={};for(let i of n)a[i]=i;return a},r.getValidEnumValues=n=>{let a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(let o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let a=[];for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(let i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Fe;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Fe||(Fe={}));var f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),M=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}};var d=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Pt=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),C=class r 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]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,c=0;for(;c<i.path.length;){let u=i.path[c],m=c===i.path.length-1;if(u==="_errors"){m&&o._errors.push(t(i)),c++;continue}Object.prototype.hasOwnProperty.call(o,u)||(u==="__proto__"?Object.defineProperty(o,u,{value:{_errors:[]},writable:!0,enumerable:!0,configurable:!0}):o[u]={_errors:[]}),o=o[u],m&&o._errors.push(t(i)),c++}}};return n(this),s}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t=Object.create(null),s=[];for(let n of this.issues)if(n.path.length>0){let a=n.path[0];t[a]=t[a]||[],t[a].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};C.create=r=>new C(r);var $t=(r,e)=>{let t;switch(r.code){case d.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,x.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(r.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(r.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:x.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case d.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case d.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(r)}return{message:t}},H=$t;var it=H;function Dt(r){it=r}function _e(){return it}var Ie=r=>{let{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let o="",c=s.filter(u=>!!u).slice().reverse();for(let u of c)o=u(i,{data:e,defaultError:o}).message;return{...n,path:a,message:o}},Zt=[];function l(r,e){let t=_e(),s=Ie({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===H?void 0:H].filter(n=>!!n)});r.common.issues.push(s)}var R=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let s=[];for(let n of t){if(n.status==="aborted")return y;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let n of t){let a=await n.key,i=await n.value;s.push({key:a,value:i})}return r.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let n of t){let{key:a,value:i}=n;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"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}},y=Object.freeze({status:"aborted"}),X=r=>({status:"dirty",value:r}),A=r=>({status:"valid",value:r}),$e=r=>r.status==="aborted",De=r=>r.status==="dirty",J=r=>r.status==="valid",xe=r=>typeof Promise<"u"&&r instanceof Promise;var p;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(p||(p={}));var $=class{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},ot=(r,e)=>{if(J(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new C(r.common.issues);return this._error=t,this._error}}};function v(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>{let{message:c}=r;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??t??o.defaultError}},description:n}}var _=class{get description(){return this._def.description}_getType(e){return M(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new R,ctx:{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(xe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){let s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},n=this._parseSync({data:e,path:s.path,parent:s});return ot(s,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:t});return J(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>J(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){let s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(xe(n)?n:Promise.resolve(n));return ot(s,a)}refine(e,t){let s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{let i=e(n),o=()=>a.addIssue({code:d.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new D({schema:this,typeName:g.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return P.create(this,this._def)}nullable(){return V.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return W.create(this)}promise(){return K.create(this,this._def)}or(e){return ie.create([this,e],this._def)}and(e){return oe.create(this,e,this._def)}transform(e){return new D({...v(this._def),schema:this,typeName:g.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new fe({...v(this._def),innerType:this,defaultValue:t,typeName:g.ZodDefault})}brand(){return new Ce({typeName:g.ZodBranded,type:this,...v(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new pe({...v(this._def),innerType:this,catchValue:t,typeName:g.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return je.create(this,e)}readonly(){return he.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Ut=/^c[^\s-]{8,}$/i,Mt=/^[0-9a-z]+$/,zt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Vt=/^[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,Lt=/^[a-z0-9_-]{21}$/i,qt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ht=/^[-+]?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)?)??$/,Ft=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Bt="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$",Be,Wt=/^(?:(?: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])$/,Jt=/^(?:(?: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])$/,Gt=/^(([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]))$/,Yt=/^(([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])$/,Kt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Qt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,dt="((\\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])))",Xt=new RegExp(`^${dt}$`);function ut(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);let t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function er(r){return new RegExp(`^${ut(r)}$`)}function lt(r){let e=`${dt}T${ut(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function tr(r,e){return!!((e==="v4"||!e)&&Wt.test(r)||(e==="v6"||!e)&&Gt.test(r))}function rr(r,e){if(!qt.test(r))return!1;try{let[t]=r.split(".");if(!t)return!1;let s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function sr(r,e){return!!((e==="v4"||!e)&&Jt.test(r)||(e==="v6"||!e)&&Yt.test(r))}var G=class r extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_type,expected:f.string,received:a.parsedType}),y}let s=new R,n;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?l(n,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(n,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")Ft.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"email",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")Be||(Be=new RegExp(Bt,"u")),Be.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"emoji",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")Vt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"uuid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")Lt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"nanoid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")Ut.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")Mt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid2",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")zt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ulid",code:d.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),l(n,{validation:"url",code:d.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"regex",code:d.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?lt(a).test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?Xt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?er(a).test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:d.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Ht.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"duration",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?tr(e.data,a.version)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ip",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?rr(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"jwt",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?sr(e.data,a.version)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cidr",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Kt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"base64",code:d.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Qt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"base64url",code:d.invalid_string,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:d.invalid_string,...p.errToObj(s)})}_addCheck(e){return new r({...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,t){return this._addCheck({kind:"regex",regex:e,...p.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...p.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...p.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...p.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...p.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...p.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...p.errToObj(t)})}nonempty(e){return this.min(1,p.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};G.create=r=>new G({checks:[],typeName:g.ZodString,coerce:r?.coerce??!1,...v(r)});function nr(r,e){let t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=Number.parseInt(r.toFixed(n).replace(".","")),i=Number.parseInt(e.toFixed(n).replace(".",""));return a%i/10**n}var ee=class r extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){let a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_type,expected:f.number,received:a.parsedType}),y}let s,n=new R;for(let a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?nr(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_finite,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:p.toString(n)}]})}_addCheck(e){return new r({...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,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}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(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}};ee.create=r=>new ee({checks:[],typeName:g.ZodNumber,coerce:r?.coerce||!1,...v(r)});var te=class r extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.bigint)return this._getInvalidInput(e);let s,n=new R;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),l(s,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return l(t,{code:d.invalid_type,expected:f.bigint,received:t.parsedType}),y}gte(e,t){return this.setLimit("min",e,!0,p.toString(t))}gt(e,t){return this.setLimit("min",e,!1,p.toString(t))}lte(e,t){return this.setLimit("max",e,!0,p.toString(t))}lt(e,t){return this.setLimit("max",e,!1,p.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:p.toString(n)}]})}_addCheck(e){return new r({...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,t){return this._addCheck({kind:"multipleOf",value:e,message:p.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};te.create=r=>new te({checks:[],typeName:g.ZodBigInt,coerce:r?.coerce??!1,...v(r)});var re=class extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.boolean,received:s.parsedType}),y}return A(e.data)}};re.create=r=>new re({typeName:g.ZodBoolean,coerce:r?.coerce||!1,...v(r)});var se=class r extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_type,expected:f.date,received:a.parsedType}),y}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return l(a,{code:d.invalid_date}),y}let s=new R,n;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):x.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:p.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:p.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};se.create=r=>new se({checks:[],coerce:r?.coerce||!1,typeName:g.ZodDate,...v(r)});var ke=class extends _{_parse(e){if(this._getType(e)!==f.symbol){let s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.symbol,received:s.parsedType}),y}return A(e.data)}};ke.create=r=>new ke({typeName:g.ZodSymbol,...v(r)});var ne=class extends _{_parse(e){if(this._getType(e)!==f.undefined){let s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.undefined,received:s.parsedType}),y}return A(e.data)}};ne.create=r=>new ne({typeName:g.ZodUndefined,...v(r)});var ae=class extends _{_parse(e){if(this._getType(e)!==f.null){let s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.null,received:s.parsedType}),y}return A(e.data)}};ae.create=r=>new ae({typeName:g.ZodNull,...v(r)});var Y=class extends _{constructor(){super(...arguments),this._any=!0}_parse(e){return A(e.data)}};Y.create=r=>new Y({typeName:g.ZodAny,...v(r)});var B=class extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return A(e.data)}};B.create=r=>new B({typeName:g.ZodUnknown,...v(r)});var Z=class extends _{_parse(e){let t=this._getOrReturnCtx(e);return l(t,{code:d.invalid_type,expected:f.never,received:t.parsedType}),y}};Z.create=r=>new Z({typeName:g.ZodNever,...v(r)});var we=class extends _{_parse(e){if(this._getType(e)!==f.undefined){let s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.void,received:s.parsedType}),y}return A(e.data)}};we.create=r=>new we({typeName:g.ZodVoid,...v(r)});var W=class r extends _{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==f.array)return l(t,{code:d.invalid_type,expected:f.array,received:t.parsedType}),y;if(n.exactLength!==null){let i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(l(t,{code:i?d.too_big:d.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(l(t,{code:d.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(l(t,{code:d.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new $(t,i,t.path,o)))).then(i=>R.mergeArray(s,i));let a=[...t.data].map((i,o)=>n.type._parseSync(new $(t,i,t.path,o)));return R.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:p.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:p.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:p.toString(t)}})}nonempty(e){return this.min(1,e)}};W.create=(r,e)=>new W({type:r,minLength:null,maxLength:null,exactLength:null,typeName:g.ZodArray,...v(e)});function be(r){if(r instanceof j){let e={};for(let t in r.shape){let s=r.shape[t];e[t]=P.create(be(s))}return new j({...r._def,shape:()=>e})}else return r instanceof W?new W({...r._def,type:be(r.element)}):r instanceof P?P.create(be(r.unwrap())):r instanceof V?V.create(be(r.unwrap())):r instanceof z?z.create(r.items.map(e=>be(e))):r}var j=class r extends _{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=x.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==f.object){let u=this._getOrReturnCtx(e);return l(u,{code:d.invalid_type,expected:f.object,received:u.parsedType}),y}let{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof Z&&this._def.unknownKeys==="strip"))for(let u in n.data)i.includes(u)||o.push(u);let c=[];for(let u of i){let m=a[u],T=n.data[u];c.push({key:{status:"valid",value:u},value:m._parse(new $(n,T,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof Z){let u=this._def.unknownKeys;if(u==="passthrough")for(let m of o)c.push({key:{status:"valid",value:m},value:{status:"valid",value:n.data[m]}});else if(u==="strict")o.length>0&&(l(n,{code:d.unrecognized_keys,keys:o}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let m of o){let T=n.data[m];c.push({key:{status:"valid",value:m},value:u._parse(new $(n,T,n.path,m)),alwaysSet:m in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let u=[];for(let m of c){let T=await m.key,U=await m.value;u.push({key:T,value:U,alwaysSet:m.alwaysSet})}return u}).then(u=>R.mergeObjectSync(s,u)):R.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return p.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{let n=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:p.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:g.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};for(let s of x.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new r({...this._def,shape:()=>t})}omit(e){let t={};for(let s of x.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new r({...this._def,shape:()=>t})}deepPartial(){return be(this)}partial(e){let t={};for(let s of x.objectKeys(this.shape)){let n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}return new r({...this._def,shape:()=>t})}required(e){let t={};for(let s of x.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof P;)a=a._def.innerType;t[s]=a}return new r({...this._def,shape:()=>t})}keyof(){return ft(x.objectKeys(this.shape))}};j.create=(r,e)=>new j({shape:()=>r,unknownKeys:"strip",catchall:Z.create(),typeName:g.ZodObject,...v(e)});j.strictCreate=(r,e)=>new j({shape:()=>r,unknownKeys:"strict",catchall:Z.create(),typeName:g.ZodObject,...v(e)});j.lazycreate=(r,e)=>new j({shape:r,unknownKeys:"strip",catchall:Z.create(),typeName:g.ZodObject,...v(e)});var ie=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(let o of a)if(o.result.status==="valid")return o.result;for(let o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new C(o.ctx.common.issues));return l(t,{code:d.invalid_union,unionErrors:i}),y}if(t.common.async)return Promise.all(s.map(async a=>{let i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a,i=[];for(let c of s){let u={...t,common:{...t.common,issues:[]},parent:null},m=c._parseSync({data:t.data,path:t.path,parent:u});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(c=>new C(c));return l(t,{code:d.invalid_union,unionErrors:o}),y}}get options(){return this._def.options}};ie.create=(r,e)=>new ie({options:r,typeName:g.ZodUnion,...v(e)});var F=r=>r instanceof ce?F(r.schema):r instanceof D?F(r.innerType()):r instanceof de?[r.value]:r instanceof ue?r.options:r instanceof le?x.objectValues(r.enum):r instanceof fe?F(r._def.innerType):r instanceof ne?[void 0]:r instanceof ae?[null]:r instanceof P?[void 0,...F(r.unwrap())]:r instanceof V?[null,...F(r.unwrap())]:r instanceof Ce||r instanceof he?F(r.unwrap()):r instanceof pe?F(r._def.innerType):[],Ze=class r extends _{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return l(t,{code:d.invalid_type,expected:f.object,received:t.parsedType}),y;let s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(l(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){let n=new Map;for(let a of t){let i=F(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new r({typeName:g.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...v(s)})}};function We(r,e){let t=M(r),s=M(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&s===f.object){let n=x.objectKeys(e),a=x.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};Object.prototype.hasOwnProperty.call(i,"__proto__")&&delete i.__proto__;for(let o of a){if(o==="__proto__")continue;let c=We(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===f.array&&s===f.array){if(r.length!==e.length)return{valid:!1};let n=[];for(let a=0;a<r.length;a++){let i=r[a],o=e[a],c=We(i,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===f.date&&s===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var oe=class extends _{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if($e(a)||$e(i))return y;let o=We(a.value,i.value);return o.valid?((De(a)||De(i))&&t.dirty(),{status:t.value,value:o.data}):(l(s,{code:d.invalid_intersection_types}),y)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};oe.create=(r,e,t)=>new oe({left:r,right:e,typeName:g.ZodIntersection,...v(t)});var z=class r extends _{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.array)return l(s,{code:d.invalid_type,expected:f.array,received:s.parsedType}),y;if(s.data.length<this._def.items.length)return l(s,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&s.data.length>this._def.items.length&&(l(s,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...s.data].map((i,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new $(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>R.mergeArray(t,i)):R.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};z.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new z({items:r,typeName:g.ZodTuple,rest:null,...v(e)})};var Ue=class r extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.object)return l(s,{code:d.invalid_type,expected:f.object,received:s.parsedType}),y;let n=[],a=this._def.keyType,i=this._def.valueType;for(let o in s.data)n.push({key:a._parse(new $(s,o,s.path,o)),value:i._parse(new $(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?R.mergeObjectAsync(t,n):R.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof _?new r({keyType:e,valueType:t,typeName:g.ZodRecord,...v(s)}):new r({keyType:G.create(),valueType:e,typeName:g.ZodRecord,...v(t)})}},Te=class extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.map)return l(s,{code:d.invalid_type,expected:f.map,received:s.parsedType}),y;let n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],u)=>({key:n._parse(new $(s,o,s.path,[u,"key"])),value:a._parse(new $(s,c,s.path,[u,"value"]))}));if(s.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of i){let u=await c.key,m=await c.value;if(u.status==="aborted"||m.status==="aborted")return y;(u.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(u.value,m.value)}return{status:t.value,value:o}})}else{let o=new Map;for(let c of i){let u=c.key,m=c.value;if(u.status==="aborted"||m.status==="aborted")return y;(u.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(u.value,m.value)}return{status:t.value,value:o}}}};Te.create=(r,e,t)=>new Te({valueType:e,keyType:r,typeName:g.ZodMap,...v(t)});var Se=class r extends _{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.set)return l(s,{code:d.invalid_type,expected:f.set,received:s.parsedType}),y;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(l(s,{code:d.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(l(s,{code:d.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let a=this._def.valueType;function i(c){let u=new Set;for(let m of c){if(m.status==="aborted")return y;m.status==="dirty"&&t.dirty(),u.add(m.value)}return{status:t.value,value:u}}let o=[...s.data.values()].map((c,u)=>a._parse(new $(s,c,s.path,u)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new r({...this._def,minSize:{value:e,message:p.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:p.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Se.create=(r,e)=>new Se({valueType:r,minSize:null,maxSize:null,typeName:g.ZodSet,...v(e)});var Me=class r extends _{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return l(t,{code:d.invalid_type,expected:f.function,received:t.parsedType}),y;function s(o,c){return Ie({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_e(),H].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:c}})}function n(o,c){return Ie({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_e(),H].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:c}})}let a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof K){let o=this;return A(async function(...c){let u=new C([]),m=await o._def.args.parseAsync(c,a).catch(ye=>{throw u.addIssue(s(c,ye)),u}),T=await Reflect.apply(i,this,m);return await o._def.returns._def.type.parseAsync(T,a).catch(ye=>{throw u.addIssue(n(T,ye)),u})})}else{let o=this;return A(function(...c){let u=o._def.args.safeParse(c,a);if(!u.success)throw new C([s(c,u.error)]);let m=Reflect.apply(i,this,u.data),T=o._def.returns.safeParse(m,a);if(!T.success)throw new C([n(m,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:z.create(e).rest(B.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new r({args:e||z.create([]).rest(B.create()),returns:t||B.create(),typeName:g.ZodFunction,...v(s)})}},ce=class extends _{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};ce.create=(r,e)=>new ce({getter:r,typeName:g.ZodLazy,...v(e)});var de=class extends _{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}};de.create=(r,e)=>new de({value:r,typeName:g.ZodLiteral,...v(e)});function ft(r,e){return new ue({values:r,typeName:g.ZodEnum,...v(e)})}var ue=class r extends _{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{expected:x.joinValues(s),received:t.parsedType,code:d.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{received:t.data,code:d.invalid_enum_value,options:s}),y}return A(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}};ue.create=ft;var le=class extends _{_parse(e){let t=x.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==f.string&&s.parsedType!==f.number){let n=x.objectValues(t);return l(s,{expected:x.joinValues(n),received:s.parsedType,code:d.invalid_type}),y}if(this._cache||(this._cache=new Set(x.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=x.objectValues(t);return l(s,{received:s.data,code:d.invalid_enum_value,options:n}),y}return A(e.data)}get enum(){return this._def.values}};le.create=(r,e)=>new le({values:r,typeName:g.ZodNativeEnum,...v(e)});var K=class extends _{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return l(t,{code:d.invalid_type,expected:f.promise,received:t.parsedType}),y;let s=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return A(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};K.create=(r,e)=>new K({type:r,typeName:g.ZodPromise,...v(e)});var D=class extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===g.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{l(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){let i=n.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return y;let c=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return c.status==="aborted"?y:c.status==="dirty"?X(c.value):t.value==="dirty"?X(c.value):c});{if(t.value==="aborted")return y;let o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?y:o.status==="dirty"?X(o.value):t.value==="dirty"?X(o.value):o}}if(n.type==="refinement"){let i=o=>{let c=n.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){let o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?y:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?y:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){let i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!J(i))return y;let o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>J(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):y);x.assertNever(n)}};D.create=(r,e,t)=>new D({schema:r,typeName:g.ZodEffects,effect:e,...v(t)});D.createWithPreprocess=(r,e,t)=>new D({schema:e,effect:{type:"preprocess",transform:r},typeName:g.ZodEffects,...v(t)});var P=class extends _{_parse(e){return this._getType(e)===f.undefined?A(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};P.create=(r,e)=>new P({innerType:r,typeName:g.ZodOptional,...v(e)});var V=class extends _{_parse(e){return this._getType(e)===f.null?A(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};V.create=(r,e)=>new V({innerType:r,typeName:g.ZodNullable,...v(e)});var fe=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===f.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};fe.create=(r,e)=>new fe({innerType:r,typeName:g.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});var pe=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return xe(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new C(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new C(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};pe.create=(r,e)=>new pe({innerType:r,typeName:g.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});var Oe=class extends _{_parse(e){if(this._getType(e)!==f.nan){let s=this._getOrReturnCtx(e);return l(s,{code:d.invalid_type,expected:f.nan,received:s.parsedType}),y}return{status:"valid",value:e.data}}};Oe.create=r=>new Oe({typeName:g.ZodNaN,...v(r)});var ar=Symbol("zod_brand"),Ce=class extends _{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}},je=class r extends _{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?y:a.status==="dirty"?(t.dirty(),X(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{let n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?y:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new r({in:e,out:t,typeName:g.ZodPipeline})}},he=class extends _{_parse(e){let t=this._def.innerType._parse(e),s=n=>(J(n)&&(n.value=Object.freeze(n.value)),n);return xe(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}};he.create=(r,e)=>new he({innerType:r,typeName:g.ZodReadonly,...v(e)});function ct(r,e){let t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function pt(r,e={},t){return r?Y.create().superRefine((s,n)=>{let a=r(s);if(a instanceof Promise)return a.then(i=>{if(!i){let o=ct(e,s),c=o.fatal??t??!0;n.addIssue({code:"custom",...o,fatal:c})}});if(!a){let i=ct(e,s),o=i.fatal??t??!0;n.addIssue({code:"custom",...i,fatal:o})}}):Y.create()}var ir={object:j.lazycreate},g;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(g||(g={}));var or=(r,e={message:`Input not instance of ${r.name}`})=>pt(t=>t instanceof r,e),ht=G.create,mt=ee.create,cr=Oe.create,dr=te.create,yt=re.create,ur=se.create,lr=ke.create,fr=ne.create,pr=ae.create,hr=Y.create,mr=B.create,yr=Z.create,gr=we.create,vr=W.create,_r=j.create,xr=j.strictCreate,br=ie.create,kr=Ze.create,wr=oe.create,Tr=z.create,Sr=Ue.create,Or=Te.create,Rr=Se.create,Ar=Me.create,Er=ce.create,Ir=de.create,Cr=ue.create,jr=le.create,Nr=K.create,Pr=D.create,$r=P.create,Dr=V.create,Zr=D.createWithPreprocess,Ur=je.create,Mr=()=>ht().optional(),zr=()=>mt().optional(),Vr=()=>yt().optional(),Lr={string:(r=>G.create({...r,coerce:!0})),number:(r=>ee.create({...r,coerce:!0})),boolean:(r=>re.create({...r,coerce:!0})),bigint:(r=>te.create({...r,coerce:!0})),date:(r=>se.create({...r,coerce:!0}))};var qr=y;var Je=h.object({environmentId:h.string().uuid(),allowed:h.boolean(),revision:h.string().uuid(),updatedAt:h.string().datetime(),updatedBy:h.string().uuid()}).strict();function gt(r,e,t){let s=Je.safeParse(e);return!s.success||!s.data.allowed||!r.environmentId||s.data.environmentId!==r.environmentId||!r.environmentAddress||r.persistentDataPolicy&&r.persistentDataPolicy.revision!==s.data.revision?!1:Ge(r.environmentAddress,t)}function Ge(r,e){try{let t=new URL(e),s=new URL(r);if(s.search||s.hash)return!1;let n=/%(?:2f|5c|2e|25)/i;if(e.includes("\\")||r.includes("\\")||n.test(t.pathname)||n.test(s.pathname))return!1;let a=s.pathname.replace(/\/$/,"");return["https:","http:"].includes(s.protocol)&&t.origin===s.origin&&(t.pathname===a||t.pathname.startsWith(`${a}/`))}catch{return!1}}var Qe=(t=>(t.Patch="PATCH",t.Put="PUT",t))(Qe||{}),Re=class extends Error{constructor(t){super(`Safety gap: ${t.reason}`);this.incident=t}incident},Ae=class extends Error{constructor(t){super("The delivered test assertion or execution failed; its resource trace is retained in diagnostics");this.trace=t}trace},me=class extends Error{};function w(r){throw new me(`environment restriction: ${r}`)}function Xe(r){let e=new URL(r);return(!["https:","http:"].includes(e.protocol)||e.username||e.password||e.search||e.hash||/%(?:2f|5c|2e|25)/i.test(e.pathname)||r.includes("\\"))&&w("unsupported environment address"),e.href.replace(/\/$/,"")}function ze(r,e){let t=new URL(e,`${r}/`);return(!Ge(r,e.includes("://")?e:t.href)||t.username||t.password||t.hash)&&w("request leaves the selected environment"),t}function Hr(r){let e=r.map(t=>{(!t||t.includes("\\")||/[\[\]{}()]/.test(t))&&w("unsupported off-limits pattern");let s=n=>n.split("*").map(a=>a.replace(/[.+?^$|]/g,"\\$&")).join(".*");return new RegExp(t.endsWith("/**")?`^(?:${s(t)}|${s(t.slice(0,-3))})$`:`^${s(t)}$`,"i")});return t=>e.some(s=>s.test(t.href)||s.test(t.pathname))}async function Fr(r){let e=await r.text();if(e)try{return JSON.parse(e)}catch{throw new Error("Shared test response was not JSON")}}function Ke(r){let e=new URL(r);if(e.protocol!=="https:"||e.username||e.password||e.pathname!=="/"||e.search||e.hash)throw new Error("expected a bare HTTPS origin");return e.origin}function vt(r,e,t){let s=new URL(r),n=(e??"").split(",").map(a=>a.trim()).filter(Boolean);return(s.protocol!=="https:"||s.username||s.password||s.hash||!(s.port===""&&t(s.hostname))&&!n.some(a=>Ke(a)===s.origin))&&w("unsupported workflow identity endpoint"),s}function Ve(r,e){let t=r;for(let s of e){if(!t||typeof t!="object"||!Object.hasOwn(t,s))return;t=t[s]}return t}async function _t(r){let e=await r.text(),t;if(e)try{t=JSON.parse(e)}catch{t=e}return{status:r.status,headers:r.headers,body:t}}function Br(r,e){let t=r.bearerTokenEnv;if(!t)return;let s=process.env[t];if(!s?.trim())throw new Error(`required SUT credential ${t} is unavailable`);if(process.env.TESTBOT_SHARED_SUT_TOKEN_ENV!==t)throw new Error("declared SUT credential is not approved by TESTBOT_SHARED_SUT_TOKEN_ENV");let n=process.env.TESTBOT_SHARED_SUT_ADDRESS,a=!1;try{a=!!n&&Xe(n)===e}catch{}if(!a)throw new Error("SUT address does not match TESTBOT_SHARED_SUT_ADDRESS");return s}async function Wr(r){let e=process.env.ACTIONS_ID_TOKEN_REQUEST_URL,t=process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN,s=process.env.SYSTEM_OIDCREQUESTURI,n=process.env.SYSTEM_ACCESSTOKEN,a,i,o;if(e&&t)a=vt(e,process.env.TESTBOT_GITHUB_OIDC_ORIGINS,T=>T.endsWith(".actions.githubusercontent.com")),a.searchParams.set("audience",r),i=t,o="github";else if(s&&n)a=vt(s,process.env.TESTBOT_AZURE_OIDC_ORIGINS,T=>T==="dev.azure.com"||T.endsWith(".visualstudio.com")),a.searchParams.set("api-version","7.1-preview.1"),i=n,o="azure";else return w("fresh provider-signed workflow identity is unavailable");let c=await fetch(a,{method:o==="github"?"GET":"POST",headers:{Authorization:`Bearer ${i}`,...o==="azure"?{"Content-Type":"application/json",Accept:"application/json"}:{}},...o==="azure"?{body:"{}"}:{},redirect:"error",signal:AbortSignal.timeout(1e4)});if(!c.ok)return w("workflow identity request failed");let u=await c.json(),m=o==="github"?u.value:u.oidcToken;return typeof m=="string"&&m?m:w("workflow identity response is invalid")}async function Ye(r,e){try{r.targetId||w("current persistent-data policy is unavailable");let t=Ke(process.env.TESTBOT_POLICY_ORIGIN??"https://testbot.skyramp.dev");r.appOrigin&&Ke(r.appOrigin)!==t&&w("policy service origin does not match trusted CI configuration");let s=await Wr(t),n=`${t}/api/v1/runner/targets/${encodeURIComponent(r.targetId)}/test-environments/${encodeURIComponent(r.environmentId)}/persistent-data-policy`,a=await fetch(n,{headers:{Authorization:`Bearer ${s}`},cache:"no-store",redirect:"error",signal:AbortSignal.timeout(1e4)});a.ok||w("current persistent-data policy is unavailable");let i=await a.json(),o=Je.safeParse(i.persistentDataPolicy);(i.schemaVersion!==1||i.environmentId!==r.environmentId||typeof i.environmentAddress!="string"||Xe(i.environmentAddress)!==e||!o.success||!gt({environmentId:r.environmentId,environmentAddress:e},o.data,e))&&w("current policy does not authorize this environment")}catch(t){if(t instanceof me)throw t;w("current persistent-data policy is unavailable")}}function xt(r){return{status:"restricted",detail:r instanceof me?r.message:"environment restriction: unsupported shared-environment configuration"}}async function kt(r,e){let t,s;try{(!r||!r.environmentId||!Array.isArray(r.offLimits))&&w("shared-environment identity and off-limits rules are required"),t=Xe(r.environmentAddress),s=Hr(r.offLimits),r.route?.kind!=="persistence"&&w("delivered shared tests require the persistence route")}catch(b){return xt(b)}let n=Br(r,t);try{await Ye(r,t)}catch(b){return xt(b)}let a=`testbot-${(0,bt.randomUUID)()}`,i=new Set,o=[],c=async(b,O,k)=>{let N=ze(t,O);return s(N)&&w("the request is off limits"),["GET","HEAD","OPTIONS"].includes(b)||(ye=!0),await fetch(N,{method:b,headers:{...n?{Authorization:`Bearer ${n}`}:{},...k===void 0?{}:{"Content-Type":"application/json"}},redirect:"error",signal:AbortSignal.timeout(1e4),...k===void 0?{}:{body:JSON.stringify(k)}})},u=b=>{let O=ze(t,b).href;return i.has(O)||w("mutations and resource reads require a run-owned resource"),O},m=b=>new Ae({runId:a,route:r.route.kind,resources:o,retained:!0,outcome:"test-failed",...b===void 0?{}:{status:b}}),T=async(b,O)=>{let k=b.status;if(!(O===void 0?b.ok:O===k)||k<200||k>=300&&k<400||k>=500)throw await b.body?.cancel(),m(k);return _t(b)},U,ye=!1;try{await e({async create(b,O,k,N={}){(!k.trim()||!Object.hasOwn(O,k)||typeof O[k]!="string")&&w("creation needs a supported run-unique string field"),Object.keys(O).some(q=>/^(?:id|_id|uuid|pk)$/i.test(q))&&w("caller-selected resource IDs cannot establish a newly owned record");let I=ze(t,b);I.search&&w("create-only collections cannot use query actions"),s(I)&&w("the request is off limits");let ge=`${O[k]}-${a}`,ve=q=>new Re({runId:a,route:r.route.kind,resources:[...o,I.href],outcome:"failed-or-unknown",reason:q});await Ye(r,t);let E;try{E=await c("POST",I.href,{...O,[k]:ge})}catch(q){throw q instanceof me?q:ve("create response was unavailable; side effects are unknown")}if(E.status>=400&&E.status<500){if(E.status===N.expectedStatus)return _t(E);throw await E.body?.cancel(),m(E.status)}if(!E.ok)throw ve(`create did not establish new-resource provenance (${E.status})`);let Pe;try{Pe=await Fr(E)}catch{throw ve("create returned unreadable resource provenance")}if(Ve(Pe,N.responseUniqueFieldPath??[k])!==ge)throw ve("create did not confirm the run-unique value");let qe=Ve(Pe,N.responseIdPath??["id"]),rt=E.headers.get("location"),L;try{let q=rt?new URL(rt,I).href:typeof qe=="string"||typeof qe=="number"?`${I.href.replace(/\/$/,"")}/${encodeURIComponent(qe)}`:void 0;if(!q)throw new Error("no resource identity");L=ze(t,q)}catch{throw ve("create returned missing, invalid or out-of-scope resource provenance")}let st=I.pathname.replace(/\/$/,"")+"/",nt=L.pathname.slice(st.length);if(L.search||!L.pathname.startsWith(st)||!nt||nt.includes("/")||s(L)||i.has(L.href))throw ve("create returned unsupported resource provenance");if(i.add(L.href),o.push(L.href),E.status!==(N.expectedStatus??201))throw m(E.status);return{url:L.href,body:Pe,status:E.status,headers:E.headers}},async read(b,O={}){let k=new URL(u(b));for(let[I,ge]of Object.entries(O.query??{}))k.searchParams.append(I,ge);let N=await c("GET",k.href);return T(N,O.expectedStatus)},async update(b,O,k={}){let N=u(b),I=k.method??"PATCH";I!=="PATCH"&&I!=="PUT"&&w("unsupported resource update method"),await Ye(r,t);let ge=await c(I,N,O);return T(ge,k.expectedStatus)}})}catch(b){U=b}if(U instanceof me&&!ye)return{status:"restricted",detail:U.message};if(U instanceof Re||U instanceof Ae)throw U;if(U)throw m();return{status:"executed",runId:a,resources:o,retained:!0}}var Ne=h.lazy(()=>h.union([h.string(),h.number().finite(),h.boolean(),h.null(),h.array(Ne),h.record(Ne)])),S=h.string().trim().min(1),Tt=h.string().regex(/^[A-Za-z_]\w*$/).optional(),et=h.number().int().refine(r=>r>=200&&r<300||r>=400&&r<500,"Expected an explicit success or client rejection status").optional(),wt=h.array(S).min(1).max(20).optional(),Jr=h.object({environmentId:h.string().uuid(),environmentAddress:h.string().url(),targetId:S.optional(),appOrigin:h.string().url().optional(),offLimits:h.array(S),bearerTokenEnv:Tt,route:h.object({kind:h.literal("persistence")}).strict()}).strict(),St=h.array(h.discriminatedUnion("op",[h.object({op:h.literal("create"),collection:S,body:h.record(Ne),uniqueField:S,expectedStatus:et,responseIdPath:wt,responseUniqueFieldPath:wt,as:S}).strict(),h.object({op:h.literal("read"),resource:S,as:S,expectedStatus:et,query:h.record(h.string()).optional()}).strict(),h.object({op:h.literal("update"),resource:S,method:h.nativeEnum(Qe).optional(),expectedStatus:et,body:h.record(Ne),as:S}).strict(),h.object({op:h.literal("assert"),resource:S,path:h.array(S),equals:Ne}).strict(),h.object({op:h.literal("assertStatus"),resource:S,equals:h.number().int().min(200).max(499)}).strict(),h.object({op:h.literal("assertHeader"),resource:S,name:h.string().regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/),equals:h.string().nullable()}).strict()])).min(1).refine(r=>r.some(e=>e.op==="assert"||e.op==="assertStatus"||e.op==="assertHeader"),"A runnable test must retain a planned assertion"),js=h.object({name:S,bearerTokenEnv:Tt,steps:St.describe("ordered objects with op: create (collection, body, uniqueField, as; optional expectedStatus, responseIdPath, responseUniqueFieldPath), read (resource, as; optional expectedStatus, query), update (resource, body, as; optional expectedStatus, method PUT or PATCH), assert (resource, path, equals), assertStatus (resource, equals), or assertHeader (resource, name, equals). Resource names an earlier request alias and paths are arrays of JSON keys")}).strict(),tt=h.union([h.object({name:S,definition:Jr,steps:St}).strict(),h.object({name:S,restriction:S,sourceAsset:h.object({path:S.regex(/^(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))[^\\]+\.source$/),sha256:h.string().regex(/^[a-f0-9]{64}$/)}).strict()}).strict()]),Gr=`"use strict";
|
|
2
|
-
const spec = `,
|
|
1
|
+
"use strict";var Fe=Object.defineProperty;var St=Object.getOwnPropertyDescriptor;var Rt=Object.getOwnPropertyNames;var Ot=Object.prototype.hasOwnProperty;var tt=(r,e)=>{for(var t in e)Fe(r,t,{get:e[t],enumerable:!0})},Et=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Rt(e))!Ot.call(r,n)&&n!==t&&Fe(r,n,{get:()=>e[n],enumerable:!(s=St(e,n))||s.enumerable});return r};var At=r=>Et(Fe({},"__esModule",{value:!0}),r);var Jr={};tt(Jr,{renderDeliveredSharedTest:()=>kt,sharedEnvironmentTest:()=>Wr});module.exports=At(Jr);var Q=require("node:fs"),wt=require("node:crypto"),Ce=require("node:path"),Tt=require("node:test"),qe=require("node:assert");var yt=require("node:crypto");var p={};tt(p,{BRAND:()=>tr,DIRTY:()=>K,EMPTY_PATH:()=>It,INVALID:()=>m,NEVER:()=>Vr,OK:()=>R,ParseStatus:()=>S,Schema:()=>v,ZodAny:()=>G,ZodArray:()=>W,ZodBigInt:()=>te,ZodBoolean:()=>re,ZodBranded:()=>Ne,ZodCatch:()=>pe,ZodDate:()=>se,ZodDefault:()=>fe,ZodDiscriminatedUnion:()=>Me,ZodEffects:()=>$,ZodEnum:()=>ue,ZodError:()=>C,ZodFirstPartyTypeKind:()=>y,ZodFunction:()=>Ue,ZodIntersection:()=>oe,ZodIssueCode:()=>c,ZodLazy:()=>ce,ZodLiteral:()=>de,ZodMap:()=>we,ZodNaN:()=>Se,ZodNativeEnum:()=>le,ZodNever:()=>Z,ZodNull:()=>ae,ZodNullable:()=>L,ZodNumber:()=>ee,ZodObject:()=>j,ZodOptional:()=>I,ZodParsedType:()=>f,ZodPipeline:()=>Ie,ZodPromise:()=>X,ZodReadonly:()=>he,ZodRecord:()=>Ve,ZodSchema:()=>v,ZodSet:()=>Te,ZodString:()=>Y,ZodSymbol:()=>be,ZodTransformer:()=>$,ZodTuple:()=>U,ZodType:()=>v,ZodUndefined:()=>ne,ZodUnion:()=>ie,ZodUnknown:()=>B,ZodVoid:()=>ke,addIssueToContext:()=>l,any:()=>ur,array:()=>hr,bigint:()=>ar,boolean:()=>ft,coerce:()=>Mr,custom:()=>dt,date:()=>ir,datetimeRegex:()=>ot,defaultErrorMap:()=>H,discriminatedUnion:()=>_r,effect:()=>Cr,enum:()=>Or,function:()=>Tr,getErrorMap:()=>_e,getParsedType:()=>V,instanceof:()=>sr,intersection:()=>vr,isAborted:()=>De,isAsync:()=>ve,isDirty:()=>Ze,isValid:()=>J,late:()=>rr,lazy:()=>Sr,literal:()=>Rr,makeIssue:()=>je,map:()=>kr,nan:()=>nr,nativeEnum:()=>Er,never:()=>fr,null:()=>dr,nullable:()=>Nr,number:()=>lt,object:()=>mr,objectUtil:()=>Be,oboolean:()=>Zr,onumber:()=>Dr,optional:()=>jr,ostring:()=>$r,pipeline:()=>Pr,preprocess:()=>Ir,promise:()=>Ar,quotelessJson:()=>Ct,record:()=>br,set:()=>wr,setErrorMap:()=>Nt,strictObject:()=>yr,string:()=>ut,symbol:()=>or,transformer:()=>Cr,tuple:()=>xr,undefined:()=>cr,union:()=>gr,unknown:()=>lr,util:()=>x,void:()=>pr});var x;(function(r){r.assertEqual=n=>{};function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{let a={};for(let i of n)a[i]=i;return a},r.getValidEnumValues=n=>{let a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(let o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{let a=[];for(let i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(let i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Be;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Be||(Be={}));var f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),V=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}};var c=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ct=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),C=class r 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]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,d=0;for(;d<i.path.length;){let u=i.path[d],g=d===i.path.length-1;if(u==="_errors"){g&&o._errors.push(t(i)),d++;continue}Object.prototype.hasOwnProperty.call(o,u)||(u==="__proto__"?Object.defineProperty(o,u,{value:{_errors:[]},writable:!0,enumerable:!0,configurable:!0}):o[u]={_errors:[]}),o=o[u],g&&o._errors.push(t(i)),d++}}};return n(this),s}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t=Object.create(null),s=[];for(let n of this.issues)if(n.path.length>0){let a=n.path[0];t[a]=t[a]||[],t[a].push(e(n))}else s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};C.create=r=>new C(r);var jt=(r,e)=>{let t;switch(r.code){case c.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case c.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,x.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(r.keys,", ")}`;break;case c.invalid_union:t="Invalid input";break;case c.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(r.options)}`;break;case c.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;break;case c.invalid_arguments:t="Invalid function arguments";break;case c.invalid_return_type:t="Invalid function return type";break;case c.invalid_date:t="Invalid date";break;case c.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:x.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case c.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case c.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case c.custom:t="Invalid input";break;case c.invalid_intersection_types:t="Intersection results could not be merged";break;case c.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case c.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(r)}return{message:t}},H=jt;var rt=H;function Nt(r){rt=r}function _e(){return rt}var je=r=>{let{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let o="",d=s.filter(u=>!!u).slice().reverse();for(let u of d)o=u(i,{data:e,defaultError:o}).message;return{...n,path:a,message:o}},It=[];function l(r,e){let t=_e(),s=je({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===H?void 0:H].filter(n=>!!n)});r.common.issues.push(s)}var S=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let s=[];for(let n of t){if(n.status==="aborted")return m;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){let s=[];for(let n of t){let a=await n.key,i=await n.value;s.push({key:a,value:i})}return r.mergeObjectSync(e,s)}static mergeObjectSync(e,t){let s={};for(let n of t){let{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return m;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}},m=Object.freeze({status:"aborted"}),K=r=>({status:"dirty",value:r}),R=r=>({status:"valid",value:r}),De=r=>r.status==="aborted",Ze=r=>r.status==="dirty",J=r=>r.status==="valid",ve=r=>typeof Promise<"u"&&r instanceof Promise;var h;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(h||(h={}));var P=class{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},st=(r,e)=>{if(J(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new C(r.common.issues);return this._error=t,this._error}}};function _(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(i,o)=>{let{message:d}=r;return i.code==="invalid_enum_value"?{message:d??o.defaultError}:typeof o.data>"u"?{message:d??s??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:d??t??o.defaultError}},description:n}}var v=class{get description(){return this._def.description}_getType(e){return V(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new S,ctx:{common:e.parent.common,data:e.data,parsedType:V(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ve(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){let s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)},n=this._parseSync({data:e,path:s.path,parent:s});return st(s,n)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)};if(!this["~standard"].async)try{let s=this._parseSync({data:e,path:[],parent:t});return J(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>J(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){let s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){let s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:V(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(ve(n)?n:Promise.resolve(n));return st(s,a)}refine(e,t){let s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{let i=e(n),o=()=>a.addIssue({code:c.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new $({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return I.create(this,this._def)}nullable(){return L.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return W.create(this)}promise(){return X.create(this,this._def)}or(e){return ie.create([this,e],this._def)}and(e){return oe.create(this,e,this._def)}transform(e){return new $({..._(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new fe({..._(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new Ne({typeName:y.ZodBranded,type:this,..._(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new pe({..._(this._def),innerType:this,catchValue:t,typeName:y.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ie.create(this,e)}readonly(){return he.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Pt=/^c[^\s-]{8,}$/i,$t=/^[0-9a-z]+$/,Dt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Zt=/^[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,Mt=/^[a-z0-9_-]{21}$/i,Vt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Ut=/^[-+]?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)?)??$/,Lt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,zt="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$",We,qt=/^(?:(?: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])$/,Ht=/^(?:(?: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])$/,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]))$/,Bt=/^(([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])$/,Wt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Jt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,at="((\\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])))",Yt=new RegExp(`^${at}$`);function it(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);let t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Gt(r){return new RegExp(`^${it(r)}$`)}function ot(r){let e=`${at}T${it(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Xt(r,e){return!!((e==="v4"||!e)&&qt.test(r)||(e==="v6"||!e)&&Ft.test(r))}function Qt(r,e){if(!Vt.test(r))return!1;try{let[t]=r.split(".");if(!t)return!1;let s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function Kt(r,e){return!!((e==="v4"||!e)&&Ht.test(r)||(e==="v6"||!e)&&Bt.test(r))}var Y=class r extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.string,received:a.parsedType}),m}let s=new S,n;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(n=this._getOrReturnCtx(e,n),i?l(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")Lt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"email",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")We||(We=new RegExp(zt,"u")),We.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"emoji",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")Zt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"uuid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")Mt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"nanoid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")Pt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")$t.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cuid2",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")Dt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ulid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),l(n,{validation:"url",code:c.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"regex",code:c.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?ot(a).test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?Yt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?Gt(a).test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Ut.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"duration",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?Xt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"ip",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?Qt(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"jwt",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?Kt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"cidr",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Wt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"base64",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Jt.test(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{validation:"base64url",code:c.invalid_string,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:c.invalid_string,...h.errToObj(s)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...h.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,...h.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...h.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...h.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...h.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...h.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...h.errToObj(t)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Y.create=r=>new Y({checks:[],typeName:y.ZodString,coerce:r?.coerce??!1,..._(r)});function er(r,e){let t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=Number.parseInt(r.toFixed(n).replace(".","")),i=Number.parseInt(e.toFixed(n).replace(".",""));return a%i/10**n}var ee=class r extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){let a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.number,received:a.parsedType}),m}let s,n=new S;for(let a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:c.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?er(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:c.not_finite,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:h.toString(n)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}};ee.create=r=>new ee({checks:[],typeName:y.ZodNumber,coerce:r?.coerce||!1,..._(r)});var te=class r extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.bigint)return this._getInvalidInput(e);let s,n=new S;for(let 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:c.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),l(s,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return l(t,{code:c.invalid_type,expected:f.bigint,received:t.parsedType}),m}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,s,n){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:h.toString(n)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};te.create=r=>new te({checks:[],typeName:y.ZodBigInt,coerce:r?.coerce??!1,..._(r)});var re=class extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:f.boolean,received:s.parsedType}),m}return R(e.data)}};re.create=r=>new re({typeName:y.ZodBoolean,coerce:r?.coerce||!1,..._(r)});var se=class r extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.date,received:a.parsedType}),m}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_date}),m}let s=new S,n;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):x.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};se.create=r=>new se({checks:[],coerce:r?.coerce||!1,typeName:y.ZodDate,..._(r)});var be=class extends v{_parse(e){if(this._getType(e)!==f.symbol){let s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:f.symbol,received:s.parsedType}),m}return R(e.data)}};be.create=r=>new be({typeName:y.ZodSymbol,..._(r)});var ne=class extends v{_parse(e){if(this._getType(e)!==f.undefined){let s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:f.undefined,received:s.parsedType}),m}return R(e.data)}};ne.create=r=>new ne({typeName:y.ZodUndefined,..._(r)});var ae=class extends v{_parse(e){if(this._getType(e)!==f.null){let s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:f.null,received:s.parsedType}),m}return R(e.data)}};ae.create=r=>new ae({typeName:y.ZodNull,..._(r)});var G=class extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return R(e.data)}};G.create=r=>new G({typeName:y.ZodAny,..._(r)});var B=class extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return R(e.data)}};B.create=r=>new B({typeName:y.ZodUnknown,..._(r)});var Z=class extends v{_parse(e){let t=this._getOrReturnCtx(e);return l(t,{code:c.invalid_type,expected:f.never,received:t.parsedType}),m}};Z.create=r=>new Z({typeName:y.ZodNever,..._(r)});var ke=class extends v{_parse(e){if(this._getType(e)!==f.undefined){let s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:f.void,received:s.parsedType}),m}return R(e.data)}};ke.create=r=>new ke({typeName:y.ZodVoid,..._(r)});var W=class r extends v{_parse(e){let{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==f.array)return l(t,{code:c.invalid_type,expected:f.array,received:t.parsedType}),m;if(n.exactLength!==null){let i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(l(t,{code:i?c.too_big:c.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(l(t,{code:c.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(l(t,{code:c.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new P(t,i,t.path,o)))).then(i=>S.mergeArray(s,i));let a=[...t.data].map((i,o)=>n.type._parseSync(new P(t,i,t.path,o)));return S.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:h.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:h.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:h.toString(t)}})}nonempty(e){return this.min(1,e)}};W.create=(r,e)=>new W({type:r,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,..._(e)});function xe(r){if(r instanceof j){let e={};for(let t in r.shape){let s=r.shape[t];e[t]=I.create(xe(s))}return new j({...r._def,shape:()=>e})}else return r instanceof W?new W({...r._def,type:xe(r.element)}):r instanceof I?I.create(xe(r.unwrap())):r instanceof L?L.create(xe(r.unwrap())):r instanceof U?U.create(r.items.map(e=>xe(e))):r}var j=class r extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=x.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==f.object){let u=this._getOrReturnCtx(e);return l(u,{code:c.invalid_type,expected:f.object,received:u.parsedType}),m}let{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof Z&&this._def.unknownKeys==="strip"))for(let u in n.data)i.includes(u)||o.push(u);let d=[];for(let u of i){let g=a[u],O=n.data[u];d.push({key:{status:"valid",value:u},value:g._parse(new P(n,O,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof Z){let u=this._def.unknownKeys;if(u==="passthrough")for(let g of o)d.push({key:{status:"valid",value:g},value:{status:"valid",value:n.data[g]}});else if(u==="strict")o.length>0&&(l(n,{code:c.unrecognized_keys,keys:o}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let g of o){let O=n.data[g];d.push({key:{status:"valid",value:g},value:u._parse(new P(n,O,n.path,g)),alwaysSet:g in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let u=[];for(let g of d){let O=await g.key,M=await g.value;u.push({key:O,value:M,alwaysSet:g.alwaysSet})}return u}).then(u=>S.mergeObjectSync(s,u)):S.mergeObjectSync(s,d)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{let n=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:h.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};for(let s of x.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new r({...this._def,shape:()=>t})}omit(e){let t={};for(let s of x.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new r({...this._def,shape:()=>t})}deepPartial(){return xe(this)}partial(e){let t={};for(let s of x.objectKeys(this.shape)){let n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}return new r({...this._def,shape:()=>t})}required(e){let t={};for(let s of x.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof I;)a=a._def.innerType;t[s]=a}return new r({...this._def,shape:()=>t})}keyof(){return ct(x.objectKeys(this.shape))}};j.create=(r,e)=>new j({shape:()=>r,unknownKeys:"strip",catchall:Z.create(),typeName:y.ZodObject,..._(e)});j.strictCreate=(r,e)=>new j({shape:()=>r,unknownKeys:"strict",catchall:Z.create(),typeName:y.ZodObject,..._(e)});j.lazycreate=(r,e)=>new j({shape:r,unknownKeys:"strip",catchall:Z.create(),typeName:y.ZodObject,..._(e)});var ie=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(let o of a)if(o.result.status==="valid")return o.result;for(let o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new C(o.ctx.common.issues));return l(t,{code:c.invalid_union,unionErrors:i}),m}if(t.common.async)return Promise.all(s.map(async a=>{let i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a,i=[];for(let d of s){let u={...t,common:{...t.common,issues:[]},parent:null},g=d._parseSync({data:t.data,path:t.path,parent:u});if(g.status==="valid")return g;g.status==="dirty"&&!a&&(a={result:g,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(d=>new C(d));return l(t,{code:c.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}};ie.create=(r,e)=>new ie({options:r,typeName:y.ZodUnion,..._(e)});var F=r=>r instanceof ce?F(r.schema):r instanceof $?F(r.innerType()):r instanceof de?[r.value]:r instanceof ue?r.options:r instanceof le?x.objectValues(r.enum):r instanceof fe?F(r._def.innerType):r instanceof ne?[void 0]:r instanceof ae?[null]:r instanceof I?[void 0,...F(r.unwrap())]:r instanceof L?[null,...F(r.unwrap())]:r instanceof Ne||r instanceof he?F(r.unwrap()):r instanceof pe?F(r._def.innerType):[],Me=class r extends v{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return l(t,{code:c.invalid_type,expected:f.object,received:t.parsedType}),m;let s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(l(t,{code:c.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){let n=new Map;for(let a of t){let i=F(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new r({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,..._(s)})}};function Je(r,e){let t=V(r),s=V(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&s===f.object){let n=x.objectKeys(e),a=x.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};Object.prototype.hasOwnProperty.call(i,"__proto__")&&delete i.__proto__;for(let o of a){if(o==="__proto__")continue;let d=Je(r[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(t===f.array&&s===f.array){if(r.length!==e.length)return{valid:!1};let n=[];for(let a=0;a<r.length;a++){let i=r[a],o=e[a],d=Je(i,o);if(!d.valid)return{valid:!1};n.push(d.data)}return{valid:!0,data:n}}else return t===f.date&&s===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var oe=class extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(De(a)||De(i))return m;let o=Je(a.value,i.value);return o.valid?((Ze(a)||Ze(i))&&t.dirty(),{status:t.value,value:o.data}):(l(s,{code:c.invalid_intersection_types}),m)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};oe.create=(r,e,t)=>new oe({left:r,right:e,typeName:y.ZodIntersection,..._(t)});var U=class r extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.array)return l(s,{code:c.invalid_type,expected:f.array,received:s.parsedType}),m;if(s.data.length<this._def.items.length)return l(s,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),m;!this._def.rest&&s.data.length>this._def.items.length&&(l(s,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...s.data].map((i,o)=>{let d=this._def.items[o]||this._def.rest;return d?d._parse(new P(s,i,s.path,o)):null}).filter(i=>!!i);return s.common.async?Promise.all(a).then(i=>S.mergeArray(t,i)):S.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};U.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new U({items:r,typeName:y.ZodTuple,rest:null,..._(e)})};var Ve=class r extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.object)return l(s,{code:c.invalid_type,expected:f.object,received:s.parsedType}),m;let n=[],a=this._def.keyType,i=this._def.valueType;for(let o in s.data)n.push({key:a._parse(new P(s,o,s.path,o)),value:i._parse(new P(s,s.data[o],s.path,o)),alwaysSet:o in s.data});return s.common.async?S.mergeObjectAsync(t,n):S.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof v?new r({keyType:e,valueType:t,typeName:y.ZodRecord,..._(s)}):new r({keyType:Y.create(),valueType:e,typeName:y.ZodRecord,..._(t)})}},we=class extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.map)return l(s,{code:c.invalid_type,expected:f.map,received:s.parsedType}),m;let n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,d],u)=>({key:n._parse(new P(s,o,s.path,[u,"key"])),value:a._parse(new P(s,d,s.path,[u,"value"]))}));if(s.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let d of i){let u=await d.key,g=await d.value;if(u.status==="aborted"||g.status==="aborted")return m;(u.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(u.value,g.value)}return{status:t.value,value:o}})}else{let o=new Map;for(let d of i){let u=d.key,g=d.value;if(u.status==="aborted"||g.status==="aborted")return m;(u.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(u.value,g.value)}return{status:t.value,value:o}}}};we.create=(r,e,t)=>new we({valueType:e,keyType:r,typeName:y.ZodMap,..._(t)});var Te=class r extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==f.set)return l(s,{code:c.invalid_type,expected:f.set,received:s.parsedType}),m;let n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(l(s,{code:c.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(l(s,{code:c.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());let a=this._def.valueType;function i(d){let u=new Set;for(let g of d){if(g.status==="aborted")return m;g.status==="dirty"&&t.dirty(),u.add(g.value)}return{status:t.value,value:u}}let o=[...s.data.values()].map((d,u)=>a._parse(new P(s,d,s.path,u)));return s.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,t){return new r({...this._def,minSize:{value:e,message:h.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:h.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Te.create=(r,e)=>new Te({valueType:r,minSize:null,maxSize:null,typeName:y.ZodSet,..._(e)});var Ue=class r extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return l(t,{code:c.invalid_type,expected:f.function,received:t.parsedType}),m;function s(o,d){return je({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_e(),H].filter(u=>!!u),issueData:{code:c.invalid_arguments,argumentsError:d}})}function n(o,d){return je({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_e(),H].filter(u=>!!u),issueData:{code:c.invalid_return_type,returnTypeError:d}})}let a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof X){let o=this;return R(async function(...d){let u=new C([]),g=await o._def.args.parseAsync(d,a).catch(me=>{throw u.addIssue(s(d,me)),u}),O=await Reflect.apply(i,this,g);return await o._def.returns._def.type.parseAsync(O,a).catch(me=>{throw u.addIssue(n(O,me)),u})})}else{let o=this;return R(function(...d){let u=o._def.args.safeParse(d,a);if(!u.success)throw new C([s(d,u.error)]);let g=Reflect.apply(i,this,u.data),O=o._def.returns.safeParse(g,a);if(!O.success)throw new C([n(g,O.error)]);return O.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:U.create(e).rest(B.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new r({args:e||U.create([]).rest(B.create()),returns:t||B.create(),typeName:y.ZodFunction,..._(s)})}},ce=class extends v{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};ce.create=(r,e)=>new ce({getter:r,typeName:y.ZodLazy,..._(e)});var de=class extends v{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:c.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}};de.create=(r,e)=>new de({value:r,typeName:y.ZodLiteral,..._(e)});function ct(r,e){return new ue({values:r,typeName:y.ZodEnum,..._(e)})}var ue=class r extends v{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{expected:x.joinValues(s),received:t.parsedType,code:c.invalid_type}),m}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{received:t.data,code:c.invalid_enum_value,options:s}),m}return R(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}};ue.create=ct;var le=class extends v{_parse(e){let t=x.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==f.string&&s.parsedType!==f.number){let n=x.objectValues(t);return l(s,{expected:x.joinValues(n),received:s.parsedType,code:c.invalid_type}),m}if(this._cache||(this._cache=new Set(x.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let n=x.objectValues(t);return l(s,{received:s.data,code:c.invalid_enum_value,options:n}),m}return R(e.data)}get enum(){return this._def.values}};le.create=(r,e)=>new le({values:r,typeName:y.ZodNativeEnum,..._(e)});var X=class extends v{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return l(t,{code:c.invalid_type,expected:f.promise,received:t.parsedType}),m;let s=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return R(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};X.create=(r,e)=>new X({type:r,typeName:y.ZodPromise,..._(e)});var $=class extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{l(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){let i=n.transform(s.data,a);if(s.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return m;let d=await this._def.schema._parseAsync({data:o,path:s.path,parent:s});return d.status==="aborted"?m:d.status==="dirty"?K(d.value):t.value==="dirty"?K(d.value):d});{if(t.value==="aborted")return m;let o=this._def.schema._parseSync({data:i,path:s.path,parent:s});return o.status==="aborted"?m:o.status==="dirty"?K(o.value):t.value==="dirty"?K(o.value):o}}if(n.type==="refinement"){let i=o=>{let d=n.refinement(o,a);if(s.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){let o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){let i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!J(i))return m;let o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>J(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):m);x.assertNever(n)}};$.create=(r,e,t)=>new $({schema:r,typeName:y.ZodEffects,effect:e,..._(t)});$.createWithPreprocess=(r,e,t)=>new $({schema:e,effect:{type:"preprocess",transform:r},typeName:y.ZodEffects,..._(t)});var I=class extends v{_parse(e){return this._getType(e)===f.undefined?R(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};I.create=(r,e)=>new I({innerType:r,typeName:y.ZodOptional,..._(e)});var L=class extends v{_parse(e){return this._getType(e)===f.null?R(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};L.create=(r,e)=>new L({innerType:r,typeName:y.ZodNullable,..._(e)});var fe=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return t.parsedType===f.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};fe.create=(r,e)=>new fe({innerType:r,typeName:y.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,..._(e)});var pe=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ve(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new C(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new C(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};pe.create=(r,e)=>new pe({innerType:r,typeName:y.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,..._(e)});var Se=class extends v{_parse(e){if(this._getType(e)!==f.nan){let s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:f.nan,received:s.parsedType}),m}return{status:"valid",value:e.data}}};Se.create=r=>new Se({typeName:y.ZodNaN,..._(r)});var tr=Symbol("zod_brand"),Ne=class extends v{_parse(e){let{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}},Ie=class r extends v{_parse(e){let{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?m:a.status==="dirty"?(t.dirty(),K(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{let n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?m:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new r({in:e,out:t,typeName:y.ZodPipeline})}},he=class extends v{_parse(e){let t=this._def.innerType._parse(e),s=n=>(J(n)&&(n.value=Object.freeze(n.value)),n);return ve(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}};he.create=(r,e)=>new he({innerType:r,typeName:y.ZodReadonly,..._(e)});function nt(r,e){let t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function dt(r,e={},t){return r?G.create().superRefine((s,n)=>{let a=r(s);if(a instanceof Promise)return a.then(i=>{if(!i){let o=nt(e,s),d=o.fatal??t??!0;n.addIssue({code:"custom",...o,fatal:d})}});if(!a){let i=nt(e,s),o=i.fatal??t??!0;n.addIssue({code:"custom",...i,fatal:o})}}):G.create()}var rr={object:j.lazycreate},y;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(y||(y={}));var sr=(r,e={message:`Input not instance of ${r.name}`})=>dt(t=>t instanceof r,e),ut=Y.create,lt=ee.create,nr=Se.create,ar=te.create,ft=re.create,ir=se.create,or=be.create,cr=ne.create,dr=ae.create,ur=G.create,lr=B.create,fr=Z.create,pr=ke.create,hr=W.create,mr=j.create,yr=j.strictCreate,gr=ie.create,_r=Me.create,vr=oe.create,xr=U.create,br=Ve.create,kr=we.create,wr=Te.create,Tr=Ue.create,Sr=ce.create,Rr=de.create,Or=ue.create,Er=le.create,Ar=X.create,Cr=$.create,jr=I.create,Nr=L.create,Ir=$.createWithPreprocess,Pr=Ie.create,$r=()=>ut().optional(),Dr=()=>lt().optional(),Zr=()=>ft().optional(),Mr={string:(r=>Y.create({...r,coerce:!0})),number:(r=>ee.create({...r,coerce:!0})),boolean:(r=>re.create({...r,coerce:!0})),bigint:(r=>te.create({...r,coerce:!0})),date:(r=>se.create({...r,coerce:!0}))};var Vr=m;var Re=p.string().uuid(),ws=p.object({environmentId:p.string().uuid(),allowed:p.boolean(),revision:Re,updatedAt:p.string().datetime(),updatedBy:p.string().uuid()}).strict();var pt=(i=>(i.NoEnvironment="no_environment",i.NoRecordedGrant="no_recorded_grant",i.Unavailable="unavailable",i.Changed="changed",i.Denied="denied",i.OutOfScope="out_of_scope",i))(pt||{});function ht(r,e){try{let t=new URL(e),s=new URL(r);if(s.search||s.hash)return!1;let n=/%(?:2f|5c|2e|25)/i;if(e.includes("\\")||r.includes("\\")||n.test(t.pathname)||n.test(s.pathname))return!1;let a=s.pathname.replace(/\/$/,"");return["https:","http:"].includes(s.protocol)&&t.origin===s.origin&&(t.pathname===a||t.pathname.startsWith(`${a}/`))}catch{return!1}}var Ts=p.object({environmentId:p.string().uuid(),environmentAddress:p.string().url(),revision:Re}).strict(),Ss=p.object({refusal:p.nativeEnum(pt)}).strict();var Ye=(t=>(t.Patch="PATCH",t.Put="PUT",t))(Ye||{}),Oe=class extends Error{constructor(t){super(`Safety gap: ${t.reason}`);this.incident=t}incident},Ee=class extends Error{constructor(t){super("The delivered test assertion or execution failed; its resource trace is retained in diagnostics");this.trace=t}trace},Ae=class extends Error{};function D(r){throw new Ae(`environment restriction: ${r}`)}function gt(r){let e=new URL(r);return(!["https:","http:"].includes(e.protocol)||e.username||e.password||e.search||e.hash||/%(?:2f|5c|2e|25)/i.test(e.pathname)||r.includes("\\"))&&D("unsupported environment address"),e.href.replace(/\/$/,"")}function Le(r,e){let t=new URL(e,`${r}/`);return(!ht(r,e.includes("://")?e:t.href)||t.username||t.password||t.hash)&&D("request leaves the selected environment"),t}function Ur(r){let e=r.map(t=>{(!t||t.includes("\\")||/[\[\]{}()]/.test(t))&&D("unsupported off-limits pattern");let s=n=>n.split("*").map(a=>a.replace(/[.+?^$|]/g,"\\$&")).join(".*");return new RegExp(t.endsWith("/**")?`^(?:${s(t)}|${s(t.slice(0,-3))})$`:`^${s(t)}$`,"i")});return t=>e.some(s=>s.test(t.href)||s.test(t.pathname))}async function Lr(r){let e=await r.text();if(e)try{return JSON.parse(e)}catch{throw new Error("Shared test response was not JSON")}}function ze(r,e){let t=r;for(let s of e){if(!t||typeof t!="object"||!Object.hasOwn(t,s))return;t=t[s]}return t}async function mt(r){let e=await r.text(),t;if(e)try{t=JSON.parse(e)}catch{t=e}return{status:r.status,headers:r.headers,body:t}}function zr(r,e){let t=r.bearerTokenEnv;if(!t)return;let s=process.env[t];if(!s?.trim())throw new Error(`required SUT credential ${t} is unavailable`);if(process.env.TESTBOT_SHARED_SUT_TOKEN_ENV!==t)throw new Error("declared SUT credential is not approved by TESTBOT_SHARED_SUT_TOKEN_ENV");let n=process.env.TESTBOT_SHARED_SUT_ADDRESS,a=!1;try{a=!!n&>(n)===e}catch{}if(!a)throw new Error("SUT address does not match TESTBOT_SHARED_SUT_ADDRESS");return s}function qr(r){return{status:"restricted",detail:r instanceof Ae?r.message:"environment restriction: unsupported shared-environment configuration"}}async function _t(r,e){let t,s;try{(!r||!r.environmentId||!Array.isArray(r.offLimits))&&D("shared-environment identity and off-limits rules are required"),t=gt(r.environmentAddress),s=Ur(r.offLimits),r.route?.kind!=="persistence"&&D("delivered shared tests require the persistence route")}catch(k){return qr(k)}if(!Re.safeParse(r.persistenceRevision).success)throw new Error("No valid persistence revision was recorded at generation. Regenerate this test with persistence permission.");let n=zr(r,t),a=`testbot-${(0,yt.randomUUID)()}`,i=new Set,o=[],d=async(k,T,b)=>{let N=Le(t,T);return s(N)&&D("the request is off limits"),["GET","HEAD","OPTIONS"].includes(k)||(me=!0),await fetch(N,{method:k,headers:{...n?{Authorization:`Bearer ${n}`}:{},...b===void 0?{}:{"Content-Type":"application/json"}},redirect:"error",signal:AbortSignal.timeout(1e4),...b===void 0?{}:{body:JSON.stringify(b)}})},u=k=>{let T=Le(t,k).href;return i.has(T)||D("mutations and resource reads require a run-owned resource"),T},g=k=>new Ee({runId:a,route:r.route.kind,resources:o,retained:!0,outcome:"test-failed",...k===void 0?{}:{status:k}}),O=async(k,T)=>{let b=k.status;if(!(T===void 0?k.ok:T===b)||b<200||b>=300&&b<400||b>=500)throw await k.body?.cancel(),g(b);return mt(k)},M,me=!1;try{await e({async create(k,T,b,N={}){(!b.trim()||!Object.hasOwn(T,b)||typeof T[b]!="string")&&D("creation needs a supported run-unique string field"),Object.keys(T).some(q=>/^(?:id|_id|uuid|pk)$/i.test(q))&&D("caller-selected resource IDs cannot establish a newly owned record");let A=Le(t,k);A.search&&D("create-only collections cannot use query actions"),s(A)&&D("the request is off limits");let ye=`${T[b]}-${a}`,ge=q=>new Oe({runId:a,route:r.route.kind,resources:[...o,A.href],outcome:"failed-or-unknown",reason:q}),E;try{E=await d("POST",A.href,{...T,[b]:ye})}catch(q){throw q instanceof Ae?q:ge("create response was unavailable; side effects are unknown")}if(E.status>=400&&E.status<500){if(E.status===N.expectedStatus)return mt(E);throw await E.body?.cancel(),g(E.status)}if(!E.ok)throw ge(`create did not establish new-resource provenance (${E.status})`);let $e;try{$e=await Lr(E)}catch{throw ge("create returned unreadable resource provenance")}if(ze($e,N.responseUniqueFieldPath??[b])!==ye)throw ge("create did not confirm the run-unique value");let He=ze($e,N.responseIdPath??["id"]),Qe=E.headers.get("location"),z;try{let q=Qe?new URL(Qe,A).href:typeof He=="string"||typeof He=="number"?`${A.href.replace(/\/$/,"")}/${encodeURIComponent(He)}`:void 0;if(!q)throw new Error("no resource identity");z=Le(t,q)}catch{throw ge("create returned missing, invalid or out-of-scope resource provenance")}let Ke=A.pathname.replace(/\/$/,"")+"/",et=z.pathname.slice(Ke.length);if(z.search||!z.pathname.startsWith(Ke)||!et||et.includes("/")||s(z)||i.has(z.href))throw ge("create returned unsupported resource provenance");if(i.add(z.href),o.push(z.href),E.status!==(N.expectedStatus??201))throw g(E.status);return{url:z.href,body:$e,status:E.status,headers:E.headers}},async read(k,T={}){let b=new URL(u(k));for(let[A,ye]of Object.entries(T.query??{}))b.searchParams.append(A,ye);let N=await d("GET",b.href);return O(N,T.expectedStatus)},async update(k,T,b={}){let N=u(k),A=b.method??"PATCH";A!=="PATCH"&&A!=="PUT"&&D("unsupported resource update method");let ye=await d(A,N,T);return O(ye,b.expectedStatus)}})}catch(k){M=k}if(M instanceof Ae&&!me)return{status:"restricted",detail:M.message};if(M instanceof Oe||M instanceof Ee)throw M;if(M)throw g();return{status:"executed",runId:a,resources:o,retained:!0}}var Pe=p.lazy(()=>p.union([p.string(),p.number().finite(),p.boolean(),p.null(),p.array(Pe),p.record(Pe)])),w=p.string().trim().min(1),xt=p.string().regex(/^[A-Za-z_]\w*$/).optional(),Ge=p.number().int().refine(r=>r>=200&&r<300||r>=400&&r<500,"Expected an explicit success or client rejection status").optional(),vt=p.array(w).min(1).max(20).optional(),Hr=p.object({environmentId:p.string().uuid(),environmentAddress:p.string().url(),targetId:w.optional(),appOrigin:p.string().url().optional(),persistenceRevision:Re.optional(),offLimits:p.array(w),bearerTokenEnv:xt,route:p.object({kind:p.literal("persistence")}).strict()}).strict().refine(r=>!r.persistenceRevision||!r.targetId&&!r.appOrigin,"A generated persistence decision cannot include legacy policy lookup fields"),bt=p.array(p.discriminatedUnion("op",[p.object({op:p.literal("create"),collection:w,body:p.record(Pe),uniqueField:w,expectedStatus:Ge,responseIdPath:vt,responseUniqueFieldPath:vt,as:w}).strict(),p.object({op:p.literal("read"),resource:w,as:w,expectedStatus:Ge,query:p.record(p.string()).optional()}).strict(),p.object({op:p.literal("update"),resource:w,method:p.nativeEnum(Ye).optional(),expectedStatus:Ge,body:p.record(Pe),as:w}).strict(),p.object({op:p.literal("assert"),resource:w,path:p.array(w),equals:Pe}).strict(),p.object({op:p.literal("assertStatus"),resource:w,equals:p.number().int().min(200).max(499)}).strict(),p.object({op:p.literal("assertHeader"),resource:w,name:p.string().regex(/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/),equals:p.string().nullable()}).strict()])).min(1).refine(r=>r.some(e=>e.op==="assert"||e.op==="assertStatus"||e.op==="assertHeader"),"A runnable test must retain a planned assertion"),Ns=p.object({name:w,bearerTokenEnv:xt,steps:bt.describe("ordered objects with op: create (collection, body, uniqueField, as; optional expectedStatus, responseIdPath, responseUniqueFieldPath), read (resource, as; optional expectedStatus, query), update (resource, body, as; optional expectedStatus, method PUT or PATCH), assert (resource, path, equals), assertStatus (resource, equals), or assertHeader (resource, name, equals). Resource names an earlier request alias and paths are arrays of JSON keys")}).strict(),Xe=p.union([p.object({name:w,definition:Hr,steps:bt}).strict(),p.object({name:w,restriction:w,sourceAsset:p.object({path:w.regex(/^(?!\/)(?!.*(?:^|\/)\.\.?(?:\/|$))[^\\]+\.source$/),sha256:p.string().regex(/^[a-f0-9]{64}$/)}).strict()}).strict()]),Fr=`"use strict";
|
|
2
|
+
const spec = `,Br=`;
|
|
3
3
|
let runtime;
|
|
4
4
|
try { runtime = require("@skyramp/testbot-core/dist/shared-environment-test.cjs"); } catch {}
|
|
5
5
|
if (runtime && typeof runtime.sharedEnvironmentTest === "function") runtime.sharedEnvironmentTest(spec, __filename);
|
|
6
6
|
else require("node:test").test(spec.name, () => { throw new Error("required shared-environment guard runtime is unavailable"); });
|
|
7
|
-
`;function
|
|
7
|
+
`;function kt(r){return Fr+JSON.stringify(Xe.parse(r),null,2)+Br}function Wr(r,e){let t=Xe.parse(r);return(0,Tt.test)(t.name,async s=>{if("restriction"in t){let a=(0,Q.realpathSync)((0,Ce.dirname)(e)),i=(0,Ce.resolve)(a,t.sourceAsset.path);if(!i.startsWith(a+Ce.sep)||!(0,Q.lstatSync)(i).isFile()||(0,Q.lstatSync)(i).isSymbolicLink()||(0,Q.realpathSync)(i)!==i||(0,wt.createHash)("sha256").update((0,Q.readFileSync)(i)).digest("hex")!==t.sourceAsset.sha256)throw new Error("The restricted required test source asset is missing or changed");s.skip(`environment restriction: ${t.restriction}`);return}let n;try{n=await _t(t.definition,async a=>{let i=new Map,o=d=>{if(i.has(d))throw new Error("A delivered response alias cannot be reused")};for(let d of t.steps){if(d.op==="create"){o(d.as),i.set(d.as,await a.create(d.collection,d.body,d.uniqueField,d));continue}let u=i.get(d.resource);if(!u)throw new Error("A delivered step names no earlier response");if(d.op==="assert"){let g=ze(u.body,d.path);if(g===void 0)throw new Error("The planned assertion field was absent");(0,qe.deepStrictEqual)(g,d.equals)}else if(d.op==="assertStatus")(0,qe.deepStrictEqual)(u.status,d.equals);else if(d.op==="assertHeader")(0,qe.deepStrictEqual)(u.headers.get(d.name),d.equals);else{if(!u.url)throw new Error("A delivered request names no run-owned resource");o(d.as);let g=d.op==="read"?await a.read(u.url,d):await a.update(u.url,d.body,d);i.set(d.as,{...g,url:u.url})}}})}catch(a){throw a instanceof Oe&&s.diagnostic(JSON.stringify(a.incident)),a instanceof Ee&&s.diagnostic(JSON.stringify(a.trace)),a}n.status==="restricted"?s.skip(n.detail):s.diagnostic(JSON.stringify(n))})}0&&(module.exports={renderDeliveredSharedTest,sharedEnvironmentTest});
|
|
@@ -12,11 +12,12 @@ export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
|
12
12
|
declare const DeliveredSharedTestSpecSchema: z.ZodUnion<[
|
|
13
13
|
z.ZodObject<{
|
|
14
14
|
name: z.ZodString;
|
|
15
|
-
definition: z.ZodObject<{
|
|
15
|
+
definition: z.ZodEffects<z.ZodObject<{
|
|
16
16
|
environmentId: z.ZodString;
|
|
17
17
|
environmentAddress: z.ZodString;
|
|
18
18
|
targetId: z.ZodOptional<z.ZodString>;
|
|
19
19
|
appOrigin: z.ZodOptional<z.ZodString>;
|
|
20
|
+
persistenceRevision: z.ZodOptional<z.ZodString>;
|
|
20
21
|
offLimits: z.ZodArray<z.ZodString, "many">;
|
|
21
22
|
bearerTokenEnv: z.ZodOptional<z.ZodString>;
|
|
22
23
|
route: z.ZodObject<{
|
|
@@ -35,6 +36,7 @@ declare const DeliveredSharedTestSpecSchema: z.ZodUnion<[
|
|
|
35
36
|
};
|
|
36
37
|
targetId?: string | undefined;
|
|
37
38
|
appOrigin?: string | undefined;
|
|
39
|
+
persistenceRevision?: string | undefined;
|
|
38
40
|
bearerTokenEnv?: string | undefined;
|
|
39
41
|
}, {
|
|
40
42
|
environmentId: string;
|
|
@@ -45,6 +47,29 @@ declare const DeliveredSharedTestSpecSchema: z.ZodUnion<[
|
|
|
45
47
|
};
|
|
46
48
|
targetId?: string | undefined;
|
|
47
49
|
appOrigin?: string | undefined;
|
|
50
|
+
persistenceRevision?: string | undefined;
|
|
51
|
+
bearerTokenEnv?: string | undefined;
|
|
52
|
+
}>, {
|
|
53
|
+
environmentId: string;
|
|
54
|
+
environmentAddress: string;
|
|
55
|
+
offLimits: string[];
|
|
56
|
+
route: {
|
|
57
|
+
kind: "persistence";
|
|
58
|
+
};
|
|
59
|
+
targetId?: string | undefined;
|
|
60
|
+
appOrigin?: string | undefined;
|
|
61
|
+
persistenceRevision?: string | undefined;
|
|
62
|
+
bearerTokenEnv?: string | undefined;
|
|
63
|
+
}, {
|
|
64
|
+
environmentId: string;
|
|
65
|
+
environmentAddress: string;
|
|
66
|
+
offLimits: string[];
|
|
67
|
+
route: {
|
|
68
|
+
kind: "persistence";
|
|
69
|
+
};
|
|
70
|
+
targetId?: string | undefined;
|
|
71
|
+
appOrigin?: string | undefined;
|
|
72
|
+
persistenceRevision?: string | undefined;
|
|
48
73
|
bearerTokenEnv?: string | undefined;
|
|
49
74
|
}>;
|
|
50
75
|
steps: z.ZodEffects<z.ZodArray<z.ZodDiscriminatedUnion<"op", [
|
|
@@ -283,6 +308,7 @@ declare const DeliveredSharedTestSpecSchema: z.ZodUnion<[
|
|
|
283
308
|
};
|
|
284
309
|
targetId?: string | undefined;
|
|
285
310
|
appOrigin?: string | undefined;
|
|
311
|
+
persistenceRevision?: string | undefined;
|
|
286
312
|
bearerTokenEnv?: string | undefined;
|
|
287
313
|
};
|
|
288
314
|
}, {
|
|
@@ -333,6 +359,7 @@ declare const DeliveredSharedTestSpecSchema: z.ZodUnion<[
|
|
|
333
359
|
};
|
|
334
360
|
targetId?: string | undefined;
|
|
335
361
|
appOrigin?: string | undefined;
|
|
362
|
+
persistenceRevision?: string | undefined;
|
|
336
363
|
bearerTokenEnv?: string | undefined;
|
|
337
364
|
};
|
|
338
365
|
}>,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyramp/testbot-core",
|
|
3
|
-
"version": "0.13.2-v3.
|
|
3
|
+
"version": "0.13.2-v3.482",
|
|
4
4
|
"description": "Skyramp Testbot engine: AI-powered deterministic test generation, execution and maintenance",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"//files": "An explicit allowlist, never a glob. `dist/` is gitignored, so without this key npm's .gitignore fallback would publish a package with no engine in it; with a glob it would publish the sourcemaps, whose sourcesContent embeds every src/*.ts verbatim. dist/VERSION.json exists only in a release-engine.yml build.",
|