@authhero/kysely-adapter 0.7.10 → 0.7.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
var kyselyAdapter=function(){"use strict";var io=Object.defineProperty;var oo=(K,ae,E)=>ae in K?io(K,ae,{enumerable:!0,configurable:!0,writable:!0,value:E}):K[ae]=E;var fn=(K,ae,E)=>oo(K,typeof ae!="symbol"?ae+"":ae,E);var K=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});fn(this,"res");fn(this,"status");this.res=t==null?void 0:t.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}};function ae(n){return async(e,t)=>{const{identities:s,...r}=t,a={...r,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,email_verified:t.email_verified?1:0,is_social:t.is_social?1:0};try{await n.insertInto("users").values(a).execute()}catch(o){throw o.code==="SQLITE_CONSTRAINT_UNIQUE"||o.message.includes("AlreadyExists")?new K(409,{message:"User already exists"}):(console.log(o.message),new K(500,{message:`${o.code}, ${o.message}`}))}return{...a,email:a.email||"",email_verified:a.email_verified===1,is_social:a.is_social===1}}}function E(n){const e={...n};for(const t in e)e[t]===null?delete e[t]:typeof e[t]=="object"&&(Array.isArray(e[t])?e[t]=e[t].map(E):e[t]=E(e[t]));return e}function Qn(n,e){var t={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(n);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(n,s[r])&&(t[s[r]]=n[s[r]]);return t}function Hn(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function Ye(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...s){const r=t.apply(this,s);return r._def.openapi=this._def.openapi,r}}function Yn(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(r,a){var o,c,d,u,l,T;const C=typeof r=="string"?a:r,L=C??{},{param:te}=L,de=Qn(L,["param"]),be=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof r=="string"?{refId:r}:void 0),xe=Object.assign(Object.assign(Object.assign({},(c=this._def.openapi)===null||c===void 0?void 0:c.metadata),de),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||te?{param:Object.assign(Object.assign({},(T=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||T===void 0?void 0:T.param),te)}:void 0),Te=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(be).length>0?{_internal:be}:void 0),Object.keys(xe).length>0?{metadata:xe}:void 0)}));if(Hn(this,"ZodObject")){const Qe=this.extend;Te.extend=function(...He){var ne,se,re,Oe,Re,$e;const Pe=Qe.apply(this,He);return Pe._def.openapi={_internal:{extendedFrom:!((se=(ne=this._def.openapi)===null||ne===void 0?void 0:ne._internal)===null||se===void 0)&&se.refId?{refId:(Oe=(re=this._def.openapi)===null||re===void 0?void 0:re._internal)===null||Oe===void 0?void 0:Oe.refId,schema:this}:(Re=this._def.openapi)===null||Re===void 0?void 0:Re._internal.extendedFrom},metadata:($e=Pe._def.openapi)===null||$e===void 0?void 0:$e.metadata},Pe}}return Te},Ye(n,"optional"),Ye(n,"nullable"),Ye(n,"default"),Ye(n,"transform"),Ye(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const r=this._def.shape(),a=e.apply(this),o=a._def.shape();return Object.entries(o).forEach(([c,d])=>{var u,l;d._def.openapi=(l=(u=r[c])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...r){const a=t.apply(this,r);return a._def.openapi=void 0,a};const s=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...r){const a=s.apply(this,r);return a._def.openapi=void 0,a}}new Set(".\\+*[^]$()");var N;(function(n){n.assertEqual=r=>r;function e(r){}n.assertIs=e;function t(r){throw new Error}n.assertNever=t,n.arrayToEnum=r=>{const a={};for(const o of r)a[o]=o;return a},n.getValidEnumValues=r=>{const a=n.objectKeys(r).filter(c=>typeof r[r[c]]!="number"),o={};for(const c of a)o[c]=r[c];return n.objectValues(o)},n.objectValues=r=>n.objectKeys(r).map(function(a){return r[a]}),n.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&a.push(o);return a},n.find=(r,a)=>{for(const o of r)if(a(o))return o},n.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function s(r,a=" | "){return r.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}n.joinValues=s,n.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(N||(N={}));var Gt;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Gt||(Gt={}));const _=N.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ue=n=>{switch(typeof n){case"undefined":return _.undefined;case"string":return _.string;case"number":return isNaN(n)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":return Array.isArray(n)?_.array:n===null?_.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?_.promise:typeof Map<"u"&&n instanceof Map?_.map:typeof Set<"u"&&n instanceof Set?_.set:typeof Date<"u"&&n instanceof Date?_.date:_.object;default:return _.unknown}},p=N.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Gn=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class V extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},s={_errors:[]},r=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(r);else if(o.code==="invalid_return_type")r(o.returnTypeError);else if(o.code==="invalid_arguments")r(o.argumentsError);else if(o.path.length===0)s._errors.push(t(o));else{let c=s,d=0;for(;d<o.path.length;){const u=o.path[d];d===o.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(o))):c[u]=c[u]||{_errors:[]},c=c[u],d++}}};return r(this),s}static assert(e){if(!(e instanceof V))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,N.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):s.push(e(r));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}V.create=n=>new V(n);const De=(n,e)=>{let t;switch(n.code){case p.invalid_type:n.received===_.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case p.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,N.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:t=`Unrecognized key(s) in object: ${N.joinValues(n.keys,", ")}`;break;case p.invalid_union:t="Invalid input";break;case p.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${N.joinValues(n.options)}`;break;case p.invalid_enum_value:t=`Invalid enum value. Expected ${N.joinValues(n.options)}, received '${n.received}'`;break;case p.invalid_arguments:t="Invalid function arguments";break;case p.invalid_return_type:t="Invalid function return type";break;case p.invalid_date:t="Invalid date";break;case p.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:N.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case p.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case p.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case p.custom:t="Invalid input";break;case p.invalid_intersection_types:t="Intersection results could not be merged";break;case p.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case p.not_finite:t="Number must be finite";break;default:t=e.defaultError,N.assertNever(n)}return{message:t}};let mn=De;function Xn(n){mn=n}function Rt(){return mn}const $t=n=>{const{data:e,path:t,errorMaps:s,issueData:r}=n,a=[...t,...r.path||[]],o={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let c="";const d=s.filter(u=>!!u).slice().reverse();for(const u of d)c=u(o,{data:e,defaultError:c}).message;return{...r,path:a,message:c}},es=[];function f(n,e){const t=Rt(),s=$t({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===De?void 0:De].filter(r=>!!r)});n.common.issues.push(s)}class ${constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const r of t){if(r.status==="aborted")return x;r.status==="dirty"&&e.dirty(),s.push(r.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const r of t){const a=await r.key,o=await r.value;s.push({key:a,value:o})}return $.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const r of t){const{key:a,value:o}=r;if(a.status==="aborted"||o.status==="aborted")return x;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||r.alwaysSet)&&(s[a.value]=o.value)}return{status:e.value,value:s}}}const x=Object.freeze({status:"aborted"}),Pt=n=>({status:"dirty",value:n}),D=n=>({status:"valid",value:n}),Xt=n=>n.status==="aborted",en=n=>n.status==="dirty",Ge=n=>n.status==="valid",Xe=n=>typeof Promise<"u"&&n instanceof Promise;function Dt(n,e,t,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function _n(n,e,t,s,r){if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var y;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(y||(y={}));var et,tt;class Q{constructor(e,t,s,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const gn=(n,e)=>{if(Ge(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new V(n.common.issues);return this._error=t,this._error}}};function O(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:r}=n;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(a,o)=>{var c,d;const{message:u}=n;return a.code==="invalid_enum_value"?{message:u??o.defaultError}:typeof o.data>"u"?{message:(c=u??s)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(d=u??t)!==null&&d!==void 0?d:o.defaultError}},description:r}}class Z{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return ue(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $,ctx:{common:e.parent.common,data:e.data,parsedType:ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Xe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const r={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ue(e)},a=this._parseSync({data:e,path:r.path,parent:r});return gn(r,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ue(e)},r=this._parse({data:e,path:s.path,parent:s}),a=await(Xe(r)?r:Promise.resolve(r));return gn(s,a)}refine(e,t){const s=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,a)=>{const o=e(r),c=()=>a.addIssue({code:p.custom,...s(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((s,r)=>e(s)?!0:(r.addIssue(typeof t=="function"?t(s,r):t),!1))}_refinement(e){return new B({schema:this,typeName:w.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Y.create(this,this._def)}nullable(){return me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return z.create(this,this._def)}promise(){return Ue.create(this,this._def)}or(e){return at.create([this,e],this._def)}and(e){return it.create(this,e,this._def)}transform(e){return new B({...O(this._def),schema:this,typeName:w.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new lt({...O(this._def),innerType:this,defaultValue:t,typeName:w.ZodDefault})}brand(){return new sn({typeName:w.ZodBranded,type:this,...O(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new pt({...O(this._def),innerType:this,catchValue:t,typeName:w.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ht.create(this,e)}readonly(){return ft.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ts=/^c[^\s-]{8,}$/i,ns=/^[0-9a-z]+$/,ss=/^[0-9A-HJKMNP-TV-Z]{26}$/,rs=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,as=/^[a-z0-9_-]{21}$/i,is=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,os=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,cs="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let tn;const ds=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,us=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ls=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,yn="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ps=new RegExp(`^${yn}$`);function vn(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function hs(n){return new RegExp(`^${vn(n)}$`)}function wn(n){let e=`${yn}T${vn(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function fs(n,e){return!!((e==="v4"||!e)&&ds.test(n)||(e==="v6"||!e)&&us.test(n))}class F extends Z{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){const r=this._getOrReturnCtx(e);return f(r,{code:p.invalid_type,expected:_.string,received:r.parsedType}),x}const t=new $;let s;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:p.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="max")e.data.length>r.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:p.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="length"){const a=e.data.length>r.value,o=e.data.length<r.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?f(s,{code:p.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):o&&f(s,{code:p.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind==="email")os.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"email",code:p.invalid_string,message:r.message}),t.dirty());else if(r.kind==="emoji")tn||(tn=new RegExp(cs,"u")),tn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"emoji",code:p.invalid_string,message:r.message}),t.dirty());else if(r.kind==="uuid")rs.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"uuid",code:p.invalid_string,message:r.message}),t.dirty());else if(r.kind==="nanoid")as.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"nanoid",code:p.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid")ts.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid",code:p.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid2")ns.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid2",code:p.invalid_string,message:r.message}),t.dirty());else if(r.kind==="ulid")ss.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ulid",code:p.invalid_string,message:r.message}),t.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),f(s,{validation:"url",code:p.invalid_string,message:r.message}),t.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"regex",code:p.invalid_string,message:r.message}),t.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind==="datetime"?wn(r).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:"datetime",message:r.message}),t.dirty()):r.kind==="date"?ps.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:"date",message:r.message}),t.dirty()):r.kind==="time"?hs(r).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:"time",message:r.message}),t.dirty()):r.kind==="duration"?is.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"duration",code:p.invalid_string,message:r.message}),t.dirty()):r.kind==="ip"?fs(e.data,r.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ip",code:p.invalid_string,message:r.message}),t.dirty()):r.kind==="base64"?ls.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64",code:p.invalid_string,message:r.message}),t.dirty()):N.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement(r=>e.test(r),{validation:t,code:p.invalid_string,...y.errToObj(s)})}_addCheck(e){return new F({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...y.errToObj(e)})}datetime(e){var t,s;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(s=e==null?void 0:e.local)!==null&&s!==void 0?s:!1,...y.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...y.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...y.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...y.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...y.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...y.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...y.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...y.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...y.errToObj(t)})}nonempty(e){return this.min(1,y.errToObj(e))}trim(){return new F({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new F({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new F({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}F.create=n=>{var e;return new F({checks:[],typeName:w.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...O(n)})};function ms(n,e){const t=(n.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,r=t>s?t:s,a=parseInt(n.toFixed(r).replace(".","")),o=parseInt(e.toFixed(r).replace(".",""));return a%o/Math.pow(10,r)}class le extends Z{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_.number){const r=this._getOrReturnCtx(e);return f(r,{code:p.invalid_type,expected:_.number,received:r.parsedType}),x}let t;const s=new $;for(const r of this._def.checks)r.kind==="int"?N.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),f(t,{code:p.invalid_type,expected:"integer",received:"float",message:r.message}),s.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),s.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),s.dirty()):r.kind==="multipleOf"?ms(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.not_multiple_of,multipleOf:r.value,message:r.message}),s.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),f(t,{code:p.not_finite,message:r.message}),s.dirty()):N.assertNever(r);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,s,r){return new le({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:y.toString(r)}]})}_addCheck(e){return new le({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&N.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}le.create=n=>new le({checks:[],typeName:w.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...O(n)});class pe extends Z{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==_.bigint){const r=this._getOrReturnCtx(e);return f(r,{code:p.invalid_type,expected:_.bigint,received:r.parsedType}),x}let t;const s=new $;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),s.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),s.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.not_multiple_of,multipleOf:r.value,message:r.message}),s.dirty()):N.assertNever(r);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,s,r){return new pe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:y.toString(r)}]})}_addCheck(e){return new pe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}pe.create=n=>{var e;return new pe({checks:[],typeName:w.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...O(n)})};class nt extends Z{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.boolean,received:t.parsedType}),x}return D(e.data)}}nt.create=n=>new nt({typeName:w.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...O(n)});class Se extends Z{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){const r=this._getOrReturnCtx(e);return f(r,{code:p.invalid_type,expected:_.date,received:r.parsedType}),x}if(isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return f(r,{code:p.invalid_date}),x}const t=new $;let s;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:p.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:p.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):N.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Se({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:y.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Se.create=n=>new Se({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:w.ZodDate,...O(n)});class Mt extends Z{_parse(e){if(this._getType(e)!==_.symbol){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.symbol,received:t.parsedType}),x}return D(e.data)}}Mt.create=n=>new Mt({typeName:w.ZodSymbol,...O(n)});class st extends Z{_parse(e){if(this._getType(e)!==_.undefined){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.undefined,received:t.parsedType}),x}return D(e.data)}}st.create=n=>new st({typeName:w.ZodUndefined,...O(n)});class rt extends Z{_parse(e){if(this._getType(e)!==_.null){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.null,received:t.parsedType}),x}return D(e.data)}}rt.create=n=>new rt({typeName:w.ZodNull,...O(n)});class Me extends Z{constructor(){super(...arguments),this._any=!0}_parse(e){return D(e.data)}}Me.create=n=>new Me({typeName:w.ZodAny,...O(n)});class Ze extends Z{constructor(){super(...arguments),this._unknown=!0}_parse(e){return D(e.data)}}Ze.create=n=>new Ze({typeName:w.ZodUnknown,...O(n)});class ie extends Z{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.never,received:t.parsedType}),x}}ie.create=n=>new ie({typeName:w.ZodNever,...O(n)});class Lt extends Z{_parse(e){if(this._getType(e)!==_.undefined){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.void,received:t.parsedType}),x}return D(e.data)}}Lt.create=n=>new Lt({typeName:w.ZodVoid,...O(n)});class z extends Z{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),r=this._def;if(t.parsedType!==_.array)return f(t,{code:p.invalid_type,expected:_.array,received:t.parsedType}),x;if(r.exactLength!==null){const o=t.data.length>r.exactLength.value,c=t.data.length<r.exactLength.value;(o||c)&&(f(t,{code:o?p.too_big:p.too_small,minimum:c?r.exactLength.value:void 0,maximum:o?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(f(t,{code:p.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(f(t,{code:p.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>r.type._parseAsync(new Q(t,o,t.path,c)))).then(o=>$.mergeArray(s,o));const a=[...t.data].map((o,c)=>r.type._parseSync(new Q(t,o,t.path,c)));return $.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new z({...this._def,minLength:{value:e,message:y.toString(t)}})}max(e,t){return new z({...this._def,maxLength:{value:e,message:y.toString(t)}})}length(e,t){return new z({...this._def,exactLength:{value:e,message:y.toString(t)}})}nonempty(e){return this.min(1,e)}}z.create=(n,e)=>new z({type:n,minLength:null,maxLength:null,exactLength:null,typeName:w.ZodArray,...O(e)});function Le(n){if(n instanceof A){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=Y.create(Le(s))}return new A({...n._def,shape:()=>e})}else return n instanceof z?new z({...n._def,type:Le(n.element)}):n instanceof Y?Y.create(Le(n.unwrap())):n instanceof me?me.create(Le(n.unwrap())):n instanceof H?H.create(n.items.map(e=>Le(e))):n}class A extends Z{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=N.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==_.object){const d=this._getOrReturnCtx(e);return f(d,{code:p.invalid_type,expected:_.object,received:d.parsedType}),x}const{status:t,ctx:s}=this._processInputParams(e),{shape:r,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof ie&&this._def.unknownKeys==="strip"))for(const d in s.data)a.includes(d)||o.push(d);const c=[];for(const d of a){const u=r[d],l=s.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new Q(s,l,s.path,d)),alwaysSet:d in s.data})}if(this._def.catchall instanceof ie){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of o)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(d==="strict")o.length>0&&(f(s,{code:p.unrecognized_keys,keys:o}),t.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of o){const l=s.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new Q(s,l,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of c){const l=await u.key,T=await u.value;d.push({key:l,value:T,alwaysSet:u.alwaysSet})}return d}).then(d=>$.mergeObjectSync(t,d)):$.mergeObjectSync(t,c)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new A({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var r,a,o,c;const d=(o=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,t,s).message)!==null&&o!==void 0?o:s.defaultError;return t.code==="unrecognized_keys"?{message:(c=y.errToObj(e).message)!==null&&c!==void 0?c:d}:{message:d}}}:{}})}strip(){return new A({...this._def,unknownKeys:"strip"})}passthrough(){return new A({...this._def,unknownKeys:"passthrough"})}extend(e){return new A({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new A({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:w.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new A({...this._def,catchall:e})}pick(e){const t={};return N.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new A({...this._def,shape:()=>t})}omit(e){const t={};return N.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new A({...this._def,shape:()=>t})}deepPartial(){return Le(this)}partial(e){const t={};return N.objectKeys(this.shape).forEach(s=>{const r=this.shape[s];e&&!e[s]?t[s]=r:t[s]=r.optional()}),new A({...this._def,shape:()=>t})}required(e){const t={};return N.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let r=this.shape[s];for(;r instanceof Y;)r=r._def.innerType;t[s]=r}}),new A({...this._def,shape:()=>t})}keyof(){return kn(N.objectKeys(this.shape))}}A.create=(n,e)=>new A({shape:()=>n,unknownKeys:"strip",catchall:ie.create(),typeName:w.ZodObject,...O(e)}),A.strictCreate=(n,e)=>new A({shape:()=>n,unknownKeys:"strict",catchall:ie.create(),typeName:w.ZodObject,...O(e)}),A.lazycreate=(n,e)=>new A({shape:n,unknownKeys:"strip",catchall:ie.create(),typeName:w.ZodObject,...O(e)});class at extends Z{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function r(a){for(const c of a)if(c.result.status==="valid")return c.result;for(const c of a)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=a.map(c=>new V(c.ctx.common.issues));return f(t,{code:p.invalid_union,unionErrors:o}),x}if(t.common.async)return Promise.all(s.map(async a=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(r);{let a;const o=[];for(const d of s){const u={...t,common:{...t.common,issues:[]},parent:null},l=d._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const c=o.map(d=>new V(d));return f(t,{code:p.invalid_union,unionErrors:c}),x}}get options(){return this._def.options}}at.create=(n,e)=>new at({options:n,typeName:w.ZodUnion,...O(e)});const he=n=>n instanceof ct?he(n.schema):n instanceof B?he(n.innerType()):n instanceof dt?[n.value]:n instanceof fe?n.options:n instanceof ut?N.objectValues(n.enum):n instanceof lt?he(n._def.innerType):n instanceof st?[void 0]:n instanceof rt?[null]:n instanceof Y?[void 0,...he(n.unwrap())]:n instanceof me?[null,...he(n.unwrap())]:n instanceof sn||n instanceof ft?he(n.unwrap()):n instanceof pt?he(n._def.innerType):[];class Vt extends Z{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.object)return f(t,{code:p.invalid_type,expected:_.object,received:t.parsedType}),x;const s=this.discriminator,r=t.data[s],a=this.optionsMap.get(r);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(f(t,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const r=new Map;for(const a of t){const o=he(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(r.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);r.set(c,a)}}return new Vt({typeName:w.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...O(s)})}}function nn(n,e){const t=ue(n),s=ue(e);if(n===e)return{valid:!0,data:n};if(t===_.object&&s===_.object){const r=N.objectKeys(e),a=N.objectKeys(n).filter(c=>r.indexOf(c)!==-1),o={...n,...e};for(const c of a){const d=nn(n[c],e[c]);if(!d.valid)return{valid:!1};o[c]=d.data}return{valid:!0,data:o}}else if(t===_.array&&s===_.array){if(n.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<n.length;a++){const o=n[a],c=e[a],d=nn(o,c);if(!d.valid)return{valid:!1};r.push(d.data)}return{valid:!0,data:r}}else return t===_.date&&s===_.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class it extends Z{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=(a,o)=>{if(Xt(a)||Xt(o))return x;const c=nn(a.value,o.value);return c.valid?((en(a)||en(o))&&t.dirty(),{status:t.value,value:c.data}):(f(s,{code:p.invalid_intersection_types}),x)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,o])=>r(a,o)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}it.create=(n,e,t)=>new it({left:n,right:e,typeName:w.ZodIntersection,...O(t)});class H extends Z{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==_.array)return f(s,{code:p.invalid_type,expected:_.array,received:s.parsedType}),x;if(s.data.length<this._def.items.length)return f(s,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&s.data.length>this._def.items.length&&(f(s,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...s.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Q(s,a,s.path,o)):null}).filter(a=>!!a);return s.common.async?Promise.all(r).then(a=>$.mergeArray(t,a)):$.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new H({...this._def,rest:e})}}H.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new H({items:n,typeName:w.ZodTuple,rest:null,...O(e)})};class ot extends Z{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==_.object)return f(s,{code:p.invalid_type,expected:_.object,received:s.parsedType}),x;const r=[],a=this._def.keyType,o=this._def.valueType;for(const c in s.data)r.push({key:a._parse(new Q(s,c,s.path,c)),value:o._parse(new Q(s,s.data[c],s.path,c)),alwaysSet:c in s.data});return s.common.async?$.mergeObjectAsync(t,r):$.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof Z?new ot({keyType:e,valueType:t,typeName:w.ZodRecord,...O(s)}):new ot({keyType:F.create(),valueType:e,typeName:w.ZodRecord,...O(t)})}}class Ut extends Z{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==_.map)return f(s,{code:p.invalid_type,expected:_.map,received:s.parsedType}),x;const r=this._def.keyType,a=this._def.valueType,o=[...s.data.entries()].map(([c,d],u)=>({key:r._parse(new Q(s,c,s.path,[u,"key"])),value:a._parse(new Q(s,d,s.path,[u,"value"]))}));if(s.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const d of o){const u=await d.key,l=await d.value;if(u.status==="aborted"||l.status==="aborted")return x;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),c.set(u.value,l.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const d of o){const u=d.key,l=d.value;if(u.status==="aborted"||l.status==="aborted")return x;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),c.set(u.value,l.value)}return{status:t.value,value:c}}}}Ut.create=(n,e,t)=>new Ut({valueType:e,keyType:n,typeName:w.ZodMap,...O(t)});class je extends Z{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==_.set)return f(s,{code:p.invalid_type,expected:_.set,received:s.parsedType}),x;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(f(s,{code:p.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(f(s,{code:p.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const a=this._def.valueType;function o(d){const u=new Set;for(const l of d){if(l.status==="aborted")return x;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const c=[...s.data.values()].map((d,u)=>a._parse(new Q(s,d,s.path,u)));return s.common.async?Promise.all(c).then(d=>o(d)):o(c)}min(e,t){return new je({...this._def,minSize:{value:e,message:y.toString(t)}})}max(e,t){return new je({...this._def,maxSize:{value:e,message:y.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}je.create=(n,e)=>new je({valueType:n,minSize:null,maxSize:null,typeName:w.ZodSet,...O(e)});class Ve extends Z{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.function)return f(t,{code:p.invalid_type,expected:_.function,received:t.parsedType}),x;function s(c,d){return $t({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Rt(),De].filter(u=>!!u),issueData:{code:p.invalid_arguments,argumentsError:d}})}function r(c,d){return $t({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Rt(),De].filter(u=>!!u),issueData:{code:p.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Ue){const c=this;return D(async function(...d){const u=new V([]),l=await c._def.args.parseAsync(d,a).catch(C=>{throw u.addIssue(s(d,C)),u}),T=await Reflect.apply(o,this,l);return await c._def.returns._def.type.parseAsync(T,a).catch(C=>{throw u.addIssue(r(T,C)),u})})}else{const c=this;return D(function(...d){const u=c._def.args.safeParse(d,a);if(!u.success)throw new V([s(d,u.error)]);const l=Reflect.apply(o,this,u.data),T=c._def.returns.safeParse(l,a);if(!T.success)throw new V([r(l,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ve({...this._def,args:H.create(e).rest(Ze.create())})}returns(e){return new Ve({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new Ve({args:e||H.create([]).rest(Ze.create()),returns:t||Ze.create(),typeName:w.ZodFunction,...O(s)})}}class ct extends Z{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ct.create=(n,e)=>new ct({getter:n,typeName:w.ZodLazy,...O(e)});class dt extends Z{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:p.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}}dt.create=(n,e)=>new dt({value:n,typeName:w.ZodLiteral,...O(e)});function kn(n,e){return new fe({values:n,typeName:w.ZodEnum,...O(e)})}class fe extends Z{constructor(){super(...arguments),et.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return f(t,{expected:N.joinValues(s),received:t.parsedType,code:p.invalid_type}),x}if(Dt(this,et)||_n(this,et,new Set(this._def.values)),!Dt(this,et).has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return f(t,{received:t.data,code:p.invalid_enum_value,options:s}),x}return D(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return fe.create(e,{...this._def,...t})}exclude(e,t=this._def){return fe.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}et=new WeakMap,fe.create=kn;class ut extends Z{constructor(){super(...arguments),tt.set(this,void 0)}_parse(e){const t=N.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==_.string&&s.parsedType!==_.number){const r=N.objectValues(t);return f(s,{expected:N.joinValues(r),received:s.parsedType,code:p.invalid_type}),x}if(Dt(this,tt)||_n(this,tt,new Set(N.getValidEnumValues(this._def.values))),!Dt(this,tt).has(e.data)){const r=N.objectValues(t);return f(s,{received:s.data,code:p.invalid_enum_value,options:r}),x}return D(e.data)}get enum(){return this._def.values}}tt=new WeakMap,ut.create=(n,e)=>new ut({values:n,typeName:w.ZodNativeEnum,...O(e)});class Ue extends Z{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.promise&&t.common.async===!1)return f(t,{code:p.invalid_type,expected:_.promise,received:t.parsedType}),x;const s=t.parsedType===_.promise?t.data:Promise.resolve(t.data);return D(s.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ue.create=(n,e)=>new Ue({type:n,typeName:w.ZodPromise,...O(e)});class B extends Z{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===w.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:o=>{f(s,o),o.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const o=r.transform(s.data,a);if(s.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return x;const d=await this._def.schema._parseAsync({data:c,path:s.path,parent:s});return d.status==="aborted"?x:d.status==="dirty"||t.value==="dirty"?Pt(d.value):d});{if(t.value==="aborted")return x;const c=this._def.schema._parseSync({data:o,path:s.path,parent:s});return c.status==="aborted"?x:c.status==="dirty"||t.value==="dirty"?Pt(c.value):c}}if(r.type==="refinement"){const o=c=>{const d=r.refinement(c,a);if(s.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(s.common.async===!1){const c=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return c.status==="aborted"?x:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(c=>c.status==="aborted"?x:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(r.type==="transform")if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Ge(o))return o;const c=r.transform(o.value,a);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>Ge(o)?Promise.resolve(r.transform(o.value,a)).then(c=>({status:t.value,value:c})):o);N.assertNever(r)}}B.create=(n,e,t)=>new B({schema:n,typeName:w.ZodEffects,effect:e,...O(t)}),B.createWithPreprocess=(n,e,t)=>new B({schema:e,effect:{type:"preprocess",transform:n},typeName:w.ZodEffects,...O(t)});class Y extends Z{_parse(e){return this._getType(e)===_.undefined?D(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Y.create=(n,e)=>new Y({innerType:n,typeName:w.ZodOptional,...O(e)});class me extends Z{_parse(e){return this._getType(e)===_.null?D(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}me.create=(n,e)=>new me({innerType:n,typeName:w.ZodNullable,...O(e)});class lt extends Z{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===_.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}lt.create=(n,e)=>new lt({innerType:n,typeName:w.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...O(e)});class pt extends Z{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return Xe(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new V(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new V(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}pt.create=(n,e)=>new pt({innerType:n,typeName:w.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...O(e)});class Ft extends Z{_parse(e){if(this._getType(e)!==_.nan){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.nan,received:t.parsedType}),x}return{status:"valid",value:e.data}}}Ft.create=n=>new Ft({typeName:w.ZodNaN,...O(n)});const _s=Symbol("zod_brand");class sn extends Z{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class ht extends Z{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?x:r.status==="dirty"?(t.dirty(),Pt(r.value)):this._def.out._parseAsync({data:r.value,path:s.path,parent:s})})();{const r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?x:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(e,t){return new ht({in:e,out:t,typeName:w.ZodPipeline})}}class ft extends Z{_parse(e){const t=this._def.innerType._parse(e),s=r=>(Ge(r)&&(r.value=Object.freeze(r.value)),r);return Xe(t)?t.then(r=>s(r)):s(t)}unwrap(){return this._def.innerType}}ft.create=(n,e)=>new ft({innerType:n,typeName:w.ZodReadonly,...O(e)});function bn(n,e={},t){return n?Me.create().superRefine((s,r)=>{var a,o;if(!n(s)){const c=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,d=(o=(a=c.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0,u=typeof c=="string"?{message:c}:c;r.addIssue({code:"custom",...u,fatal:d})}}):Me.create()}const gs={object:A.lazycreate};var w;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(w||(w={}));const ys=(n,e={message:`Input not instance of ${n.name}`})=>bn(t=>t instanceof n,e),xn=F.create,Tn=le.create,vs=Ft.create,ws=pe.create,On=nt.create,ks=Se.create,bs=Mt.create,xs=st.create,Ts=rt.create,Os=Me.create,Ss=Ze.create,Zs=ie.create,js=Lt.create,Ns=z.create,Is=A.create,Cs=A.strictCreate,Es=at.create,As=Vt.create,Rs=it.create,$s=H.create,Ps=ot.create,Ds=Ut.create,Ms=je.create,Ls=Ve.create,Vs=ct.create,Us=dt.create,Fs=fe.create,zs=ut.create,Bs=Ue.create,Sn=B.create,Ws=Y.create,qs=me.create,Js=B.createWithPreprocess,Ks=ht.create;var i=Object.freeze({__proto__:null,defaultErrorMap:De,setErrorMap:Xn,getErrorMap:Rt,makeIssue:$t,EMPTY_PATH:es,addIssueToContext:f,ParseStatus:$,INVALID:x,DIRTY:Pt,OK:D,isAborted:Xt,isDirty:en,isValid:Ge,isAsync:Xe,get util(){return N},get objectUtil(){return Gt},ZodParsedType:_,getParsedType:ue,ZodType:Z,datetimeRegex:wn,ZodString:F,ZodNumber:le,ZodBigInt:pe,ZodBoolean:nt,ZodDate:Se,ZodSymbol:Mt,ZodUndefined:st,ZodNull:rt,ZodAny:Me,ZodUnknown:Ze,ZodNever:ie,ZodVoid:Lt,ZodArray:z,ZodObject:A,ZodUnion:at,ZodDiscriminatedUnion:Vt,ZodIntersection:it,ZodTuple:H,ZodRecord:ot,ZodMap:Ut,ZodSet:je,ZodFunction:Ve,ZodLazy:ct,ZodLiteral:dt,ZodEnum:fe,ZodNativeEnum:ut,ZodPromise:Ue,ZodEffects:B,ZodTransformer:B,ZodOptional:Y,ZodNullable:me,ZodDefault:lt,ZodCatch:pt,ZodNaN:Ft,BRAND:_s,ZodBranded:sn,ZodPipeline:ht,ZodReadonly:ft,custom:bn,Schema:Z,ZodSchema:Z,late:gs,get ZodFirstPartyTypeKind(){return w},coerce:{string:n=>F.create({...n,coerce:!0}),number:n=>le.create({...n,coerce:!0}),boolean:n=>nt.create({...n,coerce:!0}),bigint:n=>pe.create({...n,coerce:!0}),date:n=>Se.create({...n,coerce:!0})},any:Os,array:Ns,bigint:ws,boolean:On,date:ks,discriminatedUnion:As,effect:Sn,enum:Fs,function:Ls,instanceof:ys,intersection:Rs,lazy:Vs,literal:Us,map:Ds,nan:vs,nativeEnum:zs,never:Zs,null:Ts,nullable:qs,number:Tn,object:Is,oboolean:()=>On().optional(),onumber:()=>Tn().optional(),optional:Ws,ostring:()=>xn().optional(),pipeline:Ks,preprocess:Js,promise:Bs,record:Ps,set:Ms,strictObject:Cs,string:xn,symbol:bs,transformer:Sn,tuple:$s,undefined:xs,union:Es,unknown:Ss,void:js,NEVER:x,ZodIssueCode:p,quotelessJson:Gn,ZodError:V});Yn(i),i.object({start:i.number(),limit:i.number(),length:i.number()});const rn=i.object({created_at:i.string(),updated_at:i.string()}),Qs=i.object({email:i.string().optional(),email_verified:i.boolean().optional(),name:i.string().optional(),username:i.string().optional(),given_name:i.string().optional(),phone_number:i.string().optional(),phone_verified:i.boolean().optional(),family_name:i.string().optional()}).catchall(i.any()),Hs=i.object({connection:i.string(),user_id:i.string(),provider:i.string(),isSocial:i.boolean(),access_token:i.string().optional(),access_token_secret:i.string().optional(),refresh_token:i.string().optional(),profileData:Qs.optional()}),Zn=i.object({email:i.string().optional(),username:i.string().optional(),given_name:i.string().optional(),family_name:i.string().optional(),nickname:i.string().optional(),name:i.string().optional(),picture:i.string().optional(),locale:i.string().optional(),linked_to:i.string().optional(),profileData:i.string().optional(),user_id:i.string().optional()});Zn.extend({email_verified:i.boolean().default(!1),verify_email:i.boolean().optional(),last_ip:i.string().optional(),last_login:i.string().optional(),user_id:i.string().optional(),provider:i.string().default("email"),connection:i.string().default("email")}).extend(rn.shape).extend({user_id:i.string(),email:i.string(),is_social:i.boolean(),login_count:i.number(),identities:i.array(Hs).optional()}),Zn.extend({email:i.string(),login_count:i.number(),multifactor:i.array(i.string()).optional(),last_ip:i.string().optional(),last_login:i.string().optional(),user_id:i.string()}).catchall(i.any());const Ys=i.object({audience:i.string().optional(),recipient:i.string().optional(),createUpnClaim:i.boolean().optional(),mapUnknownClaimsAsIs:i.boolean().optional(),passthroughClaimsWithNoMapping:i.boolean().optional(),mapIdentities:i.boolean().optional(),signatureAlgorithm:i.string().optional(),digestAlgorithm:i.string().optional(),issuer:i.string().optional(),destination:i.string().optional(),lifetimeInSeconds:i.number().optional(),signResponse:i.boolean().optional(),nameIdentifierFormat:i.string().optional(),nameIdentifierProbes:i.array(i.string()).optional(),authnContextClassRef:i.string().optional(),mappings:i.record(i.string()).optional()}),Gs=i.object({id:i.string(),name:i.string(),callbacks:i.array(i.string()).openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:i.array(i.string()).openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:i.array(i.string()).openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:i.array(i.string()).openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),addons:i.object({samlp:Ys.optional()}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:i.enum(["enabled","disabled","enforced"]).default("enforced").openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:i.string().default(""),disable_sign_ups:i.boolean().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),Xs=i.object({created_at:i.string().transform(n=>n===null?"":n),updated_at:i.string().transform(n=>n===null?"":n),...Gs.shape});var jn=(n=>(n.TOKEN="token",n.TOKEN_ID_TOKEN="token id_token",n.CODE="code",n))(jn||{}),Nn=(n=>(n.QUERY="query",n.FRAGMENT="fragment",n.FORM_POST="form_post",n.WEB_MESSAGE="web_message",n.SAML_POST="saml_post",n))(Nn||{}),In=(n=>(n.S265="S256",n.plain="plain",n))(In||{});const zt=i.object({client_id:i.string(),vendor_id:i.string().optional(),response_type:i.nativeEnum(jn).optional(),response_mode:i.nativeEnum(Nn).optional(),redirect_uri:i.string().optional(),audience:i.string().optional(),state:i.string().optional(),nonce:i.string().optional(),scope:i.string().optional(),code_challenge_method:i.nativeEnum(In).optional(),code_challenge:i.string().optional(),username:i.string().optional()});i.object({colors:i.object({primary:i.string(),page_background:i.object({type:i.string().optional(),start:i.string().optional(),end:i.string().optional(),angle_deg:i.number().optional()}).optional()}).optional(),logo_url:i.string().optional(),favicon_url:i.string().optional(),font:i.object({url:i.string()}).optional()});const er=i.object({id:i.string().optional(),name:i.string(),client_id:i.string().optional(),client_secret:i.string().optional(),authorization_endpoint:i.string().optional(),response_type:i.custom().optional(),response_mode:i.custom().optional(),private_key:i.string().optional(),kid:i.string().optional(),team_id:i.string().optional(),token_endpoint:i.string().optional(),token_exchange_basic_auth:i.boolean().optional(),userinfo_endpoint:i.string().optional(),scope:i.string().optional()}),Cn=i.object({id:i.string(),created_at:i.string().transform(n=>n===null?"":n),updated_at:i.string().transform(n=>n===null?"":n)}).extend(er.shape),tr=i.object({name:i.string(),audience:i.string(),sender_email:i.string().email(),sender_name:i.string(),support_url:i.string().url().optional(),logo:i.string().url().optional(),primary_color:i.string().optional(),secondary_color:i.string().optional(),language:i.string().optional()}),nr=i.object({created_at:i.string().transform(n=>n===null?"":n),updated_at:i.string().transform(n=>n===null?"":n),id:i.string(),...tr.shape});i.object({logoUrl:i.string(),loginBackgroundImage:i.string().nullish(),style:i.object({primaryColor:i.string(),buttonTextColor:i.string(),primaryHoverColor:i.string()}),supportEmail:i.string().nullable(),supportUrl:i.string().nullable(),name:i.string(),showGreyishBackground:i.boolean().optional(),termsAndConditionsUrl:i.string().nullable(),companyName:i.string().optional(),checkoutHideSocial:i.boolean().optional(),siteUrl:i.string().nullable(),manageSubscriptionsUrl:i.string().optional()});const sr=i.object({domain:i.string(),dkim_private_key:i.string().optional(),dkim_public_key:i.string().optional(),email_api_key:i.string().optional(),email_service:i.union([i.literal("mailgun"),i.literal("mailchannels")]).optional()});i.object({...Xs.shape,domains:i.array(sr),tenant:nr,connections:i.array(Cn)});const rr=i.enum(["password_reset","email_verification","otp","oauth2","oauth2_state","ticket"]),ar=i.object({code_id:i.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:i.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:i.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:rr,expires_at:i.string(),used_at:i.string().optional()}),ir=i.object({...ar.shape,created_at:i.string()}),or=i.object({domain:i.string(),dkim_private_key:i.string().optional(),dkim_public_key:i.string().optional(),email_api_key:i.string().optional(),email_service:i.enum(["mailgun","mailchannels"])});rn.extend({...or.shape,id:i.string()}),i.object({trigger_id:i.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:i.boolean().default(!1),url:i.string(),hook_id:i.string().optional(),synchronous:i.boolean().default(!1),priority:i.number().optional()}).extend({...rn.shape,hook_id:i.string()});const cr=i.object({alg:i.string(),e:i.string(),kid:i.string(),kty:i.string(),n:i.string(),use:i.string().optional()});i.object({keys:i.array(cr)}),i.object({issuer:i.string(),authorization_endpoint:i.string(),token_endpoint:i.string(),device_authorization_endpoint:i.string(),userinfo_endpoint:i.string(),mfa_challenge_endpoint:i.string(),jwks_uri:i.string(),registration_endpoint:i.string(),revocation_endpoint:i.string(),scopes_supported:i.array(i.string()),response_types_supported:i.array(i.string()),code_challenge_methods_supported:i.array(i.string()),response_modes_supported:i.array(i.string()),subject_types_supported:i.array(i.string()),id_token_signing_alg_values_supported:i.array(i.string()),token_endpoint_auth_methods_supported:i.array(i.string()),claims_supported:i.array(i.string()),request_uri_parameter_supported:i.boolean(),request_parameter_supported:i.boolean(),token_endpoint_auth_signing_alg_values_supported:i.array(i.string())});const dr=i.object({auth0Client:i.string().optional(),authParams:zt,expires_at:i.string(),deleted_at:i.string().optional(),ip:i.string().optional()}).openapi({description:"This represents a login sesion"}),ur=i.object({...dr.shape,login_id:i.string().openapi({description:"This is is used as the state in the universal login"}),created_at:i.string(),updated_at:i.string()}),lr=i.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),pr=i.object({name:i.string(),version:i.string(),env:i.object({node:i.string().optional()}).optional()});i.object({type:lr,date:i.string(),description:i.string().optional(),log_id:i.string().optional(),_id:i.string().optional(),ip:i.string(),user_agent:i.string(),details:i.any().optional(),isMobile:i.boolean(),user_id:i.string().optional(),user_name:i.string().optional(),connection:i.string().optional(),connection_id:i.string().optional(),client_id:i.string().optional(),client_name:i.string().optional(),audience:i.string().optional(),scope:i.array(i.string()).optional(),strategy:i.string().optional(),strategy_type:i.string().optional(),hostname:i.string().optional(),auth0_client:pr.optional()});const hr=i.object({user_id:i.string(),password:i.string(),algorithm:i.enum(["bcrypt","argon2id"]).default("argon2id")});i.object({...hr.shape,created_at:i.string(),updated_at:i.string()});const fr=i.object({session_id:i.string(),client_id:i.string(),expires_at:i.string(),used_at:i.string(),deleted_at:i.string().optional(),user_id:i.string()});i.object({created_at:i.string(),...fr.shape}),i.object({private_key:i.string(),public_key:i.string(),kid:i.string(),created_at:i.string(),revoked_at:i.string().optional()}),i.object({kid:i.string().openapi({description:"The key id of the signing key"}),cert:i.string().openapi({description:"The public certificate of the signing key"}),fingerprint:i.string().openapi({description:"The cert fingerprint"}),thumbprint:i.string().openapi({description:"The cert thumbprint"}),pkcs7:i.string().optional().openapi({description:"The public certificate of the signing key in pkcs7 format"}),current:i.boolean().optional().openapi({description:"True if the key is the current key"}),next:i.boolean().optional().openapi({description:"True if the key is the next key"}),previous:i.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:i.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:i.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:i.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:i.string().optional().openapi({description:"The date and time when the key was revoked"})});var En=(n=>(n.RefreshToken="refresh_token",n.AuthorizationCode="authorization_code",n.ClientCredential="client_credentials",n.Passwordless="passwordless",n.Password="password",n))(En||{});const an=i.nativeEnum(En);i.object({grant_type:an.refine(n=>n==="authorization_code"),code:i.string(),client_secret:i.string(),client_id:i.string()}),i.object({grant_type:an.refine(n=>n==="authorization_code"),code:i.string(),code_verifier:i.string(),client_id:i.string().optional(),redirect_uri:i.string()}),i.object({grant_type:an.refine(n=>n==="client_credentials"),scope:i.string().optional(),client_secret:i.string(),client_id:i.string(),audience:i.string().optional()}),i.object({access_token:i.string(),id_token:i.string().optional(),scope:i.string().optional(),state:i.string().optional(),refresh_token:i.string().optional(),token_type:i.string(),expires_in:i.number()}),i.object({code:i.string(),state:i.string().optional()});const mr=i.object({button_border_radius:i.number(),button_border_weight:i.number(),buttons_style:i.enum(["pill"]),input_border_radius:i.number(),input_border_weight:i.number(),inputs_style:i.enum(["pill"]),show_widget_shadow:i.boolean(),widget_border_weight:i.number(),widget_corner_radius:i.number()}),_r=i.object({base_focus_color:i.string(),base_hover_color:i.string(),body_text:i.string(),captcha_widget_theme:i.enum(["auto"]),error:i.string(),header:i.string(),icons:i.string(),input_background:i.string(),input_border:i.string(),input_filled_text:i.string(),input_labels_placeholders:i.string(),links_focused_components:i.string(),primary_button:i.string(),primary_button_label:i.string(),secondary_button_border:i.string(),secondary_button_label:i.string(),success:i.string(),widget_background:i.string(),widget_border:i.string()}),Fe=i.object({bold:i.boolean(),size:i.number()}),gr=i.object({body_text:Fe,buttons_text:Fe,font_url:i.string(),input_labels:Fe,links:Fe,links_style:i.enum(["normal"]),reference_text_size:i.number(),subtitle:Fe,title:Fe}),yr=i.object({background_color:i.string(),background_image_url:i.string(),page_layout:i.enum(["center"])}),vr=i.object({header_text_alignment:i.enum(["center"]),logo_height:i.number(),logo_position:i.enum(["center"]),logo_url:i.string(),social_buttons_layout:i.enum(["bottom"])});i.object({borders:mr,colors:_r,displayName:i.string(),fonts:gr,page_background:yr,widget:vr}).extend({themeId:i.string()});const wr=i.object({id:i.string(),expires_at:i.string(),auth0Client:i.string().optional(),authParams:zt});i.object({...wr.shape,created_at:i.string(),updated_at:i.string()});const kr=i.object({id:i.string(),email:i.string(),code:i.string(),ip:i.string().optional(),send:i.enum(["code","link"]),authParams:zt,expires_at:i.string(),used_at:i.string().optional(),user_id:i.string().optional()});i.object({created_at:i.string(),...kr.shape});const br=i.object({authParams:zt,code:i.string(),user_id:i.string(),created_at:i.string(),expires_at:i.string(),used_at:i.string().optional()});i.object({...br.shape,created_at:i.string()});function on(n){const[e,t]=n.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${n}`);return{connection:e,id:t}}function An(n){let e={};try{e=JSON.parse(n.profileData||"{}")}catch(t){console.error("Error parsing profileData",t)}return{connection:n.connection,provider:n.provider,user_id:on(n.user_id).id,isSocial:!!n.is_social,profileData:{email:n.email,email_verified:!!n.email_verified,...e}}}function xr(n){return async(e,t)=>{const[s,r]=await Promise.all([n.selectFrom("users").where("users.tenant_id","=",e).where("users.user_id","=",t).selectAll().executeTakeFirst(),n.selectFrom("users").where("users.tenant_id","=",e).where("users.linked_to","=",t).selectAll().execute()]);if(!s)return null;const{tenant_id:a,...o}=s,c={...o,email:s.email||"",email_verified:s.email_verified===1,is_social:s.is_social===1,identities:[{connection:s.connection,provider:s.provider,user_id:on(s.user_id).id,isSocial:!!s.is_social},...r.map(An)]};return E(c)}}function Ne(n,e,t,s){return t.split(/\s+/).map(a=>a.replace(/^([^:]+)=/g,"$1:")).map(a=>{let o=a.startsWith("-"),c,d,u,l;return a.startsWith("-_exists_:")?(c=a.substring(10),u=!0,o=!0):a.startsWith("_exists_:")?(c=a.substring(9),u=!0,o=!1):a.includes(":")?(o=a.startsWith("-"),[c,d]=o?a.substring(1).split(":"):a.split(":"),u=!1,d.startsWith(">=")?(l=">=",d=d.substring(2)):d.startsWith(">")?(l=">",d=d.substring(1)):d.startsWith("<=")?(console.log("value",d),l="<=",d=d.substring(2)):d.startsWith("<")?(l="<",d=d.substring(1)):l="="):(c=null,d=a,u=!1),{key:c,value:d,isNegation:o,isExistsQuery:u,operator:l}}).forEach(({key:a,value:o,isNegation:c,isExistsQuery:d,operator:u})=>{if(a)if(d)c?e=e.where(a,"is",null):e=e.where(a,"is not",null);else if(c)switch(u){case">":e=e.where(a,"<=",o);break;case">=":e=e.where(a,"<",o);break;case"<":e=e.where(a,">=",o);break;case"<=":e=e.where(a,">",o);break;default:e=e.where(a,"!=",o)}else e=e.where(a,u,o);else{const{ref:l}=n.dynamic;e=e.where(T=>T.or(s.map(C=>T(l(C),"like",`%${o}%`))))}}),e}function _e(n){return typeof n=="string"?parseInt(n,10):typeof n=="bigint"?Number(n):n}function Tr(n){return async(e,t)=>{let s=n.selectFrom("users").where("users.tenant_id","=",e);if(t.q&&(s=Ne(n,s,t.q,["email","name"])),t.sort&&t.sort.sort_by){const{ref:l}=n.dynamic;s=s.orderBy(l(t.sort.sort_by),t.sort.sort_order)}const a=await s.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),o=a.map(l=>l.user_id),c=o.length?await n.selectFrom("users").selectAll().where("users.tenant_id","=",e).where("users.linked_to","in",o).execute():[],d=a.map(l=>{const T=c.filter(C=>C.linked_to===l.user_id);return E({...l,email_verified:l.email_verified===1,is_social:l.is_social===1,identities:[{connection:l.connection,provider:l.provider,user_id:on(l.user_id).id,isSocial:!!l.is_social},...T.map(An)]})}),{count:u}=await s.select(l=>l.fn.countAll().as("count")).executeTakeFirstOrThrow();return{users:d,start:t.page*t.per_page,limit:t.per_page,length:_e(u)}}}function Or(n){return async(e,t)=>(await n.deleteFrom("users").where("users.tenant_id","=",e).where("users.linked_to","=",t).execute(),(await n.deleteFrom("users").where("users.tenant_id","=",e).where("users.user_id","=",t).execute()).length===1)}function Sr(n){if(n.email_verified!==void 0)return n.email_verified?1:0}function Zr(n){return async(e,t,s)=>{const r={...s,email_verified:Sr(s),updated_at:new Date().toISOString()};return(await n.updateTable("users").set(r).where("users.tenant_id","=",e).where("users.user_id","=",t).execute()).length===1}}function jr(n){return async(e,t,s,r)=>{const a={linked_to:null};return(await n.updateTable("users").set(a).where("users.tenant_id","=",e).where("users.user_id","=",`${s}|${r}`).where("users.linked_to","=",`${t}`).execute()).length===1}}function Nr(n){return{create:ae(n),remove:Or(n),get:xr(n),list:Tr(n),update:Zr(n),unlink:jr(n)}}const Ir="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ie=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n));for(;n--;)e+=Ir[t[n]&63];return e};function Cr(n){return async e=>{const t={id:e.id||Ie(),created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...e};return await n.insertInto("tenants").values(t).execute(),t}}function Er(n){return async e=>{const t=await n.selectFrom("tenants").where("tenants.id","=",e).selectAll().executeTakeFirst();return t?E(t):null}}function Ar(n){return async e=>{let t=n.selectFrom("tenants");if(e.sort&&e.sort.sort_by){const{ref:c}=n.dynamic;t=t.orderBy(c(e.sort.sort_by),e.sort.sort_order)}e.q&&(t=t.where(c=>c.or([c("name","like",`%${e.q}%`)])));const r=await t.offset(e.page*e.per_page).limit(e.per_page).selectAll().execute();if(!e.include_totals)return{tenants:r};const{count:a}=await t.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow(),o=_e(a);return{tenants:r.map(E),start:(e.page-1)*e.per_page,limit:e.per_page,length:o}}}function Rr(n){return async(e,t)=>{const s={...t,id:e,updated_at:new Date().toISOString()};await n.updateTable("tenants").set(s).where("id","=",e).execute()}}function $r(n){return async e=>(await n.deleteFrom("tenants").where("tenants.id","=",e).execute()).length===1}function Pr(n){return{create:Cr(n),get:Er(n),list:Ar(n),update:Rr(n),remove:$r(n)}}function Rn(n){return n?JSON.stringify(n):void 0}const Dr=1024;function Mr(n){return async(e,t)=>{var r,a,o;const s={id:Ie(),...t,user_agent:t.user_agent.slice(0,Dr)};return await n.insertInto("logs").values({...s,description:(r=s.description)==null?void 0:r.substring(0,256),isMobile:t.isMobile?1:0,tenant_id:e,scope:(a=t.scope)==null?void 0:a.join(","),auth0_client:Rn(t.auth0_client),details:(o=Rn(t.details))==null?void 0:o.substring(0,8192)}).execute(),s}}function $n(n){if(!n)return"";try{return JSON.parse(n)}catch{return n}}function Pn(n){return{...n,client_id:n.client_id,client_name:"",auth0_client:$n(n.auth0_client),details:$n(n.details),isMobile:!!n.isMobile,scope:n.scope?n.scope.split(","):void 0,log_id:n.id,_id:n.id}}function Lr(n){return async(e,t)=>{let s=n.selectFrom("logs").where("logs.tenant_id","=",e);t.q&&(s=Ne(n,s,t.q,["user_id","ip"]));let r=s;if(t.sort&&t.sort.sort_by){const{ref:c}=n.dynamic;r=r.orderBy(c(t.sort.sort_by),t.sort.sort_order)}r=r.offset(t.page*t.per_page).limit(t.per_page);const a=await r.selectAll().execute(),{count:o}=await s.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{logs:a.map(Pn),start:t.page*t.per_page,limit:t.per_page,length:_e(o)}}}function Vr(n){return async(e,t)=>{const s=await n.selectFrom("logs").where("logs.tenant_id","=",e).where("logs.id","=",t).selectAll().executeTakeFirst();return s?Pn(s):null}}function Ur(n){return{create:Mr(n),list:Lr(n),get:Vr(n)}}function Fr(n){return async(e,t)=>await n.selectFrom("sessions").where("sessions.tenant_id","=",e).where("sessions.session_id","=",t).where("sessions.deleted_at","is",null).selectAll().executeTakeFirst()??null}function zr(n){return async(e,t)=>{const s={...t,created_at:new Date().toISOString(),expires_at:new Date().toISOString()};return await n.insertInto("sessions").values({...s,tenant_id:e}).execute(),{...t,...s}}}function Br(n){return async(e,t)=>!!(await n.updateTable("sessions").set({deleted_at:new Date().toISOString()}).where("tenant_id","=",e).where("sessions.session_id","=",t).where("sessions.deleted_at","is",null).execute()).length}function Wr(n){return async(e,t,s)=>!!(await n.updateTable("sessions").set(s).where("tenant_id","=",e).where("sessions.session_id","=",t).where("sessions.deleted_at","is",null).execute()).length}function qr(n){return async(e,t)=>{let s=n.selectFrom("sessions").where("sessions.tenant_id","=",e);t.q&&(s=Ne(n,s,t.q,["user_id","session_id"]));let r=s;if(t.sort&&t.sort.sort_by){const{ref:d}=n.dynamic;r=r.orderBy(d(t.sort.sort_by),t.sort.sort_order)}r=r.offset(t.page*t.per_page).limit(t.per_page);const a=await r.selectAll().execute(),{count:o}=await s.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow(),c=_e(o);return{sessions:a,start:t.page*t.per_page,limit:t.per_page,length:c}}}function Jr(n){return{create:zr(n),get:Fr(n),list:qr(n),remove:Br(n),update:Wr(n)}}function Kr(n){return async(e,t)=>{const s=await n.selectFrom("tickets").where("tickets.tenant_id","=",e).where("tickets.id","=",t).where("tickets.used_at","is",null).selectAll().executeTakeFirst();if(!s)return null;const{nonce:r,state:a,scope:o,response_type:c,response_mode:d,redirect_uri:u,...l}=s;return{...l,authParams:{nonce:r,state:a,scope:o,response_type:c,response_mode:d,redirect_uri:u},created_at:new Date(s.created_at),expires_at:new Date(s.expires_at),used_at:s.used_at?new Date(s.used_at):void 0}}}function Qr(n){return async e=>{const{authParams:t,...s}=e,r={...s,...t,created_at:e.created_at.toISOString(),expires_at:e.expires_at.toISOString(),used_at:e.used_at?e.used_at.toISOString():void 0};await n.insertInto("tickets").values(r).execute()}}function Hr(n){return async(e,t)=>{await n.updateTable("tickets").set({used_at:new Date().toISOString()}).where("tickets.tenant_id","=",e).where("tickets.id","=",t).execute()}}function Yr(n){return{create:Qr(n),get:Kr(n),remove:Hr(n)}}function Gr(n){return async(e,t)=>{const s=new Date().toISOString();return(await n.selectFrom("otps").where("otps.tenant_id","=",e).where("otps.email","=",t).where("otps.expires_at",">",s).where("otps.used_at","is",null).selectAll().execute()).map(a=>{const{nonce:o,state:c,scope:d,response_type:u,redirect_uri:l,client_id:T,...C}=a;return{...C,client_id:T,authParams:{client_id:T,nonce:o,state:c,scope:d,response_type:u,redirect_uri:l},created_at:a.created_at,expires_at:a.expires_at}})}}function Xr(n){return async(e,t)=>{const{authParams:s,...r}=t;await n.insertInto("otps").values({...r,...s,created_at:new Date().toISOString(),tenant_id:e,send:t.send==="code"?"code":"link"}).execute()}}function ea(n){return async(e,t)=>(await n.updateTable("otps").set({used_at:new Date().toISOString()}).where("otps.tenant_id","=",e).where("otps.id","=",t).execute()).length>0}function ta(n){return{create:Xr(n),list:Gr(n),remove:ea(n)}}function na(n){return async(e,t)=>{const s=await n.selectFrom("passwords").where("passwords.tenant_id","=",e).where("passwords.user_id","=",t).selectAll().executeTakeFirstOrThrow(),{tenant_id:r,...a}=s;return a}}function sa(n){return async(e,t)=>{const s={...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("passwords").values({...s,tenant_id:e}).execute(),s}}function ra(n){return async(e,t)=>(await n.updateTable("passwords").set({password:t.password,updated_at:new Date().toISOString()}).where("tenant_id","=",e).where("user_id","=",t.user_id).execute()).length===1}function aa(n){return{create:sa(n),update:ra(n),get:na(n)}}function ia(n){return async(e,t)=>{let s=n.selectFrom("codes").where("codes.tenant_id","=",e);t.q&&(s=Ne(n,s,t.q,["code","login_id"]));const a=await s.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await s.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{codes:a.map(d=>{const{tenant_id:u,...l}=d;return ir.parse(E(l))}),start:t.page*t.per_page,limit:t.per_page,length:_e(o)}}}function oa(n){return async(e,t)=>{const s={...t,created_at:new Date().toISOString()};return await n.insertInto("codes").values({...s,tenant_id:e}).execute(),s}}function ca(n){return async(e,t)=>(await n.deleteFrom("codes").where("codes.tenant_id","=",e).where("codes.code_id","=",t).executeTakeFirst()).numDeletedRows>0}function da(n){return async(e,t,s)=>{const r=await n.selectFrom("codes").where("codes.code_id","=",t).where("codes.code_type","=",s).where("codes.expires_at",">",new Date().toISOString()).selectAll().executeTakeFirst();return r?E(r):null}}function ua(n){return{create:oa(n),list:ia(n),remove:ca(n),get:da(n)}}function la(n){return async e=>{const t=new Date().toISOString(),s=await n.selectFrom("universal_login_sessions").where("universal_login_sessions.expires_at",">",t).where("universal_login_sessions.id","=",e).selectAll().executeTakeFirst();if(!s)return null;const{response_type:r,response_mode:a,redirect_uri:o,audience:c,state:d,nonce:u,scope:l,code_challenge_method:T,code_challenge:C,username:L,vendor_id:te,...de}=s;return{...de,authParams:{client_id:de.client_id,vendor_id:te,response_type:r,response_mode:a,redirect_uri:o,audience:c,state:d,nonce:u,scope:l,code_challenge_method:T,code_challenge:C,username:L}}}}function pa(n){return async(e,t)=>{const{authParams:s,...r}=t,a={created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("universal_login_sessions").values({...s,...r,...a,tenant_id:e}).execute(),{...t,...a}}}function ha(n){return async(e,t,s)=>{const{authParams:r,...a}=s;return(await n.updateTable("universal_login_sessions").set({...r,...a}).where("id","=",t).where("tenant_id","=",e).execute()).length===1}}function fa(n){return{create:pa(n),get:la(n),update:ha(n)}}function ma(n){return async(e,t)=>{const s={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...t},r=JSON.stringify(t.allowed_origins),a=JSON.stringify(t.callbacks),o=JSON.stringify(t.web_origins),c=JSON.stringify(t.allowed_logout_urls);return await n.insertInto("applications").values({...s,tenant_id:e,disable_sign_ups:t.disable_sign_ups?1:0,addons:t.addons?JSON.stringify(t.addons):"{}",callbacks:a,allowed_origins:r,web_origins:o,allowed_logout_urls:c}).execute(),s}}function _a(n){return async e=>({applications:(await n.selectFrom("applications").where("applications.tenant_id","=",e).selectAll().execute()).map(a=>({...a,disable_sign_ups:!!a.disable_sign_ups,addons:a.addons?JSON.parse(a.addons):{},callbacks:a.callbacks?JSON.parse(a.callbacks):[],allowed_origins:a.allowed_origins?JSON.parse(a.allowed_origins):[],web_origins:a.web_origins?JSON.parse(a.web_origins):[],allowed_logout_urls:a.allowed_logout_urls?JSON.parse(a.allowed_logout_urls):[]}))})}function ga(n){return async(e,t)=>{const s=await n.selectFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",t).selectAll().executeTakeFirst();return s?E({...s,disable_sign_ups:!!s.disable_sign_ups,addons:JSON.parse(s.addons),callbacks:JSON.parse(s.callbacks),allowed_origins:JSON.parse(s.allowed_origins),web_origins:JSON.parse(s.web_origins),allowed_logout_urls:JSON.parse(s.allowed_logout_urls)}):null}}function ya(n){return async(e,t)=>(await n.deleteFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",t).executeTakeFirst()).numDeletedRows>0}function va(n){return async(e,t,s)=>{const r={...s,updated_at:new Date().toISOString(),allowed_origins:s.allowed_origins?JSON.stringify(s.allowed_origins):void 0,callbacks:s.callbacks?JSON.stringify(s.callbacks):void 0,web_origins:s.web_origins?JSON.stringify(s.web_origins):void 0,allowed_logout_urls:s.allowed_logout_urls?JSON.stringify(s.allowed_logout_urls):void 0,addons:s.addons?JSON.stringify(s.addons):"{}",disable_sign_ups:s.disable_sign_ups?1:0};return await n.updateTable("applications").set(r).where("applications.id","=",t).where("applications.tenant_id","=",e).execute(),!0}}function wa(n){return{create:ma(n),list:_a(n),get:ga(n),remove:ya(n),update:va(n)}}function ka(n){return async(e,t)=>{const s={id:Ie(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("connections").values({...s,tenant_id:e}).execute(),s}}function ba(n){return async(e,t)=>{let s=n.selectFrom("connections").where("connections.tenant_id","=",e);t.q&&(s=Ne(n,s,t.q,["user_id","ip"]));const a=await s.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await s.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{connections:a.map(E),start:t.page*t.per_page,limit:t.per_page,length:_e(o)}}}function xa(n){return async(e,t)=>(await n.deleteFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",t).executeTakeFirst()).numDeletedRows>0}function Ta(n){return async(e,t)=>{const s=await n.selectFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",t).selectAll().executeTakeFirst();return s?E(s):null}}function Oa(n){return async(e,t,s)=>{const r={...s,updated_at:new Date().toISOString()};return await n.updateTable("connections").set(r).where("connections.id","=",t).where("connections.tenant_id","=",e).execute(),!0}}function Sa(n){return{create:ka(n),get:Ta(n),list:ba(n),remove:xa(n),update:Oa(n)}}function Za(n){return{get:async e=>{const t=await n.selectFrom("applications").selectAll().where("id","=",e).executeTakeFirst();if(!t)return null;const s=await n.selectFrom("tenants").selectAll().where("id","=",t.tenant_id).executeTakeFirst();if(!s)throw new K(404,{message:"Tenant not found"});const r=await n.selectFrom("connections").where("tenant_id","=",t.tenant_id).selectAll().execute(),a=await n.selectFrom("domains").where("tenant_id","=",t.tenant_id).selectAll().execute();return{...t,connections:r.map(c=>Cn.parse(E(c))),domains:a,addons:t.addons?JSON.parse(t.addons):{},callbacks:t.callbacks?JSON.parse(t.callbacks):[],allowed_origins:t.allowed_origins?JSON.parse(t.allowed_origins):[],web_origins:t.web_origins?JSON.parse(t.web_origins):[],allowed_logout_urls:t.allowed_logout_urls?JSON.parse(t.allowed_logout_urls):[],tenant:E(s),disable_sign_ups:!!t.disable_sign_ups}}}}function ja(n){return async()=>await n.selectFrom("keys").where("revoked_at","is",null).selectAll().execute()}function Na(n){return async e=>{await n.insertInto("keys").values(e).execute()}}function Ia(n){return async(e,t)=>!!(await n.updateTable("keys").set({revoked_at:t.toISOString()}).where("kid","=",e).execute()).length}function Ca(n){return{create:Na(n),list:ja(n),revoke:Ia(n)}}function Ea(n){return async(e,t)=>{const s={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,id:Ie(),...t};return await n.insertInto("domains").values(s).execute(),s}}function Aa(n){return async(e,t)=>{let s=n.selectFrom("domains").where("domains.tenant_id","=",e);t.q&&(s=Ne(n,s,t.q,["user_id","ip"]));const a=await s.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await s.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{domains:a,start:t.page*t.per_page,limit:t.per_page,length:_e(o)}}}function Ra(n){return{create:Ea(n),list:Aa(n)}}function $a(n){return async e=>{const[t]=await n.selectFrom("branding").where("branding.tenant_id","=",e).selectAll().execute();if(!t)return null;const{tenant_id:s,colors_primary:r,colors_page_background_type:a,colors_page_background_start:o,colors_page_background_end:c,colors_page_background_angle_dev:d,font_url:u,...l}=t;return E({...l,colors:{primary:r,page_background:{type:a,start:o,end:c,angle_deg:d}},font:u?{url:u}:void 0})}}function Pa(n){return async(e,t)=>{var o,c,d,u,l,T,C,L,te,de,be,xe,Te,Qe,He,ne,se,re;const{colors:s,font:r,...a}=t;try{await n.insertInto("branding").values({...a,colors_primary:s==null?void 0:s.primary,colors_page_background_type:(c=(o=t.colors)==null?void 0:o.page_background)==null?void 0:c.type,colors_page_background_start:(u=(d=t.colors)==null?void 0:d.page_background)==null?void 0:u.start,colors_page_background_end:(T=(l=t.colors)==null?void 0:l.page_background)==null?void 0:T.end,colors_page_background_angle_dev:(L=(C=t.colors)==null?void 0:C.page_background)==null?void 0:L.angle_deg,font_url:(te=t.font)==null?void 0:te.url,tenant_id:e}).execute()}catch{await n.updateTable("branding").set({...a,colors_primary:s==null?void 0:s.primary,colors_page_background_type:(be=(de=t.colors)==null?void 0:de.page_background)==null?void 0:be.type,colors_page_background_start:(Te=(xe=t.colors)==null?void 0:xe.page_background)==null?void 0:Te.start,colors_page_background_end:(He=(Qe=t.colors)==null?void 0:Qe.page_background)==null?void 0:He.end,colors_page_background_angle_dev:(se=(ne=t.colors)==null?void 0:ne.page_background)==null?void 0:se.angle_deg,font_url:(re=t.font)==null?void 0:re.url}).where("tenant_id","=",e).execute()}}}function Da(n){return{get:$a(n),set:Pa(n)}}function Ma(n){return async(e,t)=>{const s=await n.selectFrom("authentication_codes").where("tenant_id","=",e).where("code","=",t).selectAll().executeTakeFirst();if(!s)throw new K(403,{message:"Code not found or expired"});const{state:r,nonce:a,scope:o,client_id:c,response_type:d,response_mode:u,redirect_uri:l,...T}=s;return{...T,authParams:{state:r,nonce:a,scope:o,client_id:c,response_type:d,response_mode:u,redirect_uri:l}}}}function La(n){return async(e,t)=>{const{authParams:s,...r}=t;await n.insertInto("authentication_codes").values({...r,...s,tenant_id:e}).execute()}}function Va(n){return{create:La(n),get:Ma(n)}}function Ua(n){return async(e,t)=>{let s=n.selectFrom("hooks").where("hooks.tenant_id","=",e);t.q&&(s=Ne(n,s,t.q,["url"]));const a=await s.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await s.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{hooks:a.map(d=>{const{tenant_id:u,enabled:l,synchronous:T,...C}=d;return E({...C,enabled:!!l,synchronous:!!T})}),start:t.page*t.per_page,limit:t.per_page,length:_e(o)}}}function Fa(n){return async(e,t)=>{const s=await n.selectFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",t).selectAll().executeTakeFirst();return s?(s.enabled=!!s.enabled,s.synchronous=!!s.synchronous,E(s)):null}}function za(n){return async(e,t)=>(await n.deleteFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",t).executeTakeFirst()).numDeletedRows>0}function Ba(n){return async(e,t)=>{const s={hook_id:Ie(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("hooks").values({...s,tenant_id:e}).execute(),s}}function Wa(n){return async(e,t,s)=>{const r={...s,updated_at:new Date().toISOString()};return await n.updateTable("hooks").set(r).where("hooks.hook_id","=",t).where("hooks.tenant_id","=",e).execute(),!0}}function qa(n){return{create:Ba(n),get:Fa(n),list:Ua(n),update:Wa(n),remove:za(n)}}function Ja(n,e){var t={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(n);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(n,s[r])&&(t[s[r]]=n[s[r]]);return t}typeof SuppressedError=="function"&&SuppressedError;function Ka(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function mt(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...s){const r=t.apply(this,s);return r._def.openapi=this._def.openapi,r}}function Qa(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(r,a){var o,c,d,u,l,T;const C=typeof r=="string"?a:r,L=C??{},{param:te}=L,de=Ja(L,["param"]),be=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof r=="string"?{refId:r}:void 0),xe=Object.assign(Object.assign(Object.assign({},(c=this._def.openapi)===null||c===void 0?void 0:c.metadata),de),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||te?{param:Object.assign(Object.assign({},(T=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||T===void 0?void 0:T.param),te)}:void 0),Te=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(be).length>0?{_internal:be}:void 0),Object.keys(xe).length>0?{metadata:xe}:void 0)}));if(Ka(this,"ZodObject")){const Qe=this.extend;Te.extend=function(...He){var ne,se,re,Oe,Re,$e;const Pe=Qe.apply(this,He);return Pe._def.openapi={_internal:{extendedFrom:!((se=(ne=this._def.openapi)===null||ne===void 0?void 0:ne._internal)===null||se===void 0)&&se.refId?{refId:(Oe=(re=this._def.openapi)===null||re===void 0?void 0:re._internal)===null||Oe===void 0?void 0:Oe.refId,schema:this}:(Re=this._def.openapi)===null||Re===void 0?void 0:Re._internal.extendedFrom},metadata:($e=Pe._def.openapi)===null||$e===void 0?void 0:$e.metadata},Pe}}return Te},mt(n,"optional"),mt(n,"nullable"),mt(n,"default"),mt(n,"transform"),mt(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const r=this._def.shape(),a=e.apply(this),o=a._def.shape();return Object.entries(o).forEach(([c,d])=>{var u,l;d._def.openapi=(l=(u=r[c])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...r){const a=t.apply(this,r);return a._def.openapi=void 0,a};const s=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...r){const a=s.apply(this,r);return a._def.openapi=void 0,a}}new Set(".\\+*[^]$()");var I;(function(n){n.assertEqual=r=>r;function e(r){}n.assertIs=e;function t(r){throw new Error}n.assertNever=t,n.arrayToEnum=r=>{const a={};for(const o of r)a[o]=o;return a},n.getValidEnumValues=r=>{const a=n.objectKeys(r).filter(c=>typeof r[r[c]]!="number"),o={};for(const c of a)o[c]=r[c];return n.objectValues(o)},n.objectValues=r=>n.objectKeys(r).map(function(a){return r[a]}),n.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&a.push(o);return a},n.find=(r,a)=>{for(const o of r)if(a(o))return o},n.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function s(r,a=" | "){return r.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}n.joinValues=s,n.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(I||(I={}));var cn;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(cn||(cn={}));const g=I.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ge=n=>{switch(typeof n){case"undefined":return g.undefined;case"string":return g.string;case"number":return isNaN(n)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(n)?g.array:n===null?g.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?g.promise:typeof Map<"u"&&n instanceof Map?g.map:typeof Set<"u"&&n instanceof Set?g.set:typeof Date<"u"&&n instanceof Date?g.date:g.object;default:return g.unknown}},h=I.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ha=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class U extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},s={_errors:[]},r=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(r);else if(o.code==="invalid_return_type")r(o.returnTypeError);else if(o.code==="invalid_arguments")r(o.argumentsError);else if(o.path.length===0)s._errors.push(t(o));else{let c=s,d=0;for(;d<o.path.length;){const u=o.path[d];d===o.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(o))):c[u]=c[u]||{_errors:[]},c=c[u],d++}}};return r(this),s}static assert(e){if(!(e instanceof U))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,I.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):s.push(e(r));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}U.create=n=>new U(n);const ze=(n,e)=>{let t;switch(n.code){case h.invalid_type:n.received===g.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case h.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,I.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:t=`Unrecognized key(s) in object: ${I.joinValues(n.keys,", ")}`;break;case h.invalid_union:t="Invalid input";break;case h.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${I.joinValues(n.options)}`;break;case h.invalid_enum_value:t=`Invalid enum value. Expected ${I.joinValues(n.options)}, received '${n.received}'`;break;case h.invalid_arguments:t="Invalid function arguments";break;case h.invalid_return_type:t="Invalid function return type";break;case h.invalid_date:t="Invalid date";break;case h.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:I.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case h.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case h.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case h.custom:t="Invalid input";break;case h.invalid_intersection_types:t="Intersection results could not be merged";break;case h.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case h.not_finite:t="Number must be finite";break;default:t=e.defaultError,I.assertNever(n)}return{message:t}};let Dn=ze;function Ya(n){Dn=n}function Bt(){return Dn}const Wt=n=>{const{data:e,path:t,errorMaps:s,issueData:r}=n,a=[...t,...r.path||[]],o={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let c="";const d=s.filter(u=>!!u).slice().reverse();for(const u of d)c=u(o,{data:e,defaultError:c}).message;return{...r,path:a,message:c}},Ga=[];function m(n,e){const t=Bt(),s=Wt({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===ze?void 0:ze].filter(r=>!!r)});n.common.issues.push(s)}class P{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const r of t){if(r.status==="aborted")return b;r.status==="dirty"&&e.dirty(),s.push(r.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const r of t){const a=await r.key,o=await r.value;s.push({key:a,value:o})}return P.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const r of t){const{key:a,value:o}=r;if(a.status==="aborted"||o.status==="aborted")return b;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||r.alwaysSet)&&(s[a.value]=o.value)}return{status:e.value,value:s}}}const b=Object.freeze({status:"aborted"}),Be=n=>({status:"dirty",value:n}),M=n=>({status:"valid",value:n}),dn=n=>n.status==="aborted",un=n=>n.status==="dirty",_t=n=>n.status==="valid",gt=n=>typeof Promise<"u"&&n instanceof Promise;function qt(n,e,t,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Mn(n,e,t,s,r){if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}typeof SuppressedError=="function"&&SuppressedError;var v;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(v||(v={}));var yt,vt;class G{constructor(e,t,s,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ln=(n,e)=>{if(_t(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new U(n.common.issues);return this._error=t,this._error}}};function S(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:r}=n;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(o,c)=>{var d,u;const{message:l}=n;return o.code==="invalid_enum_value"?{message:l??c.defaultError}:typeof c.data>"u"?{message:(d=l??s)!==null&&d!==void 0?d:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(u=l??t)!==null&&u!==void 0?u:c.defaultError}},description:r}}class j{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return ge(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ge(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new P,ctx:{common:e.parent.common,data:e.data,parsedType:ge(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(gt(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const r={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)},a=this._parseSync({data:e,path:r.path,parent:r});return Ln(r,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)},r=this._parse({data:e,path:s.path,parent:s}),a=await(gt(r)?r:Promise.resolve(r));return Ln(s,a)}refine(e,t){const s=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,a)=>{const o=e(r),c=()=>a.addIssue({code:h.custom,...s(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((s,r)=>e(s)?!0:(r.addIssue(typeof t=="function"?t(s,r):t),!1))}_refinement(e){return new J({schema:this,typeName:k.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ee.create(this,this._def)}nullable(){return ke.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return q.create(this,this._def)}promise(){return Ke.create(this,this._def)}or(e){return xt.create([this,e],this._def)}and(e){return Tt.create(this,e,this._def)}transform(e){return new J({...S(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Nt({...S(this._def),innerType:this,defaultValue:t,typeName:k.ZodDefault})}brand(){return new hn({typeName:k.ZodBranded,type:this,...S(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new It({...S(this._def),innerType:this,catchValue:t,typeName:k.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ct.create(this,e)}readonly(){return Et.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Xa=/^c[^\s-]{8,}$/i,ei=/^[0-9a-z]+$/,ti=/^[0-9A-HJKMNP-TV-Z]{26}$/,ni=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,si=/^[a-z0-9_-]{21}$/i,ri=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ai=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ii="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ln;const oi=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ci=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,di=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Vn="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ui=new RegExp(`^${Vn}$`);function Un(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function li(n){return new RegExp(`^${Un(n)}$`)}function Fn(n){let e=`${Vn}T${Un(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function pi(n,e){return!!((e==="v4"||!e)&&oi.test(n)||(e==="v6"||!e)&&ci.test(n))}class W extends j{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.string,received:a.parsedType}),b}const s=new P;let r;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){const o=e.data.length>a.value,c=e.data.length<a.value;(o||c)&&(r=this._getOrReturnCtx(e,r),o?m(r,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):c&&m(r,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")ai.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"email",code:h.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")ln||(ln=new RegExp(ii,"u")),ln.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"emoji",code:h.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")ni.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"uuid",code:h.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")si.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"nanoid",code:h.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")Xa.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"cuid",code:h.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")ei.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"cuid2",code:h.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")ti.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"ulid",code:h.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),m(r,{validation:"url",code:h.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"regex",code:h.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?Fn(a).test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?ui.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?li(a).test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?ri.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"duration",code:h.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?pi(e.data,a.version)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"ip",code:h.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?di.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"base64",code:h.invalid_string,message:a.message}),s.dirty()):I.assertNever(a);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(r=>e.test(r),{validation:t,code:h.invalid_string,...v.errToObj(s)})}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...v.errToObj(e)})}url(e){return this._addCheck({kind:"url",...v.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...v.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...v.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...v.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...v.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...v.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...v.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...v.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...v.errToObj(e)})}datetime(e){var t,s;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(s=e==null?void 0:e.local)!==null&&s!==void 0?s:!1,...v.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...v.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...v.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...v.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...v.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...v.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...v.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...v.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...v.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...v.errToObj(t)})}nonempty(e){return this.min(1,v.errToObj(e))}trim(){return new W({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}W.create=n=>{var e;return new W({checks:[],typeName:k.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...S(n)})};function hi(n,e){const t=(n.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,r=t>s?t:s,a=parseInt(n.toFixed(r).replace(".","")),o=parseInt(e.toFixed(r).replace(".",""));return a%o/Math.pow(10,r)}class ye extends j{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==g.number){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.number,received:a.parsedType}),b}let s;const r=new P;for(const a of this._def.checks)a.kind==="int"?I.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:h.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?hi(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:h.not_finite,message:a.message}),r.dirty()):I.assertNever(a);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,s,r){return new ye({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:v.toString(r)}]})}_addCheck(e){return new ye({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:v.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:v.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&I.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ye.create=n=>new ye({checks:[],typeName:k.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...S(n)});class ve extends j{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==g.bigint){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.bigint,received:a.parsedType}),b}let s;const r=new P;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):I.assertNever(a);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,s,r){return new ve({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:v.toString(r)}]})}_addCheck(e){return new ve({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ve.create=n=>{var e;return new ve({checks:[],typeName:k.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...S(n)})};class wt extends j{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){const s=this._getOrReturnCtx(e);return m(s,{code:h.invalid_type,expected:g.boolean,received:s.parsedType}),b}return M(e.data)}}wt.create=n=>new wt({typeName:k.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...S(n)});class Ce extends j{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.date,received:a.parsedType}),b}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_date}),b}const s=new P;let r;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):I.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ce({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:v.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:v.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Ce.create=n=>new Ce({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:k.ZodDate,...S(n)});class Jt extends j{_parse(e){if(this._getType(e)!==g.symbol){const s=this._getOrReturnCtx(e);return m(s,{code:h.invalid_type,expected:g.symbol,received:s.parsedType}),b}return M(e.data)}}Jt.create=n=>new Jt({typeName:k.ZodSymbol,...S(n)});class kt extends j{_parse(e){if(this._getType(e)!==g.undefined){const s=this._getOrReturnCtx(e);return m(s,{code:h.invalid_type,expected:g.undefined,received:s.parsedType}),b}return M(e.data)}}kt.create=n=>new kt({typeName:k.ZodUndefined,...S(n)});class bt extends j{_parse(e){if(this._getType(e)!==g.null){const s=this._getOrReturnCtx(e);return m(s,{code:h.invalid_type,expected:g.null,received:s.parsedType}),b}return M(e.data)}}bt.create=n=>new bt({typeName:k.ZodNull,...S(n)});class We extends j{constructor(){super(...arguments),this._any=!0}_parse(e){return M(e.data)}}We.create=n=>new We({typeName:k.ZodAny,...S(n)});class Ee extends j{constructor(){super(...arguments),this._unknown=!0}_parse(e){return M(e.data)}}Ee.create=n=>new Ee({typeName:k.ZodUnknown,...S(n)});class oe extends j{_parse(e){const t=this._getOrReturnCtx(e);return m(t,{code:h.invalid_type,expected:g.never,received:t.parsedType}),b}}oe.create=n=>new oe({typeName:k.ZodNever,...S(n)});class Kt extends j{_parse(e){if(this._getType(e)!==g.undefined){const s=this._getOrReturnCtx(e);return m(s,{code:h.invalid_type,expected:g.void,received:s.parsedType}),b}return M(e.data)}}Kt.create=n=>new Kt({typeName:k.ZodVoid,...S(n)});class q extends j{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),r=this._def;if(t.parsedType!==g.array)return m(t,{code:h.invalid_type,expected:g.array,received:t.parsedType}),b;if(r.exactLength!==null){const o=t.data.length>r.exactLength.value,c=t.data.length<r.exactLength.value;(o||c)&&(m(t,{code:o?h.too_big:h.too_small,minimum:c?r.exactLength.value:void 0,maximum:o?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(m(t,{code:h.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(m(t,{code:h.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>r.type._parseAsync(new G(t,o,t.path,c)))).then(o=>P.mergeArray(s,o));const a=[...t.data].map((o,c)=>r.type._parseSync(new G(t,o,t.path,c)));return P.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new q({...this._def,minLength:{value:e,message:v.toString(t)}})}max(e,t){return new q({...this._def,maxLength:{value:e,message:v.toString(t)}})}length(e,t){return new q({...this._def,exactLength:{value:e,message:v.toString(t)}})}nonempty(e){return this.min(1,e)}}q.create=(n,e)=>new q({type:n,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...S(e)});function qe(n){if(n instanceof R){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=ee.create(qe(s))}return new R({...n._def,shape:()=>e})}else return n instanceof q?new q({...n._def,type:qe(n.element)}):n instanceof ee?ee.create(qe(n.unwrap())):n instanceof ke?ke.create(qe(n.unwrap())):n instanceof X?X.create(n.items.map(e=>qe(e))):n}class R extends j{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=I.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==g.object){const u=this._getOrReturnCtx(e);return m(u,{code:h.invalid_type,expected:g.object,received:u.parsedType}),b}const{status:s,ctx:r}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof oe&&this._def.unknownKeys==="strip"))for(const u in r.data)o.includes(u)||c.push(u);const d=[];for(const u of o){const l=a[u],T=r.data[u];d.push({key:{status:"valid",value:u},value:l._parse(new G(r,T,r.path,u)),alwaysSet:u in r.data})}if(this._def.catchall instanceof oe){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of c)d.push({key:{status:"valid",value:l},value:{status:"valid",value:r.data[l]}});else if(u==="strict")c.length>0&&(m(r,{code:h.unrecognized_keys,keys:c}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of c){const T=r.data[l];d.push({key:{status:"valid",value:l},value:u._parse(new G(r,T,r.path,l)),alwaysSet:l in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of d){const T=await l.key,C=await l.value;u.push({key:T,value:C,alwaysSet:l.alwaysSet})}return u}).then(u=>P.mergeObjectSync(s,u)):P.mergeObjectSync(s,d)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new R({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var r,a,o,c;const d=(o=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,t,s).message)!==null&&o!==void 0?o:s.defaultError;return t.code==="unrecognized_keys"?{message:(c=v.errToObj(e).message)!==null&&c!==void 0?c:d}:{message:d}}}:{}})}strip(){return new R({...this._def,unknownKeys:"strip"})}passthrough(){return new R({...this._def,unknownKeys:"passthrough"})}extend(e){return new R({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new R({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:k.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new R({...this._def,catchall:e})}pick(e){const t={};return I.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new R({...this._def,shape:()=>t})}omit(e){const t={};return I.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new R({...this._def,shape:()=>t})}deepPartial(){return qe(this)}partial(e){const t={};return I.objectKeys(this.shape).forEach(s=>{const r=this.shape[s];e&&!e[s]?t[s]=r:t[s]=r.optional()}),new R({...this._def,shape:()=>t})}required(e){const t={};return I.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof ee;)a=a._def.innerType;t[s]=a}}),new R({...this._def,shape:()=>t})}keyof(){return zn(I.objectKeys(this.shape))}}R.create=(n,e)=>new R({shape:()=>n,unknownKeys:"strip",catchall:oe.create(),typeName:k.ZodObject,...S(e)}),R.strictCreate=(n,e)=>new R({shape:()=>n,unknownKeys:"strict",catchall:oe.create(),typeName:k.ZodObject,...S(e)}),R.lazycreate=(n,e)=>new R({shape:n,unknownKeys:"strip",catchall:oe.create(),typeName:k.ZodObject,...S(e)});class xt extends j{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function r(a){for(const c of a)if(c.result.status==="valid")return c.result;for(const c of a)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=a.map(c=>new U(c.ctx.common.issues));return m(t,{code:h.invalid_union,unionErrors:o}),b}if(t.common.async)return Promise.all(s.map(async a=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(r);{let a;const o=[];for(const d of s){const u={...t,common:{...t.common,issues:[]},parent:null},l=d._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const c=o.map(d=>new U(d));return m(t,{code:h.invalid_union,unionErrors:c}),b}}get options(){return this._def.options}}xt.create=(n,e)=>new xt({options:n,typeName:k.ZodUnion,...S(e)});const ce=n=>n instanceof St?ce(n.schema):n instanceof J?ce(n.innerType()):n instanceof Zt?[n.value]:n instanceof we?n.options:n instanceof jt?I.objectValues(n.enum):n instanceof Nt?ce(n._def.innerType):n instanceof kt?[void 0]:n instanceof bt?[null]:n instanceof ee?[void 0,...ce(n.unwrap())]:n instanceof ke?[null,...ce(n.unwrap())]:n instanceof hn||n instanceof Et?ce(n.unwrap()):n instanceof It?ce(n._def.innerType):[];class Qt extends j{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.object)return m(t,{code:h.invalid_type,expected:g.object,received:t.parsedType}),b;const s=this.discriminator,r=t.data[s],a=this.optionsMap.get(r);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(m(t,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),b)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const r=new Map;for(const a of t){const o=ce(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(r.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);r.set(c,a)}}return new Qt({typeName:k.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...S(s)})}}function pn(n,e){const t=ge(n),s=ge(e);if(n===e)return{valid:!0,data:n};if(t===g.object&&s===g.object){const r=I.objectKeys(e),a=I.objectKeys(n).filter(c=>r.indexOf(c)!==-1),o={...n,...e};for(const c of a){const d=pn(n[c],e[c]);if(!d.valid)return{valid:!1};o[c]=d.data}return{valid:!0,data:o}}else if(t===g.array&&s===g.array){if(n.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<n.length;a++){const o=n[a],c=e[a],d=pn(o,c);if(!d.valid)return{valid:!1};r.push(d.data)}return{valid:!0,data:r}}else return t===g.date&&s===g.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Tt extends j{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=(a,o)=>{if(dn(a)||dn(o))return b;const c=pn(a.value,o.value);return c.valid?((un(a)||un(o))&&t.dirty(),{status:t.value,value:c.data}):(m(s,{code:h.invalid_intersection_types}),b)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,o])=>r(a,o)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}Tt.create=(n,e,t)=>new Tt({left:n,right:e,typeName:k.ZodIntersection,...S(t)});class X extends j{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==g.array)return m(s,{code:h.invalid_type,expected:g.array,received:s.parsedType}),b;if(s.data.length<this._def.items.length)return m(s,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),b;!this._def.rest&&s.data.length>this._def.items.length&&(m(s,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map((o,c)=>{const d=this._def.items[c]||this._def.rest;return d?d._parse(new G(s,o,s.path,c)):null}).filter(o=>!!o);return s.common.async?Promise.all(a).then(o=>P.mergeArray(t,o)):P.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new X({...this._def,rest:e})}}X.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new X({items:n,typeName:k.ZodTuple,rest:null,...S(e)})};class Ot extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==g.object)return m(s,{code:h.invalid_type,expected:g.object,received:s.parsedType}),b;const r=[],a=this._def.keyType,o=this._def.valueType;for(const c in s.data)r.push({key:a._parse(new G(s,c,s.path,c)),value:o._parse(new G(s,s.data[c],s.path,c)),alwaysSet:c in s.data});return s.common.async?P.mergeObjectAsync(t,r):P.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof j?new Ot({keyType:e,valueType:t,typeName:k.ZodRecord,...S(s)}):new Ot({keyType:W.create(),valueType:e,typeName:k.ZodRecord,...S(t)})}}class Ht extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==g.map)return m(s,{code:h.invalid_type,expected:g.map,received:s.parsedType}),b;const r=this._def.keyType,a=this._def.valueType,o=[...s.data.entries()].map(([c,d],u)=>({key:r._parse(new G(s,c,s.path,[u,"key"])),value:a._parse(new G(s,d,s.path,[u,"value"]))}));if(s.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const d of o){const u=await d.key,l=await d.value;if(u.status==="aborted"||l.status==="aborted")return b;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),c.set(u.value,l.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const d of o){const u=d.key,l=d.value;if(u.status==="aborted"||l.status==="aborted")return b;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),c.set(u.value,l.value)}return{status:t.value,value:c}}}}Ht.create=(n,e,t)=>new Ht({valueType:e,keyType:n,typeName:k.ZodMap,...S(t)});class Ae extends j{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==g.set)return m(s,{code:h.invalid_type,expected:g.set,received:s.parsedType}),b;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(m(s,{code:h.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(m(s,{code:h.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const a=this._def.valueType;function o(d){const u=new Set;for(const l of d){if(l.status==="aborted")return b;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const c=[...s.data.values()].map((d,u)=>a._parse(new G(s,d,s.path,u)));return s.common.async?Promise.all(c).then(d=>o(d)):o(c)}min(e,t){return new Ae({...this._def,minSize:{value:e,message:v.toString(t)}})}max(e,t){return new Ae({...this._def,maxSize:{value:e,message:v.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ae.create=(n,e)=>new Ae({valueType:n,minSize:null,maxSize:null,typeName:k.ZodSet,...S(e)});class Je extends j{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.function)return m(t,{code:h.invalid_type,expected:g.function,received:t.parsedType}),b;function s(c,d){return Wt({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Bt(),ze].filter(u=>!!u),issueData:{code:h.invalid_arguments,argumentsError:d}})}function r(c,d){return Wt({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Bt(),ze].filter(u=>!!u),issueData:{code:h.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Ke){const c=this;return M(async function(...d){const u=new U([]),l=await c._def.args.parseAsync(d,a).catch(L=>{throw u.addIssue(s(d,L)),u}),T=await Reflect.apply(o,this,l);return await c._def.returns._def.type.parseAsync(T,a).catch(L=>{throw u.addIssue(r(T,L)),u})})}else{const c=this;return M(function(...d){const u=c._def.args.safeParse(d,a);if(!u.success)throw new U([s(d,u.error)]);const l=Reflect.apply(o,this,u.data),T=c._def.returns.safeParse(l,a);if(!T.success)throw new U([r(l,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Je({...this._def,args:X.create(e).rest(Ee.create())})}returns(e){return new Je({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new Je({args:e||X.create([]).rest(Ee.create()),returns:t||Ee.create(),typeName:k.ZodFunction,...S(s)})}}class St extends j{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}St.create=(n,e)=>new St({getter:n,typeName:k.ZodLazy,...S(e)});class Zt extends j{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return m(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),b}return{status:"valid",value:e.data}}get value(){return this._def.value}}Zt.create=(n,e)=>new Zt({value:n,typeName:k.ZodLiteral,...S(e)});function zn(n,e){return new we({values:n,typeName:k.ZodEnum,...S(e)})}class we extends j{constructor(){super(...arguments),yt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return m(t,{expected:I.joinValues(s),received:t.parsedType,code:h.invalid_type}),b}if(qt(this,yt)||Mn(this,yt,new Set(this._def.values)),!qt(this,yt).has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return m(t,{received:t.data,code:h.invalid_enum_value,options:s}),b}return M(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return we.create(e,{...this._def,...t})}exclude(e,t=this._def){return we.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}yt=new WeakMap,we.create=zn;class jt extends j{constructor(){super(...arguments),vt.set(this,void 0)}_parse(e){const t=I.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==g.string&&s.parsedType!==g.number){const r=I.objectValues(t);return m(s,{expected:I.joinValues(r),received:s.parsedType,code:h.invalid_type}),b}if(qt(this,vt)||Mn(this,vt,new Set(I.getValidEnumValues(this._def.values))),!qt(this,vt).has(e.data)){const r=I.objectValues(t);return m(s,{received:s.data,code:h.invalid_enum_value,options:r}),b}return M(e.data)}get enum(){return this._def.values}}vt=new WeakMap,jt.create=(n,e)=>new jt({values:n,typeName:k.ZodNativeEnum,...S(e)});class Ke extends j{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.promise&&t.common.async===!1)return m(t,{code:h.invalid_type,expected:g.promise,received:t.parsedType}),b;const s=t.parsedType===g.promise?t.data:Promise.resolve(t.data);return M(s.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ke.create=(n,e)=>new Ke({type:n,typeName:k.ZodPromise,...S(e)});class J extends j{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:o=>{m(s,o),o.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const o=r.transform(s.data,a);if(s.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return b;const d=await this._def.schema._parseAsync({data:c,path:s.path,parent:s});return d.status==="aborted"?b:d.status==="dirty"||t.value==="dirty"?Be(d.value):d});{if(t.value==="aborted")return b;const c=this._def.schema._parseSync({data:o,path:s.path,parent:s});return c.status==="aborted"?b:c.status==="dirty"||t.value==="dirty"?Be(c.value):c}}if(r.type==="refinement"){const o=c=>{const d=r.refinement(c,a);if(s.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(s.common.async===!1){const c=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return c.status==="aborted"?b:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(c=>c.status==="aborted"?b:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(r.type==="transform")if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!_t(o))return o;const c=r.transform(o.value,a);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>_t(o)?Promise.resolve(r.transform(o.value,a)).then(c=>({status:t.value,value:c})):o);I.assertNever(r)}}J.create=(n,e,t)=>new J({schema:n,typeName:k.ZodEffects,effect:e,...S(t)}),J.createWithPreprocess=(n,e,t)=>new J({schema:e,effect:{type:"preprocess",transform:n},typeName:k.ZodEffects,...S(t)});class ee extends j{_parse(e){return this._getType(e)===g.undefined?M(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ee.create=(n,e)=>new ee({innerType:n,typeName:k.ZodOptional,...S(e)});class ke extends j{_parse(e){return this._getType(e)===g.null?M(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ke.create=(n,e)=>new ke({innerType:n,typeName:k.ZodNullable,...S(e)});class Nt extends j{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===g.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Nt.create=(n,e)=>new Nt({innerType:n,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...S(e)});class It extends j{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return gt(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new U(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new U(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}It.create=(n,e)=>new It({innerType:n,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...S(e)});class Yt extends j{_parse(e){if(this._getType(e)!==g.nan){const s=this._getOrReturnCtx(e);return m(s,{code:h.invalid_type,expected:g.nan,received:s.parsedType}),b}return{status:"valid",value:e.data}}}Yt.create=n=>new Yt({typeName:k.ZodNaN,...S(n)});const fi=Symbol("zod_brand");class hn extends j{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ct extends j{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?b:a.status==="dirty"?(t.dirty(),Be(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{const r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?b:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(e,t){return new Ct({in:e,out:t,typeName:k.ZodPipeline})}}class Et extends j{_parse(e){const t=this._def.innerType._parse(e),s=r=>(_t(r)&&(r.value=Object.freeze(r.value)),r);return gt(t)?t.then(r=>s(r)):s(t)}unwrap(){return this._def.innerType}}Et.create=(n,e)=>new Et({innerType:n,typeName:k.ZodReadonly,...S(e)});function Bn(n,e={},t){return n?We.create().superRefine((s,r)=>{var a,o;if(!n(s)){const c=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,d=(o=(a=c.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0,u=typeof c=="string"?{message:c}:c;r.addIssue({code:"custom",...u,fatal:d})}}):We.create()}const mi={object:R.lazycreate};var k;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(k||(k={}));const _i=(n,e={message:`Input not instance of ${n.name}`})=>Bn(t=>t instanceof n,e),Wn=W.create,qn=ye.create,gi=Yt.create,yi=ve.create,Jn=wt.create,vi=Ce.create,wi=Jt.create,ki=kt.create,bi=bt.create,xi=We.create,Ti=Ee.create,Oi=oe.create,Si=Kt.create,Zi=q.create,ji=R.create,Ni=R.strictCreate,Ii=xt.create,Ci=Qt.create,Ei=Tt.create,Ai=X.create,Ri=Ot.create,$i=Ht.create,Pi=Ae.create,Di=Je.create,Mi=St.create,Li=Zt.create,Vi=we.create,Ui=jt.create,Fi=Ke.create,Kn=J.create,zi=ee.create,Bi=ke.create,Wi=J.createWithPreprocess,qi=Ct.create;var Ji=Object.freeze({__proto__:null,defaultErrorMap:ze,setErrorMap:Ya,getErrorMap:Bt,makeIssue:Wt,EMPTY_PATH:Ga,addIssueToContext:m,ParseStatus:P,INVALID:b,DIRTY:Be,OK:M,isAborted:dn,isDirty:un,isValid:_t,isAsync:gt,get util(){return I},get objectUtil(){return cn},ZodParsedType:g,getParsedType:ge,ZodType:j,datetimeRegex:Fn,ZodString:W,ZodNumber:ye,ZodBigInt:ve,ZodBoolean:wt,ZodDate:Ce,ZodSymbol:Jt,ZodUndefined:kt,ZodNull:bt,ZodAny:We,ZodUnknown:Ee,ZodNever:oe,ZodVoid:Kt,ZodArray:q,ZodObject:R,ZodUnion:xt,ZodDiscriminatedUnion:Qt,ZodIntersection:Tt,ZodTuple:X,ZodRecord:Ot,ZodMap:Ht,ZodSet:Ae,ZodFunction:Je,ZodLazy:St,ZodLiteral:Zt,ZodEnum:we,ZodNativeEnum:jt,ZodPromise:Ke,ZodEffects:J,ZodTransformer:J,ZodOptional:ee,ZodNullable:ke,ZodDefault:Nt,ZodCatch:It,ZodNaN:Yt,BRAND:fi,ZodBranded:hn,ZodPipeline:Ct,ZodReadonly:Et,custom:Bn,Schema:j,ZodSchema:j,late:mi,get ZodFirstPartyTypeKind(){return k},coerce:{string:n=>W.create({...n,coerce:!0}),number:n=>ye.create({...n,coerce:!0}),boolean:n=>wt.create({...n,coerce:!0}),bigint:n=>ve.create({...n,coerce:!0}),date:n=>Ce.create({...n,coerce:!0})},any:xi,array:Zi,bigint:yi,boolean:Jn,date:vi,discriminatedUnion:Ci,effect:Kn,enum:Vi,function:Di,instanceof:_i,intersection:Ei,lazy:Mi,literal:Li,map:$i,nan:gi,nativeEnum:Ui,never:Oi,null:bi,nullable:Bi,number:qn,object:ji,oboolean:()=>Jn().optional(),onumber:()=>qn().optional(),optional:zi,ostring:()=>Wn().optional(),pipeline:qi,preprocess:Wi,promise:Fi,record:Ri,set:Pi,strictObject:Ni,string:Wn,symbol:wi,transformer:Kn,tuple:Ai,undefined:ki,union:Ii,unknown:Ti,void:Si,NEVER:b,ZodIssueCode:h,quotelessJson:Ha,ZodError:U});Qa(Ji);function At(n,e="",t={}){for(let s in n)if(Object.prototype.hasOwnProperty.call(n,s)){const r=e?`${e}_${s}`:s;typeof n[s]=="object"&&n[s]!==null&&!Array.isArray(n[s])?At(n[s],r,t):t[r]=n[s]}return t}function Ki(n,e){const t={};for(const[s,r]of Object.entries(n)){const a=e.find(o=>s.startsWith(`${o}_`));if(!a)t[s]=r;else{const o=s.slice(a.length+1);t[a]={...t[a],[o]:r}}}return t}function Qi(n){return async(e,t)=>{const s={themeId:Ie(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("themes").values({...At(s),tenant_id:e}).execute(),s}}function Hi(n){return async(e,t)=>(await n.deleteFrom("themes").where("themes.tenant_id","=",e).where("themes.theme_id","=",t).executeTakeFirst()).numDeletedRows>0}function Yi(n){return async(e,t)=>{const s=await n.selectFrom("themes").where("themes.tenant_id","=",e).where("themes.theme_id","=",t).selectAll().executeTakeFirst();return s?E(s):null}}function Gi(n){return async(e,t,s)=>{const r=At({...s,updated_at:new Date().toISOString()});return await n.updateTable("themes").set(r).where("themes.id","=",t).where("themes.tenant_id","=",e).execute(),!0}}function Xi(n){return{create:Qi(n),get:Yi(n),remove:Hi(n),update:Gi(n)}}function eo(n){return async(e,t)=>{const s=new Date().toISOString(),r=await n.selectFrom("logins").where("logins.expires_at",">",s).where("logins.login_id","=",t).selectAll().executeTakeFirst();return r?ur.parse(Ki(E(r),["authParams"])):null}}function to(n){return async(e,t)=>{const s={login_id:Ie(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("logins").values({...At(s),tenant_id:e}).execute(),s}}function no(n){return async(e,t,s)=>(await n.updateTable("logins").set(At(s)).where("logins.login_id","=",t).where("logins.tenant_id","=",e).execute()).length===1}function so(n){return async(e,t)=>(await n.deleteFrom("logins").where("logins.tenant_id","=",e).where("logins.login_id","=",t).execute()).length>0}function ro(n){return{create:to(n),get:eo(n),update:no(n),remove:so(n)}}function ao(n){return{applications:wa(n),authenticationCodes:Va(n),branding:Da(n),clients:Za(n),codes:ua(n),connections:Sa(n),domains:Ra(n),hooks:qa(n),keys:Ca(n),logins:ro(n),logs:Ur(n),OTP:ta(n),passwords:aa(n),users:Nr(n),sessions:Jr(n),tenants:Pr(n),themes:Xi(n),tickets:Yr(n),universalLoginSessions:fa(n)}}return ao}();
|
|
1
|
+
var kyselyAdapter=function(){"use strict";var io=Object.defineProperty;var oo=(K,ae,E)=>ae in K?io(K,ae,{enumerable:!0,configurable:!0,writable:!0,value:E}):K[ae]=E;var fn=(K,ae,E)=>oo(K,typeof ae!="symbol"?ae+"":ae,E);var K=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});fn(this,"res");fn(this,"status");this.res=t==null?void 0:t.res,this.status=e}getResponse(){return this.res?new Response(this.res.body,{status:this.status,headers:this.res.headers}):new Response(this.message,{status:this.status})}};function ae(n){return async(e,t)=>{const{identities:s,...r}=t,a={...r,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,email_verified:t.email_verified?1:0,is_social:t.is_social?1:0};try{await n.insertInto("users").values(a).execute()}catch(o){throw o.code==="SQLITE_CONSTRAINT_UNIQUE"||o.message.includes("AlreadyExists")?new K(409,{message:"User already exists"}):(console.log(o.message),new K(500,{message:`${o.code}, ${o.message}`}))}return{...a,email:a.email||"",email_verified:a.email_verified===1,is_social:a.is_social===1}}}function E(n){const e={...n};for(const t in e)e[t]===null?delete e[t]:typeof e[t]=="object"&&(Array.isArray(e[t])?e[t]=e[t].map(E):e[t]=E(e[t]));return e}function Qn(n,e){var t={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(n);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(n,s[r])&&(t[s[r]]=n[s[r]]);return t}function Hn(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function Ye(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...s){const r=t.apply(this,s);return r._def.openapi=this._def.openapi,r}}function Yn(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(r,a){var o,c,d,u,l,T;const C=typeof r=="string"?a:r,L=C??{},{param:te}=L,de=Qn(L,["param"]),be=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof r=="string"?{refId:r}:void 0),xe=Object.assign(Object.assign(Object.assign({},(c=this._def.openapi)===null||c===void 0?void 0:c.metadata),de),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||te?{param:Object.assign(Object.assign({},(T=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||T===void 0?void 0:T.param),te)}:void 0),Te=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(be).length>0?{_internal:be}:void 0),Object.keys(xe).length>0?{metadata:xe}:void 0)}));if(Hn(this,"ZodObject")){const Qe=this.extend;Te.extend=function(...He){var ne,se,re,Oe,Re,$e;const Pe=Qe.apply(this,He);return Pe._def.openapi={_internal:{extendedFrom:!((se=(ne=this._def.openapi)===null||ne===void 0?void 0:ne._internal)===null||se===void 0)&&se.refId?{refId:(Oe=(re=this._def.openapi)===null||re===void 0?void 0:re._internal)===null||Oe===void 0?void 0:Oe.refId,schema:this}:(Re=this._def.openapi)===null||Re===void 0?void 0:Re._internal.extendedFrom},metadata:($e=Pe._def.openapi)===null||$e===void 0?void 0:$e.metadata},Pe}}return Te},Ye(n,"optional"),Ye(n,"nullable"),Ye(n,"default"),Ye(n,"transform"),Ye(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const r=this._def.shape(),a=e.apply(this),o=a._def.shape();return Object.entries(o).forEach(([c,d])=>{var u,l;d._def.openapi=(l=(u=r[c])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...r){const a=t.apply(this,r);return a._def.openapi=void 0,a};const s=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...r){const a=s.apply(this,r);return a._def.openapi=void 0,a}}new Set(".\\+*[^]$()");var N;(function(n){n.assertEqual=r=>r;function e(r){}n.assertIs=e;function t(r){throw new Error}n.assertNever=t,n.arrayToEnum=r=>{const a={};for(const o of r)a[o]=o;return a},n.getValidEnumValues=r=>{const a=n.objectKeys(r).filter(c=>typeof r[r[c]]!="number"),o={};for(const c of a)o[c]=r[c];return n.objectValues(o)},n.objectValues=r=>n.objectKeys(r).map(function(a){return r[a]}),n.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&a.push(o);return a},n.find=(r,a)=>{for(const o of r)if(a(o))return o},n.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function s(r,a=" | "){return r.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}n.joinValues=s,n.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(N||(N={}));var Gt;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Gt||(Gt={}));const _=N.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ue=n=>{switch(typeof n){case"undefined":return _.undefined;case"string":return _.string;case"number":return isNaN(n)?_.nan:_.number;case"boolean":return _.boolean;case"function":return _.function;case"bigint":return _.bigint;case"symbol":return _.symbol;case"object":return Array.isArray(n)?_.array:n===null?_.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?_.promise:typeof Map<"u"&&n instanceof Map?_.map:typeof Set<"u"&&n instanceof Set?_.set:typeof Date<"u"&&n instanceof Date?_.date:_.object;default:return _.unknown}},p=N.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Gn=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class V extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},s={_errors:[]},r=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(r);else if(o.code==="invalid_return_type")r(o.returnTypeError);else if(o.code==="invalid_arguments")r(o.argumentsError);else if(o.path.length===0)s._errors.push(t(o));else{let c=s,d=0;for(;d<o.path.length;){const u=o.path[d];d===o.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(o))):c[u]=c[u]||{_errors:[]},c=c[u],d++}}};return r(this),s}static assert(e){if(!(e instanceof V))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,N.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):s.push(e(r));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}V.create=n=>new V(n);const De=(n,e)=>{let t;switch(n.code){case p.invalid_type:n.received===_.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case p.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,N.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:t=`Unrecognized key(s) in object: ${N.joinValues(n.keys,", ")}`;break;case p.invalid_union:t="Invalid input";break;case p.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${N.joinValues(n.options)}`;break;case p.invalid_enum_value:t=`Invalid enum value. Expected ${N.joinValues(n.options)}, received '${n.received}'`;break;case p.invalid_arguments:t="Invalid function arguments";break;case p.invalid_return_type:t="Invalid function return type";break;case p.invalid_date:t="Invalid date";break;case p.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:N.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case p.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case p.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case p.custom:t="Invalid input";break;case p.invalid_intersection_types:t="Intersection results could not be merged";break;case p.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case p.not_finite:t="Number must be finite";break;default:t=e.defaultError,N.assertNever(n)}return{message:t}};let mn=De;function Xn(n){mn=n}function Rt(){return mn}const $t=n=>{const{data:e,path:t,errorMaps:s,issueData:r}=n,a=[...t,...r.path||[]],o={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let c="";const d=s.filter(u=>!!u).slice().reverse();for(const u of d)c=u(o,{data:e,defaultError:c}).message;return{...r,path:a,message:c}},es=[];function f(n,e){const t=Rt(),s=$t({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===De?void 0:De].filter(r=>!!r)});n.common.issues.push(s)}class ${constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const r of t){if(r.status==="aborted")return x;r.status==="dirty"&&e.dirty(),s.push(r.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const r of t){const a=await r.key,o=await r.value;s.push({key:a,value:o})}return $.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const r of t){const{key:a,value:o}=r;if(a.status==="aborted"||o.status==="aborted")return x;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||r.alwaysSet)&&(s[a.value]=o.value)}return{status:e.value,value:s}}}const x=Object.freeze({status:"aborted"}),Pt=n=>({status:"dirty",value:n}),D=n=>({status:"valid",value:n}),Xt=n=>n.status==="aborted",en=n=>n.status==="dirty",Ge=n=>n.status==="valid",Xe=n=>typeof Promise<"u"&&n instanceof Promise;function Dt(n,e,t,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function _n(n,e,t,s,r){if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}var y;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(y||(y={}));var et,tt;class Q{constructor(e,t,s,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const gn=(n,e)=>{if(Ge(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new V(n.common.issues);return this._error=t,this._error}}};function O(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:r}=n;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(a,o)=>{var c,d;const{message:u}=n;return a.code==="invalid_enum_value"?{message:u??o.defaultError}:typeof o.data>"u"?{message:(c=u??s)!==null&&c!==void 0?c:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(d=u??t)!==null&&d!==void 0?d:o.defaultError}},description:r}}class Z{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return ue(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new $,ctx:{common:e.parent.common,data:e.data,parsedType:ue(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Xe(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const r={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ue(e)},a=this._parseSync({data:e,path:r.path,parent:r});return gn(r,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ue(e)},r=this._parse({data:e,path:s.path,parent:s}),a=await(Xe(r)?r:Promise.resolve(r));return gn(s,a)}refine(e,t){const s=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,a)=>{const o=e(r),c=()=>a.addIssue({code:p.custom,...s(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((s,r)=>e(s)?!0:(r.addIssue(typeof t=="function"?t(s,r):t),!1))}_refinement(e){return new B({schema:this,typeName:w.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Y.create(this,this._def)}nullable(){return me.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return z.create(this,this._def)}promise(){return Ue.create(this,this._def)}or(e){return at.create([this,e],this._def)}and(e){return it.create(this,e,this._def)}transform(e){return new B({...O(this._def),schema:this,typeName:w.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new lt({...O(this._def),innerType:this,defaultValue:t,typeName:w.ZodDefault})}brand(){return new sn({typeName:w.ZodBranded,type:this,...O(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new pt({...O(this._def),innerType:this,catchValue:t,typeName:w.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ht.create(this,e)}readonly(){return ft.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ts=/^c[^\s-]{8,}$/i,ns=/^[0-9a-z]+$/,ss=/^[0-9A-HJKMNP-TV-Z]{26}$/,rs=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,as=/^[a-z0-9_-]{21}$/i,is=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,os=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,cs="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let tn;const ds=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,us=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ls=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,yn="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ps=new RegExp(`^${yn}$`);function vn(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function hs(n){return new RegExp(`^${vn(n)}$`)}function wn(n){let e=`${yn}T${vn(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function fs(n,e){return!!((e==="v4"||!e)&&ds.test(n)||(e==="v6"||!e)&&us.test(n))}class F extends Z{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==_.string){const r=this._getOrReturnCtx(e);return f(r,{code:p.invalid_type,expected:_.string,received:r.parsedType}),x}const t=new $;let s;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:p.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="max")e.data.length>r.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:p.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind==="length"){const a=e.data.length>r.value,o=e.data.length<r.value;(a||o)&&(s=this._getOrReturnCtx(e,s),a?f(s,{code:p.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):o&&f(s,{code:p.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind==="email")os.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"email",code:p.invalid_string,message:r.message}),t.dirty());else if(r.kind==="emoji")tn||(tn=new RegExp(cs,"u")),tn.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"emoji",code:p.invalid_string,message:r.message}),t.dirty());else if(r.kind==="uuid")rs.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"uuid",code:p.invalid_string,message:r.message}),t.dirty());else if(r.kind==="nanoid")as.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"nanoid",code:p.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid")ts.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid",code:p.invalid_string,message:r.message}),t.dirty());else if(r.kind==="cuid2")ns.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"cuid2",code:p.invalid_string,message:r.message}),t.dirty());else if(r.kind==="ulid")ss.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ulid",code:p.invalid_string,message:r.message}),t.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),f(s,{validation:"url",code:p.invalid_string,message:r.message}),t.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"regex",code:p.invalid_string,message:r.message}),t.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind==="datetime"?wn(r).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:"datetime",message:r.message}),t.dirty()):r.kind==="date"?ps.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:"date",message:r.message}),t.dirty()):r.kind==="time"?hs(r).test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:"time",message:r.message}),t.dirty()):r.kind==="duration"?is.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"duration",code:p.invalid_string,message:r.message}),t.dirty()):r.kind==="ip"?fs(e.data,r.version)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"ip",code:p.invalid_string,message:r.message}),t.dirty()):r.kind==="base64"?ls.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"base64",code:p.invalid_string,message:r.message}),t.dirty()):N.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement(r=>e.test(r),{validation:t,code:p.invalid_string,...y.errToObj(s)})}_addCheck(e){return new F({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...y.errToObj(e)})}datetime(e){var t,s;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(s=e==null?void 0:e.local)!==null&&s!==void 0?s:!1,...y.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...y.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...y.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...y.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...y.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...y.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...y.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...y.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...y.errToObj(t)})}nonempty(e){return this.min(1,y.errToObj(e))}trim(){return new F({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new F({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new F({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}F.create=n=>{var e;return new F({checks:[],typeName:w.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...O(n)})};function ms(n,e){const t=(n.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,r=t>s?t:s,a=parseInt(n.toFixed(r).replace(".","")),o=parseInt(e.toFixed(r).replace(".",""));return a%o/Math.pow(10,r)}class le extends Z{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==_.number){const r=this._getOrReturnCtx(e);return f(r,{code:p.invalid_type,expected:_.number,received:r.parsedType}),x}let t;const s=new $;for(const r of this._def.checks)r.kind==="int"?N.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),f(t,{code:p.invalid_type,expected:"integer",received:"float",message:r.message}),s.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),s.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),s.dirty()):r.kind==="multipleOf"?ms(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.not_multiple_of,multipleOf:r.value,message:r.message}),s.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),f(t,{code:p.not_finite,message:r.message}),s.dirty()):N.assertNever(r);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,s,r){return new le({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:y.toString(r)}]})}_addCheck(e){return new le({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&N.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}le.create=n=>new le({checks:[],typeName:w.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...O(n)});class pe extends Z{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==_.bigint){const r=this._getOrReturnCtx(e);return f(r,{code:p.invalid_type,expected:_.bigint,received:r.parsedType}),x}let t;const s=new $;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),s.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),s.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),f(t,{code:p.not_multiple_of,multipleOf:r.value,message:r.message}),s.dirty()):N.assertNever(r);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,y.toString(t))}setLimit(e,t,s,r){return new pe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:y.toString(r)}]})}_addCheck(e){return new pe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}pe.create=n=>{var e;return new pe({checks:[],typeName:w.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...O(n)})};class nt extends Z{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==_.boolean){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.boolean,received:t.parsedType}),x}return D(e.data)}}nt.create=n=>new nt({typeName:w.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...O(n)});class Se extends Z{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==_.date){const r=this._getOrReturnCtx(e);return f(r,{code:p.invalid_type,expected:_.date,received:r.parsedType}),x}if(isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return f(r,{code:p.invalid_date}),x}const t=new $;let s;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:p.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(s=this._getOrReturnCtx(e,s),f(s,{code:p.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):N.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Se({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:y.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Se.create=n=>new Se({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:w.ZodDate,...O(n)});class Mt extends Z{_parse(e){if(this._getType(e)!==_.symbol){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.symbol,received:t.parsedType}),x}return D(e.data)}}Mt.create=n=>new Mt({typeName:w.ZodSymbol,...O(n)});class st extends Z{_parse(e){if(this._getType(e)!==_.undefined){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.undefined,received:t.parsedType}),x}return D(e.data)}}st.create=n=>new st({typeName:w.ZodUndefined,...O(n)});class rt extends Z{_parse(e){if(this._getType(e)!==_.null){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.null,received:t.parsedType}),x}return D(e.data)}}rt.create=n=>new rt({typeName:w.ZodNull,...O(n)});class Me extends Z{constructor(){super(...arguments),this._any=!0}_parse(e){return D(e.data)}}Me.create=n=>new Me({typeName:w.ZodAny,...O(n)});class Ze extends Z{constructor(){super(...arguments),this._unknown=!0}_parse(e){return D(e.data)}}Ze.create=n=>new Ze({typeName:w.ZodUnknown,...O(n)});class ie extends Z{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.never,received:t.parsedType}),x}}ie.create=n=>new ie({typeName:w.ZodNever,...O(n)});class Lt extends Z{_parse(e){if(this._getType(e)!==_.undefined){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.void,received:t.parsedType}),x}return D(e.data)}}Lt.create=n=>new Lt({typeName:w.ZodVoid,...O(n)});class z extends Z{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),r=this._def;if(t.parsedType!==_.array)return f(t,{code:p.invalid_type,expected:_.array,received:t.parsedType}),x;if(r.exactLength!==null){const o=t.data.length>r.exactLength.value,c=t.data.length<r.exactLength.value;(o||c)&&(f(t,{code:o?p.too_big:p.too_small,minimum:c?r.exactLength.value:void 0,maximum:o?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(f(t,{code:p.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(f(t,{code:p.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>r.type._parseAsync(new Q(t,o,t.path,c)))).then(o=>$.mergeArray(s,o));const a=[...t.data].map((o,c)=>r.type._parseSync(new Q(t,o,t.path,c)));return $.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new z({...this._def,minLength:{value:e,message:y.toString(t)}})}max(e,t){return new z({...this._def,maxLength:{value:e,message:y.toString(t)}})}length(e,t){return new z({...this._def,exactLength:{value:e,message:y.toString(t)}})}nonempty(e){return this.min(1,e)}}z.create=(n,e)=>new z({type:n,minLength:null,maxLength:null,exactLength:null,typeName:w.ZodArray,...O(e)});function Le(n){if(n instanceof A){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=Y.create(Le(s))}return new A({...n._def,shape:()=>e})}else return n instanceof z?new z({...n._def,type:Le(n.element)}):n instanceof Y?Y.create(Le(n.unwrap())):n instanceof me?me.create(Le(n.unwrap())):n instanceof H?H.create(n.items.map(e=>Le(e))):n}class A extends Z{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=N.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==_.object){const d=this._getOrReturnCtx(e);return f(d,{code:p.invalid_type,expected:_.object,received:d.parsedType}),x}const{status:t,ctx:s}=this._processInputParams(e),{shape:r,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof ie&&this._def.unknownKeys==="strip"))for(const d in s.data)a.includes(d)||o.push(d);const c=[];for(const d of a){const u=r[d],l=s.data[d];c.push({key:{status:"valid",value:d},value:u._parse(new Q(s,l,s.path,d)),alwaysSet:d in s.data})}if(this._def.catchall instanceof ie){const d=this._def.unknownKeys;if(d==="passthrough")for(const u of o)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(d==="strict")o.length>0&&(f(s,{code:p.unrecognized_keys,keys:o}),t.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const u of o){const l=s.data[u];c.push({key:{status:"valid",value:u},value:d._parse(new Q(s,l,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const d=[];for(const u of c){const l=await u.key,T=await u.value;d.push({key:l,value:T,alwaysSet:u.alwaysSet})}return d}).then(d=>$.mergeObjectSync(t,d)):$.mergeObjectSync(t,c)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new A({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var r,a,o,c;const d=(o=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,t,s).message)!==null&&o!==void 0?o:s.defaultError;return t.code==="unrecognized_keys"?{message:(c=y.errToObj(e).message)!==null&&c!==void 0?c:d}:{message:d}}}:{}})}strip(){return new A({...this._def,unknownKeys:"strip"})}passthrough(){return new A({...this._def,unknownKeys:"passthrough"})}extend(e){return new A({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new A({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:w.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new A({...this._def,catchall:e})}pick(e){const t={};return N.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new A({...this._def,shape:()=>t})}omit(e){const t={};return N.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new A({...this._def,shape:()=>t})}deepPartial(){return Le(this)}partial(e){const t={};return N.objectKeys(this.shape).forEach(s=>{const r=this.shape[s];e&&!e[s]?t[s]=r:t[s]=r.optional()}),new A({...this._def,shape:()=>t})}required(e){const t={};return N.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let r=this.shape[s];for(;r instanceof Y;)r=r._def.innerType;t[s]=r}}),new A({...this._def,shape:()=>t})}keyof(){return kn(N.objectKeys(this.shape))}}A.create=(n,e)=>new A({shape:()=>n,unknownKeys:"strip",catchall:ie.create(),typeName:w.ZodObject,...O(e)}),A.strictCreate=(n,e)=>new A({shape:()=>n,unknownKeys:"strict",catchall:ie.create(),typeName:w.ZodObject,...O(e)}),A.lazycreate=(n,e)=>new A({shape:n,unknownKeys:"strip",catchall:ie.create(),typeName:w.ZodObject,...O(e)});class at extends Z{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function r(a){for(const c of a)if(c.result.status==="valid")return c.result;for(const c of a)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=a.map(c=>new V(c.ctx.common.issues));return f(t,{code:p.invalid_union,unionErrors:o}),x}if(t.common.async)return Promise.all(s.map(async a=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(r);{let a;const o=[];for(const d of s){const u={...t,common:{...t.common,issues:[]},parent:null},l=d._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const c=o.map(d=>new V(d));return f(t,{code:p.invalid_union,unionErrors:c}),x}}get options(){return this._def.options}}at.create=(n,e)=>new at({options:n,typeName:w.ZodUnion,...O(e)});const he=n=>n instanceof ct?he(n.schema):n instanceof B?he(n.innerType()):n instanceof dt?[n.value]:n instanceof fe?n.options:n instanceof ut?N.objectValues(n.enum):n instanceof lt?he(n._def.innerType):n instanceof st?[void 0]:n instanceof rt?[null]:n instanceof Y?[void 0,...he(n.unwrap())]:n instanceof me?[null,...he(n.unwrap())]:n instanceof sn||n instanceof ft?he(n.unwrap()):n instanceof pt?he(n._def.innerType):[];class Vt extends Z{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.object)return f(t,{code:p.invalid_type,expected:_.object,received:t.parsedType}),x;const s=this.discriminator,r=t.data[s],a=this.optionsMap.get(r);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(f(t,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),x)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const r=new Map;for(const a of t){const o=he(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(r.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);r.set(c,a)}}return new Vt({typeName:w.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...O(s)})}}function nn(n,e){const t=ue(n),s=ue(e);if(n===e)return{valid:!0,data:n};if(t===_.object&&s===_.object){const r=N.objectKeys(e),a=N.objectKeys(n).filter(c=>r.indexOf(c)!==-1),o={...n,...e};for(const c of a){const d=nn(n[c],e[c]);if(!d.valid)return{valid:!1};o[c]=d.data}return{valid:!0,data:o}}else if(t===_.array&&s===_.array){if(n.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<n.length;a++){const o=n[a],c=e[a],d=nn(o,c);if(!d.valid)return{valid:!1};r.push(d.data)}return{valid:!0,data:r}}else return t===_.date&&s===_.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class it extends Z{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=(a,o)=>{if(Xt(a)||Xt(o))return x;const c=nn(a.value,o.value);return c.valid?((en(a)||en(o))&&t.dirty(),{status:t.value,value:c.data}):(f(s,{code:p.invalid_intersection_types}),x)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,o])=>r(a,o)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}it.create=(n,e,t)=>new it({left:n,right:e,typeName:w.ZodIntersection,...O(t)});class H extends Z{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==_.array)return f(s,{code:p.invalid_type,expected:_.array,received:s.parsedType}),x;if(s.data.length<this._def.items.length)return f(s,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),x;!this._def.rest&&s.data.length>this._def.items.length&&(f(s,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const r=[...s.data].map((a,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new Q(s,a,s.path,o)):null}).filter(a=>!!a);return s.common.async?Promise.all(r).then(a=>$.mergeArray(t,a)):$.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new H({...this._def,rest:e})}}H.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new H({items:n,typeName:w.ZodTuple,rest:null,...O(e)})};class ot extends Z{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==_.object)return f(s,{code:p.invalid_type,expected:_.object,received:s.parsedType}),x;const r=[],a=this._def.keyType,o=this._def.valueType;for(const c in s.data)r.push({key:a._parse(new Q(s,c,s.path,c)),value:o._parse(new Q(s,s.data[c],s.path,c)),alwaysSet:c in s.data});return s.common.async?$.mergeObjectAsync(t,r):$.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof Z?new ot({keyType:e,valueType:t,typeName:w.ZodRecord,...O(s)}):new ot({keyType:F.create(),valueType:e,typeName:w.ZodRecord,...O(t)})}}class Ut extends Z{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==_.map)return f(s,{code:p.invalid_type,expected:_.map,received:s.parsedType}),x;const r=this._def.keyType,a=this._def.valueType,o=[...s.data.entries()].map(([c,d],u)=>({key:r._parse(new Q(s,c,s.path,[u,"key"])),value:a._parse(new Q(s,d,s.path,[u,"value"]))}));if(s.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const d of o){const u=await d.key,l=await d.value;if(u.status==="aborted"||l.status==="aborted")return x;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),c.set(u.value,l.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const d of o){const u=d.key,l=d.value;if(u.status==="aborted"||l.status==="aborted")return x;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),c.set(u.value,l.value)}return{status:t.value,value:c}}}}Ut.create=(n,e,t)=>new Ut({valueType:e,keyType:n,typeName:w.ZodMap,...O(t)});class je extends Z{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==_.set)return f(s,{code:p.invalid_type,expected:_.set,received:s.parsedType}),x;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(f(s,{code:p.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(f(s,{code:p.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const a=this._def.valueType;function o(d){const u=new Set;for(const l of d){if(l.status==="aborted")return x;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const c=[...s.data.values()].map((d,u)=>a._parse(new Q(s,d,s.path,u)));return s.common.async?Promise.all(c).then(d=>o(d)):o(c)}min(e,t){return new je({...this._def,minSize:{value:e,message:y.toString(t)}})}max(e,t){return new je({...this._def,maxSize:{value:e,message:y.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}je.create=(n,e)=>new je({valueType:n,minSize:null,maxSize:null,typeName:w.ZodSet,...O(e)});class Ve extends Z{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.function)return f(t,{code:p.invalid_type,expected:_.function,received:t.parsedType}),x;function s(c,d){return $t({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Rt(),De].filter(u=>!!u),issueData:{code:p.invalid_arguments,argumentsError:d}})}function r(c,d){return $t({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Rt(),De].filter(u=>!!u),issueData:{code:p.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Ue){const c=this;return D(async function(...d){const u=new V([]),l=await c._def.args.parseAsync(d,a).catch(C=>{throw u.addIssue(s(d,C)),u}),T=await Reflect.apply(o,this,l);return await c._def.returns._def.type.parseAsync(T,a).catch(C=>{throw u.addIssue(r(T,C)),u})})}else{const c=this;return D(function(...d){const u=c._def.args.safeParse(d,a);if(!u.success)throw new V([s(d,u.error)]);const l=Reflect.apply(o,this,u.data),T=c._def.returns.safeParse(l,a);if(!T.success)throw new V([r(l,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ve({...this._def,args:H.create(e).rest(Ze.create())})}returns(e){return new Ve({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new Ve({args:e||H.create([]).rest(Ze.create()),returns:t||Ze.create(),typeName:w.ZodFunction,...O(s)})}}class ct extends Z{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ct.create=(n,e)=>new ct({getter:n,typeName:w.ZodLazy,...O(e)});class dt extends Z{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return f(t,{received:t.data,code:p.invalid_literal,expected:this._def.value}),x}return{status:"valid",value:e.data}}get value(){return this._def.value}}dt.create=(n,e)=>new dt({value:n,typeName:w.ZodLiteral,...O(e)});function kn(n,e){return new fe({values:n,typeName:w.ZodEnum,...O(e)})}class fe extends Z{constructor(){super(...arguments),et.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return f(t,{expected:N.joinValues(s),received:t.parsedType,code:p.invalid_type}),x}if(Dt(this,et)||_n(this,et,new Set(this._def.values)),!Dt(this,et).has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return f(t,{received:t.data,code:p.invalid_enum_value,options:s}),x}return D(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return fe.create(e,{...this._def,...t})}exclude(e,t=this._def){return fe.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}et=new WeakMap,fe.create=kn;class ut extends Z{constructor(){super(...arguments),tt.set(this,void 0)}_parse(e){const t=N.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==_.string&&s.parsedType!==_.number){const r=N.objectValues(t);return f(s,{expected:N.joinValues(r),received:s.parsedType,code:p.invalid_type}),x}if(Dt(this,tt)||_n(this,tt,new Set(N.getValidEnumValues(this._def.values))),!Dt(this,tt).has(e.data)){const r=N.objectValues(t);return f(s,{received:s.data,code:p.invalid_enum_value,options:r}),x}return D(e.data)}get enum(){return this._def.values}}tt=new WeakMap,ut.create=(n,e)=>new ut({values:n,typeName:w.ZodNativeEnum,...O(e)});class Ue extends Z{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==_.promise&&t.common.async===!1)return f(t,{code:p.invalid_type,expected:_.promise,received:t.parsedType}),x;const s=t.parsedType===_.promise?t.data:Promise.resolve(t.data);return D(s.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ue.create=(n,e)=>new Ue({type:n,typeName:w.ZodPromise,...O(e)});class B extends Z{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===w.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:o=>{f(s,o),o.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const o=r.transform(s.data,a);if(s.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return x;const d=await this._def.schema._parseAsync({data:c,path:s.path,parent:s});return d.status==="aborted"?x:d.status==="dirty"||t.value==="dirty"?Pt(d.value):d});{if(t.value==="aborted")return x;const c=this._def.schema._parseSync({data:o,path:s.path,parent:s});return c.status==="aborted"?x:c.status==="dirty"||t.value==="dirty"?Pt(c.value):c}}if(r.type==="refinement"){const o=c=>{const d=r.refinement(c,a);if(s.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(s.common.async===!1){const c=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return c.status==="aborted"?x:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(c=>c.status==="aborted"?x:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(r.type==="transform")if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Ge(o))return o;const c=r.transform(o.value,a);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>Ge(o)?Promise.resolve(r.transform(o.value,a)).then(c=>({status:t.value,value:c})):o);N.assertNever(r)}}B.create=(n,e,t)=>new B({schema:n,typeName:w.ZodEffects,effect:e,...O(t)}),B.createWithPreprocess=(n,e,t)=>new B({schema:e,effect:{type:"preprocess",transform:n},typeName:w.ZodEffects,...O(t)});class Y extends Z{_parse(e){return this._getType(e)===_.undefined?D(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Y.create=(n,e)=>new Y({innerType:n,typeName:w.ZodOptional,...O(e)});class me extends Z{_parse(e){return this._getType(e)===_.null?D(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}me.create=(n,e)=>new me({innerType:n,typeName:w.ZodNullable,...O(e)});class lt extends Z{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===_.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}lt.create=(n,e)=>new lt({innerType:n,typeName:w.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...O(e)});class pt extends Z{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return Xe(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new V(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new V(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}pt.create=(n,e)=>new pt({innerType:n,typeName:w.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...O(e)});class Ft extends Z{_parse(e){if(this._getType(e)!==_.nan){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.nan,received:t.parsedType}),x}return{status:"valid",value:e.data}}}Ft.create=n=>new Ft({typeName:w.ZodNaN,...O(n)});const _s=Symbol("zod_brand");class sn extends Z{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class ht extends Z{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?x:r.status==="dirty"?(t.dirty(),Pt(r.value)):this._def.out._parseAsync({data:r.value,path:s.path,parent:s})})();{const r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?x:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(e,t){return new ht({in:e,out:t,typeName:w.ZodPipeline})}}class ft extends Z{_parse(e){const t=this._def.innerType._parse(e),s=r=>(Ge(r)&&(r.value=Object.freeze(r.value)),r);return Xe(t)?t.then(r=>s(r)):s(t)}unwrap(){return this._def.innerType}}ft.create=(n,e)=>new ft({innerType:n,typeName:w.ZodReadonly,...O(e)});function bn(n,e={},t){return n?Me.create().superRefine((s,r)=>{var a,o;if(!n(s)){const c=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,d=(o=(a=c.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0,u=typeof c=="string"?{message:c}:c;r.addIssue({code:"custom",...u,fatal:d})}}):Me.create()}const gs={object:A.lazycreate};var w;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(w||(w={}));const ys=(n,e={message:`Input not instance of ${n.name}`})=>bn(t=>t instanceof n,e),xn=F.create,Tn=le.create,vs=Ft.create,ws=pe.create,On=nt.create,ks=Se.create,bs=Mt.create,xs=st.create,Ts=rt.create,Os=Me.create,Ss=Ze.create,Zs=ie.create,js=Lt.create,Ns=z.create,Is=A.create,Cs=A.strictCreate,Es=at.create,As=Vt.create,Rs=it.create,$s=H.create,Ps=ot.create,Ds=Ut.create,Ms=je.create,Ls=Ve.create,Vs=ct.create,Us=dt.create,Fs=fe.create,zs=ut.create,Bs=Ue.create,Sn=B.create,Ws=Y.create,qs=me.create,Js=B.createWithPreprocess,Ks=ht.create;var i=Object.freeze({__proto__:null,defaultErrorMap:De,setErrorMap:Xn,getErrorMap:Rt,makeIssue:$t,EMPTY_PATH:es,addIssueToContext:f,ParseStatus:$,INVALID:x,DIRTY:Pt,OK:D,isAborted:Xt,isDirty:en,isValid:Ge,isAsync:Xe,get util(){return N},get objectUtil(){return Gt},ZodParsedType:_,getParsedType:ue,ZodType:Z,datetimeRegex:wn,ZodString:F,ZodNumber:le,ZodBigInt:pe,ZodBoolean:nt,ZodDate:Se,ZodSymbol:Mt,ZodUndefined:st,ZodNull:rt,ZodAny:Me,ZodUnknown:Ze,ZodNever:ie,ZodVoid:Lt,ZodArray:z,ZodObject:A,ZodUnion:at,ZodDiscriminatedUnion:Vt,ZodIntersection:it,ZodTuple:H,ZodRecord:ot,ZodMap:Ut,ZodSet:je,ZodFunction:Ve,ZodLazy:ct,ZodLiteral:dt,ZodEnum:fe,ZodNativeEnum:ut,ZodPromise:Ue,ZodEffects:B,ZodTransformer:B,ZodOptional:Y,ZodNullable:me,ZodDefault:lt,ZodCatch:pt,ZodNaN:Ft,BRAND:_s,ZodBranded:sn,ZodPipeline:ht,ZodReadonly:ft,custom:bn,Schema:Z,ZodSchema:Z,late:gs,get ZodFirstPartyTypeKind(){return w},coerce:{string:n=>F.create({...n,coerce:!0}),number:n=>le.create({...n,coerce:!0}),boolean:n=>nt.create({...n,coerce:!0}),bigint:n=>pe.create({...n,coerce:!0}),date:n=>Se.create({...n,coerce:!0})},any:Os,array:Ns,bigint:ws,boolean:On,date:ks,discriminatedUnion:As,effect:Sn,enum:Fs,function:Ls,instanceof:ys,intersection:Rs,lazy:Vs,literal:Us,map:Ds,nan:vs,nativeEnum:zs,never:Zs,null:Ts,nullable:qs,number:Tn,object:Is,oboolean:()=>On().optional(),onumber:()=>Tn().optional(),optional:Ws,ostring:()=>xn().optional(),pipeline:Ks,preprocess:Js,promise:Bs,record:Ps,set:Ms,strictObject:Cs,string:xn,symbol:bs,transformer:Sn,tuple:$s,undefined:xs,union:Es,unknown:Ss,void:js,NEVER:x,ZodIssueCode:p,quotelessJson:Gn,ZodError:V});Yn(i),i.object({start:i.number(),limit:i.number(),length:i.number()});const rn=i.object({created_at:i.string(),updated_at:i.string()}),Qs=i.object({email:i.string().optional(),email_verified:i.boolean().optional(),name:i.string().optional(),username:i.string().optional(),given_name:i.string().optional(),phone_number:i.string().optional(),phone_verified:i.boolean().optional(),family_name:i.string().optional()}).catchall(i.any()),Hs=i.object({connection:i.string(),user_id:i.string(),provider:i.string(),isSocial:i.boolean(),access_token:i.string().optional(),access_token_secret:i.string().optional(),refresh_token:i.string().optional(),profileData:Qs.optional()}),Zn=i.object({email:i.string().optional(),username:i.string().optional(),given_name:i.string().optional(),family_name:i.string().optional(),nickname:i.string().optional(),name:i.string().optional(),picture:i.string().optional(),locale:i.string().optional(),linked_to:i.string().optional(),profileData:i.string().optional(),user_id:i.string().optional()});Zn.extend({email_verified:i.boolean().default(!1),verify_email:i.boolean().optional(),last_ip:i.string().optional(),last_login:i.string().optional(),user_id:i.string().optional(),provider:i.string().default("email"),connection:i.string().default("email")}).extend(rn.shape).extend({user_id:i.string(),email:i.string(),is_social:i.boolean(),login_count:i.number(),identities:i.array(Hs).optional()}),Zn.extend({email:i.string(),login_count:i.number(),multifactor:i.array(i.string()).optional(),last_ip:i.string().optional(),last_login:i.string().optional(),user_id:i.string()}).catchall(i.any());const Ys=i.object({audience:i.string().optional(),recipient:i.string().optional(),createUpnClaim:i.boolean().optional(),mapUnknownClaimsAsIs:i.boolean().optional(),passthroughClaimsWithNoMapping:i.boolean().optional(),mapIdentities:i.boolean().optional(),signatureAlgorithm:i.string().optional(),digestAlgorithm:i.string().optional(),issuer:i.string().optional(),destination:i.string().optional(),lifetimeInSeconds:i.number().optional(),signResponse:i.boolean().optional(),nameIdentifierFormat:i.string().optional(),nameIdentifierProbes:i.array(i.string()).optional(),authnContextClassRef:i.string().optional(),mappings:i.record(i.string()).optional()}),Gs=i.object({id:i.string(),name:i.string(),callbacks:i.array(i.string()).openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:i.array(i.string()).openapi({description:"Comma-separated list of URLs allowed to make requests from JavaScript to Auth0 API (typically used with CORS). By default, all your callback URLs will be allowed. This field allows you to enter other origins if necessary. You can also use wildcards at the subdomain level. Query strings and hash information are not taken into account when validating these URLs."}),web_origins:i.array(i.string()).openapi({description:"Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode."}),allowed_logout_urls:i.array(i.string()).openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),addons:i.object({samlp:Ys.optional()}).optional().openapi({description:"Addons associated with the client. The key is the addon's package name and the value is an object with the configuration for the addon."}),email_validation:i.enum(["enabled","disabled","enforced"]).default("enforced").openapi({description:"Defines if it possible to sign in with an unverified email and if verification emails will be sent. This is not available in auth0"}),client_secret:i.string().default(""),disable_sign_ups:i.boolean().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),Xs=i.object({created_at:i.string().transform(n=>n===null?"":n),updated_at:i.string().transform(n=>n===null?"":n),...Gs.shape});var jn=(n=>(n.TOKEN="token",n.TOKEN_ID_TOKEN="token id_token",n.CODE="code",n))(jn||{}),Nn=(n=>(n.QUERY="query",n.FRAGMENT="fragment",n.FORM_POST="form_post",n.WEB_MESSAGE="web_message",n.SAML_POST="saml_post",n))(Nn||{}),In=(n=>(n.S265="S256",n.plain="plain",n))(In||{});const zt=i.object({client_id:i.string(),vendor_id:i.string().optional(),response_type:i.nativeEnum(jn).optional(),response_mode:i.nativeEnum(Nn).optional(),redirect_uri:i.string().optional(),audience:i.string().optional(),state:i.string().optional(),nonce:i.string().optional(),scope:i.string().optional(),code_challenge_method:i.nativeEnum(In).optional(),code_challenge:i.string().optional(),username:i.string().optional()});i.object({colors:i.object({primary:i.string(),page_background:i.object({type:i.string().optional(),start:i.string().optional(),end:i.string().optional(),angle_deg:i.number().optional()}).optional()}).optional(),logo_url:i.string().optional(),favicon_url:i.string().optional(),font:i.object({url:i.string()}).optional()});const er=i.object({id:i.string().optional(),name:i.string(),client_id:i.string().optional(),client_secret:i.string().optional(),authorization_endpoint:i.string().optional(),response_type:i.custom().optional(),response_mode:i.custom().optional(),private_key:i.string().optional(),kid:i.string().optional(),team_id:i.string().optional(),token_endpoint:i.string().optional(),token_exchange_basic_auth:i.boolean().optional(),userinfo_endpoint:i.string().optional(),scope:i.string().optional()}),Cn=i.object({id:i.string(),created_at:i.string().transform(n=>n===null?"":n),updated_at:i.string().transform(n=>n===null?"":n)}).extend(er.shape),tr=i.object({name:i.string(),audience:i.string(),sender_email:i.string().email(),sender_name:i.string(),support_url:i.string().url().optional(),logo:i.string().url().optional(),primary_color:i.string().optional(),secondary_color:i.string().optional(),language:i.string().optional()}),nr=i.object({created_at:i.string().transform(n=>n===null?"":n),updated_at:i.string().transform(n=>n===null?"":n),id:i.string(),...tr.shape});i.object({logoUrl:i.string(),loginBackgroundImage:i.string().nullish(),style:i.object({primaryColor:i.string(),buttonTextColor:i.string(),primaryHoverColor:i.string()}),supportEmail:i.string().nullable(),supportUrl:i.string().nullable(),name:i.string(),showGreyishBackground:i.boolean().optional(),termsAndConditionsUrl:i.string().nullable(),companyName:i.string().optional(),checkoutHideSocial:i.boolean().optional(),siteUrl:i.string().nullable(),manageSubscriptionsUrl:i.string().optional()});const sr=i.object({domain:i.string(),dkim_private_key:i.string().optional(),dkim_public_key:i.string().optional(),email_api_key:i.string().optional(),email_service:i.union([i.literal("mailgun"),i.literal("mailchannels")]).optional()});i.object({...Xs.shape,domains:i.array(sr),tenant:nr,connections:i.array(Cn)});const rr=i.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),ar=i.object({code_id:i.string().openapi({description:"The code that will be used in for instance an email verification flow"}),login_id:i.string().openapi({description:"The id of the login session that the code is connected to"}),connection_id:i.string().optional().openapi({description:"The connection that the code is connected to"}),code_type:rr,expires_at:i.string(),used_at:i.string().optional(),user_id:i.string().optional()}),ir=i.object({...ar.shape,created_at:i.string()}),or=i.object({domain:i.string(),dkim_private_key:i.string().optional(),dkim_public_key:i.string().optional(),email_api_key:i.string().optional(),email_service:i.enum(["mailgun","mailchannels"])});rn.extend({...or.shape,id:i.string()}),i.object({trigger_id:i.enum(["pre-user-signup","post-user-registration","post-user-login"]),enabled:i.boolean().default(!1),url:i.string(),hook_id:i.string().optional(),synchronous:i.boolean().default(!1),priority:i.number().optional()}).extend({...rn.shape,hook_id:i.string()});const cr=i.object({alg:i.string(),e:i.string(),kid:i.string(),kty:i.string(),n:i.string(),use:i.string().optional()});i.object({keys:i.array(cr)}),i.object({issuer:i.string(),authorization_endpoint:i.string(),token_endpoint:i.string(),device_authorization_endpoint:i.string(),userinfo_endpoint:i.string(),mfa_challenge_endpoint:i.string(),jwks_uri:i.string(),registration_endpoint:i.string(),revocation_endpoint:i.string(),scopes_supported:i.array(i.string()),response_types_supported:i.array(i.string()),code_challenge_methods_supported:i.array(i.string()),response_modes_supported:i.array(i.string()),subject_types_supported:i.array(i.string()),id_token_signing_alg_values_supported:i.array(i.string()),token_endpoint_auth_methods_supported:i.array(i.string()),claims_supported:i.array(i.string()),request_uri_parameter_supported:i.boolean(),request_parameter_supported:i.boolean(),token_endpoint_auth_signing_alg_values_supported:i.array(i.string())});const dr=i.object({auth0Client:i.string().optional(),authParams:zt,expires_at:i.string(),deleted_at:i.string().optional(),ip:i.string().optional()}).openapi({description:"This represents a login sesion"}),ur=i.object({...dr.shape,login_id:i.string().openapi({description:"This is is used as the state in the universal login"}),created_at:i.string(),updated_at:i.string()}),lr=i.enum(["cls","fsa","fs","f","fc","fcoa","fcp","fh","fp","fs","fu","s","sapi","scoa","scp","scpr","scu","seacft","serft","slo","ss","ssa","sv","svr"]),pr=i.object({name:i.string(),version:i.string(),env:i.object({node:i.string().optional()}).optional()});i.object({type:lr,date:i.string(),description:i.string().optional(),log_id:i.string().optional(),_id:i.string().optional(),ip:i.string(),user_agent:i.string(),details:i.any().optional(),isMobile:i.boolean(),user_id:i.string().optional(),user_name:i.string().optional(),connection:i.string().optional(),connection_id:i.string().optional(),client_id:i.string().optional(),client_name:i.string().optional(),audience:i.string().optional(),scope:i.array(i.string()).optional(),strategy:i.string().optional(),strategy_type:i.string().optional(),hostname:i.string().optional(),auth0_client:pr.optional()});const hr=i.object({user_id:i.string(),password:i.string(),algorithm:i.enum(["bcrypt","argon2id"]).default("argon2id")});i.object({...hr.shape,created_at:i.string(),updated_at:i.string()});const fr=i.object({session_id:i.string(),client_id:i.string(),expires_at:i.string(),used_at:i.string(),deleted_at:i.string().optional(),user_id:i.string()});i.object({created_at:i.string(),...fr.shape}),i.object({private_key:i.string(),public_key:i.string(),kid:i.string(),created_at:i.string(),revoked_at:i.string().optional()}),i.object({kid:i.string().openapi({description:"The key id of the signing key"}),cert:i.string().openapi({description:"The public certificate of the signing key"}),fingerprint:i.string().openapi({description:"The cert fingerprint"}),thumbprint:i.string().openapi({description:"The cert thumbprint"}),pkcs7:i.string().optional().openapi({description:"The public certificate of the signing key in pkcs7 format"}),current:i.boolean().optional().openapi({description:"True if the key is the current key"}),next:i.boolean().optional().openapi({description:"True if the key is the next key"}),previous:i.boolean().optional().openapi({description:"True if the key is the previous key"}),current_since:i.string().optional().openapi({description:"The date and time when the key became the current key"}),current_until:i.string().optional().openapi({description:"The date and time when the current key was rotated"}),revoked:i.boolean().optional().openapi({description:"True if the key is revoked"}),revoked_at:i.string().optional().openapi({description:"The date and time when the key was revoked"})});var En=(n=>(n.RefreshToken="refresh_token",n.AuthorizationCode="authorization_code",n.ClientCredential="client_credentials",n.Passwordless="passwordless",n.Password="password",n))(En||{});const an=i.nativeEnum(En);i.object({grant_type:an.refine(n=>n==="authorization_code"),code:i.string(),client_secret:i.string(),client_id:i.string()}),i.object({grant_type:an.refine(n=>n==="authorization_code"),code:i.string(),code_verifier:i.string(),client_id:i.string().optional(),redirect_uri:i.string()}),i.object({grant_type:an.refine(n=>n==="client_credentials"),scope:i.string().optional(),client_secret:i.string(),client_id:i.string(),audience:i.string().optional()}),i.object({access_token:i.string(),id_token:i.string().optional(),scope:i.string().optional(),state:i.string().optional(),refresh_token:i.string().optional(),token_type:i.string(),expires_in:i.number()}),i.object({code:i.string(),state:i.string().optional()});const mr=i.object({button_border_radius:i.number(),button_border_weight:i.number(),buttons_style:i.enum(["pill"]),input_border_radius:i.number(),input_border_weight:i.number(),inputs_style:i.enum(["pill"]),show_widget_shadow:i.boolean(),widget_border_weight:i.number(),widget_corner_radius:i.number()}),_r=i.object({base_focus_color:i.string(),base_hover_color:i.string(),body_text:i.string(),captcha_widget_theme:i.enum(["auto"]),error:i.string(),header:i.string(),icons:i.string(),input_background:i.string(),input_border:i.string(),input_filled_text:i.string(),input_labels_placeholders:i.string(),links_focused_components:i.string(),primary_button:i.string(),primary_button_label:i.string(),secondary_button_border:i.string(),secondary_button_label:i.string(),success:i.string(),widget_background:i.string(),widget_border:i.string()}),Fe=i.object({bold:i.boolean(),size:i.number()}),gr=i.object({body_text:Fe,buttons_text:Fe,font_url:i.string(),input_labels:Fe,links:Fe,links_style:i.enum(["normal"]),reference_text_size:i.number(),subtitle:Fe,title:Fe}),yr=i.object({background_color:i.string(),background_image_url:i.string(),page_layout:i.enum(["center"])}),vr=i.object({header_text_alignment:i.enum(["center"]),logo_height:i.number(),logo_position:i.enum(["center"]),logo_url:i.string(),social_buttons_layout:i.enum(["bottom"])});i.object({borders:mr,colors:_r,displayName:i.string(),fonts:gr,page_background:yr,widget:vr}).extend({themeId:i.string()});const wr=i.object({id:i.string(),expires_at:i.string(),auth0Client:i.string().optional(),authParams:zt});i.object({...wr.shape,created_at:i.string(),updated_at:i.string()});const kr=i.object({id:i.string(),email:i.string(),code:i.string(),ip:i.string().optional(),send:i.enum(["code","link"]),authParams:zt,expires_at:i.string(),used_at:i.string().optional(),user_id:i.string().optional()});i.object({created_at:i.string(),...kr.shape});const br=i.object({authParams:zt,code:i.string(),user_id:i.string(),created_at:i.string(),expires_at:i.string(),used_at:i.string().optional()});i.object({...br.shape,created_at:i.string()});function on(n){const[e,t]=n.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${n}`);return{connection:e,id:t}}function An(n){let e={};try{e=JSON.parse(n.profileData||"{}")}catch(t){console.error("Error parsing profileData",t)}return{connection:n.connection,provider:n.provider,user_id:on(n.user_id).id,isSocial:!!n.is_social,profileData:{email:n.email,email_verified:!!n.email_verified,...e}}}function xr(n){return async(e,t)=>{const[s,r]=await Promise.all([n.selectFrom("users").where("users.tenant_id","=",e).where("users.user_id","=",t).selectAll().executeTakeFirst(),n.selectFrom("users").where("users.tenant_id","=",e).where("users.linked_to","=",t).selectAll().execute()]);if(!s)return null;const{tenant_id:a,...o}=s,c={...o,email:s.email||"",email_verified:s.email_verified===1,is_social:s.is_social===1,identities:[{connection:s.connection,provider:s.provider,user_id:on(s.user_id).id,isSocial:!!s.is_social},...r.map(An)]};return E(c)}}function Ne(n,e,t,s){return t.split(/\s+/).map(a=>a.replace(/^([^:]+)=/g,"$1:")).map(a=>{let o=a.startsWith("-"),c,d,u,l;return a.startsWith("-_exists_:")?(c=a.substring(10),u=!0,o=!0):a.startsWith("_exists_:")?(c=a.substring(9),u=!0,o=!1):a.includes(":")?(o=a.startsWith("-"),[c,d]=o?a.substring(1).split(":"):a.split(":"),u=!1,d.startsWith(">=")?(l=">=",d=d.substring(2)):d.startsWith(">")?(l=">",d=d.substring(1)):d.startsWith("<=")?(console.log("value",d),l="<=",d=d.substring(2)):d.startsWith("<")?(l="<",d=d.substring(1)):l="="):(c=null,d=a,u=!1),{key:c,value:d,isNegation:o,isExistsQuery:u,operator:l}}).forEach(({key:a,value:o,isNegation:c,isExistsQuery:d,operator:u})=>{if(a)if(d)c?e=e.where(a,"is",null):e=e.where(a,"is not",null);else if(c)switch(u){case">":e=e.where(a,"<=",o);break;case">=":e=e.where(a,"<",o);break;case"<":e=e.where(a,">=",o);break;case"<=":e=e.where(a,">",o);break;default:e=e.where(a,"!=",o)}else e=e.where(a,u,o);else{const{ref:l}=n.dynamic;e=e.where(T=>T.or(s.map(C=>T(l(C),"like",`%${o}%`))))}}),e}function _e(n){return typeof n=="string"?parseInt(n,10):typeof n=="bigint"?Number(n):n}function Tr(n){return async(e,t)=>{let s=n.selectFrom("users").where("users.tenant_id","=",e);if(t.q&&(s=Ne(n,s,t.q,["email","name"])),t.sort&&t.sort.sort_by){const{ref:l}=n.dynamic;s=s.orderBy(l(t.sort.sort_by),t.sort.sort_order)}const a=await s.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),o=a.map(l=>l.user_id),c=o.length?await n.selectFrom("users").selectAll().where("users.tenant_id","=",e).where("users.linked_to","in",o).execute():[],d=a.map(l=>{const T=c.filter(C=>C.linked_to===l.user_id);return E({...l,email_verified:l.email_verified===1,is_social:l.is_social===1,identities:[{connection:l.connection,provider:l.provider,user_id:on(l.user_id).id,isSocial:!!l.is_social},...T.map(An)]})}),{count:u}=await s.select(l=>l.fn.countAll().as("count")).executeTakeFirstOrThrow();return{users:d,start:t.page*t.per_page,limit:t.per_page,length:_e(u)}}}function Or(n){return async(e,t)=>(await n.deleteFrom("users").where("users.tenant_id","=",e).where("users.linked_to","=",t).execute(),(await n.deleteFrom("users").where("users.tenant_id","=",e).where("users.user_id","=",t).execute()).length===1)}function Sr(n){if(n.email_verified!==void 0)return n.email_verified?1:0}function Zr(n){return async(e,t,s)=>{const r={...s,email_verified:Sr(s),updated_at:new Date().toISOString()};return(await n.updateTable("users").set(r).where("users.tenant_id","=",e).where("users.user_id","=",t).execute()).length===1}}function jr(n){return async(e,t,s,r)=>{const a={linked_to:null};return(await n.updateTable("users").set(a).where("users.tenant_id","=",e).where("users.user_id","=",`${s}|${r}`).where("users.linked_to","=",`${t}`).execute()).length===1}}function Nr(n){return{create:ae(n),remove:Or(n),get:xr(n),list:Tr(n),update:Zr(n),unlink:jr(n)}}const Ir="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ie=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n));for(;n--;)e+=Ir[t[n]&63];return e};function Cr(n){return async e=>{const t={id:e.id||Ie(),created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...e};return await n.insertInto("tenants").values(t).execute(),t}}function Er(n){return async e=>{const t=await n.selectFrom("tenants").where("tenants.id","=",e).selectAll().executeTakeFirst();return t?E(t):null}}function Ar(n){return async e=>{let t=n.selectFrom("tenants");if(e.sort&&e.sort.sort_by){const{ref:c}=n.dynamic;t=t.orderBy(c(e.sort.sort_by),e.sort.sort_order)}e.q&&(t=t.where(c=>c.or([c("name","like",`%${e.q}%`)])));const r=await t.offset(e.page*e.per_page).limit(e.per_page).selectAll().execute();if(!e.include_totals)return{tenants:r};const{count:a}=await t.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow(),o=_e(a);return{tenants:r.map(E),start:(e.page-1)*e.per_page,limit:e.per_page,length:o}}}function Rr(n){return async(e,t)=>{const s={...t,id:e,updated_at:new Date().toISOString()};await n.updateTable("tenants").set(s).where("id","=",e).execute()}}function $r(n){return async e=>(await n.deleteFrom("tenants").where("tenants.id","=",e).execute()).length===1}function Pr(n){return{create:Cr(n),get:Er(n),list:Ar(n),update:Rr(n),remove:$r(n)}}function Rn(n){return n?JSON.stringify(n):void 0}const Dr=1024;function Mr(n){return async(e,t)=>{var r,a,o;const s={id:Ie(),...t,user_agent:t.user_agent.slice(0,Dr)};return await n.insertInto("logs").values({...s,description:(r=s.description)==null?void 0:r.substring(0,256),isMobile:t.isMobile?1:0,tenant_id:e,scope:(a=t.scope)==null?void 0:a.join(","),auth0_client:Rn(t.auth0_client),details:(o=Rn(t.details))==null?void 0:o.substring(0,8192)}).execute(),s}}function $n(n){if(!n)return"";try{return JSON.parse(n)}catch{return n}}function Pn(n){return{...n,client_id:n.client_id,client_name:"",auth0_client:$n(n.auth0_client),details:$n(n.details),isMobile:!!n.isMobile,scope:n.scope?n.scope.split(","):void 0,log_id:n.id,_id:n.id}}function Lr(n){return async(e,t)=>{let s=n.selectFrom("logs").where("logs.tenant_id","=",e);t.q&&(s=Ne(n,s,t.q,["user_id","ip"]));let r=s;if(t.sort&&t.sort.sort_by){const{ref:c}=n.dynamic;r=r.orderBy(c(t.sort.sort_by),t.sort.sort_order)}r=r.offset(t.page*t.per_page).limit(t.per_page);const a=await r.selectAll().execute(),{count:o}=await s.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{logs:a.map(Pn),start:t.page*t.per_page,limit:t.per_page,length:_e(o)}}}function Vr(n){return async(e,t)=>{const s=await n.selectFrom("logs").where("logs.tenant_id","=",e).where("logs.id","=",t).selectAll().executeTakeFirst();return s?Pn(s):null}}function Ur(n){return{create:Mr(n),list:Lr(n),get:Vr(n)}}function Fr(n){return async(e,t)=>await n.selectFrom("sessions").where("sessions.tenant_id","=",e).where("sessions.session_id","=",t).where("sessions.deleted_at","is",null).selectAll().executeTakeFirst()??null}function zr(n){return async(e,t)=>{const s={...t,created_at:new Date().toISOString(),expires_at:new Date().toISOString()};return await n.insertInto("sessions").values({...s,tenant_id:e}).execute(),{...t,...s}}}function Br(n){return async(e,t)=>!!(await n.updateTable("sessions").set({deleted_at:new Date().toISOString()}).where("tenant_id","=",e).where("sessions.session_id","=",t).where("sessions.deleted_at","is",null).execute()).length}function Wr(n){return async(e,t,s)=>!!(await n.updateTable("sessions").set(s).where("tenant_id","=",e).where("sessions.session_id","=",t).where("sessions.deleted_at","is",null).execute()).length}function qr(n){return async(e,t)=>{let s=n.selectFrom("sessions").where("sessions.tenant_id","=",e);t.q&&(s=Ne(n,s,t.q,["user_id","session_id"]));let r=s;if(t.sort&&t.sort.sort_by){const{ref:d}=n.dynamic;r=r.orderBy(d(t.sort.sort_by),t.sort.sort_order)}r=r.offset(t.page*t.per_page).limit(t.per_page);const a=await r.selectAll().execute(),{count:o}=await s.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow(),c=_e(o);return{sessions:a,start:t.page*t.per_page,limit:t.per_page,length:c}}}function Jr(n){return{create:zr(n),get:Fr(n),list:qr(n),remove:Br(n),update:Wr(n)}}function Kr(n){return async(e,t)=>{const s=await n.selectFrom("tickets").where("tickets.tenant_id","=",e).where("tickets.id","=",t).where("tickets.used_at","is",null).selectAll().executeTakeFirst();if(!s)return null;const{nonce:r,state:a,scope:o,response_type:c,response_mode:d,redirect_uri:u,...l}=s;return{...l,authParams:{nonce:r,state:a,scope:o,response_type:c,response_mode:d,redirect_uri:u},created_at:new Date(s.created_at),expires_at:new Date(s.expires_at),used_at:s.used_at?new Date(s.used_at):void 0}}}function Qr(n){return async e=>{const{authParams:t,...s}=e,r={...s,...t,created_at:e.created_at.toISOString(),expires_at:e.expires_at.toISOString(),used_at:e.used_at?e.used_at.toISOString():void 0};await n.insertInto("tickets").values(r).execute()}}function Hr(n){return async(e,t)=>{await n.updateTable("tickets").set({used_at:new Date().toISOString()}).where("tickets.tenant_id","=",e).where("tickets.id","=",t).execute()}}function Yr(n){return{create:Qr(n),get:Kr(n),remove:Hr(n)}}function Gr(n){return async(e,t)=>{const s=new Date().toISOString();return(await n.selectFrom("otps").where("otps.tenant_id","=",e).where("otps.email","=",t).where("otps.expires_at",">",s).where("otps.used_at","is",null).selectAll().execute()).map(a=>{const{nonce:o,state:c,scope:d,response_type:u,redirect_uri:l,client_id:T,...C}=a;return{...C,client_id:T,authParams:{client_id:T,nonce:o,state:c,scope:d,response_type:u,redirect_uri:l},created_at:a.created_at,expires_at:a.expires_at}})}}function Xr(n){return async(e,t)=>{const{authParams:s,...r}=t;await n.insertInto("otps").values({...r,...s,created_at:new Date().toISOString(),tenant_id:e,send:t.send==="code"?"code":"link"}).execute()}}function ea(n){return async(e,t)=>(await n.updateTable("otps").set({used_at:new Date().toISOString()}).where("otps.tenant_id","=",e).where("otps.id","=",t).execute()).length>0}function ta(n){return{create:Xr(n),list:Gr(n),remove:ea(n)}}function na(n){return async(e,t)=>{const s=await n.selectFrom("passwords").where("passwords.tenant_id","=",e).where("passwords.user_id","=",t).selectAll().executeTakeFirstOrThrow(),{tenant_id:r,...a}=s;return a}}function sa(n){return async(e,t)=>{const s={...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("passwords").values({...s,tenant_id:e}).execute(),s}}function ra(n){return async(e,t)=>(await n.updateTable("passwords").set({password:t.password,updated_at:new Date().toISOString()}).where("tenant_id","=",e).where("user_id","=",t.user_id).execute()).length===1}function aa(n){return{create:sa(n),update:ra(n),get:na(n)}}function ia(n){return async(e,t)=>{let s=n.selectFrom("codes").where("codes.tenant_id","=",e);t.q&&(s=Ne(n,s,t.q,["code","login_id"]));const a=await s.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await s.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{codes:a.map(d=>{const{tenant_id:u,...l}=d;return ir.parse(E(l))}),start:t.page*t.per_page,limit:t.per_page,length:_e(o)}}}function oa(n){return async(e,t)=>{const s={...t,created_at:new Date().toISOString()};return await n.insertInto("codes").values({...s,tenant_id:e}).execute(),s}}function ca(n){return async(e,t)=>(await n.deleteFrom("codes").where("codes.tenant_id","=",e).where("codes.code_id","=",t).executeTakeFirst()).numDeletedRows>0}function da(n){return async(e,t,s)=>{let r=n.selectFrom("codes").where("codes.code_id","=",t).where("codes.code_type","=",s).where("codes.expires_at",">",new Date().toISOString());e.length&&(r=r.where("codes.tenant_id","=",e));const a=await r.selectAll().executeTakeFirst();return a?E(a):null}}function ua(n){return{create:oa(n),list:ia(n),remove:ca(n),get:da(n)}}function la(n){return async e=>{const t=new Date().toISOString(),s=await n.selectFrom("universal_login_sessions").where("universal_login_sessions.expires_at",">",t).where("universal_login_sessions.id","=",e).selectAll().executeTakeFirst();if(!s)return null;const{response_type:r,response_mode:a,redirect_uri:o,audience:c,state:d,nonce:u,scope:l,code_challenge_method:T,code_challenge:C,username:L,vendor_id:te,...de}=s;return{...de,authParams:{client_id:de.client_id,vendor_id:te,response_type:r,response_mode:a,redirect_uri:o,audience:c,state:d,nonce:u,scope:l,code_challenge_method:T,code_challenge:C,username:L}}}}function pa(n){return async(e,t)=>{const{authParams:s,...r}=t,a={created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("universal_login_sessions").values({...s,...r,...a,tenant_id:e}).execute(),{...t,...a}}}function ha(n){return async(e,t,s)=>{const{authParams:r,...a}=s;return(await n.updateTable("universal_login_sessions").set({...r,...a}).where("id","=",t).where("tenant_id","=",e).execute()).length===1}}function fa(n){return{create:pa(n),get:la(n),update:ha(n)}}function ma(n){return async(e,t)=>{const s={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...t},r=JSON.stringify(t.allowed_origins),a=JSON.stringify(t.callbacks),o=JSON.stringify(t.web_origins),c=JSON.stringify(t.allowed_logout_urls);return await n.insertInto("applications").values({...s,tenant_id:e,disable_sign_ups:t.disable_sign_ups?1:0,addons:t.addons?JSON.stringify(t.addons):"{}",callbacks:a,allowed_origins:r,web_origins:o,allowed_logout_urls:c}).execute(),s}}function _a(n){return async e=>({applications:(await n.selectFrom("applications").where("applications.tenant_id","=",e).selectAll().execute()).map(a=>({...a,disable_sign_ups:!!a.disable_sign_ups,addons:a.addons?JSON.parse(a.addons):{},callbacks:a.callbacks?JSON.parse(a.callbacks):[],allowed_origins:a.allowed_origins?JSON.parse(a.allowed_origins):[],web_origins:a.web_origins?JSON.parse(a.web_origins):[],allowed_logout_urls:a.allowed_logout_urls?JSON.parse(a.allowed_logout_urls):[]}))})}function ga(n){return async(e,t)=>{const s=await n.selectFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",t).selectAll().executeTakeFirst();return s?E({...s,disable_sign_ups:!!s.disable_sign_ups,addons:JSON.parse(s.addons),callbacks:JSON.parse(s.callbacks),allowed_origins:JSON.parse(s.allowed_origins),web_origins:JSON.parse(s.web_origins),allowed_logout_urls:JSON.parse(s.allowed_logout_urls)}):null}}function ya(n){return async(e,t)=>(await n.deleteFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",t).executeTakeFirst()).numDeletedRows>0}function va(n){return async(e,t,s)=>{const r={...s,updated_at:new Date().toISOString(),allowed_origins:s.allowed_origins?JSON.stringify(s.allowed_origins):void 0,callbacks:s.callbacks?JSON.stringify(s.callbacks):void 0,web_origins:s.web_origins?JSON.stringify(s.web_origins):void 0,allowed_logout_urls:s.allowed_logout_urls?JSON.stringify(s.allowed_logout_urls):void 0,addons:s.addons?JSON.stringify(s.addons):"{}",disable_sign_ups:s.disable_sign_ups?1:0};return await n.updateTable("applications").set(r).where("applications.id","=",t).where("applications.tenant_id","=",e).execute(),!0}}function wa(n){return{create:ma(n),list:_a(n),get:ga(n),remove:ya(n),update:va(n)}}function ka(n){return async(e,t)=>{const s={id:Ie(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("connections").values({...s,tenant_id:e}).execute(),s}}function ba(n){return async(e,t)=>{let s=n.selectFrom("connections").where("connections.tenant_id","=",e);t.q&&(s=Ne(n,s,t.q,["user_id","ip"]));const a=await s.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await s.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{connections:a.map(E),start:t.page*t.per_page,limit:t.per_page,length:_e(o)}}}function xa(n){return async(e,t)=>(await n.deleteFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",t).executeTakeFirst()).numDeletedRows>0}function Ta(n){return async(e,t)=>{const s=await n.selectFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",t).selectAll().executeTakeFirst();return s?E(s):null}}function Oa(n){return async(e,t,s)=>{const r={...s,updated_at:new Date().toISOString()};return await n.updateTable("connections").set(r).where("connections.id","=",t).where("connections.tenant_id","=",e).execute(),!0}}function Sa(n){return{create:ka(n),get:Ta(n),list:ba(n),remove:xa(n),update:Oa(n)}}function Za(n){return{get:async e=>{const t=await n.selectFrom("applications").selectAll().where("id","=",e).executeTakeFirst();if(!t)return null;const s=await n.selectFrom("tenants").selectAll().where("id","=",t.tenant_id).executeTakeFirst();if(!s)throw new K(404,{message:"Tenant not found"});const r=await n.selectFrom("connections").where("tenant_id","=",t.tenant_id).selectAll().execute(),a=await n.selectFrom("domains").where("tenant_id","=",t.tenant_id).selectAll().execute();return{...t,connections:r.map(c=>Cn.parse(E(c))),domains:a,addons:t.addons?JSON.parse(t.addons):{},callbacks:t.callbacks?JSON.parse(t.callbacks):[],allowed_origins:t.allowed_origins?JSON.parse(t.allowed_origins):[],web_origins:t.web_origins?JSON.parse(t.web_origins):[],allowed_logout_urls:t.allowed_logout_urls?JSON.parse(t.allowed_logout_urls):[],tenant:E(s),disable_sign_ups:!!t.disable_sign_ups}}}}function ja(n){return async()=>await n.selectFrom("keys").where("revoked_at","is",null).selectAll().execute()}function Na(n){return async e=>{await n.insertInto("keys").values(e).execute()}}function Ia(n){return async(e,t)=>!!(await n.updateTable("keys").set({revoked_at:t.toISOString()}).where("kid","=",e).execute()).length}function Ca(n){return{create:Na(n),list:ja(n),revoke:Ia(n)}}function Ea(n){return async(e,t)=>{const s={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,id:Ie(),...t};return await n.insertInto("domains").values(s).execute(),s}}function Aa(n){return async(e,t)=>{let s=n.selectFrom("domains").where("domains.tenant_id","=",e);t.q&&(s=Ne(n,s,t.q,["user_id","ip"]));const a=await s.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await s.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{domains:a,start:t.page*t.per_page,limit:t.per_page,length:_e(o)}}}function Ra(n){return{create:Ea(n),list:Aa(n)}}function $a(n){return async e=>{const[t]=await n.selectFrom("branding").where("branding.tenant_id","=",e).selectAll().execute();if(!t)return null;const{tenant_id:s,colors_primary:r,colors_page_background_type:a,colors_page_background_start:o,colors_page_background_end:c,colors_page_background_angle_dev:d,font_url:u,...l}=t;return E({...l,colors:{primary:r,page_background:{type:a,start:o,end:c,angle_deg:d}},font:u?{url:u}:void 0})}}function Pa(n){return async(e,t)=>{var o,c,d,u,l,T,C,L,te,de,be,xe,Te,Qe,He,ne,se,re;const{colors:s,font:r,...a}=t;try{await n.insertInto("branding").values({...a,colors_primary:s==null?void 0:s.primary,colors_page_background_type:(c=(o=t.colors)==null?void 0:o.page_background)==null?void 0:c.type,colors_page_background_start:(u=(d=t.colors)==null?void 0:d.page_background)==null?void 0:u.start,colors_page_background_end:(T=(l=t.colors)==null?void 0:l.page_background)==null?void 0:T.end,colors_page_background_angle_dev:(L=(C=t.colors)==null?void 0:C.page_background)==null?void 0:L.angle_deg,font_url:(te=t.font)==null?void 0:te.url,tenant_id:e}).execute()}catch{await n.updateTable("branding").set({...a,colors_primary:s==null?void 0:s.primary,colors_page_background_type:(be=(de=t.colors)==null?void 0:de.page_background)==null?void 0:be.type,colors_page_background_start:(Te=(xe=t.colors)==null?void 0:xe.page_background)==null?void 0:Te.start,colors_page_background_end:(He=(Qe=t.colors)==null?void 0:Qe.page_background)==null?void 0:He.end,colors_page_background_angle_dev:(se=(ne=t.colors)==null?void 0:ne.page_background)==null?void 0:se.angle_deg,font_url:(re=t.font)==null?void 0:re.url}).where("tenant_id","=",e).execute()}}}function Da(n){return{get:$a(n),set:Pa(n)}}function Ma(n){return async(e,t)=>{const s=await n.selectFrom("authentication_codes").where("tenant_id","=",e).where("code","=",t).selectAll().executeTakeFirst();if(!s)throw new K(403,{message:"Code not found or expired"});const{state:r,nonce:a,scope:o,client_id:c,response_type:d,response_mode:u,redirect_uri:l,...T}=s;return{...T,authParams:{state:r,nonce:a,scope:o,client_id:c,response_type:d,response_mode:u,redirect_uri:l}}}}function La(n){return async(e,t)=>{const{authParams:s,...r}=t;await n.insertInto("authentication_codes").values({...r,...s,tenant_id:e}).execute()}}function Va(n){return{create:La(n),get:Ma(n)}}function Ua(n){return async(e,t)=>{let s=n.selectFrom("hooks").where("hooks.tenant_id","=",e);t.q&&(s=Ne(n,s,t.q,["url"]));const a=await s.offset(t.page*t.per_page).limit(t.per_page).selectAll().execute(),{count:o}=await s.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{hooks:a.map(d=>{const{tenant_id:u,enabled:l,synchronous:T,...C}=d;return E({...C,enabled:!!l,synchronous:!!T})}),start:t.page*t.per_page,limit:t.per_page,length:_e(o)}}}function Fa(n){return async(e,t)=>{const s=await n.selectFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",t).selectAll().executeTakeFirst();return s?(s.enabled=!!s.enabled,s.synchronous=!!s.synchronous,E(s)):null}}function za(n){return async(e,t)=>(await n.deleteFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",t).executeTakeFirst()).numDeletedRows>0}function Ba(n){return async(e,t)=>{const s={hook_id:Ie(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("hooks").values({...s,tenant_id:e}).execute(),s}}function Wa(n){return async(e,t,s)=>{const r={...s,updated_at:new Date().toISOString()};return await n.updateTable("hooks").set(r).where("hooks.hook_id","=",t).where("hooks.tenant_id","=",e).execute(),!0}}function qa(n){return{create:Ba(n),get:Fa(n),list:Ua(n),update:Wa(n),remove:za(n)}}function Ja(n,e){var t={};for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&e.indexOf(s)<0&&(t[s]=n[s]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,s=Object.getOwnPropertySymbols(n);r<s.length;r++)e.indexOf(s[r])<0&&Object.prototype.propertyIsEnumerable.call(n,s[r])&&(t[s[r]]=n[s[r]]);return t}typeof SuppressedError=="function"&&SuppressedError;function Ka(n,e){var t;return((t=n==null?void 0:n._def)===null||t===void 0?void 0:t.typeName)===e}function mt(n,e){const t=n.ZodType.prototype[e];n.ZodType.prototype[e]=function(...s){const r=t.apply(this,s);return r._def.openapi=this._def.openapi,r}}function Qa(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(r,a){var o,c,d,u,l,T;const C=typeof r=="string"?a:r,L=C??{},{param:te}=L,de=Ja(L,["param"]),be=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof r=="string"?{refId:r}:void 0),xe=Object.assign(Object.assign(Object.assign({},(c=this._def.openapi)===null||c===void 0?void 0:c.metadata),de),!((u=(d=this._def.openapi)===null||d===void 0?void 0:d.metadata)===null||u===void 0)&&u.param||te?{param:Object.assign(Object.assign({},(T=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||T===void 0?void 0:T.param),te)}:void 0),Te=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(be).length>0?{_internal:be}:void 0),Object.keys(xe).length>0?{metadata:xe}:void 0)}));if(Ka(this,"ZodObject")){const Qe=this.extend;Te.extend=function(...He){var ne,se,re,Oe,Re,$e;const Pe=Qe.apply(this,He);return Pe._def.openapi={_internal:{extendedFrom:!((se=(ne=this._def.openapi)===null||ne===void 0?void 0:ne._internal)===null||se===void 0)&&se.refId?{refId:(Oe=(re=this._def.openapi)===null||re===void 0?void 0:re._internal)===null||Oe===void 0?void 0:Oe.refId,schema:this}:(Re=this._def.openapi)===null||Re===void 0?void 0:Re._internal.extendedFrom},metadata:($e=Pe._def.openapi)===null||$e===void 0?void 0:$e.metadata},Pe}}return Te},mt(n,"optional"),mt(n,"nullable"),mt(n,"default"),mt(n,"transform"),mt(n,"refine");const e=n.ZodObject.prototype.deepPartial;n.ZodObject.prototype.deepPartial=function(){const r=this._def.shape(),a=e.apply(this),o=a._def.shape();return Object.entries(o).forEach(([c,d])=>{var u,l;d._def.openapi=(l=(u=r[c])===null||u===void 0?void 0:u._def)===null||l===void 0?void 0:l.openapi}),a._def.openapi=void 0,a};const t=n.ZodObject.prototype.pick;n.ZodObject.prototype.pick=function(...r){const a=t.apply(this,r);return a._def.openapi=void 0,a};const s=n.ZodObject.prototype.omit;n.ZodObject.prototype.omit=function(...r){const a=s.apply(this,r);return a._def.openapi=void 0,a}}new Set(".\\+*[^]$()");var I;(function(n){n.assertEqual=r=>r;function e(r){}n.assertIs=e;function t(r){throw new Error}n.assertNever=t,n.arrayToEnum=r=>{const a={};for(const o of r)a[o]=o;return a},n.getValidEnumValues=r=>{const a=n.objectKeys(r).filter(c=>typeof r[r[c]]!="number"),o={};for(const c of a)o[c]=r[c];return n.objectValues(o)},n.objectValues=r=>n.objectKeys(r).map(function(a){return r[a]}),n.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&a.push(o);return a},n.find=(r,a)=>{for(const o of r)if(a(o))return o},n.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function s(r,a=" | "){return r.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}n.joinValues=s,n.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(I||(I={}));var cn;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(cn||(cn={}));const g=I.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ge=n=>{switch(typeof n){case"undefined":return g.undefined;case"string":return g.string;case"number":return isNaN(n)?g.nan:g.number;case"boolean":return g.boolean;case"function":return g.function;case"bigint":return g.bigint;case"symbol":return g.symbol;case"object":return Array.isArray(n)?g.array:n===null?g.null:n.then&&typeof n.then=="function"&&n.catch&&typeof n.catch=="function"?g.promise:typeof Map<"u"&&n instanceof Map?g.map:typeof Set<"u"&&n instanceof Set?g.set:typeof Date<"u"&&n instanceof Date?g.date:g.object;default:return g.unknown}},h=I.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ha=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class U extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},s={_errors:[]},r=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(r);else if(o.code==="invalid_return_type")r(o.returnTypeError);else if(o.code==="invalid_arguments")r(o.argumentsError);else if(o.path.length===0)s._errors.push(t(o));else{let c=s,d=0;for(;d<o.path.length;){const u=o.path[d];d===o.path.length-1?(c[u]=c[u]||{_errors:[]},c[u]._errors.push(t(o))):c[u]=c[u]||{_errors:[]},c=c[u],d++}}};return r(this),s}static assert(e){if(!(e instanceof U))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,I.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):s.push(e(r));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}U.create=n=>new U(n);const ze=(n,e)=>{let t;switch(n.code){case h.invalid_type:n.received===g.undefined?t="Required":t=`Expected ${n.expected}, received ${n.received}`;break;case h.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(n.expected,I.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:t=`Unrecognized key(s) in object: ${I.joinValues(n.keys,", ")}`;break;case h.invalid_union:t="Invalid input";break;case h.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${I.joinValues(n.options)}`;break;case h.invalid_enum_value:t=`Invalid enum value. Expected ${I.joinValues(n.options)}, received '${n.received}'`;break;case h.invalid_arguments:t="Invalid function arguments";break;case h.invalid_return_type:t="Invalid function return type";break;case h.invalid_date:t="Invalid date";break;case h.invalid_string:typeof n.validation=="object"?"includes"in n.validation?(t=`Invalid input: must include "${n.validation.includes}"`,typeof n.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${n.validation.position}`)):"startsWith"in n.validation?t=`Invalid input: must start with "${n.validation.startsWith}"`:"endsWith"in n.validation?t=`Invalid input: must end with "${n.validation.endsWith}"`:I.assertNever(n.validation):n.validation!=="regex"?t=`Invalid ${n.validation}`:t="Invalid";break;case h.too_small:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at least":"more than"} ${n.minimum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at least":"over"} ${n.minimum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${n.minimum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly equal to ":n.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(n.minimum))}`:t="Invalid input";break;case h.too_big:n.type==="array"?t=`Array must contain ${n.exact?"exactly":n.inclusive?"at most":"less than"} ${n.maximum} element(s)`:n.type==="string"?t=`String must contain ${n.exact?"exactly":n.inclusive?"at most":"under"} ${n.maximum} character(s)`:n.type==="number"?t=`Number must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="bigint"?t=`BigInt must be ${n.exact?"exactly":n.inclusive?"less than or equal to":"less than"} ${n.maximum}`:n.type==="date"?t=`Date must be ${n.exact?"exactly":n.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(n.maximum))}`:t="Invalid input";break;case h.custom:t="Invalid input";break;case h.invalid_intersection_types:t="Intersection results could not be merged";break;case h.not_multiple_of:t=`Number must be a multiple of ${n.multipleOf}`;break;case h.not_finite:t="Number must be finite";break;default:t=e.defaultError,I.assertNever(n)}return{message:t}};let Dn=ze;function Ya(n){Dn=n}function Bt(){return Dn}const Wt=n=>{const{data:e,path:t,errorMaps:s,issueData:r}=n,a=[...t,...r.path||[]],o={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let c="";const d=s.filter(u=>!!u).slice().reverse();for(const u of d)c=u(o,{data:e,defaultError:c}).message;return{...r,path:a,message:c}},Ga=[];function m(n,e){const t=Bt(),s=Wt({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===ze?void 0:ze].filter(r=>!!r)});n.common.issues.push(s)}class P{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const r of t){if(r.status==="aborted")return b;r.status==="dirty"&&e.dirty(),s.push(r.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const r of t){const a=await r.key,o=await r.value;s.push({key:a,value:o})}return P.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const r of t){const{key:a,value:o}=r;if(a.status==="aborted"||o.status==="aborted")return b;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||r.alwaysSet)&&(s[a.value]=o.value)}return{status:e.value,value:s}}}const b=Object.freeze({status:"aborted"}),Be=n=>({status:"dirty",value:n}),M=n=>({status:"valid",value:n}),dn=n=>n.status==="aborted",un=n=>n.status==="dirty",_t=n=>n.status==="valid",gt=n=>typeof Promise<"u"&&n instanceof Promise;function qt(n,e,t,s){if(typeof e=="function"?n!==e||!s:!e.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(n)}function Mn(n,e,t,s,r){if(typeof e=="function"?n!==e||!r:!e.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(n,t),t}typeof SuppressedError=="function"&&SuppressedError;var v;(function(n){n.errToObj=e=>typeof e=="string"?{message:e}:e||{},n.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(v||(v={}));var yt,vt;class G{constructor(e,t,s,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ln=(n,e)=>{if(_t(e))return{success:!0,data:e.value};if(!n.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new U(n.common.issues);return this._error=t,this._error}}};function S(n){if(!n)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:r}=n;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(o,c)=>{var d,u;const{message:l}=n;return o.code==="invalid_enum_value"?{message:l??c.defaultError}:typeof c.data>"u"?{message:(d=l??s)!==null&&d!==void 0?d:c.defaultError}:o.code!=="invalid_type"?{message:c.defaultError}:{message:(u=l??t)!==null&&u!==void 0?u:c.defaultError}},description:r}}class j{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return ge(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ge(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new P,ctx:{common:e.parent.common,data:e.data,parsedType:ge(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(gt(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const r={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)},a=this._parseSync({data:e,path:r.path,parent:r});return Ln(r,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ge(e)},r=this._parse({data:e,path:s.path,parent:s}),a=await(gt(r)?r:Promise.resolve(r));return Ln(s,a)}refine(e,t){const s=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;return this._refinement((r,a)=>{const o=e(r),c=()=>a.addIssue({code:h.custom,...s(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(c(),!1)):o?!0:(c(),!1)})}refinement(e,t){return this._refinement((s,r)=>e(s)?!0:(r.addIssue(typeof t=="function"?t(s,r):t),!1))}_refinement(e){return new J({schema:this,typeName:k.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ee.create(this,this._def)}nullable(){return ke.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return q.create(this,this._def)}promise(){return Ke.create(this,this._def)}or(e){return xt.create([this,e],this._def)}and(e){return Tt.create(this,e,this._def)}transform(e){return new J({...S(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Nt({...S(this._def),innerType:this,defaultValue:t,typeName:k.ZodDefault})}brand(){return new hn({typeName:k.ZodBranded,type:this,...S(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new It({...S(this._def),innerType:this,catchValue:t,typeName:k.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ct.create(this,e)}readonly(){return Et.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Xa=/^c[^\s-]{8,}$/i,ei=/^[0-9a-z]+$/,ti=/^[0-9A-HJKMNP-TV-Z]{26}$/,ni=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,si=/^[a-z0-9_-]{21}$/i,ri=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ai=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ii="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ln;const oi=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ci=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,di=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Vn="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",ui=new RegExp(`^${Vn}$`);function Un(n){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return n.precision?e=`${e}\\.\\d{${n.precision}}`:n.precision==null&&(e=`${e}(\\.\\d+)?`),e}function li(n){return new RegExp(`^${Un(n)}$`)}function Fn(n){let e=`${Vn}T${Un(n)}`;const t=[];return t.push(n.local?"Z?":"Z"),n.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function pi(n,e){return!!((e==="v4"||!e)&&oi.test(n)||(e==="v6"||!e)&&ci.test(n))}class W extends j{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.string,received:a.parsedType}),b}const s=new P;let r;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){const o=e.data.length>a.value,c=e.data.length<a.value;(o||c)&&(r=this._getOrReturnCtx(e,r),o?m(r,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):c&&m(r,{code:h.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")ai.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"email",code:h.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")ln||(ln=new RegExp(ii,"u")),ln.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"emoji",code:h.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")ni.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"uuid",code:h.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")si.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"nanoid",code:h.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")Xa.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"cuid",code:h.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")ei.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"cuid2",code:h.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")ti.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"ulid",code:h.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),m(r,{validation:"url",code:h.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"regex",code:h.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?Fn(a).test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?ui.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?li(a).test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?ri.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"duration",code:h.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?pi(e.data,a.version)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"ip",code:h.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?di.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"base64",code:h.invalid_string,message:a.message}),s.dirty()):I.assertNever(a);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(r=>e.test(r),{validation:t,code:h.invalid_string,...v.errToObj(s)})}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...v.errToObj(e)})}url(e){return this._addCheck({kind:"url",...v.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...v.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...v.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...v.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...v.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...v.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...v.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...v.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...v.errToObj(e)})}datetime(e){var t,s;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,local:(s=e==null?void 0:e.local)!==null&&s!==void 0?s:!1,...v.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...v.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...v.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...v.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...v.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...v.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...v.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...v.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...v.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...v.errToObj(t)})}nonempty(e){return this.min(1,v.errToObj(e))}trim(){return new W({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}W.create=n=>{var e;return new W({checks:[],typeName:k.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...S(n)})};function hi(n,e){const t=(n.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,r=t>s?t:s,a=parseInt(n.toFixed(r).replace(".","")),o=parseInt(e.toFixed(r).replace(".",""));return a%o/Math.pow(10,r)}class ye extends j{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==g.number){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.number,received:a.parsedType}),b}let s;const r=new P;for(const a of this._def.checks)a.kind==="int"?I.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:h.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?hi(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:h.not_finite,message:a.message}),r.dirty()):I.assertNever(a);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,s,r){return new ye({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:v.toString(r)}]})}_addCheck(e){return new ye({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:v.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:v.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&I.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}ye.create=n=>new ye({checks:[],typeName:k.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...S(n)});class ve extends j{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==g.bigint){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.bigint,received:a.parsedType}),b}let s;const r=new P;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),m(s,{code:h.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):I.assertNever(a);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,s,r){return new ve({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:v.toString(r)}]})}_addCheck(e){return new ve({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}ve.create=n=>{var e;return new ve({checks:[],typeName:k.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...S(n)})};class wt extends j{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){const s=this._getOrReturnCtx(e);return m(s,{code:h.invalid_type,expected:g.boolean,received:s.parsedType}),b}return M(e.data)}}wt.create=n=>new wt({typeName:k.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...S(n)});class Ce extends j{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.date,received:a.parsedType}),b}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_date}),b}const s=new P;let r;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(r=this._getOrReturnCtx(e,r),m(r,{code:h.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):I.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ce({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:v.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:v.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}Ce.create=n=>new Ce({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:k.ZodDate,...S(n)});class Jt extends j{_parse(e){if(this._getType(e)!==g.symbol){const s=this._getOrReturnCtx(e);return m(s,{code:h.invalid_type,expected:g.symbol,received:s.parsedType}),b}return M(e.data)}}Jt.create=n=>new Jt({typeName:k.ZodSymbol,...S(n)});class kt extends j{_parse(e){if(this._getType(e)!==g.undefined){const s=this._getOrReturnCtx(e);return m(s,{code:h.invalid_type,expected:g.undefined,received:s.parsedType}),b}return M(e.data)}}kt.create=n=>new kt({typeName:k.ZodUndefined,...S(n)});class bt extends j{_parse(e){if(this._getType(e)!==g.null){const s=this._getOrReturnCtx(e);return m(s,{code:h.invalid_type,expected:g.null,received:s.parsedType}),b}return M(e.data)}}bt.create=n=>new bt({typeName:k.ZodNull,...S(n)});class We extends j{constructor(){super(...arguments),this._any=!0}_parse(e){return M(e.data)}}We.create=n=>new We({typeName:k.ZodAny,...S(n)});class Ee extends j{constructor(){super(...arguments),this._unknown=!0}_parse(e){return M(e.data)}}Ee.create=n=>new Ee({typeName:k.ZodUnknown,...S(n)});class oe extends j{_parse(e){const t=this._getOrReturnCtx(e);return m(t,{code:h.invalid_type,expected:g.never,received:t.parsedType}),b}}oe.create=n=>new oe({typeName:k.ZodNever,...S(n)});class Kt extends j{_parse(e){if(this._getType(e)!==g.undefined){const s=this._getOrReturnCtx(e);return m(s,{code:h.invalid_type,expected:g.void,received:s.parsedType}),b}return M(e.data)}}Kt.create=n=>new Kt({typeName:k.ZodVoid,...S(n)});class q extends j{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),r=this._def;if(t.parsedType!==g.array)return m(t,{code:h.invalid_type,expected:g.array,received:t.parsedType}),b;if(r.exactLength!==null){const o=t.data.length>r.exactLength.value,c=t.data.length<r.exactLength.value;(o||c)&&(m(t,{code:o?h.too_big:h.too_small,minimum:c?r.exactLength.value:void 0,maximum:o?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),s.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(m(t,{code:h.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),s.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(m(t,{code:h.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((o,c)=>r.type._parseAsync(new G(t,o,t.path,c)))).then(o=>P.mergeArray(s,o));const a=[...t.data].map((o,c)=>r.type._parseSync(new G(t,o,t.path,c)));return P.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new q({...this._def,minLength:{value:e,message:v.toString(t)}})}max(e,t){return new q({...this._def,maxLength:{value:e,message:v.toString(t)}})}length(e,t){return new q({...this._def,exactLength:{value:e,message:v.toString(t)}})}nonempty(e){return this.min(1,e)}}q.create=(n,e)=>new q({type:n,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...S(e)});function qe(n){if(n instanceof R){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=ee.create(qe(s))}return new R({...n._def,shape:()=>e})}else return n instanceof q?new q({...n._def,type:qe(n.element)}):n instanceof ee?ee.create(qe(n.unwrap())):n instanceof ke?ke.create(qe(n.unwrap())):n instanceof X?X.create(n.items.map(e=>qe(e))):n}class R extends j{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=I.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==g.object){const u=this._getOrReturnCtx(e);return m(u,{code:h.invalid_type,expected:g.object,received:u.parsedType}),b}const{status:s,ctx:r}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),c=[];if(!(this._def.catchall instanceof oe&&this._def.unknownKeys==="strip"))for(const u in r.data)o.includes(u)||c.push(u);const d=[];for(const u of o){const l=a[u],T=r.data[u];d.push({key:{status:"valid",value:u},value:l._parse(new G(r,T,r.path,u)),alwaysSet:u in r.data})}if(this._def.catchall instanceof oe){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of c)d.push({key:{status:"valid",value:l},value:{status:"valid",value:r.data[l]}});else if(u==="strict")c.length>0&&(m(r,{code:h.unrecognized_keys,keys:c}),s.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of c){const T=r.data[l];d.push({key:{status:"valid",value:l},value:u._parse(new G(r,T,r.path,l)),alwaysSet:l in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of d){const T=await l.key,C=await l.value;u.push({key:T,value:C,alwaysSet:l.alwaysSet})}return u}).then(u=>P.mergeObjectSync(s,u)):P.mergeObjectSync(s,d)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new R({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var r,a,o,c;const d=(o=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,t,s).message)!==null&&o!==void 0?o:s.defaultError;return t.code==="unrecognized_keys"?{message:(c=v.errToObj(e).message)!==null&&c!==void 0?c:d}:{message:d}}}:{}})}strip(){return new R({...this._def,unknownKeys:"strip"})}passthrough(){return new R({...this._def,unknownKeys:"passthrough"})}extend(e){return new R({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new R({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:k.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new R({...this._def,catchall:e})}pick(e){const t={};return I.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new R({...this._def,shape:()=>t})}omit(e){const t={};return I.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new R({...this._def,shape:()=>t})}deepPartial(){return qe(this)}partial(e){const t={};return I.objectKeys(this.shape).forEach(s=>{const r=this.shape[s];e&&!e[s]?t[s]=r:t[s]=r.optional()}),new R({...this._def,shape:()=>t})}required(e){const t={};return I.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof ee;)a=a._def.innerType;t[s]=a}}),new R({...this._def,shape:()=>t})}keyof(){return zn(I.objectKeys(this.shape))}}R.create=(n,e)=>new R({shape:()=>n,unknownKeys:"strip",catchall:oe.create(),typeName:k.ZodObject,...S(e)}),R.strictCreate=(n,e)=>new R({shape:()=>n,unknownKeys:"strict",catchall:oe.create(),typeName:k.ZodObject,...S(e)}),R.lazycreate=(n,e)=>new R({shape:n,unknownKeys:"strip",catchall:oe.create(),typeName:k.ZodObject,...S(e)});class xt extends j{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function r(a){for(const c of a)if(c.result.status==="valid")return c.result;for(const c of a)if(c.result.status==="dirty")return t.common.issues.push(...c.ctx.common.issues),c.result;const o=a.map(c=>new U(c.ctx.common.issues));return m(t,{code:h.invalid_union,unionErrors:o}),b}if(t.common.async)return Promise.all(s.map(async a=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(r);{let a;const o=[];for(const d of s){const u={...t,common:{...t.common,issues:[]},parent:null},l=d._parseSync({data:t.data,path:t.path,parent:u});if(l.status==="valid")return l;l.status==="dirty"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&o.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const c=o.map(d=>new U(d));return m(t,{code:h.invalid_union,unionErrors:c}),b}}get options(){return this._def.options}}xt.create=(n,e)=>new xt({options:n,typeName:k.ZodUnion,...S(e)});const ce=n=>n instanceof St?ce(n.schema):n instanceof J?ce(n.innerType()):n instanceof Zt?[n.value]:n instanceof we?n.options:n instanceof jt?I.objectValues(n.enum):n instanceof Nt?ce(n._def.innerType):n instanceof kt?[void 0]:n instanceof bt?[null]:n instanceof ee?[void 0,...ce(n.unwrap())]:n instanceof ke?[null,...ce(n.unwrap())]:n instanceof hn||n instanceof Et?ce(n.unwrap()):n instanceof It?ce(n._def.innerType):[];class Qt extends j{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.object)return m(t,{code:h.invalid_type,expected:g.object,received:t.parsedType}),b;const s=this.discriminator,r=t.data[s],a=this.optionsMap.get(r);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(m(t,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),b)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const r=new Map;for(const a of t){const o=ce(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const c of o){if(r.has(c))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(c)}`);r.set(c,a)}}return new Qt({typeName:k.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...S(s)})}}function pn(n,e){const t=ge(n),s=ge(e);if(n===e)return{valid:!0,data:n};if(t===g.object&&s===g.object){const r=I.objectKeys(e),a=I.objectKeys(n).filter(c=>r.indexOf(c)!==-1),o={...n,...e};for(const c of a){const d=pn(n[c],e[c]);if(!d.valid)return{valid:!1};o[c]=d.data}return{valid:!0,data:o}}else if(t===g.array&&s===g.array){if(n.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<n.length;a++){const o=n[a],c=e[a],d=pn(o,c);if(!d.valid)return{valid:!1};r.push(d.data)}return{valid:!0,data:r}}else return t===g.date&&s===g.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class Tt extends j{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=(a,o)=>{if(dn(a)||dn(o))return b;const c=pn(a.value,o.value);return c.valid?((un(a)||un(o))&&t.dirty(),{status:t.value,value:c.data}):(m(s,{code:h.invalid_intersection_types}),b)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,o])=>r(a,o)):r(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}Tt.create=(n,e,t)=>new Tt({left:n,right:e,typeName:k.ZodIntersection,...S(t)});class X extends j{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==g.array)return m(s,{code:h.invalid_type,expected:g.array,received:s.parsedType}),b;if(s.data.length<this._def.items.length)return m(s,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),b;!this._def.rest&&s.data.length>this._def.items.length&&(m(s,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map((o,c)=>{const d=this._def.items[c]||this._def.rest;return d?d._parse(new G(s,o,s.path,c)):null}).filter(o=>!!o);return s.common.async?Promise.all(a).then(o=>P.mergeArray(t,o)):P.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new X({...this._def,rest:e})}}X.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new X({items:n,typeName:k.ZodTuple,rest:null,...S(e)})};class Ot extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==g.object)return m(s,{code:h.invalid_type,expected:g.object,received:s.parsedType}),b;const r=[],a=this._def.keyType,o=this._def.valueType;for(const c in s.data)r.push({key:a._parse(new G(s,c,s.path,c)),value:o._parse(new G(s,s.data[c],s.path,c)),alwaysSet:c in s.data});return s.common.async?P.mergeObjectAsync(t,r):P.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof j?new Ot({keyType:e,valueType:t,typeName:k.ZodRecord,...S(s)}):new Ot({keyType:W.create(),valueType:e,typeName:k.ZodRecord,...S(t)})}}class Ht extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==g.map)return m(s,{code:h.invalid_type,expected:g.map,received:s.parsedType}),b;const r=this._def.keyType,a=this._def.valueType,o=[...s.data.entries()].map(([c,d],u)=>({key:r._parse(new G(s,c,s.path,[u,"key"])),value:a._parse(new G(s,d,s.path,[u,"value"]))}));if(s.common.async){const c=new Map;return Promise.resolve().then(async()=>{for(const d of o){const u=await d.key,l=await d.value;if(u.status==="aborted"||l.status==="aborted")return b;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),c.set(u.value,l.value)}return{status:t.value,value:c}})}else{const c=new Map;for(const d of o){const u=d.key,l=d.value;if(u.status==="aborted"||l.status==="aborted")return b;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),c.set(u.value,l.value)}return{status:t.value,value:c}}}}Ht.create=(n,e,t)=>new Ht({valueType:e,keyType:n,typeName:k.ZodMap,...S(t)});class Ae extends j{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==g.set)return m(s,{code:h.invalid_type,expected:g.set,received:s.parsedType}),b;const r=this._def;r.minSize!==null&&s.data.size<r.minSize.value&&(m(s,{code:h.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&s.data.size>r.maxSize.value&&(m(s,{code:h.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());const a=this._def.valueType;function o(d){const u=new Set;for(const l of d){if(l.status==="aborted")return b;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const c=[...s.data.values()].map((d,u)=>a._parse(new G(s,d,s.path,u)));return s.common.async?Promise.all(c).then(d=>o(d)):o(c)}min(e,t){return new Ae({...this._def,minSize:{value:e,message:v.toString(t)}})}max(e,t){return new Ae({...this._def,maxSize:{value:e,message:v.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ae.create=(n,e)=>new Ae({valueType:n,minSize:null,maxSize:null,typeName:k.ZodSet,...S(e)});class Je extends j{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.function)return m(t,{code:h.invalid_type,expected:g.function,received:t.parsedType}),b;function s(c,d){return Wt({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Bt(),ze].filter(u=>!!u),issueData:{code:h.invalid_arguments,argumentsError:d}})}function r(c,d){return Wt({data:c,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Bt(),ze].filter(u=>!!u),issueData:{code:h.invalid_return_type,returnTypeError:d}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Ke){const c=this;return M(async function(...d){const u=new U([]),l=await c._def.args.parseAsync(d,a).catch(L=>{throw u.addIssue(s(d,L)),u}),T=await Reflect.apply(o,this,l);return await c._def.returns._def.type.parseAsync(T,a).catch(L=>{throw u.addIssue(r(T,L)),u})})}else{const c=this;return M(function(...d){const u=c._def.args.safeParse(d,a);if(!u.success)throw new U([s(d,u.error)]);const l=Reflect.apply(o,this,u.data),T=c._def.returns.safeParse(l,a);if(!T.success)throw new U([r(l,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Je({...this._def,args:X.create(e).rest(Ee.create())})}returns(e){return new Je({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new Je({args:e||X.create([]).rest(Ee.create()),returns:t||Ee.create(),typeName:k.ZodFunction,...S(s)})}}class St extends j{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}St.create=(n,e)=>new St({getter:n,typeName:k.ZodLazy,...S(e)});class Zt extends j{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return m(t,{received:t.data,code:h.invalid_literal,expected:this._def.value}),b}return{status:"valid",value:e.data}}get value(){return this._def.value}}Zt.create=(n,e)=>new Zt({value:n,typeName:k.ZodLiteral,...S(e)});function zn(n,e){return new we({values:n,typeName:k.ZodEnum,...S(e)})}class we extends j{constructor(){super(...arguments),yt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return m(t,{expected:I.joinValues(s),received:t.parsedType,code:h.invalid_type}),b}if(qt(this,yt)||Mn(this,yt,new Set(this._def.values)),!qt(this,yt).has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return m(t,{received:t.data,code:h.invalid_enum_value,options:s}),b}return M(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return we.create(e,{...this._def,...t})}exclude(e,t=this._def){return we.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}yt=new WeakMap,we.create=zn;class jt extends j{constructor(){super(...arguments),vt.set(this,void 0)}_parse(e){const t=I.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==g.string&&s.parsedType!==g.number){const r=I.objectValues(t);return m(s,{expected:I.joinValues(r),received:s.parsedType,code:h.invalid_type}),b}if(qt(this,vt)||Mn(this,vt,new Set(I.getValidEnumValues(this._def.values))),!qt(this,vt).has(e.data)){const r=I.objectValues(t);return m(s,{received:s.data,code:h.invalid_enum_value,options:r}),b}return M(e.data)}get enum(){return this._def.values}}vt=new WeakMap,jt.create=(n,e)=>new jt({values:n,typeName:k.ZodNativeEnum,...S(e)});class Ke extends j{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==g.promise&&t.common.async===!1)return m(t,{code:h.invalid_type,expected:g.promise,received:t.parsedType}),b;const s=t.parsedType===g.promise?t.data:Promise.resolve(t.data);return M(s.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ke.create=(n,e)=>new Ke({type:n,typeName:k.ZodPromise,...S(e)});class J extends j{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:o=>{m(s,o),o.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const o=r.transform(s.data,a);if(s.common.async)return Promise.resolve(o).then(async c=>{if(t.value==="aborted")return b;const d=await this._def.schema._parseAsync({data:c,path:s.path,parent:s});return d.status==="aborted"?b:d.status==="dirty"||t.value==="dirty"?Be(d.value):d});{if(t.value==="aborted")return b;const c=this._def.schema._parseSync({data:o,path:s.path,parent:s});return c.status==="aborted"?b:c.status==="dirty"||t.value==="dirty"?Be(c.value):c}}if(r.type==="refinement"){const o=c=>{const d=r.refinement(c,a);if(s.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return c};if(s.common.async===!1){const c=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return c.status==="aborted"?b:(c.status==="dirty"&&t.dirty(),o(c.value),{status:t.value,value:c.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(c=>c.status==="aborted"?b:(c.status==="dirty"&&t.dirty(),o(c.value).then(()=>({status:t.value,value:c.value}))))}if(r.type==="transform")if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!_t(o))return o;const c=r.transform(o.value,a);if(c instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:c}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>_t(o)?Promise.resolve(r.transform(o.value,a)).then(c=>({status:t.value,value:c})):o);I.assertNever(r)}}J.create=(n,e,t)=>new J({schema:n,typeName:k.ZodEffects,effect:e,...S(t)}),J.createWithPreprocess=(n,e,t)=>new J({schema:e,effect:{type:"preprocess",transform:n},typeName:k.ZodEffects,...S(t)});class ee extends j{_parse(e){return this._getType(e)===g.undefined?M(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ee.create=(n,e)=>new ee({innerType:n,typeName:k.ZodOptional,...S(e)});class ke extends j{_parse(e){return this._getType(e)===g.null?M(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ke.create=(n,e)=>new ke({innerType:n,typeName:k.ZodNullable,...S(e)});class Nt extends j{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===g.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Nt.create=(n,e)=>new Nt({innerType:n,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...S(e)});class It extends j{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return gt(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new U(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new U(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}It.create=(n,e)=>new It({innerType:n,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...S(e)});class Yt extends j{_parse(e){if(this._getType(e)!==g.nan){const s=this._getOrReturnCtx(e);return m(s,{code:h.invalid_type,expected:g.nan,received:s.parsedType}),b}return{status:"valid",value:e.data}}}Yt.create=n=>new Yt({typeName:k.ZodNaN,...S(n)});const fi=Symbol("zod_brand");class hn extends j{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ct extends j{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?b:a.status==="dirty"?(t.dirty(),Be(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{const r=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return r.status==="aborted"?b:r.status==="dirty"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:s.path,parent:s})}}static create(e,t){return new Ct({in:e,out:t,typeName:k.ZodPipeline})}}class Et extends j{_parse(e){const t=this._def.innerType._parse(e),s=r=>(_t(r)&&(r.value=Object.freeze(r.value)),r);return gt(t)?t.then(r=>s(r)):s(t)}unwrap(){return this._def.innerType}}Et.create=(n,e)=>new Et({innerType:n,typeName:k.ZodReadonly,...S(e)});function Bn(n,e={},t){return n?We.create().superRefine((s,r)=>{var a,o;if(!n(s)){const c=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,d=(o=(a=c.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0,u=typeof c=="string"?{message:c}:c;r.addIssue({code:"custom",...u,fatal:d})}}):We.create()}const mi={object:R.lazycreate};var k;(function(n){n.ZodString="ZodString",n.ZodNumber="ZodNumber",n.ZodNaN="ZodNaN",n.ZodBigInt="ZodBigInt",n.ZodBoolean="ZodBoolean",n.ZodDate="ZodDate",n.ZodSymbol="ZodSymbol",n.ZodUndefined="ZodUndefined",n.ZodNull="ZodNull",n.ZodAny="ZodAny",n.ZodUnknown="ZodUnknown",n.ZodNever="ZodNever",n.ZodVoid="ZodVoid",n.ZodArray="ZodArray",n.ZodObject="ZodObject",n.ZodUnion="ZodUnion",n.ZodDiscriminatedUnion="ZodDiscriminatedUnion",n.ZodIntersection="ZodIntersection",n.ZodTuple="ZodTuple",n.ZodRecord="ZodRecord",n.ZodMap="ZodMap",n.ZodSet="ZodSet",n.ZodFunction="ZodFunction",n.ZodLazy="ZodLazy",n.ZodLiteral="ZodLiteral",n.ZodEnum="ZodEnum",n.ZodEffects="ZodEffects",n.ZodNativeEnum="ZodNativeEnum",n.ZodOptional="ZodOptional",n.ZodNullable="ZodNullable",n.ZodDefault="ZodDefault",n.ZodCatch="ZodCatch",n.ZodPromise="ZodPromise",n.ZodBranded="ZodBranded",n.ZodPipeline="ZodPipeline",n.ZodReadonly="ZodReadonly"})(k||(k={}));const _i=(n,e={message:`Input not instance of ${n.name}`})=>Bn(t=>t instanceof n,e),Wn=W.create,qn=ye.create,gi=Yt.create,yi=ve.create,Jn=wt.create,vi=Ce.create,wi=Jt.create,ki=kt.create,bi=bt.create,xi=We.create,Ti=Ee.create,Oi=oe.create,Si=Kt.create,Zi=q.create,ji=R.create,Ni=R.strictCreate,Ii=xt.create,Ci=Qt.create,Ei=Tt.create,Ai=X.create,Ri=Ot.create,$i=Ht.create,Pi=Ae.create,Di=Je.create,Mi=St.create,Li=Zt.create,Vi=we.create,Ui=jt.create,Fi=Ke.create,Kn=J.create,zi=ee.create,Bi=ke.create,Wi=J.createWithPreprocess,qi=Ct.create;var Ji=Object.freeze({__proto__:null,defaultErrorMap:ze,setErrorMap:Ya,getErrorMap:Bt,makeIssue:Wt,EMPTY_PATH:Ga,addIssueToContext:m,ParseStatus:P,INVALID:b,DIRTY:Be,OK:M,isAborted:dn,isDirty:un,isValid:_t,isAsync:gt,get util(){return I},get objectUtil(){return cn},ZodParsedType:g,getParsedType:ge,ZodType:j,datetimeRegex:Fn,ZodString:W,ZodNumber:ye,ZodBigInt:ve,ZodBoolean:wt,ZodDate:Ce,ZodSymbol:Jt,ZodUndefined:kt,ZodNull:bt,ZodAny:We,ZodUnknown:Ee,ZodNever:oe,ZodVoid:Kt,ZodArray:q,ZodObject:R,ZodUnion:xt,ZodDiscriminatedUnion:Qt,ZodIntersection:Tt,ZodTuple:X,ZodRecord:Ot,ZodMap:Ht,ZodSet:Ae,ZodFunction:Je,ZodLazy:St,ZodLiteral:Zt,ZodEnum:we,ZodNativeEnum:jt,ZodPromise:Ke,ZodEffects:J,ZodTransformer:J,ZodOptional:ee,ZodNullable:ke,ZodDefault:Nt,ZodCatch:It,ZodNaN:Yt,BRAND:fi,ZodBranded:hn,ZodPipeline:Ct,ZodReadonly:Et,custom:Bn,Schema:j,ZodSchema:j,late:mi,get ZodFirstPartyTypeKind(){return k},coerce:{string:n=>W.create({...n,coerce:!0}),number:n=>ye.create({...n,coerce:!0}),boolean:n=>wt.create({...n,coerce:!0}),bigint:n=>ve.create({...n,coerce:!0}),date:n=>Ce.create({...n,coerce:!0})},any:xi,array:Zi,bigint:yi,boolean:Jn,date:vi,discriminatedUnion:Ci,effect:Kn,enum:Vi,function:Di,instanceof:_i,intersection:Ei,lazy:Mi,literal:Li,map:$i,nan:gi,nativeEnum:Ui,never:Oi,null:bi,nullable:Bi,number:qn,object:ji,oboolean:()=>Jn().optional(),onumber:()=>qn().optional(),optional:zi,ostring:()=>Wn().optional(),pipeline:qi,preprocess:Wi,promise:Fi,record:Ri,set:Pi,strictObject:Ni,string:Wn,symbol:wi,transformer:Kn,tuple:Ai,undefined:ki,union:Ii,unknown:Ti,void:Si,NEVER:b,ZodIssueCode:h,quotelessJson:Ha,ZodError:U});Qa(Ji);function At(n,e="",t={}){for(let s in n)if(Object.prototype.hasOwnProperty.call(n,s)){const r=e?`${e}_${s}`:s;typeof n[s]=="object"&&n[s]!==null&&!Array.isArray(n[s])?At(n[s],r,t):t[r]=n[s]}return t}function Ki(n,e){const t={};for(const[s,r]of Object.entries(n)){const a=e.find(o=>s.startsWith(`${o}_`));if(!a)t[s]=r;else{const o=s.slice(a.length+1);t[a]={...t[a],[o]:r}}}return t}function Qi(n){return async(e,t)=>{const s={themeId:Ie(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("themes").values({...At(s),tenant_id:e}).execute(),s}}function Hi(n){return async(e,t)=>(await n.deleteFrom("themes").where("themes.tenant_id","=",e).where("themes.theme_id","=",t).executeTakeFirst()).numDeletedRows>0}function Yi(n){return async(e,t)=>{const s=await n.selectFrom("themes").where("themes.tenant_id","=",e).where("themes.theme_id","=",t).selectAll().executeTakeFirst();return s?E(s):null}}function Gi(n){return async(e,t,s)=>{const r=At({...s,updated_at:new Date().toISOString()});return await n.updateTable("themes").set(r).where("themes.id","=",t).where("themes.tenant_id","=",e).execute(),!0}}function Xi(n){return{create:Qi(n),get:Yi(n),remove:Hi(n),update:Gi(n)}}function eo(n){return async(e,t)=>{const s=new Date().toISOString(),r=await n.selectFrom("logins").where("logins.expires_at",">",s).where("logins.login_id","=",t).selectAll().executeTakeFirst();return r?ur.parse(Ki(E(r),["authParams"])):null}}function to(n){return async(e,t)=>{const s={login_id:Ie(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("logins").values({...At(s),tenant_id:e}).execute(),s}}function no(n){return async(e,t,s)=>(await n.updateTable("logins").set(At(s)).where("logins.login_id","=",t).where("logins.tenant_id","=",e).execute()).length===1}function so(n){return async(e,t)=>(await n.deleteFrom("logins").where("logins.tenant_id","=",e).where("logins.login_id","=",t).execute()).length>0}function ro(n){return{create:to(n),get:eo(n),update:no(n),remove:so(n)}}function ao(n){return{applications:wa(n),authenticationCodes:Va(n),branding:Da(n),clients:Za(n),codes:ua(n),connections:Sa(n),domains:Ra(n),hooks:qa(n),keys:Ca(n),logins:ro(n),logs:Ur(n),OTP:ta(n),passwords:aa(n),users:Nr(n),sessions:Jr(n),tenants:Pr(n),themes:Xi(n),tickets:Yr(n),universalLoginSessions:fa(n)}}return ao}();
|