Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@esmj/schema

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@esmj/schema - npm Package Compare versions

Comparing version
0.7.4
to
0.8.0
+1
dist/chunk-7VTVE334.mjs
import {p}from'./chunk-AKXLQP64.mjs';p((a,s,i)=>{if(i?.type==="string"){let r=a;r.min=function(n,{message:t}={}){return this.refine(e=>e.length>=n,{message:t||(e=>`String must be at least ${n} characters long (received ${e.length} characters: "${e}")`)})},r.max=function(n,{message:t}={}){return this.refine(e=>e.length<=n,{message:t||(e=>`String must be at most ${n} characters long (received ${e.length} characters: "${e}")`)})},r.length=function(n,{message:t}={}){return this.refine(e=>e.length===n,{message:t||(e=>`String must be exactly ${n} characters long (received ${e.length} characters: "${e}")`)})},r.nonEmpty=function({message:n}={}){return this.refine(t=>t.length>0,{message:n||"String must not be empty (received empty string)"})},r.startsWith=function(n,{message:t}={}){return this.refine(e=>e.startsWith(n),{message:t||(e=>`String must start with "${n}" (received: "${e}")`)})},r.endsWith=function(n,{message:t}={}){return this.refine(e=>e.endsWith(n),{message:t||(e=>`String must end with "${n}" (received: "${e}")`)})},r.includes=function(n,{message:t}={}){return this.refine(e=>e.includes(n),{message:t||(e=>`String must include "${n}" (received: "${e}")`)})},r.toLowerCase=function(){return this.transform(n=>n.toLowerCase())},r.toUpperCase=function(){return this.transform(n=>n.toUpperCase())},r.trim=function(){return this.transform(n=>n.trim())},r.padStart=function(n,t=" "){return this.transform(e=>e.padStart(n,t))},r.padEnd=function(n,t=" "){return this.transform(e=>e.padEnd(n,t))},r.replace=function(n,t){return this.transform(e=>e.replace(n,t))};}return a});
var N={abortEarly:true};function T(e,a){if(!a)return e;let n=e?.cause?.key?`${a}.${e.cause.key}`:`${a}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function w(e,a,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)a.push(T(e.errors[r],n));}function O(e){return e?.abortEarly!==void 0?e:N}var l=e=>typeof e=="string"||e instanceof String,y=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),g=e=>e===true||e===false,R=e=>e instanceof Date&&!Number.isNaN(e.getTime()),A=e=>typeof e=="function",j=e=>Array.isArray(e),P=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function F(e,a){let n=h(P,{...a,type:"object"});return n._getDescription=()=>`object({ ${Object.entries(e).map(([p,o])=>`${p}: ${o._getDescription()}`).join(", ")} })`,m(n,"_parse",(r,p,o)=>{let t=r(p,o),{abortEarly:s}=O(o);if(t.success===false)return t;let u={},c=[];for(let i in e){let f=e[i]._parse(t.data[i],o);if(f.success)u[i]=f.data;else {if(f=f,s!==false){let I=T(f.error,i);return {success:false,error:I,errors:[I]}}w(f,c,i);}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:u}}),n}function E(e){return h(l,{...e,type:"string"})}function _(e){return h(y,{...e,type:"number"})}function D(e){return h(g,{...e,type:"boolean"})}function $(e){return h(R,{...e,type:"date"})}function C(e){return h(A,{...e,type:"function"})}function V(e,a){let n=t=>e.includes(t),r=t=>`Invalid ${p} value. Expected ${e.map(s=>`"${s}"`).join(" | ")}, received "${t}".`,p="enum",o=h(n,{message:r,...a,type:p});return o._getDescription=()=>`enum(${e.map(t=>`"${t}"`).join(" | ")})`,o}function L(e,a){let n=h(j,{...a,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,m(n,"_parse",(r,p,o)=>{let t=r(p,o),{abortEarly:s}=O(o);if(t.success===false)return t;let u=[],c=[];for(let i=0;i<t.data.length;i++){let f=e._parse(t.data[i],o);if(f.success)u.push(f.data);else {if(f=f,s!==false){let I=T(f.error,i);return {success:false,error:I,errors:[I]}}w(f,c,i);}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:u}}),n}function M(){return h(()=>true)}function d(e,a){return m(a,"_parse",(n,r)=>(r=e(r),n(r))),a}function B(e,a){return h(o=>{for(let t=0;t<e.length;t++){let s=e[t]._parse(o);if(s.success)return s}return false},{message:o=>`Invalid union value. Expected the value to match one of the schemas:${e.map((t,s)=>` ${s+1}. ${t._getDescription()}`).join(",")} but received "${typeof o}" with value: ${P(o)?JSON.stringify(o):`"${o}"`}`,...a,type:"union"})}function U(e,a){let p=h(o=>o===e,{message:o=>a?.message?typeof a.message=="function"?a.message(o):a.message:`Expected literal value "${e}", received "${o}"`,name:a?.name,type:"literal"});return p._getDescription=()=>`literal("${e}")`,p}var J={boolean(e){let a=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return d(n=>{let r;return l(n)&&(r=n.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||n===1?true:r==="false"||r==="no"||r==="off"||r==="0"||n===0?false:n},D({...e,message:a}))},number(e){let a=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return d(n=>{if(g(n))return Number(n);if(l(n)){let r=n.trim();if(r==="")return n;let p=Number(r);if(Number.isFinite(p))return p}return n},_({...e,message:a}))},string(e){let a=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return d(n=>g(n)||y(n)&&Number.isFinite(n)?String(n):n,E({...e,message:a}))},date(e){let a=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return d(n=>{let r;return l(n)&&(r=n.trim()),y(n)&&Number.isFinite(n)||r?new Date(r??n):n},$({...e,message:a}))},json(e,a){let n=a?.message??(r=>`Cannot parse "${r}" as JSON.`);return m(e,"_parse",(r,p)=>{if(l(p))try{p=JSON.parse(p);}catch{let o={message:typeof n=="function"?n(p):n};return {success:false,error:o,errors:[o]}}return r(p)}),e}},G={object:F,string:E,number:_,boolean:D,date:$,function:C,enum:V,array:L,any:M,preprocess:d,union:B,literal:U,coerce:{},cast:J};function x(e){return a=>`The value "${a}" must be type of ${e} but is type of "${typeof a}".`}function m(e,a,n){let r=e[a];e[a]=(...p)=>n(r,...p);}function h(e,{type:a="any",name:n,message:r}={}){r=r||x(a);let p={name:n,message:r,type:a},o={_getName(){return n},_getType(){return a},_getDescription(){return this._getName()??this._getType()},_parse(t,s){let u=e(t);if(u===true)return {success:true,data:t};if(typeof u=="object"&&u?.success===true)return u;let c={message:typeof r=="function"?r(t):r};return {success:false,error:c,errors:[c]}},parse(t,s){let u=o._parse(t,s);if(!u.success)throw u=u,new Error(u.error.message,{cause:u.error.cause});return u.data},safeParse(t,s){return o._parse(t,s)},transform(t){return m(this,"_parse",(s,u,c)=>{let i=s(u,c);return i.success&&(i.data=t(i.data)),i}),this},optional(){return m(this,"_parse",(t,s,u)=>{let c=t(s,u);return !c.success&&s===void 0&&(c.data=void 0,c.success=true),c}),this},nullable(){return m(this,"_parse",(t,s,u)=>{let c=t(s,u);return !c.success&&s===null&&(c.data=null,c.success=true),c}),this},nullish(){return m(this,"_parse",(t,s,u)=>{let c=t(s,u);return !c.success&&s==null&&(c.success=true,c.data=s),c}),this},default(t){return m(this,"_parse",(s,u,c)=>(u===void 0&&(u=typeof t=="function"?t():t),s(u,c))),this},catch(t){return m(this,"_parse",(s,u,c)=>{let i=s(u,c);return i.success?i:{success:true,data:typeof t=="function"?t({input:u,error:i.error}):t}}),this},pipe(t){return m(this,"_parse",(s,u,c)=>{let i=s(u,c);return i.success?t._parse(i.data,c):i}),this},refine(t,{message:s,type:u}={}){return u&&(s=s||x(u),a=u),m(this,"_parse",(c,i,f)=>{let I=c(i,f),{abortEarly:q}=O(f);if(!I.success)return I;let S=t(I.data);if(S===true||typeof S=="object"&&S?.success===true)return I;let k={message:typeof s=="function"?s(i):s};return {success:false,error:k,errors:[k]}}),this}};return b.length>0?b.reduce((t,s)=>s(t,e,p)??t,o):o}var b=[];function H(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");b.push(e);}export{F as a,E as b,_ as c,D as d,$ as e,C as f,V as g,L as h,M as i,d as j,B as k,U as l,J as m,G as n,m as o,H as p};
import {p}from'./chunk-AKXLQP64.mjs';p((t,h,i)=>{if(i?.type==="array"){let r=t;r.min=function(e,{message:n}={}){return this.refine(a=>a.length>=e,{message:n||`Array must contain at least ${e} items.`})},r.max=function(e,{message:n}={}){return this.refine(a=>a.length<=e,{message:n||`Array must contain at most ${e} items.`})},r.length=function(e,{message:n}={}){return this.refine(a=>a.length===e,{message:n||`Array must contain exactly ${e} items.`})},r.nonEmpty=function({message:e}={}){return this.refine(n=>n.length>0,{message:e||"Array must not be empty."})},r.unique=function({message:e}={}){return this.refine(n=>{let a=new Set;try{return n.every(c=>{let s=JSON.stringify(c);return a.has(s)?!1:(a.add(s),!0)})}catch{return new Set(n).size===n.length}},{message:e||"Array items must be unique."})},r.sort=function(){return this.transform(e=>[...e].sort())},r.reverse=function(){return this.transform(e=>[...e].reverse())};}return t});
import {p}from'./chunk-AKXLQP64.mjs';p((r,c,i)=>{if(i?.type==="number"){let t=r;t.min=function(e,{message:n}={}){return this.refine(a=>a>=e,{message:n||`Number must be greater than or equal to ${e}.`})},t.max=function(e,{message:n}={}){return this.refine(a=>a<=e,{message:n||`Number must be less than or equal to ${e}.`})},t.positive=function({message:e}={}){return this.refine(n=>n>0,{message:e||"Number must be positive."})},t.negative=function({message:e}={}){return this.refine(n=>n<0,{message:e||"Number must be negative."})},t.int=function({message:e}={}){return this.refine(n=>Number.isInteger(n),{message:e||"Number must be an integer."})},t.float=function({message:e}={}){return this.refine(n=>Number.isFinite(n)&&!Number.isInteger(n),{message:e||"Number must be a floating point (non-integer)."})},t.multipleOf=function(e,{message:n}={}){return this.refine(a=>a%e===0,{message:n||`Number must be a multiple of ${e}.`})},t.finite=function({message:e}={}){return this.refine(n=>Number.isFinite(n),{message:e||"Number must be finite."})};}return r});
import {n,j,e,d,c,b}from'./chunk-AKXLQP64.mjs';Object.assign(n.coerce,{string(e){return j(n=>String(n),b(e))},number(e){let n=e?.message??(a=>`Cannot coerce "${a}" to a valid number.`);return j(a=>Number(a),c({...e,message:n}))},boolean(e){return j(n=>!!n,d(e))},date(e$1){let n=e$1?.message??(a=>`Cannot coerce "${a}" to a valid date.`);return j(a=>new Date(a),e({...e$1,message:n}))}});
'use strict';var R={abortEarly:true};function x(e,t){if(!t)return e;let n=e?.cause?.key?`${t}.${e.cause.key}`:`${t}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function N(e,t,n){if(e.errors?.length)for(let a=0;a<e.errors.length;a++)t.push(x(e.errors[a],n));}function P(e){return e?.abortEarly!==void 0?e:R}var l=e=>typeof e=="string"||e instanceof String,T=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),k=e=>e===true||e===false,A=e=>e instanceof Date&&!Number.isNaN(e.getTime()),j=e=>typeof e=="function",F=e=>Array.isArray(e),_=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function C(e,t){let n=h(_,{...t,type:"object"});return n._getDescription=()=>`object({ ${Object.entries(e).map(([f,u])=>`${f}: ${u._getDescription()}`).join(", ")} })`,m(n,"_parse",(a,f,u)=>{let r=a(f,u),{abortEarly:c}=P(u);if(r.success===false)return r;let o={},s=[];for(let i in e){let p=e[i]._parse(r.data[i],u);if(p.success)o[i]=p.data;else {if(p=p,c!==false){let I=x(p.error,i);return {success:false,error:I,errors:[I]}}N(p,s,i);}}return s.length>0?{success:false,error:s[0],errors:s}:{success:true,data:o}}),n}function d(e){return h(l,{...e,type:"string"})}function y(e){return h(T,{...e,type:"number"})}function g(e){return h(k,{...e,type:"boolean"})}function b(e){return h(A,{...e,type:"date"})}function V(e){return h(j,{...e,type:"function"})}function B(e,t){let n=r=>e.includes(r),a=r=>`Invalid ${f} value. Expected ${e.map(c=>`"${c}"`).join(" | ")}, received "${r}".`,f="enum",u=h(n,{message:a,...t,type:f});return u._getDescription=()=>`enum(${e.map(r=>`"${r}"`).join(" | ")})`,u}function L(e,t){let n=h(F,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,m(n,"_parse",(a,f,u)=>{let r=a(f,u),{abortEarly:c}=P(u);if(r.success===false)return r;let o=[],s=[];for(let i=0;i<r.data.length;i++){let p=e._parse(r.data[i],u);if(p.success)o.push(p.data);else {if(p=p,c!==false){let I=x(p.error,i);return {success:false,error:I,errors:[I]}}N(p,s,i);}}return s.length>0?{success:false,error:s[0],errors:s}:{success:true,data:o}}),n}function M(){return h(()=>true)}function S(e,t){return m(t,"_parse",(n,a)=>(a=e(a),n(a))),t}function U(e,t){return h(u=>{for(let r=0;r<e.length;r++){let c=e[r]._parse(u);if(c.success)return c}return false},{message:u=>`Invalid union value. Expected the value to match one of the schemas:${e.map((r,c)=>` ${c+1}. ${r._getDescription()}`).join(",")} but received "${typeof u}" with value: ${_(u)?JSON.stringify(u):`"${u}"`}`,...t,type:"union"})}function J(e,t){let f=h(u=>u===e,{message:u=>t?.message?typeof t.message=="function"?t.message(u):t.message:`Expected literal value "${e}", received "${u}"`,name:t?.name,type:"literal"});return f._getDescription=()=>`literal("${e}")`,f}var q={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return S(n=>{let a;return l(n)&&(a=n.toLowerCase()),a==="true"||a==="yes"||a==="on"||a==="1"||n===1?true:a==="false"||a==="no"||a==="off"||a==="0"||n===0?false:n},g({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return S(n=>{if(k(n))return Number(n);if(l(n)){let a=n.trim();if(a==="")return n;let f=Number(a);if(Number.isFinite(f))return f}return n},y({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return S(n=>k(n)||T(n)&&Number.isFinite(n)?String(n):n,d({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return S(n=>{let a;return l(n)&&(a=n.trim()),T(n)&&Number.isFinite(n)||a?new Date(a??n):n},b({...e,message:t}))},json(e,t){let n=t?.message??(a=>`Cannot parse "${a}" as JSON.`);return m(e,"_parse",(a,f)=>{if(l(f))try{f=JSON.parse(f);}catch{let u={message:typeof n=="function"?n(f):n};return {success:false,error:u,errors:[u]}}return a(f)}),e}},$={object:C,string:d,number:y,boolean:g,date:b,function:V,enum:B,array:L,any:M,preprocess:S,union:U,literal:J,coerce:{},cast:q};function D(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function m(e,t,n){let a=e[t];e[t]=(...f)=>n(a,...f);}function h(e,{type:t="any",name:n,message:a}={}){a=a||D(t);let f={name:n,message:a,type:t},u={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(r,c){let o=e(r);if(o===true)return {success:true,data:r};if(typeof o=="object"&&o?.success===true)return o;let s={message:typeof a=="function"?a(r):a};return {success:false,error:s,errors:[s]}},parse(r,c){let o=u._parse(r,c);if(!o.success)throw o=o,new Error(o.error.message,{cause:o.error.cause});return o.data},safeParse(r,c){return u._parse(r,c)},transform(r){return m(this,"_parse",(c,o,s)=>{let i=c(o,s);return i.success&&(i.data=r(i.data)),i}),this},optional(){return m(this,"_parse",(r,c,o)=>{let s=r(c,o);return !s.success&&c===void 0&&(s.data=void 0,s.success=true),s}),this},nullable(){return m(this,"_parse",(r,c,o)=>{let s=r(c,o);return !s.success&&c===null&&(s.data=null,s.success=true),s}),this},nullish(){return m(this,"_parse",(r,c,o)=>{let s=r(c,o);return !s.success&&c==null&&(s.success=true,s.data=c),s}),this},default(r){return m(this,"_parse",(c,o,s)=>(o===void 0&&(o=typeof r=="function"?r():r),c(o,s))),this},catch(r){return m(this,"_parse",(c,o,s)=>{let i=c(o,s);return i.success?i:{success:true,data:typeof r=="function"?r({input:o,error:i.error}):r}}),this},pipe(r){return m(this,"_parse",(c,o,s)=>{let i=c(o,s);return i.success?r._parse(i.data,s):i}),this},refine(r,{message:c,type:o}={}){return o&&(c=c||D(o),t=o),m(this,"_parse",(s,i,p)=>{let I=s(i,p),{abortEarly:z}=P(p);if(!I.success)return I;let O=r(I.data);if(O===true||typeof O=="object"&&O?.success===true)return I;let E={message:typeof c=="function"?c(i):c};return {success:false,error:E,errors:[E]}}),this}};return w.length>0?w.reduce((r,c)=>c(r,e,f)??r,u):u}var w=[];function H(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");w.push(e);}Object.assign($.coerce,{string(e){return S(t=>String(t),d(e))},number(e){let t=e?.message??(n=>`Cannot coerce "${n}" to a valid number.`);return S(n=>Number(n),y({...e,message:t}))},boolean(e){return S(t=>!!t,g(e))},date(e){let t=e?.message??(n=>`Cannot coerce "${n}" to a valid date.`);return S(n=>new Date(n),b({...e,message:t}))}});exports.any=M;exports.array=L;exports.boolean=g;exports.cast=q;exports.date=b;exports.enumSchema=B;exports.extend=H;exports.functionSchema=V;exports.hookOriginal=m;exports.literal=J;exports.number=y;exports.object=C;exports.preprocess=S;exports.s=$;exports.schema=$;exports.string=d;exports.union=U;
export { ArraySchemaInterface, BooleanSchemaInterface, CoerceInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.mjs';
declare module './index.ts' {
interface CoerceInterface {
/**
* Creates a string schema that coerces input using `String(value)`.
* Always succeeds — `String()` never produces an invalid string.
*/
string(options?: SchemaInterfaceOptions): StringSchemaInterface;
/**
* Creates a number schema that coerces input using `Number(value)`.
* Fails when the result is `NaN` (e.g. `'bad'`, `undefined`, plain objects).
*/
number(options?: SchemaInterfaceOptions): NumberSchemaInterface;
/**
* Creates a boolean schema that coerces input using `Boolean(value)`.
* Always succeeds — `Boolean()` always produces `true` or `false`.
* Note: `Boolean('false')` is `true` because `'false'` is a non-empty string.
*/
boolean(options?: SchemaInterfaceOptions): BooleanSchemaInterface;
/**
* Creates a date schema that coerces input using `new Date(value)`.
* Fails when the result is an invalid Date (e.g. `'garbage'`).
*/
date(options?: SchemaInterfaceOptions): DateSchemaInterface;
}
}
export { ArraySchemaInterface, BooleanSchemaInterface, CoerceInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.js';
declare module './index.ts' {
interface CoerceInterface {
/**
* Creates a string schema that coerces input using `String(value)`.
* Always succeeds — `String()` never produces an invalid string.
*/
string(options?: SchemaInterfaceOptions): StringSchemaInterface;
/**
* Creates a number schema that coerces input using `Number(value)`.
* Fails when the result is `NaN` (e.g. `'bad'`, `undefined`, plain objects).
*/
number(options?: SchemaInterfaceOptions): NumberSchemaInterface;
/**
* Creates a boolean schema that coerces input using `Boolean(value)`.
* Always succeeds — `Boolean()` always produces `true` or `false`.
* Note: `Boolean('false')` is `true` because `'false'` is a non-empty string.
*/
boolean(options?: SchemaInterfaceOptions): BooleanSchemaInterface;
/**
* Creates a date schema that coerces input using `new Date(value)`.
* Fails when the result is an invalid Date (e.g. `'garbage'`).
*/
date(options?: SchemaInterfaceOptions): DateSchemaInterface;
}
}
import'./chunk-SR7R5QYC.mjs';export{i as any,h as array,d as boolean,m as cast,e as date,g as enumSchema,p as extend,f as functionSchema,o as hookOriginal,l as literal,c as number,a as object,j as preprocess,n as s,n as schema,b as string,k as union}from'./chunk-AKXLQP64.mjs';
+1
-1

@@ -1,1 +0,1 @@

'use strict';var N={abortEarly:true};function b(e,a){if(!a)return e;let n=e?.cause?.key?`${a}.${e.cause.key}`:`${a}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function $(e,a,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)a.push(b(e.errors[r],n));}function O(e){return e?.abortEarly!==void 0?e:N}var y=e=>typeof e=="string"||e instanceof String,d=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),g=e=>e===true||e===false,R=e=>e instanceof Date&&!Number.isNaN(e.getTime()),j=e=>typeof e=="function",F=e=>Array.isArray(e),_=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function C(e,a){let n=h(_,{...a,type:"object"});return n._getDescription=()=>`object({ ${Object.entries(e).map(([u,s])=>`${u}: ${s._getDescription()}`).join(", ")} })`,m(n,"_parse",(r,u,s)=>{let t=r(u,s),{abortEarly:c}=O(s);if(t.success===false)return t;let o={},i=[];for(let f in e){let p=e[f]._parse(t.data[f],s);if(p.success)o[f]=p.data;else {if(p=p,c!==false){let S=b(p.error,f);return {success:false,error:S,errors:[S]}}$(p,i,f);}}return i.length>0?{success:false,error:i[0],errors:i}:{success:true,data:o}}),n}function k(e){return h(y,{...e,type:"string"})}function w(e){return h(d,{...e,type:"number"})}function x(e){return h(g,{...e,type:"boolean"})}function A(e){return h(R,{...e,type:"date"})}function V(e){return h(j,{...e,type:"function"})}function B(e,a){let n=t=>e.includes(t),r=t=>`Invalid ${u} value. Expected ${e.map(c=>`"${c}"`).join(" | ")}, received "${t}".`,u="enum",s=h(n,{message:r,...a,type:u});return s._getDescription=()=>`enum(${e.map(t=>`"${t}"`).join(" | ")})`,s}function L(e,a){let n=h(F,{...a,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,m(n,"_parse",(r,u,s)=>{let t=r(u,s),{abortEarly:c}=O(s);if(t.success===false)return t;let o=[],i=[];for(let f=0;f<t.data.length;f++){let p=e._parse(t.data[f],s);if(p.success)o.push(p.data);else {if(p=p,c!==false){let S=b(p.error,f);return {success:false,error:S,errors:[S]}}$(p,i,f);}}return i.length>0?{success:false,error:i[0],errors:i}:{success:true,data:o}}),n}function M(){return h(()=>true)}function I(e,a){return m(a,"_parse",(n,r)=>(r=e(r),n(r))),a}function q(e,a){return h(s=>{for(let t=0;t<e.length;t++){let c=e[t]._parse(s);if(c.success)return c}return false},{message:s=>`Invalid union value. Expected the value to match one of the schemas:${e.map((t,c)=>` ${c+1}. ${t._getDescription()}`).join(",")} but received "${typeof s}" with value: ${_(s)?JSON.stringify(s):`"${s}"`}`,...a,type:"union"})}function J(e,a){let u=h(s=>s===e,{message:s=>a?.message?typeof a.message=="function"?a.message(s):a.message:`Expected literal value "${e}", received "${s}"`,name:a?.name,type:"literal"});return u._getDescription=()=>`literal("${e}")`,u}var U={string(e){return I(a=>String(a),k(e))},number(e){let a=e?.message??(n=>`Cannot coerce "${n}" to a valid number.`);return I(n=>Number(n),w({...e,message:a}))},boolean(e){return I(a=>!!a,x(e))},date(e){let a=e?.message??(n=>`Cannot coerce "${n}" to a valid date.`);return I(n=>new Date(n),A({...e,message:a}))}},v={boolean(e){let a=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return I(n=>{let r;return y(n)&&(r=n.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||n===1?true:r==="false"||r==="no"||r==="off"||r==="0"||n===0?false:n},x({...e,message:a}))},number(e){let a=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return I(n=>{if(g(n))return Number(n);if(y(n)){let r=n.trim();if(r==="")return n;let u=Number(r);if(Number.isFinite(u))return u}return n},w({...e,message:a}))},string(e){let a=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return I(n=>g(n)||d(n)&&Number.isFinite(n)?String(n):n,k({...e,message:a}))},date(e){let a=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return I(n=>{let r;return y(n)&&(r=n.trim()),d(n)&&Number.isFinite(n)||r?new Date(r??n):n},A({...e,message:a}))},json(e,a){let n=a?.message??(r=>`Cannot parse "${r}" as JSON.`);return m(e,"_parse",(r,u)=>{if(y(u))try{u=JSON.parse(u);}catch{let s={message:typeof n=="function"?n(u):n};return {success:false,error:s,errors:[s]}}return r(u)}),e}},H={object:C,string:k,number:w,boolean:x,date:A,function:V,enum:B,array:L,any:M,preprocess:I,union:q,literal:J,coerce:U,cast:v};function E(e){return a=>`The value "${a}" must be type of ${e} but is type of "${typeof a}".`}function m(e,a,n){let r=e[a];e[a]=(...u)=>n(r,...u);}function h(e,{type:a="any",name:n,message:r}={}){r=r||E(a);let u={name:n,message:r,type:a},s={_getName(){return n},_getType(){return a},_getDescription(){return this._getName()??this._getType()},_parse(t,c){let o=e(t);if(o===true)return {success:true,data:t};if(typeof o=="object"&&o?.success===true)return o;let i={message:typeof r=="function"?r(t):r};return {success:false,error:i,errors:[i]}},parse(t,c){let o=s._parse(t,c);if(!o.success)throw o=o,new Error(o.error.message,{cause:o.error.cause});return o.data},safeParse(t,c){return s._parse(t,c)},transform(t){return m(this,"_parse",(c,o,i)=>{let f=c(o,i);return f.success&&(f.data=t(f.data)),f}),this},optional(){return m(this,"_parse",(t,c,o)=>{let i=t(c,o);return !i.success&&c===void 0&&(i.data=void 0,i.success=true),i}),this},nullable(){return m(this,"_parse",(t,c,o)=>{let i=t(c,o);return !i.success&&c===null&&(i.data=null,i.success=true),i}),this},nullish(){return m(this,"_parse",(t,c,o)=>{let i=t(c,o);return !i.success&&c==null&&(i.success=true,i.data=c),i}),this},default(t){return m(this,"_parse",(c,o,i)=>(o===void 0&&(o=typeof t=="function"?t():t),c(o,i))),this},catch(t){return m(this,"_parse",(c,o,i)=>{let f=c(o,i);return f.success?f:{success:true,data:typeof t=="function"?t({input:o,error:f.error}):t}}),this},pipe(t){return m(this,"_parse",(c,o,i)=>{let f=c(o,i);return f.success?t._parse(f.data,i):f}),this},refine(t,{message:c,type:o}={}){return o&&(c=c||E(o),a=o),m(this,"_parse",(i,f,p)=>{let S=i(f,p),{abortEarly:z}=O(p);if(!S.success)return S;let l=t(S.data);if(l===true||typeof l=="object"&&l?.success===true)return S;let P={message:typeof c=="function"?c(f):c};return {success:false,error:P,errors:[P]}}),this}};return T.length>0?T.reduce((t,c)=>c(t,e,u)??t,s):s}var T=[];function D(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");T.push(e);}D((e,a,n)=>{if(n?.type==="array"){let r=e;r.min=function(u,{message:s}={}){return this.refine(t=>t.length>=u,{message:s||`Array must contain at least ${u} items.`})},r.max=function(u,{message:s}={}){return this.refine(t=>t.length<=u,{message:s||`Array must contain at most ${u} items.`})},r.length=function(u,{message:s}={}){return this.refine(t=>t.length===u,{message:s||`Array must contain exactly ${u} items.`})},r.nonEmpty=function({message:u}={}){return this.refine(s=>s.length>0,{message:u||"Array must not be empty."})},r.unique=function({message:u}={}){return this.refine(s=>{let t=new Set;try{return s.every(c=>{let o=JSON.stringify(c);return t.has(o)?!1:(t.add(o),!0)})}catch{return new Set(s).size===s.length}},{message:u||"Array items must be unique."})},r.sort=function(){return this.transform(u=>[...u].sort())},r.reverse=function(){return this.transform(u=>[...u].reverse())};}return e});exports.any=M;exports.array=L;exports.boolean=x;exports.cast=v;exports.coerce=U;exports.date=A;exports.enumSchema=B;exports.extend=D;exports.functionSchema=V;exports.hookOriginal=m;exports.literal=J;exports.number=w;exports.object=C;exports.preprocess=I;exports.s=H;exports.schema=H;exports.string=k;exports.union=q;
'use strict';var N={abortEarly:true};function b(e,c){if(!c)return e;let n=e?.cause?.key?`${c}.${e.cause.key}`:`${c}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function x(e,c,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)c.push(b(e.errors[r],n));}function O(e){return e?.abortEarly!==void 0?e:N}var I=e=>typeof e=="string"||e instanceof String,d=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),g=e=>e===true||e===false,R=e=>e instanceof Date&&!Number.isNaN(e.getTime()),j=e=>typeof e=="function",F=e=>Array.isArray(e),A=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function C(e,c){let n=h(A,{...c,type:"object"});return n._getDescription=()=>`object({ ${Object.entries(e).map(([u,s])=>`${u}: ${s._getDescription()}`).join(", ")} })`,m(n,"_parse",(r,u,s)=>{let t=r(u,s),{abortEarly:a}=O(s);if(t.success===false)return t;let o={},i=[];for(let f in e){let p=e[f]._parse(t.data[f],s);if(p.success)o[f]=p.data;else {if(p=p,a!==false){let S=b(p.error,f);return {success:false,error:S,errors:[S]}}x(p,i,f);}}return i.length>0?{success:false,error:i[0],errors:i}:{success:true,data:o}}),n}function P(e){return h(I,{...e,type:"string"})}function E(e){return h(d,{...e,type:"number"})}function _(e){return h(g,{...e,type:"boolean"})}function $(e){return h(R,{...e,type:"date"})}function V(e){return h(j,{...e,type:"function"})}function L(e,c){let n=t=>e.includes(t),r=t=>`Invalid ${u} value. Expected ${e.map(a=>`"${a}"`).join(" | ")}, received "${t}".`,u="enum",s=h(n,{message:r,...c,type:u});return s._getDescription=()=>`enum(${e.map(t=>`"${t}"`).join(" | ")})`,s}function M(e,c){let n=h(F,{...c,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,m(n,"_parse",(r,u,s)=>{let t=r(u,s),{abortEarly:a}=O(s);if(t.success===false)return t;let o=[],i=[];for(let f=0;f<t.data.length;f++){let p=e._parse(t.data[f],s);if(p.success)o.push(p.data);else {if(p=p,a!==false){let S=b(p.error,f);return {success:false,error:S,errors:[S]}}x(p,i,f);}}return i.length>0?{success:false,error:i[0],errors:i}:{success:true,data:o}}),n}function B(){return h(()=>true)}function y(e,c){return m(c,"_parse",(n,r)=>(r=e(r),n(r))),c}function q(e,c){return h(s=>{for(let t=0;t<e.length;t++){let a=e[t]._parse(s);if(a.success)return a}return false},{message:s=>`Invalid union value. Expected the value to match one of the schemas:${e.map((t,a)=>` ${a+1}. ${t._getDescription()}`).join(",")} but received "${typeof s}" with value: ${A(s)?JSON.stringify(s):`"${s}"`}`,...c,type:"union"})}function J(e,c){let u=h(s=>s===e,{message:s=>c?.message?typeof c.message=="function"?c.message(s):c.message:`Expected literal value "${e}", received "${s}"`,name:c?.name,type:"literal"});return u._getDescription=()=>`literal("${e}")`,u}var U={boolean(e){let c=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return y(n=>{let r;return I(n)&&(r=n.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||n===1?true:r==="false"||r==="no"||r==="off"||r==="0"||n===0?false:n},_({...e,message:c}))},number(e){let c=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return y(n=>{if(g(n))return Number(n);if(I(n)){let r=n.trim();if(r==="")return n;let u=Number(r);if(Number.isFinite(u))return u}return n},E({...e,message:c}))},string(e){let c=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return y(n=>g(n)||d(n)&&Number.isFinite(n)?String(n):n,P({...e,message:c}))},date(e){let c=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return y(n=>{let r;return I(n)&&(r=n.trim()),d(n)&&Number.isFinite(n)||r?new Date(r??n):n},$({...e,message:c}))},json(e,c){let n=c?.message??(r=>`Cannot parse "${r}" as JSON.`);return m(e,"_parse",(r,u)=>{if(I(u))try{u=JSON.parse(u);}catch{let s={message:typeof n=="function"?n(u):n};return {success:false,error:s,errors:[s]}}return r(u)}),e}},G={object:C,string:P,number:E,boolean:_,date:$,function:V,enum:L,array:M,any:B,preprocess:y,union:q,literal:J,coerce:{},cast:U};function w(e){return c=>`The value "${c}" must be type of ${e} but is type of "${typeof c}".`}function m(e,c,n){let r=e[c];e[c]=(...u)=>n(r,...u);}function h(e,{type:c="any",name:n,message:r}={}){r=r||w(c);let u={name:n,message:r,type:c},s={_getName(){return n},_getType(){return c},_getDescription(){return this._getName()??this._getType()},_parse(t,a){let o=e(t);if(o===true)return {success:true,data:t};if(typeof o=="object"&&o?.success===true)return o;let i={message:typeof r=="function"?r(t):r};return {success:false,error:i,errors:[i]}},parse(t,a){let o=s._parse(t,a);if(!o.success)throw o=o,new Error(o.error.message,{cause:o.error.cause});return o.data},safeParse(t,a){return s._parse(t,a)},transform(t){return m(this,"_parse",(a,o,i)=>{let f=a(o,i);return f.success&&(f.data=t(f.data)),f}),this},optional(){return m(this,"_parse",(t,a,o)=>{let i=t(a,o);return !i.success&&a===void 0&&(i.data=void 0,i.success=true),i}),this},nullable(){return m(this,"_parse",(t,a,o)=>{let i=t(a,o);return !i.success&&a===null&&(i.data=null,i.success=true),i}),this},nullish(){return m(this,"_parse",(t,a,o)=>{let i=t(a,o);return !i.success&&a==null&&(i.success=true,i.data=a),i}),this},default(t){return m(this,"_parse",(a,o,i)=>(o===void 0&&(o=typeof t=="function"?t():t),a(o,i))),this},catch(t){return m(this,"_parse",(a,o,i)=>{let f=a(o,i);return f.success?f:{success:true,data:typeof t=="function"?t({input:o,error:f.error}):t}}),this},pipe(t){return m(this,"_parse",(a,o,i)=>{let f=a(o,i);return f.success?t._parse(f.data,i):f}),this},refine(t,{message:a,type:o}={}){return o&&(a=a||w(o),c=o),m(this,"_parse",(i,f,p)=>{let S=i(f,p),{abortEarly:z}=O(p);if(!S.success)return S;let l=t(S.data);if(l===true||typeof l=="object"&&l?.success===true)return S;let k={message:typeof a=="function"?a(f):a};return {success:false,error:k,errors:[k]}}),this}};return T.length>0?T.reduce((t,a)=>a(t,e,u)??t,s):s}var T=[];function D(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");T.push(e);}D((e,c,n)=>{if(n?.type==="array"){let r=e;r.min=function(u,{message:s}={}){return this.refine(t=>t.length>=u,{message:s||`Array must contain at least ${u} items.`})},r.max=function(u,{message:s}={}){return this.refine(t=>t.length<=u,{message:s||`Array must contain at most ${u} items.`})},r.length=function(u,{message:s}={}){return this.refine(t=>t.length===u,{message:s||`Array must contain exactly ${u} items.`})},r.nonEmpty=function({message:u}={}){return this.refine(s=>s.length>0,{message:u||"Array must not be empty."})},r.unique=function({message:u}={}){return this.refine(s=>{let t=new Set;try{return s.every(a=>{let o=JSON.stringify(a);return t.has(o)?!1:(t.add(o),!0)})}catch{return new Set(s).size===s.length}},{message:u||"Array items must be unique."})},r.sort=function(){return this.transform(u=>[...u].sort())},r.reverse=function(){return this.transform(u=>[...u].reverse())};}return e});exports.any=B;exports.array=M;exports.boolean=_;exports.cast=U;exports.date=$;exports.enumSchema=L;exports.extend=D;exports.functionSchema=V;exports.hookOriginal=m;exports.literal=J;exports.number=E;exports.object=C;exports.preprocess=y;exports.s=G;exports.schema=G;exports.string=P;exports.union=q;

@@ -1,2 +0,2 @@

export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, coerce, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.mjs';
export { ArraySchemaInterface, BooleanSchemaInterface, CoerceInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.mjs';

@@ -3,0 +3,0 @@ declare module './index.ts' {

@@ -1,2 +0,2 @@

export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, coerce, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.js';
export { ArraySchemaInterface, BooleanSchemaInterface, CoerceInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.js';

@@ -3,0 +3,0 @@ declare module './index.ts' {

@@ -1,1 +0,1 @@

import'./chunk-5XWCCG75.mjs';export{i as any,h as array,d as boolean,n as cast,m as coerce,e as date,g as enumSchema,q as extend,f as functionSchema,p as hookOriginal,l as literal,c as number,a as object,j as preprocess,o as s,o as schema,b as string,k as union}from'./chunk-37YJYCTR.mjs';
import'./chunk-AQFELD23.mjs';export{i as any,h as array,d as boolean,m as cast,e as date,g as enumSchema,p as extend,f as functionSchema,o as hookOriginal,l as literal,c as number,a as object,j as preprocess,n as s,n as schema,b as string,k as union}from'./chunk-AKXLQP64.mjs';

@@ -1,1 +0,1 @@

'use strict';var D={abortEarly:true};function T(e,s){if(!s)return e;let c=e?.cause?.key?`${s}.${e.cause.key}`:`${s}`;return {message:`Error parsing key "${c}": ${e.message}`,cause:{key:c}}}function E(e,s,c){if(e.errors?.length)for(let a=0;a<e.errors.length;a++)s.push(T(e.errors[a],c));}function w(e){return e?.abortEarly!==void 0?e:D}var g=e=>typeof e=="string"||e instanceof String,d=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),b=e=>e===true||e===false,R=e=>e instanceof Date&&!Number.isNaN(e.getTime()),j=e=>typeof e=="function",F=e=>Array.isArray(e),_=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function C(e,s){let c=h(_,{...s,type:"object"});return c._getDescription=()=>`object({ ${Object.entries(e).map(([t,r])=>`${t}: ${r._getDescription()}`).join(", ")} })`,p(c,"_parse",(a,t,r)=>{let n=a(t,r),{abortEarly:o}=w(r);if(n.success===false)return n;let u={},i=[];for(let m in e){let f=e[m]._parse(n.data[m],r);if(f.success)u[m]=f.data;else {if(f=f,o!==false){let S=T(f.error,m);return {success:false,error:S,errors:[S]}}E(f,i,m);}}return i.length>0?{success:false,error:i[0],errors:i}:{success:true,data:u}}),c}function k(e){return h(g,{...e,type:"string"})}function x(e){return h(d,{...e,type:"number"})}function N(e){return h(b,{...e,type:"boolean"})}function $(e){return h(R,{...e,type:"date"})}function v(e){return h(j,{...e,type:"function"})}function V(e,s){let c=n=>e.includes(n),a=n=>`Invalid ${t} value. Expected ${e.map(o=>`"${o}"`).join(" | ")}, received "${n}".`,t="enum",r=h(c,{message:a,...s,type:t});return r._getDescription=()=>`enum(${e.map(n=>`"${n}"`).join(" | ")})`,r}function L(e,s){let c=h(F,{...s,type:"array"});return c._getDescription=()=>`array(${e._getDescription()})`,p(c,"_parse",(a,t,r)=>{let n=a(t,r),{abortEarly:o}=w(r);if(n.success===false)return n;let u=[],i=[];for(let m=0;m<n.data.length;m++){let f=e._parse(n.data[m],r);if(f.success)u.push(f.data);else {if(f=f,o!==false){let S=T(f.error,m);return {success:false,error:S,errors:[S]}}E(f,i,m);}}return i.length>0?{success:false,error:i[0],errors:i}:{success:true,data:u}}),c}function B(){return h(()=>true)}function I(e,s){return p(s,"_parse",(c,a)=>(a=e(a),c(a))),s}function M(e,s){return h(r=>{for(let n=0;n<e.length;n++){let o=e[n]._parse(r);if(o.success)return o}return false},{message:r=>`Invalid union value. Expected the value to match one of the schemas:${e.map((n,o)=>` ${o+1}. ${n._getDescription()}`).join(",")} but received "${typeof r}" with value: ${_(r)?JSON.stringify(r):`"${r}"`}`,...s,type:"union"})}function U(e,s){let t=h(r=>r===e,{message:r=>s?.message?typeof s.message=="function"?s.message(r):s.message:`Expected literal value "${e}", received "${r}"`,name:s?.name,type:"literal"});return t._getDescription=()=>`literal("${e}")`,t}var q={string(e){return I(s=>String(s),k(e))},number(e){let s=e?.message??(c=>`Cannot coerce "${c}" to a valid number.`);return I(c=>Number(c),x({...e,message:s}))},boolean(e){return I(s=>!!s,N(e))},date(e){let s=e?.message??(c=>`Cannot coerce "${c}" to a valid date.`);return I(c=>new Date(c),$({...e,message:s}))}},W={boolean(e){let s=e?.message??(c=>`Cannot cast "${c}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return I(c=>{let a;return g(c)&&(a=c.toLowerCase()),a==="true"||a==="yes"||a==="on"||a==="1"||c===1?true:a==="false"||a==="no"||a==="off"||a==="0"||c===0?false:c},N({...e,message:s}))},number(e){let s=e?.message??(c=>`Cannot cast "${c}" to a number. Expected a numeric string or number.`);return I(c=>{if(b(c))return Number(c);if(g(c)){let a=c.trim();if(a==="")return c;let t=Number(a);if(Number.isFinite(t))return t}return c},x({...e,message:s}))},string(e){let s=e?.message??(c=>`Cannot cast "${c}" to string. Expected a string, number, or boolean.`);return I(c=>b(c)||d(c)&&Number.isFinite(c)?String(c):c,k({...e,message:s}))},date(e){let s=e?.message??(c=>`Cannot cast "${c}" to a valid date.`);return I(c=>{let a;return g(c)&&(a=c.trim()),d(c)&&Number.isFinite(c)||a?new Date(a??c):c},$({...e,message:s}))},json(e,s){let c=s?.message??(a=>`Cannot parse "${a}" as JSON.`);return p(e,"_parse",(a,t)=>{if(g(t))try{t=JSON.parse(t);}catch{let r={message:typeof c=="function"?c(t):c};return {success:false,error:r,errors:[r]}}return a(t)}),e}},G={object:C,string:k,number:x,boolean:N,date:$,function:v,enum:V,array:L,any:B,preprocess:I,union:M,literal:U,coerce:q,cast:W};function P(e){return s=>`The value "${s}" must be type of ${e} but is type of "${typeof s}".`}function p(e,s,c){let a=e[s];e[s]=(...t)=>c(a,...t);}function h(e,{type:s="any",name:c,message:a}={}){a=a||P(s);let t={name:c,message:a,type:s},r={_getName(){return c},_getType(){return s},_getDescription(){return this._getName()??this._getType()},_parse(n,o){let u=e(n);if(u===true)return {success:true,data:n};if(typeof u=="object"&&u?.success===true)return u;let i={message:typeof a=="function"?a(n):a};return {success:false,error:i,errors:[i]}},parse(n,o){let u=r._parse(n,o);if(!u.success)throw u=u,new Error(u.error.message,{cause:u.error.cause});return u.data},safeParse(n,o){return r._parse(n,o)},transform(n){return p(this,"_parse",(o,u,i)=>{let m=o(u,i);return m.success&&(m.data=n(m.data)),m}),this},optional(){return p(this,"_parse",(n,o,u)=>{let i=n(o,u);return !i.success&&o===void 0&&(i.data=void 0,i.success=true),i}),this},nullable(){return p(this,"_parse",(n,o,u)=>{let i=n(o,u);return !i.success&&o===null&&(i.data=null,i.success=true),i}),this},nullish(){return p(this,"_parse",(n,o,u)=>{let i=n(o,u);return !i.success&&o==null&&(i.success=true,i.data=o),i}),this},default(n){return p(this,"_parse",(o,u,i)=>(u===void 0&&(u=typeof n=="function"?n():n),o(u,i))),this},catch(n){return p(this,"_parse",(o,u,i)=>{let m=o(u,i);return m.success?m:{success:true,data:typeof n=="function"?n({input:u,error:m.error}):n}}),this},pipe(n){return p(this,"_parse",(o,u,i)=>{let m=o(u,i);return m.success?n._parse(m.data,i):m}),this},refine(n,{message:o,type:u}={}){return u&&(o=o||P(u),s=u),p(this,"_parse",(i,m,f)=>{let S=i(m,f),{abortEarly:J}=w(f);if(!S.success)return S;let y=n(S.data);if(y===true||typeof y=="object"&&y?.success===true)return S;let A={message:typeof o=="function"?o(m):o};return {success:false,error:A,errors:[A]}}),this}};return O.length>0?O.reduce((n,o)=>o(n,e,t)??n,r):r}var O=[];function l(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");O.push(e);}l((e,s,c)=>{if(c?.type==="string"){let a=e;a.min=function(t,{message:r}={}){return this.refine(n=>n.length>=t,{message:r||(n=>`String must be at least ${t} characters long (received ${n.length} characters: "${n}")`)})},a.max=function(t,{message:r}={}){return this.refine(n=>n.length<=t,{message:r||(n=>`String must be at most ${t} characters long (received ${n.length} characters: "${n}")`)})},a.length=function(t,{message:r}={}){return this.refine(n=>n.length===t,{message:r||(n=>`String must be exactly ${t} characters long (received ${n.length} characters: "${n}")`)})},a.nonEmpty=function({message:t}={}){return this.refine(r=>r.length>0,{message:t||"String must not be empty (received empty string)"})},a.startsWith=function(t,{message:r}={}){return this.refine(n=>n.startsWith(t),{message:r||(n=>`String must start with "${t}" (received: "${n}")`)})},a.endsWith=function(t,{message:r}={}){return this.refine(n=>n.endsWith(t),{message:r||(n=>`String must end with "${t}" (received: "${n}")`)})},a.includes=function(t,{message:r}={}){return this.refine(n=>n.includes(t),{message:r||(n=>`String must include "${t}" (received: "${n}")`)})},a.toLowerCase=function(){return this.transform(t=>t.toLowerCase())},a.toUpperCase=function(){return this.transform(t=>t.toUpperCase())},a.trim=function(){return this.transform(t=>t.trim())},a.padStart=function(t,r=" "){return this.transform(n=>n.padStart(t,r))},a.padEnd=function(t,r=" "){return this.transform(n=>n.padEnd(t,r))},a.replace=function(t,r){return this.transform(n=>n.replace(t,r))};}return e});l((e,s,c)=>{if(c?.type==="number"){let a=e;a.min=function(t,{message:r}={}){return this.refine(n=>n>=t,{message:r||`Number must be greater than or equal to ${t}.`})},a.max=function(t,{message:r}={}){return this.refine(n=>n<=t,{message:r||`Number must be less than or equal to ${t}.`})},a.positive=function({message:t}={}){return this.refine(r=>r>0,{message:t||"Number must be positive."})},a.negative=function({message:t}={}){return this.refine(r=>r<0,{message:t||"Number must be negative."})},a.int=function({message:t}={}){return this.refine(r=>Number.isInteger(r),{message:t||"Number must be an integer."})},a.float=function({message:t}={}){return this.refine(r=>Number.isFinite(r)&&!Number.isInteger(r),{message:t||"Number must be a floating point (non-integer)."})},a.multipleOf=function(t,{message:r}={}){return this.refine(n=>n%t===0,{message:r||`Number must be a multiple of ${t}.`})},a.finite=function({message:t}={}){return this.refine(r=>Number.isFinite(r),{message:t||"Number must be finite."})};}return e});l((e,s,c)=>{if(c?.type==="array"){let a=e;a.min=function(t,{message:r}={}){return this.refine(n=>n.length>=t,{message:r||`Array must contain at least ${t} items.`})},a.max=function(t,{message:r}={}){return this.refine(n=>n.length<=t,{message:r||`Array must contain at most ${t} items.`})},a.length=function(t,{message:r}={}){return this.refine(n=>n.length===t,{message:r||`Array must contain exactly ${t} items.`})},a.nonEmpty=function({message:t}={}){return this.refine(r=>r.length>0,{message:t||"Array must not be empty."})},a.unique=function({message:t}={}){return this.refine(r=>{let n=new Set;try{return r.every(o=>{let u=JSON.stringify(o);return n.has(u)?!1:(n.add(u),!0)})}catch{return new Set(r).size===r.length}},{message:t||"Array items must be unique."})},a.sort=function(){return this.transform(t=>[...t].sort())},a.reverse=function(){return this.transform(t=>[...t].reverse())};}return e});exports.any=B;exports.array=L;exports.boolean=N;exports.cast=W;exports.coerce=q;exports.date=$;exports.enumSchema=V;exports.extend=l;exports.functionSchema=v;exports.hookOriginal=p;exports.literal=U;exports.number=x;exports.object=C;exports.preprocess=I;exports.s=G;exports.schema=G;exports.string=k;exports.union=M;
'use strict';var R={abortEarly:true};function N(e,s){if(!s)return e;let c=e?.cause?.key?`${s}.${e.cause.key}`:`${s}`;return {message:`Error parsing key "${c}": ${e.message}`,cause:{key:c}}}function E(e,s,c){if(e.errors?.length)for(let a=0;a<e.errors.length;a++)s.push(N(e.errors[a],c));}function $(e){return e?.abortEarly!==void 0?e:R}var g=e=>typeof e=="string"||e instanceof String,w=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),k=e=>e===true||e===false,j=e=>e instanceof Date&&!Number.isNaN(e.getTime()),C=e=>typeof e=="function",F=e=>Array.isArray(e),_=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function v(e,s){let c=h(_,{...s,type:"object"});return c._getDescription=()=>`object({ ${Object.entries(e).map(([t,r])=>`${t}: ${r._getDescription()}`).join(", ")} })`,p(c,"_parse",(a,t,r)=>{let n=a(t,r),{abortEarly:o}=$(r);if(n.success===false)return n;let u={},i=[];for(let m in e){let f=e[m]._parse(n.data[m],r);if(f.success)u[m]=f.data;else {if(f=f,o!==false){let S=N(f.error,m);return {success:false,error:S,errors:[S]}}E(f,i,m);}}return i.length>0?{success:false,error:i[0],errors:i}:{success:true,data:u}}),c}function y(e){return h(g,{...e,type:"string"})}function d(e){return h(w,{...e,type:"number"})}function b(e){return h(k,{...e,type:"boolean"})}function O(e){return h(j,{...e,type:"date"})}function V(e){return h(C,{...e,type:"function"})}function B(e,s){let c=n=>e.includes(n),a=n=>`Invalid ${t} value. Expected ${e.map(o=>`"${o}"`).join(" | ")}, received "${n}".`,t="enum",r=h(c,{message:a,...s,type:t});return r._getDescription=()=>`enum(${e.map(n=>`"${n}"`).join(" | ")})`,r}function L(e,s){let c=h(F,{...s,type:"array"});return c._getDescription=()=>`array(${e._getDescription()})`,p(c,"_parse",(a,t,r)=>{let n=a(t,r),{abortEarly:o}=$(r);if(n.success===false)return n;let u=[],i=[];for(let m=0;m<n.data.length;m++){let f=e._parse(n.data[m],r);if(f.success)u.push(f.data);else {if(f=f,o!==false){let S=N(f.error,m);return {success:false,error:S,errors:[S]}}E(f,i,m);}}return i.length>0?{success:false,error:i[0],errors:i}:{success:true,data:u}}),c}function M(){return h(()=>true)}function I(e,s){return p(s,"_parse",(c,a)=>(a=e(a),c(a))),s}function U(e,s){return h(r=>{for(let n=0;n<e.length;n++){let o=e[n]._parse(r);if(o.success)return o}return false},{message:r=>`Invalid union value. Expected the value to match one of the schemas:${e.map((n,o)=>` ${o+1}. ${n._getDescription()}`).join(",")} but received "${typeof r}" with value: ${_(r)?JSON.stringify(r):`"${r}"`}`,...s,type:"union"})}function q(e,s){let t=h(r=>r===e,{message:r=>s?.message?typeof s.message=="function"?s.message(r):s.message:`Expected literal value "${e}", received "${r}"`,name:s?.name,type:"literal"});return t._getDescription=()=>`literal("${e}")`,t}var W={boolean(e){let s=e?.message??(c=>`Cannot cast "${c}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return I(c=>{let a;return g(c)&&(a=c.toLowerCase()),a==="true"||a==="yes"||a==="on"||a==="1"||c===1?true:a==="false"||a==="no"||a==="off"||a==="0"||c===0?false:c},b({...e,message:s}))},number(e){let s=e?.message??(c=>`Cannot cast "${c}" to a number. Expected a numeric string or number.`);return I(c=>{if(k(c))return Number(c);if(g(c)){let a=c.trim();if(a==="")return c;let t=Number(a);if(Number.isFinite(t))return t}return c},d({...e,message:s}))},string(e){let s=e?.message??(c=>`Cannot cast "${c}" to string. Expected a string, number, or boolean.`);return I(c=>k(c)||w(c)&&Number.isFinite(c)?String(c):c,y({...e,message:s}))},date(e){let s=e?.message??(c=>`Cannot cast "${c}" to a valid date.`);return I(c=>{let a;return g(c)&&(a=c.trim()),w(c)&&Number.isFinite(c)||a?new Date(a??c):c},O({...e,message:s}))},json(e,s){let c=s?.message??(a=>`Cannot parse "${a}" as JSON.`);return p(e,"_parse",(a,t)=>{if(g(t))try{t=JSON.parse(t);}catch{let r={message:typeof c=="function"?c(t):c};return {success:false,error:r,errors:[r]}}return a(t)}),e}},D={object:v,string:y,number:d,boolean:b,date:O,function:V,enum:B,array:L,any:M,preprocess:I,union:U,literal:q,coerce:{},cast:W};function P(e){return s=>`The value "${s}" must be type of ${e} but is type of "${typeof s}".`}function p(e,s,c){let a=e[s];e[s]=(...t)=>c(a,...t);}function h(e,{type:s="any",name:c,message:a}={}){a=a||P(s);let t={name:c,message:a,type:s},r={_getName(){return c},_getType(){return s},_getDescription(){return this._getName()??this._getType()},_parse(n,o){let u=e(n);if(u===true)return {success:true,data:n};if(typeof u=="object"&&u?.success===true)return u;let i={message:typeof a=="function"?a(n):a};return {success:false,error:i,errors:[i]}},parse(n,o){let u=r._parse(n,o);if(!u.success)throw u=u,new Error(u.error.message,{cause:u.error.cause});return u.data},safeParse(n,o){return r._parse(n,o)},transform(n){return p(this,"_parse",(o,u,i)=>{let m=o(u,i);return m.success&&(m.data=n(m.data)),m}),this},optional(){return p(this,"_parse",(n,o,u)=>{let i=n(o,u);return !i.success&&o===void 0&&(i.data=void 0,i.success=true),i}),this},nullable(){return p(this,"_parse",(n,o,u)=>{let i=n(o,u);return !i.success&&o===null&&(i.data=null,i.success=true),i}),this},nullish(){return p(this,"_parse",(n,o,u)=>{let i=n(o,u);return !i.success&&o==null&&(i.success=true,i.data=o),i}),this},default(n){return p(this,"_parse",(o,u,i)=>(u===void 0&&(u=typeof n=="function"?n():n),o(u,i))),this},catch(n){return p(this,"_parse",(o,u,i)=>{let m=o(u,i);return m.success?m:{success:true,data:typeof n=="function"?n({input:u,error:m.error}):n}}),this},pipe(n){return p(this,"_parse",(o,u,i)=>{let m=o(u,i);return m.success?n._parse(m.data,i):m}),this},refine(n,{message:o,type:u}={}){return u&&(o=o||P(u),s=u),p(this,"_parse",(i,m,f)=>{let S=i(m,f),{abortEarly:J}=$(f);if(!S.success)return S;let T=n(S.data);if(T===true||typeof T=="object"&&T?.success===true)return S;let A={message:typeof o=="function"?o(m):o};return {success:false,error:A,errors:[A]}}),this}};return x.length>0?x.reduce((n,o)=>o(n,e,t)??n,r):r}var x=[];function l(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");x.push(e);}l((e,s,c)=>{if(c?.type==="string"){let a=e;a.min=function(t,{message:r}={}){return this.refine(n=>n.length>=t,{message:r||(n=>`String must be at least ${t} characters long (received ${n.length} characters: "${n}")`)})},a.max=function(t,{message:r}={}){return this.refine(n=>n.length<=t,{message:r||(n=>`String must be at most ${t} characters long (received ${n.length} characters: "${n}")`)})},a.length=function(t,{message:r}={}){return this.refine(n=>n.length===t,{message:r||(n=>`String must be exactly ${t} characters long (received ${n.length} characters: "${n}")`)})},a.nonEmpty=function({message:t}={}){return this.refine(r=>r.length>0,{message:t||"String must not be empty (received empty string)"})},a.startsWith=function(t,{message:r}={}){return this.refine(n=>n.startsWith(t),{message:r||(n=>`String must start with "${t}" (received: "${n}")`)})},a.endsWith=function(t,{message:r}={}){return this.refine(n=>n.endsWith(t),{message:r||(n=>`String must end with "${t}" (received: "${n}")`)})},a.includes=function(t,{message:r}={}){return this.refine(n=>n.includes(t),{message:r||(n=>`String must include "${t}" (received: "${n}")`)})},a.toLowerCase=function(){return this.transform(t=>t.toLowerCase())},a.toUpperCase=function(){return this.transform(t=>t.toUpperCase())},a.trim=function(){return this.transform(t=>t.trim())},a.padStart=function(t,r=" "){return this.transform(n=>n.padStart(t,r))},a.padEnd=function(t,r=" "){return this.transform(n=>n.padEnd(t,r))},a.replace=function(t,r){return this.transform(n=>n.replace(t,r))};}return e});l((e,s,c)=>{if(c?.type==="number"){let a=e;a.min=function(t,{message:r}={}){return this.refine(n=>n>=t,{message:r||`Number must be greater than or equal to ${t}.`})},a.max=function(t,{message:r}={}){return this.refine(n=>n<=t,{message:r||`Number must be less than or equal to ${t}.`})},a.positive=function({message:t}={}){return this.refine(r=>r>0,{message:t||"Number must be positive."})},a.negative=function({message:t}={}){return this.refine(r=>r<0,{message:t||"Number must be negative."})},a.int=function({message:t}={}){return this.refine(r=>Number.isInteger(r),{message:t||"Number must be an integer."})},a.float=function({message:t}={}){return this.refine(r=>Number.isFinite(r)&&!Number.isInteger(r),{message:t||"Number must be a floating point (non-integer)."})},a.multipleOf=function(t,{message:r}={}){return this.refine(n=>n%t===0,{message:r||`Number must be a multiple of ${t}.`})},a.finite=function({message:t}={}){return this.refine(r=>Number.isFinite(r),{message:t||"Number must be finite."})};}return e});l((e,s,c)=>{if(c?.type==="array"){let a=e;a.min=function(t,{message:r}={}){return this.refine(n=>n.length>=t,{message:r||`Array must contain at least ${t} items.`})},a.max=function(t,{message:r}={}){return this.refine(n=>n.length<=t,{message:r||`Array must contain at most ${t} items.`})},a.length=function(t,{message:r}={}){return this.refine(n=>n.length===t,{message:r||`Array must contain exactly ${t} items.`})},a.nonEmpty=function({message:t}={}){return this.refine(r=>r.length>0,{message:t||"Array must not be empty."})},a.unique=function({message:t}={}){return this.refine(r=>{let n=new Set;try{return r.every(o=>{let u=JSON.stringify(o);return n.has(u)?!1:(n.add(u),!0)})}catch{return new Set(r).size===r.length}},{message:t||"Array items must be unique."})},a.sort=function(){return this.transform(t=>[...t].sort())},a.reverse=function(){return this.transform(t=>[...t].reverse())};}return e});Object.assign(D.coerce,{string(e){return I(s=>String(s),y(e))},number(e){let s=e?.message??(c=>`Cannot coerce "${c}" to a valid number.`);return I(c=>Number(c),d({...e,message:s}))},boolean(e){return I(s=>!!s,b(e))},date(e){let s=e?.message??(c=>`Cannot coerce "${c}" to a valid date.`);return I(c=>new Date(c),O({...e,message:s}))}});exports.any=M;exports.array=L;exports.boolean=b;exports.cast=W;exports.date=O;exports.enumSchema=B;exports.extend=l;exports.functionSchema=V;exports.hookOriginal=p;exports.literal=q;exports.number=d;exports.object=v;exports.preprocess=I;exports.s=D;exports.schema=D;exports.string=y;exports.union=U;
import './string.mjs';
import './number.mjs';
import './array.mjs';
export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, coerce, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.mjs';
import './coerce.mjs';
export { ArraySchemaInterface, BooleanSchemaInterface, CoerceInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.mjs';
import './string.js';
import './number.js';
import './array.js';
export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, coerce, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.js';
import './coerce.js';
export { ArraySchemaInterface, BooleanSchemaInterface, CoerceInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.js';

@@ -1,1 +0,1 @@

import'./chunk-5XWCCG75.mjs';import'./chunk-NCRS6NBV.mjs';import'./chunk-NRGPACGD.mjs';export{i as any,h as array,d as boolean,n as cast,m as coerce,e as date,g as enumSchema,q as extend,f as functionSchema,p as hookOriginal,l as literal,c as number,a as object,j as preprocess,o as s,o as schema,b as string,k as union}from'./chunk-37YJYCTR.mjs';
import'./chunk-AQFELD23.mjs';import'./chunk-SR7R5QYC.mjs';import'./chunk-HVQY2UKM.mjs';import'./chunk-7VTVE334.mjs';export{i as any,h as array,d as boolean,m as cast,e as date,g as enumSchema,p as extend,f as functionSchema,o as hookOriginal,l as literal,c as number,a as object,j as preprocess,n as s,n as schema,b as string,k as union}from'./chunk-AKXLQP64.mjs';

@@ -1,1 +0,1 @@

'use strict';var N={abortEarly:true};function T(e,t){if(!t)return e;let n=e?.cause?.key?`${t}.${e.cause.key}`:`${t}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function _(e,t,n){if(e.errors?.length)for(let a=0;a<e.errors.length;a++)t.push(T(e.errors[a],n));}function O(e){return e?.abortEarly!==void 0?e:N}var S=e=>typeof e=="string"||e instanceof String,y=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),g=e=>e===true||e===false,R=e=>e instanceof Date&&!Number.isNaN(e.getTime()),A=e=>typeof e=="function",j=e=>Array.isArray(e),$=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function F(e,t){let n=h($,{...t,type:"object"});return n._getDescription=()=>`object({ ${Object.entries(e).map(([f,o])=>`${f}: ${o._getDescription()}`).join(", ")} })`,m(n,"_parse",(a,f,o)=>{let r=a(f,o),{abortEarly:c}=O(o);if(r.success===false)return r;let u={},s=[];for(let i in e){let p=e[i]._parse(r.data[i],o);if(p.success)u[i]=p.data;else {if(p=p,c!==false){let I=T(p.error,i);return {success:false,error:I,errors:[I]}}_(p,s,i);}}return s.length>0?{success:false,error:s[0],errors:s}:{success:true,data:u}}),n}function k(e){return h(S,{...e,type:"string"})}function w(e){return h(y,{...e,type:"number"})}function x(e){return h(g,{...e,type:"boolean"})}function P(e){return h(R,{...e,type:"date"})}function C(e){return h(A,{...e,type:"function"})}function V(e,t){let n=r=>e.includes(r),a=r=>`Invalid ${f} value. Expected ${e.map(c=>`"${c}"`).join(" | ")}, received "${r}".`,f="enum",o=h(n,{message:a,...t,type:f});return o._getDescription=()=>`enum(${e.map(r=>`"${r}"`).join(" | ")})`,o}function B(e,t){let n=h(j,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,m(n,"_parse",(a,f,o)=>{let r=a(f,o),{abortEarly:c}=O(o);if(r.success===false)return r;let u=[],s=[];for(let i=0;i<r.data.length;i++){let p=e._parse(r.data[i],o);if(p.success)u.push(p.data);else {if(p=p,c!==false){let I=T(p.error,i);return {success:false,error:I,errors:[I]}}_(p,s,i);}}return s.length>0?{success:false,error:s[0],errors:s}:{success:true,data:u}}),n}function L(){return h(()=>true)}function l(e,t){return m(t,"_parse",(n,a)=>(a=e(a),n(a))),t}function M(e,t){return h(o=>{for(let r=0;r<e.length;r++){let c=e[r]._parse(o);if(c.success)return c}return false},{message:o=>`Invalid union value. Expected the value to match one of the schemas:${e.map((r,c)=>` ${c+1}. ${r._getDescription()}`).join(",")} but received "${typeof o}" with value: ${$(o)?JSON.stringify(o):`"${o}"`}`,...t,type:"union"})}function U(e,t){let f=h(o=>o===e,{message:o=>t?.message?typeof t.message=="function"?t.message(o):t.message:`Expected literal value "${e}", received "${o}"`,name:t?.name,type:"literal"});return f._getDescription=()=>`literal("${e}")`,f}var J={string(e){return l(t=>String(t),k(e))},number(e){let t=e?.message??(n=>`Cannot coerce "${n}" to a valid number.`);return l(n=>Number(n),w({...e,message:t}))},boolean(e){return l(t=>!!t,x(e))},date(e){let t=e?.message??(n=>`Cannot coerce "${n}" to a valid date.`);return l(n=>new Date(n),P({...e,message:t}))}},q={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return l(n=>{let a;return S(n)&&(a=n.toLowerCase()),a==="true"||a==="yes"||a==="on"||a==="1"||n===1?true:a==="false"||a==="no"||a==="off"||a==="0"||n===0?false:n},x({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return l(n=>{if(g(n))return Number(n);if(S(n)){let a=n.trim();if(a==="")return n;let f=Number(a);if(Number.isFinite(f))return f}return n},w({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return l(n=>g(n)||y(n)&&Number.isFinite(n)?String(n):n,k({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return l(n=>{let a;return S(n)&&(a=n.trim()),y(n)&&Number.isFinite(n)||a?new Date(a??n):n},P({...e,message:t}))},json(e,t){let n=t?.message??(a=>`Cannot parse "${a}" as JSON.`);return m(e,"_parse",(a,f)=>{if(S(f))try{f=JSON.parse(f);}catch{let o={message:typeof n=="function"?n(f):n};return {success:false,error:o,errors:[o]}}return a(f)}),e}},H={object:F,string:k,number:w,boolean:x,date:P,function:C,enum:V,array:B,any:L,preprocess:l,union:M,literal:U,coerce:J,cast:q};function D(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function m(e,t,n){let a=e[t];e[t]=(...f)=>n(a,...f);}function h(e,{type:t="any",name:n,message:a}={}){a=a||D(t);let f={name:n,message:a,type:t},o={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(r,c){let u=e(r);if(u===true)return {success:true,data:r};if(typeof u=="object"&&u?.success===true)return u;let s={message:typeof a=="function"?a(r):a};return {success:false,error:s,errors:[s]}},parse(r,c){let u=o._parse(r,c);if(!u.success)throw u=u,new Error(u.error.message,{cause:u.error.cause});return u.data},safeParse(r,c){return o._parse(r,c)},transform(r){return m(this,"_parse",(c,u,s)=>{let i=c(u,s);return i.success&&(i.data=r(i.data)),i}),this},optional(){return m(this,"_parse",(r,c,u)=>{let s=r(c,u);return !s.success&&c===void 0&&(s.data=void 0,s.success=true),s}),this},nullable(){return m(this,"_parse",(r,c,u)=>{let s=r(c,u);return !s.success&&c===null&&(s.data=null,s.success=true),s}),this},nullish(){return m(this,"_parse",(r,c,u)=>{let s=r(c,u);return !s.success&&c==null&&(s.success=true,s.data=c),s}),this},default(r){return m(this,"_parse",(c,u,s)=>(u===void 0&&(u=typeof r=="function"?r():r),c(u,s))),this},catch(r){return m(this,"_parse",(c,u,s)=>{let i=c(u,s);return i.success?i:{success:true,data:typeof r=="function"?r({input:u,error:i.error}):r}}),this},pipe(r){return m(this,"_parse",(c,u,s)=>{let i=c(u,s);return i.success?r._parse(i.data,s):i}),this},refine(r,{message:c,type:u}={}){return u&&(c=c||D(u),t=u),m(this,"_parse",(s,i,p)=>{let I=s(i,p),{abortEarly:z}=O(p);if(!I.success)return I;let d=r(I.data);if(d===true||typeof d=="object"&&d?.success===true)return I;let E={message:typeof c=="function"?c(i):c};return {success:false,error:E,errors:[E]}}),this}};return b.length>0?b.reduce((r,c)=>c(r,e,f)??r,o):o}var b=[];function Q(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");b.push(e);}exports.any=L;exports.array=B;exports.boolean=x;exports.cast=q;exports.coerce=J;exports.date=P;exports.enumSchema=V;exports.extend=Q;exports.functionSchema=C;exports.hookOriginal=m;exports.literal=U;exports.number=w;exports.object=F;exports.preprocess=l;exports.s=H;exports.schema=H;exports.string=k;exports.union=M;
'use strict';var N={abortEarly:true};function T(e,a){if(!a)return e;let n=e?.cause?.key?`${a}.${e.cause.key}`:`${a}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function w(e,a,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)a.push(T(e.errors[r],n));}function O(e){return e?.abortEarly!==void 0?e:N}var l=e=>typeof e=="string"||e instanceof String,y=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),g=e=>e===true||e===false,R=e=>e instanceof Date&&!Number.isNaN(e.getTime()),A=e=>typeof e=="function",j=e=>Array.isArray(e),P=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function F(e,a){let n=h(P,{...a,type:"object"});return n._getDescription=()=>`object({ ${Object.entries(e).map(([p,o])=>`${p}: ${o._getDescription()}`).join(", ")} })`,m(n,"_parse",(r,p,o)=>{let t=r(p,o),{abortEarly:s}=O(o);if(t.success===false)return t;let u={},c=[];for(let i in e){let f=e[i]._parse(t.data[i],o);if(f.success)u[i]=f.data;else {if(f=f,s!==false){let I=T(f.error,i);return {success:false,error:I,errors:[I]}}w(f,c,i);}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:u}}),n}function E(e){return h(l,{...e,type:"string"})}function _(e){return h(y,{...e,type:"number"})}function D(e){return h(g,{...e,type:"boolean"})}function $(e){return h(R,{...e,type:"date"})}function C(e){return h(A,{...e,type:"function"})}function V(e,a){let n=t=>e.includes(t),r=t=>`Invalid ${p} value. Expected ${e.map(s=>`"${s}"`).join(" | ")}, received "${t}".`,p="enum",o=h(n,{message:r,...a,type:p});return o._getDescription=()=>`enum(${e.map(t=>`"${t}"`).join(" | ")})`,o}function L(e,a){let n=h(j,{...a,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,m(n,"_parse",(r,p,o)=>{let t=r(p,o),{abortEarly:s}=O(o);if(t.success===false)return t;let u=[],c=[];for(let i=0;i<t.data.length;i++){let f=e._parse(t.data[i],o);if(f.success)u.push(f.data);else {if(f=f,s!==false){let I=T(f.error,i);return {success:false,error:I,errors:[I]}}w(f,c,i);}}return c.length>0?{success:false,error:c[0],errors:c}:{success:true,data:u}}),n}function M(){return h(()=>true)}function d(e,a){return m(a,"_parse",(n,r)=>(r=e(r),n(r))),a}function B(e,a){return h(o=>{for(let t=0;t<e.length;t++){let s=e[t]._parse(o);if(s.success)return s}return false},{message:o=>`Invalid union value. Expected the value to match one of the schemas:${e.map((t,s)=>` ${s+1}. ${t._getDescription()}`).join(",")} but received "${typeof o}" with value: ${P(o)?JSON.stringify(o):`"${o}"`}`,...a,type:"union"})}function U(e,a){let p=h(o=>o===e,{message:o=>a?.message?typeof a.message=="function"?a.message(o):a.message:`Expected literal value "${e}", received "${o}"`,name:a?.name,type:"literal"});return p._getDescription=()=>`literal("${e}")`,p}var J={boolean(e){let a=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return d(n=>{let r;return l(n)&&(r=n.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||n===1?true:r==="false"||r==="no"||r==="off"||r==="0"||n===0?false:n},D({...e,message:a}))},number(e){let a=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return d(n=>{if(g(n))return Number(n);if(l(n)){let r=n.trim();if(r==="")return n;let p=Number(r);if(Number.isFinite(p))return p}return n},_({...e,message:a}))},string(e){let a=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return d(n=>g(n)||y(n)&&Number.isFinite(n)?String(n):n,E({...e,message:a}))},date(e){let a=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return d(n=>{let r;return l(n)&&(r=n.trim()),y(n)&&Number.isFinite(n)||r?new Date(r??n):n},$({...e,message:a}))},json(e,a){let n=a?.message??(r=>`Cannot parse "${r}" as JSON.`);return m(e,"_parse",(r,p)=>{if(l(p))try{p=JSON.parse(p);}catch{let o={message:typeof n=="function"?n(p):n};return {success:false,error:o,errors:[o]}}return r(p)}),e}},G={object:F,string:E,number:_,boolean:D,date:$,function:C,enum:V,array:L,any:M,preprocess:d,union:B,literal:U,coerce:{},cast:J};function x(e){return a=>`The value "${a}" must be type of ${e} but is type of "${typeof a}".`}function m(e,a,n){let r=e[a];e[a]=(...p)=>n(r,...p);}function h(e,{type:a="any",name:n,message:r}={}){r=r||x(a);let p={name:n,message:r,type:a},o={_getName(){return n},_getType(){return a},_getDescription(){return this._getName()??this._getType()},_parse(t,s){let u=e(t);if(u===true)return {success:true,data:t};if(typeof u=="object"&&u?.success===true)return u;let c={message:typeof r=="function"?r(t):r};return {success:false,error:c,errors:[c]}},parse(t,s){let u=o._parse(t,s);if(!u.success)throw u=u,new Error(u.error.message,{cause:u.error.cause});return u.data},safeParse(t,s){return o._parse(t,s)},transform(t){return m(this,"_parse",(s,u,c)=>{let i=s(u,c);return i.success&&(i.data=t(i.data)),i}),this},optional(){return m(this,"_parse",(t,s,u)=>{let c=t(s,u);return !c.success&&s===void 0&&(c.data=void 0,c.success=true),c}),this},nullable(){return m(this,"_parse",(t,s,u)=>{let c=t(s,u);return !c.success&&s===null&&(c.data=null,c.success=true),c}),this},nullish(){return m(this,"_parse",(t,s,u)=>{let c=t(s,u);return !c.success&&s==null&&(c.success=true,c.data=s),c}),this},default(t){return m(this,"_parse",(s,u,c)=>(u===void 0&&(u=typeof t=="function"?t():t),s(u,c))),this},catch(t){return m(this,"_parse",(s,u,c)=>{let i=s(u,c);return i.success?i:{success:true,data:typeof t=="function"?t({input:u,error:i.error}):t}}),this},pipe(t){return m(this,"_parse",(s,u,c)=>{let i=s(u,c);return i.success?t._parse(i.data,c):i}),this},refine(t,{message:s,type:u}={}){return u&&(s=s||x(u),a=u),m(this,"_parse",(c,i,f)=>{let I=c(i,f),{abortEarly:q}=O(f);if(!I.success)return I;let S=t(I.data);if(S===true||typeof S=="object"&&S?.success===true)return I;let k={message:typeof s=="function"?s(i):s};return {success:false,error:k,errors:[k]}}),this}};return b.length>0?b.reduce((t,s)=>s(t,e,p)??t,o):o}var b=[];function H(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");b.push(e);}exports.any=M;exports.array=L;exports.boolean=D;exports.cast=J;exports.date=$;exports.enumSchema=V;exports.extend=H;exports.functionSchema=C;exports.hookOriginal=m;exports.literal=U;exports.number=_;exports.object=F;exports.preprocess=d;exports.s=G;exports.schema=G;exports.string=E;exports.union=B;

@@ -58,2 +58,4 @@ type ErrorStructure = {

}
interface CoerceInterface {
}
interface ObjectSchemaInterface<T extends Record<string, SchemaType>> extends SchemaInterface<{

@@ -91,8 +93,2 @@ [Property in keyof T]: ReturnType<T[Property]['parse']>;

declare function literal<T extends string | number | boolean>(value: T, options?: SchemaInterfaceOptions): LiteralSchemaInterface<T>;
declare const coerce: {
string(options?: SchemaInterfaceOptions): StringSchemaInterface;
number(options?: SchemaInterfaceOptions): NumberSchemaInterface;
boolean(options?: SchemaInterfaceOptions): BooleanSchemaInterface;
date(options?: SchemaInterfaceOptions): DateSchemaInterface;
};
declare const cast: {

@@ -118,8 +114,3 @@ boolean(options?: SchemaInterfaceOptions): BooleanSchemaInterface;

literal: typeof literal;
coerce: {
string(options?: SchemaInterfaceOptions): StringSchemaInterface;
number(options?: SchemaInterfaceOptions): NumberSchemaInterface;
boolean(options?: SchemaInterfaceOptions): BooleanSchemaInterface;
date(options?: SchemaInterfaceOptions): DateSchemaInterface;
};
coerce: CoerceInterface;
cast: {

@@ -192,2 +183,2 @@ boolean(options?: SchemaInterfaceOptions): BooleanSchemaInterface;

export { type ArraySchemaInterface, type BooleanSchemaInterface, type DateSchemaInterface, type EnumSchemaInterface, type ErrorStructure, type ExtenderType, type FunctionSchemaInterface, type Infer, type Invalid, type LiteralSchemaInterface, type NumberSchemaInterface, type ObjectSchemaInterface, type SchemaInterface, type SchemaInterfaceOptions, type SchemaType, type StringSchemaInterface, type UnionSchemaInterface, type Valid, any, array, boolean, cast, coerce, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union };
export { type ArraySchemaInterface, type BooleanSchemaInterface, type CoerceInterface, type DateSchemaInterface, type EnumSchemaInterface, type ErrorStructure, type ExtenderType, type FunctionSchemaInterface, type Infer, type Invalid, type LiteralSchemaInterface, type NumberSchemaInterface, type ObjectSchemaInterface, type SchemaInterface, type SchemaInterfaceOptions, type SchemaType, type StringSchemaInterface, type UnionSchemaInterface, type Valid, any, array, boolean, cast, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union };

@@ -58,2 +58,4 @@ type ErrorStructure = {

}
interface CoerceInterface {
}
interface ObjectSchemaInterface<T extends Record<string, SchemaType>> extends SchemaInterface<{

@@ -91,8 +93,2 @@ [Property in keyof T]: ReturnType<T[Property]['parse']>;

declare function literal<T extends string | number | boolean>(value: T, options?: SchemaInterfaceOptions): LiteralSchemaInterface<T>;
declare const coerce: {
string(options?: SchemaInterfaceOptions): StringSchemaInterface;
number(options?: SchemaInterfaceOptions): NumberSchemaInterface;
boolean(options?: SchemaInterfaceOptions): BooleanSchemaInterface;
date(options?: SchemaInterfaceOptions): DateSchemaInterface;
};
declare const cast: {

@@ -118,8 +114,3 @@ boolean(options?: SchemaInterfaceOptions): BooleanSchemaInterface;

literal: typeof literal;
coerce: {
string(options?: SchemaInterfaceOptions): StringSchemaInterface;
number(options?: SchemaInterfaceOptions): NumberSchemaInterface;
boolean(options?: SchemaInterfaceOptions): BooleanSchemaInterface;
date(options?: SchemaInterfaceOptions): DateSchemaInterface;
};
coerce: CoerceInterface;
cast: {

@@ -192,2 +183,2 @@ boolean(options?: SchemaInterfaceOptions): BooleanSchemaInterface;

export { type ArraySchemaInterface, type BooleanSchemaInterface, type DateSchemaInterface, type EnumSchemaInterface, type ErrorStructure, type ExtenderType, type FunctionSchemaInterface, type Infer, type Invalid, type LiteralSchemaInterface, type NumberSchemaInterface, type ObjectSchemaInterface, type SchemaInterface, type SchemaInterfaceOptions, type SchemaType, type StringSchemaInterface, type UnionSchemaInterface, type Valid, any, array, boolean, cast, coerce, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union };
export { type ArraySchemaInterface, type BooleanSchemaInterface, type CoerceInterface, type DateSchemaInterface, type EnumSchemaInterface, type ErrorStructure, type ExtenderType, type FunctionSchemaInterface, type Infer, type Invalid, type LiteralSchemaInterface, type NumberSchemaInterface, type ObjectSchemaInterface, type SchemaInterface, type SchemaInterfaceOptions, type SchemaType, type StringSchemaInterface, type UnionSchemaInterface, type Valid, any, array, boolean, cast, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union };

@@ -1,1 +0,1 @@

export{i as any,h as array,d as boolean,n as cast,m as coerce,e as date,g as enumSchema,q as extend,f as functionSchema,p as hookOriginal,l as literal,c as number,a as object,j as preprocess,o as s,o as schema,b as string,k as union}from'./chunk-37YJYCTR.mjs';
export{i as any,h as array,d as boolean,m as cast,e as date,g as enumSchema,p as extend,f as functionSchema,o as hookOriginal,l as literal,c as number,a as object,j as preprocess,n as s,n as schema,b as string,k as union}from'./chunk-AKXLQP64.mjs';

@@ -1,1 +0,1 @@

'use strict';var R={abortEarly:true};function O(e,a){if(!a)return e;let n=e?.cause?.key?`${a}.${e.cause.key}`:`${a}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function $(e,a,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)a.push(O(e.errors[r],n));}function T(e){return e?.abortEarly!==void 0?e:R}var l=e=>typeof e=="string"||e instanceof String,y=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),b=e=>e===true||e===false,A=e=>e instanceof Date&&!Number.isNaN(e.getTime()),j=e=>typeof e=="function",F=e=>Array.isArray(e),_=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function C(e,a){let n=h(_,{...a,type:"object"});return n._getDescription=()=>`object({ ${Object.entries(e).map(([s,c])=>`${s}: ${c._getDescription()}`).join(", ")} })`,p(n,"_parse",(r,s,c)=>{let t=r(s,c),{abortEarly:u}=T(c);if(t.success===false)return t;let i={},o=[];for(let f in e){let m=e[f]._parse(t.data[f],c);if(m.success)i[f]=m.data;else {if(m=m,u!==false){let I=O(m.error,f);return {success:false,error:I,errors:[I]}}$(m,o,f);}}return o.length>0?{success:false,error:o[0],errors:o}:{success:true,data:i}}),n}function k(e){return h(l,{...e,type:"string"})}function w(e){return h(y,{...e,type:"number"})}function x(e){return h(b,{...e,type:"boolean"})}function N(e){return h(A,{...e,type:"date"})}function V(e){return h(j,{...e,type:"function"})}function B(e,a){let n=t=>e.includes(t),r=t=>`Invalid ${s} value. Expected ${e.map(u=>`"${u}"`).join(" | ")}, received "${t}".`,s="enum",c=h(n,{message:r,...a,type:s});return c._getDescription=()=>`enum(${e.map(t=>`"${t}"`).join(" | ")})`,c}function L(e,a){let n=h(F,{...a,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,p(n,"_parse",(r,s,c)=>{let t=r(s,c),{abortEarly:u}=T(c);if(t.success===false)return t;let i=[],o=[];for(let f=0;f<t.data.length;f++){let m=e._parse(t.data[f],c);if(m.success)i.push(m.data);else {if(m=m,u!==false){let I=O(m.error,f);return {success:false,error:I,errors:[I]}}$(m,o,f);}}return o.length>0?{success:false,error:o[0],errors:o}:{success:true,data:i}}),n}function M(){return h(()=>true)}function S(e,a){return p(a,"_parse",(n,r)=>(r=e(r),n(r))),a}function v(e,a){return h(c=>{for(let t=0;t<e.length;t++){let u=e[t]._parse(c);if(u.success)return u}return false},{message:c=>`Invalid union value. Expected the value to match one of the schemas:${e.map((t,u)=>` ${u+1}. ${t._getDescription()}`).join(",")} but received "${typeof c}" with value: ${_(c)?JSON.stringify(c):`"${c}"`}`,...a,type:"union"})}function U(e,a){let s=h(c=>c===e,{message:c=>a?.message?typeof a.message=="function"?a.message(c):a.message:`Expected literal value "${e}", received "${c}"`,name:a?.name,type:"literal"});return s._getDescription=()=>`literal("${e}")`,s}var q={string(e){return S(a=>String(a),k(e))},number(e){let a=e?.message??(n=>`Cannot coerce "${n}" to a valid number.`);return S(n=>Number(n),w({...e,message:a}))},boolean(e){return S(a=>!!a,x(e))},date(e){let a=e?.message??(n=>`Cannot coerce "${n}" to a valid date.`);return S(n=>new Date(n),N({...e,message:a}))}},J={boolean(e){let a=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return S(n=>{let r;return l(n)&&(r=n.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||n===1?true:r==="false"||r==="no"||r==="off"||r==="0"||n===0?false:n},x({...e,message:a}))},number(e){let a=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return S(n=>{if(b(n))return Number(n);if(l(n)){let r=n.trim();if(r==="")return n;let s=Number(r);if(Number.isFinite(s))return s}return n},w({...e,message:a}))},string(e){let a=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return S(n=>b(n)||y(n)&&Number.isFinite(n)?String(n):n,k({...e,message:a}))},date(e){let a=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return S(n=>{let r;return l(n)&&(r=n.trim()),y(n)&&Number.isFinite(n)||r?new Date(r??n):n},N({...e,message:a}))},json(e,a){let n=a?.message??(r=>`Cannot parse "${r}" as JSON.`);return p(e,"_parse",(r,s)=>{if(l(s))try{s=JSON.parse(s);}catch{let c={message:typeof n=="function"?n(s):n};return {success:false,error:c,errors:[c]}}return r(s)}),e}},H={object:C,string:k,number:w,boolean:x,date:N,function:V,enum:B,array:L,any:M,preprocess:S,union:v,literal:U,coerce:q,cast:J};function E(e){return a=>`The value "${a}" must be type of ${e} but is type of "${typeof a}".`}function p(e,a,n){let r=e[a];e[a]=(...s)=>n(r,...s);}function h(e,{type:a="any",name:n,message:r}={}){r=r||E(a);let s={name:n,message:r,type:a},c={_getName(){return n},_getType(){return a},_getDescription(){return this._getName()??this._getType()},_parse(t,u){let i=e(t);if(i===true)return {success:true,data:t};if(typeof i=="object"&&i?.success===true)return i;let o={message:typeof r=="function"?r(t):r};return {success:false,error:o,errors:[o]}},parse(t,u){let i=c._parse(t,u);if(!i.success)throw i=i,new Error(i.error.message,{cause:i.error.cause});return i.data},safeParse(t,u){return c._parse(t,u)},transform(t){return p(this,"_parse",(u,i,o)=>{let f=u(i,o);return f.success&&(f.data=t(f.data)),f}),this},optional(){return p(this,"_parse",(t,u,i)=>{let o=t(u,i);return !o.success&&u===void 0&&(o.data=void 0,o.success=true),o}),this},nullable(){return p(this,"_parse",(t,u,i)=>{let o=t(u,i);return !o.success&&u===null&&(o.data=null,o.success=true),o}),this},nullish(){return p(this,"_parse",(t,u,i)=>{let o=t(u,i);return !o.success&&u==null&&(o.success=true,o.data=u),o}),this},default(t){return p(this,"_parse",(u,i,o)=>(i===void 0&&(i=typeof t=="function"?t():t),u(i,o))),this},catch(t){return p(this,"_parse",(u,i,o)=>{let f=u(i,o);return f.success?f:{success:true,data:typeof t=="function"?t({input:i,error:f.error}):t}}),this},pipe(t){return p(this,"_parse",(u,i,o)=>{let f=u(i,o);return f.success?t._parse(f.data,o):f}),this},refine(t,{message:u,type:i}={}){return i&&(u=u||E(i),a=i),p(this,"_parse",(o,f,m)=>{let I=o(f,m),{abortEarly:z}=T(m);if(!I.success)return I;let d=t(I.data);if(d===true||typeof d=="object"&&d?.success===true)return I;let P={message:typeof u=="function"?u(f):u};return {success:false,error:P,errors:[P]}}),this}};return g.length>0?g.reduce((t,u)=>u(t,e,s)??t,c):c}var g=[];function D(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");g.push(e);}D((e,a,n)=>{if(n?.type==="number"){let r=e;r.min=function(s,{message:c}={}){return this.refine(t=>t>=s,{message:c||`Number must be greater than or equal to ${s}.`})},r.max=function(s,{message:c}={}){return this.refine(t=>t<=s,{message:c||`Number must be less than or equal to ${s}.`})},r.positive=function({message:s}={}){return this.refine(c=>c>0,{message:s||"Number must be positive."})},r.negative=function({message:s}={}){return this.refine(c=>c<0,{message:s||"Number must be negative."})},r.int=function({message:s}={}){return this.refine(c=>Number.isInteger(c),{message:s||"Number must be an integer."})},r.float=function({message:s}={}){return this.refine(c=>Number.isFinite(c)&&!Number.isInteger(c),{message:s||"Number must be a floating point (non-integer)."})},r.multipleOf=function(s,{message:c}={}){return this.refine(t=>t%s===0,{message:c||`Number must be a multiple of ${s}.`})},r.finite=function({message:s}={}){return this.refine(c=>Number.isFinite(c),{message:s||"Number must be finite."})};}return e});exports.any=M;exports.array=L;exports.boolean=x;exports.cast=J;exports.coerce=q;exports.date=N;exports.enumSchema=B;exports.extend=D;exports.functionSchema=V;exports.hookOriginal=p;exports.literal=U;exports.number=w;exports.object=C;exports.preprocess=S;exports.s=H;exports.schema=H;exports.string=k;exports.union=v;
'use strict';var R={abortEarly:true};function O(e,c){if(!c)return e;let n=e?.cause?.key?`${c}.${e.cause.key}`:`${c}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function x(e,c,n){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)c.push(O(e.errors[r],n));}function T(e){return e?.abortEarly!==void 0?e:R}var S=e=>typeof e=="string"||e instanceof String,y=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),b=e=>e===true||e===false,A=e=>e instanceof Date&&!Number.isNaN(e.getTime()),j=e=>typeof e=="function",F=e=>Array.isArray(e),N=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function C(e,c){let n=h(N,{...c,type:"object"});return n._getDescription=()=>`object({ ${Object.entries(e).map(([s,a])=>`${s}: ${a._getDescription()}`).join(", ")} })`,p(n,"_parse",(r,s,a)=>{let t=r(s,a),{abortEarly:u}=T(a);if(t.success===false)return t;let i={},o=[];for(let f in e){let m=e[f]._parse(t.data[f],a);if(m.success)i[f]=m.data;else {if(m=m,u!==false){let I=O(m.error,f);return {success:false,error:I,errors:[I]}}x(m,o,f);}}return o.length>0?{success:false,error:o[0],errors:o}:{success:true,data:i}}),n}function P(e){return h(S,{...e,type:"string"})}function E(e){return h(y,{...e,type:"number"})}function _(e){return h(b,{...e,type:"boolean"})}function $(e){return h(A,{...e,type:"date"})}function V(e){return h(j,{...e,type:"function"})}function L(e,c){let n=t=>e.includes(t),r=t=>`Invalid ${s} value. Expected ${e.map(u=>`"${u}"`).join(" | ")}, received "${t}".`,s="enum",a=h(n,{message:r,...c,type:s});return a._getDescription=()=>`enum(${e.map(t=>`"${t}"`).join(" | ")})`,a}function M(e,c){let n=h(F,{...c,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,p(n,"_parse",(r,s,a)=>{let t=r(s,a),{abortEarly:u}=T(a);if(t.success===false)return t;let i=[],o=[];for(let f=0;f<t.data.length;f++){let m=e._parse(t.data[f],a);if(m.success)i.push(m.data);else {if(m=m,u!==false){let I=O(m.error,f);return {success:false,error:I,errors:[I]}}x(m,o,f);}}return o.length>0?{success:false,error:o[0],errors:o}:{success:true,data:i}}),n}function B(){return h(()=>true)}function l(e,c){return p(c,"_parse",(n,r)=>(r=e(r),n(r))),c}function U(e,c){return h(a=>{for(let t=0;t<e.length;t++){let u=e[t]._parse(a);if(u.success)return u}return false},{message:a=>`Invalid union value. Expected the value to match one of the schemas:${e.map((t,u)=>` ${u+1}. ${t._getDescription()}`).join(",")} but received "${typeof a}" with value: ${N(a)?JSON.stringify(a):`"${a}"`}`,...c,type:"union"})}function q(e,c){let s=h(a=>a===e,{message:a=>c?.message?typeof c.message=="function"?c.message(a):c.message:`Expected literal value "${e}", received "${a}"`,name:c?.name,type:"literal"});return s._getDescription=()=>`literal("${e}")`,s}var v={boolean(e){let c=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return l(n=>{let r;return S(n)&&(r=n.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||n===1?true:r==="false"||r==="no"||r==="off"||r==="0"||n===0?false:n},_({...e,message:c}))},number(e){let c=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return l(n=>{if(b(n))return Number(n);if(S(n)){let r=n.trim();if(r==="")return n;let s=Number(r);if(Number.isFinite(s))return s}return n},E({...e,message:c}))},string(e){let c=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return l(n=>b(n)||y(n)&&Number.isFinite(n)?String(n):n,P({...e,message:c}))},date(e){let c=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return l(n=>{let r;return S(n)&&(r=n.trim()),y(n)&&Number.isFinite(n)||r?new Date(r??n):n},$({...e,message:c}))},json(e,c){let n=c?.message??(r=>`Cannot parse "${r}" as JSON.`);return p(e,"_parse",(r,s)=>{if(S(s))try{s=JSON.parse(s);}catch{let a={message:typeof n=="function"?n(s):n};return {success:false,error:a,errors:[a]}}return r(s)}),e}},G={object:C,string:P,number:E,boolean:_,date:$,function:V,enum:L,array:M,any:B,preprocess:l,union:U,literal:q,coerce:{},cast:v};function w(e){return c=>`The value "${c}" must be type of ${e} but is type of "${typeof c}".`}function p(e,c,n){let r=e[c];e[c]=(...s)=>n(r,...s);}function h(e,{type:c="any",name:n,message:r}={}){r=r||w(c);let s={name:n,message:r,type:c},a={_getName(){return n},_getType(){return c},_getDescription(){return this._getName()??this._getType()},_parse(t,u){let i=e(t);if(i===true)return {success:true,data:t};if(typeof i=="object"&&i?.success===true)return i;let o={message:typeof r=="function"?r(t):r};return {success:false,error:o,errors:[o]}},parse(t,u){let i=a._parse(t,u);if(!i.success)throw i=i,new Error(i.error.message,{cause:i.error.cause});return i.data},safeParse(t,u){return a._parse(t,u)},transform(t){return p(this,"_parse",(u,i,o)=>{let f=u(i,o);return f.success&&(f.data=t(f.data)),f}),this},optional(){return p(this,"_parse",(t,u,i)=>{let o=t(u,i);return !o.success&&u===void 0&&(o.data=void 0,o.success=true),o}),this},nullable(){return p(this,"_parse",(t,u,i)=>{let o=t(u,i);return !o.success&&u===null&&(o.data=null,o.success=true),o}),this},nullish(){return p(this,"_parse",(t,u,i)=>{let o=t(u,i);return !o.success&&u==null&&(o.success=true,o.data=u),o}),this},default(t){return p(this,"_parse",(u,i,o)=>(i===void 0&&(i=typeof t=="function"?t():t),u(i,o))),this},catch(t){return p(this,"_parse",(u,i,o)=>{let f=u(i,o);return f.success?f:{success:true,data:typeof t=="function"?t({input:i,error:f.error}):t}}),this},pipe(t){return p(this,"_parse",(u,i,o)=>{let f=u(i,o);return f.success?t._parse(f.data,o):f}),this},refine(t,{message:u,type:i}={}){return i&&(u=u||w(i),c=i),p(this,"_parse",(o,f,m)=>{let I=o(f,m),{abortEarly:J}=T(m);if(!I.success)return I;let d=t(I.data);if(d===true||typeof d=="object"&&d?.success===true)return I;let k={message:typeof u=="function"?u(f):u};return {success:false,error:k,errors:[k]}}),this}};return g.length>0?g.reduce((t,u)=>u(t,e,s)??t,a):a}var g=[];function D(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");g.push(e);}D((e,c,n)=>{if(n?.type==="number"){let r=e;r.min=function(s,{message:a}={}){return this.refine(t=>t>=s,{message:a||`Number must be greater than or equal to ${s}.`})},r.max=function(s,{message:a}={}){return this.refine(t=>t<=s,{message:a||`Number must be less than or equal to ${s}.`})},r.positive=function({message:s}={}){return this.refine(a=>a>0,{message:s||"Number must be positive."})},r.negative=function({message:s}={}){return this.refine(a=>a<0,{message:s||"Number must be negative."})},r.int=function({message:s}={}){return this.refine(a=>Number.isInteger(a),{message:s||"Number must be an integer."})},r.float=function({message:s}={}){return this.refine(a=>Number.isFinite(a)&&!Number.isInteger(a),{message:s||"Number must be a floating point (non-integer)."})},r.multipleOf=function(s,{message:a}={}){return this.refine(t=>t%s===0,{message:a||`Number must be a multiple of ${s}.`})},r.finite=function({message:s}={}){return this.refine(a=>Number.isFinite(a),{message:s||"Number must be finite."})};}return e});exports.any=B;exports.array=M;exports.boolean=_;exports.cast=v;exports.date=$;exports.enumSchema=L;exports.extend=D;exports.functionSchema=V;exports.hookOriginal=p;exports.literal=q;exports.number=E;exports.object=C;exports.preprocess=l;exports.s=G;exports.schema=G;exports.string=P;exports.union=U;

@@ -1,2 +0,2 @@

export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, coerce, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.mjs';
export { ArraySchemaInterface, BooleanSchemaInterface, CoerceInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.mjs';

@@ -3,0 +3,0 @@ declare module './index.ts' {

@@ -1,2 +0,2 @@

export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, coerce, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.js';
export { ArraySchemaInterface, BooleanSchemaInterface, CoerceInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.js';

@@ -3,0 +3,0 @@ declare module './index.ts' {

@@ -1,1 +0,1 @@

import'./chunk-NCRS6NBV.mjs';export{i as any,h as array,d as boolean,n as cast,m as coerce,e as date,g as enumSchema,q as extend,f as functionSchema,p as hookOriginal,l as literal,c as number,a as object,j as preprocess,o as s,o as schema,b as string,k as union}from'./chunk-37YJYCTR.mjs';
import'./chunk-HVQY2UKM.mjs';export{i as any,h as array,d as boolean,m as cast,e as date,g as enumSchema,p as extend,f as functionSchema,o as hookOriginal,l as literal,c as number,a as object,j as preprocess,n as s,n as schema,b as string,k as union}from'./chunk-AKXLQP64.mjs';

@@ -1,1 +0,1 @@

'use strict';var R={abortEarly:true};function O(e,c){if(!c)return e;let t=e?.cause?.key?`${c}.${e.cause.key}`:`${c}`;return {message:`Error parsing key "${t}": ${e.message}`,cause:{key:t}}}function _(e,c,t){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)c.push(O(e.errors[r],t));}function T(e){return e?.abortEarly!==void 0?e:R}var l=e=>typeof e=="string"||e instanceof String,g=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),y=e=>e===true||e===false,A=e=>e instanceof Date&&!Number.isNaN(e.getTime()),j=e=>typeof e=="function",C=e=>Array.isArray(e),D=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function F(e,c){let t=h(D,{...c,type:"object"});return t._getDescription=()=>`object({ ${Object.entries(e).map(([a,s])=>`${a}: ${s._getDescription()}`).join(", ")} })`,p(t,"_parse",(r,a,s)=>{let n=r(a,s),{abortEarly:o}=T(s);if(n.success===false)return n;let i={},u=[];for(let f in e){let m=e[f]._parse(n.data[f],s);if(m.success)i[f]=m.data;else {if(m=m,o!==false){let S=O(m.error,f);return {success:false,error:S,errors:[S]}}_(m,u,f);}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:i}}),t}function w(e){return h(l,{...e,type:"string"})}function k(e){return h(g,{...e,type:"number"})}function x(e){return h(y,{...e,type:"boolean"})}function P(e){return h(A,{...e,type:"date"})}function V(e){return h(j,{...e,type:"function"})}function L(e,c){let t=n=>e.includes(n),r=n=>`Invalid ${a} value. Expected ${e.map(o=>`"${o}"`).join(" | ")}, received "${n}".`,a="enum",s=h(t,{message:r,...c,type:a});return s._getDescription=()=>`enum(${e.map(n=>`"${n}"`).join(" | ")})`,s}function B(e,c){let t=h(C,{...c,type:"array"});return t._getDescription=()=>`array(${e._getDescription()})`,p(t,"_parse",(r,a,s)=>{let n=r(a,s),{abortEarly:o}=T(s);if(n.success===false)return n;let i=[],u=[];for(let f=0;f<n.data.length;f++){let m=e._parse(n.data[f],s);if(m.success)i.push(m.data);else {if(m=m,o!==false){let S=O(m.error,f);return {success:false,error:S,errors:[S]}}_(m,u,f);}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:i}}),t}function M(){return h(()=>true)}function I(e,c){return p(c,"_parse",(t,r)=>(r=e(r),t(r))),c}function U(e,c){return h(s=>{for(let n=0;n<e.length;n++){let o=e[n]._parse(s);if(o.success)return o}return false},{message:s=>`Invalid union value. Expected the value to match one of the schemas:${e.map((n,o)=>` ${o+1}. ${n._getDescription()}`).join(",")} but received "${typeof s}" with value: ${D(s)?JSON.stringify(s):`"${s}"`}`,...c,type:"union"})}function W(e,c){let a=h(s=>s===e,{message:s=>c?.message?typeof c.message=="function"?c.message(s):c.message:`Expected literal value "${e}", received "${s}"`,name:c?.name,type:"literal"});return a._getDescription=()=>`literal("${e}")`,a}var v={string(e){return I(c=>String(c),w(e))},number(e){let c=e?.message??(t=>`Cannot coerce "${t}" to a valid number.`);return I(t=>Number(t),k({...e,message:c}))},boolean(e){return I(c=>!!c,x(e))},date(e){let c=e?.message??(t=>`Cannot coerce "${t}" to a valid date.`);return I(t=>new Date(t),P({...e,message:c}))}},J={boolean(e){let c=e?.message??(t=>`Cannot cast "${t}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return I(t=>{let r;return l(t)&&(r=t.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||t===1?true:r==="false"||r==="no"||r==="off"||r==="0"||t===0?false:t},x({...e,message:c}))},number(e){let c=e?.message??(t=>`Cannot cast "${t}" to a number. Expected a numeric string or number.`);return I(t=>{if(y(t))return Number(t);if(l(t)){let r=t.trim();if(r==="")return t;let a=Number(r);if(Number.isFinite(a))return a}return t},k({...e,message:c}))},string(e){let c=e?.message??(t=>`Cannot cast "${t}" to string. Expected a string, number, or boolean.`);return I(t=>y(t)||g(t)&&Number.isFinite(t)?String(t):t,w({...e,message:c}))},date(e){let c=e?.message??(t=>`Cannot cast "${t}" to a valid date.`);return I(t=>{let r;return l(t)&&(r=t.trim()),g(t)&&Number.isFinite(t)||r?new Date(r??t):t},P({...e,message:c}))},json(e,c){let t=c?.message??(r=>`Cannot parse "${r}" as JSON.`);return p(e,"_parse",(r,a)=>{if(l(a))try{a=JSON.parse(a);}catch{let s={message:typeof t=="function"?t(a):t};return {success:false,error:s,errors:[s]}}return r(a)}),e}},G={object:F,string:w,number:k,boolean:x,date:P,function:V,enum:L,array:B,any:M,preprocess:I,union:U,literal:W,coerce:v,cast:J};function E(e){return c=>`The value "${c}" must be type of ${e} but is type of "${typeof c}".`}function p(e,c,t){let r=e[c];e[c]=(...a)=>t(r,...a);}function h(e,{type:c="any",name:t,message:r}={}){r=r||E(c);let a={name:t,message:r,type:c},s={_getName(){return t},_getType(){return c},_getDescription(){return this._getName()??this._getType()},_parse(n,o){let i=e(n);if(i===true)return {success:true,data:n};if(typeof i=="object"&&i?.success===true)return i;let u={message:typeof r=="function"?r(n):r};return {success:false,error:u,errors:[u]}},parse(n,o){let i=s._parse(n,o);if(!i.success)throw i=i,new Error(i.error.message,{cause:i.error.cause});return i.data},safeParse(n,o){return s._parse(n,o)},transform(n){return p(this,"_parse",(o,i,u)=>{let f=o(i,u);return f.success&&(f.data=n(f.data)),f}),this},optional(){return p(this,"_parse",(n,o,i)=>{let u=n(o,i);return !u.success&&o===void 0&&(u.data=void 0,u.success=true),u}),this},nullable(){return p(this,"_parse",(n,o,i)=>{let u=n(o,i);return !u.success&&o===null&&(u.data=null,u.success=true),u}),this},nullish(){return p(this,"_parse",(n,o,i)=>{let u=n(o,i);return !u.success&&o==null&&(u.success=true,u.data=o),u}),this},default(n){return p(this,"_parse",(o,i,u)=>(i===void 0&&(i=typeof n=="function"?n():n),o(i,u))),this},catch(n){return p(this,"_parse",(o,i,u)=>{let f=o(i,u);return f.success?f:{success:true,data:typeof n=="function"?n({input:i,error:f.error}):n}}),this},pipe(n){return p(this,"_parse",(o,i,u)=>{let f=o(i,u);return f.success?n._parse(f.data,u):f}),this},refine(n,{message:o,type:i}={}){return i&&(o=o||E(i),c=i),p(this,"_parse",(u,f,m)=>{let S=u(f,m),{abortEarly:q}=T(m);if(!S.success)return S;let d=n(S.data);if(d===true||typeof d=="object"&&d?.success===true)return S;let $={message:typeof o=="function"?o(f):o};return {success:false,error:$,errors:[$]}}),this}};return b.length>0?b.reduce((n,o)=>o(n,e,a)??n,s):s}var b=[];function N(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");b.push(e);}N((e,c,t)=>{if(t?.type==="string"){let r=e;r.min=function(a,{message:s}={}){return this.refine(n=>n.length>=a,{message:s||(n=>`String must be at least ${a} characters long (received ${n.length} characters: "${n}")`)})},r.max=function(a,{message:s}={}){return this.refine(n=>n.length<=a,{message:s||(n=>`String must be at most ${a} characters long (received ${n.length} characters: "${n}")`)})},r.length=function(a,{message:s}={}){return this.refine(n=>n.length===a,{message:s||(n=>`String must be exactly ${a} characters long (received ${n.length} characters: "${n}")`)})},r.nonEmpty=function({message:a}={}){return this.refine(s=>s.length>0,{message:a||"String must not be empty (received empty string)"})},r.startsWith=function(a,{message:s}={}){return this.refine(n=>n.startsWith(a),{message:s||(n=>`String must start with "${a}" (received: "${n}")`)})},r.endsWith=function(a,{message:s}={}){return this.refine(n=>n.endsWith(a),{message:s||(n=>`String must end with "${a}" (received: "${n}")`)})},r.includes=function(a,{message:s}={}){return this.refine(n=>n.includes(a),{message:s||(n=>`String must include "${a}" (received: "${n}")`)})},r.toLowerCase=function(){return this.transform(a=>a.toLowerCase())},r.toUpperCase=function(){return this.transform(a=>a.toUpperCase())},r.trim=function(){return this.transform(a=>a.trim())},r.padStart=function(a,s=" "){return this.transform(n=>n.padStart(a,s))},r.padEnd=function(a,s=" "){return this.transform(n=>n.padEnd(a,s))},r.replace=function(a,s){return this.transform(n=>n.replace(a,s))};}return e});exports.any=M;exports.array=B;exports.boolean=x;exports.cast=J;exports.coerce=v;exports.date=P;exports.enumSchema=L;exports.extend=N;exports.functionSchema=V;exports.hookOriginal=p;exports.literal=W;exports.number=k;exports.object=F;exports.preprocess=I;exports.s=G;exports.schema=G;exports.string=w;exports.union=U;
'use strict';var R={abortEarly:true};function O(e,s){if(!s)return e;let t=e?.cause?.key?`${s}.${e.cause.key}`:`${s}`;return {message:`Error parsing key "${t}": ${e.message}`,cause:{key:t}}}function x(e,s,t){if(e.errors?.length)for(let r=0;r<e.errors.length;r++)s.push(O(e.errors[r],t));}function T(e){return e?.abortEarly!==void 0?e:R}var I=e=>typeof e=="string"||e instanceof String,g=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),y=e=>e===true||e===false,A=e=>e instanceof Date&&!Number.isNaN(e.getTime()),j=e=>typeof e=="function",C=e=>Array.isArray(e),P=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function F(e,s){let t=h(P,{...s,type:"object"});return t._getDescription=()=>`object({ ${Object.entries(e).map(([a,c])=>`${a}: ${c._getDescription()}`).join(", ")} })`,m(t,"_parse",(r,a,c)=>{let n=r(a,c),{abortEarly:o}=T(c);if(n.success===false)return n;let i={},u=[];for(let f in e){let p=e[f]._parse(n.data[f],c);if(p.success)i[f]=p.data;else {if(p=p,o!==false){let S=O(p.error,f);return {success:false,error:S,errors:[S]}}x(p,u,f);}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:i}}),t}function $(e){return h(I,{...e,type:"string"})}function E(e){return h(g,{...e,type:"number"})}function _(e){return h(y,{...e,type:"boolean"})}function D(e){return h(A,{...e,type:"date"})}function V(e){return h(j,{...e,type:"function"})}function L(e,s){let t=n=>e.includes(n),r=n=>`Invalid ${a} value. Expected ${e.map(o=>`"${o}"`).join(" | ")}, received "${n}".`,a="enum",c=h(t,{message:r,...s,type:a});return c._getDescription=()=>`enum(${e.map(n=>`"${n}"`).join(" | ")})`,c}function M(e,s){let t=h(C,{...s,type:"array"});return t._getDescription=()=>`array(${e._getDescription()})`,m(t,"_parse",(r,a,c)=>{let n=r(a,c),{abortEarly:o}=T(c);if(n.success===false)return n;let i=[],u=[];for(let f=0;f<n.data.length;f++){let p=e._parse(n.data[f],c);if(p.success)i.push(p.data);else {if(p=p,o!==false){let S=O(p.error,f);return {success:false,error:S,errors:[S]}}x(p,u,f);}}return u.length>0?{success:false,error:u[0],errors:u}:{success:true,data:i}}),t}function U(){return h(()=>true)}function l(e,s){return m(s,"_parse",(t,r)=>(r=e(r),t(r))),s}function B(e,s){return h(c=>{for(let n=0;n<e.length;n++){let o=e[n]._parse(c);if(o.success)return o}return false},{message:c=>`Invalid union value. Expected the value to match one of the schemas:${e.map((n,o)=>` ${o+1}. ${n._getDescription()}`).join(",")} but received "${typeof c}" with value: ${P(c)?JSON.stringify(c):`"${c}"`}`,...s,type:"union"})}function W(e,s){let a=h(c=>c===e,{message:c=>s?.message?typeof s.message=="function"?s.message(c):s.message:`Expected literal value "${e}", received "${c}"`,name:s?.name,type:"literal"});return a._getDescription=()=>`literal("${e}")`,a}var J={boolean(e){let s=e?.message??(t=>`Cannot cast "${t}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return l(t=>{let r;return I(t)&&(r=t.toLowerCase()),r==="true"||r==="yes"||r==="on"||r==="1"||t===1?true:r==="false"||r==="no"||r==="off"||r==="0"||t===0?false:t},_({...e,message:s}))},number(e){let s=e?.message??(t=>`Cannot cast "${t}" to a number. Expected a numeric string or number.`);return l(t=>{if(y(t))return Number(t);if(I(t)){let r=t.trim();if(r==="")return t;let a=Number(r);if(Number.isFinite(a))return a}return t},E({...e,message:s}))},string(e){let s=e?.message??(t=>`Cannot cast "${t}" to string. Expected a string, number, or boolean.`);return l(t=>y(t)||g(t)&&Number.isFinite(t)?String(t):t,$({...e,message:s}))},date(e){let s=e?.message??(t=>`Cannot cast "${t}" to a valid date.`);return l(t=>{let r;return I(t)&&(r=t.trim()),g(t)&&Number.isFinite(t)||r?new Date(r??t):t},D({...e,message:s}))},json(e,s){let t=s?.message??(r=>`Cannot parse "${r}" as JSON.`);return m(e,"_parse",(r,a)=>{if(I(a))try{a=JSON.parse(a);}catch{let c={message:typeof t=="function"?t(a):t};return {success:false,error:c,errors:[c]}}return r(a)}),e}},z={object:F,string:$,number:E,boolean:_,date:D,function:V,enum:L,array:M,any:U,preprocess:l,union:B,literal:W,coerce:{},cast:J};function k(e){return s=>`The value "${s}" must be type of ${e} but is type of "${typeof s}".`}function m(e,s,t){let r=e[s];e[s]=(...a)=>t(r,...a);}function h(e,{type:s="any",name:t,message:r}={}){r=r||k(s);let a={name:t,message:r,type:s},c={_getName(){return t},_getType(){return s},_getDescription(){return this._getName()??this._getType()},_parse(n,o){let i=e(n);if(i===true)return {success:true,data:n};if(typeof i=="object"&&i?.success===true)return i;let u={message:typeof r=="function"?r(n):r};return {success:false,error:u,errors:[u]}},parse(n,o){let i=c._parse(n,o);if(!i.success)throw i=i,new Error(i.error.message,{cause:i.error.cause});return i.data},safeParse(n,o){return c._parse(n,o)},transform(n){return m(this,"_parse",(o,i,u)=>{let f=o(i,u);return f.success&&(f.data=n(f.data)),f}),this},optional(){return m(this,"_parse",(n,o,i)=>{let u=n(o,i);return !u.success&&o===void 0&&(u.data=void 0,u.success=true),u}),this},nullable(){return m(this,"_parse",(n,o,i)=>{let u=n(o,i);return !u.success&&o===null&&(u.data=null,u.success=true),u}),this},nullish(){return m(this,"_parse",(n,o,i)=>{let u=n(o,i);return !u.success&&o==null&&(u.success=true,u.data=o),u}),this},default(n){return m(this,"_parse",(o,i,u)=>(i===void 0&&(i=typeof n=="function"?n():n),o(i,u))),this},catch(n){return m(this,"_parse",(o,i,u)=>{let f=o(i,u);return f.success?f:{success:true,data:typeof n=="function"?n({input:i,error:f.error}):n}}),this},pipe(n){return m(this,"_parse",(o,i,u)=>{let f=o(i,u);return f.success?n._parse(f.data,u):f}),this},refine(n,{message:o,type:i}={}){return i&&(o=o||k(i),s=i),m(this,"_parse",(u,f,p)=>{let S=u(f,p),{abortEarly:q}=T(p);if(!S.success)return S;let d=n(S.data);if(d===true||typeof d=="object"&&d?.success===true)return S;let w={message:typeof o=="function"?o(f):o};return {success:false,error:w,errors:[w]}}),this}};return b.length>0?b.reduce((n,o)=>o(n,e,a)??n,c):c}var b=[];function N(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");b.push(e);}N((e,s,t)=>{if(t?.type==="string"){let r=e;r.min=function(a,{message:c}={}){return this.refine(n=>n.length>=a,{message:c||(n=>`String must be at least ${a} characters long (received ${n.length} characters: "${n}")`)})},r.max=function(a,{message:c}={}){return this.refine(n=>n.length<=a,{message:c||(n=>`String must be at most ${a} characters long (received ${n.length} characters: "${n}")`)})},r.length=function(a,{message:c}={}){return this.refine(n=>n.length===a,{message:c||(n=>`String must be exactly ${a} characters long (received ${n.length} characters: "${n}")`)})},r.nonEmpty=function({message:a}={}){return this.refine(c=>c.length>0,{message:a||"String must not be empty (received empty string)"})},r.startsWith=function(a,{message:c}={}){return this.refine(n=>n.startsWith(a),{message:c||(n=>`String must start with "${a}" (received: "${n}")`)})},r.endsWith=function(a,{message:c}={}){return this.refine(n=>n.endsWith(a),{message:c||(n=>`String must end with "${a}" (received: "${n}")`)})},r.includes=function(a,{message:c}={}){return this.refine(n=>n.includes(a),{message:c||(n=>`String must include "${a}" (received: "${n}")`)})},r.toLowerCase=function(){return this.transform(a=>a.toLowerCase())},r.toUpperCase=function(){return this.transform(a=>a.toUpperCase())},r.trim=function(){return this.transform(a=>a.trim())},r.padStart=function(a,c=" "){return this.transform(n=>n.padStart(a,c))},r.padEnd=function(a,c=" "){return this.transform(n=>n.padEnd(a,c))},r.replace=function(a,c){return this.transform(n=>n.replace(a,c))};}return e});exports.any=U;exports.array=M;exports.boolean=_;exports.cast=J;exports.date=D;exports.enumSchema=L;exports.extend=N;exports.functionSchema=V;exports.hookOriginal=m;exports.literal=W;exports.number=E;exports.object=F;exports.preprocess=l;exports.s=z;exports.schema=z;exports.string=$;exports.union=B;

@@ -1,2 +0,2 @@

export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, coerce, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.mjs';
export { ArraySchemaInterface, BooleanSchemaInterface, CoerceInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.mjs';

@@ -3,0 +3,0 @@ declare module './index.ts' {

@@ -1,2 +0,2 @@

export { ArraySchemaInterface, BooleanSchemaInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, coerce, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.js';
export { ArraySchemaInterface, BooleanSchemaInterface, CoerceInterface, DateSchemaInterface, EnumSchemaInterface, ErrorStructure, ExtenderType, FunctionSchemaInterface, Infer, Invalid, LiteralSchemaInterface, NumberSchemaInterface, ObjectSchemaInterface, SchemaInterface, SchemaInterfaceOptions, SchemaType, StringSchemaInterface, UnionSchemaInterface, Valid, any, array, boolean, cast, date, enumSchema, extend, functionSchema, hookOriginal, literal, number, object, preprocess, s, s as schema, string, union } from './index.js';

@@ -3,0 +3,0 @@ declare module './index.ts' {

@@ -1,1 +0,1 @@

import'./chunk-NRGPACGD.mjs';export{i as any,h as array,d as boolean,n as cast,m as coerce,e as date,g as enumSchema,q as extend,f as functionSchema,p as hookOriginal,l as literal,c as number,a as object,j as preprocess,o as s,o as schema,b as string,k as union}from'./chunk-37YJYCTR.mjs';
import'./chunk-7VTVE334.mjs';export{i as any,h as array,d as boolean,m as cast,e as date,g as enumSchema,p as extend,f as functionSchema,o as hookOriginal,l as literal,c as number,a as object,j as preprocess,n as s,n as schema,b as string,k as union}from'./chunk-AKXLQP64.mjs';
{
"name": "@esmj/schema",
"version": "0.7.4",
"version": "0.8.0",
"description": "Tiny extendable package for schema validation.",

@@ -49,2 +49,7 @@ "keywords": [

"require": "./dist/array.cjs"
},
"./coerce": {
"types": "./dist/coerce.d.ts",
"import": "./dist/coerce.mjs",
"require": "./dist/coerce.cjs"
}

@@ -64,3 +69,6 @@ },

"./dist/full.mjs",
"./dist/full.cjs"
"./dist/full.cjs",
"./src/coerce.ts",
"./dist/coerce.mjs",
"./dist/coerce.cjs"
],

@@ -67,0 +75,0 @@ "typings": "dist/index.d.ts",

@@ -17,2 +17,3 @@ # Schema

- [Array Extensions](#array-extensions-esmjschemaarray)
- [Coerce Extensions](#coerce-extensions-esmjschemacoerce)
- [Full Extensions](#full-extensions-esmjschemafull)

@@ -257,5 +258,9 @@ - [Named Exports & Tree-Shaking](#named-exports--tree-shaking)

// Coerce extensions only
import { s } from '@esmj/schema/coerce';
// Mix and match (side-effect imports)
import '@esmj/schema/string';
import '@esmj/schema/number';
import '@esmj/schema/coerce';
import { s } from '@esmj/schema';

@@ -277,2 +282,3 @@

- **Array extensions** (`@esmj/schema/array`): +~0.5 KB
- **Coerce extensions** (`@esmj/schema/coerce`): +~0.3 KB
- **Full** (`@esmj/schema/full`): ~4 KB gzipped (all extensions)

@@ -306,6 +312,15 @@

```typescript
import { coerce } from '@esmj/schema';
// coerce is a named export from @esmj/schema but s.coerce methods
// require importing '@esmj/schema/coerce' (or '@esmj/schema/full') first:
import '@esmj/schema/coerce';
import { s } from '@esmj/schema';
const schema = coerce.number();
const schema = s.coerce.number();
schema.parse('42'); // 42
// Or import the standalone coerce object directly:
import { coerce } from '@esmj/schema/coerce';
const schema2 = coerce.number();
schema2.parse('42'); // 42
```

@@ -422,2 +437,32 @@

### Coerce Extensions (`@esmj/schema/coerce`)
Coerce extensions add `s.coerce` methods that apply native JS constructors before validation, providing convenient type coercion with clear error messages.
> **Note:** `s.coerce` is opt-in. Import `@esmj/schema/coerce` (or `@esmj/schema/full`) to activate it. Importing only the core `@esmj/schema` leaves `s.coerce` empty.
```typescript
import { s } from '@esmj/schema/coerce';
s.coerce.number().parse('42'); // 42
s.coerce.string().parse(123); // '123'
s.coerce.boolean().parse(0); // false
s.coerce.date().parse('2024-01-01'); // Date object
// Coerce then chain schema methods:
s.coerce.number().refine((v) => v > 0, { message: 'Must be positive' }).parse('5'); // 5
// Custom error message:
s.coerce.number({ message: 'Expected a numeric value' }).parse('bad'); // throws: Expected a numeric value
```
**Available Coerce Methods:**
| Method | Coercion | Fails when |
|---|---|---|
| `s.coerce.string(options?)` | `String(v)` | Never |
| `s.coerce.number(options?)` | `Number(v)` | Result is `NaN` |
| `s.coerce.boolean(options?)` | `Boolean(v)` | Never |
| `s.coerce.date(options?)` | `new Date(v)` | Result is an invalid Date |
### Full Extensions (`@esmj/schema/full`)

@@ -499,3 +544,3 @@

- `s.preprocess(fn, schema)` / `import { preprocess }` - Preprocess before validation
- `s.coerce` / `import { coerce }` - Coerce namespace
- `s.coerce` / `import { coerce } from '@esmj/schema/coerce'` - Coerce namespace (requires `@esmj/schema/coerce` import)
- `s.cast` / `import { cast }` - Cast namespace

@@ -513,2 +558,4 @@

> Requires `import '@esmj/schema/coerce'` or `import '@esmj/schema/full'`. `s.coerce` is empty without this import.
- `s.coerce.string()` - Coerce any value to string, then validate

@@ -840,2 +887,4 @@ - `s.coerce.number()` - Coerce any value to number, then validate (fails for NaN)

> **Requires `import '@esmj/schema/coerce'`** (or `'@esmj/schema/full'`) as a side-effect. Importing only the core `@esmj/schema` leaves `s.coerce` empty — calling `s.coerce.string()` will throw at runtime and produce a TypeScript error.
The `coerce` namespace applies a native JS constructor to the input **before** validation.

@@ -842,0 +891,0 @@ Unlike `s.preprocess`, you don't need to write the conversion yourself, and coerce methods

var N={abortEarly:true};function T(e,t){if(!t)return e;let n=e?.cause?.key?`${t}.${e.cause.key}`:`${t}`;return {message:`Error parsing key "${n}": ${e.message}`,cause:{key:n}}}function _(e,t,n){if(e.errors?.length)for(let a=0;a<e.errors.length;a++)t.push(T(e.errors[a],n));}function O(e){return e?.abortEarly!==void 0?e:N}var S=e=>typeof e=="string"||e instanceof String,y=e=>(typeof e=="number"||e instanceof Number)&&!Number.isNaN(e),g=e=>e===true||e===false,R=e=>e instanceof Date&&!Number.isNaN(e.getTime()),A=e=>typeof e=="function",j=e=>Array.isArray(e),$=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function F(e,t){let n=h($,{...t,type:"object"});return n._getDescription=()=>`object({ ${Object.entries(e).map(([f,o])=>`${f}: ${o._getDescription()}`).join(", ")} })`,m(n,"_parse",(a,f,o)=>{let r=a(f,o),{abortEarly:c}=O(o);if(r.success===false)return r;let u={},s=[];for(let i in e){let p=e[i]._parse(r.data[i],o);if(p.success)u[i]=p.data;else {if(p=p,c!==false){let I=T(p.error,i);return {success:false,error:I,errors:[I]}}_(p,s,i);}}return s.length>0?{success:false,error:s[0],errors:s}:{success:true,data:u}}),n}function k(e){return h(S,{...e,type:"string"})}function w(e){return h(y,{...e,type:"number"})}function x(e){return h(g,{...e,type:"boolean"})}function P(e){return h(R,{...e,type:"date"})}function C(e){return h(A,{...e,type:"function"})}function V(e,t){let n=r=>e.includes(r),a=r=>`Invalid ${f} value. Expected ${e.map(c=>`"${c}"`).join(" | ")}, received "${r}".`,f="enum",o=h(n,{message:a,...t,type:f});return o._getDescription=()=>`enum(${e.map(r=>`"${r}"`).join(" | ")})`,o}function B(e,t){let n=h(j,{...t,type:"array"});return n._getDescription=()=>`array(${e._getDescription()})`,m(n,"_parse",(a,f,o)=>{let r=a(f,o),{abortEarly:c}=O(o);if(r.success===false)return r;let u=[],s=[];for(let i=0;i<r.data.length;i++){let p=e._parse(r.data[i],o);if(p.success)u.push(p.data);else {if(p=p,c!==false){let I=T(p.error,i);return {success:false,error:I,errors:[I]}}_(p,s,i);}}return s.length>0?{success:false,error:s[0],errors:s}:{success:true,data:u}}),n}function L(){return h(()=>true)}function l(e,t){return m(t,"_parse",(n,a)=>(a=e(a),n(a))),t}function M(e,t){return h(o=>{for(let r=0;r<e.length;r++){let c=e[r]._parse(o);if(c.success)return c}return false},{message:o=>`Invalid union value. Expected the value to match one of the schemas:${e.map((r,c)=>` ${c+1}. ${r._getDescription()}`).join(",")} but received "${typeof o}" with value: ${$(o)?JSON.stringify(o):`"${o}"`}`,...t,type:"union"})}function U(e,t){let f=h(o=>o===e,{message:o=>t?.message?typeof t.message=="function"?t.message(o):t.message:`Expected literal value "${e}", received "${o}"`,name:t?.name,type:"literal"});return f._getDescription=()=>`literal("${e}")`,f}var J={string(e){return l(t=>String(t),k(e))},number(e){let t=e?.message??(n=>`Cannot coerce "${n}" to a valid number.`);return l(n=>Number(n),w({...e,message:t}))},boolean(e){return l(t=>!!t,x(e))},date(e){let t=e?.message??(n=>`Cannot coerce "${n}" to a valid date.`);return l(n=>new Date(n),P({...e,message:t}))}},q={boolean(e){let t=e?.message??(n=>`Cannot cast "${n}" to boolean. Accepted: true/false, 1/0, yes/no, on/off.`);return l(n=>{let a;return S(n)&&(a=n.toLowerCase()),a==="true"||a==="yes"||a==="on"||a==="1"||n===1?true:a==="false"||a==="no"||a==="off"||a==="0"||n===0?false:n},x({...e,message:t}))},number(e){let t=e?.message??(n=>`Cannot cast "${n}" to a number. Expected a numeric string or number.`);return l(n=>{if(g(n))return Number(n);if(S(n)){let a=n.trim();if(a==="")return n;let f=Number(a);if(Number.isFinite(f))return f}return n},w({...e,message:t}))},string(e){let t=e?.message??(n=>`Cannot cast "${n}" to string. Expected a string, number, or boolean.`);return l(n=>g(n)||y(n)&&Number.isFinite(n)?String(n):n,k({...e,message:t}))},date(e){let t=e?.message??(n=>`Cannot cast "${n}" to a valid date.`);return l(n=>{let a;return S(n)&&(a=n.trim()),y(n)&&Number.isFinite(n)||a?new Date(a??n):n},P({...e,message:t}))},json(e,t){let n=t?.message??(a=>`Cannot parse "${a}" as JSON.`);return m(e,"_parse",(a,f)=>{if(S(f))try{f=JSON.parse(f);}catch{let o={message:typeof n=="function"?n(f):n};return {success:false,error:o,errors:[o]}}return a(f)}),e}},H={object:F,string:k,number:w,boolean:x,date:P,function:C,enum:V,array:B,any:L,preprocess:l,union:M,literal:U,coerce:J,cast:q};function D(e){return t=>`The value "${t}" must be type of ${e} but is type of "${typeof t}".`}function m(e,t,n){let a=e[t];e[t]=(...f)=>n(a,...f);}function h(e,{type:t="any",name:n,message:a}={}){a=a||D(t);let f={name:n,message:a,type:t},o={_getName(){return n},_getType(){return t},_getDescription(){return this._getName()??this._getType()},_parse(r,c){let u=e(r);if(u===true)return {success:true,data:r};if(typeof u=="object"&&u?.success===true)return u;let s={message:typeof a=="function"?a(r):a};return {success:false,error:s,errors:[s]}},parse(r,c){let u=o._parse(r,c);if(!u.success)throw u=u,new Error(u.error.message,{cause:u.error.cause});return u.data},safeParse(r,c){return o._parse(r,c)},transform(r){return m(this,"_parse",(c,u,s)=>{let i=c(u,s);return i.success&&(i.data=r(i.data)),i}),this},optional(){return m(this,"_parse",(r,c,u)=>{let s=r(c,u);return !s.success&&c===void 0&&(s.data=void 0,s.success=true),s}),this},nullable(){return m(this,"_parse",(r,c,u)=>{let s=r(c,u);return !s.success&&c===null&&(s.data=null,s.success=true),s}),this},nullish(){return m(this,"_parse",(r,c,u)=>{let s=r(c,u);return !s.success&&c==null&&(s.success=true,s.data=c),s}),this},default(r){return m(this,"_parse",(c,u,s)=>(u===void 0&&(u=typeof r=="function"?r():r),c(u,s))),this},catch(r){return m(this,"_parse",(c,u,s)=>{let i=c(u,s);return i.success?i:{success:true,data:typeof r=="function"?r({input:u,error:i.error}):r}}),this},pipe(r){return m(this,"_parse",(c,u,s)=>{let i=c(u,s);return i.success?r._parse(i.data,s):i}),this},refine(r,{message:c,type:u}={}){return u&&(c=c||D(u),t=u),m(this,"_parse",(s,i,p)=>{let I=s(i,p),{abortEarly:z}=O(p);if(!I.success)return I;let d=r(I.data);if(d===true||typeof d=="object"&&d?.success===true)return I;let E={message:typeof c=="function"?c(i):c};return {success:false,error:E,errors:[E]}}),this}};return b.length>0?b.reduce((r,c)=>c(r,e,f)??r,o):o}var b=[];function Q(e){if(typeof e!="function")throw new TypeError("extend() requires a function argument");b.push(e);}export{F as a,k as b,w as c,x as d,P as e,C as f,V as g,B as h,L as i,l as j,M as k,U as l,J as m,q as n,H as o,m as p,Q as q};
import {q}from'./chunk-37YJYCTR.mjs';q((t,h,i)=>{if(i?.type==="array"){let r=t;r.min=function(e,{message:n}={}){return this.refine(a=>a.length>=e,{message:n||`Array must contain at least ${e} items.`})},r.max=function(e,{message:n}={}){return this.refine(a=>a.length<=e,{message:n||`Array must contain at most ${e} items.`})},r.length=function(e,{message:n}={}){return this.refine(a=>a.length===e,{message:n||`Array must contain exactly ${e} items.`})},r.nonEmpty=function({message:e}={}){return this.refine(n=>n.length>0,{message:e||"Array must not be empty."})},r.unique=function({message:e}={}){return this.refine(n=>{let a=new Set;try{return n.every(c=>{let s=JSON.stringify(c);return a.has(s)?!1:(a.add(s),!0)})}catch{return new Set(n).size===n.length}},{message:e||"Array items must be unique."})},r.sort=function(){return this.transform(e=>[...e].sort())},r.reverse=function(){return this.transform(e=>[...e].reverse())};}return t});
import {q}from'./chunk-37YJYCTR.mjs';q((r,c,i)=>{if(i?.type==="number"){let t=r;t.min=function(e,{message:n}={}){return this.refine(a=>a>=e,{message:n||`Number must be greater than or equal to ${e}.`})},t.max=function(e,{message:n}={}){return this.refine(a=>a<=e,{message:n||`Number must be less than or equal to ${e}.`})},t.positive=function({message:e}={}){return this.refine(n=>n>0,{message:e||"Number must be positive."})},t.negative=function({message:e}={}){return this.refine(n=>n<0,{message:e||"Number must be negative."})},t.int=function({message:e}={}){return this.refine(n=>Number.isInteger(n),{message:e||"Number must be an integer."})},t.float=function({message:e}={}){return this.refine(n=>Number.isFinite(n)&&!Number.isInteger(n),{message:e||"Number must be a floating point (non-integer)."})},t.multipleOf=function(e,{message:n}={}){return this.refine(a=>a%e===0,{message:n||`Number must be a multiple of ${e}.`})},t.finite=function({message:e}={}){return this.refine(n=>Number.isFinite(n),{message:e||"Number must be finite."})};}return r});
import {q}from'./chunk-37YJYCTR.mjs';q((a,s,i)=>{if(i?.type==="string"){let r=a;r.min=function(n,{message:t}={}){return this.refine(e=>e.length>=n,{message:t||(e=>`String must be at least ${n} characters long (received ${e.length} characters: "${e}")`)})},r.max=function(n,{message:t}={}){return this.refine(e=>e.length<=n,{message:t||(e=>`String must be at most ${n} characters long (received ${e.length} characters: "${e}")`)})},r.length=function(n,{message:t}={}){return this.refine(e=>e.length===n,{message:t||(e=>`String must be exactly ${n} characters long (received ${e.length} characters: "${e}")`)})},r.nonEmpty=function({message:n}={}){return this.refine(t=>t.length>0,{message:n||"String must not be empty (received empty string)"})},r.startsWith=function(n,{message:t}={}){return this.refine(e=>e.startsWith(n),{message:t||(e=>`String must start with "${n}" (received: "${e}")`)})},r.endsWith=function(n,{message:t}={}){return this.refine(e=>e.endsWith(n),{message:t||(e=>`String must end with "${n}" (received: "${e}")`)})},r.includes=function(n,{message:t}={}){return this.refine(e=>e.includes(n),{message:t||(e=>`String must include "${n}" (received: "${e}")`)})},r.toLowerCase=function(){return this.transform(n=>n.toLowerCase())},r.toUpperCase=function(){return this.transform(n=>n.toUpperCase())},r.trim=function(){return this.transform(n=>n.trim())},r.padStart=function(n,t=" "){return this.transform(e=>e.padStart(n,t))},r.padEnd=function(n,t=" "){return this.transform(e=>e.padEnd(n,t))},r.replace=function(n,t){return this.transform(e=>e.replace(n,t))};}return a});