@authhero/kysely-adapter 0.13.3 → 0.13.4

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 eo=Object.defineProperty;var to=(se,re,I)=>re in se?eo(se,re,{enumerable:!0,configurable:!0,writable:!0,value:I}):se[re]=I;var hn=(se,re,I)=>to(se,typeof re!="symbol"?re+"":re,I);var se=class extends Error{constructor(e=500,t){super(t==null?void 0:t.message,{cause:t==null?void 0:t.cause});hn(this,"res");hn(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 re(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,app_metadata:JSON.stringify(t.app_metadata),user_metadata:JSON.stringify(t.user_metadata)};try{await n.insertInto("users").values(a).execute()}catch(o){throw o.code==="SQLITE_CONSTRAINT_UNIQUE"||o.message.includes("AlreadyExists")?new se(409,{message:"User already exists"}):(console.log(o.message),new se(500,{message:`${o.code}, ${o.message}`}))}return{...a,email:a.email||"",email_verified:a.email_verified===1,is_social:a.is_social===1}}}function I(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(I):e[t]=I(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 Yn(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 Gn(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(r,a){var o,d,c,u,l,j;const R=typeof r=="string"?a:r,U=R??{},{param:we}=U,Ke=Qn(U,["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),ke=Object.assign(Object.assign(Object.assign({},(d=this._def.openapi)===null||d===void 0?void 0:d.metadata),Ke),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||we?{param:Object.assign(Object.assign({},(j=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||j===void 0?void 0:j.param),we)}:void 0),xe=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(ke).length>0?{metadata:ke}:void 0)}));if(Yn(this,"ZodObject")){const He=this.extend;xe.extend=function(...Qe){var ee,te,ne,Te,Ae,Re;const $e=He.apply(this,Qe);return $e._def.openapi={_internal:{extendedFrom:!((te=(ee=this._def.openapi)===null||ee===void 0?void 0:ee._internal)===null||te===void 0)&&te.refId?{refId:(Te=(ne=this._def.openapi)===null||ne===void 0?void 0:ne._internal)===null||Te===void 0?void 0:Te.refId,schema:this}:(Ae=this._def.openapi)===null||Ae===void 0?void 0:Ae._internal.extendedFrom},metadata:(Re=$e._def.openapi)===null||Re===void 0?void 0:Re.metadata},$e}}return xe},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(([d,c])=>{var u,l;c._def.openapi=(l=(u=r[d])===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(d=>typeof r[r[d]]!="number"),o={};for(const d of a)o[d]=r[d];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 Yt;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(Yt||(Yt={}));const _=N.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),de=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"]),Xn=n=>JSON.stringify(n,null,2).replace(/"([^"]+)":/g,"$1:");class L 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 d=s,c=0;for(;c<o.path.length;){const u=o.path[c];c===o.path.length-1?(d[u]=d[u]||{_errors:[]},d[u]._errors.push(t(o))):d[u]=d[u]||{_errors:[]},d=d[u],c++}}};return r(this),s}static assert(e){if(!(e instanceof L))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()}}L.create=n=>new L(n);const Pe=(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 fn=Pe;function es(n){fn=n}function Rt(){return fn}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 d="";const c=s.filter(u=>!!u).slice().reverse();for(const u of c)d=u(o,{data:e,defaultError:d}).message;return{...r,path:a,message:d}},ts=[];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===Pe?void 0:Pe].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}),Gt=n=>n.status==="aborted",Xt=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 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}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 K{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 _n=(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 L(n.common.issues);return this._error=t,this._error}}};function T(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 d,c;const{message:u}=n;return a.code==="invalid_enum_value"?{message:u??o.defaultError}:typeof o.data>"u"?{message:(d=u??s)!==null&&d!==void 0?d:o.defaultError}:a.code!=="invalid_type"?{message:o.defaultError}:{message:(c=u??t)!==null&&c!==void 0?c:o.defaultError}},description:r}}class S{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 de(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:de(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:de(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:de(e)},a=this._parseSync({data:e,path:r.path,parent:r});return _n(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:de(e)},r=this._parse({data:e,path:s.path,parent:s}),a=await(Xe(r)?r:Promise.resolve(r));return _n(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),d=()=>a.addIssue({code:p.custom,...s(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(d(),!1)):o?!0:(d(),!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 Q.create(this,this._def)}nullable(){return he.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return z.create(this,this._def)}promise(){return Ve.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({...T(this._def),schema:this,typeName:w.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new lt({...T(this._def),innerType:this,defaultValue:t,typeName:w.ZodDefault})}brand(){return new nn({typeName:w.ZodBranded,type:this,...T(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new pt({...T(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 ns=/^c[^\s-]{8,}$/i,ss=/^[0-9a-z]+$/,rs=/^[0-9A-HJKMNP-TV-Z]{26}$/,as=/^[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,is=/^[a-z0-9_-]{21}$/i,os=/^[-+]?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)?)??$/,ds=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,cs="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let en;const us=/^(?:(?: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])$/,ls=/^(([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})))$/,ps=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,gn="((\\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])))",hs=new RegExp(`^${gn}$`);function yn(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 fs(n){return new RegExp(`^${yn(n)}$`)}function vn(n){let e=`${gn}T${yn(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 ms(n,e){return!!((e==="v4"||!e)&&us.test(n)||(e==="v6"||!e)&&ls.test(n))}class F extends S{_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")ds.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")en||(en=new RegExp(cs,"u")),en.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")as.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")is.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")ns.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")ss.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")rs.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"?vn(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"?hs.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{code:p.invalid_string,validation:"date",message:r.message}),t.dirty()):r.kind==="time"?fs(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"?os.test(e.data)||(s=this._getOrReturnCtx(e,s),f(s,{validation:"duration",code:p.invalid_string,message:r.message}),t.dirty()):r.kind==="ip"?ms(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"?ps.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,...T(n)})};function _s(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 ce extends S{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"?_s(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 ce({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:y.toString(r)}]})}_addCheck(e){return new ce({...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)}}ce.create=n=>new ce({checks:[],typeName:w.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...T(n)});class ue extends S{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 ue({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:y.toString(r)}]})}_addCheck(e){return new ue({...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}}ue.create=n=>{var e;return new ue({checks:[],typeName:w.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...T(n)})};class nt extends S{_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,...T(n)});class Oe extends S{_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 Oe({...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}}Oe.create=n=>new Oe({checks:[],coerce:(n==null?void 0:n.coerce)||!1,typeName:w.ZodDate,...T(n)});class Mt extends S{_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,...T(n)});class st extends S{_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,...T(n)});class rt extends S{_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,...T(n)});class De extends S{constructor(){super(...arguments),this._any=!0}_parse(e){return D(e.data)}}De.create=n=>new De({typeName:w.ZodAny,...T(n)});class Se extends S{constructor(){super(...arguments),this._unknown=!0}_parse(e){return D(e.data)}}Se.create=n=>new Se({typeName:w.ZodUnknown,...T(n)});class ae extends S{_parse(e){const t=this._getOrReturnCtx(e);return f(t,{code:p.invalid_type,expected:_.never,received:t.parsedType}),x}}ae.create=n=>new ae({typeName:w.ZodNever,...T(n)});class Lt extends S{_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,...T(n)});class z extends S{_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,d=t.data.length<r.exactLength.value;(o||d)&&(f(t,{code:o?p.too_big:p.too_small,minimum:d?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,d)=>r.type._parseAsync(new K(t,o,t.path,d)))).then(o=>$.mergeArray(s,o));const a=[...t.data].map((o,d)=>r.type._parseSync(new K(t,o,t.path,d)));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,...T(e)});function Me(n){if(n instanceof E){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=Q.create(Me(s))}return new E({...n._def,shape:()=>e})}else return n instanceof z?new z({...n._def,type:Me(n.element)}):n instanceof Q?Q.create(Me(n.unwrap())):n instanceof he?he.create(Me(n.unwrap())):n instanceof H?H.create(n.items.map(e=>Me(e))):n}class E extends S{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 c=this._getOrReturnCtx(e);return f(c,{code:p.invalid_type,expected:_.object,received:c.parsedType}),x}const{status:t,ctx:s}=this._processInputParams(e),{shape:r,keys:a}=this._getCached(),o=[];if(!(this._def.catchall instanceof ae&&this._def.unknownKeys==="strip"))for(const c in s.data)a.includes(c)||o.push(c);const d=[];for(const c of a){const u=r[c],l=s.data[c];d.push({key:{status:"valid",value:c},value:u._parse(new K(s,l,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof ae){const c=this._def.unknownKeys;if(c==="passthrough")for(const u of o)d.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(c==="strict")o.length>0&&(f(s,{code:p.unrecognized_keys,keys:o}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const u of o){const l=s.data[u];d.push({key:{status:"valid",value:u},value:c._parse(new K(s,l,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const u of d){const l=await u.key,j=await u.value;c.push({key:l,value:j,alwaysSet:u.alwaysSet})}return c}).then(c=>$.mergeObjectSync(t,c)):$.mergeObjectSync(t,d)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new E({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var r,a,o,d;const c=(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:(d=y.errToObj(e).message)!==null&&d!==void 0?d:c}:{message:c}}}:{}})}strip(){return new E({...this._def,unknownKeys:"strip"})}passthrough(){return new E({...this._def,unknownKeys:"passthrough"})}extend(e){return new E({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new E({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 E({...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 E({...this._def,shape:()=>t})}omit(e){const t={};return N.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new E({...this._def,shape:()=>t})}deepPartial(){return Me(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 E({...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 Q;)r=r._def.innerType;t[s]=r}}),new E({...this._def,shape:()=>t})}keyof(){return wn(N.objectKeys(this.shape))}}E.create=(n,e)=>new E({shape:()=>n,unknownKeys:"strip",catchall:ae.create(),typeName:w.ZodObject,...T(e)}),E.strictCreate=(n,e)=>new E({shape:()=>n,unknownKeys:"strict",catchall:ae.create(),typeName:w.ZodObject,...T(e)}),E.lazycreate=(n,e)=>new E({shape:n,unknownKeys:"strip",catchall:ae.create(),typeName:w.ZodObject,...T(e)});class at extends S{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function r(a){for(const d of a)if(d.result.status==="valid")return d.result;for(const d of a)if(d.result.status==="dirty")return t.common.issues.push(...d.ctx.common.issues),d.result;const o=a.map(d=>new L(d.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 c of s){const u={...t,common:{...t.common,issues:[]},parent:null},l=c._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 d=o.map(c=>new L(c));return f(t,{code:p.invalid_union,unionErrors:d}),x}}get options(){return this._def.options}}at.create=(n,e)=>new at({options:n,typeName:w.ZodUnion,...T(e)});const le=n=>n instanceof dt?le(n.schema):n instanceof B?le(n.innerType()):n instanceof ct?[n.value]:n instanceof pe?n.options:n instanceof ut?N.objectValues(n.enum):n instanceof lt?le(n._def.innerType):n instanceof st?[void 0]:n instanceof rt?[null]:n instanceof Q?[void 0,...le(n.unwrap())]:n instanceof he?[null,...le(n.unwrap())]:n instanceof nn||n instanceof ft?le(n.unwrap()):n instanceof pt?le(n._def.innerType):[];class Vt extends S{_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=le(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 d of o){if(r.has(d))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(d)}`);r.set(d,a)}}return new Vt({typeName:w.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...T(s)})}}function tn(n,e){const t=de(n),s=de(e);if(n===e)return{valid:!0,data:n};if(t===_.object&&s===_.object){const r=N.objectKeys(e),a=N.objectKeys(n).filter(d=>r.indexOf(d)!==-1),o={...n,...e};for(const d of a){const c=tn(n[d],e[d]);if(!c.valid)return{valid:!1};o[d]=c.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],d=e[a],c=tn(o,d);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return t===_.date&&s===_.date&&+n==+e?{valid:!0,data:n}:{valid:!1}}class it extends S{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=(a,o)=>{if(Gt(a)||Gt(o))return x;const d=tn(a.value,o.value);return d.valid?((Xt(a)||Xt(o))&&t.dirty(),{status:t.value,value:d.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,...T(t)});class H extends S{_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 d=this._def.items[o]||this._def.rest;return d?d._parse(new K(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,...T(e)})};class ot extends S{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 d in s.data)r.push({key:a._parse(new K(s,d,s.path,d)),value:o._parse(new K(s,s.data[d],s.path,d)),alwaysSet:d 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 S?new ot({keyType:e,valueType:t,typeName:w.ZodRecord,...T(s)}):new ot({keyType:F.create(),valueType:e,typeName:w.ZodRecord,...T(t)})}}class Ut extends S{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(([d,c],u)=>({key:r._parse(new K(s,d,s.path,[u,"key"])),value:a._parse(new K(s,c,s.path,[u,"value"]))}));if(s.common.async){const d=new Map;return Promise.resolve().then(async()=>{for(const c of o){const u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return x;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),d.set(u.value,l.value)}return{status:t.value,value:d}})}else{const d=new Map;for(const c of o){const u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return x;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),d.set(u.value,l.value)}return{status:t.value,value:d}}}}Ut.create=(n,e,t)=>new Ut({valueType:e,keyType:n,typeName:w.ZodMap,...T(t)});class Ze extends S{_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(c){const u=new Set;for(const l of c){if(l.status==="aborted")return x;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const d=[...s.data.values()].map((c,u)=>a._parse(new K(s,c,s.path,u)));return s.common.async?Promise.all(d).then(c=>o(c)):o(d)}min(e,t){return new Ze({...this._def,minSize:{value:e,message:y.toString(t)}})}max(e,t){return new Ze({...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)}}Ze.create=(n,e)=>new Ze({valueType:n,minSize:null,maxSize:null,typeName:w.ZodSet,...T(e)});class Le extends S{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(d,c){return $t({data:d,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Rt(),Pe].filter(u=>!!u),issueData:{code:p.invalid_arguments,argumentsError:c}})}function r(d,c){return $t({data:d,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Rt(),Pe].filter(u=>!!u),issueData:{code:p.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof Ve){const d=this;return D(async function(...c){const u=new L([]),l=await d._def.args.parseAsync(c,a).catch(R=>{throw u.addIssue(s(c,R)),u}),j=await Reflect.apply(o,this,l);return await d._def.returns._def.type.parseAsync(j,a).catch(R=>{throw u.addIssue(r(j,R)),u})})}else{const d=this;return D(function(...c){const u=d._def.args.safeParse(c,a);if(!u.success)throw new L([s(c,u.error)]);const l=Reflect.apply(o,this,u.data),j=d._def.returns.safeParse(l,a);if(!j.success)throw new L([r(l,j.error)]);return j.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Le({...this._def,args:H.create(e).rest(Se.create())})}returns(e){return new Le({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new Le({args:e||H.create([]).rest(Se.create()),returns:t||Se.create(),typeName:w.ZodFunction,...T(s)})}}class dt extends S{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})}}dt.create=(n,e)=>new dt({getter:n,typeName:w.ZodLazy,...T(e)});class ct extends S{_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}}ct.create=(n,e)=>new ct({value:n,typeName:w.ZodLiteral,...T(e)});function wn(n,e){return new pe({values:n,typeName:w.ZodEnum,...T(e)})}class pe extends S{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)||mn(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 pe.create(e,{...this._def,...t})}exclude(e,t=this._def){return pe.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}et=new WeakMap,pe.create=wn;class ut extends S{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)||mn(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,...T(e)});class Ve extends S{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})))}}Ve.create=(n,e)=>new Ve({type:n,typeName:w.ZodPromise,...T(e)});class B extends S{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 d=>{if(t.value==="aborted")return x;const c=await this._def.schema._parseAsync({data:d,path:s.path,parent:s});return c.status==="aborted"?x:c.status==="dirty"||t.value==="dirty"?Pt(c.value):c});{if(t.value==="aborted")return x;const d=this._def.schema._parseSync({data:o,path:s.path,parent:s});return d.status==="aborted"?x:d.status==="dirty"||t.value==="dirty"?Pt(d.value):d}}if(r.type==="refinement"){const o=d=>{const c=r.refinement(d,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return d};if(s.common.async===!1){const d=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return d.status==="aborted"?x:(d.status==="dirty"&&t.dirty(),o(d.value),{status:t.value,value:d.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(d=>d.status==="aborted"?x:(d.status==="dirty"&&t.dirty(),o(d.value).then(()=>({status:t.value,value:d.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 d=r.transform(o.value,a);if(d instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:d}}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(d=>({status:t.value,value:d})):o);N.assertNever(r)}}B.create=(n,e,t)=>new B({schema:n,typeName:w.ZodEffects,effect:e,...T(t)}),B.createWithPreprocess=(n,e,t)=>new B({schema:e,effect:{type:"preprocess",transform:n},typeName:w.ZodEffects,...T(t)});class Q extends S{_parse(e){return this._getType(e)===_.undefined?D(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Q.create=(n,e)=>new Q({innerType:n,typeName:w.ZodOptional,...T(e)});class he extends S{_parse(e){return this._getType(e)===_.null?D(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}he.create=(n,e)=>new he({innerType:n,typeName:w.ZodNullable,...T(e)});class lt extends S{_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,...T(e)});class pt extends S{_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 L(s.common.issues)},input:s.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new L(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,...T(e)});class Ft extends S{_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,...T(n)});const gs=Symbol("zod_brand");class nn extends S{_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 S{_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 S{_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,...T(e)});function bn(n,e={},t){return n?De.create().superRefine((s,r)=>{var a,o;if(!n(s)){const d=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,c=(o=(a=d.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0,u=typeof d=="string"?{message:d}:d;r.addIssue({code:"custom",...u,fatal:c})}}):De.create()}const ys={object:E.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 vs=(n,e={message:`Input not instance of ${n.name}`})=>bn(t=>t instanceof n,e),kn=F.create,xn=ce.create,ws=Ft.create,bs=ue.create,Tn=nt.create,ks=Oe.create,xs=Mt.create,Ts=st.create,Os=rt.create,Ss=De.create,Zs=Se.create,js=ae.create,Ns=Lt.create,Cs=z.create,Is=E.create,Es=E.strictCreate,As=at.create,Rs=Vt.create,$s=it.create,Ps=H.create,Ds=ot.create,Ms=Ut.create,Ls=Ze.create,Vs=Le.create,Us=dt.create,Fs=ct.create,zs=pe.create,Bs=ut.create,Js=Ve.create,On=B.create,Ws=Q.create,qs=he.create,Ks=B.createWithPreprocess,Hs=ht.create;var i=Object.freeze({__proto__:null,defaultErrorMap:Pe,setErrorMap:es,getErrorMap:Rt,makeIssue:$t,EMPTY_PATH:ts,addIssueToContext:f,ParseStatus:$,INVALID:x,DIRTY:Pt,OK:D,isAborted:Gt,isDirty:Xt,isValid:Ge,isAsync:Xe,get util(){return N},get objectUtil(){return Yt},ZodParsedType:_,getParsedType:de,ZodType:S,datetimeRegex:vn,ZodString:F,ZodNumber:ce,ZodBigInt:ue,ZodBoolean:nt,ZodDate:Oe,ZodSymbol:Mt,ZodUndefined:st,ZodNull:rt,ZodAny:De,ZodUnknown:Se,ZodNever:ae,ZodVoid:Lt,ZodArray:z,ZodObject:E,ZodUnion:at,ZodDiscriminatedUnion:Vt,ZodIntersection:it,ZodTuple:H,ZodRecord:ot,ZodMap:Ut,ZodSet:Ze,ZodFunction:Le,ZodLazy:dt,ZodLiteral:ct,ZodEnum:pe,ZodNativeEnum:ut,ZodPromise:Ve,ZodEffects:B,ZodTransformer:B,ZodOptional:Q,ZodNullable:he,ZodDefault:lt,ZodCatch:pt,ZodNaN:Ft,BRAND:gs,ZodBranded:nn,ZodPipeline:ht,ZodReadonly:ft,custom:bn,Schema:S,ZodSchema:S,late:ys,get ZodFirstPartyTypeKind(){return w},coerce:{string:n=>F.create({...n,coerce:!0}),number:n=>ce.create({...n,coerce:!0}),boolean:n=>nt.create({...n,coerce:!0}),bigint:n=>ue.create({...n,coerce:!0}),date:n=>Oe.create({...n,coerce:!0})},any:Ss,array:Cs,bigint:bs,boolean:Tn,date:ks,discriminatedUnion:Rs,effect:On,enum:zs,function:Vs,instanceof:vs,intersection:$s,lazy:Us,literal:Fs,map:Ms,nan:ws,nativeEnum:Bs,never:js,null:Os,nullable:qs,number:xn,object:Is,oboolean:()=>Tn().optional(),onumber:()=>xn().optional(),optional:Ws,ostring:()=>kn().optional(),pipeline:Hs,preprocess:Ks,promise:Js,record:Ds,set:Ls,strictObject:Es,string:kn,symbol:xs,transformer:On,tuple:Ps,undefined:Ts,union:As,unknown:Zs,void:Ns,NEVER:x,ZodIssueCode:p,quotelessJson:Xn,ZodError:L});Gn(i),i.object({start:i.number(),limit:i.number(),length:i.number()});const sn=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()),Ys=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()}),Sn=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(),app_metadata:i.any().default({}).optional(),user_metadata:i.any().default({}).optional()}),Gs=Sn.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")});i.object({...Gs.shape,...sn.shape,user_id:i.string(),email:i.string(),is_social:i.boolean(),login_count:i.number(),identities:i.array(Ys).optional()}),Sn.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 Xs="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let er=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n));for(;n--;)e+=Xs[t[n]&63];return e};const tr=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()}),nr=i.object({id:i.string(),name:i.string(),callbacks:i.array(i.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:i.array(i.string()).default([]).optional().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()).default([]).optional().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()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:i.array(i.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:i.object({samlp:tr.optional()}).default({}).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").optional().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(()=>er()).optional(),disable_sign_ups:i.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),sr=i.object({created_at:i.string().transform(n=>n===null?"":n),updated_at:i.string().transform(n=>n===null?"":n),...nr.shape});var Zn=(n=>(n.TOKEN="token",n.TOKEN_ID_TOKEN="token id_token",n.CODE="code",n))(Zn||{}),jn=(n=>(n.QUERY="query",n.FRAGMENT="fragment",n.FORM_POST="form_post",n.WEB_MESSAGE="web_message",n.SAML_POST="saml_post",n))(jn||{}),Nn=(n=>(n.S265="S256",n.plain="plain",n))(Nn||{});const rr=i.object({client_id:i.string(),vendor_id:i.string().optional(),response_type:i.nativeEnum(Zn).optional(),response_mode:i.nativeEnum(jn).optional(),redirect_uri:i.string().optional(),audience:i.string().optional(),state:i.string().optional(),nonce:i.string().optional(),scope:i.string().optional(),prompt:i.string().optional(),code_challenge_method:i.nativeEnum(Nn).optional(),code_challenge:i.string().optional(),username:i.string().optional(),ui_locales: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 ar=i.object({id:i.string().optional(),name:i.string(),strategy:i.enum(["google-oauth2","facebook","vipps","freja","apple","email","Username-Password-Authentication","oidc","oauth2","custom"]).optional(),options:i.object({kid:i.string().optional(),team_id:i.string().optional(),realms:i.string().optional(),client_id:i.string().optional(),client_secret:i.string().optional(),app_secret:i.string().optional(),scope:i.string().optional(),authorization_endpoint:i.string().default("").optional(),token_endpoint:i.string().default("").optional(),userinfo_endpoint:i.string().default("").optional(),jwks_uri:i.string().default("").optional(),discovery_url:i.string().default("").optional(),issuer:i.string().default("").optional()}).default({}).optional(),enabled_clients:i.array(i.string()).default([]).optional(),response_type:i.custom().optional(),response_mode:i.custom().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(ar.shape),ir=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()}),or=i.object({created_at:i.string().transform(n=>n===null?"":n),updated_at:i.string().transform(n=>n===null?"":n),id:i.string(),...ir.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 dr=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({...sr.shape,domains:i.array(dr),tenant:or,connections:i.array(Cn)});const cr=i.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),ur=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:cr,expires_at:i.string(),used_at:i.string().optional(),user_id:i.string().optional()}),lr=i.object({...ur.shape,created_at:i.string()}),pr=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"])});sn.extend({...pr.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({...sn.shape,hook_id:i.string()});const hr=i.object({alg:i.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:i.string(),kid:i.string(),kty:i.enum(["RSA","EC","oct"]),n:i.string(),x5t:i.string().optional(),x5c:i.array(i.string()).optional(),use:i.enum(["sig","enc"]).optional()});i.object({keys:i.array(hr)}),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 fr=i.object({auth0Client:i.string().optional(),authParams:rr,expires_at:i.string(),deleted_at:i.string().optional(),ip:i.string().optional()}).openapi({description:"This represents a login sesion"}),mr=i.object({...fr.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()}),_r=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"]),gr=i.object({name:i.string(),version:i.string(),env:i.object({node:i.string().optional()}).optional()});i.object({type:_r,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:gr.optional()});const yr=i.object({user_id:i.string(),password:i.string(),algorithm:i.enum(["bcrypt","argon2id"]).default("argon2id")});i.object({...yr.shape,created_at:i.string(),updated_at:i.string()});const vr=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(),...vr.shape}),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 private 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 In=(n=>(n.RefreshToken="refresh_token",n.AuthorizationCode="authorization_code",n.ClientCredential="client_credentials",n.Passwordless="passwordless",n.Password="password",n))(In||{});const rn=i.nativeEnum(In);i.object({grant_type:rn.refine(n=>n==="authorization_code"),code:i.string(),client_secret:i.string(),client_id:i.string()}),i.object({grant_type:rn.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:rn.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 wr=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()}),br=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()}),Ue=i.object({bold:i.boolean(),size:i.number()}),kr=i.object({body_text:Ue,buttons_text:Ue,font_url:i.string(),input_labels:Ue,links:Ue,links_style:i.enum(["normal"]),reference_text_size:i.number(),subtitle:Ue,title:Ue}),xr=i.object({background_color:i.string(),background_image_url:i.string(),page_layout:i.enum(["center"])}),Tr=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:wr,colors:br,displayName:i.string(),fonts:kr,page_background:xr,widget:Tr}).extend({themeId:i.string()});const Or=i.object({universal_login_experience:i.enum(["new","classic"]).default("new"),identifier_first:i.boolean().default(!0),password_first:i.boolean().default(!1),webauthn_platform_first_factor:i.boolean()});function an(n){const[e,t]=n.split("|");if(!e||!t)throw new Error(`Invalid user_id: ${n}`);return{connection:e,id:t}}function En(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:an(n.user_id).id,isSocial:!!n.is_social,profileData:{email:n.email,email_verified:!!n.email_verified,...e}}}function Sr(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,d={...o,email:s.email||"",email_verified:s.email_verified===1,is_social:s.is_social===1,app_metadata:JSON.parse(s.app_metadata),user_metadata:JSON.parse(s.user_metadata),identities:[{connection:s.connection,provider:s.provider,user_id:an(s.user_id).id,isSocial:!!s.is_social},...r.map(En)]};return I(d)}}function je(n,e,t,s){return t.split(/\s+/).map(a=>a.replace(/^([^:]+)=/g,"$1:")).map(a=>{let o=a.startsWith("-"),d,c,u,l;return a.startsWith("-_exists_:")?(d=a.substring(10),u=!0,o=!0):a.startsWith("_exists_:")?(d=a.substring(9),u=!0,o=!1):a.includes(":")?(o=a.startsWith("-"),[d,c]=o?a.substring(1).split(":"):a.split(":"),u=!1,c.startsWith(">=")?(l=">=",c=c.substring(2)):c.startsWith(">")?(l=">",c=c.substring(1)):c.startsWith("<=")?(console.log("value",c),l="<=",c=c.substring(2)):c.startsWith("<")?(l="<",c=c.substring(1)):l="="):(d=null,c=a,u=!1),{key:d,value:c,isNegation:o,isExistsQuery:u,operator:l}}).forEach(({key:a,value:o,isNegation:d,isExistsQuery:c,operator:u})=>{if(a)if(c)d?e=e.where(a,"is",null):e=e.where(a,"is not",null);else if(d)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(j=>j.or(s.map(R=>j(l(R),"like",`%${o}%`))))}}),e}function fe(n){return typeof n=="string"?parseInt(n,10):typeof n=="bigint"?Number(n):n}function Zr(n){return async(e,t)=>{let s=n.selectFrom("users").where("users.tenant_id","=",e);if(t.q&&(s=je(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),d=o.length?await n.selectFrom("users").selectAll().where("users.tenant_id","=",e).where("users.linked_to","in",o).execute():[],c=a.map(l=>{const j=d.filter(R=>R.linked_to===l.user_id);return I({...l,email_verified:l.email_verified===1,is_social:l.is_social===1,app_metadata:JSON.parse(l.app_metadata),user_metadata:JSON.parse(l.user_metadata),identities:[{connection:l.connection,provider:l.provider,user_id:an(l.user_id).id,isSocial:!!l.is_social},...j.map(En)]})}),{count:u}=await s.select(l=>l.fn.countAll().as("count")).executeTakeFirstOrThrow();return{users:c,start:t.page*t.per_page,limit:t.per_page,length:fe(u)}}}function jr(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 Nr(n){if(n.email_verified!==void 0)return n.email_verified?1:0}function Cr(n){return async(e,t,s)=>{const r={...s,email_verified:Nr(s),updated_at:new Date().toISOString()};return s.app_metadata&&(r.app_metadata=JSON.stringify(s.app_metadata)),s.user_metadata&&(r.user_metadata=JSON.stringify(s.user_metadata)),(await n.updateTable("users").set(r).where("users.tenant_id","=",e).where("users.user_id","=",t).execute()).length===1}}function Ir(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 Er(n){return{create:re(n),remove:jr(n),get:Sr(n),list:Zr(n),update:Cr(n),unlink:Ir(n)}}const Ar="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ne=(n=21)=>{let e="",t=crypto.getRandomValues(new Uint8Array(n));for(;n--;)e+=Ar[t[n]&63];return e};function Rr(n){return async e=>{const t={id:e.id||Ne(),created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...e};return await n.insertInto("tenants").values(t).execute(),t}}function $r(n){return async e=>{const t=await n.selectFrom("tenants").where("tenants.id","=",e).selectAll().executeTakeFirst();return t?I(t):null}}function Pr(n){return async e=>{let t=n.selectFrom("tenants");if(e.sort&&e.sort.sort_by){const{ref:d}=n.dynamic;t=t.orderBy(d(e.sort.sort_by),e.sort.sort_order)}e.q&&(t=t.where(d=>d.or([d("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(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow(),o=fe(a);return{tenants:r.map(I),start:(e.page-1)*e.per_page,limit:e.per_page,length:o}}}function Dr(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 Mr(n){return async e=>(await n.deleteFrom("tenants").where("tenants.id","=",e).execute()).length===1}function Lr(n){return{create:Rr(n),get:$r(n),list:Pr(n),update:Dr(n),remove:Mr(n)}}function An(n){return n?JSON.stringify(n):void 0}const Vr=1024;function Ur(n){return async(e,t)=>{var r,a,o;const s={id:Ne(),...t,user_agent:t.user_agent.slice(0,Vr)};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:An(t.auth0_client),details:(o=An(t.details))==null?void 0:o.substring(0,8192)}).execute(),s}}function Rn(n){if(!n)return"";try{return JSON.parse(n)}catch{return n}}function $n(n){return{...n,client_id:n.client_id,client_name:"",auth0_client:Rn(n.auth0_client),details:Rn(n.details),isMobile:!!n.isMobile,scope:n.scope?n.scope.split(","):void 0,log_id:n.id,_id:n.id}}function Fr(n){return async(e,t)=>{let s=n.selectFrom("logs").where("logs.tenant_id","=",e);t.q&&(s=je(n,s,t.q,["user_id","ip"]));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();return{logs:a.map($n),start:t.page*t.per_page,limit:t.per_page,length:fe(o)}}}function zr(n){return async(e,t)=>{const s=await n.selectFrom("logs").where("logs.tenant_id","=",e).where("logs.id","=",t).selectAll().executeTakeFirst();return s?$n(s):null}}function Br(n){return{create:Ur(n),list:Fr(n),get:zr(n)}}function Jr(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 Wr(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 qr(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 Kr(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 Hr(n){return async(e,t)=>{let s=n.selectFrom("sessions").where("sessions.tenant_id","=",e);t.q&&(s=je(n,s,t.q,["user_id","session_id"]));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(),d=fe(o);return{sessions:a,start:t.page*t.per_page,limit:t.per_page,length:d}}}function Qr(n){return{create:Wr(n),get:Jr(n),list:Hr(n),remove:qr(n),update:Kr(n)}}function Yr(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:d,response_mode:c,redirect_uri:u,...l}=s;return{...l,authParams:{nonce:r,state:a,scope:o,response_type:d,response_mode:c,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 Gr(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 Xr(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 ea(n){return{create:Gr(n),get:Yr(n),remove:Xr(n)}}function ta(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 na(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 sa(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 ra(n){return{create:na(n),update:sa(n),get:ta(n)}}function aa(n){return async(e,t)=>{let s=n.selectFrom("codes").where("codes.tenant_id","=",e);t.q&&(s=je(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(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{codes:a.map(c=>{const{tenant_id:u,...l}=c;return lr.parse(I(l))}),start:t.page*t.per_page,limit:t.per_page,length:fe(o)}}}function ia(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 oa(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?I(a):null}}function ca(n){return{create:ia(n),list:aa(n),remove:oa(n),get:da(n)}}function ua(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),d=JSON.stringify(t.allowed_logout_urls),c=JSON.stringify(t.allowed_clients);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:d,allowed_clients:c}).execute(),s}}function la(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):[],allowed_clients:a.allowed_logout_urls?JSON.parse(a.allowed_logout_urls):[]}))})}function pa(n){return async(e,t)=>{const s=await n.selectFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",t).selectAll().executeTakeFirst();return s?I({...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 ha(n){return async(e,t)=>(await n.deleteFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",t).executeTakeFirst()).numDeletedRows>0}function fa(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,allowed_clients:s.allowed_clients?JSON.stringify(s.allowed_clients):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 ma(n){return{create:ua(n),list:la(n),get:pa(n),remove:ha(n),update:fa(n)}}function _a(n){return async(e,t)=>{const s={id:Ne(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("connections").values({...s,options:JSON.stringify(s.options||{}),tenant_id:e}).execute(),s}}function ga(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 ya(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 va(n){if(typeof n.ZodType.prototype.openapi<"u")return;n.ZodType.prototype.openapi=function(r,a){var o,d,c,u,l,j;const R=typeof r=="string"?a:r,U=R??{},{param:we}=U,Ke=ga(U,["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),ke=Object.assign(Object.assign(Object.assign({},(d=this._def.openapi)===null||d===void 0?void 0:d.metadata),Ke),!((u=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||u===void 0)&&u.param||we?{param:Object.assign(Object.assign({},(j=(l=this._def.openapi)===null||l===void 0?void 0:l.metadata)===null||j===void 0?void 0:j.param),we)}:void 0),xe=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(ke).length>0?{metadata:ke}:void 0)}));if(ya(this,"ZodObject")){const He=this.extend;xe.extend=function(...Qe){var ee,te,ne,Te,Ae,Re;const $e=He.apply(this,Qe);return $e._def.openapi={_internal:{extendedFrom:!((te=(ee=this._def.openapi)===null||ee===void 0?void 0:ee._internal)===null||te===void 0)&&te.refId?{refId:(Te=(ne=this._def.openapi)===null||ne===void 0?void 0:ne._internal)===null||Te===void 0?void 0:Te.refId,schema:this}:(Ae=this._def.openapi)===null||Ae===void 0?void 0:Ae._internal.extendedFrom},metadata:(Re=$e._def.openapi)===null||Re===void 0?void 0:Re.metadata},$e}}return xe},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(([d,c])=>{var u,l;c._def.openapi=(l=(u=r[d])===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 C;(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(d=>typeof r[r[d]]!="number"),o={};for(const d of a)o[d]=r[d];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})(C||(C={}));var on;(function(n){n.mergeShapes=(e,t)=>({...e,...t})})(on||(on={}));const g=C.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),me=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=C.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"]),wa=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 d=s,c=0;for(;c<o.path.length;){const u=o.path[c];c===o.path.length-1?(d[u]=d[u]||{_errors:[]},d[u]._errors.push(t(o))):d[u]=d[u]||{_errors:[]},d=d[u],c++}}};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,C.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 Fe=(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,C.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:t=`Unrecognized key(s) in object: ${C.joinValues(n.keys,", ")}`;break;case h.invalid_union:t="Invalid input";break;case h.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${C.joinValues(n.options)}`;break;case h.invalid_enum_value:t=`Invalid enum value. Expected ${C.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}"`:C.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,C.assertNever(n)}return{message:t}};let Pn=Fe;function ba(n){Pn=n}function zt(){return Pn}const Bt=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 d="";const c=s.filter(u=>!!u).slice().reverse();for(const u of c)d=u(o,{data:e,defaultError:d}).message;return{...r,path:a,message:d}},ka=[];function m(n,e){const t=zt(),s=Bt({issueData:e,data:n.data,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,t,t===Fe?void 0:Fe].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 k;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 k;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 k=Object.freeze({status:"aborted"}),ze=n=>({status:"dirty",value:n}),M=n=>({status:"valid",value:n}),dn=n=>n.status==="aborted",cn=n=>n.status==="dirty",_t=n=>n.status==="valid",gt=n=>typeof Promise<"u"&&n instanceof Promise;function Jt(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 Dn(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 Y{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 Mn=(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 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:(o,d)=>{var c,u;const{message:l}=n;return o.code==="invalid_enum_value"?{message:l??d.defaultError}:typeof d.data>"u"?{message:(c=l??s)!==null&&c!==void 0?c:d.defaultError}:o.code!=="invalid_type"?{message:d.defaultError}:{message:(u=l??t)!==null&&u!==void 0?u:d.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 me(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:me(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:me(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:me(e)},a=this._parseSync({data:e,path:r.path,parent:r});return Mn(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:me(e)},r=this._parse({data:e,path:s.path,parent:s}),a=await(gt(r)?r:Promise.resolve(r));return Mn(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),d=()=>a.addIssue({code:h.custom,...s(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(d(),!1)):o?!0:(d(),!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 q({schema:this,typeName:b.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return X.create(this,this._def)}nullable(){return ve.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return W.create(this,this._def)}promise(){return qe.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 q({...O(this._def),schema:this,typeName:b.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Nt({...O(this._def),innerType:this,defaultValue:t,typeName:b.ZodDefault})}brand(){return new pn({typeName:b.ZodBranded,type:this,...O(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ct({...O(this._def),innerType:this,catchValue:t,typeName:b.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return It.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,Ta=/^[0-9a-z]+$/,Oa=/^[0-9A-HJKMNP-TV-Z]{26}$/,Sa=/^[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,Za=/^[a-z0-9_-]{21}$/i,ja=/^[-+]?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)?)??$/,Na=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ca="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let un;const Ia=/^(?:(?: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])$/,Ea=/^(([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})))$/,Aa=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ln="((\\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])))",Ra=new RegExp(`^${Ln}$`);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 $a(n){return new RegExp(`^${Vn(n)}$`)}function Un(n){let e=`${Ln}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 Pa(n,e){return!!((e==="v4"||!e)&&Ia.test(n)||(e==="v6"||!e)&&Ea.test(n))}class J extends Z{_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}),k}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,d=e.data.length<a.value;(o||d)&&(r=this._getOrReturnCtx(e,r),o?m(r,{code:h.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):d&&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")Na.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")un||(un=new RegExp(Ca,"u")),un.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")Sa.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")Za.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")Ta.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")Oa.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"?Un(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"?Ra.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{code:h.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?$a(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"?ja.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"duration",code:h.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?Pa(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"?Aa.test(e.data)||(r=this._getOrReturnCtx(e,r),m(r,{validation:"base64",code:h.invalid_string,message:a.message}),s.dirty()):C.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 J({...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 J({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new J({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new J({...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}}J.create=n=>{var e;return new J({checks:[],typeName:b.ZodString,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...O(n)})};function Da(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 _e 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)!==g.number){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.number,received:a.parsedType}),k}let s;const r=new P;for(const a of this._def.checks)a.kind==="int"?C.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"?Da(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()):C.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 _e({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:v.toString(r)}]})}_addCheck(e){return new _e({...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"&&C.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)}}_e.create=n=>new _e({checks:[],typeName:b.ZodNumber,coerce:(n==null?void 0:n.coerce)||!1,...O(n)});class ge 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)!==g.bigint){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_type,expected:g.bigint,received:a.parsedType}),k}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()):C.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 ge({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:v.toString(r)}]})}_addCheck(e){return new ge({...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}}ge.create=n=>{var e;return new ge({checks:[],typeName:b.ZodBigInt,coerce:(e=n==null?void 0:n.coerce)!==null&&e!==void 0?e:!1,...O(n)})};class wt extends Z{_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}),k}return M(e.data)}}wt.create=n=>new wt({typeName:b.ZodBoolean,coerce:(n==null?void 0:n.coerce)||!1,...O(n)});class Ce extends Z{_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}),k}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return m(a,{code:h.invalid_date}),k}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()):C.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:b.ZodDate,...O(n)});class Wt extends Z{_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}),k}return M(e.data)}}Wt.create=n=>new Wt({typeName:b.ZodSymbol,...O(n)});class bt extends Z{_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}),k}return M(e.data)}}bt.create=n=>new bt({typeName:b.ZodUndefined,...O(n)});class kt extends Z{_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}),k}return M(e.data)}}kt.create=n=>new kt({typeName:b.ZodNull,...O(n)});class Be extends Z{constructor(){super(...arguments),this._any=!0}_parse(e){return M(e.data)}}Be.create=n=>new Be({typeName:b.ZodAny,...O(n)});class Ie extends Z{constructor(){super(...arguments),this._unknown=!0}_parse(e){return M(e.data)}}Ie.create=n=>new Ie({typeName:b.ZodUnknown,...O(n)});class ie extends Z{_parse(e){const t=this._getOrReturnCtx(e);return m(t,{code:h.invalid_type,expected:g.never,received:t.parsedType}),k}}ie.create=n=>new ie({typeName:b.ZodNever,...O(n)});class qt extends Z{_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}),k}return M(e.data)}}qt.create=n=>new qt({typeName:b.ZodVoid,...O(n)});class W extends Z{_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}),k;if(r.exactLength!==null){const o=t.data.length>r.exactLength.value,d=t.data.length<r.exactLength.value;(o||d)&&(m(t,{code:o?h.too_big:h.too_small,minimum:d?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,d)=>r.type._parseAsync(new Y(t,o,t.path,d)))).then(o=>P.mergeArray(s,o));const a=[...t.data].map((o,d)=>r.type._parseSync(new Y(t,o,t.path,d)));return P.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new W({...this._def,minLength:{value:e,message:v.toString(t)}})}max(e,t){return new W({...this._def,maxLength:{value:e,message:v.toString(t)}})}length(e,t){return new W({...this._def,exactLength:{value:e,message:v.toString(t)}})}nonempty(e){return this.min(1,e)}}W.create=(n,e)=>new W({type:n,minLength:null,maxLength:null,exactLength:null,typeName:b.ZodArray,...O(e)});function Je(n){if(n instanceof A){const e={};for(const t in n.shape){const s=n.shape[t];e[t]=X.create(Je(s))}return new A({...n._def,shape:()=>e})}else return n instanceof W?new W({...n._def,type:Je(n.element)}):n instanceof X?X.create(Je(n.unwrap())):n instanceof ve?ve.create(Je(n.unwrap())):n instanceof G?G.create(n.items.map(e=>Je(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=C.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}),k}const{status:s,ctx:r}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),d=[];if(!(this._def.catchall instanceof ie&&this._def.unknownKeys==="strip"))for(const u in r.data)o.includes(u)||d.push(u);const c=[];for(const u of o){const l=a[u],j=r.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new Y(r,j,r.path,u)),alwaysSet:u in r.data})}if(this._def.catchall instanceof ie){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of d)c.push({key:{status:"valid",value:l},value:{status:"valid",value:r.data[l]}});else if(u==="strict")d.length>0&&(m(r,{code:h.unrecognized_keys,keys:d}),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 d){const j=r.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new Y(r,j,r.path,l)),alwaysSet:l in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of c){const j=await l.key,R=await l.value;u.push({key:j,value:R,alwaysSet:l.alwaysSet})}return u}).then(u=>P.mergeObjectSync(s,u)):P.mergeObjectSync(s,c)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new A({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var r,a,o,d;const c=(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:(d=v.errToObj(e).message)!==null&&d!==void 0?d:c}:{message:c}}}:{}})}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:b.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new A({...this._def,catchall:e})}pick(e){const t={};return C.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 C.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new A({...this._def,shape:()=>t})}deepPartial(){return Je(this)}partial(e){const t={};return C.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 C.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof X;)a=a._def.innerType;t[s]=a}}),new A({...this._def,shape:()=>t})}keyof(){return Fn(C.objectKeys(this.shape))}}A.create=(n,e)=>new A({shape:()=>n,unknownKeys:"strip",catchall:ie.create(),typeName:b.ZodObject,...O(e)}),A.strictCreate=(n,e)=>new A({shape:()=>n,unknownKeys:"strict",catchall:ie.create(),typeName:b.ZodObject,...O(e)}),A.lazycreate=(n,e)=>new A({shape:n,unknownKeys:"strip",catchall:ie.create(),typeName:b.ZodObject,...O(e)});class xt extends Z{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function r(a){for(const d of a)if(d.result.status==="valid")return d.result;for(const d of a)if(d.result.status==="dirty")return t.common.issues.push(...d.ctx.common.issues),d.result;const o=a.map(d=>new V(d.ctx.common.issues));return m(t,{code:h.invalid_union,unionErrors:o}),k}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 c of s){const u={...t,common:{...t.common,issues:[]},parent:null},l=c._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 d=o.map(c=>new V(c));return m(t,{code:h.invalid_union,unionErrors:d}),k}}get options(){return this._def.options}}xt.create=(n,e)=>new xt({options:n,typeName:b.ZodUnion,...O(e)});const oe=n=>n instanceof St?oe(n.schema):n instanceof q?oe(n.innerType()):n instanceof Zt?[n.value]:n instanceof ye?n.options:n instanceof jt?C.objectValues(n.enum):n instanceof Nt?oe(n._def.innerType):n instanceof bt?[void 0]:n instanceof kt?[null]:n instanceof X?[void 0,...oe(n.unwrap())]:n instanceof ve?[null,...oe(n.unwrap())]:n instanceof pn||n instanceof Et?oe(n.unwrap()):n instanceof Ct?oe(n._def.innerType):[];class Kt extends Z{_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}),k;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]}),k)}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=oe(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 d of o){if(r.has(d))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(d)}`);r.set(d,a)}}return new Kt({typeName:b.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...O(s)})}}function ln(n,e){const t=me(n),s=me(e);if(n===e)return{valid:!0,data:n};if(t===g.object&&s===g.object){const r=C.objectKeys(e),a=C.objectKeys(n).filter(d=>r.indexOf(d)!==-1),o={...n,...e};for(const d of a){const c=ln(n[d],e[d]);if(!c.valid)return{valid:!1};o[d]=c.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],d=e[a],c=ln(o,d);if(!c.valid)return{valid:!1};r.push(c.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 Z{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),r=(a,o)=>{if(dn(a)||dn(o))return k;const d=ln(a.value,o.value);return d.valid?((cn(a)||cn(o))&&t.dirty(),{status:t.value,value:d.data}):(m(s,{code:h.invalid_intersection_types}),k)};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:b.ZodIntersection,...O(t)});class G extends Z{_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}),k;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"}),k;!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,d)=>{const c=this._def.items[d]||this._def.rest;return c?c._parse(new Y(s,o,s.path,d)):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 G({...this._def,rest:e})}}G.create=(n,e)=>{if(!Array.isArray(n))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new G({items:n,typeName:b.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!==g.object)return m(s,{code:h.invalid_type,expected:g.object,received:s.parsedType}),k;const r=[],a=this._def.keyType,o=this._def.valueType;for(const d in s.data)r.push({key:a._parse(new Y(s,d,s.path,d)),value:o._parse(new Y(s,s.data[d],s.path,d)),alwaysSet:d 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 Z?new Ot({keyType:e,valueType:t,typeName:b.ZodRecord,...O(s)}):new Ot({keyType:J.create(),valueType:e,typeName:b.ZodRecord,...O(t)})}}class Ht 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!==g.map)return m(s,{code:h.invalid_type,expected:g.map,received:s.parsedType}),k;const r=this._def.keyType,a=this._def.valueType,o=[...s.data.entries()].map(([d,c],u)=>({key:r._parse(new Y(s,d,s.path,[u,"key"])),value:a._parse(new Y(s,c,s.path,[u,"value"]))}));if(s.common.async){const d=new Map;return Promise.resolve().then(async()=>{for(const c of o){const u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return k;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),d.set(u.value,l.value)}return{status:t.value,value:d}})}else{const d=new Map;for(const c of o){const u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return k;(u.status==="dirty"||l.status==="dirty")&&t.dirty(),d.set(u.value,l.value)}return{status:t.value,value:d}}}}Ht.create=(n,e,t)=>new Ht({valueType:e,keyType:n,typeName:b.ZodMap,...O(t)});class Ee extends Z{_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}),k;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(c){const u=new Set;for(const l of c){if(l.status==="aborted")return k;l.status==="dirty"&&t.dirty(),u.add(l.value)}return{status:t.value,value:u}}const d=[...s.data.values()].map((c,u)=>a._parse(new Y(s,c,s.path,u)));return s.common.async?Promise.all(d).then(c=>o(c)):o(d)}min(e,t){return new Ee({...this._def,minSize:{value:e,message:v.toString(t)}})}max(e,t){return new Ee({...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)}}Ee.create=(n,e)=>new Ee({valueType:n,minSize:null,maxSize:null,typeName:b.ZodSet,...O(e)});class We extends Z{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}),k;function s(d,c){return Bt({data:d,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,zt(),Fe].filter(u=>!!u),issueData:{code:h.invalid_arguments,argumentsError:c}})}function r(d,c){return Bt({data:d,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,zt(),Fe].filter(u=>!!u),issueData:{code:h.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof qe){const d=this;return M(async function(...c){const u=new V([]),l=await d._def.args.parseAsync(c,a).catch(U=>{throw u.addIssue(s(c,U)),u}),j=await Reflect.apply(o,this,l);return await d._def.returns._def.type.parseAsync(j,a).catch(U=>{throw u.addIssue(r(j,U)),u})})}else{const d=this;return M(function(...c){const u=d._def.args.safeParse(c,a);if(!u.success)throw new V([s(c,u.error)]);const l=Reflect.apply(o,this,u.data),j=d._def.returns.safeParse(l,a);if(!j.success)throw new V([r(l,j.error)]);return j.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new We({...this._def,args:G.create(e).rest(Ie.create())})}returns(e){return new We({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new We({args:e||G.create([]).rest(Ie.create()),returns:t||Ie.create(),typeName:b.ZodFunction,...O(s)})}}class St 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})}}St.create=(n,e)=>new St({getter:n,typeName:b.ZodLazy,...O(e)});class Zt extends Z{_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}),k}return{status:"valid",value:e.data}}get value(){return this._def.value}}Zt.create=(n,e)=>new Zt({value:n,typeName:b.ZodLiteral,...O(e)});function Fn(n,e){return new ye({values:n,typeName:b.ZodEnum,...O(e)})}class ye extends Z{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:C.joinValues(s),received:t.parsedType,code:h.invalid_type}),k}if(Jt(this,yt)||Dn(this,yt,new Set(this._def.values)),!Jt(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}),k}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 ye.create(e,{...this._def,...t})}exclude(e,t=this._def){return ye.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}yt=new WeakMap,ye.create=Fn;class jt extends Z{constructor(){super(...arguments),vt.set(this,void 0)}_parse(e){const t=C.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==g.string&&s.parsedType!==g.number){const r=C.objectValues(t);return m(s,{expected:C.joinValues(r),received:s.parsedType,code:h.invalid_type}),k}if(Jt(this,vt)||Dn(this,vt,new Set(C.getValidEnumValues(this._def.values))),!Jt(this,vt).has(e.data)){const r=C.objectValues(t);return m(s,{received:s.data,code:h.invalid_enum_value,options:r}),k}return M(e.data)}get enum(){return this._def.values}}vt=new WeakMap,jt.create=(n,e)=>new jt({values:n,typeName:b.ZodNativeEnum,...O(e)});class qe extends Z{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}),k;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})))}}qe.create=(n,e)=>new qe({type:n,typeName:b.ZodPromise,...O(e)});class q extends Z{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===b.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 d=>{if(t.value==="aborted")return k;const c=await this._def.schema._parseAsync({data:d,path:s.path,parent:s});return c.status==="aborted"?k:c.status==="dirty"||t.value==="dirty"?ze(c.value):c});{if(t.value==="aborted")return k;const d=this._def.schema._parseSync({data:o,path:s.path,parent:s});return d.status==="aborted"?k:d.status==="dirty"||t.value==="dirty"?ze(d.value):d}}if(r.type==="refinement"){const o=d=>{const c=r.refinement(d,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return d};if(s.common.async===!1){const d=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return d.status==="aborted"?k:(d.status==="dirty"&&t.dirty(),o(d.value),{status:t.value,value:d.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(d=>d.status==="aborted"?k:(d.status==="dirty"&&t.dirty(),o(d.value).then(()=>({status:t.value,value:d.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 d=r.transform(o.value,a);if(d instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:d}}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(d=>({status:t.value,value:d})):o);C.assertNever(r)}}q.create=(n,e,t)=>new q({schema:n,typeName:b.ZodEffects,effect:e,...O(t)}),q.createWithPreprocess=(n,e,t)=>new q({schema:e,effect:{type:"preprocess",transform:n},typeName:b.ZodEffects,...O(t)});class X extends Z{_parse(e){return this._getType(e)===g.undefined?M(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}X.create=(n,e)=>new X({innerType:n,typeName:b.ZodOptional,...O(e)});class ve extends Z{_parse(e){return this._getType(e)===g.null?M(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ve.create=(n,e)=>new ve({innerType:n,typeName:b.ZodNullable,...O(e)});class Nt extends Z{_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:b.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...O(e)});class Ct 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 gt(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}}Ct.create=(n,e)=>new Ct({innerType:n,typeName:b.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...O(e)});class Qt extends Z{_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}),k}return{status:"valid",value:e.data}}}Qt.create=n=>new Qt({typeName:b.ZodNaN,...O(n)});const Ma=Symbol("zod_brand");class pn 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 It extends Z{_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"?k:a.status==="dirty"?(t.dirty(),ze(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"?k: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 It({in:e,out:t,typeName:b.ZodPipeline})}}class Et extends Z{_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:b.ZodReadonly,...O(e)});function zn(n,e={},t){return n?Be.create().superRefine((s,r)=>{var a,o;if(!n(s)){const d=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,c=(o=(a=d.fatal)!==null&&a!==void 0?a:t)!==null&&o!==void 0?o:!0,u=typeof d=="string"?{message:d}:d;r.addIssue({code:"custom",...u,fatal:c})}}):Be.create()}const La={object:A.lazycreate};var b;(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"})(b||(b={}));const Va=(n,e={message:`Input not instance of ${n.name}`})=>zn(t=>t instanceof n,e),Bn=J.create,Jn=_e.create,Ua=Qt.create,Fa=ge.create,Wn=wt.create,za=Ce.create,Ba=Wt.create,Ja=bt.create,Wa=kt.create,qa=Be.create,Ka=Ie.create,Ha=ie.create,Qa=qt.create,Ya=W.create,Ga=A.create,Xa=A.strictCreate,ei=xt.create,ti=Kt.create,ni=Tt.create,si=G.create,ri=Ot.create,ai=Ht.create,ii=Ee.create,oi=We.create,di=St.create,ci=Zt.create,ui=ye.create,li=jt.create,pi=qe.create,qn=q.create,hi=X.create,fi=ve.create,mi=q.createWithPreprocess,_i=It.create;var gi=Object.freeze({__proto__:null,defaultErrorMap:Fe,setErrorMap:ba,getErrorMap:zt,makeIssue:Bt,EMPTY_PATH:ka,addIssueToContext:m,ParseStatus:P,INVALID:k,DIRTY:ze,OK:M,isAborted:dn,isDirty:cn,isValid:_t,isAsync:gt,get util(){return C},get objectUtil(){return on},ZodParsedType:g,getParsedType:me,ZodType:Z,datetimeRegex:Un,ZodString:J,ZodNumber:_e,ZodBigInt:ge,ZodBoolean:wt,ZodDate:Ce,ZodSymbol:Wt,ZodUndefined:bt,ZodNull:kt,ZodAny:Be,ZodUnknown:Ie,ZodNever:ie,ZodVoid:qt,ZodArray:W,ZodObject:A,ZodUnion:xt,ZodDiscriminatedUnion:Kt,ZodIntersection:Tt,ZodTuple:G,ZodRecord:Ot,ZodMap:Ht,ZodSet:Ee,ZodFunction:We,ZodLazy:St,ZodLiteral:Zt,ZodEnum:ye,ZodNativeEnum:jt,ZodPromise:qe,ZodEffects:q,ZodTransformer:q,ZodOptional:X,ZodNullable:ve,ZodDefault:Nt,ZodCatch:Ct,ZodNaN:Qt,BRAND:Ma,ZodBranded:pn,ZodPipeline:It,ZodReadonly:Et,custom:zn,Schema:Z,ZodSchema:Z,late:La,get ZodFirstPartyTypeKind(){return b},coerce:{string:n=>J.create({...n,coerce:!0}),number:n=>_e.create({...n,coerce:!0}),boolean:n=>wt.create({...n,coerce:!0}),bigint:n=>ge.create({...n,coerce:!0}),date:n=>Ce.create({...n,coerce:!0})},any:qa,array:Ya,bigint:Fa,boolean:Wn,date:za,discriminatedUnion:ti,effect:qn,enum:ui,function:oi,instanceof:Va,intersection:ni,lazy:di,literal:ci,map:ai,nan:Ua,nativeEnum:li,never:Ha,null:Wa,nullable:fi,number:Jn,object:Ga,oboolean:()=>Wn().optional(),onumber:()=>Jn().optional(),optional:hi,ostring:()=>Bn().optional(),pipeline:_i,preprocess:mi,promise:pi,record:ri,set:ii,strictObject:Xa,string:Bn,symbol:Ba,transformer:qn,tuple:si,undefined:Ja,union:ei,unknown:Ka,void:Qa,NEVER:k,ZodIssueCode:h,quotelessJson:wa,ZodError:V});va(gi);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 Kn(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 yi(n){return async(e,t)=>{let s=n.selectFrom("connections").where("connections.tenant_id","=",e);t.q&&(s=je(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(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{connections:a.map(d=>I(Kn(d,["options"]))),start:t.page*t.per_page,limit:t.per_page,length:fe(o)}}}function vi(n){return async(e,t)=>(await n.deleteFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",t).executeTakeFirst()).numDeletedRows>0}function wi(n){return async(e,t)=>{const s=await n.selectFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",t).selectAll().executeTakeFirst();return s?I({...s,options:JSON.parse(s.options)}):null}}function bi(n){return async(e,t,s)=>{const r={...s,updated_at:new Date().toISOString()};return await n.updateTable("connections").set({...r,options:r.options?JSON.stringify(r.options):void 0}).where("connections.id","=",t).where("connections.tenant_id","=",e).execute(),!0}}function ki(n){return{create:_a(n),get:wi(n),list:yi(n),remove:vi(n),update:bi(n)}}function xi(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 se(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(d=>Cn.parse(I({...d,options:d.options?JSON.parse(d.options):{}}))),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):[],allowed_clients:t.allowed_clients?JSON.parse(t.allowed_clients):[],tenant:I(s),disable_sign_ups:!!t.disable_sign_ups}}}}function Ti(n){return async()=>await n.selectFrom("keys").where("revoked_at","is",null).selectAll().execute()}function Oi(n){return async e=>{await n.insertInto("keys").values({...e,created_at:new Date().toDateString()}).execute()}}function Si(n){return async(e,t)=>!!(await n.updateTable("keys").set(t).where("kid","=",e).execute()).length}function Zi(n){return{create:Oi(n),list:Ti(n),update:Si(n)}}function ji(n){return async(e,t)=>{const s={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,id:Ne(),...t};return await n.insertInto("domains").values(s).execute(),s}}function Ni(n){return async(e,t)=>{let s=n.selectFrom("domains").where("domains.tenant_id","=",e);t.q&&(s=je(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(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{domains:a,start:t.page*t.per_page,limit:t.per_page,length:fe(o)}}}function Ci(n){return{create:ji(n),list:Ni(n)}}function Ii(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:d,colors_page_background_angle_dev:c,font_url:u,...l}=t;return I({...l,colors:{primary:r,page_background:{type:a,start:o,end:d,angle_deg:c}},font:u?{url:u}:void 0})}}function Ei(n){return async(e,t)=>{var o,d,c,u,l,j,R,U,we,Ke,be,ke,xe,He,Qe,ee,te,ne;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:(d=(o=t.colors)==null?void 0:o.page_background)==null?void 0:d.type,colors_page_background_start:(u=(c=t.colors)==null?void 0:c.page_background)==null?void 0:u.start,colors_page_background_end:(j=(l=t.colors)==null?void 0:l.page_background)==null?void 0:j.end,colors_page_background_angle_dev:(U=(R=t.colors)==null?void 0:R.page_background)==null?void 0:U.angle_deg,font_url:(we=t.font)==null?void 0:we.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=(Ke=t.colors)==null?void 0:Ke.page_background)==null?void 0:be.type,colors_page_background_start:(xe=(ke=t.colors)==null?void 0:ke.page_background)==null?void 0:xe.start,colors_page_background_end:(Qe=(He=t.colors)==null?void 0:He.page_background)==null?void 0:Qe.end,colors_page_background_angle_dev:(te=(ee=t.colors)==null?void 0:ee.page_background)==null?void 0:te.angle_deg,font_url:(ne=t.font)==null?void 0:ne.url}).where("tenant_id","=",e).execute()}}}function Ai(n){return{get:Ii(n),set:Ei(n)}}function Ri(n){return async(e,t)=>{let s=n.selectFrom("hooks").where("hooks.tenant_id","=",e);t.q&&(s=je(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(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{hooks:a.map(c=>{const{tenant_id:u,enabled:l,synchronous:j,...R}=c;return I({...R,enabled:!!l,synchronous:!!j})}),start:t.page*t.per_page,limit:t.per_page,length:fe(o)}}}function $i(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,I(s)):null}}function Pi(n){return async(e,t)=>(await n.deleteFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",t).executeTakeFirst()).numDeletedRows>0}function Di(n){return async(e,t)=>{const s={hook_id:Ne(),...t,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await n.insertInto("hooks").values({...s,tenant_id:e}).execute(),s}}function Mi(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 Li(n){return{create:Di(n),get:$i(n),list:Ri(n),update:Mi(n),remove:Pi(n)}}function Vi(n){return async(e,t)=>{const s={themeId:Ne(),...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 Ui(n){return async(e,t)=>(await n.deleteFrom("themes").where("themes.tenant_id","=",e).where("themes.theme_id","=",t).executeTakeFirst()).numDeletedRows>0}function Fi(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?I(s):null}}function zi(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 Bi(n){return{create:Vi(n),get:Fi(n),remove:Ui(n),update:zi(n)}}function Ji(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?mr.parse(Kn(I(r),["authParams"])):null}}function Wi(n){return async(e,t)=>{const s={login_id:Ne(),...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 qi(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 Ki(n){return async(e,t)=>(await n.deleteFrom("logins").where("logins.tenant_id","=",e).where("logins.login_id","=",t).execute()).length>0}function Hi(n){return{create:Wi(n),get:Ji(n),update:qi(n),remove:Ki(n)}}function Qi(n){return async e=>{const[t]=await n.selectFrom("prompt_settings").where("prompt_settings.tenant_id","=",e).selectAll().execute();return I({identifier_first:!!(t!=null&&t.identifier_first),password_first:!!(t!=null&&t.password_first),webauthn_platform_first_factor:!!(t!=null&&t.webauthn_platform_first_factor),universal_login_experience:(t==null?void 0:t.universal_login_experience)||"new"})}}function Hn(n){return I({...n,webauthn_platform_first_factor:n.webauthn_platform_first_factor?!!n.webauthn_platform_first_factor:void 0,identifier_first:n.identifier_first?!!n.identifier_first:void 0,password_first:n.password_first?!!n.password_first:void 0,universal_login_experience:n.universal_login_experience})}function Yi(n){return async(e,t)=>{try{const s=Or.parse(t);await n.insertInto("prompt_settings").values({...Hn(s),tenant_id:e}).execute()}catch{await n.updateTable("prompt_settings").set(Hn(t)).where("tenant_id","=",e).execute()}}}function Gi(n){return{get:Qi(n),set:Yi(n)}}function Xi(n){return{applications:ma(n),branding:Ai(n),clients:xi(n),codes:ca(n),connections:ki(n),domains:Ci(n),hooks:Li(n),keys:Zi(n),logins:Hi(n),logs:Br(n),passwords:ra(n),promptSettings:Gi(n),users:Er(n),sessions:Qr(n),tenants:Lr(n),themes:Bi(n),tickets:ea(n)}}return Xi}();
1
+ var kyselyAdapter=function(A){"use strict";var Uu=Object.defineProperty;var $a=A=>{throw TypeError(A)};var Fu=(A,P,U)=>P in A?Uu(A,P,{enumerable:!0,configurable:!0,writable:!0,value:U}):A[P]=U;var Xt=(A,P,U)=>Fu(A,typeof P!="symbol"?P+"":P,U),Fn=(A,P,U)=>P.has(A)||$a("Cannot "+U);var v=(A,P,U)=>(Fn(A,P,"read from private field"),U?U.call(A):P.get(A)),he=(A,P,U)=>P.has(A)?$a("Cannot add the same private member more than once"):P instanceof WeakSet?P.add(A):P.set(A,U),en=(A,P,U,R)=>(Fn(A,P,"write to private field"),R?R.call(A,U):P.set(A,U),U),C=(A,P,U)=>(Fn(A,P,"access private method"),U);var xn,ot,Be,Ke,V,Aa,Pa,Da,ut,Vn,Ra,Gt,D,p,tn,_e,ge,ht,Ma,ye,La,za,Ua,Fa,Va,Bn,mt,Kn,Ba,Ka,Wa,Wn,Ja,qa,Qa,Ha,Ga,nn,Yt;var P=class extends Error{constructor(e=500,n){super(n==null?void 0:n.message,{cause:n==null?void 0:n.cause});Xt(this,"res");Xt(this,"status");this.res=n==null?void 0:n.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 U(t){return async(e,n)=>{const{identities:a,...r}=n,s={...r,created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,email_verified:n.email_verified?1:0,is_social:n.is_social?1:0,app_metadata:JSON.stringify(n.app_metadata),user_metadata:JSON.stringify(n.user_metadata)};try{await t.insertInto("users").values(s).execute()}catch(o){throw o.code==="SQLITE_CONSTRAINT_UNIQUE"||o.message.includes("AlreadyExists")?new P(409,{message:"User already exists"}):(console.log(o.message),new P(500,{message:`${o.code}, ${o.message}`}))}return{...s,email:s.email||"",email_verified:s.email_verified===1,is_social:s.is_social===1}}}function R(t){const e={...t};for(const n in e)e[n]===null?delete e[n]:typeof e[n]=="object"&&(Array.isArray(e[n])?e[n]=e[n].map(R):e[n]=R(e[n]));return e}function Ya(t,e){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(n[a]=t[a]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,a=Object.getOwnPropertySymbols(t);r<a.length;r++)e.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(t,a[r])&&(n[a[r]]=t[a[r]]);return n}function Xa(t,e){var n;return((n=t==null?void 0:t._def)===null||n===void 0?void 0:n.typeName)===e}function pt(t,e){const n=t.ZodType.prototype[e];t.ZodType.prototype[e]=function(...a){const r=n.apply(this,a);return r._def.openapi=this._def.openapi,r}}function er(t){if(typeof t.ZodType.prototype.openapi<"u")return;t.ZodType.prototype.openapi=function(r,s){var o,d,c,l,u,Z;const z=typeof r=="string"?s:r,H=z??{},{param:Ze}=H,dt=Ya(H,["param"]),Ee=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof r=="string"?{refId:r}:void 0),$e=Object.assign(Object.assign(Object.assign({},(d=this._def.openapi)===null||d===void 0?void 0:d.metadata),dt),!((l=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||l===void 0)&&l.param||Ze?{param:Object.assign(Object.assign({},(Z=(u=this._def.openapi)===null||u===void 0?void 0:u.metadata)===null||Z===void 0?void 0:Z.param),Ze)}:void 0),Ae=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(Ee).length>0?{_internal:Ee}:void 0),Object.keys($e).length>0?{metadata:$e}:void 0)}));if(Xa(this,"ZodObject")){const ct=this.extend;Ae.extend=function(...lt){var ce,le,ue,Pe,We,Je;const qe=ct.apply(this,lt);return qe._def.openapi={_internal:{extendedFrom:!((le=(ce=this._def.openapi)===null||ce===void 0?void 0:ce._internal)===null||le===void 0)&&le.refId?{refId:(Pe=(ue=this._def.openapi)===null||ue===void 0?void 0:ue._internal)===null||Pe===void 0?void 0:Pe.refId,schema:this}:(We=this._def.openapi)===null||We===void 0?void 0:We._internal.extendedFrom},metadata:(Je=qe._def.openapi)===null||Je===void 0?void 0:Je.metadata},qe}}return Ae},pt(t,"optional"),pt(t,"nullable"),pt(t,"default"),pt(t,"transform"),pt(t,"refine");const e=t.ZodObject.prototype.deepPartial;t.ZodObject.prototype.deepPartial=function(){const r=this._def.shape(),s=e.apply(this),o=s._def.shape();return Object.entries(o).forEach(([d,c])=>{var l,u;c._def.openapi=(u=(l=r[d])===null||l===void 0?void 0:l._def)===null||u===void 0?void 0:u.openapi}),s._def.openapi=void 0,s};const n=t.ZodObject.prototype.pick;t.ZodObject.prototype.pick=function(...r){const s=n.apply(this,r);return s._def.openapi=void 0,s};const a=t.ZodObject.prototype.omit;t.ZodObject.prototype.omit=function(...r){const s=a.apply(this,r);return s._def.openapi=void 0,s}}new Set(".\\+*[^]$()");var E;(function(t){t.assertEqual=r=>r;function e(r){}t.assertIs=e;function n(r){throw new Error}t.assertNever=n,t.arrayToEnum=r=>{const s={};for(const o of r)s[o]=o;return s},t.getValidEnumValues=r=>{const s=t.objectKeys(r).filter(d=>typeof r[r[d]]!="number"),o={};for(const d of s)o[d]=r[d];return t.objectValues(o)},t.objectValues=r=>t.objectKeys(r).map(function(s){return r[s]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const s=[];for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&s.push(o);return s},t.find=(r,s)=>{for(const o of r)if(s(o))return o},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function a(r,s=" | "){return r.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}t.joinValues=a,t.jsonStringifyReplacer=(r,s)=>typeof s=="bigint"?s.toString():s})(E||(E={}));var kn;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(kn||(kn={}));const g=E.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ve=t=>{switch(typeof t){case"undefined":return g.undefined;case"string":return g.string;case"number":return isNaN(t)?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(t)?g.array:t===null?g.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?g.promise:typeof Map<"u"&&t instanceof Map?g.map:typeof Set<"u"&&t instanceof Set?g.set:typeof Date<"u"&&t instanceof Date?g.date:g.object;default:return g.unknown}},h=E.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"]),tr=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class q extends Error{constructor(e){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const n=e||function(s){return s.message},a={_errors:[]},r=s=>{for(const o of s.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)a._errors.push(n(o));else{let d=a,c=0;for(;c<o.path.length;){const l=o.path[c];c===o.path.length-1?(d[l]=d[l]||{_errors:[]},d[l]._errors.push(n(o))):d[l]=d[l]||{_errors:[]},d=d[l],c++}}};return r(this),a}static assert(e){if(!(e instanceof q))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,E.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},a=[];for(const r of this.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(e(r))):a.push(e(r));return{formErrors:a,fieldErrors:n}}get formErrors(){return this.flatten()}}q.create=t=>new q(t);const Qe=(t,e)=>{let n;switch(t.code){case h.invalid_type:t.received===g.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case h.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,E.jsonStringifyReplacer)}`;break;case h.unrecognized_keys:n=`Unrecognized key(s) in object: ${E.joinValues(t.keys,", ")}`;break;case h.invalid_union:n="Invalid input";break;case h.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${E.joinValues(t.options)}`;break;case h.invalid_enum_value:n=`Invalid enum value. Expected ${E.joinValues(t.options)}, received '${t.received}'`;break;case h.invalid_arguments:n="Invalid function arguments";break;case h.invalid_return_type:n="Invalid function return type";break;case h.invalid_date:n="Invalid date";break;case h.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:E.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case h.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case h.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case h.custom:n="Invalid input";break;case h.invalid_intersection_types:n="Intersection results could not be merged";break;case h.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case h.not_finite:n="Number must be finite";break;default:n=e.defaultError,E.assertNever(t)}return{message:n}};let Jn=Qe;function nr(t){Jn=t}function an(){return Jn}const rn=t=>{const{data:e,path:n,errorMaps:a,issueData:r}=t,s=[...n,...r.path||[]],o={...r,path:s};if(r.message!==void 0)return{...r,path:s,message:r.message};let d="";const c=a.filter(l=>!!l).slice().reverse();for(const l of c)d=l(o,{data:e,defaultError:d}).message;return{...r,path:s,message:d}},ar=[];function f(t,e){const n=an(),a=rn({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===Qe?void 0:Qe].filter(r=>!!r)});t.common.issues.push(a)}class B{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const a=[];for(const r of n){if(r.status==="aborted")return T;r.status==="dirty"&&e.dirty(),a.push(r.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,n){const a=[];for(const r of n){const s=await r.key,o=await r.value;a.push({key:s,value:o})}return B.mergeObjectSync(e,a)}static mergeObjectSync(e,n){const a={};for(const r of n){const{key:s,value:o}=r;if(s.status==="aborted"||o.status==="aborted")return T;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||r.alwaysSet)&&(a[s.value]=o.value)}return{status:e.value,value:a}}}const T=Object.freeze({status:"aborted"}),sn=t=>({status:"dirty",value:t}),W=t=>({status:"valid",value:t}),Nn=t=>t.status==="aborted",Tn=t=>t.status==="dirty",ft=t=>t.status==="valid",_t=t=>typeof Promise<"u"&&t instanceof Promise;function on(t,e,n,a){if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function qn(t,e,n,a,r){if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}var w;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(w||(w={}));var gt,yt;class ae{constructor(e,n,a,r){this._cachedPath=[],this.parent=e,this.data=n,this._path=a,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 Qn=(t,e)=>{if(ft(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new q(t.common.issues);return this._error=n,this._error}}};function O(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:a,description:r}=t;if(e&&(n||a))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:(s,o)=>{var d,c;const{message:l}=t;return s.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:(d=l??a)!==null&&d!==void 0?d:o.defaultError}:s.code!=="invalid_type"?{message:o.defaultError}:{message:(c=l??n)!==null&&c!==void 0?c:o.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 ve(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:ve(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new B,ctx:{common:e.parent.common,data:e.data,parsedType:ve(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(_t(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const a=this.safeParse(e,n);if(a.success)return a.data;throw a.error}safeParse(e,n){var a;const r={common:{issues:[],async:(a=n==null?void 0:n.async)!==null&&a!==void 0?a:!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ve(e)},s=this._parseSync({data:e,path:r.path,parent:r});return Qn(r,s)}async parseAsync(e,n){const a=await this.safeParseAsync(e,n);if(a.success)return a.data;throw a.error}async safeParseAsync(e,n){const a={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ve(e)},r=this._parse({data:e,path:a.path,parent:a}),s=await(_t(r)?r:Promise.resolve(r));return Qn(a,s)}refine(e,n){const a=r=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(r):n;return this._refinement((r,s)=>{const o=e(r),d=()=>s.addIssue({code:h.custom,...a(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(d(),!1)):o?!0:(d(),!1)})}refinement(e,n){return this._refinement((a,r)=>e(a)?!0:(r.addIssue(typeof n=="function"?n(a,r):n),!1))}_refinement(e){return new X({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return se.create(this,this._def)}nullable(){return Ne.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Y.create(this,this._def)}promise(){return Xe.create(this,this._def)}or(e){return xt.create([this,e],this._def)}and(e){return kt.create(this,e,this._def)}transform(e){return new X({...O(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new St({...O(this._def),innerType:this,defaultValue:n,typeName:x.ZodDefault})}brand(){return new Sn({typeName:x.ZodBranded,type:this,...O(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new jt({...O(this._def),innerType:this,catchValue:n,typeName:x.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return It.create(this,e)}readonly(){return Zt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const rr=/^c[^\s-]{8,}$/i,sr=/^[0-9a-z]+$/,ir=/^[0-9A-HJKMNP-TV-Z]{26}$/,or=/^[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,dr=/^[a-z0-9_-]{21}$/i,cr=/^[-+]?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)?)??$/,lr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ur="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Cn;const hr=/^(?:(?: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])$/,mr=/^(([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})))$/,pr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Hn="((\\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])))",fr=new RegExp(`^${Hn}$`);function Gn(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function _r(t){return new RegExp(`^${Gn(t)}$`)}function Yn(t){let e=`${Hn}T${Gn(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function gr(t,e){return!!((e==="v4"||!e)&&hr.test(t)||(e==="v6"||!e)&&mr.test(t))}class G extends j{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==g.string){const r=this._getOrReturnCtx(e);return f(r,{code:h.invalid_type,expected:g.string,received:r.parsedType}),T}const n=new B;let a;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:h.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind==="max")e.data.length>r.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:h.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind==="length"){const s=e.data.length>r.value,o=e.data.length<r.value;(s||o)&&(a=this._getOrReturnCtx(e,a),s?f(a,{code:h.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):o&&f(a,{code:h.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),n.dirty())}else if(r.kind==="email")lr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"email",code:h.invalid_string,message:r.message}),n.dirty());else if(r.kind==="emoji")Cn||(Cn=new RegExp(ur,"u")),Cn.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"emoji",code:h.invalid_string,message:r.message}),n.dirty());else if(r.kind==="uuid")or.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"uuid",code:h.invalid_string,message:r.message}),n.dirty());else if(r.kind==="nanoid")dr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"nanoid",code:h.invalid_string,message:r.message}),n.dirty());else if(r.kind==="cuid")rr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid",code:h.invalid_string,message:r.message}),n.dirty());else if(r.kind==="cuid2")sr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"cuid2",code:h.invalid_string,message:r.message}),n.dirty());else if(r.kind==="ulid")ir.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ulid",code:h.invalid_string,message:r.message}),n.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),f(a,{validation:"url",code:h.invalid_string,message:r.message}),n.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"regex",code:h.invalid_string,message:r.message}),n.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(a=this._getOrReturnCtx(e,a),f(a,{code:h.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),n.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)||(a=this._getOrReturnCtx(e,a),f(a,{code:h.invalid_string,validation:{startsWith:r.value},message:r.message}),n.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(a=this._getOrReturnCtx(e,a),f(a,{code:h.invalid_string,validation:{endsWith:r.value},message:r.message}),n.dirty()):r.kind==="datetime"?Yn(r).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:h.invalid_string,validation:"datetime",message:r.message}),n.dirty()):r.kind==="date"?fr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:h.invalid_string,validation:"date",message:r.message}),n.dirty()):r.kind==="time"?_r(r).test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{code:h.invalid_string,validation:"time",message:r.message}),n.dirty()):r.kind==="duration"?cr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"duration",code:h.invalid_string,message:r.message}),n.dirty()):r.kind==="ip"?gr(e.data,r.version)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"ip",code:h.invalid_string,message:r.message}),n.dirty()):r.kind==="base64"?pr.test(e.data)||(a=this._getOrReturnCtx(e,a),f(a,{validation:"base64",code:h.invalid_string,message:r.message}),n.dirty()):E.assertNever(r);return{status:n.value,value:e.data}}_regex(e,n,a){return this.refinement(r=>e.test(r),{validation:n,code:h.invalid_string,...w.errToObj(a)})}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}datetime(e){var n,a;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:(n=e==null?void 0:e.offset)!==null&&n!==void 0?n:!1,local:(a=e==null?void 0:e.local)!==null&&a!==void 0?a:!1,...w.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,...w.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...w.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...w.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...w.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...w.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...w.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...w.errToObj(n)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new G({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new G({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new G({...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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}G.create=t=>{var e;return new G({checks:[],typeName:x.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...O(t)})};function yr(t,e){const n=(t.toString().split(".")[1]||"").length,a=(e.toString().split(".")[1]||"").length,r=n>a?n:a,s=parseInt(t.toFixed(r).replace(".","")),o=parseInt(e.toFixed(r).replace(".",""));return s%o/Math.pow(10,r)}class we 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 r=this._getOrReturnCtx(e);return f(r,{code:h.invalid_type,expected:g.number,received:r.parsedType}),T}let n;const a=new B;for(const r of this._def.checks)r.kind==="int"?E.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:h.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="multipleOf"?yr(e.data,r.value)!==0&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),f(n,{code:h.not_finite,message:r.message}),a.dirty()):E.assertNever(r);return{status:a.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,w.toString(n))}gt(e,n){return this.setLimit("min",e,!1,w.toString(n))}lte(e,n){return this.setLimit("max",e,!0,w.toString(n))}lt(e,n){return this.setLimit("max",e,!1,w.toString(n))}setLimit(e,n,a,r){return new we({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:a,message:w.toString(r)}]})}_addCheck(e){return new we({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&E.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(n===null||a.value>n)&&(n=a.value):a.kind==="max"&&(e===null||a.value<e)&&(e=a.value)}return Number.isFinite(n)&&Number.isFinite(e)}}we.create=t=>new we({checks:[],typeName:x.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...O(t)});class be 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 r=this._getOrReturnCtx(e);return f(r,{code:h.invalid_type,expected:g.bigint,received:r.parsedType}),T}let n;const a=new B;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),f(n,{code:h.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):E.assertNever(r);return{status:a.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,w.toString(n))}gt(e,n){return this.setLimit("min",e,!1,w.toString(n))}lte(e,n){return this.setLimit("max",e,!0,w.toString(n))}lt(e,n){return this.setLimit("max",e,!1,w.toString(n))}setLimit(e,n,a,r){return new be({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:a,message:w.toString(r)}]})}_addCheck(e){return new be({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}be.create=t=>{var e;return new be({checks:[],typeName:x.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...O(t)})};class vt extends j{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==g.boolean){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.boolean,received:n.parsedType}),T}return W(e.data)}}vt.create=t=>new vt({typeName:x.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...O(t)});class De extends j{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==g.date){const r=this._getOrReturnCtx(e);return f(r,{code:h.invalid_type,expected:g.date,received:r.parsedType}),T}if(isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return f(r,{code:h.invalid_date}),T}const n=new B;let a;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:h.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),n.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(a=this._getOrReturnCtx(e,a),f(a,{code:h.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),n.dirty()):E.assertNever(r);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new De({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}De.create=t=>new De({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:x.ZodDate,...O(t)});class dn extends j{_parse(e){if(this._getType(e)!==g.symbol){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.symbol,received:n.parsedType}),T}return W(e.data)}}dn.create=t=>new dn({typeName:x.ZodSymbol,...O(t)});class wt extends j{_parse(e){if(this._getType(e)!==g.undefined){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.undefined,received:n.parsedType}),T}return W(e.data)}}wt.create=t=>new wt({typeName:x.ZodUndefined,...O(t)});class bt extends j{_parse(e){if(this._getType(e)!==g.null){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.null,received:n.parsedType}),T}return W(e.data)}}bt.create=t=>new bt({typeName:x.ZodNull,...O(t)});class He extends j{constructor(){super(...arguments),this._any=!0}_parse(e){return W(e.data)}}He.create=t=>new He({typeName:x.ZodAny,...O(t)});class Re extends j{constructor(){super(...arguments),this._unknown=!0}_parse(e){return W(e.data)}}Re.create=t=>new Re({typeName:x.ZodUnknown,...O(t)});class me extends j{_parse(e){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.never,received:n.parsedType}),T}}me.create=t=>new me({typeName:x.ZodNever,...O(t)});class cn extends j{_parse(e){if(this._getType(e)!==g.undefined){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.void,received:n.parsedType}),T}return W(e.data)}}cn.create=t=>new cn({typeName:x.ZodVoid,...O(t)});class Y extends j{_parse(e){const{ctx:n,status:a}=this._processInputParams(e),r=this._def;if(n.parsedType!==g.array)return f(n,{code:h.invalid_type,expected:g.array,received:n.parsedType}),T;if(r.exactLength!==null){const o=n.data.length>r.exactLength.value,d=n.data.length<r.exactLength.value;(o||d)&&(f(n,{code:o?h.too_big:h.too_small,minimum:d?r.exactLength.value:void 0,maximum:o?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),a.dirty())}if(r.minLength!==null&&n.data.length<r.minLength.value&&(f(n,{code:h.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),a.dirty()),r.maxLength!==null&&n.data.length>r.maxLength.value&&(f(n,{code:h.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),a.dirty()),n.common.async)return Promise.all([...n.data].map((o,d)=>r.type._parseAsync(new ae(n,o,n.path,d)))).then(o=>B.mergeArray(a,o));const s=[...n.data].map((o,d)=>r.type._parseSync(new ae(n,o,n.path,d)));return B.mergeArray(a,s)}get element(){return this._def.type}min(e,n){return new Y({...this._def,minLength:{value:e,message:w.toString(n)}})}max(e,n){return new Y({...this._def,maxLength:{value:e,message:w.toString(n)}})}length(e,n){return new Y({...this._def,exactLength:{value:e,message:w.toString(n)}})}nonempty(e){return this.min(1,e)}}Y.create=(t,e)=>new Y({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...O(e)});function Ge(t){if(t instanceof M){const e={};for(const n in t.shape){const a=t.shape[n];e[n]=se.create(Ge(a))}return new M({...t._def,shape:()=>e})}else return t instanceof Y?new Y({...t._def,type:Ge(t.element)}):t instanceof se?se.create(Ge(t.unwrap())):t instanceof Ne?Ne.create(Ge(t.unwrap())):t instanceof re?re.create(t.items.map(e=>Ge(e))):t}class M 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(),n=E.objectKeys(e);return this._cached={shape:e,keys:n}}_parse(e){if(this._getType(e)!==g.object){const c=this._getOrReturnCtx(e);return f(c,{code:h.invalid_type,expected:g.object,received:c.parsedType}),T}const{status:n,ctx:a}=this._processInputParams(e),{shape:r,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof me&&this._def.unknownKeys==="strip"))for(const c in a.data)s.includes(c)||o.push(c);const d=[];for(const c of s){const l=r[c],u=a.data[c];d.push({key:{status:"valid",value:c},value:l._parse(new ae(a,u,a.path,c)),alwaysSet:c in a.data})}if(this._def.catchall instanceof me){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of o)d.push({key:{status:"valid",value:l},value:{status:"valid",value:a.data[l]}});else if(c==="strict")o.length>0&&(f(a,{code:h.unrecognized_keys,keys:o}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of o){const u=a.data[l];d.push({key:{status:"valid",value:l},value:c._parse(new ae(a,u,a.path,l)),alwaysSet:l in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of d){const u=await l.key,Z=await l.value;c.push({key:u,value:Z,alwaysSet:l.alwaysSet})}return c}).then(c=>B.mergeObjectSync(n,c)):B.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new M({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,a)=>{var r,s,o,d;const c=(o=(s=(r=this._def).errorMap)===null||s===void 0?void 0:s.call(r,n,a).message)!==null&&o!==void 0?o:a.defaultError;return n.code==="unrecognized_keys"?{message:(d=w.errToObj(e).message)!==null&&d!==void 0?d:c}:{message:c}}}:{}})}strip(){return new M({...this._def,unknownKeys:"strip"})}passthrough(){return new M({...this._def,unknownKeys:"passthrough"})}extend(e){return new M({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new M({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new M({...this._def,catchall:e})}pick(e){const n={};return E.objectKeys(e).forEach(a=>{e[a]&&this.shape[a]&&(n[a]=this.shape[a])}),new M({...this._def,shape:()=>n})}omit(e){const n={};return E.objectKeys(this.shape).forEach(a=>{e[a]||(n[a]=this.shape[a])}),new M({...this._def,shape:()=>n})}deepPartial(){return Ge(this)}partial(e){const n={};return E.objectKeys(this.shape).forEach(a=>{const r=this.shape[a];e&&!e[a]?n[a]=r:n[a]=r.optional()}),new M({...this._def,shape:()=>n})}required(e){const n={};return E.objectKeys(this.shape).forEach(a=>{if(e&&!e[a])n[a]=this.shape[a];else{let r=this.shape[a];for(;r instanceof se;)r=r._def.innerType;n[a]=r}}),new M({...this._def,shape:()=>n})}keyof(){return Xn(E.objectKeys(this.shape))}}M.create=(t,e)=>new M({shape:()=>t,unknownKeys:"strip",catchall:me.create(),typeName:x.ZodObject,...O(e)}),M.strictCreate=(t,e)=>new M({shape:()=>t,unknownKeys:"strict",catchall:me.create(),typeName:x.ZodObject,...O(e)}),M.lazycreate=(t,e)=>new M({shape:t,unknownKeys:"strip",catchall:me.create(),typeName:x.ZodObject,...O(e)});class xt extends j{_parse(e){const{ctx:n}=this._processInputParams(e),a=this._def.options;function r(s){for(const d of s)if(d.result.status==="valid")return d.result;for(const d of s)if(d.result.status==="dirty")return n.common.issues.push(...d.ctx.common.issues),d.result;const o=s.map(d=>new q(d.ctx.common.issues));return f(n,{code:h.invalid_union,unionErrors:o}),T}if(n.common.async)return Promise.all(a.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(r);{let s;const o=[];for(const c of a){const l={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const d=o.map(c=>new q(c));return f(n,{code:h.invalid_union,unionErrors:d}),T}}get options(){return this._def.options}}xt.create=(t,e)=>new xt({options:t,typeName:x.ZodUnion,...O(e)});const xe=t=>t instanceof Tt?xe(t.schema):t instanceof X?xe(t.innerType()):t instanceof Ct?[t.value]:t instanceof ke?t.options:t instanceof Ot?E.objectValues(t.enum):t instanceof St?xe(t._def.innerType):t instanceof wt?[void 0]:t instanceof bt?[null]:t instanceof se?[void 0,...xe(t.unwrap())]:t instanceof Ne?[null,...xe(t.unwrap())]:t instanceof Sn||t instanceof Zt?xe(t.unwrap()):t instanceof jt?xe(t._def.innerType):[];class ln extends j{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.object)return f(n,{code:h.invalid_type,expected:g.object,received:n.parsedType}),T;const a=this.discriminator,r=n.data[a],s=this.optionsMap.get(r);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(f(n,{code:h.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),T)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,a){const r=new Map;for(const s of n){const o=xe(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const d of o){if(r.has(d))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(d)}`);r.set(d,s)}}return new ln({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:r,...O(a)})}}function On(t,e){const n=ve(t),a=ve(e);if(t===e)return{valid:!0,data:t};if(n===g.object&&a===g.object){const r=E.objectKeys(e),s=E.objectKeys(t).filter(d=>r.indexOf(d)!==-1),o={...t,...e};for(const d of s){const c=On(t[d],e[d]);if(!c.valid)return{valid:!1};o[d]=c.data}return{valid:!0,data:o}}else if(n===g.array&&a===g.array){if(t.length!==e.length)return{valid:!1};const r=[];for(let s=0;s<t.length;s++){const o=t[s],d=e[s],c=On(o,d);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===g.date&&a===g.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class kt extends j{_parse(e){const{status:n,ctx:a}=this._processInputParams(e),r=(s,o)=>{if(Nn(s)||Nn(o))return T;const d=On(s.value,o.value);return d.valid?((Tn(s)||Tn(o))&&n.dirty(),{status:n.value,value:d.data}):(f(a,{code:h.invalid_intersection_types}),T)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([s,o])=>r(s,o)):r(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}kt.create=(t,e,n)=>new kt({left:t,right:e,typeName:x.ZodIntersection,...O(n)});class re extends j{_parse(e){const{status:n,ctx:a}=this._processInputParams(e);if(a.parsedType!==g.array)return f(a,{code:h.invalid_type,expected:g.array,received:a.parsedType}),T;if(a.data.length<this._def.items.length)return f(a,{code:h.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),T;!this._def.rest&&a.data.length>this._def.items.length&&(f(a,{code:h.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const r=[...a.data].map((s,o)=>{const d=this._def.items[o]||this._def.rest;return d?d._parse(new ae(a,s,a.path,o)):null}).filter(s=>!!s);return a.common.async?Promise.all(r).then(s=>B.mergeArray(n,s)):B.mergeArray(n,r)}get items(){return this._def.items}rest(e){return new re({...this._def,rest:e})}}re.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new re({items:t,typeName:x.ZodTuple,rest:null,...O(e)})};class Nt extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:a}=this._processInputParams(e);if(a.parsedType!==g.object)return f(a,{code:h.invalid_type,expected:g.object,received:a.parsedType}),T;const r=[],s=this._def.keyType,o=this._def.valueType;for(const d in a.data)r.push({key:s._parse(new ae(a,d,a.path,d)),value:o._parse(new ae(a,a.data[d],a.path,d)),alwaysSet:d in a.data});return a.common.async?B.mergeObjectAsync(n,r):B.mergeObjectSync(n,r)}get element(){return this._def.valueType}static create(e,n,a){return n instanceof j?new Nt({keyType:e,valueType:n,typeName:x.ZodRecord,...O(a)}):new Nt({keyType:G.create(),valueType:e,typeName:x.ZodRecord,...O(n)})}}class un extends j{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:a}=this._processInputParams(e);if(a.parsedType!==g.map)return f(a,{code:h.invalid_type,expected:g.map,received:a.parsedType}),T;const r=this._def.keyType,s=this._def.valueType,o=[...a.data.entries()].map(([d,c],l)=>({key:r._parse(new ae(a,d,a.path,[l,"key"])),value:s._parse(new ae(a,c,a.path,[l,"value"]))}));if(a.common.async){const d=new Map;return Promise.resolve().then(async()=>{for(const c of o){const l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return T;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),d.set(l.value,u.value)}return{status:n.value,value:d}})}else{const d=new Map;for(const c of o){const l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return T;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),d.set(l.value,u.value)}return{status:n.value,value:d}}}}un.create=(t,e,n)=>new un({valueType:e,keyType:t,typeName:x.ZodMap,...O(n)});class Me extends j{_parse(e){const{status:n,ctx:a}=this._processInputParams(e);if(a.parsedType!==g.set)return f(a,{code:h.invalid_type,expected:g.set,received:a.parsedType}),T;const r=this._def;r.minSize!==null&&a.data.size<r.minSize.value&&(f(a,{code:h.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),n.dirty()),r.maxSize!==null&&a.data.size>r.maxSize.value&&(f(a,{code:h.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),n.dirty());const s=this._def.valueType;function o(c){const l=new Set;for(const u of c){if(u.status==="aborted")return T;u.status==="dirty"&&n.dirty(),l.add(u.value)}return{status:n.value,value:l}}const d=[...a.data.values()].map((c,l)=>s._parse(new ae(a,c,a.path,l)));return a.common.async?Promise.all(d).then(c=>o(c)):o(d)}min(e,n){return new Me({...this._def,minSize:{value:e,message:w.toString(n)}})}max(e,n){return new Me({...this._def,maxSize:{value:e,message:w.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Me.create=(t,e)=>new Me({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...O(e)});class Ye extends j{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.function)return f(n,{code:h.invalid_type,expected:g.function,received:n.parsedType}),T;function a(d,c){return rn({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,an(),Qe].filter(l=>!!l),issueData:{code:h.invalid_arguments,argumentsError:c}})}function r(d,c){return rn({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,an(),Qe].filter(l=>!!l),issueData:{code:h.invalid_return_type,returnTypeError:c}})}const s={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof Xe){const d=this;return W(async function(...c){const l=new q([]),u=await d._def.args.parseAsync(c,s).catch(z=>{throw l.addIssue(a(c,z)),l}),Z=await Reflect.apply(o,this,u);return await d._def.returns._def.type.parseAsync(Z,s).catch(z=>{throw l.addIssue(r(Z,z)),l})})}else{const d=this;return W(function(...c){const l=d._def.args.safeParse(c,s);if(!l.success)throw new q([a(c,l.error)]);const u=Reflect.apply(o,this,l.data),Z=d._def.returns.safeParse(u,s);if(!Z.success)throw new q([r(u,Z.error)]);return Z.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ye({...this._def,args:re.create(e).rest(Re.create())})}returns(e){return new Ye({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,a){return new Ye({args:e||re.create([]).rest(Re.create()),returns:n||Re.create(),typeName:x.ZodFunction,...O(a)})}}class Tt extends j{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Tt.create=(t,e)=>new Tt({getter:t,typeName:x.ZodLazy,...O(e)});class Ct extends j{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return f(n,{received:n.data,code:h.invalid_literal,expected:this._def.value}),T}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ct.create=(t,e)=>new Ct({value:t,typeName:x.ZodLiteral,...O(e)});function Xn(t,e){return new ke({values:t,typeName:x.ZodEnum,...O(e)})}class ke extends j{constructor(){super(...arguments),gt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),a=this._def.values;return f(n,{expected:E.joinValues(a),received:n.parsedType,code:h.invalid_type}),T}if(on(this,gt)||qn(this,gt,new Set(this._def.values)),!on(this,gt).has(e.data)){const n=this._getOrReturnCtx(e),a=this._def.values;return f(n,{received:n.data,code:h.invalid_enum_value,options:a}),T}return W(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return ke.create(e,{...this._def,...n})}exclude(e,n=this._def){return ke.create(this.options.filter(a=>!e.includes(a)),{...this._def,...n})}}gt=new WeakMap,ke.create=Xn;class Ot extends j{constructor(){super(...arguments),yt.set(this,void 0)}_parse(e){const n=E.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==g.string&&a.parsedType!==g.number){const r=E.objectValues(n);return f(a,{expected:E.joinValues(r),received:a.parsedType,code:h.invalid_type}),T}if(on(this,yt)||qn(this,yt,new Set(E.getValidEnumValues(this._def.values))),!on(this,yt).has(e.data)){const r=E.objectValues(n);return f(a,{received:a.data,code:h.invalid_enum_value,options:r}),T}return W(e.data)}get enum(){return this._def.values}}yt=new WeakMap,Ot.create=(t,e)=>new Ot({values:t,typeName:x.ZodNativeEnum,...O(e)});class Xe extends j{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==g.promise&&n.common.async===!1)return f(n,{code:h.invalid_type,expected:g.promise,received:n.parsedType}),T;const a=n.parsedType===g.promise?n.data:Promise.resolve(n.data);return W(a.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Xe.create=(t,e)=>new Xe({type:t,typeName:x.ZodPromise,...O(e)});class X extends j{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:a}=this._processInputParams(e),r=this._def.effect||null,s={addIssue:o=>{f(a,o),o.fatal?n.abort():n.dirty()},get path(){return a.path}};if(s.addIssue=s.addIssue.bind(s),r.type==="preprocess"){const o=r.transform(a.data,s);if(a.common.async)return Promise.resolve(o).then(async d=>{if(n.value==="aborted")return T;const c=await this._def.schema._parseAsync({data:d,path:a.path,parent:a});return c.status==="aborted"?T:c.status==="dirty"||n.value==="dirty"?sn(c.value):c});{if(n.value==="aborted")return T;const d=this._def.schema._parseSync({data:o,path:a.path,parent:a});return d.status==="aborted"?T:d.status==="dirty"||n.value==="dirty"?sn(d.value):d}}if(r.type==="refinement"){const o=d=>{const c=r.refinement(d,s);if(a.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return d};if(a.common.async===!1){const d=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return d.status==="aborted"?T:(d.status==="dirty"&&n.dirty(),o(d.value),{status:n.value,value:d.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(d=>d.status==="aborted"?T:(d.status==="dirty"&&n.dirty(),o(d.value).then(()=>({status:n.value,value:d.value}))))}if(r.type==="transform")if(a.common.async===!1){const o=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!ft(o))return o;const d=r.transform(o.value,s);if(d instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:d}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(o=>ft(o)?Promise.resolve(r.transform(o.value,s)).then(d=>({status:n.value,value:d})):o);E.assertNever(r)}}X.create=(t,e,n)=>new X({schema:t,typeName:x.ZodEffects,effect:e,...O(n)}),X.createWithPreprocess=(t,e,n)=>new X({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...O(n)});class se extends j{_parse(e){return this._getType(e)===g.undefined?W(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}se.create=(t,e)=>new se({innerType:t,typeName:x.ZodOptional,...O(e)});class Ne extends j{_parse(e){return this._getType(e)===g.null?W(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ne.create=(t,e)=>new Ne({innerType:t,typeName:x.ZodNullable,...O(e)});class St extends j{_parse(e){const{ctx:n}=this._processInputParams(e);let a=n.data;return n.parsedType===g.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}St.create=(t,e)=>new St({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...O(e)});class jt extends j{_parse(e){const{ctx:n}=this._processInputParams(e),a={...n,common:{...n.common,issues:[]}},r=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return _t(r)?r.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new q(a.common.issues)},input:a.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new q(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}jt.create=(t,e)=>new jt({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...O(e)});class hn extends j{_parse(e){if(this._getType(e)!==g.nan){const n=this._getOrReturnCtx(e);return f(n,{code:h.invalid_type,expected:g.nan,received:n.parsedType}),T}return{status:"valid",value:e.data}}}hn.create=t=>new hn({typeName:x.ZodNaN,...O(t)});const vr=Symbol("zod_brand");class Sn extends j{_parse(e){const{ctx:n}=this._processInputParams(e),a=n.data;return this._def.type._parse({data:a,path:n.path,parent:n})}unwrap(){return this._def.type}}class It extends j{_parse(e){const{status:n,ctx:a}=this._processInputParams(e);if(a.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return r.status==="aborted"?T:r.status==="dirty"?(n.dirty(),sn(r.value)):this._def.out._parseAsync({data:r.value,path:a.path,parent:a})})();{const r=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return r.status==="aborted"?T:r.status==="dirty"?(n.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:a.path,parent:a})}}static create(e,n){return new It({in:e,out:n,typeName:x.ZodPipeline})}}class Zt extends j{_parse(e){const n=this._def.innerType._parse(e),a=r=>(ft(r)&&(r.value=Object.freeze(r.value)),r);return _t(n)?n.then(r=>a(r)):a(n)}unwrap(){return this._def.innerType}}Zt.create=(t,e)=>new Zt({innerType:t,typeName:x.ZodReadonly,...O(e)});function ea(t,e={},n){return t?He.create().superRefine((a,r)=>{var s,o;if(!t(a)){const d=typeof e=="function"?e(a):typeof e=="string"?{message:e}:e,c=(o=(s=d.fatal)!==null&&s!==void 0?s:n)!==null&&o!==void 0?o:!0,l=typeof d=="string"?{message:d}:d;r.addIssue({code:"custom",...l,fatal:c})}}):He.create()}const wr={object:M.lazycreate};var x;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(x||(x={}));const br=(t,e={message:`Input not instance of ${t.name}`})=>ea(n=>n instanceof t,e),ta=G.create,na=we.create,xr=hn.create,kr=be.create,aa=vt.create,Nr=De.create,Tr=dn.create,Cr=wt.create,Or=bt.create,Sr=He.create,jr=Re.create,Ir=me.create,Zr=cn.create,Er=Y.create,$r=M.create,Ar=M.strictCreate,Pr=xt.create,Dr=ln.create,Rr=kt.create,Mr=re.create,Lr=Nt.create,zr=un.create,Ur=Me.create,Fr=Ye.create,Vr=Tt.create,Br=Ct.create,Kr=ke.create,Wr=Ot.create,Jr=Xe.create,ra=X.create,qr=se.create,Qr=Ne.create,Hr=X.createWithPreprocess,Gr=It.create;var i=Object.freeze({__proto__:null,defaultErrorMap:Qe,setErrorMap:nr,getErrorMap:an,makeIssue:rn,EMPTY_PATH:ar,addIssueToContext:f,ParseStatus:B,INVALID:T,DIRTY:sn,OK:W,isAborted:Nn,isDirty:Tn,isValid:ft,isAsync:_t,get util(){return E},get objectUtil(){return kn},ZodParsedType:g,getParsedType:ve,ZodType:j,datetimeRegex:Yn,ZodString:G,ZodNumber:we,ZodBigInt:be,ZodBoolean:vt,ZodDate:De,ZodSymbol:dn,ZodUndefined:wt,ZodNull:bt,ZodAny:He,ZodUnknown:Re,ZodNever:me,ZodVoid:cn,ZodArray:Y,ZodObject:M,ZodUnion:xt,ZodDiscriminatedUnion:ln,ZodIntersection:kt,ZodTuple:re,ZodRecord:Nt,ZodMap:un,ZodSet:Me,ZodFunction:Ye,ZodLazy:Tt,ZodLiteral:Ct,ZodEnum:ke,ZodNativeEnum:Ot,ZodPromise:Xe,ZodEffects:X,ZodTransformer:X,ZodOptional:se,ZodNullable:Ne,ZodDefault:St,ZodCatch:jt,ZodNaN:hn,BRAND:vr,ZodBranded:Sn,ZodPipeline:It,ZodReadonly:Zt,custom:ea,Schema:j,ZodSchema:j,late:wr,get ZodFirstPartyTypeKind(){return x},coerce:{string:t=>G.create({...t,coerce:!0}),number:t=>we.create({...t,coerce:!0}),boolean:t=>vt.create({...t,coerce:!0}),bigint:t=>be.create({...t,coerce:!0}),date:t=>De.create({...t,coerce:!0})},any:Sr,array:Er,bigint:kr,boolean:aa,date:Nr,discriminatedUnion:Dr,effect:ra,enum:Kr,function:Fr,instanceof:br,intersection:Rr,lazy:Vr,literal:Br,map:zr,nan:xr,nativeEnum:Wr,never:Ir,null:Or,nullable:Qr,number:na,object:$r,oboolean:()=>aa().optional(),onumber:()=>na().optional(),optional:qr,ostring:()=>ta().optional(),pipeline:Gr,preprocess:Hr,promise:Jr,record:Lr,set:Ur,strictObject:Ar,string:ta,symbol:Tr,transformer:ra,tuple:Mr,undefined:Cr,union:Pr,unknown:jr,void:Zr,NEVER:T,ZodIssueCode:h,quotelessJson:tr,ZodError:q});er(i),i.object({start:i.number(),limit:i.number(),length:i.number()});const jn=i.object({created_at:i.string(),updated_at:i.string()}),Yr=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()),Xr=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:Yr.optional()}),sa=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(),app_metadata:i.any().default({}).optional(),user_metadata:i.any().default({}).optional()}),es=sa.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")});i.object({...es.shape,...jn.shape,user_id:i.string(),email:i.string(),is_social:i.boolean(),login_count:i.number(),identities:i.array(Xr).optional()}),sa.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 ts="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ns=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=ts[n[t]&63];return e};const as=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()}),rs=i.object({id:i.string(),name:i.string(),callbacks:i.array(i.string()).default([]).optional().openapi({description:"Comma-separated list of URLs whitelisted to use as a callback to the client after authentication."}),allowed_origins:i.array(i.string()).default([]).optional().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()).default([]).optional().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()).default([]).optional().openapi({description:"Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains."}),allowed_clients:i.array(i.string()).default([]).optional().openapi({description:"Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients"}),addons:i.object({samlp:as.optional()}).default({}).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").optional().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(()=>ns()).optional(),disable_sign_ups:i.boolean().optional().default(!1).openapi({description:"Prevents users from signing up using the hosted login page. This is not available in auth0"})}),ss=i.object({created_at:i.string().transform(t=>t===null?"":t),updated_at:i.string().transform(t=>t===null?"":t),...rs.shape});var ia=(t=>(t.TOKEN="token",t.TOKEN_ID_TOKEN="token id_token",t.CODE="code",t))(ia||{}),oa=(t=>(t.QUERY="query",t.FRAGMENT="fragment",t.FORM_POST="form_post",t.WEB_MESSAGE="web_message",t.SAML_POST="saml_post",t))(oa||{}),da=(t=>(t.S265="S256",t.plain="plain",t))(da||{});const is=i.object({client_id:i.string(),vendor_id:i.string().optional(),response_type:i.nativeEnum(ia).optional(),response_mode:i.nativeEnum(oa).optional(),redirect_uri:i.string().optional(),audience:i.string().optional(),state:i.string().optional(),nonce:i.string().optional(),scope:i.string().optional(),prompt:i.string().optional(),code_challenge_method:i.nativeEnum(da).optional(),code_challenge:i.string().optional(),username:i.string().optional(),ui_locales: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 os=i.object({id:i.string().optional(),name:i.string(),strategy:i.enum(["google-oauth2","facebook","vipps","freja","apple","email","Username-Password-Authentication","oidc","oauth2","custom"]).optional(),options:i.object({kid:i.string().optional(),team_id:i.string().optional(),realms:i.string().optional(),client_id:i.string().optional(),client_secret:i.string().optional(),app_secret:i.string().optional(),scope:i.string().optional(),authorization_endpoint:i.string().default("").optional(),token_endpoint:i.string().default("").optional(),userinfo_endpoint:i.string().default("").optional(),jwks_uri:i.string().default("").optional(),discovery_url:i.string().default("").optional(),issuer:i.string().default("").optional()}).default({}).optional(),enabled_clients:i.array(i.string()).default([]).optional(),response_type:i.custom().optional(),response_mode:i.custom().optional()}),ca=i.object({id:i.string(),created_at:i.string().transform(t=>t===null?"":t),updated_at:i.string().transform(t=>t===null?"":t)}).extend(os.shape),ds=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()}),cs=i.object({created_at:i.string().transform(t=>t===null?"":t),updated_at:i.string().transform(t=>t===null?"":t),id:i.string(),...ds.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 ls=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({...ss.shape,domains:i.array(ls),tenant:cs,connections:i.array(ca)});const us=i.enum(["password_reset","email_verification","otp","authorization_code","oauth2_state","ticket"]),hs=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:us,expires_at:i.string(),used_at:i.string().optional(),user_id:i.string().optional()}),ms=i.object({...hs.shape,created_at:i.string()}),ps=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"])});jn.extend({...ps.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({...jn.shape,hook_id:i.string()});const fs=i.object({alg:i.enum(["RS256","RS384","RS512","ES256","ES384","ES512","HS256","HS384","HS512"]),e:i.string(),kid:i.string(),kty:i.enum(["RSA","EC","oct"]),n:i.string(),x5t:i.string().optional(),x5c:i.array(i.string()).optional(),use:i.enum(["sig","enc"]).optional()});i.object({keys:i.array(fs)}),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 _s=i.object({auth0Client:i.string().optional(),authParams:is,expires_at:i.string(),deleted_at:i.string().optional(),ip:i.string().optional()}).openapi({description:"This represents a login sesion"}),gs=i.object({..._s.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()}),ys=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"]),vs=i.object({name:i.string(),version:i.string(),env:i.object({node:i.string().optional()}).optional()});i.object({type:ys,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:vs.optional()});const ws=i.object({user_id:i.string(),password:i.string(),algorithm:i.enum(["bcrypt","argon2id"]).default("argon2id")});i.object({...ws.shape,created_at:i.string(),updated_at:i.string()});const bs=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(),...bs.shape}),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 private 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 la=(t=>(t.RefreshToken="refresh_token",t.AuthorizationCode="authorization_code",t.ClientCredential="client_credentials",t.Passwordless="passwordless",t.Password="password",t))(la||{});const In=i.nativeEnum(la);i.object({grant_type:In.refine(t=>t==="authorization_code"),code:i.string(),client_secret:i.string(),client_id:i.string()}),i.object({grant_type:In.refine(t=>t==="authorization_code"),code:i.string(),code_verifier:i.string(),client_id:i.string().optional(),redirect_uri:i.string()}),i.object({grant_type:In.refine(t=>t==="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 xs=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()}),ks=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()}),et=i.object({bold:i.boolean(),size:i.number()}),Ns=i.object({body_text:et,buttons_text:et,font_url:i.string(),input_labels:et,links:et,links_style:i.enum(["normal"]),reference_text_size:i.number(),subtitle:et,title:et}),Ts=i.object({background_color:i.string(),background_image_url:i.string(),page_layout:i.enum(["center"])}),Cs=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:xs,colors:ks,displayName:i.string(),fonts:Ns,page_background:Ts,widget:Cs}).extend({themeId:i.string()});const Os=i.object({universal_login_experience:i.enum(["new","classic"]).default("new"),identifier_first:i.boolean().default(!0),password_first:i.boolean().default(!1),webauthn_platform_first_factor:i.boolean()});function Zn(t){const[e,n]=t.split("|");if(!e||!n)throw new Error(`Invalid user_id: ${t}`);return{connection:e,id:n}}function ua(t){let e={};try{e=JSON.parse(t.profileData||"{}")}catch(n){console.error("Error parsing profileData",n)}return{connection:t.connection,provider:t.provider,user_id:Zn(t.user_id).id,isSocial:!!t.is_social,profileData:{email:t.email,email_verified:!!t.email_verified,...e}}}function Ss(t){return async(e,n)=>{const[a,r]=await Promise.all([t.selectFrom("users").where("users.tenant_id","=",e).where("users.user_id","=",n).selectAll().executeTakeFirst(),t.selectFrom("users").where("users.tenant_id","=",e).where("users.linked_to","=",n).selectAll().execute()]);if(!a)return null;const{tenant_id:s,...o}=a,d={...o,email:a.email||"",email_verified:a.email_verified===1,is_social:a.is_social===1,app_metadata:JSON.parse(a.app_metadata),user_metadata:JSON.parse(a.user_metadata),identities:[{connection:a.connection,provider:a.provider,user_id:Zn(a.user_id).id,isSocial:!!a.is_social},...r.map(ua)]};return R(d)}}function Le(t,e,n,a){return n.split(/\s+/).map(s=>s.replace(/^([^:]+)=/g,"$1:")).map(s=>{let o=s.startsWith("-"),d,c,l,u;return s.startsWith("-_exists_:")?(d=s.substring(10),l=!0,o=!0):s.startsWith("_exists_:")?(d=s.substring(9),l=!0,o=!1):s.includes(":")?(o=s.startsWith("-"),[d,c]=o?s.substring(1).split(":"):s.split(":"),l=!1,c.startsWith(">=")?(u=">=",c=c.substring(2)):c.startsWith(">")?(u=">",c=c.substring(1)):c.startsWith("<=")?(console.log("value",c),u="<=",c=c.substring(2)):c.startsWith("<")?(u="<",c=c.substring(1)):u="="):(d=null,c=s,l=!1),{key:d,value:c,isNegation:o,isExistsQuery:l,operator:u}}).forEach(({key:s,value:o,isNegation:d,isExistsQuery:c,operator:l})=>{if(s)if(c)d?e=e.where(s,"is",null):e=e.where(s,"is not",null);else if(d)switch(l){case">":e=e.where(s,"<=",o);break;case">=":e=e.where(s,"<",o);break;case"<":e=e.where(s,">=",o);break;case"<=":e=e.where(s,">",o);break;default:e=e.where(s,"!=",o)}else e=e.where(s,l,o);else{const{ref:u}=t.dynamic;e=e.where(Z=>Z.or(a.map(z=>Z(u(z),"like",`%${o}%`))))}}),e}function Te(t){return typeof t=="string"?parseInt(t,10):typeof t=="bigint"?Number(t):t}function js(t){return async(e,n)=>{let a=t.selectFrom("users").where("users.tenant_id","=",e);if(n.q&&(a=Le(t,a,n.q,["email","name"])),n.sort&&n.sort.sort_by){const{ref:u}=t.dynamic;a=a.orderBy(u(n.sort.sort_by),n.sort.sort_order)}const s=await a.offset(n.page*n.per_page).limit(n.per_page).selectAll().execute(),o=s.map(u=>u.user_id),d=o.length?await t.selectFrom("users").selectAll().where("users.tenant_id","=",e).where("users.linked_to","in",o).execute():[],c=s.map(u=>{const Z=d.filter(z=>z.linked_to===u.user_id);return R({...u,email_verified:u.email_verified===1,is_social:u.is_social===1,app_metadata:JSON.parse(u.app_metadata),user_metadata:JSON.parse(u.user_metadata),identities:[{connection:u.connection,provider:u.provider,user_id:Zn(u.user_id).id,isSocial:!!u.is_social},...Z.map(ua)]})}),{count:l}=await a.select(u=>u.fn.countAll().as("count")).executeTakeFirstOrThrow();return{users:c,start:n.page*n.per_page,limit:n.per_page,length:Te(l)}}}function Is(t){return async(e,n)=>(await t.deleteFrom("users").where("users.tenant_id","=",e).where("users.linked_to","=",n).execute(),(await t.deleteFrom("users").where("users.tenant_id","=",e).where("users.user_id","=",n).execute()).length===1)}function Zs(t){if(t.email_verified!==void 0)return t.email_verified?1:0}function Es(t){return async(e,n,a)=>{const r={...a,email_verified:Zs(a),updated_at:new Date().toISOString()};return a.app_metadata&&(r.app_metadata=JSON.stringify(a.app_metadata)),a.user_metadata&&(r.user_metadata=JSON.stringify(a.user_metadata)),(await t.updateTable("users").set(r).where("users.tenant_id","=",e).where("users.user_id","=",n).execute()).length===1}}function $s(t){return async(e,n,a,r)=>{const s={linked_to:null};return(await t.updateTable("users").set(s).where("users.tenant_id","=",e).where("users.user_id","=",`${a}|${r}`).where("users.linked_to","=",`${n}`).execute()).length===1}}function As(t){return{create:U(t),remove:Is(t),get:Ss(t),list:js(t),update:Es(t),unlink:$s(t)}}const Ps="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let ze=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=Ps[n[t]&63];return e};function Ds(t){return async e=>{const n={id:e.id||ze(),created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...e};return await t.insertInto("tenants").values(n).execute(),n}}function Rs(t){return async e=>{const n=await t.selectFrom("tenants").where("tenants.id","=",e).selectAll().executeTakeFirst();return n?R(n):null}}function Ms(t){return async e=>{let n=t.selectFrom("tenants");if(e.sort&&e.sort.sort_by){const{ref:d}=t.dynamic;n=n.orderBy(d(e.sort.sort_by),e.sort.sort_order)}e.q&&(n=n.where(d=>d.or([d("name","like",`%${e.q}%`)])));const r=await n.offset(e.page*e.per_page).limit(e.per_page).selectAll().execute();if(!e.include_totals)return{tenants:r};const{count:s}=await n.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow(),o=Te(s);return{tenants:r.map(R),start:(e.page-1)*e.per_page,limit:e.per_page,length:o}}}function Ls(t){return async(e,n)=>{const a={...n,id:e,updated_at:new Date().toISOString()};await t.updateTable("tenants").set(a).where("id","=",e).execute()}}function zs(t){return async e=>(await t.deleteFrom("tenants").where("tenants.id","=",e).execute()).length===1}function Us(t){return{create:Ds(t),get:Rs(t),list:Ms(t),update:Ls(t),remove:zs(t)}}function ha(t){return t?JSON.stringify(t):void 0}const Fs=1024;function Vs(t){return async(e,n)=>{var r,s,o;const a={id:ze(),...n,user_agent:n.user_agent.slice(0,Fs)};return await t.insertInto("logs").values({...a,description:(r=a.description)==null?void 0:r.substring(0,256),isMobile:n.isMobile?1:0,tenant_id:e,scope:(s=n.scope)==null?void 0:s.join(","),auth0_client:ha(n.auth0_client),details:(o=ha(n.details))==null?void 0:o.substring(0,8192)}).execute(),a}}function ma(t){if(!t)return"";try{return JSON.parse(t)}catch{return t}}function pa(t){return{...t,client_id:t.client_id,client_name:"",auth0_client:ma(t.auth0_client),details:ma(t.details),isMobile:!!t.isMobile,scope:t.scope?t.scope.split(","):void 0,log_id:t.id,_id:t.id}}function Bs(t){return async(e,n)=>{let a=t.selectFrom("logs").where("logs.tenant_id","=",e);n.q&&(a=Le(t,a,n.q,["user_id","ip"]));let r=a;if(n.sort&&n.sort.sort_by){const{ref:d}=t.dynamic;r=r.orderBy(d(n.sort.sort_by),n.sort.sort_order)}r=r.offset(n.page*n.per_page).limit(n.per_page);const s=await r.selectAll().execute(),{count:o}=await a.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{logs:s.map(pa),start:n.page*n.per_page,limit:n.per_page,length:Te(o)}}}function Ks(t){return async(e,n)=>{const a=await t.selectFrom("logs").where("logs.tenant_id","=",e).where("logs.id","=",n).selectAll().executeTakeFirst();return a?pa(a):null}}function Ws(t){return{create:Vs(t),list:Bs(t),get:Ks(t)}}function Js(t){return async(e,n)=>await t.selectFrom("sessions").where("sessions.tenant_id","=",e).where("sessions.session_id","=",n).where("sessions.deleted_at","is",null).selectAll().executeTakeFirst()??null}function qs(t){return async(e,n)=>{const a={...n,created_at:new Date().toISOString(),expires_at:new Date().toISOString()};return await t.insertInto("sessions").values({...a,tenant_id:e}).execute(),{...n,...a}}}function Qs(t){return async(e,n)=>!!(await t.updateTable("sessions").set({deleted_at:new Date().toISOString()}).where("tenant_id","=",e).where("sessions.session_id","=",n).where("sessions.deleted_at","is",null).execute()).length}function Hs(t){return async(e,n,a)=>!!(await t.updateTable("sessions").set(a).where("tenant_id","=",e).where("sessions.session_id","=",n).where("sessions.deleted_at","is",null).execute()).length}function Gs(t){return async(e,n)=>{let a=t.selectFrom("sessions").where("sessions.tenant_id","=",e);n.q&&(a=Le(t,a,n.q,["user_id","session_id"]));let r=a;if(n.sort&&n.sort.sort_by){const{ref:c}=t.dynamic;r=r.orderBy(c(n.sort.sort_by),n.sort.sort_order)}r=r.offset(n.page*n.per_page).limit(n.per_page);const s=await r.selectAll().execute(),{count:o}=await a.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow(),d=Te(o);return{sessions:s,start:n.page*n.per_page,limit:n.per_page,length:d}}}function Ys(t){return{create:qs(t),get:Js(t),list:Gs(t),remove:Qs(t),update:Hs(t)}}function Xs(t){return async(e,n)=>{const a=await t.selectFrom("tickets").where("tickets.tenant_id","=",e).where("tickets.id","=",n).where("tickets.used_at","is",null).selectAll().executeTakeFirst();if(!a)return null;const{nonce:r,state:s,scope:o,response_type:d,response_mode:c,redirect_uri:l,...u}=a;return{...u,authParams:{nonce:r,state:s,scope:o,response_type:d,response_mode:c,redirect_uri:l},created_at:new Date(a.created_at),expires_at:new Date(a.expires_at),used_at:a.used_at?new Date(a.used_at):void 0}}}function ei(t){return async e=>{const{authParams:n,...a}=e,r={...a,...n,created_at:e.created_at.toISOString(),expires_at:e.expires_at.toISOString(),used_at:e.used_at?e.used_at.toISOString():void 0};await t.insertInto("tickets").values(r).execute()}}function ti(t){return async(e,n)=>{await t.updateTable("tickets").set({used_at:new Date().toISOString()}).where("tickets.tenant_id","=",e).where("tickets.id","=",n).execute()}}function ni(t){return{create:ei(t),get:Xs(t),remove:ti(t)}}function ai(t){return async(e,n)=>{const a=await t.selectFrom("passwords").where("passwords.tenant_id","=",e).where("passwords.user_id","=",n).selectAll().executeTakeFirstOrThrow(),{tenant_id:r,...s}=a;return s}}function ri(t){return async(e,n)=>{const a={...n,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await t.insertInto("passwords").values({...a,tenant_id:e}).execute(),a}}function si(t){return async(e,n)=>(await t.updateTable("passwords").set({password:n.password,updated_at:new Date().toISOString()}).where("tenant_id","=",e).where("user_id","=",n.user_id).execute()).length===1}function ii(t){return{create:ri(t),update:si(t),get:ai(t)}}function oi(t){return async(e,n)=>{let a=t.selectFrom("codes").where("codes.tenant_id","=",e);n.q&&(a=Le(t,a,n.q,["code","login_id"]));const s=await a.offset(n.page*n.per_page).limit(n.per_page).selectAll().execute(),{count:o}=await a.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{codes:s.map(c=>{const{tenant_id:l,...u}=c;return ms.parse(R(u))}),start:n.page*n.per_page,limit:n.per_page,length:Te(o)}}}function di(t){return async(e,n)=>{const a={...n,created_at:new Date().toISOString()};return await t.insertInto("codes").values({...a,tenant_id:e}).execute(),a}}function ci(t){return async(e,n)=>(await t.deleteFrom("codes").where("codes.tenant_id","=",e).where("codes.code_id","=",n).executeTakeFirst()).numDeletedRows>0}function li(t){return async(e,n,a)=>{let r=t.selectFrom("codes").where("codes.code_id","=",n).where("codes.code_type","=",a).where("codes.expires_at",">",new Date().toISOString());e.length&&(r=r.where("codes.tenant_id","=",e));const s=await r.selectAll().executeTakeFirst();return s?R(s):null}}function ui(t){return{create:di(t),list:oi(t),remove:ci(t),get:li(t)}}function hi(t){return async(e,n)=>{const a={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),...n},r=JSON.stringify(n.allowed_origins),s=JSON.stringify(n.callbacks),o=JSON.stringify(n.web_origins),d=JSON.stringify(n.allowed_logout_urls),c=JSON.stringify(n.allowed_clients);return await t.insertInto("applications").values({...a,tenant_id:e,disable_sign_ups:n.disable_sign_ups?1:0,addons:n.addons?JSON.stringify(n.addons):"{}",callbacks:s,allowed_origins:r,web_origins:o,allowed_logout_urls:d,allowed_clients:c}).execute(),a}}function mi(t){return async e=>({applications:(await t.selectFrom("applications").where("applications.tenant_id","=",e).selectAll().execute()).map(s=>({...s,disable_sign_ups:!!s.disable_sign_ups,addons:s.addons?JSON.parse(s.addons):{},callbacks:s.callbacks?JSON.parse(s.callbacks):[],allowed_origins:s.allowed_origins?JSON.parse(s.allowed_origins):[],web_origins:s.web_origins?JSON.parse(s.web_origins):[],allowed_logout_urls:s.allowed_logout_urls?JSON.parse(s.allowed_logout_urls):[],allowed_clients:s.allowed_logout_urls?JSON.parse(s.allowed_logout_urls):[]}))})}function pi(t){return async(e,n)=>{const a=await t.selectFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",n).selectAll().executeTakeFirst();return a?R({...a,disable_sign_ups:!!a.disable_sign_ups,addons:JSON.parse(a.addons),callbacks:JSON.parse(a.callbacks),allowed_origins:JSON.parse(a.allowed_origins),web_origins:JSON.parse(a.web_origins),allowed_logout_urls:JSON.parse(a.allowed_logout_urls)}):null}}function fi(t){return async(e,n)=>(await t.deleteFrom("applications").where("applications.tenant_id","=",e).where("applications.id","=",n).executeTakeFirst()).numDeletedRows>0}function _i(t){return async(e,n,a)=>{const r={...a,updated_at:new Date().toISOString(),allowed_origins:a.allowed_origins?JSON.stringify(a.allowed_origins):void 0,callbacks:a.callbacks?JSON.stringify(a.callbacks):void 0,web_origins:a.web_origins?JSON.stringify(a.web_origins):void 0,allowed_logout_urls:a.allowed_logout_urls?JSON.stringify(a.allowed_logout_urls):void 0,allowed_clients:a.allowed_clients?JSON.stringify(a.allowed_clients):void 0,addons:a.addons?JSON.stringify(a.addons):"{}",disable_sign_ups:a.disable_sign_ups?1:0};return await t.updateTable("applications").set(r).where("applications.id","=",n).where("applications.tenant_id","=",e).execute(),!0}}function gi(t){return{create:hi(t),list:mi(t),get:pi(t),remove:fi(t),update:_i(t)}}function yi(t){return async(e,n)=>{const a={id:ze(),...n,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await t.insertInto("connections").values({...a,options:JSON.stringify(a.options||{}),tenant_id:e}).execute(),a}}function vi(t,e){var n={};for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&e.indexOf(a)<0&&(n[a]=t[a]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var r=0,a=Object.getOwnPropertySymbols(t);r<a.length;r++)e.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(t,a[r])&&(n[a[r]]=t[a[r]]);return n}typeof SuppressedError=="function"&&SuppressedError;function wi(t,e){var n;return((n=t==null?void 0:t._def)===null||n===void 0?void 0:n.typeName)===e}function Et(t,e){const n=t.ZodType.prototype[e];t.ZodType.prototype[e]=function(...a){const r=n.apply(this,a);return r._def.openapi=this._def.openapi,r}}function bi(t){if(typeof t.ZodType.prototype.openapi<"u")return;t.ZodType.prototype.openapi=function(r,s){var o,d,c,l,u,Z;const z=typeof r=="string"?s:r,H=z??{},{param:Ze}=H,dt=vi(H,["param"]),Ee=Object.assign(Object.assign({},(o=this._def.openapi)===null||o===void 0?void 0:o._internal),typeof r=="string"?{refId:r}:void 0),$e=Object.assign(Object.assign(Object.assign({},(d=this._def.openapi)===null||d===void 0?void 0:d.metadata),dt),!((l=(c=this._def.openapi)===null||c===void 0?void 0:c.metadata)===null||l===void 0)&&l.param||Ze?{param:Object.assign(Object.assign({},(Z=(u=this._def.openapi)===null||u===void 0?void 0:u.metadata)===null||Z===void 0?void 0:Z.param),Ze)}:void 0),Ae=new this.constructor(Object.assign(Object.assign({},this._def),{openapi:Object.assign(Object.assign({},Object.keys(Ee).length>0?{_internal:Ee}:void 0),Object.keys($e).length>0?{metadata:$e}:void 0)}));if(wi(this,"ZodObject")){const ct=this.extend;Ae.extend=function(...lt){var ce,le,ue,Pe,We,Je;const qe=ct.apply(this,lt);return qe._def.openapi={_internal:{extendedFrom:!((le=(ce=this._def.openapi)===null||ce===void 0?void 0:ce._internal)===null||le===void 0)&&le.refId?{refId:(Pe=(ue=this._def.openapi)===null||ue===void 0?void 0:ue._internal)===null||Pe===void 0?void 0:Pe.refId,schema:this}:(We=this._def.openapi)===null||We===void 0?void 0:We._internal.extendedFrom},metadata:(Je=qe._def.openapi)===null||Je===void 0?void 0:Je.metadata},qe}}return Ae},Et(t,"optional"),Et(t,"nullable"),Et(t,"default"),Et(t,"transform"),Et(t,"refine");const e=t.ZodObject.prototype.deepPartial;t.ZodObject.prototype.deepPartial=function(){const r=this._def.shape(),s=e.apply(this),o=s._def.shape();return Object.entries(o).forEach(([d,c])=>{var l,u;c._def.openapi=(u=(l=r[d])===null||l===void 0?void 0:l._def)===null||u===void 0?void 0:u.openapi}),s._def.openapi=void 0,s};const n=t.ZodObject.prototype.pick;t.ZodObject.prototype.pick=function(...r){const s=n.apply(this,r);return s._def.openapi=void 0,s};const a=t.ZodObject.prototype.omit;t.ZodObject.prototype.omit=function(...r){const s=a.apply(this,r);return s._def.openapi=void 0,s}}new Set(".\\+*[^]$()");var $;(function(t){t.assertEqual=r=>r;function e(r){}t.assertIs=e;function n(r){throw new Error}t.assertNever=n,t.arrayToEnum=r=>{const s={};for(const o of r)s[o]=o;return s},t.getValidEnumValues=r=>{const s=t.objectKeys(r).filter(d=>typeof r[r[d]]!="number"),o={};for(const d of s)o[d]=r[d];return t.objectValues(o)},t.objectValues=r=>t.objectKeys(r).map(function(s){return r[s]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const s=[];for(const o in r)Object.prototype.hasOwnProperty.call(r,o)&&s.push(o);return s},t.find=(r,s)=>{for(const o of r)if(s(o))return o},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function a(r,s=" | "){return r.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}t.joinValues=a,t.jsonStringifyReplacer=(r,s)=>typeof s=="bigint"?s.toString():s})($||($={}));var En;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(En||(En={}));const y=$.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ce=t=>{switch(typeof t){case"undefined":return y.undefined;case"string":return y.string;case"number":return isNaN(t)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(t)?y.array:t===null?y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?y.promise:typeof Map<"u"&&t instanceof Map?y.map:typeof Set<"u"&&t instanceof Set?y.set:typeof Date<"u"&&t instanceof Date?y.date:y.object;default:return y.unknown}},m=$.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"]),xi=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class Q extends Error{constructor(e){super(),this.issues=[],this.addIssue=a=>{this.issues=[...this.issues,a]},this.addIssues=(a=[])=>{this.issues=[...this.issues,...a]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const n=e||function(s){return s.message},a={_errors:[]},r=s=>{for(const o of s.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)a._errors.push(n(o));else{let d=a,c=0;for(;c<o.path.length;){const l=o.path[c];c===o.path.length-1?(d[l]=d[l]||{_errors:[]},d[l]._errors.push(n(o))):d[l]=d[l]||{_errors:[]},d=d[l],c++}}};return r(this),a}static assert(e){if(!(e instanceof Q))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,$.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},a=[];for(const r of this.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(e(r))):a.push(e(r));return{formErrors:a,fieldErrors:n}}get formErrors(){return this.flatten()}}Q.create=t=>new Q(t);const tt=(t,e)=>{let n;switch(t.code){case m.invalid_type:t.received===y.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case m.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,$.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:n=`Unrecognized key(s) in object: ${$.joinValues(t.keys,", ")}`;break;case m.invalid_union:n="Invalid input";break;case m.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${$.joinValues(t.options)}`;break;case m.invalid_enum_value:n=`Invalid enum value. Expected ${$.joinValues(t.options)}, received '${t.received}'`;break;case m.invalid_arguments:n="Invalid function arguments";break;case m.invalid_return_type:n="Invalid function return type";break;case m.invalid_date:n="Invalid date";break;case m.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:$.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case m.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case m.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case m.custom:n="Invalid input";break;case m.invalid_intersection_types:n="Intersection results could not be merged";break;case m.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case m.not_finite:n="Number must be finite";break;default:n=e.defaultError,$.assertNever(t)}return{message:n}};let fa=tt;function ki(t){fa=t}function mn(){return fa}const pn=t=>{const{data:e,path:n,errorMaps:a,issueData:r}=t,s=[...n,...r.path||[]],o={...r,path:s};if(r.message!==void 0)return{...r,path:s,message:r.message};let d="";const c=a.filter(l=>!!l).slice().reverse();for(const l of c)d=l(o,{data:e,defaultError:d}).message;return{...r,path:s,message:d}},Ni=[];function _(t,e){const n=mn(),a=pn({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===tt?void 0:tt].filter(r=>!!r)});t.common.issues.push(a)}class K{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const a=[];for(const r of n){if(r.status==="aborted")return N;r.status==="dirty"&&e.dirty(),a.push(r.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,n){const a=[];for(const r of n){const s=await r.key,o=await r.value;a.push({key:s,value:o})}return K.mergeObjectSync(e,a)}static mergeObjectSync(e,n){const a={};for(const r of n){const{key:s,value:o}=r;if(s.status==="aborted"||o.status==="aborted")return N;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||r.alwaysSet)&&(a[s.value]=o.value)}return{status:e.value,value:a}}}const N=Object.freeze({status:"aborted"}),nt=t=>({status:"dirty",value:t}),J=t=>({status:"valid",value:t}),$n=t=>t.status==="aborted",An=t=>t.status==="dirty",$t=t=>t.status==="valid",At=t=>typeof Promise<"u"&&t instanceof Promise;function fn(t,e,n,a){if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function _a(t,e,n,a,r){if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,n),n}typeof SuppressedError=="function"&&SuppressedError;var b;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(b||(b={}));var Pt,Dt;class ie{constructor(e,n,a,r){this._cachedPath=[],this.parent=e,this.data=n,this._path=a,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 ga=(t,e)=>{if($t(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Q(t.common.issues);return this._error=n,this._error}}};function S(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:a,description:r}=t;if(e&&(n||a))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,d)=>{var c,l;const{message:u}=t;return o.code==="invalid_enum_value"?{message:u??d.defaultError}:typeof d.data>"u"?{message:(c=u??a)!==null&&c!==void 0?c:d.defaultError}:o.code!=="invalid_type"?{message:d.defaultError}:{message:(l=u??n)!==null&&l!==void 0?l:d.defaultError}},description:r}}class I{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 Ce(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:Ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new K,ctx:{common:e.parent.common,data:e.data,parsedType:Ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(At(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const a=this.safeParse(e,n);if(a.success)return a.data;throw a.error}safeParse(e,n){var a;const r={common:{issues:[],async:(a=n==null?void 0:n.async)!==null&&a!==void 0?a:!1,contextualErrorMap:n==null?void 0:n.errorMap},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ce(e)},s=this._parseSync({data:e,path:r.path,parent:r});return ga(r,s)}async parseAsync(e,n){const a=await this.safeParseAsync(e,n);if(a.success)return a.data;throw a.error}async safeParseAsync(e,n){const a={common:{issues:[],contextualErrorMap:n==null?void 0:n.errorMap,async:!0},path:(n==null?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ce(e)},r=this._parse({data:e,path:a.path,parent:a}),s=await(At(r)?r:Promise.resolve(r));return ga(a,s)}refine(e,n){const a=r=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(r):n;return this._refinement((r,s)=>{const o=e(r),d=()=>s.addIssue({code:m.custom,...a(r)});return typeof Promise<"u"&&o instanceof Promise?o.then(c=>c?!0:(d(),!1)):o?!0:(d(),!1)})}refinement(e,n){return this._refinement((a,r)=>e(a)?!0:(r.addIssue(typeof n=="function"?n(a,r):n),!1))}_refinement(e){return new ne({schema:this,typeName:k.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return de.create(this,this._def)}nullable(){return Ie.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return te.create(this,this._def)}promise(){return it.create(this,this._def)}or(e){return zt.create([this,e],this._def)}and(e){return Ut.create(this,e,this._def)}transform(e){return new ne({...S(this._def),schema:this,typeName:k.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new Wt({...S(this._def),innerType:this,defaultValue:n,typeName:k.ZodDefault})}brand(){return new Rn({typeName:k.ZodBranded,type:this,...S(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new Jt({...S(this._def),innerType:this,catchValue:n,typeName:k.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return qt.create(this,e)}readonly(){return Qt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Ti=/^c[^\s-]{8,}$/i,Ci=/^[0-9a-z]+$/,Oi=/^[0-9A-HJKMNP-TV-Z]{26}$/,Si=/^[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,ji=/^[a-z0-9_-]{21}$/i,Ii=/^[-+]?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)?)??$/,Zi=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ei="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Pn;const $i=/^(?:(?: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])$/,Ai=/^(([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})))$/,Pi=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ya="((\\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])))",Di=new RegExp(`^${ya}$`);function va(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Ri(t){return new RegExp(`^${va(t)}$`)}function wa(t){let e=`${ya}T${va(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function Mi(t,e){return!!((e==="v4"||!e)&&$i.test(t)||(e==="v6"||!e)&&Ai.test(t))}class ee extends I{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){const s=this._getOrReturnCtx(e);return _(s,{code:m.invalid_type,expected:y.string,received:s.parsedType}),N}const a=new K;let r;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(r=this._getOrReturnCtx(e,r),_(r,{code:m.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if(s.kind==="max")e.data.length>s.value&&(r=this._getOrReturnCtx(e,r),_(r,{code:m.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),a.dirty());else if(s.kind==="length"){const o=e.data.length>s.value,d=e.data.length<s.value;(o||d)&&(r=this._getOrReturnCtx(e,r),o?_(r,{code:m.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):d&&_(r,{code:m.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),a.dirty())}else if(s.kind==="email")Zi.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"email",code:m.invalid_string,message:s.message}),a.dirty());else if(s.kind==="emoji")Pn||(Pn=new RegExp(Ei,"u")),Pn.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"emoji",code:m.invalid_string,message:s.message}),a.dirty());else if(s.kind==="uuid")Si.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"uuid",code:m.invalid_string,message:s.message}),a.dirty());else if(s.kind==="nanoid")ji.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"nanoid",code:m.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid")Ti.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"cuid",code:m.invalid_string,message:s.message}),a.dirty());else if(s.kind==="cuid2")Ci.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"cuid2",code:m.invalid_string,message:s.message}),a.dirty());else if(s.kind==="ulid")Oi.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"ulid",code:m.invalid_string,message:s.message}),a.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),_(r,{validation:"url",code:m.invalid_string,message:s.message}),a.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"regex",code:m.invalid_string,message:s.message}),a.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(r=this._getOrReturnCtx(e,r),_(r,{code:m.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),a.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(r=this._getOrReturnCtx(e,r),_(r,{code:m.invalid_string,validation:{startsWith:s.value},message:s.message}),a.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(r=this._getOrReturnCtx(e,r),_(r,{code:m.invalid_string,validation:{endsWith:s.value},message:s.message}),a.dirty()):s.kind==="datetime"?wa(s).test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:m.invalid_string,validation:"datetime",message:s.message}),a.dirty()):s.kind==="date"?Di.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:m.invalid_string,validation:"date",message:s.message}),a.dirty()):s.kind==="time"?Ri(s).test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{code:m.invalid_string,validation:"time",message:s.message}),a.dirty()):s.kind==="duration"?Ii.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"duration",code:m.invalid_string,message:s.message}),a.dirty()):s.kind==="ip"?Mi(e.data,s.version)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"ip",code:m.invalid_string,message:s.message}),a.dirty()):s.kind==="base64"?Pi.test(e.data)||(r=this._getOrReturnCtx(e,r),_(r,{validation:"base64",code:m.invalid_string,message:s.message}),a.dirty()):$.assertNever(s);return{status:a.value,value:e.data}}_regex(e,n,a){return this.refinement(r=>e.test(r),{validation:n,code:m.invalid_string,...b.errToObj(a)})}_addCheck(e){return new ee({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...b.errToObj(e)})}url(e){return this._addCheck({kind:"url",...b.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...b.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...b.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...b.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...b.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...b.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...b.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...b.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...b.errToObj(e)})}datetime(e){var n,a;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:(n=e==null?void 0:e.offset)!==null&&n!==void 0?n:!1,local:(a=e==null?void 0:e.local)!==null&&a!==void 0?a:!1,...b.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,...b.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...b.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...b.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n==null?void 0:n.position,...b.errToObj(n==null?void 0:n.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...b.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...b.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...b.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...b.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...b.errToObj(n)})}nonempty(e){return this.min(1,b.errToObj(e))}trim(){return new ee({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new ee({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new ee({...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 n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}ee.create=t=>{var e;return new ee({checks:[],typeName:k.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...S(t)})};function Li(t,e){const n=(t.toString().split(".")[1]||"").length,a=(e.toString().split(".")[1]||"").length,r=n>a?n:a,s=parseInt(t.toFixed(r).replace(".","")),o=parseInt(e.toFixed(r).replace(".",""));return s%o/Math.pow(10,r)}class Oe extends I{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)!==y.number){const s=this._getOrReturnCtx(e);return _(s,{code:m.invalid_type,expected:y.number,received:s.parsedType}),N}let a;const r=new K;for(const s of this._def.checks)s.kind==="int"?$.isInteger(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{code:m.invalid_type,expected:"integer",received:"float",message:s.message}),r.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(a=this._getOrReturnCtx(e,a),_(a,{code:m.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(a=this._getOrReturnCtx(e,a),_(a,{code:m.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),r.dirty()):s.kind==="multipleOf"?Li(e.data,s.value)!==0&&(a=this._getOrReturnCtx(e,a),_(a,{code:m.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(a=this._getOrReturnCtx(e,a),_(a,{code:m.not_finite,message:s.message}),r.dirty()):$.assertNever(s);return{status:r.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,a,r){return new Oe({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:a,message:b.toString(r)}]})}_addCheck(e){return new Oe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:b.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:b.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:b.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:b.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&$.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const a of this._def.checks){if(a.kind==="finite"||a.kind==="int"||a.kind==="multipleOf")return!0;a.kind==="min"?(n===null||a.value>n)&&(n=a.value):a.kind==="max"&&(e===null||a.value<e)&&(e=a.value)}return Number.isFinite(n)&&Number.isFinite(e)}}Oe.create=t=>new Oe({checks:[],typeName:k.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...S(t)});class Se extends I{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)!==y.bigint){const s=this._getOrReturnCtx(e);return _(s,{code:m.invalid_type,expected:y.bigint,received:s.parsedType}),N}let a;const r=new K;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(a=this._getOrReturnCtx(e,a),_(a,{code:m.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(a=this._getOrReturnCtx(e,a),_(a,{code:m.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(a=this._getOrReturnCtx(e,a),_(a,{code:m.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):$.assertNever(s);return{status:r.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,b.toString(n))}gt(e,n){return this.setLimit("min",e,!1,b.toString(n))}lte(e,n){return this.setLimit("max",e,!0,b.toString(n))}lt(e,n){return this.setLimit("max",e,!1,b.toString(n))}setLimit(e,n,a,r){return new Se({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:a,message:b.toString(r)}]})}_addCheck(e){return new Se({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:b.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:b.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:b.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:b.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:b.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}Se.create=t=>{var e;return new Se({checks:[],typeName:k.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...S(t)})};class Rt extends I{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==y.boolean){const a=this._getOrReturnCtx(e);return _(a,{code:m.invalid_type,expected:y.boolean,received:a.parsedType}),N}return J(e.data)}}Rt.create=t=>new Rt({typeName:k.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...S(t)});class Ue extends I{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){const s=this._getOrReturnCtx(e);return _(s,{code:m.invalid_type,expected:y.date,received:s.parsedType}),N}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return _(s,{code:m.invalid_date}),N}const a=new K;let r;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(r=this._getOrReturnCtx(e,r),_(r,{code:m.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),a.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(r=this._getOrReturnCtx(e,r),_(r,{code:m.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),a.dirty()):$.assertNever(s);return{status:a.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ue({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:b.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:b.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}Ue.create=t=>new Ue({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:k.ZodDate,...S(t)});class _n extends I{_parse(e){if(this._getType(e)!==y.symbol){const a=this._getOrReturnCtx(e);return _(a,{code:m.invalid_type,expected:y.symbol,received:a.parsedType}),N}return J(e.data)}}_n.create=t=>new _n({typeName:k.ZodSymbol,...S(t)});class Mt extends I{_parse(e){if(this._getType(e)!==y.undefined){const a=this._getOrReturnCtx(e);return _(a,{code:m.invalid_type,expected:y.undefined,received:a.parsedType}),N}return J(e.data)}}Mt.create=t=>new Mt({typeName:k.ZodUndefined,...S(t)});class Lt extends I{_parse(e){if(this._getType(e)!==y.null){const a=this._getOrReturnCtx(e);return _(a,{code:m.invalid_type,expected:y.null,received:a.parsedType}),N}return J(e.data)}}Lt.create=t=>new Lt({typeName:k.ZodNull,...S(t)});class at extends I{constructor(){super(...arguments),this._any=!0}_parse(e){return J(e.data)}}at.create=t=>new at({typeName:k.ZodAny,...S(t)});class Fe extends I{constructor(){super(...arguments),this._unknown=!0}_parse(e){return J(e.data)}}Fe.create=t=>new Fe({typeName:k.ZodUnknown,...S(t)});class pe extends I{_parse(e){const n=this._getOrReturnCtx(e);return _(n,{code:m.invalid_type,expected:y.never,received:n.parsedType}),N}}pe.create=t=>new pe({typeName:k.ZodNever,...S(t)});class gn extends I{_parse(e){if(this._getType(e)!==y.undefined){const a=this._getOrReturnCtx(e);return _(a,{code:m.invalid_type,expected:y.void,received:a.parsedType}),N}return J(e.data)}}gn.create=t=>new gn({typeName:k.ZodVoid,...S(t)});class te extends I{_parse(e){const{ctx:n,status:a}=this._processInputParams(e),r=this._def;if(n.parsedType!==y.array)return _(n,{code:m.invalid_type,expected:y.array,received:n.parsedType}),N;if(r.exactLength!==null){const o=n.data.length>r.exactLength.value,d=n.data.length<r.exactLength.value;(o||d)&&(_(n,{code:o?m.too_big:m.too_small,minimum:d?r.exactLength.value:void 0,maximum:o?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),a.dirty())}if(r.minLength!==null&&n.data.length<r.minLength.value&&(_(n,{code:m.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),a.dirty()),r.maxLength!==null&&n.data.length>r.maxLength.value&&(_(n,{code:m.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),a.dirty()),n.common.async)return Promise.all([...n.data].map((o,d)=>r.type._parseAsync(new ie(n,o,n.path,d)))).then(o=>K.mergeArray(a,o));const s=[...n.data].map((o,d)=>r.type._parseSync(new ie(n,o,n.path,d)));return K.mergeArray(a,s)}get element(){return this._def.type}min(e,n){return new te({...this._def,minLength:{value:e,message:b.toString(n)}})}max(e,n){return new te({...this._def,maxLength:{value:e,message:b.toString(n)}})}length(e,n){return new te({...this._def,exactLength:{value:e,message:b.toString(n)}})}nonempty(e){return this.min(1,e)}}te.create=(t,e)=>new te({type:t,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...S(e)});function rt(t){if(t instanceof L){const e={};for(const n in t.shape){const a=t.shape[n];e[n]=de.create(rt(a))}return new L({...t._def,shape:()=>e})}else return t instanceof te?new te({...t._def,type:rt(t.element)}):t instanceof de?de.create(rt(t.unwrap())):t instanceof Ie?Ie.create(rt(t.unwrap())):t instanceof oe?oe.create(t.items.map(e=>rt(e))):t}class L extends I{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(),n=$.objectKeys(e);return this._cached={shape:e,keys:n}}_parse(e){if(this._getType(e)!==y.object){const l=this._getOrReturnCtx(e);return _(l,{code:m.invalid_type,expected:y.object,received:l.parsedType}),N}const{status:a,ctx:r}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),d=[];if(!(this._def.catchall instanceof pe&&this._def.unknownKeys==="strip"))for(const l in r.data)o.includes(l)||d.push(l);const c=[];for(const l of o){const u=s[l],Z=r.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new ie(r,Z,r.path,l)),alwaysSet:l in r.data})}if(this._def.catchall instanceof pe){const l=this._def.unknownKeys;if(l==="passthrough")for(const u of d)c.push({key:{status:"valid",value:u},value:{status:"valid",value:r.data[u]}});else if(l==="strict")d.length>0&&(_(r,{code:m.unrecognized_keys,keys:d}),a.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const u of d){const Z=r.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new ie(r,Z,r.path,u)),alwaysSet:u in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const l=[];for(const u of c){const Z=await u.key,z=await u.value;l.push({key:Z,value:z,alwaysSet:u.alwaysSet})}return l}).then(l=>K.mergeObjectSync(a,l)):K.mergeObjectSync(a,c)}get shape(){return this._def.shape()}strict(e){return b.errToObj,new L({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,a)=>{var r,s,o,d;const c=(o=(s=(r=this._def).errorMap)===null||s===void 0?void 0:s.call(r,n,a).message)!==null&&o!==void 0?o:a.defaultError;return n.code==="unrecognized_keys"?{message:(d=b.errToObj(e).message)!==null&&d!==void 0?d:c}:{message:c}}}:{}})}strip(){return new L({...this._def,unknownKeys:"strip"})}passthrough(){return new L({...this._def,unknownKeys:"passthrough"})}extend(e){return new L({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new L({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:k.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new L({...this._def,catchall:e})}pick(e){const n={};return $.objectKeys(e).forEach(a=>{e[a]&&this.shape[a]&&(n[a]=this.shape[a])}),new L({...this._def,shape:()=>n})}omit(e){const n={};return $.objectKeys(this.shape).forEach(a=>{e[a]||(n[a]=this.shape[a])}),new L({...this._def,shape:()=>n})}deepPartial(){return rt(this)}partial(e){const n={};return $.objectKeys(this.shape).forEach(a=>{const r=this.shape[a];e&&!e[a]?n[a]=r:n[a]=r.optional()}),new L({...this._def,shape:()=>n})}required(e){const n={};return $.objectKeys(this.shape).forEach(a=>{if(e&&!e[a])n[a]=this.shape[a];else{let s=this.shape[a];for(;s instanceof de;)s=s._def.innerType;n[a]=s}}),new L({...this._def,shape:()=>n})}keyof(){return ba($.objectKeys(this.shape))}}L.create=(t,e)=>new L({shape:()=>t,unknownKeys:"strip",catchall:pe.create(),typeName:k.ZodObject,...S(e)}),L.strictCreate=(t,e)=>new L({shape:()=>t,unknownKeys:"strict",catchall:pe.create(),typeName:k.ZodObject,...S(e)}),L.lazycreate=(t,e)=>new L({shape:t,unknownKeys:"strip",catchall:pe.create(),typeName:k.ZodObject,...S(e)});class zt extends I{_parse(e){const{ctx:n}=this._processInputParams(e),a=this._def.options;function r(s){for(const d of s)if(d.result.status==="valid")return d.result;for(const d of s)if(d.result.status==="dirty")return n.common.issues.push(...d.ctx.common.issues),d.result;const o=s.map(d=>new Q(d.ctx.common.issues));return _(n,{code:m.invalid_union,unionErrors:o}),N}if(n.common.async)return Promise.all(a.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(r);{let s;const o=[];for(const c of a){const l={...n,common:{...n.common,issues:[]},parent:null},u=c._parseSync({data:n.data,path:n.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!s&&(s={result:u,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const d=o.map(c=>new Q(c));return _(n,{code:m.invalid_union,unionErrors:d}),N}}get options(){return this._def.options}}zt.create=(t,e)=>new zt({options:t,typeName:k.ZodUnion,...S(e)});const fe=t=>t instanceof Vt?fe(t.schema):t instanceof ne?fe(t.innerType()):t instanceof Bt?[t.value]:t instanceof je?t.options:t instanceof Kt?$.objectValues(t.enum):t instanceof Wt?fe(t._def.innerType):t instanceof Mt?[void 0]:t instanceof Lt?[null]:t instanceof de?[void 0,...fe(t.unwrap())]:t instanceof Ie?[null,...fe(t.unwrap())]:t instanceof Rn||t instanceof Qt?fe(t.unwrap()):t instanceof Jt?fe(t._def.innerType):[];class yn extends I{_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.object)return _(n,{code:m.invalid_type,expected:y.object,received:n.parsedType}),N;const a=this.discriminator,r=n.data[a],s=this.optionsMap.get(r);return s?n.common.async?s._parseAsync({data:n.data,path:n.path,parent:n}):s._parseSync({data:n.data,path:n.path,parent:n}):(_(n,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),N)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,n,a){const r=new Map;for(const s of n){const o=fe(s.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const d of o){if(r.has(d))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(d)}`);r.set(d,s)}}return new yn({typeName:k.ZodDiscriminatedUnion,discriminator:e,options:n,optionsMap:r,...S(a)})}}function Dn(t,e){const n=Ce(t),a=Ce(e);if(t===e)return{valid:!0,data:t};if(n===y.object&&a===y.object){const r=$.objectKeys(e),s=$.objectKeys(t).filter(d=>r.indexOf(d)!==-1),o={...t,...e};for(const d of s){const c=Dn(t[d],e[d]);if(!c.valid)return{valid:!1};o[d]=c.data}return{valid:!0,data:o}}else if(n===y.array&&a===y.array){if(t.length!==e.length)return{valid:!1};const r=[];for(let s=0;s<t.length;s++){const o=t[s],d=e[s],c=Dn(o,d);if(!c.valid)return{valid:!1};r.push(c.data)}return{valid:!0,data:r}}else return n===y.date&&a===y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Ut extends I{_parse(e){const{status:n,ctx:a}=this._processInputParams(e),r=(s,o)=>{if($n(s)||$n(o))return N;const d=Dn(s.value,o.value);return d.valid?((An(s)||An(o))&&n.dirty(),{status:n.value,value:d.data}):(_(a,{code:m.invalid_intersection_types}),N)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then(([s,o])=>r(s,o)):r(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}Ut.create=(t,e,n)=>new Ut({left:t,right:e,typeName:k.ZodIntersection,...S(n)});class oe extends I{_parse(e){const{status:n,ctx:a}=this._processInputParams(e);if(a.parsedType!==y.array)return _(a,{code:m.invalid_type,expected:y.array,received:a.parsedType}),N;if(a.data.length<this._def.items.length)return _(a,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),N;!this._def.rest&&a.data.length>this._def.items.length&&(_(a,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const s=[...a.data].map((o,d)=>{const c=this._def.items[d]||this._def.rest;return c?c._parse(new ie(a,o,a.path,d)):null}).filter(o=>!!o);return a.common.async?Promise.all(s).then(o=>K.mergeArray(n,o)):K.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new oe({...this._def,rest:e})}}oe.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new oe({items:t,typeName:k.ZodTuple,rest:null,...S(e)})};class Ft extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:a}=this._processInputParams(e);if(a.parsedType!==y.object)return _(a,{code:m.invalid_type,expected:y.object,received:a.parsedType}),N;const r=[],s=this._def.keyType,o=this._def.valueType;for(const d in a.data)r.push({key:s._parse(new ie(a,d,a.path,d)),value:o._parse(new ie(a,a.data[d],a.path,d)),alwaysSet:d in a.data});return a.common.async?K.mergeObjectAsync(n,r):K.mergeObjectSync(n,r)}get element(){return this._def.valueType}static create(e,n,a){return n instanceof I?new Ft({keyType:e,valueType:n,typeName:k.ZodRecord,...S(a)}):new Ft({keyType:ee.create(),valueType:e,typeName:k.ZodRecord,...S(n)})}}class vn extends I{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:a}=this._processInputParams(e);if(a.parsedType!==y.map)return _(a,{code:m.invalid_type,expected:y.map,received:a.parsedType}),N;const r=this._def.keyType,s=this._def.valueType,o=[...a.data.entries()].map(([d,c],l)=>({key:r._parse(new ie(a,d,a.path,[l,"key"])),value:s._parse(new ie(a,c,a.path,[l,"value"]))}));if(a.common.async){const d=new Map;return Promise.resolve().then(async()=>{for(const c of o){const l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return N;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),d.set(l.value,u.value)}return{status:n.value,value:d}})}else{const d=new Map;for(const c of o){const l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return N;(l.status==="dirty"||u.status==="dirty")&&n.dirty(),d.set(l.value,u.value)}return{status:n.value,value:d}}}}vn.create=(t,e,n)=>new vn({valueType:e,keyType:t,typeName:k.ZodMap,...S(n)});class Ve extends I{_parse(e){const{status:n,ctx:a}=this._processInputParams(e);if(a.parsedType!==y.set)return _(a,{code:m.invalid_type,expected:y.set,received:a.parsedType}),N;const r=this._def;r.minSize!==null&&a.data.size<r.minSize.value&&(_(a,{code:m.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),n.dirty()),r.maxSize!==null&&a.data.size>r.maxSize.value&&(_(a,{code:m.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),n.dirty());const s=this._def.valueType;function o(c){const l=new Set;for(const u of c){if(u.status==="aborted")return N;u.status==="dirty"&&n.dirty(),l.add(u.value)}return{status:n.value,value:l}}const d=[...a.data.values()].map((c,l)=>s._parse(new ie(a,c,a.path,l)));return a.common.async?Promise.all(d).then(c=>o(c)):o(d)}min(e,n){return new Ve({...this._def,minSize:{value:e,message:b.toString(n)}})}max(e,n){return new Ve({...this._def,maxSize:{value:e,message:b.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Ve.create=(t,e)=>new Ve({valueType:t,minSize:null,maxSize:null,typeName:k.ZodSet,...S(e)});class st extends I{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.function)return _(n,{code:m.invalid_type,expected:y.function,received:n.parsedType}),N;function a(d,c){return pn({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,mn(),tt].filter(l=>!!l),issueData:{code:m.invalid_arguments,argumentsError:c}})}function r(d,c){return pn({data:d,path:n.path,errorMaps:[n.common.contextualErrorMap,n.schemaErrorMap,mn(),tt].filter(l=>!!l),issueData:{code:m.invalid_return_type,returnTypeError:c}})}const s={errorMap:n.common.contextualErrorMap},o=n.data;if(this._def.returns instanceof it){const d=this;return J(async function(...c){const l=new Q([]),u=await d._def.args.parseAsync(c,s).catch(H=>{throw l.addIssue(a(c,H)),l}),Z=await Reflect.apply(o,this,u);return await d._def.returns._def.type.parseAsync(Z,s).catch(H=>{throw l.addIssue(r(Z,H)),l})})}else{const d=this;return J(function(...c){const l=d._def.args.safeParse(c,s);if(!l.success)throw new Q([a(c,l.error)]);const u=Reflect.apply(o,this,l.data),Z=d._def.returns.safeParse(u,s);if(!Z.success)throw new Q([r(u,Z.error)]);return Z.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new st({...this._def,args:oe.create(e).rest(Fe.create())})}returns(e){return new st({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,n,a){return new st({args:e||oe.create([]).rest(Fe.create()),returns:n||Fe.create(),typeName:k.ZodFunction,...S(a)})}}class Vt extends I{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}Vt.create=(t,e)=>new Vt({getter:t,typeName:k.ZodLazy,...S(e)});class Bt extends I{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return _(n,{received:n.data,code:m.invalid_literal,expected:this._def.value}),N}return{status:"valid",value:e.data}}get value(){return this._def.value}}Bt.create=(t,e)=>new Bt({value:t,typeName:k.ZodLiteral,...S(e)});function ba(t,e){return new je({values:t,typeName:k.ZodEnum,...S(e)})}class je extends I{constructor(){super(...arguments),Pt.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),a=this._def.values;return _(n,{expected:$.joinValues(a),received:n.parsedType,code:m.invalid_type}),N}if(fn(this,Pt)||_a(this,Pt,new Set(this._def.values)),!fn(this,Pt).has(e.data)){const n=this._getOrReturnCtx(e),a=this._def.values;return _(n,{received:n.data,code:m.invalid_enum_value,options:a}),N}return J(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return je.create(e,{...this._def,...n})}exclude(e,n=this._def){return je.create(this.options.filter(a=>!e.includes(a)),{...this._def,...n})}}Pt=new WeakMap,je.create=ba;class Kt extends I{constructor(){super(...arguments),Dt.set(this,void 0)}_parse(e){const n=$.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==y.string&&a.parsedType!==y.number){const r=$.objectValues(n);return _(a,{expected:$.joinValues(r),received:a.parsedType,code:m.invalid_type}),N}if(fn(this,Dt)||_a(this,Dt,new Set($.getValidEnumValues(this._def.values))),!fn(this,Dt).has(e.data)){const r=$.objectValues(n);return _(a,{received:a.data,code:m.invalid_enum_value,options:r}),N}return J(e.data)}get enum(){return this._def.values}}Dt=new WeakMap,Kt.create=(t,e)=>new Kt({values:t,typeName:k.ZodNativeEnum,...S(e)});class it extends I{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==y.promise&&n.common.async===!1)return _(n,{code:m.invalid_type,expected:y.promise,received:n.parsedType}),N;const a=n.parsedType===y.promise?n.data:Promise.resolve(n.data);return J(a.then(r=>this._def.type.parseAsync(r,{path:n.path,errorMap:n.common.contextualErrorMap})))}}it.create=(t,e)=>new it({type:t,typeName:k.ZodPromise,...S(e)});class ne extends I{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:n,ctx:a}=this._processInputParams(e),r=this._def.effect||null,s={addIssue:o=>{_(a,o),o.fatal?n.abort():n.dirty()},get path(){return a.path}};if(s.addIssue=s.addIssue.bind(s),r.type==="preprocess"){const o=r.transform(a.data,s);if(a.common.async)return Promise.resolve(o).then(async d=>{if(n.value==="aborted")return N;const c=await this._def.schema._parseAsync({data:d,path:a.path,parent:a});return c.status==="aborted"?N:c.status==="dirty"||n.value==="dirty"?nt(c.value):c});{if(n.value==="aborted")return N;const d=this._def.schema._parseSync({data:o,path:a.path,parent:a});return d.status==="aborted"?N:d.status==="dirty"||n.value==="dirty"?nt(d.value):d}}if(r.type==="refinement"){const o=d=>{const c=r.refinement(d,s);if(a.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return d};if(a.common.async===!1){const d=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return d.status==="aborted"?N:(d.status==="dirty"&&n.dirty(),o(d.value),{status:n.value,value:d.value})}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(d=>d.status==="aborted"?N:(d.status==="dirty"&&n.dirty(),o(d.value).then(()=>({status:n.value,value:d.value}))))}if(r.type==="transform")if(a.common.async===!1){const o=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!$t(o))return o;const d=r.transform(o.value,s);if(d instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:d}}else return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(o=>$t(o)?Promise.resolve(r.transform(o.value,s)).then(d=>({status:n.value,value:d})):o);$.assertNever(r)}}ne.create=(t,e,n)=>new ne({schema:t,typeName:k.ZodEffects,effect:e,...S(n)}),ne.createWithPreprocess=(t,e,n)=>new ne({schema:e,effect:{type:"preprocess",transform:t},typeName:k.ZodEffects,...S(n)});class de extends I{_parse(e){return this._getType(e)===y.undefined?J(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}de.create=(t,e)=>new de({innerType:t,typeName:k.ZodOptional,...S(e)});class Ie extends I{_parse(e){return this._getType(e)===y.null?J(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ie.create=(t,e)=>new Ie({innerType:t,typeName:k.ZodNullable,...S(e)});class Wt extends I{_parse(e){const{ctx:n}=this._processInputParams(e);let a=n.data;return n.parsedType===y.undefined&&(a=this._def.defaultValue()),this._def.innerType._parse({data:a,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}Wt.create=(t,e)=>new Wt({innerType:t,typeName:k.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...S(e)});class Jt extends I{_parse(e){const{ctx:n}=this._processInputParams(e),a={...n,common:{...n.common,issues:[]}},r=this._def.innerType._parse({data:a.data,path:a.path,parent:{...a}});return At(r)?r.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Q(a.common.issues)},input:a.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new Q(a.common.issues)},input:a.data})}}removeCatch(){return this._def.innerType}}Jt.create=(t,e)=>new Jt({innerType:t,typeName:k.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...S(e)});class wn extends I{_parse(e){if(this._getType(e)!==y.nan){const a=this._getOrReturnCtx(e);return _(a,{code:m.invalid_type,expected:y.nan,received:a.parsedType}),N}return{status:"valid",value:e.data}}}wn.create=t=>new wn({typeName:k.ZodNaN,...S(t)});const zi=Symbol("zod_brand");class Rn extends I{_parse(e){const{ctx:n}=this._processInputParams(e),a=n.data;return this._def.type._parse({data:a,path:n.path,parent:n})}unwrap(){return this._def.type}}class qt extends I{_parse(e){const{status:n,ctx:a}=this._processInputParams(e);if(a.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:a.data,path:a.path,parent:a});return s.status==="aborted"?N:s.status==="dirty"?(n.dirty(),nt(s.value)):this._def.out._parseAsync({data:s.value,path:a.path,parent:a})})();{const r=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return r.status==="aborted"?N:r.status==="dirty"?(n.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:a.path,parent:a})}}static create(e,n){return new qt({in:e,out:n,typeName:k.ZodPipeline})}}class Qt extends I{_parse(e){const n=this._def.innerType._parse(e),a=r=>($t(r)&&(r.value=Object.freeze(r.value)),r);return At(n)?n.then(r=>a(r)):a(n)}unwrap(){return this._def.innerType}}Qt.create=(t,e)=>new Qt({innerType:t,typeName:k.ZodReadonly,...S(e)});function xa(t,e={},n){return t?at.create().superRefine((a,r)=>{var s,o;if(!t(a)){const d=typeof e=="function"?e(a):typeof e=="string"?{message:e}:e,c=(o=(s=d.fatal)!==null&&s!==void 0?s:n)!==null&&o!==void 0?o:!0,l=typeof d=="string"?{message:d}:d;r.addIssue({code:"custom",...l,fatal:c})}}):at.create()}const Ui={object:L.lazycreate};var k;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(k||(k={}));const Fi=(t,e={message:`Input not instance of ${t.name}`})=>xa(n=>n instanceof t,e),ka=ee.create,Na=Oe.create,Vi=wn.create,Bi=Se.create,Ta=Rt.create,Ki=Ue.create,Wi=_n.create,Ji=Mt.create,qi=Lt.create,Qi=at.create,Hi=Fe.create,Gi=pe.create,Yi=gn.create,Xi=te.create,eo=L.create,to=L.strictCreate,no=zt.create,ao=yn.create,ro=Ut.create,so=oe.create,io=Ft.create,oo=vn.create,co=Ve.create,lo=st.create,uo=Vt.create,ho=Bt.create,mo=je.create,po=Kt.create,fo=it.create,Ca=ne.create,_o=de.create,go=Ie.create,yo=ne.createWithPreprocess,vo=qt.create;var wo=Object.freeze({__proto__:null,defaultErrorMap:tt,setErrorMap:ki,getErrorMap:mn,makeIssue:pn,EMPTY_PATH:Ni,addIssueToContext:_,ParseStatus:K,INVALID:N,DIRTY:nt,OK:J,isAborted:$n,isDirty:An,isValid:$t,isAsync:At,get util(){return $},get objectUtil(){return En},ZodParsedType:y,getParsedType:Ce,ZodType:I,datetimeRegex:wa,ZodString:ee,ZodNumber:Oe,ZodBigInt:Se,ZodBoolean:Rt,ZodDate:Ue,ZodSymbol:_n,ZodUndefined:Mt,ZodNull:Lt,ZodAny:at,ZodUnknown:Fe,ZodNever:pe,ZodVoid:gn,ZodArray:te,ZodObject:L,ZodUnion:zt,ZodDiscriminatedUnion:yn,ZodIntersection:Ut,ZodTuple:oe,ZodRecord:Ft,ZodMap:vn,ZodSet:Ve,ZodFunction:st,ZodLazy:Vt,ZodLiteral:Bt,ZodEnum:je,ZodNativeEnum:Kt,ZodPromise:it,ZodEffects:ne,ZodTransformer:ne,ZodOptional:de,ZodNullable:Ie,ZodDefault:Wt,ZodCatch:Jt,ZodNaN:wn,BRAND:zi,ZodBranded:Rn,ZodPipeline:qt,ZodReadonly:Qt,custom:xa,Schema:I,ZodSchema:I,late:Ui,get ZodFirstPartyTypeKind(){return k},coerce:{string:t=>ee.create({...t,coerce:!0}),number:t=>Oe.create({...t,coerce:!0}),boolean:t=>Rt.create({...t,coerce:!0}),bigint:t=>Se.create({...t,coerce:!0}),date:t=>Ue.create({...t,coerce:!0})},any:Qi,array:Xi,bigint:Bi,boolean:Ta,date:Ki,discriminatedUnion:ao,effect:Ca,enum:mo,function:lo,instanceof:Fi,intersection:ro,lazy:uo,literal:ho,map:oo,nan:Vi,nativeEnum:po,never:Gi,null:qi,nullable:go,number:Na,object:eo,oboolean:()=>Ta().optional(),onumber:()=>Na().optional(),optional:_o,ostring:()=>ka().optional(),pipeline:vo,preprocess:yo,promise:fo,record:io,set:co,strictObject:to,string:ka,symbol:Wi,transformer:Ca,tuple:so,undefined:Ji,union:no,unknown:Hi,void:Yi,NEVER:N,ZodIssueCode:m,quotelessJson:xi,ZodError:Q});bi(wo);function Ht(t,e="",n={}){for(let a in t)if(Object.prototype.hasOwnProperty.call(t,a)){const r=e?`${e}_${a}`:a;typeof t[a]=="object"&&t[a]!==null&&!Array.isArray(t[a])?Ht(t[a],r,n):n[r]=t[a]}return n}function Oa(t,e){const n={};for(const[a,r]of Object.entries(t)){const s=e.find(o=>a.startsWith(`${o}_`));if(!s)n[a]=r;else{const o=a.slice(s.length+1);n[s]={...n[s],[o]:r}}}return n}function bo(t){return async(e,n)=>{let a=t.selectFrom("connections").where("connections.tenant_id","=",e);n.q&&(a=Le(t,a,n.q,["user_id","ip"]));const s=await a.offset(n.page*n.per_page).limit(n.per_page).selectAll().execute(),{count:o}=await a.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{connections:s.map(d=>R(Oa(d,["options"]))),start:n.page*n.per_page,limit:n.per_page,length:Te(o)}}}function xo(t){return async(e,n)=>(await t.deleteFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",n).executeTakeFirst()).numDeletedRows>0}function ko(t){return async(e,n)=>{const a=await t.selectFrom("connections").where("connections.tenant_id","=",e).where("connections.id","=",n).selectAll().executeTakeFirst();return a?R({...a,options:JSON.parse(a.options)}):null}}function No(t){return async(e,n,a)=>{const r={...a,updated_at:new Date().toISOString()};return await t.updateTable("connections").set({...r,options:r.options?JSON.stringify(r.options):void 0}).where("connections.id","=",n).where("connections.tenant_id","=",e).execute(),!0}}function To(t){return{create:yi(t),get:ko(t),list:bo(t),remove:xo(t),update:No(t)}}function Co(t){return{get:async e=>{const n=await t.selectFrom("applications").selectAll().where("id","=",e).executeTakeFirst();if(!n)return null;const a=await t.selectFrom("tenants").selectAll().where("id","=",n.tenant_id).executeTakeFirst();if(!a)throw new P(404,{message:"Tenant not found"});const r=await t.selectFrom("connections").where("tenant_id","=",n.tenant_id).selectAll().execute(),s=await t.selectFrom("domains").where("tenant_id","=",n.tenant_id).selectAll().execute();return{...n,connections:r.map(d=>ca.parse(R({...d,options:d.options?JSON.parse(d.options):{}}))),domains:s,addons:n.addons?JSON.parse(n.addons):{},callbacks:n.callbacks?JSON.parse(n.callbacks):[],allowed_origins:n.allowed_origins?JSON.parse(n.allowed_origins):[],web_origins:n.web_origins?JSON.parse(n.web_origins):[],allowed_logout_urls:n.allowed_logout_urls?JSON.parse(n.allowed_logout_urls):[],allowed_clients:n.allowed_clients?JSON.parse(n.allowed_clients):[],tenant:R(a),disable_sign_ups:!!n.disable_sign_ups}}}}function Oo(t){return async()=>await t.selectFrom("keys").where("revoked_at","is",null).selectAll().execute()}function So(t){return async e=>{await t.insertInto("keys").values({...e,created_at:new Date().toDateString()}).execute()}}function jo(t){return async(e,n)=>!!(await t.updateTable("keys").set(n).where("kid","=",e).execute()).length}function Io(t){return{create:So(t),list:Oo(t),update:jo(t)}}function Zo(t){return async(e,n)=>{const a={created_at:new Date().toISOString(),updated_at:new Date().toISOString(),tenant_id:e,id:ze(),...n};return await t.insertInto("domains").values(a).execute(),a}}function Eo(t){return async(e,n)=>{let a=t.selectFrom("domains").where("domains.tenant_id","=",e);n.q&&(a=Le(t,a,n.q,["user_id","ip"]));const s=await a.offset(n.page*n.per_page).limit(n.per_page).selectAll().execute(),{count:o}=await a.select(d=>d.fn.countAll().as("count")).executeTakeFirstOrThrow();return{domains:s,start:n.page*n.per_page,limit:n.per_page,length:Te(o)}}}function $o(t){return{create:Zo(t),list:Eo(t)}}function Ao(t){return async e=>{const[n]=await t.selectFrom("branding").where("branding.tenant_id","=",e).selectAll().execute();if(!n)return null;const{tenant_id:a,colors_primary:r,colors_page_background_type:s,colors_page_background_start:o,colors_page_background_end:d,colors_page_background_angle_dev:c,font_url:l,...u}=n;return R({...u,colors:{primary:r,page_background:{type:s,start:o,end:d,angle_deg:c}},font:l?{url:l}:void 0})}}function Po(t){return async(e,n)=>{var o,d,c,l,u,Z,z,H,Ze,dt,Ee,$e,Ae,ct,lt,ce,le,ue;const{colors:a,font:r,...s}=n;try{await t.insertInto("branding").values({...s,colors_primary:a==null?void 0:a.primary,colors_page_background_type:(d=(o=n.colors)==null?void 0:o.page_background)==null?void 0:d.type,colors_page_background_start:(l=(c=n.colors)==null?void 0:c.page_background)==null?void 0:l.start,colors_page_background_end:(Z=(u=n.colors)==null?void 0:u.page_background)==null?void 0:Z.end,colors_page_background_angle_dev:(H=(z=n.colors)==null?void 0:z.page_background)==null?void 0:H.angle_deg,font_url:(Ze=n.font)==null?void 0:Ze.url,tenant_id:e}).execute()}catch{await t.updateTable("branding").set({...s,colors_primary:a==null?void 0:a.primary,colors_page_background_type:(Ee=(dt=n.colors)==null?void 0:dt.page_background)==null?void 0:Ee.type,colors_page_background_start:(Ae=($e=n.colors)==null?void 0:$e.page_background)==null?void 0:Ae.start,colors_page_background_end:(lt=(ct=n.colors)==null?void 0:ct.page_background)==null?void 0:lt.end,colors_page_background_angle_dev:(le=(ce=n.colors)==null?void 0:ce.page_background)==null?void 0:le.angle_deg,font_url:(ue=n.font)==null?void 0:ue.url}).where("tenant_id","=",e).execute()}}}function Do(t){return{get:Ao(t),set:Po(t)}}function Ro(t){return async(e,n)=>{let a=t.selectFrom("hooks").where("hooks.tenant_id","=",e);n.q&&(a=Le(t,a,n.q,["url"]));const s=await a.offset(n.page*n.per_page).limit(n.per_page).selectAll().execute(),{count:o}=await a.select(c=>c.fn.countAll().as("count")).executeTakeFirstOrThrow();return{hooks:s.map(c=>{const{tenant_id:l,enabled:u,synchronous:Z,...z}=c;return R({...z,enabled:!!u,synchronous:!!Z})}),start:n.page*n.per_page,limit:n.per_page,length:Te(o)}}}function Mo(t){return async(e,n)=>{const a=await t.selectFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",n).selectAll().executeTakeFirst();return a?(a.enabled=!!a.enabled,a.synchronous=!!a.synchronous,R(a)):null}}function Lo(t){return async(e,n)=>(await t.deleteFrom("hooks").where("hooks.tenant_id","=",e).where("hooks.hook_id","=",n).executeTakeFirst()).numDeletedRows>0}function zo(t){return async(e,n)=>{const a={hook_id:ze(),...n,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await t.insertInto("hooks").values({...a,tenant_id:e}).execute(),a}}function Uo(t){return async(e,n,a)=>{const r={...a,updated_at:new Date().toISOString()};return await t.updateTable("hooks").set(r).where("hooks.hook_id","=",n).where("hooks.tenant_id","=",e).execute(),!0}}function Fo(t){return{create:zo(t),get:Mo(t),list:Ro(t),update:Uo(t),remove:Lo(t)}}function Vo(t){return async(e,n)=>{const a={themeId:ze(),...n,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await t.insertInto("themes").values({...Ht(a),tenant_id:e}).execute(),a}}function Bo(t){return async(e,n)=>(await t.deleteFrom("themes").where("themes.tenant_id","=",e).where("themes.theme_id","=",n).executeTakeFirst()).numDeletedRows>0}function Ko(t){return async(e,n)=>{const a=await t.selectFrom("themes").where("themes.tenant_id","=",e).where("themes.theme_id","=",n).selectAll().executeTakeFirst();return a?R(a):null}}function Wo(t){return async(e,n,a)=>{const r=Ht({...a,updated_at:new Date().toISOString()});return await t.updateTable("themes").set(r).where("themes.id","=",n).where("themes.tenant_id","=",e).execute(),!0}}function Jo(t){return{create:Vo(t),get:Ko(t),remove:Bo(t),update:Wo(t)}}function qo(t){return async(e,n)=>{const a=new Date().toISOString(),r=await t.selectFrom("logins").where("logins.expires_at",">",a).where("logins.login_id","=",n).selectAll().executeTakeFirst();return r?gs.parse(Oa(R(r),["authParams"])):null}}function Qo(t){return async(e,n)=>{const a={login_id:ze(),...n,created_at:new Date().toISOString(),updated_at:new Date().toISOString()};return await t.insertInto("logins").values({...Ht(a),tenant_id:e}).execute(),a}}function Ho(t){return async(e,n,a)=>(await t.updateTable("logins").set(Ht(a)).where("logins.login_id","=",n).where("logins.tenant_id","=",e).execute()).length===1}function Go(t){return async(e,n)=>(await t.deleteFrom("logins").where("logins.tenant_id","=",e).where("logins.login_id","=",n).execute()).length>0}function Yo(t){return{create:Qo(t),get:qo(t),update:Ho(t),remove:Go(t)}}function Xo(t){return async e=>{const[n]=await t.selectFrom("prompt_settings").where("prompt_settings.tenant_id","=",e).selectAll().execute();return R({identifier_first:!!(n!=null&&n.identifier_first),password_first:!!(n!=null&&n.password_first),webauthn_platform_first_factor:!!(n!=null&&n.webauthn_platform_first_factor),universal_login_experience:(n==null?void 0:n.universal_login_experience)||"new"})}}function Sa(t){return R({...t,webauthn_platform_first_factor:t.webauthn_platform_first_factor?!!t.webauthn_platform_first_factor:void 0,identifier_first:t.identifier_first?!!t.identifier_first:void 0,password_first:t.password_first?!!t.password_first:void 0,universal_login_experience:t.universal_login_experience})}function ed(t){return async(e,n)=>{try{const a=Os.parse(n);await t.insertInto("prompt_settings").values({...Sa(a),tenant_id:e}).execute()}catch{await t.updateTable("prompt_settings").set(Sa(n)).where("tenant_id","=",e).execute()}}}function td(t){return{get:Xo(t),set:ed(t)}}function nd(t){return t[t.length-1]}function F(t){return Object.freeze(t)}const bn=F({is(t){return t.kind==="IdentifierNode"},create(t){return F({kind:"IdentifierNode",name:t})}}),Mn=F({is(t){return t.kind==="SchemableIdentifierNode"},create(t){return F({kind:"SchemableIdentifierNode",identifier:bn.create(t)})},createWithSchema(t,e){return F({kind:"SchemableIdentifierNode",schema:bn.create(t),identifier:bn.create(e)})}}),ad=F({is(t){return t.kind==="AliasNode"},create(t,e){return F({kind:"AliasNode",node:t,alias:e})}}),Ln=F({is(t){return t.kind==="TableNode"},create(t){return F({kind:"TableNode",table:Mn.create(t)})},createWithSchema(t,e){return F({kind:"TableNode",table:Mn.createWithSchema(t,e)})}});function th(t){return t}class rd{constructor(){Xt(this,"nodeStack",[]);he(this,xn,F({AliasNode:this.transformAlias.bind(this),ColumnNode:this.transformColumn.bind(this),IdentifierNode:this.transformIdentifier.bind(this),SchemableIdentifierNode:this.transformSchemableIdentifier.bind(this),RawNode:this.transformRaw.bind(this),ReferenceNode:this.transformReference.bind(this),SelectQueryNode:this.transformSelectQuery.bind(this),SelectionNode:this.transformSelection.bind(this),TableNode:this.transformTable.bind(this),FromNode:this.transformFrom.bind(this),SelectAllNode:this.transformSelectAll.bind(this),AndNode:this.transformAnd.bind(this),OrNode:this.transformOr.bind(this),ValueNode:this.transformValue.bind(this),ValueListNode:this.transformValueList.bind(this),PrimitiveValueListNode:this.transformPrimitiveValueList.bind(this),ParensNode:this.transformParens.bind(this),JoinNode:this.transformJoin.bind(this),OperatorNode:this.transformOperator.bind(this),WhereNode:this.transformWhere.bind(this),InsertQueryNode:this.transformInsertQuery.bind(this),DeleteQueryNode:this.transformDeleteQuery.bind(this),ReturningNode:this.transformReturning.bind(this),CreateTableNode:this.transformCreateTable.bind(this),AddColumnNode:this.transformAddColumn.bind(this),ColumnDefinitionNode:this.transformColumnDefinition.bind(this),DropTableNode:this.transformDropTable.bind(this),DataTypeNode:this.transformDataType.bind(this),OrderByNode:this.transformOrderBy.bind(this),OrderByItemNode:this.transformOrderByItem.bind(this),GroupByNode:this.transformGroupBy.bind(this),GroupByItemNode:this.transformGroupByItem.bind(this),UpdateQueryNode:this.transformUpdateQuery.bind(this),ColumnUpdateNode:this.transformColumnUpdate.bind(this),LimitNode:this.transformLimit.bind(this),OffsetNode:this.transformOffset.bind(this),OnConflictNode:this.transformOnConflict.bind(this),OnDuplicateKeyNode:this.transformOnDuplicateKey.bind(this),CreateIndexNode:this.transformCreateIndex.bind(this),DropIndexNode:this.transformDropIndex.bind(this),ListNode:this.transformList.bind(this),PrimaryKeyConstraintNode:this.transformPrimaryKeyConstraint.bind(this),UniqueConstraintNode:this.transformUniqueConstraint.bind(this),ReferencesNode:this.transformReferences.bind(this),CheckConstraintNode:this.transformCheckConstraint.bind(this),WithNode:this.transformWith.bind(this),CommonTableExpressionNode:this.transformCommonTableExpression.bind(this),CommonTableExpressionNameNode:this.transformCommonTableExpressionName.bind(this),HavingNode:this.transformHaving.bind(this),CreateSchemaNode:this.transformCreateSchema.bind(this),DropSchemaNode:this.transformDropSchema.bind(this),AlterTableNode:this.transformAlterTable.bind(this),DropColumnNode:this.transformDropColumn.bind(this),RenameColumnNode:this.transformRenameColumn.bind(this),AlterColumnNode:this.transformAlterColumn.bind(this),ModifyColumnNode:this.transformModifyColumn.bind(this),AddConstraintNode:this.transformAddConstraint.bind(this),DropConstraintNode:this.transformDropConstraint.bind(this),ForeignKeyConstraintNode:this.transformForeignKeyConstraint.bind(this),CreateViewNode:this.transformCreateView.bind(this),DropViewNode:this.transformDropView.bind(this),GeneratedNode:this.transformGenerated.bind(this),DefaultValueNode:this.transformDefaultValue.bind(this),OnNode:this.transformOn.bind(this),ValuesNode:this.transformValues.bind(this),SelectModifierNode:this.transformSelectModifier.bind(this),CreateTypeNode:this.transformCreateType.bind(this),DropTypeNode:this.transformDropType.bind(this),ExplainNode:this.transformExplain.bind(this),DefaultInsertValueNode:this.transformDefaultInsertValue.bind(this),AggregateFunctionNode:this.transformAggregateFunction.bind(this),OverNode:this.transformOver.bind(this),PartitionByNode:this.transformPartitionBy.bind(this),PartitionByItemNode:this.transformPartitionByItem.bind(this),SetOperationNode:this.transformSetOperation.bind(this),BinaryOperationNode:this.transformBinaryOperation.bind(this),UnaryOperationNode:this.transformUnaryOperation.bind(this),UsingNode:this.transformUsing.bind(this),FunctionNode:this.transformFunction.bind(this),CaseNode:this.transformCase.bind(this),WhenNode:this.transformWhen.bind(this),JSONReferenceNode:this.transformJSONReference.bind(this),JSONPathNode:this.transformJSONPath.bind(this),JSONPathLegNode:this.transformJSONPathLeg.bind(this),JSONOperatorChainNode:this.transformJSONOperatorChain.bind(this),TupleNode:this.transformTuple.bind(this),MergeQueryNode:this.transformMergeQuery.bind(this),MatchedNode:this.transformMatched.bind(this),AddIndexNode:this.transformAddIndex.bind(this),CastNode:this.transformCast.bind(this),FetchNode:this.transformFetch.bind(this),TopNode:this.transformTop.bind(this),OutputNode:this.transformOutput.bind(this)}))}transformNode(e){if(!e)return e;this.nodeStack.push(e);const n=this.transformNodeImpl(e);return this.nodeStack.pop(),F(n)}transformNodeImpl(e){return v(this,xn)[e.kind](e)}transformNodeList(e){return e&&F(e.map(n=>this.transformNode(n)))}transformSelectQuery(e){return{kind:"SelectQueryNode",from:this.transformNode(e.from),selections:this.transformNodeList(e.selections),distinctOn:this.transformNodeList(e.distinctOn),joins:this.transformNodeList(e.joins),groupBy:this.transformNode(e.groupBy),orderBy:this.transformNode(e.orderBy),where:this.transformNode(e.where),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),limit:this.transformNode(e.limit),offset:this.transformNode(e.offset),with:this.transformNode(e.with),having:this.transformNode(e.having),explain:this.transformNode(e.explain),setOperations:this.transformNodeList(e.setOperations),fetch:this.transformNode(e.fetch),top:this.transformNode(e.top)}}transformSelection(e){return{kind:"SelectionNode",selection:this.transformNode(e.selection)}}transformColumn(e){return{kind:"ColumnNode",column:this.transformNode(e.column)}}transformAlias(e){return{kind:"AliasNode",node:this.transformNode(e.node),alias:this.transformNode(e.alias)}}transformTable(e){return{kind:"TableNode",table:this.transformNode(e.table)}}transformFrom(e){return{kind:"FromNode",froms:this.transformNodeList(e.froms)}}transformReference(e){return{kind:"ReferenceNode",column:this.transformNode(e.column),table:this.transformNode(e.table)}}transformAnd(e){return{kind:"AndNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformOr(e){return{kind:"OrNode",left:this.transformNode(e.left),right:this.transformNode(e.right)}}transformValueList(e){return{kind:"ValueListNode",values:this.transformNodeList(e.values)}}transformParens(e){return{kind:"ParensNode",node:this.transformNode(e.node)}}transformJoin(e){return{kind:"JoinNode",joinType:e.joinType,table:this.transformNode(e.table),on:this.transformNode(e.on)}}transformRaw(e){return{kind:"RawNode",sqlFragments:F([...e.sqlFragments]),parameters:this.transformNodeList(e.parameters)}}transformWhere(e){return{kind:"WhereNode",where:this.transformNode(e.where)}}transformInsertQuery(e){return{kind:"InsertQueryNode",into:this.transformNode(e.into),columns:this.transformNodeList(e.columns),values:this.transformNode(e.values),returning:this.transformNode(e.returning),onConflict:this.transformNode(e.onConflict),onDuplicateKey:this.transformNode(e.onDuplicateKey),with:this.transformNode(e.with),ignore:e.ignore,replace:e.replace,explain:this.transformNode(e.explain),defaultValues:e.defaultValues,top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformValues(e){return{kind:"ValuesNode",values:this.transformNodeList(e.values)}}transformDeleteQuery(e){return{kind:"DeleteQueryNode",from:this.transformNode(e.from),using:this.transformNode(e.using),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),returning:this.transformNode(e.returning),with:this.transformNode(e.with),orderBy:this.transformNode(e.orderBy),limit:this.transformNode(e.limit),explain:this.transformNode(e.explain),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformReturning(e){return{kind:"ReturningNode",selections:this.transformNodeList(e.selections)}}transformCreateTable(e){return{kind:"CreateTableNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),constraints:this.transformNodeList(e.constraints),temporary:e.temporary,ifNotExists:e.ifNotExists,onCommit:e.onCommit,frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),selectQuery:this.transformNode(e.selectQuery)}}transformColumnDefinition(e){return{kind:"ColumnDefinitionNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),references:this.transformNode(e.references),primaryKey:e.primaryKey,autoIncrement:e.autoIncrement,unique:e.unique,notNull:e.notNull,unsigned:e.unsigned,defaultTo:this.transformNode(e.defaultTo),check:this.transformNode(e.check),generated:this.transformNode(e.generated),frontModifiers:this.transformNodeList(e.frontModifiers),endModifiers:this.transformNodeList(e.endModifiers),nullsNotDistinct:e.nullsNotDistinct,identity:e.identity,ifNotExists:e.ifNotExists}}transformAddColumn(e){return{kind:"AddColumnNode",column:this.transformNode(e.column)}}transformDropTable(e){return{kind:"DropTableNode",table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformOrderBy(e){return{kind:"OrderByNode",items:this.transformNodeList(e.items)}}transformOrderByItem(e){return{kind:"OrderByItemNode",orderBy:this.transformNode(e.orderBy),direction:this.transformNode(e.direction)}}transformGroupBy(e){return{kind:"GroupByNode",items:this.transformNodeList(e.items)}}transformGroupByItem(e){return{kind:"GroupByItemNode",groupBy:this.transformNode(e.groupBy)}}transformUpdateQuery(e){return{kind:"UpdateQueryNode",table:this.transformNode(e.table),from:this.transformNode(e.from),joins:this.transformNodeList(e.joins),where:this.transformNode(e.where),updates:this.transformNodeList(e.updates),returning:this.transformNode(e.returning),with:this.transformNode(e.with),explain:this.transformNode(e.explain),limit:this.transformNode(e.limit),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformColumnUpdate(e){return{kind:"ColumnUpdateNode",column:this.transformNode(e.column),value:this.transformNode(e.value)}}transformLimit(e){return{kind:"LimitNode",limit:this.transformNode(e.limit)}}transformOffset(e){return{kind:"OffsetNode",offset:this.transformNode(e.offset)}}transformOnConflict(e){return{kind:"OnConflictNode",columns:this.transformNodeList(e.columns),constraint:this.transformNode(e.constraint),indexExpression:this.transformNode(e.indexExpression),indexWhere:this.transformNode(e.indexWhere),updates:this.transformNodeList(e.updates),updateWhere:this.transformNode(e.updateWhere),doNothing:e.doNothing}}transformOnDuplicateKey(e){return{kind:"OnDuplicateKeyNode",updates:this.transformNodeList(e.updates)}}transformCreateIndex(e){return{kind:"CreateIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists,where:this.transformNode(e.where),nullsNotDistinct:e.nullsNotDistinct}}transformList(e){return{kind:"ListNode",items:this.transformNodeList(e.items)}}transformDropIndex(e){return{kind:"DropIndexNode",name:this.transformNode(e.name),table:this.transformNode(e.table),ifExists:e.ifExists,cascade:e.cascade}}transformPrimaryKeyConstraint(e){return{kind:"PrimaryKeyConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name)}}transformUniqueConstraint(e){return{kind:"UniqueConstraintNode",columns:this.transformNodeList(e.columns),name:this.transformNode(e.name),nullsNotDistinct:e.nullsNotDistinct}}transformForeignKeyConstraint(e){return{kind:"ForeignKeyConstraintNode",columns:this.transformNodeList(e.columns),references:this.transformNode(e.references),name:this.transformNode(e.name),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformSetOperation(e){return{kind:"SetOperationNode",operator:e.operator,expression:this.transformNode(e.expression),all:e.all}}transformReferences(e){return{kind:"ReferencesNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns),onDelete:e.onDelete,onUpdate:e.onUpdate}}transformCheckConstraint(e){return{kind:"CheckConstraintNode",expression:this.transformNode(e.expression),name:this.transformNode(e.name)}}transformWith(e){return{kind:"WithNode",expressions:this.transformNodeList(e.expressions),recursive:e.recursive}}transformCommonTableExpression(e){return{kind:"CommonTableExpressionNode",name:this.transformNode(e.name),materialized:e.materialized,expression:this.transformNode(e.expression)}}transformCommonTableExpressionName(e){return{kind:"CommonTableExpressionNameNode",table:this.transformNode(e.table),columns:this.transformNodeList(e.columns)}}transformHaving(e){return{kind:"HavingNode",having:this.transformNode(e.having)}}transformCreateSchema(e){return{kind:"CreateSchemaNode",schema:this.transformNode(e.schema),ifNotExists:e.ifNotExists}}transformDropSchema(e){return{kind:"DropSchemaNode",schema:this.transformNode(e.schema),ifExists:e.ifExists,cascade:e.cascade}}transformAlterTable(e){return{kind:"AlterTableNode",table:this.transformNode(e.table),renameTo:this.transformNode(e.renameTo),setSchema:this.transformNode(e.setSchema),columnAlterations:this.transformNodeList(e.columnAlterations),addConstraint:this.transformNode(e.addConstraint),dropConstraint:this.transformNode(e.dropConstraint),addIndex:this.transformNode(e.addIndex),dropIndex:this.transformNode(e.dropIndex)}}transformDropColumn(e){return{kind:"DropColumnNode",column:this.transformNode(e.column)}}transformRenameColumn(e){return{kind:"RenameColumnNode",column:this.transformNode(e.column),renameTo:this.transformNode(e.renameTo)}}transformAlterColumn(e){return{kind:"AlterColumnNode",column:this.transformNode(e.column),dataType:this.transformNode(e.dataType),dataTypeExpression:this.transformNode(e.dataTypeExpression),setDefault:this.transformNode(e.setDefault),dropDefault:e.dropDefault,setNotNull:e.setNotNull,dropNotNull:e.dropNotNull}}transformModifyColumn(e){return{kind:"ModifyColumnNode",column:this.transformNode(e.column)}}transformAddConstraint(e){return{kind:"AddConstraintNode",constraint:this.transformNode(e.constraint)}}transformDropConstraint(e){return{kind:"DropConstraintNode",constraintName:this.transformNode(e.constraintName),ifExists:e.ifExists,modifier:e.modifier}}transformCreateView(e){return{kind:"CreateViewNode",name:this.transformNode(e.name),temporary:e.temporary,orReplace:e.orReplace,ifNotExists:e.ifNotExists,materialized:e.materialized,columns:this.transformNodeList(e.columns),as:this.transformNode(e.as)}}transformDropView(e){return{kind:"DropViewNode",name:this.transformNode(e.name),ifExists:e.ifExists,materialized:e.materialized,cascade:e.cascade}}transformGenerated(e){return{kind:"GeneratedNode",byDefault:e.byDefault,always:e.always,identity:e.identity,stored:e.stored,expression:this.transformNode(e.expression)}}transformDefaultValue(e){return{kind:"DefaultValueNode",defaultValue:this.transformNode(e.defaultValue)}}transformOn(e){return{kind:"OnNode",on:this.transformNode(e.on)}}transformSelectModifier(e){return{kind:"SelectModifierNode",modifier:e.modifier,rawModifier:this.transformNode(e.rawModifier),of:this.transformNodeList(e.of)}}transformCreateType(e){return{kind:"CreateTypeNode",name:this.transformNode(e.name),enum:this.transformNode(e.enum)}}transformDropType(e){return{kind:"DropTypeNode",name:this.transformNode(e.name),ifExists:e.ifExists}}transformExplain(e){return{kind:"ExplainNode",format:e.format,options:this.transformNode(e.options)}}transformSchemableIdentifier(e){return{kind:"SchemableIdentifierNode",schema:this.transformNode(e.schema),identifier:this.transformNode(e.identifier)}}transformAggregateFunction(e){return{kind:"AggregateFunctionNode",aggregated:this.transformNodeList(e.aggregated),distinct:e.distinct,filter:this.transformNode(e.filter),func:e.func,over:this.transformNode(e.over)}}transformOver(e){return{kind:"OverNode",orderBy:this.transformNode(e.orderBy),partitionBy:this.transformNode(e.partitionBy)}}transformPartitionBy(e){return{kind:"PartitionByNode",items:this.transformNodeList(e.items)}}transformPartitionByItem(e){return{kind:"PartitionByItemNode",partitionBy:this.transformNode(e.partitionBy)}}transformBinaryOperation(e){return{kind:"BinaryOperationNode",leftOperand:this.transformNode(e.leftOperand),operator:this.transformNode(e.operator),rightOperand:this.transformNode(e.rightOperand)}}transformUnaryOperation(e){return{kind:"UnaryOperationNode",operator:this.transformNode(e.operator),operand:this.transformNode(e.operand)}}transformUsing(e){return{kind:"UsingNode",tables:this.transformNodeList(e.tables)}}transformFunction(e){return{kind:"FunctionNode",func:e.func,arguments:this.transformNodeList(e.arguments)}}transformCase(e){return{kind:"CaseNode",value:this.transformNode(e.value),when:this.transformNodeList(e.when),else:this.transformNode(e.else),isStatement:e.isStatement}}transformWhen(e){return{kind:"WhenNode",condition:this.transformNode(e.condition),result:this.transformNode(e.result)}}transformJSONReference(e){return{kind:"JSONReferenceNode",reference:this.transformNode(e.reference),traversal:this.transformNode(e.traversal)}}transformJSONPath(e){return{kind:"JSONPathNode",inOperator:this.transformNode(e.inOperator),pathLegs:this.transformNodeList(e.pathLegs)}}transformJSONPathLeg(e){return{kind:"JSONPathLegNode",type:e.type,value:e.value}}transformJSONOperatorChain(e){return{kind:"JSONOperatorChainNode",operator:this.transformNode(e.operator),values:this.transformNodeList(e.values)}}transformTuple(e){return{kind:"TupleNode",values:this.transformNodeList(e.values)}}transformMergeQuery(e){return{kind:"MergeQueryNode",into:this.transformNode(e.into),using:this.transformNode(e.using),whens:this.transformNodeList(e.whens),with:this.transformNode(e.with),top:this.transformNode(e.top),output:this.transformNode(e.output)}}transformMatched(e){return{kind:"MatchedNode",not:e.not,bySource:e.bySource}}transformAddIndex(e){return{kind:"AddIndexNode",name:this.transformNode(e.name),columns:this.transformNodeList(e.columns),unique:e.unique,using:this.transformNode(e.using),ifNotExists:e.ifNotExists}}transformCast(e){return{kind:"CastNode",expression:this.transformNode(e.expression),dataType:this.transformNode(e.dataType)}}transformFetch(e){return{kind:"FetchNode",rowCount:this.transformNode(e.rowCount),modifier:e.modifier}}transformTop(e){return{kind:"TopNode",expression:e.expression,modifiers:e.modifiers}}transformOutput(e){return{kind:"OutputNode",selections:this.transformNodeList(e.selections)}}transformDataType(e){return e}transformSelectAll(e){return e}transformIdentifier(e){return e}transformValue(e){return e}transformPrimitiveValueList(e){return e}transformOperator(e){return e}transformDefaultInsertValue(e){return e}}xn=new WeakMap;const sd=F({AlterTableNode:!0,CreateIndexNode:!0,CreateSchemaNode:!0,CreateTableNode:!0,CreateTypeNode:!0,CreateViewNode:!0,DeleteQueryNode:!0,DropIndexNode:!0,DropSchemaNode:!0,DropTableNode:!0,DropTypeNode:!0,DropViewNode:!0,InsertQueryNode:!0,RawNode:!0,SelectQueryNode:!0,UpdateQueryNode:!0,MergeQueryNode:!0});class id extends rd{constructor(n){super();he(this,V);he(this,ot);he(this,Be,new Set);he(this,Ke,new Set);en(this,ot,n)}transformNodeImpl(n){if(!C(this,V,Aa).call(this,n))return super.transformNodeImpl(n);const a=C(this,V,Da).call(this,n);for(const o of a)v(this,Ke).add(o);const r=C(this,V,Pa).call(this,n);for(const o of r)v(this,Be).add(o);const s=super.transformNodeImpl(n);for(const o of r)v(this,Be).delete(o);for(const o of a)v(this,Ke).delete(o);return s}transformSchemableIdentifier(n){const a=super.transformSchemableIdentifier(n);return a.schema||!v(this,Be).has(n.identifier.name)?a:{...a,schema:bn.create(v(this,ot))}}transformReferences(n){const a=super.transformReferences(n);return a.table.table.schema?a:{...a,table:Ln.createWithSchema(v(this,ot),a.table.table.identifier.name)}}}ot=new WeakMap,Be=new WeakMap,Ke=new WeakMap,V=new WeakSet,Aa=function(n){return n.kind in sd},Pa=function(n){const a=new Set;if("name"in n&&n.name&&Mn.is(n.name)&&C(this,V,Vn).call(this,n.name,a),"from"in n&&n.from)for(const r of n.from.froms)C(this,V,ut).call(this,r,a);if("into"in n&&n.into&&C(this,V,ut).call(this,n.into,a),"table"in n&&n.table&&C(this,V,ut).call(this,n.table,a),"joins"in n&&n.joins)for(const r of n.joins)C(this,V,ut).call(this,r.table,a);return"using"in n&&n.using&&C(this,V,ut).call(this,n.using,a),a},Da=function(n){const a=new Set;return"with"in n&&n.with&&C(this,V,Ra).call(this,n.with,a),a},ut=function(n,a){const r=Ln.is(n)?n:ad.is(n)&&Ln.is(n.node)?n.node:null;r&&C(this,V,Vn).call(this,r.table,a)},Vn=function(n,a){const r=n.identifier.name;!v(this,Be).has(r)&&!v(this,Ke).has(r)&&a.add(r)},Ra=function(n,a){for(const r of n.expressions){const s=r.name.table.table.identifier.name;v(this,Ke).has(s)||a.add(s)}};class od{constructor(e){he(this,Gt);en(this,Gt,new id(e))}transformQuery(e){return v(this,Gt).transformNode(e.node)}async transformResult(e){return e.result}}Gt=new WeakMap;class dd{transformQuery(e){return e.node}async transformResult(e){return e.result}}const cd="kysely_migration",ja="kysely_migration_lock",ld=!1,zn="migration_lock",ud=F({__noMigrations__:!0});class Ia{constructor(e){he(this,p);he(this,D);en(this,D,F(e))}async getMigrations(){const e=await C(this,p,mt).call(this,v(this,p,ge))?await v(this,D).db.withPlugin(v(this,p,ye)).selectFrom(v(this,p,ge)).select(["name","timestamp"]).execute():[];return(await C(this,p,Wn).call(this)).map(({name:a,...r})=>{const s=e.find(o=>o.name===a);return{name:a,migration:r,executedAt:s?new Date(s.timestamp):void 0}})}async migrateToLatest(){return C(this,p,tn).call(this,()=>({direction:"Up",step:1/0}))}async migrateTo(e){return C(this,p,tn).call(this,({migrations:n,executedMigrations:a,pendingMigrations:r})=>{if(e===ud)return{direction:"Down",step:1/0};if(!n.find(d=>d.name===e))throw new Error(`migration "${e}" doesn't exist`);const s=a.indexOf(e),o=r.findIndex(d=>d.name===e);if(s!==-1)return{direction:"Down",step:a.length-s-1};if(o!==-1)return{direction:"Up",step:o+1};throw new Error(`migration "${e}" isn't executed or pending`)})}async migrateUp(){return C(this,p,tn).call(this,()=>({direction:"Up",step:1}))}async migrateDown(){return C(this,p,tn).call(this,()=>({direction:"Down",step:1}))}}D=new WeakMap,p=new WeakSet,tn=async function(e){try{return await C(this,p,La).call(this),await C(this,p,Ba).call(this,e)}catch(n){return n instanceof Un?n.resultSet:{error:n}}},_e=function(){return v(this,D).migrationTableSchema},ge=function(){return v(this,D).migrationTableName??cd},ht=function(){return v(this,D).migrationLockTableName??ja},Ma=function(){return v(this,D).allowUnorderedMigrations??ld},ye=function(){return v(this,p,_e)?new od(v(this,p,_e)):new dd},La=async function(){await C(this,p,za).call(this),await C(this,p,Ua).call(this),await C(this,p,Fa).call(this),await C(this,p,Va).call(this)},za=async function(){if(v(this,p,_e)&&!await C(this,p,Bn).call(this))try{await C(this,p,nn).call(this,v(this,D).db.schema.createSchema(v(this,p,_e)))}catch(e){if(!await C(this,p,Bn).call(this))throw e}},Ua=async function(){if(!await C(this,p,mt).call(this,v(this,p,ge)))try{v(this,p,_e)&&await C(this,p,nn).call(this,v(this,D).db.schema.createSchema(v(this,p,_e))),await C(this,p,nn).call(this,v(this,D).db.schema.withPlugin(v(this,p,ye)).createTable(v(this,p,ge)).addColumn("name","varchar(255)",e=>e.notNull().primaryKey()).addColumn("timestamp","varchar(255)",e=>e.notNull()))}catch(e){if(!await C(this,p,mt).call(this,v(this,p,ge)))throw e}},Fa=async function(){if(!await C(this,p,mt).call(this,v(this,p,ht)))try{await C(this,p,nn).call(this,v(this,D).db.schema.withPlugin(v(this,p,ye)).createTable(v(this,p,ht)).addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("is_locked","integer",e=>e.notNull().defaultTo(0)))}catch(e){if(!await C(this,p,mt).call(this,v(this,p,ht)))throw e}},Va=async function(){if(!await C(this,p,Kn).call(this))try{await v(this,D).db.withPlugin(v(this,p,ye)).insertInto(v(this,p,ht)).values({id:zn,is_locked:0}).execute()}catch(e){if(!await C(this,p,Kn).call(this))throw e}},Bn=async function(){return(await v(this,D).db.introspection.getSchemas()).some(n=>n.name===v(this,p,_e))},mt=async function(e){const n=v(this,p,_e);return(await v(this,D).db.introspection.getTables({withInternalKyselyTables:!0})).some(r=>r.name===e&&(!n||r.schema===n))},Kn=async function(){return!!await v(this,D).db.withPlugin(v(this,p,ye)).selectFrom(v(this,p,ht)).where("id","=",zn).select("id").executeTakeFirst()},Ba=async function(e){const n=v(this,D).db.getExecutor().adapter,a=F({lockTable:v(this,D).migrationLockTableName??ja,lockRowId:zn,lockTableSchema:v(this,D).migrationTableSchema}),r=async s=>{try{await n.acquireMigrationLock(s,a);const o=await C(this,p,Ka).call(this,s);if(o.migrations.length===0)return{results:[]};const{direction:d,step:c}=e(o);return c<=0?{results:[]}:d==="Down"?await C(this,p,Ha).call(this,s,o,c):d==="Up"?await C(this,p,Ga).call(this,s,o,c):{results:[]}}finally{await n.releaseMigrationLock(s,a)}};return n.supportsTransactionalDdl?v(this,D).db.transaction().execute(r):v(this,D).db.connection().execute(r)},Ka=async function(e){const n=await C(this,p,Wn).call(this),a=await C(this,p,Ja).call(this,e);C(this,p,qa).call(this,n,a),v(this,p,Ma)||C(this,p,Qa).call(this,n,a);const r=C(this,p,Wa).call(this,n,a);return F({migrations:n,executedMigrations:a,lastMigration:nd(a),pendingMigrations:r})},Wa=function(e,n){return e.filter(a=>!n.includes(a.name))},Wn=async function(){const e=await v(this,D).provider.getMigrations();return Object.keys(e).sort().map(n=>({...e[n],name:n}))},Ja=async function(e){return(await e.withPlugin(v(this,p,ye)).selectFrom(v(this,p,ge)).select("name").orderBy(["timestamp","name"]).execute()).map(a=>a.name)},qa=function(e,n){for(const a of n)if(!e.some(r=>r.name===a))throw new Error(`corrupted migrations: previously executed migration ${a} is missing`)},Qa=function(e,n){for(let a=0;a<n.length;++a)if(e[a].name!==n[a])throw new Error(`corrupted migrations: expected previously executed migration ${n[a]} to be at index ${a} but ${e[a].name} was found in its place. New migrations must always have a name that comes alphabetically after the last executed migration.`)},Ha=async function(e,n,a){const r=n.executedMigrations.slice().reverse().slice(0,a).map(o=>n.migrations.find(d=>d.name===o)),s=r.map(o=>({migrationName:o.name,direction:"Down",status:"NotExecuted"}));for(let o=0;o<s.length;++o){const d=r[o];try{d.down&&(await d.down(e),await e.withPlugin(v(this,p,ye)).deleteFrom(v(this,p,ge)).where("name","=",d.name).execute(),s[o]={migrationName:d.name,direction:"Down",status:"Success"})}catch(c){throw s[o]={migrationName:d.name,direction:"Down",status:"Error"},new Un({error:c,results:s})}}return{results:s}},Ga=async function(e,n,a){const s=n.pendingMigrations.slice(0,a).map(o=>({migrationName:o.name,direction:"Up",status:"NotExecuted"}));for(let o=0;o<s.length;o++){const d=n.pendingMigrations[o];try{await d.up(e),await e.withPlugin(v(this,p,ye)).insertInto(v(this,p,ge)).values({name:d.name,timestamp:new Date().toISOString()}).execute(),s[o]={migrationName:d.name,direction:"Up",status:"Success"}}catch(c){throw s[o]={migrationName:d.name,direction:"Up",status:"Error"},new Un({error:c,results:s})}}return{results:s}},nn=async function(e){v(this,D).db.getExecutor().adapter.supportsCreateIfNotExists&&(e=e.ifNotExists()),await e.execute()};class Un extends Error{constructor(n){super();he(this,Yt);en(this,Yt,n)}get resultSet(){return v(this,Yt)}}Yt=new WeakMap;class Za{constructor(e){Xt(this,"migrations");this.migrations=e}async getMigrations(){return this.migrations}}async function hd(t){await t.schema.createTable("tenants").addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("name","varchar(255)").addColumn("audience","varchar(255)").addColumn("sender_email","varchar(255)").addColumn("sender_name","varchar(255)").addColumn("language","varchar(255)").addColumn("logo","varchar(255)").addColumn("primary_color","varchar(255)").addColumn("secondary_color","varchar(255)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("modified_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.createTable("users").addColumn("user_id","varchar(255)",e=>e.notNull()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("email","varchar(255)",e=>e.notNull()).addColumn("given_name","varchar(255)").addColumn("family_name","varchar(255)").addColumn("nickname","varchar(255)").addColumn("name","varchar(255)").addColumn("picture","varchar(2083)").addColumn("tags","varchar(255)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("modified_at","varchar(255)",e=>e.notNull()).addPrimaryKeyConstraint("users_tenants",["user_id","tenant_id"]).addColumn("linked_to","varchar(255)").addForeignKeyConstraint("linked_to_constraint",["linked_to","tenant_id"],"users",["user_id","tenant_id"]).addColumn("last_ip","varchar(255)").addColumn("login_count","integer",e=>e.notNull()).addColumn("last_login","varchar(255)").addColumn("provider","varchar(255)",e=>e.notNull()).addColumn("connection","varchar(255)").addColumn("email_verified","boolean",e=>e.notNull()).addColumn("is_social","boolean",e=>e.notNull()).addColumn("app_metadata","varchar(4096)",e=>e.defaultTo("{}").notNull()).addColumn("user_metadata","varchar(4096)",e=>e.defaultTo("{}").notNull()).addUniqueConstraint("unique_email_provider",["email","provider","tenant_id"]).execute(),await t.schema.createTable("members").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("sub","varchar(255)").addColumn("email","varchar(255)").addColumn("name","varchar(255)").addColumn("status","varchar(255)").addColumn("role","varchar(255)").addColumn("picture","varchar(2083)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("modified_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.createTable("applications").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("name","varchar(255)",e=>e.notNull()).addColumn("client_secret","varchar(255)").addColumn("allowed_logout_urls","varchar(255)").addColumn("authentication_settings","varchar(255)").addColumn("addons","varchar(4096)",e=>e.notNull().defaultTo("{}")).addColumn("callbacks","varchar(1024)",e=>e.notNull().defaultTo("[]")).addColumn("allowed_origins","varchar(1024)",e=>e.notNull().defaultTo("[]")).addColumn("web_origins","varchar(1024)",e=>e.notNull().defaultTo("[]")).addColumn("allowed_clients","varchar(1024)",e=>e.defaultTo("[]").notNull()).addColumn("options_kid","varchar(32)").addColumn("options_team_id","varchar(32)").addColumn("options_client_id","varchar(128)").addColumn("options_client_secret","varchar(255)").addColumn("options_scope","varchar(255)").addColumn("options_realms","varchar(255)").addColumn("options_app_secret","varchar(1024)").addColumn("email_validation","varchar(255)").addColumn("disable_sign_ups","boolean",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("modified_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.createTable("connections").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("name","varchar(255)",e=>e.notNull()).addColumn("response_type","varchar(255)").addColumn("response_mode","varchar(255)").addColumn("options","varchar(2048)",e=>e.defaultTo("{}").notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("modified_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.createTable("migrations").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("provider","varchar(255)").addColumn("client_id","varchar(255)").addColumn("origin","varchar(255)").addColumn("domain","varchar(255)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("modified_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.createTable("domains").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("domain","varchar(255)",e=>e.notNull()).addColumn("email_service","varchar(255)").addColumn("email_api_key","varchar(255)").addColumn("dkim_private_key","varchar(2048)").addColumn("dkim_public_key","varchar(2048)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("modified_at","varchar(255)",e=>e.notNull()).execute()}async function md(t){await t.schema.dropTable("domains").execute(),await t.schema.dropTable("members").execute(),await t.schema.dropTable("users").execute(),await t.schema.dropTable("connections").execute(),await t.schema.dropTable("applications").execute(),await t.schema.dropTable("migrations").execute(),await t.schema.dropTable("tenants").execute()}const pd=Object.freeze(Object.defineProperty({__proto__:null,down:md,up:hd},Symbol.toStringTag,{value:"Module"}));async function fd(t){await t.schema.alterTable("tenants").addColumn("support_url","varchar(255)").execute()}async function _d(t){await t.schema.alterTable("tenants").dropColumn("support_url").execute()}const gd=Object.freeze(Object.defineProperty({__proto__:null,down:_d,up:fd},Symbol.toStringTag,{value:"Module"}));async function yd(t){await t.schema.alterTable("applications").renameColumn("modified_at","updated_at").execute(),await t.schema.alterTable("connections").renameColumn("modified_at","updated_at").execute(),await t.schema.alterTable("domains").renameColumn("modified_at","updated_at").execute(),await t.schema.alterTable("members").renameColumn("modified_at","updated_at").execute(),await t.schema.alterTable("migrations").renameColumn("modified_at","updated_at").execute(),await t.schema.alterTable("tenants").renameColumn("modified_at","updated_at").execute(),await t.schema.alterTable("users").renameColumn("modified_at","updated_at").execute()}async function vd(t){await t.schema.alterTable("applications").renameColumn("updated_at","modified_at").execute(),await t.schema.alterTable("connections").renameColumn("updated_at","modified_at").execute(),await t.schema.alterTable("domains").renameColumn("updated_at","modified_at").execute(),await t.schema.alterTable("members").renameColumn("updated_at","modified_at").execute(),await t.schema.alterTable("migrations").renameColumn("updated_at","modified_at").execute(),await t.schema.alterTable("tenants").renameColumn("updated_at","modified_at").execute(),await t.schema.alterTable("users").renameColumn("updated_at","modified_at").execute()}const wd=Object.freeze(Object.defineProperty({__proto__:null,down:vd,up:yd},Symbol.toStringTag,{value:"Module"}));async function bd(t){await t.schema.createTable("logs").addColumn("id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("category","varchar(255)",e=>e.notNull()).addColumn("tenant_id","varchar(64)").addColumn("user_id","varchar(64)").addForeignKeyConstraint("tenant_id_constraint",["tenant_id"],"tenants",["id"],e=>e.onDelete("cascade")).addColumn("ip","varchar(255)").addColumn("type","varchar(8)",e=>e.notNull()).addColumn("date","varchar(25)",e=>e.notNull()).addColumn("client_id","varchar(255)").addColumn("client_name","varchar(255)").addColumn("user_agent","varchar(255)").addColumn("description","varchar(255)").addColumn("details","varchar(2048)").execute()}async function xd(t){await t.schema.dropTable("logs").execute()}const kd=Object.freeze(Object.defineProperty({__proto__:null,down:xd,up:bd},Symbol.toStringTag,{value:"Module"}));async function Nd(t){}async function Td(t){}const Cd=Object.freeze(Object.defineProperty({__proto__:null,down:Td,up:Nd},Symbol.toStringTag,{value:"Module"}));async function Od(t){await t.schema.createTable("sessions").addColumn("session_id","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("tenant_id","varchar(255)").addColumn("user_id","varchar(255)").addForeignKeyConstraint("user_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").addColumn("deleted_at","varchar(255)").execute(),await t.schema.createTable("tickets").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("email","varchar(255)",e=>e.notNull()).addColumn("nonce","varchar(255)").addColumn("state","varchar(1024)").addColumn("scope","varchar(1024)").addColumn("response_type","varchar(256)").addColumn("response_mode","varchar(256)").addColumn("redirect_uri","varchar(1024)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute(),await t.schema.createTable("otps").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("code","varchar(255)",e=>e.notNull()).addColumn("email","varchar(255)",e=>e.notNull()).addColumn("user_id","varchar(255)").addColumn("send","varchar(255)").addColumn("nonce","varchar(255)").addColumn("state","varchar(1024)").addColumn("scope","varchar(1024)").addColumn("response_type","varchar(256)").addColumn("response_mode","varchar(256)").addColumn("redirect_uri","varchar(1024)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute(),await t.schema.createIndex("otps_email_index").on("otps").column("email").execute(),await t.schema.createIndex("otps_expires_at_index").on("otps").column("expires_at").execute()}async function Sd(t){await t.schema.dropTable("sessions").execute(),await t.schema.dropTable("tickets").execute(),await t.schema.dropTable("otps").execute()}const jd=Object.freeze(Object.defineProperty({__proto__:null,down:Sd,up:Od},Symbol.toStringTag,{value:"Module"}));async function Id(t){await t.schema.createTable("passwords").addColumn("tenant_id","varchar(255)").addColumn("user_id","varchar(255)").addForeignKeyConstraint("user_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("created_at","varchar(255)").addColumn("updated_at","varchar(255)").execute(),await t.schema.createTable("codes").addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("user_id","varchar(255)").addColumn("tenant_id","varchar(255)").addForeignKeyConstraint("user_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("type","varchar(255)",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute(),await t.schema.createIndex("codes_expires_at_index").on("codes").column("expires_at").execute()}async function Zd(t){await t.schema.dropTable("passwords").execute(),await t.schema.dropTable("codes").execute()}const Ed=Object.freeze(Object.defineProperty({__proto__:null,down:Zd,up:Id},Symbol.toStringTag,{value:"Module"}));async function $d(t){}async function Ad(t){}const Pd=Object.freeze(Object.defineProperty({__proto__:null,down:Ad,up:$d},Symbol.toStringTag,{value:"Module"}));async function Dd(t){await t.schema.alterTable("passwords").addColumn("password","varchar(255)",e=>e.notNull()).execute()}async function Rd(t){await t.schema.alterTable("passwords").dropColumn("password").execute()}const Md=Object.freeze(Object.defineProperty({__proto__:null,down:Rd,up:Dd},Symbol.toStringTag,{value:"Module"}));async function Ld(t){}async function zd(t){}const Ud=Object.freeze(Object.defineProperty({__proto__:null,down:zd,up:Ld},Symbol.toStringTag,{value:"Module"}));async function Fd(t){}async function Vd(t){}const Bd=Object.freeze(Object.defineProperty({__proto__:null,down:Vd,up:Fd},Symbol.toStringTag,{value:"Module"}));async function Kd(t){}async function Wd(t){}const Jd=Object.freeze(Object.defineProperty({__proto__:null,down:Wd,up:Kd},Symbol.toStringTag,{value:"Module"}));async function qd(t){await t.schema.createIndex("users_email_index").on("users").column("email").execute()}async function Qd(t){await t.schema.dropIndex("users_email_index").execute()}const Hd=Object.freeze(Object.defineProperty({__proto__:null,down:Qd,up:qd},Symbol.toStringTag,{value:"Module"}));async function Gd(t){await t.schema.alterTable("users").addColumn("profileData","varchar(2048)").execute()}async function Yd(t){await t.schema.alterTable("users").dropColumn("profileData").execute()}const Xd=Object.freeze(Object.defineProperty({__proto__:null,down:Yd,up:Gd},Symbol.toStringTag,{value:"Module"}));async function ec(t){await t.schema.createIndex("users_linked_to_index").on("users").column("linked_to").execute()}async function tc(t){await t.schema.dropIndex("users_linked_to_index")}const nc=Object.freeze(Object.defineProperty({__proto__:null,down:tc,up:ec},Symbol.toStringTag,{value:"Module"}));async function ac(t){await t.schema.alterTable("users").addColumn("locale","varchar(255)").execute()}async function rc(t){await t.schema.alterTable("users").dropColumn("locale").execute()}const sc=Object.freeze(Object.defineProperty({__proto__:null,down:rc,up:ac},Symbol.toStringTag,{value:"Module"}));async function ic(t){await t.schema.createTable("keys").addColumn("kid","varchar(255)",e=>e.primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade")).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("revoked_at","varchar(255)").addColumn("cert","varchar(2048)").addColumn("pkcs7","varchar(2048)").addColumn("fingerprint","varchar(256)").addColumn("thumbprint","varchar(256)").addColumn("current_since","varchar(256)").addColumn("current_until","varchar(256)").execute()}async function oc(t){await t.schema.dropTable("keys").execute()}const dc=Object.freeze(Object.defineProperty({__proto__:null,down:oc,up:ic},Symbol.toStringTag,{value:"Module"}));async function cc(t){}async function lc(t){}const uc=Object.freeze(Object.defineProperty({__proto__:null,down:lc,up:cc},Symbol.toStringTag,{value:"Module"}));async function hc(t){await t.schema.alterTable("connections").addColumn("userinfo_endpoint","varchar(256)").execute()}async function mc(t){await t.schema.alterTable("connections").dropColumn("userinfo_endpoint").execute()}const pc=Object.freeze(Object.defineProperty({__proto__:null,down:mc,up:hc},Symbol.toStringTag,{value:"Module"}));async function fc(t){await t.schema.alterTable("otps").addColumn("audience","varchar(255)").execute()}async function _c(t){await t.schema.alterTable("otps").dropColumn("audience").execute()}const gc=Object.freeze(Object.defineProperty({__proto__:null,down:_c,up:fc},Symbol.toStringTag,{value:"Module"}));async function yc(t){}async function vc(t){}const wc=Object.freeze(Object.defineProperty({__proto__:null,down:vc,up:yc},Symbol.toStringTag,{value:"Module"}));async function bc(t){await t.schema.alterTable("logs").dropColumn("category").execute()}async function xc(t){await t.schema.alterTable("logs").addColumn("category","varchar(255)",e=>e.notNull()).execute()}const kc=Object.freeze(Object.defineProperty({__proto__:null,down:xc,up:bc},Symbol.toStringTag,{value:"Module"}));async function Nc(t){await t.schema.alterTable("users").dropColumn("tags").execute()}async function Tc(t){await t.schema.alterTable("users").addColumn("tags","varchar(255)").execute()}const Cc=Object.freeze(Object.defineProperty({__proto__:null,down:Tc,up:Nc},Symbol.toStringTag,{value:"Module"}));async function Oc(t){await t.schema.createIndex("logs_user_id").on("logs").column("user_id").execute(),await t.schema.createIndex("logs_tenant_id").on("logs").column("tenant_id").execute(),await t.schema.createIndex("logs_date").on("logs").column("date").execute()}async function Sc(t){await t.schema.dropIndex("logs_user_id"),await t.schema.dropIndex("logs_tenant_id"),await t.schema.dropIndex("logs_date")}const jc=Object.freeze(Object.defineProperty({__proto__:null,down:Sc,up:Oc},Symbol.toStringTag,{value:"Module"}));async function Ic(t){await t.schema.alterTable("logs").dropColumn("details").execute(),await t.schema.alterTable("logs").addColumn("details","varchar(8192)").execute()}async function Zc(t){await t.schema.alterTable("logs").dropColumn("details").execute(),await t.schema.alterTable("logs").addColumn("details","varchar(2048)").execute()}const Ec=Object.freeze(Object.defineProperty({__proto__:null,down:Zc,up:Ic},Symbol.toStringTag,{value:"Module"}));async function $c(t){await t.schema.alterTable("logs").addColumn("user_name","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("auth0_client","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("isMobile","boolean").execute(),await t.schema.alterTable("logs").addColumn("connection","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("connection_id","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("audience","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("scope","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("strategy","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("strategy_type","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("hostname","varchar(255)").execute(),await t.schema.alterTable("logs").addColumn("session_connection","varchar(255)").execute()}async function Ac(t){await t.schema.alterTable("logs").dropColumn("user_name").execute(),await t.schema.alterTable("logs").dropColumn("auth0_client").execute(),await t.schema.alterTable("logs").dropColumn("isMobile").execute(),await t.schema.alterTable("logs").dropColumn("connection").execute(),await t.schema.alterTable("logs").dropColumn("connection_id").execute(),await t.schema.alterTable("logs").dropColumn("audience").execute(),await t.schema.alterTable("logs").dropColumn("scope").execute(),await t.schema.alterTable("logs").dropColumn("strategy").execute(),await t.schema.alterTable("logs").dropColumn("strategy_type").execute(),await t.schema.alterTable("logs").dropColumn("hostname").execute(),await t.schema.alterTable("logs").dropColumn("session_connection").execute()}const Pc=Object.freeze(Object.defineProperty({__proto__:null,down:Ac,up:$c},Symbol.toStringTag,{value:"Module"}));async function Dc(t){await t.schema.createIndex("users_name_index").on("users").column("name").execute()}async function Rc(t){await t.schema.dropIndex("users_name_index").execute()}const Mc=Object.freeze(Object.defineProperty({__proto__:null,down:Rc,up:Dc},Symbol.toStringTag,{value:"Module"}));async function Lc(t){}async function zc(t){await t.schema.alterTable("users").dropConstraint("unique_email_provider").execute()}const Uc=Object.freeze(Object.defineProperty({__proto__:null,down:zc,up:Lc},Symbol.toStringTag,{value:"Module"}));async function Fc(t){await t.schema.alterTable("otps").dropColumn("state").execute(),await t.schema.alterTable("otps").addColumn("state","varchar(8192)").execute()}async function Vc(t){await t.schema.alterTable("otps").dropColumn("state").execute(),await t.schema.alterTable("otps").addColumn("state","varchar(1024)").execute()}const Bc=Object.freeze(Object.defineProperty({__proto__:null,down:Vc,up:Fc},Symbol.toStringTag,{value:"Module"}));async function Kc(t){await t.schema.alterTable("tickets").dropColumn("state").execute(),await t.schema.alterTable("tickets").addColumn("state","varchar(8192)").execute()}async function Wc(t){await t.schema.alterTable("tickets").dropColumn("state").execute(),await t.schema.alterTable("tickets").addColumn("state","varchar(1024)").execute()}const Jc=Object.freeze(Object.defineProperty({__proto__:null,down:Wc,up:Kc},Symbol.toStringTag,{value:"Module"}));async function qc(t){await t.schema.createTable("branding").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull().primaryKey()).addColumn("logo_url","varchar(512)").addColumn("favicon_url","varchar(512)").addColumn("font_url","varchar(512)").addColumn("colors_primary","varchar(8)").addColumn("colors_page_background_type","varchar(32)").addColumn("colors_page_background_start","varchar(8)").addColumn("colors_page_background_end","varchar(8)").addColumn("colors_page_background_angle_dev","integer").execute()}async function Qc(t){await t.schema.dropTable("branding").execute()}const Hc=Object.freeze(Object.defineProperty({__proto__:null,down:Qc,up:qc},Symbol.toStringTag,{value:"Module"}));async function Gc(t){}async function Yc(t){}const Xc=Object.freeze(Object.defineProperty({__proto__:null,down:Yc,up:Gc},Symbol.toStringTag,{value:"Module"}));async function el(t){}async function tl(t){}const nl=Object.freeze(Object.defineProperty({__proto__:null,down:tl,up:el},Symbol.toStringTag,{value:"Module"}));async function al(t){}async function rl(t){}const sl=Object.freeze(Object.defineProperty({__proto__:null,down:rl,up:al},Symbol.toStringTag,{value:"Module"}));async function il(t){}async function ol(t){}const dl=Object.freeze(Object.defineProperty({__proto__:null,down:ol,up:il},Symbol.toStringTag,{value:"Module"}));async function cl(t){await t.schema.createTable("authentication_codes").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("code","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("user_id","varchar(255)",e=>e.notNull()).addColumn("nonce","varchar(255)").addColumn("state","varchar(8192)").addColumn("scope","varchar(1024)").addColumn("response_type","varchar(256)").addColumn("response_mode","varchar(256)").addColumn("redirect_uri","varchar(1024)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute()}async function ll(t){await t.schema.dropTable("authentication_codes").execute()}const ul=Object.freeze(Object.defineProperty({__proto__:null,down:ll,up:cl},Symbol.toStringTag,{value:"Module"}));async function hl(t){}async function ml(t){}const pl=Object.freeze(Object.defineProperty({__proto__:null,down:ml,up:hl},Symbol.toStringTag,{value:"Module"}));async function fl(t){await t.schema.alterTable("otps").addColumn("ip","varchar(64)").execute()}async function _l(t){await t.schema.alterTable("otps").dropColumn("ip").execute()}const gl=Object.freeze(Object.defineProperty({__proto__:null,down:_l,up:fl},Symbol.toStringTag,{value:"Module"}));async function yl(t){await t.schema.alterTable("logs").dropColumn("user_agent").execute(),await t.schema.alterTable("logs").addColumn("user_agent","varchar(1024)").execute()}async function vl(t){await t.schema.alterTable("logs").dropColumn("user_agent").execute(),await t.schema.alterTable("logs").addColumn("user_agent","varchar(255)").execute()}const wl=Object.freeze(Object.defineProperty({__proto__:null,down:vl,up:yl},Symbol.toStringTag,{value:"Module"}));async function bl(t){}async function xl(t){}const kl=Object.freeze(Object.defineProperty({__proto__:null,down:xl,up:bl},Symbol.toStringTag,{value:"Module"}));async function Nl(t){await t.schema.createTable("hooks").addColumn("hook_id","varchar(255)",e=>e.notNull().primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("url","varchar(512)",e=>e.notNull()).addColumn("trigger_id","varchar(255)",e=>e.notNull()).addColumn("enabled","boolean",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).addColumn("synchronous","boolean",e=>e.defaultTo(!1).notNull()).addColumn("priority","integer").execute()}async function Tl(t){await t.schema.dropTable("hooks").execute()}const Cl=Object.freeze(Object.defineProperty({__proto__:null,down:Tl,up:Nl},Symbol.toStringTag,{value:"Module"}));async function Ol(t){}async function Sl(t){}const jl=Object.freeze(Object.defineProperty({__proto__:null,down:Sl,up:Ol},Symbol.toStringTag,{value:"Module"}));async function Il(t){}async function Zl(t){}const El=Object.freeze(Object.defineProperty({__proto__:null,down:Zl,up:Il},Symbol.toStringTag,{value:"Module"}));async function $l(t){await t.schema.createTable("logins").addColumn("login_id","varchar(255)",e=>e.primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("authParams_client_id","varchar(255)",e=>e.notNull()).addColumn("authParams_vendor_id","varchar(255)").addColumn("authParams_username","varchar(255)").addColumn("authParams_response_type","varchar(255)").addColumn("authParams_response_mode","varchar(255)").addColumn("authParams_audience","varchar(255)").addColumn("authParams_scope","varchar(511)").addColumn("authParams_state","varchar(511)").addColumn("authParams_code_challenge_method","varchar(256)").addColumn("authParams_code_challenge","varchar(256)").addColumn("authParams_redirect_uri","varchar(256)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("updated_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).execute(),await t.schema.alterTable("passwords").addColumn("algorithm","varchar(16)").execute(),await t.schema.dropTable("codes").execute(),await t.schema.createTable("codes").addColumn("code_id","varchar(255)",e=>e.primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("user_id","varchar(255)").addColumn("login_id","varchar(255)").addForeignKeyConstraint("codes_user_id_tenant_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("code_type","varchar(255)",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute()}async function Al(t){await t.schema.dropTable("logins").execute(),await t.schema.alterTable("passwords").dropColumn("algorithm").execute(),await t.schema.dropTable("codes").execute(),await t.schema.createTable("codes").addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("code","varchar(255)",e=>e.notNull()).addColumn("user_id","varchar(255)").addColumn("tenant_id","varchar(255)").addForeignKeyConstraint("codes_user_id_tenant_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("type","varchar(255)",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute()}const Pl=Object.freeze(Object.defineProperty({__proto__:null,down:Al,up:$l},Symbol.toStringTag,{value:"Module"}));async function Dl(t){}async function Rl(t){}const Ml=Object.freeze(Object.defineProperty({__proto__:null,down:Rl,up:Dl},Symbol.toStringTag,{value:"Module"}));async function Ll(t){await t.schema.alterTable("logins").addColumn("auth0Client","varchar(256)").execute()}async function zl(t){await t.schema.alterTable("logins").dropColumn("auth0Client").execute()}const Ul=Object.freeze(Object.defineProperty({__proto__:null,down:zl,up:Ll},Symbol.toStringTag,{value:"Module"}));async function Fl(t){await t.schema.alterTable("logins").dropColumn("authParams_state").execute(),await t.schema.alterTable("logins").addColumn("authParams_state","varchar(8192)").execute()}async function Vl(t){await t.schema.alterTable("logins").dropColumn("authParams_state").execute(),await t.schema.alterTable("logins").addColumn("authParams_state","varchar(511)").execute()}const Bl=Object.freeze(Object.defineProperty({__proto__:null,down:Vl,up:Fl},Symbol.toStringTag,{value:"Module"}));async function Kl(t){}async function Wl(t){}const Jl=Object.freeze(Object.defineProperty({__proto__:null,down:Wl,up:Kl},Symbol.toStringTag,{value:"Module"}));async function ql(t){}async function Ql(t){}const Hl=Object.freeze(Object.defineProperty({__proto__:null,down:Ql,up:ql},Symbol.toStringTag,{value:"Module"}));async function Gl(t){await t.schema.alterTable("logins").addColumn("authParams_nonce","varchar(255)").execute()}async function Yl(t){await t.schema.alterTable("logins").dropColumn("nonce").execute()}const Xl=Object.freeze(Object.defineProperty({__proto__:null,down:Yl,up:Gl},Symbol.toStringTag,{value:"Module"}));async function eu(t){}async function tu(t){}const nu=Object.freeze(Object.defineProperty({__proto__:null,down:tu,up:eu},Symbol.toStringTag,{value:"Module"}));async function au(t){}async function ru(t){}const su=Object.freeze(Object.defineProperty({__proto__:null,down:ru,up:au},Symbol.toStringTag,{value:"Module"}));async function iu(t){await t.schema.dropTable("codes").execute(),await t.schema.createTable("codes").addColumn("code_id","varchar(255)",e=>e.notNull()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("user_id","varchar(255)").addColumn("login_id","varchar(255)").addColumn("connection_id","varchar(255)").addForeignKeyConstraint("codes_user_id_tenant_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("code_type","varchar(255)",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").addPrimaryKeyConstraint("PK_codes_code_id_code_type",["code_id","code_type"]).execute()}async function ou(t){await t.schema.dropTable("codes").execute(),await t.schema.createTable("codes").addColumn("code_id","varchar(255)",e=>e.primaryKey()).addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("user_id","varchar(255)").addColumn("connection_id","varchar(255)").addColumn("login_id","varchar(255)").addForeignKeyConstraint("codes_user_id_tenant_id_constraint",["user_id","tenant_id"],"users",["user_id","tenant_id"],e=>e.onDelete("cascade")).addColumn("code_type","varchar(255)",e=>e.notNull()).addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute()}const du=Object.freeze(Object.defineProperty({__proto__:null,down:ou,up:iu},Symbol.toStringTag,{value:"Module"}));async function cu(t){await t.schema.dropTable("otps").execute(),await t.schema.dropTable("authentication_codes").execute()}async function lu(t){await t.schema.alterTable("keys").addColumn("private_key","varchar(2048)").addColumn("public_key","varchar(2048)").execute(),await t.schema.createTable("otps").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("id","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("code","varchar(255)",e=>e.notNull()).addColumn("email","varchar(255)",e=>e.notNull()).addColumn("user_id","varchar(255)").addColumn("send","varchar(255)").addColumn("nonce","varchar(255)").addColumn("state","varchar(1024)").addColumn("scope","varchar(1024)").addColumn("response_type","varchar(256)").addColumn("response_mode","varchar(256)").addColumn("redirect_uri","varchar(1024)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute(),await t.schema.createTable("authentication_codes").addColumn("tenant_id","varchar(255)",e=>e.references("tenants.id").onDelete("cascade").notNull()).addColumn("code","varchar(255)",e=>e.primaryKey()).addColumn("client_id","varchar(255)",e=>e.references("applications.id").onDelete("cascade").notNull()).addColumn("user_id","varchar(255)",e=>e.notNull()).addColumn("nonce","varchar(255)").addColumn("state","varchar(8192)").addColumn("scope","varchar(1024)").addColumn("response_type","varchar(256)").addColumn("response_mode","varchar(256)").addColumn("redirect_uri","varchar(1024)").addColumn("created_at","varchar(255)",e=>e.notNull()).addColumn("expires_at","varchar(255)",e=>e.notNull()).addColumn("used_at","varchar(255)").execute()}const uu=Object.freeze(Object.defineProperty({__proto__:null,down:lu,up:cu},Symbol.toStringTag,{value:"Module"}));async function hu(t){await t.schema.createIndex("IDX_logs_tenant_date_type_user").on("logs").columns(["tenant_id","date","type","user_id"]).execute()}async function mu(t){await t.schema.dropIndex("IDX_logs_tenant_date_type_user").on("logs").execute()}const pu=Object.freeze(Object.defineProperty({__proto__:null,down:mu,up:hu},Symbol.toStringTag,{value:"Module"}));async function fu(t){}async function _u(t){}const gu=Object.freeze(Object.defineProperty({__proto__:null,down:_u,up:fu},Symbol.toStringTag,{value:"Module"}));async function yu(t){await t.schema.createTable("prompt_settings").addColumn("tenant_id","varchar(64)",e=>e.primaryKey()).addColumn("universal_login_experience","varchar(16)",e=>e.defaultTo("new").notNull()).addColumn("identifier_first","boolean",e=>e.defaultTo(!0).notNull()).addColumn("password_first","boolean",e=>e.defaultTo(!1).notNull()).addColumn("webauthn_platform_first_factor","boolean",e=>e.defaultTo(!1).notNull()).execute()}async function vu(t){await t.schema.dropTable("prompt_settings").execute()}const wu=Object.freeze(Object.defineProperty({__proto__:null,down:vu,up:yu},Symbol.toStringTag,{value:"Module"}));async function bu(t){}async function xu(t){}const ku=Object.freeze(Object.defineProperty({__proto__:null,down:xu,up:bu},Symbol.toStringTag,{value:"Module"}));async function Nu(t){}async function Tu(t){}const Cu=Object.freeze(Object.defineProperty({__proto__:null,down:Tu,up:Nu},Symbol.toStringTag,{value:"Module"}));async function Ou(t){}async function Su(t){}const ju=Object.freeze(Object.defineProperty({__proto__:null,down:Su,up:Ou},Symbol.toStringTag,{value:"Module"}));async function Iu(t){await t.schema.alterTable("logins").addColumn("authParams_ui_locales","varchar(32)").execute()}async function Zu(t){await t.schema.alterTable("logins").dropColumn("authParams_ui_locales").execute()}const Eu=Object.freeze(Object.defineProperty({__proto__:null,down:Zu,up:Iu},Symbol.toStringTag,{value:"Module"}));async function $u(t){await t.schema.alterTable("logins").addColumn("authParams_prompt","varchar(16)").execute()}async function Au(t){await t.schema.alterTable("logins").dropColumn("authParams_prompt").execute()}const Pu=Object.freeze(Object.defineProperty({__proto__:null,down:Au,up:$u},Symbol.toStringTag,{value:"Module"}));async function Du(t){}async function Ru(t){}const Ea={m1_init:pd,m2_magicLink:gd,m3_updateAt:wd,m4_logTable:kd,m5_userProfile:Cd,m6_sessions:jd,m7_passwords:Ed,m8_logsTableNewFields:Pd,m9_passwordTableNewField:Md,n01_codesTable:Ud,n11_universalLoginSession:Bd,n12_userFields:Jd,n13_userEmailIndex:Hd,n14_profileDataField:Xd,n15_userEmailIndex:nc,n16_userLocale:sc,n17_signingKeys:dc,n18_logsFields:uc,n19_connectionsUserinfo:pc,n20_missingFields:gc,n21_sessionDeletedAt:wc,n22_dropLogsFields:kc,n23_dropUsersFields:Cc,n24_logsIndexes:jc,n25_logDescMaxLength:Ec,n26_logsTableExtraFields:Pc,n27_usersTableNameIndex:Mc,n28_usersEmailConstrain:Uc,n29_increaseOtpStateLength:Bc,n30_increaseTicketStateLength:Jc,n31_branding:Hc,n32_indexesAndNotNull:Xc,n33_vendorIdInUniversalLoginSession:nl,n34_auth0ClientInUniversalLoginSession:sl,n35_increaseUniversalSessionStateLength:dl,n36_authenticationCodes:ul,n37_disableSignUps:pl,n38_otpIpAddress:gl,n39_increaseUserAgentLength:wl,n40_userId:kl,n41_hooks:Cl,n42_userIdIndexes:jl,n43_userIdIndexes:El,n44_codes:Pl,n45_hookProperties:Ml,n46_loginAuth0Client:Ul,n47_loginAuth0Client:Bl,n48_saml:Jl,n49_removeFields:Hl,n50_authParamsNonce:Xl,n51_connectionid:nu,n52_cert:su,n53_codes_primary_key:du,n54_cleanup_tables:uu,n55_logs_index:pu,n56_application_fields:gu,n57_prompt_settings:wu,n58_connection_client_id:ku,n59_connection_options:Cu,n60_users_metadata:ju,n61_userLocales:Eu,n62_prompt:Pu,n63_connection_cleanup:Object.freeze(Object.defineProperty({__proto__:null,down:Ru,up:Du},Symbol.toStringTag,{value:"Module"}))};async function Mu(t,e=!1){e&&console.log("migrating...");const n=new Za(Ea),a=new Ia({db:t,provider:n}),{error:r,results:s}=await a.migrateToLatest();if(s==null||s.forEach(o=>{o.status==="Success"?e&&console.log(`migration "${o.migrationName}" was executed successfully`):o.status==="Error"&&console.error(`failed to execute migration "${o.migrationName}"`)}),r)throw console.error("failed to migrate"),console.error(r),r}async function Lu(t){console.log("migrating...");const e=new Za(Ea),n=new Ia({db:t,provider:e}),{error:a,results:r}=await n.migrateDown();if(r==null||r.forEach(s=>{s.status==="Success"?console.log(`migration "${s.migrationName}" was reverted successfully`):s.status==="Error"&&console.error(`failed to execute migration "${s.migrationName}"`)}),a)throw console.error("failed to migrate"),console.error(a),a}function zu(t){return{applications:gi(t),branding:Do(t),clients:Co(t),codes:ui(t),connections:To(t),domains:$o(t),hooks:Fo(t),keys:Io(t),logins:Yo(t),logs:Ws(t),passwords:ii(t),promptSettings:td(t),users:As(t),sessions:Ys(t),tenants:Us(t),themes:Jo(t),tickets:ni(t)}}return A.default=zu,A.migrateDown=Lu,A.migrateToLatest=Mu,Object.defineProperties(A,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),A}({});