UNPKG

@proofgeist/kit

Version:

Create web application with the ProofKit stack

10 lines 524 kB
#!/usr/bin/env node --no-warnings import{a as Ih}from"./chunk-FEIY7W7S.js";import*as Jo from"@clack/prompts";import Zb from"chalk";import{Command as Jb}from"commander";import sh from"path";import*as Ds from"@clack/prompts";import{Command as ub}from"commander";import{execa as ab}from"execa";import uh from"fs-extra";import ac from"path";import{fileURLToPath as Lh}from"url";import xh from"path";import Nh from"fs-extra";var Wt=()=>{let e=xh.join(Ie,"package.json");return Nh.readJSONSync(e).version??"1.0.0"},uc=()=>{let e="22";try{return process.versions.node.split(".")[0]??e}catch{return e}};var jh=Lh(import.meta.url),Mh=ac.dirname(jh),Ie=ac.join(Mh,"../"),oc="proofkit",Gn="@proofgeist/kit",Nu="https://proofkit.dev",cc=Wt(),$h=cc.length,lc=` _______ ___ ___ ____ _ _ |_ __ \\ .' ..]|_ ||_ _| (_) / |_ | |__) |_ .--. .--. .--. _| |_ | |_/ / __ \`| |-' | ___/[ \`/'\`\\]/ .'\`\\ \\/ .'\`\\ \\'-| |-' | __'. [ | | | _| |_ | | | \\__. || \\__. | | | _| | \\ \\_ | | | |, |_____| [___] '.__.' '.__.' [___] |____||____|[___]\\__/ ${" ".repeat(61-$h)}v${cc} `,ys="my-proofkit-app";import{readFileSync as a2,writeFileSync as o2}from"fs";import c2 from"path";import{glob as l2}from"glob";import HD from"chalk";import{execa as Ac}from"execa";import bc from"ora";var Ee;(function(e){e.assertEqual=i=>i;function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{let s={};for(let u of i)s[u]=u;return s},e.getValidEnumValues=i=>{let s=e.objectKeys(i).filter(a=>typeof i[i[a]]!="number"),u={};for(let a of s)u[a]=i[a];return e.objectValues(u)},e.objectValues=i=>e.objectKeys(i).map(function(s){return i[s]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let s=[];for(let u in i)Object.prototype.hasOwnProperty.call(i,u)&&s.push(u);return s},e.find=(i,s)=>{for(let u of i)if(s(u))return u},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,s=" | "){return i.map(u=>typeof u=="string"?`'${u}'`:u).join(s)}e.joinValues=n,e.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(Ee||(Ee={}));var ju;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(ju||(ju={}));var X=Ee.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Cr=e=>{switch(typeof e){case"undefined":return X.undefined;case"string":return X.string;case"number":return isNaN(e)?X.nan:X.number;case"boolean":return X.boolean;case"function":return X.function;case"bigint":return X.bigint;case"symbol":return X.symbol;case"object":return Array.isArray(e)?X.array:e===null?X.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?X.promise:typeof Map<"u"&&e instanceof Map?X.map:typeof Set<"u"&&e instanceof Set?X.set:typeof Date<"u"&&e instanceof Date?X.date:X.object;default:return X.unknown}},q=Ee.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"]),Uh=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),Qe=class extends Error{constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}get errors(){return this.issues}format(t){let r=t||function(s){return s.message},n={_errors:[]},i=s=>{for(let u of s.issues)if(u.code==="invalid_union")u.unionErrors.map(i);else if(u.code==="invalid_return_type")i(u.returnTypeError);else if(u.code==="invalid_arguments")i(u.argumentsError);else if(u.path.length===0)n._errors.push(r(u));else{let a=n,o=0;for(;o<u.path.length;){let c=u.path[o];o===u.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(r(u))):a[c]=a[c]||{_errors:[]},a=a[c],o++}}};return i(this),n}static assert(t){if(!(t instanceof Qe))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Ee.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},n=[];for(let i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(t(i))):n.push(t(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Qe.create=e=>new Qe(e);var Zn=(e,t)=>{let r;switch(e.code){case q.invalid_type:e.received===X.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case q.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,Ee.jsonStringifyReplacer)}`;break;case q.unrecognized_keys:r=`Unrecognized key(s) in object: ${Ee.joinValues(e.keys,", ")}`;break;case q.invalid_union:r="Invalid input";break;case q.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${Ee.joinValues(e.options)}`;break;case q.invalid_enum_value:r=`Invalid enum value. Expected ${Ee.joinValues(e.options)}, received '${e.received}'`;break;case q.invalid_arguments:r="Invalid function arguments";break;case q.invalid_return_type:r="Invalid function return type";break;case q.invalid_date:r="Invalid date";break;case q.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:Ee.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case q.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case q.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case q.custom:r="Invalid input";break;case q.invalid_intersection_types:r="Intersection results could not be merged";break;case q.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case q.not_finite:r="Number must be finite";break;default:r=t.defaultError,Ee.assertNever(e)}return{message:r}},pc=Zn;function Vh(e){pc=e}function Es(){return pc}var vs=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,s=[...r,...i.path||[]],u={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let a="",o=n.filter(c=>!!c).slice().reverse();for(let c of o)a=c(u,{data:t,defaultError:a}).message;return{...i,path:s,message:a}},Hh=[];function J(e,t){let r=Es(),n=vs({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Zn?void 0:Zn].filter(i=>!!i)});e.common.issues.push(n)}var Ge=class{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(t,r){let n=[];for(let i of r){if(i.status==="aborted")return se;i.status==="dirty"&&t.dirty(),n.push(i.value)}return{status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let i of r){let s=await i.key,u=await i.value;n.push({key:s,value:u})}return Ge.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let i of r){let{key:s,value:u}=i;if(s.status==="aborted"||u.status==="aborted")return se;s.status==="dirty"&&t.dirty(),u.status==="dirty"&&t.dirty(),s.value!=="__proto__"&&(typeof u.value<"u"||i.alwaysSet)&&(n[s.value]=u.value)}return{status:t.value,value:n}}},se=Object.freeze({status:"aborted"}),Yn=e=>({status:"dirty",value:e}),st=e=>({status:"valid",value:e}),Mu=e=>e.status==="aborted",$u=e=>e.status==="dirty",Pi=e=>e.status==="valid",Ii=e=>typeof Promise<"u"&&e instanceof Promise;function Fs(e,t,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(e):n?n.value:t.get(e)}function hc(e,t,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(e,r):i?i.value=r:t.set(e,r),r}var ee;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(ee||(ee={}));var ki,Oi,_t=class{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},fc=(e,t)=>{if(Pi(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let r=new Qe(e.common.issues);return this._error=r,this._error}}};function fe(e){if(!e)return{};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(u,a)=>{var o,c;let{message:l}=e;return u.code==="invalid_enum_value"?{message:l??a.defaultError}:typeof a.data>"u"?{message:(o=l??n)!==null&&o!==void 0?o:a.defaultError}:u.code!=="invalid_type"?{message:a.defaultError}:{message:(c=l??r)!==null&&c!==void 0?c:a.defaultError}},description:i}}var de=class{constructor(t){this.spa=this.safeParseAsync,this._def=t,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)}get description(){return this._def.description}_getType(t){return Cr(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:Cr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return{status:new Ge,ctx:{common:t.parent.common,data:t.data,parsedType:Cr(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Ii(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){var n;let i={common:{issues:[],async:(n=r?.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Cr(t)},s=this._parseSync({data:t,path:i.path,parent:i});return fc(i,s)}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:Cr(t)},i=this._parse({data:t,path:n.path,parent:n}),s=await(Ii(i)?i:Promise.resolve(i));return fc(n,s)}refine(t,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,s)=>{let u=t(i),a=()=>s.addIssue({code:q.custom,...n(i)});return typeof Promise<"u"&&u instanceof Promise?u.then(o=>o?!0:(a(),!1)):u?!0:(a(),!1)})}refinement(t,r){return this._refinement((n,i)=>t(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(t){return new yt({schema:this,typeName:ie.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}optional(){return Ct.create(this,this._def)}nullable(){return zt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return gt.create(this,this._def)}promise(){return br.create(this,this._def)}or(t){return nn.create([this,t],this._def)}and(t){return sn.create(this,t,this._def)}transform(t){return new yt({...fe(this._def),schema:this,typeName:ie.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new ln({...fe(this._def),innerType:this,defaultValue:r,typeName:ie.ZodDefault})}brand(){return new xi({typeName:ie.ZodBranded,type:this,...fe(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new fn({...fe(this._def),innerType:this,catchValue:r,typeName:ie.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return dn.create(this,t)}readonly(){return pn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Wh=/^c[^\s-]{8,}$/i,Kh=/^[0-9a-z]+$/,qh=/^[0-9A-HJKMNP-TV-Z]{26}$/,Gh=/^[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,zh=/^[a-z0-9_-]{21}$/i,Yh=/^[-+]?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)?)??$/,Zh=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Jh="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Lu,Xh=/^(?:(?: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])$/,Qh=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,eD=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Dc="((\\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])))",tD=new RegExp(`^${Dc}$`);function mc(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`),t}function rD(e){return new RegExp(`^${mc(e)}$`)}function gc(e){let t=`${Dc}T${mc(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function nD(e,t){return!!((t==="v4"||!t)&&Xh.test(e)||(t==="v6"||!t)&&Qh.test(e))}var mt=class extends de{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==X.string){let s=this._getOrReturnCtx(t);return J(s,{code:q.invalid_type,expected:X.string,received:s.parsedType}),se}let n=new Ge,i;for(let s of this._def.checks)if(s.kind==="min")t.data.length<s.value&&(i=this._getOrReturnCtx(t,i),J(i,{code:q.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")t.data.length>s.value&&(i=this._getOrReturnCtx(t,i),J(i,{code:q.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let u=t.data.length>s.value,a=t.data.length<s.value;(u||a)&&(i=this._getOrReturnCtx(t,i),u?J(i,{code:q.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&J(i,{code:q.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")Zh.test(t.data)||(i=this._getOrReturnCtx(t,i),J(i,{validation:"email",code:q.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")Lu||(Lu=new RegExp(Jh,"u")),Lu.test(t.data)||(i=this._getOrReturnCtx(t,i),J(i,{validation:"emoji",code:q.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")Gh.test(t.data)||(i=this._getOrReturnCtx(t,i),J(i,{validation:"uuid",code:q.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")zh.test(t.data)||(i=this._getOrReturnCtx(t,i),J(i,{validation:"nanoid",code:q.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")Wh.test(t.data)||(i=this._getOrReturnCtx(t,i),J(i,{validation:"cuid",code:q.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")Kh.test(t.data)||(i=this._getOrReturnCtx(t,i),J(i,{validation:"cuid2",code:q.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")qh.test(t.data)||(i=this._getOrReturnCtx(t,i),J(i,{validation:"ulid",code:q.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(t.data)}catch{i=this._getOrReturnCtx(t,i),J(i,{validation:"url",code:q.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),J(i,{validation:"regex",code:q.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?t.data=t.data.trim():s.kind==="includes"?t.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(t,i),J(i,{code:q.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?t.data=t.data.toLowerCase():s.kind==="toUpperCase"?t.data=t.data.toUpperCase():s.kind==="startsWith"?t.data.startsWith(s.value)||(i=this._getOrReturnCtx(t,i),J(i,{code:q.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?t.data.endsWith(s.value)||(i=this._getOrReturnCtx(t,i),J(i,{code:q.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?gc(s).test(t.data)||(i=this._getOrReturnCtx(t,i),J(i,{code:q.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?tD.test(t.data)||(i=this._getOrReturnCtx(t,i),J(i,{code:q.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?rD(s).test(t.data)||(i=this._getOrReturnCtx(t,i),J(i,{code:q.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?Yh.test(t.data)||(i=this._getOrReturnCtx(t,i),J(i,{validation:"duration",code:q.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?nD(t.data,s.version)||(i=this._getOrReturnCtx(t,i),J(i,{validation:"ip",code:q.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?eD.test(t.data)||(i=this._getOrReturnCtx(t,i),J(i,{validation:"base64",code:q.invalid_string,message:s.message}),n.dirty()):Ee.assertNever(s);return{status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:q.invalid_string,...ee.errToObj(n)})}_addCheck(t){return new mt({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...ee.errToObj(t)})}url(t){return this._addCheck({kind:"url",...ee.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...ee.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...ee.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...ee.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...ee.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...ee.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...ee.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...ee.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...ee.errToObj(t)})}datetime(t){var r,n;return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:(r=t?.offset)!==null&&r!==void 0?r:!1,local:(n=t?.local)!==null&&n!==void 0?n:!1,...ee.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...ee.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...ee.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...ee.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...ee.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...ee.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...ee.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...ee.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...ee.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...ee.errToObj(r)})}nonempty(t){return this.min(1,ee.errToObj(t))}trim(){return new mt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new mt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new mt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(t=>t.kind==="datetime")}get isDate(){return!!this._def.checks.find(t=>t.kind==="date")}get isTime(){return!!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return!!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return!!this._def.checks.find(t=>t.kind==="email")}get isURL(){return!!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return!!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return!!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return!!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return!!this._def.checks.find(t=>t.kind==="ip")}get isBase64(){return!!this._def.checks.find(t=>t.kind==="base64")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};mt.create=e=>{var t;return new mt({checks:[],typeName:ie.ZodString,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...fe(e)})};function iD(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,s=parseInt(e.toFixed(i).replace(".","")),u=parseInt(t.toFixed(i).replace(".",""));return s%u/Math.pow(10,i)}var Kt=class extends de{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==X.number){let s=this._getOrReturnCtx(t);return J(s,{code:q.invalid_type,expected:X.number,received:s.parsedType}),se}let n,i=new Ge;for(let s of this._def.checks)s.kind==="int"?Ee.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),J(n,{code:q.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(n=this._getOrReturnCtx(t,n),J(n,{code:q.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(n=this._getOrReturnCtx(t,n),J(n,{code:q.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?iD(t.data,s.value)!==0&&(n=this._getOrReturnCtx(t,n),J(n,{code:q.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),J(n,{code:q.not_finite,message:s.message}),i.dirty()):Ee.assertNever(s);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,ee.toString(r))}gt(t,r){return this.setLimit("min",t,!1,ee.toString(r))}lte(t,r){return this.setLimit("max",t,!0,ee.toString(r))}lt(t,r){return this.setLimit("max",t,!1,ee.toString(r))}setLimit(t,r,n,i){return new Kt({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:ee.toString(i)}]})}_addCheck(t){return new Kt({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:ee.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ee.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ee.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ee.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ee.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:ee.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:ee.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ee.toString(t)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ee.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return!!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&Ee.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value)}return Number.isFinite(r)&&Number.isFinite(t)}};Kt.create=e=>new Kt({checks:[],typeName:ie.ZodNumber,coerce:e?.coerce||!1,...fe(e)});var qt=class extends de{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(t){if(this._def.coerce&&(t.data=BigInt(t.data)),this._getType(t)!==X.bigint){let s=this._getOrReturnCtx(t);return J(s,{code:q.invalid_type,expected:X.bigint,received:s.parsedType}),se}let n,i=new Ge;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?t.data<s.value:t.data<=s.value)&&(n=this._getOrReturnCtx(t,n),J(n,{code:q.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?t.data>s.value:t.data>=s.value)&&(n=this._getOrReturnCtx(t,n),J(n,{code:q.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?t.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),J(n,{code:q.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):Ee.assertNever(s);return{status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,!0,ee.toString(r))}gt(t,r){return this.setLimit("min",t,!1,ee.toString(r))}lte(t,r){return this.setLimit("max",t,!0,ee.toString(r))}lt(t,r){return this.setLimit("max",t,!1,ee.toString(r))}setLimit(t,r,n,i){return new qt({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:ee.toString(i)}]})}_addCheck(t){return new qt({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ee.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ee.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ee.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ee.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:ee.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};qt.create=e=>{var t;return new qt({checks:[],typeName:ie.ZodBigInt,coerce:(t=e?.coerce)!==null&&t!==void 0?t:!1,...fe(e)})};var en=class extends de{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==X.boolean){let n=this._getOrReturnCtx(t);return J(n,{code:q.invalid_type,expected:X.boolean,received:n.parsedType}),se}return st(t.data)}};en.create=e=>new en({typeName:ie.ZodBoolean,coerce:e?.coerce||!1,...fe(e)});var ur=class extends de{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==X.date){let s=this._getOrReturnCtx(t);return J(s,{code:q.invalid_type,expected:X.date,received:s.parsedType}),se}if(isNaN(t.data.getTime())){let s=this._getOrReturnCtx(t);return J(s,{code:q.invalid_date}),se}let n=new Ge,i;for(let s of this._def.checks)s.kind==="min"?t.data.getTime()<s.value&&(i=this._getOrReturnCtx(t,i),J(i,{code:q.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?t.data.getTime()>s.value&&(i=this._getOrReturnCtx(t,i),J(i,{code:q.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):Ee.assertNever(s);return{status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new ur({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:ee.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:ee.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};ur.create=e=>new ur({checks:[],coerce:e?.coerce||!1,typeName:ie.ZodDate,...fe(e)});var Jn=class extends de{_parse(t){if(this._getType(t)!==X.symbol){let n=this._getOrReturnCtx(t);return J(n,{code:q.invalid_type,expected:X.symbol,received:n.parsedType}),se}return st(t.data)}};Jn.create=e=>new Jn({typeName:ie.ZodSymbol,...fe(e)});var tn=class extends de{_parse(t){if(this._getType(t)!==X.undefined){let n=this._getOrReturnCtx(t);return J(n,{code:q.invalid_type,expected:X.undefined,received:n.parsedType}),se}return st(t.data)}};tn.create=e=>new tn({typeName:ie.ZodUndefined,...fe(e)});var rn=class extends de{_parse(t){if(this._getType(t)!==X.null){let n=this._getOrReturnCtx(t);return J(n,{code:q.invalid_type,expected:X.null,received:n.parsedType}),se}return st(t.data)}};rn.create=e=>new rn({typeName:ie.ZodNull,...fe(e)});var Ar=class extends de{constructor(){super(...arguments),this._any=!0}_parse(t){return st(t.data)}};Ar.create=e=>new Ar({typeName:ie.ZodAny,...fe(e)});var sr=class extends de{constructor(){super(...arguments),this._unknown=!0}_parse(t){return st(t.data)}};sr.create=e=>new sr({typeName:ie.ZodUnknown,...fe(e)});var xt=class extends de{_parse(t){let r=this._getOrReturnCtx(t);return J(r,{code:q.invalid_type,expected:X.never,received:r.parsedType}),se}};xt.create=e=>new xt({typeName:ie.ZodNever,...fe(e)});var Xn=class extends de{_parse(t){if(this._getType(t)!==X.undefined){let n=this._getOrReturnCtx(t);return J(n,{code:q.invalid_type,expected:X.void,received:n.parsedType}),se}return st(t.data)}};Xn.create=e=>new Xn({typeName:ie.ZodVoid,...fe(e)});var gt=class extends de{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==X.array)return J(r,{code:q.invalid_type,expected:X.array,received:r.parsedType}),se;if(i.exactLength!==null){let u=r.data.length>i.exactLength.value,a=r.data.length<i.exactLength.value;(u||a)&&(J(r,{code:u?q.too_big:q.too_small,minimum:a?i.exactLength.value:void 0,maximum:u?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(J(r,{code:q.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(J(r,{code:q.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((u,a)=>i.type._parseAsync(new _t(r,u,r.path,a)))).then(u=>Ge.mergeArray(n,u));let s=[...r.data].map((u,a)=>i.type._parseSync(new _t(r,u,r.path,a)));return Ge.mergeArray(n,s)}get element(){return this._def.type}min(t,r){return new gt({...this._def,minLength:{value:t,message:ee.toString(r)}})}max(t,r){return new gt({...this._def,maxLength:{value:t,message:ee.toString(r)}})}length(t,r){return new gt({...this._def,exactLength:{value:t,message:ee.toString(r)}})}nonempty(t){return this.min(1,t)}};gt.create=(e,t)=>new gt({type:e,minLength:null,maxLength:null,exactLength:null,typeName:ie.ZodArray,...fe(t)});function zn(e){if(e instanceof Re){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=Ct.create(zn(n))}return new Re({...e._def,shape:()=>t})}else return e instanceof gt?new gt({...e._def,type:zn(e.element)}):e instanceof Ct?Ct.create(zn(e.unwrap())):e instanceof zt?zt.create(zn(e.unwrap())):e instanceof At?At.create(e.items.map(t=>zn(t))):e}var Re=class extends de{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=Ee.objectKeys(t);return this._cached={shape:t,keys:r}}_parse(t){if(this._getType(t)!==X.object){let c=this._getOrReturnCtx(t);return J(c,{code:q.invalid_type,expected:X.object,received:c.parsedType}),se}let{status:n,ctx:i}=this._processInputParams(t),{shape:s,keys:u}=this._getCached(),a=[];if(!(this._def.catchall instanceof xt&&this._def.unknownKeys==="strip"))for(let c in i.data)u.includes(c)||a.push(c);let o=[];for(let c of u){let l=s[c],f=i.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new _t(i,f,i.path,c)),alwaysSet:c in i.data})}if(this._def.catchall instanceof xt){let c=this._def.unknownKeys;if(c==="passthrough")for(let l of a)o.push({key:{status:"valid",value:l},value:{status:"valid",value:i.data[l]}});else if(c==="strict")a.length>0&&(J(i,{code:q.unrecognized_keys,keys:a}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let c=this._def.catchall;for(let l of a){let f=i.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new _t(i,f,i.path,l)),alwaysSet:l in i.data})}}return i.common.async?Promise.resolve().then(async()=>{let c=[];for(let l of o){let f=await l.key,d=await l.value;c.push({key:f,value:d,alwaysSet:l.alwaysSet})}return c}).then(c=>Ge.mergeObjectSync(n,c)):Ge.mergeObjectSync(n,o)}get shape(){return this._def.shape()}strict(t){return ee.errToObj,new Re({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{var i,s,u,a;let o=(u=(s=(i=this._def).errorMap)===null||s===void 0?void 0:s.call(i,r,n).message)!==null&&u!==void 0?u:n.defaultError;return r.code==="unrecognized_keys"?{message:(a=ee.errToObj(t).message)!==null&&a!==void 0?a:o}:{message:o}}}:{}})}strip(){return new Re({...this._def,unknownKeys:"strip"})}passthrough(){return new Re({...this._def,unknownKeys:"passthrough"})}extend(t){return new Re({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new Re({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:ie.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new Re({...this._def,catchall:t})}pick(t){let r={};return Ee.objectKeys(t).forEach(n=>{t[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new Re({...this._def,shape:()=>r})}omit(t){let r={};return Ee.objectKeys(this.shape).forEach(n=>{t[n]||(r[n]=this.shape[n])}),new Re({...this._def,shape:()=>r})}deepPartial(){return zn(this)}partial(t){let r={};return Ee.objectKeys(this.shape).forEach(n=>{let i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional()}),new Re({...this._def,shape:()=>r})}required(t){let r={};return Ee.objectKeys(this.shape).forEach(n=>{if(t&&!t[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Ct;)s=s._def.innerType;r[n]=s}}),new Re({...this._def,shape:()=>r})}keyof(){return yc(Ee.objectKeys(this.shape))}};Re.create=(e,t)=>new Re({shape:()=>e,unknownKeys:"strip",catchall:xt.create(),typeName:ie.ZodObject,...fe(t)});Re.strictCreate=(e,t)=>new Re({shape:()=>e,unknownKeys:"strict",catchall:xt.create(),typeName:ie.ZodObject,...fe(t)});Re.lazycreate=(e,t)=>new Re({shape:e,unknownKeys:"strip",catchall:xt.create(),typeName:ie.ZodObject,...fe(t)});var nn=class extends de{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function i(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let u=s.map(a=>new Qe(a.ctx.common.issues));return J(r,{code:q.invalid_union,unionErrors:u}),se}if(r.common.async)return Promise.all(n.map(async s=>{let u={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:u}),ctx:u}})).then(i);{let s,u=[];for(let o of n){let c={...r,common:{...r.common,issues:[]},parent:null},l=o._parseSync({data:r.data,path:r.path,parent:c});if(l.status==="valid")return l;l.status==="dirty"&&!s&&(s={result:l,ctx:c}),c.common.issues.length&&u.push(c.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let a=u.map(o=>new Qe(o));return J(r,{code:q.invalid_union,unionErrors:a}),se}}get options(){return this._def.options}};nn.create=(e,t)=>new nn({options:e,typeName:ie.ZodUnion,...fe(t)});var ir=e=>e instanceof an?ir(e.schema):e instanceof yt?ir(e.innerType()):e instanceof on?[e.value]:e instanceof Gt?e.options:e instanceof cn?Ee.objectValues(e.enum):e instanceof ln?ir(e._def.innerType):e instanceof tn?[void 0]:e instanceof rn?[null]:e instanceof Ct?[void 0,...ir(e.unwrap())]:e instanceof zt?[null,...ir(e.unwrap())]:e instanceof xi||e instanceof pn?ir(e.unwrap()):e instanceof fn?ir(e._def.innerType):[],Qn=class extends de{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==X.object)return J(r,{code:q.invalid_type,expected:X.object,received:r.parsedType}),se;let n=this.discriminator,i=r.data[n],s=this.optionsMap.get(i);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):(J(r,{code:q.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),se)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let i=new Map;for(let s of r){let u=ir(s.shape[t]);if(!u.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let a of u){if(i.has(a))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(a)}`);i.set(a,s)}}return new Qn({typeName:ie.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...fe(n)})}};function Uu(e,t){let r=Cr(e),n=Cr(t);if(e===t)return{valid:!0,data:e};if(r===X.object&&n===X.object){let i=Ee.objectKeys(t),s=Ee.objectKeys(e).filter(a=>i.indexOf(a)!==-1),u={...e,...t};for(let a of s){let o=Uu(e[a],t[a]);if(!o.valid)return{valid:!1};u[a]=o.data}return{valid:!0,data:u}}else if(r===X.array&&n===X.array){if(e.length!==t.length)return{valid:!1};let i=[];for(let s=0;s<e.length;s++){let u=e[s],a=t[s],o=Uu(u,a);if(!o.valid)return{valid:!1};i.push(o.data)}return{valid:!0,data:i}}else return r===X.date&&n===X.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var sn=class extends de{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=(s,u)=>{if(Mu(s)||Mu(u))return se;let a=Uu(s.value,u.value);return a.valid?(($u(s)||$u(u))&&r.dirty(),{status:r.value,value:a.data}):(J(n,{code:q.invalid_intersection_types}),se)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([s,u])=>i(s,u)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};sn.create=(e,t,r)=>new sn({left:e,right:t,typeName:ie.ZodIntersection,...fe(r)});var At=class extends de{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==X.array)return J(n,{code:q.invalid_type,expected:X.array,received:n.parsedType}),se;if(n.data.length<this._def.items.length)return J(n,{code:q.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),se;!this._def.rest&&n.data.length>this._def.items.length&&(J(n,{code:q.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...n.data].map((u,a)=>{let o=this._def.items[a]||this._def.rest;return o?o._parse(new _t(n,u,n.path,a)):null}).filter(u=>!!u);return n.common.async?Promise.all(s).then(u=>Ge.mergeArray(r,u)):Ge.mergeArray(r,s)}get items(){return this._def.items}rest(t){return new At({...this._def,rest:t})}};At.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new At({items:e,typeName:ie.ZodTuple,rest:null,...fe(t)})};var un=class extends de{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==X.object)return J(n,{code:q.invalid_type,expected:X.object,received:n.parsedType}),se;let i=[],s=this._def.keyType,u=this._def.valueType;for(let a in n.data)i.push({key:s._parse(new _t(n,a,n.path,a)),value:u._parse(new _t(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?Ge.mergeObjectAsync(r,i):Ge.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof de?new un({keyType:t,valueType:r,typeName:ie.ZodRecord,...fe(n)}):new un({keyType:mt.create(),valueType:t,typeName:ie.ZodRecord,...fe(r)})}},ei=class extends de{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==X.map)return J(n,{code:q.invalid_type,expected:X.map,received:n.parsedType}),se;let i=this._def.keyType,s=this._def.valueType,u=[...n.data.entries()].map(([a,o],c)=>({key:i._parse(new _t(n,a,n.path,[c,"key"])),value:s._parse(new _t(n,o,n.path,[c,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let o of u){let c=await o.key,l=await o.value;if(c.status==="aborted"||l.status==="aborted")return se;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(c.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let o of u){let c=o.key,l=o.value;if(c.status==="aborted"||l.status==="aborted")return se;(c.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(c.value,l.value)}return{status:r.value,value:a}}}};ei.create=(e,t,r)=>new ei({valueType:t,keyType:e,typeName:ie.ZodMap,...fe(r)});var ar=class extends de{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==X.set)return J(n,{code:q.invalid_type,expected:X.set,received:n.parsedType}),se;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(J(n,{code:q.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(J(n,{code:q.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());let s=this._def.valueType;function u(o){let c=new Set;for(let l of o){if(l.status==="aborted")return se;l.status==="dirty"&&r.dirty(),c.add(l.value)}return{status:r.value,value:c}}let a=[...n.data.values()].map((o,c)=>s._parse(new _t(n,o,n.path,c)));return n.common.async?Promise.all(a).then(o=>u(o)):u(a)}min(t,r){return new ar({...this._def,minSize:{value:t,message:ee.toString(r)}})}max(t,r){return new ar({...this._def,maxSize:{value:t,message:ee.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};ar.create=(e,t)=>new ar({valueType:e,minSize:null,maxSize:null,typeName:ie.ZodSet,...fe(t)});var _r=class extends de{constructor(){super(...arguments),this.validate=this.implement}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==X.function)return J(r,{code:q.invalid_type,expected:X.function,received:r.parsedType}),se;function n(a,o){return vs({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Es(),Zn].filter(c=>!!c),issueData:{code:q.invalid_arguments,argumentsError:o}})}function i(a,o){return vs({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Es(),Zn].filter(c=>!!c),issueData:{code:q.invalid_return_type,returnTypeError:o}})}let s={errorMap:r.common.contextualErrorMap},u=r.data;if(this._def.returns instanceof br){let a=this;return st(async function(...o){let c=new Qe([]),l=await a._def.args.parseAsync(o,s).catch(h=>{throw c.addIssue(n(o,h)),c}),f=await Reflect.apply(u,this,l);return await a._def.returns._def.type.parseAsync(f,s).catch(h=>{throw c.addIssue(i(f,h)),c})})}else{let a=this;return st(function(...o){let c=a._def.args.safeParse(o,s);if(!c.success)throw new Qe([n(o,c.error)]);let l=Reflect.apply(u,this,c.data),f=a._def.returns.safeParse(l,s);if(!f.success)throw new Qe([i(l,f.error)]);return f.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new _r({...this._def,args:At.create(t).rest(sr.create())})}returns(t){return new _r({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new _r({args:t||At.create([]).rest(sr.create()),returns:r||sr.create(),typeName:ie.ZodFunction,...fe(n)})}},an=class extends de{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};an.create=(e,t)=>new an({getter:e,typeName:ie.ZodLazy,...fe(t)});var on=class extends de{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return J(r,{received:r.data,code:q.invalid_literal,expected:this._def.value}),se}return{status:"valid",value:t.data}}get value(){return this._def.value}};on.create=(e,t)=>new on({value:e,typeName:ie.ZodLiteral,...fe(t)});function yc(e,t){return new Gt({values:e,typeName:ie.ZodEnum,...fe(t)})}var Gt=class extends de{constructor(){super(...arguments),ki.set(this,void 0)}_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return J(r,{expected:Ee.joinValues(n),received:r.parsedType,code:q.invalid_type}),se}if(Fs(this,ki,"f")||hc(this,ki,new Set(this._def.values),"f"),!Fs(this,ki,"f").has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return J(r,{received:r.data,code:q.invalid_enum_value,options:n}),se}return st(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return Gt.create(t,{...this._def,...r})}exclude(t,r=this._def){return Gt.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};ki=new WeakMap;Gt.create=yc;var cn=class extends de{constructor(){super(...arguments),Oi.set(this,void 0)}_parse(t){let r=Ee.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==X.string&&n.parsedType!==X.number){let i=Ee.objectValues(r);return J(n,{expected:Ee.joinValues(i),received:n.parsedType,code:q.invalid_type}),se}if(Fs(this,Oi,"f")||hc(this,Oi,new Set(Ee.getValidEnumValues(this._def.values)),"f"),!Fs(this,Oi,"f").has(t.data)){let i=Ee.objectValues(r);return J(n,{received:n.data,code:q.invalid_enum_value,options:i}),se}return st(t.data)}get enum(){return this._def.values}};Oi=new WeakMap;cn.create=(e,t)=>new cn({values:e,typeName:ie.ZodNativeEnum,...fe(t)});var br=class extends de{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==X.promise&&r.common.async===!1)return J(r,{code:q.invalid_type,expected:X.promise,received:r.parsedType}),se;let n=r.parsedType===X.pro