diff --git a/packages/next/package.json b/packages/next/package.json index 7b4bf037bf3967..8da39be1b5ded3 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -96,8 +96,7 @@ "caniuse-lite": "^1.0.30001406", "postcss": "8.4.14", "styled-jsx": "5.1.1", - "watchpack": "2.4.0", - "zod": "3.21.4" + "watchpack": "2.4.0" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", @@ -297,6 +296,7 @@ "string-hash": "1.1.3", "string_decoder": "1.3.0", "strip-ansi": "6.0.0", + "superstruct": "1.0.3", "tar": "6.1.15", "taskr": "1.1.0", "terser": "5.14.1", diff --git a/packages/next/src/compiled/superstruct/index.cjs b/packages/next/src/compiled/superstruct/index.cjs new file mode 100644 index 00000000000000..a173ca657dbfbd --- /dev/null +++ b/packages/next/src/compiled/superstruct/index.cjs @@ -0,0 +1 @@ +(()=>{var e={318:function(e,t){(function(e,n){true?n(t):0})(this,(function(e){"use strict";class StructError extends TypeError{constructor(e,t){let n;const{message:r,explanation:i,...c}=e;const{path:o}=e;const a=o.length===0?r:`At path: ${o.join(".")} -- ${r}`;super(i??a);if(i!=null)this.cause=a;Object.assign(this,c);this.name=this.constructor.name;this.failures=()=>n??(n=[e,...t()])}}function isIterable(e){return isObject(e)&&typeof e[Symbol.iterator]==="function"}function isObject(e){return typeof e==="object"&&e!=null}function isPlainObject(e){if(Object.prototype.toString.call(e)!=="[object Object]"){return false}const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function print(e){if(typeof e==="symbol"){return e.toString()}return typeof e==="string"?JSON.stringify(e):`${e}`}function shiftIterator(e){const{done:t,value:n}=e.next();return t?undefined:n}function toFailure(e,t,n,r){if(e===true){return}else if(e===false){e={}}else if(typeof e==="string"){e={message:e}}const{path:i,branch:c}=t;const{type:o}=n;const{refinement:a,message:s=`Expected a value of type \`${o}\`${a?` with refinement \`${a}\``:""}, but received: \`${print(r)}\``}=e;return{value:r,type:o,refinement:a,key:i[i.length-1],path:i,branch:c,...e,message:s}}function*toFailures(e,t,n,r){if(!isIterable(e)){e=[e]}for(const i of e){const e=toFailure(i,t,n,r);if(e){yield e}}}function*run(e,t,n={}){const{path:r=[],branch:i=[e],coerce:c=false,mask:o=false}=n;const a={path:r,branch:i};if(c){e=t.coercer(e,a);if(o&&t.type!=="type"&&isObject(t.schema)&&isObject(e)&&!Array.isArray(e)){for(const n in e){if(t.schema[n]===undefined){delete e[n]}}}}let s="valid";for(const r of t.validator(e,a)){r.explanation=n.message;s="not_valid";yield[r,undefined]}for(let[u,f,l]of t.entries(e,a)){const t=run(f,l,{path:u===undefined?r:[...r,u],branch:u===undefined?i:[...i,f],coerce:c,mask:o,message:n.message});for(const n of t){if(n[0]){s=n[0].refinement!=null?"not_refined":"not_valid";yield[n[0],undefined]}else if(c){f=n[1];if(u===undefined){e=f}else if(e instanceof Map){e.set(u,f)}else if(e instanceof Set){e.add(f)}else if(isObject(e)){if(f!==undefined||u in e)e[u]=f}}}}if(s!=="not_valid"){for(const r of t.refiner(e,a)){r.explanation=n.message;s="not_refined";yield[r,undefined]}}if(s==="valid"){yield[undefined,e]}}class Struct{constructor(e){const{type:t,schema:n,validator:r,refiner:i,coercer:c=(e=>e),entries:o=function*(){}}=e;this.type=t;this.schema=n;this.entries=o;this.coercer=c;if(r){this.validator=(e,t)=>{const n=r(e,t);return toFailures(n,t,this,e)}}else{this.validator=()=>[]}if(i){this.refiner=(e,t)=>{const n=i(e,t);return toFailures(n,t,this,e)}}else{this.refiner=()=>[]}}assert(e,t){return assert(e,this,t)}create(e,t){return create(e,this,t)}is(e){return is(e,this)}mask(e,t){return mask(e,this,t)}validate(e,t={}){return validate(e,this,t)}}function assert(e,t,n){const r=validate(e,t,{message:n});if(r[0]){throw r[0]}}function create(e,t,n){const r=validate(e,t,{coerce:true,message:n});if(r[0]){throw r[0]}else{return r[1]}}function mask(e,t,n){const r=validate(e,t,{coerce:true,mask:true,message:n});if(r[0]){throw r[0]}else{return r[1]}}function is(e,t){const n=validate(e,t);return!n[0]}function validate(e,t,n={}){const r=run(e,t,n);const i=shiftIterator(r);if(i[0]){const e=new StructError(i[0],(function*(){for(const e of r){if(e[0]){yield e[0]}}}));return[e,undefined]}else{const e=i[1];return[undefined,e]}}function assign(...e){const t=e[0].type==="type";const n=e.map((e=>e.schema));const r=Object.assign({},...n);return t?type(r):object(r)}function define(e,t){return new Struct({type:e,schema:null,validator:t})}function deprecated(e,t){return new Struct({...e,refiner:(t,n)=>t===undefined||e.refiner(t,n),validator(n,r){if(n===undefined){return true}else{t(n,r);return e.validator(n,r)}}})}function dynamic(e){return new Struct({type:"dynamic",schema:null,*entries(t,n){const r=e(t,n);yield*r.entries(t,n)},validator(t,n){const r=e(t,n);return r.validator(t,n)},coercer(t,n){const r=e(t,n);return r.coercer(t,n)},refiner(t,n){const r=e(t,n);return r.refiner(t,n)}})}function lazy(e){let t;return new Struct({type:"lazy",schema:null,*entries(n,r){t??(t=e());yield*t.entries(n,r)},validator(n,r){t??(t=e());return t.validator(n,r)},coercer(n,r){t??(t=e());return t.coercer(n,r)},refiner(n,r){t??(t=e());return t.refiner(n,r)}})}function omit(e,t){const{schema:n}=e;const r={...n};for(const e of t){delete r[e]}switch(e.type){case"type":return type(r);default:return object(r)}}function partial(e){const t=e instanceof Struct?{...e.schema}:{...e};for(const e in t){t[e]=optional(t[e])}return object(t)}function pick(e,t){const{schema:n}=e;const r={};for(const e of t){r[e]=n[e]}return object(r)}function struct(e,t){console.warn("superstruct@0.11 - The `struct` helper has been renamed to `define`.");return define(e,t)}function any(){return define("any",(()=>true))}function array(e){return new Struct({type:"array",schema:e,*entries(t){if(e&&Array.isArray(t)){for(const[n,r]of t.entries()){yield[n,r,e]}}},coercer(e){return Array.isArray(e)?e.slice():e},validator(e){return Array.isArray(e)||`Expected an array value, but received: ${print(e)}`}})}function bigint(){return define("bigint",(e=>typeof e==="bigint"))}function boolean(){return define("boolean",(e=>typeof e==="boolean"))}function date(){return define("date",(e=>e instanceof Date&&!isNaN(e.getTime())||`Expected a valid \`Date\` object, but received: ${print(e)}`))}function enums(e){const t={};const n=e.map((e=>print(e))).join();for(const n of e){t[n]=n}return new Struct({type:"enums",schema:t,validator(t){return e.includes(t)||`Expected one of \`${n}\`, but received: ${print(t)}`}})}function func(){return define("func",(e=>typeof e==="function"||`Expected a function, but received: ${print(e)}`))}function instance(e){return define("instance",(t=>t instanceof e||`Expected a \`${e.name}\` instance, but received: ${print(t)}`))}function integer(){return define("integer",(e=>typeof e==="number"&&!isNaN(e)&&Number.isInteger(e)||`Expected an integer, but received: ${print(e)}`))}function intersection(e){return new Struct({type:"intersection",schema:null,*entries(t,n){for(const r of e){yield*r.entries(t,n)}},*validator(t,n){for(const r of e){yield*r.validator(t,n)}},*refiner(t,n){for(const r of e){yield*r.refiner(t,n)}}})}function literal(e){const t=print(e);const n=typeof e;return new Struct({type:"literal",schema:n==="string"||n==="number"||n==="boolean"?e:null,validator(n){return n===e||`Expected the literal \`${t}\`, but received: ${print(n)}`}})}function map(e,t){return new Struct({type:"map",schema:null,*entries(n){if(e&&t&&n instanceof Map){for(const[r,i]of n.entries()){yield[r,r,e];yield[r,i,t]}}},coercer(e){return e instanceof Map?new Map(e):e},validator(e){return e instanceof Map||`Expected a \`Map\` object, but received: ${print(e)}`}})}function never(){return define("never",(()=>false))}function nullable(e){return new Struct({...e,validator:(t,n)=>t===null||e.validator(t,n),refiner:(t,n)=>t===null||e.refiner(t,n)})}function number(){return define("number",(e=>typeof e==="number"&&!isNaN(e)||`Expected a number, but received: ${print(e)}`))}function object(e){const t=e?Object.keys(e):[];const n=never();return new Struct({type:"object",schema:e?e:null,*entries(r){if(e&&isObject(r)){const i=new Set(Object.keys(r));for(const n of t){i.delete(n);yield[n,r[n],e[n]]}for(const e of i){yield[e,r[e],n]}}},validator(e){return isObject(e)||`Expected an object, but received: ${print(e)}`},coercer(e){return isObject(e)?{...e}:e}})}function optional(e){return new Struct({...e,validator:(t,n)=>t===undefined||e.validator(t,n),refiner:(t,n)=>t===undefined||e.refiner(t,n)})}function record(e,t){return new Struct({type:"record",schema:null,*entries(n){if(isObject(n)){for(const r in n){const i=n[r];yield[r,r,e];yield[r,i,t]}}},validator(e){return isObject(e)||`Expected an object, but received: ${print(e)}`}})}function regexp(){return define("regexp",(e=>e instanceof RegExp))}function set(e){return new Struct({type:"set",schema:null,*entries(t){if(e&&t instanceof Set){for(const n of t){yield[n,n,e]}}},coercer(e){return e instanceof Set?new Set(e):e},validator(e){return e instanceof Set||`Expected a \`Set\` object, but received: ${print(e)}`}})}function string(){return define("string",(e=>typeof e==="string"||`Expected a string, but received: ${print(e)}`))}function tuple(e){const t=never();return new Struct({type:"tuple",schema:null,*entries(n){if(Array.isArray(n)){const r=Math.max(e.length,n.length);for(let i=0;ie.type)).join(" | ");return new Struct({type:"union",schema:null,coercer(t){for(const n of e){const[e,r]=n.validate(t,{coerce:true});if(!e){return r}}return t},validator(n,r){const i=[];for(const t of e){const[...e]=run(n,t,r);const[c]=e;if(!c[0]){return[]}else{for(const[t]of e){if(t){i.push(t)}}}}return[`Expected the value to satisfy a union of \`${t}\`, but received: ${print(n)}`,...i]}})}function unknown(){return define("unknown",(()=>true))}function coerce(e,t,n){return new Struct({...e,coercer:(r,i)=>is(r,t)?e.coercer(n(r,i),i):e.coercer(r,i)})}function defaulted(e,t,n={}){return coerce(e,unknown(),(e=>{const r=typeof t==="function"?t():t;if(e===undefined){return r}if(!n.strict&&isPlainObject(e)&&isPlainObject(r)){const t={...e};let n=false;for(const e in r){if(t[e]===undefined){t[e]=r[e];n=true}}if(n){return t}}return e}))}function trimmed(e){return coerce(e,string(),(e=>e.trim()))}function empty(e){return refine(e,"empty",(t=>{const n=getSize(t);return n===0||`Expected an empty ${e.type} but received one with a size of \`${n}\``}))}function getSize(e){if(e instanceof Map||e instanceof Set){return e.size}else{return e.length}}function max(e,t,n={}){const{exclusive:r}=n;return refine(e,"max",(n=>r?nr?n>t:n>=t||`Expected a ${e.type} greater than ${r?"":"or equal to "}${t} but received \`${n}\``))}function nonempty(e){return refine(e,"nonempty",(t=>{const n=getSize(t);return n>0||`Expected a nonempty ${e.type} but received an empty one`}))}function pattern(e,t){return refine(e,"pattern",(n=>t.test(n)||`Expected a ${e.type} matching \`/${t.source}/\` but received "${n}"`))}function size(e,t,n=t){const r=`Expected a ${e.type}`;const i=t===n?`of \`${t}\``:`between \`${t}\` and \`${n}\``;return refine(e,"size",(e=>{if(typeof e==="number"||e instanceof Date){return t<=e&&e<=n||`${r} ${i} but received \`${e}\``}else if(e instanceof Map||e instanceof Set){const{size:c}=e;return t<=c&&c<=n||`${r} with a size ${i} but received one with a size of \`${c}\``}else{const{length:c}=e;return t<=c&&c<=n||`${r} with a length ${i} but received one with a length of \`${c}\``}}))}function refine(e,t,n){return new Struct({...e,*refiner(r,i){yield*e.refiner(r,i);const c=n(r,i);const o=toFailures(c,i,e,r);for(const e of o){yield{...e,refinement:t}}}})}e.Struct=Struct;e.StructError=StructError;e.any=any;e.array=array;e.assert=assert;e.assign=assign;e.bigint=bigint;e.boolean=boolean;e.coerce=coerce;e.create=create;e.date=date;e.defaulted=defaulted;e.define=define;e.deprecated=deprecated;e.dynamic=dynamic;e.empty=empty;e.enums=enums;e.func=func;e.instance=instance;e.integer=integer;e.intersection=intersection;e.is=is;e.lazy=lazy;e.literal=literal;e.map=map;e.mask=mask;e.max=max;e.min=min;e.never=never;e.nonempty=nonempty;e.nullable=nullable;e.number=number;e.object=object;e.omit=omit;e.optional=optional;e.partial=partial;e.pattern=pattern;e.pick=pick;e.record=record;e.refine=refine;e.regexp=regexp;e.set=set;e.size=size;e.string=string;e.struct=struct;e.trimmed=trimmed;e.tuple=tuple;e.type=type;e.union=union;e.unknown=unknown;e.validate=validate}))}};if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t={};e[318](0,t);module.exports=t})(); \ No newline at end of file diff --git a/packages/next/src/compiled/superstruct/package.json b/packages/next/src/compiled/superstruct/package.json new file mode 100644 index 00000000000000..bee4891e3fcccc --- /dev/null +++ b/packages/next/src/compiled/superstruct/package.json @@ -0,0 +1 @@ +{"name":"superstruct","main":"index.cjs","license":"MIT"} diff --git a/packages/next/src/compiled/zod/LICENSE b/packages/next/src/compiled/zod/LICENSE deleted file mode 100644 index 2c93bb52b93391..00000000000000 --- a/packages/next/src/compiled/zod/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2020 Colin McDonnell - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/next/src/compiled/zod/index.js b/packages/next/src/compiled/zod/index.js deleted file mode 100644 index b4b91ed2deab96..00000000000000 --- a/packages/next/src/compiled/zod/index.js +++ /dev/null @@ -1 +0,0 @@ -(()=>{"use strict";var e={322:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:true});t.ZodError=t.quotelessJson=t.ZodIssueCode=void 0;const r=s(700);t.ZodIssueCode=r.util.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"]);const quotelessJson=e=>{const t=JSON.stringify(e,null,2);return t.replace(/"([^"]+)":/g,"$1:")};t.quotelessJson=quotelessJson;class ZodError extends Error{constructor(e){super();this.issues=[];this.addIssue=e=>{this.issues=[...this.issues,e]};this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;if(Object.setPrototypeOf){Object.setPrototypeOf(this,t)}else{this.__proto__=t}this.name="ZodError";this.issues=e}get errors(){return this.issues}format(e){const t=e||function(e){return e.message};const s={_errors:[]};const processError=e=>{for(const r of e.issues){if(r.code==="invalid_union"){r.unionErrors.map(processError)}else if(r.code==="invalid_return_type"){processError(r.returnTypeError)}else if(r.code==="invalid_arguments"){processError(r.argumentsError)}else if(r.path.length===0){s._errors.push(t(r))}else{let e=s;let a=0;while(ae.message)){const t={};const s=[];for(const r of this.issues){if(r.path.length>0){t[r.path[0]]=t[r.path[0]]||[];t[r.path[0]].push(e(r))}else{s.push(e(r))}}return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}t.ZodError=ZodError;ZodError.create=e=>{const t=new ZodError(e);return t}},326:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.getErrorMap=t.setErrorMap=t.defaultErrorMap=void 0;const a=r(s(657));t.defaultErrorMap=a.default;let n=a.default;function setErrorMap(e){n=e}t.setErrorMap=setErrorMap;function getErrorMap(){return n}t.getErrorMap=getErrorMap},328:function(e,t,s){var r=this&&this.__createBinding||(Object.create?function(e,t,s,r){if(r===undefined)r=s;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[s]}})}:function(e,t,s,r){if(r===undefined)r=s;e[r]=t[s]});var a=this&&this.__exportStar||function(e,t){for(var s in e)if(s!=="default"&&!Object.prototype.hasOwnProperty.call(t,s))r(t,e,s)};Object.defineProperty(t,"__esModule",{value:true});a(s(326),t);a(s(282),t);a(s(929),t);a(s(700),t);a(s(841),t);a(s(322),t)},496:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.errorUtil=void 0;var s;(function(e){e.errToObj=e=>typeof e==="string"?{message:e}:e||{};e.toString=e=>typeof e==="string"?e:e===null||e===void 0?void 0:e.message})(s=t.errorUtil||(t.errorUtil={}))},282:function(e,t,s){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:true});t.isAsync=t.isValid=t.isDirty=t.isAborted=t.OK=t.DIRTY=t.INVALID=t.ParseStatus=t.addIssueToContext=t.EMPTY_PATH=t.makeIssue=void 0;const a=s(326);const n=r(s(657));const makeIssue=e=>{const{data:t,path:s,errorMaps:r,issueData:a}=e;const n=[...s,...a.path||[]];const o={...a,path:n};let i="";const d=r.filter((e=>!!e)).slice().reverse();for(const e of d){i=e(o,{data:t,defaultError:i}).message}return{...a,path:n,message:a.message||i}};t.makeIssue=makeIssue;t.EMPTY_PATH=[];function addIssueToContext(e,s){const r=(0,t.makeIssue)({issueData:s,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,(0,a.getErrorMap)(),n.default].filter((e=>!!e))});e.common.issues.push(r)}t.addIssueToContext=addIssueToContext;class ParseStatus{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(e,s){const r=[];for(const a of s){if(a.status==="aborted")return t.INVALID;if(a.status==="dirty")e.dirty();r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const s=[];for(const e of t){s.push({key:await e.key,value:await e.value})}return ParseStatus.mergeObjectSync(e,s)}static mergeObjectSync(e,s){const r={};for(const a of s){const{key:s,value:n}=a;if(s.status==="aborted")return t.INVALID;if(n.status==="aborted")return t.INVALID;if(s.status==="dirty")e.dirty();if(n.status==="dirty")e.dirty();if(typeof n.value!=="undefined"||a.alwaysSet){r[s.value]=n.value}}return{status:e.value,value:r}}}t.ParseStatus=ParseStatus;t.INVALID=Object.freeze({status:"aborted"});const DIRTY=e=>({status:"dirty",value:e});t.DIRTY=DIRTY;const OK=e=>({status:"valid",value:e});t.OK=OK;const isAborted=e=>e.status==="aborted";t.isAborted=isAborted;const isDirty=e=>e.status==="dirty";t.isDirty=isDirty;const isValid=e=>e.status==="valid";t.isValid=isValid;const isAsync=e=>typeof Promise!=="undefined"&&e instanceof Promise;t.isAsync=isAsync},929:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true})},700:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.getParsedType=t.ZodParsedType=t.objectUtil=t.util=void 0;var s;(function(e){e.assertEqual=e=>e;function assertIs(e){}e.assertIs=assertIs;function assertNever(e){throw new Error}e.assertNever=assertNever;e.arrayToEnum=e=>{const t={};for(const s of e){t[s]=s}return t};e.getValidEnumValues=t=>{const s=e.objectKeys(t).filter((e=>typeof t[t[e]]!=="number"));const r={};for(const e of s){r[e]=t[e]}return e.objectValues(r)};e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]}));e.objectKeys=typeof Object.keys==="function"?e=>Object.keys(e):e=>{const t=[];for(const s in e){if(Object.prototype.hasOwnProperty.call(e,s)){t.push(s)}}return t};e.find=(e,t)=>{for(const s of e){if(t(s))return s}return undefined};e.isInteger=typeof Number.isInteger==="function"?e=>Number.isInteger(e):e=>typeof e==="number"&&isFinite(e)&&Math.floor(e)===e;function joinValues(e,t=" | "){return e.map((e=>typeof e==="string"?`'${e}'`:e)).join(t)}e.joinValues=joinValues;e.jsonStringifyReplacer=(e,t)=>{if(typeof t==="bigint"){return t.toString()}return t}})(s=t.util||(t.util={}));var r;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(r=t.objectUtil||(t.objectUtil={}));t.ZodParsedType=s.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);const getParsedType=e=>{const s=typeof e;switch(s){case"undefined":return t.ZodParsedType.undefined;case"string":return t.ZodParsedType.string;case"number":return isNaN(e)?t.ZodParsedType.nan:t.ZodParsedType.number;case"boolean":return t.ZodParsedType.boolean;case"function":return t.ZodParsedType.function;case"bigint":return t.ZodParsedType.bigint;case"symbol":return t.ZodParsedType.symbol;case"object":if(Array.isArray(e)){return t.ZodParsedType.array}if(e===null){return t.ZodParsedType.null}if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function"){return t.ZodParsedType.promise}if(typeof Map!=="undefined"&&e instanceof Map){return t.ZodParsedType.map}if(typeof Set!=="undefined"&&e instanceof Set){return t.ZodParsedType.set}if(typeof Date!=="undefined"&&e instanceof Date){return t.ZodParsedType.date}return t.ZodParsedType.object;default:return t.ZodParsedType.unknown}};t.getParsedType=getParsedType},828:function(e,t,s){var r=this&&this.__createBinding||(Object.create?function(e,t,s,r){if(r===undefined)r=s;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[s]}})}:function(e,t,s,r){if(r===undefined)r=s;e[r]=t[s]});var a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var s in e)if(s!=="default"&&Object.prototype.hasOwnProperty.call(e,s))r(t,e,s);a(t,e);return t};var o=this&&this.__exportStar||function(e,t){for(var s in e)if(s!=="default"&&!Object.prototype.hasOwnProperty.call(t,s))r(t,e,s)};Object.defineProperty(t,"__esModule",{value:true});t.z=void 0;const i=n(s(328));t.z=i;o(s(328),t);t["default"]=i},657:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:true});const r=s(700);const a=s(322);const errorMap=(e,t)=>{let s;switch(e.code){case a.ZodIssueCode.invalid_type:if(e.received===r.ZodParsedType.undefined){s="Required"}else{s=`Expected ${e.expected}, received ${e.received}`}break;case a.ZodIssueCode.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(e.expected,r.util.jsonStringifyReplacer)}`;break;case a.ZodIssueCode.unrecognized_keys:s=`Unrecognized key(s) in object: ${r.util.joinValues(e.keys,", ")}`;break;case a.ZodIssueCode.invalid_union:s=`Invalid input`;break;case a.ZodIssueCode.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${r.util.joinValues(e.options)}`;break;case a.ZodIssueCode.invalid_enum_value:s=`Invalid enum value. Expected ${r.util.joinValues(e.options)}, received '${e.received}'`;break;case a.ZodIssueCode.invalid_arguments:s=`Invalid function arguments`;break;case a.ZodIssueCode.invalid_return_type:s=`Invalid function return type`;break;case a.ZodIssueCode.invalid_date:s=`Invalid date`;break;case a.ZodIssueCode.invalid_string:if(typeof e.validation==="object"){if("includes"in e.validation){s=`Invalid input: must include "${e.validation.includes}"`;if(typeof e.validation.position==="number"){s=`${s} at one or more positions greater than or equal to ${e.validation.position}`}}else if("startsWith"in e.validation){s=`Invalid input: must start with "${e.validation.startsWith}"`}else if("endsWith"in e.validation){s=`Invalid input: must end with "${e.validation.endsWith}"`}else{r.util.assertNever(e.validation)}}else if(e.validation!=="regex"){s=`Invalid ${e.validation}`}else{s="Invalid"}break;case a.ZodIssueCode.too_small:if(e.type==="array")s=`Array must contain ${e.exact?"exactly":e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`;else if(e.type==="string")s=`String must contain ${e.exact?"exactly":e.inclusive?`at least`:`over`} ${e.minimum} character(s)`;else if(e.type==="number")s=`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`;else if(e.type==="date")s=`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`;else s="Invalid input";break;case a.ZodIssueCode.too_big:if(e.type==="array")s=`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`;else if(e.type==="string")s=`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`;else if(e.type==="number")s=`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`;else if(e.type==="bigint")s=`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`;else if(e.type==="date")s=`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`;else s="Invalid input";break;case a.ZodIssueCode.custom:s=`Invalid input`;break;case a.ZodIssueCode.invalid_intersection_types:s=`Intersection results could not be merged`;break;case a.ZodIssueCode.not_multiple_of:s=`Number must be a multiple of ${e.multipleOf}`;break;case a.ZodIssueCode.not_finite:s="Number must be finite";break;default:s=t.defaultError;r.util.assertNever(e)}return{message:s}};t["default"]=errorMap},841:(e,t,s)=>{Object.defineProperty(t,"__esModule",{value:true});t.discriminatedUnion=t.date=t.boolean=t.bigint=t.array=t.any=t.coerce=t.ZodFirstPartyTypeKind=t.late=t.ZodSchema=t.Schema=t.custom=t.ZodPipeline=t.ZodBranded=t.BRAND=t.ZodNaN=t.ZodCatch=t.ZodDefault=t.ZodNullable=t.ZodOptional=t.ZodTransformer=t.ZodEffects=t.ZodPromise=t.ZodNativeEnum=t.ZodEnum=t.ZodLiteral=t.ZodLazy=t.ZodFunction=t.ZodSet=t.ZodMap=t.ZodRecord=t.ZodTuple=t.ZodIntersection=t.ZodDiscriminatedUnion=t.ZodUnion=t.ZodObject=t.ZodArray=t.ZodVoid=t.ZodNever=t.ZodUnknown=t.ZodAny=t.ZodNull=t.ZodUndefined=t.ZodSymbol=t.ZodDate=t.ZodBoolean=t.ZodBigInt=t.ZodNumber=t.ZodString=t.ZodType=void 0;t.NEVER=t["void"]=t.unknown=t.union=t.undefined=t.tuple=t.transformer=t.symbol=t.string=t.strictObject=t.set=t.record=t.promise=t.preprocess=t.pipeline=t.ostring=t.optional=t.onumber=t.oboolean=t.object=t.number=t.nullable=t["null"]=t.never=t.nativeEnum=t.nan=t.map=t.literal=t.lazy=t.intersection=t["instanceof"]=t["function"]=t["enum"]=t.effect=void 0;const r=s(326);const a=s(496);const n=s(282);const o=s(700);const i=s(322);class ParseInputLazyPath{constructor(e,t,s,r){this._cachedPath=[];this.parent=e;this.data=t;this._path=s;this._key=r}get path(){if(!this._cachedPath.length){if(this._key instanceof Array){this._cachedPath.push(...this._path,...this._key)}else{this._cachedPath.push(...this._path,this._key)}}return this._cachedPath}}const handleResult=(e,t)=>{if((0,n.isValid)(t)){return{success:true,data:t.value}}else{if(!e.common.issues.length){throw new Error("Validation failed but no issues detected.")}return{success:false,get error(){if(this._error)return this._error;const t=new i.ZodError(e.common.issues);this._error=t;return this._error}}}};function processCreateParams(e){if(!e)return{};const{errorMap:t,invalid_type_error:s,required_error:r,description:a}=e;if(t&&(s||r)){throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`)}if(t)return{errorMap:t,description:a};const customMap=(e,t)=>{if(e.code!=="invalid_type")return{message:t.defaultError};if(typeof t.data==="undefined"){return{message:r!==null&&r!==void 0?r:t.defaultError}}return{message:s!==null&&s!==void 0?s:t.defaultError}};return{errorMap:customMap,description:a}}class ZodType{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.isNullable=this.isNullable.bind(this);this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return(0,o.getParsedType)(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:(0,o.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new n.ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:(0,o.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if((0,n.isAsync)(t)){throw new Error("Synchronous parse encountered promise.")}return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const r={common:{issues:[],async:(s=t===null||t===void 0?void 0:t.async)!==null&&s!==void 0?s:false,contextualErrorMap:t===null||t===void 0?void 0:t.errorMap},path:(t===null||t===void 0?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,o.getParsedType)(e)};const a=this._parseSync({data:e,path:r.path,parent:r});return handleResult(r,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t===null||t===void 0?void 0:t.errorMap,async:true},path:(t===null||t===void 0?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,o.getParsedType)(e)};const r=this._parse({data:e,path:s.path,parent:s});const a=await((0,n.isAsync)(r)?r:Promise.resolve(r));return handleResult(s,a)}refine(e,t){const getIssueProperties=e=>{if(typeof t==="string"||typeof t==="undefined"){return{message:t}}else if(typeof t==="function"){return t(e)}else{return t}};return this._refinement(((t,s)=>{const r=e(t);const setError=()=>s.addIssue({code:i.ZodIssueCode.custom,...getIssueProperties(t)});if(typeof Promise!=="undefined"&&r instanceof Promise){return r.then((e=>{if(!e){setError();return false}else{return true}}))}if(!r){setError();return false}else{return true}}))}refinement(e,t){return this._refinement(((s,r)=>{if(!e(s)){r.addIssue(typeof t==="function"?t(s,r):t);return false}else{return true}}))}_refinement(e){return new ZodEffects({schema:this,typeName:y.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ZodOptional.create(this,this._def)}nullable(){return ZodNullable.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ZodArray.create(this,this._def)}promise(){return ZodPromise.create(this,this._def)}or(e){return ZodUnion.create([this,e],this._def)}and(e){return ZodIntersection.create(this,e,this._def)}transform(e){return new ZodEffects({...processCreateParams(this._def),schema:this,typeName:y.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e==="function"?e:()=>e;return new ZodDefault({...processCreateParams(this._def),innerType:this,defaultValue:t,typeName:y.ZodDefault})}brand(){return new ZodBranded({typeName:y.ZodBranded,type:this,...processCreateParams(this._def)})}catch(e){const t=typeof e==="function"?e:()=>e;return new ZodCatch({...processCreateParams(this._def),innerType:this,catchValue:t,typeName:y.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ZodPipeline.create(this,e)}isOptional(){return this.safeParse(undefined).success}isNullable(){return this.safeParse(null).success}}t.ZodType=ZodType;t.Schema=ZodType;t.ZodSchema=ZodType;const d=/^c[^\s-]{8,}$/i;const u=/^[a-z][a-z0-9]*$/;const c=/[0-9A-HJKMNP-TV-Z]{26}/;const l=/^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;const p=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[(((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}))\])|(\[IPv6:(([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})))\])|([A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])*(\.[A-Za-z]{2,})+))$/;const f=/^(\p{Extended_Pictographic}|\p{Emoji_Component})+$/u;const h=/^(((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}))$/;const m=/^(([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})))$/;const datetimeRegex=e=>{if(e.precision){if(e.offset){return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${e.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`)}else{return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${e.precision}}Z$`)}}else if(e.precision===0){if(e.offset){return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`)}else{return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`)}}else{if(e.offset){return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`)}else{return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`)}}};function isValidIP(e,t){if((t==="v4"||!t)&&h.test(e)){return true}if((t==="v6"||!t)&&m.test(e)){return true}return false}class ZodString extends ZodType{constructor(){super(...arguments);this._regex=(e,t,s)=>this.refinement((t=>e.test(t)),{validation:t,code:i.ZodIssueCode.invalid_string,...a.errorUtil.errToObj(s)});this.nonempty=e=>this.min(1,a.errorUtil.errToObj(e));this.trim=()=>new ZodString({...this._def,checks:[...this._def.checks,{kind:"trim"}]});this.toLowerCase=()=>new ZodString({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]});this.toUpperCase=()=>new ZodString({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}_parse(e){if(this._def.coerce){e.data=String(e.data)}const t=this._getType(e);if(t!==o.ZodParsedType.string){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.string,received:t.parsedType});return n.INVALID}const s=new n.ParseStatus;let r=undefined;for(const t of this._def.checks){if(t.kind==="min"){if(e.data.lengtht.value){r=this._getOrReturnCtx(e,r);(0,n.addIssueToContext)(r,{code:i.ZodIssueCode.too_big,maximum:t.value,type:"string",inclusive:true,exact:false,message:t.message});s.dirty()}}else if(t.kind==="length"){const a=e.data.length>t.value;const o=e.data.lengthe.kind==="datetime"))}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 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 minLength(){let e=null;for(const t of this._def.checks){if(t.kind==="min"){if(e===null||t.value>e)e=t.value}}return e}get maxLength(){let e=null;for(const t of this._def.checks){if(t.kind==="max"){if(e===null||t.value{var t;return new ZodString({checks:[],typeName:y.ZodString,coerce:(t=e===null||e===void 0?void 0:e.coerce)!==null&&t!==void 0?t:false,...processCreateParams(e)})};function floatSafeRemainder(e,t){const s=(e.toString().split(".")[1]||"").length;const r=(t.toString().split(".")[1]||"").length;const a=s>r?s:r;const n=parseInt(e.toFixed(a).replace(".",""));const o=parseInt(t.toFixed(a).replace(".",""));return n%o/Math.pow(10,a)}class ZodNumber extends ZodType{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)}const t=this._getType(e);if(t!==o.ZodParsedType.number){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.number,received:t.parsedType});return n.INVALID}let s=undefined;const r=new n.ParseStatus;for(const t of this._def.checks){if(t.kind==="int"){if(!o.util.isInteger(e.data)){s=this._getOrReturnCtx(e,s);(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.invalid_type,expected:"integer",received:"float",message:t.message});r.dirty()}}else if(t.kind==="min"){const a=t.inclusive?e.datat.value:e.data>=t.value;if(a){s=this._getOrReturnCtx(e,s);(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.too_big,maximum:t.value,type:"number",inclusive:t.inclusive,exact:false,message:t.message});r.dirty()}}else if(t.kind==="multipleOf"){if(floatSafeRemainder(e.data,t.value)!==0){s=this._getOrReturnCtx(e,s);(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.not_multiple_of,multipleOf:t.value,message:t.message});r.dirty()}}else if(t.kind==="finite"){if(!Number.isFinite(e.data)){s=this._getOrReturnCtx(e,s);(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.not_finite,message:t.message});r.dirty()}}else{o.util.assertNever(t)}}return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,true,a.errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,false,a.errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,true,a.errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,false,a.errorUtil.toString(t))}setLimit(e,t,s,r){return new ZodNumber({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:a.errorUtil.toString(r)}]})}_addCheck(e){return new ZodNumber({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:a.errorUtil.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:false,message:a.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:false,message:a.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:true,message:a.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:true,message:a.errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:a.errorUtil.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:a.errorUtil.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:true,value:Number.MIN_SAFE_INTEGER,message:a.errorUtil.toString(e)})._addCheck({kind:"max",inclusive:true,value:Number.MAX_SAFE_INTEGER,message:a.errorUtil.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks){if(t.kind==="min"){if(e===null||t.value>e)e=t.value}}return e}get maxValue(){let e=null;for(const t of this._def.checks){if(t.kind==="max"){if(e===null||t.valuee.kind==="int"||e.kind==="multipleOf"&&o.util.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf"){return true}else if(s.kind==="min"){if(t===null||s.value>t)t=s.value}else if(s.kind==="max"){if(e===null||s.valuenew ZodNumber({checks:[],typeName:y.ZodNumber,coerce:(e===null||e===void 0?void 0:e.coerce)||false,...processCreateParams(e)});class ZodBigInt extends ZodType{constructor(){super(...arguments);this.min=this.gte;this.max=this.lte}_parse(e){if(this._def.coerce){e.data=BigInt(e.data)}const t=this._getType(e);if(t!==o.ZodParsedType.bigint){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.bigint,received:t.parsedType});return n.INVALID}let s=undefined;const r=new n.ParseStatus;for(const t of this._def.checks){if(t.kind==="min"){const a=t.inclusive?e.datat.value:e.data>=t.value;if(a){s=this._getOrReturnCtx(e,s);(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.too_big,type:"bigint",maximum:t.value,inclusive:t.inclusive,message:t.message});r.dirty()}}else if(t.kind==="multipleOf"){if(e.data%t.value!==BigInt(0)){s=this._getOrReturnCtx(e,s);(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.not_multiple_of,multipleOf:t.value,message:t.message});r.dirty()}}else{o.util.assertNever(t)}}return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,true,a.errorUtil.toString(t))}gt(e,t){return this.setLimit("min",e,false,a.errorUtil.toString(t))}lte(e,t){return this.setLimit("max",e,true,a.errorUtil.toString(t))}lt(e,t){return this.setLimit("max",e,false,a.errorUtil.toString(t))}setLimit(e,t,s,r){return new ZodBigInt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:a.errorUtil.toString(r)}]})}_addCheck(e){return new ZodBigInt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:false,message:a.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:false,message:a.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:true,message:a.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:true,message:a.errorUtil.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:a.errorUtil.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks){if(t.kind==="min"){if(e===null||t.value>e)e=t.value}}return e}get maxValue(){let e=null;for(const t of this._def.checks){if(t.kind==="max"){if(e===null||t.value{var t;return new ZodBigInt({checks:[],typeName:y.ZodBigInt,coerce:(t=e===null||e===void 0?void 0:e.coerce)!==null&&t!==void 0?t:false,...processCreateParams(e)})};class ZodBoolean extends ZodType{_parse(e){if(this._def.coerce){e.data=Boolean(e.data)}const t=this._getType(e);if(t!==o.ZodParsedType.boolean){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.boolean,received:t.parsedType});return n.INVALID}return(0,n.OK)(e.data)}}t.ZodBoolean=ZodBoolean;ZodBoolean.create=e=>new ZodBoolean({typeName:y.ZodBoolean,coerce:(e===null||e===void 0?void 0:e.coerce)||false,...processCreateParams(e)});class ZodDate extends ZodType{_parse(e){if(this._def.coerce){e.data=new Date(e.data)}const t=this._getType(e);if(t!==o.ZodParsedType.date){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.date,received:t.parsedType});return n.INVALID}if(isNaN(e.data.getTime())){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_date});return n.INVALID}const s=new n.ParseStatus;let r=undefined;for(const t of this._def.checks){if(t.kind==="min"){if(e.data.getTime()t.value){r=this._getOrReturnCtx(e,r);(0,n.addIssueToContext)(r,{code:i.ZodIssueCode.too_big,message:t.message,inclusive:true,exact:false,maximum:t.value,type:"date"});s.dirty()}}else{o.util.assertNever(t)}}return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ZodDate({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:a.errorUtil.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:a.errorUtil.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks){if(t.kind==="min"){if(e===null||t.value>e)e=t.value}}return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks){if(t.kind==="max"){if(e===null||t.valuenew ZodDate({checks:[],coerce:(e===null||e===void 0?void 0:e.coerce)||false,typeName:y.ZodDate,...processCreateParams(e)});class ZodSymbol extends ZodType{_parse(e){const t=this._getType(e);if(t!==o.ZodParsedType.symbol){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.symbol,received:t.parsedType});return n.INVALID}return(0,n.OK)(e.data)}}t.ZodSymbol=ZodSymbol;ZodSymbol.create=e=>new ZodSymbol({typeName:y.ZodSymbol,...processCreateParams(e)});class ZodUndefined extends ZodType{_parse(e){const t=this._getType(e);if(t!==o.ZodParsedType.undefined){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.undefined,received:t.parsedType});return n.INVALID}return(0,n.OK)(e.data)}}t.ZodUndefined=ZodUndefined;ZodUndefined.create=e=>new ZodUndefined({typeName:y.ZodUndefined,...processCreateParams(e)});class ZodNull extends ZodType{_parse(e){const t=this._getType(e);if(t!==o.ZodParsedType.null){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.null,received:t.parsedType});return n.INVALID}return(0,n.OK)(e.data)}}t.ZodNull=ZodNull;ZodNull.create=e=>new ZodNull({typeName:y.ZodNull,...processCreateParams(e)});class ZodAny extends ZodType{constructor(){super(...arguments);this._any=true}_parse(e){return(0,n.OK)(e.data)}}t.ZodAny=ZodAny;ZodAny.create=e=>new ZodAny({typeName:y.ZodAny,...processCreateParams(e)});class ZodUnknown extends ZodType{constructor(){super(...arguments);this._unknown=true}_parse(e){return(0,n.OK)(e.data)}}t.ZodUnknown=ZodUnknown;ZodUnknown.create=e=>new ZodUnknown({typeName:y.ZodUnknown,...processCreateParams(e)});class ZodNever extends ZodType{_parse(e){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.never,received:t.parsedType});return n.INVALID}}t.ZodNever=ZodNever;ZodNever.create=e=>new ZodNever({typeName:y.ZodNever,...processCreateParams(e)});class ZodVoid extends ZodType{_parse(e){const t=this._getType(e);if(t!==o.ZodParsedType.undefined){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.void,received:t.parsedType});return n.INVALID}return(0,n.OK)(e.data)}}t.ZodVoid=ZodVoid;ZodVoid.create=e=>new ZodVoid({typeName:y.ZodVoid,...processCreateParams(e)});class ZodArray extends ZodType{_parse(e){const{ctx:t,status:s}=this._processInputParams(e);const r=this._def;if(t.parsedType!==o.ZodParsedType.array){(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.array,received:t.parsedType});return n.INVALID}if(r.exactLength!==null){const e=t.data.length>r.exactLength.value;const a=t.data.lengthr.maxLength.value){(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.too_big,maximum:r.maxLength.value,type:"array",inclusive:true,exact:false,message:r.maxLength.message});s.dirty()}}if(t.common.async){return Promise.all([...t.data].map(((e,s)=>r.type._parseAsync(new ParseInputLazyPath(t,e,t.path,s))))).then((e=>n.ParseStatus.mergeArray(s,e)))}const a=[...t.data].map(((e,s)=>r.type._parseSync(new ParseInputLazyPath(t,e,t.path,s))));return n.ParseStatus.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new ZodArray({...this._def,minLength:{value:e,message:a.errorUtil.toString(t)}})}max(e,t){return new ZodArray({...this._def,maxLength:{value:e,message:a.errorUtil.toString(t)}})}length(e,t){return new ZodArray({...this._def,exactLength:{value:e,message:a.errorUtil.toString(t)}})}nonempty(e){return this.min(1,e)}}t.ZodArray=ZodArray;ZodArray.create=(e,t)=>new ZodArray({type:e,minLength:null,maxLength:null,exactLength:null,typeName:y.ZodArray,...processCreateParams(t)});function deepPartialify(e){if(e instanceof ZodObject){const t={};for(const s in e.shape){const r=e.shape[s];t[s]=ZodOptional.create(deepPartialify(r))}return new ZodObject({...e._def,shape:()=>t})}else if(e instanceof ZodArray){return new ZodArray({...e._def,type:deepPartialify(e.element)})}else if(e instanceof ZodOptional){return ZodOptional.create(deepPartialify(e.unwrap()))}else if(e instanceof ZodNullable){return ZodNullable.create(deepPartialify(e.unwrap()))}else if(e instanceof ZodTuple){return ZodTuple.create(e.items.map((e=>deepPartialify(e))))}else{return e}}class ZodObject extends ZodType{constructor(){super(...arguments);this._cached=null;this.nonstrict=this.passthrough;this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape();const t=o.util.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){const t=this._getType(e);if(t!==o.ZodParsedType.object){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.object,received:t.parsedType});return n.INVALID}const{status:s,ctx:r}=this._processInputParams(e);const{shape:a,keys:d}=this._getCached();const u=[];if(!(this._def.catchall instanceof ZodNever&&this._def.unknownKeys==="strip")){for(const e in r.data){if(!d.includes(e)){u.push(e)}}}const c=[];for(const e of d){const t=a[e];const s=r.data[e];c.push({key:{status:"valid",value:e},value:t._parse(new ParseInputLazyPath(r,s,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof ZodNever){const e=this._def.unknownKeys;if(e==="passthrough"){for(const e of u){c.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}})}}else if(e==="strict"){if(u.length>0){(0,n.addIssueToContext)(r,{code:i.ZodIssueCode.unrecognized_keys,keys:u});s.dirty()}}else if(e==="strip"){}else{throw new Error(`Internal ZodObject error: invalid unknownKeys value.`)}}else{const e=this._def.catchall;for(const t of u){const s=r.data[t];c.push({key:{status:"valid",value:t},value:e._parse(new ParseInputLazyPath(r,s,r.path,t)),alwaysSet:t in r.data})}}if(r.common.async){return Promise.resolve().then((async()=>{const e=[];for(const t of c){const s=await t.key;e.push({key:s,value:await t.value,alwaysSet:t.alwaysSet})}return e})).then((e=>n.ParseStatus.mergeObjectSync(s,e)))}else{return n.ParseStatus.mergeObjectSync(s,c)}}get shape(){return this._def.shape()}strict(e){a.errorUtil.errToObj;return new ZodObject({...this._def,unknownKeys:"strict",...e!==undefined?{errorMap:(t,s)=>{var r,n,o,i;const d=(o=(n=(r=this._def).errorMap)===null||n===void 0?void 0:n.call(r,t,s).message)!==null&&o!==void 0?o:s.defaultError;if(t.code==="unrecognized_keys")return{message:(i=a.errorUtil.errToObj(e).message)!==null&&i!==void 0?i:d};return{message:d}}}:{}})}strip(){return new ZodObject({...this._def,unknownKeys:"strip"})}passthrough(){return new ZodObject({...this._def,unknownKeys:"passthrough"})}extend(e){return new ZodObject({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){const t=new ZodObject({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:y.ZodObject});return t}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ZodObject({...this._def,catchall:e})}pick(e){const t={};o.util.objectKeys(e).forEach((s=>{if(e[s]&&this.shape[s]){t[s]=this.shape[s]}}));return new ZodObject({...this._def,shape:()=>t})}omit(e){const t={};o.util.objectKeys(this.shape).forEach((s=>{if(!e[s]){t[s]=this.shape[s]}}));return new ZodObject({...this._def,shape:()=>t})}deepPartial(){return deepPartialify(this)}partial(e){const t={};o.util.objectKeys(this.shape).forEach((s=>{const r=this.shape[s];if(e&&!e[s]){t[s]=r}else{t[s]=r.optional()}}));return new ZodObject({...this._def,shape:()=>t})}required(e){const t={};o.util.objectKeys(this.shape).forEach((s=>{if(e&&!e[s]){t[s]=this.shape[s]}else{const e=this.shape[s];let r=e;while(r instanceof ZodOptional){r=r._def.innerType}t[s]=r}}));return new ZodObject({...this._def,shape:()=>t})}keyof(){return createZodEnum(o.util.objectKeys(this.shape))}}t.ZodObject=ZodObject;ZodObject.create=(e,t)=>new ZodObject({shape:()=>e,unknownKeys:"strip",catchall:ZodNever.create(),typeName:y.ZodObject,...processCreateParams(t)});ZodObject.strictCreate=(e,t)=>new ZodObject({shape:()=>e,unknownKeys:"strict",catchall:ZodNever.create(),typeName:y.ZodObject,...processCreateParams(t)});ZodObject.lazycreate=(e,t)=>new ZodObject({shape:e,unknownKeys:"strip",catchall:ZodNever.create(),typeName:y.ZodObject,...processCreateParams(t)});class ZodUnion extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);const s=this._def.options;function handleResults(e){for(const t of e){if(t.result.status==="valid"){return t.result}}for(const s of e){if(s.result.status==="dirty"){t.common.issues.push(...s.ctx.common.issues);return s.result}}const s=e.map((e=>new i.ZodError(e.ctx.common.issues)));(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_union,unionErrors:s});return n.INVALID}if(t.common.async){return Promise.all(s.map((async e=>{const s={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}}))).then(handleResults)}else{let e=undefined;const r=[];for(const a of s){const s={...t,common:{...t.common,issues:[]},parent:null};const n=a._parseSync({data:t.data,path:t.path,parent:s});if(n.status==="valid"){return n}else if(n.status==="dirty"&&!e){e={result:n,ctx:s}}if(s.common.issues.length){r.push(s.common.issues)}}if(e){t.common.issues.push(...e.ctx.common.issues);return e.result}const a=r.map((e=>new i.ZodError(e)));(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_union,unionErrors:a});return n.INVALID}}get options(){return this._def.options}}t.ZodUnion=ZodUnion;ZodUnion.create=(e,t)=>new ZodUnion({options:e,typeName:y.ZodUnion,...processCreateParams(t)});const getDiscriminator=e=>{if(e instanceof ZodLazy){return getDiscriminator(e.schema)}else if(e instanceof ZodEffects){return getDiscriminator(e.innerType())}else if(e instanceof ZodLiteral){return[e.value]}else if(e instanceof ZodEnum){return e.options}else if(e instanceof ZodNativeEnum){return Object.keys(e.enum)}else if(e instanceof ZodDefault){return getDiscriminator(e._def.innerType)}else if(e instanceof ZodUndefined){return[undefined]}else if(e instanceof ZodNull){return[null]}else{return null}};class ZodDiscriminatedUnion extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==o.ZodParsedType.object){(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.object,received:t.parsedType});return n.INVALID}const s=this.discriminator;const r=t.data[s];const a=this.optionsMap.get(r);if(!a){(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]});return n.INVALID}if(t.common.async){return a._parseAsync({data:t.data,path:t.path,parent:t})}else{return a._parseSync({data:t.data,path:t.path,parent:t})}}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const r=new Map;for(const s of t){const t=getDiscriminator(s.shape[e]);if(!t){throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`)}for(const a of t){if(r.has(a)){throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`)}r.set(a,s)}}return new ZodDiscriminatedUnion({typeName:y.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...processCreateParams(s)})}}t.ZodDiscriminatedUnion=ZodDiscriminatedUnion;function mergeValues(e,t){const s=(0,o.getParsedType)(e);const r=(0,o.getParsedType)(t);if(e===t){return{valid:true,data:e}}else if(s===o.ZodParsedType.object&&r===o.ZodParsedType.object){const s=o.util.objectKeys(t);const r=o.util.objectKeys(e).filter((e=>s.indexOf(e)!==-1));const a={...e,...t};for(const s of r){const r=mergeValues(e[s],t[s]);if(!r.valid){return{valid:false}}a[s]=r.data}return{valid:true,data:a}}else if(s===o.ZodParsedType.array&&r===o.ZodParsedType.array){if(e.length!==t.length){return{valid:false}}const s=[];for(let r=0;r{if((0,n.isAborted)(e)||(0,n.isAborted)(r)){return n.INVALID}const a=mergeValues(e.value,r.value);if(!a.valid){(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.invalid_intersection_types});return n.INVALID}if((0,n.isDirty)(e)||(0,n.isDirty)(r)){t.dirty()}return{status:t.value,value:a.data}};if(s.common.async){return 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((([e,t])=>handleParsed(e,t)))}else{return handleParsed(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}}t.ZodIntersection=ZodIntersection;ZodIntersection.create=(e,t,s)=>new ZodIntersection({left:e,right:t,typeName:y.ZodIntersection,...processCreateParams(s)});class ZodTuple extends ZodType{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==o.ZodParsedType.array){(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.array,received:s.parsedType});return n.INVALID}if(s.data.lengththis._def.items.length){(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"});t.dirty()}const a=[...s.data].map(((e,t)=>{const r=this._def.items[t]||this._def.rest;if(!r)return null;return r._parse(new ParseInputLazyPath(s,e,s.path,t))})).filter((e=>!!e));if(s.common.async){return Promise.all(a).then((e=>n.ParseStatus.mergeArray(t,e)))}else{return n.ParseStatus.mergeArray(t,a)}}get items(){return this._def.items}rest(e){return new ZodTuple({...this._def,rest:e})}}t.ZodTuple=ZodTuple;ZodTuple.create=(e,t)=>{if(!Array.isArray(e)){throw new Error("You must pass an array of schemas to z.tuple([ ... ])")}return new ZodTuple({items:e,typeName:y.ZodTuple,rest:null,...processCreateParams(t)})};class ZodRecord extends ZodType{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==o.ZodParsedType.object){(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.object,received:s.parsedType});return n.INVALID}const r=[];const a=this._def.keyType;const d=this._def.valueType;for(const e in s.data){r.push({key:a._parse(new ParseInputLazyPath(s,e,s.path,e)),value:d._parse(new ParseInputLazyPath(s,s.data[e],s.path,e))})}if(s.common.async){return n.ParseStatus.mergeObjectAsync(t,r)}else{return n.ParseStatus.mergeObjectSync(t,r)}}get element(){return this._def.valueType}static create(e,t,s){if(t instanceof ZodType){return new ZodRecord({keyType:e,valueType:t,typeName:y.ZodRecord,...processCreateParams(s)})}return new ZodRecord({keyType:ZodString.create(),valueType:e,typeName:y.ZodRecord,...processCreateParams(t)})}}t.ZodRecord=ZodRecord;class ZodMap extends ZodType{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==o.ZodParsedType.map){(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.map,received:s.parsedType});return n.INVALID}const r=this._def.keyType;const a=this._def.valueType;const d=[...s.data.entries()].map((([e,t],n)=>({key:r._parse(new ParseInputLazyPath(s,e,s.path,[n,"key"])),value:a._parse(new ParseInputLazyPath(s,t,s.path,[n,"value"]))})));if(s.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const s of d){const r=await s.key;const a=await s.value;if(r.status==="aborted"||a.status==="aborted"){return n.INVALID}if(r.status==="dirty"||a.status==="dirty"){t.dirty()}e.set(r.value,a.value)}return{status:t.value,value:e}}))}else{const e=new Map;for(const s of d){const r=s.key;const a=s.value;if(r.status==="aborted"||a.status==="aborted"){return n.INVALID}if(r.status==="dirty"||a.status==="dirty"){t.dirty()}e.set(r.value,a.value)}return{status:t.value,value:e}}}}t.ZodMap=ZodMap;ZodMap.create=(e,t,s)=>new ZodMap({valueType:t,keyType:e,typeName:y.ZodMap,...processCreateParams(s)});class ZodSet extends ZodType{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==o.ZodParsedType.set){(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.set,received:s.parsedType});return n.INVALID}const r=this._def;if(r.minSize!==null){if(s.data.sizer.maxSize.value){(0,n.addIssueToContext)(s,{code:i.ZodIssueCode.too_big,maximum:r.maxSize.value,type:"set",inclusive:true,exact:false,message:r.maxSize.message});t.dirty()}}const a=this._def.valueType;function finalizeSet(e){const s=new Set;for(const r of e){if(r.status==="aborted")return n.INVALID;if(r.status==="dirty")t.dirty();s.add(r.value)}return{status:t.value,value:s}}const d=[...s.data.values()].map(((e,t)=>a._parse(new ParseInputLazyPath(s,e,s.path,t))));if(s.common.async){return Promise.all(d).then((e=>finalizeSet(e)))}else{return finalizeSet(d)}}min(e,t){return new ZodSet({...this._def,minSize:{value:e,message:a.errorUtil.toString(t)}})}max(e,t){return new ZodSet({...this._def,maxSize:{value:e,message:a.errorUtil.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}t.ZodSet=ZodSet;ZodSet.create=(e,t)=>new ZodSet({valueType:e,minSize:null,maxSize:null,typeName:y.ZodSet,...processCreateParams(t)});class ZodFunction extends ZodType{constructor(){super(...arguments);this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==o.ZodParsedType.function){(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.function,received:t.parsedType});return n.INVALID}function makeArgsIssue(e,s){return(0,n.makeIssue)({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,(0,r.getErrorMap)(),r.defaultErrorMap].filter((e=>!!e)),issueData:{code:i.ZodIssueCode.invalid_arguments,argumentsError:s}})}function makeReturnsIssue(e,s){return(0,n.makeIssue)({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,(0,r.getErrorMap)(),r.defaultErrorMap].filter((e=>!!e)),issueData:{code:i.ZodIssueCode.invalid_return_type,returnTypeError:s}})}const s={errorMap:t.common.contextualErrorMap};const a=t.data;if(this._def.returns instanceof ZodPromise){return(0,n.OK)((async(...e)=>{const t=new i.ZodError([]);const r=await this._def.args.parseAsync(e,s).catch((s=>{t.addIssue(makeArgsIssue(e,s));throw t}));const n=await a(...r);const o=await this._def.returns._def.type.parseAsync(n,s).catch((e=>{t.addIssue(makeReturnsIssue(n,e));throw t}));return o}))}else{return(0,n.OK)(((...e)=>{const t=this._def.args.safeParse(e,s);if(!t.success){throw new i.ZodError([makeArgsIssue(e,t.error)])}const r=a(...t.data);const n=this._def.returns.safeParse(r,s);if(!n.success){throw new i.ZodError([makeReturnsIssue(r,n.error)])}return n.data}))}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ZodFunction({...this._def,args:ZodTuple.create(e).rest(ZodUnknown.create())})}returns(e){return new ZodFunction({...this._def,returns:e})}implement(e){const t=this.parse(e);return t}strictImplement(e){const t=this.parse(e);return t}static create(e,t,s){return new ZodFunction({args:e?e:ZodTuple.create([]).rest(ZodUnknown.create()),returns:t||ZodUnknown.create(),typeName:y.ZodFunction,...processCreateParams(s)})}}t.ZodFunction=ZodFunction;class ZodLazy extends ZodType{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);const s=this._def.getter();return s._parse({data:t.data,path:t.path,parent:t})}}t.ZodLazy=ZodLazy;ZodLazy.create=(e,t)=>new ZodLazy({getter:e,typeName:y.ZodLazy,...processCreateParams(t)});class ZodLiteral extends ZodType{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{received:t.data,code:i.ZodIssueCode.invalid_literal,expected:this._def.value});return n.INVALID}return{status:"valid",value:e.data}}get value(){return this._def.value}}t.ZodLiteral=ZodLiteral;ZodLiteral.create=(e,t)=>new ZodLiteral({value:e,typeName:y.ZodLiteral,...processCreateParams(t)});function createZodEnum(e,t){return new ZodEnum({values:e,typeName:y.ZodEnum,...processCreateParams(t)})}class ZodEnum extends ZodType{_parse(e){if(typeof e.data!=="string"){const t=this._getOrReturnCtx(e);const s=this._def.values;(0,n.addIssueToContext)(t,{expected:o.util.joinValues(s),received:t.parsedType,code:i.ZodIssueCode.invalid_type});return n.INVALID}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e);const s=this._def.values;(0,n.addIssueToContext)(t,{received:t.data,code:i.ZodIssueCode.invalid_enum_value,options:s});return n.INVALID}return(0,n.OK)(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values){e[t]=t}return e}get Values(){const e={};for(const t of this._def.values){e[t]=t}return e}get Enum(){const e={};for(const t of this._def.values){e[t]=t}return e}extract(e){return ZodEnum.create(e)}exclude(e){return ZodEnum.create(this.options.filter((t=>!e.includes(t))))}}t.ZodEnum=ZodEnum;ZodEnum.create=createZodEnum;class ZodNativeEnum extends ZodType{_parse(e){const t=o.util.getValidEnumValues(this._def.values);const s=this._getOrReturnCtx(e);if(s.parsedType!==o.ZodParsedType.string&&s.parsedType!==o.ZodParsedType.number){const e=o.util.objectValues(t);(0,n.addIssueToContext)(s,{expected:o.util.joinValues(e),received:s.parsedType,code:i.ZodIssueCode.invalid_type});return n.INVALID}if(t.indexOf(e.data)===-1){const e=o.util.objectValues(t);(0,n.addIssueToContext)(s,{received:s.data,code:i.ZodIssueCode.invalid_enum_value,options:e});return n.INVALID}return(0,n.OK)(e.data)}get enum(){return this._def.values}}t.ZodNativeEnum=ZodNativeEnum;ZodNativeEnum.create=(e,t)=>new ZodNativeEnum({values:e,typeName:y.ZodNativeEnum,...processCreateParams(t)});class ZodPromise extends ZodType{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==o.ZodParsedType.promise&&t.common.async===false){(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.promise,received:t.parsedType});return n.INVALID}const s=t.parsedType===o.ZodParsedType.promise?t.data:Promise.resolve(t.data);return(0,n.OK)(s.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}t.ZodPromise=ZodPromise;ZodPromise.create=(e,t)=>new ZodPromise({type:e,typeName:y.ZodPromise,...processCreateParams(t)});class ZodEffects extends ZodType{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);const r=this._def.effect||null;if(r.type==="preprocess"){const e=r.transform(s.data);if(s.common.async){return Promise.resolve(e).then((e=>this._def.schema._parseAsync({data:e,path:s.path,parent:s})))}else{return this._def.schema._parseSync({data:e,path:s.path,parent:s})}}const a={addIssue:e=>{(0,n.addIssueToContext)(s,e);if(e.fatal){t.abort()}else{t.dirty()}},get path(){return s.path}};a.addIssue=a.addIssue.bind(a);if(r.type==="refinement"){const executeRefinement=e=>{const t=r.refinement(e,a);if(s.common.async){return Promise.resolve(t)}if(t instanceof Promise){throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.")}return e};if(s.common.async===false){const e=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(e.status==="aborted")return n.INVALID;if(e.status==="dirty")t.dirty();executeRefinement(e.value);return{status:t.value,value:e.value}}else{return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then((e=>{if(e.status==="aborted")return n.INVALID;if(e.status==="dirty")t.dirty();return executeRefinement(e.value).then((()=>({status:t.value,value:e.value})))}))}}if(r.type==="transform"){if(s.common.async===false){const e=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!(0,n.isValid)(e))return e;const o=r.transform(e.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((e=>{if(!(0,n.isValid)(e))return e;return Promise.resolve(r.transform(e.value,a)).then((e=>({status:t.value,value:e})))}))}}o.util.assertNever(r)}}t.ZodEffects=ZodEffects;t.ZodTransformer=ZodEffects;ZodEffects.create=(e,t,s)=>new ZodEffects({schema:e,typeName:y.ZodEffects,effect:t,...processCreateParams(s)});ZodEffects.createWithPreprocess=(e,t,s)=>new ZodEffects({schema:t,effect:{type:"preprocess",transform:e},typeName:y.ZodEffects,...processCreateParams(s)});class ZodOptional extends ZodType{_parse(e){const t=this._getType(e);if(t===o.ZodParsedType.undefined){return(0,n.OK)(undefined)}return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}t.ZodOptional=ZodOptional;ZodOptional.create=(e,t)=>new ZodOptional({innerType:e,typeName:y.ZodOptional,...processCreateParams(t)});class ZodNullable extends ZodType{_parse(e){const t=this._getType(e);if(t===o.ZodParsedType.null){return(0,n.OK)(null)}return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}t.ZodNullable=ZodNullable;ZodNullable.create=(e,t)=>new ZodNullable({innerType:e,typeName:y.ZodNullable,...processCreateParams(t)});class ZodDefault extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;if(t.parsedType===o.ZodParsedType.undefined){s=this._def.defaultValue()}return this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}t.ZodDefault=ZodDefault;ZodDefault.create=(e,t)=>new ZodDefault({innerType:e,typeName:y.ZodDefault,defaultValue:typeof t.default==="function"?t.default:()=>t.default,...processCreateParams(t)});class ZodCatch extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);const s={...t,common:{...t.common,issues:[]}};const r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});if((0,n.isAsync)(r)){return r.then((e=>({status:"valid",value:e.status==="valid"?e.value:this._def.catchValue({get error(){return new i.ZodError(s.common.issues)},input:s.data})})))}else{return{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new i.ZodError(s.common.issues)},input:s.data})}}}removeCatch(){return this._def.innerType}}t.ZodCatch=ZodCatch;ZodCatch.create=(e,t)=>new ZodCatch({innerType:e,typeName:y.ZodCatch,catchValue:typeof t.catch==="function"?t.catch:()=>t.catch,...processCreateParams(t)});class ZodNaN extends ZodType{_parse(e){const t=this._getType(e);if(t!==o.ZodParsedType.nan){const t=this._getOrReturnCtx(e);(0,n.addIssueToContext)(t,{code:i.ZodIssueCode.invalid_type,expected:o.ZodParsedType.nan,received:t.parsedType});return n.INVALID}return{status:"valid",value:e.data}}}t.ZodNaN=ZodNaN;ZodNaN.create=e=>new ZodNaN({typeName:y.ZodNaN,...processCreateParams(e)});t.BRAND=Symbol("zod_brand");class ZodBranded extends ZodType{_parse(e){const{ctx:t}=this._processInputParams(e);const s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}t.ZodBranded=ZodBranded;class ZodPipeline extends ZodType{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async){const handleAsync=async()=>{const e=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});if(e.status==="aborted")return n.INVALID;if(e.status==="dirty"){t.dirty();return(0,n.DIRTY)(e.value)}else{return this._def.out._parseAsync({data:e.value,path:s.path,parent:s})}};return handleAsync()}else{const e=this._def.in._parseSync({data:s.data,path:s.path,parent:s});if(e.status==="aborted")return n.INVALID;if(e.status==="dirty"){t.dirty();return{status:"dirty",value:e.value}}else{return this._def.out._parseSync({data:e.value,path:s.path,parent:s})}}}static create(e,t){return new ZodPipeline({in:e,out:t,typeName:y.ZodPipeline})}}t.ZodPipeline=ZodPipeline;const custom=(e,t={},s)=>{if(e)return ZodAny.create().superRefine(((r,a)=>{var n,o;if(!e(r)){const e=typeof t==="function"?t(r):typeof t==="string"?{message:t}:t;const i=(o=(n=e.fatal)!==null&&n!==void 0?n:s)!==null&&o!==void 0?o:true;const d=typeof e==="string"?{message:e}:e;a.addIssue({code:"custom",...d,fatal:i})}}));return ZodAny.create()};t.custom=custom;t.late={object:ZodObject.lazycreate};var y;(function(e){e["ZodString"]="ZodString";e["ZodNumber"]="ZodNumber";e["ZodNaN"]="ZodNaN";e["ZodBigInt"]="ZodBigInt";e["ZodBoolean"]="ZodBoolean";e["ZodDate"]="ZodDate";e["ZodSymbol"]="ZodSymbol";e["ZodUndefined"]="ZodUndefined";e["ZodNull"]="ZodNull";e["ZodAny"]="ZodAny";e["ZodUnknown"]="ZodUnknown";e["ZodNever"]="ZodNever";e["ZodVoid"]="ZodVoid";e["ZodArray"]="ZodArray";e["ZodObject"]="ZodObject";e["ZodUnion"]="ZodUnion";e["ZodDiscriminatedUnion"]="ZodDiscriminatedUnion";e["ZodIntersection"]="ZodIntersection";e["ZodTuple"]="ZodTuple";e["ZodRecord"]="ZodRecord";e["ZodMap"]="ZodMap";e["ZodSet"]="ZodSet";e["ZodFunction"]="ZodFunction";e["ZodLazy"]="ZodLazy";e["ZodLiteral"]="ZodLiteral";e["ZodEnum"]="ZodEnum";e["ZodEffects"]="ZodEffects";e["ZodNativeEnum"]="ZodNativeEnum";e["ZodOptional"]="ZodOptional";e["ZodNullable"]="ZodNullable";e["ZodDefault"]="ZodDefault";e["ZodCatch"]="ZodCatch";e["ZodPromise"]="ZodPromise";e["ZodBranded"]="ZodBranded";e["ZodPipeline"]="ZodPipeline"})(y=t.ZodFirstPartyTypeKind||(t.ZodFirstPartyTypeKind={}));class Class{constructor(...e){}}const instanceOfType=(e,s={message:`Input not instance of ${e.name}`})=>(0,t.custom)((t=>t instanceof e),s);t["instanceof"]=instanceOfType;const Z=ZodString.create;t.string=Z;const _=ZodNumber.create;t.number=_;const v=ZodNaN.create;t.nan=v;const g=ZodBigInt.create;t.bigint=g;const I=ZodBoolean.create;t.boolean=I;const T=ZodDate.create;t.date=T;const x=ZodSymbol.create;t.symbol=x;const b=ZodUndefined.create;t.undefined=b;const C=ZodNull.create;t["null"]=C;const P=ZodAny.create;t.any=P;const k=ZodUnknown.create;t.unknown=k;const w=ZodNever.create;t.never=w;const N=ZodVoid.create;t["void"]=N;const O=ZodArray.create;t.array=O;const S=ZodObject.create;t.object=S;const E=ZodObject.strictCreate;t.strictObject=E;const j=ZodUnion.create;t.union=j;const A=ZodDiscriminatedUnion.create;t.discriminatedUnion=A;const L=ZodIntersection.create;t.intersection=L;const U=ZodTuple.create;t.tuple=U;const D=ZodRecord.create;t.record=D;const V=ZodMap.create;t.map=V;const M=ZodSet.create;t.set=M;const R=ZodFunction.create;t["function"]=R;const z=ZodLazy.create;t.lazy=z;const $=ZodLiteral.create;t.literal=$;const B=ZodEnum.create;t["enum"]=B;const K=ZodNativeEnum.create;t.nativeEnum=K;const F=ZodPromise.create;t.promise=F;const q=ZodEffects.create;t.effect=q;t.transformer=q;const W=ZodOptional.create;t.optional=W;const J=ZodNullable.create;t.nullable=J;const Y=ZodEffects.createWithPreprocess;t.preprocess=Y;const H=ZodPipeline.create;t.pipeline=H;const ostring=()=>Z().optional();t.ostring=ostring;const onumber=()=>_().optional();t.onumber=onumber;const oboolean=()=>I().optional();t.oboolean=oboolean;t.coerce={string:e=>ZodString.create({...e,coerce:true}),number:e=>ZodNumber.create({...e,coerce:true}),boolean:e=>ZodBoolean.create({...e,coerce:true}),bigint:e=>ZodBigInt.create({...e,coerce:true}),date:e=>ZodDate.create({...e,coerce:true})};t.NEVER=n.INVALID}};var t={};function __nccwpck_require__(s){var r=t[s];if(r!==undefined){return r.exports}var a=t[s]={exports:{}};var n=true;try{e[s].call(a.exports,a,a.exports,__nccwpck_require__);n=false}finally{if(n)delete t[s]}return a.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var s=__nccwpck_require__(828);module.exports=s})(); \ No newline at end of file diff --git a/packages/next/src/compiled/zod/package.json b/packages/next/src/compiled/zod/package.json deleted file mode 100644 index 23793495cb3666..00000000000000 --- a/packages/next/src/compiled/zod/package.json +++ /dev/null @@ -1 +0,0 @@ -{"name":"zod","main":"index.js","author":"Colin McDonnell ","license":"MIT"} diff --git a/packages/next/src/server/app-render/parse-and-validate-flight-router-state.tsx b/packages/next/src/server/app-render/parse-and-validate-flight-router-state.tsx index b8d4e43b10c6a6..49086f94d8123c 100644 --- a/packages/next/src/server/app-render/parse-and-validate-flight-router-state.tsx +++ b/packages/next/src/server/app-render/parse-and-validate-flight-router-state.tsx @@ -1,5 +1,6 @@ import { FlightRouterState } from './types' import { flightRouterStateSchema } from './types' +import { assert } from 'next/dist/compiled/superstruct' export function parseAndValidateFlightRouterState( stateHeader: string | string[] | undefined @@ -23,9 +24,9 @@ export function parseAndValidateFlightRouterState( } try { - return flightRouterStateSchema.parse( - JSON.parse(decodeURIComponent(stateHeader)) - ) + const state = JSON.parse(decodeURIComponent(stateHeader)) + assert(state, flightRouterStateSchema) + return state } catch { throw new Error('The router state header was sent but could not be parsed.') } diff --git a/packages/next/src/server/app-render/types.test.ts b/packages/next/src/server/app-render/types.test.ts new file mode 100644 index 00000000000000..8452d988fa7ca8 --- /dev/null +++ b/packages/next/src/server/app-render/types.test.ts @@ -0,0 +1,72 @@ +import { flightRouterStateSchema } from './types' +import { assert } from 'next/dist/compiled/superstruct' + +const validFixtures = [ + [ + ['a', 'b', 'c'], + { + a: [['a', 'b', 'c'], {}], + b: [['a', 'b', 'c'], {}], + }, + ], + [ + ['a', 'b', 'c'], + { + a: [['a', 'b', 'c'], {}], + b: [['a', 'b', 'c'], {}], + }, + null, + null, + true, + ], + [ + ['a', 'b', 'c'], + { + a: [['a', 'b', 'c'], {}], + b: [['a', 'b', 'c'], {}], + }, + null, + 'refetch', + ], +] + +const invalidFixtures = [ + // plain wrong + ['1', 'b', 'c'], + // invalid enum + [['a', 'b', 'foo'], {}], + // invalid url + [ + ['a', 'b', 'c'], + { + a: [['a', 'b', 'c'], {}], + b: [['a', 'b', 'c'], {}], + }, + { + invalid: 'invalid', + }, + ], + // invalid isRootLayout + [ + ['a', 'b', 'c'], + { + a: [['a', 'b', 'c'], {}], + b: [['a', 'b', 'c'], {}], + }, + null, + 1, + ], +] + +describe('flightRouterStateSchema', () => { + it('should validate a correct flight router state', () => { + for (const state of validFixtures) { + expect(() => assert(state, flightRouterStateSchema)).not.toThrow() + } + }) + it('should not validate an incorrect flight router state', () => { + for (const state of invalidFixtures) { + expect(() => assert(state, flightRouterStateSchema)).toThrow() + } + }) +}) diff --git a/packages/next/src/server/app-render/types.ts b/packages/next/src/server/app-render/types.ts index 7401f92444506c..9345d114b620f5 100644 --- a/packages/next/src/server/app-render/types.ts +++ b/packages/next/src/server/app-render/types.ts @@ -5,55 +5,35 @@ import type { ClientReferenceManifest } from '../../build/webpack/plugins/flight import type { NextFontManifest } from '../../build/webpack/plugins/next-font-manifest-plugin' import type { ParsedUrlQuery } from 'querystring' -import zod from 'zod' +import s from 'next/dist/compiled/superstruct' export type DynamicParamTypes = 'catchall' | 'optional-catchall' | 'dynamic' -const dynamicParamTypesSchema = zod.enum(['c', 'oc', 'd']) -/** - * c = catchall - * oc = optional catchall - * d = dynamic - */ -export type DynamicParamTypesShort = zod.infer +const dynamicParamTypesSchema = s.enums(['c', 'oc', 'd']) + +export type DynamicParamTypesShort = s.Infer -const segmentSchema = zod.union([ - zod.string(), - zod.tuple([zod.string(), zod.string(), dynamicParamTypesSchema]), +const segmentSchema = s.union([ + s.string(), + s.tuple([s.string(), s.string(), dynamicParamTypesSchema]), ]) -/** - * Segment in the router state. - */ -export type Segment = zod.infer - -export const flightRouterStateSchema: zod.ZodType = zod.lazy( - () => { - const parallelRoutesSchema = zod.record(flightRouterStateSchema) - const urlSchema = zod.string().nullable().optional() - const refreshSchema = zod.literal('refetch').nullable().optional() - const isRootLayoutSchema = zod.boolean().optional() - - // Due to the lack of optional tuple types in Zod, we need to use union here. - // https://github.com/colinhacks/zod/issues/1465 - return zod.union([ - zod.tuple([ - segmentSchema, - parallelRoutesSchema, - urlSchema, - refreshSchema, - isRootLayoutSchema, - ]), - zod.tuple([ - segmentSchema, - parallelRoutesSchema, - urlSchema, - refreshSchema, - ]), - zod.tuple([segmentSchema, parallelRoutesSchema, urlSchema]), - zod.tuple([segmentSchema, parallelRoutesSchema]), - ]) - } -) + +export type Segment = s.Infer + +// unfortunately the tuple is not understood well by Describe so we have to +// use any here. This does not have any impact on the runtime type since the validation +// does work correctly. +export const flightRouterStateSchema: s.Describe = s.tuple([ + segmentSchema, + s.record( + s.string(), + s.lazy(() => flightRouterStateSchema) + ), + s.optional(s.nullable(s.string())), + s.optional(s.nullable(s.literal('refetch'))), + s.optional(s.boolean()), +]) + /** * Router state */ diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index eef85d32a3d9d8..9cab5c04d477e6 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -1991,6 +1991,16 @@ export async function ncc_unistore(task, opts) { .ncc({ packageName: 'unistore', externals }) .target('src/compiled/unistore') } + +// eslint-disable-next-line camelcase +externals['unistore'] = 'next/dist/compiled/superstruct' +export async function ncc_superstruct(task, opts) { + await task + .source(relative(__dirname, require.resolve('superstruct'))) + .ncc({ packageName: 'superstruct', externals }) + .target('src/compiled/superstruct') +} + // eslint-disable-next-line camelcase externals['web-vitals'] = 'next/dist/compiled/web-vitals' export async function ncc_web_vitals(task, opts) { @@ -2314,6 +2324,7 @@ export async function ncc(task, opts) { 'ncc_source_map', 'ncc_string_hash', 'ncc_strip_ansi', + 'ncc_superstruct', 'ncc_nft', 'ncc_tar', 'ncc_terser', diff --git a/packages/next/types/global.d.ts b/packages/next/types/global.d.ts index ca0ca52b8c2f70..f3e6943339c42f 100644 --- a/packages/next/types/global.d.ts +++ b/packages/next/types/global.d.ts @@ -55,3 +55,11 @@ interface NextFetchRequestConfig { interface RequestInit { next?: NextFetchRequestConfig | undefined } + +// TOOD: remove this. Somehow putting this in compiler.d.ts doesn't work when skipLibCheck: false +// so we put it here instead +declare module 'next/dist/compiled/superstruct' { + // eslint-disable-next-line + import m from 'superstruct' + export = m +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4e96612f297378..d64d0f8cd47e5a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -819,9 +819,6 @@ importers: watchpack: specifier: 2.4.0 version: 2.4.0 - zod: - specifier: 3.21.4 - version: 3.21.4 devDependencies: '@ampproject/toolbox-optimizer': specifier: 2.8.3 @@ -1372,6 +1369,9 @@ importers: strip-ansi: specifier: 6.0.0 version: 6.0.0 + superstruct: + specifier: 1.0.3 + version: 1.0.3 tar: specifier: 6.1.15 version: 6.1.15 @@ -23707,7 +23707,6 @@ packages: dependencies: klona: 2.0.4 neo-async: 2.6.2 - sass: 1.54.0 webpack: 5.86.0(@swc/core@1.3.85) dev: true @@ -24838,6 +24837,11 @@ packages: - supports-color dev: true + /superstruct@1.0.3: + resolution: {integrity: sha512-8iTn3oSS8nRGn+C2pgXSKPI3jmpm6FExNazNpjvqS6ZUJQCej3PUXEKM8NjHBOs54ExM+LPW/FBRhymrdcCiSg==} + engines: {node: '>=14.0.0'} + dev: true + /supports-color@2.0.0: resolution: {integrity: sha512-KKNVtd6pCYgPIKU4cp2733HWYCpplQhddZLBUryaAHou723x+FRzQ5Df824Fj+IyyuiQTRoub4SnIFfIcrp70g==} engines: {node: '>=0.8.0'} @@ -26956,10 +26960,6 @@ packages: resolution: {integrity: sha512-N+d4UJSJbt/R3wqY7Coqs5pcV0aUj2j9IaQ3rNj9bVCLld8tTGKRa2USARjnvZJWVx1NDmQev8EknoczaOQDOA==} dev: true - /zod@3.21.4: - resolution: {integrity: sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==} - dev: false - /zwitch@1.0.5: resolution: {integrity: sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw==} dev: true