@rizom/brain 0.2.0-alpha.129 → 0.2.0-alpha.130

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.
@@ -314,6 +314,12 @@ type CreateInterceptor = (input: CreateInput, executionContext: CreateExecutionC
314
314
  */
315
315
  interface EntityAdapter<TEntity extends BaseEntity<TMetadata>, TMetadata = Record<string, unknown>> {
316
316
  entityType: string;
317
+ /**
318
+ * One declarative sentence describing what this entity type is. This is the
319
+ * data the model reads to select `entityType`, replacing hardcoded example
320
+ * phrasings in system instructions. Required: every type must define itself.
321
+ */
322
+ purpose: string;
317
323
  schema: z.ZodType<TEntity, z.ZodTypeDef, unknown>;
318
324
  toMarkdown(entity: TEntity): string;
319
325
  fromMarkdown(markdown: string): Partial<TEntity>;
@@ -535,6 +541,7 @@ interface BodyTemplateProvider {
535
541
  }
536
542
  interface BaseEntityAdapterConfig<TEntity extends BaseEntity<TMetadata>, TMetadata extends object> {
537
543
  entityType: string;
544
+ purpose: string;
538
545
  schema: z.ZodType<TEntity, z.ZodTypeDef, unknown>;
539
546
  frontmatterSchema: z.ZodObject<z.ZodRawShape>;
540
547
  isSingleton?: boolean;
@@ -553,6 +560,7 @@ interface BaseEntityAdapterConfig<TEntity extends BaseEntity<TMetadata>, TMetada
553
560
  */
554
561
  declare abstract class BaseEntityAdapter<TEntity extends BaseEntity<TMetadata>, TMetadata extends object = Record<string, unknown>, TFrontmatter = TMetadata> implements EntityAdapter<TEntity, TMetadata> {
555
562
  readonly entityType: string;
563
+ readonly purpose: string;
556
564
  readonly schema: z.ZodType<TEntity, z.ZodTypeDef, unknown>;
557
565
  readonly frontmatterSchema: z.ZodObject<z.ZodRawShape>;
558
566
  readonly isSingleton?: boolean;
package/dist/entities.js CHANGED
@@ -116,7 +116,7 @@ return `+str.trim()+`;
116
116
  `+$.slice(q,V),q=V+1;Y=W}if(H+=`
117
117
  `,$.length-q>G&&Y>q)H+=$.slice(q,Y)+`
118
118
  `+$.slice(Y+1);else H+=$.slice(q);return H.slice(1)}function SQ($){var G="",J=0,X;for(var q=0;q<$.length;J>=65536?q+=2:q++)if(J=j4($,q),X=L1[J],!X&&P4(J)){if(G+=$[q],J>=65536)G+=$[q+1]}else G+=X||jQ(J);return G}function CQ($,G,J){var X="",q=$.tag,V,Y,W;for(V=0,Y=J.length;V<Y;V+=1){if(W=J[V],$.replacer)W=$.replacer.call(J,String(V),W);if(R0($,G,W,!1,!1)||typeof W>"u"&&R0($,G,null,!1,!1)){if(X!=="")X+=","+(!$.condenseFlow?" ":"");X+=$.dump}}$.tag=q,$.dump="["+X+"]"}function W3($,G,J,X){var q="",V=$.tag,Y,W,H;for(Y=0,W=J.length;Y<W;Y+=1){if(H=J[Y],$.replacer)H=$.replacer.call(J,String(Y),H);if(R0($,G+1,H,!0,!0,!1,!0)||typeof H>"u"&&R0($,G+1,null,!0,!0,!1,!0)){if(!X||q!=="")q+=T9($,G);if($.dump&&Z4===$.dump.charCodeAt(0))q+="-";else q+="- ";q+=$.dump}}$.tag=V,$.dump=q||"[]"}function bQ($,G,J){var X="",q=$.tag,V=Object.keys(J),Y,W,H,U,M;for(Y=0,W=V.length;Y<W;Y+=1){if(M="",X!=="")M+=", ";if($.condenseFlow)M+='"';if(H=V[Y],U=J[H],$.replacer)U=$.replacer.call(J,H,U);if(!R0($,G,H,!1,!1))continue;if($.dump.length>1024)M+="? ";if(M+=$.dump+($.condenseFlow?'"':"")+":"+($.condenseFlow?"":" "),!R0($,G,U,!1,!1))continue;M+=$.dump,X+=M}$.tag=q,$.dump="{"+X+"}"}function xQ($,G,J,X){var q="",V=$.tag,Y=Object.keys(J),W,H,U,M,z,F;if($.sortKeys===!0)Y.sort();else if(typeof $.sortKeys==="function")Y.sort($.sortKeys);else if($.sortKeys)throw new k1("sortKeys must be a boolean or a function");for(W=0,H=Y.length;W<H;W+=1){if(F="",!X||q!=="")F+=T9($,G);if(U=Y[W],M=J[U],$.replacer)M=$.replacer.call(J,U,M);if(!R0($,G+1,U,!0,!0,!0))continue;if(z=$.tag!==null&&$.tag!=="?"||$.dump&&$.dump.length>1024,z)if($.dump&&Z4===$.dump.charCodeAt(0))F+="?";else F+="? ";if(F+=$.dump,z)F+=T9($,G);if(!R0($,G+1,M,!0,z))continue;if($.dump&&Z4===$.dump.charCodeAt(0))F+=":";else F+=": ";F+=$.dump,q+=F}$.tag=V,$.dump=q||"{}"}function H3($,G,J){var X,q,V,Y,W,H;q=J?$.explicitTypes:$.implicitTypes;for(V=0,Y=q.length;V<Y;V+=1)if(W=q[V],(W.instanceOf||W.predicate)&&(!W.instanceOf||typeof G==="object"&&G instanceof W.instanceOf)&&(!W.predicate||W.predicate(G))){if(J)if(W.multi&&W.representName)$.tag=W.representName(G);else $.tag=W.tag;else $.tag="?";if(W.represent){if(H=$.styleMap[W.tag]||W.defaultStyle,_3.call(W.represent)==="[object Function]")X=W.represent(G,H);else if(P3.call(W.represent,H))X=W.represent[H](G,H);else throw new k1("!<"+W.tag+'> tag resolver accepts not "'+H+'" style');$.dump=X}return!0}return!1}function R0($,G,J,X,q,V,Y){if($.tag=null,$.dump=J,!H3($,J,!1))H3($,J,!0);var W=_3.call($.dump),H=X,U;if(X)X=$.flowLevel<0||$.flowLevel>G;var M=W==="[object Object]"||W==="[object Array]",z,F;if(M)z=$.duplicates.indexOf(J),F=z!==-1;if($.tag!==null&&$.tag!=="?"||F||$.indent!==2&&G>0)q=!1;if(F&&$.usedDuplicates[z])$.dump="*ref_"+z;else{if(M&&F&&!$.usedDuplicates[z])$.usedDuplicates[z]=!0;if(W==="[object Object]"){if(X&&Object.keys($.dump).length!==0){if(xQ($,G,$.dump,q),F)$.dump="&ref_"+z+$.dump}else if(bQ($,G,$.dump),F)$.dump="&ref_"+z+" "+$.dump}else if(W==="[object Array]"){if(X&&$.dump.length!==0){if($.noArrayIndent&&!Y&&G>0)W3($,G-1,$.dump,q);else W3($,G,$.dump,q);if(F)$.dump="&ref_"+z+$.dump}else if(CQ($,G,$.dump),F)$.dump="&ref_"+z+" "+$.dump}else if(W==="[object String]"){if($.tag!=="?")IQ($,$.dump,G,V,H)}else if(W==="[object Undefined]")return!1;else{if($.skipInvalid)return!1;throw new k1("unacceptable kind of an object to dump "+W)}if($.tag!==null&&$.tag!=="?"){if(U=encodeURI($.tag[0]==="!"?$.tag.slice(1):$.tag).replace(/!/g,"%21"),$.tag[0]==="!")U="!"+U;else if(U.slice(0,18)==="tag:yaml.org,2002:")U="!!"+U.slice(18);else U="!<"+U+">";$.dump=U+" "+$.dump}}return!0}function vQ($,G){var J=[],X=[],q,V;E9($,J,X);for(q=0,V=X.length;q<V;q+=1)G.duplicates.push(J[X[q]]);G.usedDuplicates=Array(V)}function E9($,G,J){var X,q,V;if($!==null&&typeof $==="object")if(q=G.indexOf($),q!==-1){if(J.indexOf(q)===-1)J.push(q)}else if(G.push($),Array.isArray($))for(q=0,V=$.length;q<V;q+=1)E9($[q],G,J);else{X=Object.keys($);for(q=0,V=X.length;q<V;q+=1)E9($[X[q]],G,J)}}function kQ($,G){G=G||{};var J=new ZQ(G);if(!J.noRefs)vQ($,J);var X=$;if(J.replacer)X=J.replacer.call({"":X},"",X);if(R0(J,0,X,!0,!0))return J.dump+`
119
- `;return""}var gQ=kQ,hQ={dump:gQ};function v9($,G){return function(){throw Error("Function yaml."+$+" is removed in js-yaml 4. Use yaml."+G+" instead, which is now safe by default.")}}var{load:yQ,loadAll:vP}=Z3,mQ=hQ.dump;var kP=v9("safeLoad","load"),gP=v9("safeLoadAll","loadAll"),hP=v9("safeDump","dump");var I={};d9(I,{void:()=>_z,util:()=>a,unknown:()=>Nz,union:()=>Iz,undefined:()=>Az,tuple:()=>Cz,transformer:()=>uz,symbol:()=>Oz,string:()=>l3,strictObject:()=>Tz,setErrorMap:()=>lQ,set:()=>vz,record:()=>bz,quotelessJson:()=>uQ,promise:()=>fz,preprocess:()=>rz,pipeline:()=>dz,ostring:()=>cz,optional:()=>pz,onumber:()=>iz,oboolean:()=>oz,objectUtil:()=>k9,object:()=>Lz,number:()=>r3,nullable:()=>lz,null:()=>wz,never:()=>Zz,nativeEnum:()=>mz,nan:()=>Fz,map:()=>xz,makeIssue:()=>L4,literal:()=>hz,lazy:()=>gz,late:()=>zz,isValid:()=>b0,isDirty:()=>m5,isAsync:()=>h2,isAborted:()=>y5,intersection:()=>Sz,instanceof:()=>Kz,getParsedType:()=>V0,getErrorMap:()=>g2,function:()=>kz,enum:()=>yz,effect:()=>uz,discriminatedUnion:()=>Ez,defaultErrorMap:()=>B0,datetimeRegex:()=>f3,date:()=>Bz,custom:()=>p3,coerce:()=>nz,boolean:()=>d3,bigint:()=>Rz,array:()=>Pz,any:()=>jz,addIssueToContext:()=>C,ZodVoid:()=>I4,ZodUnknown:()=>x0,ZodUnion:()=>l2,ZodUndefined:()=>u2,ZodType:()=>o,ZodTuple:()=>H0,ZodTransformer:()=>G0,ZodSymbol:()=>T4,ZodString:()=>s1,ZodSet:()=>W2,ZodSchema:()=>o,ZodRecord:()=>E4,ZodReadonly:()=>a2,ZodPromise:()=>H2,ZodPipeline:()=>b4,ZodParsedType:()=>E,ZodOptional:()=>e1,ZodObject:()=>Y1,ZodNumber:()=>v0,ZodNullable:()=>A0,ZodNull:()=>p2,ZodNever:()=>W0,ZodNativeEnum:()=>i2,ZodNaN:()=>C4,ZodMap:()=>S4,ZodLiteral:()=>c2,ZodLazy:()=>d2,ZodIssueCode:()=>T,ZodIntersection:()=>r2,ZodFunction:()=>m2,ZodFirstPartyTypeKind:()=>p,ZodError:()=>T1,ZodEnum:()=>g0,ZodEffects:()=>G0,ZodDiscriminatedUnion:()=>f5,ZodDefault:()=>o2,ZodDate:()=>Y2,ZodCatch:()=>n2,ZodBranded:()=>u5,ZodBoolean:()=>f2,ZodBigInt:()=>k0,ZodArray:()=>t1,ZodAny:()=>V2,Schema:()=>o,ParseStatus:()=>N1,OK:()=>I1,NEVER:()=>az,INVALID:()=>u,EMPTY_PATH:()=>rQ,DIRTY:()=>q2,BRAND:()=>Qz});var a;(function($){$.assertEqual=(q)=>{};function G(q){}$.assertIs=G;function J(q){throw Error()}$.assertNever=J,$.arrayToEnum=(q)=>{let V={};for(let Y of q)V[Y]=Y;return V},$.getValidEnumValues=(q)=>{let V=$.objectKeys(q).filter((W)=>typeof q[q[W]]!=="number"),Y={};for(let W of V)Y[W]=q[W];return $.objectValues(Y)},$.objectValues=(q)=>{return $.objectKeys(q).map(function(V){return q[V]})},$.objectKeys=typeof Object.keys==="function"?(q)=>Object.keys(q):(q)=>{let V=[];for(let Y in q)if(Object.prototype.hasOwnProperty.call(q,Y))V.push(Y);return V},$.find=(q,V)=>{for(let Y of q)if(V(Y))return Y;return},$.isInteger=typeof Number.isInteger==="function"?(q)=>Number.isInteger(q):(q)=>typeof q==="number"&&Number.isFinite(q)&&Math.floor(q)===q;function X(q,V=" | "){return q.map((Y)=>typeof Y==="string"?`'${Y}'`:Y).join(V)}$.joinValues=X,$.jsonStringifyReplacer=(q,V)=>{if(typeof V==="bigint")return V.toString();return V}})(a||(a={}));var k9;(function($){$.mergeShapes=(G,J)=>{return{...G,...J}}})(k9||(k9={}));var E=a.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),V0=($)=>{switch(typeof $){case"undefined":return E.undefined;case"string":return E.string;case"number":return Number.isNaN($)?E.nan:E.number;case"boolean":return E.boolean;case"function":return E.function;case"bigint":return E.bigint;case"symbol":return E.symbol;case"object":if(Array.isArray($))return E.array;if($===null)return E.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return E.promise;if(typeof Map<"u"&&$ instanceof Map)return E.map;if(typeof Set<"u"&&$ instanceof Set)return E.set;if(typeof Date<"u"&&$ instanceof Date)return E.date;return E.object;default:return E.unknown}};var T=a.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"]),uQ=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class T1 extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(J)=>{this.issues=[...this.issues,J]},this.addIssues=(J=[])=>{this.issues=[...this.issues,...J]};let G=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,G);else this.__proto__=G;this.name="ZodError",this.issues=$}format($){let G=$||function(q){return q.message},J={_errors:[]},X=(q)=>{for(let V of q.issues)if(V.code==="invalid_union")V.unionErrors.map(X);else if(V.code==="invalid_return_type")X(V.returnTypeError);else if(V.code==="invalid_arguments")X(V.argumentsError);else if(V.path.length===0)J._errors.push(G(V));else{let Y=J,W=0;while(W<V.path.length){let H=V.path[W];if(W!==V.path.length-1)Y[H]=Y[H]||{_errors:[]};else Y[H]=Y[H]||{_errors:[]},Y[H]._errors.push(G(V));Y=Y[H],W++}}};return X(this),J}static assert($){if(!($ instanceof T1))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,a.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(G)=>G.message){let G={},J=[];for(let X of this.issues)if(X.path.length>0){let q=X.path[0];G[q]=G[q]||[],G[q].push($(X))}else J.push($(X));return{formErrors:J,fieldErrors:G}}get formErrors(){return this.flatten()}}T1.create=($)=>{return new T1($)};var pQ=($,G)=>{let J;switch($.code){case T.invalid_type:if($.received===E.undefined)J="Required";else J=`Expected ${$.expected}, received ${$.received}`;break;case T.invalid_literal:J=`Invalid literal value, expected ${JSON.stringify($.expected,a.jsonStringifyReplacer)}`;break;case T.unrecognized_keys:J=`Unrecognized key(s) in object: ${a.joinValues($.keys,", ")}`;break;case T.invalid_union:J="Invalid input";break;case T.invalid_union_discriminator:J=`Invalid discriminator value. Expected ${a.joinValues($.options)}`;break;case T.invalid_enum_value:J=`Invalid enum value. Expected ${a.joinValues($.options)}, received '${$.received}'`;break;case T.invalid_arguments:J="Invalid function arguments";break;case T.invalid_return_type:J="Invalid function return type";break;case T.invalid_date:J="Invalid date";break;case T.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(J=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")J=`${J} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)J=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)J=`Invalid input: must end with "${$.validation.endsWith}"`;else a.assertNever($.validation);else if($.validation!=="regex")J=`Invalid ${$.validation}`;else J="Invalid";break;case T.too_small:if($.type==="array")J=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")J=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")J=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")J=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")J=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else J="Invalid input";break;case T.too_big:if($.type==="array")J=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")J=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")J=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")J=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")J=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else J="Invalid input";break;case T.custom:J="Invalid input";break;case T.invalid_intersection_types:J="Intersection results could not be merged";break;case T.not_multiple_of:J=`Number must be a multiple of ${$.multipleOf}`;break;case T.not_finite:J="Number must be finite";break;default:J=G.defaultError,a.assertNever($)}return{message:J}},B0=pQ;var k3=B0;function lQ($){k3=$}function g2(){return k3}var L4=($)=>{let{data:G,path:J,errorMaps:X,issueData:q}=$,V=[...J,...q.path||[]],Y={...q,path:V};if(q.message!==void 0)return{...q,path:V,message:q.message};let W="",H=X.filter((U)=>!!U).slice().reverse();for(let U of H)W=U(Y,{data:G,defaultError:W}).message;return{...q,path:V,message:W}},rQ=[];function C($,G){let J=g2(),X=L4({issueData:G,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,J,J===B0?void 0:B0].filter((q)=>!!q)});$.common.issues.push(X)}class N1{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,G){let J=[];for(let X of G){if(X.status==="aborted")return u;if(X.status==="dirty")$.dirty();J.push(X.value)}return{status:$.value,value:J}}static async mergeObjectAsync($,G){let J=[];for(let X of G){let q=await X.key,V=await X.value;J.push({key:q,value:V})}return N1.mergeObjectSync($,J)}static mergeObjectSync($,G){let J={};for(let X of G){let{key:q,value:V}=X;if(q.status==="aborted")return u;if(V.status==="aborted")return u;if(q.status==="dirty")$.dirty();if(V.status==="dirty")$.dirty();if(q.value!=="__proto__"&&(typeof V.value<"u"||X.alwaysSet))J[q.value]=V.value}return{status:$.value,value:J}}}var u=Object.freeze({status:"aborted"}),q2=($)=>({status:"dirty",value:$}),I1=($)=>({status:"valid",value:$}),y5=($)=>$.status==="aborted",m5=($)=>$.status==="dirty",b0=($)=>$.status==="valid",h2=($)=>typeof Promise<"u"&&$ instanceof Promise;var g;(function($){$.errToObj=(G)=>typeof G==="string"?{message:G}:G||{},$.toString=(G)=>typeof G==="string"?G:G?.message})(g||(g={}));class $0{constructor($,G,J,X){this._cachedPath=[],this.parent=$,this.data=G,this._path=J,this._key=X}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var g3=($,G)=>{if(b0(G))return{success:!0,data:G.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let J=new T1($.common.issues);return this._error=J,this._error}}}};function c($){if(!$)return{};let{errorMap:G,invalid_type_error:J,required_error:X,description:q}=$;if(G&&(J||X))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(G)return{errorMap:G,description:q};return{errorMap:(Y,W)=>{let{message:H}=$;if(Y.code==="invalid_enum_value")return{message:H??W.defaultError};if(typeof W.data>"u")return{message:H??X??W.defaultError};if(Y.code!=="invalid_type")return{message:W.defaultError};return{message:H??J??W.defaultError}},description:q}}class o{get description(){return this._def.description}_getType($){return V0($.data)}_getOrReturnCtx($,G){return G||{common:$.parent.common,data:$.data,parsedType:V0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new N1,ctx:{common:$.parent.common,data:$.data,parsedType:V0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let G=this._parse($);if(h2(G))throw Error("Synchronous parse encountered promise.");return G}_parseAsync($){let G=this._parse($);return Promise.resolve(G)}parse($,G){let J=this.safeParse($,G);if(J.success)return J.data;throw J.error}safeParse($,G){let J={common:{issues:[],async:G?.async??!1,contextualErrorMap:G?.errorMap},path:G?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:V0($)},X=this._parseSync({data:$,path:J.path,parent:J});return g3(J,X)}"~validate"($){let G={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:V0($)};if(!this["~standard"].async)try{let J=this._parseSync({data:$,path:[],parent:G});return b0(J)?{value:J.value}:{issues:G.common.issues}}catch(J){if(J?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;G.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:G}).then((J)=>b0(J)?{value:J.value}:{issues:G.common.issues})}async parseAsync($,G){let J=await this.safeParseAsync($,G);if(J.success)return J.data;throw J.error}async safeParseAsync($,G){let J={common:{issues:[],contextualErrorMap:G?.errorMap,async:!0},path:G?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:V0($)},X=this._parse({data:$,path:J.path,parent:J}),q=await(h2(X)?X:Promise.resolve(X));return g3(J,q)}refine($,G){let J=(X)=>{if(typeof G==="string"||typeof G>"u")return{message:G};else if(typeof G==="function")return G(X);else return G};return this._refinement((X,q)=>{let V=$(X),Y=()=>q.addIssue({code:T.custom,...J(X)});if(typeof Promise<"u"&&V instanceof Promise)return V.then((W)=>{if(!W)return Y(),!1;else return!0});if(!V)return Y(),!1;else return!0})}refinement($,G){return this._refinement((J,X)=>{if(!$(J))return X.addIssue(typeof G==="function"?G(J,X):G),!1;else return!0})}_refinement($){return new G0({schema:this,typeName:p.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,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),this["~standard"]={version:1,vendor:"zod",validate:(G)=>this["~validate"](G)}}optional(){return e1.create(this,this._def)}nullable(){return A0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return t1.create(this)}promise(){return H2.create(this,this._def)}or($){return l2.create([this,$],this._def)}and($){return r2.create(this,$,this._def)}transform($){return new G0({...c(this._def),schema:this,typeName:p.ZodEffects,effect:{type:"transform",transform:$}})}default($){let G=typeof $==="function"?$:()=>$;return new o2({...c(this._def),innerType:this,defaultValue:G,typeName:p.ZodDefault})}brand(){return new u5({typeName:p.ZodBranded,type:this,...c(this._def)})}catch($){let G=typeof $==="function"?$:()=>$;return new n2({...c(this._def),innerType:this,catchValue:G,typeName:p.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return b4.create(this,$)}readonly(){return a2.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var dQ=/^c[^\s-]{8,}$/i,cQ=/^[0-9a-z]+$/,iQ=/^[0-9A-HJKMNP-TV-Z]{26}$/i,oQ=/^[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,nQ=/^[a-z0-9_-]{21}$/i,aQ=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,sQ=/^[-+]?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)?)??$/,tQ=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,eQ="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",g9,$z=/^(?:(?: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])$/,Gz=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,Jz=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Xz=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,qz=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Yz=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,y3="((\\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])))",Vz=new RegExp(`^${y3}$`);function m3($){let G="[0-5]\\d";if($.precision)G=`${G}\\.\\d{${$.precision}}`;else if($.precision==null)G=`${G}(\\.\\d+)?`;let J=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${G})${J}`}function Wz($){return new RegExp(`^${m3($)}$`)}function f3($){let G=`${y3}T${m3($)}`,J=[];if(J.push($.local?"Z?":"Z"),$.offset)J.push("([+-]\\d{2}:?\\d{2})");return G=`${G}(${J.join("|")})`,new RegExp(`^${G}$`)}function Hz($,G){if((G==="v4"||!G)&&$z.test($))return!0;if((G==="v6"||!G)&&Jz.test($))return!0;return!1}function Uz($,G){if(!aQ.test($))return!1;try{let[J]=$.split(".");if(!J)return!1;let X=J.replace(/-/g,"+").replace(/_/g,"/").padEnd(J.length+(4-J.length%4)%4,"="),q=JSON.parse(atob(X));if(typeof q!=="object"||q===null)return!1;if("typ"in q&&q?.typ!=="JWT")return!1;if(!q.alg)return!1;if(G&&q.alg!==G)return!1;return!0}catch{return!1}}function Mz($,G){if((G==="v4"||!G)&&Gz.test($))return!0;if((G==="v6"||!G)&&Xz.test($))return!0;return!1}class s1 extends o{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==E.string){let q=this._getOrReturnCtx($);return C(q,{code:T.invalid_type,expected:E.string,received:q.parsedType}),u}let J=new N1,X=void 0;for(let q of this._def.checks)if(q.kind==="min"){if($.data.length<q.value)X=this._getOrReturnCtx($,X),C(X,{code:T.too_small,minimum:q.value,type:"string",inclusive:!0,exact:!1,message:q.message}),J.dirty()}else if(q.kind==="max"){if($.data.length>q.value)X=this._getOrReturnCtx($,X),C(X,{code:T.too_big,maximum:q.value,type:"string",inclusive:!0,exact:!1,message:q.message}),J.dirty()}else if(q.kind==="length"){let V=$.data.length>q.value,Y=$.data.length<q.value;if(V||Y){if(X=this._getOrReturnCtx($,X),V)C(X,{code:T.too_big,maximum:q.value,type:"string",inclusive:!0,exact:!0,message:q.message});else if(Y)C(X,{code:T.too_small,minimum:q.value,type:"string",inclusive:!0,exact:!0,message:q.message});J.dirty()}}else if(q.kind==="email"){if(!tQ.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"email",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="emoji"){if(!g9)g9=new RegExp(eQ,"u");if(!g9.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"emoji",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="uuid"){if(!oQ.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"uuid",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="nanoid"){if(!nQ.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"nanoid",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="cuid"){if(!dQ.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"cuid",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="cuid2"){if(!cQ.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"cuid2",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="ulid"){if(!iQ.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"ulid",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="url")try{new URL($.data)}catch{X=this._getOrReturnCtx($,X),C(X,{validation:"url",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="regex"){if(q.regex.lastIndex=0,!q.regex.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"regex",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="trim")$.data=$.data.trim();else if(q.kind==="includes"){if(!$.data.includes(q.value,q.position))X=this._getOrReturnCtx($,X),C(X,{code:T.invalid_string,validation:{includes:q.value,position:q.position},message:q.message}),J.dirty()}else if(q.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(q.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(q.kind==="startsWith"){if(!$.data.startsWith(q.value))X=this._getOrReturnCtx($,X),C(X,{code:T.invalid_string,validation:{startsWith:q.value},message:q.message}),J.dirty()}else if(q.kind==="endsWith"){if(!$.data.endsWith(q.value))X=this._getOrReturnCtx($,X),C(X,{code:T.invalid_string,validation:{endsWith:q.value},message:q.message}),J.dirty()}else if(q.kind==="datetime"){if(!f3(q).test($.data))X=this._getOrReturnCtx($,X),C(X,{code:T.invalid_string,validation:"datetime",message:q.message}),J.dirty()}else if(q.kind==="date"){if(!Vz.test($.data))X=this._getOrReturnCtx($,X),C(X,{code:T.invalid_string,validation:"date",message:q.message}),J.dirty()}else if(q.kind==="time"){if(!Wz(q).test($.data))X=this._getOrReturnCtx($,X),C(X,{code:T.invalid_string,validation:"time",message:q.message}),J.dirty()}else if(q.kind==="duration"){if(!sQ.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"duration",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="ip"){if(!Hz($.data,q.version))X=this._getOrReturnCtx($,X),C(X,{validation:"ip",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="jwt"){if(!Uz($.data,q.alg))X=this._getOrReturnCtx($,X),C(X,{validation:"jwt",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="cidr"){if(!Mz($.data,q.version))X=this._getOrReturnCtx($,X),C(X,{validation:"cidr",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="base64"){if(!qz.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"base64",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="base64url"){if(!Yz.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"base64url",code:T.invalid_string,message:q.message}),J.dirty()}else a.assertNever(q);return{status:J.value,value:$.data}}_regex($,G,J){return this.refinement((X)=>$.test(X),{validation:G,code:T.invalid_string,...g.errToObj(J)})}_addCheck($){return new s1({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...g.errToObj($)})}url($){return this._addCheck({kind:"url",...g.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...g.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...g.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...g.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...g.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...g.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...g.errToObj($)})}base64($){return this._addCheck({kind:"base64",...g.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...g.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...g.errToObj($)})}ip($){return this._addCheck({kind:"ip",...g.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...g.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...g.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...g.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...g.errToObj($)})}regex($,G){return this._addCheck({kind:"regex",regex:$,...g.errToObj(G)})}includes($,G){return this._addCheck({kind:"includes",value:$,position:G?.position,...g.errToObj(G?.message)})}startsWith($,G){return this._addCheck({kind:"startsWith",value:$,...g.errToObj(G)})}endsWith($,G){return this._addCheck({kind:"endsWith",value:$,...g.errToObj(G)})}min($,G){return this._addCheck({kind:"min",value:$,...g.errToObj(G)})}max($,G){return this._addCheck({kind:"max",value:$,...g.errToObj(G)})}length($,G){return this._addCheck({kind:"length",value:$,...g.errToObj(G)})}nonempty($){return this.min(1,g.errToObj($))}trim(){return new s1({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new s1({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new s1({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let G of this._def.checks)if(G.kind==="min"){if($===null||G.value>$)$=G.value}return $}get maxLength(){let $=null;for(let G of this._def.checks)if(G.kind==="max"){if($===null||G.value<$)$=G.value}return $}}s1.create=($)=>{return new s1({checks:[],typeName:p.ZodString,coerce:$?.coerce??!1,...c($)})};function Dz($,G){let J=($.toString().split(".")[1]||"").length,X=(G.toString().split(".")[1]||"").length,q=J>X?J:X,V=Number.parseInt($.toFixed(q).replace(".","")),Y=Number.parseInt(G.toFixed(q).replace(".",""));return V%Y/10**q}class v0 extends o{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==E.number){let q=this._getOrReturnCtx($);return C(q,{code:T.invalid_type,expected:E.number,received:q.parsedType}),u}let J=void 0,X=new N1;for(let q of this._def.checks)if(q.kind==="int"){if(!a.isInteger($.data))J=this._getOrReturnCtx($,J),C(J,{code:T.invalid_type,expected:"integer",received:"float",message:q.message}),X.dirty()}else if(q.kind==="min"){if(q.inclusive?$.data<q.value:$.data<=q.value)J=this._getOrReturnCtx($,J),C(J,{code:T.too_small,minimum:q.value,type:"number",inclusive:q.inclusive,exact:!1,message:q.message}),X.dirty()}else if(q.kind==="max"){if(q.inclusive?$.data>q.value:$.data>=q.value)J=this._getOrReturnCtx($,J),C(J,{code:T.too_big,maximum:q.value,type:"number",inclusive:q.inclusive,exact:!1,message:q.message}),X.dirty()}else if(q.kind==="multipleOf"){if(Dz($.data,q.value)!==0)J=this._getOrReturnCtx($,J),C(J,{code:T.not_multiple_of,multipleOf:q.value,message:q.message}),X.dirty()}else if(q.kind==="finite"){if(!Number.isFinite($.data))J=this._getOrReturnCtx($,J),C(J,{code:T.not_finite,message:q.message}),X.dirty()}else a.assertNever(q);return{status:X.value,value:$.data}}gte($,G){return this.setLimit("min",$,!0,g.toString(G))}gt($,G){return this.setLimit("min",$,!1,g.toString(G))}lte($,G){return this.setLimit("max",$,!0,g.toString(G))}lt($,G){return this.setLimit("max",$,!1,g.toString(G))}setLimit($,G,J,X){return new v0({...this._def,checks:[...this._def.checks,{kind:$,value:G,inclusive:J,message:g.toString(X)}]})}_addCheck($){return new v0({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:g.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString($)})}multipleOf($,G){return this._addCheck({kind:"multipleOf",value:$,message:g.toString(G)})}finite($){return this._addCheck({kind:"finite",message:g.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.toString($)})}get minValue(){let $=null;for(let G of this._def.checks)if(G.kind==="min"){if($===null||G.value>$)$=G.value}return $}get maxValue(){let $=null;for(let G of this._def.checks)if(G.kind==="max"){if($===null||G.value<$)$=G.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&a.isInteger($.value))}get isFinite(){let $=null,G=null;for(let J of this._def.checks)if(J.kind==="finite"||J.kind==="int"||J.kind==="multipleOf")return!0;else if(J.kind==="min"){if(G===null||J.value>G)G=J.value}else if(J.kind==="max"){if($===null||J.value<$)$=J.value}return Number.isFinite(G)&&Number.isFinite($)}}v0.create=($)=>{return new v0({checks:[],typeName:p.ZodNumber,coerce:$?.coerce||!1,...c($)})};class k0 extends o{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==E.bigint)return this._getInvalidInput($);let J=void 0,X=new N1;for(let q of this._def.checks)if(q.kind==="min"){if(q.inclusive?$.data<q.value:$.data<=q.value)J=this._getOrReturnCtx($,J),C(J,{code:T.too_small,type:"bigint",minimum:q.value,inclusive:q.inclusive,message:q.message}),X.dirty()}else if(q.kind==="max"){if(q.inclusive?$.data>q.value:$.data>=q.value)J=this._getOrReturnCtx($,J),C(J,{code:T.too_big,type:"bigint",maximum:q.value,inclusive:q.inclusive,message:q.message}),X.dirty()}else if(q.kind==="multipleOf"){if($.data%q.value!==BigInt(0))J=this._getOrReturnCtx($,J),C(J,{code:T.not_multiple_of,multipleOf:q.value,message:q.message}),X.dirty()}else a.assertNever(q);return{status:X.value,value:$.data}}_getInvalidInput($){let G=this._getOrReturnCtx($);return C(G,{code:T.invalid_type,expected:E.bigint,received:G.parsedType}),u}gte($,G){return this.setLimit("min",$,!0,g.toString(G))}gt($,G){return this.setLimit("min",$,!1,g.toString(G))}lte($,G){return this.setLimit("max",$,!0,g.toString(G))}lt($,G){return this.setLimit("max",$,!1,g.toString(G))}setLimit($,G,J,X){return new k0({...this._def,checks:[...this._def.checks,{kind:$,value:G,inclusive:J,message:g.toString(X)}]})}_addCheck($){return new k0({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:g.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString($)})}multipleOf($,G){return this._addCheck({kind:"multipleOf",value:$,message:g.toString(G)})}get minValue(){let $=null;for(let G of this._def.checks)if(G.kind==="min"){if($===null||G.value>$)$=G.value}return $}get maxValue(){let $=null;for(let G of this._def.checks)if(G.kind==="max"){if($===null||G.value<$)$=G.value}return $}}k0.create=($)=>{return new k0({checks:[],typeName:p.ZodBigInt,coerce:$?.coerce??!1,...c($)})};class f2 extends o{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==E.boolean){let J=this._getOrReturnCtx($);return C(J,{code:T.invalid_type,expected:E.boolean,received:J.parsedType}),u}return I1($.data)}}f2.create=($)=>{return new f2({typeName:p.ZodBoolean,coerce:$?.coerce||!1,...c($)})};class Y2 extends o{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==E.date){let q=this._getOrReturnCtx($);return C(q,{code:T.invalid_type,expected:E.date,received:q.parsedType}),u}if(Number.isNaN($.data.getTime())){let q=this._getOrReturnCtx($);return C(q,{code:T.invalid_date}),u}let J=new N1,X=void 0;for(let q of this._def.checks)if(q.kind==="min"){if($.data.getTime()<q.value)X=this._getOrReturnCtx($,X),C(X,{code:T.too_small,message:q.message,inclusive:!0,exact:!1,minimum:q.value,type:"date"}),J.dirty()}else if(q.kind==="max"){if($.data.getTime()>q.value)X=this._getOrReturnCtx($,X),C(X,{code:T.too_big,message:q.message,inclusive:!0,exact:!1,maximum:q.value,type:"date"}),J.dirty()}else a.assertNever(q);return{status:J.value,value:new Date($.data.getTime())}}_addCheck($){return new Y2({...this._def,checks:[...this._def.checks,$]})}min($,G){return this._addCheck({kind:"min",value:$.getTime(),message:g.toString(G)})}max($,G){return this._addCheck({kind:"max",value:$.getTime(),message:g.toString(G)})}get minDate(){let $=null;for(let G of this._def.checks)if(G.kind==="min"){if($===null||G.value>$)$=G.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let G of this._def.checks)if(G.kind==="max"){if($===null||G.value<$)$=G.value}return $!=null?new Date($):null}}Y2.create=($)=>{return new Y2({checks:[],coerce:$?.coerce||!1,typeName:p.ZodDate,...c($)})};class T4 extends o{_parse($){if(this._getType($)!==E.symbol){let J=this._getOrReturnCtx($);return C(J,{code:T.invalid_type,expected:E.symbol,received:J.parsedType}),u}return I1($.data)}}T4.create=($)=>{return new T4({typeName:p.ZodSymbol,...c($)})};class u2 extends o{_parse($){if(this._getType($)!==E.undefined){let J=this._getOrReturnCtx($);return C(J,{code:T.invalid_type,expected:E.undefined,received:J.parsedType}),u}return I1($.data)}}u2.create=($)=>{return new u2({typeName:p.ZodUndefined,...c($)})};class p2 extends o{_parse($){if(this._getType($)!==E.null){let J=this._getOrReturnCtx($);return C(J,{code:T.invalid_type,expected:E.null,received:J.parsedType}),u}return I1($.data)}}p2.create=($)=>{return new p2({typeName:p.ZodNull,...c($)})};class V2 extends o{constructor(){super(...arguments);this._any=!0}_parse($){return I1($.data)}}V2.create=($)=>{return new V2({typeName:p.ZodAny,...c($)})};class x0 extends o{constructor(){super(...arguments);this._unknown=!0}_parse($){return I1($.data)}}x0.create=($)=>{return new x0({typeName:p.ZodUnknown,...c($)})};class W0 extends o{_parse($){let G=this._getOrReturnCtx($);return C(G,{code:T.invalid_type,expected:E.never,received:G.parsedType}),u}}W0.create=($)=>{return new W0({typeName:p.ZodNever,...c($)})};class I4 extends o{_parse($){if(this._getType($)!==E.undefined){let J=this._getOrReturnCtx($);return C(J,{code:T.invalid_type,expected:E.void,received:J.parsedType}),u}return I1($.data)}}I4.create=($)=>{return new I4({typeName:p.ZodVoid,...c($)})};class t1 extends o{_parse($){let{ctx:G,status:J}=this._processInputParams($),X=this._def;if(G.parsedType!==E.array)return C(G,{code:T.invalid_type,expected:E.array,received:G.parsedType}),u;if(X.exactLength!==null){let V=G.data.length>X.exactLength.value,Y=G.data.length<X.exactLength.value;if(V||Y)C(G,{code:V?T.too_big:T.too_small,minimum:Y?X.exactLength.value:void 0,maximum:V?X.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:X.exactLength.message}),J.dirty()}if(X.minLength!==null){if(G.data.length<X.minLength.value)C(G,{code:T.too_small,minimum:X.minLength.value,type:"array",inclusive:!0,exact:!1,message:X.minLength.message}),J.dirty()}if(X.maxLength!==null){if(G.data.length>X.maxLength.value)C(G,{code:T.too_big,maximum:X.maxLength.value,type:"array",inclusive:!0,exact:!1,message:X.maxLength.message}),J.dirty()}if(G.common.async)return Promise.all([...G.data].map((V,Y)=>{return X.type._parseAsync(new $0(G,V,G.path,Y))})).then((V)=>{return N1.mergeArray(J,V)});let q=[...G.data].map((V,Y)=>{return X.type._parseSync(new $0(G,V,G.path,Y))});return N1.mergeArray(J,q)}get element(){return this._def.type}min($,G){return new t1({...this._def,minLength:{value:$,message:g.toString(G)}})}max($,G){return new t1({...this._def,maxLength:{value:$,message:g.toString(G)}})}length($,G){return new t1({...this._def,exactLength:{value:$,message:g.toString(G)}})}nonempty($){return this.min(1,$)}}t1.create=($,G)=>{return new t1({type:$,minLength:null,maxLength:null,exactLength:null,typeName:p.ZodArray,...c(G)})};function y2($){if($ instanceof Y1){let G={};for(let J in $.shape){let X=$.shape[J];G[J]=e1.create(y2(X))}return new Y1({...$._def,shape:()=>G})}else if($ instanceof t1)return new t1({...$._def,type:y2($.element)});else if($ instanceof e1)return e1.create(y2($.unwrap()));else if($ instanceof A0)return A0.create(y2($.unwrap()));else if($ instanceof H0)return H0.create($.items.map((G)=>y2(G)));else return $}class Y1 extends o{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),G=a.objectKeys($);return this._cached={shape:$,keys:G},this._cached}_parse($){if(this._getType($)!==E.object){let H=this._getOrReturnCtx($);return C(H,{code:T.invalid_type,expected:E.object,received:H.parsedType}),u}let{status:J,ctx:X}=this._processInputParams($),{shape:q,keys:V}=this._getCached(),Y=[];if(!(this._def.catchall instanceof W0&&this._def.unknownKeys==="strip")){for(let H in X.data)if(!V.includes(H))Y.push(H)}let W=[];for(let H of V){let U=q[H],M=X.data[H];W.push({key:{status:"valid",value:H},value:U._parse(new $0(X,M,X.path,H)),alwaysSet:H in X.data})}if(this._def.catchall instanceof W0){let H=this._def.unknownKeys;if(H==="passthrough")for(let U of Y)W.push({key:{status:"valid",value:U},value:{status:"valid",value:X.data[U]}});else if(H==="strict"){if(Y.length>0)C(X,{code:T.unrecognized_keys,keys:Y}),J.dirty()}else if(H==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let H=this._def.catchall;for(let U of Y){let M=X.data[U];W.push({key:{status:"valid",value:U},value:H._parse(new $0(X,M,X.path,U)),alwaysSet:U in X.data})}}if(X.common.async)return Promise.resolve().then(async()=>{let H=[];for(let U of W){let M=await U.key,z=await U.value;H.push({key:M,value:z,alwaysSet:U.alwaysSet})}return H}).then((H)=>{return N1.mergeObjectSync(J,H)});else return N1.mergeObjectSync(J,W)}get shape(){return this._def.shape()}strict($){return g.errToObj,new Y1({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(G,J)=>{let X=this._def.errorMap?.(G,J).message??J.defaultError;if(G.code==="unrecognized_keys")return{message:g.errToObj($).message??X};return{message:X}}}:{}})}strip(){return new Y1({...this._def,unknownKeys:"strip"})}passthrough(){return new Y1({...this._def,unknownKeys:"passthrough"})}extend($){return new Y1({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new Y1({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:p.ZodObject})}setKey($,G){return this.augment({[$]:G})}catchall($){return new Y1({...this._def,catchall:$})}pick($){let G={};for(let J of a.objectKeys($))if($[J]&&this.shape[J])G[J]=this.shape[J];return new Y1({...this._def,shape:()=>G})}omit($){let G={};for(let J of a.objectKeys(this.shape))if(!$[J])G[J]=this.shape[J];return new Y1({...this._def,shape:()=>G})}deepPartial(){return y2(this)}partial($){let G={};for(let J of a.objectKeys(this.shape)){let X=this.shape[J];if($&&!$[J])G[J]=X;else G[J]=X.optional()}return new Y1({...this._def,shape:()=>G})}required($){let G={};for(let J of a.objectKeys(this.shape))if($&&!$[J])G[J]=this.shape[J];else{let q=this.shape[J];while(q instanceof e1)q=q._def.innerType;G[J]=q}return new Y1({...this._def,shape:()=>G})}keyof(){return u3(a.objectKeys(this.shape))}}Y1.create=($,G)=>{return new Y1({shape:()=>$,unknownKeys:"strip",catchall:W0.create(),typeName:p.ZodObject,...c(G)})};Y1.strictCreate=($,G)=>{return new Y1({shape:()=>$,unknownKeys:"strict",catchall:W0.create(),typeName:p.ZodObject,...c(G)})};Y1.lazycreate=($,G)=>{return new Y1({shape:$,unknownKeys:"strip",catchall:W0.create(),typeName:p.ZodObject,...c(G)})};class l2 extends o{_parse($){let{ctx:G}=this._processInputParams($),J=this._def.options;function X(q){for(let Y of q)if(Y.result.status==="valid")return Y.result;for(let Y of q)if(Y.result.status==="dirty")return G.common.issues.push(...Y.ctx.common.issues),Y.result;let V=q.map((Y)=>new T1(Y.ctx.common.issues));return C(G,{code:T.invalid_union,unionErrors:V}),u}if(G.common.async)return Promise.all(J.map(async(q)=>{let V={...G,common:{...G.common,issues:[]},parent:null};return{result:await q._parseAsync({data:G.data,path:G.path,parent:V}),ctx:V}})).then(X);else{let q=void 0,V=[];for(let W of J){let H={...G,common:{...G.common,issues:[]},parent:null},U=W._parseSync({data:G.data,path:G.path,parent:H});if(U.status==="valid")return U;else if(U.status==="dirty"&&!q)q={result:U,ctx:H};if(H.common.issues.length)V.push(H.common.issues)}if(q)return G.common.issues.push(...q.ctx.common.issues),q.result;let Y=V.map((W)=>new T1(W));return C(G,{code:T.invalid_union,unionErrors:Y}),u}}get options(){return this._def.options}}l2.create=($,G)=>{return new l2({options:$,typeName:p.ZodUnion,...c(G)})};var O0=($)=>{if($ instanceof d2)return O0($.schema);else if($ instanceof G0)return O0($.innerType());else if($ instanceof c2)return[$.value];else if($ instanceof g0)return $.options;else if($ instanceof i2)return a.objectValues($.enum);else if($ instanceof o2)return O0($._def.innerType);else if($ instanceof u2)return[void 0];else if($ instanceof p2)return[null];else if($ instanceof e1)return[void 0,...O0($.unwrap())];else if($ instanceof A0)return[null,...O0($.unwrap())];else if($ instanceof u5)return O0($.unwrap());else if($ instanceof a2)return O0($.unwrap());else if($ instanceof n2)return O0($._def.innerType);else return[]};class f5 extends o{_parse($){let{ctx:G}=this._processInputParams($);if(G.parsedType!==E.object)return C(G,{code:T.invalid_type,expected:E.object,received:G.parsedType}),u;let J=this.discriminator,X=G.data[J],q=this.optionsMap.get(X);if(!q)return C(G,{code:T.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[J]}),u;if(G.common.async)return q._parseAsync({data:G.data,path:G.path,parent:G});else return q._parseSync({data:G.data,path:G.path,parent:G})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,G,J){let X=new Map;for(let q of G){let V=O0(q.shape[$]);if(!V.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let Y of V){if(X.has(Y))throw Error(`Discriminator property ${String($)} has duplicate value ${String(Y)}`);X.set(Y,q)}}return new f5({typeName:p.ZodDiscriminatedUnion,discriminator:$,options:G,optionsMap:X,...c(J)})}}function h9($,G){let J=V0($),X=V0(G);if($===G)return{valid:!0,data:$};else if(J===E.object&&X===E.object){let q=a.objectKeys(G),V=a.objectKeys($).filter((W)=>q.indexOf(W)!==-1),Y={...$,...G};for(let W of V){let H=h9($[W],G[W]);if(!H.valid)return{valid:!1};Y[W]=H.data}return{valid:!0,data:Y}}else if(J===E.array&&X===E.array){if($.length!==G.length)return{valid:!1};let q=[];for(let V=0;V<$.length;V++){let Y=$[V],W=G[V],H=h9(Y,W);if(!H.valid)return{valid:!1};q.push(H.data)}return{valid:!0,data:q}}else if(J===E.date&&X===E.date&&+$===+G)return{valid:!0,data:$};else return{valid:!1}}class r2 extends o{_parse($){let{status:G,ctx:J}=this._processInputParams($),X=(q,V)=>{if(y5(q)||y5(V))return u;let Y=h9(q.value,V.value);if(!Y.valid)return C(J,{code:T.invalid_intersection_types}),u;if(m5(q)||m5(V))G.dirty();return{status:G.value,value:Y.data}};if(J.common.async)return Promise.all([this._def.left._parseAsync({data:J.data,path:J.path,parent:J}),this._def.right._parseAsync({data:J.data,path:J.path,parent:J})]).then(([q,V])=>X(q,V));else return X(this._def.left._parseSync({data:J.data,path:J.path,parent:J}),this._def.right._parseSync({data:J.data,path:J.path,parent:J}))}}r2.create=($,G,J)=>{return new r2({left:$,right:G,typeName:p.ZodIntersection,...c(J)})};class H0 extends o{_parse($){let{status:G,ctx:J}=this._processInputParams($);if(J.parsedType!==E.array)return C(J,{code:T.invalid_type,expected:E.array,received:J.parsedType}),u;if(J.data.length<this._def.items.length)return C(J,{code:T.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),u;if(!this._def.rest&&J.data.length>this._def.items.length)C(J,{code:T.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),G.dirty();let q=[...J.data].map((V,Y)=>{let W=this._def.items[Y]||this._def.rest;if(!W)return null;return W._parse(new $0(J,V,J.path,Y))}).filter((V)=>!!V);if(J.common.async)return Promise.all(q).then((V)=>{return N1.mergeArray(G,V)});else return N1.mergeArray(G,q)}get items(){return this._def.items}rest($){return new H0({...this._def,rest:$})}}H0.create=($,G)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new H0({items:$,typeName:p.ZodTuple,rest:null,...c(G)})};class E4 extends o{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:G,ctx:J}=this._processInputParams($);if(J.parsedType!==E.object)return C(J,{code:T.invalid_type,expected:E.object,received:J.parsedType}),u;let X=[],q=this._def.keyType,V=this._def.valueType;for(let Y in J.data)X.push({key:q._parse(new $0(J,Y,J.path,Y)),value:V._parse(new $0(J,J.data[Y],J.path,Y)),alwaysSet:Y in J.data});if(J.common.async)return N1.mergeObjectAsync(G,X);else return N1.mergeObjectSync(G,X)}get element(){return this._def.valueType}static create($,G,J){if(G instanceof o)return new E4({keyType:$,valueType:G,typeName:p.ZodRecord,...c(J)});return new E4({keyType:s1.create(),valueType:$,typeName:p.ZodRecord,...c(G)})}}class S4 extends o{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:G,ctx:J}=this._processInputParams($);if(J.parsedType!==E.map)return C(J,{code:T.invalid_type,expected:E.map,received:J.parsedType}),u;let X=this._def.keyType,q=this._def.valueType,V=[...J.data.entries()].map(([Y,W],H)=>{return{key:X._parse(new $0(J,Y,J.path,[H,"key"])),value:q._parse(new $0(J,W,J.path,[H,"value"]))}});if(J.common.async){let Y=new Map;return Promise.resolve().then(async()=>{for(let W of V){let H=await W.key,U=await W.value;if(H.status==="aborted"||U.status==="aborted")return u;if(H.status==="dirty"||U.status==="dirty")G.dirty();Y.set(H.value,U.value)}return{status:G.value,value:Y}})}else{let Y=new Map;for(let W of V){let{key:H,value:U}=W;if(H.status==="aborted"||U.status==="aborted")return u;if(H.status==="dirty"||U.status==="dirty")G.dirty();Y.set(H.value,U.value)}return{status:G.value,value:Y}}}}S4.create=($,G,J)=>{return new S4({valueType:G,keyType:$,typeName:p.ZodMap,...c(J)})};class W2 extends o{_parse($){let{status:G,ctx:J}=this._processInputParams($);if(J.parsedType!==E.set)return C(J,{code:T.invalid_type,expected:E.set,received:J.parsedType}),u;let X=this._def;if(X.minSize!==null){if(J.data.size<X.minSize.value)C(J,{code:T.too_small,minimum:X.minSize.value,type:"set",inclusive:!0,exact:!1,message:X.minSize.message}),G.dirty()}if(X.maxSize!==null){if(J.data.size>X.maxSize.value)C(J,{code:T.too_big,maximum:X.maxSize.value,type:"set",inclusive:!0,exact:!1,message:X.maxSize.message}),G.dirty()}let q=this._def.valueType;function V(W){let H=new Set;for(let U of W){if(U.status==="aborted")return u;if(U.status==="dirty")G.dirty();H.add(U.value)}return{status:G.value,value:H}}let Y=[...J.data.values()].map((W,H)=>q._parse(new $0(J,W,J.path,H)));if(J.common.async)return Promise.all(Y).then((W)=>V(W));else return V(Y)}min($,G){return new W2({...this._def,minSize:{value:$,message:g.toString(G)}})}max($,G){return new W2({...this._def,maxSize:{value:$,message:g.toString(G)}})}size($,G){return this.min($,G).max($,G)}nonempty($){return this.min(1,$)}}W2.create=($,G)=>{return new W2({valueType:$,minSize:null,maxSize:null,typeName:p.ZodSet,...c(G)})};class m2 extends o{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:G}=this._processInputParams($);if(G.parsedType!==E.function)return C(G,{code:T.invalid_type,expected:E.function,received:G.parsedType}),u;function J(Y,W){return L4({data:Y,path:G.path,errorMaps:[G.common.contextualErrorMap,G.schemaErrorMap,g2(),B0].filter((H)=>!!H),issueData:{code:T.invalid_arguments,argumentsError:W}})}function X(Y,W){return L4({data:Y,path:G.path,errorMaps:[G.common.contextualErrorMap,G.schemaErrorMap,g2(),B0].filter((H)=>!!H),issueData:{code:T.invalid_return_type,returnTypeError:W}})}let q={errorMap:G.common.contextualErrorMap},V=G.data;if(this._def.returns instanceof H2){let Y=this;return I1(async function(...W){let H=new T1([]),U=await Y._def.args.parseAsync(W,q).catch((F)=>{throw H.addIssue(J(W,F)),H}),M=await Reflect.apply(V,this,U);return await Y._def.returns._def.type.parseAsync(M,q).catch((F)=>{throw H.addIssue(X(M,F)),H})})}else{let Y=this;return I1(function(...W){let H=Y._def.args.safeParse(W,q);if(!H.success)throw new T1([J(W,H.error)]);let U=Reflect.apply(V,this,H.data),M=Y._def.returns.safeParse(U,q);if(!M.success)throw new T1([X(U,M.error)]);return M.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new m2({...this._def,args:H0.create($).rest(x0.create())})}returns($){return new m2({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,G,J){return new m2({args:$?$:H0.create([]).rest(x0.create()),returns:G||x0.create(),typeName:p.ZodFunction,...c(J)})}}class d2 extends o{get schema(){return this._def.getter()}_parse($){let{ctx:G}=this._processInputParams($);return this._def.getter()._parse({data:G.data,path:G.path,parent:G})}}d2.create=($,G)=>{return new d2({getter:$,typeName:p.ZodLazy,...c(G)})};class c2 extends o{_parse($){if($.data!==this._def.value){let G=this._getOrReturnCtx($);return C(G,{received:G.data,code:T.invalid_literal,expected:this._def.value}),u}return{status:"valid",value:$.data}}get value(){return this._def.value}}c2.create=($,G)=>{return new c2({value:$,typeName:p.ZodLiteral,...c(G)})};function u3($,G){return new g0({values:$,typeName:p.ZodEnum,...c(G)})}class g0 extends o{_parse($){if(typeof $.data!=="string"){let G=this._getOrReturnCtx($),J=this._def.values;return C(G,{expected:a.joinValues(J),received:G.parsedType,code:T.invalid_type}),u}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let G=this._getOrReturnCtx($),J=this._def.values;return C(G,{received:G.data,code:T.invalid_enum_value,options:J}),u}return I1($.data)}get options(){return this._def.values}get enum(){let $={};for(let G of this._def.values)$[G]=G;return $}get Values(){let $={};for(let G of this._def.values)$[G]=G;return $}get Enum(){let $={};for(let G of this._def.values)$[G]=G;return $}extract($,G=this._def){return g0.create($,{...this._def,...G})}exclude($,G=this._def){return g0.create(this.options.filter((J)=>!$.includes(J)),{...this._def,...G})}}g0.create=u3;class i2 extends o{_parse($){let G=a.getValidEnumValues(this._def.values),J=this._getOrReturnCtx($);if(J.parsedType!==E.string&&J.parsedType!==E.number){let X=a.objectValues(G);return C(J,{expected:a.joinValues(X),received:J.parsedType,code:T.invalid_type}),u}if(!this._cache)this._cache=new Set(a.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let X=a.objectValues(G);return C(J,{received:J.data,code:T.invalid_enum_value,options:X}),u}return I1($.data)}get enum(){return this._def.values}}i2.create=($,G)=>{return new i2({values:$,typeName:p.ZodNativeEnum,...c(G)})};class H2 extends o{unwrap(){return this._def.type}_parse($){let{ctx:G}=this._processInputParams($);if(G.parsedType!==E.promise&&G.common.async===!1)return C(G,{code:T.invalid_type,expected:E.promise,received:G.parsedType}),u;let J=G.parsedType===E.promise?G.data:Promise.resolve(G.data);return I1(J.then((X)=>{return this._def.type.parseAsync(X,{path:G.path,errorMap:G.common.contextualErrorMap})}))}}H2.create=($,G)=>{return new H2({type:$,typeName:p.ZodPromise,...c(G)})};class G0 extends o{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===p.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:G,ctx:J}=this._processInputParams($),X=this._def.effect||null,q={addIssue:(V)=>{if(C(J,V),V.fatal)G.abort();else G.dirty()},get path(){return J.path}};if(q.addIssue=q.addIssue.bind(q),X.type==="preprocess"){let V=X.transform(J.data,q);if(J.common.async)return Promise.resolve(V).then(async(Y)=>{if(G.value==="aborted")return u;let W=await this._def.schema._parseAsync({data:Y,path:J.path,parent:J});if(W.status==="aborted")return u;if(W.status==="dirty")return q2(W.value);if(G.value==="dirty")return q2(W.value);return W});else{if(G.value==="aborted")return u;let Y=this._def.schema._parseSync({data:V,path:J.path,parent:J});if(Y.status==="aborted")return u;if(Y.status==="dirty")return q2(Y.value);if(G.value==="dirty")return q2(Y.value);return Y}}if(X.type==="refinement"){let V=(Y)=>{let W=X.refinement(Y,q);if(J.common.async)return Promise.resolve(W);if(W instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return Y};if(J.common.async===!1){let Y=this._def.schema._parseSync({data:J.data,path:J.path,parent:J});if(Y.status==="aborted")return u;if(Y.status==="dirty")G.dirty();return V(Y.value),{status:G.value,value:Y.value}}else return this._def.schema._parseAsync({data:J.data,path:J.path,parent:J}).then((Y)=>{if(Y.status==="aborted")return u;if(Y.status==="dirty")G.dirty();return V(Y.value).then(()=>{return{status:G.value,value:Y.value}})})}if(X.type==="transform")if(J.common.async===!1){let V=this._def.schema._parseSync({data:J.data,path:J.path,parent:J});if(!b0(V))return u;let Y=X.transform(V.value,q);if(Y instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:G.value,value:Y}}else return this._def.schema._parseAsync({data:J.data,path:J.path,parent:J}).then((V)=>{if(!b0(V))return u;return Promise.resolve(X.transform(V.value,q)).then((Y)=>({status:G.value,value:Y}))});a.assertNever(X)}}G0.create=($,G,J)=>{return new G0({schema:$,typeName:p.ZodEffects,effect:G,...c(J)})};G0.createWithPreprocess=($,G,J)=>{return new G0({schema:G,effect:{type:"preprocess",transform:$},typeName:p.ZodEffects,...c(J)})};class e1 extends o{_parse($){if(this._getType($)===E.undefined)return I1(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}e1.create=($,G)=>{return new e1({innerType:$,typeName:p.ZodOptional,...c(G)})};class A0 extends o{_parse($){if(this._getType($)===E.null)return I1(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}A0.create=($,G)=>{return new A0({innerType:$,typeName:p.ZodNullable,...c(G)})};class o2 extends o{_parse($){let{ctx:G}=this._processInputParams($),J=G.data;if(G.parsedType===E.undefined)J=this._def.defaultValue();return this._def.innerType._parse({data:J,path:G.path,parent:G})}removeDefault(){return this._def.innerType}}o2.create=($,G)=>{return new o2({innerType:$,typeName:p.ZodDefault,defaultValue:typeof G.default==="function"?G.default:()=>G.default,...c(G)})};class n2 extends o{_parse($){let{ctx:G}=this._processInputParams($),J={...G,common:{...G.common,issues:[]}},X=this._def.innerType._parse({data:J.data,path:J.path,parent:{...J}});if(h2(X))return X.then((q)=>{return{status:"valid",value:q.status==="valid"?q.value:this._def.catchValue({get error(){return new T1(J.common.issues)},input:J.data})}});else return{status:"valid",value:X.status==="valid"?X.value:this._def.catchValue({get error(){return new T1(J.common.issues)},input:J.data})}}removeCatch(){return this._def.innerType}}n2.create=($,G)=>{return new n2({innerType:$,typeName:p.ZodCatch,catchValue:typeof G.catch==="function"?G.catch:()=>G.catch,...c(G)})};class C4 extends o{_parse($){if(this._getType($)!==E.nan){let J=this._getOrReturnCtx($);return C(J,{code:T.invalid_type,expected:E.nan,received:J.parsedType}),u}return{status:"valid",value:$.data}}}C4.create=($)=>{return new C4({typeName:p.ZodNaN,...c($)})};var Qz=Symbol("zod_brand");class u5 extends o{_parse($){let{ctx:G}=this._processInputParams($),J=G.data;return this._def.type._parse({data:J,path:G.path,parent:G})}unwrap(){return this._def.type}}class b4 extends o{_parse($){let{status:G,ctx:J}=this._processInputParams($);if(J.common.async)return(async()=>{let q=await this._def.in._parseAsync({data:J.data,path:J.path,parent:J});if(q.status==="aborted")return u;if(q.status==="dirty")return G.dirty(),q2(q.value);else return this._def.out._parseAsync({data:q.value,path:J.path,parent:J})})();else{let X=this._def.in._parseSync({data:J.data,path:J.path,parent:J});if(X.status==="aborted")return u;if(X.status==="dirty")return G.dirty(),{status:"dirty",value:X.value};else return this._def.out._parseSync({data:X.value,path:J.path,parent:J})}}static create($,G){return new b4({in:$,out:G,typeName:p.ZodPipeline})}}class a2 extends o{_parse($){let G=this._def.innerType._parse($),J=(X)=>{if(b0(X))X.value=Object.freeze(X.value);return X};return h2(G)?G.then((X)=>J(X)):J(G)}unwrap(){return this._def.innerType}}a2.create=($,G)=>{return new a2({innerType:$,typeName:p.ZodReadonly,...c(G)})};function h3($,G){let J=typeof $==="function"?$(G):typeof $==="string"?{message:$}:$;return typeof J==="string"?{message:J}:J}function p3($,G={},J){if($)return V2.create().superRefine((X,q)=>{let V=$(X);if(V instanceof Promise)return V.then((Y)=>{if(!Y){let W=h3(G,X),H=W.fatal??J??!0;q.addIssue({code:"custom",...W,fatal:H})}});if(!V){let Y=h3(G,X),W=Y.fatal??J??!0;q.addIssue({code:"custom",...Y,fatal:W})}return});return V2.create()}var zz={object:Y1.lazycreate},p;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(p||(p={}));var Kz=($,G={message:`Input not instance of ${$.name}`})=>p3((J)=>J instanceof $,G),l3=s1.create,r3=v0.create,Fz=C4.create,Rz=k0.create,d3=f2.create,Bz=Y2.create,Oz=T4.create,Az=u2.create,wz=p2.create,jz=V2.create,Nz=x0.create,Zz=W0.create,_z=I4.create,Pz=t1.create,Lz=Y1.create,Tz=Y1.strictCreate,Iz=l2.create,Ez=f5.create,Sz=r2.create,Cz=H0.create,bz=E4.create,xz=S4.create,vz=W2.create,kz=m2.create,gz=d2.create,hz=c2.create,yz=g0.create,mz=i2.create,fz=H2.create,uz=G0.create,pz=e1.create,lz=A0.create,rz=G0.createWithPreprocess,dz=b4.create,cz=()=>l3().optional(),iz=()=>r3().optional(),oz=()=>d3().optional(),nz={string:($)=>s1.create({...$,coerce:!0}),number:($)=>v0.create({...$,coerce:!0}),boolean:($)=>f2.create({...$,coerce:!0}),bigint:($)=>k0.create({...$,coerce:!0}),date:($)=>Y2.create({...$,coerce:!0})};var az=u;var $K=I.enum(["public","shared","restricted"]),U2=I.union([$K,I.literal("private")]).optional().transform(($)=>{if($===void 0)return"public";if($==="private")return"restricted";return $});var o3="note",p5=I.object({id:I.string(),entityType:I.string(),content:I.string(),created:I.string().datetime(),updated:I.string().datetime(),visibility:U2,metadata:I.record(I.string(),I.unknown()),contentHash:I.string()}),qK=I.object({mediaType:I.string(),url:I.string(),downloadUrl:I.string().optional(),previewUrl:I.string().optional(),filename:I.string().optional(),sizeBytes:I.number().optional(),source:I.object({entityType:I.string().optional(),entityId:I.string().optional(),attachmentType:I.string().optional()}).optional()});var gT=I.object({id:I.string().min(1,"Entity ID is required"),entityType:I.string().min(1,"Entity type is required"),contentHash:I.string().min(1,"Content hash is required"),operation:I.enum(["create","update"])});var uT=I.object({limit:I.number().int().positive().optional().default(20),offset:I.number().int().min(0).optional().default(0),types:I.array(I.string()).optional().default([]),excludeTypes:I.array(I.string()).optional().default([]),weight:I.record(I.string(),I.number()).optional(),visibilityScope:I.enum(["public","shared","restricted"]).optional(),includeUngenerated:I.boolean().optional().default(!1)});var l5=k4(T6(),1);function r5($,G){if(Object.keys(G).length===0)return $;let J=Object.fromEntries(Object.entries(G).filter(([,X])=>X!==void 0));return l5.default.stringify($,J)}function m9($){if($ instanceof Date)return $.toISOString();if(Array.isArray($))return $.map(m9);if($!==null&&typeof $==="object"){let G={};for(let[J,X]of Object.entries($))G[J]=m9(X);return G}return $}function h0($,G){let{content:J,data:X}=l5.default($),q=m9(X);return{content:J.trim(),metadata:G.parse(q)}}function d5($){if(Object.keys($).length===0)return"";let J=l5.default.stringify("",$).match(/^---\n[\s\S]*?\n---/);return J?J[0]:""}var dT=I.object({visibility:U2});var HK=I.object({field:I.string(),direction:I.enum(["asc","desc"]),nullsFirst:I.boolean().optional()}),qI=I.object({limit:I.number().int().positive().optional(),offset:I.number().int().min(0).optional().default(0),sortFields:I.array(HK).optional(),filter:I.object({metadata:I.record(I.string(),I.unknown()).optional(),visibilityScope:I.enum(["public","shared","restricted"]).optional()}).optional(),publishedOnly:I.boolean().optional()});var QI=I.object({id:I.string().min(1),entityType:I.string().min(1),contentHash:I.string().min(1)});var BK={generateBodyTemplate:()=>""};class x4{entityType;schema;frontmatterSchema;isSingleton;hasBody;supportsCoverImage;fmSchema;bodyFormatter;constructor($){if(this.entityType=$.entityType,this.schema=$.schema,this.frontmatterSchema=$.frontmatterSchema,this.fmSchema=$.frontmatterSchema,this.bodyFormatter=$.bodyFormatter??BK,$.isSingleton!==void 0)this.isSingleton=$.isSingleton;if($.hasBody!==void 0)this.hasBody=$.hasBody;if($.supportsCoverImage!==void 0)this.supportsCoverImage=$.supportsCoverImage}toMarkdown($){let G=this.renderBody($),X={...this.readExistingFrontmatter($.content)},q=Object.keys(this.frontmatterSchema.shape);for(let[V,Y]of Object.entries($.metadata))if(q.includes(V))X[V]=Y;return this.buildMarkdown(G,X)}renderBody($){return this.extractBody($.content)}readExistingFrontmatter($){try{return h0($,I.record(I.unknown())).metadata}catch{return{}}}extractMetadata($){return $.metadata}parseFrontMatter($,G){return h0($,G).metadata}getBodyTemplate(){return this.bodyFormatter.generateBodyTemplate()}generateFrontMatter($){let G=$.metadata;return d5(G)}extractBody($){try{return h0($,I.record(I.unknown())).content}catch{return $}}parseFrontmatter($){return h0($,this.fmSchema).metadata}buildMarkdown($,G){return r5($,G)}}var n3=I.object({currentPage:I.number(),totalPages:I.number(),totalItems:I.number(),pageSize:I.number(),hasNextPage:I.boolean(),hasPrevPage:I.boolean()});function a3($,G,J){let X=Math.max(1,Math.ceil($/J));return{currentPage:G,totalPages:X,totalItems:$,pageSize:J,hasNextPage:G<X,hasPrevPage:G>1}}function s3($,G){let{page:J,limit:X,pageSize:q}=G;if(J!==void 0){let V=J,Y=q??X??$.length,W=$.length,H=Math.ceil(W/Y),U=(V-1)*Y,M=U+Y;return{items:$.slice(U,M),pagination:{currentPage:V,totalPages:H,totalItems:W,pageSize:Y,hasNextPage:V<H,hasPrevPage:V>1}}}if(X!==void 0)return{items:$.slice(0,X),pagination:null};return{items:$,pagination:null}}export{h0 as parseMarkdownWithFrontmatter,n3 as paginationInfoSchema,s3 as paginateItems,r5 as generateMarkdownWithFrontmatter,d5 as generateFrontmatter,a3 as buildPaginationInfo,p5 as baseEntitySchema,o3 as NOTE_ENTITY_TYPE,x4 as BaseEntityAdapter};
119
+ `;return""}var gQ=kQ,hQ={dump:gQ};function v9($,G){return function(){throw Error("Function yaml."+$+" is removed in js-yaml 4. Use yaml."+G+" instead, which is now safe by default.")}}var{load:yQ,loadAll:vP}=Z3,mQ=hQ.dump;var kP=v9("safeLoad","load"),gP=v9("safeLoadAll","loadAll"),hP=v9("safeDump","dump");var I={};d9(I,{void:()=>_z,util:()=>a,unknown:()=>Nz,union:()=>Iz,undefined:()=>Az,tuple:()=>Cz,transformer:()=>uz,symbol:()=>Oz,string:()=>l3,strictObject:()=>Tz,setErrorMap:()=>lQ,set:()=>vz,record:()=>bz,quotelessJson:()=>uQ,promise:()=>fz,preprocess:()=>rz,pipeline:()=>dz,ostring:()=>cz,optional:()=>pz,onumber:()=>iz,oboolean:()=>oz,objectUtil:()=>k9,object:()=>Lz,number:()=>r3,nullable:()=>lz,null:()=>wz,never:()=>Zz,nativeEnum:()=>mz,nan:()=>Fz,map:()=>xz,makeIssue:()=>L4,literal:()=>hz,lazy:()=>gz,late:()=>zz,isValid:()=>b0,isDirty:()=>m5,isAsync:()=>h2,isAborted:()=>y5,intersection:()=>Sz,instanceof:()=>Kz,getParsedType:()=>V0,getErrorMap:()=>g2,function:()=>kz,enum:()=>yz,effect:()=>uz,discriminatedUnion:()=>Ez,defaultErrorMap:()=>B0,datetimeRegex:()=>f3,date:()=>Bz,custom:()=>p3,coerce:()=>nz,boolean:()=>d3,bigint:()=>Rz,array:()=>Pz,any:()=>jz,addIssueToContext:()=>C,ZodVoid:()=>I4,ZodUnknown:()=>x0,ZodUnion:()=>l2,ZodUndefined:()=>u2,ZodType:()=>o,ZodTuple:()=>H0,ZodTransformer:()=>G0,ZodSymbol:()=>T4,ZodString:()=>s1,ZodSet:()=>W2,ZodSchema:()=>o,ZodRecord:()=>E4,ZodReadonly:()=>a2,ZodPromise:()=>H2,ZodPipeline:()=>b4,ZodParsedType:()=>E,ZodOptional:()=>e1,ZodObject:()=>Y1,ZodNumber:()=>v0,ZodNullable:()=>A0,ZodNull:()=>p2,ZodNever:()=>W0,ZodNativeEnum:()=>i2,ZodNaN:()=>C4,ZodMap:()=>S4,ZodLiteral:()=>c2,ZodLazy:()=>d2,ZodIssueCode:()=>T,ZodIntersection:()=>r2,ZodFunction:()=>m2,ZodFirstPartyTypeKind:()=>p,ZodError:()=>T1,ZodEnum:()=>g0,ZodEffects:()=>G0,ZodDiscriminatedUnion:()=>f5,ZodDefault:()=>o2,ZodDate:()=>Y2,ZodCatch:()=>n2,ZodBranded:()=>u5,ZodBoolean:()=>f2,ZodBigInt:()=>k0,ZodArray:()=>t1,ZodAny:()=>V2,Schema:()=>o,ParseStatus:()=>N1,OK:()=>I1,NEVER:()=>az,INVALID:()=>u,EMPTY_PATH:()=>rQ,DIRTY:()=>q2,BRAND:()=>Qz});var a;(function($){$.assertEqual=(q)=>{};function G(q){}$.assertIs=G;function J(q){throw Error()}$.assertNever=J,$.arrayToEnum=(q)=>{let V={};for(let Y of q)V[Y]=Y;return V},$.getValidEnumValues=(q)=>{let V=$.objectKeys(q).filter((W)=>typeof q[q[W]]!=="number"),Y={};for(let W of V)Y[W]=q[W];return $.objectValues(Y)},$.objectValues=(q)=>{return $.objectKeys(q).map(function(V){return q[V]})},$.objectKeys=typeof Object.keys==="function"?(q)=>Object.keys(q):(q)=>{let V=[];for(let Y in q)if(Object.prototype.hasOwnProperty.call(q,Y))V.push(Y);return V},$.find=(q,V)=>{for(let Y of q)if(V(Y))return Y;return},$.isInteger=typeof Number.isInteger==="function"?(q)=>Number.isInteger(q):(q)=>typeof q==="number"&&Number.isFinite(q)&&Math.floor(q)===q;function X(q,V=" | "){return q.map((Y)=>typeof Y==="string"?`'${Y}'`:Y).join(V)}$.joinValues=X,$.jsonStringifyReplacer=(q,V)=>{if(typeof V==="bigint")return V.toString();return V}})(a||(a={}));var k9;(function($){$.mergeShapes=(G,J)=>{return{...G,...J}}})(k9||(k9={}));var E=a.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),V0=($)=>{switch(typeof $){case"undefined":return E.undefined;case"string":return E.string;case"number":return Number.isNaN($)?E.nan:E.number;case"boolean":return E.boolean;case"function":return E.function;case"bigint":return E.bigint;case"symbol":return E.symbol;case"object":if(Array.isArray($))return E.array;if($===null)return E.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return E.promise;if(typeof Map<"u"&&$ instanceof Map)return E.map;if(typeof Set<"u"&&$ instanceof Set)return E.set;if(typeof Date<"u"&&$ instanceof Date)return E.date;return E.object;default:return E.unknown}};var T=a.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"]),uQ=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class T1 extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(J)=>{this.issues=[...this.issues,J]},this.addIssues=(J=[])=>{this.issues=[...this.issues,...J]};let G=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,G);else this.__proto__=G;this.name="ZodError",this.issues=$}format($){let G=$||function(q){return q.message},J={_errors:[]},X=(q)=>{for(let V of q.issues)if(V.code==="invalid_union")V.unionErrors.map(X);else if(V.code==="invalid_return_type")X(V.returnTypeError);else if(V.code==="invalid_arguments")X(V.argumentsError);else if(V.path.length===0)J._errors.push(G(V));else{let Y=J,W=0;while(W<V.path.length){let H=V.path[W];if(W!==V.path.length-1)Y[H]=Y[H]||{_errors:[]};else Y[H]=Y[H]||{_errors:[]},Y[H]._errors.push(G(V));Y=Y[H],W++}}};return X(this),J}static assert($){if(!($ instanceof T1))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,a.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(G)=>G.message){let G={},J=[];for(let X of this.issues)if(X.path.length>0){let q=X.path[0];G[q]=G[q]||[],G[q].push($(X))}else J.push($(X));return{formErrors:J,fieldErrors:G}}get formErrors(){return this.flatten()}}T1.create=($)=>{return new T1($)};var pQ=($,G)=>{let J;switch($.code){case T.invalid_type:if($.received===E.undefined)J="Required";else J=`Expected ${$.expected}, received ${$.received}`;break;case T.invalid_literal:J=`Invalid literal value, expected ${JSON.stringify($.expected,a.jsonStringifyReplacer)}`;break;case T.unrecognized_keys:J=`Unrecognized key(s) in object: ${a.joinValues($.keys,", ")}`;break;case T.invalid_union:J="Invalid input";break;case T.invalid_union_discriminator:J=`Invalid discriminator value. Expected ${a.joinValues($.options)}`;break;case T.invalid_enum_value:J=`Invalid enum value. Expected ${a.joinValues($.options)}, received '${$.received}'`;break;case T.invalid_arguments:J="Invalid function arguments";break;case T.invalid_return_type:J="Invalid function return type";break;case T.invalid_date:J="Invalid date";break;case T.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(J=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")J=`${J} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)J=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)J=`Invalid input: must end with "${$.validation.endsWith}"`;else a.assertNever($.validation);else if($.validation!=="regex")J=`Invalid ${$.validation}`;else J="Invalid";break;case T.too_small:if($.type==="array")J=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")J=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")J=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")J=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")J=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else J="Invalid input";break;case T.too_big:if($.type==="array")J=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")J=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")J=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")J=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")J=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else J="Invalid input";break;case T.custom:J="Invalid input";break;case T.invalid_intersection_types:J="Intersection results could not be merged";break;case T.not_multiple_of:J=`Number must be a multiple of ${$.multipleOf}`;break;case T.not_finite:J="Number must be finite";break;default:J=G.defaultError,a.assertNever($)}return{message:J}},B0=pQ;var k3=B0;function lQ($){k3=$}function g2(){return k3}var L4=($)=>{let{data:G,path:J,errorMaps:X,issueData:q}=$,V=[...J,...q.path||[]],Y={...q,path:V};if(q.message!==void 0)return{...q,path:V,message:q.message};let W="",H=X.filter((U)=>!!U).slice().reverse();for(let U of H)W=U(Y,{data:G,defaultError:W}).message;return{...q,path:V,message:W}},rQ=[];function C($,G){let J=g2(),X=L4({issueData:G,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,J,J===B0?void 0:B0].filter((q)=>!!q)});$.common.issues.push(X)}class N1{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,G){let J=[];for(let X of G){if(X.status==="aborted")return u;if(X.status==="dirty")$.dirty();J.push(X.value)}return{status:$.value,value:J}}static async mergeObjectAsync($,G){let J=[];for(let X of G){let q=await X.key,V=await X.value;J.push({key:q,value:V})}return N1.mergeObjectSync($,J)}static mergeObjectSync($,G){let J={};for(let X of G){let{key:q,value:V}=X;if(q.status==="aborted")return u;if(V.status==="aborted")return u;if(q.status==="dirty")$.dirty();if(V.status==="dirty")$.dirty();if(q.value!=="__proto__"&&(typeof V.value<"u"||X.alwaysSet))J[q.value]=V.value}return{status:$.value,value:J}}}var u=Object.freeze({status:"aborted"}),q2=($)=>({status:"dirty",value:$}),I1=($)=>({status:"valid",value:$}),y5=($)=>$.status==="aborted",m5=($)=>$.status==="dirty",b0=($)=>$.status==="valid",h2=($)=>typeof Promise<"u"&&$ instanceof Promise;var g;(function($){$.errToObj=(G)=>typeof G==="string"?{message:G}:G||{},$.toString=(G)=>typeof G==="string"?G:G?.message})(g||(g={}));class $0{constructor($,G,J,X){this._cachedPath=[],this.parent=$,this.data=G,this._path=J,this._key=X}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var g3=($,G)=>{if(b0(G))return{success:!0,data:G.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let J=new T1($.common.issues);return this._error=J,this._error}}}};function c($){if(!$)return{};let{errorMap:G,invalid_type_error:J,required_error:X,description:q}=$;if(G&&(J||X))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(G)return{errorMap:G,description:q};return{errorMap:(Y,W)=>{let{message:H}=$;if(Y.code==="invalid_enum_value")return{message:H??W.defaultError};if(typeof W.data>"u")return{message:H??X??W.defaultError};if(Y.code!=="invalid_type")return{message:W.defaultError};return{message:H??J??W.defaultError}},description:q}}class o{get description(){return this._def.description}_getType($){return V0($.data)}_getOrReturnCtx($,G){return G||{common:$.parent.common,data:$.data,parsedType:V0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new N1,ctx:{common:$.parent.common,data:$.data,parsedType:V0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let G=this._parse($);if(h2(G))throw Error("Synchronous parse encountered promise.");return G}_parseAsync($){let G=this._parse($);return Promise.resolve(G)}parse($,G){let J=this.safeParse($,G);if(J.success)return J.data;throw J.error}safeParse($,G){let J={common:{issues:[],async:G?.async??!1,contextualErrorMap:G?.errorMap},path:G?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:V0($)},X=this._parseSync({data:$,path:J.path,parent:J});return g3(J,X)}"~validate"($){let G={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:V0($)};if(!this["~standard"].async)try{let J=this._parseSync({data:$,path:[],parent:G});return b0(J)?{value:J.value}:{issues:G.common.issues}}catch(J){if(J?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;G.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:G}).then((J)=>b0(J)?{value:J.value}:{issues:G.common.issues})}async parseAsync($,G){let J=await this.safeParseAsync($,G);if(J.success)return J.data;throw J.error}async safeParseAsync($,G){let J={common:{issues:[],contextualErrorMap:G?.errorMap,async:!0},path:G?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:V0($)},X=this._parse({data:$,path:J.path,parent:J}),q=await(h2(X)?X:Promise.resolve(X));return g3(J,q)}refine($,G){let J=(X)=>{if(typeof G==="string"||typeof G>"u")return{message:G};else if(typeof G==="function")return G(X);else return G};return this._refinement((X,q)=>{let V=$(X),Y=()=>q.addIssue({code:T.custom,...J(X)});if(typeof Promise<"u"&&V instanceof Promise)return V.then((W)=>{if(!W)return Y(),!1;else return!0});if(!V)return Y(),!1;else return!0})}refinement($,G){return this._refinement((J,X)=>{if(!$(J))return X.addIssue(typeof G==="function"?G(J,X):G),!1;else return!0})}_refinement($){return new G0({schema:this,typeName:p.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,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),this["~standard"]={version:1,vendor:"zod",validate:(G)=>this["~validate"](G)}}optional(){return e1.create(this,this._def)}nullable(){return A0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return t1.create(this)}promise(){return H2.create(this,this._def)}or($){return l2.create([this,$],this._def)}and($){return r2.create(this,$,this._def)}transform($){return new G0({...c(this._def),schema:this,typeName:p.ZodEffects,effect:{type:"transform",transform:$}})}default($){let G=typeof $==="function"?$:()=>$;return new o2({...c(this._def),innerType:this,defaultValue:G,typeName:p.ZodDefault})}brand(){return new u5({typeName:p.ZodBranded,type:this,...c(this._def)})}catch($){let G=typeof $==="function"?$:()=>$;return new n2({...c(this._def),innerType:this,catchValue:G,typeName:p.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return b4.create(this,$)}readonly(){return a2.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var dQ=/^c[^\s-]{8,}$/i,cQ=/^[0-9a-z]+$/,iQ=/^[0-9A-HJKMNP-TV-Z]{26}$/i,oQ=/^[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,nQ=/^[a-z0-9_-]{21}$/i,aQ=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,sQ=/^[-+]?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)?)??$/,tQ=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,eQ="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",g9,$z=/^(?:(?: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])$/,Gz=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,Jz=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Xz=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,qz=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Yz=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,y3="((\\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])))",Vz=new RegExp(`^${y3}$`);function m3($){let G="[0-5]\\d";if($.precision)G=`${G}\\.\\d{${$.precision}}`;else if($.precision==null)G=`${G}(\\.\\d+)?`;let J=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${G})${J}`}function Wz($){return new RegExp(`^${m3($)}$`)}function f3($){let G=`${y3}T${m3($)}`,J=[];if(J.push($.local?"Z?":"Z"),$.offset)J.push("([+-]\\d{2}:?\\d{2})");return G=`${G}(${J.join("|")})`,new RegExp(`^${G}$`)}function Hz($,G){if((G==="v4"||!G)&&$z.test($))return!0;if((G==="v6"||!G)&&Jz.test($))return!0;return!1}function Uz($,G){if(!aQ.test($))return!1;try{let[J]=$.split(".");if(!J)return!1;let X=J.replace(/-/g,"+").replace(/_/g,"/").padEnd(J.length+(4-J.length%4)%4,"="),q=JSON.parse(atob(X));if(typeof q!=="object"||q===null)return!1;if("typ"in q&&q?.typ!=="JWT")return!1;if(!q.alg)return!1;if(G&&q.alg!==G)return!1;return!0}catch{return!1}}function Mz($,G){if((G==="v4"||!G)&&Gz.test($))return!0;if((G==="v6"||!G)&&Xz.test($))return!0;return!1}class s1 extends o{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==E.string){let q=this._getOrReturnCtx($);return C(q,{code:T.invalid_type,expected:E.string,received:q.parsedType}),u}let J=new N1,X=void 0;for(let q of this._def.checks)if(q.kind==="min"){if($.data.length<q.value)X=this._getOrReturnCtx($,X),C(X,{code:T.too_small,minimum:q.value,type:"string",inclusive:!0,exact:!1,message:q.message}),J.dirty()}else if(q.kind==="max"){if($.data.length>q.value)X=this._getOrReturnCtx($,X),C(X,{code:T.too_big,maximum:q.value,type:"string",inclusive:!0,exact:!1,message:q.message}),J.dirty()}else if(q.kind==="length"){let V=$.data.length>q.value,Y=$.data.length<q.value;if(V||Y){if(X=this._getOrReturnCtx($,X),V)C(X,{code:T.too_big,maximum:q.value,type:"string",inclusive:!0,exact:!0,message:q.message});else if(Y)C(X,{code:T.too_small,minimum:q.value,type:"string",inclusive:!0,exact:!0,message:q.message});J.dirty()}}else if(q.kind==="email"){if(!tQ.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"email",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="emoji"){if(!g9)g9=new RegExp(eQ,"u");if(!g9.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"emoji",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="uuid"){if(!oQ.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"uuid",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="nanoid"){if(!nQ.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"nanoid",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="cuid"){if(!dQ.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"cuid",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="cuid2"){if(!cQ.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"cuid2",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="ulid"){if(!iQ.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"ulid",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="url")try{new URL($.data)}catch{X=this._getOrReturnCtx($,X),C(X,{validation:"url",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="regex"){if(q.regex.lastIndex=0,!q.regex.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"regex",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="trim")$.data=$.data.trim();else if(q.kind==="includes"){if(!$.data.includes(q.value,q.position))X=this._getOrReturnCtx($,X),C(X,{code:T.invalid_string,validation:{includes:q.value,position:q.position},message:q.message}),J.dirty()}else if(q.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(q.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(q.kind==="startsWith"){if(!$.data.startsWith(q.value))X=this._getOrReturnCtx($,X),C(X,{code:T.invalid_string,validation:{startsWith:q.value},message:q.message}),J.dirty()}else if(q.kind==="endsWith"){if(!$.data.endsWith(q.value))X=this._getOrReturnCtx($,X),C(X,{code:T.invalid_string,validation:{endsWith:q.value},message:q.message}),J.dirty()}else if(q.kind==="datetime"){if(!f3(q).test($.data))X=this._getOrReturnCtx($,X),C(X,{code:T.invalid_string,validation:"datetime",message:q.message}),J.dirty()}else if(q.kind==="date"){if(!Vz.test($.data))X=this._getOrReturnCtx($,X),C(X,{code:T.invalid_string,validation:"date",message:q.message}),J.dirty()}else if(q.kind==="time"){if(!Wz(q).test($.data))X=this._getOrReturnCtx($,X),C(X,{code:T.invalid_string,validation:"time",message:q.message}),J.dirty()}else if(q.kind==="duration"){if(!sQ.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"duration",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="ip"){if(!Hz($.data,q.version))X=this._getOrReturnCtx($,X),C(X,{validation:"ip",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="jwt"){if(!Uz($.data,q.alg))X=this._getOrReturnCtx($,X),C(X,{validation:"jwt",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="cidr"){if(!Mz($.data,q.version))X=this._getOrReturnCtx($,X),C(X,{validation:"cidr",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="base64"){if(!qz.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"base64",code:T.invalid_string,message:q.message}),J.dirty()}else if(q.kind==="base64url"){if(!Yz.test($.data))X=this._getOrReturnCtx($,X),C(X,{validation:"base64url",code:T.invalid_string,message:q.message}),J.dirty()}else a.assertNever(q);return{status:J.value,value:$.data}}_regex($,G,J){return this.refinement((X)=>$.test(X),{validation:G,code:T.invalid_string,...g.errToObj(J)})}_addCheck($){return new s1({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...g.errToObj($)})}url($){return this._addCheck({kind:"url",...g.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...g.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...g.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...g.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...g.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...g.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...g.errToObj($)})}base64($){return this._addCheck({kind:"base64",...g.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...g.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...g.errToObj($)})}ip($){return this._addCheck({kind:"ip",...g.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...g.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...g.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...g.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...g.errToObj($)})}regex($,G){return this._addCheck({kind:"regex",regex:$,...g.errToObj(G)})}includes($,G){return this._addCheck({kind:"includes",value:$,position:G?.position,...g.errToObj(G?.message)})}startsWith($,G){return this._addCheck({kind:"startsWith",value:$,...g.errToObj(G)})}endsWith($,G){return this._addCheck({kind:"endsWith",value:$,...g.errToObj(G)})}min($,G){return this._addCheck({kind:"min",value:$,...g.errToObj(G)})}max($,G){return this._addCheck({kind:"max",value:$,...g.errToObj(G)})}length($,G){return this._addCheck({kind:"length",value:$,...g.errToObj(G)})}nonempty($){return this.min(1,g.errToObj($))}trim(){return new s1({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new s1({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new s1({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let G of this._def.checks)if(G.kind==="min"){if($===null||G.value>$)$=G.value}return $}get maxLength(){let $=null;for(let G of this._def.checks)if(G.kind==="max"){if($===null||G.value<$)$=G.value}return $}}s1.create=($)=>{return new s1({checks:[],typeName:p.ZodString,coerce:$?.coerce??!1,...c($)})};function Dz($,G){let J=($.toString().split(".")[1]||"").length,X=(G.toString().split(".")[1]||"").length,q=J>X?J:X,V=Number.parseInt($.toFixed(q).replace(".","")),Y=Number.parseInt(G.toFixed(q).replace(".",""));return V%Y/10**q}class v0 extends o{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==E.number){let q=this._getOrReturnCtx($);return C(q,{code:T.invalid_type,expected:E.number,received:q.parsedType}),u}let J=void 0,X=new N1;for(let q of this._def.checks)if(q.kind==="int"){if(!a.isInteger($.data))J=this._getOrReturnCtx($,J),C(J,{code:T.invalid_type,expected:"integer",received:"float",message:q.message}),X.dirty()}else if(q.kind==="min"){if(q.inclusive?$.data<q.value:$.data<=q.value)J=this._getOrReturnCtx($,J),C(J,{code:T.too_small,minimum:q.value,type:"number",inclusive:q.inclusive,exact:!1,message:q.message}),X.dirty()}else if(q.kind==="max"){if(q.inclusive?$.data>q.value:$.data>=q.value)J=this._getOrReturnCtx($,J),C(J,{code:T.too_big,maximum:q.value,type:"number",inclusive:q.inclusive,exact:!1,message:q.message}),X.dirty()}else if(q.kind==="multipleOf"){if(Dz($.data,q.value)!==0)J=this._getOrReturnCtx($,J),C(J,{code:T.not_multiple_of,multipleOf:q.value,message:q.message}),X.dirty()}else if(q.kind==="finite"){if(!Number.isFinite($.data))J=this._getOrReturnCtx($,J),C(J,{code:T.not_finite,message:q.message}),X.dirty()}else a.assertNever(q);return{status:X.value,value:$.data}}gte($,G){return this.setLimit("min",$,!0,g.toString(G))}gt($,G){return this.setLimit("min",$,!1,g.toString(G))}lte($,G){return this.setLimit("max",$,!0,g.toString(G))}lt($,G){return this.setLimit("max",$,!1,g.toString(G))}setLimit($,G,J,X){return new v0({...this._def,checks:[...this._def.checks,{kind:$,value:G,inclusive:J,message:g.toString(X)}]})}_addCheck($){return new v0({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:g.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString($)})}multipleOf($,G){return this._addCheck({kind:"multipleOf",value:$,message:g.toString(G)})}finite($){return this._addCheck({kind:"finite",message:g.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.toString($)})}get minValue(){let $=null;for(let G of this._def.checks)if(G.kind==="min"){if($===null||G.value>$)$=G.value}return $}get maxValue(){let $=null;for(let G of this._def.checks)if(G.kind==="max"){if($===null||G.value<$)$=G.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&a.isInteger($.value))}get isFinite(){let $=null,G=null;for(let J of this._def.checks)if(J.kind==="finite"||J.kind==="int"||J.kind==="multipleOf")return!0;else if(J.kind==="min"){if(G===null||J.value>G)G=J.value}else if(J.kind==="max"){if($===null||J.value<$)$=J.value}return Number.isFinite(G)&&Number.isFinite($)}}v0.create=($)=>{return new v0({checks:[],typeName:p.ZodNumber,coerce:$?.coerce||!1,...c($)})};class k0 extends o{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==E.bigint)return this._getInvalidInput($);let J=void 0,X=new N1;for(let q of this._def.checks)if(q.kind==="min"){if(q.inclusive?$.data<q.value:$.data<=q.value)J=this._getOrReturnCtx($,J),C(J,{code:T.too_small,type:"bigint",minimum:q.value,inclusive:q.inclusive,message:q.message}),X.dirty()}else if(q.kind==="max"){if(q.inclusive?$.data>q.value:$.data>=q.value)J=this._getOrReturnCtx($,J),C(J,{code:T.too_big,type:"bigint",maximum:q.value,inclusive:q.inclusive,message:q.message}),X.dirty()}else if(q.kind==="multipleOf"){if($.data%q.value!==BigInt(0))J=this._getOrReturnCtx($,J),C(J,{code:T.not_multiple_of,multipleOf:q.value,message:q.message}),X.dirty()}else a.assertNever(q);return{status:X.value,value:$.data}}_getInvalidInput($){let G=this._getOrReturnCtx($);return C(G,{code:T.invalid_type,expected:E.bigint,received:G.parsedType}),u}gte($,G){return this.setLimit("min",$,!0,g.toString(G))}gt($,G){return this.setLimit("min",$,!1,g.toString(G))}lte($,G){return this.setLimit("max",$,!0,g.toString(G))}lt($,G){return this.setLimit("max",$,!1,g.toString(G))}setLimit($,G,J,X){return new k0({...this._def,checks:[...this._def.checks,{kind:$,value:G,inclusive:J,message:g.toString(X)}]})}_addCheck($){return new k0({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:g.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString($)})}multipleOf($,G){return this._addCheck({kind:"multipleOf",value:$,message:g.toString(G)})}get minValue(){let $=null;for(let G of this._def.checks)if(G.kind==="min"){if($===null||G.value>$)$=G.value}return $}get maxValue(){let $=null;for(let G of this._def.checks)if(G.kind==="max"){if($===null||G.value<$)$=G.value}return $}}k0.create=($)=>{return new k0({checks:[],typeName:p.ZodBigInt,coerce:$?.coerce??!1,...c($)})};class f2 extends o{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==E.boolean){let J=this._getOrReturnCtx($);return C(J,{code:T.invalid_type,expected:E.boolean,received:J.parsedType}),u}return I1($.data)}}f2.create=($)=>{return new f2({typeName:p.ZodBoolean,coerce:$?.coerce||!1,...c($)})};class Y2 extends o{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==E.date){let q=this._getOrReturnCtx($);return C(q,{code:T.invalid_type,expected:E.date,received:q.parsedType}),u}if(Number.isNaN($.data.getTime())){let q=this._getOrReturnCtx($);return C(q,{code:T.invalid_date}),u}let J=new N1,X=void 0;for(let q of this._def.checks)if(q.kind==="min"){if($.data.getTime()<q.value)X=this._getOrReturnCtx($,X),C(X,{code:T.too_small,message:q.message,inclusive:!0,exact:!1,minimum:q.value,type:"date"}),J.dirty()}else if(q.kind==="max"){if($.data.getTime()>q.value)X=this._getOrReturnCtx($,X),C(X,{code:T.too_big,message:q.message,inclusive:!0,exact:!1,maximum:q.value,type:"date"}),J.dirty()}else a.assertNever(q);return{status:J.value,value:new Date($.data.getTime())}}_addCheck($){return new Y2({...this._def,checks:[...this._def.checks,$]})}min($,G){return this._addCheck({kind:"min",value:$.getTime(),message:g.toString(G)})}max($,G){return this._addCheck({kind:"max",value:$.getTime(),message:g.toString(G)})}get minDate(){let $=null;for(let G of this._def.checks)if(G.kind==="min"){if($===null||G.value>$)$=G.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let G of this._def.checks)if(G.kind==="max"){if($===null||G.value<$)$=G.value}return $!=null?new Date($):null}}Y2.create=($)=>{return new Y2({checks:[],coerce:$?.coerce||!1,typeName:p.ZodDate,...c($)})};class T4 extends o{_parse($){if(this._getType($)!==E.symbol){let J=this._getOrReturnCtx($);return C(J,{code:T.invalid_type,expected:E.symbol,received:J.parsedType}),u}return I1($.data)}}T4.create=($)=>{return new T4({typeName:p.ZodSymbol,...c($)})};class u2 extends o{_parse($){if(this._getType($)!==E.undefined){let J=this._getOrReturnCtx($);return C(J,{code:T.invalid_type,expected:E.undefined,received:J.parsedType}),u}return I1($.data)}}u2.create=($)=>{return new u2({typeName:p.ZodUndefined,...c($)})};class p2 extends o{_parse($){if(this._getType($)!==E.null){let J=this._getOrReturnCtx($);return C(J,{code:T.invalid_type,expected:E.null,received:J.parsedType}),u}return I1($.data)}}p2.create=($)=>{return new p2({typeName:p.ZodNull,...c($)})};class V2 extends o{constructor(){super(...arguments);this._any=!0}_parse($){return I1($.data)}}V2.create=($)=>{return new V2({typeName:p.ZodAny,...c($)})};class x0 extends o{constructor(){super(...arguments);this._unknown=!0}_parse($){return I1($.data)}}x0.create=($)=>{return new x0({typeName:p.ZodUnknown,...c($)})};class W0 extends o{_parse($){let G=this._getOrReturnCtx($);return C(G,{code:T.invalid_type,expected:E.never,received:G.parsedType}),u}}W0.create=($)=>{return new W0({typeName:p.ZodNever,...c($)})};class I4 extends o{_parse($){if(this._getType($)!==E.undefined){let J=this._getOrReturnCtx($);return C(J,{code:T.invalid_type,expected:E.void,received:J.parsedType}),u}return I1($.data)}}I4.create=($)=>{return new I4({typeName:p.ZodVoid,...c($)})};class t1 extends o{_parse($){let{ctx:G,status:J}=this._processInputParams($),X=this._def;if(G.parsedType!==E.array)return C(G,{code:T.invalid_type,expected:E.array,received:G.parsedType}),u;if(X.exactLength!==null){let V=G.data.length>X.exactLength.value,Y=G.data.length<X.exactLength.value;if(V||Y)C(G,{code:V?T.too_big:T.too_small,minimum:Y?X.exactLength.value:void 0,maximum:V?X.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:X.exactLength.message}),J.dirty()}if(X.minLength!==null){if(G.data.length<X.minLength.value)C(G,{code:T.too_small,minimum:X.minLength.value,type:"array",inclusive:!0,exact:!1,message:X.minLength.message}),J.dirty()}if(X.maxLength!==null){if(G.data.length>X.maxLength.value)C(G,{code:T.too_big,maximum:X.maxLength.value,type:"array",inclusive:!0,exact:!1,message:X.maxLength.message}),J.dirty()}if(G.common.async)return Promise.all([...G.data].map((V,Y)=>{return X.type._parseAsync(new $0(G,V,G.path,Y))})).then((V)=>{return N1.mergeArray(J,V)});let q=[...G.data].map((V,Y)=>{return X.type._parseSync(new $0(G,V,G.path,Y))});return N1.mergeArray(J,q)}get element(){return this._def.type}min($,G){return new t1({...this._def,minLength:{value:$,message:g.toString(G)}})}max($,G){return new t1({...this._def,maxLength:{value:$,message:g.toString(G)}})}length($,G){return new t1({...this._def,exactLength:{value:$,message:g.toString(G)}})}nonempty($){return this.min(1,$)}}t1.create=($,G)=>{return new t1({type:$,minLength:null,maxLength:null,exactLength:null,typeName:p.ZodArray,...c(G)})};function y2($){if($ instanceof Y1){let G={};for(let J in $.shape){let X=$.shape[J];G[J]=e1.create(y2(X))}return new Y1({...$._def,shape:()=>G})}else if($ instanceof t1)return new t1({...$._def,type:y2($.element)});else if($ instanceof e1)return e1.create(y2($.unwrap()));else if($ instanceof A0)return A0.create(y2($.unwrap()));else if($ instanceof H0)return H0.create($.items.map((G)=>y2(G)));else return $}class Y1 extends o{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),G=a.objectKeys($);return this._cached={shape:$,keys:G},this._cached}_parse($){if(this._getType($)!==E.object){let H=this._getOrReturnCtx($);return C(H,{code:T.invalid_type,expected:E.object,received:H.parsedType}),u}let{status:J,ctx:X}=this._processInputParams($),{shape:q,keys:V}=this._getCached(),Y=[];if(!(this._def.catchall instanceof W0&&this._def.unknownKeys==="strip")){for(let H in X.data)if(!V.includes(H))Y.push(H)}let W=[];for(let H of V){let U=q[H],M=X.data[H];W.push({key:{status:"valid",value:H},value:U._parse(new $0(X,M,X.path,H)),alwaysSet:H in X.data})}if(this._def.catchall instanceof W0){let H=this._def.unknownKeys;if(H==="passthrough")for(let U of Y)W.push({key:{status:"valid",value:U},value:{status:"valid",value:X.data[U]}});else if(H==="strict"){if(Y.length>0)C(X,{code:T.unrecognized_keys,keys:Y}),J.dirty()}else if(H==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let H=this._def.catchall;for(let U of Y){let M=X.data[U];W.push({key:{status:"valid",value:U},value:H._parse(new $0(X,M,X.path,U)),alwaysSet:U in X.data})}}if(X.common.async)return Promise.resolve().then(async()=>{let H=[];for(let U of W){let M=await U.key,z=await U.value;H.push({key:M,value:z,alwaysSet:U.alwaysSet})}return H}).then((H)=>{return N1.mergeObjectSync(J,H)});else return N1.mergeObjectSync(J,W)}get shape(){return this._def.shape()}strict($){return g.errToObj,new Y1({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(G,J)=>{let X=this._def.errorMap?.(G,J).message??J.defaultError;if(G.code==="unrecognized_keys")return{message:g.errToObj($).message??X};return{message:X}}}:{}})}strip(){return new Y1({...this._def,unknownKeys:"strip"})}passthrough(){return new Y1({...this._def,unknownKeys:"passthrough"})}extend($){return new Y1({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new Y1({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:p.ZodObject})}setKey($,G){return this.augment({[$]:G})}catchall($){return new Y1({...this._def,catchall:$})}pick($){let G={};for(let J of a.objectKeys($))if($[J]&&this.shape[J])G[J]=this.shape[J];return new Y1({...this._def,shape:()=>G})}omit($){let G={};for(let J of a.objectKeys(this.shape))if(!$[J])G[J]=this.shape[J];return new Y1({...this._def,shape:()=>G})}deepPartial(){return y2(this)}partial($){let G={};for(let J of a.objectKeys(this.shape)){let X=this.shape[J];if($&&!$[J])G[J]=X;else G[J]=X.optional()}return new Y1({...this._def,shape:()=>G})}required($){let G={};for(let J of a.objectKeys(this.shape))if($&&!$[J])G[J]=this.shape[J];else{let q=this.shape[J];while(q instanceof e1)q=q._def.innerType;G[J]=q}return new Y1({...this._def,shape:()=>G})}keyof(){return u3(a.objectKeys(this.shape))}}Y1.create=($,G)=>{return new Y1({shape:()=>$,unknownKeys:"strip",catchall:W0.create(),typeName:p.ZodObject,...c(G)})};Y1.strictCreate=($,G)=>{return new Y1({shape:()=>$,unknownKeys:"strict",catchall:W0.create(),typeName:p.ZodObject,...c(G)})};Y1.lazycreate=($,G)=>{return new Y1({shape:$,unknownKeys:"strip",catchall:W0.create(),typeName:p.ZodObject,...c(G)})};class l2 extends o{_parse($){let{ctx:G}=this._processInputParams($),J=this._def.options;function X(q){for(let Y of q)if(Y.result.status==="valid")return Y.result;for(let Y of q)if(Y.result.status==="dirty")return G.common.issues.push(...Y.ctx.common.issues),Y.result;let V=q.map((Y)=>new T1(Y.ctx.common.issues));return C(G,{code:T.invalid_union,unionErrors:V}),u}if(G.common.async)return Promise.all(J.map(async(q)=>{let V={...G,common:{...G.common,issues:[]},parent:null};return{result:await q._parseAsync({data:G.data,path:G.path,parent:V}),ctx:V}})).then(X);else{let q=void 0,V=[];for(let W of J){let H={...G,common:{...G.common,issues:[]},parent:null},U=W._parseSync({data:G.data,path:G.path,parent:H});if(U.status==="valid")return U;else if(U.status==="dirty"&&!q)q={result:U,ctx:H};if(H.common.issues.length)V.push(H.common.issues)}if(q)return G.common.issues.push(...q.ctx.common.issues),q.result;let Y=V.map((W)=>new T1(W));return C(G,{code:T.invalid_union,unionErrors:Y}),u}}get options(){return this._def.options}}l2.create=($,G)=>{return new l2({options:$,typeName:p.ZodUnion,...c(G)})};var O0=($)=>{if($ instanceof d2)return O0($.schema);else if($ instanceof G0)return O0($.innerType());else if($ instanceof c2)return[$.value];else if($ instanceof g0)return $.options;else if($ instanceof i2)return a.objectValues($.enum);else if($ instanceof o2)return O0($._def.innerType);else if($ instanceof u2)return[void 0];else if($ instanceof p2)return[null];else if($ instanceof e1)return[void 0,...O0($.unwrap())];else if($ instanceof A0)return[null,...O0($.unwrap())];else if($ instanceof u5)return O0($.unwrap());else if($ instanceof a2)return O0($.unwrap());else if($ instanceof n2)return O0($._def.innerType);else return[]};class f5 extends o{_parse($){let{ctx:G}=this._processInputParams($);if(G.parsedType!==E.object)return C(G,{code:T.invalid_type,expected:E.object,received:G.parsedType}),u;let J=this.discriminator,X=G.data[J],q=this.optionsMap.get(X);if(!q)return C(G,{code:T.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[J]}),u;if(G.common.async)return q._parseAsync({data:G.data,path:G.path,parent:G});else return q._parseSync({data:G.data,path:G.path,parent:G})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,G,J){let X=new Map;for(let q of G){let V=O0(q.shape[$]);if(!V.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let Y of V){if(X.has(Y))throw Error(`Discriminator property ${String($)} has duplicate value ${String(Y)}`);X.set(Y,q)}}return new f5({typeName:p.ZodDiscriminatedUnion,discriminator:$,options:G,optionsMap:X,...c(J)})}}function h9($,G){let J=V0($),X=V0(G);if($===G)return{valid:!0,data:$};else if(J===E.object&&X===E.object){let q=a.objectKeys(G),V=a.objectKeys($).filter((W)=>q.indexOf(W)!==-1),Y={...$,...G};for(let W of V){let H=h9($[W],G[W]);if(!H.valid)return{valid:!1};Y[W]=H.data}return{valid:!0,data:Y}}else if(J===E.array&&X===E.array){if($.length!==G.length)return{valid:!1};let q=[];for(let V=0;V<$.length;V++){let Y=$[V],W=G[V],H=h9(Y,W);if(!H.valid)return{valid:!1};q.push(H.data)}return{valid:!0,data:q}}else if(J===E.date&&X===E.date&&+$===+G)return{valid:!0,data:$};else return{valid:!1}}class r2 extends o{_parse($){let{status:G,ctx:J}=this._processInputParams($),X=(q,V)=>{if(y5(q)||y5(V))return u;let Y=h9(q.value,V.value);if(!Y.valid)return C(J,{code:T.invalid_intersection_types}),u;if(m5(q)||m5(V))G.dirty();return{status:G.value,value:Y.data}};if(J.common.async)return Promise.all([this._def.left._parseAsync({data:J.data,path:J.path,parent:J}),this._def.right._parseAsync({data:J.data,path:J.path,parent:J})]).then(([q,V])=>X(q,V));else return X(this._def.left._parseSync({data:J.data,path:J.path,parent:J}),this._def.right._parseSync({data:J.data,path:J.path,parent:J}))}}r2.create=($,G,J)=>{return new r2({left:$,right:G,typeName:p.ZodIntersection,...c(J)})};class H0 extends o{_parse($){let{status:G,ctx:J}=this._processInputParams($);if(J.parsedType!==E.array)return C(J,{code:T.invalid_type,expected:E.array,received:J.parsedType}),u;if(J.data.length<this._def.items.length)return C(J,{code:T.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),u;if(!this._def.rest&&J.data.length>this._def.items.length)C(J,{code:T.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),G.dirty();let q=[...J.data].map((V,Y)=>{let W=this._def.items[Y]||this._def.rest;if(!W)return null;return W._parse(new $0(J,V,J.path,Y))}).filter((V)=>!!V);if(J.common.async)return Promise.all(q).then((V)=>{return N1.mergeArray(G,V)});else return N1.mergeArray(G,q)}get items(){return this._def.items}rest($){return new H0({...this._def,rest:$})}}H0.create=($,G)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new H0({items:$,typeName:p.ZodTuple,rest:null,...c(G)})};class E4 extends o{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:G,ctx:J}=this._processInputParams($);if(J.parsedType!==E.object)return C(J,{code:T.invalid_type,expected:E.object,received:J.parsedType}),u;let X=[],q=this._def.keyType,V=this._def.valueType;for(let Y in J.data)X.push({key:q._parse(new $0(J,Y,J.path,Y)),value:V._parse(new $0(J,J.data[Y],J.path,Y)),alwaysSet:Y in J.data});if(J.common.async)return N1.mergeObjectAsync(G,X);else return N1.mergeObjectSync(G,X)}get element(){return this._def.valueType}static create($,G,J){if(G instanceof o)return new E4({keyType:$,valueType:G,typeName:p.ZodRecord,...c(J)});return new E4({keyType:s1.create(),valueType:$,typeName:p.ZodRecord,...c(G)})}}class S4 extends o{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:G,ctx:J}=this._processInputParams($);if(J.parsedType!==E.map)return C(J,{code:T.invalid_type,expected:E.map,received:J.parsedType}),u;let X=this._def.keyType,q=this._def.valueType,V=[...J.data.entries()].map(([Y,W],H)=>{return{key:X._parse(new $0(J,Y,J.path,[H,"key"])),value:q._parse(new $0(J,W,J.path,[H,"value"]))}});if(J.common.async){let Y=new Map;return Promise.resolve().then(async()=>{for(let W of V){let H=await W.key,U=await W.value;if(H.status==="aborted"||U.status==="aborted")return u;if(H.status==="dirty"||U.status==="dirty")G.dirty();Y.set(H.value,U.value)}return{status:G.value,value:Y}})}else{let Y=new Map;for(let W of V){let{key:H,value:U}=W;if(H.status==="aborted"||U.status==="aborted")return u;if(H.status==="dirty"||U.status==="dirty")G.dirty();Y.set(H.value,U.value)}return{status:G.value,value:Y}}}}S4.create=($,G,J)=>{return new S4({valueType:G,keyType:$,typeName:p.ZodMap,...c(J)})};class W2 extends o{_parse($){let{status:G,ctx:J}=this._processInputParams($);if(J.parsedType!==E.set)return C(J,{code:T.invalid_type,expected:E.set,received:J.parsedType}),u;let X=this._def;if(X.minSize!==null){if(J.data.size<X.minSize.value)C(J,{code:T.too_small,minimum:X.minSize.value,type:"set",inclusive:!0,exact:!1,message:X.minSize.message}),G.dirty()}if(X.maxSize!==null){if(J.data.size>X.maxSize.value)C(J,{code:T.too_big,maximum:X.maxSize.value,type:"set",inclusive:!0,exact:!1,message:X.maxSize.message}),G.dirty()}let q=this._def.valueType;function V(W){let H=new Set;for(let U of W){if(U.status==="aborted")return u;if(U.status==="dirty")G.dirty();H.add(U.value)}return{status:G.value,value:H}}let Y=[...J.data.values()].map((W,H)=>q._parse(new $0(J,W,J.path,H)));if(J.common.async)return Promise.all(Y).then((W)=>V(W));else return V(Y)}min($,G){return new W2({...this._def,minSize:{value:$,message:g.toString(G)}})}max($,G){return new W2({...this._def,maxSize:{value:$,message:g.toString(G)}})}size($,G){return this.min($,G).max($,G)}nonempty($){return this.min(1,$)}}W2.create=($,G)=>{return new W2({valueType:$,minSize:null,maxSize:null,typeName:p.ZodSet,...c(G)})};class m2 extends o{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:G}=this._processInputParams($);if(G.parsedType!==E.function)return C(G,{code:T.invalid_type,expected:E.function,received:G.parsedType}),u;function J(Y,W){return L4({data:Y,path:G.path,errorMaps:[G.common.contextualErrorMap,G.schemaErrorMap,g2(),B0].filter((H)=>!!H),issueData:{code:T.invalid_arguments,argumentsError:W}})}function X(Y,W){return L4({data:Y,path:G.path,errorMaps:[G.common.contextualErrorMap,G.schemaErrorMap,g2(),B0].filter((H)=>!!H),issueData:{code:T.invalid_return_type,returnTypeError:W}})}let q={errorMap:G.common.contextualErrorMap},V=G.data;if(this._def.returns instanceof H2){let Y=this;return I1(async function(...W){let H=new T1([]),U=await Y._def.args.parseAsync(W,q).catch((F)=>{throw H.addIssue(J(W,F)),H}),M=await Reflect.apply(V,this,U);return await Y._def.returns._def.type.parseAsync(M,q).catch((F)=>{throw H.addIssue(X(M,F)),H})})}else{let Y=this;return I1(function(...W){let H=Y._def.args.safeParse(W,q);if(!H.success)throw new T1([J(W,H.error)]);let U=Reflect.apply(V,this,H.data),M=Y._def.returns.safeParse(U,q);if(!M.success)throw new T1([X(U,M.error)]);return M.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new m2({...this._def,args:H0.create($).rest(x0.create())})}returns($){return new m2({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,G,J){return new m2({args:$?$:H0.create([]).rest(x0.create()),returns:G||x0.create(),typeName:p.ZodFunction,...c(J)})}}class d2 extends o{get schema(){return this._def.getter()}_parse($){let{ctx:G}=this._processInputParams($);return this._def.getter()._parse({data:G.data,path:G.path,parent:G})}}d2.create=($,G)=>{return new d2({getter:$,typeName:p.ZodLazy,...c(G)})};class c2 extends o{_parse($){if($.data!==this._def.value){let G=this._getOrReturnCtx($);return C(G,{received:G.data,code:T.invalid_literal,expected:this._def.value}),u}return{status:"valid",value:$.data}}get value(){return this._def.value}}c2.create=($,G)=>{return new c2({value:$,typeName:p.ZodLiteral,...c(G)})};function u3($,G){return new g0({values:$,typeName:p.ZodEnum,...c(G)})}class g0 extends o{_parse($){if(typeof $.data!=="string"){let G=this._getOrReturnCtx($),J=this._def.values;return C(G,{expected:a.joinValues(J),received:G.parsedType,code:T.invalid_type}),u}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let G=this._getOrReturnCtx($),J=this._def.values;return C(G,{received:G.data,code:T.invalid_enum_value,options:J}),u}return I1($.data)}get options(){return this._def.values}get enum(){let $={};for(let G of this._def.values)$[G]=G;return $}get Values(){let $={};for(let G of this._def.values)$[G]=G;return $}get Enum(){let $={};for(let G of this._def.values)$[G]=G;return $}extract($,G=this._def){return g0.create($,{...this._def,...G})}exclude($,G=this._def){return g0.create(this.options.filter((J)=>!$.includes(J)),{...this._def,...G})}}g0.create=u3;class i2 extends o{_parse($){let G=a.getValidEnumValues(this._def.values),J=this._getOrReturnCtx($);if(J.parsedType!==E.string&&J.parsedType!==E.number){let X=a.objectValues(G);return C(J,{expected:a.joinValues(X),received:J.parsedType,code:T.invalid_type}),u}if(!this._cache)this._cache=new Set(a.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let X=a.objectValues(G);return C(J,{received:J.data,code:T.invalid_enum_value,options:X}),u}return I1($.data)}get enum(){return this._def.values}}i2.create=($,G)=>{return new i2({values:$,typeName:p.ZodNativeEnum,...c(G)})};class H2 extends o{unwrap(){return this._def.type}_parse($){let{ctx:G}=this._processInputParams($);if(G.parsedType!==E.promise&&G.common.async===!1)return C(G,{code:T.invalid_type,expected:E.promise,received:G.parsedType}),u;let J=G.parsedType===E.promise?G.data:Promise.resolve(G.data);return I1(J.then((X)=>{return this._def.type.parseAsync(X,{path:G.path,errorMap:G.common.contextualErrorMap})}))}}H2.create=($,G)=>{return new H2({type:$,typeName:p.ZodPromise,...c(G)})};class G0 extends o{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===p.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:G,ctx:J}=this._processInputParams($),X=this._def.effect||null,q={addIssue:(V)=>{if(C(J,V),V.fatal)G.abort();else G.dirty()},get path(){return J.path}};if(q.addIssue=q.addIssue.bind(q),X.type==="preprocess"){let V=X.transform(J.data,q);if(J.common.async)return Promise.resolve(V).then(async(Y)=>{if(G.value==="aborted")return u;let W=await this._def.schema._parseAsync({data:Y,path:J.path,parent:J});if(W.status==="aborted")return u;if(W.status==="dirty")return q2(W.value);if(G.value==="dirty")return q2(W.value);return W});else{if(G.value==="aborted")return u;let Y=this._def.schema._parseSync({data:V,path:J.path,parent:J});if(Y.status==="aborted")return u;if(Y.status==="dirty")return q2(Y.value);if(G.value==="dirty")return q2(Y.value);return Y}}if(X.type==="refinement"){let V=(Y)=>{let W=X.refinement(Y,q);if(J.common.async)return Promise.resolve(W);if(W instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return Y};if(J.common.async===!1){let Y=this._def.schema._parseSync({data:J.data,path:J.path,parent:J});if(Y.status==="aborted")return u;if(Y.status==="dirty")G.dirty();return V(Y.value),{status:G.value,value:Y.value}}else return this._def.schema._parseAsync({data:J.data,path:J.path,parent:J}).then((Y)=>{if(Y.status==="aborted")return u;if(Y.status==="dirty")G.dirty();return V(Y.value).then(()=>{return{status:G.value,value:Y.value}})})}if(X.type==="transform")if(J.common.async===!1){let V=this._def.schema._parseSync({data:J.data,path:J.path,parent:J});if(!b0(V))return u;let Y=X.transform(V.value,q);if(Y instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:G.value,value:Y}}else return this._def.schema._parseAsync({data:J.data,path:J.path,parent:J}).then((V)=>{if(!b0(V))return u;return Promise.resolve(X.transform(V.value,q)).then((Y)=>({status:G.value,value:Y}))});a.assertNever(X)}}G0.create=($,G,J)=>{return new G0({schema:$,typeName:p.ZodEffects,effect:G,...c(J)})};G0.createWithPreprocess=($,G,J)=>{return new G0({schema:G,effect:{type:"preprocess",transform:$},typeName:p.ZodEffects,...c(J)})};class e1 extends o{_parse($){if(this._getType($)===E.undefined)return I1(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}e1.create=($,G)=>{return new e1({innerType:$,typeName:p.ZodOptional,...c(G)})};class A0 extends o{_parse($){if(this._getType($)===E.null)return I1(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}A0.create=($,G)=>{return new A0({innerType:$,typeName:p.ZodNullable,...c(G)})};class o2 extends o{_parse($){let{ctx:G}=this._processInputParams($),J=G.data;if(G.parsedType===E.undefined)J=this._def.defaultValue();return this._def.innerType._parse({data:J,path:G.path,parent:G})}removeDefault(){return this._def.innerType}}o2.create=($,G)=>{return new o2({innerType:$,typeName:p.ZodDefault,defaultValue:typeof G.default==="function"?G.default:()=>G.default,...c(G)})};class n2 extends o{_parse($){let{ctx:G}=this._processInputParams($),J={...G,common:{...G.common,issues:[]}},X=this._def.innerType._parse({data:J.data,path:J.path,parent:{...J}});if(h2(X))return X.then((q)=>{return{status:"valid",value:q.status==="valid"?q.value:this._def.catchValue({get error(){return new T1(J.common.issues)},input:J.data})}});else return{status:"valid",value:X.status==="valid"?X.value:this._def.catchValue({get error(){return new T1(J.common.issues)},input:J.data})}}removeCatch(){return this._def.innerType}}n2.create=($,G)=>{return new n2({innerType:$,typeName:p.ZodCatch,catchValue:typeof G.catch==="function"?G.catch:()=>G.catch,...c(G)})};class C4 extends o{_parse($){if(this._getType($)!==E.nan){let J=this._getOrReturnCtx($);return C(J,{code:T.invalid_type,expected:E.nan,received:J.parsedType}),u}return{status:"valid",value:$.data}}}C4.create=($)=>{return new C4({typeName:p.ZodNaN,...c($)})};var Qz=Symbol("zod_brand");class u5 extends o{_parse($){let{ctx:G}=this._processInputParams($),J=G.data;return this._def.type._parse({data:J,path:G.path,parent:G})}unwrap(){return this._def.type}}class b4 extends o{_parse($){let{status:G,ctx:J}=this._processInputParams($);if(J.common.async)return(async()=>{let q=await this._def.in._parseAsync({data:J.data,path:J.path,parent:J});if(q.status==="aborted")return u;if(q.status==="dirty")return G.dirty(),q2(q.value);else return this._def.out._parseAsync({data:q.value,path:J.path,parent:J})})();else{let X=this._def.in._parseSync({data:J.data,path:J.path,parent:J});if(X.status==="aborted")return u;if(X.status==="dirty")return G.dirty(),{status:"dirty",value:X.value};else return this._def.out._parseSync({data:X.value,path:J.path,parent:J})}}static create($,G){return new b4({in:$,out:G,typeName:p.ZodPipeline})}}class a2 extends o{_parse($){let G=this._def.innerType._parse($),J=(X)=>{if(b0(X))X.value=Object.freeze(X.value);return X};return h2(G)?G.then((X)=>J(X)):J(G)}unwrap(){return this._def.innerType}}a2.create=($,G)=>{return new a2({innerType:$,typeName:p.ZodReadonly,...c(G)})};function h3($,G){let J=typeof $==="function"?$(G):typeof $==="string"?{message:$}:$;return typeof J==="string"?{message:J}:J}function p3($,G={},J){if($)return V2.create().superRefine((X,q)=>{let V=$(X);if(V instanceof Promise)return V.then((Y)=>{if(!Y){let W=h3(G,X),H=W.fatal??J??!0;q.addIssue({code:"custom",...W,fatal:H})}});if(!V){let Y=h3(G,X),W=Y.fatal??J??!0;q.addIssue({code:"custom",...Y,fatal:W})}return});return V2.create()}var zz={object:Y1.lazycreate},p;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(p||(p={}));var Kz=($,G={message:`Input not instance of ${$.name}`})=>p3((J)=>J instanceof $,G),l3=s1.create,r3=v0.create,Fz=C4.create,Rz=k0.create,d3=f2.create,Bz=Y2.create,Oz=T4.create,Az=u2.create,wz=p2.create,jz=V2.create,Nz=x0.create,Zz=W0.create,_z=I4.create,Pz=t1.create,Lz=Y1.create,Tz=Y1.strictCreate,Iz=l2.create,Ez=f5.create,Sz=r2.create,Cz=H0.create,bz=E4.create,xz=S4.create,vz=W2.create,kz=m2.create,gz=d2.create,hz=c2.create,yz=g0.create,mz=i2.create,fz=H2.create,uz=G0.create,pz=e1.create,lz=A0.create,rz=G0.createWithPreprocess,dz=b4.create,cz=()=>l3().optional(),iz=()=>r3().optional(),oz=()=>d3().optional(),nz={string:($)=>s1.create({...$,coerce:!0}),number:($)=>v0.create({...$,coerce:!0}),boolean:($)=>f2.create({...$,coerce:!0}),bigint:($)=>k0.create({...$,coerce:!0}),date:($)=>Y2.create({...$,coerce:!0})};var az=u;var $K=I.enum(["public","shared","restricted"]),U2=I.union([$K,I.literal("private")]).optional().transform(($)=>{if($===void 0)return"public";if($==="private")return"restricted";return $});var o3="note",p5=I.object({id:I.string(),entityType:I.string(),content:I.string(),created:I.string().datetime(),updated:I.string().datetime(),visibility:U2,metadata:I.record(I.string(),I.unknown()),contentHash:I.string()}),qK=I.object({mediaType:I.string(),url:I.string(),downloadUrl:I.string().optional(),previewUrl:I.string().optional(),filename:I.string().optional(),sizeBytes:I.number().optional(),source:I.object({entityType:I.string().optional(),entityId:I.string().optional(),attachmentType:I.string().optional()}).optional()});var gT=I.object({id:I.string().min(1,"Entity ID is required"),entityType:I.string().min(1,"Entity type is required"),contentHash:I.string().min(1,"Content hash is required"),operation:I.enum(["create","update"])});var uT=I.object({limit:I.number().int().positive().optional().default(20),offset:I.number().int().min(0).optional().default(0),types:I.array(I.string()).optional().default([]),excludeTypes:I.array(I.string()).optional().default([]),weight:I.record(I.string(),I.number()).optional(),visibilityScope:I.enum(["public","shared","restricted"]).optional(),includeUngenerated:I.boolean().optional().default(!1)});var l5=k4(T6(),1);function r5($,G){if(Object.keys(G).length===0)return $;let J=Object.fromEntries(Object.entries(G).filter(([,X])=>X!==void 0));return l5.default.stringify($,J)}function m9($){if($ instanceof Date)return $.toISOString();if(Array.isArray($))return $.map(m9);if($!==null&&typeof $==="object"){let G={};for(let[J,X]of Object.entries($))G[J]=m9(X);return G}return $}function h0($,G){let{content:J,data:X}=l5.default($),q=m9(X);return{content:J.trim(),metadata:G.parse(q)}}function d5($){if(Object.keys($).length===0)return"";let J=l5.default.stringify("",$).match(/^---\n[\s\S]*?\n---/);return J?J[0]:""}var dT=I.object({visibility:U2});var HK=I.object({field:I.string(),direction:I.enum(["asc","desc"]),nullsFirst:I.boolean().optional()}),qI=I.object({limit:I.number().int().positive().optional(),offset:I.number().int().min(0).optional().default(0),sortFields:I.array(HK).optional(),filter:I.object({metadata:I.record(I.string(),I.unknown()).optional(),visibilityScope:I.enum(["public","shared","restricted"]).optional()}).optional(),publishedOnly:I.boolean().optional()});var QI=I.object({id:I.string().min(1),entityType:I.string().min(1),contentHash:I.string().min(1)});var BK={generateBodyTemplate:()=>""};class x4{entityType;purpose;schema;frontmatterSchema;isSingleton;hasBody;supportsCoverImage;fmSchema;bodyFormatter;constructor($){if(this.entityType=$.entityType,this.purpose=$.purpose,this.schema=$.schema,this.frontmatterSchema=$.frontmatterSchema,this.fmSchema=$.frontmatterSchema,this.bodyFormatter=$.bodyFormatter??BK,$.isSingleton!==void 0)this.isSingleton=$.isSingleton;if($.hasBody!==void 0)this.hasBody=$.hasBody;if($.supportsCoverImage!==void 0)this.supportsCoverImage=$.supportsCoverImage}toMarkdown($){let G=this.renderBody($),X={...this.readExistingFrontmatter($.content)},q=Object.keys(this.frontmatterSchema.shape);for(let[V,Y]of Object.entries($.metadata))if(q.includes(V))X[V]=Y;return this.buildMarkdown(G,X)}renderBody($){return this.extractBody($.content)}readExistingFrontmatter($){try{return h0($,I.record(I.unknown())).metadata}catch{return{}}}extractMetadata($){return $.metadata}parseFrontMatter($,G){return h0($,G).metadata}getBodyTemplate(){return this.bodyFormatter.generateBodyTemplate()}generateFrontMatter($){let G=$.metadata;return d5(G)}extractBody($){try{return h0($,I.record(I.unknown())).content}catch{return $}}parseFrontmatter($){return h0($,this.fmSchema).metadata}buildMarkdown($,G){return r5($,G)}}var n3=I.object({currentPage:I.number(),totalPages:I.number(),totalItems:I.number(),pageSize:I.number(),hasNextPage:I.boolean(),hasPrevPage:I.boolean()});function a3($,G,J){let X=Math.max(1,Math.ceil($/J));return{currentPage:G,totalPages:X,totalItems:$,pageSize:J,hasNextPage:G<X,hasPrevPage:G>1}}function s3($,G){let{page:J,limit:X,pageSize:q}=G;if(J!==void 0){let V=J,Y=q??X??$.length,W=$.length,H=Math.ceil(W/Y),U=(V-1)*Y,M=U+Y;return{items:$.slice(U,M),pagination:{currentPage:V,totalPages:H,totalItems:W,pageSize:Y,hasNextPage:V<H,hasPrevPage:V>1}}}if(X!==void 0)return{items:$.slice(0,X),pagination:null};return{items:$,pagination:null}}export{h0 as parseMarkdownWithFrontmatter,n3 as paginationInfoSchema,s3 as paginateItems,r5 as generateMarkdownWithFrontmatter,d5 as generateFrontmatter,a3 as buildPaginationInfo,p5 as baseEntitySchema,o3 as NOTE_ENTITY_TYPE,x4 as BaseEntityAdapter};
120
120
 
121
- //# debugId=ED33CC1C09A6436D64756E2164756E21
121
+ //# debugId=18D9BA97256EF15364756E2164756E21
122
122
  //# sourceMappingURL=entities.js.map