@gabrywu/knowledge-bank 0.1.2-alpha.227 → 0.1.2-alpha.252

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- import{ZodOptional as e,z as t}from"zod";import r from"node:process";import n,{existsSync as s,mkdirSync as a,writeFileSync as i,readFileSync as o}from"fs";import c from"os";import d,{dirname as u}from"path";import l from"better-sqlite3";import"child_process";import{fileURLToPath as p}from"url";var f,h;!function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const r of e)t[r]=r;return t},e.getValidEnumValues=t=>{const r=e.objectKeys(t).filter(e=>"number"!=typeof t[t[e]]),n={};for(const e of r)n[e]=t[e];return e.objectValues(n)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},e.find=(e,t)=>{for(const r of e)if(t(r))return r},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(f||(f={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(h||(h={}));const m=f.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),g=e=>{switch(typeof e){case"undefined":return m.undefined;case"string":return m.string;case"number":return Number.isNaN(e)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(e)?m.array:null===e?m.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?m.promise:"undefined"!=typeof Map&&e instanceof Map?m.map:"undefined"!=typeof Set&&e instanceof Set?m.set:"undefined"!=typeof Date&&e instanceof Date?m.date:m.object;default:return m.unknown}},y=f.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"]);class _ extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},r={_errors:[]},n=e=>{for(const s of e.issues)if("invalid_union"===s.code)s.unionErrors.map(n);else if("invalid_return_type"===s.code)n(s.returnTypeError);else if("invalid_arguments"===s.code)n(s.argumentsError);else if(0===s.path.length)r._errors.push(t(s));else{let e=r,n=0;for(;n<s.path.length;){const r=s.path[n];n===s.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(s))):e[r]=e[r]||{_errors:[]},e=e[r],n++}}};return n(this),r}static assert(e){if(!(e instanceof _))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,f.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t=Object.create(null),r=[];for(const n of this.issues)if(n.path.length>0){const r=n.path[0];t[r]=t[r]||[],t[r].push(e(n))}else r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}_.create=e=>new _(e);const v=(e,t)=>{let r;switch(e.code){case y.invalid_type:r=e.received===m.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case y.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,f.jsonStringifyReplacer)}`;break;case y.unrecognized_keys:r=`Unrecognized key(s) in object: ${f.joinValues(e.keys,", ")}`;break;case y.invalid_union:r="Invalid input";break;case y.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${f.joinValues(e.options)}`;break;case y.invalid_enum_value:r=`Invalid enum value. Expected ${f.joinValues(e.options)}, received '${e.received}'`;break;case y.invalid_arguments:r="Invalid function arguments";break;case y.invalid_return_type:r="Invalid function return type";break;case y.invalid_date:r="Invalid date";break;case y.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:f.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case y.too_small:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case y.too_big:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case y.custom:r="Invalid input";break;case y.invalid_intersection_types:r="Intersection results could not be merged";break;case y.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case y.not_finite:r="Number must be finite";break;default:r=t.defaultError,f.assertNever(e)}return{message:r}};let w=v;function b(e,t){const r=w,n=(e=>{const{data:t,path:r,errorMaps:n,issueData:s}=e,a=[...r,...s.path||[]],i={...s,path:a};if(void 0!==s.message)return{...s,path:a,message:s.message};let o="";const c=n.filter(e=>!!e).slice().reverse();for(const e of c)o=e(i,{data:t,defaultError:o}).message;return{...s,path:a,message:o}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===v?void 0:v].filter(e=>!!e)});e.common.issues.push(n)}class k{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const n of t){if("aborted"===n.status)return $;"dirty"===n.status&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const e of t){const t=await e.key,n=await e.value;r.push({key:t,value:n})}return k.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const n of t){const{key:t,value:s}=n;if("aborted"===t.status)return $;if("aborted"===s.status)return $;"dirty"===t.status&&e.dirty(),"dirty"===s.status&&e.dirty(),"__proto__"===t.value||void 0===s.value&&!n.alwaysSet||(r[t.value]=s.value)}return{status:e.value,value:r}}}const $=Object.freeze({status:"aborted"}),S=e=>({status:"dirty",value:e}),E=e=>({status:"valid",value:e}),T=e=>"aborted"===e.status,x=e=>"dirty"===e.status,N=e=>"valid"===e.status,P=e=>"undefined"!=typeof Promise&&e instanceof Promise;var O;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(O||(O={}));class I{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const j=(e,t)=>{if(N(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new _(e.common.issues);return this._error=t,this._error}}};function R(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:n,description:s}=e;if(t&&(r||n))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:s}:{errorMap:(t,s)=>{const{message:a}=e;return"invalid_enum_value"===t.code?{message:a??s.defaultError}:void 0===s.data?{message:a??n??s.defaultError}:"invalid_type"!==t.code?{message:s.defaultError}:{message:a??r??s.defaultError}},description:s}}let z=class{get description(){return this._def.description}_getType(e){return g(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:g(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new k,ctx:{common:e.parent.common,data:e.data,parsedType:g(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(P(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:g(e)},n=this._parseSync({data:e,path:r.path,parent:r});return j(r,n)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:g(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:t});return N(r)?{value:r.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>N(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:g(e)},n=this._parse({data:e,path:r.path,parent:r}),s=await(P(n)?n:Promise.resolve(n));return j(r,s)}refine(e,t){const r=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,n)=>{const s=e(t),a=()=>n.addIssue({code:y.custom,...r(t)});return"undefined"!=typeof Promise&&s instanceof Promise?s.then(e=>!!e||(a(),!1)):!!s||(a(),!1)})}refinement(e,t){return this._refinement((r,n)=>!!e(r)||(n.addIssue("function"==typeof t?t(r,n):t),!1))}_refinement(e){return new je({schema:this,typeName:Fe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Re.create(this,this._def)}nullable(){return ze.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ye.create(this)}promise(){return Ie.create(this,this._def)}or(e){return we.create([this,e],this._def)}and(e){return ke.create(this,e,this._def)}transform(e){return new je({...R(this._def),schema:this,typeName:Fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Ce({...R(this._def),innerType:this,defaultValue:t,typeName:Fe.ZodDefault})}brand(){return new Ze({typeName:Fe.ZodBranded,type:this,...R(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Ae({...R(this._def),innerType:this,catchValue:t,typeName:Fe.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return De.create(this,e)}readonly(){return Le.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const C=/^c[^\s-]{8,}$/i,A=/^[0-9a-z]+$/,M=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Z=/^[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,D=/^[a-z0-9_-]{21}$/i,L=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,F=/^[-+]?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)?)??$/,q=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let U;const V=/^(?:(?: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])$/,H=/^(?:(?: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])$/,J=/^(([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]))$/,K=/^(([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])$/,B=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,G=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,W="((\\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])))",X=new RegExp(`^${W}$`);function Y(e){let t="[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function Q(e){return new RegExp(`^${Y(e)}$`)}function ee(e){let t=`${W}T${Y(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function te(e,t){return!("v4"!==t&&t||!V.test(e))||!("v6"!==t&&t||!J.test(e))}function re(e,t){if(!L.test(e))return!1;try{const[r]=e.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!("object"!=typeof s||null===s||"typ"in s&&"JWT"!==s?.typ||!s.alg||t&&s.alg!==t)}catch{return!1}}function ne(e,t){return!("v4"!==t&&t||!H.test(e))||!("v6"!==t&&t||!K.test(e))}let se=class e extends z{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.string,received:t.parsedType}),$}const t=new k;let r;for(const n of this._def.checks)if("min"===n.kind)e.data.length<n.value&&(r=this._getOrReturnCtx(e,r),b(r,{code:y.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if("max"===n.kind)e.data.length>n.value&&(r=this._getOrReturnCtx(e,r),b(r,{code:y.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if("length"===n.kind){const s=e.data.length>n.value,a=e.data.length<n.value;(s||a)&&(r=this._getOrReturnCtx(e,r),s?b(r,{code:y.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):a&&b(r,{code:y.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if("email"===n.kind)q.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"email",code:y.invalid_string,message:n.message}),t.dirty());else if("emoji"===n.kind)U||(U=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),U.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"emoji",code:y.invalid_string,message:n.message}),t.dirty());else if("uuid"===n.kind)Z.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"uuid",code:y.invalid_string,message:n.message}),t.dirty());else if("nanoid"===n.kind)D.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"nanoid",code:y.invalid_string,message:n.message}),t.dirty());else if("cuid"===n.kind)C.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"cuid",code:y.invalid_string,message:n.message}),t.dirty());else if("cuid2"===n.kind)A.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"cuid2",code:y.invalid_string,message:n.message}),t.dirty());else if("ulid"===n.kind)M.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"ulid",code:y.invalid_string,message:n.message}),t.dirty());else if("url"===n.kind)try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),b(r,{validation:"url",code:y.invalid_string,message:n.message}),t.dirty()}else"regex"===n.kind?(n.regex.lastIndex=0,n.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"regex",code:y.invalid_string,message:n.message}),t.dirty())):"trim"===n.kind?e.data=e.data.trim():"includes"===n.kind?e.data.includes(n.value,n.position)||(r=this._getOrReturnCtx(e,r),b(r,{code:y.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):"toLowerCase"===n.kind?e.data=e.data.toLowerCase():"toUpperCase"===n.kind?e.data=e.data.toUpperCase():"startsWith"===n.kind?e.data.startsWith(n.value)||(r=this._getOrReturnCtx(e,r),b(r,{code:y.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):"endsWith"===n.kind?e.data.endsWith(n.value)||(r=this._getOrReturnCtx(e,r),b(r,{code:y.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):"datetime"===n.kind?ee(n).test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{code:y.invalid_string,validation:"datetime",message:n.message}),t.dirty()):"date"===n.kind?X.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{code:y.invalid_string,validation:"date",message:n.message}),t.dirty()):"time"===n.kind?Q(n).test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{code:y.invalid_string,validation:"time",message:n.message}),t.dirty()):"duration"===n.kind?F.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"duration",code:y.invalid_string,message:n.message}),t.dirty()):"ip"===n.kind?te(e.data,n.version)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"ip",code:y.invalid_string,message:n.message}),t.dirty()):"jwt"===n.kind?re(e.data,n.alg)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"jwt",code:y.invalid_string,message:n.message}),t.dirty()):"cidr"===n.kind?ne(e.data,n.version)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"cidr",code:y.invalid_string,message:n.message}),t.dirty()):"base64"===n.kind?B.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"base64",code:y.invalid_string,message:n.message}),t.dirty()):"base64url"===n.kind?G.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"base64url",code:y.invalid_string,message:n.message}),t.dirty()):f.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:y.invalid_string,...O.errToObj(r)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:"email",...O.errToObj(e)})}url(e){return this._addCheck({kind:"url",...O.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...O.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...O.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...O.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...O.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...O.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...O.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...O.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...O.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...O.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...O.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...O.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...O.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...O.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...O.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...O.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...O.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...O.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...O.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...O.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...O.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...O.errToObj(t)})}nonempty(e){return this.min(1,O.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}};function ae(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,s=r>n?r:n;return Number.parseInt(e.toFixed(s).replace(".",""))%Number.parseInt(t.toFixed(s).replace(".",""))/10**s}se.create=e=>new se({checks:[],typeName:Fe.ZodString,coerce:e?.coerce??!1,...R(e)});let ie=class e extends z{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==m.number){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.number,received:t.parsedType}),$}let t;const r=new k;for(const n of this._def.checks)"int"===n.kind?f.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),b(t,{code:y.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty()):"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:y.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:y.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"multipleOf"===n.kind?0!==ae(e.data,n.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:y.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),b(t,{code:y.not_finite,message:n.message}),r.dirty()):f.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,O.toString(t))}gt(e,t){return this.setLimit("min",e,!1,O.toString(t))}lte(e,t){return this.setLimit("max",e,!0,O.toString(t))}lt(e,t){return this.setLimit("max",e,!1,O.toString(t))}setLimit(t,r,n,s){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:O.toString(s)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:"int",message:O.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:O.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:O.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:O.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:O.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:O.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:O.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:O.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:O.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&f.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}};ie.create=e=>new ie({checks:[],typeName:Fe.ZodNumber,coerce:e?.coerce||!1,...R(e)});class oe extends z{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==m.bigint)return this._getInvalidInput(e);let t;const r=new k;for(const n of this._def.checks)"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:y.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:y.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),b(t,{code:y.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):f.assertNever(n);return{status:r.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.bigint,received:t.parsedType}),$}gte(e,t){return this.setLimit("min",e,!0,O.toString(t))}gt(e,t){return this.setLimit("min",e,!1,O.toString(t))}lte(e,t){return this.setLimit("max",e,!0,O.toString(t))}lt(e,t){return this.setLimit("max",e,!1,O.toString(t))}setLimit(e,t,r,n){return new oe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:O.toString(n)}]})}_addCheck(e){return new oe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:O.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:O.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:O.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:O.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:O.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}oe.create=e=>new oe({checks:[],typeName:Fe.ZodBigInt,coerce:e?.coerce??!1,...R(e)});let ce=class extends z{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==m.boolean){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.boolean,received:t.parsedType}),$}return E(e.data)}};ce.create=e=>new ce({typeName:Fe.ZodBoolean,coerce:e?.coerce||!1,...R(e)});class de extends z{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==m.date){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.date,received:t.parsedType}),$}if(Number.isNaN(e.data.getTime()))return b(this._getOrReturnCtx(e),{code:y.invalid_date}),$;const t=new k;let r;for(const n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(r=this._getOrReturnCtx(e,r),b(r,{code:y.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):"max"===n.kind?e.data.getTime()>n.value&&(r=this._getOrReturnCtx(e,r),b(r,{code:y.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):f.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new de({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:O.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:O.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}de.create=e=>new de({checks:[],coerce:e?.coerce||!1,typeName:Fe.ZodDate,...R(e)});class ue extends z{_parse(e){if(this._getType(e)!==m.symbol){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.symbol,received:t.parsedType}),$}return E(e.data)}}ue.create=e=>new ue({typeName:Fe.ZodSymbol,...R(e)});class le extends z{_parse(e){if(this._getType(e)!==m.undefined){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.undefined,received:t.parsedType}),$}return E(e.data)}}le.create=e=>new le({typeName:Fe.ZodUndefined,...R(e)});let pe=class extends z{_parse(e){if(this._getType(e)!==m.null){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.null,received:t.parsedType}),$}return E(e.data)}};pe.create=e=>new pe({typeName:Fe.ZodNull,...R(e)});class fe extends z{constructor(){super(...arguments),this._any=!0}_parse(e){return E(e.data)}}fe.create=e=>new fe({typeName:Fe.ZodAny,...R(e)});let he=class extends z{constructor(){super(...arguments),this._unknown=!0}_parse(e){return E(e.data)}};he.create=e=>new he({typeName:Fe.ZodUnknown,...R(e)});let me=class extends z{_parse(e){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.never,received:t.parsedType}),$}};me.create=e=>new me({typeName:Fe.ZodNever,...R(e)});class ge extends z{_parse(e){if(this._getType(e)!==m.undefined){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.void,received:t.parsedType}),$}return E(e.data)}}ge.create=e=>new ge({typeName:Fe.ZodVoid,...R(e)});let ye=class e extends z{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==m.array)return b(t,{code:y.invalid_type,expected:m.array,received:t.parsedType}),$;if(null!==n.exactLength){const e=t.data.length>n.exactLength.value,s=t.data.length<n.exactLength.value;(e||s)&&(b(t,{code:e?y.too_big:y.too_small,minimum:s?n.exactLength.value:void 0,maximum:e?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(null!==n.minLength&&t.data.length<n.minLength.value&&(b(t,{code:y.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),null!==n.maxLength&&t.data.length>n.maxLength.value&&(b(t,{code:y.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((e,r)=>n.type._parseAsync(new I(t,e,t.path,r)))).then(e=>k.mergeArray(r,e));const s=[...t.data].map((e,r)=>n.type._parseSync(new I(t,e,t.path,r)));return k.mergeArray(r,s)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:O.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:O.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:O.toString(r)}})}nonempty(e){return this.min(1,e)}};function _e(e){if(e instanceof ve){const t={};for(const r in e.shape){const n=e.shape[r];t[r]=Re.create(_e(n))}return new ve({...e._def,shape:()=>t})}return e instanceof ye?new ye({...e._def,type:_e(e.element)}):e instanceof Re?Re.create(_e(e.unwrap())):e instanceof ze?ze.create(_e(e.unwrap())):e instanceof $e?$e.create(e.items.map(e=>_e(e))):e}ye.create=(e,t)=>new ye({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Fe.ZodArray,...R(t)});let ve=class e extends z{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=f.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==m.object){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.object,received:t.parsedType}),$}const{status:t,ctx:r}=this._processInputParams(e),{shape:n,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof me&&"strip"===this._def.unknownKeys))for(const e in r.data)s.includes(e)||a.push(e);const i=[];for(const e of s){const t=n[e],s=r.data[e];i.push({key:{status:"valid",value:e},value:t._parse(new I(r,s,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof me){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of a)i.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)a.length>0&&(b(r,{code:y.unrecognized_keys,keys:a}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of a){const n=r.data[t];i.push({key:{status:"valid",value:t},value:e._parse(new I(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of i){const r=await t.key,n=await t.value;e.push({key:r,value:n,alwaysSet:t.alwaysSet})}return e}).then(e=>k.mergeObjectSync(t,e)):k.mergeObjectSync(t,i)}get shape(){return this._def.shape()}strict(t){return O.errToObj,new e({...this._def,unknownKeys:"strict",...void 0!==t?{errorMap:(e,r)=>{const n=this._def.errorMap?.(e,r).message??r.defaultError;return"unrecognized_keys"===e.code?{message:O.errToObj(t).message??n}:{message:n}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Fe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){const r={};for(const e of f.objectKeys(t))t[e]&&this.shape[e]&&(r[e]=this.shape[e]);return new e({...this._def,shape:()=>r})}omit(t){const r={};for(const e of f.objectKeys(this.shape))t[e]||(r[e]=this.shape[e]);return new e({...this._def,shape:()=>r})}deepPartial(){return _e(this)}partial(t){const r={};for(const e of f.objectKeys(this.shape)){const n=this.shape[e];t&&!t[e]?r[e]=n:r[e]=n.optional()}return new e({...this._def,shape:()=>r})}required(t){const r={};for(const e of f.objectKeys(this.shape))if(t&&!t[e])r[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Re;)t=t._def.innerType;r[e]=t}return new e({...this._def,shape:()=>r})}keyof(){return Ne(f.objectKeys(this.shape))}};ve.create=(e,t)=>new ve({shape:()=>e,unknownKeys:"strip",catchall:me.create(),typeName:Fe.ZodObject,...R(t)}),ve.strictCreate=(e,t)=>new ve({shape:()=>e,unknownKeys:"strict",catchall:me.create(),typeName:Fe.ZodObject,...R(t)}),ve.lazycreate=(e,t)=>new ve({shape:e,unknownKeys:"strip",catchall:me.create(),typeName:Fe.ZodObject,...R(t)});let we=class extends z{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map(async e=>{const r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;const r=e.map(e=>new _(e.ctx.common.issues));return b(t,{code:y.invalid_union,unionErrors:r}),$});{let e;const n=[];for(const s of r){const r={...t,common:{...t.common,issues:[]},parent:null},a=s._parseSync({data:t.data,path:t.path,parent:r});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,ctx:r}),r.common.issues.length&&n.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const s=n.map(e=>new _(e));return b(t,{code:y.invalid_union,unionErrors:s}),$}}get options(){return this._def.options}};function be(e,t){const r=g(e),n=g(t);if(e===t)return{valid:!0,data:e};if(r===m.object&&n===m.object){const r=f.objectKeys(t),n=f.objectKeys(e).filter(e=>-1!==r.indexOf(e)),s={...e,...t};for(const r of n){const n=be(e[r],t[r]);if(!n.valid)return{valid:!1};s[r]=n.data}return{valid:!0,data:s}}if(r===m.array&&n===m.array){if(e.length!==t.length)return{valid:!1};const r=[];for(let n=0;n<e.length;n++){const s=be(e[n],t[n]);if(!s.valid)return{valid:!1};r.push(s.data)}return{valid:!0,data:r}}return r===m.date&&n===m.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}we.create=(e,t)=>new we({options:e,typeName:Fe.ZodUnion,...R(t)});let ke=class extends z{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=(e,n)=>{if(T(e)||T(n))return $;const s=be(e.value,n.value);return s.valid?((x(e)||x(n))&&t.dirty(),{status:t.value,value:s.data}):(b(r,{code:y.invalid_intersection_types}),$)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([e,t])=>n(e,t)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};ke.create=(e,t,r)=>new ke({left:e,right:t,typeName:Fe.ZodIntersection,...R(r)});class $e extends z{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.array)return b(r,{code:y.invalid_type,expected:m.array,received:r.parsedType}),$;if(r.data.length<this._def.items.length)return b(r,{code:y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),$;!this._def.rest&&r.data.length>this._def.items.length&&(b(r,{code:y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...r.data].map((e,t)=>{const n=this._def.items[t]||this._def.rest;return n?n._parse(new I(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(n).then(e=>k.mergeArray(t,e)):k.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new $e({...this._def,rest:e})}}$e.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new $e({items:e,typeName:Fe.ZodTuple,rest:null,...R(t)})};class Se extends z{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.map)return b(r,{code:y.invalid_type,expected:m.map,received:r.parsedType}),$;const n=this._def.keyType,s=this._def.valueType,a=[...r.data.entries()].map(([e,t],a)=>({key:n._parse(new I(r,e,r.path,[a,"key"])),value:s._parse(new I(r,t,r.path,[a,"value"]))}));if(r.common.async){const e=new Map;return Promise.resolve().then(async()=>{for(const r of a){const n=await r.key,s=await r.value;if("aborted"===n.status||"aborted"===s.status)return $;"dirty"!==n.status&&"dirty"!==s.status||t.dirty(),e.set(n.value,s.value)}return{status:t.value,value:e}})}{const e=new Map;for(const r of a){const n=r.key,s=r.value;if("aborted"===n.status||"aborted"===s.status)return $;"dirty"!==n.status&&"dirty"!==s.status||t.dirty(),e.set(n.value,s.value)}return{status:t.value,value:e}}}}Se.create=(e,t,r)=>new Se({valueType:t,keyType:e,typeName:Fe.ZodMap,...R(r)});class Ee extends z{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.set)return b(r,{code:y.invalid_type,expected:m.set,received:r.parsedType}),$;const n=this._def;null!==n.minSize&&r.data.size<n.minSize.value&&(b(r,{code:y.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),null!==n.maxSize&&r.data.size>n.maxSize.value&&(b(r,{code:y.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const s=this._def.valueType;function a(e){const r=new Set;for(const n of e){if("aborted"===n.status)return $;"dirty"===n.status&&t.dirty(),r.add(n.value)}return{status:t.value,value:r}}const i=[...r.data.values()].map((e,t)=>s._parse(new I(r,e,r.path,t)));return r.common.async?Promise.all(i).then(e=>a(e)):a(i)}min(e,t){return new Ee({...this._def,minSize:{value:e,message:O.toString(t)}})}max(e,t){return new Ee({...this._def,maxSize:{value:e,message:O.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ee.create=(e,t)=>new Ee({valueType:e,minSize:null,maxSize:null,typeName:Fe.ZodSet,...R(t)});class Te extends z{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Te.create=(e,t)=>new Te({getter:e,typeName:Fe.ZodLazy,...R(t)});let xe=class extends z{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return b(t,{received:t.data,code:y.invalid_literal,expected:this._def.value}),$}return{status:"valid",value:e.data}}get value(){return this._def.value}};function Ne(e,t){return new Pe({values:e,typeName:Fe.ZodEnum,...R(t)})}xe.create=(e,t)=>new xe({value:e,typeName:Fe.ZodLiteral,...R(t)});let Pe=class e extends z{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),r=this._def.values;return b(t,{expected:f.joinValues(r),received:t.parsedType,code:y.invalid_type}),$}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return b(t,{received:t.data,code:y.invalid_enum_value,options:r}),$}return E(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...r})}};Pe.create=Ne;class Oe extends z{_parse(e){const t=f.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==m.string&&r.parsedType!==m.number){const e=f.objectValues(t);return b(r,{expected:f.joinValues(e),received:r.parsedType,code:y.invalid_type}),$}if(this._cache||(this._cache=new Set(f.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=f.objectValues(t);return b(r,{received:r.data,code:y.invalid_enum_value,options:e}),$}return E(e.data)}get enum(){return this._def.values}}Oe.create=(e,t)=>new Oe({values:e,typeName:Fe.ZodNativeEnum,...R(t)});class Ie extends z{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.promise&&!1===t.common.async)return b(t,{code:y.invalid_type,expected:m.promise,received:t.parsedType}),$;const r=t.parsedType===m.promise?t.data:Promise.resolve(t.data);return E(r.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ie.create=(e,t)=>new Ie({type:e,typeName:Fe.ZodPromise,...R(t)});class je extends z{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Fe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,s={addIssue:e=>{b(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),"preprocess"===n.type){const e=n.transform(r.data,s);if(r.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return $;const n=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===n.status?$:"dirty"===n.status||"dirty"===t.value?S(n.value):n});{if("aborted"===t.value)return $;const n=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===n.status?$:"dirty"===n.status||"dirty"===t.value?S(n.value):n}}if("refinement"===n.type){const e=e=>{const t=n.refinement(e,s);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===r.common.async){const n=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===n.status?$:("dirty"===n.status&&t.dirty(),e(n.value),{status:t.value,value:n.value})}return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(r=>"aborted"===r.status?$:("dirty"===r.status&&t.dirty(),e(r.value).then(()=>({status:t.value,value:r.value}))))}if("transform"===n.type){if(!1===r.common.async){const e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!N(e))return $;const a=n.transform(e.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>N(e)?Promise.resolve(n.transform(e.value,s)).then(e=>({status:t.value,value:e})):$)}f.assertNever(n)}}je.create=(e,t,r)=>new je({schema:e,typeName:Fe.ZodEffects,effect:t,...R(r)}),je.createWithPreprocess=(e,t,r)=>new je({schema:t,effect:{type:"preprocess",transform:e},typeName:Fe.ZodEffects,...R(r)});let Re=class extends z{_parse(e){return this._getType(e)===m.undefined?E(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Re.create=(e,t)=>new Re({innerType:e,typeName:Fe.ZodOptional,...R(t)});let ze=class extends z{_parse(e){return this._getType(e)===m.null?E(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ze.create=(e,t)=>new ze({innerType:e,typeName:Fe.ZodNullable,...R(t)});let Ce=class extends z{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===m.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Ce.create=(e,t)=>new Ce({innerType:e,typeName:Fe.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...R(t)});let Ae=class extends z{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return P(n)?n.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new _(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new _(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Ae.create=(e,t)=>new Ae({innerType:e,typeName:Fe.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...R(t)});class Me extends z{_parse(e){if(this._getType(e)!==m.nan){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.nan,received:t.parsedType}),$}return{status:"valid",value:e.data}}}Me.create=e=>new Me({typeName:Fe.ZodNaN,...R(e)});class Ze extends z{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class De extends z{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?$:"dirty"===e.status?(t.dirty(),S(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{const e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?$:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new De({in:e,out:t,typeName:Fe.ZodPipeline})}}let Le=class extends z{_parse(e){const t=this._def.innerType._parse(e),r=e=>(N(e)&&(e.value=Object.freeze(e.value)),e);return P(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}};var Fe;Le.create=(e,t)=>new Le({innerType:e,typeName:Fe.ZodReadonly,...R(t)}),function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(Fe||(Fe={})),me.create,ye.create;const qe=ve.create;function Ue(e,t,r){function n(r,n){if(r._zod||Object.defineProperty(r,"_zod",{value:{def:n,constr:i,traits:new Set},enumerable:!1}),r._zod.traits.has(e))return;r._zod.traits.add(e),t(r,n);const s=i.prototype,a=Object.keys(s);for(let e=0;e<a.length;e++){const t=a[e];t in r||(r[t]=s[t].bind(r))}}const s=r?.Parent??Object;class a extends s{}function i(e){var t;const s=r?.Parent?new a:this;n(s,e),(t=s._zod).deferred??(t.deferred=[]);for(const e of s._zod.deferred)e();return s}return Object.defineProperty(a,"name",{value:e}),Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:t=>!!(r?.Parent&&t instanceof r.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}we.create,ke.create,$e.create,Pe.create,Ie.create,Re.create,ze.create;class Ve extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class He extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Je={};function Ke(e){return Je}function Be(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function Ge(e,t){return"bigint"==typeof t?t.toString():t}function We(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Xe(e){return null==e}function Ye(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}const Qe=Symbol("evaluating");function et(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Qe)return void 0===n&&(n=Qe,n=r()),n},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function tt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function rt(...e){const t={};for(const r of e){const e=Object.getOwnPropertyDescriptors(r);Object.assign(t,e)}return Object.defineProperties({},t)}function nt(e){return JSON.stringify(e)}const st="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function at(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const it=We(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function ot(e){if(!1===at(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const r=t.prototype;return!1!==at(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function ct(e){return ot(e)?{...e}:Array.isArray(e)?[...e]:e}const dt=new Set(["string","number","symbol"]);function ut(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lt(e,t,r){const n=new e._zod.constr(t??e._zod.def);return t&&!r?.parent||(n._zod.parent=e),n}function pt(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const ft={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ht(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(!0!==e.issues[r]?.continue)return!0;return!1}function mt(e,t){return t.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(e),t})}function gt(e){return"string"==typeof e?e:e?.message}function yt(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const s=gt(e.inst?._zod.def?.error?.(e))??gt(t?.error?.(e))??gt(r.customError?.(e))??gt(r.localeError?.(e))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function _t(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function vt(...e){const[t,r,n]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:n}:{...t}}const wt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ge,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},bt=Ue("$ZodError",wt),kt=Ue("$ZodError",wt,{Parent:Error}),$t=e=>(t,r,n,s)=>{const a=n?Object.assign(n,{async:!1}):{async:!1},i=t._zod.run({value:r,issues:[]},a);if(i instanceof Promise)throw new Ve;if(i.issues.length){const t=new(s?.Err??e)(i.issues.map(e=>yt(e,a,Ke())));throw st(t,s?.callee),t}return i.value},St=$t(kt),Et=e=>async(t,r,n,s)=>{const a=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:r,issues:[]},a);if(i instanceof Promise&&(i=await i),i.issues.length){const t=new(s?.Err??e)(i.issues.map(e=>yt(e,a,Ke())));throw st(t,s?.callee),t}return i.value},Tt=Et(kt),xt=e=>(t,r,n)=>{const s=n?{...n,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new Ve;return a.issues.length?{success:!1,error:new(e??bt)(a.issues.map(e=>yt(e,s,Ke())))}:{success:!0,data:a.value}},Nt=xt(kt),Pt=e=>async(t,r,n)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},s);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>yt(e,s,Ke())))}:{success:!0,data:a.value}},Ot=Pt(kt),It=e=>(t,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return $t(e)(t,r,s)},jt=e=>(t,r,n)=>$t(e)(t,r,n),Rt=e=>async(t,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Et(e)(t,r,s)},zt=e=>async(t,r,n)=>Et(e)(t,r,n),Ct=e=>(t,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return xt(e)(t,r,s)},At=e=>(t,r,n)=>xt(e)(t,r,n),Mt=e=>async(t,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Pt(e)(t,r,s)},Zt=e=>async(t,r,n)=>Pt(e)(t,r,n),Dt=/^[cC][^\s-]{8,}$/,Lt=/^[0-9a-z]+$/,Ft=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,qt=/^[0-9a-vA-V]{20}$/,Ut=/^[A-Za-z0-9]{27}$/,Vt=/^[a-zA-Z0-9_-]{21}$/,Ht=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Jt=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Kt=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Bt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Gt=/^(?:(?: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])$/,Wt=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,Xt=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,Yt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Qt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,er=/^[A-Za-z0-9_-]*$/,tr=/^\+[1-9]\d{6,14}$/,rr="(?:(?:\\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])))",nr=new RegExp(`^${rr}$`);function sr(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const ar=/^-?\d+$/,ir=/^-?\d+(?:\.\d+)?$/,or=/^(?:true|false)$/i,cr=/^null$/i,dr=/^[^A-Z]*$/,ur=/^[^a-z]*$/,lr=Ue("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),pr={number:"number",bigint:"bigint",object:"date"},fr=Ue("$ZodCheckLessThan",(e,t)=>{lr.init(e,t);const r=pr[typeof t.value];e._zod.onattach.push(e=>{const r=e._zod.bag,n=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<n&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),hr=Ue("$ZodCheckGreaterThan",(e,t)=>{lr.init(e,t);const r=pr[typeof t.value];e._zod.onattach.push(e=>{const r=e._zod.bag,n=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>n&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),mr=Ue("$ZodCheckMultipleOf",(e,t)=>{lr.init(e,t),e._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?r.value%t.value===BigInt(0):0===function(e,t){const r=(e.toString().split(".")[1]||"").length,n=t.toString();let s=(n.split(".")[1]||"").length;if(0===s&&/\d?e-\d?/.test(n)){const e=n.match(/\d?e-(\d?)/);e?.[1]&&(s=Number.parseInt(e[1]))}const a=r>s?r:s;return Number.parseInt(e.toFixed(a).replace(".",""))%Number.parseInt(t.toFixed(a).replace(".",""))/10**a}(r.value,t.value))||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),gr=Ue("$ZodCheckNumberFormat",(e,t)=>{lr.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[s,a]=ft[t.format];e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,n.minimum=s,n.maximum=a,r&&(n.pattern=ar)}),e._zod.check=i=>{const o=i.value;if(r){if(!Number.isInteger(o))return void i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:o,inst:e});if(!Number.isSafeInteger(o))return void(o>0?i.issues.push({input:o,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:o,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}))}o<s&&i.issues.push({origin:"number",input:o,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort}),o>a&&i.issues.push({origin:"number",input:o,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),yr=Ue("$ZodCheckMaxLength",(e,t)=>{var r;lr.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!Xe(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const n=r.value;if(n.length<=t.maximum)return;const s=_t(n);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),_r=Ue("$ZodCheckMinLength",(e,t)=>{var r;lr.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!Xe(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const n=r.value;if(n.length>=t.minimum)return;const s=_t(n);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),vr=Ue("$ZodCheckLengthEquals",(e,t)=>{var r;lr.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!Xe(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=r=>{const n=r.value,s=n.length;if(s===t.length)return;const a=_t(n),i=s>t.length;r.issues.push({origin:a,...i?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),wr=Ue("$ZodCheckStringFormat",(e,t)=>{var r,n;lr.init(e,t),e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),br=Ue("$ZodCheckRegex",(e,t)=>{wr.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),kr=Ue("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=dr),wr.init(e,t)}),$r=Ue("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ur),wr.init(e,t)}),Sr=Ue("$ZodCheckIncludes",(e,t)=>{lr.init(e,t);const r=ut(t.includes),n=new RegExp("number"==typeof t.position?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Er=Ue("$ZodCheckStartsWith",(e,t)=>{lr.init(e,t);const r=new RegExp(`^${ut(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Tr=Ue("$ZodCheckEndsWith",(e,t)=>{lr.init(e,t);const r=new RegExp(`.*${ut(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),xr=Ue("$ZodCheckOverwrite",(e,t)=>{lr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class Nr{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length)),n=t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e);for(const e of n)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const Pr={major:4,minor:3,patch:6},Or=Ue("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Pr;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const t of n)for(const r of t._zod.onattach)r(e);if(0===n.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,r)=>{let n,s=ht(e);for(const a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(s)continue;const t=e.issues.length,i=a._zod.check(e);if(i instanceof Promise&&!1===r?.async)throw new Ve;if(n||i instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await i,e.issues.length!==t&&(s||(s=ht(e,t)))});else{if(e.issues.length===t)continue;s||(s=ht(e,t))}}return n?n.then(()=>e):e},r=(r,s,a)=>{if(ht(r))return r.aborted=!0,r;const i=t(s,n,a);if(i instanceof Promise){if(!1===a.async)throw new Ve;return i.then(t=>e._zod.parse(t,a))}return e._zod.parse(i,a)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if("backward"===a.direction){const t=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,s,a)):r(t,s,a)}const i=e._zod.parse(s,a);if(i instanceof Promise){if(!1===a.async)throw new Ve;return i.then(e=>t(e,n,a))}return t(i,n,a)}}et(e,"~standard",()=>({validate:t=>{try{const r=Nt(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return Ot(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Ir=Ue("$ZodString",(e,t)=>{var r;Or.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(r=e._zod.bag,new RegExp(`^${r?`[\\s\\S]{${r?.minimum??0},${r?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),jr=Ue("$ZodStringFormat",(e,t)=>{wr.init(e,t),Ir.init(e,t)}),Rr=Ue("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Jt),jr.init(e,t)}),zr=Ue("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Kt(e))}else t.pattern??(t.pattern=Kt());jr.init(e,t)}),Cr=Ue("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Bt),jr.init(e,t)}),Ar=Ue("$ZodURL",(e,t)=>{jr.init(e,t),e._zod.check=r=>{try{const n=r.value.trim(),s=new URL(n);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(s.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),void(t.normalize?r.value=s.href:r.value=n)}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Mr=Ue("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),jr.init(e,t)}),Zr=Ue("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Vt),jr.init(e,t)}),Dr=Ue("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Dt),jr.init(e,t)}),Lr=Ue("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Lt),jr.init(e,t)}),Fr=Ue("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ft),jr.init(e,t)}),qr=Ue("$ZodXID",(e,t)=>{t.pattern??(t.pattern=qt),jr.init(e,t)}),Ur=Ue("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ut),jr.init(e,t)}),Vr=Ue("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=sr({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${rr}T(?:${n})$`)}(t)),jr.init(e,t)}),Hr=Ue("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=nr),jr.init(e,t)}),Jr=Ue("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${sr(t)}$`)),jr.init(e,t)}),Kr=Ue("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ht),jr.init(e,t)}),Br=Ue("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Gt),jr.init(e,t),e._zod.bag.format="ipv4"}),Gr=Ue("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Wt),jr.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Wr=Ue("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Xt),jr.init(e,t)}),Xr=Ue("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Yt),jr.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(2!==n.length)throw new Error;const[e,t]=n;if(!t)throw new Error;const r=Number(t);if(`${r}`!==t)throw new Error;if(r<0||r>128)throw new Error;new URL(`http://[${e}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Yr(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Qr=Ue("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Qt),jr.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Yr(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),en=Ue("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=er),jr.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{(function(e){if(!er.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return Yr(t.padEnd(4*Math.ceil(t.length/4),"="))})(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),tn=Ue("$ZodE164",(e,t)=>{t.pattern??(t.pattern=tr),jr.init(e,t)}),rn=Ue("$ZodJWT",(e,t)=>{jr.init(e,t),e._zod.check=r=>{(function(e,t=null){try{const r=e.split(".");if(3!==r.length)return!1;const[n]=r;if(!n)return!1;const s=JSON.parse(atob(n));return!("typ"in s&&"JWT"!==s?.typ||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}})(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),nn=Ue("$ZodNumber",(e,t)=>{Or.init(e,t),e._zod.pattern=e._zod.bag.pattern??ir,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(e){}const s=r.value;if("number"==typeof s&&!Number.isNaN(s)&&Number.isFinite(s))return r;const a="number"==typeof s?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...a?{received:a}:{}}),r}}),sn=Ue("$ZodNumberFormat",(e,t)=>{gr.init(e,t),nn.init(e,t)}),an=Ue("$ZodBoolean",(e,t)=>{Or.init(e,t),e._zod.pattern=or,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(e){}const s=r.value;return"boolean"==typeof s||r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),r}}),on=Ue("$ZodNull",(e,t)=>{Or.init(e,t),e._zod.pattern=cr,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{const n=t.value;return null===n||t.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),t}}),cn=Ue("$ZodUnknown",(e,t)=>{Or.init(e,t),e._zod.parse=e=>e}),dn=Ue("$ZodNever",(e,t)=>{Or.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function un(e,t,r){e.issues.length&&t.issues.push(...mt(r,e.issues)),t.value[r]=e.value}const ln=Ue("$ZodArray",(e,t)=>{Or.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=Array(s.length);const a=[];for(let e=0;e<s.length;e++){const i=s[e],o=t.element._zod.run({value:i,issues:[]},n);o instanceof Promise?a.push(o.then(t=>un(t,r,e))):un(o,r,e)}return a.length?Promise.all(a).then(()=>r):r}});function pn(e,t,r,n,s){if(e.issues.length){if(s&&!(r in n))return;t.issues.push(...mt(r,e.issues))}void 0===e.value?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function fn(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const r=(n=e.shape,Object.keys(n).filter(e=>"optional"===n[e]._zod.optin&&"optional"===n[e]._zod.optout));var n;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function hn(e,t,r,n,s,a){const i=[],o=s.keySet,c=s.catchall._zod,d=c.def.type,u="optional"===c.optout;for(const s in t){if(o.has(s))continue;if("never"===d){i.push(s);continue}const a=c.run({value:t[s],issues:[]},n);a instanceof Promise?e.push(a.then(e=>pn(e,r,s,t,u))):pn(a,r,s,t,u)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:a}),e.length?Promise.all(e).then(()=>r):r}const mn=Ue("$ZodObject",(e,t)=>{Or.init(e,t);const r=Object.getOwnPropertyDescriptor(t,"shape");if(!r?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const r={...e};return Object.defineProperty(t,"shape",{value:r}),r}})}const n=We(()=>fn(t));et(e._zod,"propValues",()=>{const e=t.shape,r={};for(const t in e){const n=e[t]._zod;if(n.values){r[t]??(r[t]=new Set);for(const e of n.values)r[t].add(e)}}return r});const s=at,a=t.catchall;let i;e._zod.parse=(t,r)=>{i??(i=n.value);const o=t.value;if(!s(o))return t.issues.push({expected:"object",code:"invalid_type",input:o,inst:e}),t;t.value={};const c=[],d=i.shape;for(const e of i.keys){const n=d[e],s="optional"===n._zod.optout,a=n._zod.run({value:o[e],issues:[]},r);a instanceof Promise?c.push(a.then(r=>pn(r,t,e,o,s))):pn(a,t,e,o,s)}return a?hn(c,o,t,r,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),gn=Ue("$ZodObjectJIT",(e,t)=>{mn.init(e,t);const r=e._zod.parse,n=We(()=>fn(t));let s;const a=at,i=!Je.jitless,o=i&&it.value,c=t.catchall;let d;e._zod.parse=(u,l)=>{d??(d=n.value);const p=u.value;return a(p)?i&&o&&!1===l?.async&&!0!==l.jitless?(s||(s=(e=>{const t=new Nr(["shape","payload","ctx"]),r=n.value,s=e=>{const t=nt(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const a=Object.create(null);let i=0;for(const e of r.keys)a[e]="key_"+i++;t.write("const newResult = {};");for(const n of r.keys){const r=a[n],i=nt(n),o=e[n],c="optional"===o?._zod?.optout;t.write(`const ${r} = ${s(n)};`),c?t.write(`\n if (${r}.issues.length) {\n if (${i} in input) {\n payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${i}, ...iss.path] : [${i}]\n })));\n }\n }\n \n if (${r}.value === undefined) {\n if (${i} in input) {\n newResult[${i}] = undefined;\n }\n } else {\n newResult[${i}] = ${r}.value;\n }\n \n `):t.write(`\n if (${r}.issues.length) {\n payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${i}, ...iss.path] : [${i}]\n })));\n }\n \n if (${r}.value === undefined) {\n if (${i} in input) {\n newResult[${i}] = undefined;\n }\n } else {\n newResult[${i}] = ${r}.value;\n }\n \n `)}t.write("payload.value = newResult;"),t.write("return payload;");const o=t.compile();return(t,r)=>o(e,t,r)})(t.shape)),u=s(u,l),c?hn([],p,u,l,d,e):u):r(u,l):(u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u)}});function yn(e,t,r,n){for(const r of e)if(0===r.issues.length)return t.value=r.value,t;const s=e.filter(e=>!ht(e));return 1===s.length?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(e=>e.issues.map(e=>yt(e,n,Ke())))}),t)}const _n=Ue("$ZodUnion",(e,t)=>{Or.init(e,t),et(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),et(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),et(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),et(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>Ye(e.source)).join("|")})$`)}});const r=1===t.options.length,n=t.options[0]._zod.run;e._zod.parse=(s,a)=>{if(r)return n(s,a);let i=!1;const o=[];for(const e of t.options){const t=e._zod.run({value:s.value,issues:[]},a);if(t instanceof Promise)o.push(t),i=!0;else{if(0===t.issues.length)return t;o.push(t)}}return i?Promise.all(o).then(t=>yn(t,s,e,a)):yn(o,s,e,a)}}),vn=Ue("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,_n.init(e,t);const r=e._zod.parse;et(e._zod,"propValues",()=>{const e={};for(const r of t.options){const n=r._zod.propValues;if(!n||0===Object.keys(n).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(const[t,r]of Object.entries(n)){e[t]||(e[t]=new Set);for(const n of r)e[t].add(n)}}return e});const n=We(()=>{const e=t.options,r=new Map;for(const n of e){const e=n._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const t of e){if(r.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);r.set(t,n)}}return r});e._zod.parse=(s,a)=>{const i=s.value;if(!at(i))return s.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),s;const o=n.value.get(i?.[t.discriminator]);return o?o._zod.run(s,a):t.unionFallback?r(s,a):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:i,path:[t.discriminator],inst:e}),s)}}),wn=Ue("$ZodIntersection",(e,t)=>{Or.init(e,t),e._zod.parse=(e,r)=>{const n=e.value,s=t.left._zod.run({value:n,issues:[]},r),a=t.right._zod.run({value:n,issues:[]},r);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([t,r])=>kn(e,t,r)):kn(e,s,a)}});function bn(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(ot(e)&&ot(t)){const r=Object.keys(t),n=Object.keys(e).filter(e=>-1!==r.indexOf(e)),s={...e,...t};for(const r of n){const n=bn(e[r],t[r]);if(!n.valid)return{valid:!1,mergeErrorPath:[r,...n.mergeErrorPath]};s[r]=n.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const s=bn(e[n],t[n]);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function kn(e,t,r){const n=new Map;let s;for(const r of t.issues)if("unrecognized_keys"===r.code){s??(s=r);for(const e of r.keys)n.has(e)||n.set(e,{}),n.get(e).l=!0}else e.issues.push(r);for(const t of r.issues)if("unrecognized_keys"===t.code)for(const e of t.keys)n.has(e)||n.set(e,{}),n.get(e).r=!0;else e.issues.push(t);const a=[...n].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&s&&e.issues.push({...s,keys:a}),ht(e))return e;const i=bn(t.value,r.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const $n=Ue("$ZodRecord",(e,t)=>{Or.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!ot(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),r;const a=[],i=t.keyType._zod.values;if(i){r.value={};const o=new Set;for(const e of i)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){o.add("number"==typeof e?e.toString():e);const i=t.valueType._zod.run({value:s[e],issues:[]},n);i instanceof Promise?a.push(i.then(t=>{t.issues.length&&r.issues.push(...mt(e,t.issues)),r.value[e]=t.value})):(i.issues.length&&r.issues.push(...mt(e,i.issues)),r.value[e]=i.value)}let c;for(const e in s)o.has(e)||(c=c??[],c.push(e));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c})}else{r.value={};for(const i of Reflect.ownKeys(s)){if("__proto__"===i)continue;let o=t.keyType._zod.run({value:i,issues:[]},n);if(o instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof i&&ir.test(i)&&o.issues.length){const e=t.keyType._zod.run({value:Number(i),issues:[]},n);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(o=e)}if(o.issues.length){"loose"===t.mode?r.value[i]=s[i]:r.issues.push({code:"invalid_key",origin:"record",issues:o.issues.map(e=>yt(e,n,Ke())),input:i,path:[i],inst:e});continue}const c=t.valueType._zod.run({value:s[i],issues:[]},n);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&r.issues.push(...mt(i,e.issues)),r.value[o.value]=e.value})):(c.issues.length&&r.issues.push(...mt(i,c.issues)),r.value[o.value]=c.value)}}return a.length?Promise.all(a).then(()=>r):r}}),Sn=Ue("$ZodEnum",(e,t)=>{Or.init(e,t);const r=Be(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(e=>dt.has(typeof e)).map(e=>"string"==typeof e?ut(e):e.toString()).join("|")})$`),e._zod.parse=(t,s)=>{const a=t.value;return n.has(a)||t.issues.push({code:"invalid_value",values:r,input:a,inst:e}),t}}),En=Ue("$ZodLiteral",(e,t)=>{if(Or.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?ut(e):e?ut(e.toString()):String(e)).join("|")})$`),e._zod.parse=(n,s)=>{const a=n.value;return r.has(a)||n.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),n}}),Tn=Ue("$ZodTransform",(e,t)=>{Or.init(e,t),e._zod.parse=(r,n)=>{if("backward"===n.direction)throw new He(e.constructor.name);const s=t.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(e=>(r.value=e,r));if(s instanceof Promise)throw new Ve;return r.value=s,r}});function xn(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const Nn=Ue("$ZodOptional",(e,t)=>{Or.init(e,t),e._zod.optin="optional",e._zod.optout="optional",et(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),et(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Ye(e.source)})?$`):void 0}),e._zod.parse=(e,r)=>{if("optional"===t.innerType._zod.optin){const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(t=>xn(t,e.value)):xn(n,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,r)}}),Pn=Ue("$ZodExactOptional",(e,t)=>{Nn.init(e,t),et(e._zod,"values",()=>t.innerType._zod.values),et(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),On=Ue("$ZodNullable",(e,t)=>{Or.init(e,t),et(e._zod,"optin",()=>t.innerType._zod.optin),et(e._zod,"optout",()=>t.innerType._zod.optout),et(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Ye(e.source)}|null)$`):void 0}),et(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,r)=>null===e.value?e:t.innerType._zod.run(e,r)}),In=Ue("$ZodDefault",(e,t)=>{Or.init(e,t),e._zod.optin="optional",et(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);if(void 0===e.value)return e.value=t.defaultValue,e;const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(e=>jn(e,t)):jn(n,t)}});function jn(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Rn=Ue("$ZodPrefault",(e,t)=>{Or.init(e,t),e._zod.optin="optional",et(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>("backward"===r.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),zn=Ue("$ZodNonOptional",(e,t)=>{Or.init(e,t),et(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(t=>Cn(t,e)):Cn(s,e)}});function Cn(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const An=Ue("$ZodCatch",(e,t)=>{Or.init(e,t),et(e._zod,"optin",()=>t.innerType._zod.optin),et(e._zod,"optout",()=>t.innerType._zod.optout),et(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(n=>(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>yt(e,r,Ke()))},input:e.value}),e.issues=[]),e)):(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>yt(e,r,Ke()))},input:e.value}),e.issues=[]),e)}}),Mn=Ue("$ZodPipe",(e,t)=>{Or.init(e,t),et(e._zod,"values",()=>t.in._zod.values),et(e._zod,"optin",()=>t.in._zod.optin),et(e._zod,"optout",()=>t.out._zod.optout),et(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,r)=>{if("backward"===r.direction){const n=t.out._zod.run(e,r);return n instanceof Promise?n.then(e=>Zn(e,t.in,r)):Zn(n,t.in,r)}const n=t.in._zod.run(e,r);return n instanceof Promise?n.then(e=>Zn(e,t.out,r)):Zn(n,t.out,r)}});function Zn(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const Dn=Ue("$ZodReadonly",(e,t)=>{Or.init(e,t),et(e._zod,"propValues",()=>t.innerType._zod.propValues),et(e._zod,"values",()=>t.innerType._zod.values),et(e._zod,"optin",()=>t.innerType?._zod?.optin),et(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(Ln):Ln(n)}});function Ln(e){return e.value=Object.freeze(e.value),e}const Fn=Ue("$ZodCustom",(e,t)=>{lr.init(e,t),Or.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=r=>{const n=r.value,s=t.fn(n);if(s instanceof Promise)return s.then(t=>qn(t,r,n,e));qn(s,r,n,e)}});function qn(e,t,r,n){if(!e){const e={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(e.params=n._zod.def.params),t.issues.push(vt(e))}}var Un;(Un=globalThis).__zod_globalRegistry??(Un.__zod_globalRegistry=new class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&"object"==typeof r&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}});const Vn=globalThis.__zod_globalRegistry;function Hn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...pt(t)})}function Jn(e,t){return new fr({check:"less_than",...pt(t),value:e,inclusive:!1})}function Kn(e,t){return new fr({check:"less_than",...pt(t),value:e,inclusive:!0})}function Bn(e,t){return new hr({check:"greater_than",...pt(t),value:e,inclusive:!1})}function Gn(e,t){return new hr({check:"greater_than",...pt(t),value:e,inclusive:!0})}function Wn(e,t){return new mr({check:"multiple_of",...pt(t),value:e})}function Xn(e,t){return new yr({check:"max_length",...pt(t),maximum:e})}function Yn(e,t){return new _r({check:"min_length",...pt(t),minimum:e})}function Qn(e,t){return new vr({check:"length_equals",...pt(t),length:e})}function es(e){return new xr({check:"overwrite",tx:e})}function ts(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Vn,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function rs(e,t,r={path:[],schemaPath:[]}){var n;const s=e._zod.def,a=t.seen.get(e);if(a)return a.count++,r.schemaPath.includes(e)&&(a.cycle=r.path),a.schema;const i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i);const o=e._zod.toJSONSchema?.();if(o)i.schema=o;else{const n={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,n);else{const r=i.schema,a=t.processors[s.type];if(!a)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);a(e,t,r,n)}const a=e._zod.parent;a&&(i.ref||(i.ref=a),rs(a,t,n),t.seen.get(a).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),"input"===t.io&&as(e)&&(delete i.schema.examples,delete i.schema.default),"input"===t.io&&i.schema._prefault&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function ns(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const t of e.seen.entries()){const r=e.metadataRegistry.get(t[0])?.id;if(r){const e=n.get(r);if(e&&e!==t[0])throw new Error(`Duplicate schema id "${r}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(r,t[0])}}const s=t=>{if(t[1].schema.$ref)return;const n=t[1],{ref:s,defId:a}=(t=>{const n="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const r=e.external.registry.get(t[0])?.id,s=e.external.uri??(e=>e);if(r)return{ref:s(r)};const a=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=a,{defId:a,ref:`${s("__shared")}#/${n}/${a}`}}if(t[1]===r)return{ref:"#"};const s=`#/${n}/`,a=t[1].schema.id??"__schema"+e.counter++;return{defId:a,ref:s+a}})(t);n.def={...n.schema},a&&(n.defId=a);const i=n.schema;for(const e in i)delete i[e];i.$ref=s};if("throw"===e.cycles)for(const t of e.seen.entries()){const e=t[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const r of e.seen.entries()){const n=r[1];if(t===r[0]){s(r);continue}if(e.external){const n=e.external.registry.get(r[0])?.id;if(t!==r[0]&&n){s(r);continue}}const a=e.metadataRegistry.get(r[0])?.id;(a||n.cycle||n.count>1&&"ref"===e.reused)&&s(r)}}function ss(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=t=>{const r=e.seen.get(t);if(null===r.ref)return;const s=r.def??r.schema,a={...s},i=r.ref;if(r.ref=null,i){n(i);const r=e.seen.get(i),o=r.schema;if(!o.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(s,o):(s.allOf=s.allOf??[],s.allOf.push(o)),Object.assign(s,a),t._zod.parent===i)for(const e in s)"$ref"!==e&&"allOf"!==e&&(e in a||delete s[e]);if(o.$ref&&r.def)for(const e in s)"$ref"!==e&&"allOf"!==e&&e in r.def&&JSON.stringify(s[e])===JSON.stringify(r.def[e])&&delete s[e]}const o=t._zod.parent;if(o&&o!==i){n(o);const t=e.seen.get(o);if(t?.schema.$ref&&(s.$ref=t.schema.$ref,t.def))for(const e in s)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(s[e])===JSON.stringify(t.def[e])&&delete s[e]}e.override({zodSchema:t,jsonSchema:s,path:r.path??[]})};for(const t of[...e.seen.entries()].reverse())n(t[0]);const s={};if("draft-2020-12"===e.target?s.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?s.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?s.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const r=e.external.registry.get(t)?.id;if(!r)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(r)}Object.assign(s,r.def??r.schema);const a=e.external?.defs??{};for(const t of e.seen.entries()){const e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&("draft-2020-12"===e.target?s.$defs=a:s.definitions=a);try{const r=JSON.parse(JSON.stringify(s));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:is(t,"input",e.processors),output:is(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch(e){throw new Error("Error converting schema to JSON.")}}function as(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if("transform"===n.type)return!0;if("array"===n.type)return as(n.element,r);if("set"===n.type)return as(n.valueType,r);if("lazy"===n.type)return as(n.getter(),r);if("promise"===n.type||"optional"===n.type||"nonoptional"===n.type||"nullable"===n.type||"readonly"===n.type||"default"===n.type||"prefault"===n.type)return as(n.innerType,r);if("intersection"===n.type)return as(n.left,r)||as(n.right,r);if("record"===n.type||"map"===n.type)return as(n.keyType,r)||as(n.valueType,r);if("pipe"===n.type)return as(n.in,r)||as(n.out,r);if("object"===n.type){for(const e in n.shape)if(as(n.shape[e],r))return!0;return!1}if("union"===n.type){for(const e of n.options)if(as(e,r))return!0;return!1}if("tuple"===n.type){for(const e of n.items)if(as(e,r))return!0;return!(!n.rest||!as(n.rest,r))}return!1}const is=(e,t,r={})=>n=>{const{libraryOptions:s,target:a}=n??{},i=ts({...s??{},target:a,io:t,processors:r});return rs(e,i),ns(i,e),ss(i,e)},os={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},cs=(e,t,r,n)=>{const s=r;s.type="string";const{minimum:a,maximum:i,format:o,patterns:c,contentEncoding:d}=e._zod.bag;if("number"==typeof a&&(s.minLength=a),"number"==typeof i&&(s.maxLength=i),o&&(s.format=os[o]??o,""===s.format&&delete s.format,"time"===o&&delete s.format),d&&(s.contentEncoding=d),c&&c.size>0){const e=[...c];1===e.length?s.pattern=e[0].source:e.length>1&&(s.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}},ds=(e,t,r,n)=>{const s=r,{minimum:a,maximum:i,format:o,multipleOf:c,exclusiveMaximum:d,exclusiveMinimum:u}=e._zod.bag;"string"==typeof o&&o.includes("int")?s.type="integer":s.type="number","number"==typeof u&&("draft-04"===t.target||"openapi-3.0"===t.target?(s.minimum=u,s.exclusiveMinimum=!0):s.exclusiveMinimum=u),"number"==typeof a&&(s.minimum=a,"number"==typeof u&&"draft-04"!==t.target&&(u>=a?delete s.minimum:delete s.exclusiveMinimum)),"number"==typeof d&&("draft-04"===t.target||"openapi-3.0"===t.target?(s.maximum=d,s.exclusiveMaximum=!0):s.exclusiveMaximum=d),"number"==typeof i&&(s.maximum=i,"number"==typeof d&&"draft-04"!==t.target&&(d<=i?delete s.maximum:delete s.exclusiveMaximum)),"number"==typeof c&&(s.multipleOf=c)},us=(e,t,r,n)=>{r.type="boolean"},ls=(e,t,r,n)=>{"openapi-3.0"===t.target?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},ps=(e,t,r,n)=>{r.not={}},fs=(e,t,r,n)=>{const s=Be(e._zod.def.entries);s.every(e=>"number"==typeof e)&&(r.type="number"),s.every(e=>"string"==typeof e)&&(r.type="string"),r.enum=s},hs=(e,t,r,n)=>{const s=e._zod.def,a=[];for(const e of s.values)if(void 0===e){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof e){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");a.push(Number(e))}else a.push(e);if(0===a.length);else if(1===a.length){const e=a[0];r.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?r.enum=[e]:r.const=e}else a.every(e=>"number"==typeof e)&&(r.type="number"),a.every(e=>"string"==typeof e)&&(r.type="string"),a.every(e=>"boolean"==typeof e)&&(r.type="boolean"),a.every(e=>null===e)&&(r.type="null"),r.enum=a},ms=(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")},gs=(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")},ys=(e,t,r,n)=>{const s=r,a=e._zod.def,{minimum:i,maximum:o}=e._zod.bag;"number"==typeof i&&(s.minItems=i),"number"==typeof o&&(s.maxItems=o),s.type="array",s.items=rs(a.element,t,{...n,path:[...n.path,"items"]})},_s=(e,t,r,n)=>{const s=r,a=e._zod.def;s.type="object",s.properties={};const i=a.shape;for(const e in i)s.properties[e]=rs(i[e],t,{...n,path:[...n.path,"properties",e]});const o=new Set(Object.keys(i)),c=new Set([...o].filter(e=>{const r=a.shape[e]._zod;return"input"===t.io?void 0===r.optin:void 0===r.optout}));c.size>0&&(s.required=Array.from(c)),"never"===a.catchall?._zod.def.type?s.additionalProperties=!1:a.catchall?a.catchall&&(s.additionalProperties=rs(a.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):"output"===t.io&&(s.additionalProperties=!1)},vs=(e,t,r,n)=>{const s=e._zod.def,a=!1===s.inclusive,i=s.options.map((e,r)=>rs(e,t,{...n,path:[...n.path,a?"oneOf":"anyOf",r]}));a?r.oneOf=i:r.anyOf=i},ws=(e,t,r,n)=>{const s=e._zod.def,a=rs(s.left,t,{...n,path:[...n.path,"allOf",0]}),i=rs(s.right,t,{...n,path:[...n.path,"allOf",1]}),o=e=>"allOf"in e&&1===Object.keys(e).length,c=[...o(a)?a.allOf:[a],...o(i)?i.allOf:[i]];r.allOf=c},bs=(e,t,r,n)=>{const s=r,a=e._zod.def;s.type="object";const i=a.keyType,o=i._zod.bag,c=o?.patterns;if("loose"===a.mode&&c&&c.size>0){const e=rs(a.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});s.patternProperties={};for(const t of c)s.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(s.propertyNames=rs(a.keyType,t,{...n,path:[...n.path,"propertyNames"]})),s.additionalProperties=rs(a.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const d=i._zod.values;if(d){const e=[...d].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(s.required=e)}},ks=(e,t,r,n)=>{const s=e._zod.def,a=rs(s.innerType,t,n),i=t.seen.get(e);"openapi-3.0"===t.target?(i.ref=s.innerType,r.nullable=!0):r.anyOf=[a,{type:"null"}]},$s=(e,t,r,n)=>{const s=e._zod.def;rs(s.innerType,t,n),t.seen.get(e).ref=s.innerType},Ss=(e,t,r,n)=>{const s=e._zod.def;rs(s.innerType,t,n),t.seen.get(e).ref=s.innerType,r.default=JSON.parse(JSON.stringify(s.defaultValue))},Es=(e,t,r,n)=>{const s=e._zod.def;rs(s.innerType,t,n),t.seen.get(e).ref=s.innerType,"input"===t.io&&(r._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},Ts=(e,t,r,n)=>{const s=e._zod.def;let a;rs(s.innerType,t,n),t.seen.get(e).ref=s.innerType;try{a=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},xs=(e,t,r,n)=>{const s=e._zod.def,a="input"===t.io?"transform"===s.in._zod.def.type?s.out:s.in:s.out;rs(a,t,n),t.seen.get(e).ref=a},Ns=(e,t,r,n)=>{const s=e._zod.def;rs(s.innerType,t,n),t.seen.get(e).ref=s.innerType,r.readOnly=!0},Ps=(e,t,r,n)=>{const s=e._zod.def;rs(s.innerType,t,n),t.seen.get(e).ref=s.innerType},Os={string:cs,number:ds,boolean:us,bigint:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("BigInt cannot be represented in JSON Schema")},symbol:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Symbols cannot be represented in JSON Schema")},null:ls,undefined:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Undefined cannot be represented in JSON Schema")},void:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Void cannot be represented in JSON Schema")},never:ps,any:(e,t,r,n)=>{},unknown:(e,t,r,n)=>{},date:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Date cannot be represented in JSON Schema")},enum:fs,literal:hs,nan:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("NaN cannot be represented in JSON Schema")},template_literal:(e,t,r,n)=>{const s=r,a=e._zod.pattern;if(!a)throw new Error("Pattern not found in template literal");s.type="string",s.pattern=a.source},file:(e,t,r,n)=>{const s=r,a={type:"string",format:"binary",contentEncoding:"binary"},{minimum:i,maximum:o,mime:c}=e._zod.bag;void 0!==i&&(a.minLength=i),void 0!==o&&(a.maxLength=o),c?1===c.length?(a.contentMediaType=c[0],Object.assign(s,a)):(Object.assign(s,a),s.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(s,a)},success:(e,t,r,n)=>{r.type="boolean"},custom:ms,function:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Function types cannot be represented in JSON Schema")},transform:gs,map:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Map cannot be represented in JSON Schema")},set:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Set cannot be represented in JSON Schema")},array:ys,object:_s,union:vs,intersection:ws,tuple:(e,t,r,n)=>{const s=r,a=e._zod.def;s.type="array";const i="draft-2020-12"===t.target?"prefixItems":"items",o="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",c=a.items.map((e,r)=>rs(e,t,{...n,path:[...n.path,i,r]})),d=a.rest?rs(a.rest,t,{...n,path:[...n.path,o,..."openapi-3.0"===t.target?[a.items.length]:[]]}):null;"draft-2020-12"===t.target?(s.prefixItems=c,d&&(s.items=d)):"openapi-3.0"===t.target?(s.items={anyOf:c},d&&s.items.anyOf.push(d),s.minItems=c.length,d||(s.maxItems=c.length)):(s.items=c,d&&(s.additionalItems=d));const{minimum:u,maximum:l}=e._zod.bag;"number"==typeof u&&(s.minItems=u),"number"==typeof l&&(s.maxItems=l)},record:bs,nullable:ks,nonoptional:$s,default:Ss,prefault:Es,catch:Ts,pipe:xs,readonly:Ns,promise:(e,t,r,n)=>{const s=e._zod.def;rs(s.innerType,t,n),t.seen.get(e).ref=s.innerType},optional:Ps,lazy:(e,t,r,n)=>{const s=e._zod.innerType;rs(s,t,n),t.seen.get(e).ref=s}},Is=Ue("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");Or.init(e,t),e.def=t,e.type=t.type,e.parse=(t,r)=>St(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>Nt(e,t,r),e.parseAsync=async(t,r)=>Tt(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>Ot(e,t,r),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]},{parent:!0}),e.with=e.check,e.clone=(t,r)=>lt(e,t,r),e.brand=()=>e,e.register=(t,r)=>(t.add(e,r),e),e.apply=t=>t(e)}),js=Ue("ZodMiniObject",(e,t)=>{mn.init(e,t),Is.init(e,t),et(e,"shape",()=>t.shape)});function Rs(e,t){const r={type:"object",shape:e??{},...pt(t)};return new js(r)}function zs(e){return!!e._zod}function Cs(e){const t=Object.values(e);if(0===t.length)return Rs({});const r=t.every(zs),n=t.every(e=>!zs(e));if(r)return Rs(e);if(n)return qe(e);throw new Error("Mixed Zod versions detected in object shape.")}function As(e,t){return zs(e)?Nt(e,t):e.safeParse(t)}async function Ms(e,t){if(zs(e))return await Ot(e,t);const r=e;return await r.safeParseAsync(t)}function Zs(e){if(!e)return;let t;if(zs(e)){const r=e;t=r._zod?.def?.shape}else t=e.shape;if(t){if("function"==typeof t)try{return t()}catch{return}return t}}function Ds(e){if(e){if("object"==typeof e){const t=e;if(!e._def&&!t._zod){const t=Object.values(e);if(t.length>0&&t.every(e=>"object"==typeof e&&null!==e&&(void 0!==e._def||void 0!==e._zod||"function"==typeof e.parse)))return Cs(e)}}if(zs(e)){const t=e,r=t._zod?.def;if(r&&("object"===r.type||void 0!==r.shape))return e}else if(void 0!==e.shape)return e}}function Ls(e){if(e&&"object"==typeof e){if("message"in e&&"string"==typeof e.message)return e.message;if("issues"in e&&Array.isArray(e.issues)&&e.issues.length>0){const t=e.issues[0];if(t&&"object"==typeof t&&"message"in t)return String(t.message)}try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function Fs(e){if(zs(e)){const t=e,r=t._zod?.def;if(r){if(void 0!==r.value)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}}const t=e._def;if(t){if(void 0!==t.value)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}const r=e.value;if(void 0!==r)return r}const qs=Ue("ZodISODateTime",(e,t)=>{Vr.init(e,t),ua.init(e,t)});function Us(e){return function(e,t){return new qs({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...pt(t)})}(0,e)}const Vs=Ue("ZodISODate",(e,t)=>{Hr.init(e,t),ua.init(e,t)});const Hs=Ue("ZodISOTime",(e,t)=>{Jr.init(e,t),ua.init(e,t)});const Js=Ue("ZodISODuration",(e,t)=>{Kr.init(e,t),ua.init(e,t)});const Ks=Ue("ZodError",(e,t)=>{bt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const r={_errors:[]},n=e=>{for(const s of e.issues)if("invalid_union"===s.code&&s.errors.length)s.errors.map(e=>n({issues:e}));else if("invalid_key"===s.code)n({issues:s.issues});else if("invalid_element"===s.code)n({issues:s.issues});else if(0===s.path.length)r._errors.push(t(s));else{let e=r,n=0;for(;n<s.path.length;){const r=s.path[n];n===s.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(s))):e[r]=e[r]||{_errors:[]},e=e[r],n++}}};return n(e),r}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const r={},n=[];for(const s of e.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(t(s))):n.push(t(s));return{formErrors:n,fieldErrors:r}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ge,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ge,2)}},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),Bs=$t(Ks),Gs=Et(Ks),Ws=xt(Ks),Xs=Pt(Ks),Ys=It(Ks),Qs=jt(Ks),ea=Rt(Ks),ta=zt(Ks),ra=Ct(Ks),na=At(Ks),sa=Mt(Ks),aa=Zt(Ks),ia=Ue("ZodType",(e,t)=>(Or.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:is(e,"input"),output:is(e,"output")}}),e.toJSONSchema=((e,t={})=>r=>{const n=ts({...r,processors:t});return rs(e,n),ns(n,e),ss(n,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(rt(t,{checks:[...t.checks??[],...r.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,r)=>lt(e,t,r),e.brand=()=>e,e.register=(t,r)=>(t.add(e,r),e),e.parse=(t,r)=>Bs(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>Ws(e,t,r),e.parseAsync=async(t,r)=>Gs(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>Xs(e,t,r),e.spa=e.safeParseAsync,e.encode=(t,r)=>Ys(e,t,r),e.decode=(t,r)=>Qs(e,t,r),e.encodeAsync=async(t,r)=>ea(e,t,r),e.decodeAsync=async(t,r)=>ta(e,t,r),e.safeEncode=(t,r)=>ra(e,t,r),e.safeDecode=(t,r)=>na(e,t,r),e.safeEncodeAsync=async(t,r)=>sa(e,t,r),e.safeDecodeAsync=async(t,r)=>aa(e,t,r),e.refine=(t,r)=>e.check(function(e,t={}){return function(e,t,r){return new _i({type:"custom",check:"custom",fn:t,...pt(r)})}(0,e,t)}(t,r)),e.superRefine=t=>e.check(function(e){const t=function(e){const t=new lr({check:"custom",...pt(void 0)});return t._zod.check=e,t}(r=>(r.addIssue=e=>{if("string"==typeof e)r.issues.push(vt(e,r.value,t._zod.def));else{const n=e;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=r.value),n.inst??(n.inst=t),n.continue??(n.continue=!t._zod.def.abort),r.issues.push(vt(n))}},e(r.value,r)));return t}(t)),e.overwrite=t=>e.check(es(t)),e.optional=()=>oi(e),e.exactOptional=()=>new ci({type:"optional",innerType:e}),e.nullable=()=>ui(e),e.nullish=()=>oi(ui(e)),e.nonoptional=t=>function(e,t){return new fi({type:"nonoptional",innerType:e,...pt(t)})}(e,t),e.array=()=>qa(e),e.or=t=>Ka([e,t]),e.and=t=>Xa(e,t),e.transform=t=>gi(e,ai(t)),e.default=t=>{return r=t,new li({type:"default",innerType:e,get defaultValue(){return"function"==typeof r?r():ct(r)}});var r},e.prefault=t=>{return r=t,new pi({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof r?r():ct(r)}});var r},e.catch=t=>{return new hi({type:"catch",innerType:e,catchValue:"function"==typeof(r=t)?r:()=>r});var r},e.pipe=t=>gi(e,t),e.readonly=()=>new yi({type:"readonly",innerType:e}),e.describe=t=>{const r=e.clone();return Vn.add(r,{description:t}),r},Object.defineProperty(e,"description",{get:()=>Vn.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return Vn.get(e);const r=e.clone();return Vn.add(r,t[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),oa=Ue("_ZodString",(e,t)=>{Ir.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>cs(e,t,r);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new br({check:"string_format",format:"regex",...pt(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new Sr({check:"string_format",format:"includes",...pt(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new Er({check:"string_format",format:"starts_with",...pt(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Tr({check:"string_format",format:"ends_with",...pt(t),suffix:e})}(...t)),e.min=(...t)=>e.check(Yn(...t)),e.max=(...t)=>e.check(Xn(...t)),e.length=(...t)=>e.check(Qn(...t)),e.nonempty=(...t)=>e.check(Yn(1,...t)),e.lowercase=t=>e.check(function(e){return new kr({check:"string_format",format:"lowercase",...pt(e)})}(t)),e.uppercase=t=>e.check(function(e){return new $r({check:"string_format",format:"uppercase",...pt(e)})}(t)),e.trim=()=>e.check(es(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return es(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(es(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(es(e=>e.toUpperCase())),e.slugify=()=>e.check(es(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}),ca=Ue("ZodString",(e,t)=>{Ir.init(e,t),oa.init(e,t),e.email=t=>e.check(function(e,t){return new la({type:"string",format:"email",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.url=t=>e.check(function(e,t){return new ha({type:"string",format:"url",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.jwt=t=>e.check(function(e,t){return new Pa({type:"string",format:"jwt",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.emoji=t=>e.check(function(e,t){return new ma({type:"string",format:"emoji",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.guid=t=>e.check(Hn(pa,t)),e.uuid=t=>e.check(function(e,t){return new fa({type:"string",format:"uuid",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.uuidv4=t=>e.check(function(e,t){return new fa({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...pt(t)})}(0,t)),e.uuidv6=t=>e.check(function(e,t){return new fa({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...pt(t)})}(0,t)),e.uuidv7=t=>e.check(function(e,t){return new fa({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...pt(t)})}(0,t)),e.nanoid=t=>e.check(function(e,t){return new ga({type:"string",format:"nanoid",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.guid=t=>e.check(Hn(pa,t)),e.cuid=t=>e.check(function(e,t){return new ya({type:"string",format:"cuid",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.cuid2=t=>e.check(function(e,t){return new _a({type:"string",format:"cuid2",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.ulid=t=>e.check(function(e,t){return new va({type:"string",format:"ulid",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.base64=t=>e.check(function(e,t){return new Ta({type:"string",format:"base64",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.base64url=t=>e.check(function(e,t){return new xa({type:"string",format:"base64url",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.xid=t=>e.check(function(e,t){return new wa({type:"string",format:"xid",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.ksuid=t=>e.check(function(e,t){return new ba({type:"string",format:"ksuid",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.ipv4=t=>e.check(function(e,t){return new ka({type:"string",format:"ipv4",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.ipv6=t=>e.check(function(e,t){return new $a({type:"string",format:"ipv6",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.cidrv4=t=>e.check(function(e,t){return new Sa({type:"string",format:"cidrv4",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.cidrv6=t=>e.check(function(e,t){return new Ea({type:"string",format:"cidrv6",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.e164=t=>e.check(function(e,t){return new Na({type:"string",format:"e164",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.datetime=t=>e.check(Us(t)),e.date=t=>e.check(function(e){return function(e,t){return new Vs({type:"string",format:"date",check:"string_format",...pt(t)})}(0,e)}(t)),e.time=t=>e.check(function(e){return function(e,t){return new Hs({type:"string",format:"time",check:"string_format",precision:null,...pt(t)})}(0,e)}(t)),e.duration=t=>e.check(function(e){return function(e,t){return new Js({type:"string",format:"duration",check:"string_format",...pt(t)})}(0,e)}(t))});function da(e){return function(e,t){return new ca({type:"string",...pt(t)})}(0,e)}const ua=Ue("ZodStringFormat",(e,t)=>{jr.init(e,t),oa.init(e,t)}),la=Ue("ZodEmail",(e,t)=>{Cr.init(e,t),ua.init(e,t)}),pa=Ue("ZodGUID",(e,t)=>{Rr.init(e,t),ua.init(e,t)}),fa=Ue("ZodUUID",(e,t)=>{zr.init(e,t),ua.init(e,t)}),ha=Ue("ZodURL",(e,t)=>{Ar.init(e,t),ua.init(e,t)}),ma=Ue("ZodEmoji",(e,t)=>{Mr.init(e,t),ua.init(e,t)}),ga=Ue("ZodNanoID",(e,t)=>{Zr.init(e,t),ua.init(e,t)}),ya=Ue("ZodCUID",(e,t)=>{Dr.init(e,t),ua.init(e,t)}),_a=Ue("ZodCUID2",(e,t)=>{Lr.init(e,t),ua.init(e,t)}),va=Ue("ZodULID",(e,t)=>{Fr.init(e,t),ua.init(e,t)}),wa=Ue("ZodXID",(e,t)=>{qr.init(e,t),ua.init(e,t)}),ba=Ue("ZodKSUID",(e,t)=>{Ur.init(e,t),ua.init(e,t)}),ka=Ue("ZodIPv4",(e,t)=>{Br.init(e,t),ua.init(e,t)}),$a=Ue("ZodIPv6",(e,t)=>{Gr.init(e,t),ua.init(e,t)}),Sa=Ue("ZodCIDRv4",(e,t)=>{Wr.init(e,t),ua.init(e,t)}),Ea=Ue("ZodCIDRv6",(e,t)=>{Xr.init(e,t),ua.init(e,t)}),Ta=Ue("ZodBase64",(e,t)=>{Qr.init(e,t),ua.init(e,t)}),xa=Ue("ZodBase64URL",(e,t)=>{en.init(e,t),ua.init(e,t)}),Na=Ue("ZodE164",(e,t)=>{tn.init(e,t),ua.init(e,t)}),Pa=Ue("ZodJWT",(e,t)=>{rn.init(e,t),ua.init(e,t)}),Oa=Ue("ZodNumber",(e,t)=>{nn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ds(e,t,r),e.gt=(t,r)=>e.check(Bn(t,r)),e.gte=(t,r)=>e.check(Gn(t,r)),e.min=(t,r)=>e.check(Gn(t,r)),e.lt=(t,r)=>e.check(Jn(t,r)),e.lte=(t,r)=>e.check(Kn(t,r)),e.max=(t,r)=>e.check(Kn(t,r)),e.int=t=>e.check(Ra(t)),e.safe=t=>e.check(Ra(t)),e.positive=t=>e.check(Bn(0,t)),e.nonnegative=t=>e.check(Gn(0,t)),e.negative=t=>e.check(Jn(0,t)),e.nonpositive=t=>e.check(Kn(0,t)),e.multipleOf=(t,r)=>e.check(Wn(t,r)),e.step=(t,r)=>e.check(Wn(t,r)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function Ia(e){return function(e,t){return new Oa({type:"number",checks:[],...pt(t)})}(0,e)}const ja=Ue("ZodNumberFormat",(e,t)=>{sn.init(e,t),Oa.init(e,t)});function Ra(e){return function(e,t){return new ja({type:"number",check:"number_format",abort:!1,format:"safeint",...pt(t)})}(0,e)}const za=Ue("ZodBoolean",(e,t)=>{an.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(e,t,r)=>us(0,0,t)});function Ca(e){return function(e,t){return new za({type:"boolean",...pt(t)})}(0,e)}const Aa=Ue("ZodNull",(e,t)=>{on.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(e,t,r)=>ls(0,e,t)});function Ma(e){return function(e,t){return new Aa({type:"null",...pt(t)})}(0,e)}const Za=Ue("ZodUnknown",(e,t)=>{cn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(e,t,r)=>{}});function Da(){return new Za({type:"unknown"})}const La=Ue("ZodNever",(e,t)=>{dn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(e,t,r)=>ps(0,0,t)});const Fa=Ue("ZodArray",(e,t)=>{ln.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ys(e,t,r,n),e.element=t.element,e.min=(t,r)=>e.check(Yn(t,r)),e.nonempty=t=>e.check(Yn(1,t)),e.max=(t,r)=>e.check(Xn(t,r)),e.length=(t,r)=>e.check(Qn(t,r)),e.unwrap=()=>e.element});function qa(e,t){return function(e,t,r){return new Fa({type:"array",element:t,...pt(r)})}(0,e,t)}const Ua=Ue("ZodObject",(e,t)=>{gn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>_s(e,t,r,n),et(e,"shape",()=>t.shape),e.keyof=()=>ti(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Da()}),e.loose=()=>e.clone({...e._zod.def,catchall:Da()}),e.strict=()=>{return e.clone({...e._zod.def,catchall:function(e,t){return new La({type:"never",...pt(t)})}(0,t)});var t},e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!ot(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const r=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(r,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const n=rt(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return tt(this,"shape",r),r}});return lt(e,n)}(e,t),e.safeExtend=t=>function(e,t){if(!ot(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=rt(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return tt(this,"shape",r),r}});return lt(e,r)}(e,t),e.merge=t=>function(e,t){const r=rt(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return tt(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return lt(e,r)}(e,t),e.pick=t=>function(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return lt(e,rt(e._zod.def,{get shape(){const e={};for(const n in t){if(!(n in r.shape))throw new Error(`Unrecognized key: "${n}"`);t[n]&&(e[n]=r.shape[n])}return tt(this,"shape",e),e},checks:[]}))}(e,t),e.omit=t=>function(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=rt(e._zod.def,{get shape(){const n={...e._zod.def.shape};for(const e in t){if(!(e in r.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return tt(this,"shape",n),n},checks:[]});return lt(e,s)}(e,t),e.partial=(...t)=>function(e,t,r){const n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const s=rt(t._zod.def,{get shape(){const n=t._zod.def.shape,s={...n};if(r)for(const t in r){if(!(t in n))throw new Error(`Unrecognized key: "${t}"`);r[t]&&(s[t]=e?new e({type:"optional",innerType:n[t]}):n[t])}else for(const t in n)s[t]=e?new e({type:"optional",innerType:n[t]}):n[t];return tt(this,"shape",s),s},checks:[]});return lt(t,s)}(ii,e,t[0]),e.required=(...t)=>function(e,t,r){const n=rt(t._zod.def,{get shape(){const n=t._zod.def.shape,s={...n};if(r)for(const t in r){if(!(t in s))throw new Error(`Unrecognized key: "${t}"`);r[t]&&(s[t]=new e({type:"nonoptional",innerType:n[t]}))}else for(const t in n)s[t]=new e({type:"nonoptional",innerType:n[t]});return tt(this,"shape",s),s}});return lt(t,n)}(fi,e,t[0])});function Va(e,t){const r={type:"object",shape:e??{},...pt(t)};return new Ua(r)}function Ha(e,t){return new Ua({type:"object",shape:e,catchall:Da(),...pt(t)})}const Ja=Ue("ZodUnion",(e,t)=>{_n.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>vs(e,t,r,n),e.options=t.options});function Ka(e,t){return new Ja({type:"union",options:e,...pt(t)})}const Ba=Ue("ZodDiscriminatedUnion",(e,t)=>{Ja.init(e,t),vn.init(e,t)});function Ga(e,t,r){return new Ba({type:"union",options:t,discriminator:e,...pt(r)})}const Wa=Ue("ZodIntersection",(e,t)=>{wn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ws(e,t,r,n)});function Xa(e,t){return new Wa({type:"intersection",left:e,right:t})}const Ya=Ue("ZodRecord",(e,t)=>{$n.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>bs(e,t,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function Qa(e,t,r){return new Ya({type:"record",keyType:e,valueType:t,...pt(r)})}const ei=Ue("ZodEnum",(e,t)=>{Sn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>fs(e,0,r),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(e,n)=>{const s={};for(const n of e){if(!r.has(n))throw new Error(`Key ${n} not found in enum`);s[n]=t.entries[n]}return new ei({...t,checks:[],...pt(n),entries:s})},e.exclude=(e,n)=>{const s={...t.entries};for(const t of e){if(!r.has(t))throw new Error(`Key ${t} not found in enum`);delete s[t]}return new ei({...t,checks:[],...pt(n),entries:s})}});function ti(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new ei({type:"enum",entries:r,...pt(t)})}const ri=Ue("ZodLiteral",(e,t)=>{En.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>hs(e,t,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ni(e,t){return new ri({type:"literal",values:Array.isArray(e)?e:[e],...pt(t)})}const si=Ue("ZodTransform",(e,t)=>{Tn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(e,t,r)=>gs(0,e),e._zod.parse=(r,n)=>{if("backward"===n.direction)throw new He(e.constructor.name);r.addIssue=n=>{if("string"==typeof n)r.issues.push(vt(n,r.value,t));else{const t=n;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=r.value),t.inst??(t.inst=e),r.issues.push(vt(t))}};const s=t.transform(r.value,r);return s instanceof Promise?s.then(e=>(r.value=e,r)):(r.value=s,r)}});function ai(e){return new si({type:"transform",transform:e})}const ii=Ue("ZodOptional",(e,t)=>{Nn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Ps(e,t,0,n),e.unwrap=()=>e._zod.def.innerType});function oi(e){return new ii({type:"optional",innerType:e})}const ci=Ue("ZodExactOptional",(e,t)=>{Pn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Ps(e,t,0,n),e.unwrap=()=>e._zod.def.innerType}),di=Ue("ZodNullable",(e,t)=>{On.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ks(e,t,r,n),e.unwrap=()=>e._zod.def.innerType});function ui(e){return new di({type:"nullable",innerType:e})}const li=Ue("ZodDefault",(e,t)=>{In.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Ss(e,t,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),pi=Ue("ZodPrefault",(e,t)=>{Rn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Es(e,t,r,n),e.unwrap=()=>e._zod.def.innerType}),fi=Ue("ZodNonOptional",(e,t)=>{zn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>$s(e,t,0,n),e.unwrap=()=>e._zod.def.innerType}),hi=Ue("ZodCatch",(e,t)=>{An.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Ts(e,t,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),mi=Ue("ZodPipe",(e,t)=>{Mn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>xs(e,t,0,n),e.in=t.in,e.out=t.out});function gi(e,t){return new mi({type:"pipe",in:e,out:t})}const yi=Ue("ZodReadonly",(e,t)=>{Dn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Ns(e,t,r,n),e.unwrap=()=>e._zod.def.innerType}),_i=Ue("ZodCustom",(e,t)=>{Fn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(e,t,r)=>ms(0,e)});function vi(e,t){return gi(ai(e),t)}const wi="2025-11-25",bi=[wi,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],ki="io.modelcontextprotocol/related-task",$i="2.0",Si=function(e,t,r){const n=pt(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:(e=>null!==e&&("object"==typeof e||"function"==typeof e))??(()=>!0),...n})}(_i,0,void 0);const Ei=Ka([da(),Ia().int()]),Ti=da();Ha({ttl:Ka([Ia(),Ma()]).optional(),pollInterval:Ia().optional()});const xi=Va({ttl:Ia().optional()}),Ni=Va({taskId:da()}),Pi=Ha({progressToken:Ei.optional(),[ki]:Ni.optional()}),Oi=Va({_meta:Pi.optional()}),Ii=Oi.extend({task:xi.optional()}),ji=Va({method:da(),params:Oi.loose().optional()}),Ri=Va({_meta:Pi.optional()}),zi=Va({method:da(),params:Ri.loose().optional()}),Ci=Ha({_meta:Pi.optional()}),Ai=Ka([da(),Ia().int()]),Mi=Va({jsonrpc:ni($i),id:Ai,...ji.shape}).strict(),Zi=e=>Mi.safeParse(e).success,Di=Va({jsonrpc:ni($i),...zi.shape}).strict(),Li=Va({jsonrpc:ni($i),id:Ai,result:Ci}).strict(),Fi=e=>Li.safeParse(e).success;var qi;!function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"}(qi||(qi={}));const Ui=Va({jsonrpc:ni($i),id:Ai.optional(),error:Va({code:Ia().int(),message:da(),data:Da().optional()})}).strict(),Vi=Ka([Mi,Di,Li,Ui]);Ka([Li,Ui]);const Hi=Ci.strict(),Ji=Ri.extend({requestId:Ai.optional(),reason:da().optional()}),Ki=zi.extend({method:ni("notifications/cancelled"),params:Ji}),Bi=Va({src:da(),mimeType:da().optional(),sizes:qa(da()).optional(),theme:ti(["light","dark"]).optional()}),Gi=Va({icons:qa(Bi).optional()}),Wi=Va({name:da(),title:da().optional()}),Xi=Wi.extend({...Wi.shape,...Gi.shape,version:da(),websiteUrl:da().optional(),description:da().optional()}),Yi=Xa(Va({applyDefaults:Ca().optional()}),Qa(da(),Da())),Qi=vi(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,Xa(Va({form:Yi.optional(),url:Si.optional()}),Qa(da(),Da()).optional())),eo=Ha({list:Si.optional(),cancel:Si.optional(),requests:Ha({sampling:Ha({createMessage:Si.optional()}).optional(),elicitation:Ha({create:Si.optional()}).optional()}).optional()}),to=Ha({list:Si.optional(),cancel:Si.optional(),requests:Ha({tools:Ha({call:Si.optional()}).optional()}).optional()}),ro=Va({experimental:Qa(da(),Si).optional(),sampling:Va({context:Si.optional(),tools:Si.optional()}).optional(),elicitation:Qi.optional(),roots:Va({listChanged:Ca().optional()}).optional(),tasks:eo.optional()}),no=Oi.extend({protocolVersion:da(),capabilities:ro,clientInfo:Xi}),so=ji.extend({method:ni("initialize"),params:no}),ao=Va({experimental:Qa(da(),Si).optional(),logging:Si.optional(),completions:Si.optional(),prompts:Va({listChanged:Ca().optional()}).optional(),resources:Va({subscribe:Ca().optional(),listChanged:Ca().optional()}).optional(),tools:Va({listChanged:Ca().optional()}).optional(),tasks:to.optional()}),io=Ci.extend({protocolVersion:da(),capabilities:ao,serverInfo:Xi,instructions:da().optional()}),oo=zi.extend({method:ni("notifications/initialized"),params:Ri.optional()}),co=ji.extend({method:ni("ping"),params:Oi.optional()}),uo=Va({progress:Ia(),total:oi(Ia()),message:oi(da())}),lo=Va({...Ri.shape,...uo.shape,progressToken:Ei}),po=zi.extend({method:ni("notifications/progress"),params:lo}),fo=Oi.extend({cursor:Ti.optional()}),ho=ji.extend({params:fo.optional()}),mo=Ci.extend({nextCursor:Ti.optional()}),go=ti(["working","input_required","completed","failed","cancelled"]),yo=Va({taskId:da(),status:go,ttl:Ka([Ia(),Ma()]),createdAt:da(),lastUpdatedAt:da(),pollInterval:oi(Ia()),statusMessage:oi(da())}),_o=Ci.extend({task:yo}),vo=Ri.merge(yo),wo=zi.extend({method:ni("notifications/tasks/status"),params:vo}),bo=ji.extend({method:ni("tasks/get"),params:Oi.extend({taskId:da()})}),ko=Ci.merge(yo),$o=ji.extend({method:ni("tasks/result"),params:Oi.extend({taskId:da()})});Ci.loose();const So=ho.extend({method:ni("tasks/list")}),Eo=mo.extend({tasks:qa(yo)}),To=ji.extend({method:ni("tasks/cancel"),params:Oi.extend({taskId:da()})}),xo=Ci.merge(yo),No=Va({uri:da(),mimeType:oi(da()),_meta:Qa(da(),Da()).optional()}),Po=No.extend({text:da()}),Oo=da().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Io=No.extend({blob:Oo}),jo=ti(["user","assistant"]),Ro=Va({audience:qa(jo).optional(),priority:Ia().min(0).max(1).optional(),lastModified:Us({offset:!0}).optional()}),zo=Va({...Wi.shape,...Gi.shape,uri:da(),description:oi(da()),mimeType:oi(da()),annotations:Ro.optional(),_meta:oi(Ha({}))}),Co=Va({...Wi.shape,...Gi.shape,uriTemplate:da(),description:oi(da()),mimeType:oi(da()),annotations:Ro.optional(),_meta:oi(Ha({}))}),Ao=ho.extend({method:ni("resources/list")}),Mo=mo.extend({resources:qa(zo)}),Zo=ho.extend({method:ni("resources/templates/list")}),Do=mo.extend({resourceTemplates:qa(Co)}),Lo=Oi.extend({uri:da()}),Fo=Lo,qo=ji.extend({method:ni("resources/read"),params:Fo}),Uo=Ci.extend({contents:qa(Ka([Po,Io]))}),Vo=zi.extend({method:ni("notifications/resources/list_changed"),params:Ri.optional()}),Ho=Lo,Jo=ji.extend({method:ni("resources/subscribe"),params:Ho}),Ko=Lo,Bo=ji.extend({method:ni("resources/unsubscribe"),params:Ko}),Go=Ri.extend({uri:da()}),Wo=zi.extend({method:ni("notifications/resources/updated"),params:Go}),Xo=Va({name:da(),description:oi(da()),required:oi(Ca())}),Yo=Va({...Wi.shape,...Gi.shape,description:oi(da()),arguments:oi(qa(Xo)),_meta:oi(Ha({}))}),Qo=ho.extend({method:ni("prompts/list")}),ec=mo.extend({prompts:qa(Yo)}),tc=Oi.extend({name:da(),arguments:Qa(da(),da()).optional()}),rc=ji.extend({method:ni("prompts/get"),params:tc}),nc=Va({type:ni("text"),text:da(),annotations:Ro.optional(),_meta:Qa(da(),Da()).optional()}),sc=Va({type:ni("image"),data:Oo,mimeType:da(),annotations:Ro.optional(),_meta:Qa(da(),Da()).optional()}),ac=Va({type:ni("audio"),data:Oo,mimeType:da(),annotations:Ro.optional(),_meta:Qa(da(),Da()).optional()}),ic=Va({type:ni("tool_use"),name:da(),id:da(),input:Qa(da(),Da()),_meta:Qa(da(),Da()).optional()}),oc=Va({type:ni("resource"),resource:Ka([Po,Io]),annotations:Ro.optional(),_meta:Qa(da(),Da()).optional()}),cc=Ka([nc,sc,ac,zo.extend({type:ni("resource_link")}),oc]),dc=Va({role:jo,content:cc}),uc=Ci.extend({description:da().optional(),messages:qa(dc)}),lc=zi.extend({method:ni("notifications/prompts/list_changed"),params:Ri.optional()}),pc=Va({title:da().optional(),readOnlyHint:Ca().optional(),destructiveHint:Ca().optional(),idempotentHint:Ca().optional(),openWorldHint:Ca().optional()}),fc=Va({taskSupport:ti(["required","optional","forbidden"]).optional()}),hc=Va({...Wi.shape,...Gi.shape,description:da().optional(),inputSchema:Va({type:ni("object"),properties:Qa(da(),Si).optional(),required:qa(da()).optional()}).catchall(Da()),outputSchema:Va({type:ni("object"),properties:Qa(da(),Si).optional(),required:qa(da()).optional()}).catchall(Da()).optional(),annotations:pc.optional(),execution:fc.optional(),_meta:Qa(da(),Da()).optional()}),mc=ho.extend({method:ni("tools/list")}),gc=mo.extend({tools:qa(hc)}),yc=Ci.extend({content:qa(cc).default([]),structuredContent:Qa(da(),Da()).optional(),isError:Ca().optional()});yc.or(Ci.extend({toolResult:Da()}));const _c=Ii.extend({name:da(),arguments:Qa(da(),Da()).optional()}),vc=ji.extend({method:ni("tools/call"),params:_c}),wc=zi.extend({method:ni("notifications/tools/list_changed"),params:Ri.optional()});Va({autoRefresh:Ca().default(!0),debounceMs:Ia().int().nonnegative().default(300)});const bc=ti(["debug","info","notice","warning","error","critical","alert","emergency"]),kc=Oi.extend({level:bc}),$c=ji.extend({method:ni("logging/setLevel"),params:kc}),Sc=Ri.extend({level:bc,logger:da().optional(),data:Da()}),Ec=zi.extend({method:ni("notifications/message"),params:Sc}),Tc=Va({name:da().optional()}),xc=Va({hints:qa(Tc).optional(),costPriority:Ia().min(0).max(1).optional(),speedPriority:Ia().min(0).max(1).optional(),intelligencePriority:Ia().min(0).max(1).optional()}),Nc=Va({mode:ti(["auto","required","none"]).optional()}),Pc=Va({type:ni("tool_result"),toolUseId:da().describe("The unique identifier for the corresponding tool call."),content:qa(cc).default([]),structuredContent:Va({}).loose().optional(),isError:Ca().optional(),_meta:Qa(da(),Da()).optional()}),Oc=Ga("type",[nc,sc,ac]),Ic=Ga("type",[nc,sc,ac,ic,Pc]),jc=Va({role:jo,content:Ka([Ic,qa(Ic)]),_meta:Qa(da(),Da()).optional()}),Rc=Ii.extend({messages:qa(jc),modelPreferences:xc.optional(),systemPrompt:da().optional(),includeContext:ti(["none","thisServer","allServers"]).optional(),temperature:Ia().optional(),maxTokens:Ia().int(),stopSequences:qa(da()).optional(),metadata:Si.optional(),tools:qa(hc).optional(),toolChoice:Nc.optional()}),zc=ji.extend({method:ni("sampling/createMessage"),params:Rc}),Cc=Ci.extend({model:da(),stopReason:oi(ti(["endTurn","stopSequence","maxTokens"]).or(da())),role:jo,content:Oc}),Ac=Ci.extend({model:da(),stopReason:oi(ti(["endTurn","stopSequence","maxTokens","toolUse"]).or(da())),role:jo,content:Ka([Ic,qa(Ic)])}),Mc=Va({type:ni("boolean"),title:da().optional(),description:da().optional(),default:Ca().optional()}),Zc=Va({type:ni("string"),title:da().optional(),description:da().optional(),minLength:Ia().optional(),maxLength:Ia().optional(),format:ti(["email","uri","date","date-time"]).optional(),default:da().optional()}),Dc=Va({type:ti(["number","integer"]),title:da().optional(),description:da().optional(),minimum:Ia().optional(),maximum:Ia().optional(),default:Ia().optional()}),Lc=Va({type:ni("string"),title:da().optional(),description:da().optional(),enum:qa(da()),default:da().optional()}),Fc=Va({type:ni("string"),title:da().optional(),description:da().optional(),oneOf:qa(Va({const:da(),title:da()})),default:da().optional()}),qc=Va({type:ni("string"),title:da().optional(),description:da().optional(),enum:qa(da()),enumNames:qa(da()).optional(),default:da().optional()}),Uc=Ka([Lc,Fc]),Vc=Ka([Va({type:ni("array"),title:da().optional(),description:da().optional(),minItems:Ia().optional(),maxItems:Ia().optional(),items:Va({type:ni("string"),enum:qa(da())}),default:qa(da()).optional()}),Va({type:ni("array"),title:da().optional(),description:da().optional(),minItems:Ia().optional(),maxItems:Ia().optional(),items:Va({anyOf:qa(Va({const:da(),title:da()}))}),default:qa(da()).optional()})]),Hc=Ka([qc,Uc,Vc]),Jc=Ka([Hc,Mc,Zc,Dc]),Kc=Ka([Ii.extend({mode:ni("form").optional(),message:da(),requestedSchema:Va({type:ni("object"),properties:Qa(da(),Jc),required:qa(da()).optional()})}),Ii.extend({mode:ni("url"),message:da(),elicitationId:da(),url:da().url()})]),Bc=ji.extend({method:ni("elicitation/create"),params:Kc}),Gc=Ri.extend({elicitationId:da()}),Wc=zi.extend({method:ni("notifications/elicitation/complete"),params:Gc}),Xc=Ci.extend({action:ti(["accept","decline","cancel"]),content:vi(e=>null===e?void 0:e,Qa(da(),Ka([da(),Ia(),Ca(),qa(da())])).optional())}),Yc=Va({type:ni("ref/resource"),uri:da()}),Qc=Va({type:ni("ref/prompt"),name:da()}),ed=Oi.extend({ref:Ka([Qc,Yc]),argument:Va({name:da(),value:da()}),context:Va({arguments:Qa(da(),da()).optional()}).optional()}),td=ji.extend({method:ni("completion/complete"),params:ed}),rd=Ci.extend({completion:Ha({values:qa(da()).max(100),total:oi(Ia().int()),hasMore:oi(Ca())})}),nd=Va({uri:da().startsWith("file://"),name:da().optional(),_meta:Qa(da(),Da()).optional()}),sd=ji.extend({method:ni("roots/list"),params:Oi.optional()}),ad=Ci.extend({roots:qa(nd)}),id=zi.extend({method:ni("notifications/roots/list_changed"),params:Ri.optional()});Ka([co,so,td,$c,rc,Qo,Ao,Zo,qo,Jo,Bo,vc,mc,bo,$o,So,To]),Ka([Ki,po,oo,id,wo]),Ka([Hi,Cc,Ac,Xc,ad,ko,Eo,_o]),Ka([co,zc,Bc,sd,bo,$o,So,To]),Ka([Ki,po,Ec,Wo,Vo,wc,lc,wo,Wc]),Ka([Hi,io,rd,uc,ec,Mo,Do,Uo,yc,gc,ko,Eo,_o]);class od extends Error{constructor(e,t,r){super(`MCP error ${e}: ${t}`),this.code=e,this.data=r,this.name="McpError"}static fromError(e,t,r){if(e===qi.UrlElicitationRequired&&r){const e=r;if(e.elicitations)return new cd(e.elicitations,t)}return new od(e,t,r)}}class cd extends od{constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(qi.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}function dd(e){return"completed"===e||"failed"===e||"cancelled"===e}const ud=Symbol("Let zodToJsonSchema decide on which parser to use"),ld={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"};function pd(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function fd(e,t,r,n,s){e[t]=r,pd(e,t,n,s)}const hd=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function md(e){if("openAi"!==e.target)return{};const t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===e.$refStrategy?hd(t,e.currentPath):t.join("/")}}function gd(e,t){return qd(e.type._def,t)}function yd(e,t,r){const n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((r,n)=>yd(e,t,r))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return _d(e,t)}}const _d=(e,t)=>{const r={type:"integer",format:"unix-time"};if("openApi3"===t.target)return r;for(const n of e.checks)switch(n.kind){case"min":fd(r,"minimum",n.value,n.message,t);break;case"max":fd(r,"maximum",n.value,n.message,t)}return r};let vd;const wd=/^[cC][^\s-]{8,}$/,bd=/^[0-9a-z]+$/,kd=/^[0-9A-HJKMNP-TV-Z]{26}$/,$d=/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,Sd=()=>(void 0===vd&&(vd=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),vd),Ed=/^(?:(?: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])$/,Td=/^(([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])$/,xd=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Nd=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Pd=/^[a-zA-Z0-9_-]{21}$/,Od=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;function Id(e,t){const r={type:"string"};if(e.checks)for(const n of e.checks)switch(n.kind){case"min":fd(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,n.value):n.value,n.message,t);break;case"max":fd(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"email":switch(t.emailStrategy){case"format:email":zd(r,"email",n.message,t);break;case"format:idn-email":zd(r,"idn-email",n.message,t);break;case"pattern:zod":Cd(r,$d,n.message,t)}break;case"url":zd(r,"uri",n.message,t);break;case"uuid":zd(r,"uuid",n.message,t);break;case"regex":Cd(r,n.regex,n.message,t);break;case"cuid":Cd(r,wd,n.message,t);break;case"cuid2":Cd(r,bd,n.message,t);break;case"startsWith":Cd(r,RegExp(`^${jd(n.value,t)}`),n.message,t);break;case"endsWith":Cd(r,RegExp(`${jd(n.value,t)}$`),n.message,t);break;case"datetime":zd(r,"date-time",n.message,t);break;case"date":zd(r,"date",n.message,t);break;case"time":zd(r,"time",n.message,t);break;case"duration":zd(r,"duration",n.message,t);break;case"length":fd(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,n.value):n.value,n.message,t),fd(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"includes":Cd(r,RegExp(jd(n.value,t)),n.message,t);break;case"ip":"v6"!==n.version&&zd(r,"ipv4",n.message,t),"v4"!==n.version&&zd(r,"ipv6",n.message,t);break;case"base64url":Cd(r,Nd,n.message,t);break;case"jwt":Cd(r,Od,n.message,t);break;case"cidr":"v6"!==n.version&&Cd(r,Ed,n.message,t),"v4"!==n.version&&Cd(r,Td,n.message,t);break;case"emoji":Cd(r,Sd(),n.message,t);break;case"ulid":Cd(r,kd,n.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":zd(r,"binary",n.message,t);break;case"contentEncoding:base64":fd(r,"contentEncoding","base64",n.message,t);break;case"pattern:zod":Cd(r,xd,n.message,t)}break;case"nanoid":Cd(r,Pd,n.message,t)}return r}function jd(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let r=0;r<e.length;r++)Rd.has(e[r])||(t+="\\"),t+=e[r];return t}(e):e}const Rd=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function zd(e,t,r,n){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&n.errorMessages&&{errorMessage:{format:r}}})):fd(e,"format",t,r,n)}function Cd(e,t,r,n){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:Ad(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):fd(e,"pattern",Ad(t,n),r,n)}function Ad(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;const r=e.flags.includes("i"),n=e.flags.includes("m"),s=e.flags.includes("s"),a=r?e.source.toLowerCase():e.source;let i="",o=!1,c=!1,d=!1;for(let e=0;e<a.length;e++)if(o)i+=a[e],o=!1;else{if(r)if(c){if(a[e].match(/[a-z]/)){d?(i+=a[e],i+=`${a[e-2]}-${a[e]}`.toUpperCase(),d=!1):"-"===a[e+1]&&a[e+2]?.match(/[a-z]/)?(i+=a[e],d=!0):i+=`${a[e]}${a[e].toUpperCase()}`;continue}}else if(a[e].match(/[a-z]/)){i+=`[${a[e]}${a[e].toUpperCase()}]`;continue}if(n){if("^"===a[e]){i+="(^|(?<=[\r\n]))";continue}if("$"===a[e]){i+="($|(?=[\r\n]))";continue}}s&&"."===a[e]?i+=c?`${a[e]}\r\n`:`[${a[e]}\r\n]`:(i+=a[e],"\\"===a[e]?o=!0:c&&"]"===a[e]?c=!1:c||"["!==a[e]||(c=!0))}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function Md(e,t){if("openAi"===t.target&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),"openApi3"===t.target&&e.keyType?._def.typeName===Fe.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,n)=>({...r,[n]:qd(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??md(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};const r={type:"object",additionalProperties:qd(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if("openApi3"===t.target)return r;if(e.keyType?._def.typeName===Fe.ZodString&&e.keyType._def.checks?.length){const{type:n,...s}=Id(e.keyType._def,t);return{...r,propertyNames:s}}if(e.keyType?._def.typeName===Fe.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===Fe.ZodBranded&&e.keyType._def.type._def.typeName===Fe.ZodString&&e.keyType._def.type._def.checks?.length){const{type:n,...s}=gd(e.keyType._def,t);return{...r,propertyNames:s}}return r}const Zd={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},Dd=(e,t)=>{const r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,r)=>qd(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return r.length?{anyOf:r}:void 0};function Ld(e){try{return e.isOptional()}catch{return!0}}const Fd=(e,t,r)=>{switch(t){case Fe.ZodString:return Id(e,r);case Fe.ZodNumber:return function(e,t){const r={type:"number"};if(!e.checks)return r;for(const n of e.checks)switch(n.kind){case"int":r.type="integer",pd(r,"type",n.message,t);break;case"min":"jsonSchema7"===t.target?n.inclusive?fd(r,"minimum",n.value,n.message,t):fd(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),fd(r,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?fd(r,"maximum",n.value,n.message,t):fd(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),fd(r,"maximum",n.value,n.message,t));break;case"multipleOf":fd(r,"multipleOf",n.value,n.message,t)}return r}(e,r);case Fe.ZodObject:return function(e,t){const r="openAi"===t.target,n={type:"object",properties:{}},s=[],a=e.shape();for(const e in a){let i=a[e];if(void 0===i||void 0===i._def)continue;let o=Ld(i);o&&r&&("ZodOptional"===i._def.typeName&&(i=i._def.innerType),i.isNullable()||(i=i.nullable()),o=!1);const c=qd(i._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==c&&(n.properties[e]=c,o||s.push(e))}s.length&&(n.required=s);const i=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return qd(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==i&&(n.additionalProperties=i),n}(e,r);case Fe.ZodBigInt:return function(e,t){const r={type:"integer",format:"int64"};if(!e.checks)return r;for(const n of e.checks)switch(n.kind){case"min":"jsonSchema7"===t.target?n.inclusive?fd(r,"minimum",n.value,n.message,t):fd(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),fd(r,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?fd(r,"maximum",n.value,n.message,t):fd(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),fd(r,"maximum",n.value,n.message,t));break;case"multipleOf":fd(r,"multipleOf",n.value,n.message,t)}return r}(e,r);case Fe.ZodBoolean:return{type:"boolean"};case Fe.ZodDate:return yd(e,r);case Fe.ZodUndefined:return function(e){return{not:md(e)}}(r);case Fe.ZodNull:return function(e){return"openApi3"===e.target?{enum:["null"],nullable:!0}:{type:"null"}}(r);case Fe.ZodArray:return function(e,t){const r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==Fe.ZodAny&&(r.items=qd(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&fd(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&fd(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(fd(r,"minItems",e.exactLength.value,e.exactLength.message,t),fd(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}(e,r);case Fe.ZodUnion:case Fe.ZodDiscriminatedUnion:return function(e,t){if("openApi3"===t.target)return Dd(e,t);const r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(e=>e._def.typeName in Zd&&(!e._def.checks||!e._def.checks.length))){const e=r.reduce((e,t)=>{const r=Zd[t._def.typeName];return r&&!e.includes(r)?[...e,r]:e},[]);return{type:e.length>1?e:e[0]}}if(r.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){const e=r.reduce((e,t)=>{const r=typeof t._def.value;switch(r){case"string":case"number":case"boolean":return[...e,r];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===r.length){const t=e.filter((e,t,r)=>r.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:r.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(r.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:r.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return Dd(e,t)}(e,r);case Fe.ZodIntersection:return function(e,t){const r=[qd(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),qd(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(e=>!!e);let n="jsonSchema2019-09"===t.target?{unevaluatedProperties:!1}:void 0;const s=[];return r.forEach(e=>{if("type"in(t=e)&&"string"===t.type||!("allOf"in t)){let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){const{additionalProperties:r,...n}=e;t=n}else n=void 0;s.push(t)}else s.push(...e.allOf),void 0===e.unevaluatedProperties&&(n=void 0);var t}),s.length?{allOf:s,...n}:void 0}(e,r);case Fe.ZodTuple:return function(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,r)=>qd(e._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:qd(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,r)=>qd(e._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])}}(e,r);case Fe.ZodRecord:return Md(e,r);case Fe.ZodLiteral:return function(e,t){const r=typeof e.value;return"bigint"!==r&&"number"!==r&&"boolean"!==r&&"string"!==r?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===t.target?{type:"bigint"===r?"integer":r,enum:[e.value]}:{type:"bigint"===r?"integer":r,const:e.value}}(e,r);case Fe.ZodEnum:return function(e){return{type:"string",enum:Array.from(e.values)}}(e);case Fe.ZodNativeEnum:return function(e){const t=e.values,r=Object.keys(e.values).filter(e=>"number"!=typeof t[t[e]]).map(e=>t[e]),n=Array.from(new Set(r.map(e=>typeof e)));return{type:1===n.length?"string"===n[0]?"string":"number":["string","number"],enum:r}}(e);case Fe.ZodNullable:return function(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===t.target?{type:Zd[e.innerType._def.typeName],nullable:!0}:{type:[Zd[e.innerType._def.typeName],"null"]};if("openApi3"===t.target){const r=qd(e.innerType._def,{...t,currentPath:[...t.currentPath]});return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&{...r,nullable:!0}}const r=qd(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}(e,r);case Fe.ZodOptional:return((e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return qd(e.innerType._def,t);const r=qd(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:md(t)},r]}:md(t)})(e,r);case Fe.ZodMap:return function(e,t){return"record"===t.mapStrategy?Md(e,t):{type:"array",maxItems:125,items:{type:"array",items:[qd(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||md(t),qd(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||md(t)],minItems:2,maxItems:2}}}(e,r);case Fe.ZodSet:return function(e,t){const r={type:"array",uniqueItems:!0,items:qd(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&fd(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&fd(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}(e,r);case Fe.ZodLazy:return()=>e.getter()._def;case Fe.ZodPromise:return function(e,t){return qd(e.type._def,t)}(e,r);case Fe.ZodNaN:case Fe.ZodNever:return function(e){return"openAi"===e.target?void 0:{not:md({...e,currentPath:[...e.currentPath,"not"]})}}(r);case Fe.ZodEffects:return function(e,t){return"input"===t.effectStrategy?qd(e.schema._def,t):md(t)}(e,r);case Fe.ZodAny:return md(r);case Fe.ZodUnknown:return function(e){return md(e)}(r);case Fe.ZodDefault:return function(e,t){return{...qd(e.innerType._def,t),default:e.defaultValue()}}(e,r);case Fe.ZodBranded:return gd(e,r);case Fe.ZodReadonly:case Fe.ZodCatch:return((e,t)=>qd(e.innerType._def,t))(e,r);case Fe.ZodPipeline:return((e,t)=>{if("input"===t.pipeStrategy)return qd(e.in._def,t);if("output"===t.pipeStrategy)return qd(e.out._def,t);const r=qd(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[r,qd(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]})].filter(e=>void 0!==e)}})(e,r);case Fe.ZodFunction:case Fe.ZodVoid:case Fe.ZodSymbol:default:return}};function qd(e,t,r=!1){const n=t.seen.get(e);if(t.override){const s=t.override?.(e,t,n,r);if(s!==ud)return s}if(n&&!r){const e=Ud(n,t);if(void 0!==e)return e}const s={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,s);const a=Fd(e,e.typeName,t),i="function"==typeof a?qd(a(),t):a;if(i&&Vd(e,t,i),t.postProcess){const r=t.postProcess(i,e,t);return s.jsonSchema=i,r}return s.jsonSchema=i,i}const Ud=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:hd(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((e,r)=>t.currentPath[r]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),md(t)):"seen"===t.$refStrategy?md(t):void 0}},Vd=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);function Hd(e,t){return zs(e)?function(e,t){if("_idmap"in e){const r=e,n=ts({...t,processors:Os}),s={};for(const e of r._idmap.entries()){const[t,r]=e;rs(r,n)}const a={},i={registry:r,uri:t?.uri,defs:s};n.external=i;for(const e of r._idmap.entries()){const[t,r]=e;ns(n,r),a[t]=ss(n,r)}if(Object.keys(s).length>0){const e="draft-2020-12"===n.target?"$defs":"definitions";a.__shared={[e]:s}}return{schemas:a}}const r=ts({...t,processors:Os});return rs(e,r),ns(r,e),ss(r,e)}(e,{target:(r=t?.target,r?"jsonSchema7"===r||"draft-7"===r?"draft-7":"jsonSchema2019-09"===r||"draft-2020-12"===r?"draft-2020-12":"draft-7":"draft-7"),io:t?.pipeStrategy??"input"}):((e,t)=>{const r=(e=>{const t=(e=>"string"==typeof e?{...ld,name:e}:{...ld,...e})(e),r=void 0!==t.name?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,r])=>[r._def,{def:r._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}})(t);let n=t.definitions?Object.entries(t.definitions).reduce((e,[t,n])=>({...e,[t]:qd(n._def,{...r,currentPath:[...r.basePath,r.definitionPath,t]},!0)??md(r)}),{}):void 0;const s="title"===t?.nameStrategy?void 0:t?.name,a=qd(e._def,void 0===s?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??md(r),i=void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==i&&(a.title=i),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:"relative"===r.$refStrategy?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));const o=void 0===s?n?{...a,[r.definitionPath]:n}:a:{$ref:[..."relative"===r.$refStrategy?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...n,[s]:a}};return"jsonSchema7"===r.target?o.$schema="http://json-schema.org/draft-07/schema#":"jsonSchema2019-09"!==r.target&&"openAi"!==r.target||(o.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===r.target&&("anyOf"in o||"oneOf"in o||"allOf"in o||"type"in o&&Array.isArray(o.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),o})(e,{strictUnions:t?.strictUnions??!0,pipeStrategy:t?.pipeStrategy??"input"});var r}function Jd(e){const t=Zs(e),r=t?.method;if(!r)throw new Error("Schema is missing a method literal");const n=Fs(r);if("string"!=typeof n)throw new Error("Schema method literal must be a string");return n}function Kd(e,t){const r=As(e,t);if(!r.success)throw r.error;return r.data}class Bd{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Ki,e=>{this._oncancel(e)}),this.setNotificationHandler(po,e=>{this._onprogress(e)}),this.setRequestHandler(co,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(bo,async(e,t)=>{const r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new od(qi.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler($o,async(e,t)=>{const r=async()=>{const n=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(n,t.sessionId);){if("response"===e.type||"error"===e.type){const t=e.message,r=t.id,n=this._requestResolvers.get(r);if(n)if(this._requestResolvers.delete(r),"response"===e.type)n(t);else{const e=t;n(new od(e.error.code,e.error.message,e.error.data))}else{const t="response"===e.type?"Response":"Error";this._onerror(new Error(`${t} handler missing for request ${r}`))}continue}await(this._transport?.send(e.message,{relatedRequestId:t.requestId}))}}const s=await this._taskStore.getTask(n,t.sessionId);if(!s)throw new od(qi.InvalidParams,`Task not found: ${n}`);if(!dd(s.status))return await this._waitForTaskUpdate(n,t.signal),await r();if(dd(s.status)){const e=await this._taskStore.getTaskResult(n,t.sessionId);return this._clearTaskQueue(n),{...e,_meta:{...e._meta,[ki]:{taskId:n}}}}return await r()};return await r()}),this.setRequestHandler(So,async(e,t)=>{try{const{tasks:r,nextCursor:n}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:r,nextCursor:n,_meta:{}}}catch(e){throw new od(qi.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(To,async(e,t)=>{try{const r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new od(qi.InvalidParams,`Task not found: ${e.params.taskId}`);if(dd(r.status))throw new od(qi.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,"cancelled","Client cancelled task execution.",t.sessionId),this._clearTaskQueue(e.params.taskId);const n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new od(qi.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...n}}catch(e){if(e instanceof od)throw e;throw new od(qi.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;const t=this._requestHandlerAbortControllers.get(e.params.requestId);t?.abort(e.params.reason)}_setupTimeout(e,t,r,n,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(n,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:s,onTimeout:n})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const r=Date.now()-t.startTime;if(t.maxTotalTimeout&&r>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),od.fromError(qi.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:r});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;const t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};const r=this.transport?.onerror;this._transport.onerror=e=>{r?.(e),this._onerror(e)};const n=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{var r;n?.(e,t),Fi(e)||(r=e,Ui.safeParse(r).success)?this._onresponse(e):Zi(e)?this._onrequest(e,t):(e=>Di.safeParse(e).success)(e)?this._onnotification(e):this._onerror(new Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();const t=od.fromError(qi.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const r of e.values())r(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){const t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;void 0!==t&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(new Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){const r=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,n=this._transport,s=e.params?._meta?.[ki]?.taskId;if(void 0===r){const t={jsonrpc:"2.0",id:e.id,error:{code:qi.MethodNotFound,message:"Method not found"}};return void(s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:t,timestamp:Date.now()},n?.sessionId).catch(e=>this._onerror(new Error(`Failed to enqueue error response: ${e}`))):n?.send(t).catch(e=>this._onerror(new Error(`Failed to send an error response: ${e}`))))}const a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);const i=(o=e.params,Ii.safeParse(o).success?e.params.task:void 0);var o;const c=this._taskStore?this.requestTaskStore(e,n?.sessionId):void 0,d={signal:a.signal,sessionId:n?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{const r={relatedRequestId:e.id};s&&(r.relatedTask={taskId:s}),await this.notification(t,r)},sendRequest:async(t,r,n)=>{const a={...n,relatedRequestId:e.id};s&&!a.relatedTask&&(a.relatedTask={taskId:s});const i=a.relatedTask?.taskId??s;return i&&c&&await c.updateTaskStatus(i,"input_required"),await this.request(t,r,a)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:i?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(e.method)}).then(()=>r(e,d)).then(async t=>{if(a.signal.aborted)return;const r={result:t,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:r,timestamp:Date.now()},n?.sessionId):await(n?.send(r))},async t=>{if(a.signal.aborted)return;const r={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:qi.InternalError,message:t.message??"Internal error",...void 0!==t.data&&{data:t.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:r,timestamp:Date.now()},n?.sessionId):await(n?.send(r))}).catch(e=>this._onerror(new Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...r}=e.params,n=Number(t),s=this._progressHandlers.get(n);if(!s)return void this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));const a=this._responseHandlers.get(n),i=this._timeoutInfo.get(n);if(i&&a&&i.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(e){return this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),void a(e)}s(r)}_onresponse(e){const t=Number(e.id),r=this._requestResolvers.get(t);if(r)return this._requestResolvers.delete(t),void(Fi(e)?r(e):r(new od(e.error.code,e.error.message,e.error.data)));const n=this._responseHandlers.get(t);if(void 0===n)return void this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));this._responseHandlers.delete(t),this._cleanupTimeout(t);let s=!1;if(Fi(e)&&e.result&&"object"==typeof e.result){const r=e.result;if(r.task&&"object"==typeof r.task){const e=r.task;"string"==typeof e.taskId&&(s=!0,this._taskProgressTokens.set(e.taskId,t))}}s||this._progressHandlers.delete(t),Fi(e)?n(e):n(od.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await(this._transport?.close())}async*requestStream(e,t,r){const{task:n}=r??{};if(!n){try{const n=await this.request(e,t,r);yield{type:"result",result:n}}catch(e){yield{type:"error",error:e instanceof od?e:new od(qi.InternalError,String(e))}}return}let s;try{const n=await this.request(e,_o,r);if(!n.task)throw new od(qi.InternalError,"Task creation did not return a task");for(s=n.task.taskId,yield{type:"taskCreated",task:n.task};;){const e=await this.getTask({taskId:s},r);if(yield{type:"taskStatus",task:e},dd(e.status)){if("completed"===e.status){const e=await this.getTaskResult({taskId:s},t,r);yield{type:"result",result:e}}else"failed"===e.status?yield{type:"error",error:new od(qi.InternalError,`Task ${s} failed`)}:"cancelled"===e.status&&(yield{type:"error",error:new od(qi.InternalError,`Task ${s} was cancelled`)});return}if("input_required"===e.status){const e=await this.getTaskResult({taskId:s},t,r);return void(yield{type:"result",result:e})}const n=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,n)),r?.signal?.throwIfAborted()}}catch(e){yield{type:"error",error:e instanceof od?e:new od(qi.InternalError,String(e))}}}request(e,t,r){const{relatedRequestId:n,resumptionToken:s,onresumptiontoken:a,task:i,relatedTask:o}=r??{};return new Promise((c,d)=>{const u=e=>{d(e)};if(!this._transport)return void u(new Error("Not connected"));if(!0===this._options?.enforceStrictCapabilities)try{this.assertCapabilityForMethod(e.method),i&&this.assertTaskCapability(e.method)}catch(e){return void u(e)}r?.signal?.throwIfAborted();const l=this._requestMessageId++,p={...e,jsonrpc:"2.0",id:l};r?.onprogress&&(this._progressHandlers.set(l,r.onprogress),p.params={...e.params,_meta:{...e.params?._meta||{},progressToken:l}}),i&&(p.params={...p.params,task:i}),o&&(p.params={...p.params,_meta:{...p.params?._meta||{},[ki]:o}});const f=e=>{this._responseHandlers.delete(l),this._progressHandlers.delete(l),this._cleanupTimeout(l),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:l,reason:String(e)}},{relatedRequestId:n,resumptionToken:s,onresumptiontoken:a}).catch(e=>this._onerror(new Error(`Failed to send cancellation: ${e}`)));const t=e instanceof od?e:new od(qi.RequestTimeout,String(e));d(t)};this._responseHandlers.set(l,e=>{if(!r?.signal?.aborted){if(e instanceof Error)return d(e);try{const r=As(t,e.result);r.success?c(r.data):d(r.error)}catch(e){d(e)}}}),r?.signal?.addEventListener("abort",()=>{f(r?.signal?.reason)});const h=r?.timeout??6e4;this._setupTimeout(l,h,r?.maxTotalTimeout,()=>f(od.fromError(qi.RequestTimeout,"Request timed out",{timeout:h})),r?.resetTimeoutOnProgress??!1);const m=o?.taskId;if(m){const e=e=>{const t=this._responseHandlers.get(l);t?t(e):this._onerror(new Error(`Response handler missing for side-channeled request ${l}`))};this._requestResolvers.set(l,e),this._enqueueTaskMessage(m,{type:"request",message:p,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(l),d(e)})}else this._transport.send(p,{relatedRequestId:n,resumptionToken:s,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(l),d(e)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},ko,t)}async getTaskResult(e,t,r){return this.request({method:"tasks/result",params:e},t,r)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},Eo,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},xo,t)}async notification(e,t){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const r=t?.relatedTask?.taskId;if(r){const n={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[ki]:t.relatedTask}}};return void await this._enqueueTaskMessage(r,{type:"notification",message:n,timestamp:Date.now()})}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;return this._pendingDebouncedNotifications.add(e.method),void Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let r={...e,jsonrpc:"2.0"};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[ki]:t.relatedTask}}}),this._transport?.send(r,t).catch(e=>this._onerror(e))})}let n={...e,jsonrpc:"2.0"};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[ki]:t.relatedTask}}}),await this._transport.send(n,t)}setRequestHandler(e,t){const r=Jd(e);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(r,n)=>{const s=Kd(e,r);return Promise.resolve(t(s,n))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){const r=Jd(e);this._notificationHandlers.set(r,r=>{const n=Kd(e,r);return Promise.resolve(t(n))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const t=this._taskProgressTokens.get(e);void 0!==t&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,r){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const n=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,r,n)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const r=await this._taskMessageQueue.dequeueAll(e,t);for(const t of r)if("request"===t.type&&Zi(t.message)){const r=t.message.id,n=this._requestResolvers.get(r);n?(n(new od(qi.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(r)):this._onerror(new Error(`Resolver missing for request ${r} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let r=this._options?.defaultTaskPollInterval??1e3;try{const t=await(this._taskStore?.getTask(e));t?.pollInterval&&(r=t.pollInterval)}catch{}return new Promise((e,n)=>{if(t.aborted)return void n(new od(qi.InvalidRequest,"Request cancelled"));const s=setTimeout(e,r);t.addEventListener("abort",()=>{clearTimeout(s),n(new od(qi.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const r=this._taskStore;if(!r)throw new Error("No task store configured");return{createTask:async n=>{if(!e)throw new Error("No request provided");return await r.createTask(n,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{const n=await r.getTask(e,t);if(!n)throw new od(qi.InvalidParams,"Failed to retrieve task: Task not found");return n},storeTaskResult:async(e,n,s)=>{await r.storeTaskResult(e,n,s,t);const a=await r.getTask(e,t);if(a){const t=wo.parse({method:"notifications/tasks/status",params:a});await this.notification(t),dd(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>r.getTaskResult(e,t),updateTaskStatus:async(e,n,s)=>{const a=await r.getTask(e,t);if(!a)throw new od(qi.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(dd(a.status))throw new od(qi.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${n}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await r.updateTaskStatus(e,n,s,t);const i=await r.getTask(e,t);if(i){const t=wo.parse({method:"notifications/tasks/status",params:i});await this.notification(t),dd(i.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>r.listTasks(e,t)}}}function Gd(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function Wd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Xd,Yd={exports:{}},Qd={},eu={},tu={},ru={},nu={},su={};function au(){return Xd||(Xd=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(e){super(),this._items="string"==typeof e?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const e=this._items[0];return""===e||'""'===e}get str(){var e;return null!==(e=this._str)&&void 0!==e?e:this._str=this._items.reduce((e,t)=>`${e}${t}`,"")}get names(){var e;return null!==(e=this._names)&&void 0!==e?e:this._names=this._items.reduce((e,t)=>(t instanceof r&&(e[t.str]=(e[t.str]||0)+1),e),{})}}function s(e,...t){const r=[e[0]];let s=0;for(;s<t.length;)o(r,t[s]),r.push(e[++s]);return new n(r)}e._Code=n,e.nil=new n(""),e._=s;const a=new n("+");function i(e,...t){const r=[d(e[0])];let s=0;for(;s<t.length;)r.push(a),o(r,t[s]),r.push(a,d(e[++s]));return function(e){let t=1;for(;t<e.length-1;){if(e[t]===a){const r=c(e[t-1],e[t+1]);if(void 0!==r){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}(r),new n(r)}function o(e,t){var s;t instanceof n?e.push(...t._items):t instanceof r?e.push(t):e.push("number"==typeof(s=t)||"boolean"==typeof s||null===s?s:d(Array.isArray(s)?s.join(","):s))}function c(e,t){if('""'===t)return e;if('""'===e)return t;if("string"==typeof e){if(t instanceof r||'"'!==e[e.length-1])return;return"string"!=typeof t?`${e.slice(0,-1)}${t}"`:'"'===t[0]?e.slice(0,-1)+t.slice(1):void 0}return"string"!=typeof t||'"'!==t[0]||e instanceof r?void 0:`"${e}${t.slice(1)}`}function d(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.str=i,e.addCodeArg=o,e.strConcat=function(e,t){return t.emptyStr()?e:e.emptyStr()?t:i`${e}${t}`},e.stringify=function(e){return new n(d(e))},e.safeStringify=d,e.getProperty=function(t){return"string"==typeof t&&e.IDENTIFIER.test(t)?new n(`.${t}`):s`[${t}]`},e.getEsmExportName=function(t){if("string"==typeof t&&e.IDENTIFIER.test(t))return new n(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)},e.regexpCode=function(e){return new n(e.toString())}}(su)),su}var iu,ou,cu={};function du(){return iu||(iu=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const t=au();class r extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}}var n;!function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"}(n||(e.UsedValueState=n={})),e.varKinds={const:new t.Name("const"),let:new t.Name("let"),var:new t.Name("var")};class s{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){return`${e}${(this._names[e]||this._nameGroup(e)).index++}`}_nameGroup(e){var t,r;if((null===(r=null===(t=this._parent)||void 0===t?void 0:t._prefixes)||void 0===r?void 0:r.has(e))||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}}e.Scope=s;class a extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=t._`.${new t.Name(r)}[${n}]`}}e.ValueScopeName=a;const i=t._`\n`;e.ValueScope=class extends s{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?i:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){var r;if(void 0===t.ref)throw new Error("CodeGen: ref must be passed in value");const n=this.toName(e),{prefix:s}=n,a=null!==(r=t.key)&&void 0!==r?r:t.ref;let i=this._values[s];if(i){const e=i.get(a);if(e)return e}else i=this._values[s]=new Map;i.set(a,n);const o=this._scope[s]||(this._scope[s]=[]),c=o.length;return o[c]=t.ref,n.setValue(t,{property:s,itemIndex:c}),n}getValue(e,t){const r=this._values[e];if(r)return r.get(t)}scopeRefs(e,r=this._values){return this._reduceValues(r,r=>{if(void 0===r.scopePath)throw new Error(`CodeGen: name "${r}" has no value`);return t._`${e}${r.scopePath}`})}scopeCode(e=this._values,t,r){return this._reduceValues(e,e=>{if(void 0===e.value)throw new Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,r)}_reduceValues(s,a,i={},o){let c=t.nil;for(const d in s){const u=s[d];if(!u)continue;const l=i[d]=i[d]||new Map;u.forEach(s=>{if(l.has(s))return;l.set(s,n.Started);let i=a(s);if(i){const r=this.opts.es5?e.varKinds.var:e.varKinds.const;c=t._`${c}${r} ${s} = ${i};${this.opts._n}`}else{if(!(i=null==o?void 0:o(s)))throw new r(s);c=t._`${c}${i}${this.opts._n}`}l.set(s,n.Completed)})}return c}}}(cu)),cu}function uu(){return ou||(ou=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=au(),r=du();var n=au();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var s=du();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class a{optimizeNodes(){return this}optimizeNames(e,t){return this}}class i extends a{constructor(e,t,r){super(),this.varKind=e,this.name=t,this.rhs=r}render({es5:e,_n:t}){const n=e?r.varKinds.var:this.varKind,s=void 0===this.rhs?"":` = ${this.rhs}`;return`${n} ${this.name}${s};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&(this.rhs=P(this.rhs,e,t)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class o extends a{constructor(e,t,r){super(),this.lhs=e,this.rhs=t,this.sideEffects=r}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof t.Name)||e[this.lhs.str]||this.sideEffects)return this.rhs=P(this.rhs,e,r),this}get names(){return N(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}}class c extends o{constructor(e,t,r,n){super(e,r,n),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}}class d extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}}class u extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}}class l extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}}class p extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=P(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class f extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,r)=>t+r.render(e),"")}optimizeNodes(){const{nodes:e}=this;let t=e.length;for(;t--;){const r=e[t].optimizeNodes();Array.isArray(r)?e.splice(t,1,...r):r?e[t]=r:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){const{nodes:r}=this;let n=r.length;for(;n--;){const s=r[n];s.optimizeNames(e,t)||(O(e,s.names),r.splice(n,1))}return r.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>x(e,t.names),{})}}class h extends f{render(e){return"{"+e._n+super.render(e)+"}"+e._n}}class m extends f{}class g extends h{}g.kind="else";class y extends h{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+="else "+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();const e=this.condition;if(!0===e)return this.nodes;let t=this.else;if(t){const e=t.optimizeNodes();t=this.else=Array.isArray(e)?new g(e):e}return t?!1===e?t instanceof y?t:t.nodes:this.nodes.length?this:new y(I(e),t instanceof y?[t]:t.nodes):!1!==e&&this.nodes.length?this:void 0}optimizeNames(e,t){var r;if(this.else=null===(r=this.else)||void 0===r?void 0:r.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=P(this.condition,e,t),this}get names(){const e=super.names;return N(e,this.condition),this.else&&x(e,this.else.names),e}}y.kind="if";class _ extends h{}_.kind="for";class v extends _{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=P(this.iteration,e,t),this}get names(){return x(super.names,this.iteration.names)}}class w extends _{constructor(e,t,r,n){super(),this.varKind=e,this.name=t,this.from=r,this.to=n}render(e){const t=e.es5?r.varKinds.var:this.varKind,{name:n,from:s,to:a}=this;return`for(${t} ${n}=${s}; ${n}<${a}; ${n}++)`+super.render(e)}get names(){const e=N(super.names,this.from);return N(e,this.to)}}class b extends _{constructor(e,t,r,n){super(),this.loop=e,this.varKind=t,this.name=r,this.iterable=n}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=P(this.iterable,e,t),this}get names(){return x(super.names,this.iterable.names)}}class k extends h{constructor(e,t,r){super(),this.name=e,this.args=t,this.async=r}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}}k.kind="func";class $ extends f{render(e){return"return "+super.render(e)}}$.kind="return";class S extends h{render(e){let t="try"+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),null===(e=this.catch)||void 0===e||e.optimizeNodes(),null===(t=this.finally)||void 0===t||t.optimizeNodes(),this}optimizeNames(e,t){var r,n;return super.optimizeNames(e,t),null===(r=this.catch)||void 0===r||r.optimizeNames(e,t),null===(n=this.finally)||void 0===n||n.optimizeNames(e,t),this}get names(){const e=super.names;return this.catch&&x(e,this.catch.names),this.finally&&x(e,this.finally.names),e}}class E extends h{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}E.kind="catch";class T extends h{render(e){return"finally"+super.render(e)}}function x(e,t){for(const r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function N(e,r){return r instanceof t._CodeOrName?x(e,r.names):e}function P(e,r,n){return e instanceof t.Name?a(e):(s=e)instanceof t._Code&&s._items.some(e=>e instanceof t.Name&&1===r[e.str]&&void 0!==n[e.str])?new t._Code(e._items.reduce((e,r)=>(r instanceof t.Name&&(r=a(r)),r instanceof t._Code?e.push(...r._items):e.push(r),e),[])):e;var s;function a(e){const t=n[e.str];return void 0===t||1!==r[e.str]?e:(delete r[e.str],t)}}function O(e,t){for(const r in t)e[r]=(e[r]||0)-(t[r]||0)}function I(e){return"boolean"==typeof e||"number"==typeof e||null===e?!e:t._`!${C(e)}`}T.kind="finally",e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?"\n":""},this._extScope=e,this._scope=new r.Scope({parent:e}),this._nodes=[new m]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){const r=this._extScope.value(e,t);return(this._values[r.prefix]||(this._values[r.prefix]=new Set)).add(r),r}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,r,n){const s=this._scope.toName(t);return void 0!==r&&n&&(this._constants[s.str]=r),this._leafNode(new i(e,s,r)),s}const(e,t,n){return this._def(r.varKinds.const,e,t,n)}let(e,t,n){return this._def(r.varKinds.let,e,t,n)}var(e,t,n){return this._def(r.varKinds.var,e,t,n)}assign(e,t,r){return this._leafNode(new o(e,t,r))}add(t,r){return this._leafNode(new c(t,e.operators.ADD,r))}code(e){return"function"==typeof e?e():e!==t.nil&&this._leafNode(new p(e)),this}object(...e){const r=["{"];for(const[n,s]of e)r.length>1&&r.push(","),r.push(n),(n!==s||this.opts.es5)&&(r.push(":"),(0,t.addCodeArg)(r,s));return r.push("}"),new t._Code(r)}if(e,t,r){if(this._blockNode(new y(e)),t&&r)this.code(t).else().code(r).endIf();else if(t)this.code(t).endIf();else if(r)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new y(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(y,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new v(e),t)}forRange(e,t,n,s,a=(this.opts.es5?r.varKinds.var:r.varKinds.let)){const i=this._scope.toName(e);return this._for(new w(a,i,t,n),()=>s(i))}forOf(e,n,s,a=r.varKinds.const){const i=this._scope.toName(e);if(this.opts.es5){const e=n instanceof t.Name?n:this.var("_arr",n);return this.forRange("_i",0,t._`${e}.length`,r=>{this.var(i,t._`${e}[${r}]`),s(i)})}return this._for(new b("of",a,i,n),()=>s(i))}forIn(e,n,s,a=(this.opts.es5?r.varKinds.var:r.varKinds.const)){if(this.opts.ownProperties)return this.forOf(e,t._`Object.keys(${n})`,s);const i=this._scope.toName(e);return this._for(new b("in",a,i,n),()=>s(i))}endFor(){return this._endBlockNode(_)}label(e){return this._leafNode(new d(e))}break(e){return this._leafNode(new u(e))}return(e){const t=new $;if(this._blockNode(t),this.code(e),1!==t.nodes.length)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode($)}try(e,t,r){if(!t&&!r)throw new Error('CodeGen: "try" without "catch" and "finally"');const n=new S;if(this._blockNode(n),this.code(e),t){const e=this.name("e");this._currNode=n.catch=new E(e),t(e)}return r&&(this._currNode=n.finally=new T,this.code(r)),this._endBlockNode(E,T)}throw(e){return this._leafNode(new l(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){const t=this._blockStarts.pop();if(void 0===t)throw new Error("CodeGen: not in self-balancing block");const r=this._nodes.length-t;if(r<0||void 0!==e&&r!==e)throw new Error(`CodeGen: wrong number of nodes: ${r} vs ${e} expected`);return this._nodes.length=t,this}func(e,r=t.nil,n,s){return this._blockNode(new k(e,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(k)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){const r=this._currNode;if(r instanceof e||t&&r instanceof t)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){const t=this._currNode;if(!(t instanceof y))throw new Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){const e=this._nodes;return e[e.length-1]}set _currNode(e){const t=this._nodes;t[t.length-1]=e}},e.not=I;const j=z(e.operators.AND);e.and=function(...e){return e.reduce(j)};const R=z(e.operators.OR);function z(e){return(r,n)=>r===t.nil?n:n===t.nil?r:t._`${C(r)} ${e} ${C(n)}`}function C(e){return e instanceof t.Name?e:t._`(${e})`}e.or=function(...e){return e.reduce(R)}}(nu)),nu}var lu,pu={};function fu(){if(lu)return pu;lu=1,Object.defineProperty(pu,"__esModule",{value:!0}),pu.checkStrictMode=pu.getErrorPath=pu.Type=pu.useFunc=pu.setEvaluated=pu.evaluatedPropsToName=pu.mergeEvaluated=pu.eachItem=pu.unescapeJsonPointer=pu.escapeJsonPointer=pu.escapeFragment=pu.unescapeFragment=pu.schemaRefOrVal=pu.schemaHasRulesButRef=pu.schemaHasRules=pu.checkUnknownRules=pu.alwaysValidSchema=pu.toHash=void 0;const e=uu(),t=au();function r(e,t=e.schema){const{opts:r,self:n}=e;if(!r.strictSchema)return;if("boolean"==typeof t)return;const s=n.RULES.keywords;for(const r in t)s[r]||l(e,`unknown keyword: "${r}"`)}function n(e,t){if("boolean"==typeof e)return!e;for(const r in e)if(t[r])return!0;return!1}function s(e){return"number"==typeof e?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}function a(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function i({mergeNames:t,mergeToName:r,mergeValues:n,resultToName:s}){return(a,i,o,c)=>{const d=void 0===o?i:o instanceof e.Name?(i instanceof e.Name?t(a,i,o):r(a,i,o),o):i instanceof e.Name?(r(a,o,i),i):n(i,o);return c!==e.Name||d instanceof e.Name?d:s(a,d)}}function o(t,r){if(!0===r)return t.var("props",!0);const n=t.var("props",e._`{}`);return void 0!==r&&c(t,n,r),n}function c(t,r,n){Object.keys(n).forEach(n=>t.assign(e._`${r}${(0,e.getProperty)(n)}`,!0))}pu.toHash=function(e){const t={};for(const r of e)t[r]=!0;return t},pu.alwaysValidSchema=function(e,t){return"boolean"==typeof t?t:0===Object.keys(t).length||(r(e,t),!n(t,e.self.RULES.all))},pu.checkUnknownRules=r,pu.schemaHasRules=n,pu.schemaHasRulesButRef=function(e,t){if("boolean"==typeof e)return!e;for(const r in e)if("$ref"!==r&&t.all[r])return!0;return!1},pu.schemaRefOrVal=function({topSchemaRef:t,schemaPath:r},n,s,a){if(!a){if("number"==typeof n||"boolean"==typeof n)return n;if("string"==typeof n)return e._`${n}`}return e._`${t}${r}${(0,e.getProperty)(s)}`},pu.unescapeFragment=function(e){return a(decodeURIComponent(e))},pu.escapeFragment=function(e){return encodeURIComponent(s(e))},pu.escapeJsonPointer=s,pu.unescapeJsonPointer=a,pu.eachItem=function(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)},pu.mergeEvaluated={props:i({mergeNames:(t,r,n)=>t.if(e._`${n} !== true && ${r} !== undefined`,()=>{t.if(e._`${r} === true`,()=>t.assign(n,!0),()=>t.assign(n,e._`${n} || {}`).code(e._`Object.assign(${n}, ${r})`))}),mergeToName:(t,r,n)=>t.if(e._`${n} !== true`,()=>{!0===r?t.assign(n,!0):(t.assign(n,e._`${n} || {}`),c(t,n,r))}),mergeValues:(e,t)=>!0===e||{...e,...t},resultToName:o}),items:i({mergeNames:(t,r,n)=>t.if(e._`${n} !== true && ${r} !== undefined`,()=>t.assign(n,e._`${r} === true ? true : ${n} > ${r} ? ${n} : ${r}`)),mergeToName:(t,r,n)=>t.if(e._`${n} !== true`,()=>t.assign(n,!0===r||e._`${n} > ${r} ? ${n} : ${r}`)),mergeValues:(e,t)=>!0===e||Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})},pu.evaluatedPropsToName=o,pu.setEvaluated=c;const d={};var u;function l(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,!0===r)throw new Error(t);e.self.logger.warn(t)}}return pu.useFunc=function(e,r){return e.scopeValue("func",{ref:r,code:d[r.code]||(d[r.code]=new t._Code(r.code))})},function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"}(u||(pu.Type=u={})),pu.getErrorPath=function(t,r,n){if(t instanceof e.Name){const s=r===u.Num;return n?s?e._`"[" + ${t} + "]"`:e._`"['" + ${t} + "']"`:s?e._`"/" + ${t}`:e._`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,e.getProperty)(t).toString():"/"+s(t)},pu.checkStrictMode=l,pu}var hu,mu,gu,yu={};function _u(){if(hu)return yu;hu=1,Object.defineProperty(yu,"__esModule",{value:!0});const e=uu(),t={data:new e.Name("data"),valCxt:new e.Name("valCxt"),instancePath:new e.Name("instancePath"),parentData:new e.Name("parentData"),parentDataProperty:new e.Name("parentDataProperty"),rootData:new e.Name("rootData"),dynamicAnchors:new e.Name("dynamicAnchors"),vErrors:new e.Name("vErrors"),errors:new e.Name("errors"),this:new e.Name("this"),self:new e.Name("self"),scope:new e.Name("scope"),json:new e.Name("json"),jsonPos:new e.Name("jsonPos"),jsonLen:new e.Name("jsonLen"),jsonPart:new e.Name("jsonPart")};return yu.default=t,yu}function vu(){return mu||(mu=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=uu(),r=fu(),n=_u();function s(e,r){const s=e.const("err",r);e.if(t._`${n.default.vErrors} === null`,()=>e.assign(n.default.vErrors,t._`[${s}]`),t._`${n.default.vErrors}.push(${s})`),e.code(t._`${n.default.errors}++`)}function a(e,r){const{gen:n,validateName:s,schemaEnv:a}=e;a.$async?n.throw(t._`new ${e.ValidationError}(${r})`):(n.assign(t._`${s}.errors`,r),n.return(!1))}e.keywordError={message:({keyword:e})=>t.str`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:r})=>r?t.str`"${e}" keyword must be ${r} ($data)`:t.str`"${e}" keyword is invalid ($data)`},e.reportError=function(r,n=e.keywordError,i,c){const{it:d}=r,{gen:u,compositeRule:l,allErrors:p}=d,f=o(r,n,i);(null!=c?c:l||p)?s(u,f):a(d,t._`[${f}]`)},e.reportExtraError=function(t,r=e.keywordError,i){const{it:c}=t,{gen:d,compositeRule:u,allErrors:l}=c;s(d,o(t,r,i)),u||l||a(c,n.default.vErrors)},e.resetErrorsCount=function(e,r){e.assign(n.default.errors,r),e.if(t._`${n.default.vErrors} !== null`,()=>e.if(r,()=>e.assign(t._`${n.default.vErrors}.length`,r),()=>e.assign(n.default.vErrors,null)))},e.extendErrors=function({gen:e,keyword:r,schemaValue:s,data:a,errsCount:i,it:o}){if(void 0===i)throw new Error("ajv implementation error");const c=e.name("err");e.forRange("i",i,n.default.errors,i=>{e.const(c,t._`${n.default.vErrors}[${i}]`),e.if(t._`${c}.instancePath === undefined`,()=>e.assign(t._`${c}.instancePath`,(0,t.strConcat)(n.default.instancePath,o.errorPath))),e.assign(t._`${c}.schemaPath`,t.str`${o.errSchemaPath}/${r}`),o.opts.verbose&&(e.assign(t._`${c}.schema`,s),e.assign(t._`${c}.data`,a))})};const i={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function o(e,r,s){const{createErrors:a}=e.it;return!1===a?t._`{}`:function(e,r,s={}){const{gen:a,it:o}=e,u=[c(o,s),d(e,s)];return function(e,{params:r,message:s},a){const{keyword:o,data:c,schemaValue:d,it:u}=e,{opts:l,propertyName:p,topSchemaRef:f,schemaPath:h}=u;a.push([i.keyword,o],[i.params,"function"==typeof r?r(e):r||t._`{}`]),l.messages&&a.push([i.message,"function"==typeof s?s(e):s]),l.verbose&&a.push([i.schema,d],[i.parentSchema,t._`${f}${h}`],[n.default.data,c]),p&&a.push([i.propertyName,p])}(e,r,u),a.object(...u)}(e,r,s)}function c({errorPath:e},{instancePath:s}){const a=s?t.str`${e}${(0,r.getErrorPath)(s,r.Type.Str)}`:e;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,a)]}function d({keyword:e,it:{errSchemaPath:n}},{schemaPath:s,parentSchema:a}){let o=a?n:t.str`${n}/${e}`;return s&&(o=t.str`${o}${(0,r.getErrorPath)(s,r.Type.Str)}`),[i.schemaPath,o]}}(ru)),ru}var wu,bu={},ku={};function $u(){if(wu)return ku;wu=1,Object.defineProperty(ku,"__esModule",{value:!0}),ku.getRules=ku.isJSONType=void 0;const e=new Set(["string","number","integer","boolean","null","object","array"]);return ku.isJSONType=function(t){return"string"==typeof t&&e.has(t)},ku.getRules=function(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}},ku}var Su,Eu,Tu={};function xu(){if(Su)return Tu;function e(e,r){return r.rules.some(r=>t(e,r))}function t(e,t){var r;return void 0!==e[t.keyword]||(null===(r=t.definition.implements)||void 0===r?void 0:r.some(t=>void 0!==e[t]))}return Su=1,Object.defineProperty(Tu,"__esModule",{value:!0}),Tu.shouldUseRule=Tu.shouldUseGroup=Tu.schemaHasRulesForType=void 0,Tu.schemaHasRulesForType=function({schema:t,self:r},n){const s=r.RULES.types[n];return s&&!0!==s&&e(t,s)},Tu.shouldUseGroup=e,Tu.shouldUseRule=t,Tu}function Nu(){if(Eu)return bu;Eu=1,Object.defineProperty(bu,"__esModule",{value:!0}),bu.reportTypeError=bu.checkDataTypes=bu.checkDataType=bu.coerceAndCheckDataType=bu.getJSONTypes=bu.getSchemaTypes=bu.DataType=void 0;const e=$u(),t=xu(),r=vu(),n=uu(),s=fu();var a;function i(t){const r=Array.isArray(t)?t:t?[t]:[];if(r.every(e.isJSONType))return r;throw new Error("type must be JSONType or JSONType[]: "+r.join(","))}!function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"}(a||(bu.DataType=a={})),bu.getSchemaTypes=function(e){const t=i(e.type);if(t.includes("null")){if(!1===e.nullable)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&void 0!==e.nullable)throw new Error('"nullable" cannot be used without "type"');!0===e.nullable&&t.push("null")}return t},bu.getJSONTypes=i,bu.coerceAndCheckDataType=function(e,r){const{gen:s,data:i,opts:c}=e,u=function(e,t){return t?e.filter(e=>o.has(e)||"array"===t&&"array"===e):[]}(r,c.coerceTypes),p=r.length>0&&!(0===u.length&&1===r.length&&(0,t.schemaHasRulesForType)(e,r[0]));if(p){const t=d(r,i,c.strictNumbers,a.Wrong);s.if(t,()=>{u.length?function(e,t,r){const{gen:s,data:a,opts:i}=e,c=s.let("dataType",n._`typeof ${a}`),u=s.let("coerced",n._`undefined`);"array"===i.coerceTypes&&s.if(n._`${c} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>s.assign(a,n._`${a}[0]`).assign(c,n._`typeof ${a}`).if(d(t,a,i.strictNumbers),()=>s.assign(u,a))),s.if(n._`${u} !== undefined`);for(const e of r)(o.has(e)||"array"===e&&"array"===i.coerceTypes)&&p(e);function p(e){switch(e){case"string":return void s.elseIf(n._`${c} == "number" || ${c} == "boolean"`).assign(u,n._`"" + ${a}`).elseIf(n._`${a} === null`).assign(u,n._`""`);case"number":return void s.elseIf(n._`${c} == "boolean" || ${a} === null
1
+ import{ZodOptional as e,z as t}from"zod";import r from"node:process";import n,{existsSync as s,mkdirSync as a,writeFileSync as i,readFileSync as o}from"fs";import c from"os";import d,{dirname as u}from"path";import l from"better-sqlite3";import"child_process";import{fileURLToPath as p}from"url";var f,h;!function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const r of e)t[r]=r;return t},e.getValidEnumValues=t=>{const r=e.objectKeys(t).filter(e=>"number"!=typeof t[t[e]]),n={};for(const e of r)n[e]=t[e];return e.objectValues(n)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},e.find=(e,t)=>{for(const r of e)if(t(r))return r},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map(e=>"string"==typeof e?`'${e}'`:e).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(f||(f={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(h||(h={}));const m=f.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),g=e=>{switch(typeof e){case"undefined":return m.undefined;case"string":return m.string;case"number":return Number.isNaN(e)?m.nan:m.number;case"boolean":return m.boolean;case"function":return m.function;case"bigint":return m.bigint;case"symbol":return m.symbol;case"object":return Array.isArray(e)?m.array:null===e?m.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?m.promise:"undefined"!=typeof Map&&e instanceof Map?m.map:"undefined"!=typeof Set&&e instanceof Set?m.set:"undefined"!=typeof Date&&e instanceof Date?m.date:m.object;default:return m.unknown}},y=f.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"]);class _ extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},r={_errors:[]},n=e=>{for(const s of e.issues)if("invalid_union"===s.code)s.unionErrors.map(n);else if("invalid_return_type"===s.code)n(s.returnTypeError);else if("invalid_arguments"===s.code)n(s.argumentsError);else if(0===s.path.length)r._errors.push(t(s));else{let e=r,n=0;for(;n<s.path.length;){const r=s.path[n];n===s.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(s))):e[r]=e[r]||{_errors:[]},e=e[r],n++}}};return n(this),r}static assert(e){if(!(e instanceof _))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,f.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t=Object.create(null),r=[];for(const n of this.issues)if(n.path.length>0){const r=n.path[0];t[r]=t[r]||[],t[r].push(e(n))}else r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}_.create=e=>new _(e);const v=(e,t)=>{let r;switch(e.code){case y.invalid_type:r=e.received===m.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case y.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,f.jsonStringifyReplacer)}`;break;case y.unrecognized_keys:r=`Unrecognized key(s) in object: ${f.joinValues(e.keys,", ")}`;break;case y.invalid_union:r="Invalid input";break;case y.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${f.joinValues(e.options)}`;break;case y.invalid_enum_value:r=`Invalid enum value. Expected ${f.joinValues(e.options)}, received '${e.received}'`;break;case y.invalid_arguments:r="Invalid function arguments";break;case y.invalid_return_type:r="Invalid function return type";break;case y.invalid_date:r="Invalid date";break;case y.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:f.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case y.too_small:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type||"bigint"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case y.too_big:r="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case y.custom:r="Invalid input";break;case y.invalid_intersection_types:r="Intersection results could not be merged";break;case y.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case y.not_finite:r="Number must be finite";break;default:r=t.defaultError,f.assertNever(e)}return{message:r}};let w=v;function b(e,t){const r=w,n=(e=>{const{data:t,path:r,errorMaps:n,issueData:s}=e,a=[...r,...s.path||[]],i={...s,path:a};if(void 0!==s.message)return{...s,path:a,message:s.message};let o="";const c=n.filter(e=>!!e).slice().reverse();for(const e of c)o=e(i,{data:t,defaultError:o}).message;return{...s,path:a,message:o}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===v?void 0:v].filter(e=>!!e)});e.common.issues.push(n)}class k{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const n of t){if("aborted"===n.status)return $;"dirty"===n.status&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const e of t){const t=await e.key,n=await e.value;r.push({key:t,value:n})}return k.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const n of t){const{key:t,value:s}=n;if("aborted"===t.status)return $;if("aborted"===s.status)return $;"dirty"===t.status&&e.dirty(),"dirty"===s.status&&e.dirty(),"__proto__"===t.value||void 0===s.value&&!n.alwaysSet||(r[t.value]=s.value)}return{status:e.value,value:r}}}const $=Object.freeze({status:"aborted"}),S=e=>({status:"dirty",value:e}),E=e=>({status:"valid",value:e}),T=e=>"aborted"===e.status,x=e=>"dirty"===e.status,N=e=>"valid"===e.status,O=e=>"undefined"!=typeof Promise&&e instanceof Promise;var P;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(P||(P={}));class I{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const R=(e,t)=>{if(N(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new _(e.common.issues);return this._error=t,this._error}}};function j(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:n,description:s}=e;if(t&&(r||n))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');return t?{errorMap:t,description:s}:{errorMap:(t,s)=>{const{message:a}=e;return"invalid_enum_value"===t.code?{message:a??s.defaultError}:void 0===s.data?{message:a??n??s.defaultError}:"invalid_type"!==t.code?{message:s.defaultError}:{message:a??r??s.defaultError}},description:s}}let z=class{get description(){return this._def.description}_getType(e){return g(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:g(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new k,ctx:{common:e.parent.common,data:e.data,parsedType:g(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(O(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:g(e)},n=this._parseSync({data:e,path:r.path,parent:r});return R(r,n)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:g(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:t});return N(r)?{value:r.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>N(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:g(e)},n=this._parse({data:e,path:r.path,parent:r}),s=await(O(n)?n:Promise.resolve(n));return R(r,s)}refine(e,t){const r=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,n)=>{const s=e(t),a=()=>n.addIssue({code:y.custom,...r(t)});return"undefined"!=typeof Promise&&s instanceof Promise?s.then(e=>!!e||(a(),!1)):!!s||(a(),!1)})}refinement(e,t){return this._refinement((r,n)=>!!e(r)||(n.addIssue("function"==typeof t?t(r,n):t),!1))}_refinement(e){return new Re({schema:this,typeName:Fe.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return je.create(this,this._def)}nullable(){return ze.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ye.create(this)}promise(){return Ie.create(this,this._def)}or(e){return we.create([this,e],this._def)}and(e){return ke.create(this,e,this._def)}transform(e){return new Re({...j(this._def),schema:this,typeName:Fe.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Ce({...j(this._def),innerType:this,defaultValue:t,typeName:Fe.ZodDefault})}brand(){return new Ze({typeName:Fe.ZodBranded,type:this,...j(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Ae({...j(this._def),innerType:this,catchValue:t,typeName:Fe.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return De.create(this,e)}readonly(){return Le.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const C=/^c[^\s-]{8,}$/i,A=/^[0-9a-z]+$/,M=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Z=/^[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,D=/^[a-z0-9_-]{21}$/i,L=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,F=/^[-+]?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)?)??$/,q=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let U;const V=/^(?:(?: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])$/,H=/^(?:(?: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])$/,J=/^(([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]))$/,K=/^(([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])$/,B=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,G=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,X="((\\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])))",W=new RegExp(`^${X}$`);function Y(e){let t="[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function Q(e){return new RegExp(`^${Y(e)}$`)}function ee(e){let t=`${X}T${Y(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function te(e,t){return!("v4"!==t&&t||!V.test(e))||!("v6"!==t&&t||!J.test(e))}function re(e,t){if(!L.test(e))return!1;try{const[r]=e.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(n));return!("object"!=typeof s||null===s||"typ"in s&&"JWT"!==s?.typ||!s.alg||t&&s.alg!==t)}catch{return!1}}function ne(e,t){return!("v4"!==t&&t||!H.test(e))||!("v6"!==t&&t||!K.test(e))}let se=class e extends z{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==m.string){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.string,received:t.parsedType}),$}const t=new k;let r;for(const n of this._def.checks)if("min"===n.kind)e.data.length<n.value&&(r=this._getOrReturnCtx(e,r),b(r,{code:y.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if("max"===n.kind)e.data.length>n.value&&(r=this._getOrReturnCtx(e,r),b(r,{code:y.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if("length"===n.kind){const s=e.data.length>n.value,a=e.data.length<n.value;(s||a)&&(r=this._getOrReturnCtx(e,r),s?b(r,{code:y.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):a&&b(r,{code:y.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if("email"===n.kind)q.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"email",code:y.invalid_string,message:n.message}),t.dirty());else if("emoji"===n.kind)U||(U=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),U.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"emoji",code:y.invalid_string,message:n.message}),t.dirty());else if("uuid"===n.kind)Z.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"uuid",code:y.invalid_string,message:n.message}),t.dirty());else if("nanoid"===n.kind)D.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"nanoid",code:y.invalid_string,message:n.message}),t.dirty());else if("cuid"===n.kind)C.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"cuid",code:y.invalid_string,message:n.message}),t.dirty());else if("cuid2"===n.kind)A.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"cuid2",code:y.invalid_string,message:n.message}),t.dirty());else if("ulid"===n.kind)M.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"ulid",code:y.invalid_string,message:n.message}),t.dirty());else if("url"===n.kind)try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),b(r,{validation:"url",code:y.invalid_string,message:n.message}),t.dirty()}else"regex"===n.kind?(n.regex.lastIndex=0,n.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"regex",code:y.invalid_string,message:n.message}),t.dirty())):"trim"===n.kind?e.data=e.data.trim():"includes"===n.kind?e.data.includes(n.value,n.position)||(r=this._getOrReturnCtx(e,r),b(r,{code:y.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):"toLowerCase"===n.kind?e.data=e.data.toLowerCase():"toUpperCase"===n.kind?e.data=e.data.toUpperCase():"startsWith"===n.kind?e.data.startsWith(n.value)||(r=this._getOrReturnCtx(e,r),b(r,{code:y.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):"endsWith"===n.kind?e.data.endsWith(n.value)||(r=this._getOrReturnCtx(e,r),b(r,{code:y.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):"datetime"===n.kind?ee(n).test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{code:y.invalid_string,validation:"datetime",message:n.message}),t.dirty()):"date"===n.kind?W.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{code:y.invalid_string,validation:"date",message:n.message}),t.dirty()):"time"===n.kind?Q(n).test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{code:y.invalid_string,validation:"time",message:n.message}),t.dirty()):"duration"===n.kind?F.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"duration",code:y.invalid_string,message:n.message}),t.dirty()):"ip"===n.kind?te(e.data,n.version)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"ip",code:y.invalid_string,message:n.message}),t.dirty()):"jwt"===n.kind?re(e.data,n.alg)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"jwt",code:y.invalid_string,message:n.message}),t.dirty()):"cidr"===n.kind?ne(e.data,n.version)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"cidr",code:y.invalid_string,message:n.message}),t.dirty()):"base64"===n.kind?B.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"base64",code:y.invalid_string,message:n.message}),t.dirty()):"base64url"===n.kind?G.test(e.data)||(r=this._getOrReturnCtx(e,r),b(r,{validation:"base64url",code:y.invalid_string,message:n.message}),t.dirty()):f.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:y.invalid_string,...P.errToObj(r)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:"email",...P.errToObj(e)})}url(e){return this._addCheck({kind:"url",...P.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...P.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...P.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...P.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...P.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...P.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...P.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...P.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...P.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...P.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...P.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...P.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...P.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...P.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...P.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...P.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...P.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...P.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...P.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...P.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...P.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...P.errToObj(t)})}nonempty(e){return this.min(1,P.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>"datetime"===e.kind)}get isDate(){return!!this._def.checks.find(e=>"date"===e.kind)}get isTime(){return!!this._def.checks.find(e=>"time"===e.kind)}get isDuration(){return!!this._def.checks.find(e=>"duration"===e.kind)}get isEmail(){return!!this._def.checks.find(e=>"email"===e.kind)}get isURL(){return!!this._def.checks.find(e=>"url"===e.kind)}get isEmoji(){return!!this._def.checks.find(e=>"emoji"===e.kind)}get isUUID(){return!!this._def.checks.find(e=>"uuid"===e.kind)}get isNANOID(){return!!this._def.checks.find(e=>"nanoid"===e.kind)}get isCUID(){return!!this._def.checks.find(e=>"cuid"===e.kind)}get isCUID2(){return!!this._def.checks.find(e=>"cuid2"===e.kind)}get isULID(){return!!this._def.checks.find(e=>"ulid"===e.kind)}get isIP(){return!!this._def.checks.find(e=>"ip"===e.kind)}get isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===e.kind)}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}};function ae(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,s=r>n?r:n;return Number.parseInt(e.toFixed(s).replace(".",""))%Number.parseInt(t.toFixed(s).replace(".",""))/10**s}se.create=e=>new se({checks:[],typeName:Fe.ZodString,coerce:e?.coerce??!1,...j(e)});let ie=class e extends z{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==m.number){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.number,received:t.parsedType}),$}let t;const r=new k;for(const n of this._def.checks)"int"===n.kind?f.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),b(t,{code:y.invalid_type,expected:"integer",received:"float",message:n.message}),r.dirty()):"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:y.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:y.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"multipleOf"===n.kind?0!==ae(e.data,n.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:y.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),b(t,{code:y.not_finite,message:n.message}),r.dirty()):f.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,P.toString(t))}gt(e,t){return this.setLimit("min",e,!1,P.toString(t))}lte(e,t){return this.setLimit("max",e,!0,P.toString(t))}lt(e,t){return this.setLimit("max",e,!1,P.toString(t))}setLimit(t,r,n,s){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:P.toString(s)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:"int",message:P.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:P.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:P.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:P.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:P.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>"int"===e.kind||"multipleOf"===e.kind&&f.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}};ie.create=e=>new ie({checks:[],typeName:Fe.ZodNumber,coerce:e?.coerce||!1,...j(e)});class oe extends z{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==m.bigint)return this._getInvalidInput(e);let t;const r=new k;for(const n of this._def.checks)"min"===n.kind?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:y.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):"max"===n.kind?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:y.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),r.dirty()):"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),b(t,{code:y.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):f.assertNever(n);return{status:r.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.bigint,received:t.parsedType}),$}gte(e,t){return this.setLimit("min",e,!0,P.toString(t))}gt(e,t){return this.setLimit("min",e,!1,P.toString(t))}lte(e,t){return this.setLimit("max",e,!0,P.toString(t))}lt(e,t){return this.setLimit("max",e,!1,P.toString(t))}setLimit(e,t,r,n){return new oe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:P.toString(n)}]})}_addCheck(e){return new oe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:P.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:P.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:P.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:P.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:P.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}oe.create=e=>new oe({checks:[],typeName:Fe.ZodBigInt,coerce:e?.coerce??!1,...j(e)});let ce=class extends z{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==m.boolean){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.boolean,received:t.parsedType}),$}return E(e.data)}};ce.create=e=>new ce({typeName:Fe.ZodBoolean,coerce:e?.coerce||!1,...j(e)});class de extends z{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==m.date){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.date,received:t.parsedType}),$}if(Number.isNaN(e.data.getTime()))return b(this._getOrReturnCtx(e),{code:y.invalid_date}),$;const t=new k;let r;for(const n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(r=this._getOrReturnCtx(e,r),b(r,{code:y.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):"max"===n.kind?e.data.getTime()>n.value&&(r=this._getOrReturnCtx(e,r),b(r,{code:y.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):f.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new de({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:P.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:P.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}de.create=e=>new de({checks:[],coerce:e?.coerce||!1,typeName:Fe.ZodDate,...j(e)});class ue extends z{_parse(e){if(this._getType(e)!==m.symbol){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.symbol,received:t.parsedType}),$}return E(e.data)}}ue.create=e=>new ue({typeName:Fe.ZodSymbol,...j(e)});class le extends z{_parse(e){if(this._getType(e)!==m.undefined){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.undefined,received:t.parsedType}),$}return E(e.data)}}le.create=e=>new le({typeName:Fe.ZodUndefined,...j(e)});let pe=class extends z{_parse(e){if(this._getType(e)!==m.null){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.null,received:t.parsedType}),$}return E(e.data)}};pe.create=e=>new pe({typeName:Fe.ZodNull,...j(e)});class fe extends z{constructor(){super(...arguments),this._any=!0}_parse(e){return E(e.data)}}fe.create=e=>new fe({typeName:Fe.ZodAny,...j(e)});let he=class extends z{constructor(){super(...arguments),this._unknown=!0}_parse(e){return E(e.data)}};he.create=e=>new he({typeName:Fe.ZodUnknown,...j(e)});let me=class extends z{_parse(e){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.never,received:t.parsedType}),$}};me.create=e=>new me({typeName:Fe.ZodNever,...j(e)});class ge extends z{_parse(e){if(this._getType(e)!==m.undefined){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.void,received:t.parsedType}),$}return E(e.data)}}ge.create=e=>new ge({typeName:Fe.ZodVoid,...j(e)});let ye=class e extends z{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==m.array)return b(t,{code:y.invalid_type,expected:m.array,received:t.parsedType}),$;if(null!==n.exactLength){const e=t.data.length>n.exactLength.value,s=t.data.length<n.exactLength.value;(e||s)&&(b(t,{code:e?y.too_big:y.too_small,minimum:s?n.exactLength.value:void 0,maximum:e?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(null!==n.minLength&&t.data.length<n.minLength.value&&(b(t,{code:y.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),null!==n.maxLength&&t.data.length>n.maxLength.value&&(b(t,{code:y.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((e,r)=>n.type._parseAsync(new I(t,e,t.path,r)))).then(e=>k.mergeArray(r,e));const s=[...t.data].map((e,r)=>n.type._parseSync(new I(t,e,t.path,r)));return k.mergeArray(r,s)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:P.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:P.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:P.toString(r)}})}nonempty(e){return this.min(1,e)}};function _e(e){if(e instanceof ve){const t={};for(const r in e.shape){const n=e.shape[r];t[r]=je.create(_e(n))}return new ve({...e._def,shape:()=>t})}return e instanceof ye?new ye({...e._def,type:_e(e.element)}):e instanceof je?je.create(_e(e.unwrap())):e instanceof ze?ze.create(_e(e.unwrap())):e instanceof $e?$e.create(e.items.map(e=>_e(e))):e}ye.create=(e,t)=>new ye({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Fe.ZodArray,...j(t)});let ve=class e extends z{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=f.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==m.object){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.object,received:t.parsedType}),$}const{status:t,ctx:r}=this._processInputParams(e),{shape:n,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof me&&"strip"===this._def.unknownKeys))for(const e in r.data)s.includes(e)||a.push(e);const i=[];for(const e of s){const t=n[e],s=r.data[e];i.push({key:{status:"valid",value:e},value:t._parse(new I(r,s,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof me){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of a)i.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)a.length>0&&(b(r,{code:y.unrecognized_keys,keys:a}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of a){const n=r.data[t];i.push({key:{status:"valid",value:t},value:e._parse(new I(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of i){const r=await t.key,n=await t.value;e.push({key:r,value:n,alwaysSet:t.alwaysSet})}return e}).then(e=>k.mergeObjectSync(t,e)):k.mergeObjectSync(t,i)}get shape(){return this._def.shape()}strict(t){return P.errToObj,new e({...this._def,unknownKeys:"strict",...void 0!==t?{errorMap:(e,r)=>{const n=this._def.errorMap?.(e,r).message??r.defaultError;return"unrecognized_keys"===e.code?{message:P.errToObj(t).message??n}:{message:n}}}:{}})}strip(){return new e({...this._def,unknownKeys:"strip"})}passthrough(){return new e({...this._def,unknownKeys:"passthrough"})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Fe.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){const r={};for(const e of f.objectKeys(t))t[e]&&this.shape[e]&&(r[e]=this.shape[e]);return new e({...this._def,shape:()=>r})}omit(t){const r={};for(const e of f.objectKeys(this.shape))t[e]||(r[e]=this.shape[e]);return new e({...this._def,shape:()=>r})}deepPartial(){return _e(this)}partial(t){const r={};for(const e of f.objectKeys(this.shape)){const n=this.shape[e];t&&!t[e]?r[e]=n:r[e]=n.optional()}return new e({...this._def,shape:()=>r})}required(t){const r={};for(const e of f.objectKeys(this.shape))if(t&&!t[e])r[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof je;)t=t._def.innerType;r[e]=t}return new e({...this._def,shape:()=>r})}keyof(){return Ne(f.objectKeys(this.shape))}};ve.create=(e,t)=>new ve({shape:()=>e,unknownKeys:"strip",catchall:me.create(),typeName:Fe.ZodObject,...j(t)}),ve.strictCreate=(e,t)=>new ve({shape:()=>e,unknownKeys:"strict",catchall:me.create(),typeName:Fe.ZodObject,...j(t)}),ve.lazycreate=(e,t)=>new ve({shape:e,unknownKeys:"strip",catchall:me.create(),typeName:Fe.ZodObject,...j(t)});let we=class extends z{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map(async e=>{const r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}})).then(function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;const r=e.map(e=>new _(e.ctx.common.issues));return b(t,{code:y.invalid_union,unionErrors:r}),$});{let e;const n=[];for(const s of r){const r={...t,common:{...t.common,issues:[]},parent:null},a=s._parseSync({data:t.data,path:t.path,parent:r});if("valid"===a.status)return a;"dirty"!==a.status||e||(e={result:a,ctx:r}),r.common.issues.length&&n.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const s=n.map(e=>new _(e));return b(t,{code:y.invalid_union,unionErrors:s}),$}}get options(){return this._def.options}};function be(e,t){const r=g(e),n=g(t);if(e===t)return{valid:!0,data:e};if(r===m.object&&n===m.object){const r=f.objectKeys(t),n=f.objectKeys(e).filter(e=>-1!==r.indexOf(e)),s={...e,...t};for(const r of n){const n=be(e[r],t[r]);if(!n.valid)return{valid:!1};s[r]=n.data}return{valid:!0,data:s}}if(r===m.array&&n===m.array){if(e.length!==t.length)return{valid:!1};const r=[];for(let n=0;n<e.length;n++){const s=be(e[n],t[n]);if(!s.valid)return{valid:!1};r.push(s.data)}return{valid:!0,data:r}}return r===m.date&&n===m.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}we.create=(e,t)=>new we({options:e,typeName:Fe.ZodUnion,...j(t)});let ke=class extends z{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=(e,n)=>{if(T(e)||T(n))return $;const s=be(e.value,n.value);return s.valid?((x(e)||x(n))&&t.dirty(),{status:t.value,value:s.data}):(b(r,{code:y.invalid_intersection_types}),$)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([e,t])=>n(e,t)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}};ke.create=(e,t,r)=>new ke({left:e,right:t,typeName:Fe.ZodIntersection,...j(r)});class $e extends z{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.array)return b(r,{code:y.invalid_type,expected:m.array,received:r.parsedType}),$;if(r.data.length<this._def.items.length)return b(r,{code:y.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),$;!this._def.rest&&r.data.length>this._def.items.length&&(b(r,{code:y.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...r.data].map((e,t)=>{const n=this._def.items[t]||this._def.rest;return n?n._parse(new I(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(n).then(e=>k.mergeArray(t,e)):k.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new $e({...this._def,rest:e})}}$e.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new $e({items:e,typeName:Fe.ZodTuple,rest:null,...j(t)})};class Se extends z{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.map)return b(r,{code:y.invalid_type,expected:m.map,received:r.parsedType}),$;const n=this._def.keyType,s=this._def.valueType,a=[...r.data.entries()].map(([e,t],a)=>({key:n._parse(new I(r,e,r.path,[a,"key"])),value:s._parse(new I(r,t,r.path,[a,"value"]))}));if(r.common.async){const e=new Map;return Promise.resolve().then(async()=>{for(const r of a){const n=await r.key,s=await r.value;if("aborted"===n.status||"aborted"===s.status)return $;"dirty"!==n.status&&"dirty"!==s.status||t.dirty(),e.set(n.value,s.value)}return{status:t.value,value:e}})}{const e=new Map;for(const r of a){const n=r.key,s=r.value;if("aborted"===n.status||"aborted"===s.status)return $;"dirty"!==n.status&&"dirty"!==s.status||t.dirty(),e.set(n.value,s.value)}return{status:t.value,value:e}}}}Se.create=(e,t,r)=>new Se({valueType:t,keyType:e,typeName:Fe.ZodMap,...j(r)});class Ee extends z{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==m.set)return b(r,{code:y.invalid_type,expected:m.set,received:r.parsedType}),$;const n=this._def;null!==n.minSize&&r.data.size<n.minSize.value&&(b(r,{code:y.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),null!==n.maxSize&&r.data.size>n.maxSize.value&&(b(r,{code:y.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const s=this._def.valueType;function a(e){const r=new Set;for(const n of e){if("aborted"===n.status)return $;"dirty"===n.status&&t.dirty(),r.add(n.value)}return{status:t.value,value:r}}const i=[...r.data.values()].map((e,t)=>s._parse(new I(r,e,r.path,t)));return r.common.async?Promise.all(i).then(e=>a(e)):a(i)}min(e,t){return new Ee({...this._def,minSize:{value:e,message:P.toString(t)}})}max(e,t){return new Ee({...this._def,maxSize:{value:e,message:P.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}Ee.create=(e,t)=>new Ee({valueType:e,minSize:null,maxSize:null,typeName:Fe.ZodSet,...j(t)});class Te extends z{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Te.create=(e,t)=>new Te({getter:e,typeName:Fe.ZodLazy,...j(t)});let xe=class extends z{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return b(t,{received:t.data,code:y.invalid_literal,expected:this._def.value}),$}return{status:"valid",value:e.data}}get value(){return this._def.value}};function Ne(e,t){return new Oe({values:e,typeName:Fe.ZodEnum,...j(t)})}xe.create=(e,t)=>new xe({value:e,typeName:Fe.ZodLiteral,...j(t)});let Oe=class e extends z{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),r=this._def.values;return b(t,{expected:f.joinValues(r),received:t.parsedType,code:y.invalid_type}),$}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return b(t,{received:t.data,code:y.invalid_enum_value,options:r}),$}return E(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...r})}};Oe.create=Ne;class Pe extends z{_parse(e){const t=f.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==m.string&&r.parsedType!==m.number){const e=f.objectValues(t);return b(r,{expected:f.joinValues(e),received:r.parsedType,code:y.invalid_type}),$}if(this._cache||(this._cache=new Set(f.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=f.objectValues(t);return b(r,{received:r.data,code:y.invalid_enum_value,options:e}),$}return E(e.data)}get enum(){return this._def.values}}Pe.create=(e,t)=>new Pe({values:e,typeName:Fe.ZodNativeEnum,...j(t)});class Ie extends z{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==m.promise&&!1===t.common.async)return b(t,{code:y.invalid_type,expected:m.promise,received:t.parsedType}),$;const r=t.parsedType===m.promise?t.data:Promise.resolve(t.data);return E(r.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ie.create=(e,t)=>new Ie({type:e,typeName:Fe.ZodPromise,...j(t)});class Re extends z{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Fe.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,s={addIssue:e=>{b(r,e),e.fatal?t.abort():t.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),"preprocess"===n.type){const e=n.transform(r.data,s);if(r.common.async)return Promise.resolve(e).then(async e=>{if("aborted"===t.value)return $;const n=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===n.status?$:"dirty"===n.status||"dirty"===t.value?S(n.value):n});{if("aborted"===t.value)return $;const n=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===n.status?$:"dirty"===n.status||"dirty"===t.value?S(n.value):n}}if("refinement"===n.type){const e=e=>{const t=n.refinement(e,s);if(r.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===r.common.async){const n=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===n.status?$:("dirty"===n.status&&t.dirty(),e(n.value),{status:t.value,value:n.value})}return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(r=>"aborted"===r.status?$:("dirty"===r.status&&t.dirty(),e(r.value).then(()=>({status:t.value,value:r.value}))))}if("transform"===n.type){if(!1===r.common.async){const e=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!N(e))return $;const a=n.transform(e.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(e=>N(e)?Promise.resolve(n.transform(e.value,s)).then(e=>({status:t.value,value:e})):$)}f.assertNever(n)}}Re.create=(e,t,r)=>new Re({schema:e,typeName:Fe.ZodEffects,effect:t,...j(r)}),Re.createWithPreprocess=(e,t,r)=>new Re({schema:t,effect:{type:"preprocess",transform:e},typeName:Fe.ZodEffects,...j(r)});let je=class extends z{_parse(e){return this._getType(e)===m.undefined?E(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};je.create=(e,t)=>new je({innerType:e,typeName:Fe.ZodOptional,...j(t)});let ze=class extends z{_parse(e){return this._getType(e)===m.null?E(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};ze.create=(e,t)=>new ze({innerType:e,typeName:Fe.ZodNullable,...j(t)});let Ce=class extends z{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===m.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Ce.create=(e,t)=>new Ce({innerType:e,typeName:Fe.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...j(t)});let Ae=class extends z{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return O(n)?n.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new _(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new _(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Ae.create=(e,t)=>new Ae({innerType:e,typeName:Fe.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...j(t)});class Me extends z{_parse(e){if(this._getType(e)!==m.nan){const t=this._getOrReturnCtx(e);return b(t,{code:y.invalid_type,expected:m.nan,received:t.parsedType}),$}return{status:"valid",value:e.data}}}Me.create=e=>new Me({typeName:Fe.ZodNaN,...j(e)});class Ze extends z{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class De extends z{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?$:"dirty"===e.status?(t.dirty(),S(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})();{const e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?$:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new De({in:e,out:t,typeName:Fe.ZodPipeline})}}let Le=class extends z{_parse(e){const t=this._def.innerType._parse(e),r=e=>(N(e)&&(e.value=Object.freeze(e.value)),e);return O(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}};var Fe;Le.create=(e,t)=>new Le({innerType:e,typeName:Fe.ZodReadonly,...j(t)}),function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(Fe||(Fe={})),me.create,ye.create;const qe=ve.create;function Ue(e,t,r){function n(r,n){if(r._zod||Object.defineProperty(r,"_zod",{value:{def:n,constr:i,traits:new Set},enumerable:!1}),r._zod.traits.has(e))return;r._zod.traits.add(e),t(r,n);const s=i.prototype,a=Object.keys(s);for(let e=0;e<a.length;e++){const t=a[e];t in r||(r[t]=s[t].bind(r))}}const s=r?.Parent??Object;class a extends s{}function i(e){var t;const s=r?.Parent?new a:this;n(s,e),(t=s._zod).deferred??(t.deferred=[]);for(const e of s._zod.deferred)e();return s}return Object.defineProperty(a,"name",{value:e}),Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:t=>!!(r?.Parent&&t instanceof r.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}we.create,ke.create,$e.create,Oe.create,Ie.create,je.create,ze.create;class Ve extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class He extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Je={};function Ke(e){return Je}function Be(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function Ge(e,t){return"bigint"==typeof t?t.toString():t}function Xe(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function We(e){return null==e}function Ye(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}const Qe=Symbol("evaluating");function et(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Qe)return void 0===n&&(n=Qe,n=r()),n},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function tt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function rt(...e){const t={};for(const r of e){const e=Object.getOwnPropertyDescriptors(r);Object.assign(t,e)}return Object.defineProperties({},t)}function nt(e){return JSON.stringify(e)}const st="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function at(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const it=Xe(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function ot(e){if(!1===at(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const r=t.prototype;return!1!==at(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function ct(e){return ot(e)?{...e}:Array.isArray(e)?[...e]:e}const dt=new Set(["string","number","symbol"]);function ut(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lt(e,t,r){const n=new e._zod.constr(t??e._zod.def);return t&&!r?.parent||(n._zod.parent=e),n}function pt(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const ft={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ht(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(!0!==e.issues[r]?.continue)return!0;return!1}function mt(e,t){return t.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(e),t})}function gt(e){return"string"==typeof e?e:e?.message}function yt(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const s=gt(e.inst?._zod.def?.error?.(e))??gt(t?.error?.(e))??gt(r.customError?.(e))??gt(r.localeError?.(e))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function _t(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function vt(...e){const[t,r,n]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:n}:{...t}}const wt=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Ge,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},bt=Ue("$ZodError",wt),kt=Ue("$ZodError",wt,{Parent:Error}),$t=e=>(t,r,n,s)=>{const a=n?Object.assign(n,{async:!1}):{async:!1},i=t._zod.run({value:r,issues:[]},a);if(i instanceof Promise)throw new Ve;if(i.issues.length){const t=new(s?.Err??e)(i.issues.map(e=>yt(e,a,Ke())));throw st(t,s?.callee),t}return i.value},St=$t(kt),Et=e=>async(t,r,n,s)=>{const a=n?Object.assign(n,{async:!0}):{async:!0};let i=t._zod.run({value:r,issues:[]},a);if(i instanceof Promise&&(i=await i),i.issues.length){const t=new(s?.Err??e)(i.issues.map(e=>yt(e,a,Ke())));throw st(t,s?.callee),t}return i.value},Tt=Et(kt),xt=e=>(t,r,n)=>{const s=n?{...n,async:!1}:{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new Ve;return a.issues.length?{success:!1,error:new(e??bt)(a.issues.map(e=>yt(e,s,Ke())))}:{success:!0,data:a.value}},Nt=xt(kt),Ot=e=>async(t,r,n)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},s);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>yt(e,s,Ke())))}:{success:!0,data:a.value}},Pt=Ot(kt),It=e=>(t,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return $t(e)(t,r,s)},Rt=e=>(t,r,n)=>$t(e)(t,r,n),jt=e=>async(t,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Et(e)(t,r,s)},zt=e=>async(t,r,n)=>Et(e)(t,r,n),Ct=e=>(t,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return xt(e)(t,r,s)},At=e=>(t,r,n)=>xt(e)(t,r,n),Mt=e=>async(t,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ot(e)(t,r,s)},Zt=e=>async(t,r,n)=>Ot(e)(t,r,n),Dt=/^[cC][^\s-]{8,}$/,Lt=/^[0-9a-z]+$/,Ft=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,qt=/^[0-9a-vA-V]{20}$/,Ut=/^[A-Za-z0-9]{27}$/,Vt=/^[a-zA-Z0-9_-]{21}$/,Ht=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Jt=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Kt=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Bt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Gt=/^(?:(?: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])$/,Xt=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,Wt=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,Yt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Qt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,er=/^[A-Za-z0-9_-]*$/,tr=/^\+[1-9]\d{6,14}$/,rr="(?:(?:\\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])))",nr=new RegExp(`^${rr}$`);function sr(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const ar=/^-?\d+$/,ir=/^-?\d+(?:\.\d+)?$/,or=/^(?:true|false)$/i,cr=/^null$/i,dr=/^[^A-Z]*$/,ur=/^[^a-z]*$/,lr=Ue("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),pr={number:"number",bigint:"bigint",object:"date"},fr=Ue("$ZodCheckLessThan",(e,t)=>{lr.init(e,t);const r=pr[typeof t.value];e._zod.onattach.push(e=>{const r=e._zod.bag,n=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<n&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:"object"==typeof t.value?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),hr=Ue("$ZodCheckGreaterThan",(e,t)=>{lr.init(e,t);const r=pr[typeof t.value];e._zod.onattach.push(e=>{const r=e._zod.bag,n=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>n&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:"object"==typeof t.value?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),mr=Ue("$ZodCheckMultipleOf",(e,t)=>{lr.init(e,t),e._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?r.value%t.value===BigInt(0):0===function(e,t){const r=(e.toString().split(".")[1]||"").length,n=t.toString();let s=(n.split(".")[1]||"").length;if(0===s&&/\d?e-\d?/.test(n)){const e=n.match(/\d?e-(\d?)/);e?.[1]&&(s=Number.parseInt(e[1]))}const a=r>s?r:s;return Number.parseInt(e.toFixed(a).replace(".",""))%Number.parseInt(t.toFixed(a).replace(".",""))/10**a}(r.value,t.value))||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),gr=Ue("$ZodCheckNumberFormat",(e,t)=>{lr.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[s,a]=ft[t.format];e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,n.minimum=s,n.maximum=a,r&&(n.pattern=ar)}),e._zod.check=i=>{const o=i.value;if(r){if(!Number.isInteger(o))return void i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:o,inst:e});if(!Number.isSafeInteger(o))return void(o>0?i.issues.push({input:o,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:o,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}))}o<s&&i.issues.push({origin:"number",input:o,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort}),o>a&&i.issues.push({origin:"number",input:o,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),yr=Ue("$ZodCheckMaxLength",(e,t)=>{var r;lr.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!We(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{const n=r.value;if(n.length<=t.maximum)return;const s=_t(n);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),_r=Ue("$ZodCheckMinLength",(e,t)=>{var r;lr.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!We(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const n=r.value;if(n.length>=t.minimum)return;const s=_t(n);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),vr=Ue("$ZodCheckLengthEquals",(e,t)=>{var r;lr.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!We(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=r=>{const n=r.value,s=n.length;if(s===t.length)return;const a=_t(n),i=s>t.length;r.issues.push({origin:a,...i?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),wr=Ue("$ZodCheckStringFormat",(e,t)=>{var r,n;lr.init(e,t),e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),br=Ue("$ZodCheckRegex",(e,t)=>{wr.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),kr=Ue("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=dr),wr.init(e,t)}),$r=Ue("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ur),wr.init(e,t)}),Sr=Ue("$ZodCheckIncludes",(e,t)=>{lr.init(e,t);const r=ut(t.includes),n=new RegExp("number"==typeof t.position?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),Er=Ue("$ZodCheckStartsWith",(e,t)=>{lr.init(e,t);const r=new RegExp(`^${ut(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Tr=Ue("$ZodCheckEndsWith",(e,t)=>{lr.init(e,t);const r=new RegExp(`.*${ut(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),xr=Ue("$ZodCheckOverwrite",(e,t)=>{lr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class Nr{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length)),n=t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e);for(const e of n)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const Or={major:4,minor:3,patch:6},Pr=Ue("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Or;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const t of n)for(const r of t._zod.onattach)r(e);if(0===n.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,r)=>{let n,s=ht(e);for(const a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(s)continue;const t=e.issues.length,i=a._zod.check(e);if(i instanceof Promise&&!1===r?.async)throw new Ve;if(n||i instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await i,e.issues.length!==t&&(s||(s=ht(e,t)))});else{if(e.issues.length===t)continue;s||(s=ht(e,t))}}return n?n.then(()=>e):e},r=(r,s,a)=>{if(ht(r))return r.aborted=!0,r;const i=t(s,n,a);if(i instanceof Promise){if(!1===a.async)throw new Ve;return i.then(t=>e._zod.parse(t,a))}return e._zod.parse(i,a)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if("backward"===a.direction){const t=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,s,a)):r(t,s,a)}const i=e._zod.parse(s,a);if(i instanceof Promise){if(!1===a.async)throw new Ve;return i.then(e=>t(e,n,a))}return t(i,n,a)}}et(e,"~standard",()=>({validate:t=>{try{const r=Nt(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return Pt(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Ir=Ue("$ZodString",(e,t)=>{var r;Pr.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(r=e._zod.bag,new RegExp(`^${r?`[\\s\\S]{${r?.minimum??0},${r?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Rr=Ue("$ZodStringFormat",(e,t)=>{wr.init(e,t),Ir.init(e,t)}),jr=Ue("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Jt),Rr.init(e,t)}),zr=Ue("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Kt(e))}else t.pattern??(t.pattern=Kt());Rr.init(e,t)}),Cr=Ue("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Bt),Rr.init(e,t)}),Ar=Ue("$ZodURL",(e,t)=>{Rr.init(e,t),e._zod.check=r=>{try{const n=r.value.trim(),s=new URL(n);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(s.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),void(t.normalize?r.value=s.href:r.value=n)}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Mr=Ue("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Rr.init(e,t)}),Zr=Ue("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Vt),Rr.init(e,t)}),Dr=Ue("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Dt),Rr.init(e,t)}),Lr=Ue("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Lt),Rr.init(e,t)}),Fr=Ue("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ft),Rr.init(e,t)}),qr=Ue("$ZodXID",(e,t)=>{t.pattern??(t.pattern=qt),Rr.init(e,t)}),Ur=Ue("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ut),Rr.init(e,t)}),Vr=Ue("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=sr({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${rr}T(?:${n})$`)}(t)),Rr.init(e,t)}),Hr=Ue("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=nr),Rr.init(e,t)}),Jr=Ue("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${sr(t)}$`)),Rr.init(e,t)}),Kr=Ue("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ht),Rr.init(e,t)}),Br=Ue("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Gt),Rr.init(e,t),e._zod.bag.format="ipv4"}),Gr=Ue("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Xt),Rr.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Xr=Ue("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Wt),Rr.init(e,t)}),Wr=Ue("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Yt),Rr.init(e,t),e._zod.check=r=>{const n=r.value.split("/");try{if(2!==n.length)throw new Error;const[e,t]=n;if(!t)throw new Error;const r=Number(t);if(`${r}`!==t)throw new Error;if(r<0||r>128)throw new Error;new URL(`http://[${e}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Yr(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const Qr=Ue("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Qt),Rr.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{Yr(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),en=Ue("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=er),Rr.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{(function(e){if(!er.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return Yr(t.padEnd(4*Math.ceil(t.length/4),"="))})(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),tn=Ue("$ZodE164",(e,t)=>{t.pattern??(t.pattern=tr),Rr.init(e,t)}),rn=Ue("$ZodJWT",(e,t)=>{Rr.init(e,t),e._zod.check=r=>{(function(e,t=null){try{const r=e.split(".");if(3!==r.length)return!1;const[n]=r;if(!n)return!1;const s=JSON.parse(atob(n));return!("typ"in s&&"JWT"!==s?.typ||!s.alg||t&&(!("alg"in s)||s.alg!==t))}catch{return!1}})(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),nn=Ue("$ZodNumber",(e,t)=>{Pr.init(e,t),e._zod.pattern=e._zod.bag.pattern??ir,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(e){}const s=r.value;if("number"==typeof s&&!Number.isNaN(s)&&Number.isFinite(s))return r;const a="number"==typeof s?Number.isNaN(s)?"NaN":Number.isFinite(s)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:s,inst:e,...a?{received:a}:{}}),r}}),sn=Ue("$ZodNumberFormat",(e,t)=>{gr.init(e,t),nn.init(e,t)}),an=Ue("$ZodBoolean",(e,t)=>{Pr.init(e,t),e._zod.pattern=or,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(e){}const s=r.value;return"boolean"==typeof s||r.issues.push({expected:"boolean",code:"invalid_type",input:s,inst:e}),r}}),on=Ue("$ZodNull",(e,t)=>{Pr.init(e,t),e._zod.pattern=cr,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{const n=t.value;return null===n||t.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),t}}),cn=Ue("$ZodUnknown",(e,t)=>{Pr.init(e,t),e._zod.parse=e=>e}),dn=Ue("$ZodNever",(e,t)=>{Pr.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function un(e,t,r){e.issues.length&&t.issues.push(...mt(r,e.issues)),t.value[r]=e.value}const ln=Ue("$ZodArray",(e,t)=>{Pr.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=Array(s.length);const a=[];for(let e=0;e<s.length;e++){const i=s[e],o=t.element._zod.run({value:i,issues:[]},n);o instanceof Promise?a.push(o.then(t=>un(t,r,e))):un(o,r,e)}return a.length?Promise.all(a).then(()=>r):r}});function pn(e,t,r,n,s){if(e.issues.length){if(s&&!(r in n))return;t.issues.push(...mt(r,e.issues))}void 0===e.value?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function fn(e){const t=Object.keys(e.shape);for(const r of t)if(!e.shape?.[r]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const r=(n=e.shape,Object.keys(n).filter(e=>"optional"===n[e]._zod.optin&&"optional"===n[e]._zod.optout));var n;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function hn(e,t,r,n,s,a){const i=[],o=s.keySet,c=s.catchall._zod,d=c.def.type,u="optional"===c.optout;for(const s in t){if(o.has(s))continue;if("never"===d){i.push(s);continue}const a=c.run({value:t[s],issues:[]},n);a instanceof Promise?e.push(a.then(e=>pn(e,r,s,t,u))):pn(a,r,s,t,u)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:t,inst:a}),e.length?Promise.all(e).then(()=>r):r}const mn=Ue("$ZodObject",(e,t)=>{Pr.init(e,t);const r=Object.getOwnPropertyDescriptor(t,"shape");if(!r?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const r={...e};return Object.defineProperty(t,"shape",{value:r}),r}})}const n=Xe(()=>fn(t));et(e._zod,"propValues",()=>{const e=t.shape,r={};for(const t in e){const n=e[t]._zod;if(n.values){r[t]??(r[t]=new Set);for(const e of n.values)r[t].add(e)}}return r});const s=at,a=t.catchall;let i;e._zod.parse=(t,r)=>{i??(i=n.value);const o=t.value;if(!s(o))return t.issues.push({expected:"object",code:"invalid_type",input:o,inst:e}),t;t.value={};const c=[],d=i.shape;for(const e of i.keys){const n=d[e],s="optional"===n._zod.optout,a=n._zod.run({value:o[e],issues:[]},r);a instanceof Promise?c.push(a.then(r=>pn(r,t,e,o,s))):pn(a,t,e,o,s)}return a?hn(c,o,t,r,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),gn=Ue("$ZodObjectJIT",(e,t)=>{mn.init(e,t);const r=e._zod.parse,n=Xe(()=>fn(t));let s;const a=at,i=!Je.jitless,o=i&&it.value,c=t.catchall;let d;e._zod.parse=(u,l)=>{d??(d=n.value);const p=u.value;return a(p)?i&&o&&!1===l?.async&&!0!==l.jitless?(s||(s=(e=>{const t=new Nr(["shape","payload","ctx"]),r=n.value,s=e=>{const t=nt(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const a=Object.create(null);let i=0;for(const e of r.keys)a[e]="key_"+i++;t.write("const newResult = {};");for(const n of r.keys){const r=a[n],i=nt(n),o=e[n],c="optional"===o?._zod?.optout;t.write(`const ${r} = ${s(n)};`),c?t.write(`\n if (${r}.issues.length) {\n if (${i} in input) {\n payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${i}, ...iss.path] : [${i}]\n })));\n }\n }\n \n if (${r}.value === undefined) {\n if (${i} in input) {\n newResult[${i}] = undefined;\n }\n } else {\n newResult[${i}] = ${r}.value;\n }\n \n `):t.write(`\n if (${r}.issues.length) {\n payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${i}, ...iss.path] : [${i}]\n })));\n }\n \n if (${r}.value === undefined) {\n if (${i} in input) {\n newResult[${i}] = undefined;\n }\n } else {\n newResult[${i}] = ${r}.value;\n }\n \n `)}t.write("payload.value = newResult;"),t.write("return payload;");const o=t.compile();return(t,r)=>o(e,t,r)})(t.shape)),u=s(u,l),c?hn([],p,u,l,d,e):u):r(u,l):(u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u)}});function yn(e,t,r,n){for(const r of e)if(0===r.issues.length)return t.value=r.value,t;const s=e.filter(e=>!ht(e));return 1===s.length?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(e=>e.issues.map(e=>yt(e,n,Ke())))}),t)}const _n=Ue("$ZodUnion",(e,t)=>{Pr.init(e,t),et(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),et(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),et(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),et(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>Ye(e.source)).join("|")})$`)}});const r=1===t.options.length,n=t.options[0]._zod.run;e._zod.parse=(s,a)=>{if(r)return n(s,a);let i=!1;const o=[];for(const e of t.options){const t=e._zod.run({value:s.value,issues:[]},a);if(t instanceof Promise)o.push(t),i=!0;else{if(0===t.issues.length)return t;o.push(t)}}return i?Promise.all(o).then(t=>yn(t,s,e,a)):yn(o,s,e,a)}}),vn=Ue("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,_n.init(e,t);const r=e._zod.parse;et(e._zod,"propValues",()=>{const e={};for(const r of t.options){const n=r._zod.propValues;if(!n||0===Object.keys(n).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(const[t,r]of Object.entries(n)){e[t]||(e[t]=new Set);for(const n of r)e[t].add(n)}}return e});const n=Xe(()=>{const e=t.options,r=new Map;for(const n of e){const e=n._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const t of e){if(r.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);r.set(t,n)}}return r});e._zod.parse=(s,a)=>{const i=s.value;if(!at(i))return s.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),s;const o=n.value.get(i?.[t.discriminator]);return o?o._zod.run(s,a):t.unionFallback?r(s,a):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:i,path:[t.discriminator],inst:e}),s)}}),wn=Ue("$ZodIntersection",(e,t)=>{Pr.init(e,t),e._zod.parse=(e,r)=>{const n=e.value,s=t.left._zod.run({value:n,issues:[]},r),a=t.right._zod.run({value:n,issues:[]},r);return s instanceof Promise||a instanceof Promise?Promise.all([s,a]).then(([t,r])=>kn(e,t,r)):kn(e,s,a)}});function bn(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(ot(e)&&ot(t)){const r=Object.keys(t),n=Object.keys(e).filter(e=>-1!==r.indexOf(e)),s={...e,...t};for(const r of n){const n=bn(e[r],t[r]);if(!n.valid)return{valid:!1,mergeErrorPath:[r,...n.mergeErrorPath]};s[r]=n.data}return{valid:!0,data:s}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n<e.length;n++){const s=bn(e[n],t[n]);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};r.push(s.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function kn(e,t,r){const n=new Map;let s;for(const r of t.issues)if("unrecognized_keys"===r.code){s??(s=r);for(const e of r.keys)n.has(e)||n.set(e,{}),n.get(e).l=!0}else e.issues.push(r);for(const t of r.issues)if("unrecognized_keys"===t.code)for(const e of t.keys)n.has(e)||n.set(e,{}),n.get(e).r=!0;else e.issues.push(t);const a=[...n].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&s&&e.issues.push({...s,keys:a}),ht(e))return e;const i=bn(t.value,r.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return e.value=i.data,e}const $n=Ue("$ZodRecord",(e,t)=>{Pr.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!ot(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),r;const a=[],i=t.keyType._zod.values;if(i){r.value={};const o=new Set;for(const e of i)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){o.add("number"==typeof e?e.toString():e);const i=t.valueType._zod.run({value:s[e],issues:[]},n);i instanceof Promise?a.push(i.then(t=>{t.issues.length&&r.issues.push(...mt(e,t.issues)),r.value[e]=t.value})):(i.issues.length&&r.issues.push(...mt(e,i.issues)),r.value[e]=i.value)}let c;for(const e in s)o.has(e)||(c=c??[],c.push(e));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c})}else{r.value={};for(const i of Reflect.ownKeys(s)){if("__proto__"===i)continue;let o=t.keyType._zod.run({value:i,issues:[]},n);if(o instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof i&&ir.test(i)&&o.issues.length){const e=t.keyType._zod.run({value:Number(i),issues:[]},n);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(o=e)}if(o.issues.length){"loose"===t.mode?r.value[i]=s[i]:r.issues.push({code:"invalid_key",origin:"record",issues:o.issues.map(e=>yt(e,n,Ke())),input:i,path:[i],inst:e});continue}const c=t.valueType._zod.run({value:s[i],issues:[]},n);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&r.issues.push(...mt(i,e.issues)),r.value[o.value]=e.value})):(c.issues.length&&r.issues.push(...mt(i,c.issues)),r.value[o.value]=c.value)}}return a.length?Promise.all(a).then(()=>r):r}}),Sn=Ue("$ZodEnum",(e,t)=>{Pr.init(e,t);const r=Be(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(e=>dt.has(typeof e)).map(e=>"string"==typeof e?ut(e):e.toString()).join("|")})$`),e._zod.parse=(t,s)=>{const a=t.value;return n.has(a)||t.issues.push({code:"invalid_value",values:r,input:a,inst:e}),t}}),En=Ue("$ZodLiteral",(e,t)=>{if(Pr.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?ut(e):e?ut(e.toString()):String(e)).join("|")})$`),e._zod.parse=(n,s)=>{const a=n.value;return r.has(a)||n.issues.push({code:"invalid_value",values:t.values,input:a,inst:e}),n}}),Tn=Ue("$ZodTransform",(e,t)=>{Pr.init(e,t),e._zod.parse=(r,n)=>{if("backward"===n.direction)throw new He(e.constructor.name);const s=t.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(e=>(r.value=e,r));if(s instanceof Promise)throw new Ve;return r.value=s,r}});function xn(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const Nn=Ue("$ZodOptional",(e,t)=>{Pr.init(e,t),e._zod.optin="optional",e._zod.optout="optional",et(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),et(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Ye(e.source)})?$`):void 0}),e._zod.parse=(e,r)=>{if("optional"===t.innerType._zod.optin){const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(t=>xn(t,e.value)):xn(n,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,r)}}),On=Ue("$ZodExactOptional",(e,t)=>{Nn.init(e,t),et(e._zod,"values",()=>t.innerType._zod.values),et(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),Pn=Ue("$ZodNullable",(e,t)=>{Pr.init(e,t),et(e._zod,"optin",()=>t.innerType._zod.optin),et(e._zod,"optout",()=>t.innerType._zod.optout),et(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${Ye(e.source)}|null)$`):void 0}),et(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,r)=>null===e.value?e:t.innerType._zod.run(e,r)}),In=Ue("$ZodDefault",(e,t)=>{Pr.init(e,t),e._zod.optin="optional",et(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);if(void 0===e.value)return e.value=t.defaultValue,e;const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(e=>Rn(e,t)):Rn(n,t)}});function Rn(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const jn=Ue("$ZodPrefault",(e,t)=>{Pr.init(e,t),e._zod.optin="optional",et(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>("backward"===r.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),zn=Ue("$ZodNonOptional",(e,t)=>{Pr.init(e,t),et(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(r,n)=>{const s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(t=>Cn(t,e)):Cn(s,e)}});function Cn(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const An=Ue("$ZodCatch",(e,t)=>{Pr.init(e,t),et(e._zod,"optin",()=>t.innerType._zod.optin),et(e._zod,"optout",()=>t.innerType._zod.optout),et(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(n=>(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>yt(e,r,Ke()))},input:e.value}),e.issues=[]),e)):(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>yt(e,r,Ke()))},input:e.value}),e.issues=[]),e)}}),Mn=Ue("$ZodPipe",(e,t)=>{Pr.init(e,t),et(e._zod,"values",()=>t.in._zod.values),et(e._zod,"optin",()=>t.in._zod.optin),et(e._zod,"optout",()=>t.out._zod.optout),et(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,r)=>{if("backward"===r.direction){const n=t.out._zod.run(e,r);return n instanceof Promise?n.then(e=>Zn(e,t.in,r)):Zn(n,t.in,r)}const n=t.in._zod.run(e,r);return n instanceof Promise?n.then(e=>Zn(e,t.out,r)):Zn(n,t.out,r)}});function Zn(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const Dn=Ue("$ZodReadonly",(e,t)=>{Pr.init(e,t),et(e._zod,"propValues",()=>t.innerType._zod.propValues),et(e._zod,"values",()=>t.innerType._zod.values),et(e._zod,"optin",()=>t.innerType?._zod?.optin),et(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(Ln):Ln(n)}});function Ln(e){return e.value=Object.freeze(e.value),e}const Fn=Ue("$ZodCustom",(e,t)=>{lr.init(e,t),Pr.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=r=>{const n=r.value,s=t.fn(n);if(s instanceof Promise)return s.then(t=>qn(t,r,n,e));qn(s,r,n,e)}});function qn(e,t,r,n){if(!e){const e={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(e.params=n._zod.def.params),t.issues.push(vt(e))}}var Un;(Un=globalThis).__zod_globalRegistry??(Un.__zod_globalRegistry=new class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const r=t[0];return this._map.set(e,r),r&&"object"==typeof r&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};delete r.id;const n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}});const Vn=globalThis.__zod_globalRegistry;function Hn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...pt(t)})}function Jn(e,t){return new fr({check:"less_than",...pt(t),value:e,inclusive:!1})}function Kn(e,t){return new fr({check:"less_than",...pt(t),value:e,inclusive:!0})}function Bn(e,t){return new hr({check:"greater_than",...pt(t),value:e,inclusive:!1})}function Gn(e,t){return new hr({check:"greater_than",...pt(t),value:e,inclusive:!0})}function Xn(e,t){return new mr({check:"multiple_of",...pt(t),value:e})}function Wn(e,t){return new yr({check:"max_length",...pt(t),maximum:e})}function Yn(e,t){return new _r({check:"min_length",...pt(t),minimum:e})}function Qn(e,t){return new vr({check:"length_equals",...pt(t),length:e})}function es(e){return new xr({check:"overwrite",tx:e})}function ts(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Vn,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function rs(e,t,r={path:[],schemaPath:[]}){var n;const s=e._zod.def,a=t.seen.get(e);if(a)return a.count++,r.schemaPath.includes(e)&&(a.cycle=r.path),a.schema;const i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i);const o=e._zod.toJSONSchema?.();if(o)i.schema=o;else{const n={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,n);else{const r=i.schema,a=t.processors[s.type];if(!a)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);a(e,t,r,n)}const a=e._zod.parent;a&&(i.ref||(i.ref=a),rs(a,t,n),t.seen.get(a).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(i.schema,c),"input"===t.io&&as(e)&&(delete i.schema.examples,delete i.schema.default),"input"===t.io&&i.schema._prefault&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function ns(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=new Map;for(const t of e.seen.entries()){const r=e.metadataRegistry.get(t[0])?.id;if(r){const e=n.get(r);if(e&&e!==t[0])throw new Error(`Duplicate schema id "${r}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(r,t[0])}}const s=t=>{if(t[1].schema.$ref)return;const n=t[1],{ref:s,defId:a}=(t=>{const n="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){const r=e.external.registry.get(t[0])?.id,s=e.external.uri??(e=>e);if(r)return{ref:s(r)};const a=t[1].defId??t[1].schema.id??"schema"+e.counter++;return t[1].defId=a,{defId:a,ref:`${s("__shared")}#/${n}/${a}`}}if(t[1]===r)return{ref:"#"};const s=`#/${n}/`,a=t[1].schema.id??"__schema"+e.counter++;return{defId:a,ref:s+a}})(t);n.def={...n.schema},a&&(n.defId=a);const i=n.schema;for(const e in i)delete i[e];i.$ref=s};if("throw"===e.cycles)for(const t of e.seen.entries()){const e=t[1];if(e.cycle)throw new Error(`Cycle detected: #/${e.cycle?.join("/")}/<root>\n\nSet the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const r of e.seen.entries()){const n=r[1];if(t===r[0]){s(r);continue}if(e.external){const n=e.external.registry.get(r[0])?.id;if(t!==r[0]&&n){s(r);continue}}const a=e.metadataRegistry.get(r[0])?.id;(a||n.cycle||n.count>1&&"ref"===e.reused)&&s(r)}}function ss(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const n=t=>{const r=e.seen.get(t);if(null===r.ref)return;const s=r.def??r.schema,a={...s},i=r.ref;if(r.ref=null,i){n(i);const r=e.seen.get(i),o=r.schema;if(!o.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(s,o):(s.allOf=s.allOf??[],s.allOf.push(o)),Object.assign(s,a),t._zod.parent===i)for(const e in s)"$ref"!==e&&"allOf"!==e&&(e in a||delete s[e]);if(o.$ref&&r.def)for(const e in s)"$ref"!==e&&"allOf"!==e&&e in r.def&&JSON.stringify(s[e])===JSON.stringify(r.def[e])&&delete s[e]}const o=t._zod.parent;if(o&&o!==i){n(o);const t=e.seen.get(o);if(t?.schema.$ref&&(s.$ref=t.schema.$ref,t.def))for(const e in s)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(s[e])===JSON.stringify(t.def[e])&&delete s[e]}e.override({zodSchema:t,jsonSchema:s,path:r.path??[]})};for(const t of[...e.seen.entries()].reverse())n(t[0]);const s={};if("draft-2020-12"===e.target?s.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?s.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?s.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const r=e.external.registry.get(t)?.id;if(!r)throw new Error("Schema is missing an `id` property");s.$id=e.external.uri(r)}Object.assign(s,r.def??r.schema);const a=e.external?.defs??{};for(const t of e.seen.entries()){const e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&("draft-2020-12"===e.target?s.$defs=a:s.definitions=a);try{const r=JSON.parse(JSON.stringify(s));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:is(t,"input",e.processors),output:is(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch(e){throw new Error("Error converting schema to JSON.")}}function as(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const n=e._zod.def;if("transform"===n.type)return!0;if("array"===n.type)return as(n.element,r);if("set"===n.type)return as(n.valueType,r);if("lazy"===n.type)return as(n.getter(),r);if("promise"===n.type||"optional"===n.type||"nonoptional"===n.type||"nullable"===n.type||"readonly"===n.type||"default"===n.type||"prefault"===n.type)return as(n.innerType,r);if("intersection"===n.type)return as(n.left,r)||as(n.right,r);if("record"===n.type||"map"===n.type)return as(n.keyType,r)||as(n.valueType,r);if("pipe"===n.type)return as(n.in,r)||as(n.out,r);if("object"===n.type){for(const e in n.shape)if(as(n.shape[e],r))return!0;return!1}if("union"===n.type){for(const e of n.options)if(as(e,r))return!0;return!1}if("tuple"===n.type){for(const e of n.items)if(as(e,r))return!0;return!(!n.rest||!as(n.rest,r))}return!1}const is=(e,t,r={})=>n=>{const{libraryOptions:s,target:a}=n??{},i=ts({...s??{},target:a,io:t,processors:r});return rs(e,i),ns(i,e),ss(i,e)},os={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},cs=(e,t,r,n)=>{const s=r;s.type="string";const{minimum:a,maximum:i,format:o,patterns:c,contentEncoding:d}=e._zod.bag;if("number"==typeof a&&(s.minLength=a),"number"==typeof i&&(s.maxLength=i),o&&(s.format=os[o]??o,""===s.format&&delete s.format,"time"===o&&delete s.format),d&&(s.contentEncoding=d),c&&c.size>0){const e=[...c];1===e.length?s.pattern=e[0].source:e.length>1&&(s.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}},ds=(e,t,r,n)=>{const s=r,{minimum:a,maximum:i,format:o,multipleOf:c,exclusiveMaximum:d,exclusiveMinimum:u}=e._zod.bag;"string"==typeof o&&o.includes("int")?s.type="integer":s.type="number","number"==typeof u&&("draft-04"===t.target||"openapi-3.0"===t.target?(s.minimum=u,s.exclusiveMinimum=!0):s.exclusiveMinimum=u),"number"==typeof a&&(s.minimum=a,"number"==typeof u&&"draft-04"!==t.target&&(u>=a?delete s.minimum:delete s.exclusiveMinimum)),"number"==typeof d&&("draft-04"===t.target||"openapi-3.0"===t.target?(s.maximum=d,s.exclusiveMaximum=!0):s.exclusiveMaximum=d),"number"==typeof i&&(s.maximum=i,"number"==typeof d&&"draft-04"!==t.target&&(d<=i?delete s.maximum:delete s.exclusiveMaximum)),"number"==typeof c&&(s.multipleOf=c)},us=(e,t,r,n)=>{r.type="boolean"},ls=(e,t,r,n)=>{"openapi-3.0"===t.target?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},ps=(e,t,r,n)=>{r.not={}},fs=(e,t,r,n)=>{const s=Be(e._zod.def.entries);s.every(e=>"number"==typeof e)&&(r.type="number"),s.every(e=>"string"==typeof e)&&(r.type="string"),r.enum=s},hs=(e,t,r,n)=>{const s=e._zod.def,a=[];for(const e of s.values)if(void 0===e){if("throw"===t.unrepresentable)throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if("bigint"==typeof e){if("throw"===t.unrepresentable)throw new Error("BigInt literals cannot be represented in JSON Schema");a.push(Number(e))}else a.push(e);if(0===a.length);else if(1===a.length){const e=a[0];r.type=null===e?"null":typeof e,"draft-04"===t.target||"openapi-3.0"===t.target?r.enum=[e]:r.const=e}else a.every(e=>"number"==typeof e)&&(r.type="number"),a.every(e=>"string"==typeof e)&&(r.type="string"),a.every(e=>"boolean"==typeof e)&&(r.type="boolean"),a.every(e=>null===e)&&(r.type="null"),r.enum=a},ms=(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")},gs=(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")},ys=(e,t,r,n)=>{const s=r,a=e._zod.def,{minimum:i,maximum:o}=e._zod.bag;"number"==typeof i&&(s.minItems=i),"number"==typeof o&&(s.maxItems=o),s.type="array",s.items=rs(a.element,t,{...n,path:[...n.path,"items"]})},_s=(e,t,r,n)=>{const s=r,a=e._zod.def;s.type="object",s.properties={};const i=a.shape;for(const e in i)s.properties[e]=rs(i[e],t,{...n,path:[...n.path,"properties",e]});const o=new Set(Object.keys(i)),c=new Set([...o].filter(e=>{const r=a.shape[e]._zod;return"input"===t.io?void 0===r.optin:void 0===r.optout}));c.size>0&&(s.required=Array.from(c)),"never"===a.catchall?._zod.def.type?s.additionalProperties=!1:a.catchall?a.catchall&&(s.additionalProperties=rs(a.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):"output"===t.io&&(s.additionalProperties=!1)},vs=(e,t,r,n)=>{const s=e._zod.def,a=!1===s.inclusive,i=s.options.map((e,r)=>rs(e,t,{...n,path:[...n.path,a?"oneOf":"anyOf",r]}));a?r.oneOf=i:r.anyOf=i},ws=(e,t,r,n)=>{const s=e._zod.def,a=rs(s.left,t,{...n,path:[...n.path,"allOf",0]}),i=rs(s.right,t,{...n,path:[...n.path,"allOf",1]}),o=e=>"allOf"in e&&1===Object.keys(e).length,c=[...o(a)?a.allOf:[a],...o(i)?i.allOf:[i]];r.allOf=c},bs=(e,t,r,n)=>{const s=r,a=e._zod.def;s.type="object";const i=a.keyType,o=i._zod.bag,c=o?.patterns;if("loose"===a.mode&&c&&c.size>0){const e=rs(a.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});s.patternProperties={};for(const t of c)s.patternProperties[t.source]=e}else"draft-07"!==t.target&&"draft-2020-12"!==t.target||(s.propertyNames=rs(a.keyType,t,{...n,path:[...n.path,"propertyNames"]})),s.additionalProperties=rs(a.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const d=i._zod.values;if(d){const e=[...d].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(s.required=e)}},ks=(e,t,r,n)=>{const s=e._zod.def,a=rs(s.innerType,t,n),i=t.seen.get(e);"openapi-3.0"===t.target?(i.ref=s.innerType,r.nullable=!0):r.anyOf=[a,{type:"null"}]},$s=(e,t,r,n)=>{const s=e._zod.def;rs(s.innerType,t,n),t.seen.get(e).ref=s.innerType},Ss=(e,t,r,n)=>{const s=e._zod.def;rs(s.innerType,t,n),t.seen.get(e).ref=s.innerType,r.default=JSON.parse(JSON.stringify(s.defaultValue))},Es=(e,t,r,n)=>{const s=e._zod.def;rs(s.innerType,t,n),t.seen.get(e).ref=s.innerType,"input"===t.io&&(r._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},Ts=(e,t,r,n)=>{const s=e._zod.def;let a;rs(s.innerType,t,n),t.seen.get(e).ref=s.innerType;try{a=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},xs=(e,t,r,n)=>{const s=e._zod.def,a="input"===t.io?"transform"===s.in._zod.def.type?s.out:s.in:s.out;rs(a,t,n),t.seen.get(e).ref=a},Ns=(e,t,r,n)=>{const s=e._zod.def;rs(s.innerType,t,n),t.seen.get(e).ref=s.innerType,r.readOnly=!0},Os=(e,t,r,n)=>{const s=e._zod.def;rs(s.innerType,t,n),t.seen.get(e).ref=s.innerType},Ps={string:cs,number:ds,boolean:us,bigint:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("BigInt cannot be represented in JSON Schema")},symbol:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Symbols cannot be represented in JSON Schema")},null:ls,undefined:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Undefined cannot be represented in JSON Schema")},void:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Void cannot be represented in JSON Schema")},never:ps,any:(e,t,r,n)=>{},unknown:(e,t,r,n)=>{},date:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Date cannot be represented in JSON Schema")},enum:fs,literal:hs,nan:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("NaN cannot be represented in JSON Schema")},template_literal:(e,t,r,n)=>{const s=r,a=e._zod.pattern;if(!a)throw new Error("Pattern not found in template literal");s.type="string",s.pattern=a.source},file:(e,t,r,n)=>{const s=r,a={type:"string",format:"binary",contentEncoding:"binary"},{minimum:i,maximum:o,mime:c}=e._zod.bag;void 0!==i&&(a.minLength=i),void 0!==o&&(a.maxLength=o),c?1===c.length?(a.contentMediaType=c[0],Object.assign(s,a)):(Object.assign(s,a),s.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(s,a)},success:(e,t,r,n)=>{r.type="boolean"},custom:ms,function:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Function types cannot be represented in JSON Schema")},transform:gs,map:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Map cannot be represented in JSON Schema")},set:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Set cannot be represented in JSON Schema")},array:ys,object:_s,union:vs,intersection:ws,tuple:(e,t,r,n)=>{const s=r,a=e._zod.def;s.type="array";const i="draft-2020-12"===t.target?"prefixItems":"items",o="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",c=a.items.map((e,r)=>rs(e,t,{...n,path:[...n.path,i,r]})),d=a.rest?rs(a.rest,t,{...n,path:[...n.path,o,..."openapi-3.0"===t.target?[a.items.length]:[]]}):null;"draft-2020-12"===t.target?(s.prefixItems=c,d&&(s.items=d)):"openapi-3.0"===t.target?(s.items={anyOf:c},d&&s.items.anyOf.push(d),s.minItems=c.length,d||(s.maxItems=c.length)):(s.items=c,d&&(s.additionalItems=d));const{minimum:u,maximum:l}=e._zod.bag;"number"==typeof u&&(s.minItems=u),"number"==typeof l&&(s.maxItems=l)},record:bs,nullable:ks,nonoptional:$s,default:Ss,prefault:Es,catch:Ts,pipe:xs,readonly:Ns,promise:(e,t,r,n)=>{const s=e._zod.def;rs(s.innerType,t,n),t.seen.get(e).ref=s.innerType},optional:Os,lazy:(e,t,r,n)=>{const s=e._zod.innerType;rs(s,t,n),t.seen.get(e).ref=s}},Is=Ue("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");Pr.init(e,t),e.def=t,e.type=t.type,e.parse=(t,r)=>St(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>Nt(e,t,r),e.parseAsync=async(t,r)=>Tt(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>Pt(e,t,r),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]},{parent:!0}),e.with=e.check,e.clone=(t,r)=>lt(e,t,r),e.brand=()=>e,e.register=(t,r)=>(t.add(e,r),e),e.apply=t=>t(e)}),Rs=Ue("ZodMiniObject",(e,t)=>{mn.init(e,t),Is.init(e,t),et(e,"shape",()=>t.shape)});function js(e,t){const r={type:"object",shape:e??{},...pt(t)};return new Rs(r)}function zs(e){return!!e._zod}function Cs(e){const t=Object.values(e);if(0===t.length)return js({});const r=t.every(zs),n=t.every(e=>!zs(e));if(r)return js(e);if(n)return qe(e);throw new Error("Mixed Zod versions detected in object shape.")}function As(e,t){return zs(e)?Nt(e,t):e.safeParse(t)}async function Ms(e,t){if(zs(e))return await Pt(e,t);const r=e;return await r.safeParseAsync(t)}function Zs(e){if(!e)return;let t;if(zs(e)){const r=e;t=r._zod?.def?.shape}else t=e.shape;if(t){if("function"==typeof t)try{return t()}catch{return}return t}}function Ds(e){if(e){if("object"==typeof e){const t=e;if(!e._def&&!t._zod){const t=Object.values(e);if(t.length>0&&t.every(e=>"object"==typeof e&&null!==e&&(void 0!==e._def||void 0!==e._zod||"function"==typeof e.parse)))return Cs(e)}}if(zs(e)){const t=e,r=t._zod?.def;if(r&&("object"===r.type||void 0!==r.shape))return e}else if(void 0!==e.shape)return e}}function Ls(e){if(e&&"object"==typeof e){if("message"in e&&"string"==typeof e.message)return e.message;if("issues"in e&&Array.isArray(e.issues)&&e.issues.length>0){const t=e.issues[0];if(t&&"object"==typeof t&&"message"in t)return String(t.message)}try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function Fs(e){if(zs(e)){const t=e,r=t._zod?.def;if(r){if(void 0!==r.value)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}}const t=e._def;if(t){if(void 0!==t.value)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}const r=e.value;if(void 0!==r)return r}const qs=Ue("ZodISODateTime",(e,t)=>{Vr.init(e,t),ua.init(e,t)});function Us(e){return function(e,t){return new qs({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...pt(t)})}(0,e)}const Vs=Ue("ZodISODate",(e,t)=>{Hr.init(e,t),ua.init(e,t)});const Hs=Ue("ZodISOTime",(e,t)=>{Jr.init(e,t),ua.init(e,t)});const Js=Ue("ZodISODuration",(e,t)=>{Kr.init(e,t),ua.init(e,t)});const Ks=Ue("ZodError",(e,t)=>{bt.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const r={_errors:[]},n=e=>{for(const s of e.issues)if("invalid_union"===s.code&&s.errors.length)s.errors.map(e=>n({issues:e}));else if("invalid_key"===s.code)n({issues:s.issues});else if("invalid_element"===s.code)n({issues:s.issues});else if(0===s.path.length)r._errors.push(t(s));else{let e=r,n=0;for(;n<s.path.length;){const r=s.path[n];n===s.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(s))):e[r]=e[r]||{_errors:[]},e=e[r],n++}}};return n(e),r}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const r={},n=[];for(const s of e.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(t(s))):n.push(t(s));return{formErrors:n,fieldErrors:r}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,Ge,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Ge,2)}},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),Bs=$t(Ks),Gs=Et(Ks),Xs=xt(Ks),Ws=Ot(Ks),Ys=It(Ks),Qs=Rt(Ks),ea=jt(Ks),ta=zt(Ks),ra=Ct(Ks),na=At(Ks),sa=Mt(Ks),aa=Zt(Ks),ia=Ue("ZodType",(e,t)=>(Pr.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:is(e,"input"),output:is(e,"output")}}),e.toJSONSchema=((e,t={})=>r=>{const n=ts({...r,processors:t});return rs(e,n),ns(n,e),ss(n,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(rt(t,{checks:[...t.checks??[],...r.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,r)=>lt(e,t,r),e.brand=()=>e,e.register=(t,r)=>(t.add(e,r),e),e.parse=(t,r)=>Bs(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>Xs(e,t,r),e.parseAsync=async(t,r)=>Gs(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>Ws(e,t,r),e.spa=e.safeParseAsync,e.encode=(t,r)=>Ys(e,t,r),e.decode=(t,r)=>Qs(e,t,r),e.encodeAsync=async(t,r)=>ea(e,t,r),e.decodeAsync=async(t,r)=>ta(e,t,r),e.safeEncode=(t,r)=>ra(e,t,r),e.safeDecode=(t,r)=>na(e,t,r),e.safeEncodeAsync=async(t,r)=>sa(e,t,r),e.safeDecodeAsync=async(t,r)=>aa(e,t,r),e.refine=(t,r)=>e.check(function(e,t={}){return function(e,t,r){return new _i({type:"custom",check:"custom",fn:t,...pt(r)})}(0,e,t)}(t,r)),e.superRefine=t=>e.check(function(e){const t=function(e){const t=new lr({check:"custom",...pt(void 0)});return t._zod.check=e,t}(r=>(r.addIssue=e=>{if("string"==typeof e)r.issues.push(vt(e,r.value,t._zod.def));else{const n=e;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=r.value),n.inst??(n.inst=t),n.continue??(n.continue=!t._zod.def.abort),r.issues.push(vt(n))}},e(r.value,r)));return t}(t)),e.overwrite=t=>e.check(es(t)),e.optional=()=>oi(e),e.exactOptional=()=>new ci({type:"optional",innerType:e}),e.nullable=()=>ui(e),e.nullish=()=>oi(ui(e)),e.nonoptional=t=>function(e,t){return new fi({type:"nonoptional",innerType:e,...pt(t)})}(e,t),e.array=()=>qa(e),e.or=t=>Ka([e,t]),e.and=t=>Wa(e,t),e.transform=t=>gi(e,ai(t)),e.default=t=>{return r=t,new li({type:"default",innerType:e,get defaultValue(){return"function"==typeof r?r():ct(r)}});var r},e.prefault=t=>{return r=t,new pi({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof r?r():ct(r)}});var r},e.catch=t=>{return new hi({type:"catch",innerType:e,catchValue:"function"==typeof(r=t)?r:()=>r});var r},e.pipe=t=>gi(e,t),e.readonly=()=>new yi({type:"readonly",innerType:e}),e.describe=t=>{const r=e.clone();return Vn.add(r,{description:t}),r},Object.defineProperty(e,"description",{get:()=>Vn.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return Vn.get(e);const r=e.clone();return Vn.add(r,t[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),oa=Ue("_ZodString",(e,t)=>{Ir.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>cs(e,t,r);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new br({check:"string_format",format:"regex",...pt(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new Sr({check:"string_format",format:"includes",...pt(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new Er({check:"string_format",format:"starts_with",...pt(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Tr({check:"string_format",format:"ends_with",...pt(t),suffix:e})}(...t)),e.min=(...t)=>e.check(Yn(...t)),e.max=(...t)=>e.check(Wn(...t)),e.length=(...t)=>e.check(Qn(...t)),e.nonempty=(...t)=>e.check(Yn(1,...t)),e.lowercase=t=>e.check(function(e){return new kr({check:"string_format",format:"lowercase",...pt(e)})}(t)),e.uppercase=t=>e.check(function(e){return new $r({check:"string_format",format:"uppercase",...pt(e)})}(t)),e.trim=()=>e.check(es(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return es(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(es(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(es(e=>e.toUpperCase())),e.slugify=()=>e.check(es(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}),ca=Ue("ZodString",(e,t)=>{Ir.init(e,t),oa.init(e,t),e.email=t=>e.check(function(e,t){return new la({type:"string",format:"email",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.url=t=>e.check(function(e,t){return new ha({type:"string",format:"url",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.jwt=t=>e.check(function(e,t){return new Oa({type:"string",format:"jwt",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.emoji=t=>e.check(function(e,t){return new ma({type:"string",format:"emoji",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.guid=t=>e.check(Hn(pa,t)),e.uuid=t=>e.check(function(e,t){return new fa({type:"string",format:"uuid",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.uuidv4=t=>e.check(function(e,t){return new fa({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...pt(t)})}(0,t)),e.uuidv6=t=>e.check(function(e,t){return new fa({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...pt(t)})}(0,t)),e.uuidv7=t=>e.check(function(e,t){return new fa({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...pt(t)})}(0,t)),e.nanoid=t=>e.check(function(e,t){return new ga({type:"string",format:"nanoid",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.guid=t=>e.check(Hn(pa,t)),e.cuid=t=>e.check(function(e,t){return new ya({type:"string",format:"cuid",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.cuid2=t=>e.check(function(e,t){return new _a({type:"string",format:"cuid2",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.ulid=t=>e.check(function(e,t){return new va({type:"string",format:"ulid",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.base64=t=>e.check(function(e,t){return new Ta({type:"string",format:"base64",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.base64url=t=>e.check(function(e,t){return new xa({type:"string",format:"base64url",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.xid=t=>e.check(function(e,t){return new wa({type:"string",format:"xid",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.ksuid=t=>e.check(function(e,t){return new ba({type:"string",format:"ksuid",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.ipv4=t=>e.check(function(e,t){return new ka({type:"string",format:"ipv4",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.ipv6=t=>e.check(function(e,t){return new $a({type:"string",format:"ipv6",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.cidrv4=t=>e.check(function(e,t){return new Sa({type:"string",format:"cidrv4",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.cidrv6=t=>e.check(function(e,t){return new Ea({type:"string",format:"cidrv6",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.e164=t=>e.check(function(e,t){return new Na({type:"string",format:"e164",check:"string_format",abort:!1,...pt(t)})}(0,t)),e.datetime=t=>e.check(Us(t)),e.date=t=>e.check(function(e){return function(e,t){return new Vs({type:"string",format:"date",check:"string_format",...pt(t)})}(0,e)}(t)),e.time=t=>e.check(function(e){return function(e,t){return new Hs({type:"string",format:"time",check:"string_format",precision:null,...pt(t)})}(0,e)}(t)),e.duration=t=>e.check(function(e){return function(e,t){return new Js({type:"string",format:"duration",check:"string_format",...pt(t)})}(0,e)}(t))});function da(e){return function(e,t){return new ca({type:"string",...pt(t)})}(0,e)}const ua=Ue("ZodStringFormat",(e,t)=>{Rr.init(e,t),oa.init(e,t)}),la=Ue("ZodEmail",(e,t)=>{Cr.init(e,t),ua.init(e,t)}),pa=Ue("ZodGUID",(e,t)=>{jr.init(e,t),ua.init(e,t)}),fa=Ue("ZodUUID",(e,t)=>{zr.init(e,t),ua.init(e,t)}),ha=Ue("ZodURL",(e,t)=>{Ar.init(e,t),ua.init(e,t)}),ma=Ue("ZodEmoji",(e,t)=>{Mr.init(e,t),ua.init(e,t)}),ga=Ue("ZodNanoID",(e,t)=>{Zr.init(e,t),ua.init(e,t)}),ya=Ue("ZodCUID",(e,t)=>{Dr.init(e,t),ua.init(e,t)}),_a=Ue("ZodCUID2",(e,t)=>{Lr.init(e,t),ua.init(e,t)}),va=Ue("ZodULID",(e,t)=>{Fr.init(e,t),ua.init(e,t)}),wa=Ue("ZodXID",(e,t)=>{qr.init(e,t),ua.init(e,t)}),ba=Ue("ZodKSUID",(e,t)=>{Ur.init(e,t),ua.init(e,t)}),ka=Ue("ZodIPv4",(e,t)=>{Br.init(e,t),ua.init(e,t)}),$a=Ue("ZodIPv6",(e,t)=>{Gr.init(e,t),ua.init(e,t)}),Sa=Ue("ZodCIDRv4",(e,t)=>{Xr.init(e,t),ua.init(e,t)}),Ea=Ue("ZodCIDRv6",(e,t)=>{Wr.init(e,t),ua.init(e,t)}),Ta=Ue("ZodBase64",(e,t)=>{Qr.init(e,t),ua.init(e,t)}),xa=Ue("ZodBase64URL",(e,t)=>{en.init(e,t),ua.init(e,t)}),Na=Ue("ZodE164",(e,t)=>{tn.init(e,t),ua.init(e,t)}),Oa=Ue("ZodJWT",(e,t)=>{rn.init(e,t),ua.init(e,t)}),Pa=Ue("ZodNumber",(e,t)=>{nn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ds(e,t,r),e.gt=(t,r)=>e.check(Bn(t,r)),e.gte=(t,r)=>e.check(Gn(t,r)),e.min=(t,r)=>e.check(Gn(t,r)),e.lt=(t,r)=>e.check(Jn(t,r)),e.lte=(t,r)=>e.check(Kn(t,r)),e.max=(t,r)=>e.check(Kn(t,r)),e.int=t=>e.check(ja(t)),e.safe=t=>e.check(ja(t)),e.positive=t=>e.check(Bn(0,t)),e.nonnegative=t=>e.check(Gn(0,t)),e.negative=t=>e.check(Jn(0,t)),e.nonpositive=t=>e.check(Kn(0,t)),e.multipleOf=(t,r)=>e.check(Xn(t,r)),e.step=(t,r)=>e.check(Xn(t,r)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function Ia(e){return function(e,t){return new Pa({type:"number",checks:[],...pt(t)})}(0,e)}const Ra=Ue("ZodNumberFormat",(e,t)=>{sn.init(e,t),Pa.init(e,t)});function ja(e){return function(e,t){return new Ra({type:"number",check:"number_format",abort:!1,format:"safeint",...pt(t)})}(0,e)}const za=Ue("ZodBoolean",(e,t)=>{an.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(e,t,r)=>us(0,0,t)});function Ca(e){return function(e,t){return new za({type:"boolean",...pt(t)})}(0,e)}const Aa=Ue("ZodNull",(e,t)=>{on.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(e,t,r)=>ls(0,e,t)});function Ma(e){return function(e,t){return new Aa({type:"null",...pt(t)})}(0,e)}const Za=Ue("ZodUnknown",(e,t)=>{cn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(e,t,r)=>{}});function Da(){return new Za({type:"unknown"})}const La=Ue("ZodNever",(e,t)=>{dn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(e,t,r)=>ps(0,0,t)});const Fa=Ue("ZodArray",(e,t)=>{ln.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ys(e,t,r,n),e.element=t.element,e.min=(t,r)=>e.check(Yn(t,r)),e.nonempty=t=>e.check(Yn(1,t)),e.max=(t,r)=>e.check(Wn(t,r)),e.length=(t,r)=>e.check(Qn(t,r)),e.unwrap=()=>e.element});function qa(e,t){return function(e,t,r){return new Fa({type:"array",element:t,...pt(r)})}(0,e,t)}const Ua=Ue("ZodObject",(e,t)=>{gn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>_s(e,t,r,n),et(e,"shape",()=>t.shape),e.keyof=()=>ti(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Da()}),e.loose=()=>e.clone({...e._zod.def,catchall:Da()}),e.strict=()=>{return e.clone({...e._zod.def,catchall:function(e,t){return new La({type:"never",...pt(t)})}(0,t)});var t},e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!ot(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0){const r=e._zod.def.shape;for(const e in t)if(void 0!==Object.getOwnPropertyDescriptor(r,e))throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const n=rt(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return tt(this,"shape",r),r}});return lt(e,n)}(e,t),e.safeExtend=t=>function(e,t){if(!ot(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=rt(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return tt(this,"shape",r),r}});return lt(e,r)}(e,t),e.merge=t=>function(e,t){const r=rt(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return tt(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return lt(e,r)}(e,t),e.pick=t=>function(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");return lt(e,rt(e._zod.def,{get shape(){const e={};for(const n in t){if(!(n in r.shape))throw new Error(`Unrecognized key: "${n}"`);t[n]&&(e[n]=r.shape[n])}return tt(this,"shape",e),e},checks:[]}))}(e,t),e.omit=t=>function(e,t){const r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const s=rt(e._zod.def,{get shape(){const n={...e._zod.def.shape};for(const e in t){if(!(e in r.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return tt(this,"shape",n),n},checks:[]});return lt(e,s)}(e,t),e.partial=(...t)=>function(e,t,r){const n=t._zod.def.checks;if(n&&n.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const s=rt(t._zod.def,{get shape(){const n=t._zod.def.shape,s={...n};if(r)for(const t in r){if(!(t in n))throw new Error(`Unrecognized key: "${t}"`);r[t]&&(s[t]=e?new e({type:"optional",innerType:n[t]}):n[t])}else for(const t in n)s[t]=e?new e({type:"optional",innerType:n[t]}):n[t];return tt(this,"shape",s),s},checks:[]});return lt(t,s)}(ii,e,t[0]),e.required=(...t)=>function(e,t,r){const n=rt(t._zod.def,{get shape(){const n=t._zod.def.shape,s={...n};if(r)for(const t in r){if(!(t in s))throw new Error(`Unrecognized key: "${t}"`);r[t]&&(s[t]=new e({type:"nonoptional",innerType:n[t]}))}else for(const t in n)s[t]=new e({type:"nonoptional",innerType:n[t]});return tt(this,"shape",s),s}});return lt(t,n)}(fi,e,t[0])});function Va(e,t){const r={type:"object",shape:e??{},...pt(t)};return new Ua(r)}function Ha(e,t){return new Ua({type:"object",shape:e,catchall:Da(),...pt(t)})}const Ja=Ue("ZodUnion",(e,t)=>{_n.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>vs(e,t,r,n),e.options=t.options});function Ka(e,t){return new Ja({type:"union",options:e,...pt(t)})}const Ba=Ue("ZodDiscriminatedUnion",(e,t)=>{Ja.init(e,t),vn.init(e,t)});function Ga(e,t,r){return new Ba({type:"union",options:t,discriminator:e,...pt(r)})}const Xa=Ue("ZodIntersection",(e,t)=>{wn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ws(e,t,r,n)});function Wa(e,t){return new Xa({type:"intersection",left:e,right:t})}const Ya=Ue("ZodRecord",(e,t)=>{$n.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>bs(e,t,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function Qa(e,t,r){return new Ya({type:"record",keyType:e,valueType:t,...pt(r)})}const ei=Ue("ZodEnum",(e,t)=>{Sn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>fs(e,0,r),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(e,n)=>{const s={};for(const n of e){if(!r.has(n))throw new Error(`Key ${n} not found in enum`);s[n]=t.entries[n]}return new ei({...t,checks:[],...pt(n),entries:s})},e.exclude=(e,n)=>{const s={...t.entries};for(const t of e){if(!r.has(t))throw new Error(`Key ${t} not found in enum`);delete s[t]}return new ei({...t,checks:[],...pt(n),entries:s})}});function ti(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new ei({type:"enum",entries:r,...pt(t)})}const ri=Ue("ZodLiteral",(e,t)=>{En.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>hs(e,t,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function ni(e,t){return new ri({type:"literal",values:Array.isArray(e)?e:[e],...pt(t)})}const si=Ue("ZodTransform",(e,t)=>{Tn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(e,t,r)=>gs(0,e),e._zod.parse=(r,n)=>{if("backward"===n.direction)throw new He(e.constructor.name);r.addIssue=n=>{if("string"==typeof n)r.issues.push(vt(n,r.value,t));else{const t=n;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=r.value),t.inst??(t.inst=e),r.issues.push(vt(t))}};const s=t.transform(r.value,r);return s instanceof Promise?s.then(e=>(r.value=e,r)):(r.value=s,r)}});function ai(e){return new si({type:"transform",transform:e})}const ii=Ue("ZodOptional",(e,t)=>{Nn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Os(e,t,0,n),e.unwrap=()=>e._zod.def.innerType});function oi(e){return new ii({type:"optional",innerType:e})}const ci=Ue("ZodExactOptional",(e,t)=>{On.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Os(e,t,0,n),e.unwrap=()=>e._zod.def.innerType}),di=Ue("ZodNullable",(e,t)=>{Pn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ks(e,t,r,n),e.unwrap=()=>e._zod.def.innerType});function ui(e){return new di({type:"nullable",innerType:e})}const li=Ue("ZodDefault",(e,t)=>{In.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Ss(e,t,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),pi=Ue("ZodPrefault",(e,t)=>{jn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Es(e,t,r,n),e.unwrap=()=>e._zod.def.innerType}),fi=Ue("ZodNonOptional",(e,t)=>{zn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>$s(e,t,0,n),e.unwrap=()=>e._zod.def.innerType}),hi=Ue("ZodCatch",(e,t)=>{An.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Ts(e,t,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),mi=Ue("ZodPipe",(e,t)=>{Mn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>xs(e,t,0,n),e.in=t.in,e.out=t.out});function gi(e,t){return new mi({type:"pipe",in:e,out:t})}const yi=Ue("ZodReadonly",(e,t)=>{Dn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Ns(e,t,r,n),e.unwrap=()=>e._zod.def.innerType}),_i=Ue("ZodCustom",(e,t)=>{Fn.init(e,t),ia.init(e,t),e._zod.processJSONSchema=(e,t,r)=>ms(0,e)});function vi(e,t){return gi(ai(e),t)}const wi="2025-11-25",bi=[wi,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],ki="io.modelcontextprotocol/related-task",$i="2.0",Si=function(e,t,r){const n=pt(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:(e=>null!==e&&("object"==typeof e||"function"==typeof e))??(()=>!0),...n})}(_i,0,void 0);const Ei=Ka([da(),Ia().int()]),Ti=da();Ha({ttl:Ka([Ia(),Ma()]).optional(),pollInterval:Ia().optional()});const xi=Va({ttl:Ia().optional()}),Ni=Va({taskId:da()}),Oi=Ha({progressToken:Ei.optional(),[ki]:Ni.optional()}),Pi=Va({_meta:Oi.optional()}),Ii=Pi.extend({task:xi.optional()}),Ri=Va({method:da(),params:Pi.loose().optional()}),ji=Va({_meta:Oi.optional()}),zi=Va({method:da(),params:ji.loose().optional()}),Ci=Ha({_meta:Oi.optional()}),Ai=Ka([da(),Ia().int()]),Mi=Va({jsonrpc:ni($i),id:Ai,...Ri.shape}).strict(),Zi=e=>Mi.safeParse(e).success,Di=Va({jsonrpc:ni($i),...zi.shape}).strict(),Li=Va({jsonrpc:ni($i),id:Ai,result:Ci}).strict(),Fi=e=>Li.safeParse(e).success;var qi;!function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"}(qi||(qi={}));const Ui=Va({jsonrpc:ni($i),id:Ai.optional(),error:Va({code:Ia().int(),message:da(),data:Da().optional()})}).strict(),Vi=Ka([Mi,Di,Li,Ui]);Ka([Li,Ui]);const Hi=Ci.strict(),Ji=ji.extend({requestId:Ai.optional(),reason:da().optional()}),Ki=zi.extend({method:ni("notifications/cancelled"),params:Ji}),Bi=Va({src:da(),mimeType:da().optional(),sizes:qa(da()).optional(),theme:ti(["light","dark"]).optional()}),Gi=Va({icons:qa(Bi).optional()}),Xi=Va({name:da(),title:da().optional()}),Wi=Xi.extend({...Xi.shape,...Gi.shape,version:da(),websiteUrl:da().optional(),description:da().optional()}),Yi=Wa(Va({applyDefaults:Ca().optional()}),Qa(da(),Da())),Qi=vi(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,Wa(Va({form:Yi.optional(),url:Si.optional()}),Qa(da(),Da()).optional())),eo=Ha({list:Si.optional(),cancel:Si.optional(),requests:Ha({sampling:Ha({createMessage:Si.optional()}).optional(),elicitation:Ha({create:Si.optional()}).optional()}).optional()}),to=Ha({list:Si.optional(),cancel:Si.optional(),requests:Ha({tools:Ha({call:Si.optional()}).optional()}).optional()}),ro=Va({experimental:Qa(da(),Si).optional(),sampling:Va({context:Si.optional(),tools:Si.optional()}).optional(),elicitation:Qi.optional(),roots:Va({listChanged:Ca().optional()}).optional(),tasks:eo.optional()}),no=Pi.extend({protocolVersion:da(),capabilities:ro,clientInfo:Wi}),so=Ri.extend({method:ni("initialize"),params:no}),ao=Va({experimental:Qa(da(),Si).optional(),logging:Si.optional(),completions:Si.optional(),prompts:Va({listChanged:Ca().optional()}).optional(),resources:Va({subscribe:Ca().optional(),listChanged:Ca().optional()}).optional(),tools:Va({listChanged:Ca().optional()}).optional(),tasks:to.optional()}),io=Ci.extend({protocolVersion:da(),capabilities:ao,serverInfo:Wi,instructions:da().optional()}),oo=zi.extend({method:ni("notifications/initialized"),params:ji.optional()}),co=Ri.extend({method:ni("ping"),params:Pi.optional()}),uo=Va({progress:Ia(),total:oi(Ia()),message:oi(da())}),lo=Va({...ji.shape,...uo.shape,progressToken:Ei}),po=zi.extend({method:ni("notifications/progress"),params:lo}),fo=Pi.extend({cursor:Ti.optional()}),ho=Ri.extend({params:fo.optional()}),mo=Ci.extend({nextCursor:Ti.optional()}),go=ti(["working","input_required","completed","failed","cancelled"]),yo=Va({taskId:da(),status:go,ttl:Ka([Ia(),Ma()]),createdAt:da(),lastUpdatedAt:da(),pollInterval:oi(Ia()),statusMessage:oi(da())}),_o=Ci.extend({task:yo}),vo=ji.merge(yo),wo=zi.extend({method:ni("notifications/tasks/status"),params:vo}),bo=Ri.extend({method:ni("tasks/get"),params:Pi.extend({taskId:da()})}),ko=Ci.merge(yo),$o=Ri.extend({method:ni("tasks/result"),params:Pi.extend({taskId:da()})});Ci.loose();const So=ho.extend({method:ni("tasks/list")}),Eo=mo.extend({tasks:qa(yo)}),To=Ri.extend({method:ni("tasks/cancel"),params:Pi.extend({taskId:da()})}),xo=Ci.merge(yo),No=Va({uri:da(),mimeType:oi(da()),_meta:Qa(da(),Da()).optional()}),Oo=No.extend({text:da()}),Po=da().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Io=No.extend({blob:Po}),Ro=ti(["user","assistant"]),jo=Va({audience:qa(Ro).optional(),priority:Ia().min(0).max(1).optional(),lastModified:Us({offset:!0}).optional()}),zo=Va({...Xi.shape,...Gi.shape,uri:da(),description:oi(da()),mimeType:oi(da()),annotations:jo.optional(),_meta:oi(Ha({}))}),Co=Va({...Xi.shape,...Gi.shape,uriTemplate:da(),description:oi(da()),mimeType:oi(da()),annotations:jo.optional(),_meta:oi(Ha({}))}),Ao=ho.extend({method:ni("resources/list")}),Mo=mo.extend({resources:qa(zo)}),Zo=ho.extend({method:ni("resources/templates/list")}),Do=mo.extend({resourceTemplates:qa(Co)}),Lo=Pi.extend({uri:da()}),Fo=Lo,qo=Ri.extend({method:ni("resources/read"),params:Fo}),Uo=Ci.extend({contents:qa(Ka([Oo,Io]))}),Vo=zi.extend({method:ni("notifications/resources/list_changed"),params:ji.optional()}),Ho=Lo,Jo=Ri.extend({method:ni("resources/subscribe"),params:Ho}),Ko=Lo,Bo=Ri.extend({method:ni("resources/unsubscribe"),params:Ko}),Go=ji.extend({uri:da()}),Xo=zi.extend({method:ni("notifications/resources/updated"),params:Go}),Wo=Va({name:da(),description:oi(da()),required:oi(Ca())}),Yo=Va({...Xi.shape,...Gi.shape,description:oi(da()),arguments:oi(qa(Wo)),_meta:oi(Ha({}))}),Qo=ho.extend({method:ni("prompts/list")}),ec=mo.extend({prompts:qa(Yo)}),tc=Pi.extend({name:da(),arguments:Qa(da(),da()).optional()}),rc=Ri.extend({method:ni("prompts/get"),params:tc}),nc=Va({type:ni("text"),text:da(),annotations:jo.optional(),_meta:Qa(da(),Da()).optional()}),sc=Va({type:ni("image"),data:Po,mimeType:da(),annotations:jo.optional(),_meta:Qa(da(),Da()).optional()}),ac=Va({type:ni("audio"),data:Po,mimeType:da(),annotations:jo.optional(),_meta:Qa(da(),Da()).optional()}),ic=Va({type:ni("tool_use"),name:da(),id:da(),input:Qa(da(),Da()),_meta:Qa(da(),Da()).optional()}),oc=Va({type:ni("resource"),resource:Ka([Oo,Io]),annotations:jo.optional(),_meta:Qa(da(),Da()).optional()}),cc=Ka([nc,sc,ac,zo.extend({type:ni("resource_link")}),oc]),dc=Va({role:Ro,content:cc}),uc=Ci.extend({description:da().optional(),messages:qa(dc)}),lc=zi.extend({method:ni("notifications/prompts/list_changed"),params:ji.optional()}),pc=Va({title:da().optional(),readOnlyHint:Ca().optional(),destructiveHint:Ca().optional(),idempotentHint:Ca().optional(),openWorldHint:Ca().optional()}),fc=Va({taskSupport:ti(["required","optional","forbidden"]).optional()}),hc=Va({...Xi.shape,...Gi.shape,description:da().optional(),inputSchema:Va({type:ni("object"),properties:Qa(da(),Si).optional(),required:qa(da()).optional()}).catchall(Da()),outputSchema:Va({type:ni("object"),properties:Qa(da(),Si).optional(),required:qa(da()).optional()}).catchall(Da()).optional(),annotations:pc.optional(),execution:fc.optional(),_meta:Qa(da(),Da()).optional()}),mc=ho.extend({method:ni("tools/list")}),gc=mo.extend({tools:qa(hc)}),yc=Ci.extend({content:qa(cc).default([]),structuredContent:Qa(da(),Da()).optional(),isError:Ca().optional()});yc.or(Ci.extend({toolResult:Da()}));const _c=Ii.extend({name:da(),arguments:Qa(da(),Da()).optional()}),vc=Ri.extend({method:ni("tools/call"),params:_c}),wc=zi.extend({method:ni("notifications/tools/list_changed"),params:ji.optional()});Va({autoRefresh:Ca().default(!0),debounceMs:Ia().int().nonnegative().default(300)});const bc=ti(["debug","info","notice","warning","error","critical","alert","emergency"]),kc=Pi.extend({level:bc}),$c=Ri.extend({method:ni("logging/setLevel"),params:kc}),Sc=ji.extend({level:bc,logger:da().optional(),data:Da()}),Ec=zi.extend({method:ni("notifications/message"),params:Sc}),Tc=Va({name:da().optional()}),xc=Va({hints:qa(Tc).optional(),costPriority:Ia().min(0).max(1).optional(),speedPriority:Ia().min(0).max(1).optional(),intelligencePriority:Ia().min(0).max(1).optional()}),Nc=Va({mode:ti(["auto","required","none"]).optional()}),Oc=Va({type:ni("tool_result"),toolUseId:da().describe("The unique identifier for the corresponding tool call."),content:qa(cc).default([]),structuredContent:Va({}).loose().optional(),isError:Ca().optional(),_meta:Qa(da(),Da()).optional()}),Pc=Ga("type",[nc,sc,ac]),Ic=Ga("type",[nc,sc,ac,ic,Oc]),Rc=Va({role:Ro,content:Ka([Ic,qa(Ic)]),_meta:Qa(da(),Da()).optional()}),jc=Ii.extend({messages:qa(Rc),modelPreferences:xc.optional(),systemPrompt:da().optional(),includeContext:ti(["none","thisServer","allServers"]).optional(),temperature:Ia().optional(),maxTokens:Ia().int(),stopSequences:qa(da()).optional(),metadata:Si.optional(),tools:qa(hc).optional(),toolChoice:Nc.optional()}),zc=Ri.extend({method:ni("sampling/createMessage"),params:jc}),Cc=Ci.extend({model:da(),stopReason:oi(ti(["endTurn","stopSequence","maxTokens"]).or(da())),role:Ro,content:Pc}),Ac=Ci.extend({model:da(),stopReason:oi(ti(["endTurn","stopSequence","maxTokens","toolUse"]).or(da())),role:Ro,content:Ka([Ic,qa(Ic)])}),Mc=Va({type:ni("boolean"),title:da().optional(),description:da().optional(),default:Ca().optional()}),Zc=Va({type:ni("string"),title:da().optional(),description:da().optional(),minLength:Ia().optional(),maxLength:Ia().optional(),format:ti(["email","uri","date","date-time"]).optional(),default:da().optional()}),Dc=Va({type:ti(["number","integer"]),title:da().optional(),description:da().optional(),minimum:Ia().optional(),maximum:Ia().optional(),default:Ia().optional()}),Lc=Va({type:ni("string"),title:da().optional(),description:da().optional(),enum:qa(da()),default:da().optional()}),Fc=Va({type:ni("string"),title:da().optional(),description:da().optional(),oneOf:qa(Va({const:da(),title:da()})),default:da().optional()}),qc=Va({type:ni("string"),title:da().optional(),description:da().optional(),enum:qa(da()),enumNames:qa(da()).optional(),default:da().optional()}),Uc=Ka([Lc,Fc]),Vc=Ka([Va({type:ni("array"),title:da().optional(),description:da().optional(),minItems:Ia().optional(),maxItems:Ia().optional(),items:Va({type:ni("string"),enum:qa(da())}),default:qa(da()).optional()}),Va({type:ni("array"),title:da().optional(),description:da().optional(),minItems:Ia().optional(),maxItems:Ia().optional(),items:Va({anyOf:qa(Va({const:da(),title:da()}))}),default:qa(da()).optional()})]),Hc=Ka([qc,Uc,Vc]),Jc=Ka([Hc,Mc,Zc,Dc]),Kc=Ka([Ii.extend({mode:ni("form").optional(),message:da(),requestedSchema:Va({type:ni("object"),properties:Qa(da(),Jc),required:qa(da()).optional()})}),Ii.extend({mode:ni("url"),message:da(),elicitationId:da(),url:da().url()})]),Bc=Ri.extend({method:ni("elicitation/create"),params:Kc}),Gc=ji.extend({elicitationId:da()}),Xc=zi.extend({method:ni("notifications/elicitation/complete"),params:Gc}),Wc=Ci.extend({action:ti(["accept","decline","cancel"]),content:vi(e=>null===e?void 0:e,Qa(da(),Ka([da(),Ia(),Ca(),qa(da())])).optional())}),Yc=Va({type:ni("ref/resource"),uri:da()}),Qc=Va({type:ni("ref/prompt"),name:da()}),ed=Pi.extend({ref:Ka([Qc,Yc]),argument:Va({name:da(),value:da()}),context:Va({arguments:Qa(da(),da()).optional()}).optional()}),td=Ri.extend({method:ni("completion/complete"),params:ed}),rd=Ci.extend({completion:Ha({values:qa(da()).max(100),total:oi(Ia().int()),hasMore:oi(Ca())})}),nd=Va({uri:da().startsWith("file://"),name:da().optional(),_meta:Qa(da(),Da()).optional()}),sd=Ri.extend({method:ni("roots/list"),params:Pi.optional()}),ad=Ci.extend({roots:qa(nd)}),id=zi.extend({method:ni("notifications/roots/list_changed"),params:ji.optional()});Ka([co,so,td,$c,rc,Qo,Ao,Zo,qo,Jo,Bo,vc,mc,bo,$o,So,To]),Ka([Ki,po,oo,id,wo]),Ka([Hi,Cc,Ac,Wc,ad,ko,Eo,_o]),Ka([co,zc,Bc,sd,bo,$o,So,To]),Ka([Ki,po,Ec,Xo,Vo,wc,lc,wo,Xc]),Ka([Hi,io,rd,uc,ec,Mo,Do,Uo,yc,gc,ko,Eo,_o]);class od extends Error{constructor(e,t,r){super(`MCP error ${e}: ${t}`),this.code=e,this.data=r,this.name="McpError"}static fromError(e,t,r){if(e===qi.UrlElicitationRequired&&r){const e=r;if(e.elicitations)return new cd(e.elicitations,t)}return new od(e,t,r)}}class cd extends od{constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(qi.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}function dd(e){return"completed"===e||"failed"===e||"cancelled"===e}const ud=Symbol("Let zodToJsonSchema decide on which parser to use"),ld={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref",openAiAnyTypeName:"OpenAiAnyType"};function pd(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function fd(e,t,r,n,s){e[t]=r,pd(e,t,n,s)}const hd=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")};function md(e){if("openAi"!==e.target)return{};const t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===e.$refStrategy?hd(t,e.currentPath):t.join("/")}}function gd(e,t){return qd(e.type._def,t)}function yd(e,t,r){const n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((r,n)=>yd(e,t,r))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return _d(e,t)}}const _d=(e,t)=>{const r={type:"integer",format:"unix-time"};if("openApi3"===t.target)return r;for(const n of e.checks)switch(n.kind){case"min":fd(r,"minimum",n.value,n.message,t);break;case"max":fd(r,"maximum",n.value,n.message,t)}return r};let vd;const wd=/^[cC][^\s-]{8,}$/,bd=/^[0-9a-z]+$/,kd=/^[0-9A-HJKMNP-TV-Z]{26}$/,$d=/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,Sd=()=>(void 0===vd&&(vd=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),vd),Ed=/^(?:(?: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])$/,Td=/^(([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])$/,xd=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Nd=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Od=/^[a-zA-Z0-9_-]{21}$/,Pd=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;function Id(e,t){const r={type:"string"};if(e.checks)for(const n of e.checks)switch(n.kind){case"min":fd(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,n.value):n.value,n.message,t);break;case"max":fd(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"email":switch(t.emailStrategy){case"format:email":zd(r,"email",n.message,t);break;case"format:idn-email":zd(r,"idn-email",n.message,t);break;case"pattern:zod":Cd(r,$d,n.message,t)}break;case"url":zd(r,"uri",n.message,t);break;case"uuid":zd(r,"uuid",n.message,t);break;case"regex":Cd(r,n.regex,n.message,t);break;case"cuid":Cd(r,wd,n.message,t);break;case"cuid2":Cd(r,bd,n.message,t);break;case"startsWith":Cd(r,RegExp(`^${Rd(n.value,t)}`),n.message,t);break;case"endsWith":Cd(r,RegExp(`${Rd(n.value,t)}$`),n.message,t);break;case"datetime":zd(r,"date-time",n.message,t);break;case"date":zd(r,"date",n.message,t);break;case"time":zd(r,"time",n.message,t);break;case"duration":zd(r,"duration",n.message,t);break;case"length":fd(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,n.value):n.value,n.message,t),fd(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"includes":Cd(r,RegExp(Rd(n.value,t)),n.message,t);break;case"ip":"v6"!==n.version&&zd(r,"ipv4",n.message,t),"v4"!==n.version&&zd(r,"ipv6",n.message,t);break;case"base64url":Cd(r,Nd,n.message,t);break;case"jwt":Cd(r,Pd,n.message,t);break;case"cidr":"v6"!==n.version&&Cd(r,Ed,n.message,t),"v4"!==n.version&&Cd(r,Td,n.message,t);break;case"emoji":Cd(r,Sd(),n.message,t);break;case"ulid":Cd(r,kd,n.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":zd(r,"binary",n.message,t);break;case"contentEncoding:base64":fd(r,"contentEncoding","base64",n.message,t);break;case"pattern:zod":Cd(r,xd,n.message,t)}break;case"nanoid":Cd(r,Od,n.message,t)}return r}function Rd(e,t){return"escape"===t.patternStrategy?function(e){let t="";for(let r=0;r<e.length;r++)jd.has(e[r])||(t+="\\"),t+=e[r];return t}(e):e}const jd=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function zd(e,t,r,n){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...r&&n.errorMessages&&{errorMessage:{format:r}}})):fd(e,"format",t,r,n)}function Cd(e,t,r,n){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:Ad(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):fd(e,"pattern",Ad(t,n),r,n)}function Ad(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;const r=e.flags.includes("i"),n=e.flags.includes("m"),s=e.flags.includes("s"),a=r?e.source.toLowerCase():e.source;let i="",o=!1,c=!1,d=!1;for(let e=0;e<a.length;e++)if(o)i+=a[e],o=!1;else{if(r)if(c){if(a[e].match(/[a-z]/)){d?(i+=a[e],i+=`${a[e-2]}-${a[e]}`.toUpperCase(),d=!1):"-"===a[e+1]&&a[e+2]?.match(/[a-z]/)?(i+=a[e],d=!0):i+=`${a[e]}${a[e].toUpperCase()}`;continue}}else if(a[e].match(/[a-z]/)){i+=`[${a[e]}${a[e].toUpperCase()}]`;continue}if(n){if("^"===a[e]){i+="(^|(?<=[\r\n]))";continue}if("$"===a[e]){i+="($|(?=[\r\n]))";continue}}s&&"."===a[e]?i+=c?`${a[e]}\r\n`:`[${a[e]}\r\n]`:(i+=a[e],"\\"===a[e]?o=!0:c&&"]"===a[e]?c=!1:c||"["!==a[e]||(c=!0))}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function Md(e,t){if("openAi"===t.target&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),"openApi3"===t.target&&e.keyType?._def.typeName===Fe.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,n)=>({...r,[n]:qd(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??md(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};const r={type:"object",additionalProperties:qd(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if("openApi3"===t.target)return r;if(e.keyType?._def.typeName===Fe.ZodString&&e.keyType._def.checks?.length){const{type:n,...s}=Id(e.keyType._def,t);return{...r,propertyNames:s}}if(e.keyType?._def.typeName===Fe.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===Fe.ZodBranded&&e.keyType._def.type._def.typeName===Fe.ZodString&&e.keyType._def.type._def.checks?.length){const{type:n,...s}=gd(e.keyType._def,t);return{...r,propertyNames:s}}return r}const Zd={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},Dd=(e,t)=>{const r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,r)=>qd(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${r}`]})).filter(e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0));return r.length?{anyOf:r}:void 0};function Ld(e){try{return e.isOptional()}catch{return!0}}const Fd=(e,t,r)=>{switch(t){case Fe.ZodString:return Id(e,r);case Fe.ZodNumber:return function(e,t){const r={type:"number"};if(!e.checks)return r;for(const n of e.checks)switch(n.kind){case"int":r.type="integer",pd(r,"type",n.message,t);break;case"min":"jsonSchema7"===t.target?n.inclusive?fd(r,"minimum",n.value,n.message,t):fd(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),fd(r,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?fd(r,"maximum",n.value,n.message,t):fd(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),fd(r,"maximum",n.value,n.message,t));break;case"multipleOf":fd(r,"multipleOf",n.value,n.message,t)}return r}(e,r);case Fe.ZodObject:return function(e,t){const r="openAi"===t.target,n={type:"object",properties:{}},s=[],a=e.shape();for(const e in a){let i=a[e];if(void 0===i||void 0===i._def)continue;let o=Ld(i);o&&r&&("ZodOptional"===i._def.typeName&&(i=i._def.innerType),i.isNullable()||(i=i.nullable()),o=!1);const c=qd(i._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==c&&(n.properties[e]=c,o||s.push(e))}s.length&&(n.required=s);const i=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return qd(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return"strict"===t.removeAdditionalStrategy?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}(e,t);return void 0!==i&&(n.additionalProperties=i),n}(e,r);case Fe.ZodBigInt:return function(e,t){const r={type:"integer",format:"int64"};if(!e.checks)return r;for(const n of e.checks)switch(n.kind){case"min":"jsonSchema7"===t.target?n.inclusive?fd(r,"minimum",n.value,n.message,t):fd(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),fd(r,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?fd(r,"maximum",n.value,n.message,t):fd(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),fd(r,"maximum",n.value,n.message,t));break;case"multipleOf":fd(r,"multipleOf",n.value,n.message,t)}return r}(e,r);case Fe.ZodBoolean:return{type:"boolean"};case Fe.ZodDate:return yd(e,r);case Fe.ZodUndefined:return function(e){return{not:md(e)}}(r);case Fe.ZodNull:return function(e){return"openApi3"===e.target?{enum:["null"],nullable:!0}:{type:"null"}}(r);case Fe.ZodArray:return function(e,t){const r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==Fe.ZodAny&&(r.items=qd(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&fd(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&fd(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(fd(r,"minItems",e.exactLength.value,e.exactLength.message,t),fd(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}(e,r);case Fe.ZodUnion:case Fe.ZodDiscriminatedUnion:return function(e,t){if("openApi3"===t.target)return Dd(e,t);const r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(e=>e._def.typeName in Zd&&(!e._def.checks||!e._def.checks.length))){const e=r.reduce((e,t)=>{const r=Zd[t._def.typeName];return r&&!e.includes(r)?[...e,r]:e},[]);return{type:e.length>1?e:e[0]}}if(r.every(e=>"ZodLiteral"===e._def.typeName&&!e.description)){const e=r.reduce((e,t)=>{const r=typeof t._def.value;switch(r){case"string":case"number":case"boolean":return[...e,r];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}},[]);if(e.length===r.length){const t=e.filter((e,t,r)=>r.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:r.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(r.every(e=>"ZodEnum"===e._def.typeName))return{type:"string",enum:r.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return Dd(e,t)}(e,r);case Fe.ZodIntersection:return function(e,t){const r=[qd(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),qd(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(e=>!!e);let n="jsonSchema2019-09"===t.target?{unevaluatedProperties:!1}:void 0;const s=[];return r.forEach(e=>{if("type"in(t=e)&&"string"===t.type||!("allOf"in t)){let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){const{additionalProperties:r,...n}=e;t=n}else n=void 0;s.push(t)}else s.push(...e.allOf),void 0===e.unevaluatedProperties&&(n=void 0);var t}),s.length?{allOf:s,...n}:void 0}(e,r);case Fe.ZodTuple:return function(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,r)=>qd(e._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:qd(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,r)=>qd(e._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])}}(e,r);case Fe.ZodRecord:return Md(e,r);case Fe.ZodLiteral:return function(e,t){const r=typeof e.value;return"bigint"!==r&&"number"!==r&&"boolean"!==r&&"string"!==r?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===t.target?{type:"bigint"===r?"integer":r,enum:[e.value]}:{type:"bigint"===r?"integer":r,const:e.value}}(e,r);case Fe.ZodEnum:return function(e){return{type:"string",enum:Array.from(e.values)}}(e);case Fe.ZodNativeEnum:return function(e){const t=e.values,r=Object.keys(e.values).filter(e=>"number"!=typeof t[t[e]]).map(e=>t[e]),n=Array.from(new Set(r.map(e=>typeof e)));return{type:1===n.length?"string"===n[0]?"string":"number":["string","number"],enum:r}}(e);case Fe.ZodNullable:return function(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===t.target?{type:Zd[e.innerType._def.typeName],nullable:!0}:{type:[Zd[e.innerType._def.typeName],"null"]};if("openApi3"===t.target){const r=qd(e.innerType._def,{...t,currentPath:[...t.currentPath]});return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&{...r,nullable:!0}}const r=qd(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}(e,r);case Fe.ZodOptional:return((e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return qd(e.innerType._def,t);const r=qd(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:md(t)},r]}:md(t)})(e,r);case Fe.ZodMap:return function(e,t){return"record"===t.mapStrategy?Md(e,t):{type:"array",maxItems:125,items:{type:"array",items:[qd(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||md(t),qd(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||md(t)],minItems:2,maxItems:2}}}(e,r);case Fe.ZodSet:return function(e,t){const r={type:"array",uniqueItems:!0,items:qd(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&fd(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&fd(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}(e,r);case Fe.ZodLazy:return()=>e.getter()._def;case Fe.ZodPromise:return function(e,t){return qd(e.type._def,t)}(e,r);case Fe.ZodNaN:case Fe.ZodNever:return function(e){return"openAi"===e.target?void 0:{not:md({...e,currentPath:[...e.currentPath,"not"]})}}(r);case Fe.ZodEffects:return function(e,t){return"input"===t.effectStrategy?qd(e.schema._def,t):md(t)}(e,r);case Fe.ZodAny:return md(r);case Fe.ZodUnknown:return function(e){return md(e)}(r);case Fe.ZodDefault:return function(e,t){return{...qd(e.innerType._def,t),default:e.defaultValue()}}(e,r);case Fe.ZodBranded:return gd(e,r);case Fe.ZodReadonly:case Fe.ZodCatch:return((e,t)=>qd(e.innerType._def,t))(e,r);case Fe.ZodPipeline:return((e,t)=>{if("input"===t.pipeStrategy)return qd(e.in._def,t);if("output"===t.pipeStrategy)return qd(e.out._def,t);const r=qd(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[r,qd(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]})].filter(e=>void 0!==e)}})(e,r);case Fe.ZodFunction:case Fe.ZodVoid:case Fe.ZodSymbol:default:return}};function qd(e,t,r=!1){const n=t.seen.get(e);if(t.override){const s=t.override?.(e,t,n,r);if(s!==ud)return s}if(n&&!r){const e=Ud(n,t);if(void 0!==e)return e}const s={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,s);const a=Fd(e,e.typeName,t),i="function"==typeof a?qd(a(),t):a;if(i&&Vd(e,t,i),t.postProcess){const r=t.postProcess(i,e,t);return s.jsonSchema=i,r}return s.jsonSchema=i,i}const Ud=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:hd(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((e,r)=>t.currentPath[r]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),md(t)):"seen"===t.$refStrategy?md(t):void 0}},Vd=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);function Hd(e,t){return zs(e)?function(e,t){if("_idmap"in e){const r=e,n=ts({...t,processors:Ps}),s={};for(const e of r._idmap.entries()){const[t,r]=e;rs(r,n)}const a={},i={registry:r,uri:t?.uri,defs:s};n.external=i;for(const e of r._idmap.entries()){const[t,r]=e;ns(n,r),a[t]=ss(n,r)}if(Object.keys(s).length>0){const e="draft-2020-12"===n.target?"$defs":"definitions";a.__shared={[e]:s}}return{schemas:a}}const r=ts({...t,processors:Ps});return rs(e,r),ns(r,e),ss(r,e)}(e,{target:(r=t?.target,r?"jsonSchema7"===r||"draft-7"===r?"draft-7":"jsonSchema2019-09"===r||"draft-2020-12"===r?"draft-2020-12":"draft-7":"draft-7"),io:t?.pipeStrategy??"input"}):((e,t)=>{const r=(e=>{const t=(e=>"string"==typeof e?{...ld,name:e}:{...ld,...e})(e),r=void 0!==t.name?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,r])=>[r._def,{def:r._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}})(t);let n=t.definitions?Object.entries(t.definitions).reduce((e,[t,n])=>({...e,[t]:qd(n._def,{...r,currentPath:[...r.basePath,r.definitionPath,t]},!0)??md(r)}),{}):void 0;const s="title"===t?.nameStrategy?void 0:t?.name,a=qd(e._def,void 0===s?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??md(r),i=void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==i&&(a.title=i),r.flags.hasReferencedOpenAiAnyType&&(n||(n={}),n[r.openAiAnyTypeName]||(n[r.openAiAnyTypeName]={type:["string","number","integer","boolean","array","null"],items:{$ref:"relative"===r.$refStrategy?"1":[...r.basePath,r.definitionPath,r.openAiAnyTypeName].join("/")}}));const o=void 0===s?n?{...a,[r.definitionPath]:n}:a:{$ref:[..."relative"===r.$refStrategy?[]:r.basePath,r.definitionPath,s].join("/"),[r.definitionPath]:{...n,[s]:a}};return"jsonSchema7"===r.target?o.$schema="http://json-schema.org/draft-07/schema#":"jsonSchema2019-09"!==r.target&&"openAi"!==r.target||(o.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===r.target&&("anyOf"in o||"oneOf"in o||"allOf"in o||"type"in o&&Array.isArray(o.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),o})(e,{strictUnions:t?.strictUnions??!0,pipeStrategy:t?.pipeStrategy??"input"});var r}function Jd(e){const t=Zs(e),r=t?.method;if(!r)throw new Error("Schema is missing a method literal");const n=Fs(r);if("string"!=typeof n)throw new Error("Schema method literal must be a string");return n}function Kd(e,t){const r=As(e,t);if(!r.success)throw r.error;return r.data}class Bd{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Ki,e=>{this._oncancel(e)}),this.setNotificationHandler(po,e=>{this._onprogress(e)}),this.setRequestHandler(co,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(bo,async(e,t)=>{const r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new od(qi.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler($o,async(e,t)=>{const r=async()=>{const n=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(n,t.sessionId);){if("response"===e.type||"error"===e.type){const t=e.message,r=t.id,n=this._requestResolvers.get(r);if(n)if(this._requestResolvers.delete(r),"response"===e.type)n(t);else{const e=t;n(new od(e.error.code,e.error.message,e.error.data))}else{const t="response"===e.type?"Response":"Error";this._onerror(new Error(`${t} handler missing for request ${r}`))}continue}await(this._transport?.send(e.message,{relatedRequestId:t.requestId}))}}const s=await this._taskStore.getTask(n,t.sessionId);if(!s)throw new od(qi.InvalidParams,`Task not found: ${n}`);if(!dd(s.status))return await this._waitForTaskUpdate(n,t.signal),await r();if(dd(s.status)){const e=await this._taskStore.getTaskResult(n,t.sessionId);return this._clearTaskQueue(n),{...e,_meta:{...e._meta,[ki]:{taskId:n}}}}return await r()};return await r()}),this.setRequestHandler(So,async(e,t)=>{try{const{tasks:r,nextCursor:n}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:r,nextCursor:n,_meta:{}}}catch(e){throw new od(qi.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(To,async(e,t)=>{try{const r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new od(qi.InvalidParams,`Task not found: ${e.params.taskId}`);if(dd(r.status))throw new od(qi.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,"cancelled","Client cancelled task execution.",t.sessionId),this._clearTaskQueue(e.params.taskId);const n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new od(qi.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...n}}catch(e){if(e instanceof od)throw e;throw new od(qi.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;const t=this._requestHandlerAbortControllers.get(e.params.requestId);t?.abort(e.params.reason)}_setupTimeout(e,t,r,n,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(n,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:s,onTimeout:n})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const r=Date.now()-t.startTime;if(t.maxTotalTimeout&&r>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),od.fromError(qi.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:r});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;const t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};const r=this.transport?.onerror;this._transport.onerror=e=>{r?.(e),this._onerror(e)};const n=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{var r;n?.(e,t),Fi(e)||(r=e,Ui.safeParse(r).success)?this._onresponse(e):Zi(e)?this._onrequest(e,t):(e=>Di.safeParse(e).success)(e)?this._onnotification(e):this._onerror(new Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();const t=od.fromError(qi.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const r of e.values())r(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){const t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;void 0!==t&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(new Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){const r=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,n=this._transport,s=e.params?._meta?.[ki]?.taskId;if(void 0===r){const t={jsonrpc:"2.0",id:e.id,error:{code:qi.MethodNotFound,message:"Method not found"}};return void(s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:t,timestamp:Date.now()},n?.sessionId).catch(e=>this._onerror(new Error(`Failed to enqueue error response: ${e}`))):n?.send(t).catch(e=>this._onerror(new Error(`Failed to send an error response: ${e}`))))}const a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);const i=(o=e.params,Ii.safeParse(o).success?e.params.task:void 0);var o;const c=this._taskStore?this.requestTaskStore(e,n?.sessionId):void 0,d={signal:a.signal,sessionId:n?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{const r={relatedRequestId:e.id};s&&(r.relatedTask={taskId:s}),await this.notification(t,r)},sendRequest:async(t,r,n)=>{const a={...n,relatedRequestId:e.id};s&&!a.relatedTask&&(a.relatedTask={taskId:s});const i=a.relatedTask?.taskId??s;return i&&c&&await c.updateTaskStatus(i,"input_required"),await this.request(t,r,a)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:i?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{i&&this.assertTaskHandlerCapability(e.method)}).then(()=>r(e,d)).then(async t=>{if(a.signal.aborted)return;const r={result:t,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:r,timestamp:Date.now()},n?.sessionId):await(n?.send(r))},async t=>{if(a.signal.aborted)return;const r={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:qi.InternalError,message:t.message??"Internal error",...void 0!==t.data&&{data:t.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:r,timestamp:Date.now()},n?.sessionId):await(n?.send(r))}).catch(e=>this._onerror(new Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...r}=e.params,n=Number(t),s=this._progressHandlers.get(n);if(!s)return void this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));const a=this._responseHandlers.get(n),i=this._timeoutInfo.get(n);if(i&&a&&i.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(e){return this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),void a(e)}s(r)}_onresponse(e){const t=Number(e.id),r=this._requestResolvers.get(t);if(r)return this._requestResolvers.delete(t),void(Fi(e)?r(e):r(new od(e.error.code,e.error.message,e.error.data)));const n=this._responseHandlers.get(t);if(void 0===n)return void this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));this._responseHandlers.delete(t),this._cleanupTimeout(t);let s=!1;if(Fi(e)&&e.result&&"object"==typeof e.result){const r=e.result;if(r.task&&"object"==typeof r.task){const e=r.task;"string"==typeof e.taskId&&(s=!0,this._taskProgressTokens.set(e.taskId,t))}}s||this._progressHandlers.delete(t),Fi(e)?n(e):n(od.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await(this._transport?.close())}async*requestStream(e,t,r){const{task:n}=r??{};if(!n){try{const n=await this.request(e,t,r);yield{type:"result",result:n}}catch(e){yield{type:"error",error:e instanceof od?e:new od(qi.InternalError,String(e))}}return}let s;try{const n=await this.request(e,_o,r);if(!n.task)throw new od(qi.InternalError,"Task creation did not return a task");for(s=n.task.taskId,yield{type:"taskCreated",task:n.task};;){const e=await this.getTask({taskId:s},r);if(yield{type:"taskStatus",task:e},dd(e.status)){if("completed"===e.status){const e=await this.getTaskResult({taskId:s},t,r);yield{type:"result",result:e}}else"failed"===e.status?yield{type:"error",error:new od(qi.InternalError,`Task ${s} failed`)}:"cancelled"===e.status&&(yield{type:"error",error:new od(qi.InternalError,`Task ${s} was cancelled`)});return}if("input_required"===e.status){const e=await this.getTaskResult({taskId:s},t,r);return void(yield{type:"result",result:e})}const n=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,n)),r?.signal?.throwIfAborted()}}catch(e){yield{type:"error",error:e instanceof od?e:new od(qi.InternalError,String(e))}}}request(e,t,r){const{relatedRequestId:n,resumptionToken:s,onresumptiontoken:a,task:i,relatedTask:o}=r??{};return new Promise((c,d)=>{const u=e=>{d(e)};if(!this._transport)return void u(new Error("Not connected"));if(!0===this._options?.enforceStrictCapabilities)try{this.assertCapabilityForMethod(e.method),i&&this.assertTaskCapability(e.method)}catch(e){return void u(e)}r?.signal?.throwIfAborted();const l=this._requestMessageId++,p={...e,jsonrpc:"2.0",id:l};r?.onprogress&&(this._progressHandlers.set(l,r.onprogress),p.params={...e.params,_meta:{...e.params?._meta||{},progressToken:l}}),i&&(p.params={...p.params,task:i}),o&&(p.params={...p.params,_meta:{...p.params?._meta||{},[ki]:o}});const f=e=>{this._responseHandlers.delete(l),this._progressHandlers.delete(l),this._cleanupTimeout(l),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:l,reason:String(e)}},{relatedRequestId:n,resumptionToken:s,onresumptiontoken:a}).catch(e=>this._onerror(new Error(`Failed to send cancellation: ${e}`)));const t=e instanceof od?e:new od(qi.RequestTimeout,String(e));d(t)};this._responseHandlers.set(l,e=>{if(!r?.signal?.aborted){if(e instanceof Error)return d(e);try{const r=As(t,e.result);r.success?c(r.data):d(r.error)}catch(e){d(e)}}}),r?.signal?.addEventListener("abort",()=>{f(r?.signal?.reason)});const h=r?.timeout??6e4;this._setupTimeout(l,h,r?.maxTotalTimeout,()=>f(od.fromError(qi.RequestTimeout,"Request timed out",{timeout:h})),r?.resetTimeoutOnProgress??!1);const m=o?.taskId;if(m){const e=e=>{const t=this._responseHandlers.get(l);t?t(e):this._onerror(new Error(`Response handler missing for side-channeled request ${l}`))};this._requestResolvers.set(l,e),this._enqueueTaskMessage(m,{type:"request",message:p,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(l),d(e)})}else this._transport.send(p,{relatedRequestId:n,resumptionToken:s,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(l),d(e)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},ko,t)}async getTaskResult(e,t,r){return this.request({method:"tasks/result",params:e},t,r)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},Eo,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},xo,t)}async notification(e,t){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const r=t?.relatedTask?.taskId;if(r){const n={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[ki]:t.relatedTask}}};return void await this._enqueueTaskMessage(r,{type:"notification",message:n,timestamp:Date.now()})}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;return this._pendingDebouncedNotifications.add(e.method),void Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let r={...e,jsonrpc:"2.0"};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[ki]:t.relatedTask}}}),this._transport?.send(r,t).catch(e=>this._onerror(e))})}let n={...e,jsonrpc:"2.0"};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[ki]:t.relatedTask}}}),await this._transport.send(n,t)}setRequestHandler(e,t){const r=Jd(e);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(r,n)=>{const s=Kd(e,r);return Promise.resolve(t(s,n))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){const r=Jd(e);this._notificationHandlers.set(r,r=>{const n=Kd(e,r);return Promise.resolve(t(n))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const t=this._taskProgressTokens.get(e);void 0!==t&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,r){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const n=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,r,n)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const r=await this._taskMessageQueue.dequeueAll(e,t);for(const t of r)if("request"===t.type&&Zi(t.message)){const r=t.message.id,n=this._requestResolvers.get(r);n?(n(new od(qi.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(r)):this._onerror(new Error(`Resolver missing for request ${r} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let r=this._options?.defaultTaskPollInterval??1e3;try{const t=await(this._taskStore?.getTask(e));t?.pollInterval&&(r=t.pollInterval)}catch{}return new Promise((e,n)=>{if(t.aborted)return void n(new od(qi.InvalidRequest,"Request cancelled"));const s=setTimeout(e,r);t.addEventListener("abort",()=>{clearTimeout(s),n(new od(qi.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const r=this._taskStore;if(!r)throw new Error("No task store configured");return{createTask:async n=>{if(!e)throw new Error("No request provided");return await r.createTask(n,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{const n=await r.getTask(e,t);if(!n)throw new od(qi.InvalidParams,"Failed to retrieve task: Task not found");return n},storeTaskResult:async(e,n,s)=>{await r.storeTaskResult(e,n,s,t);const a=await r.getTask(e,t);if(a){const t=wo.parse({method:"notifications/tasks/status",params:a});await this.notification(t),dd(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>r.getTaskResult(e,t),updateTaskStatus:async(e,n,s)=>{const a=await r.getTask(e,t);if(!a)throw new od(qi.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(dd(a.status))throw new od(qi.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${n}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await r.updateTaskStatus(e,n,s,t);const i=await r.getTask(e,t);if(i){const t=wo.parse({method:"notifications/tasks/status",params:i});await this.notification(t),dd(i.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>r.listTasks(e,t)}}}function Gd(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function Xd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Wd,Yd={exports:{}},Qd={},eu={},tu={},ru={},nu={},su={};function au(){return Wd||(Wd=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(e){super(),this._items="string"==typeof e?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const e=this._items[0];return""===e||'""'===e}get str(){var e;return null!==(e=this._str)&&void 0!==e?e:this._str=this._items.reduce((e,t)=>`${e}${t}`,"")}get names(){var e;return null!==(e=this._names)&&void 0!==e?e:this._names=this._items.reduce((e,t)=>(t instanceof r&&(e[t.str]=(e[t.str]||0)+1),e),{})}}function s(e,...t){const r=[e[0]];let s=0;for(;s<t.length;)o(r,t[s]),r.push(e[++s]);return new n(r)}e._Code=n,e.nil=new n(""),e._=s;const a=new n("+");function i(e,...t){const r=[d(e[0])];let s=0;for(;s<t.length;)r.push(a),o(r,t[s]),r.push(a,d(e[++s]));return function(e){let t=1;for(;t<e.length-1;){if(e[t]===a){const r=c(e[t-1],e[t+1]);if(void 0!==r){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}(r),new n(r)}function o(e,t){var s;t instanceof n?e.push(...t._items):t instanceof r?e.push(t):e.push("number"==typeof(s=t)||"boolean"==typeof s||null===s?s:d(Array.isArray(s)?s.join(","):s))}function c(e,t){if('""'===t)return e;if('""'===e)return t;if("string"==typeof e){if(t instanceof r||'"'!==e[e.length-1])return;return"string"!=typeof t?`${e.slice(0,-1)}${t}"`:'"'===t[0]?e.slice(0,-1)+t.slice(1):void 0}return"string"!=typeof t||'"'!==t[0]||e instanceof r?void 0:`"${e}${t.slice(1)}`}function d(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.str=i,e.addCodeArg=o,e.strConcat=function(e,t){return t.emptyStr()?e:e.emptyStr()?t:i`${e}${t}`},e.stringify=function(e){return new n(d(e))},e.safeStringify=d,e.getProperty=function(t){return"string"==typeof t&&e.IDENTIFIER.test(t)?new n(`.${t}`):s`[${t}]`},e.getEsmExportName=function(t){if("string"==typeof t&&e.IDENTIFIER.test(t))return new n(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)},e.regexpCode=function(e){return new n(e.toString())}}(su)),su}var iu,ou,cu={};function du(){return iu||(iu=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const t=au();class r extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}}var n;!function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"}(n||(e.UsedValueState=n={})),e.varKinds={const:new t.Name("const"),let:new t.Name("let"),var:new t.Name("var")};class s{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof t.Name?e:this.name(e)}name(e){return new t.Name(this._newName(e))}_newName(e){return`${e}${(this._names[e]||this._nameGroup(e)).index++}`}_nameGroup(e){var t,r;if((null===(r=null===(t=this._parent)||void 0===t?void 0:t._prefixes)||void 0===r?void 0:r.has(e))||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}}e.Scope=s;class a extends t.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=t._`.${new t.Name(r)}[${n}]`}}e.ValueScopeName=a;const i=t._`\n`;e.ValueScope=class extends s{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?i:t.nil}}get(){return this._scope}name(e){return new a(e,this._newName(e))}value(e,t){var r;if(void 0===t.ref)throw new Error("CodeGen: ref must be passed in value");const n=this.toName(e),{prefix:s}=n,a=null!==(r=t.key)&&void 0!==r?r:t.ref;let i=this._values[s];if(i){const e=i.get(a);if(e)return e}else i=this._values[s]=new Map;i.set(a,n);const o=this._scope[s]||(this._scope[s]=[]),c=o.length;return o[c]=t.ref,n.setValue(t,{property:s,itemIndex:c}),n}getValue(e,t){const r=this._values[e];if(r)return r.get(t)}scopeRefs(e,r=this._values){return this._reduceValues(r,r=>{if(void 0===r.scopePath)throw new Error(`CodeGen: name "${r}" has no value`);return t._`${e}${r.scopePath}`})}scopeCode(e=this._values,t,r){return this._reduceValues(e,e=>{if(void 0===e.value)throw new Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,r)}_reduceValues(s,a,i={},o){let c=t.nil;for(const d in s){const u=s[d];if(!u)continue;const l=i[d]=i[d]||new Map;u.forEach(s=>{if(l.has(s))return;l.set(s,n.Started);let i=a(s);if(i){const r=this.opts.es5?e.varKinds.var:e.varKinds.const;c=t._`${c}${r} ${s} = ${i};${this.opts._n}`}else{if(!(i=null==o?void 0:o(s)))throw new r(s);c=t._`${c}${i}${this.opts._n}`}l.set(s,n.Completed)})}return c}}}(cu)),cu}function uu(){return ou||(ou=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=au(),r=du();var n=au();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var s=du();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return s.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return s.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return s.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return s.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class a{optimizeNodes(){return this}optimizeNames(e,t){return this}}class i extends a{constructor(e,t,r){super(),this.varKind=e,this.name=t,this.rhs=r}render({es5:e,_n:t}){const n=e?r.varKinds.var:this.varKind,s=void 0===this.rhs?"":` = ${this.rhs}`;return`${n} ${this.name}${s};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&(this.rhs=O(this.rhs,e,t)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class o extends a{constructor(e,t,r){super(),this.lhs=e,this.rhs=t,this.sideEffects=r}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof t.Name)||e[this.lhs.str]||this.sideEffects)return this.rhs=O(this.rhs,e,r),this}get names(){return N(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}}class c extends o{constructor(e,t,r,n){super(e,r,n),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}}class d extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}}class u extends a{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}}class l extends a{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}}class p extends a{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=O(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class f extends a{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,r)=>t+r.render(e),"")}optimizeNodes(){const{nodes:e}=this;let t=e.length;for(;t--;){const r=e[t].optimizeNodes();Array.isArray(r)?e.splice(t,1,...r):r?e[t]=r:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){const{nodes:r}=this;let n=r.length;for(;n--;){const s=r[n];s.optimizeNames(e,t)||(P(e,s.names),r.splice(n,1))}return r.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>x(e,t.names),{})}}class h extends f{render(e){return"{"+e._n+super.render(e)+"}"+e._n}}class m extends f{}class g extends h{}g.kind="else";class y extends h{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+="else "+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();const e=this.condition;if(!0===e)return this.nodes;let t=this.else;if(t){const e=t.optimizeNodes();t=this.else=Array.isArray(e)?new g(e):e}return t?!1===e?t instanceof y?t:t.nodes:this.nodes.length?this:new y(I(e),t instanceof y?[t]:t.nodes):!1!==e&&this.nodes.length?this:void 0}optimizeNames(e,t){var r;if(this.else=null===(r=this.else)||void 0===r?void 0:r.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=O(this.condition,e,t),this}get names(){const e=super.names;return N(e,this.condition),this.else&&x(e,this.else.names),e}}y.kind="if";class _ extends h{}_.kind="for";class v extends _{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=O(this.iteration,e,t),this}get names(){return x(super.names,this.iteration.names)}}class w extends _{constructor(e,t,r,n){super(),this.varKind=e,this.name=t,this.from=r,this.to=n}render(e){const t=e.es5?r.varKinds.var:this.varKind,{name:n,from:s,to:a}=this;return`for(${t} ${n}=${s}; ${n}<${a}; ${n}++)`+super.render(e)}get names(){const e=N(super.names,this.from);return N(e,this.to)}}class b extends _{constructor(e,t,r,n){super(),this.loop=e,this.varKind=t,this.name=r,this.iterable=n}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=O(this.iterable,e,t),this}get names(){return x(super.names,this.iterable.names)}}class k extends h{constructor(e,t,r){super(),this.name=e,this.args=t,this.async=r}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}}k.kind="func";class $ extends f{render(e){return"return "+super.render(e)}}$.kind="return";class S extends h{render(e){let t="try"+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),null===(e=this.catch)||void 0===e||e.optimizeNodes(),null===(t=this.finally)||void 0===t||t.optimizeNodes(),this}optimizeNames(e,t){var r,n;return super.optimizeNames(e,t),null===(r=this.catch)||void 0===r||r.optimizeNames(e,t),null===(n=this.finally)||void 0===n||n.optimizeNames(e,t),this}get names(){const e=super.names;return this.catch&&x(e,this.catch.names),this.finally&&x(e,this.finally.names),e}}class E extends h{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}E.kind="catch";class T extends h{render(e){return"finally"+super.render(e)}}function x(e,t){for(const r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function N(e,r){return r instanceof t._CodeOrName?x(e,r.names):e}function O(e,r,n){return e instanceof t.Name?a(e):(s=e)instanceof t._Code&&s._items.some(e=>e instanceof t.Name&&1===r[e.str]&&void 0!==n[e.str])?new t._Code(e._items.reduce((e,r)=>(r instanceof t.Name&&(r=a(r)),r instanceof t._Code?e.push(...r._items):e.push(r),e),[])):e;var s;function a(e){const t=n[e.str];return void 0===t||1!==r[e.str]?e:(delete r[e.str],t)}}function P(e,t){for(const r in t)e[r]=(e[r]||0)-(t[r]||0)}function I(e){return"boolean"==typeof e||"number"==typeof e||null===e?!e:t._`!${C(e)}`}T.kind="finally",e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?"\n":""},this._extScope=e,this._scope=new r.Scope({parent:e}),this._nodes=[new m]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){const r=this._extScope.value(e,t);return(this._values[r.prefix]||(this._values[r.prefix]=new Set)).add(r),r}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,r,n){const s=this._scope.toName(t);return void 0!==r&&n&&(this._constants[s.str]=r),this._leafNode(new i(e,s,r)),s}const(e,t,n){return this._def(r.varKinds.const,e,t,n)}let(e,t,n){return this._def(r.varKinds.let,e,t,n)}var(e,t,n){return this._def(r.varKinds.var,e,t,n)}assign(e,t,r){return this._leafNode(new o(e,t,r))}add(t,r){return this._leafNode(new c(t,e.operators.ADD,r))}code(e){return"function"==typeof e?e():e!==t.nil&&this._leafNode(new p(e)),this}object(...e){const r=["{"];for(const[n,s]of e)r.length>1&&r.push(","),r.push(n),(n!==s||this.opts.es5)&&(r.push(":"),(0,t.addCodeArg)(r,s));return r.push("}"),new t._Code(r)}if(e,t,r){if(this._blockNode(new y(e)),t&&r)this.code(t).else().code(r).endIf();else if(t)this.code(t).endIf();else if(r)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new y(e))}else(){return this._elseNode(new g)}endIf(){return this._endBlockNode(y,g)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new v(e),t)}forRange(e,t,n,s,a=(this.opts.es5?r.varKinds.var:r.varKinds.let)){const i=this._scope.toName(e);return this._for(new w(a,i,t,n),()=>s(i))}forOf(e,n,s,a=r.varKinds.const){const i=this._scope.toName(e);if(this.opts.es5){const e=n instanceof t.Name?n:this.var("_arr",n);return this.forRange("_i",0,t._`${e}.length`,r=>{this.var(i,t._`${e}[${r}]`),s(i)})}return this._for(new b("of",a,i,n),()=>s(i))}forIn(e,n,s,a=(this.opts.es5?r.varKinds.var:r.varKinds.const)){if(this.opts.ownProperties)return this.forOf(e,t._`Object.keys(${n})`,s);const i=this._scope.toName(e);return this._for(new b("in",a,i,n),()=>s(i))}endFor(){return this._endBlockNode(_)}label(e){return this._leafNode(new d(e))}break(e){return this._leafNode(new u(e))}return(e){const t=new $;if(this._blockNode(t),this.code(e),1!==t.nodes.length)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode($)}try(e,t,r){if(!t&&!r)throw new Error('CodeGen: "try" without "catch" and "finally"');const n=new S;if(this._blockNode(n),this.code(e),t){const e=this.name("e");this._currNode=n.catch=new E(e),t(e)}return r&&(this._currNode=n.finally=new T,this.code(r)),this._endBlockNode(E,T)}throw(e){return this._leafNode(new l(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){const t=this._blockStarts.pop();if(void 0===t)throw new Error("CodeGen: not in self-balancing block");const r=this._nodes.length-t;if(r<0||void 0!==e&&r!==e)throw new Error(`CodeGen: wrong number of nodes: ${r} vs ${e} expected`);return this._nodes.length=t,this}func(e,r=t.nil,n,s){return this._blockNode(new k(e,r,n)),s&&this.code(s).endFunc(),this}endFunc(){return this._endBlockNode(k)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){const r=this._currNode;if(r instanceof e||t&&r instanceof t)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){const t=this._currNode;if(!(t instanceof y))throw new Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){const e=this._nodes;return e[e.length-1]}set _currNode(e){const t=this._nodes;t[t.length-1]=e}},e.not=I;const R=z(e.operators.AND);e.and=function(...e){return e.reduce(R)};const j=z(e.operators.OR);function z(e){return(r,n)=>r===t.nil?n:n===t.nil?r:t._`${C(r)} ${e} ${C(n)}`}function C(e){return e instanceof t.Name?e:t._`(${e})`}e.or=function(...e){return e.reduce(j)}}(nu)),nu}var lu,pu={};function fu(){if(lu)return pu;lu=1,Object.defineProperty(pu,"__esModule",{value:!0}),pu.checkStrictMode=pu.getErrorPath=pu.Type=pu.useFunc=pu.setEvaluated=pu.evaluatedPropsToName=pu.mergeEvaluated=pu.eachItem=pu.unescapeJsonPointer=pu.escapeJsonPointer=pu.escapeFragment=pu.unescapeFragment=pu.schemaRefOrVal=pu.schemaHasRulesButRef=pu.schemaHasRules=pu.checkUnknownRules=pu.alwaysValidSchema=pu.toHash=void 0;const e=uu(),t=au();function r(e,t=e.schema){const{opts:r,self:n}=e;if(!r.strictSchema)return;if("boolean"==typeof t)return;const s=n.RULES.keywords;for(const r in t)s[r]||l(e,`unknown keyword: "${r}"`)}function n(e,t){if("boolean"==typeof e)return!e;for(const r in e)if(t[r])return!0;return!1}function s(e){return"number"==typeof e?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}function a(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function i({mergeNames:t,mergeToName:r,mergeValues:n,resultToName:s}){return(a,i,o,c)=>{const d=void 0===o?i:o instanceof e.Name?(i instanceof e.Name?t(a,i,o):r(a,i,o),o):i instanceof e.Name?(r(a,o,i),i):n(i,o);return c!==e.Name||d instanceof e.Name?d:s(a,d)}}function o(t,r){if(!0===r)return t.var("props",!0);const n=t.var("props",e._`{}`);return void 0!==r&&c(t,n,r),n}function c(t,r,n){Object.keys(n).forEach(n=>t.assign(e._`${r}${(0,e.getProperty)(n)}`,!0))}pu.toHash=function(e){const t={};for(const r of e)t[r]=!0;return t},pu.alwaysValidSchema=function(e,t){return"boolean"==typeof t?t:0===Object.keys(t).length||(r(e,t),!n(t,e.self.RULES.all))},pu.checkUnknownRules=r,pu.schemaHasRules=n,pu.schemaHasRulesButRef=function(e,t){if("boolean"==typeof e)return!e;for(const r in e)if("$ref"!==r&&t.all[r])return!0;return!1},pu.schemaRefOrVal=function({topSchemaRef:t,schemaPath:r},n,s,a){if(!a){if("number"==typeof n||"boolean"==typeof n)return n;if("string"==typeof n)return e._`${n}`}return e._`${t}${r}${(0,e.getProperty)(s)}`},pu.unescapeFragment=function(e){return a(decodeURIComponent(e))},pu.escapeFragment=function(e){return encodeURIComponent(s(e))},pu.escapeJsonPointer=s,pu.unescapeJsonPointer=a,pu.eachItem=function(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)},pu.mergeEvaluated={props:i({mergeNames:(t,r,n)=>t.if(e._`${n} !== true && ${r} !== undefined`,()=>{t.if(e._`${r} === true`,()=>t.assign(n,!0),()=>t.assign(n,e._`${n} || {}`).code(e._`Object.assign(${n}, ${r})`))}),mergeToName:(t,r,n)=>t.if(e._`${n} !== true`,()=>{!0===r?t.assign(n,!0):(t.assign(n,e._`${n} || {}`),c(t,n,r))}),mergeValues:(e,t)=>!0===e||{...e,...t},resultToName:o}),items:i({mergeNames:(t,r,n)=>t.if(e._`${n} !== true && ${r} !== undefined`,()=>t.assign(n,e._`${r} === true ? true : ${n} > ${r} ? ${n} : ${r}`)),mergeToName:(t,r,n)=>t.if(e._`${n} !== true`,()=>t.assign(n,!0===r||e._`${n} > ${r} ? ${n} : ${r}`)),mergeValues:(e,t)=>!0===e||Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})},pu.evaluatedPropsToName=o,pu.setEvaluated=c;const d={};var u;function l(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,!0===r)throw new Error(t);e.self.logger.warn(t)}}return pu.useFunc=function(e,r){return e.scopeValue("func",{ref:r,code:d[r.code]||(d[r.code]=new t._Code(r.code))})},function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"}(u||(pu.Type=u={})),pu.getErrorPath=function(t,r,n){if(t instanceof e.Name){const s=r===u.Num;return n?s?e._`"[" + ${t} + "]"`:e._`"['" + ${t} + "']"`:s?e._`"/" + ${t}`:e._`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,e.getProperty)(t).toString():"/"+s(t)},pu.checkStrictMode=l,pu}var hu,mu,gu,yu={};function _u(){if(hu)return yu;hu=1,Object.defineProperty(yu,"__esModule",{value:!0});const e=uu(),t={data:new e.Name("data"),valCxt:new e.Name("valCxt"),instancePath:new e.Name("instancePath"),parentData:new e.Name("parentData"),parentDataProperty:new e.Name("parentDataProperty"),rootData:new e.Name("rootData"),dynamicAnchors:new e.Name("dynamicAnchors"),vErrors:new e.Name("vErrors"),errors:new e.Name("errors"),this:new e.Name("this"),self:new e.Name("self"),scope:new e.Name("scope"),json:new e.Name("json"),jsonPos:new e.Name("jsonPos"),jsonLen:new e.Name("jsonLen"),jsonPart:new e.Name("jsonPart")};return yu.default=t,yu}function vu(){return mu||(mu=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=uu(),r=fu(),n=_u();function s(e,r){const s=e.const("err",r);e.if(t._`${n.default.vErrors} === null`,()=>e.assign(n.default.vErrors,t._`[${s}]`),t._`${n.default.vErrors}.push(${s})`),e.code(t._`${n.default.errors}++`)}function a(e,r){const{gen:n,validateName:s,schemaEnv:a}=e;a.$async?n.throw(t._`new ${e.ValidationError}(${r})`):(n.assign(t._`${s}.errors`,r),n.return(!1))}e.keywordError={message:({keyword:e})=>t.str`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:r})=>r?t.str`"${e}" keyword must be ${r} ($data)`:t.str`"${e}" keyword is invalid ($data)`},e.reportError=function(r,n=e.keywordError,i,c){const{it:d}=r,{gen:u,compositeRule:l,allErrors:p}=d,f=o(r,n,i);(null!=c?c:l||p)?s(u,f):a(d,t._`[${f}]`)},e.reportExtraError=function(t,r=e.keywordError,i){const{it:c}=t,{gen:d,compositeRule:u,allErrors:l}=c;s(d,o(t,r,i)),u||l||a(c,n.default.vErrors)},e.resetErrorsCount=function(e,r){e.assign(n.default.errors,r),e.if(t._`${n.default.vErrors} !== null`,()=>e.if(r,()=>e.assign(t._`${n.default.vErrors}.length`,r),()=>e.assign(n.default.vErrors,null)))},e.extendErrors=function({gen:e,keyword:r,schemaValue:s,data:a,errsCount:i,it:o}){if(void 0===i)throw new Error("ajv implementation error");const c=e.name("err");e.forRange("i",i,n.default.errors,i=>{e.const(c,t._`${n.default.vErrors}[${i}]`),e.if(t._`${c}.instancePath === undefined`,()=>e.assign(t._`${c}.instancePath`,(0,t.strConcat)(n.default.instancePath,o.errorPath))),e.assign(t._`${c}.schemaPath`,t.str`${o.errSchemaPath}/${r}`),o.opts.verbose&&(e.assign(t._`${c}.schema`,s),e.assign(t._`${c}.data`,a))})};const i={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function o(e,r,s){const{createErrors:a}=e.it;return!1===a?t._`{}`:function(e,r,s={}){const{gen:a,it:o}=e,u=[c(o,s),d(e,s)];return function(e,{params:r,message:s},a){const{keyword:o,data:c,schemaValue:d,it:u}=e,{opts:l,propertyName:p,topSchemaRef:f,schemaPath:h}=u;a.push([i.keyword,o],[i.params,"function"==typeof r?r(e):r||t._`{}`]),l.messages&&a.push([i.message,"function"==typeof s?s(e):s]),l.verbose&&a.push([i.schema,d],[i.parentSchema,t._`${f}${h}`],[n.default.data,c]),p&&a.push([i.propertyName,p])}(e,r,u),a.object(...u)}(e,r,s)}function c({errorPath:e},{instancePath:s}){const a=s?t.str`${e}${(0,r.getErrorPath)(s,r.Type.Str)}`:e;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,a)]}function d({keyword:e,it:{errSchemaPath:n}},{schemaPath:s,parentSchema:a}){let o=a?n:t.str`${n}/${e}`;return s&&(o=t.str`${o}${(0,r.getErrorPath)(s,r.Type.Str)}`),[i.schemaPath,o]}}(ru)),ru}var wu,bu={},ku={};function $u(){if(wu)return ku;wu=1,Object.defineProperty(ku,"__esModule",{value:!0}),ku.getRules=ku.isJSONType=void 0;const e=new Set(["string","number","integer","boolean","null","object","array"]);return ku.isJSONType=function(t){return"string"==typeof t&&e.has(t)},ku.getRules=function(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}},ku}var Su,Eu,Tu={};function xu(){if(Su)return Tu;function e(e,r){return r.rules.some(r=>t(e,r))}function t(e,t){var r;return void 0!==e[t.keyword]||(null===(r=t.definition.implements)||void 0===r?void 0:r.some(t=>void 0!==e[t]))}return Su=1,Object.defineProperty(Tu,"__esModule",{value:!0}),Tu.shouldUseRule=Tu.shouldUseGroup=Tu.schemaHasRulesForType=void 0,Tu.schemaHasRulesForType=function({schema:t,self:r},n){const s=r.RULES.types[n];return s&&!0!==s&&e(t,s)},Tu.shouldUseGroup=e,Tu.shouldUseRule=t,Tu}function Nu(){if(Eu)return bu;Eu=1,Object.defineProperty(bu,"__esModule",{value:!0}),bu.reportTypeError=bu.checkDataTypes=bu.checkDataType=bu.coerceAndCheckDataType=bu.getJSONTypes=bu.getSchemaTypes=bu.DataType=void 0;const e=$u(),t=xu(),r=vu(),n=uu(),s=fu();var a;function i(t){const r=Array.isArray(t)?t:t?[t]:[];if(r.every(e.isJSONType))return r;throw new Error("type must be JSONType or JSONType[]: "+r.join(","))}!function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"}(a||(bu.DataType=a={})),bu.getSchemaTypes=function(e){const t=i(e.type);if(t.includes("null")){if(!1===e.nullable)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&void 0!==e.nullable)throw new Error('"nullable" cannot be used without "type"');!0===e.nullable&&t.push("null")}return t},bu.getJSONTypes=i,bu.coerceAndCheckDataType=function(e,r){const{gen:s,data:i,opts:c}=e,u=function(e,t){return t?e.filter(e=>o.has(e)||"array"===t&&"array"===e):[]}(r,c.coerceTypes),p=r.length>0&&!(0===u.length&&1===r.length&&(0,t.schemaHasRulesForType)(e,r[0]));if(p){const t=d(r,i,c.strictNumbers,a.Wrong);s.if(t,()=>{u.length?function(e,t,r){const{gen:s,data:a,opts:i}=e,c=s.let("dataType",n._`typeof ${a}`),u=s.let("coerced",n._`undefined`);"array"===i.coerceTypes&&s.if(n._`${c} == 'object' && Array.isArray(${a}) && ${a}.length == 1`,()=>s.assign(a,n._`${a}[0]`).assign(c,n._`typeof ${a}`).if(d(t,a,i.strictNumbers),()=>s.assign(u,a))),s.if(n._`${u} !== undefined`);for(const e of r)(o.has(e)||"array"===e&&"array"===i.coerceTypes)&&p(e);function p(e){switch(e){case"string":return void s.elseIf(n._`${c} == "number" || ${c} == "boolean"`).assign(u,n._`"" + ${a}`).elseIf(n._`${a} === null`).assign(u,n._`""`);case"number":return void s.elseIf(n._`${c} == "boolean" || ${a} === null
2
2
  || (${c} == "string" && ${a} && ${a} == +${a})`).assign(u,n._`+${a}`);case"integer":return void s.elseIf(n._`${c} === "boolean" || ${a} === null
3
3
  || (${c} === "string" && ${a} && ${a} == +${a} && !(${a} % 1))`).assign(u,n._`+${a}`);case"boolean":return void s.elseIf(n._`${a} === "false" || ${a} === 0 || ${a} === null`).assign(u,!1).elseIf(n._`${a} === "true" || ${a} === 1`).assign(u,!0);case"null":return s.elseIf(n._`${a} === "" || ${a} === 0 || ${a} === false`),void s.assign(u,null);case"array":s.elseIf(n._`${c} === "string" || ${c} === "number"
4
- || ${c} === "boolean" || ${a} === null`).assign(u,n._`[${a}]`)}}s.else(),l(e),s.endIf(),s.if(n._`${u} !== undefined`,()=>{s.assign(a,u),function({gen:e,parentData:t,parentDataProperty:r},s){e.if(n._`${t} !== undefined`,()=>e.assign(n._`${t}[${r}]`,s))}(e,u)})}(e,r,u):l(e)})}return p};const o=new Set(["string","number","integer","boolean","null"]);function c(e,t,r,s=a.Correct){const i=s===a.Correct?n.operators.EQ:n.operators.NEQ;let o;switch(e){case"null":return n._`${t} ${i} null`;case"array":o=n._`Array.isArray(${t})`;break;case"object":o=n._`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=c(n._`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=c();break;default:return n._`typeof ${t} ${i} ${e}`}return s===a.Correct?o:(0,n.not)(o);function c(e=n.nil){return(0,n.and)(n._`typeof ${t} == "number"`,e,r?n._`isFinite(${t})`:n.nil)}}function d(e,t,r,a){if(1===e.length)return c(e[0],t,r,a);let i;const o=(0,s.toHash)(e);if(o.array&&o.object){const e=n._`typeof ${t} != "object"`;i=o.null?e:n._`!${t} || ${e}`,delete o.null,delete o.array,delete o.object}else i=n.nil;o.number&&delete o.integer;for(const e in o)i=(0,n.and)(i,c(e,t,r,a));return i}bu.checkDataType=c,bu.checkDataTypes=d;const u={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>"string"==typeof e?n._`{type: ${e}}`:n._`{type: ${t}}`};function l(e){const t=function(e){const{gen:t,data:r,schema:n}=e,a=(0,s.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:a,schemaValue:a,parentSchema:n,params:{},it:e}}(e);(0,r.reportError)(t,u)}return bu.reportTypeError=l,bu}var Pu,Ou,Iu,ju={},Ru={},zu={};function Cu(){if(Ou)return zu;Ou=1,Object.defineProperty(zu,"__esModule",{value:!0}),zu.validateUnion=zu.validateArray=zu.usePattern=zu.callValidateCode=zu.schemaProperties=zu.allSchemaProperties=zu.noPropertyInData=zu.propertyInData=zu.isOwnProperty=zu.hasPropFunc=zu.reportMissingProp=zu.checkMissingProp=zu.checkReportMissingProp=void 0;const e=uu(),t=fu(),r=_u(),n=fu();function s(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:e._`Object.prototype.hasOwnProperty`})}function a(t,r,n){return e._`${s(t)}.call(${r}, ${n})`}function i(t,r,n,s){const i=e._`${r}${(0,e.getProperty)(n)} === undefined`;return s?(0,e.or)(i,(0,e.not)(a(t,r,n))):i}function o(e){return e?Object.keys(e).filter(e=>"__proto__"!==e):[]}zu.checkReportMissingProp=function(t,r){const{gen:n,data:s,it:a}=t;n.if(i(n,s,r,a.opts.ownProperties),()=>{t.setParams({missingProperty:e._`${r}`},!0),t.error()})},zu.checkMissingProp=function({gen:t,data:r,it:{opts:n}},s,a){return(0,e.or)(...s.map(s=>(0,e.and)(i(t,r,s,n.ownProperties),e._`${a} = ${s}`)))},zu.reportMissingProp=function(e,t){e.setParams({missingProperty:t},!0),e.error()},zu.hasPropFunc=s,zu.isOwnProperty=a,zu.propertyInData=function(t,r,n,s){const i=e._`${r}${(0,e.getProperty)(n)} !== undefined`;return s?e._`${i} && ${a(t,r,n)}`:i},zu.noPropertyInData=i,zu.allSchemaProperties=o,zu.schemaProperties=function(e,r){return o(r).filter(n=>!(0,t.alwaysValidSchema)(e,r[n]))},zu.callValidateCode=function({schemaCode:t,data:n,it:{gen:s,topSchemaRef:a,schemaPath:i,errorPath:o},it:c},d,u,l){const p=l?e._`${t}, ${n}, ${a}${i}`:n,f=[[r.default.instancePath,(0,e.strConcat)(r.default.instancePath,o)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&f.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const h=e._`${p}, ${s.object(...f)}`;return u!==e.nil?e._`${d}.call(${u}, ${h})`:e._`${d}(${h})`};const c=e._`new RegExp`;return zu.usePattern=function({gen:t,it:{opts:r}},s){const a=r.unicodeRegExp?"u":"",{regExp:i}=r.code,o=i(s,a);return t.scopeValue("pattern",{key:o.toString(),ref:o,code:e._`${"new RegExp"===i.code?c:(0,n.useFunc)(t,i)}(${s}, ${a})`})},zu.validateArray=function(r){const{gen:n,data:s,keyword:a,it:i}=r,o=n.name("valid");if(i.allErrors){const e=n.let("valid",!0);return c(()=>n.assign(e,!1)),e}return n.var(o,!0),c(()=>n.break()),o;function c(i){const c=n.const("len",e._`${s}.length`);n.forRange("i",0,c,s=>{r.subschema({keyword:a,dataProp:s,dataPropType:t.Type.Num},o),n.if((0,e.not)(o),i)})}},zu.validateUnion=function(r){const{gen:n,schema:s,keyword:a,it:i}=r;if(!Array.isArray(s))throw new Error("ajv implementation error");if(s.some(e=>(0,t.alwaysValidSchema)(i,e))&&!i.opts.unevaluated)return;const o=n.let("valid",!1),c=n.name("_valid");n.block(()=>s.forEach((t,s)=>{const i=r.subschema({keyword:a,schemaProp:s,compositeRule:!0},c);n.assign(o,e._`${o} || ${c}`),r.mergeValidEvaluated(i,c)||n.if((0,e.not)(o))})),r.result(o,()=>r.reset(),()=>r.error(!0))},zu}var Au,Mu,Zu,Du={},Lu={};function Fu(){return Zu||(Zu=1,Mu=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var n,s,a;if(Array.isArray(t)){if((n=t.length)!=r.length)return!1;for(s=n;0!==s--;)if(!e(t[s],r[s]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((n=(a=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(s=n;0!==s--;)if(!Object.prototype.hasOwnProperty.call(r,a[s]))return!1;for(s=n;0!==s--;){var i=a[s];if(!e(t[i],r[i]))return!1}return!0}return t!=t&&r!=r}),Mu}var qu,Uu,Vu,Hu={exports:{}};function Ju(){if(qu)return Hu.exports;qu=1;var e=Hu.exports=function(e,r,n){"function"==typeof r&&(n=r,r={}),t(r,"function"==typeof(n=r.cb||n)?n:n.pre||function(){},n.post||function(){},e,"",e)};function t(n,s,a,i,o,c,d,u,l,p){if(i&&"object"==typeof i&&!Array.isArray(i)){for(var f in s(i,o,c,d,u,l,p),i){var h=i[f];if(Array.isArray(h)){if(f in e.arrayKeywords)for(var m=0;m<h.length;m++)t(n,s,a,h[m],o+"/"+f+"/"+m,c,o,f,i,m)}else if(f in e.propsKeywords){if(h&&"object"==typeof h)for(var g in h)t(n,s,a,h[g],o+"/"+f+"/"+r(g),c,o,f,i,g)}else(f in e.keywords||n.allKeys&&!(f in e.skipKeywords))&&t(n,s,a,h,o+"/"+f,c,o,f,i)}a(i,o,c,d,u,l,p)}}function r(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}return e.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},e.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},e.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},e.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},Hu.exports}function Ku(){if(Uu)return Lu;Uu=1,Object.defineProperty(Lu,"__esModule",{value:!0}),Lu.getSchemaRefs=Lu.resolveUrl=Lu.normalizeId=Lu._getFullPath=Lu.getFullPath=Lu.inlineRef=void 0;const e=fu(),t=Fu(),r=Ju(),n=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);Lu.inlineRef=function(e,t=!0){return"boolean"==typeof e||(!0===t?!a(e):!!t&&i(e)<=t)};const s=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function a(e){for(const t in e){if(s.has(t))return!0;const r=e[t];if(Array.isArray(r)&&r.some(a))return!0;if("object"==typeof r&&a(r))return!0}return!1}function i(t){let r=0;for(const s in t){if("$ref"===s)return 1/0;if(r++,!n.has(s)&&("object"==typeof t[s]&&(0,e.eachItem)(t[s],e=>r+=i(e)),r===1/0))return 1/0}return r}function o(e,t="",r){!1!==r&&(t=u(t));const n=e.parse(t);return c(e,n)}function c(e,t){return e.serialize(t).split("#")[0]+"#"}Lu.getFullPath=o,Lu._getFullPath=c;const d=/#\/?$/;function u(e){return e?e.replace(d,""):""}Lu.normalizeId=u,Lu.resolveUrl=function(e,t,r){return r=u(r),e.resolve(t,r)};const l=/^[a-z_][-a-z0-9._]*$/i;return Lu.getSchemaRefs=function(e,n){if("boolean"==typeof e)return{};const{schemaId:s,uriResolver:a}=this.opts,i=u(e[s]||n),c={"":i},d=o(a,i,!1),p={},f=new Set;return r(e,{allKeys:!0},(e,t,r,n)=>{if(void 0===n)return;const a=d+t;let i=c[n];function o(t){const r=this.opts.uriResolver.resolve;if(t=u(i?r(i,t):t),f.has(t))throw m(t);f.add(t);let n=this.refs[t];return"string"==typeof n&&(n=this.refs[n]),"object"==typeof n?h(e,n.schema,t):t!==u(a)&&("#"===t[0]?(h(e,p[t],t),p[t]=e):this.refs[t]=a),t}function g(e){if("string"==typeof e){if(!l.test(e))throw new Error(`invalid anchor "${e}"`);o.call(this,`#${e}`)}}"string"==typeof e[s]&&(i=o.call(this,e[s])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),c[t]=i}),p;function h(e,r,n){if(void 0!==r&&!t(e,r))throw m(n)}function m(e){return new Error(`reference "${e}" resolves to more than one schema`)}},Lu}function Bu(){if(Vu)return eu;Vu=1,Object.defineProperty(eu,"__esModule",{value:!0}),eu.getData=eu.KeywordCxt=eu.validateFunctionCode=void 0;const e=function(){if(gu)return tu;gu=1,Object.defineProperty(tu,"__esModule",{value:!0}),tu.boolOrEmptySchema=tu.topBoolOrEmptySchema=void 0;const e=vu(),t=uu(),r=_u(),n={message:"boolean schema is false"};function s(t,r){const{gen:s,data:a}=t,i={gen:s,keyword:"false schema",data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,e.reportError)(i,n,void 0,r)}return tu.topBoolOrEmptySchema=function(e){const{gen:n,schema:a,validateName:i}=e;!1===a?s(e,!1):"object"==typeof a&&!0===a.$async?n.return(r.default.data):(n.assign(t._`${i}.errors`,null),n.return(!0))},tu.boolOrEmptySchema=function(e,t){const{gen:r,schema:n}=e;!1===n?(r.var(t,!1),s(e)):r.var(t,!0)},tu}(),t=Nu(),r=xu(),n=Nu(),s=function(){if(Pu)return ju;Pu=1,Object.defineProperty(ju,"__esModule",{value:!0}),ju.assignDefaults=void 0;const e=uu(),t=fu();function r(r,n,s){const{gen:a,compositeRule:i,data:o,opts:c}=r;if(void 0===s)return;const d=e._`${o}${(0,e.getProperty)(n)}`;if(i)return void(0,t.checkStrictMode)(r,`default is ignored for: ${d}`);let u=e._`${d} === undefined`;"empty"===c.useDefaults&&(u=e._`${u} || ${d} === null || ${d} === ""`),a.if(u,e._`${d} = ${(0,e.stringify)(s)}`)}return ju.assignDefaults=function(e,t){const{properties:n,items:s}=e.schema;if("object"===t&&n)for(const t in n)r(e,t,n[t].default);else"array"===t&&Array.isArray(s)&&s.forEach((t,n)=>r(e,n,t.default))},ju}(),a=function(){if(Iu)return Ru;Iu=1,Object.defineProperty(Ru,"__esModule",{value:!0}),Ru.validateKeywordUsage=Ru.validSchemaType=Ru.funcKeywordCode=Ru.macroKeywordCode=void 0;const e=uu(),t=_u(),r=Cu(),n=vu();function s(t){const{gen:r,data:n,it:s}=t;r.if(s.parentData,()=>r.assign(n,e._`${s.parentData}[${s.parentDataProperty}]`))}function a(t,r,n){if(void 0===n)throw new Error(`keyword "${r}" failed to compile`);return t.scopeValue("keyword","function"==typeof n?{ref:n}:{ref:n,code:(0,e.stringify)(n)})}return Ru.macroKeywordCode=function(t,r){const{gen:n,keyword:s,schema:i,parentSchema:o,it:c}=t,d=r.macro.call(c.self,i,o,c),u=a(n,s,d);!1!==c.opts.validateSchema&&c.self.validateSchema(d,!0);const l=n.name("valid");t.subschema({schema:d,schemaPath:e.nil,errSchemaPath:`${c.errSchemaPath}/${s}`,topSchemaRef:u,compositeRule:!0},l),t.pass(l,()=>t.error(!0))},Ru.funcKeywordCode=function(i,o){var c;const{gen:d,keyword:u,schema:l,parentSchema:p,$data:f,it:h}=i;!function({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}(h,o);const m=!f&&o.compile?o.compile.call(h.self,l,p,h):o.validate,g=a(d,u,m),y=d.let("valid");function _(n=(o.async?e._`await `:e.nil)){const s=h.opts.passContext?t.default.this:t.default.self,a=!("compile"in o&&!f||!1===o.schema);d.assign(y,e._`${n}${(0,r.callValidateCode)(i,g,s,a)}`,o.modifying)}function v(t){var r;d.if((0,e.not)(null!==(r=o.valid)&&void 0!==r?r:y),t)}i.block$data(y,function(){if(!1===o.errors)_(),o.modifying&&s(i),v(()=>i.error());else{const r=o.async?function(){const t=d.let("ruleErrs",null);return d.try(()=>_(e._`await `),r=>d.assign(y,!1).if(e._`${r} instanceof ${h.ValidationError}`,()=>d.assign(t,e._`${r}.errors`),()=>d.throw(r))),t}():function(){const t=e._`${g}.errors`;return d.assign(t,null),_(e.nil),t}();o.modifying&&s(i),v(()=>function(r,s){const{gen:a}=r;a.if(e._`Array.isArray(${s})`,()=>{a.assign(t.default.vErrors,e._`${t.default.vErrors} === null ? ${s} : ${t.default.vErrors}.concat(${s})`).assign(t.default.errors,e._`${t.default.vErrors}.length`),(0,n.extendErrors)(r)},()=>r.error())}(i,r))}}),i.ok(null!==(c=o.valid)&&void 0!==c?c:y)},Ru.validSchemaType=function(e,t,r=!1){return!t.length||t.some(t=>"array"===t?Array.isArray(e):"object"===t?e&&"object"==typeof e&&!Array.isArray(e):typeof e==t||r&&void 0===e)},Ru.validateKeywordUsage=function({schema:e,opts:t,self:r,errSchemaPath:n},s,a){if(Array.isArray(s.keyword)?!s.keyword.includes(a):s.keyword!==a)throw new Error("ajv implementation error");const i=s.dependencies;if(null==i?void 0:i.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw new Error(`parent schema must have dependencies of ${a}: ${i.join(",")}`);if(s.validateSchema&&!s.validateSchema(e[a])){const e=`keyword "${a}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if("log"!==t.validateSchema)throw new Error(e);r.logger.error(e)}},Ru}(),i=function(){if(Au)return Du;Au=1,Object.defineProperty(Du,"__esModule",{value:!0}),Du.extendSubschemaMode=Du.extendSubschemaData=Du.getSubschema=void 0;const e=uu(),t=fu();return Du.getSubschema=function(r,{keyword:n,schemaProp:s,schema:a,schemaPath:i,errSchemaPath:o,topSchemaRef:c}){if(void 0!==n&&void 0!==a)throw new Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==n){const a=r.schema[n];return void 0===s?{schema:a,schemaPath:e._`${r.schemaPath}${(0,e.getProperty)(n)}`,errSchemaPath:`${r.errSchemaPath}/${n}`}:{schema:a[s],schemaPath:e._`${r.schemaPath}${(0,e.getProperty)(n)}${(0,e.getProperty)(s)}`,errSchemaPath:`${r.errSchemaPath}/${n}/${(0,t.escapeFragment)(s)}`}}if(void 0!==a){if(void 0===i||void 0===o||void 0===c)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:a,schemaPath:i,topSchemaRef:c,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')},Du.extendSubschemaData=function(r,n,{dataProp:s,dataPropType:a,data:i,dataTypes:o,propertyName:c}){if(void 0!==i&&void 0!==s)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:d}=n;if(void 0!==s){const{errorPath:i,dataPathArr:o,opts:c}=n;u(d.let("data",e._`${n.data}${(0,e.getProperty)(s)}`,!0)),r.errorPath=e.str`${i}${(0,t.getErrorPath)(s,a,c.jsPropertySyntax)}`,r.parentDataProperty=e._`${s}`,r.dataPathArr=[...o,r.parentDataProperty]}function u(e){r.data=e,r.dataLevel=n.dataLevel+1,r.dataTypes=[],n.definedProperties=new Set,r.parentData=n.data,r.dataNames=[...n.dataNames,e]}void 0!==i&&(u(i instanceof e.Name?i:d.let("data",i,!0)),void 0!==c&&(r.propertyName=c)),o&&(r.dataTypes=o)},Du.extendSubschemaMode=function(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:a}){void 0!==n&&(e.compositeRule=n),void 0!==s&&(e.createErrors=s),void 0!==a&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=r},Du}(),o=uu(),c=_u(),d=Ku(),u=fu(),l=vu();function p({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},a){s.code.es5?e.func(t,o._`${c.default.data}, ${c.default.valCxt}`,n.$async,()=>{e.code(o._`"use strict"; ${f(r,s)}`),function(e,t){e.if(c.default.valCxt,()=>{e.var(c.default.instancePath,o._`${c.default.valCxt}.${c.default.instancePath}`),e.var(c.default.parentData,o._`${c.default.valCxt}.${c.default.parentData}`),e.var(c.default.parentDataProperty,o._`${c.default.valCxt}.${c.default.parentDataProperty}`),e.var(c.default.rootData,o._`${c.default.valCxt}.${c.default.rootData}`),t.dynamicRef&&e.var(c.default.dynamicAnchors,o._`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{e.var(c.default.instancePath,o._`""`),e.var(c.default.parentData,o._`undefined`),e.var(c.default.parentDataProperty,o._`undefined`),e.var(c.default.rootData,c.default.data),t.dynamicRef&&e.var(c.default.dynamicAnchors,o._`{}`)})}(e,s),e.code(a)}):e.func(t,o._`${c.default.data}, ${function(e){return o._`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${e.dynamicRef?o._`, ${c.default.dynamicAnchors}={}`:o.nil}}={}`}(s)}`,n.$async,()=>e.code(f(r,s)).code(a))}function f(e,t){const r="object"==typeof e&&e[t.schemaId];return r&&(t.code.source||t.code.process)?o._`/*# sourceURL=${r} */`:o.nil}function h({schema:e,self:t}){if("boolean"==typeof e)return!e;for(const r in e)if(t.RULES.all[r])return!0;return!1}function m(e){return"boolean"!=typeof e.schema}function g(e){(0,u.checkUnknownRules)(e),function(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,u.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}(e)}function y(e,r){if(e.opts.jtd)return v(e,[],!1,r);const n=(0,t.getSchemaTypes)(e.schema);v(e,n,!(0,t.coerceAndCheckDataType)(e,n),r)}function _({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){const a=r.$comment;if(!0===s.$comment)e.code(o._`${c.default.self}.logger.log(${a})`);else if("function"==typeof s.$comment){const r=o.str`${n}/$comment`,s=e.scopeValue("root",{ref:t.root});e.code(o._`${c.default.self}.opts.$comment(${a}, ${r}, ${s}.schema)`)}}function v(e,t,s,a){const{gen:i,schema:d,data:l,allErrors:p,opts:f,self:h}=e,{RULES:m}=h;function g(u){(0,r.shouldUseGroup)(d,u)&&(u.type?(i.if((0,n.checkDataType)(u.type,l,f.strictNumbers)),w(e,u),1===t.length&&t[0]===u.type&&s&&(i.else(),(0,n.reportTypeError)(e)),i.endIf()):w(e,u),p||i.if(o._`${c.default.errors} === ${a||0}`))}!d.$ref||!f.ignoreKeywordsWithRef&&(0,u.schemaHasRulesButRef)(d,m)?(f.jtd||function(e,t){!e.schemaEnv.meta&&e.opts.strictTypes&&(function(e,t){t.length&&(e.dataTypes.length?(t.forEach(t=>{b(e.dataTypes,t)||k(e,`type "${t}" not allowed by context "${e.dataTypes.join(",")}"`)}),function(e,t){const r=[];for(const n of e.dataTypes)b(t,n)?r.push(n):t.includes("integer")&&"number"===n&&r.push("integer");e.dataTypes=r}(e,t)):e.dataTypes=t)}(e,t),e.opts.allowUnionTypes||function(e,t){t.length>1&&(2!==t.length||!t.includes("null"))&&k(e,"use allowUnionTypes to allow union type keyword")}(e,t),function(e,t){const n=e.self.RULES.all;for(const s in n){const a=n[s];if("object"==typeof a&&(0,r.shouldUseRule)(e.schema,a)){const{type:r}=a.definition;r.length&&!r.some(e=>{return n=e,(r=t).includes(n)||"number"===n&&r.includes("integer");var r,n})&&k(e,`missing type "${r.join(",")}" for keyword "${s}"`)}}}(e,e.dataTypes))}(e,t),i.block(()=>{for(const e of m.rules)g(e);g(m.post)})):i.block(()=>S(e,"$ref",m.all.$ref.definition))}function w(e,t){const{gen:n,schema:a,opts:{useDefaults:i}}=e;i&&(0,s.assignDefaults)(e,t.type),n.block(()=>{for(const n of t.rules)(0,r.shouldUseRule)(a,n)&&S(e,n.keyword,n.definition,t.type)})}function b(e,t){return e.includes(t)||"integer"===t&&e.includes("number")}function k(e,t){t+=` at "${e.schemaEnv.baseId+e.errSchemaPath}" (strictTypes)`,(0,u.checkStrictMode)(e,t,e.opts.strictTypes)}eu.validateFunctionCode=function(t){m(t)&&(g(t),h(t))?function(e){const{schema:t,opts:r,gen:n}=e;p(e,()=>{r.$comment&&t.$comment&&_(e),function(e){const{schema:t,opts:r}=e;void 0!==t.default&&r.useDefaults&&r.strictSchema&&(0,u.checkStrictMode)(e,"default is ignored in the schema root")}(e),n.let(c.default.vErrors,null),n.let(c.default.errors,0),r.unevaluated&&function(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",o._`${r}.evaluated`),t.if(o._`${e.evaluated}.dynamicProps`,()=>t.assign(o._`${e.evaluated}.props`,o._`undefined`)),t.if(o._`${e.evaluated}.dynamicItems`,()=>t.assign(o._`${e.evaluated}.items`,o._`undefined`))}(e),y(e),function(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:a}=e;r.$async?t.if(o._`${c.default.errors} === 0`,()=>t.return(c.default.data),()=>t.throw(o._`new ${s}(${c.default.vErrors})`)):(t.assign(o._`${n}.errors`,c.default.vErrors),a.unevaluated&&function({gen:e,evaluated:t,props:r,items:n}){r instanceof o.Name&&e.assign(o._`${t}.props`,r),n instanceof o.Name&&e.assign(o._`${t}.items`,n)}(e),t.return(o._`${c.default.errors} === 0`))}(e)})}(t):p(t,()=>(0,e.topBoolOrEmptySchema)(t))};class ${constructor(e,t,r){if((0,a.validateKeywordUsage)(e,t,r),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=r,this.data=e.data,this.schema=e.schema[r],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,u.schemaRefOrVal)(e,this.schema,r,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",x(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,a.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:!1!==t.errors)&&(this.errsCount=e.gen.const("_errs",c.default.errors))}result(e,t,r){this.failResult((0,o.not)(e),t,r)}failResult(e,t,r){this.gen.if(e),r?r():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,o.not)(e),void 0,t)}fail(e){if(void 0===e)return this.error(),void(this.allErrors||this.gen.if(!1));this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:t}=this;this.fail(o._`${t} !== undefined && (${(0,o.or)(this.invalid$data(),e)})`)}error(e,t,r){if(t)return this.setParams(t),this._error(e,r),void this.setParams({});this._error(e,r)}_error(e,t){(e?l.reportExtraError:l.reportError)(this,this.def.error,t)}$dataError(){(0,l.reportError)(this,this.def.$dataError||l.keyword$DataError)}reset(){if(void 0===this.errsCount)throw new Error('add "trackErrors" to keyword definition');(0,l.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,r=o.nil){this.gen.block(()=>{this.check$data(e,r),t()})}check$data(e=o.nil,t=o.nil){if(!this.$data)return;const{gen:r,schemaCode:n,schemaType:s,def:a}=this;r.if((0,o.or)(o._`${n} === undefined`,t)),e!==o.nil&&r.assign(e,!0),(s.length||a.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),e!==o.nil&&r.assign(e,!1)),r.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:r,def:s,it:a}=this;return(0,o.or)(function(){if(r.length){if(!(t instanceof o.Name))throw new Error("ajv implementation error");const e=Array.isArray(r)?r:[r];return o._`${(0,n.checkDataTypes)(e,t,a.opts.strictNumbers,n.DataType.Wrong)}`}return o.nil}(),function(){if(s.validateSchema){const r=e.scopeValue("validate$data",{ref:s.validateSchema});return o._`!${r}(${t})`}return o.nil}())}subschema(t,r){const n=(0,i.getSubschema)(this.it,t);(0,i.extendSubschemaData)(n,this.it,t),(0,i.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return function(t,r){m(t)&&(g(t),h(t))?function(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&_(e),function(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,d.resolveUrl)(e.opts.uriResolver,e.baseId,t))}(e),function(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}(e);const a=n.const("_errs",c.default.errors);y(e,a),n.var(t,o._`${a} === ${c.default.errors}`)}(t,r):(0,e.boolOrEmptySchema)(t,r)}(s,r),s}mergeEvaluated(e,t){const{it:r,gen:n}=this;r.opts.unevaluated&&(!0!==r.props&&void 0!==e.props&&(r.props=u.mergeEvaluated.props(n,e.props,r.props,t)),!0!==r.items&&void 0!==e.items&&(r.items=u.mergeEvaluated.items(n,e.items,r.items,t)))}mergeValidEvaluated(e,t){const{it:r,gen:n}=this;if(r.opts.unevaluated&&(!0!==r.props||!0!==r.items))return n.if(t,()=>this.mergeEvaluated(e,o.Name)),!0}}function S(e,t,r,n){const s=new $(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,a.funcKeywordCode)(s,r):"macro"in r?(0,a.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,a.funcKeywordCode)(s,r)}eu.KeywordCxt=$;const E=/^\/(?:[^~]|~0|~1)*$/,T=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function x(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,a;if(""===e)return c.default.rootData;if("/"===e[0]){if(!E.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,a=c.default.rootData}else{const i=T.exec(e);if(!i)throw new Error(`Invalid JSON-pointer: ${e}`);const o=+i[1];if(s=i[2],"#"===s){if(o>=t)throw new Error(l("property/index",o));return n[t-o]}if(o>t)throw new Error(l("data",o));if(a=r[t-o],!s)return a}let i=a;const d=s.split("/");for(const e of d)e&&(a=o._`${a}${(0,o.getProperty)((0,u.unescapeJsonPointer)(e))}`,i=o._`${i} && ${a}`);return i;function l(e,r){return`Cannot access ${e} ${r} levels up, current level is ${t}`}}return eu.getData=x,eu}var Gu,Wu={};function Xu(){if(Gu)return Wu;Gu=1,Object.defineProperty(Wu,"__esModule",{value:!0});class e extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}}return Wu.default=e,Wu}var Yu,Qu={};function el(){if(Yu)return Qu;Yu=1,Object.defineProperty(Qu,"__esModule",{value:!0});const e=Ku();class t extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,e.resolveUrl)(t,r,n),this.missingSchema=(0,e.normalizeId)((0,e.getFullPath)(t,this.missingRef))}}return Qu.default=t,Qu}var tl,rl={};function nl(){if(tl)return rl;tl=1,Object.defineProperty(rl,"__esModule",{value:!0}),rl.resolveSchema=rl.getCompilingSchema=rl.resolveRef=rl.compileSchema=rl.SchemaEnv=void 0;const e=uu(),t=Xu(),r=_u(),n=Ku(),s=fu(),a=Bu();class i{constructor(e){var t;let r;this.refs={},this.dynamicAnchors={},"object"==typeof e.schema&&(r=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=null!==(t=e.baseId)&&void 0!==t?t:(0,n.normalizeId)(null==r?void 0:r[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=null==r?void 0:r.$async,this.refs={}}}function o(s){const i=d.call(this,s);if(i)return i;const o=(0,n.getFullPath)(this.opts.uriResolver,s.root.baseId),{es5:c,lines:u}=this.opts.code,{ownProperties:l}=this.opts,p=new e.CodeGen(this.scope,{es5:c,lines:u,ownProperties:l});let f;s.$async&&(f=p.scopeValue("Error",{ref:t.default,code:e._`require("ajv/dist/runtime/validation_error").default`}));const h=p.scopeName("validate");s.validateName=h;const m={gen:p,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[e.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:p.scopeValue("schema",!0===this.opts.code.source?{ref:s.schema,code:(0,e.stringify)(s.schema)}:{ref:s.schema}),validateName:h,ValidationError:f,schema:s.schema,schemaEnv:s,rootId:o,baseId:s.baseId||o,schemaPath:e.nil,errSchemaPath:s.schemaPath||(this.opts.jtd?"":"#"),errorPath:e._`""`,opts:this.opts,self:this};let g;try{this._compilations.add(s),(0,a.validateFunctionCode)(m),p.optimize(this.opts.code.optimize);const t=p.toString();g=`${p.scopeRefs(r.default.scope)}return ${t}`,this.opts.code.process&&(g=this.opts.code.process(g,s));const n=new Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(h,{ref:n}),n.errors=null,n.schema=s.schema,n.schemaEnv=s,s.$async&&(n.$async=!0),!0===this.opts.code.source&&(n.source={validateName:h,validateCode:t,scopeValues:p._values}),this.opts.unevaluated){const{props:t,items:r}=m;n.evaluated={props:t instanceof e.Name?void 0:t,items:r instanceof e.Name?void 0:r,dynamicProps:t instanceof e.Name,dynamicItems:r instanceof e.Name},n.source&&(n.source.evaluated=(0,e.stringify)(n.evaluated))}return s.validate=n,s}catch(e){throw delete s.validate,delete s.validateName,g&&this.logger.error("Error compiling schema, function code:",g),e}finally{this._compilations.delete(s)}}function c(e){return(0,n.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:o.call(this,e)}function d(e){for(const t of this._compilations)if(u(t,e))return t}function u(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function l(e,t){let r;for(;"string"==typeof(r=this.refs[t]);)t=r;return r||this.schemas[t]||p.call(this,e,t)}function p(e,t){const r=this.opts.uriResolver.parse(t),s=(0,n._getFullPath)(this.opts.uriResolver,r);let a=(0,n.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&s===a)return h.call(this,r,e);const c=(0,n.normalizeId)(s),d=this.refs[c]||this.schemas[c];if("string"==typeof d){const t=p.call(this,e,d);if("object"!=typeof(null==t?void 0:t.schema))return;return h.call(this,r,t)}if("object"==typeof(null==d?void 0:d.schema)){if(d.validate||o.call(this,d),c===(0,n.normalizeId)(t)){const{schema:t}=d,{schemaId:r}=this.opts,s=t[r];return s&&(a=(0,n.resolveUrl)(this.opts.uriResolver,a,s)),new i({schema:t,schemaId:r,root:e,baseId:a})}return h.call(this,r,d)}}rl.SchemaEnv=i,rl.compileSchema=o,rl.resolveRef=function(e,t,r){var s;r=(0,n.resolveUrl)(this.opts.uriResolver,t,r);const a=e.refs[r];if(a)return a;let o=l.call(this,e,r);if(void 0===o){const n=null===(s=e.localRefs)||void 0===s?void 0:s[r],{schemaId:a}=this.opts;n&&(o=new i({schema:n,schemaId:a,root:e,baseId:t}))}return void 0!==o?e.refs[r]=c.call(this,o):void 0},rl.getCompilingSchema=d,rl.resolveSchema=p;const f=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function h(e,{baseId:t,schema:r,root:a}){var o;if("/"!==(null===(o=e.fragment)||void 0===o?void 0:o[0]))return;for(const a of e.fragment.slice(1).split("/")){if("boolean"==typeof r)return;const e=r[(0,s.unescapeFragment)(a)];if(void 0===e)return;const i="object"==typeof(r=e)&&r[this.opts.schemaId];!f.has(a)&&i&&(t=(0,n.resolveUrl)(this.opts.uriResolver,t,i))}let c;if("boolean"!=typeof r&&r.$ref&&!(0,s.schemaHasRulesButRef)(r,this.RULES)){const e=(0,n.resolveUrl)(this.opts.uriResolver,t,r.$ref);c=p.call(this,a,e)}const{schemaId:d}=this.opts;return c=c||new i({schema:r,schemaId:d,root:a,baseId:t}),c.schema!==c.root.schema?c:void 0}return rl}var sl,al,il,ol,cl,dl,ul,ll={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1},pl={},fl={exports:{}};function hl(){if(al)return sl;al=1;const e=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),t=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function r(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),48!==r){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}const n=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function s(e){return e.length=0,!0}function a(e,t,n){if(e.length){const s=r(e);if(""===s)return n.error=!0,!1;t.push(s),e.length=0}return!0}function i(e){if(function(e){let t=0;for(let r=0;r<e.length;r++)":"===e[r]&&t++;return t}(e)<2)return{host:e,isIPV6:!1};const t=function(e){let t=0;const n={error:!1,address:"",zone:""},i=[],o=[];let c=!1,d=!1,u=a;for(let r=0;r<e.length;r++){const a=e[r];if("["!==a&&"]"!==a)if(":"!==a)if("%"===a){if(!u(o,i,n))break;u=s}else o.push(a);else{if(!0===c&&(d=!0),!u(o,i,n))break;if(++t>7){n.error=!0;break}r>0&&":"===e[r-1]&&(c=!0),i.push(":")}}return o.length&&(u===s?n.zone=o.join(""):d?i.push(o.join("")):i.push(r(o))),n.address=i.join(""),n}(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,r=t.address;return t.zone&&(e+="%"+t.zone,r+="%25"+t.zone),{host:e,isIPV6:!0,escapedHost:r}}}return sl={nonSimpleDomain:n,recomposeAuthority:function(e){const r=[];if(void 0!==e.userinfo&&(r.push(e.userinfo),r.push("@")),void 0!==e.host){let n=unescape(e.host);if(!t(n)){const t=i(n);n=!0===t.isIPV6?`[${t.escapedHost}]`:e.host}r.push(n)}return"number"!=typeof e.port&&"string"!=typeof e.port||(r.push(":"),r.push(String(e.port))),r.length?r.join(""):void 0},normalizeComponentEncoding:function(e,t){const r=!0!==t?escape:unescape;return void 0!==e.scheme&&(e.scheme=r(e.scheme)),void 0!==e.userinfo&&(e.userinfo=r(e.userinfo)),void 0!==e.host&&(e.host=r(e.host)),void 0!==e.path&&(e.path=r(e.path)),void 0!==e.query&&(e.query=r(e.query)),void 0!==e.fragment&&(e.fragment=r(e.fragment)),e},removeDotSegments:function(e){let t=e;const r=[];let n=-1,s=0;for(;s=t.length;){if(1===s){if("."===t)break;if("/"===t){r.push("/");break}r.push(t);break}if(2===s){if("."===t[0]){if("."===t[1])break;if("/"===t[1]){t=t.slice(2);continue}}else if("/"===t[0]&&("."===t[1]||"/"===t[1])){r.push("/");break}}else if(3===s&&"/.."===t){0!==r.length&&r.pop(),r.push("/");break}if("."===t[0]){if("."===t[1]){if("/"===t[2]){t=t.slice(3);continue}}else if("/"===t[1]){t=t.slice(2);continue}}else if("/"===t[0]&&"."===t[1]){if("/"===t[2]){t=t.slice(2);continue}if("."===t[2]&&"/"===t[3]){t=t.slice(3),0!==r.length&&r.pop();continue}}if(-1===(n=t.indexOf("/",1))){r.push(t);break}r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")},isIPv4:t,isUUID:e,normalizeIPv6:i,stringArrayToHexStripped:r},sl}function ml(){return ul||(ul=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Bu();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=uu();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=Xu(),s=el(),a=$u(),i=nl(),o=uu(),c=Ku(),d=Nu(),u=fu(),l=ll,p=function(){if(dl)return pl;dl=1,Object.defineProperty(pl,"__esModule",{value:!0});const e=function(){if(cl)return fl.exports;cl=1;const{normalizeIPv6:e,removeDotSegments:t,recomposeAuthority:r,normalizeComponentEncoding:n,isIPv4:s,nonSimpleDomain:a}=hl(),{SCHEMES:i,getSchemeHandler:o}=function(){if(ol)return il;ol=1;const{isUUID:e}=hl(),t=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,r=["http","https","ws","wss","urn","urn:uuid"];function n(e){return!0===e.secure||!1!==e.secure&&!!e.scheme&&!(3!==e.scheme.length||"w"!==e.scheme[0]&&"W"!==e.scheme[0]||"s"!==e.scheme[1]&&"S"!==e.scheme[1]||"s"!==e.scheme[2]&&"S"!==e.scheme[2])}function s(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function a(e){const t="https"===String(e.scheme).toLowerCase();return e.port!==(t?443:80)&&""!==e.port||(e.port=void 0),e.path||(e.path="/"),e}const i={scheme:"http",domainHost:!0,parse:s,serialize:a},o={scheme:"ws",domainHost:!0,parse:function(e){return e.secure=n(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e},serialize:function(e){if(e.port!==(n(e)?443:80)&&""!==e.port||(e.port=void 0),"boolean"==typeof e.secure&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){const[t,r]=e.resourceName.split("?");e.path=t&&"/"!==t?t:void 0,e.query=r,e.resourceName=void 0}return e.fragment=void 0,e}},c={http:i,https:{scheme:"https",domainHost:i.domainHost,parse:s,serialize:a},ws:o,wss:{scheme:"wss",domainHost:o.domainHost,parse:o.parse,serialize:o.serialize},urn:{scheme:"urn",parse:function(e,r){if(!e.path)return e.error="URN can not be parsed",e;const n=e.path.match(t);if(n){const t=r.scheme||e.scheme||"urn";e.nid=n[1].toLowerCase(),e.nss=n[2];const s=d(`${t}:${r.nid||e.nid}`);e.path=void 0,s&&(e=s.parse(e,r))}else e.error=e.error||"URN can not be parsed.";return e},serialize:function(e,t){if(void 0===e.nid)throw new Error("URN without nid cannot be serialized");const r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),s=d(`${r}:${t.nid||n}`);s&&(e=s.serialize(e,t));const a=e,i=e.nss;return a.path=`${n||t.nid}:${i}`,t.skipEscape=!0,a},skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:function(t,r){const n=t;return n.uuid=n.nss,n.nss=void 0,r.tolerant||n.uuid&&e(n.uuid)||(n.error=n.error||"UUID is not valid."),n},serialize:function(e){const t=e;return t.nss=(e.uuid||"").toLowerCase(),t},skipNormalize:!0}};function d(e){return e&&(c[e]||c[e.toLowerCase()])||void 0}return Object.setPrototypeOf(c,null),il={wsIsSecure:n,SCHEMES:c,isValidSchemeName:function(e){return-1!==r.indexOf(e)},getSchemeHandler:d}}();function c(e,r,n,s){const a={};return s||(e=l(d(e,n),n),r=l(d(r,n),n)),!(n=n||{}).tolerant&&r.scheme?(a.scheme=r.scheme,a.userinfo=r.userinfo,a.host=r.host,a.port=r.port,a.path=t(r.path||""),a.query=r.query):(void 0!==r.userinfo||void 0!==r.host||void 0!==r.port?(a.userinfo=r.userinfo,a.host=r.host,a.port=r.port,a.path=t(r.path||""),a.query=r.query):(r.path?("/"===r.path[0]?a.path=t(r.path):(void 0===e.userinfo&&void 0===e.host&&void 0===e.port||e.path?e.path?a.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+r.path:a.path=r.path:a.path="/"+r.path,a.path=t(a.path)),a.query=r.query):(a.path=e.path,void 0!==r.query?a.query=r.query:a.query=e.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=r.fragment,a}function d(e,n){const s={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},a=Object.assign({},n),i=[],c=o(a.scheme||s.scheme);c&&c.serialize&&c.serialize(s,a),void 0!==s.path&&(a.skipEscape?s.path=unescape(s.path):(s.path=escape(s.path),void 0!==s.scheme&&(s.path=s.path.split("%3A").join(":")))),"suffix"!==a.reference&&s.scheme&&i.push(s.scheme,":");const d=r(s);if(void 0!==d&&("suffix"!==a.reference&&i.push("//"),i.push(d),s.path&&"/"!==s.path[0]&&i.push("/")),void 0!==s.path){let e=s.path;a.absolutePath||c&&c.absolutePath||(e=t(e)),void 0===d&&"/"===e[0]&&"/"===e[1]&&(e="/%2F"+e.slice(2)),i.push(e)}return void 0!==s.query&&i.push("?",s.query),void 0!==s.fragment&&i.push("#",s.fragment),i.join("")}const u=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function l(t,r){const n=Object.assign({},r),i={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let c=!1;"suffix"===n.reference&&(t=n.scheme?n.scheme+":"+t:"//"+t);const d=t.match(u);if(d){if(i.scheme=d[1],i.userinfo=d[3],i.host=d[4],i.port=parseInt(d[5],10),i.path=d[6]||"",i.query=d[7],i.fragment=d[8],isNaN(i.port)&&(i.port=d[5]),i.host)if(!1===s(i.host)){const t=e(i.host);i.host=t.host.toLowerCase(),c=t.isIPV6}else c=!0;void 0!==i.scheme||void 0!==i.userinfo||void 0!==i.host||void 0!==i.port||void 0!==i.query||i.path?void 0===i.scheme?i.reference="relative":void 0===i.fragment?i.reference="absolute":i.reference="uri":i.reference="same-document",n.reference&&"suffix"!==n.reference&&n.reference!==i.reference&&(i.error=i.error||"URI is not a "+n.reference+" reference.");const r=o(n.scheme||i.scheme);if(!(n.unicodeSupport||r&&r.unicodeSupport)&&i.host&&(n.domainHost||r&&r.domainHost)&&!1===c&&a(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(e){i.error=i.error||"Host's domain name can not be converted to ASCII: "+e}(!r||r&&!r.skipNormalize)&&(-1!==t.indexOf("%")&&(void 0!==i.scheme&&(i.scheme=unescape(i.scheme)),void 0!==i.host&&(i.host=unescape(i.host))),i.path&&(i.path=escape(unescape(i.path))),i.fragment&&(i.fragment=encodeURI(decodeURIComponent(i.fragment)))),r&&r.parse&&r.parse(i,n)}else i.error=i.error||"URI can not be parsed.";return i}const p={SCHEMES:i,normalize:function(e,t){return"string"==typeof e?e=d(l(e,t),t):"object"==typeof e&&(e=l(d(e,t),t)),e},resolve:function(e,t,r){const n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=c(l(e,n),l(t,n),n,!0);return n.skipEscape=!0,d(s,n)},resolveComponent:c,equal:function(e,t,r){return"string"==typeof e?(e=unescape(e),e=d(n(l(e,r),!0),{...r,skipEscape:!0})):"object"==typeof e&&(e=d(n(e,!0),{...r,skipEscape:!0})),"string"==typeof t?(t=unescape(t),t=d(n(l(t,r),!0),{...r,skipEscape:!0})):"object"==typeof t&&(t=d(n(t,!0),{...r,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()},serialize:d,parse:l};return fl.exports=p,fl.exports.default=p,fl.exports.fastUri=p,fl.exports}();return e.code='require("ajv/dist/runtime/uri").default',pl.default=e,pl}(),f=(e,t)=>new RegExp(e,t);f.code="new RegExp";const h=["removeAdditional","useDefaults","coerceTypes"],m=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),g={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},y={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};function _(e){var t,r,n,s,a,i,o,c,d,u,l,h,m,g,y,_,v,w,b,k,$,S,E,T,x;const N=e.strict,P=null===(t=e.code)||void 0===t?void 0:t.optimize,O=!0===P||void 0===P?1:P||0,I=null!==(n=null===(r=e.code)||void 0===r?void 0:r.regExp)&&void 0!==n?n:f,j=null!==(s=e.uriResolver)&&void 0!==s?s:p.default;return{strictSchema:null===(i=null!==(a=e.strictSchema)&&void 0!==a?a:N)||void 0===i||i,strictNumbers:null===(c=null!==(o=e.strictNumbers)&&void 0!==o?o:N)||void 0===c||c,strictTypes:null!==(u=null!==(d=e.strictTypes)&&void 0!==d?d:N)&&void 0!==u?u:"log",strictTuples:null!==(h=null!==(l=e.strictTuples)&&void 0!==l?l:N)&&void 0!==h?h:"log",strictRequired:null!==(g=null!==(m=e.strictRequired)&&void 0!==m?m:N)&&void 0!==g&&g,code:e.code?{...e.code,optimize:O,regExp:I}:{optimize:O,regExp:I},loopRequired:null!==(y=e.loopRequired)&&void 0!==y?y:200,loopEnum:null!==(_=e.loopEnum)&&void 0!==_?_:200,meta:null===(v=e.meta)||void 0===v||v,messages:null===(w=e.messages)||void 0===w||w,inlineRefs:null===(b=e.inlineRefs)||void 0===b||b,schemaId:null!==(k=e.schemaId)&&void 0!==k?k:"$id",addUsedSchema:null===($=e.addUsedSchema)||void 0===$||$,validateSchema:null===(S=e.validateSchema)||void 0===S||S,validateFormats:null===(E=e.validateFormats)||void 0===E||E,unicodeRegExp:null===(T=e.unicodeRegExp)||void 0===T||T,int32range:null===(x=e.int32range)||void 0===x||x,uriResolver:j}}class v{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,..._(e)};const{es5:t,lines:r}=this.opts.code;this.scope=new o.ValueScope({scope:{},prefixes:m,es5:t,lines:r}),this.logger=function(e){if(!1===e)return T;if(void 0===e)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}(e.logger);const n=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),w.call(this,g,e,"NOT SUPPORTED"),w.call(this,y,e,"DEPRECATED","warn"),this._metaOpts=E.call(this),e.formats&&$.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&S.call(this,e.keywords),"object"==typeof e.meta&&this.addMetaSchema(e.meta),k.call(this),e.validateFormats=n}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:e,meta:t,schemaId:r}=this.opts;let n=l;"id"===r&&(n={...l},n.id=n.$id,delete n.$id),t&&e&&this.addMetaSchema(n,n[r],!1)}defaultMeta(){const{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta="object"==typeof e?e[t]||e:void 0}validate(e,t){let r;if("string"==typeof e){if(r=this.getSchema(e),!r)throw new Error(`no schema with key or ref "${e}"`)}else r=this.compile(e);const n=r(t);return"$async"in r||(this.errors=r.errors),n}compile(e,t){const r=this._addSchema(e,t);return r.validate||this._compileSchemaEnv(r)}compileAsync(e,t){if("function"!=typeof this.opts.loadSchema)throw new Error("options.loadSchema should be a function");const{loadSchema:r}=this.opts;return n.call(this,e,t);async function n(e,t){await a.call(this,e.$schema);const r=this._addSchema(e,t);return r.validate||i.call(this,r)}async function a(e){e&&!this.getSchema(e)&&await n.call(this,{$ref:e},!0)}async function i(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof s.default))throw t;return o.call(this,t),await c.call(this,t.missingSchema),i.call(this,e)}}function o({missingSchema:e,missingRef:t}){if(this.refs[e])throw new Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){const r=await d.call(this,e);this.refs[e]||await a.call(this,r.$schema),this.refs[e]||this.addSchema(r,e,t)}async function d(e){const t=this._loading[e];if(t)return t;try{return await(this._loading[e]=r(e))}finally{delete this._loading[e]}}}addSchema(e,t,r,n=this.opts.validateSchema){if(Array.isArray(e)){for(const t of e)this.addSchema(t,void 0,r,n);return this}let s;if("object"==typeof e){const{schemaId:t}=this.opts;if(s=e[t],void 0!==s&&"string"!=typeof s)throw new Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||s),this._checkUnique(t),this.schemas[t]=this._addSchema(e,r,t,n,!0),this}addMetaSchema(e,t,r=this.opts.validateSchema){return this.addSchema(e,t,!0,r),this}validateSchema(e,t){if("boolean"==typeof e)return!0;let r;if(r=e.$schema,void 0!==r&&"string"!=typeof r)throw new Error("$schema must be a string");if(r=r||this.opts.defaultMeta||this.defaultMeta(),!r)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const n=this.validate(r,e);if(!n&&t){const e="schema is invalid: "+this.errorsText();if("log"!==this.opts.validateSchema)throw new Error(e);this.logger.error(e)}return n}getSchema(e){let t;for(;"string"==typeof(t=b.call(this,e));)e=t;if(void 0===t){const{schemaId:r}=this.opts,n=new i.SchemaEnv({schema:{},schemaId:r});if(t=i.resolveSchema.call(this,n,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const t=b.call(this,e);return"object"==typeof t&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{const t=e;this._cache.delete(t);let r=e[this.opts.schemaId];return r&&(r=(0,c.normalizeId)(r),delete this.schemas[r],delete this.refs[r]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(const t of e)this.addKeyword(t);return this}addKeyword(e,t){let r;if("string"==typeof e)r=e,"object"==typeof t&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),t.keyword=r);else{if("object"!=typeof e||void 0!==t)throw new Error("invalid addKeywords parameters");if(r=(t=e).keyword,Array.isArray(r)&&!r.length)throw new Error("addKeywords: keyword must be string or non-empty array")}if(N.call(this,r,t),!t)return(0,u.eachItem)(r,e=>P.call(this,e)),this;I.call(this,t);const n={...t,type:(0,d.getJSONTypes)(t.type),schemaType:(0,d.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(r,0===n.type.length?e=>P.call(this,e,n):e=>n.type.forEach(t=>P.call(this,e,n,t))),this}getKeyword(e){const t=this.RULES.all[e];return"object"==typeof t?t.definition:!!t}removeKeyword(e){const{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(const r of t.rules){const t=r.rules.findIndex(t=>t.keyword===e);t>=0&&r.rules.splice(t,1)}return this}addFormat(e,t){return"string"==typeof t&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=", ",dataVar:r="data"}={}){return e&&0!==e.length?e.map(e=>`${r}${e.instancePath} ${e.message}`).reduce((e,r)=>e+t+r):"No errors"}$dataMetaSchema(e,t){const r=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(const n of t){const t=n.split("/").slice(1);let s=e;for(const e of t)s=s[e];for(const e in r){const t=r[e];if("object"!=typeof t)continue;const{$data:n}=t.definition,a=s[e];n&&a&&(s[e]=R(a))}}return e}_removeAllSchemas(e,t){for(const r in e){const n=e[r];t&&!t.test(r)||("string"==typeof n?delete e[r]:n&&!n.meta&&(this._cache.delete(n.schema),delete e[r]))}}_addSchema(e,t,r,n=this.opts.validateSchema,s=this.opts.addUsedSchema){let a;const{schemaId:o}=this.opts;if("object"==typeof e)a=e[o];else{if(this.opts.jtd)throw new Error("schema must be object");if("boolean"!=typeof e)throw new Error("schema must be object or boolean")}let d=this._cache.get(e);if(void 0!==d)return d;r=(0,c.normalizeId)(a||r);const u=c.getSchemaRefs.call(this,e,r);return d=new i.SchemaEnv({schema:e,schemaId:o,meta:t,baseId:r,localRefs:u}),this._cache.set(d.schema,d),s&&!r.startsWith("#")&&(r&&this._checkUnique(r),this.refs[r]=d),n&&this.validateSchema(e,!0),d}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):i.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){const t=this.opts;this.opts=this._metaOpts;try{i.compileSchema.call(this,e)}finally{this.opts=t}}}function w(e,t,r,n="error"){for(const s in e){const a=s;a in t&&this.logger[n](`${r}: option ${s}. ${e[a]}`)}}function b(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function k(){const e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(const t in e)this.addSchema(e[t],t)}function $(){for(const e in this.opts.formats){const t=this.opts.formats[e];t&&this.addFormat(e,t)}}function S(e){if(Array.isArray(e))this.addVocabulary(e);else{this.logger.warn("keywords option as map is deprecated, pass array");for(const t in e){const r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}}function E(){const e={...this.opts};for(const t of h)delete e[t];return e}v.ValidationError=n.default,v.MissingRefError=s.default,e.default=v;const T={log(){},warn(){},error(){}},x=/^[a-z_$][a-z0-9_$:-]*$/i;function N(e,t){const{RULES:r}=this;if((0,u.eachItem)(e,e=>{if(r.keywords[e])throw new Error(`Keyword ${e} is already defined`);if(!x.test(e))throw new Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!("code"in t)&&!("validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function P(e,t,r){var n;const s=null==t?void 0:t.post;if(r&&s)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:a}=this;let i=s?a.post:a.rules.find(({type:e})=>e===r);if(i||(i={type:r,rules:[]},a.rules.push(i)),a.keywords[e]=!0,!t)return;const o={keyword:e,definition:{...t,type:(0,d.getJSONTypes)(t.type),schemaType:(0,d.getJSONTypes)(t.schemaType)}};t.before?O.call(this,i,o,t.before):i.rules.push(o),a.all[e]=o,null===(n=t.implements)||void 0===n||n.forEach(e=>this.addKeyword(e))}function O(e,t,r){const n=e.rules.findIndex(e=>e.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function I(e){let{metaSchema:t}=e;void 0!==t&&(e.$data&&this.opts.$data&&(t=R(t)),e.validateSchema=this.compile(t,!0))}const j={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function R(e){return{anyOf:[e,j]}}}(Qd)),Qd}var gl,yl,_l,vl={},wl={},bl={},kl={};var $l,Sl,El,Tl,xl={},Nl={},Pl={},Ol={},Il={};var jl,Rl,zl,Cl={},Al={},Ml={};var Zl,Dl,Ll,Fl={},ql={},Ul={};function Vl(){if(Dl)return Ul;Dl=1,Object.defineProperty(Ul,"__esModule",{value:!0});const e=Fu();return e.code='require("ajv/dist/runtime/equal").default',Ul.default=e,Ul}function Hl(){if(Ll)return ql;Ll=1,Object.defineProperty(ql,"__esModule",{value:!0});const e=Nu(),t=uu(),r=fu(),n=Vl(),s={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:e,j:r}})=>t.str`must NOT have duplicate items (items ## ${r} and ${e} are identical)`,params:({params:{i:e,j:r}})=>t._`{i: ${e}, j: ${r}}`},code(s){const{gen:a,data:i,$data:o,schema:c,parentSchema:d,schemaCode:u,it:l}=s;if(!o&&!c)return;const p=a.let("valid"),f=d.items?(0,e.getSchemaTypes)(d.items):[];function h(r,n){const o=a.name("item"),c=(0,e.checkDataTypes)(f,o,l.opts.strictNumbers,e.DataType.Wrong),d=a.const("indices",t._`{}`);a.for(t._`;${r}--;`,()=>{a.let(o,t._`${i}[${r}]`),a.if(c,t._`continue`),f.length>1&&a.if(t._`typeof ${o} == "string"`,t._`${o} += "_"`),a.if(t._`typeof ${d}[${o}] == "number"`,()=>{a.assign(n,t._`${d}[${o}]`),s.error(),a.assign(p,!1).break()}).code(t._`${d}[${o}] = ${r}`)})}function m(e,o){const c=(0,r.useFunc)(a,n.default),d=a.name("outer");a.label(d).for(t._`;${e}--;`,()=>a.for(t._`${o} = ${e}; ${o}--;`,()=>a.if(t._`${c}(${i}[${e}], ${i}[${o}])`,()=>{s.error(),a.assign(p,!1).break(d)})))}s.block$data(p,function(){const e=a.let("i",t._`${i}.length`),r=a.let("j");s.setParams({i:e,j:r}),a.assign(p,!0),a.if(t._`${e} > 1`,()=>(f.length>0&&!f.some(e=>"object"===e||"array"===e)?h:m)(e,r))},t._`${u} === false`),s.ok(p)}};return ql.default=s,ql}var Jl,Kl,Bl,Gl={},Wl={};function Xl(){if(Bl)return xl;Bl=1,Object.defineProperty(xl,"__esModule",{value:!0});const e=function(){if($l)return Nl;$l=1,Object.defineProperty(Nl,"__esModule",{value:!0});const e=uu(),t=e.operators,r={maximum:{okStr:"<=",ok:t.LTE,fail:t.GT},minimum:{okStr:">=",ok:t.GTE,fail:t.LT},exclusiveMaximum:{okStr:"<",ok:t.LT,fail:t.GTE},exclusiveMinimum:{okStr:">",ok:t.GT,fail:t.LTE}},n={message:({keyword:t,schemaCode:n})=>e.str`must be ${r[t].okStr} ${n}`,params:({keyword:t,schemaCode:n})=>e._`{comparison: ${r[t].okStr}, limit: ${n}}`},s={keyword:Object.keys(r),type:"number",schemaType:"number",$data:!0,error:n,code(t){const{keyword:n,data:s,schemaCode:a}=t;t.fail$data(e._`${s} ${r[n].fail} ${a} || isNaN(${s})`)}};return Nl.default=s,Nl}(),t=function(){if(Sl)return Pl;Sl=1,Object.defineProperty(Pl,"__esModule",{value:!0});const e=uu(),t={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:t})=>e.str`must be multiple of ${t}`,params:({schemaCode:t})=>e._`{multipleOf: ${t}}`},code(t){const{gen:r,data:n,schemaCode:s,it:a}=t,i=a.opts.multipleOfPrecision,o=r.let("res"),c=i?e._`Math.abs(Math.round(${o}) - ${o}) > 1e-${i}`:e._`${o} !== parseInt(${o})`;t.fail$data(e._`(${s} === 0 || (${o} = ${n}/${s}, ${c}))`)}};return Pl.default=t,Pl}(),r=function(){if(Tl)return Ol;Tl=1,Object.defineProperty(Ol,"__esModule",{value:!0});const e=uu(),t=fu(),r=function(){if(El)return Il;function e(e){const t=e.length;let r,n=0,s=0;for(;s<t;)n++,r=e.charCodeAt(s++),r>=55296&&r<=56319&&s<t&&(r=e.charCodeAt(s),56320==(64512&r)&&s++);return n}return El=1,Object.defineProperty(Il,"__esModule",{value:!0}),Il.default=e,e.code='require("ajv/dist/runtime/ucs2length").default',Il}(),n={message({keyword:t,schemaCode:r}){const n="maxLength"===t?"more":"fewer";return e.str`must NOT have ${n} than ${r} characters`},params:({schemaCode:t})=>e._`{limit: ${t}}`},s={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:n,code(n){const{keyword:s,data:a,schemaCode:i,it:o}=n,c="maxLength"===s?e.operators.GT:e.operators.LT,d=!1===o.opts.unicode?e._`${a}.length`:e._`${(0,t.useFunc)(n.gen,r.default)}(${a})`;n.fail$data(e._`${d} ${c} ${i}`)}};return Ol.default=s,Ol}(),n=function(){if(jl)return Cl;jl=1,Object.defineProperty(Cl,"__esModule",{value:!0});const e=Cu(),t=uu(),r={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>t.str`must match pattern "${e}"`,params:({schemaCode:e})=>t._`{pattern: ${e}}`},code(r){const{data:n,$data:s,schema:a,schemaCode:i,it:o}=r,c=o.opts.unicodeRegExp?"u":"",d=s?t._`(new RegExp(${i}, ${c}))`:(0,e.usePattern)(r,a);r.fail$data(t._`!${d}.test(${n})`)}};return Cl.default=r,Cl}(),s=function(){if(Rl)return Al;Rl=1,Object.defineProperty(Al,"__esModule",{value:!0});const e=uu(),t={message({keyword:t,schemaCode:r}){const n="maxProperties"===t?"more":"fewer";return e.str`must NOT have ${n} than ${r} properties`},params:({schemaCode:t})=>e._`{limit: ${t}}`},r={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:t,code(t){const{keyword:r,data:n,schemaCode:s}=t,a="maxProperties"===r?e.operators.GT:e.operators.LT;t.fail$data(e._`Object.keys(${n}).length ${a} ${s}`)}};return Al.default=r,Al}(),a=function(){if(zl)return Ml;zl=1,Object.defineProperty(Ml,"__esModule",{value:!0});const e=Cu(),t=uu(),r=fu(),n={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:e}})=>t.str`must have required property '${e}'`,params:({params:{missingProperty:e}})=>t._`{missingProperty: ${e}}`},code(n){const{gen:s,schema:a,schemaCode:i,data:o,$data:c,it:d}=n,{opts:u}=d;if(!c&&0===a.length)return;const l=a.length>=u.loopRequired;if(d.allErrors?function(){if(l||c)n.block$data(t.nil,p);else for(const t of a)(0,e.checkReportMissingProp)(n,t)}():function(){const r=s.let("missing");if(l||c){const a=s.let("valid",!0);n.block$data(a,()=>function(r,a){n.setParams({missingProperty:r}),s.forOf(r,i,()=>{s.assign(a,(0,e.propertyInData)(s,o,r,u.ownProperties)),s.if((0,t.not)(a),()=>{n.error(),s.break()})},t.nil)}(r,a)),n.ok(a)}else s.if((0,e.checkMissingProp)(n,a,r)),(0,e.reportMissingProp)(n,r),s.else()}(),u.strictRequired){const e=n.parentSchema.properties,{definedProperties:t}=n.it;for(const n of a)if(void 0===(null==e?void 0:e[n])&&!t.has(n)){const e=`required property "${n}" is not defined at "${d.schemaEnv.baseId+d.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(d,e,d.opts.strictRequired)}}function p(){s.forOf("prop",i,t=>{n.setParams({missingProperty:t}),s.if((0,e.noPropertyInData)(s,o,t,u.ownProperties),()=>n.error())})}}};return Ml.default=n,Ml}(),i=function(){if(Zl)return Fl;Zl=1,Object.defineProperty(Fl,"__esModule",{value:!0});const e=uu(),t={message({keyword:t,schemaCode:r}){const n="maxItems"===t?"more":"fewer";return e.str`must NOT have ${n} than ${r} items`},params:({schemaCode:t})=>e._`{limit: ${t}}`},r={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:t,code(t){const{keyword:r,data:n,schemaCode:s}=t,a="maxItems"===r?e.operators.GT:e.operators.LT;t.fail$data(e._`${n}.length ${a} ${s}`)}};return Fl.default=r,Fl}(),o=Hl(),c=function(){if(Jl)return Gl;Jl=1,Object.defineProperty(Gl,"__esModule",{value:!0});const e=uu(),t=fu(),r=Vl(),n={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:t})=>e._`{allowedValue: ${t}}`},code(n){const{gen:s,data:a,$data:i,schemaCode:o,schema:c}=n;i||c&&"object"==typeof c?n.fail$data(e._`!${(0,t.useFunc)(s,r.default)}(${a}, ${o})`):n.fail(e._`${c} !== ${a}`)}};return Gl.default=n,Gl}(),d=function(){if(Kl)return Wl;Kl=1,Object.defineProperty(Wl,"__esModule",{value:!0});const e=uu(),t=fu(),r=Vl(),n={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:t})=>e._`{allowedValues: ${t}}`},code(n){const{gen:s,data:a,$data:i,schema:o,schemaCode:c,it:d}=n;if(!i&&0===o.length)throw new Error("enum must have non-empty array");const u=o.length>=d.opts.loopEnum;let l;const p=()=>null!=l?l:l=(0,t.useFunc)(s,r.default);let f;if(u||i)f=s.let("valid"),n.block$data(f,function(){s.assign(f,!1),s.forOf("v",c,t=>s.if(e._`${p()}(${a}, ${t})`,()=>s.assign(f,!0).break()))});else{if(!Array.isArray(o))throw new Error("ajv implementation error");const t=s.const("vSchema",c);f=(0,e.or)(...o.map((r,n)=>function(t,r){const n=o[r];return"object"==typeof n&&null!==n?e._`${p()}(${a}, ${t}[${r}])`:e._`${a} === ${n}`}(t,n)))}n.pass(f)}};return Wl.default=n,Wl}(),u=[e.default,t.default,r.default,n.default,s.default,a.default,i.default,o.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},c.default,d.default];return xl.default=u,xl}var Yl,Ql={},ep={};function tp(){if(Yl)return ep;Yl=1,Object.defineProperty(ep,"__esModule",{value:!0}),ep.validateAdditionalItems=void 0;const e=uu(),t=fu(),r={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:t}})=>e.str`must NOT have more than ${t} items`,params:({params:{len:t}})=>e._`{limit: ${t}}`},code(e){const{parentSchema:r,it:s}=e,{items:a}=r;Array.isArray(a)?n(e,a):(0,t.checkStrictMode)(s,'"additionalItems" is ignored when "items" is not an array of schemas')}};function n(r,n){const{gen:s,schema:a,data:i,keyword:o,it:c}=r;c.items=!0;const d=s.const("len",e._`${i}.length`);if(!1===a)r.setParams({len:n.length}),r.pass(e._`${d} <= ${n.length}`);else if("object"==typeof a&&!(0,t.alwaysValidSchema)(c,a)){const a=s.var("valid",e._`${d} <= ${n.length}`);s.if((0,e.not)(a),()=>function(a){s.forRange("i",n.length,d,n=>{r.subschema({keyword:o,dataProp:n,dataPropType:t.Type.Num},a),c.allErrors||s.if((0,e.not)(a),()=>s.break())})}(a)),r.ok(a)}}return ep.validateAdditionalItems=n,ep.default=r,ep}var rp,np,sp={},ap={};function ip(){if(rp)return ap;rp=1,Object.defineProperty(ap,"__esModule",{value:!0}),ap.validateTuple=void 0;const e=uu(),t=fu(),r=Cu(),n={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:n,it:a}=e;if(Array.isArray(n))return s(e,"additionalItems",n);a.items=!0,(0,t.alwaysValidSchema)(a,n)||e.ok((0,r.validateArray)(e))}};function s(r,n,s=r.schema){const{gen:a,parentSchema:i,data:o,keyword:c,it:d}=r;!function(e){const{opts:r,errSchemaPath:a}=d,i=s.length,o=i===e.minItems&&(i===e.maxItems||!1===e[n]);if(r.strictTuples&&!o){const e=`"${c}" is ${i}-tuple, but minItems or maxItems/${n} are not specified or different at path "${a}"`;(0,t.checkStrictMode)(d,e,r.strictTuples)}}(i),d.opts.unevaluated&&s.length&&!0!==d.items&&(d.items=t.mergeEvaluated.items(a,s.length,d.items));const u=a.name("valid"),l=a.const("len",e._`${o}.length`);s.forEach((n,s)=>{(0,t.alwaysValidSchema)(d,n)||(a.if(e._`${l} > ${s}`,()=>r.subschema({keyword:c,schemaProp:s,dataProp:s},u)),r.ok(u))})}return ap.validateTuple=s,ap.default=n,ap}var op,cp,dp={},up={};var lp,pp={};var fp,hp,mp={},gp={};function yp(){if(hp)return gp;hp=1,Object.defineProperty(gp,"__esModule",{value:!0});const e=Cu(),t=uu(),r=_u(),n=fu(),s={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:e})=>t._`{additionalProperty: ${e.additionalProperty}}`},code(s){const{gen:a,schema:i,parentSchema:o,data:c,errsCount:d,it:u}=s;if(!d)throw new Error("ajv implementation error");const{allErrors:l,opts:p}=u;if(u.props=!0,"all"!==p.removeAdditional&&(0,n.alwaysValidSchema)(u,i))return;const f=(0,e.allSchemaProperties)(o.properties),h=(0,e.allSchemaProperties)(o.patternProperties);function m(e){a.code(t._`delete ${c}[${e}]`)}function g(e){if("all"===p.removeAdditional||p.removeAdditional&&!1===i)m(e);else{if(!1===i)return s.setParams({additionalProperty:e}),s.error(),void(l||a.break());if("object"==typeof i&&!(0,n.alwaysValidSchema)(u,i)){const r=a.name("valid");"failing"===p.removeAdditional?(y(e,r,!1),a.if((0,t.not)(r),()=>{s.reset(),m(e)})):(y(e,r),l||a.if((0,t.not)(r),()=>a.break()))}}}function y(e,t,r){const a={keyword:"additionalProperties",dataProp:e,dataPropType:n.Type.Str};!1===r&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),s.subschema(a,t)}a.forIn("key",c,r=>{f.length||h.length?a.if(function(r){let i;if(f.length>8){const t=(0,n.schemaRefOrVal)(u,o.properties,"properties");i=(0,e.isOwnProperty)(a,t,r)}else i=f.length?(0,t.or)(...f.map(e=>t._`${r} === ${e}`)):t.nil;return h.length&&(i=(0,t.or)(i,...h.map(n=>t._`${(0,e.usePattern)(s,n)}.test(${r})`))),(0,t.not)(i)}(r),()=>g(r)):g(r)}),s.ok(t._`${d} === ${r.default.errors}`)}};return gp.default=s,gp}var _p,vp,wp,bp,kp,$p,Sp,Ep,Tp,xp={},Np={},Pp={},Op={},Ip={},jp={},Rp={},zp={};function Cp(){if(Tp)return Ql;Tp=1,Object.defineProperty(Ql,"__esModule",{value:!0});const e=tp(),t=function(){if(np)return sp;np=1,Object.defineProperty(sp,"__esModule",{value:!0});const e=ip(),t={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,e.validateTuple)(t,"items")};return sp.default=t,sp}(),r=ip(),n=function(){if(op)return dp;op=1,Object.defineProperty(dp,"__esModule",{value:!0});const e=uu(),t=fu(),r=Cu(),n=tp(),s={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:t}})=>e.str`must NOT have more than ${t} items`,params:({params:{len:t}})=>e._`{limit: ${t}}`},code(e){const{schema:s,parentSchema:a,it:i}=e,{prefixItems:o}=a;i.items=!0,(0,t.alwaysValidSchema)(i,s)||(o?(0,n.validateAdditionalItems)(e,o):e.ok((0,r.validateArray)(e)))}};return dp.default=s,dp}(),s=function(){if(cp)return up;cp=1,Object.defineProperty(up,"__esModule",{value:!0});const e=uu(),t=fu(),r={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:t,max:r}})=>void 0===r?e.str`must contain at least ${t} valid item(s)`:e.str`must contain at least ${t} and no more than ${r} valid item(s)`,params:({params:{min:t,max:r}})=>void 0===r?e._`{minContains: ${t}}`:e._`{minContains: ${t}, maxContains: ${r}}`},code(r){const{gen:n,schema:s,parentSchema:a,data:i,it:o}=r;let c,d;const{minContains:u,maxContains:l}=a;o.opts.next?(c=void 0===u?1:u,d=l):c=1;const p=n.const("len",e._`${i}.length`);if(r.setParams({min:c,max:d}),void 0===d&&0===c)return void(0,t.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==d&&c>d)return(0,t.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),void r.fail();if((0,t.alwaysValidSchema)(o,s)){let t=e._`${p} >= ${c}`;return void 0!==d&&(t=e._`${t} && ${p} <= ${d}`),void r.pass(t)}o.items=!0;const f=n.name("valid");function h(){const t=n.name("_valid"),r=n.let("count",0);m(t,()=>n.if(t,()=>function(t){n.code(e._`${t}++`),void 0===d?n.if(e._`${t} >= ${c}`,()=>n.assign(f,!0).break()):(n.if(e._`${t} > ${d}`,()=>n.assign(f,!1).break()),1===c?n.assign(f,!0):n.if(e._`${t} >= ${c}`,()=>n.assign(f,!0)))}(r)))}function m(e,s){n.forRange("i",0,p,n=>{r.subschema({keyword:"contains",dataProp:n,dataPropType:t.Type.Num,compositeRule:!0},e),s()})}void 0===d&&1===c?m(f,()=>n.if(f,()=>n.break())):0===c?(n.let(f,!0),void 0!==d&&n.if(e._`${i}.length > 0`,h)):(n.let(f,!1),h()),r.result(f,()=>r.reset())}};return up.default=r,up}(),a=(lp||(lp=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=uu(),r=fu(),n=Cu();e.error={message:({params:{property:e,depsCount:r,deps:n}})=>{const s=1===r?"property":"properties";return t.str`must have ${s} ${n} when property ${e} is present`},params:({params:{property:e,depsCount:r,deps:n,missingProperty:s}})=>t._`{property: ${e},
4
+ || ${c} === "boolean" || ${a} === null`).assign(u,n._`[${a}]`)}}s.else(),l(e),s.endIf(),s.if(n._`${u} !== undefined`,()=>{s.assign(a,u),function({gen:e,parentData:t,parentDataProperty:r},s){e.if(n._`${t} !== undefined`,()=>e.assign(n._`${t}[${r}]`,s))}(e,u)})}(e,r,u):l(e)})}return p};const o=new Set(["string","number","integer","boolean","null"]);function c(e,t,r,s=a.Correct){const i=s===a.Correct?n.operators.EQ:n.operators.NEQ;let o;switch(e){case"null":return n._`${t} ${i} null`;case"array":o=n._`Array.isArray(${t})`;break;case"object":o=n._`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":o=c(n._`!(${t} % 1) && !isNaN(${t})`);break;case"number":o=c();break;default:return n._`typeof ${t} ${i} ${e}`}return s===a.Correct?o:(0,n.not)(o);function c(e=n.nil){return(0,n.and)(n._`typeof ${t} == "number"`,e,r?n._`isFinite(${t})`:n.nil)}}function d(e,t,r,a){if(1===e.length)return c(e[0],t,r,a);let i;const o=(0,s.toHash)(e);if(o.array&&o.object){const e=n._`typeof ${t} != "object"`;i=o.null?e:n._`!${t} || ${e}`,delete o.null,delete o.array,delete o.object}else i=n.nil;o.number&&delete o.integer;for(const e in o)i=(0,n.and)(i,c(e,t,r,a));return i}bu.checkDataType=c,bu.checkDataTypes=d;const u={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>"string"==typeof e?n._`{type: ${e}}`:n._`{type: ${t}}`};function l(e){const t=function(e){const{gen:t,data:r,schema:n}=e,a=(0,s.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:a,schemaValue:a,parentSchema:n,params:{},it:e}}(e);(0,r.reportError)(t,u)}return bu.reportTypeError=l,bu}var Ou,Pu,Iu,Ru={},ju={},zu={};function Cu(){if(Pu)return zu;Pu=1,Object.defineProperty(zu,"__esModule",{value:!0}),zu.validateUnion=zu.validateArray=zu.usePattern=zu.callValidateCode=zu.schemaProperties=zu.allSchemaProperties=zu.noPropertyInData=zu.propertyInData=zu.isOwnProperty=zu.hasPropFunc=zu.reportMissingProp=zu.checkMissingProp=zu.checkReportMissingProp=void 0;const e=uu(),t=fu(),r=_u(),n=fu();function s(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:e._`Object.prototype.hasOwnProperty`})}function a(t,r,n){return e._`${s(t)}.call(${r}, ${n})`}function i(t,r,n,s){const i=e._`${r}${(0,e.getProperty)(n)} === undefined`;return s?(0,e.or)(i,(0,e.not)(a(t,r,n))):i}function o(e){return e?Object.keys(e).filter(e=>"__proto__"!==e):[]}zu.checkReportMissingProp=function(t,r){const{gen:n,data:s,it:a}=t;n.if(i(n,s,r,a.opts.ownProperties),()=>{t.setParams({missingProperty:e._`${r}`},!0),t.error()})},zu.checkMissingProp=function({gen:t,data:r,it:{opts:n}},s,a){return(0,e.or)(...s.map(s=>(0,e.and)(i(t,r,s,n.ownProperties),e._`${a} = ${s}`)))},zu.reportMissingProp=function(e,t){e.setParams({missingProperty:t},!0),e.error()},zu.hasPropFunc=s,zu.isOwnProperty=a,zu.propertyInData=function(t,r,n,s){const i=e._`${r}${(0,e.getProperty)(n)} !== undefined`;return s?e._`${i} && ${a(t,r,n)}`:i},zu.noPropertyInData=i,zu.allSchemaProperties=o,zu.schemaProperties=function(e,r){return o(r).filter(n=>!(0,t.alwaysValidSchema)(e,r[n]))},zu.callValidateCode=function({schemaCode:t,data:n,it:{gen:s,topSchemaRef:a,schemaPath:i,errorPath:o},it:c},d,u,l){const p=l?e._`${t}, ${n}, ${a}${i}`:n,f=[[r.default.instancePath,(0,e.strConcat)(r.default.instancePath,o)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&f.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const h=e._`${p}, ${s.object(...f)}`;return u!==e.nil?e._`${d}.call(${u}, ${h})`:e._`${d}(${h})`};const c=e._`new RegExp`;return zu.usePattern=function({gen:t,it:{opts:r}},s){const a=r.unicodeRegExp?"u":"",{regExp:i}=r.code,o=i(s,a);return t.scopeValue("pattern",{key:o.toString(),ref:o,code:e._`${"new RegExp"===i.code?c:(0,n.useFunc)(t,i)}(${s}, ${a})`})},zu.validateArray=function(r){const{gen:n,data:s,keyword:a,it:i}=r,o=n.name("valid");if(i.allErrors){const e=n.let("valid",!0);return c(()=>n.assign(e,!1)),e}return n.var(o,!0),c(()=>n.break()),o;function c(i){const c=n.const("len",e._`${s}.length`);n.forRange("i",0,c,s=>{r.subschema({keyword:a,dataProp:s,dataPropType:t.Type.Num},o),n.if((0,e.not)(o),i)})}},zu.validateUnion=function(r){const{gen:n,schema:s,keyword:a,it:i}=r;if(!Array.isArray(s))throw new Error("ajv implementation error");if(s.some(e=>(0,t.alwaysValidSchema)(i,e))&&!i.opts.unevaluated)return;const o=n.let("valid",!1),c=n.name("_valid");n.block(()=>s.forEach((t,s)=>{const i=r.subschema({keyword:a,schemaProp:s,compositeRule:!0},c);n.assign(o,e._`${o} || ${c}`),r.mergeValidEvaluated(i,c)||n.if((0,e.not)(o))})),r.result(o,()=>r.reset(),()=>r.error(!0))},zu}var Au,Mu,Zu,Du={},Lu={};function Fu(){return Zu||(Zu=1,Mu=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var n,s,a;if(Array.isArray(t)){if((n=t.length)!=r.length)return!1;for(s=n;0!==s--;)if(!e(t[s],r[s]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((n=(a=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(s=n;0!==s--;)if(!Object.prototype.hasOwnProperty.call(r,a[s]))return!1;for(s=n;0!==s--;){var i=a[s];if(!e(t[i],r[i]))return!1}return!0}return t!=t&&r!=r}),Mu}var qu,Uu,Vu,Hu={exports:{}};function Ju(){if(qu)return Hu.exports;qu=1;var e=Hu.exports=function(e,r,n){"function"==typeof r&&(n=r,r={}),t(r,"function"==typeof(n=r.cb||n)?n:n.pre||function(){},n.post||function(){},e,"",e)};function t(n,s,a,i,o,c,d,u,l,p){if(i&&"object"==typeof i&&!Array.isArray(i)){for(var f in s(i,o,c,d,u,l,p),i){var h=i[f];if(Array.isArray(h)){if(f in e.arrayKeywords)for(var m=0;m<h.length;m++)t(n,s,a,h[m],o+"/"+f+"/"+m,c,o,f,i,m)}else if(f in e.propsKeywords){if(h&&"object"==typeof h)for(var g in h)t(n,s,a,h[g],o+"/"+f+"/"+r(g),c,o,f,i,g)}else(f in e.keywords||n.allKeys&&!(f in e.skipKeywords))&&t(n,s,a,h,o+"/"+f,c,o,f,i)}a(i,o,c,d,u,l,p)}}function r(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}return e.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},e.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},e.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},e.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0},Hu.exports}function Ku(){if(Uu)return Lu;Uu=1,Object.defineProperty(Lu,"__esModule",{value:!0}),Lu.getSchemaRefs=Lu.resolveUrl=Lu.normalizeId=Lu._getFullPath=Lu.getFullPath=Lu.inlineRef=void 0;const e=fu(),t=Fu(),r=Ju(),n=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);Lu.inlineRef=function(e,t=!0){return"boolean"==typeof e||(!0===t?!a(e):!!t&&i(e)<=t)};const s=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function a(e){for(const t in e){if(s.has(t))return!0;const r=e[t];if(Array.isArray(r)&&r.some(a))return!0;if("object"==typeof r&&a(r))return!0}return!1}function i(t){let r=0;for(const s in t){if("$ref"===s)return 1/0;if(r++,!n.has(s)&&("object"==typeof t[s]&&(0,e.eachItem)(t[s],e=>r+=i(e)),r===1/0))return 1/0}return r}function o(e,t="",r){!1!==r&&(t=u(t));const n=e.parse(t);return c(e,n)}function c(e,t){return e.serialize(t).split("#")[0]+"#"}Lu.getFullPath=o,Lu._getFullPath=c;const d=/#\/?$/;function u(e){return e?e.replace(d,""):""}Lu.normalizeId=u,Lu.resolveUrl=function(e,t,r){return r=u(r),e.resolve(t,r)};const l=/^[a-z_][-a-z0-9._]*$/i;return Lu.getSchemaRefs=function(e,n){if("boolean"==typeof e)return{};const{schemaId:s,uriResolver:a}=this.opts,i=u(e[s]||n),c={"":i},d=o(a,i,!1),p={},f=new Set;return r(e,{allKeys:!0},(e,t,r,n)=>{if(void 0===n)return;const a=d+t;let i=c[n];function o(t){const r=this.opts.uriResolver.resolve;if(t=u(i?r(i,t):t),f.has(t))throw m(t);f.add(t);let n=this.refs[t];return"string"==typeof n&&(n=this.refs[n]),"object"==typeof n?h(e,n.schema,t):t!==u(a)&&("#"===t[0]?(h(e,p[t],t),p[t]=e):this.refs[t]=a),t}function g(e){if("string"==typeof e){if(!l.test(e))throw new Error(`invalid anchor "${e}"`);o.call(this,`#${e}`)}}"string"==typeof e[s]&&(i=o.call(this,e[s])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),c[t]=i}),p;function h(e,r,n){if(void 0!==r&&!t(e,r))throw m(n)}function m(e){return new Error(`reference "${e}" resolves to more than one schema`)}},Lu}function Bu(){if(Vu)return eu;Vu=1,Object.defineProperty(eu,"__esModule",{value:!0}),eu.getData=eu.KeywordCxt=eu.validateFunctionCode=void 0;const e=function(){if(gu)return tu;gu=1,Object.defineProperty(tu,"__esModule",{value:!0}),tu.boolOrEmptySchema=tu.topBoolOrEmptySchema=void 0;const e=vu(),t=uu(),r=_u(),n={message:"boolean schema is false"};function s(t,r){const{gen:s,data:a}=t,i={gen:s,keyword:"false schema",data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,e.reportError)(i,n,void 0,r)}return tu.topBoolOrEmptySchema=function(e){const{gen:n,schema:a,validateName:i}=e;!1===a?s(e,!1):"object"==typeof a&&!0===a.$async?n.return(r.default.data):(n.assign(t._`${i}.errors`,null),n.return(!0))},tu.boolOrEmptySchema=function(e,t){const{gen:r,schema:n}=e;!1===n?(r.var(t,!1),s(e)):r.var(t,!0)},tu}(),t=Nu(),r=xu(),n=Nu(),s=function(){if(Ou)return Ru;Ou=1,Object.defineProperty(Ru,"__esModule",{value:!0}),Ru.assignDefaults=void 0;const e=uu(),t=fu();function r(r,n,s){const{gen:a,compositeRule:i,data:o,opts:c}=r;if(void 0===s)return;const d=e._`${o}${(0,e.getProperty)(n)}`;if(i)return void(0,t.checkStrictMode)(r,`default is ignored for: ${d}`);let u=e._`${d} === undefined`;"empty"===c.useDefaults&&(u=e._`${u} || ${d} === null || ${d} === ""`),a.if(u,e._`${d} = ${(0,e.stringify)(s)}`)}return Ru.assignDefaults=function(e,t){const{properties:n,items:s}=e.schema;if("object"===t&&n)for(const t in n)r(e,t,n[t].default);else"array"===t&&Array.isArray(s)&&s.forEach((t,n)=>r(e,n,t.default))},Ru}(),a=function(){if(Iu)return ju;Iu=1,Object.defineProperty(ju,"__esModule",{value:!0}),ju.validateKeywordUsage=ju.validSchemaType=ju.funcKeywordCode=ju.macroKeywordCode=void 0;const e=uu(),t=_u(),r=Cu(),n=vu();function s(t){const{gen:r,data:n,it:s}=t;r.if(s.parentData,()=>r.assign(n,e._`${s.parentData}[${s.parentDataProperty}]`))}function a(t,r,n){if(void 0===n)throw new Error(`keyword "${r}" failed to compile`);return t.scopeValue("keyword","function"==typeof n?{ref:n}:{ref:n,code:(0,e.stringify)(n)})}return ju.macroKeywordCode=function(t,r){const{gen:n,keyword:s,schema:i,parentSchema:o,it:c}=t,d=r.macro.call(c.self,i,o,c),u=a(n,s,d);!1!==c.opts.validateSchema&&c.self.validateSchema(d,!0);const l=n.name("valid");t.subschema({schema:d,schemaPath:e.nil,errSchemaPath:`${c.errSchemaPath}/${s}`,topSchemaRef:u,compositeRule:!0},l),t.pass(l,()=>t.error(!0))},ju.funcKeywordCode=function(i,o){var c;const{gen:d,keyword:u,schema:l,parentSchema:p,$data:f,it:h}=i;!function({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}(h,o);const m=!f&&o.compile?o.compile.call(h.self,l,p,h):o.validate,g=a(d,u,m),y=d.let("valid");function _(n=(o.async?e._`await `:e.nil)){const s=h.opts.passContext?t.default.this:t.default.self,a=!("compile"in o&&!f||!1===o.schema);d.assign(y,e._`${n}${(0,r.callValidateCode)(i,g,s,a)}`,o.modifying)}function v(t){var r;d.if((0,e.not)(null!==(r=o.valid)&&void 0!==r?r:y),t)}i.block$data(y,function(){if(!1===o.errors)_(),o.modifying&&s(i),v(()=>i.error());else{const r=o.async?function(){const t=d.let("ruleErrs",null);return d.try(()=>_(e._`await `),r=>d.assign(y,!1).if(e._`${r} instanceof ${h.ValidationError}`,()=>d.assign(t,e._`${r}.errors`),()=>d.throw(r))),t}():function(){const t=e._`${g}.errors`;return d.assign(t,null),_(e.nil),t}();o.modifying&&s(i),v(()=>function(r,s){const{gen:a}=r;a.if(e._`Array.isArray(${s})`,()=>{a.assign(t.default.vErrors,e._`${t.default.vErrors} === null ? ${s} : ${t.default.vErrors}.concat(${s})`).assign(t.default.errors,e._`${t.default.vErrors}.length`),(0,n.extendErrors)(r)},()=>r.error())}(i,r))}}),i.ok(null!==(c=o.valid)&&void 0!==c?c:y)},ju.validSchemaType=function(e,t,r=!1){return!t.length||t.some(t=>"array"===t?Array.isArray(e):"object"===t?e&&"object"==typeof e&&!Array.isArray(e):typeof e==t||r&&void 0===e)},ju.validateKeywordUsage=function({schema:e,opts:t,self:r,errSchemaPath:n},s,a){if(Array.isArray(s.keyword)?!s.keyword.includes(a):s.keyword!==a)throw new Error("ajv implementation error");const i=s.dependencies;if(null==i?void 0:i.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw new Error(`parent schema must have dependencies of ${a}: ${i.join(",")}`);if(s.validateSchema&&!s.validateSchema(e[a])){const e=`keyword "${a}" value is invalid at path "${n}": `+r.errorsText(s.validateSchema.errors);if("log"!==t.validateSchema)throw new Error(e);r.logger.error(e)}},ju}(),i=function(){if(Au)return Du;Au=1,Object.defineProperty(Du,"__esModule",{value:!0}),Du.extendSubschemaMode=Du.extendSubschemaData=Du.getSubschema=void 0;const e=uu(),t=fu();return Du.getSubschema=function(r,{keyword:n,schemaProp:s,schema:a,schemaPath:i,errSchemaPath:o,topSchemaRef:c}){if(void 0!==n&&void 0!==a)throw new Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==n){const a=r.schema[n];return void 0===s?{schema:a,schemaPath:e._`${r.schemaPath}${(0,e.getProperty)(n)}`,errSchemaPath:`${r.errSchemaPath}/${n}`}:{schema:a[s],schemaPath:e._`${r.schemaPath}${(0,e.getProperty)(n)}${(0,e.getProperty)(s)}`,errSchemaPath:`${r.errSchemaPath}/${n}/${(0,t.escapeFragment)(s)}`}}if(void 0!==a){if(void 0===i||void 0===o||void 0===c)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:a,schemaPath:i,topSchemaRef:c,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')},Du.extendSubschemaData=function(r,n,{dataProp:s,dataPropType:a,data:i,dataTypes:o,propertyName:c}){if(void 0!==i&&void 0!==s)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:d}=n;if(void 0!==s){const{errorPath:i,dataPathArr:o,opts:c}=n;u(d.let("data",e._`${n.data}${(0,e.getProperty)(s)}`,!0)),r.errorPath=e.str`${i}${(0,t.getErrorPath)(s,a,c.jsPropertySyntax)}`,r.parentDataProperty=e._`${s}`,r.dataPathArr=[...o,r.parentDataProperty]}function u(e){r.data=e,r.dataLevel=n.dataLevel+1,r.dataTypes=[],n.definedProperties=new Set,r.parentData=n.data,r.dataNames=[...n.dataNames,e]}void 0!==i&&(u(i instanceof e.Name?i:d.let("data",i,!0)),void 0!==c&&(r.propertyName=c)),o&&(r.dataTypes=o)},Du.extendSubschemaMode=function(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:s,allErrors:a}){void 0!==n&&(e.compositeRule=n),void 0!==s&&(e.createErrors=s),void 0!==a&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=r},Du}(),o=uu(),c=_u(),d=Ku(),u=fu(),l=vu();function p({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},a){s.code.es5?e.func(t,o._`${c.default.data}, ${c.default.valCxt}`,n.$async,()=>{e.code(o._`"use strict"; ${f(r,s)}`),function(e,t){e.if(c.default.valCxt,()=>{e.var(c.default.instancePath,o._`${c.default.valCxt}.${c.default.instancePath}`),e.var(c.default.parentData,o._`${c.default.valCxt}.${c.default.parentData}`),e.var(c.default.parentDataProperty,o._`${c.default.valCxt}.${c.default.parentDataProperty}`),e.var(c.default.rootData,o._`${c.default.valCxt}.${c.default.rootData}`),t.dynamicRef&&e.var(c.default.dynamicAnchors,o._`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{e.var(c.default.instancePath,o._`""`),e.var(c.default.parentData,o._`undefined`),e.var(c.default.parentDataProperty,o._`undefined`),e.var(c.default.rootData,c.default.data),t.dynamicRef&&e.var(c.default.dynamicAnchors,o._`{}`)})}(e,s),e.code(a)}):e.func(t,o._`${c.default.data}, ${function(e){return o._`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${e.dynamicRef?o._`, ${c.default.dynamicAnchors}={}`:o.nil}}={}`}(s)}`,n.$async,()=>e.code(f(r,s)).code(a))}function f(e,t){const r="object"==typeof e&&e[t.schemaId];return r&&(t.code.source||t.code.process)?o._`/*# sourceURL=${r} */`:o.nil}function h({schema:e,self:t}){if("boolean"==typeof e)return!e;for(const r in e)if(t.RULES.all[r])return!0;return!1}function m(e){return"boolean"!=typeof e.schema}function g(e){(0,u.checkUnknownRules)(e),function(e){const{schema:t,errSchemaPath:r,opts:n,self:s}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,u.schemaHasRulesButRef)(t,s.RULES)&&s.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}(e)}function y(e,r){if(e.opts.jtd)return v(e,[],!1,r);const n=(0,t.getSchemaTypes)(e.schema);v(e,n,!(0,t.coerceAndCheckDataType)(e,n),r)}function _({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:s}){const a=r.$comment;if(!0===s.$comment)e.code(o._`${c.default.self}.logger.log(${a})`);else if("function"==typeof s.$comment){const r=o.str`${n}/$comment`,s=e.scopeValue("root",{ref:t.root});e.code(o._`${c.default.self}.opts.$comment(${a}, ${r}, ${s}.schema)`)}}function v(e,t,s,a){const{gen:i,schema:d,data:l,allErrors:p,opts:f,self:h}=e,{RULES:m}=h;function g(u){(0,r.shouldUseGroup)(d,u)&&(u.type?(i.if((0,n.checkDataType)(u.type,l,f.strictNumbers)),w(e,u),1===t.length&&t[0]===u.type&&s&&(i.else(),(0,n.reportTypeError)(e)),i.endIf()):w(e,u),p||i.if(o._`${c.default.errors} === ${a||0}`))}!d.$ref||!f.ignoreKeywordsWithRef&&(0,u.schemaHasRulesButRef)(d,m)?(f.jtd||function(e,t){!e.schemaEnv.meta&&e.opts.strictTypes&&(function(e,t){t.length&&(e.dataTypes.length?(t.forEach(t=>{b(e.dataTypes,t)||k(e,`type "${t}" not allowed by context "${e.dataTypes.join(",")}"`)}),function(e,t){const r=[];for(const n of e.dataTypes)b(t,n)?r.push(n):t.includes("integer")&&"number"===n&&r.push("integer");e.dataTypes=r}(e,t)):e.dataTypes=t)}(e,t),e.opts.allowUnionTypes||function(e,t){t.length>1&&(2!==t.length||!t.includes("null"))&&k(e,"use allowUnionTypes to allow union type keyword")}(e,t),function(e,t){const n=e.self.RULES.all;for(const s in n){const a=n[s];if("object"==typeof a&&(0,r.shouldUseRule)(e.schema,a)){const{type:r}=a.definition;r.length&&!r.some(e=>{return n=e,(r=t).includes(n)||"number"===n&&r.includes("integer");var r,n})&&k(e,`missing type "${r.join(",")}" for keyword "${s}"`)}}}(e,e.dataTypes))}(e,t),i.block(()=>{for(const e of m.rules)g(e);g(m.post)})):i.block(()=>S(e,"$ref",m.all.$ref.definition))}function w(e,t){const{gen:n,schema:a,opts:{useDefaults:i}}=e;i&&(0,s.assignDefaults)(e,t.type),n.block(()=>{for(const n of t.rules)(0,r.shouldUseRule)(a,n)&&S(e,n.keyword,n.definition,t.type)})}function b(e,t){return e.includes(t)||"integer"===t&&e.includes("number")}function k(e,t){t+=` at "${e.schemaEnv.baseId+e.errSchemaPath}" (strictTypes)`,(0,u.checkStrictMode)(e,t,e.opts.strictTypes)}eu.validateFunctionCode=function(t){m(t)&&(g(t),h(t))?function(e){const{schema:t,opts:r,gen:n}=e;p(e,()=>{r.$comment&&t.$comment&&_(e),function(e){const{schema:t,opts:r}=e;void 0!==t.default&&r.useDefaults&&r.strictSchema&&(0,u.checkStrictMode)(e,"default is ignored in the schema root")}(e),n.let(c.default.vErrors,null),n.let(c.default.errors,0),r.unevaluated&&function(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",o._`${r}.evaluated`),t.if(o._`${e.evaluated}.dynamicProps`,()=>t.assign(o._`${e.evaluated}.props`,o._`undefined`)),t.if(o._`${e.evaluated}.dynamicItems`,()=>t.assign(o._`${e.evaluated}.items`,o._`undefined`))}(e),y(e),function(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:a}=e;r.$async?t.if(o._`${c.default.errors} === 0`,()=>t.return(c.default.data),()=>t.throw(o._`new ${s}(${c.default.vErrors})`)):(t.assign(o._`${n}.errors`,c.default.vErrors),a.unevaluated&&function({gen:e,evaluated:t,props:r,items:n}){r instanceof o.Name&&e.assign(o._`${t}.props`,r),n instanceof o.Name&&e.assign(o._`${t}.items`,n)}(e),t.return(o._`${c.default.errors} === 0`))}(e)})}(t):p(t,()=>(0,e.topBoolOrEmptySchema)(t))};class ${constructor(e,t,r){if((0,a.validateKeywordUsage)(e,t,r),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=r,this.data=e.data,this.schema=e.schema[r],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,u.schemaRefOrVal)(e,this.schema,r,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",x(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,a.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:!1!==t.errors)&&(this.errsCount=e.gen.const("_errs",c.default.errors))}result(e,t,r){this.failResult((0,o.not)(e),t,r)}failResult(e,t,r){this.gen.if(e),r?r():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,o.not)(e),void 0,t)}fail(e){if(void 0===e)return this.error(),void(this.allErrors||this.gen.if(!1));this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:t}=this;this.fail(o._`${t} !== undefined && (${(0,o.or)(this.invalid$data(),e)})`)}error(e,t,r){if(t)return this.setParams(t),this._error(e,r),void this.setParams({});this._error(e,r)}_error(e,t){(e?l.reportExtraError:l.reportError)(this,this.def.error,t)}$dataError(){(0,l.reportError)(this,this.def.$dataError||l.keyword$DataError)}reset(){if(void 0===this.errsCount)throw new Error('add "trackErrors" to keyword definition');(0,l.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,r=o.nil){this.gen.block(()=>{this.check$data(e,r),t()})}check$data(e=o.nil,t=o.nil){if(!this.$data)return;const{gen:r,schemaCode:n,schemaType:s,def:a}=this;r.if((0,o.or)(o._`${n} === undefined`,t)),e!==o.nil&&r.assign(e,!0),(s.length||a.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),e!==o.nil&&r.assign(e,!1)),r.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:r,def:s,it:a}=this;return(0,o.or)(function(){if(r.length){if(!(t instanceof o.Name))throw new Error("ajv implementation error");const e=Array.isArray(r)?r:[r];return o._`${(0,n.checkDataTypes)(e,t,a.opts.strictNumbers,n.DataType.Wrong)}`}return o.nil}(),function(){if(s.validateSchema){const r=e.scopeValue("validate$data",{ref:s.validateSchema});return o._`!${r}(${t})`}return o.nil}())}subschema(t,r){const n=(0,i.getSubschema)(this.it,t);(0,i.extendSubschemaData)(n,this.it,t),(0,i.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return function(t,r){m(t)&&(g(t),h(t))?function(e,t){const{schema:r,gen:n,opts:s}=e;s.$comment&&r.$comment&&_(e),function(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,d.resolveUrl)(e.opts.uriResolver,e.baseId,t))}(e),function(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}(e);const a=n.const("_errs",c.default.errors);y(e,a),n.var(t,o._`${a} === ${c.default.errors}`)}(t,r):(0,e.boolOrEmptySchema)(t,r)}(s,r),s}mergeEvaluated(e,t){const{it:r,gen:n}=this;r.opts.unevaluated&&(!0!==r.props&&void 0!==e.props&&(r.props=u.mergeEvaluated.props(n,e.props,r.props,t)),!0!==r.items&&void 0!==e.items&&(r.items=u.mergeEvaluated.items(n,e.items,r.items,t)))}mergeValidEvaluated(e,t){const{it:r,gen:n}=this;if(r.opts.unevaluated&&(!0!==r.props||!0!==r.items))return n.if(t,()=>this.mergeEvaluated(e,o.Name)),!0}}function S(e,t,r,n){const s=new $(e,r,t);"code"in r?r.code(s,n):s.$data&&r.validate?(0,a.funcKeywordCode)(s,r):"macro"in r?(0,a.macroKeywordCode)(s,r):(r.compile||r.validate)&&(0,a.funcKeywordCode)(s,r)}eu.KeywordCxt=$;const E=/^\/(?:[^~]|~0|~1)*$/,T=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function x(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let s,a;if(""===e)return c.default.rootData;if("/"===e[0]){if(!E.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,a=c.default.rootData}else{const i=T.exec(e);if(!i)throw new Error(`Invalid JSON-pointer: ${e}`);const o=+i[1];if(s=i[2],"#"===s){if(o>=t)throw new Error(l("property/index",o));return n[t-o]}if(o>t)throw new Error(l("data",o));if(a=r[t-o],!s)return a}let i=a;const d=s.split("/");for(const e of d)e&&(a=o._`${a}${(0,o.getProperty)((0,u.unescapeJsonPointer)(e))}`,i=o._`${i} && ${a}`);return i;function l(e,r){return`Cannot access ${e} ${r} levels up, current level is ${t}`}}return eu.getData=x,eu}var Gu,Xu={};function Wu(){if(Gu)return Xu;Gu=1,Object.defineProperty(Xu,"__esModule",{value:!0});class e extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}}return Xu.default=e,Xu}var Yu,Qu={};function el(){if(Yu)return Qu;Yu=1,Object.defineProperty(Qu,"__esModule",{value:!0});const e=Ku();class t extends Error{constructor(t,r,n,s){super(s||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,e.resolveUrl)(t,r,n),this.missingSchema=(0,e.normalizeId)((0,e.getFullPath)(t,this.missingRef))}}return Qu.default=t,Qu}var tl,rl={};function nl(){if(tl)return rl;tl=1,Object.defineProperty(rl,"__esModule",{value:!0}),rl.resolveSchema=rl.getCompilingSchema=rl.resolveRef=rl.compileSchema=rl.SchemaEnv=void 0;const e=uu(),t=Wu(),r=_u(),n=Ku(),s=fu(),a=Bu();class i{constructor(e){var t;let r;this.refs={},this.dynamicAnchors={},"object"==typeof e.schema&&(r=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=null!==(t=e.baseId)&&void 0!==t?t:(0,n.normalizeId)(null==r?void 0:r[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=null==r?void 0:r.$async,this.refs={}}}function o(s){const i=d.call(this,s);if(i)return i;const o=(0,n.getFullPath)(this.opts.uriResolver,s.root.baseId),{es5:c,lines:u}=this.opts.code,{ownProperties:l}=this.opts,p=new e.CodeGen(this.scope,{es5:c,lines:u,ownProperties:l});let f;s.$async&&(f=p.scopeValue("Error",{ref:t.default,code:e._`require("ajv/dist/runtime/validation_error").default`}));const h=p.scopeName("validate");s.validateName=h;const m={gen:p,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[e.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:p.scopeValue("schema",!0===this.opts.code.source?{ref:s.schema,code:(0,e.stringify)(s.schema)}:{ref:s.schema}),validateName:h,ValidationError:f,schema:s.schema,schemaEnv:s,rootId:o,baseId:s.baseId||o,schemaPath:e.nil,errSchemaPath:s.schemaPath||(this.opts.jtd?"":"#"),errorPath:e._`""`,opts:this.opts,self:this};let g;try{this._compilations.add(s),(0,a.validateFunctionCode)(m),p.optimize(this.opts.code.optimize);const t=p.toString();g=`${p.scopeRefs(r.default.scope)}return ${t}`,this.opts.code.process&&(g=this.opts.code.process(g,s));const n=new Function(`${r.default.self}`,`${r.default.scope}`,g)(this,this.scope.get());if(this.scope.value(h,{ref:n}),n.errors=null,n.schema=s.schema,n.schemaEnv=s,s.$async&&(n.$async=!0),!0===this.opts.code.source&&(n.source={validateName:h,validateCode:t,scopeValues:p._values}),this.opts.unevaluated){const{props:t,items:r}=m;n.evaluated={props:t instanceof e.Name?void 0:t,items:r instanceof e.Name?void 0:r,dynamicProps:t instanceof e.Name,dynamicItems:r instanceof e.Name},n.source&&(n.source.evaluated=(0,e.stringify)(n.evaluated))}return s.validate=n,s}catch(e){throw delete s.validate,delete s.validateName,g&&this.logger.error("Error compiling schema, function code:",g),e}finally{this._compilations.delete(s)}}function c(e){return(0,n.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:o.call(this,e)}function d(e){for(const t of this._compilations)if(u(t,e))return t}function u(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function l(e,t){let r;for(;"string"==typeof(r=this.refs[t]);)t=r;return r||this.schemas[t]||p.call(this,e,t)}function p(e,t){const r=this.opts.uriResolver.parse(t),s=(0,n._getFullPath)(this.opts.uriResolver,r);let a=(0,n.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&s===a)return h.call(this,r,e);const c=(0,n.normalizeId)(s),d=this.refs[c]||this.schemas[c];if("string"==typeof d){const t=p.call(this,e,d);if("object"!=typeof(null==t?void 0:t.schema))return;return h.call(this,r,t)}if("object"==typeof(null==d?void 0:d.schema)){if(d.validate||o.call(this,d),c===(0,n.normalizeId)(t)){const{schema:t}=d,{schemaId:r}=this.opts,s=t[r];return s&&(a=(0,n.resolveUrl)(this.opts.uriResolver,a,s)),new i({schema:t,schemaId:r,root:e,baseId:a})}return h.call(this,r,d)}}rl.SchemaEnv=i,rl.compileSchema=o,rl.resolveRef=function(e,t,r){var s;r=(0,n.resolveUrl)(this.opts.uriResolver,t,r);const a=e.refs[r];if(a)return a;let o=l.call(this,e,r);if(void 0===o){const n=null===(s=e.localRefs)||void 0===s?void 0:s[r],{schemaId:a}=this.opts;n&&(o=new i({schema:n,schemaId:a,root:e,baseId:t}))}return void 0!==o?e.refs[r]=c.call(this,o):void 0},rl.getCompilingSchema=d,rl.resolveSchema=p;const f=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function h(e,{baseId:t,schema:r,root:a}){var o;if("/"!==(null===(o=e.fragment)||void 0===o?void 0:o[0]))return;for(const a of e.fragment.slice(1).split("/")){if("boolean"==typeof r)return;const e=r[(0,s.unescapeFragment)(a)];if(void 0===e)return;const i="object"==typeof(r=e)&&r[this.opts.schemaId];!f.has(a)&&i&&(t=(0,n.resolveUrl)(this.opts.uriResolver,t,i))}let c;if("boolean"!=typeof r&&r.$ref&&!(0,s.schemaHasRulesButRef)(r,this.RULES)){const e=(0,n.resolveUrl)(this.opts.uriResolver,t,r.$ref);c=p.call(this,a,e)}const{schemaId:d}=this.opts;return c=c||new i({schema:r,schemaId:d,root:a,baseId:t}),c.schema!==c.root.schema?c:void 0}return rl}var sl,al,il,ol,cl,dl,ul,ll={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1},pl={},fl={exports:{}};function hl(){if(al)return sl;al=1;const e=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),t=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function r(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),48!==r){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}const n=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function s(e){return e.length=0,!0}function a(e,t,n){if(e.length){const s=r(e);if(""===s)return n.error=!0,!1;t.push(s),e.length=0}return!0}function i(e){if(function(e){let t=0;for(let r=0;r<e.length;r++)":"===e[r]&&t++;return t}(e)<2)return{host:e,isIPV6:!1};const t=function(e){let t=0;const n={error:!1,address:"",zone:""},i=[],o=[];let c=!1,d=!1,u=a;for(let r=0;r<e.length;r++){const a=e[r];if("["!==a&&"]"!==a)if(":"!==a)if("%"===a){if(!u(o,i,n))break;u=s}else o.push(a);else{if(!0===c&&(d=!0),!u(o,i,n))break;if(++t>7){n.error=!0;break}r>0&&":"===e[r-1]&&(c=!0),i.push(":")}}return o.length&&(u===s?n.zone=o.join(""):d?i.push(o.join("")):i.push(r(o))),n.address=i.join(""),n}(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,r=t.address;return t.zone&&(e+="%"+t.zone,r+="%25"+t.zone),{host:e,isIPV6:!0,escapedHost:r}}}return sl={nonSimpleDomain:n,recomposeAuthority:function(e){const r=[];if(void 0!==e.userinfo&&(r.push(e.userinfo),r.push("@")),void 0!==e.host){let n=unescape(e.host);if(!t(n)){const t=i(n);n=!0===t.isIPV6?`[${t.escapedHost}]`:e.host}r.push(n)}return"number"!=typeof e.port&&"string"!=typeof e.port||(r.push(":"),r.push(String(e.port))),r.length?r.join(""):void 0},normalizeComponentEncoding:function(e,t){const r=!0!==t?escape:unescape;return void 0!==e.scheme&&(e.scheme=r(e.scheme)),void 0!==e.userinfo&&(e.userinfo=r(e.userinfo)),void 0!==e.host&&(e.host=r(e.host)),void 0!==e.path&&(e.path=r(e.path)),void 0!==e.query&&(e.query=r(e.query)),void 0!==e.fragment&&(e.fragment=r(e.fragment)),e},removeDotSegments:function(e){let t=e;const r=[];let n=-1,s=0;for(;s=t.length;){if(1===s){if("."===t)break;if("/"===t){r.push("/");break}r.push(t);break}if(2===s){if("."===t[0]){if("."===t[1])break;if("/"===t[1]){t=t.slice(2);continue}}else if("/"===t[0]&&("."===t[1]||"/"===t[1])){r.push("/");break}}else if(3===s&&"/.."===t){0!==r.length&&r.pop(),r.push("/");break}if("."===t[0]){if("."===t[1]){if("/"===t[2]){t=t.slice(3);continue}}else if("/"===t[1]){t=t.slice(2);continue}}else if("/"===t[0]&&"."===t[1]){if("/"===t[2]){t=t.slice(2);continue}if("."===t[2]&&"/"===t[3]){t=t.slice(3),0!==r.length&&r.pop();continue}}if(-1===(n=t.indexOf("/",1))){r.push(t);break}r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")},isIPv4:t,isUUID:e,normalizeIPv6:i,stringArrayToHexStripped:r},sl}function ml(){return ul||(ul=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=Bu();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=uu();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=Wu(),s=el(),a=$u(),i=nl(),o=uu(),c=Ku(),d=Nu(),u=fu(),l=ll,p=function(){if(dl)return pl;dl=1,Object.defineProperty(pl,"__esModule",{value:!0});const e=function(){if(cl)return fl.exports;cl=1;const{normalizeIPv6:e,removeDotSegments:t,recomposeAuthority:r,normalizeComponentEncoding:n,isIPv4:s,nonSimpleDomain:a}=hl(),{SCHEMES:i,getSchemeHandler:o}=function(){if(ol)return il;ol=1;const{isUUID:e}=hl(),t=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,r=["http","https","ws","wss","urn","urn:uuid"];function n(e){return!0===e.secure||!1!==e.secure&&!!e.scheme&&!(3!==e.scheme.length||"w"!==e.scheme[0]&&"W"!==e.scheme[0]||"s"!==e.scheme[1]&&"S"!==e.scheme[1]||"s"!==e.scheme[2]&&"S"!==e.scheme[2])}function s(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function a(e){const t="https"===String(e.scheme).toLowerCase();return e.port!==(t?443:80)&&""!==e.port||(e.port=void 0),e.path||(e.path="/"),e}const i={scheme:"http",domainHost:!0,parse:s,serialize:a},o={scheme:"ws",domainHost:!0,parse:function(e){return e.secure=n(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e},serialize:function(e){if(e.port!==(n(e)?443:80)&&""!==e.port||(e.port=void 0),"boolean"==typeof e.secure&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){const[t,r]=e.resourceName.split("?");e.path=t&&"/"!==t?t:void 0,e.query=r,e.resourceName=void 0}return e.fragment=void 0,e}},c={http:i,https:{scheme:"https",domainHost:i.domainHost,parse:s,serialize:a},ws:o,wss:{scheme:"wss",domainHost:o.domainHost,parse:o.parse,serialize:o.serialize},urn:{scheme:"urn",parse:function(e,r){if(!e.path)return e.error="URN can not be parsed",e;const n=e.path.match(t);if(n){const t=r.scheme||e.scheme||"urn";e.nid=n[1].toLowerCase(),e.nss=n[2];const s=d(`${t}:${r.nid||e.nid}`);e.path=void 0,s&&(e=s.parse(e,r))}else e.error=e.error||"URN can not be parsed.";return e},serialize:function(e,t){if(void 0===e.nid)throw new Error("URN without nid cannot be serialized");const r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),s=d(`${r}:${t.nid||n}`);s&&(e=s.serialize(e,t));const a=e,i=e.nss;return a.path=`${n||t.nid}:${i}`,t.skipEscape=!0,a},skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:function(t,r){const n=t;return n.uuid=n.nss,n.nss=void 0,r.tolerant||n.uuid&&e(n.uuid)||(n.error=n.error||"UUID is not valid."),n},serialize:function(e){const t=e;return t.nss=(e.uuid||"").toLowerCase(),t},skipNormalize:!0}};function d(e){return e&&(c[e]||c[e.toLowerCase()])||void 0}return Object.setPrototypeOf(c,null),il={wsIsSecure:n,SCHEMES:c,isValidSchemeName:function(e){return-1!==r.indexOf(e)},getSchemeHandler:d}}();function c(e,r,n,s){const a={};return s||(e=l(d(e,n),n),r=l(d(r,n),n)),!(n=n||{}).tolerant&&r.scheme?(a.scheme=r.scheme,a.userinfo=r.userinfo,a.host=r.host,a.port=r.port,a.path=t(r.path||""),a.query=r.query):(void 0!==r.userinfo||void 0!==r.host||void 0!==r.port?(a.userinfo=r.userinfo,a.host=r.host,a.port=r.port,a.path=t(r.path||""),a.query=r.query):(r.path?("/"===r.path[0]?a.path=t(r.path):(void 0===e.userinfo&&void 0===e.host&&void 0===e.port||e.path?e.path?a.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+r.path:a.path=r.path:a.path="/"+r.path,a.path=t(a.path)),a.query=r.query):(a.path=e.path,void 0!==r.query?a.query=r.query:a.query=e.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=r.fragment,a}function d(e,n){const s={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},a=Object.assign({},n),i=[],c=o(a.scheme||s.scheme);c&&c.serialize&&c.serialize(s,a),void 0!==s.path&&(a.skipEscape?s.path=unescape(s.path):(s.path=escape(s.path),void 0!==s.scheme&&(s.path=s.path.split("%3A").join(":")))),"suffix"!==a.reference&&s.scheme&&i.push(s.scheme,":");const d=r(s);if(void 0!==d&&("suffix"!==a.reference&&i.push("//"),i.push(d),s.path&&"/"!==s.path[0]&&i.push("/")),void 0!==s.path){let e=s.path;a.absolutePath||c&&c.absolutePath||(e=t(e)),void 0===d&&"/"===e[0]&&"/"===e[1]&&(e="/%2F"+e.slice(2)),i.push(e)}return void 0!==s.query&&i.push("?",s.query),void 0!==s.fragment&&i.push("#",s.fragment),i.join("")}const u=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function l(t,r){const n=Object.assign({},r),i={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let c=!1;"suffix"===n.reference&&(t=n.scheme?n.scheme+":"+t:"//"+t);const d=t.match(u);if(d){if(i.scheme=d[1],i.userinfo=d[3],i.host=d[4],i.port=parseInt(d[5],10),i.path=d[6]||"",i.query=d[7],i.fragment=d[8],isNaN(i.port)&&(i.port=d[5]),i.host)if(!1===s(i.host)){const t=e(i.host);i.host=t.host.toLowerCase(),c=t.isIPV6}else c=!0;void 0!==i.scheme||void 0!==i.userinfo||void 0!==i.host||void 0!==i.port||void 0!==i.query||i.path?void 0===i.scheme?i.reference="relative":void 0===i.fragment?i.reference="absolute":i.reference="uri":i.reference="same-document",n.reference&&"suffix"!==n.reference&&n.reference!==i.reference&&(i.error=i.error||"URI is not a "+n.reference+" reference.");const r=o(n.scheme||i.scheme);if(!(n.unicodeSupport||r&&r.unicodeSupport)&&i.host&&(n.domainHost||r&&r.domainHost)&&!1===c&&a(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(e){i.error=i.error||"Host's domain name can not be converted to ASCII: "+e}(!r||r&&!r.skipNormalize)&&(-1!==t.indexOf("%")&&(void 0!==i.scheme&&(i.scheme=unescape(i.scheme)),void 0!==i.host&&(i.host=unescape(i.host))),i.path&&(i.path=escape(unescape(i.path))),i.fragment&&(i.fragment=encodeURI(decodeURIComponent(i.fragment)))),r&&r.parse&&r.parse(i,n)}else i.error=i.error||"URI can not be parsed.";return i}const p={SCHEMES:i,normalize:function(e,t){return"string"==typeof e?e=d(l(e,t),t):"object"==typeof e&&(e=l(d(e,t),t)),e},resolve:function(e,t,r){const n=r?Object.assign({scheme:"null"},r):{scheme:"null"},s=c(l(e,n),l(t,n),n,!0);return n.skipEscape=!0,d(s,n)},resolveComponent:c,equal:function(e,t,r){return"string"==typeof e?(e=unescape(e),e=d(n(l(e,r),!0),{...r,skipEscape:!0})):"object"==typeof e&&(e=d(n(e,!0),{...r,skipEscape:!0})),"string"==typeof t?(t=unescape(t),t=d(n(l(t,r),!0),{...r,skipEscape:!0})):"object"==typeof t&&(t=d(n(t,!0),{...r,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()},serialize:d,parse:l};return fl.exports=p,fl.exports.default=p,fl.exports.fastUri=p,fl.exports}();return e.code='require("ajv/dist/runtime/uri").default',pl.default=e,pl}(),f=(e,t)=>new RegExp(e,t);f.code="new RegExp";const h=["removeAdditional","useDefaults","coerceTypes"],m=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),g={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},y={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};function _(e){var t,r,n,s,a,i,o,c,d,u,l,h,m,g,y,_,v,w,b,k,$,S,E,T,x;const N=e.strict,O=null===(t=e.code)||void 0===t?void 0:t.optimize,P=!0===O||void 0===O?1:O||0,I=null!==(n=null===(r=e.code)||void 0===r?void 0:r.regExp)&&void 0!==n?n:f,R=null!==(s=e.uriResolver)&&void 0!==s?s:p.default;return{strictSchema:null===(i=null!==(a=e.strictSchema)&&void 0!==a?a:N)||void 0===i||i,strictNumbers:null===(c=null!==(o=e.strictNumbers)&&void 0!==o?o:N)||void 0===c||c,strictTypes:null!==(u=null!==(d=e.strictTypes)&&void 0!==d?d:N)&&void 0!==u?u:"log",strictTuples:null!==(h=null!==(l=e.strictTuples)&&void 0!==l?l:N)&&void 0!==h?h:"log",strictRequired:null!==(g=null!==(m=e.strictRequired)&&void 0!==m?m:N)&&void 0!==g&&g,code:e.code?{...e.code,optimize:P,regExp:I}:{optimize:P,regExp:I},loopRequired:null!==(y=e.loopRequired)&&void 0!==y?y:200,loopEnum:null!==(_=e.loopEnum)&&void 0!==_?_:200,meta:null===(v=e.meta)||void 0===v||v,messages:null===(w=e.messages)||void 0===w||w,inlineRefs:null===(b=e.inlineRefs)||void 0===b||b,schemaId:null!==(k=e.schemaId)&&void 0!==k?k:"$id",addUsedSchema:null===($=e.addUsedSchema)||void 0===$||$,validateSchema:null===(S=e.validateSchema)||void 0===S||S,validateFormats:null===(E=e.validateFormats)||void 0===E||E,unicodeRegExp:null===(T=e.unicodeRegExp)||void 0===T||T,int32range:null===(x=e.int32range)||void 0===x||x,uriResolver:R}}class v{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,..._(e)};const{es5:t,lines:r}=this.opts.code;this.scope=new o.ValueScope({scope:{},prefixes:m,es5:t,lines:r}),this.logger=function(e){if(!1===e)return T;if(void 0===e)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}(e.logger);const n=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a.getRules)(),w.call(this,g,e,"NOT SUPPORTED"),w.call(this,y,e,"DEPRECATED","warn"),this._metaOpts=E.call(this),e.formats&&$.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&S.call(this,e.keywords),"object"==typeof e.meta&&this.addMetaSchema(e.meta),k.call(this),e.validateFormats=n}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:e,meta:t,schemaId:r}=this.opts;let n=l;"id"===r&&(n={...l},n.id=n.$id,delete n.$id),t&&e&&this.addMetaSchema(n,n[r],!1)}defaultMeta(){const{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta="object"==typeof e?e[t]||e:void 0}validate(e,t){let r;if("string"==typeof e){if(r=this.getSchema(e),!r)throw new Error(`no schema with key or ref "${e}"`)}else r=this.compile(e);const n=r(t);return"$async"in r||(this.errors=r.errors),n}compile(e,t){const r=this._addSchema(e,t);return r.validate||this._compileSchemaEnv(r)}compileAsync(e,t){if("function"!=typeof this.opts.loadSchema)throw new Error("options.loadSchema should be a function");const{loadSchema:r}=this.opts;return n.call(this,e,t);async function n(e,t){await a.call(this,e.$schema);const r=this._addSchema(e,t);return r.validate||i.call(this,r)}async function a(e){e&&!this.getSchema(e)&&await n.call(this,{$ref:e},!0)}async function i(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof s.default))throw t;return o.call(this,t),await c.call(this,t.missingSchema),i.call(this,e)}}function o({missingSchema:e,missingRef:t}){if(this.refs[e])throw new Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){const r=await d.call(this,e);this.refs[e]||await a.call(this,r.$schema),this.refs[e]||this.addSchema(r,e,t)}async function d(e){const t=this._loading[e];if(t)return t;try{return await(this._loading[e]=r(e))}finally{delete this._loading[e]}}}addSchema(e,t,r,n=this.opts.validateSchema){if(Array.isArray(e)){for(const t of e)this.addSchema(t,void 0,r,n);return this}let s;if("object"==typeof e){const{schemaId:t}=this.opts;if(s=e[t],void 0!==s&&"string"!=typeof s)throw new Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||s),this._checkUnique(t),this.schemas[t]=this._addSchema(e,r,t,n,!0),this}addMetaSchema(e,t,r=this.opts.validateSchema){return this.addSchema(e,t,!0,r),this}validateSchema(e,t){if("boolean"==typeof e)return!0;let r;if(r=e.$schema,void 0!==r&&"string"!=typeof r)throw new Error("$schema must be a string");if(r=r||this.opts.defaultMeta||this.defaultMeta(),!r)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const n=this.validate(r,e);if(!n&&t){const e="schema is invalid: "+this.errorsText();if("log"!==this.opts.validateSchema)throw new Error(e);this.logger.error(e)}return n}getSchema(e){let t;for(;"string"==typeof(t=b.call(this,e));)e=t;if(void 0===t){const{schemaId:r}=this.opts,n=new i.SchemaEnv({schema:{},schemaId:r});if(t=i.resolveSchema.call(this,n,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const t=b.call(this,e);return"object"==typeof t&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{const t=e;this._cache.delete(t);let r=e[this.opts.schemaId];return r&&(r=(0,c.normalizeId)(r),delete this.schemas[r],delete this.refs[r]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(const t of e)this.addKeyword(t);return this}addKeyword(e,t){let r;if("string"==typeof e)r=e,"object"==typeof t&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),t.keyword=r);else{if("object"!=typeof e||void 0!==t)throw new Error("invalid addKeywords parameters");if(r=(t=e).keyword,Array.isArray(r)&&!r.length)throw new Error("addKeywords: keyword must be string or non-empty array")}if(N.call(this,r,t),!t)return(0,u.eachItem)(r,e=>O.call(this,e)),this;I.call(this,t);const n={...t,type:(0,d.getJSONTypes)(t.type),schemaType:(0,d.getJSONTypes)(t.schemaType)};return(0,u.eachItem)(r,0===n.type.length?e=>O.call(this,e,n):e=>n.type.forEach(t=>O.call(this,e,n,t))),this}getKeyword(e){const t=this.RULES.all[e];return"object"==typeof t?t.definition:!!t}removeKeyword(e){const{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(const r of t.rules){const t=r.rules.findIndex(t=>t.keyword===e);t>=0&&r.rules.splice(t,1)}return this}addFormat(e,t){return"string"==typeof t&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=", ",dataVar:r="data"}={}){return e&&0!==e.length?e.map(e=>`${r}${e.instancePath} ${e.message}`).reduce((e,r)=>e+t+r):"No errors"}$dataMetaSchema(e,t){const r=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(const n of t){const t=n.split("/").slice(1);let s=e;for(const e of t)s=s[e];for(const e in r){const t=r[e];if("object"!=typeof t)continue;const{$data:n}=t.definition,a=s[e];n&&a&&(s[e]=j(a))}}return e}_removeAllSchemas(e,t){for(const r in e){const n=e[r];t&&!t.test(r)||("string"==typeof n?delete e[r]:n&&!n.meta&&(this._cache.delete(n.schema),delete e[r]))}}_addSchema(e,t,r,n=this.opts.validateSchema,s=this.opts.addUsedSchema){let a;const{schemaId:o}=this.opts;if("object"==typeof e)a=e[o];else{if(this.opts.jtd)throw new Error("schema must be object");if("boolean"!=typeof e)throw new Error("schema must be object or boolean")}let d=this._cache.get(e);if(void 0!==d)return d;r=(0,c.normalizeId)(a||r);const u=c.getSchemaRefs.call(this,e,r);return d=new i.SchemaEnv({schema:e,schemaId:o,meta:t,baseId:r,localRefs:u}),this._cache.set(d.schema,d),s&&!r.startsWith("#")&&(r&&this._checkUnique(r),this.refs[r]=d),n&&this.validateSchema(e,!0),d}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):i.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){const t=this.opts;this.opts=this._metaOpts;try{i.compileSchema.call(this,e)}finally{this.opts=t}}}function w(e,t,r,n="error"){for(const s in e){const a=s;a in t&&this.logger[n](`${r}: option ${s}. ${e[a]}`)}}function b(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function k(){const e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(const t in e)this.addSchema(e[t],t)}function $(){for(const e in this.opts.formats){const t=this.opts.formats[e];t&&this.addFormat(e,t)}}function S(e){if(Array.isArray(e))this.addVocabulary(e);else{this.logger.warn("keywords option as map is deprecated, pass array");for(const t in e){const r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}}function E(){const e={...this.opts};for(const t of h)delete e[t];return e}v.ValidationError=n.default,v.MissingRefError=s.default,e.default=v;const T={log(){},warn(){},error(){}},x=/^[a-z_$][a-z0-9_$:-]*$/i;function N(e,t){const{RULES:r}=this;if((0,u.eachItem)(e,e=>{if(r.keywords[e])throw new Error(`Keyword ${e} is already defined`);if(!x.test(e))throw new Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!("code"in t)&&!("validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function O(e,t,r){var n;const s=null==t?void 0:t.post;if(r&&s)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:a}=this;let i=s?a.post:a.rules.find(({type:e})=>e===r);if(i||(i={type:r,rules:[]},a.rules.push(i)),a.keywords[e]=!0,!t)return;const o={keyword:e,definition:{...t,type:(0,d.getJSONTypes)(t.type),schemaType:(0,d.getJSONTypes)(t.schemaType)}};t.before?P.call(this,i,o,t.before):i.rules.push(o),a.all[e]=o,null===(n=t.implements)||void 0===n||n.forEach(e=>this.addKeyword(e))}function P(e,t,r){const n=e.rules.findIndex(e=>e.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function I(e){let{metaSchema:t}=e;void 0!==t&&(e.$data&&this.opts.$data&&(t=j(t)),e.validateSchema=this.compile(t,!0))}const R={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function j(e){return{anyOf:[e,R]}}}(Qd)),Qd}var gl,yl,_l,vl={},wl={},bl={},kl={};var $l,Sl,El,Tl,xl={},Nl={},Ol={},Pl={},Il={};var Rl,jl,zl,Cl={},Al={},Ml={};var Zl,Dl,Ll,Fl={},ql={},Ul={};function Vl(){if(Dl)return Ul;Dl=1,Object.defineProperty(Ul,"__esModule",{value:!0});const e=Fu();return e.code='require("ajv/dist/runtime/equal").default',Ul.default=e,Ul}function Hl(){if(Ll)return ql;Ll=1,Object.defineProperty(ql,"__esModule",{value:!0});const e=Nu(),t=uu(),r=fu(),n=Vl(),s={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:e,j:r}})=>t.str`must NOT have duplicate items (items ## ${r} and ${e} are identical)`,params:({params:{i:e,j:r}})=>t._`{i: ${e}, j: ${r}}`},code(s){const{gen:a,data:i,$data:o,schema:c,parentSchema:d,schemaCode:u,it:l}=s;if(!o&&!c)return;const p=a.let("valid"),f=d.items?(0,e.getSchemaTypes)(d.items):[];function h(r,n){const o=a.name("item"),c=(0,e.checkDataTypes)(f,o,l.opts.strictNumbers,e.DataType.Wrong),d=a.const("indices",t._`{}`);a.for(t._`;${r}--;`,()=>{a.let(o,t._`${i}[${r}]`),a.if(c,t._`continue`),f.length>1&&a.if(t._`typeof ${o} == "string"`,t._`${o} += "_"`),a.if(t._`typeof ${d}[${o}] == "number"`,()=>{a.assign(n,t._`${d}[${o}]`),s.error(),a.assign(p,!1).break()}).code(t._`${d}[${o}] = ${r}`)})}function m(e,o){const c=(0,r.useFunc)(a,n.default),d=a.name("outer");a.label(d).for(t._`;${e}--;`,()=>a.for(t._`${o} = ${e}; ${o}--;`,()=>a.if(t._`${c}(${i}[${e}], ${i}[${o}])`,()=>{s.error(),a.assign(p,!1).break(d)})))}s.block$data(p,function(){const e=a.let("i",t._`${i}.length`),r=a.let("j");s.setParams({i:e,j:r}),a.assign(p,!0),a.if(t._`${e} > 1`,()=>(f.length>0&&!f.some(e=>"object"===e||"array"===e)?h:m)(e,r))},t._`${u} === false`),s.ok(p)}};return ql.default=s,ql}var Jl,Kl,Bl,Gl={},Xl={};function Wl(){if(Bl)return xl;Bl=1,Object.defineProperty(xl,"__esModule",{value:!0});const e=function(){if($l)return Nl;$l=1,Object.defineProperty(Nl,"__esModule",{value:!0});const e=uu(),t=e.operators,r={maximum:{okStr:"<=",ok:t.LTE,fail:t.GT},minimum:{okStr:">=",ok:t.GTE,fail:t.LT},exclusiveMaximum:{okStr:"<",ok:t.LT,fail:t.GTE},exclusiveMinimum:{okStr:">",ok:t.GT,fail:t.LTE}},n={message:({keyword:t,schemaCode:n})=>e.str`must be ${r[t].okStr} ${n}`,params:({keyword:t,schemaCode:n})=>e._`{comparison: ${r[t].okStr}, limit: ${n}}`},s={keyword:Object.keys(r),type:"number",schemaType:"number",$data:!0,error:n,code(t){const{keyword:n,data:s,schemaCode:a}=t;t.fail$data(e._`${s} ${r[n].fail} ${a} || isNaN(${s})`)}};return Nl.default=s,Nl}(),t=function(){if(Sl)return Ol;Sl=1,Object.defineProperty(Ol,"__esModule",{value:!0});const e=uu(),t={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:t})=>e.str`must be multiple of ${t}`,params:({schemaCode:t})=>e._`{multipleOf: ${t}}`},code(t){const{gen:r,data:n,schemaCode:s,it:a}=t,i=a.opts.multipleOfPrecision,o=r.let("res"),c=i?e._`Math.abs(Math.round(${o}) - ${o}) > 1e-${i}`:e._`${o} !== parseInt(${o})`;t.fail$data(e._`(${s} === 0 || (${o} = ${n}/${s}, ${c}))`)}};return Ol.default=t,Ol}(),r=function(){if(Tl)return Pl;Tl=1,Object.defineProperty(Pl,"__esModule",{value:!0});const e=uu(),t=fu(),r=function(){if(El)return Il;function e(e){const t=e.length;let r,n=0,s=0;for(;s<t;)n++,r=e.charCodeAt(s++),r>=55296&&r<=56319&&s<t&&(r=e.charCodeAt(s),56320==(64512&r)&&s++);return n}return El=1,Object.defineProperty(Il,"__esModule",{value:!0}),Il.default=e,e.code='require("ajv/dist/runtime/ucs2length").default',Il}(),n={message({keyword:t,schemaCode:r}){const n="maxLength"===t?"more":"fewer";return e.str`must NOT have ${n} than ${r} characters`},params:({schemaCode:t})=>e._`{limit: ${t}}`},s={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:n,code(n){const{keyword:s,data:a,schemaCode:i,it:o}=n,c="maxLength"===s?e.operators.GT:e.operators.LT,d=!1===o.opts.unicode?e._`${a}.length`:e._`${(0,t.useFunc)(n.gen,r.default)}(${a})`;n.fail$data(e._`${d} ${c} ${i}`)}};return Pl.default=s,Pl}(),n=function(){if(Rl)return Cl;Rl=1,Object.defineProperty(Cl,"__esModule",{value:!0});const e=Cu(),t=uu(),r={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>t.str`must match pattern "${e}"`,params:({schemaCode:e})=>t._`{pattern: ${e}}`},code(r){const{data:n,$data:s,schema:a,schemaCode:i,it:o}=r,c=o.opts.unicodeRegExp?"u":"",d=s?t._`(new RegExp(${i}, ${c}))`:(0,e.usePattern)(r,a);r.fail$data(t._`!${d}.test(${n})`)}};return Cl.default=r,Cl}(),s=function(){if(jl)return Al;jl=1,Object.defineProperty(Al,"__esModule",{value:!0});const e=uu(),t={message({keyword:t,schemaCode:r}){const n="maxProperties"===t?"more":"fewer";return e.str`must NOT have ${n} than ${r} properties`},params:({schemaCode:t})=>e._`{limit: ${t}}`},r={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:t,code(t){const{keyword:r,data:n,schemaCode:s}=t,a="maxProperties"===r?e.operators.GT:e.operators.LT;t.fail$data(e._`Object.keys(${n}).length ${a} ${s}`)}};return Al.default=r,Al}(),a=function(){if(zl)return Ml;zl=1,Object.defineProperty(Ml,"__esModule",{value:!0});const e=Cu(),t=uu(),r=fu(),n={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:e}})=>t.str`must have required property '${e}'`,params:({params:{missingProperty:e}})=>t._`{missingProperty: ${e}}`},code(n){const{gen:s,schema:a,schemaCode:i,data:o,$data:c,it:d}=n,{opts:u}=d;if(!c&&0===a.length)return;const l=a.length>=u.loopRequired;if(d.allErrors?function(){if(l||c)n.block$data(t.nil,p);else for(const t of a)(0,e.checkReportMissingProp)(n,t)}():function(){const r=s.let("missing");if(l||c){const a=s.let("valid",!0);n.block$data(a,()=>function(r,a){n.setParams({missingProperty:r}),s.forOf(r,i,()=>{s.assign(a,(0,e.propertyInData)(s,o,r,u.ownProperties)),s.if((0,t.not)(a),()=>{n.error(),s.break()})},t.nil)}(r,a)),n.ok(a)}else s.if((0,e.checkMissingProp)(n,a,r)),(0,e.reportMissingProp)(n,r),s.else()}(),u.strictRequired){const e=n.parentSchema.properties,{definedProperties:t}=n.it;for(const n of a)if(void 0===(null==e?void 0:e[n])&&!t.has(n)){const e=`required property "${n}" is not defined at "${d.schemaEnv.baseId+d.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(d,e,d.opts.strictRequired)}}function p(){s.forOf("prop",i,t=>{n.setParams({missingProperty:t}),s.if((0,e.noPropertyInData)(s,o,t,u.ownProperties),()=>n.error())})}}};return Ml.default=n,Ml}(),i=function(){if(Zl)return Fl;Zl=1,Object.defineProperty(Fl,"__esModule",{value:!0});const e=uu(),t={message({keyword:t,schemaCode:r}){const n="maxItems"===t?"more":"fewer";return e.str`must NOT have ${n} than ${r} items`},params:({schemaCode:t})=>e._`{limit: ${t}}`},r={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:t,code(t){const{keyword:r,data:n,schemaCode:s}=t,a="maxItems"===r?e.operators.GT:e.operators.LT;t.fail$data(e._`${n}.length ${a} ${s}`)}};return Fl.default=r,Fl}(),o=Hl(),c=function(){if(Jl)return Gl;Jl=1,Object.defineProperty(Gl,"__esModule",{value:!0});const e=uu(),t=fu(),r=Vl(),n={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:t})=>e._`{allowedValue: ${t}}`},code(n){const{gen:s,data:a,$data:i,schemaCode:o,schema:c}=n;i||c&&"object"==typeof c?n.fail$data(e._`!${(0,t.useFunc)(s,r.default)}(${a}, ${o})`):n.fail(e._`${c} !== ${a}`)}};return Gl.default=n,Gl}(),d=function(){if(Kl)return Xl;Kl=1,Object.defineProperty(Xl,"__esModule",{value:!0});const e=uu(),t=fu(),r=Vl(),n={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:t})=>e._`{allowedValues: ${t}}`},code(n){const{gen:s,data:a,$data:i,schema:o,schemaCode:c,it:d}=n;if(!i&&0===o.length)throw new Error("enum must have non-empty array");const u=o.length>=d.opts.loopEnum;let l;const p=()=>null!=l?l:l=(0,t.useFunc)(s,r.default);let f;if(u||i)f=s.let("valid"),n.block$data(f,function(){s.assign(f,!1),s.forOf("v",c,t=>s.if(e._`${p()}(${a}, ${t})`,()=>s.assign(f,!0).break()))});else{if(!Array.isArray(o))throw new Error("ajv implementation error");const t=s.const("vSchema",c);f=(0,e.or)(...o.map((r,n)=>function(t,r){const n=o[r];return"object"==typeof n&&null!==n?e._`${p()}(${a}, ${t}[${r}])`:e._`${a} === ${n}`}(t,n)))}n.pass(f)}};return Xl.default=n,Xl}(),u=[e.default,t.default,r.default,n.default,s.default,a.default,i.default,o.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},c.default,d.default];return xl.default=u,xl}var Yl,Ql={},ep={};function tp(){if(Yl)return ep;Yl=1,Object.defineProperty(ep,"__esModule",{value:!0}),ep.validateAdditionalItems=void 0;const e=uu(),t=fu(),r={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:t}})=>e.str`must NOT have more than ${t} items`,params:({params:{len:t}})=>e._`{limit: ${t}}`},code(e){const{parentSchema:r,it:s}=e,{items:a}=r;Array.isArray(a)?n(e,a):(0,t.checkStrictMode)(s,'"additionalItems" is ignored when "items" is not an array of schemas')}};function n(r,n){const{gen:s,schema:a,data:i,keyword:o,it:c}=r;c.items=!0;const d=s.const("len",e._`${i}.length`);if(!1===a)r.setParams({len:n.length}),r.pass(e._`${d} <= ${n.length}`);else if("object"==typeof a&&!(0,t.alwaysValidSchema)(c,a)){const a=s.var("valid",e._`${d} <= ${n.length}`);s.if((0,e.not)(a),()=>function(a){s.forRange("i",n.length,d,n=>{r.subschema({keyword:o,dataProp:n,dataPropType:t.Type.Num},a),c.allErrors||s.if((0,e.not)(a),()=>s.break())})}(a)),r.ok(a)}}return ep.validateAdditionalItems=n,ep.default=r,ep}var rp,np,sp={},ap={};function ip(){if(rp)return ap;rp=1,Object.defineProperty(ap,"__esModule",{value:!0}),ap.validateTuple=void 0;const e=uu(),t=fu(),r=Cu(),n={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:n,it:a}=e;if(Array.isArray(n))return s(e,"additionalItems",n);a.items=!0,(0,t.alwaysValidSchema)(a,n)||e.ok((0,r.validateArray)(e))}};function s(r,n,s=r.schema){const{gen:a,parentSchema:i,data:o,keyword:c,it:d}=r;!function(e){const{opts:r,errSchemaPath:a}=d,i=s.length,o=i===e.minItems&&(i===e.maxItems||!1===e[n]);if(r.strictTuples&&!o){const e=`"${c}" is ${i}-tuple, but minItems or maxItems/${n} are not specified or different at path "${a}"`;(0,t.checkStrictMode)(d,e,r.strictTuples)}}(i),d.opts.unevaluated&&s.length&&!0!==d.items&&(d.items=t.mergeEvaluated.items(a,s.length,d.items));const u=a.name("valid"),l=a.const("len",e._`${o}.length`);s.forEach((n,s)=>{(0,t.alwaysValidSchema)(d,n)||(a.if(e._`${l} > ${s}`,()=>r.subschema({keyword:c,schemaProp:s,dataProp:s},u)),r.ok(u))})}return ap.validateTuple=s,ap.default=n,ap}var op,cp,dp={},up={};var lp,pp={};var fp,hp,mp={},gp={};function yp(){if(hp)return gp;hp=1,Object.defineProperty(gp,"__esModule",{value:!0});const e=Cu(),t=uu(),r=_u(),n=fu(),s={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:e})=>t._`{additionalProperty: ${e.additionalProperty}}`},code(s){const{gen:a,schema:i,parentSchema:o,data:c,errsCount:d,it:u}=s;if(!d)throw new Error("ajv implementation error");const{allErrors:l,opts:p}=u;if(u.props=!0,"all"!==p.removeAdditional&&(0,n.alwaysValidSchema)(u,i))return;const f=(0,e.allSchemaProperties)(o.properties),h=(0,e.allSchemaProperties)(o.patternProperties);function m(e){a.code(t._`delete ${c}[${e}]`)}function g(e){if("all"===p.removeAdditional||p.removeAdditional&&!1===i)m(e);else{if(!1===i)return s.setParams({additionalProperty:e}),s.error(),void(l||a.break());if("object"==typeof i&&!(0,n.alwaysValidSchema)(u,i)){const r=a.name("valid");"failing"===p.removeAdditional?(y(e,r,!1),a.if((0,t.not)(r),()=>{s.reset(),m(e)})):(y(e,r),l||a.if((0,t.not)(r),()=>a.break()))}}}function y(e,t,r){const a={keyword:"additionalProperties",dataProp:e,dataPropType:n.Type.Str};!1===r&&Object.assign(a,{compositeRule:!0,createErrors:!1,allErrors:!1}),s.subschema(a,t)}a.forIn("key",c,r=>{f.length||h.length?a.if(function(r){let i;if(f.length>8){const t=(0,n.schemaRefOrVal)(u,o.properties,"properties");i=(0,e.isOwnProperty)(a,t,r)}else i=f.length?(0,t.or)(...f.map(e=>t._`${r} === ${e}`)):t.nil;return h.length&&(i=(0,t.or)(i,...h.map(n=>t._`${(0,e.usePattern)(s,n)}.test(${r})`))),(0,t.not)(i)}(r),()=>g(r)):g(r)}),s.ok(t._`${d} === ${r.default.errors}`)}};return gp.default=s,gp}var _p,vp,wp,bp,kp,$p,Sp,Ep,Tp,xp={},Np={},Op={},Pp={},Ip={},Rp={},jp={},zp={};function Cp(){if(Tp)return Ql;Tp=1,Object.defineProperty(Ql,"__esModule",{value:!0});const e=tp(),t=function(){if(np)return sp;np=1,Object.defineProperty(sp,"__esModule",{value:!0});const e=ip(),t={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,e.validateTuple)(t,"items")};return sp.default=t,sp}(),r=ip(),n=function(){if(op)return dp;op=1,Object.defineProperty(dp,"__esModule",{value:!0});const e=uu(),t=fu(),r=Cu(),n=tp(),s={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:t}})=>e.str`must NOT have more than ${t} items`,params:({params:{len:t}})=>e._`{limit: ${t}}`},code(e){const{schema:s,parentSchema:a,it:i}=e,{prefixItems:o}=a;i.items=!0,(0,t.alwaysValidSchema)(i,s)||(o?(0,n.validateAdditionalItems)(e,o):e.ok((0,r.validateArray)(e)))}};return dp.default=s,dp}(),s=function(){if(cp)return up;cp=1,Object.defineProperty(up,"__esModule",{value:!0});const e=uu(),t=fu(),r={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:t,max:r}})=>void 0===r?e.str`must contain at least ${t} valid item(s)`:e.str`must contain at least ${t} and no more than ${r} valid item(s)`,params:({params:{min:t,max:r}})=>void 0===r?e._`{minContains: ${t}}`:e._`{minContains: ${t}, maxContains: ${r}}`},code(r){const{gen:n,schema:s,parentSchema:a,data:i,it:o}=r;let c,d;const{minContains:u,maxContains:l}=a;o.opts.next?(c=void 0===u?1:u,d=l):c=1;const p=n.const("len",e._`${i}.length`);if(r.setParams({min:c,max:d}),void 0===d&&0===c)return void(0,t.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==d&&c>d)return(0,t.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),void r.fail();if((0,t.alwaysValidSchema)(o,s)){let t=e._`${p} >= ${c}`;return void 0!==d&&(t=e._`${t} && ${p} <= ${d}`),void r.pass(t)}o.items=!0;const f=n.name("valid");function h(){const t=n.name("_valid"),r=n.let("count",0);m(t,()=>n.if(t,()=>function(t){n.code(e._`${t}++`),void 0===d?n.if(e._`${t} >= ${c}`,()=>n.assign(f,!0).break()):(n.if(e._`${t} > ${d}`,()=>n.assign(f,!1).break()),1===c?n.assign(f,!0):n.if(e._`${t} >= ${c}`,()=>n.assign(f,!0)))}(r)))}function m(e,s){n.forRange("i",0,p,n=>{r.subschema({keyword:"contains",dataProp:n,dataPropType:t.Type.Num,compositeRule:!0},e),s()})}void 0===d&&1===c?m(f,()=>n.if(f,()=>n.break())):0===c?(n.let(f,!0),void 0!==d&&n.if(e._`${i}.length > 0`,h)):(n.let(f,!1),h()),r.result(f,()=>r.reset())}};return up.default=r,up}(),a=(lp||(lp=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=uu(),r=fu(),n=Cu();e.error={message:({params:{property:e,depsCount:r,deps:n}})=>{const s=1===r?"property":"properties";return t.str`must have ${s} ${n} when property ${e} is present`},params:({params:{property:e,depsCount:r,deps:n,missingProperty:s}})=>t._`{property: ${e},
5
5
  missingProperty: ${s},
6
6
  depsCount: ${r},
7
- deps: ${n}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(e){const[t,r]=function({schema:e}){const t={},r={};for(const n in e)"__proto__"!==n&&((Array.isArray(e[n])?t:r)[n]=e[n]);return[t,r]}(e);a(e,t),i(e,r)}};function a(e,r=e.schema){const{gen:s,data:a,it:i}=e;if(0===Object.keys(r).length)return;const o=s.let("missing");for(const c in r){const d=r[c];if(0===d.length)continue;const u=(0,n.propertyInData)(s,a,c,i.opts.ownProperties);e.setParams({property:c,depsCount:d.length,deps:d.join(", ")}),i.allErrors?s.if(u,()=>{for(const t of d)(0,n.checkReportMissingProp)(e,t)}):(s.if(t._`${u} && (${(0,n.checkMissingProp)(e,d,o)})`),(0,n.reportMissingProp)(e,o),s.else())}}function i(e,t=e.schema){const{gen:s,data:a,keyword:i,it:o}=e,c=s.name("valid");for(const d in t)(0,r.alwaysValidSchema)(o,t[d])||(s.if((0,n.propertyInData)(s,a,d,o.opts.ownProperties),()=>{const t=e.subschema({keyword:i,schemaProp:d},c);e.mergeValidEvaluated(t,c)},()=>s.var(c,!0)),e.ok(c))}e.validatePropertyDeps=a,e.validateSchemaDeps=i,e.default=s}(pp)),pp),i=function(){if(fp)return mp;fp=1,Object.defineProperty(mp,"__esModule",{value:!0});const e=uu(),t=fu(),r={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:t})=>e._`{propertyName: ${t.propertyName}}`},code(r){const{gen:n,schema:s,data:a,it:i}=r;if((0,t.alwaysValidSchema)(i,s))return;const o=n.name("valid");n.forIn("key",a,t=>{r.setParams({propertyName:t}),r.subschema({keyword:"propertyNames",data:t,dataTypes:["string"],propertyName:t,compositeRule:!0},o),n.if((0,e.not)(o),()=>{r.error(!0),i.allErrors||n.break()})}),r.ok(o)}};return mp.default=r,mp}(),o=yp(),c=function(){if(_p)return xp;_p=1,Object.defineProperty(xp,"__esModule",{value:!0});const e=Bu(),t=Cu(),r=fu(),n=yp(),s={keyword:"properties",type:"object",schemaType:"object",code(s){const{gen:a,schema:i,parentSchema:o,data:c,it:d}=s;"all"===d.opts.removeAdditional&&void 0===o.additionalProperties&&n.default.code(new e.KeywordCxt(d,n.default,"additionalProperties"));const u=(0,t.allSchemaProperties)(i);for(const e of u)d.definedProperties.add(e);d.opts.unevaluated&&u.length&&!0!==d.props&&(d.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),d.props));const l=u.filter(e=>!(0,r.alwaysValidSchema)(d,i[e]));if(0===l.length)return;const p=a.name("valid");for(const e of l)f(e)?h(e):(a.if((0,t.propertyInData)(a,c,e,d.opts.ownProperties)),h(e),d.allErrors||a.else().var(p,!0),a.endIf()),s.it.definedProperties.add(e),s.ok(p);function f(e){return d.opts.useDefaults&&!d.compositeRule&&void 0!==i[e].default}function h(e){s.subschema({keyword:"properties",schemaProp:e,dataProp:e},p)}}};return xp.default=s,xp}(),d=function(){if(vp)return Np;vp=1,Object.defineProperty(Np,"__esModule",{value:!0});const e=Cu(),t=uu(),r=fu(),n=fu(),s={keyword:"patternProperties",type:"object",schemaType:"object",code(s){const{gen:a,schema:i,data:o,parentSchema:c,it:d}=s,{opts:u}=d,l=(0,e.allSchemaProperties)(i),p=l.filter(e=>(0,r.alwaysValidSchema)(d,i[e]));if(0===l.length||p.length===l.length&&(!d.opts.unevaluated||!0===d.props))return;const f=u.strictSchema&&!u.allowMatchingProperties&&c.properties,h=a.name("valid");!0===d.props||d.props instanceof t.Name||(d.props=(0,n.evaluatedPropsToName)(a,d.props));const{props:m}=d;function g(e){for(const t in f)new RegExp(e).test(t)&&(0,r.checkStrictMode)(d,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function y(r){a.forIn("key",o,i=>{a.if(t._`${(0,e.usePattern)(s,r)}.test(${i})`,()=>{const e=p.includes(r);e||s.subschema({keyword:"patternProperties",schemaProp:r,dataProp:i,dataPropType:n.Type.Str},h),d.opts.unevaluated&&!0!==m?a.assign(t._`${m}[${i}]`,!0):e||d.allErrors||a.if((0,t.not)(h),()=>a.break())})})}!function(){for(const e of l)f&&g(e),d.allErrors?y(e):(a.var(h,!0),y(e),a.if(h))}()}};return Np.default=s,Np}(),u=function(){if(wp)return Pp;wp=1,Object.defineProperty(Pp,"__esModule",{value:!0});const e=fu(),t={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){const{gen:r,schema:n,it:s}=t;if((0,e.alwaysValidSchema)(s,n))return void t.fail();const a=r.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},a),t.failResult(a,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};return Pp.default=t,Pp}(),l=function(){if(bp)return Op;bp=1,Object.defineProperty(Op,"__esModule",{value:!0});const e={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Cu().validateUnion,error:{message:"must match a schema in anyOf"}};return Op.default=e,Op}(),p=function(){if(kp)return Ip;kp=1,Object.defineProperty(Ip,"__esModule",{value:!0});const e=uu(),t=fu(),r={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:t})=>e._`{passingSchemas: ${t.passing}}`},code(r){const{gen:n,schema:s,parentSchema:a,it:i}=r;if(!Array.isArray(s))throw new Error("ajv implementation error");if(i.opts.discriminator&&a.discriminator)return;const o=s,c=n.let("valid",!1),d=n.let("passing",null),u=n.name("_valid");r.setParams({passing:d}),n.block(function(){o.forEach((s,a)=>{let o;(0,t.alwaysValidSchema)(i,s)?n.var(u,!0):o=r.subschema({keyword:"oneOf",schemaProp:a,compositeRule:!0},u),a>0&&n.if(e._`${u} && ${c}`).assign(c,!1).assign(d,e._`[${d}, ${a}]`).else(),n.if(u,()=>{n.assign(c,!0),n.assign(d,a),o&&r.mergeEvaluated(o,e.Name)})})}),r.result(c,()=>r.reset(),()=>r.error(!0))}};return Ip.default=r,Ip}(),f=function(){if($p)return jp;$p=1,Object.defineProperty(jp,"__esModule",{value:!0});const e=fu(),t={keyword:"allOf",schemaType:"array",code(t){const{gen:r,schema:n,it:s}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");const a=r.name("valid");n.forEach((r,n)=>{if((0,e.alwaysValidSchema)(s,r))return;const i=t.subschema({keyword:"allOf",schemaProp:n},a);t.ok(a),t.mergeEvaluated(i)})}};return jp.default=t,jp}(),h=function(){if(Sp)return Rp;Sp=1,Object.defineProperty(Rp,"__esModule",{value:!0});const e=uu(),t=fu(),r={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:t})=>e.str`must match "${t.ifClause}" schema`,params:({params:t})=>e._`{failingKeyword: ${t.ifClause}}`},code(r){const{gen:s,parentSchema:a,it:i}=r;void 0===a.then&&void 0===a.else&&(0,t.checkStrictMode)(i,'"if" without "then" and "else" is ignored');const o=n(i,"then"),c=n(i,"else");if(!o&&!c)return;const d=s.let("valid",!0),u=s.name("_valid");if(function(){const e=r.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},u);r.mergeEvaluated(e)}(),r.reset(),o&&c){const e=s.let("ifClause");r.setParams({ifClause:e}),s.if(u,l("then",e),l("else",e))}else o?s.if(u,l("then")):s.if((0,e.not)(u),l("else"));function l(t,n){return()=>{const a=r.subschema({keyword:t},u);s.assign(d,u),r.mergeValidEvaluated(a,d),n?s.assign(n,e._`${t}`):r.setParams({ifClause:t})}}r.pass(d,()=>r.error(!0))}};function n(e,r){const n=e.schema[r];return void 0!==n&&!(0,t.alwaysValidSchema)(e,n)}return Rp.default=r,Rp}(),m=function(){if(Ep)return zp;Ep=1,Object.defineProperty(zp,"__esModule",{value:!0});const e=fu(),t={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:r,it:n}){void 0===r.if&&(0,e.checkStrictMode)(n,`"${t}" without "if" is ignored`)}};return zp.default=t,zp}();return Ql.default=function(g=!1){const y=[u.default,l.default,p.default,f.default,h.default,m.default,i.default,o.default,a.default,c.default,d.default];return g?y.push(t.default,n.default):y.push(e.default,r.default),y.push(s.default),y},Ql}var Ap,Mp,Zp={},Dp={};function Lp(){if(Ap)return Dp;Ap=1,Object.defineProperty(Dp,"__esModule",{value:!0});const e=uu(),t={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:t})=>e.str`must match format "${t}"`,params:({schemaCode:t})=>e._`{format: ${t}}`},code(t,r){const{gen:n,data:s,$data:a,schema:i,schemaCode:o,it:c}=t,{opts:d,errSchemaPath:u,schemaEnv:l,self:p}=c;d.validateFormats&&(a?function(){const a=n.scopeValue("formats",{ref:p.formats,code:d.code.formats}),i=n.const("fDef",e._`${a}[${o}]`),c=n.let("fType"),u=n.let("format");n.if(e._`typeof ${i} == "object" && !(${i} instanceof RegExp)`,()=>n.assign(c,e._`${i}.type || "string"`).assign(u,e._`${i}.validate`),()=>n.assign(c,e._`"string"`).assign(u,i)),t.fail$data((0,e.or)(!1===d.strictSchema?e.nil:e._`${o} && !${u}`,function(){const t=l.$async?e._`(${i}.async ? await ${u}(${s}) : ${u}(${s}))`:e._`${u}(${s})`,n=e._`(typeof ${u} == "function" ? ${t} : ${u}.test(${s}))`;return e._`${u} && ${u} !== true && ${c} === ${r} && !${n}`}()))}():function(){const a=p.formats[i];if(!a)return void function(){if(!1!==d.strictSchema)throw new Error(e());function e(){return`unknown format "${i}" ignored in schema at path "${u}"`}p.logger.warn(e())}();if(!0===a)return;const[o,c,f]=function(t){const r=t instanceof RegExp?(0,e.regexpCode)(t):d.code.formats?e._`${d.code.formats}${(0,e.getProperty)(i)}`:void 0,s=n.scopeValue("formats",{key:i,ref:t,code:r});return"object"!=typeof t||t instanceof RegExp?["string",t,s]:[t.type||"string",t.validate,e._`${s}.validate`]}(a);o===r&&t.pass(function(){if("object"==typeof a&&!(a instanceof RegExp)&&a.async){if(!l.$async)throw new Error("async format in sync schema");return e._`await ${f}(${s})`}return"function"==typeof c?e._`${f}(${s})`:e._`${f}.test(${s})`}())}())}};return Dp.default=t,Dp}var Fp,qp,Up={};function Vp(){if(qp)return vl;qp=1,Object.defineProperty(vl,"__esModule",{value:!0});const e=function(){if(_l)return wl;_l=1,Object.defineProperty(wl,"__esModule",{value:!0});const e=function(){if(gl)return bl;gl=1,Object.defineProperty(bl,"__esModule",{value:!0});const e={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};return bl.default=e,bl}(),t=function(){if(yl)return kl;yl=1,Object.defineProperty(kl,"__esModule",{value:!0}),kl.callRef=kl.getValidate=void 0;const e=el(),t=Cu(),r=uu(),n=_u(),s=nl(),a=fu(),i={keyword:"$ref",schemaType:"string",code(t){const{gen:n,schema:a,it:i}=t,{baseId:d,schemaEnv:u,validateName:l,opts:p,self:f}=i,{root:h}=u;if(("#"===a||"#/"===a)&&d===h.baseId)return function(){if(u===h)return c(t,l,u,u.$async);const e=n.scopeValue("root",{ref:h});return c(t,r._`${e}.validate`,h,h.$async)}();const m=s.resolveRef.call(f,h,d,a);if(void 0===m)throw new e.default(i.opts.uriResolver,d,a);return m instanceof s.SchemaEnv?function(e){const r=o(t,e);c(t,r,e,e.$async)}(m):function(e){const s=n.scopeValue("schema",!0===p.code.source?{ref:e,code:(0,r.stringify)(e)}:{ref:e}),i=n.name("valid"),o=t.subschema({schema:e,dataTypes:[],schemaPath:r.nil,topSchemaRef:s,errSchemaPath:a},i);t.mergeEvaluated(o),t.ok(i)}(m)}};function o(e,t){const{gen:n}=e;return t.validate?n.scopeValue("validate",{ref:t.validate}):r._`${n.scopeValue("wrapper",{ref:t})}.validate`}function c(e,s,i,o){const{gen:c,it:d}=e,{allErrors:u,schemaEnv:l,opts:p}=d,f=p.passContext?n.default.this:r.nil;function h(e){const t=r._`${e}.errors`;c.assign(n.default.vErrors,r._`${n.default.vErrors} === null ? ${t} : ${n.default.vErrors}.concat(${t})`),c.assign(n.default.errors,r._`${n.default.vErrors}.length`)}function m(e){var t;if(!d.opts.unevaluated)return;const n=null===(t=null==i?void 0:i.validate)||void 0===t?void 0:t.evaluated;if(!0!==d.props)if(n&&!n.dynamicProps)void 0!==n.props&&(d.props=a.mergeEvaluated.props(c,n.props,d.props));else{const t=c.var("props",r._`${e}.evaluated.props`);d.props=a.mergeEvaluated.props(c,t,d.props,r.Name)}if(!0!==d.items)if(n&&!n.dynamicItems)void 0!==n.items&&(d.items=a.mergeEvaluated.items(c,n.items,d.items));else{const t=c.var("items",r._`${e}.evaluated.items`);d.items=a.mergeEvaluated.items(c,t,d.items,r.Name)}}o?function(){if(!l.$async)throw new Error("async schema referenced by sync schema");const n=c.let("valid");c.try(()=>{c.code(r._`await ${(0,t.callValidateCode)(e,s,f)}`),m(s),u||c.assign(n,!0)},e=>{c.if(r._`!(${e} instanceof ${d.ValidationError})`,()=>c.throw(e)),h(e),u||c.assign(n,!1)}),e.ok(n)}():e.result((0,t.callValidateCode)(e,s,f),()=>m(s),()=>h(s))}return kl.getValidate=o,kl.callRef=c,kl.default=i,kl}(),r=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",e.default,t.default];return wl.default=r,wl}(),t=Xl(),r=Cp(),n=function(){if(Mp)return Zp;Mp=1,Object.defineProperty(Zp,"__esModule",{value:!0});const e=[Lp().default];return Zp.default=e,Zp}(),s=(Fp||(Fp=1,Object.defineProperty(Up,"__esModule",{value:!0}),Up.contentVocabulary=Up.metadataVocabulary=void 0,Up.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],Up.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]),Up),a=[e.default,t.default,(0,r.default)(),n.default,s.metadataVocabulary,s.contentVocabulary];return vl.default=a,vl}var Hp,Jp,Kp={},Bp={};var Gp,Wp={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0};function Xp(){return Gp||(Gp=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv=void 0;const r=ml(),n=Vp(),s=function(){if(Jp)return Kp;Jp=1,Object.defineProperty(Kp,"__esModule",{value:!0});const e=uu(),t=(Hp||(Hp=1,Object.defineProperty(Bp,"__esModule",{value:!0}),Bp.DiscrError=void 0,function(e){e.Tag="tag",e.Mapping="mapping"}(r||(Bp.DiscrError=r={}))),Bp);var r;const n=nl(),s=el(),a=fu(),i={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:e,tagName:r}})=>e===t.DiscrError.Tag?`tag "${r}" must be string`:`value of tag "${r}" must be in oneOf`,params:({params:{discrError:t,tag:r,tagName:n}})=>e._`{error: ${t}, tag: ${n}, tagValue: ${r}}`},code(r){const{gen:i,data:o,schema:c,parentSchema:d,it:u}=r,{oneOf:l}=d;if(!u.opts.discriminator)throw new Error("discriminator: requires discriminator option");const p=c.propertyName;if("string"!=typeof p)throw new Error("discriminator: requires propertyName");if(c.mapping)throw new Error("discriminator: mapping is not supported");if(!l)throw new Error("discriminator: requires oneOf keyword");const f=i.let("valid",!1),h=i.const("tag",e._`${o}${(0,e.getProperty)(p)}`);function m(t){const n=i.name("valid"),s=r.subschema({keyword:"oneOf",schemaProp:t},n);return r.mergeEvaluated(s,e.Name),n}i.if(e._`typeof ${h} == "string"`,()=>function(){const o=function(){var e;const t={},r=o(d);let i=!0;for(let t=0;t<l.length;t++){let d=l[t];if((null==d?void 0:d.$ref)&&!(0,a.schemaHasRulesButRef)(d,u.self.RULES)){const e=d.$ref;if(d=n.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),d instanceof n.SchemaEnv&&(d=d.schema),void 0===d)throw new s.default(u.opts.uriResolver,u.baseId,e)}const f=null===(e=null==d?void 0:d.properties)||void 0===e?void 0:e[p];if("object"!=typeof f)throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${p}"`);i=i&&(r||o(d)),c(f,t)}if(!i)throw new Error(`discriminator: "${p}" must be required`);return t;function o({required:e}){return Array.isArray(e)&&e.includes(p)}function c(e,t){if(e.const)f(e.const,t);else{if(!e.enum)throw new Error(`discriminator: "properties/${p}" must have "const" or "enum"`);for(const r of e.enum)f(r,t)}}function f(e,r){if("string"!=typeof e||e in t)throw new Error(`discriminator: "${p}" values must be unique strings`);t[e]=r}}();i.if(!1);for(const t in o)i.elseIf(e._`${h} === ${t}`),i.assign(f,m(o[t]));i.else(),r.error(!1,{discrError:t.DiscrError.Mapping,tag:h,tagName:p}),i.endIf()}(),()=>r.error(!1,{discrError:t.DiscrError.Tag,tag:h,tagName:p})),r.ok(f)}};return Kp.default=i,Kp}(),a=Wp,i=["/properties"],o="http://json-schema.org/draft-07/schema";class c extends r.default{_addVocabularies(){super._addVocabularies(),n.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const e=this.opts.$data?this.$dataMetaSchema(a,i):a;this.addMetaSchema(e,o,!1),this.refs["http://json-schema.org/schema"]=o}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(o)?o:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var d=Bu();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return d.KeywordCxt}});var u=uu();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var l=Xu();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return l.default}});var p=el();Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return p.default}})}(Yd,Yd.exports)),Yd.exports}var Yp,Qp,ef,tf=Wd(Xp()),rf={exports:{}},nf={},sf={},af=(ef||(ef=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=(Yp||(Yp=1,function(e){function t(e,t){return{validate:e,compare:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0,e.fullFormats={date:t(s,a),time:t(o(!0),c),"date-time":t(l(!0),p),"iso-time":t(o(),d),"iso-date-time":t(l(),f),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:function(e){return h.test(e)&&m.test(e)},"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:function(e){if(w.test(e))return!1;try{return new RegExp(e),!0}catch(e){return!1}},uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:function(e){return g.lastIndex=0,g.test(e)},int32:{type:"number",validate:function(e){return Number.isInteger(e)&&e<=_&&e>=y}},int64:{type:"number",validate:function(e){return Number.isInteger(e)}},float:{type:"number",validate:v},double:{type:"number",validate:v},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,a),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,c),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,d),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,f),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);const r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,n=[0,31,28,31,30,31,30,31,31,30,31,30,31];function s(e){const t=r.exec(e);if(!t)return!1;const s=+t[1],a=+t[2],i=+t[3];return a>=1&&a<=12&&i>=1&&i<=(2===a&&function(e){return e%4==0&&(e%100!=0||e%400==0)}(s)?29:n[a])}function a(e,t){if(e&&t)return e>t?1:e<t?-1:0}const i=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function o(e){return function(t){const r=i.exec(t);if(!r)return!1;const n=+r[1],s=+r[2],a=+r[3],o=r[4],c="-"===r[5]?-1:1,d=+(r[6]||0),u=+(r[7]||0);if(d>23||u>59||e&&!o)return!1;if(n<=23&&s<=59&&a<60)return!0;const l=s-u*c,p=n-d*c-(l<0?1:0);return(23===p||-1===p)&&(59===l||-1===l)&&a<61}}function c(e,t){if(!e||!t)return;const r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();return r&&n?r-n:void 0}function d(e,t){if(!e||!t)return;const r=i.exec(e),n=i.exec(t);return r&&n?(e=r[1]+r[2]+r[3])>(t=n[1]+n[2]+n[3])?1:e<t?-1:0:void 0}const u=/t|\s/i;function l(e){const t=o(e);return function(e){const r=e.split(u);return 2===r.length&&s(r[0])&&t(r[1])}}function p(e,t){if(!e||!t)return;const r=new Date(e).valueOf(),n=new Date(t).valueOf();return r&&n?r-n:void 0}function f(e,t){if(!e||!t)return;const[r,n]=e.split(u),[s,i]=t.split(u),o=a(r,s);return void 0!==o?o||c(n,i):void 0}const h=/\/|:/,m=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,g=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm,y=-2147483648,_=2**31-1;function v(){return!0}const w=/[^\\]\\Z/}(nf)),nf),n=(Qp||(Qp=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=Xp(),r=uu(),n=r.operators,s={formatMaximum:{okStr:"<=",ok:n.LTE,fail:n.GT},formatMinimum:{okStr:">=",ok:n.GTE,fail:n.LT},formatExclusiveMaximum:{okStr:"<",ok:n.LT,fail:n.GTE},formatExclusiveMinimum:{okStr:">",ok:n.GT,fail:n.LTE}},a={message:({keyword:e,schemaCode:t})=>r.str`should be ${s[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>r._`{comparison: ${s[e].okStr}, limit: ${t}}`};e.formatLimitDefinition={keyword:Object.keys(s),type:"string",schemaType:"string",$data:!0,error:a,code(e){const{gen:n,data:a,schemaCode:i,keyword:o,it:c}=e,{opts:d,self:u}=c;if(!d.validateFormats)return;const l=new t.KeywordCxt(c,u.RULES.all.format.definition,"format");function p(e){return r._`${e}.compare(${a}, ${i}) ${s[o].fail} 0`}l.$data?function(){const t=n.scopeValue("formats",{ref:u.formats,code:d.code.formats}),s=n.const("fmt",r._`${t}[${l.schemaCode}]`);e.fail$data((0,r.or)(r._`typeof ${s} != "object"`,r._`${s} instanceof RegExp`,r._`typeof ${s}.compare != "function"`,p(s)))}():function(){const t=l.schema,s=u.formats[t];if(!s||!0===s)return;if("object"!=typeof s||s instanceof RegExp||"function"!=typeof s.compare)throw new Error(`"${o}": format "${t}" does not define "compare" function`);const a=n.scopeValue("formats",{key:t,ref:s,code:d.code.formats?r._`${d.code.formats}${(0,r.getProperty)(t)}`:void 0});e.fail$data(p(a))}()},dependencies:["format"]},e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)}(sf)),sf),s=uu(),a=new s.Name("fullFormats"),i=new s.Name("fastFormats"),o=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,r.fullFormats,a),e;const[s,o]="fast"===t.mode?[r.fastFormats,i]:[r.fullFormats,a];return c(e,t.formats||r.formatNames,s,o),t.keywords&&(0,n.default)(e),e};function c(e,t,r,n){var a,i;null!==(a=(i=e.opts.code).formats)&&void 0!==a||(i.formats=s._`require("ajv-formats/dist/formats").${n}`);for(const n of t)e.addFormat(n,r[n])}o.get=(e,t="full")=>{const n=("fast"===t?r.fastFormats:r.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n},e.exports=t=o,Object.defineProperty(t,"__esModule",{value:!0}),t.default=o}(rf,rf.exports)),rf.exports),of=Wd(af);class cf{constructor(e){this._ajv=e??function(){const e=new tf({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return of(e),e}()}getValidator(e){const t="$id"in e&&"string"==typeof e.$id?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}}class df{constructor(e){this._server=e}requestStream(e,t,r){return this._server.requestStream(e,t,r)}async getTask(e,t){return this._server.getTask({taskId:e},t)}async getTaskResult(e,t,r){return this._server.getTaskResult({taskId:e},t,r)}async listTasks(e,t){return this._server.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._server.cancelTask({taskId:e},t)}}class uf extends Bd{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(bc.options.map((e,t)=>[e,t])),this.isMessageIgnored=(e,t)=>{const r=this._loggingLevels.get(t);return!!r&&this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(r)},this._capabilities=t?.capabilities??{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new cf,this.setRequestHandler(so,e=>this._oninitialize(e)),this.setNotificationHandler(oo,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler($c,async(e,t)=>{const r=t.sessionId||t.requestInfo?.headers["mcp-session-id"]||void 0,{level:n}=e.params,s=bc.safeParse(n);return s.success&&this._loggingLevels.set(r,s.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new df(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=function(e,t){const r={...e};for(const e in t){const n=e,s=t[n];if(void 0===s)continue;const a=r[n];Gd(a)&&Gd(s)?r[n]={...a,...s}:r[n]=s}return r}(this._capabilities,e)}setRequestHandler(e,t){const r=Zs(e),n=r?.method;if(!n)throw new Error("Schema is missing a method literal");let s;if(zs(n)){const e=n,t=e._zod?.def;s=t?.value??e.value}else{const e=n,t=e._def;s=t?.value??e.value}if("string"!=typeof s)throw new Error("Schema method literal must be a string");if("tools/call"===s){const r=async(e,r)=>{const n=As(vc,e);if(!n.success){const e=n.error instanceof Error?n.error.message:String(n.error);throw new od(qi.InvalidParams,`Invalid tools/call request: ${e}`)}const{params:s}=n.data,a=await Promise.resolve(t(e,r));if(s.task){const e=As(_o,a);if(!e.success){const t=e.error instanceof Error?e.error.message:String(e.error);throw new od(qi.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}const i=As(yc,a);if(!i.success){const e=i.error instanceof Error?i.error.message:String(i.error);throw new od(qi.InvalidParams,`Invalid tools/call result: ${e}`)}return i.data};return super.setRequestHandler(e,r)}return super.setRequestHandler(e,t)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`)}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`)}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`)}}assertTaskCapability(e){!function(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`)}}(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&function(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);if("tools/call"===t&&!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`)}(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){const t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:bi.includes(t)?t:wi,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Hi)}async createMessage(e,t){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){const t=e.messages[e.messages.length-1],r=Array.isArray(t.content)?t.content:[t.content],n=r.some(e=>"tool_result"===e.type),s=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=s?Array.isArray(s.content)?s.content:[s.content]:[],i=a.some(e=>"tool_use"===e.type);if(n){if(r.some(e=>"tool_result"!==e.type))throw new Error("The last message must contain only tool_result content if any is present");if(!i)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(i){const e=new Set(a.filter(e=>"tool_use"===e.type).map(e=>e.id)),t=new Set(r.filter(e=>"tool_result"===e.type).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},Ac,t):this.request({method:"sampling/createMessage",params:e},Cc,t)}async elicitInput(e,t){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");const r=e;return this.request({method:"elicitation/create",params:r},Xc,t)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");const r="form"===e.mode?e:{...e,mode:"form"},n=await this.request({method:"elicitation/create",params:r},Xc,t);if("accept"===n.action&&n.content&&r.requestedSchema)try{const e=this._jsonSchemaValidator.getValidator(r.requestedSchema)(n.content);if(!e.valid)throw new od(qi.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){if(e instanceof od)throw e;throw new od(qi.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return n}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},t)}async listRoots(e,t){return this.request({method:"roots/list",params:e},ad,t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}const lf=Symbol.for("mcp.completable");function pf(e){return!!e&&"object"==typeof e&&lf in e}var ff;!function(e){e.Completable="McpCompletable"}(ff||(ff={}));const hf=/^[A-Za-z0-9._-]{1,128}$/;function mf(e){const t=function(e){const t=[];if(0===e.length)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!hf.test(e)){const r=e.split("").filter(e=>!/[A-Za-z0-9._-]/.test(e)).filter((e,t,r)=>r.indexOf(e)===t);return t.push(`Tool name contains invalid characters: ${r.map(e=>`"${e}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}(e);return function(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(const e of t)console.warn(` - ${e}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}(e,t.warnings),t.isValid}class gf{constructor(e){this._mcpServer=e}registerToolTask(e,t,r){const n={taskSupport:"required",...t.execution};if("forbidden"===n.taskSupport)throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,t.title,t.description,t.inputSchema,t.outputSchema,t.annotations,n,t._meta,r)}}class yf{constructor(e,t){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new uf(e,t)}get experimental(){return this._experimental||(this._experimental={tasks:new gf(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler($f(mc)),this.server.assertCanSetRequestHandler($f(vc)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(mc,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>{const r={name:e,title:t.title,description:t.description,inputSchema:(()=>{const e=Ds(t.inputSchema);return e?Hd(e,{strictUnions:!0,pipeStrategy:"input"}):_f})(),annotations:t.annotations,execution:t.execution,_meta:t._meta};if(t.outputSchema){const e=Ds(t.outputSchema);e&&(r.outputSchema=Hd(e,{strictUnions:!0,pipeStrategy:"output"}))}return r})})),this.server.setRequestHandler(vc,async(e,t)=>{try{const r=this._registeredTools[e.params.name];if(!r)throw new od(qi.InvalidParams,`Tool ${e.params.name} not found`);if(!r.enabled)throw new od(qi.InvalidParams,`Tool ${e.params.name} disabled`);const n=!!e.params.task,s=r.execution?.taskSupport,a="createTask"in r.handler;if(("required"===s||"optional"===s)&&!a)throw new od(qi.InternalError,`Tool ${e.params.name} has taskSupport '${s}' but was not registered with registerToolTask`);if("required"===s&&!n)throw new od(qi.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if("optional"===s&&!n&&a)return await this.handleAutomaticTaskPolling(r,e,t);const i=await this.validateToolInput(r,e.params.arguments,e.params.name),o=await this.executeToolHandler(r,i,t);return n||await this.validateToolOutput(r,o,e.params.name),o}catch(e){if(e instanceof od&&e.code===qi.UrlElicitationRequired)throw e;return this.createToolError(e instanceof Error?e.message:String(e))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,t,r){if(!e.inputSchema)return;const n=Ds(e.inputSchema)??e.inputSchema,s=await Ms(n,t);if(!s.success){const e=Ls("error"in s?s.error:"Unknown error");throw new od(qi.InvalidParams,`Input validation error: Invalid arguments for tool ${r}: ${e}`)}return s.data}async validateToolOutput(e,t,r){if(!e.outputSchema)return;if(!("content"in t))return;if(t.isError)return;if(!t.structuredContent)throw new od(qi.InvalidParams,`Output validation error: Tool ${r} has an output schema but no structured content was provided`);const n=Ds(e.outputSchema),s=await Ms(n,t.structuredContent);if(!s.success){const e=Ls("error"in s?s.error:"Unknown error");throw new od(qi.InvalidParams,`Output validation error: Invalid structured content for tool ${r}: ${e}`)}}async executeToolHandler(e,t,r){const n=e.handler;if("createTask"in n){if(!r.taskStore)throw new Error("No task store provided.");const s={...r,taskStore:r.taskStore};if(e.inputSchema){const e=n;return await Promise.resolve(e.createTask(t,s))}{const e=n;return await Promise.resolve(e.createTask(s))}}if(e.inputSchema){const e=n;return await Promise.resolve(e(t,r))}{const e=n;return await Promise.resolve(e(r))}}async handleAutomaticTaskPolling(e,t,r){if(!r.taskStore)throw new Error("No task store provided for task-capable tool.");const n=await this.validateToolInput(e,t.params.arguments,t.params.name),s=e.handler,a={...r,taskStore:r.taskStore},i=n?await Promise.resolve(s.createTask(n,a)):await Promise.resolve(s.createTask(a)),o=i.task.taskId;let c=i.task;const d=c.pollInterval??5e3;for(;"completed"!==c.status&&"failed"!==c.status&&"cancelled"!==c.status;){await new Promise(e=>setTimeout(e,d));const e=await r.taskStore.getTask(o);if(!e)throw new od(qi.InternalError,`Task ${o} not found during polling`);c=e}return await r.taskStore.getTaskResult(o)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler($f(td)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(td,async e=>{switch(e.params.ref.type){case"ref/prompt":return function(e){if("ref/prompt"!==e.params.ref.type)throw new TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return function(e){if("ref/resource"!==e.params.ref.type)throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}(e),this.handleResourceCompletion(e,e.params.ref);default:throw new od(qi.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,t){const r=this._registeredPrompts[t.name];if(!r)throw new od(qi.InvalidParams,`Prompt ${t.name} not found`);if(!r.enabled)throw new od(qi.InvalidParams,`Prompt ${t.name} disabled`);if(!r.argsSchema)return Ef;const n=Zs(r.argsSchema),s=n?.[e.params.argument.name];if(!pf(s))return Ef;const a=function(e){const t=e[lf];return t?.complete}(s);return a?Sf(await a(e.params.argument.value,e.params.context)):Ef}async handleResourceCompletion(e,t){const r=Object.values(this._registeredResourceTemplates).find(e=>e.resourceTemplate.uriTemplate.toString()===t.uri);if(!r){if(this._registeredResources[t.uri])return Ef;throw new od(qi.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}const n=r.resourceTemplate.completeCallback(e.params.argument.name);return n?Sf(await n(e.params.argument.value,e.params.context)):Ef}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler($f(Ao)),this.server.assertCanSetRequestHandler($f(Zo)),this.server.assertCanSetRequestHandler($f(qo)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Ao,async(e,t)=>{const r=Object.entries(this._registeredResources).filter(([e,t])=>t.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata})),n=[];for(const e of Object.values(this._registeredResourceTemplates)){if(!e.resourceTemplate.listCallback)continue;const r=await e.resourceTemplate.listCallback(t);for(const t of r.resources)n.push({...e.metadata,...t})}return{resources:[...r,...n]}}),this.server.setRequestHandler(Zo,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler(qo,async(e,t)=>{const r=new URL(e.params.uri),n=this._registeredResources[r.toString()];if(n){if(!n.enabled)throw new od(qi.InvalidParams,`Resource ${r} disabled`);return n.readCallback(r,t)}for(const e of Object.values(this._registeredResourceTemplates)){const n=e.resourceTemplate.uriTemplate.match(r.toString());if(n)return e.readCallback(r,n,t)}throw new od(qi.InvalidParams,`Resource ${r} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler($f(Qo)),this.server.assertCanSetRequestHandler($f(rc)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Qo,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,title:t.title,description:t.description,arguments:t.argsSchema?kf(t.argsSchema):void 0}))})),this.server.setRequestHandler(rc,async(e,t)=>{const r=this._registeredPrompts[e.params.name];if(!r)throw new od(qi.InvalidParams,`Prompt ${e.params.name} not found`);if(!r.enabled)throw new od(qi.InvalidParams,`Prompt ${e.params.name} disabled`);if(r.argsSchema){const n=Ds(r.argsSchema),s=await Ms(n,e.params.arguments);if(!s.success){const t=Ls("error"in s?s.error:"Unknown error");throw new od(qi.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${t}`)}const a=s.data,i=r.callback;return await Promise.resolve(i(a,t))}{const e=r.callback;return await Promise.resolve(e(t))}}),this._promptHandlersInitialized=!0)}resource(e,t,...r){let n;"object"==typeof r[0]&&(n=r.shift());const s=r[0];if("string"==typeof t){if(this._registeredResources[t])throw new Error(`Resource ${t} is already registered`);const r=this._createRegisteredResource(e,void 0,t,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),r}{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);const r=this._createRegisteredResourceTemplate(e,void 0,t,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),r}}registerResource(e,t,r,n){if("string"==typeof t){if(this._registeredResources[t])throw new Error(`Resource ${t} is already registered`);const s=this._createRegisteredResource(e,r.title,t,r,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);const s=this._createRegisteredResourceTemplate(e,r.title,t,r,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}_createRegisteredResource(e,t,r,n,s){const a={name:e,title:t,metadata:n,readCallback:s,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({uri:null}),update:e=>{void 0!==e.uri&&e.uri!==r&&(delete this._registeredResources[r],e.uri&&(this._registeredResources[e.uri]=a)),void 0!==e.name&&(a.name=e.name),void 0!==e.title&&(a.title=e.title),void 0!==e.metadata&&(a.metadata=e.metadata),void 0!==e.callback&&(a.readCallback=e.callback),void 0!==e.enabled&&(a.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[r]=a,a}_createRegisteredResourceTemplate(e,t,r,n,s){const a={resourceTemplate:r,title:t,metadata:n,readCallback:s,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&(delete this._registeredResourceTemplates[e],t.name&&(this._registeredResourceTemplates[t.name]=a)),void 0!==t.title&&(a.title=t.title),void 0!==t.template&&(a.resourceTemplate=t.template),void 0!==t.metadata&&(a.metadata=t.metadata),void 0!==t.callback&&(a.readCallback=t.callback),void 0!==t.enabled&&(a.enabled=t.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=a;const i=r.uriTemplate.variableNames;return Array.isArray(i)&&i.some(e=>!!r.completeCallback(e))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(t,r,n,s,a){const i={title:r,description:n,argsSchema:void 0===s?void 0:Cs(s),callback:a,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:e=>{void 0!==e.name&&e.name!==t&&(delete this._registeredPrompts[t],e.name&&(this._registeredPrompts[e.name]=i)),void 0!==e.title&&(i.title=e.title),void 0!==e.description&&(i.description=e.description),void 0!==e.argsSchema&&(i.argsSchema=Cs(e.argsSchema)),void 0!==e.callback&&(i.callback=e.callback),void 0!==e.enabled&&(i.enabled=e.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[t]=i,s&&Object.values(s).some(t=>pf(t instanceof e?t._def?.innerType:t))&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,t,r,n,s,a,i,o,c){mf(e);const d={title:t,description:r,inputSchema:bf(n),outputSchema:bf(s),annotations:a,execution:i,_meta:o,handler:c,enabled:!0,disable:()=>d.update({enabled:!1}),enable:()=>d.update({enabled:!0}),remove:()=>d.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&("string"==typeof t.name&&mf(t.name),delete this._registeredTools[e],t.name&&(this._registeredTools[t.name]=d)),void 0!==t.title&&(d.title=t.title),void 0!==t.description&&(d.description=t.description),void 0!==t.paramsSchema&&(d.inputSchema=Cs(t.paramsSchema)),void 0!==t.outputSchema&&(d.outputSchema=Cs(t.outputSchema)),void 0!==t.callback&&(d.handler=t.callback),void 0!==t.annotations&&(d.annotations=t.annotations),void 0!==t._meta&&(d._meta=t._meta),void 0!==t.enabled&&(d.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=d,this.setToolRequestHandlers(),this.sendToolListChanged(),d}tool(e,...t){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let r,n,s;if("string"==typeof t[0]&&(r=t.shift()),t.length>1){const e=t[0];wf(e)?(n=t.shift(),t.length>1&&"object"==typeof t[0]&&null!==t[0]&&!wf(t[0])&&(s=t.shift())):"object"==typeof e&&null!==e&&(s=t.shift())}const a=t[0];return this._createRegisteredTool(e,void 0,r,n,void 0,s,{taskSupport:"forbidden"},void 0,a)}registerTool(e,t,r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);const{title:n,description:s,inputSchema:a,outputSchema:i,annotations:o,_meta:c}=t;return this._createRegisteredTool(e,n,s,a,i,o,{taskSupport:"forbidden"},c,r)}prompt(e,...t){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let r,n;"string"==typeof t[0]&&(r=t.shift()),t.length>1&&(n=t.shift());const s=t[0],a=this._createRegisteredPrompt(e,void 0,r,n,s);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}registerPrompt(e,t,r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);const{title:n,description:s,argsSchema:a}=t,i=this._createRegisteredPrompt(e,n,s,a,r);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}isConnected(){return void 0!==this.server.transport}async sendLoggingMessage(e,t){return this.server.sendLoggingMessage(e,t)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}}const _f={type:"object",properties:{}};function vf(e){return null!==e&&"object"==typeof e&&"parse"in e&&"function"==typeof e.parse&&"safeParse"in e&&"function"==typeof e.safeParse}function wf(e){return"object"==typeof e&&null!==e&&!function(e){return"_def"in e||"_zod"in e||vf(e)}(e)&&(0===Object.keys(e).length||Object.values(e).some(vf))}function bf(e){if(e)return wf(e)?Cs(e):e}function kf(e){const t=Zs(e);return t?Object.entries(t).map(([e,t])=>{const r=function(e){return e.description}(t),n=function(e){if(zs(e)){const t=e;return"optional"===t._zod?.def?.type}const t=e;return"function"==typeof e.isOptional?e.isOptional():"ZodOptional"===t._def?.typeName}(t);return{name:e,description:r,required:!n}}):[]}function $f(e){const t=Zs(e),r=t?.method;if(!r)throw new Error("Schema is missing a method literal");const n=Fs(r);if("string"==typeof n)return n;throw new Error("Schema method literal must be a string")}function Sf(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}const Ef={completion:{values:[],hasMore:!1}};class Tf{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;const e=this._buffer.indexOf("\n");if(-1===e)return null;const t=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),function(e){return Vi.parse(JSON.parse(e))}(t)}clear(){this._buffer=void 0}}class xf{constructor(e=r.stdin,t=r.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new Tf,this._started=!1,this._ondata=e=>{this._readBuffer.append(e),this.processReadBuffer()},this._onerror=e=>{this.onerror?.(e)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{const e=this._readBuffer.readMessage();if(null===e)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),0===this._stdin.listenerCount("data")&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(t=>{const r=function(e){return JSON.stringify(e)+"\n"}(e);this._stdout.write(r)?t():this._stdout.once("drain",t)})}}const Nf={logging:{level:"DEBUG"},db:{file:d.join(c.homedir(),".knowledge-bank","knowledge.db"),configs:["journal_mode = WAL","foreign_keys = ON"]},tmp:d.join(c.homedir(),".knowledge-bank","tmp")};let Pf=null;function Of(){if(null===Pf){const e=process.env.KNOWLEDGE_CONF_DIR||d.join(c.homedir(),".knowledge-bank"),t=d.join(e,"config.json");Pf={...Nf,...n.existsSync(t)?JSON.parse(n.readFileSync(t,"utf-8")):{}}}return Pf}const If=Of(),jf={DEBUG:"DEBUG",INFO:"INFO",WARN:"WARN",ERROR:"ERROR"},Rf=Object.values(jf);class zf{constructor(e,t){this.loggerName=t;const r=If.logging.path||d.join(c.homedir(),".knowledge-bank","logs");n.mkdirSync(r,{recursive:!0}),this.loggerFile=d.join(r,`${e}.log`),this.logLevel=If.logging.level.toUpperCase()||jf.INFO}formatMessage(e,t,r=null){const n=`${(new Date).toISOString().replace("T","-").split(".")[0]} ${this.loggerName} ${e}: ${t}`;return null===r?n:`${n} - ${JSON.stringify(r)}`}isLogLevelEnabled(e){const t=Rf.indexOf(this.logLevel);return Rf.indexOf(e)>=t}writeMessage(e,t,r){if(this.isLogLevelEnabled(e)){const s=this.formatMessage(e,t,r);n.appendFileSync(this.loggerFile,`${s}\n`,"utf8")}}logInfo(e,t=null){this.writeMessage(jf.INFO,e,t)}logError(e,t=null){if(t instanceof Error){const r={message:t.message,stack:t.stack,name:t.name,...t.cause&&{cause:t.cause},...Object.getOwnPropertyNames(t).reduce((e,r)=>(["message","stack","name"].includes(r)||(e[r]=t[r]),e),{})};this.writeMessage(jf.ERROR,e,r)}else this.writeMessage(jf.ERROR,e,t)}logWarn(e,t=null){this.writeMessage(jf.WARN,e,t)}logDebug(e,t=null){this.writeMessage(jf.DEBUG,e,t)}}function Cf(e,t){return new zf(e,t)}const Af=["personal","project","organization"],Mf=["developer","architect","reviewer","ai"],Zf=["code_pattern","tool_usage","architecture","config","pitfall","api_usage","exploration"],Df={DRAFT:"draft",SUGGESTED:"suggested",VERIFIED:"verified"},Lf={knowledge_item:`\n CREATE TABLE IF NOT EXISTS knowledge_item (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n session_id TEXT NOT NULL,\n\n -- Basic information\n title TEXT NOT NULL,\n summary TEXT NOT NULL,\n content TEXT NOT NULL,\n\n -- Classification dimensions\n scope TEXT NOT NULL CHECK(scope IN (${Af.map(e=>`'${e}'`).join(", ")})),\n source_type TEXT NOT NULL CHECK(source_type IN (${Mf.map(e=>`'${e}'`).join(", ")})),\n knowledge_type TEXT NOT NULL ,\n status TEXT NOT NULL DEFAULT '${Df.DRAFT}' CHECK(status IN (${Object.values(Df).map(e=>`'${e}'`).join(", ")})),\n\n -- Source tracking\n source_file TEXT,\n contributor TEXT,\n\n -- Timestamps\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n\n FOREIGN KEY (session_id) REFERENCES session(session_id)\n )\n `,session:"\n CREATE TABLE IF NOT EXISTS session (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n session_id TEXT UNIQUE NOT NULL,\n\n -- Session basic information\n cwd TEXT NOT NULL,\n cwd_updated_at INTEGER NOT NULL,\n git_url TEXT,\n git_branch TEXT,\n git_commit_id TEXT,\n user_name TEXT,\n\n -- Environment information (stored as JSON)\n env TEXT,\n\n -- Configuration information (stored as JSON)\n config TEXT,\n\n -- Session duration (seconds, calculated on session end)\n duration INTEGER,\n\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n )\n ",session_event:"\n CREATE TABLE IF NOT EXISTS session_event (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n session_id TEXT NOT NULL,\n\n -- Hook information\n name TEXT NOT NULL,\n input TEXT NOT NULL,\n output TEXT,\n exit_code INTEGER NOT NULL DEFAULT 0,\n\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n\n FOREIGN KEY (session_id) REFERENCES session(session_id)\n )\n ",knowledge_item_fts:"\n CREATE VIRTUAL TABLE IF NOT EXISTS knowledge_item_fts USING fts5(\n title, summary, content,\n content='knowledge_item',\n content_rowid='id',\n tokenize='trigram'\n )\n "},Ff={knowledge_item_fts_insert:"\n CREATE TRIGGER IF NOT EXISTS knowledge_item_fts_insert AFTER INSERT ON knowledge_item BEGIN\n INSERT INTO knowledge_item_fts(rowid, title, summary, content)\n VALUES (new.id, new.title, new.summary, new.content);\n END\n ",knowledge_item_fts_delete:"\n CREATE TRIGGER IF NOT EXISTS knowledge_item_fts_delete AFTER DELETE ON knowledge_item BEGIN\n INSERT INTO knowledge_item_fts(knowledge_item_fts, rowid, title, summary, content)\n VALUES('delete', old.id, old.title, old.summary, old.content);\n END\n ",knowledge_item_fts_update:"\n CREATE TRIGGER IF NOT EXISTS knowledge_item_fts_update AFTER UPDATE ON knowledge_item BEGIN\n INSERT INTO knowledge_item_fts(knowledge_item_fts, rowid, title, summary, content)\n VALUES('delete', old.id, old.title, old.summary, old.content);\n INSERT INTO knowledge_item_fts(rowid, title, summary, content)\n VALUES (new.id, new.title, new.summary, new.content);\n END\n "},qf={idx_knowledge_scope:"CREATE INDEX IF NOT EXISTS idx_knowledge_scope ON knowledge_item(scope)",idx_knowledge_type:"CREATE INDEX IF NOT EXISTS idx_knowledge_type ON knowledge_item(knowledge_type)",idx_knowledge_status:"CREATE INDEX IF NOT EXISTS idx_knowledge_status ON knowledge_item(status)",idx_knowledge_session:"CREATE INDEX IF NOT EXISTS idx_knowledge_session ON knowledge_item(session_id)",idx_session_id:"CREATE INDEX IF NOT EXISTS idx_session_id ON session(session_id)",idx_session_cwd:"CREATE INDEX IF NOT EXISTS idx_session_cwd ON session(cwd)",idx_session_event_session:"CREATE INDEX IF NOT EXISTS idx_session_event_session ON session_event(session_id)",idx_session_event_name:"CREATE INDEX IF NOT EXISTS idx_session_event_name ON session_event(name)"},Uf=Of(),Vf=new class{constructor(){this.dbFile=Uf.db.file,this.initialized=!1}initialize(){if(!this.initialized){const e=u(this.dbFile);s(e)||a(e,{recursive:!0})}return this.initialized=!0,this}_createConnection(){const e=new l(this.dbFile);return Uf.db.configs.forEach(t=>{e.pragma(t)}),e}withConnection(e){let t=null;try{return t=this.initialize()._createConnection(),e(t)}finally{t&&(t.close(),t=null)}}static install(){Vf.withConnection(e=>{!function(e){Object.values(Lf).forEach(t=>{e.prepare(t).run()}),Object.values(qf).forEach(t=>{e.prepare(t).run()}),Object.values(Ff).forEach(t=>{e.prepare(t).run()})}(e)})}};class Hf{constructor(){this.dbInstance=Vf}withConnection(e){return this.dbInstance.withConnection(e)}}class Jf extends Hf{create(e){return this.withConnection(t=>{const r=Date.now(),n=t.prepare("\n INSERT INTO knowledge_item (\n session_id,\n title, summary, content,\n scope, source_type, knowledge_type, status,\n source_file, contributor,\n created_at, updated_at\n ) VALUES (\n @session_id,\n @title, @summary, @content,\n @scope, @source_type, @knowledge_type, @status,\n @source_file, @contributor,\n @created_at, @updated_at\n )\n ").run({...e,status:e.status||Df.DRAFT,created_at:r,updated_at:r});return this._findById(t,n.lastInsertRowid)})}_findById(e,t){return e.prepare("SELECT * FROM knowledge_item WHERE id = ?").get(t)}findById(e){return this.withConnection(t=>this._findById(t,e))}findByCwd(e,t=10){return this.withConnection(e=>e.prepare("SELECT * FROM knowledge_item ORDER BY updated_at DESC LIMIT ?").all(t))}findByScope(e){return this.withConnection(t=>t.prepare("SELECT * FROM knowledge_item WHERE scope = ? ORDER BY updated_at DESC").all(e))}findByStatus(e){return this.withConnection(t=>t.prepare("SELECT * FROM knowledge_item WHERE status = ? ORDER BY updated_at DESC").all(e))}findByKnowledgeType(e){return this.withConnection(t=>t.prepare("SELECT * FROM knowledge_item WHERE knowledge_type = ? ORDER BY updated_at DESC").all(e))}findBySessionId(e){return this.withConnection(t=>t.prepare("SELECT * FROM knowledge_item WHERE session_id = ? ORDER BY updated_at DESC").all(e))}update(e,t){return this.withConnection(r=>{const n=Date.now(),s=Object.keys(t).map(e=>`${e} = @${e}`).join(", ");return r.prepare(`\n UPDATE knowledge_item\n SET ${s},\n updated_at = @updated_at\n WHERE id = @id\n `).run({...t,id:e,updated_at:n}),r.prepare("SELECT * FROM knowledge_item WHERE id = ?").get(e)})}updateStatus(e,t){return this.update(e,{status:t})}delete(e){return this.withConnection(t=>t.prepare("DELETE FROM knowledge_item WHERE id = ?").run(e))}count(e={}){return this.withConnection(t=>{let r="SELECT COUNT(*) as count FROM knowledge_item";const n=[],s=[];return e.scope&&(n.push("scope = ?"),s.push(e.scope)),e.status&&(n.push("status = ?"),s.push(e.status)),e.knowledge_type&&(n.push("knowledge_type = ?"),s.push(e.knowledge_type)),e.session_id&&(n.push("session_id = ?"),s.push(e.session_id)),n.length>0&&(r+=` WHERE ${n.join(" AND ")}`),t.prepare(r).get(...s).count})}findAll(e=100,t=0){return this.withConnection(r=>r.prepare("SELECT * FROM knowledge_item ORDER BY updated_at DESC LIMIT ? OFFSET ?").all(e,t))}search(e,t=10){return this.withConnection(r=>{const n=Array.isArray(e)?e.map(e=>`"${e}"`).join(" OR "):`"${e}"`;return r.prepare("\n SELECT ki.*\n FROM knowledge_item ki\n JOIN knowledge_item_fts fts ON fts.rowid = ki.id\n WHERE knowledge_item_fts MATCH ?\n ORDER BY rank\n LIMIT ?").all(n,t)})}}class Kf{constructor(){this.logger=Cf("knowledge-management","knowledge-management"),this.knowledgeRepo=new Jf}getSessionId(){return process.env.CLAUDE_SESSION_ID}buildUpdateData(e){const t={};return["title","summary","content","scope","source_type","knowledge_type","status","source_file","contributor"].forEach(r=>{void 0!==e[r]&&(t[r]=e[r])}),t}aggregateByStatus(e,t){e.forEach(e=>{t.by_status[e]=this.knowledgeRepo.count({status:e})})}aggregateByScope(e,t){e.forEach(e=>{t.by_scope[e]=this.knowledgeRepo.count({scope:e})})}aggregateByType(e,t){e.forEach(e=>{t.by_type[e]=this.knowledgeRepo.count({knowledge_type:e})})}async create(e){return this.logger.logInfo("Creating new knowledge item",{sessionId:e.session_id}),this.knowledgeRepo.create({title:e.title,summary:e.summary,content:e.content,scope:e.scope,source_type:e.source_type,knowledge_type:e.knowledge_type,status:e.status,source_file:e.source_file,contributor:e.contributor,session_id:e.session_id||this.getSessionId()})}async update(e,t){this.logger.logInfo(`Updating knowledge item ${e}...`);const r=this.buildUpdateData(t),n=this.knowledgeRepo.update(e,r);return this.logger.logInfo(`✓ Knowledge item ${e} updated`),n}async delete(e){this.logger.logInfo(`Deleting knowledge item ${e}...`),this.knowledgeRepo.delete(e),this.logger.logInfo(`✓ Knowledge item ${e} deleted`)}async get(e){return this.knowledgeRepo.findById(e)||(this.logger.logWarn(`Knowledge item ${e} not found`),null)}async list(e={}){if(e.scope)return this.knowledgeRepo.findByScope(e.scope);if(e.status)return this.knowledgeRepo.findByStatus(e.status);if(e.knowledge_type)return this.knowledgeRepo.findByKnowledgeType(e.knowledge_type);const t=e.limit||100,r=e.offset||0;return this.knowledgeRepo.findAll(t,r)}async search(e,t=10){return this.knowledgeRepo.search(e,t)}async updateStatus(e,t){this.logger.logInfo(`Updating status of knowledge item ${e} to ${t}...`);const r=this.knowledgeRepo.updateStatus(e,t);return this.logger.logInfo(`✓ Status updated to ${t}`),r}async getStats(){const e={total:0,by_status:{draft:0,suggested:0,verified:0},by_scope:{personal:0,project:0,organization:0},by_type:{code_pattern:0,architecture:0,config:0,pitfall:0,api_usage:0}};return e.total=this.knowledgeRepo.count({}),this.aggregateByStatus(["draft","suggested","verified"],e),this.aggregateByScope(["personal","project","organization"],e),this.aggregateByType(["code_pattern","architecture","config","pitfall","api_usage"],e),e}}class Bf{static exists(e){return s(e)}static writeJson(e,t){const r=u(e);a(r,{recursive:!0}),i(e,JSON.stringify(t,null,2),"utf8")}static readJson(e){if(!this.exists(e))throw new Error(`File not found: ${e}`);const t=o(e,"utf8");return JSON.parse(t)}static writeMarkdown(e,t){const r=u(e);a(r,{recursive:!0}),i(e,t,"utf8")}static formatKnowledgeAsMarkdown(e){return`# ${e.title}\n\n**ID:** ${e.id}\n**Summary:** ${e.summary}\n**Knowledge Type:** ${e.knowledge_type}\n**Status:** ${e.status}\n**Scope:** ${e.scope}\n**Source Type:** ${e.source_type}\n${e.source_file?`**Source File:** ${e.source_file}`:""}\n${e.contributor?`**Contributor:** ${e.contributor}`:""}\n${e.created_at?`**Created At:** ${e.created_at}`:""}\n${e.updated_at?`**Updated At:** ${e.updated_at}`:""}\n\n## Content\n\n${e.content}\n`}static extractKnowledgeForJson(e){return{title:e.title,summary:e.summary,content:e.content,knowledge_type:e.knowledge_type,status:e.status,scope:e.scope,source_type:e.source_type,source_file:e.source_file||null,contributor:e.contributor||null}}}const Gf=new class{constructor(e={}){this.isDev=void 0!==e.isDev?e.isDev:this.detectEnvironment(),this._rootDir=null,this._packageFile=null,this._marketplaceRepo=null}detectEnvironment(){const e=p(import.meta.url),t=d.dirname(e),r=n.existsSync(d.join(t,"..","..","src")),s=t.includes("dist"),a=d.join(t,"..","..","package.json"),i=d.join(t,"..","package.json");return r&&!s||!n.existsSync(i)&&n.existsSync(a)}getRootDir(){if(this._rootDir)return this._rootDir;const e=p(import.meta.url),t=d.dirname(e);if(this.isDev)this._rootDir=d.join(t,"..","..");else if(t.includes("dist")){const e=t.indexOf("dist");this._rootDir=t.substring(0,e-1)}else if(t.includes("src"))this._rootDir=d.join(t,"..","..");else{let e=t;for(;e!==d.dirname(e);){const t=d.join(e,"package.json");if(n.existsSync(t)){this._rootDir=e;break}e=d.dirname(e)}this._rootDir||(this._rootDir=d.dirname(t))}return this._rootDir}getPackageFile(){if(this._packageFile)return this._packageFile;const e=this.getRootDir();if(this._packageFile=d.join(e,"package.json"),!n.existsSync(this._packageFile)){const e=d.join(process.cwd(),"package.json");if(!n.existsSync(e))throw new Error(`package.json not found at ${this._packageFile} or ${e}`);this._packageFile=e}return this._packageFile}getMarketplaceRepo(){if(this._marketplaceRepo)return this._marketplaceRepo;const e=this.getRootDir();if(this.isDev){const t=d.join(e,"dist","claude-marketplace"),r=d.join(e,"src","claude-marketplace");if(n.existsSync(t))this._marketplaceRepo=t;else{if(!n.existsSync(r))throw new Error(`Marketplace directory not found at ${t} or ${r}`);this._marketplaceRepo=r}}else if(this._marketplaceRepo=d.join(e,"dist","claude-marketplace"),!n.existsSync(this._marketplaceRepo))throw new Error(`Marketplace directory not found at ${this._marketplaceRepo}`);return this._marketplaceRepo}getWebViewsPath(){const e=this.getRootDir();return this.isDev?d.join(e,"src","web","views"):d.join(e,"dist","web","views")}getWebPublicPath(){const e=this.getRootDir();return this.isDev?d.join(e,"src","web","public"):d.join(e,"dist","web","public")}};Cf("common","common");const Wf=Gf.getPackageFile();Gf.getMarketplaceRepo();const Xf=JSON.parse(o(Wf,"utf8"));d.join(c.homedir(),".claude","settings.local.json");const Yf=Of(),Qf=Cf("mcp-server","mcp-server");class eh{constructor(){this.knowledgeManagement=new Kf,this.tempDir=Yf.tmp,this.server=new yf({name:"knowledge-bank",version:Xf.version},{capabilities:{tools:{}}}),this.setupHandlers()}setupHandlers(){this.server.registerTool("knowledge_create",{description:"Create a new knowledge item",inputSchema:t.object({session_id:t.string().describe("Session ID for tracking, can be omitted to use env vars CLAUDE_SESSION_ID"),title:t.string().optional().describe("Knowledge title"),summary:t.string().optional().describe("Knowledge summary"),content:t.string().optional().describe("Knowledge content"),scope:t.enum(Af).optional().describe("Scope of knowledge"),source_type:t.enum(Mf).optional().describe("Source type"),knowledge_type:t.enum(Zf).optional().describe("Knowledge type"),status:t.enum(Df).optional().describe("Status of knowledge"),source_file:t.string().optional().describe("Source file path (optional)"),contributor:t.string().optional().describe("Contributor name (optional)"),from:t.string().optional().describe("Load knowledge data from JSON file")})},async e=>await this.handleCreate(e)),this.server.registerTool("knowledge_get",{description:"Get a knowledge item by ID",inputSchema:t.object({id:t.number().describe("Knowledge item ID"),to:t.string().optional().describe("Save knowledge to markdown file")})},async e=>await this.handleGet(e)),this.server.registerTool("knowledge_update",{description:"Update a knowledge item",inputSchema:t.object({id:t.number().describe("Knowledge item ID"),title:t.string().optional().describe("Knowledge title"),summary:t.string().optional().describe("Knowledge summary"),content:t.string().optional().describe("Knowledge content"),scope:t.enum(Af).optional().describe("Scope of knowledge"),source_type:t.enum(Mf).optional().describe("Source type"),knowledge_type:t.enum(Zf).optional().describe("Knowledge type"),status:t.enum(Df).optional().describe("Status of knowledge"),source_file:t.string().optional().describe("Source file path"),contributor:t.string().optional().describe("Contributor name"),from:t.string().optional().describe("Load update data from JSON file")})},async e=>await this.handleUpdate(e)),this.server.registerTool("knowledge_delete",{description:"Delete a knowledge item",inputSchema:t.object({id:t.number().describe("Knowledge item ID")})},async e=>await this.handleDelete(e)),this.server.registerTool("knowledge_list",{description:"List knowledge items with optional filters",inputSchema:t.object({scope:t.enum(Af).optional().describe("Filter by scope"),status:t.enum(Df).optional().describe("Filter by status"),knowledge_type:t.enum(Zf).optional().describe("Filter by knowledge type"),limit:t.number().default(100).describe("Limit number of results"),offset:t.number().default(0).describe("Offset for pagination"),to:t.string().optional().describe("Save results to JSON file")})},async e=>await this.handleList(e)),this.server.registerTool("knowledge_search",{description:"Search knowledge items by text query",inputSchema:t.object({query:t.array(t.string()).describe("Search query terms"),limit:t.number().default(10).describe("Limit number of results"),to:t.string().optional().describe("Save results to JSON file")})},async e=>await this.handleSearch(e)),this.server.registerTool("knowledge_update_status",{description:"Update knowledge item status",inputSchema:t.object({id:t.number().describe("Knowledge item ID"),status:t.enum(Df).describe("New status")})},async e=>await this.handleUpdateStatus(e)),this.server.registerTool("knowledge_stats",{description:"Get knowledge statistics",inputSchema:t.object({})},async()=>await this.handleStats())}async handleCreate(e){let t=e;if(e.from){const r=d.join(this.tempDir,d.basename(e.from));if(!Bf.exists(r))return{content:[{type:"text",text:JSON.stringify({error:`File not found: ${r}`},null,2)}],isError:!0};try{t=Bf.readJson(r)}catch(e){return{content:[{type:"text",text:JSON.stringify({error:`Error reading JSON file: ${e.message}`},null,2)}],isError:!0}}}if(!(t.title&&t.summary&&t.content&&t.scope&&t.source_type&&t.knowledge_type&&t.status))return{content:[{type:"text",text:JSON.stringify({error:"Missing required fields: title, summary, content, scope, source_type, knowledge_type, status"},null,2)}],isError:!0};const r=await this.knowledgeManagement.create({title:t.title,summary:t.summary,content:t.content,scope:t.scope,source_type:t.source_type,knowledge_type:t.knowledge_type,status:t.status,source_file:t.source_file,contributor:t.contributor,session_id:process.env.CLAUDE_SESSION_ID||t.session_id||"unknown-session"});if(e.from){const t=d.join(this.tempDir,d.basename(e.from));return{content:[{type:"text",text:JSON.stringify({id:r.id,title:r.title,message:`Knowledge item created from ${d.basename(e.from)}`,file_path:t},null,2)}]}}return{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}async handleGet(e){const t=await this.knowledgeManagement.get(e.id);if(!t)return{content:[{type:"text",text:JSON.stringify({error:"Knowledge item not found"},null,2)}],isError:!0};if(e.to)try{const r=d.join(this.tempDir,d.basename(e.to)),n=Bf.formatKnowledgeAsMarkdown(t);return Bf.writeMarkdown(r,n),{content:[{type:"text",text:JSON.stringify({success:!0,message:`Knowledge item ${e.id} saved to ${d.basename(e.to)}`,file_path:r},null,2)}]}}catch(e){return{content:[{type:"text",text:JSON.stringify({error:`Error saving file: ${e.message}`},null,2)}],isError:!0}}return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}async handleUpdate(e){const{id:t,from:r,...n}=e;let s=n;if(r){const e=d.join(this.tempDir,r);if(!Bf.exists(e))return{content:[{type:"text",text:JSON.stringify({error:`File not found: ${e}`},null,2)}],isError:!0};try{s={...Bf.readJson(e),...n}}catch(e){return{content:[{type:"text",text:JSON.stringify({error:`Error reading JSON file: ${e.message}`},null,2)}],isError:!0}}}const a=await this.knowledgeManagement.update(t,s);return{content:[{type:"text",text:JSON.stringify({id:a.id,session_id:a.session_id,message:"knowledge item updated"},null,2)}]}}async handleDelete(e){return await this.knowledgeManagement.delete(e.id),{content:[{type:"text",text:JSON.stringify({success:!0,message:"Knowledge item deleted successfully"})}]}}async handleList(e={}){const{to:t,...r}=e,n=await this.knowledgeManagement.list(r);if(t)try{const e=d.join(this.tempDir,t),s=n.map(e=>Bf.extractKnowledgeForJson(e));return Bf.writeJson(e,{count:n.length,filters:r,timestamp:(new Date).toISOString(),data:s}),{content:[{type:"text",text:JSON.stringify({success:!0,message:`${n.length} knowledge items saved to ${t}`,file_path:e},null,2)}]}}catch(e){return{content:[{type:"text",text:JSON.stringify({error:`Error saving file: ${e.message}`},null,2)}],isError:!0}}return{content:[{type:"text",text:JSON.stringify(n,null,2)}]}}async handleSearch(e){const{to:t,query:r,limit:n}=e,s=await this.knowledgeManagement.search(r,n);if(t)try{const e=d.join(this.tempDir,t),a=s.map(e=>Bf.extractKnowledgeForJson(e));return Bf.writeJson(e,{query:r,limit:n,count:s.length,timestamp:(new Date).toISOString(),data:a}),{content:[{type:"text",text:JSON.stringify({success:!0,message:`Search results (${s.length} items) saved to ${t}`,file_path:e},null,2)}]}}catch(e){return{content:[{type:"text",text:JSON.stringify({error:`Error saving file: ${e.message}`},null,2)}],isError:!0}}return{content:[{type:"text",text:JSON.stringify(s,null,2)}]}}async handleUpdateStatus(e){const t=await this.knowledgeManagement.updateStatus(e.id,e.status);return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}async handleStats(){const e=await this.knowledgeManagement.getStats();return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}async run(){const e=new xf;await this.server.connect(e),Qf.logWarn(`Knowledge Bank MCP server running under ${process.cwd()}`)}}export{eh as KnowledgeBankMCPServer};
7
+ deps: ${n}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(e){const[t,r]=function({schema:e}){const t={},r={};for(const n in e)"__proto__"!==n&&((Array.isArray(e[n])?t:r)[n]=e[n]);return[t,r]}(e);a(e,t),i(e,r)}};function a(e,r=e.schema){const{gen:s,data:a,it:i}=e;if(0===Object.keys(r).length)return;const o=s.let("missing");for(const c in r){const d=r[c];if(0===d.length)continue;const u=(0,n.propertyInData)(s,a,c,i.opts.ownProperties);e.setParams({property:c,depsCount:d.length,deps:d.join(", ")}),i.allErrors?s.if(u,()=>{for(const t of d)(0,n.checkReportMissingProp)(e,t)}):(s.if(t._`${u} && (${(0,n.checkMissingProp)(e,d,o)})`),(0,n.reportMissingProp)(e,o),s.else())}}function i(e,t=e.schema){const{gen:s,data:a,keyword:i,it:o}=e,c=s.name("valid");for(const d in t)(0,r.alwaysValidSchema)(o,t[d])||(s.if((0,n.propertyInData)(s,a,d,o.opts.ownProperties),()=>{const t=e.subschema({keyword:i,schemaProp:d},c);e.mergeValidEvaluated(t,c)},()=>s.var(c,!0)),e.ok(c))}e.validatePropertyDeps=a,e.validateSchemaDeps=i,e.default=s}(pp)),pp),i=function(){if(fp)return mp;fp=1,Object.defineProperty(mp,"__esModule",{value:!0});const e=uu(),t=fu(),r={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:t})=>e._`{propertyName: ${t.propertyName}}`},code(r){const{gen:n,schema:s,data:a,it:i}=r;if((0,t.alwaysValidSchema)(i,s))return;const o=n.name("valid");n.forIn("key",a,t=>{r.setParams({propertyName:t}),r.subschema({keyword:"propertyNames",data:t,dataTypes:["string"],propertyName:t,compositeRule:!0},o),n.if((0,e.not)(o),()=>{r.error(!0),i.allErrors||n.break()})}),r.ok(o)}};return mp.default=r,mp}(),o=yp(),c=function(){if(_p)return xp;_p=1,Object.defineProperty(xp,"__esModule",{value:!0});const e=Bu(),t=Cu(),r=fu(),n=yp(),s={keyword:"properties",type:"object",schemaType:"object",code(s){const{gen:a,schema:i,parentSchema:o,data:c,it:d}=s;"all"===d.opts.removeAdditional&&void 0===o.additionalProperties&&n.default.code(new e.KeywordCxt(d,n.default,"additionalProperties"));const u=(0,t.allSchemaProperties)(i);for(const e of u)d.definedProperties.add(e);d.opts.unevaluated&&u.length&&!0!==d.props&&(d.props=r.mergeEvaluated.props(a,(0,r.toHash)(u),d.props));const l=u.filter(e=>!(0,r.alwaysValidSchema)(d,i[e]));if(0===l.length)return;const p=a.name("valid");for(const e of l)f(e)?h(e):(a.if((0,t.propertyInData)(a,c,e,d.opts.ownProperties)),h(e),d.allErrors||a.else().var(p,!0),a.endIf()),s.it.definedProperties.add(e),s.ok(p);function f(e){return d.opts.useDefaults&&!d.compositeRule&&void 0!==i[e].default}function h(e){s.subschema({keyword:"properties",schemaProp:e,dataProp:e},p)}}};return xp.default=s,xp}(),d=function(){if(vp)return Np;vp=1,Object.defineProperty(Np,"__esModule",{value:!0});const e=Cu(),t=uu(),r=fu(),n=fu(),s={keyword:"patternProperties",type:"object",schemaType:"object",code(s){const{gen:a,schema:i,data:o,parentSchema:c,it:d}=s,{opts:u}=d,l=(0,e.allSchemaProperties)(i),p=l.filter(e=>(0,r.alwaysValidSchema)(d,i[e]));if(0===l.length||p.length===l.length&&(!d.opts.unevaluated||!0===d.props))return;const f=u.strictSchema&&!u.allowMatchingProperties&&c.properties,h=a.name("valid");!0===d.props||d.props instanceof t.Name||(d.props=(0,n.evaluatedPropsToName)(a,d.props));const{props:m}=d;function g(e){for(const t in f)new RegExp(e).test(t)&&(0,r.checkStrictMode)(d,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function y(r){a.forIn("key",o,i=>{a.if(t._`${(0,e.usePattern)(s,r)}.test(${i})`,()=>{const e=p.includes(r);e||s.subschema({keyword:"patternProperties",schemaProp:r,dataProp:i,dataPropType:n.Type.Str},h),d.opts.unevaluated&&!0!==m?a.assign(t._`${m}[${i}]`,!0):e||d.allErrors||a.if((0,t.not)(h),()=>a.break())})})}!function(){for(const e of l)f&&g(e),d.allErrors?y(e):(a.var(h,!0),y(e),a.if(h))}()}};return Np.default=s,Np}(),u=function(){if(wp)return Op;wp=1,Object.defineProperty(Op,"__esModule",{value:!0});const e=fu(),t={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){const{gen:r,schema:n,it:s}=t;if((0,e.alwaysValidSchema)(s,n))return void t.fail();const a=r.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},a),t.failResult(a,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};return Op.default=t,Op}(),l=function(){if(bp)return Pp;bp=1,Object.defineProperty(Pp,"__esModule",{value:!0});const e={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Cu().validateUnion,error:{message:"must match a schema in anyOf"}};return Pp.default=e,Pp}(),p=function(){if(kp)return Ip;kp=1,Object.defineProperty(Ip,"__esModule",{value:!0});const e=uu(),t=fu(),r={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:t})=>e._`{passingSchemas: ${t.passing}}`},code(r){const{gen:n,schema:s,parentSchema:a,it:i}=r;if(!Array.isArray(s))throw new Error("ajv implementation error");if(i.opts.discriminator&&a.discriminator)return;const o=s,c=n.let("valid",!1),d=n.let("passing",null),u=n.name("_valid");r.setParams({passing:d}),n.block(function(){o.forEach((s,a)=>{let o;(0,t.alwaysValidSchema)(i,s)?n.var(u,!0):o=r.subschema({keyword:"oneOf",schemaProp:a,compositeRule:!0},u),a>0&&n.if(e._`${u} && ${c}`).assign(c,!1).assign(d,e._`[${d}, ${a}]`).else(),n.if(u,()=>{n.assign(c,!0),n.assign(d,a),o&&r.mergeEvaluated(o,e.Name)})})}),r.result(c,()=>r.reset(),()=>r.error(!0))}};return Ip.default=r,Ip}(),f=function(){if($p)return Rp;$p=1,Object.defineProperty(Rp,"__esModule",{value:!0});const e=fu(),t={keyword:"allOf",schemaType:"array",code(t){const{gen:r,schema:n,it:s}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");const a=r.name("valid");n.forEach((r,n)=>{if((0,e.alwaysValidSchema)(s,r))return;const i=t.subschema({keyword:"allOf",schemaProp:n},a);t.ok(a),t.mergeEvaluated(i)})}};return Rp.default=t,Rp}(),h=function(){if(Sp)return jp;Sp=1,Object.defineProperty(jp,"__esModule",{value:!0});const e=uu(),t=fu(),r={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:t})=>e.str`must match "${t.ifClause}" schema`,params:({params:t})=>e._`{failingKeyword: ${t.ifClause}}`},code(r){const{gen:s,parentSchema:a,it:i}=r;void 0===a.then&&void 0===a.else&&(0,t.checkStrictMode)(i,'"if" without "then" and "else" is ignored');const o=n(i,"then"),c=n(i,"else");if(!o&&!c)return;const d=s.let("valid",!0),u=s.name("_valid");if(function(){const e=r.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},u);r.mergeEvaluated(e)}(),r.reset(),o&&c){const e=s.let("ifClause");r.setParams({ifClause:e}),s.if(u,l("then",e),l("else",e))}else o?s.if(u,l("then")):s.if((0,e.not)(u),l("else"));function l(t,n){return()=>{const a=r.subschema({keyword:t},u);s.assign(d,u),r.mergeValidEvaluated(a,d),n?s.assign(n,e._`${t}`):r.setParams({ifClause:t})}}r.pass(d,()=>r.error(!0))}};function n(e,r){const n=e.schema[r];return void 0!==n&&!(0,t.alwaysValidSchema)(e,n)}return jp.default=r,jp}(),m=function(){if(Ep)return zp;Ep=1,Object.defineProperty(zp,"__esModule",{value:!0});const e=fu(),t={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:r,it:n}){void 0===r.if&&(0,e.checkStrictMode)(n,`"${t}" without "if" is ignored`)}};return zp.default=t,zp}();return Ql.default=function(g=!1){const y=[u.default,l.default,p.default,f.default,h.default,m.default,i.default,o.default,a.default,c.default,d.default];return g?y.push(t.default,n.default):y.push(e.default,r.default),y.push(s.default),y},Ql}var Ap,Mp,Zp={},Dp={};function Lp(){if(Ap)return Dp;Ap=1,Object.defineProperty(Dp,"__esModule",{value:!0});const e=uu(),t={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:t})=>e.str`must match format "${t}"`,params:({schemaCode:t})=>e._`{format: ${t}}`},code(t,r){const{gen:n,data:s,$data:a,schema:i,schemaCode:o,it:c}=t,{opts:d,errSchemaPath:u,schemaEnv:l,self:p}=c;d.validateFormats&&(a?function(){const a=n.scopeValue("formats",{ref:p.formats,code:d.code.formats}),i=n.const("fDef",e._`${a}[${o}]`),c=n.let("fType"),u=n.let("format");n.if(e._`typeof ${i} == "object" && !(${i} instanceof RegExp)`,()=>n.assign(c,e._`${i}.type || "string"`).assign(u,e._`${i}.validate`),()=>n.assign(c,e._`"string"`).assign(u,i)),t.fail$data((0,e.or)(!1===d.strictSchema?e.nil:e._`${o} && !${u}`,function(){const t=l.$async?e._`(${i}.async ? await ${u}(${s}) : ${u}(${s}))`:e._`${u}(${s})`,n=e._`(typeof ${u} == "function" ? ${t} : ${u}.test(${s}))`;return e._`${u} && ${u} !== true && ${c} === ${r} && !${n}`}()))}():function(){const a=p.formats[i];if(!a)return void function(){if(!1!==d.strictSchema)throw new Error(e());function e(){return`unknown format "${i}" ignored in schema at path "${u}"`}p.logger.warn(e())}();if(!0===a)return;const[o,c,f]=function(t){const r=t instanceof RegExp?(0,e.regexpCode)(t):d.code.formats?e._`${d.code.formats}${(0,e.getProperty)(i)}`:void 0,s=n.scopeValue("formats",{key:i,ref:t,code:r});return"object"!=typeof t||t instanceof RegExp?["string",t,s]:[t.type||"string",t.validate,e._`${s}.validate`]}(a);o===r&&t.pass(function(){if("object"==typeof a&&!(a instanceof RegExp)&&a.async){if(!l.$async)throw new Error("async format in sync schema");return e._`await ${f}(${s})`}return"function"==typeof c?e._`${f}(${s})`:e._`${f}.test(${s})`}())}())}};return Dp.default=t,Dp}var Fp,qp,Up={};function Vp(){if(qp)return vl;qp=1,Object.defineProperty(vl,"__esModule",{value:!0});const e=function(){if(_l)return wl;_l=1,Object.defineProperty(wl,"__esModule",{value:!0});const e=function(){if(gl)return bl;gl=1,Object.defineProperty(bl,"__esModule",{value:!0});const e={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};return bl.default=e,bl}(),t=function(){if(yl)return kl;yl=1,Object.defineProperty(kl,"__esModule",{value:!0}),kl.callRef=kl.getValidate=void 0;const e=el(),t=Cu(),r=uu(),n=_u(),s=nl(),a=fu(),i={keyword:"$ref",schemaType:"string",code(t){const{gen:n,schema:a,it:i}=t,{baseId:d,schemaEnv:u,validateName:l,opts:p,self:f}=i,{root:h}=u;if(("#"===a||"#/"===a)&&d===h.baseId)return function(){if(u===h)return c(t,l,u,u.$async);const e=n.scopeValue("root",{ref:h});return c(t,r._`${e}.validate`,h,h.$async)}();const m=s.resolveRef.call(f,h,d,a);if(void 0===m)throw new e.default(i.opts.uriResolver,d,a);return m instanceof s.SchemaEnv?function(e){const r=o(t,e);c(t,r,e,e.$async)}(m):function(e){const s=n.scopeValue("schema",!0===p.code.source?{ref:e,code:(0,r.stringify)(e)}:{ref:e}),i=n.name("valid"),o=t.subschema({schema:e,dataTypes:[],schemaPath:r.nil,topSchemaRef:s,errSchemaPath:a},i);t.mergeEvaluated(o),t.ok(i)}(m)}};function o(e,t){const{gen:n}=e;return t.validate?n.scopeValue("validate",{ref:t.validate}):r._`${n.scopeValue("wrapper",{ref:t})}.validate`}function c(e,s,i,o){const{gen:c,it:d}=e,{allErrors:u,schemaEnv:l,opts:p}=d,f=p.passContext?n.default.this:r.nil;function h(e){const t=r._`${e}.errors`;c.assign(n.default.vErrors,r._`${n.default.vErrors} === null ? ${t} : ${n.default.vErrors}.concat(${t})`),c.assign(n.default.errors,r._`${n.default.vErrors}.length`)}function m(e){var t;if(!d.opts.unevaluated)return;const n=null===(t=null==i?void 0:i.validate)||void 0===t?void 0:t.evaluated;if(!0!==d.props)if(n&&!n.dynamicProps)void 0!==n.props&&(d.props=a.mergeEvaluated.props(c,n.props,d.props));else{const t=c.var("props",r._`${e}.evaluated.props`);d.props=a.mergeEvaluated.props(c,t,d.props,r.Name)}if(!0!==d.items)if(n&&!n.dynamicItems)void 0!==n.items&&(d.items=a.mergeEvaluated.items(c,n.items,d.items));else{const t=c.var("items",r._`${e}.evaluated.items`);d.items=a.mergeEvaluated.items(c,t,d.items,r.Name)}}o?function(){if(!l.$async)throw new Error("async schema referenced by sync schema");const n=c.let("valid");c.try(()=>{c.code(r._`await ${(0,t.callValidateCode)(e,s,f)}`),m(s),u||c.assign(n,!0)},e=>{c.if(r._`!(${e} instanceof ${d.ValidationError})`,()=>c.throw(e)),h(e),u||c.assign(n,!1)}),e.ok(n)}():e.result((0,t.callValidateCode)(e,s,f),()=>m(s),()=>h(s))}return kl.getValidate=o,kl.callRef=c,kl.default=i,kl}(),r=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",e.default,t.default];return wl.default=r,wl}(),t=Wl(),r=Cp(),n=function(){if(Mp)return Zp;Mp=1,Object.defineProperty(Zp,"__esModule",{value:!0});const e=[Lp().default];return Zp.default=e,Zp}(),s=(Fp||(Fp=1,Object.defineProperty(Up,"__esModule",{value:!0}),Up.contentVocabulary=Up.metadataVocabulary=void 0,Up.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],Up.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]),Up),a=[e.default,t.default,(0,r.default)(),n.default,s.metadataVocabulary,s.contentVocabulary];return vl.default=a,vl}var Hp,Jp,Kp={},Bp={};var Gp,Xp={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0};function Wp(){return Gp||(Gp=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv=void 0;const r=ml(),n=Vp(),s=function(){if(Jp)return Kp;Jp=1,Object.defineProperty(Kp,"__esModule",{value:!0});const e=uu(),t=(Hp||(Hp=1,Object.defineProperty(Bp,"__esModule",{value:!0}),Bp.DiscrError=void 0,function(e){e.Tag="tag",e.Mapping="mapping"}(r||(Bp.DiscrError=r={}))),Bp);var r;const n=nl(),s=el(),a=fu(),i={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:e,tagName:r}})=>e===t.DiscrError.Tag?`tag "${r}" must be string`:`value of tag "${r}" must be in oneOf`,params:({params:{discrError:t,tag:r,tagName:n}})=>e._`{error: ${t}, tag: ${n}, tagValue: ${r}}`},code(r){const{gen:i,data:o,schema:c,parentSchema:d,it:u}=r,{oneOf:l}=d;if(!u.opts.discriminator)throw new Error("discriminator: requires discriminator option");const p=c.propertyName;if("string"!=typeof p)throw new Error("discriminator: requires propertyName");if(c.mapping)throw new Error("discriminator: mapping is not supported");if(!l)throw new Error("discriminator: requires oneOf keyword");const f=i.let("valid",!1),h=i.const("tag",e._`${o}${(0,e.getProperty)(p)}`);function m(t){const n=i.name("valid"),s=r.subschema({keyword:"oneOf",schemaProp:t},n);return r.mergeEvaluated(s,e.Name),n}i.if(e._`typeof ${h} == "string"`,()=>function(){const o=function(){var e;const t={},r=o(d);let i=!0;for(let t=0;t<l.length;t++){let d=l[t];if((null==d?void 0:d.$ref)&&!(0,a.schemaHasRulesButRef)(d,u.self.RULES)){const e=d.$ref;if(d=n.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),d instanceof n.SchemaEnv&&(d=d.schema),void 0===d)throw new s.default(u.opts.uriResolver,u.baseId,e)}const f=null===(e=null==d?void 0:d.properties)||void 0===e?void 0:e[p];if("object"!=typeof f)throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${p}"`);i=i&&(r||o(d)),c(f,t)}if(!i)throw new Error(`discriminator: "${p}" must be required`);return t;function o({required:e}){return Array.isArray(e)&&e.includes(p)}function c(e,t){if(e.const)f(e.const,t);else{if(!e.enum)throw new Error(`discriminator: "properties/${p}" must have "const" or "enum"`);for(const r of e.enum)f(r,t)}}function f(e,r){if("string"!=typeof e||e in t)throw new Error(`discriminator: "${p}" values must be unique strings`);t[e]=r}}();i.if(!1);for(const t in o)i.elseIf(e._`${h} === ${t}`),i.assign(f,m(o[t]));i.else(),r.error(!1,{discrError:t.DiscrError.Mapping,tag:h,tagName:p}),i.endIf()}(),()=>r.error(!1,{discrError:t.DiscrError.Tag,tag:h,tagName:p})),r.ok(f)}};return Kp.default=i,Kp}(),a=Xp,i=["/properties"],o="http://json-schema.org/draft-07/schema";class c extends r.default{_addVocabularies(){super._addVocabularies(),n.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const e=this.opts.$data?this.$dataMetaSchema(a,i):a;this.addMetaSchema(e,o,!1),this.refs["http://json-schema.org/schema"]=o}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(o)?o:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var d=Bu();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return d.KeywordCxt}});var u=uu();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return u._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return u.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return u.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return u.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return u.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return u.CodeGen}});var l=Wu();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return l.default}});var p=el();Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return p.default}})}(Yd,Yd.exports)),Yd.exports}var Yp,Qp,ef,tf=Xd(Wp()),rf={exports:{}},nf={},sf={},af=(ef||(ef=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=(Yp||(Yp=1,function(e){function t(e,t){return{validate:e,compare:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0,e.fullFormats={date:t(s,a),time:t(o(!0),c),"date-time":t(l(!0),p),"iso-time":t(o(),d),"iso-date-time":t(l(),f),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:function(e){return h.test(e)&&m.test(e)},"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:function(e){if(w.test(e))return!1;try{return new RegExp(e),!0}catch(e){return!1}},uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:function(e){return g.lastIndex=0,g.test(e)},int32:{type:"number",validate:function(e){return Number.isInteger(e)&&e<=_&&e>=y}},int64:{type:"number",validate:function(e){return Number.isInteger(e)}},float:{type:"number",validate:v},double:{type:"number",validate:v},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,a),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,c),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,d),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,f),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);const r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,n=[0,31,28,31,30,31,30,31,31,30,31,30,31];function s(e){const t=r.exec(e);if(!t)return!1;const s=+t[1],a=+t[2],i=+t[3];return a>=1&&a<=12&&i>=1&&i<=(2===a&&function(e){return e%4==0&&(e%100!=0||e%400==0)}(s)?29:n[a])}function a(e,t){if(e&&t)return e>t?1:e<t?-1:0}const i=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function o(e){return function(t){const r=i.exec(t);if(!r)return!1;const n=+r[1],s=+r[2],a=+r[3],o=r[4],c="-"===r[5]?-1:1,d=+(r[6]||0),u=+(r[7]||0);if(d>23||u>59||e&&!o)return!1;if(n<=23&&s<=59&&a<60)return!0;const l=s-u*c,p=n-d*c-(l<0?1:0);return(23===p||-1===p)&&(59===l||-1===l)&&a<61}}function c(e,t){if(!e||!t)return;const r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();return r&&n?r-n:void 0}function d(e,t){if(!e||!t)return;const r=i.exec(e),n=i.exec(t);return r&&n?(e=r[1]+r[2]+r[3])>(t=n[1]+n[2]+n[3])?1:e<t?-1:0:void 0}const u=/t|\s/i;function l(e){const t=o(e);return function(e){const r=e.split(u);return 2===r.length&&s(r[0])&&t(r[1])}}function p(e,t){if(!e||!t)return;const r=new Date(e).valueOf(),n=new Date(t).valueOf();return r&&n?r-n:void 0}function f(e,t){if(!e||!t)return;const[r,n]=e.split(u),[s,i]=t.split(u),o=a(r,s);return void 0!==o?o||c(n,i):void 0}const h=/\/|:/,m=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,g=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm,y=-2147483648,_=2**31-1;function v(){return!0}const w=/[^\\]\\Z/}(nf)),nf),n=(Qp||(Qp=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=Wp(),r=uu(),n=r.operators,s={formatMaximum:{okStr:"<=",ok:n.LTE,fail:n.GT},formatMinimum:{okStr:">=",ok:n.GTE,fail:n.LT},formatExclusiveMaximum:{okStr:"<",ok:n.LT,fail:n.GTE},formatExclusiveMinimum:{okStr:">",ok:n.GT,fail:n.LTE}},a={message:({keyword:e,schemaCode:t})=>r.str`should be ${s[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>r._`{comparison: ${s[e].okStr}, limit: ${t}}`};e.formatLimitDefinition={keyword:Object.keys(s),type:"string",schemaType:"string",$data:!0,error:a,code(e){const{gen:n,data:a,schemaCode:i,keyword:o,it:c}=e,{opts:d,self:u}=c;if(!d.validateFormats)return;const l=new t.KeywordCxt(c,u.RULES.all.format.definition,"format");function p(e){return r._`${e}.compare(${a}, ${i}) ${s[o].fail} 0`}l.$data?function(){const t=n.scopeValue("formats",{ref:u.formats,code:d.code.formats}),s=n.const("fmt",r._`${t}[${l.schemaCode}]`);e.fail$data((0,r.or)(r._`typeof ${s} != "object"`,r._`${s} instanceof RegExp`,r._`typeof ${s}.compare != "function"`,p(s)))}():function(){const t=l.schema,s=u.formats[t];if(!s||!0===s)return;if("object"!=typeof s||s instanceof RegExp||"function"!=typeof s.compare)throw new Error(`"${o}": format "${t}" does not define "compare" function`);const a=n.scopeValue("formats",{key:t,ref:s,code:d.code.formats?r._`${d.code.formats}${(0,r.getProperty)(t)}`:void 0});e.fail$data(p(a))}()},dependencies:["format"]},e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)}(sf)),sf),s=uu(),a=new s.Name("fullFormats"),i=new s.Name("fastFormats"),o=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,r.fullFormats,a),e;const[s,o]="fast"===t.mode?[r.fastFormats,i]:[r.fullFormats,a];return c(e,t.formats||r.formatNames,s,o),t.keywords&&(0,n.default)(e),e};function c(e,t,r,n){var a,i;null!==(a=(i=e.opts.code).formats)&&void 0!==a||(i.formats=s._`require("ajv-formats/dist/formats").${n}`);for(const n of t)e.addFormat(n,r[n])}o.get=(e,t="full")=>{const n=("fast"===t?r.fastFormats:r.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n},e.exports=t=o,Object.defineProperty(t,"__esModule",{value:!0}),t.default=o}(rf,rf.exports)),rf.exports),of=Xd(af);class cf{constructor(e){this._ajv=e??function(){const e=new tf({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return of(e),e}()}getValidator(e){const t="$id"in e&&"string"==typeof e.$id?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}}class df{constructor(e){this._server=e}requestStream(e,t,r){return this._server.requestStream(e,t,r)}async getTask(e,t){return this._server.getTask({taskId:e},t)}async getTaskResult(e,t,r){return this._server.getTaskResult({taskId:e},t,r)}async listTasks(e,t){return this._server.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._server.cancelTask({taskId:e},t)}}class uf extends Bd{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(bc.options.map((e,t)=>[e,t])),this.isMessageIgnored=(e,t)=>{const r=this._loggingLevels.get(t);return!!r&&this.LOG_LEVEL_SEVERITY.get(e)<this.LOG_LEVEL_SEVERITY.get(r)},this._capabilities=t?.capabilities??{},this._instructions=t?.instructions,this._jsonSchemaValidator=t?.jsonSchemaValidator??new cf,this.setRequestHandler(so,e=>this._oninitialize(e)),this.setNotificationHandler(oo,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler($c,async(e,t)=>{const r=t.sessionId||t.requestInfo?.headers["mcp-session-id"]||void 0,{level:n}=e.params,s=bc.safeParse(n);return s.success&&this._loggingLevels.set(r,s.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new df(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=function(e,t){const r={...e};for(const e in t){const n=e,s=t[n];if(void 0===s)continue;const a=r[n];Gd(a)&&Gd(s)?r[n]={...a,...s}:r[n]=s}return r}(this._capabilities,e)}setRequestHandler(e,t){const r=Zs(e),n=r?.method;if(!n)throw new Error("Schema is missing a method literal");let s;if(zs(n)){const e=n,t=e._zod?.def;s=t?.value??e.value}else{const e=n,t=e._def;s=t?.value??e.value}if("string"!=typeof s)throw new Error("Schema method literal must be a string");if("tools/call"===s){const r=async(e,r)=>{const n=As(vc,e);if(!n.success){const e=n.error instanceof Error?n.error.message:String(n.error);throw new od(qi.InvalidParams,`Invalid tools/call request: ${e}`)}const{params:s}=n.data,a=await Promise.resolve(t(e,r));if(s.task){const e=As(_o,a);if(!e.success){const t=e.error instanceof Error?e.error.message:String(e.error);throw new od(qi.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}const i=As(yc,a);if(!i.success){const e=i.error instanceof Error?i.error.message:String(i.error);throw new od(qi.InvalidParams,`Invalid tools/call result: ${e}`)}return i.data};return super.setRequestHandler(e,r)}return super.setRequestHandler(e,t)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`)}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`)}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`)}}assertTaskCapability(e){!function(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`)}}(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&function(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);if("tools/call"===t&&!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`)}(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){const t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:bi.includes(t)?t:wi,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Hi)}async createMessage(e,t){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){const t=e.messages[e.messages.length-1],r=Array.isArray(t.content)?t.content:[t.content],n=r.some(e=>"tool_result"===e.type),s=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=s?Array.isArray(s.content)?s.content:[s.content]:[],i=a.some(e=>"tool_use"===e.type);if(n){if(r.some(e=>"tool_result"!==e.type))throw new Error("The last message must contain only tool_result content if any is present");if(!i)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(i){const e=new Set(a.filter(e=>"tool_use"===e.type).map(e=>e.id)),t=new Set(r.filter(e=>"tool_result"===e.type).map(e=>e.toolUseId));if(e.size!==t.size||![...e].every(e=>t.has(e)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},Ac,t):this.request({method:"sampling/createMessage",params:e},Cc,t)}async elicitInput(e,t){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");const r=e;return this.request({method:"elicitation/create",params:r},Wc,t)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");const r="form"===e.mode?e:{...e,mode:"form"},n=await this.request({method:"elicitation/create",params:r},Wc,t);if("accept"===n.action&&n.content&&r.requestedSchema)try{const e=this._jsonSchemaValidator.getValidator(r.requestedSchema)(n.content);if(!e.valid)throw new od(qi.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){if(e instanceof od)throw e;throw new od(qi.InternalError,`Error validating elicitation response: ${e instanceof Error?e.message:String(e)}`)}return n}}}createElicitationCompletionNotifier(e,t){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},t)}async listRoots(e,t){return this.request({method:"roots/list",params:e},ad,t)}async sendLoggingMessage(e,t){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,t))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}const lf=Symbol.for("mcp.completable");function pf(e){return!!e&&"object"==typeof e&&lf in e}var ff;!function(e){e.Completable="McpCompletable"}(ff||(ff={}));const hf=/^[A-Za-z0-9._-]{1,128}$/;function mf(e){const t=function(e){const t=[];if(0===e.length)return{isValid:!1,warnings:["Tool name cannot be empty"]};if(e.length>128)return{isValid:!1,warnings:[`Tool name exceeds maximum length of 128 characters (current: ${e.length})`]};if(e.includes(" ")&&t.push("Tool name contains spaces, which may cause parsing issues"),e.includes(",")&&t.push("Tool name contains commas, which may cause parsing issues"),(e.startsWith("-")||e.endsWith("-"))&&t.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts"),(e.startsWith(".")||e.endsWith("."))&&t.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts"),!hf.test(e)){const r=e.split("").filter(e=>!/[A-Za-z0-9._-]/.test(e)).filter((e,t,r)=>r.indexOf(e)===t);return t.push(`Tool name contains invalid characters: ${r.map(e=>`"${e}"`).join(", ")}`,"Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)"),{isValid:!1,warnings:t}}return{isValid:!0,warnings:t}}(e);return function(e,t){if(t.length>0){console.warn(`Tool name validation warning for "${e}":`);for(const e of t)console.warn(` - ${e}`);console.warn("Tool registration will proceed, but this may cause compatibility issues."),console.warn("Consider updating the tool name to conform to the MCP tool naming standard."),console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.")}}(e,t.warnings),t.isValid}class gf{constructor(e){this._mcpServer=e}registerToolTask(e,t,r){const n={taskSupport:"required",...t.execution};if("forbidden"===n.taskSupport)throw new Error(`Cannot register task-based tool '${e}' with taskSupport 'forbidden'. Use registerTool() instead.`);return this._mcpServer._createRegisteredTool(e,t.title,t.description,t.inputSchema,t.outputSchema,t.annotations,n,t._meta,r)}}class yf{constructor(e,t){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new uf(e,t)}get experimental(){return this._experimental||(this._experimental={tasks:new gf(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler($f(mc)),this.server.assertCanSetRequestHandler($f(vc)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(mc,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,t])=>{const r={name:e,title:t.title,description:t.description,inputSchema:(()=>{const e=Ds(t.inputSchema);return e?Hd(e,{strictUnions:!0,pipeStrategy:"input"}):_f})(),annotations:t.annotations,execution:t.execution,_meta:t._meta};if(t.outputSchema){const e=Ds(t.outputSchema);e&&(r.outputSchema=Hd(e,{strictUnions:!0,pipeStrategy:"output"}))}return r})})),this.server.setRequestHandler(vc,async(e,t)=>{try{const r=this._registeredTools[e.params.name];if(!r)throw new od(qi.InvalidParams,`Tool ${e.params.name} not found`);if(!r.enabled)throw new od(qi.InvalidParams,`Tool ${e.params.name} disabled`);const n=!!e.params.task,s=r.execution?.taskSupport,a="createTask"in r.handler;if(("required"===s||"optional"===s)&&!a)throw new od(qi.InternalError,`Tool ${e.params.name} has taskSupport '${s}' but was not registered with registerToolTask`);if("required"===s&&!n)throw new od(qi.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if("optional"===s&&!n&&a)return await this.handleAutomaticTaskPolling(r,e,t);const i=await this.validateToolInput(r,e.params.arguments,e.params.name),o=await this.executeToolHandler(r,i,t);return n||await this.validateToolOutput(r,o,e.params.name),o}catch(e){if(e instanceof od&&e.code===qi.UrlElicitationRequired)throw e;return this.createToolError(e instanceof Error?e.message:String(e))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,t,r){if(!e.inputSchema)return;const n=Ds(e.inputSchema)??e.inputSchema,s=await Ms(n,t);if(!s.success){const e=Ls("error"in s?s.error:"Unknown error");throw new od(qi.InvalidParams,`Input validation error: Invalid arguments for tool ${r}: ${e}`)}return s.data}async validateToolOutput(e,t,r){if(!e.outputSchema)return;if(!("content"in t))return;if(t.isError)return;if(!t.structuredContent)throw new od(qi.InvalidParams,`Output validation error: Tool ${r} has an output schema but no structured content was provided`);const n=Ds(e.outputSchema),s=await Ms(n,t.structuredContent);if(!s.success){const e=Ls("error"in s?s.error:"Unknown error");throw new od(qi.InvalidParams,`Output validation error: Invalid structured content for tool ${r}: ${e}`)}}async executeToolHandler(e,t,r){const n=e.handler;if("createTask"in n){if(!r.taskStore)throw new Error("No task store provided.");const s={...r,taskStore:r.taskStore};if(e.inputSchema){const e=n;return await Promise.resolve(e.createTask(t,s))}{const e=n;return await Promise.resolve(e.createTask(s))}}if(e.inputSchema){const e=n;return await Promise.resolve(e(t,r))}{const e=n;return await Promise.resolve(e(r))}}async handleAutomaticTaskPolling(e,t,r){if(!r.taskStore)throw new Error("No task store provided for task-capable tool.");const n=await this.validateToolInput(e,t.params.arguments,t.params.name),s=e.handler,a={...r,taskStore:r.taskStore},i=n?await Promise.resolve(s.createTask(n,a)):await Promise.resolve(s.createTask(a)),o=i.task.taskId;let c=i.task;const d=c.pollInterval??5e3;for(;"completed"!==c.status&&"failed"!==c.status&&"cancelled"!==c.status;){await new Promise(e=>setTimeout(e,d));const e=await r.taskStore.getTask(o);if(!e)throw new od(qi.InternalError,`Task ${o} not found during polling`);c=e}return await r.taskStore.getTaskResult(o)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler($f(td)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(td,async e=>{switch(e.params.ref.type){case"ref/prompt":return function(e){if("ref/prompt"!==e.params.ref.type)throw new TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return function(e){if("ref/resource"!==e.params.ref.type)throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}(e),this.handleResourceCompletion(e,e.params.ref);default:throw new od(qi.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,t){const r=this._registeredPrompts[t.name];if(!r)throw new od(qi.InvalidParams,`Prompt ${t.name} not found`);if(!r.enabled)throw new od(qi.InvalidParams,`Prompt ${t.name} disabled`);if(!r.argsSchema)return Ef;const n=Zs(r.argsSchema),s=n?.[e.params.argument.name];if(!pf(s))return Ef;const a=function(e){const t=e[lf];return t?.complete}(s);return a?Sf(await a(e.params.argument.value,e.params.context)):Ef}async handleResourceCompletion(e,t){const r=Object.values(this._registeredResourceTemplates).find(e=>e.resourceTemplate.uriTemplate.toString()===t.uri);if(!r){if(this._registeredResources[t.uri])return Ef;throw new od(qi.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}const n=r.resourceTemplate.completeCallback(e.params.argument.name);return n?Sf(await n(e.params.argument.value,e.params.context)):Ef}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler($f(Ao)),this.server.assertCanSetRequestHandler($f(Zo)),this.server.assertCanSetRequestHandler($f(qo)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Ao,async(e,t)=>{const r=Object.entries(this._registeredResources).filter(([e,t])=>t.enabled).map(([e,t])=>({uri:e,name:t.name,...t.metadata})),n=[];for(const e of Object.values(this._registeredResourceTemplates)){if(!e.resourceTemplate.listCallback)continue;const r=await e.resourceTemplate.listCallback(t);for(const t of r.resources)n.push({...e.metadata,...t})}return{resources:[...r,...n]}}),this.server.setRequestHandler(Zo,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler(qo,async(e,t)=>{const r=new URL(e.params.uri),n=this._registeredResources[r.toString()];if(n){if(!n.enabled)throw new od(qi.InvalidParams,`Resource ${r} disabled`);return n.readCallback(r,t)}for(const e of Object.values(this._registeredResourceTemplates)){const n=e.resourceTemplate.uriTemplate.match(r.toString());if(n)return e.readCallback(r,n,t)}throw new od(qi.InvalidParams,`Resource ${r} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler($f(Qo)),this.server.assertCanSetRequestHandler($f(rc)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Qo,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,title:t.title,description:t.description,arguments:t.argsSchema?kf(t.argsSchema):void 0}))})),this.server.setRequestHandler(rc,async(e,t)=>{const r=this._registeredPrompts[e.params.name];if(!r)throw new od(qi.InvalidParams,`Prompt ${e.params.name} not found`);if(!r.enabled)throw new od(qi.InvalidParams,`Prompt ${e.params.name} disabled`);if(r.argsSchema){const n=Ds(r.argsSchema),s=await Ms(n,e.params.arguments);if(!s.success){const t=Ls("error"in s?s.error:"Unknown error");throw new od(qi.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${t}`)}const a=s.data,i=r.callback;return await Promise.resolve(i(a,t))}{const e=r.callback;return await Promise.resolve(e(t))}}),this._promptHandlersInitialized=!0)}resource(e,t,...r){let n;"object"==typeof r[0]&&(n=r.shift());const s=r[0];if("string"==typeof t){if(this._registeredResources[t])throw new Error(`Resource ${t} is already registered`);const r=this._createRegisteredResource(e,void 0,t,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),r}{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);const r=this._createRegisteredResourceTemplate(e,void 0,t,n,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),r}}registerResource(e,t,r,n){if("string"==typeof t){if(this._registeredResources[t])throw new Error(`Resource ${t} is already registered`);const s=this._createRegisteredResource(e,r.title,t,r,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);const s=this._createRegisteredResourceTemplate(e,r.title,t,r,n);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}_createRegisteredResource(e,t,r,n,s){const a={name:e,title:t,metadata:n,readCallback:s,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({uri:null}),update:e=>{void 0!==e.uri&&e.uri!==r&&(delete this._registeredResources[r],e.uri&&(this._registeredResources[e.uri]=a)),void 0!==e.name&&(a.name=e.name),void 0!==e.title&&(a.title=e.title),void 0!==e.metadata&&(a.metadata=e.metadata),void 0!==e.callback&&(a.readCallback=e.callback),void 0!==e.enabled&&(a.enabled=e.enabled),this.sendResourceListChanged()}};return this._registeredResources[r]=a,a}_createRegisteredResourceTemplate(e,t,r,n,s){const a={resourceTemplate:r,title:t,metadata:n,readCallback:s,enabled:!0,disable:()=>a.update({enabled:!1}),enable:()=>a.update({enabled:!0}),remove:()=>a.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&(delete this._registeredResourceTemplates[e],t.name&&(this._registeredResourceTemplates[t.name]=a)),void 0!==t.title&&(a.title=t.title),void 0!==t.template&&(a.resourceTemplate=t.template),void 0!==t.metadata&&(a.metadata=t.metadata),void 0!==t.callback&&(a.readCallback=t.callback),void 0!==t.enabled&&(a.enabled=t.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=a;const i=r.uriTemplate.variableNames;return Array.isArray(i)&&i.some(e=>!!r.completeCallback(e))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(t,r,n,s,a){const i={title:r,description:n,argsSchema:void 0===s?void 0:Cs(s),callback:a,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:e=>{void 0!==e.name&&e.name!==t&&(delete this._registeredPrompts[t],e.name&&(this._registeredPrompts[e.name]=i)),void 0!==e.title&&(i.title=e.title),void 0!==e.description&&(i.description=e.description),void 0!==e.argsSchema&&(i.argsSchema=Cs(e.argsSchema)),void 0!==e.callback&&(i.callback=e.callback),void 0!==e.enabled&&(i.enabled=e.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[t]=i,s&&Object.values(s).some(t=>pf(t instanceof e?t._def?.innerType:t))&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,t,r,n,s,a,i,o,c){mf(e);const d={title:t,description:r,inputSchema:bf(n),outputSchema:bf(s),annotations:a,execution:i,_meta:o,handler:c,enabled:!0,disable:()=>d.update({enabled:!1}),enable:()=>d.update({enabled:!0}),remove:()=>d.update({name:null}),update:t=>{void 0!==t.name&&t.name!==e&&("string"==typeof t.name&&mf(t.name),delete this._registeredTools[e],t.name&&(this._registeredTools[t.name]=d)),void 0!==t.title&&(d.title=t.title),void 0!==t.description&&(d.description=t.description),void 0!==t.paramsSchema&&(d.inputSchema=Cs(t.paramsSchema)),void 0!==t.outputSchema&&(d.outputSchema=Cs(t.outputSchema)),void 0!==t.callback&&(d.handler=t.callback),void 0!==t.annotations&&(d.annotations=t.annotations),void 0!==t._meta&&(d._meta=t._meta),void 0!==t.enabled&&(d.enabled=t.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=d,this.setToolRequestHandlers(),this.sendToolListChanged(),d}tool(e,...t){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let r,n,s;if("string"==typeof t[0]&&(r=t.shift()),t.length>1){const e=t[0];wf(e)?(n=t.shift(),t.length>1&&"object"==typeof t[0]&&null!==t[0]&&!wf(t[0])&&(s=t.shift())):"object"==typeof e&&null!==e&&(s=t.shift())}const a=t[0];return this._createRegisteredTool(e,void 0,r,n,void 0,s,{taskSupport:"forbidden"},void 0,a)}registerTool(e,t,r){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);const{title:n,description:s,inputSchema:a,outputSchema:i,annotations:o,_meta:c}=t;return this._createRegisteredTool(e,n,s,a,i,o,{taskSupport:"forbidden"},c,r)}prompt(e,...t){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let r,n;"string"==typeof t[0]&&(r=t.shift()),t.length>1&&(n=t.shift());const s=t[0],a=this._createRegisteredPrompt(e,void 0,r,n,s);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}registerPrompt(e,t,r){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);const{title:n,description:s,argsSchema:a}=t,i=this._createRegisteredPrompt(e,n,s,a,r);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}isConnected(){return void 0!==this.server.transport}async sendLoggingMessage(e,t){return this.server.sendLoggingMessage(e,t)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}}const _f={type:"object",properties:{}};function vf(e){return null!==e&&"object"==typeof e&&"parse"in e&&"function"==typeof e.parse&&"safeParse"in e&&"function"==typeof e.safeParse}function wf(e){return"object"==typeof e&&null!==e&&!function(e){return"_def"in e||"_zod"in e||vf(e)}(e)&&(0===Object.keys(e).length||Object.values(e).some(vf))}function bf(e){if(e)return wf(e)?Cs(e):e}function kf(e){const t=Zs(e);return t?Object.entries(t).map(([e,t])=>{const r=function(e){return e.description}(t),n=function(e){if(zs(e)){const t=e;return"optional"===t._zod?.def?.type}const t=e;return"function"==typeof e.isOptional?e.isOptional():"ZodOptional"===t._def?.typeName}(t);return{name:e,description:r,required:!n}}):[]}function $f(e){const t=Zs(e),r=t?.method;if(!r)throw new Error("Schema is missing a method literal");const n=Fs(r);if("string"==typeof n)return n;throw new Error("Schema method literal must be a string")}function Sf(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}const Ef={completion:{values:[],hasMore:!1}};class Tf{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;const e=this._buffer.indexOf("\n");if(-1===e)return null;const t=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),function(e){return Vi.parse(JSON.parse(e))}(t)}clear(){this._buffer=void 0}}class xf{constructor(e=r.stdin,t=r.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new Tf,this._started=!1,this._ondata=e=>{this._readBuffer.append(e),this.processReadBuffer()},this._onerror=e=>{this.onerror?.(e)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{const e=this._readBuffer.readMessage();if(null===e)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),0===this._stdin.listenerCount("data")&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(t=>{const r=function(e){return JSON.stringify(e)+"\n"}(e);this._stdout.write(r)?t():this._stdout.once("drain",t)})}}const Nf={logging:{level:"DEBUG"},db:{file:d.join(c.homedir(),".knowledge-bank","knowledge.db"),configs:["journal_mode = WAL","foreign_keys = ON"]},tmp:d.join(c.homedir(),".knowledge-bank","tmp")};let Of=null;function Pf(){if(null===Of){const e=process.env.KNOWLEDGE_CONF_DIR||d.join(c.homedir(),".knowledge-bank"),t=d.join(e,"config.json");Of={...Nf,...n.existsSync(t)?JSON.parse(n.readFileSync(t,"utf-8")):{}}}return Of}const If=Pf(),Rf={DEBUG:"DEBUG",INFO:"INFO",WARN:"WARN",ERROR:"ERROR"},jf=Object.values(Rf);class zf{constructor(e,t){this.loggerName=t;const r=If.logging.path||d.join(c.homedir(),".knowledge-bank","logs");n.mkdirSync(r,{recursive:!0}),this.loggerFile=d.join(r,`${e}.log`),this.logLevel=If.logging.level.toUpperCase()||Rf.INFO}formatMessage(e,t,r=null){const n=`${(new Date).toISOString().replace("T","-").split(".")[0]} ${this.loggerName} ${e}: ${t}`;return null===r?n:`${n} - ${JSON.stringify(r)}`}isLogLevelEnabled(e){const t=jf.indexOf(this.logLevel);return jf.indexOf(e)>=t}writeMessage(e,t,r){if(this.isLogLevelEnabled(e)){const s=this.formatMessage(e,t,r);n.appendFileSync(this.loggerFile,`${s}\n`,"utf8")}}logInfo(e,t=null){this.writeMessage(Rf.INFO,e,t)}logError(e,t=null){if(t instanceof Error){const r={message:t.message,stack:t.stack,name:t.name,...t.cause&&{cause:t.cause},...Object.getOwnPropertyNames(t).reduce((e,r)=>(["message","stack","name"].includes(r)||(e[r]=t[r]),e),{})};this.writeMessage(Rf.ERROR,e,r)}else this.writeMessage(Rf.ERROR,e,t)}logWarn(e,t=null){this.writeMessage(Rf.WARN,e,t)}logDebug(e,t=null){this.writeMessage(Rf.DEBUG,e,t)}}function Cf(e,t){return new zf(e,t)}const Af=["personal","project","organization"],Mf=["developer","architect","reviewer","ai"],Zf=["code_pattern","tool_usage","architecture","config","pitfall","api_usage","exploration"],Df={DRAFT:"draft",SUGGESTED:"suggested",VERIFIED:"verified"},Lf={knowledge_item:`\n CREATE TABLE IF NOT EXISTS knowledge_item (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n session_id TEXT NOT NULL,\n\n -- Basic information\n title TEXT NOT NULL,\n summary TEXT NOT NULL,\n content TEXT NOT NULL,\n\n -- Classification dimensions\n scope TEXT NOT NULL CHECK(scope IN (${Af.map(e=>`'${e}'`).join(", ")})),\n source_type TEXT NOT NULL CHECK(source_type IN (${Mf.map(e=>`'${e}'`).join(", ")})),\n knowledge_type TEXT NOT NULL ,\n status TEXT NOT NULL DEFAULT '${Df.DRAFT}' CHECK(status IN (${Object.values(Df).map(e=>`'${e}'`).join(", ")})),\n\n -- Source tracking\n source_file TEXT,\n contributor TEXT,\n\n -- Timestamps\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n\n FOREIGN KEY (session_id) REFERENCES session(session_id)\n )\n `,session:"\n CREATE TABLE IF NOT EXISTS session (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n session_id TEXT UNIQUE NOT NULL,\n\n -- Session basic information\n cwd TEXT NOT NULL,\n cwd_updated_at INTEGER NOT NULL,\n git_url TEXT,\n git_branch TEXT,\n git_commit_id TEXT,\n user_name TEXT,\n\n -- First user prompt for the session\n first_user_prompt TEXT,\n\n -- Environment information (stored as JSON)\n env TEXT,\n\n -- Configuration information (stored as JSON)\n config TEXT,\n\n -- Session duration (seconds, calculated on session end)\n duration INTEGER,\n\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n )\n ",session_event:"\n CREATE TABLE IF NOT EXISTS session_event (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n session_id TEXT NOT NULL,\n\n -- Hook information\n name TEXT NOT NULL,\n input TEXT NOT NULL,\n output TEXT,\n exit_code INTEGER NOT NULL DEFAULT 0,\n\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n\n FOREIGN KEY (session_id) REFERENCES session(session_id)\n )\n ",session_detail:"\n CREATE TABLE IF NOT EXISTS session_detail (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n session_id TEXT NOT NULL,\n\n -- UUID is the unique key for each transcript entry\n uuid TEXT UNIQUE NOT NULL,\n\n -- Top-level JSON fields as table columns\n type TEXT,\n parentUuid TEXT,\n isSidechain INTEGER, -- SQLite boolean as INTEGER\n userType TEXT,\n cwd TEXT,\n version TEXT,\n gitBranch TEXT,\n parentToolUseID TEXT,\n toolUseID TEXT,\n timestamp TEXT,\n isMeta INTEGER, -- SQLite boolean as INTEGER\n messageId TEXT,\n isSnapshotUpdate INTEGER, -- SQLite boolean as INTEGER\n\n -- Other fields stored as JSON strings\n data TEXT, -- JSON string\n message TEXT, -- JSON string\n snapshot TEXT, -- JSON string\n usage TEXT, -- JSON string\n\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n\n FOREIGN KEY (session_id) REFERENCES session(session_id)\n )\n ",knowledge_item_fts:"\n CREATE VIRTUAL TABLE IF NOT EXISTS knowledge_item_fts USING fts5(\n title, summary, content,\n content='knowledge_item',\n content_rowid='id',\n tokenize='trigram'\n )\n "},Ff={knowledge_item_fts_insert:"\n CREATE TRIGGER IF NOT EXISTS knowledge_item_fts_insert AFTER INSERT ON knowledge_item BEGIN\n INSERT INTO knowledge_item_fts(rowid, title, summary, content)\n VALUES (new.id, new.title, new.summary, new.content);\n END\n ",knowledge_item_fts_delete:"\n CREATE TRIGGER IF NOT EXISTS knowledge_item_fts_delete AFTER DELETE ON knowledge_item BEGIN\n INSERT INTO knowledge_item_fts(knowledge_item_fts, rowid, title, summary, content)\n VALUES('delete', old.id, old.title, old.summary, old.content);\n END\n ",knowledge_item_fts_update:"\n CREATE TRIGGER IF NOT EXISTS knowledge_item_fts_update AFTER UPDATE ON knowledge_item BEGIN\n INSERT INTO knowledge_item_fts(knowledge_item_fts, rowid, title, summary, content)\n VALUES('delete', old.id, old.title, old.summary, old.content);\n INSERT INTO knowledge_item_fts(rowid, title, summary, content)\n VALUES (new.id, new.title, new.summary, new.content);\n END\n "},qf={idx_knowledge_scope:"CREATE INDEX IF NOT EXISTS idx_knowledge_scope ON knowledge_item(scope)",idx_knowledge_type:"CREATE INDEX IF NOT EXISTS idx_knowledge_type ON knowledge_item(knowledge_type)",idx_knowledge_status:"CREATE INDEX IF NOT EXISTS idx_knowledge_status ON knowledge_item(status)",idx_knowledge_session:"CREATE INDEX IF NOT EXISTS idx_knowledge_session ON knowledge_item(session_id)",idx_session_id:"CREATE INDEX IF NOT EXISTS idx_session_id ON session(session_id)",idx_session_cwd:"CREATE INDEX IF NOT EXISTS idx_session_cwd ON session(cwd)",idx_session_event_session:"CREATE INDEX IF NOT EXISTS idx_session_event_session ON session_event(session_id)",idx_session_event_name:"CREATE INDEX IF NOT EXISTS idx_session_event_name ON session_event(name)",idx_session_detail_session:"CREATE INDEX IF NOT EXISTS idx_session_detail_session ON session_detail(session_id)",idx_session_detail_uuid:"CREATE INDEX IF NOT EXISTS idx_session_detail_uuid ON session_detail(uuid)",idx_session_detail_type:"CREATE INDEX IF NOT EXISTS idx_session_detail_type ON session_detail(type)"},Uf=Pf(),Vf=new class{constructor(){this.dbFile=Uf.db.file,this.initialized=!1}initialize(){if(!this.initialized){const e=u(this.dbFile);s(e)||a(e,{recursive:!0})}return this.initialized=!0,this}_createConnection(){const e=new l(this.dbFile);return Uf.db.configs.forEach(t=>{e.pragma(t)}),e}withConnection(e){let t=null;try{return t=this.initialize()._createConnection(),e(t)}finally{t&&(t.close(),t=null)}}static install(){Vf.withConnection(e=>{!function(e){Object.values(Lf).forEach(t=>{e.prepare(t).run()}),Object.values(qf).forEach(t=>{e.prepare(t).run()}),Object.values(Ff).forEach(t=>{e.prepare(t).run()})}(e)})}};class Hf{constructor(){this.dbInstance=Vf}withConnection(e){return this.dbInstance.withConnection(e)}}class Jf extends Hf{create(e){return this.withConnection(t=>{const r=Date.now(),n=t.prepare("\n INSERT INTO knowledge_item (\n session_id,\n title, summary, content,\n scope, source_type, knowledge_type, status,\n source_file, contributor,\n created_at, updated_at\n ) VALUES (\n @session_id,\n @title, @summary, @content,\n @scope, @source_type, @knowledge_type, @status,\n @source_file, @contributor,\n @created_at, @updated_at\n )\n ").run({...e,status:e.status||Df.DRAFT,created_at:r,updated_at:r});return this._findById(t,n.lastInsertRowid)})}_findById(e,t){return e.prepare("SELECT * FROM knowledge_item WHERE id = ?").get(t)}findById(e){return this.withConnection(t=>this._findById(t,e))}findByCwd(e,t=10){return this.withConnection(e=>e.prepare("SELECT * FROM knowledge_item ORDER BY updated_at DESC LIMIT ?").all(t))}findByScope(e){return this.withConnection(t=>t.prepare("SELECT * FROM knowledge_item WHERE scope = ? ORDER BY updated_at DESC").all(e))}findByStatus(e){return this.withConnection(t=>t.prepare("SELECT * FROM knowledge_item WHERE status = ? ORDER BY updated_at DESC").all(e))}findByKnowledgeType(e){return this.withConnection(t=>t.prepare("SELECT * FROM knowledge_item WHERE knowledge_type = ? ORDER BY updated_at DESC").all(e))}findBySessionId(e){return this.withConnection(t=>t.prepare("SELECT * FROM knowledge_item WHERE session_id = ? ORDER BY updated_at DESC").all(e))}update(e,t){return this.withConnection(r=>{const n=Date.now(),s=Object.keys(t).map(e=>`${e} = @${e}`).join(", ");return r.prepare(`\n UPDATE knowledge_item\n SET ${s},\n updated_at = @updated_at\n WHERE id = @id\n `).run({...t,id:e,updated_at:n}),r.prepare("SELECT * FROM knowledge_item WHERE id = ?").get(e)})}updateStatus(e,t){return this.update(e,{status:t})}delete(e){return this.withConnection(t=>t.prepare("DELETE FROM knowledge_item WHERE id = ?").run(e))}count(e={}){return this.withConnection(t=>{let r="SELECT COUNT(*) as count FROM knowledge_item";const n=[],s=[];return e.scope&&(n.push("scope = ?"),s.push(e.scope)),e.status&&(n.push("status = ?"),s.push(e.status)),e.knowledge_type&&(n.push("knowledge_type = ?"),s.push(e.knowledge_type)),e.session_id&&(n.push("session_id = ?"),s.push(e.session_id)),n.length>0&&(r+=` WHERE ${n.join(" AND ")}`),t.prepare(r).get(...s).count})}findAll(e=100,t=0){return this.withConnection(r=>r.prepare("SELECT * FROM knowledge_item ORDER BY updated_at DESC LIMIT ? OFFSET ?").all(e,t))}search(e,t=10){return this.withConnection(r=>{const n=Array.isArray(e)?e.map(e=>`"${e}"`).join(" OR "):`"${e}"`;return r.prepare("\n SELECT ki.*\n FROM knowledge_item ki\n JOIN knowledge_item_fts fts ON fts.rowid = ki.id\n WHERE knowledge_item_fts MATCH ?\n ORDER BY rank DESC\n LIMIT ?").all(n,t)})}}class Kf{constructor(){this.logger=Cf("knowledge-management","knowledge-management"),this.knowledgeRepo=new Jf}getSessionId(){return process.env.CLAUDE_SESSION_ID}buildUpdateData(e){const t={};return["title","summary","content","scope","source_type","knowledge_type","status","source_file","contributor"].forEach(r=>{void 0!==e[r]&&(t[r]=e[r])}),t}aggregateByStatus(e,t){e.forEach(e=>{t.by_status[e]=this.knowledgeRepo.count({status:e})})}aggregateByScope(e,t){e.forEach(e=>{t.by_scope[e]=this.knowledgeRepo.count({scope:e})})}aggregateByType(e,t){e.forEach(e=>{t.by_type[e]=this.knowledgeRepo.count({knowledge_type:e})})}async create(e){return this.logger.logInfo("Creating new knowledge item",{sessionId:e.session_id}),this.knowledgeRepo.create({title:e.title,summary:e.summary,content:e.content,scope:e.scope,source_type:e.source_type,knowledge_type:e.knowledge_type,status:e.status,source_file:e.source_file,contributor:e.contributor,session_id:e.session_id||this.getSessionId()})}async update(e,t){this.logger.logInfo(`Updating knowledge item ${e}...`);const r=this.buildUpdateData(t),n=this.knowledgeRepo.update(e,r);return this.logger.logInfo(`✓ Knowledge item ${e} updated`),n}async delete(e){this.logger.logInfo(`Deleting knowledge item ${e}...`),this.knowledgeRepo.delete(e),this.logger.logInfo(`✓ Knowledge item ${e} deleted`)}async get(e){return this.knowledgeRepo.findById(e)||(this.logger.logWarn(`Knowledge item ${e} not found`),null)}async list(e={}){if(e.scope)return this.knowledgeRepo.findByScope(e.scope);if(e.status)return this.knowledgeRepo.findByStatus(e.status);if(e.knowledge_type)return this.knowledgeRepo.findByKnowledgeType(e.knowledge_type);const t=e.limit||100,r=e.offset||0;return this.knowledgeRepo.findAll(t,r)}async search(e,t=10){return this.knowledgeRepo.search(e,t)}async updateStatus(e,t){this.logger.logInfo(`Updating status of knowledge item ${e} to ${t}...`);const r=this.knowledgeRepo.updateStatus(e,t);return this.logger.logInfo(`✓ Status updated to ${t}`),r}async getStats(){const e={total:0,by_status:{draft:0,suggested:0,verified:0},by_scope:{personal:0,project:0,organization:0},by_type:{code_pattern:0,architecture:0,config:0,pitfall:0,api_usage:0}};return e.total=this.knowledgeRepo.count({}),this.aggregateByStatus(["draft","suggested","verified"],e),this.aggregateByScope(["personal","project","organization"],e),this.aggregateByType(["code_pattern","architecture","config","pitfall","api_usage"],e),e}}class Bf{static exists(e){return s(e)}static writeJson(e,t){const r=u(e);a(r,{recursive:!0}),i(e,JSON.stringify(t,null,2),"utf8")}static readJson(e){if(!this.exists(e))throw new Error(`File not found: ${e}`);const t=o(e,"utf8");return JSON.parse(t)}static writeMarkdown(e,t){const r=u(e);a(r,{recursive:!0}),i(e,t,"utf8")}static formatKnowledgeAsMarkdown(e){return`# ${e.title}\n\n**ID:** ${e.id}\n**Summary:** ${e.summary}\n**Knowledge Type:** ${e.knowledge_type}\n**Status:** ${e.status}\n**Scope:** ${e.scope}\n**Source Type:** ${e.source_type}\n${e.source_file?`**Source File:** ${e.source_file}`:""}\n${e.contributor?`**Contributor:** ${e.contributor}`:""}\n${e.created_at?`**Created At:** ${e.created_at}`:""}\n${e.updated_at?`**Updated At:** ${e.updated_at}`:""}\n\n## Content\n\n${e.content}\n`}static extractKnowledgeForJson(e){return{title:e.title,summary:e.summary,content:e.content,knowledge_type:e.knowledge_type,status:e.status,scope:e.scope,source_type:e.source_type,source_file:e.source_file||null,contributor:e.contributor||null}}}const Gf=new class{constructor(e={}){this.isDev=void 0!==e.isDev?e.isDev:this.detectEnvironment(),this._rootDir=null,this._packageFile=null,this._marketplaceRepo=null}detectEnvironment(){const e=p(import.meta.url),t=d.dirname(e),r=n.existsSync(d.join(t,"..","..","src")),s=t.includes("dist"),a=d.join(t,"..","..","package.json"),i=d.join(t,"..","package.json");return r&&!s||!n.existsSync(i)&&n.existsSync(a)}getRootDir(){if(this._rootDir)return this._rootDir;const e=p(import.meta.url),t=d.dirname(e);if(this.isDev)this._rootDir=d.join(t,"..","..");else if(t.includes("dist")){const e=t.indexOf("dist");this._rootDir=t.substring(0,e-1)}else if(t.includes("src"))this._rootDir=d.join(t,"..","..");else{let e=t;for(;e!==d.dirname(e);){const t=d.join(e,"package.json");if(n.existsSync(t)){this._rootDir=e;break}e=d.dirname(e)}this._rootDir||(this._rootDir=d.dirname(t))}return this._rootDir}getPackageFile(){if(this._packageFile)return this._packageFile;const e=this.getRootDir();if(this._packageFile=d.join(e,"package.json"),!n.existsSync(this._packageFile)){const e=d.join(process.cwd(),"package.json");if(!n.existsSync(e))throw new Error(`package.json not found at ${this._packageFile} or ${e}`);this._packageFile=e}return this._packageFile}getMarketplaceRepo(){if(this._marketplaceRepo)return this._marketplaceRepo;const e=this.getRootDir();if(this.isDev){const t=d.join(e,"dist","claude-marketplace"),r=d.join(e,"src","claude-marketplace");if(n.existsSync(t))this._marketplaceRepo=t;else{if(!n.existsSync(r))throw new Error(`Marketplace directory not found at ${t} or ${r}`);this._marketplaceRepo=r}}else if(this._marketplaceRepo=d.join(e,"dist","claude-marketplace"),!n.existsSync(this._marketplaceRepo))throw new Error(`Marketplace directory not found at ${this._marketplaceRepo}`);return this._marketplaceRepo}getWebViewsPath(){const e=this.getRootDir();return this.isDev?d.join(e,"src","web","views"):d.join(e,"dist","web","views")}getWebPublicPath(){const e=this.getRootDir();return this.isDev?d.join(e,"src","web","public"):d.join(e,"dist","web","public")}};Cf("common","common");const Xf=Gf.getPackageFile();Gf.getMarketplaceRepo();const Wf=JSON.parse(o(Xf,"utf8"));d.join(c.homedir(),".claude","settings.local.json");const Yf=Pf(),Qf=Cf("mcp-server","mcp-server");class eh{constructor(){this.knowledgeManagement=new Kf,this.tempDir=Yf.tmp,this.server=new yf({name:"knowledge-bank",version:Wf.version},{capabilities:{tools:{}}}),this.setupHandlers()}setupHandlers(){this.server.registerTool("knowledge_create",{description:"Create a new knowledge item",inputSchema:t.object({session_id:t.string().describe("Session ID for tracking, can be omitted to use env vars CLAUDE_SESSION_ID"),title:t.string().optional().describe("Knowledge title"),summary:t.string().optional().describe("Knowledge summary"),content:t.string().optional().describe("Knowledge content"),scope:t.enum(Af).optional().describe("Scope of knowledge"),source_type:t.enum(Mf).optional().describe("Source type"),knowledge_type:t.enum(Zf).optional().describe("Knowledge type"),status:t.enum(Df).optional().describe("Status of knowledge"),source_file:t.string().optional().describe("Source file path (optional)"),contributor:t.string().optional().describe("Contributor name (optional)"),from:t.string().optional().describe("Load knowledge data from JSON file")})},async e=>await this.handleCreate(e)),this.server.registerTool("knowledge_get",{description:"Get a knowledge item by ID",inputSchema:t.object({id:t.number().describe("Knowledge item ID"),to:t.string().optional().describe("Save knowledge to markdown file")})},async e=>await this.handleGet(e)),this.server.registerTool("knowledge_update",{description:"Update a knowledge item",inputSchema:t.object({id:t.number().describe("Knowledge item ID"),title:t.string().optional().describe("Knowledge title"),summary:t.string().optional().describe("Knowledge summary"),content:t.string().optional().describe("Knowledge content"),scope:t.enum(Af).optional().describe("Scope of knowledge"),source_type:t.enum(Mf).optional().describe("Source type"),knowledge_type:t.enum(Zf).optional().describe("Knowledge type"),status:t.enum(Df).optional().describe("Status of knowledge"),source_file:t.string().optional().describe("Source file path"),contributor:t.string().optional().describe("Contributor name"),from:t.string().optional().describe("Load update data from JSON file")})},async e=>await this.handleUpdate(e)),this.server.registerTool("knowledge_delete",{description:"Delete a knowledge item",inputSchema:t.object({id:t.number().describe("Knowledge item ID")})},async e=>await this.handleDelete(e)),this.server.registerTool("knowledge_list",{description:"List knowledge items with optional filters",inputSchema:t.object({scope:t.enum(Af).optional().describe("Filter by scope"),status:t.enum(Df).optional().describe("Filter by status"),knowledge_type:t.enum(Zf).optional().describe("Filter by knowledge type"),limit:t.number().default(100).describe("Limit number of results"),offset:t.number().default(0).describe("Offset for pagination"),to:t.string().optional().describe("Save results to JSON file")})},async e=>await this.handleList(e)),this.server.registerTool("knowledge_search",{description:"Search knowledge items by text query",inputSchema:t.object({query:t.array(t.string()).describe("Search query terms"),limit:t.number().default(10).describe("Limit number of results"),to:t.string().optional().describe("Save results to JSON file")})},async e=>await this.handleSearch(e)),this.server.registerTool("knowledge_update_status",{description:"Update knowledge item status",inputSchema:t.object({id:t.number().describe("Knowledge item ID"),status:t.enum(Df).describe("New status")})},async e=>await this.handleUpdateStatus(e)),this.server.registerTool("knowledge_stats",{description:"Get knowledge statistics",inputSchema:t.object({})},async()=>await this.handleStats())}async handleCreate(e){let t=e;if(e.from){const r=d.join(this.tempDir,d.basename(e.from));if(!Bf.exists(r))return{content:[{type:"text",text:JSON.stringify({error:`File not found: ${r}`},null,2)}],isError:!0};try{t=Bf.readJson(r)}catch(e){return{content:[{type:"text",text:JSON.stringify({error:`Error reading JSON file: ${e.message}`},null,2)}],isError:!0}}}const r=await this.knowledgeManagement.create({title:t.title,summary:t.summary,content:t.content,scope:t.scope,source_type:t.source_type,knowledge_type:t.knowledge_type,status:t.status,source_file:t.source_file,contributor:t.contributor,session_id:e.session_id||process.env.CLAUDE_SESSION_ID||t.session_id||"unknown-session"});return e.from?{content:[{type:"text",text:JSON.stringify({id:r.id,title:r.title,message:`Knowledge item created from ${e.from}`,file_path:e.from},null,2)}]}:{content:[{type:"text",text:JSON.stringify(r,null,2)}]}}async handleGet(e){const t=await this.knowledgeManagement.get(e.id);if(!t)return{content:[{type:"text",text:JSON.stringify({error:"Knowledge item not found"},null,2)}],isError:!0};if(e.to)try{const r=d.join(this.tempDir,d.basename(e.to)),n=Bf.formatKnowledgeAsMarkdown(t);return Bf.writeMarkdown(r,n),{content:[{type:"text",text:JSON.stringify({success:!0,message:`Knowledge item ${e.id} saved to ${r}`,file_path:r},null,2)}]}}catch(e){return{content:[{type:"text",text:JSON.stringify({error:`Error saving file: ${e.message}`},null,2)}],isError:!0}}return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}async handleUpdate(e){const{id:t,from:r,...n}=e;let s=n;if(r){const e=d.join(this.tempDir,r);if(!Bf.exists(e))return{content:[{type:"text",text:JSON.stringify({error:`File not found: ${e}`},null,2)}],isError:!0};try{s={...Bf.readJson(e),...n}}catch(e){return{content:[{type:"text",text:JSON.stringify({error:`Error reading JSON file: ${e.message}`},null,2)}],isError:!0}}}const a=await this.knowledgeManagement.update(t,s);return{content:[{type:"text",text:JSON.stringify({id:a.id,session_id:a.session_id,message:"knowledge item updated"},null,2)}]}}async handleDelete(e){return await this.knowledgeManagement.delete(e.id),{content:[{type:"text",text:JSON.stringify({success:!0,message:"Knowledge item deleted successfully"})}]}}async handleList(e={}){const{to:t,...r}=e,n=await this.knowledgeManagement.list(r);if(t)try{const e=d.join(this.tempDir,d.basename(t)),s=n.map(e=>Bf.extractKnowledgeForJson(e));return Bf.writeJson(e,{count:n.length,filters:r,timestamp:(new Date).toISOString(),data:s}),{content:[{type:"text",text:JSON.stringify({success:!0,message:`${n.length} knowledge items saved to ${e}`,file_path:e},null,2)}]}}catch(e){return{content:[{type:"text",text:JSON.stringify({error:`Error saving file: ${e.message}`},null,2)}],isError:!0}}return{content:[{type:"text",text:JSON.stringify(n,null,2)}]}}async handleSearch(e){const{to:t,query:r,limit:n}=e,s=await this.knowledgeManagement.search(r,n);if(t)try{const e=d.join(this.tempDir,d.basename(t)),a=s.map(e=>Bf.extractKnowledgeForJson(e));return Bf.writeJson(e,{query:r,limit:n,count:s.length,timestamp:(new Date).toISOString(),data:a}),{content:[{type:"text",text:JSON.stringify({success:!0,message:`Search results (${s.length} items) saved to ${e}`,file_path:e},null,2)}]}}catch(e){return{content:[{type:"text",text:JSON.stringify({error:`Error saving file: ${e.message}`},null,2)}],isError:!0}}return{content:[{type:"text",text:JSON.stringify(s,null,2)}]}}async handleUpdateStatus(e){const t=await this.knowledgeManagement.updateStatus(e.id,e.status);return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}async handleStats(){const e=await this.knowledgeManagement.getStats();return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}async run(){const e=new xf;await this.server.connect(e),Qf.logWarn(`Knowledge Bank MCP server running under ${process.cwd()}`)}}export{eh as KnowledgeBankMCPServer};