@gabrywu/knowledge-bank 0.1.2-alpha.175 → 0.1.2-alpha.181
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.
package/dist/mcp-server.js
CHANGED
|
@@ -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,readFileSync as o,writeFileSync as i}from"fs";import c,{dirname as d}from"path";import u from"os";import l from"better-sqlite3";import p from"simple-git";import{cwd as h}from"process";import{fileURLToPath as f}from"url";import"child_process";var m,g;!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}(m||(m={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(g||(g={}));const y=m.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),_=e=>{switch(typeof e){case"undefined":return y.undefined;case"string":return y.string;case"number":return Number.isNaN(e)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(e)?y.array:null===e?y.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?y.promise:"undefined"!=typeof Map&&e instanceof Map?y.map:"undefined"!=typeof Set&&e instanceof Set?y.set:"undefined"!=typeof Date&&e instanceof Date?y.date:y.object;default:return y.unknown}},v=m.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class w 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 w))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,m.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()}}w.create=e=>new w(e);const b=(e,t)=>{let r;switch(e.code){case v.invalid_type:r=e.received===y.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case v.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,m.jsonStringifyReplacer)}`;break;case v.unrecognized_keys:r=`Unrecognized key(s) in object: ${m.joinValues(e.keys,", ")}`;break;case v.invalid_union:r="Invalid input";break;case v.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${m.joinValues(e.options)}`;break;case v.invalid_enum_value:r=`Invalid enum value. Expected ${m.joinValues(e.options)}, received '${e.received}'`;break;case v.invalid_arguments:r="Invalid function arguments";break;case v.invalid_return_type:r="Invalid function return type";break;case v.invalid_date:r="Invalid date";break;case v.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}"`:m.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case v.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 v.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 v.custom:r="Invalid input";break;case v.invalid_intersection_types:r="Intersection results could not be merged";break;case v.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case v.not_finite:r="Number must be finite";break;default:r=t.defaultError,m.assertNever(e)}return{message:r}};let k=b;function $(e,t){const r=k,n=(e=>{const{data:t,path:r,errorMaps:n,issueData:s}=e,a=[...r,...s.path||[]],o={...s,path:a};if(void 0!==s.message)return{...s,path:a,message:s.message};let i="";const c=n.filter(e=>!!e).slice().reverse();for(const e of c)i=e(o,{data:t,defaultError:i}).message;return{...s,path:a,message:i}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===b?void 0:b].filter(e=>!!e)});e.common.issues.push(n)}class E{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 S;"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 E.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 S;if("aborted"===s.status)return S;"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 S=Object.freeze({status:"aborted"}),T=e=>({status:"dirty",value:e}),x=e=>({status:"valid",value:e}),N=e=>"aborted"===e.status,O=e=>"dirty"===e.status,P=e=>"valid"===e.status,I=e=>"undefined"!=typeof Promise&&e instanceof Promise;var R;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(R||(R={}));class C{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 z=(e,t)=>{if(P(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 w(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 A=class{get description(){return this._def.description}_getType(e){return _(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:_(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new E,ctx:{common:e.parent.common,data:e.data,parsedType:_(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(I(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:_(e)},n=this._parseSync({data:e,path:r.path,parent:r});return z(r,n)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:_(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:t});return P(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=>P(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:_(e)},n=this._parse({data:e,path:r.path,parent:r}),s=await(I(n)?n:Promise.resolve(n));return z(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:v.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 ze({schema:this,typeName:Ue.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 Ae.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ve.create(this)}promise(){return Ce.create(this,this._def)}or(e){return ke.create([this,e],this._def)}and(e){return Ee.create(this,e,this._def)}transform(e){return new ze({...j(this._def),schema:this,typeName:Ue.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Me({...j(this._def),innerType:this,defaultValue:t,typeName:Ue.ZodDefault})}brand(){return new Le({typeName:Ue.ZodBranded,type:this,...j(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Ze({...j(this._def),innerType:this,catchValue:t,typeName:Ue.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Fe.create(this,e)}readonly(){return qe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const M=/^c[^\s-]{8,}$/i,Z=/^[0-9a-z]+$/,D=/^[0-9A-HJKMNP-TV-Z]{26}$/i,L=/^[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,F=/^[a-z0-9_-]{21}$/i,q=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,U=/^[-+]?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)?)??$/,V=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let H;const K=/^(?:(?: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])$/,J=/^(?:(?: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])$/,B=/^(([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]))$/,G=/^(([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])$/,W=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,X=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Y="((\\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])))",Q=new RegExp(`^${Y}$`);function ee(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 te(e){return new RegExp(`^${ee(e)}$`)}function re(e){let t=`${Y}T${ee(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 ne(e,t){return!("v4"!==t&&t||!K.test(e))||!("v6"!==t&&t||!B.test(e))}function se(e,t){if(!q.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 ae(e,t){return!("v4"!==t&&t||!J.test(e))||!("v6"!==t&&t||!G.test(e))}let oe=class e extends A{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.string,received:t.parsedType}),S}const t=new E;let r;for(const n of this._def.checks)if("min"===n.kind)e.data.length<n.value&&(r=this._getOrReturnCtx(e,r),$(r,{code:v.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),$(r,{code:v.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?$(r,{code:v.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):a&&$(r,{code:v.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if("email"===n.kind)V.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"email",code:v.invalid_string,message:n.message}),t.dirty());else if("emoji"===n.kind)H||(H=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),H.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"emoji",code:v.invalid_string,message:n.message}),t.dirty());else if("uuid"===n.kind)L.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"uuid",code:v.invalid_string,message:n.message}),t.dirty());else if("nanoid"===n.kind)F.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"nanoid",code:v.invalid_string,message:n.message}),t.dirty());else if("cuid"===n.kind)M.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"cuid",code:v.invalid_string,message:n.message}),t.dirty());else if("cuid2"===n.kind)Z.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"cuid2",code:v.invalid_string,message:n.message}),t.dirty());else if("ulid"===n.kind)D.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"ulid",code:v.invalid_string,message:n.message}),t.dirty());else if("url"===n.kind)try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),$(r,{validation:"url",code:v.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),$(r,{validation:"regex",code:v.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),$(r,{code:v.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),$(r,{code:v.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):"endsWith"===n.kind?e.data.endsWith(n.value)||(r=this._getOrReturnCtx(e,r),$(r,{code:v.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):"datetime"===n.kind?re(n).test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{code:v.invalid_string,validation:"datetime",message:n.message}),t.dirty()):"date"===n.kind?Q.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{code:v.invalid_string,validation:"date",message:n.message}),t.dirty()):"time"===n.kind?te(n).test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{code:v.invalid_string,validation:"time",message:n.message}),t.dirty()):"duration"===n.kind?U.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"duration",code:v.invalid_string,message:n.message}),t.dirty()):"ip"===n.kind?ne(e.data,n.version)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"ip",code:v.invalid_string,message:n.message}),t.dirty()):"jwt"===n.kind?se(e.data,n.alg)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"jwt",code:v.invalid_string,message:n.message}),t.dirty()):"cidr"===n.kind?ae(e.data,n.version)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"cidr",code:v.invalid_string,message:n.message}),t.dirty()):"base64"===n.kind?W.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"base64",code:v.invalid_string,message:n.message}),t.dirty()):"base64url"===n.kind?X.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"base64url",code:v.invalid_string,message:n.message}),t.dirty()):m.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:v.invalid_string,...R.errToObj(r)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:"email",...R.errToObj(e)})}url(e){return this._addCheck({kind:"url",...R.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...R.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...R.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...R.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...R.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...R.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...R.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...R.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...R.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...R.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...R.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...R.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,...R.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,...R.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...R.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...R.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...R.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...R.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...R.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...R.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...R.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...R.errToObj(t)})}nonempty(e){return this.min(1,R.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 ie(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}oe.create=e=>new oe({checks:[],typeName:Ue.ZodString,coerce:e?.coerce??!1,...j(e)});let ce=class e extends A{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==y.number){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.number,received:t.parsedType}),S}let t;const r=new E;for(const n of this._def.checks)"int"===n.kind?m.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),$(t,{code:v.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),$(t,{code:v.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),$(t,{code:v.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"multipleOf"===n.kind?0!==ie(e.data,n.value)&&(t=this._getOrReturnCtx(e,t),$(t,{code:v.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),$(t,{code:v.not_finite,message:n.message}),r.dirty()):m.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,R.toString(t))}gt(e,t){return this.setLimit("min",e,!1,R.toString(t))}lte(e,t){return this.setLimit("max",e,!0,R.toString(t))}lt(e,t){return this.setLimit("max",e,!1,R.toString(t))}setLimit(t,r,n,s){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:R.toString(s)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:"int",message:R.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:R.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:R.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:R.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:R.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:R.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:R.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:R.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:R.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&&m.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)}};ce.create=e=>new ce({checks:[],typeName:Ue.ZodNumber,coerce:e?.coerce||!1,...j(e)});class de extends A{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)!==y.bigint)return this._getInvalidInput(e);let t;const r=new E;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),$(t,{code:v.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),$(t,{code:v.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),$(t,{code:v.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):m.assertNever(n);return{status:r.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.bigint,received:t.parsedType}),S}gte(e,t){return this.setLimit("min",e,!0,R.toString(t))}gt(e,t){return this.setLimit("min",e,!1,R.toString(t))}lte(e,t){return this.setLimit("max",e,!0,R.toString(t))}lt(e,t){return this.setLimit("max",e,!1,R.toString(t))}setLimit(e,t,r,n){return new de({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:R.toString(n)}]})}_addCheck(e){return new de({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:R.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:R.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:R.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:R.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:R.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}}de.create=e=>new de({checks:[],typeName:Ue.ZodBigInt,coerce:e?.coerce??!1,...j(e)});let ue=class extends A{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==y.boolean){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.boolean,received:t.parsedType}),S}return x(e.data)}};ue.create=e=>new ue({typeName:Ue.ZodBoolean,coerce:e?.coerce||!1,...j(e)});class le extends A{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.date,received:t.parsedType}),S}if(Number.isNaN(e.data.getTime()))return $(this._getOrReturnCtx(e),{code:v.invalid_date}),S;const t=new E;let r;for(const n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(r=this._getOrReturnCtx(e,r),$(r,{code:v.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),$(r,{code:v.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):m.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new le({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:R.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:R.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}}le.create=e=>new le({checks:[],coerce:e?.coerce||!1,typeName:Ue.ZodDate,...j(e)});class pe extends A{_parse(e){if(this._getType(e)!==y.symbol){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.symbol,received:t.parsedType}),S}return x(e.data)}}pe.create=e=>new pe({typeName:Ue.ZodSymbol,...j(e)});class he extends A{_parse(e){if(this._getType(e)!==y.undefined){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.undefined,received:t.parsedType}),S}return x(e.data)}}he.create=e=>new he({typeName:Ue.ZodUndefined,...j(e)});let fe=class extends A{_parse(e){if(this._getType(e)!==y.null){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.null,received:t.parsedType}),S}return x(e.data)}};fe.create=e=>new fe({typeName:Ue.ZodNull,...j(e)});class me extends A{constructor(){super(...arguments),this._any=!0}_parse(e){return x(e.data)}}me.create=e=>new me({typeName:Ue.ZodAny,...j(e)});let ge=class extends A{constructor(){super(...arguments),this._unknown=!0}_parse(e){return x(e.data)}};ge.create=e=>new ge({typeName:Ue.ZodUnknown,...j(e)});let ye=class extends A{_parse(e){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.never,received:t.parsedType}),S}};ye.create=e=>new ye({typeName:Ue.ZodNever,...j(e)});class _e extends A{_parse(e){if(this._getType(e)!==y.undefined){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.void,received:t.parsedType}),S}return x(e.data)}}_e.create=e=>new _e({typeName:Ue.ZodVoid,...j(e)});let ve=class e extends A{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==y.array)return $(t,{code:v.invalid_type,expected:y.array,received:t.parsedType}),S;if(null!==n.exactLength){const e=t.data.length>n.exactLength.value,s=t.data.length<n.exactLength.value;(e||s)&&($(t,{code:e?v.too_big:v.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&&($(t,{code:v.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&&($(t,{code:v.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 C(t,e,t.path,r)))).then(e=>E.mergeArray(r,e));const s=[...t.data].map((e,r)=>n.type._parseSync(new C(t,e,t.path,r)));return E.mergeArray(r,s)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:R.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:R.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:R.toString(r)}})}nonempty(e){return this.min(1,e)}};function we(e){if(e instanceof be){const t={};for(const r in e.shape){const n=e.shape[r];t[r]=je.create(we(n))}return new be({...e._def,shape:()=>t})}return e instanceof ve?new ve({...e._def,type:we(e.element)}):e instanceof je?je.create(we(e.unwrap())):e instanceof Ae?Ae.create(we(e.unwrap())):e instanceof Se?Se.create(e.items.map(e=>we(e))):e}ve.create=(e,t)=>new ve({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ue.ZodArray,...j(t)});let be=class e extends A{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=m.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==y.object){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.object,received:t.parsedType}),S}const{status:t,ctx:r}=this._processInputParams(e),{shape:n,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof ye&&"strip"===this._def.unknownKeys))for(const e in r.data)s.includes(e)||a.push(e);const o=[];for(const e of s){const t=n[e],s=r.data[e];o.push({key:{status:"valid",value:e},value:t._parse(new C(r,s,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof ye){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of a)o.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)a.length>0&&($(r,{code:v.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];o.push({key:{status:"valid",value:t},value:e._parse(new C(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of o){const r=await t.key,n=await t.value;e.push({key:r,value:n,alwaysSet:t.alwaysSet})}return e}).then(e=>E.mergeObjectSync(t,e)):E.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return R.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:R.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:Ue.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 m.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 m.objectKeys(this.shape))t[e]||(r[e]=this.shape[e]);return new e({...this._def,shape:()=>r})}deepPartial(){return we(this)}partial(t){const r={};for(const e of m.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 m.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 Pe(m.objectKeys(this.shape))}};be.create=(e,t)=>new be({shape:()=>e,unknownKeys:"strip",catchall:ye.create(),typeName:Ue.ZodObject,...j(t)}),be.strictCreate=(e,t)=>new be({shape:()=>e,unknownKeys:"strict",catchall:ye.create(),typeName:Ue.ZodObject,...j(t)}),be.lazycreate=(e,t)=>new be({shape:e,unknownKeys:"strip",catchall:ye.create(),typeName:Ue.ZodObject,...j(t)});let ke=class extends A{_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 w(e.ctx.common.issues));return $(t,{code:v.invalid_union,unionErrors:r}),S});{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 w(e));return $(t,{code:v.invalid_union,unionErrors:s}),S}}get options(){return this._def.options}};function $e(e,t){const r=_(e),n=_(t);if(e===t)return{valid:!0,data:e};if(r===y.object&&n===y.object){const r=m.objectKeys(t),n=m.objectKeys(e).filter(e=>-1!==r.indexOf(e)),s={...e,...t};for(const r of n){const n=$e(e[r],t[r]);if(!n.valid)return{valid:!1};s[r]=n.data}return{valid:!0,data:s}}if(r===y.array&&n===y.array){if(e.length!==t.length)return{valid:!1};const r=[];for(let n=0;n<e.length;n++){const s=$e(e[n],t[n]);if(!s.valid)return{valid:!1};r.push(s.data)}return{valid:!0,data:r}}return r===y.date&&n===y.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}ke.create=(e,t)=>new ke({options:e,typeName:Ue.ZodUnion,...j(t)});let Ee=class extends A{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=(e,n)=>{if(N(e)||N(n))return S;const s=$e(e.value,n.value);return s.valid?((O(e)||O(n))&&t.dirty(),{status:t.value,value:s.data}):($(r,{code:v.invalid_intersection_types}),S)};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}))}};Ee.create=(e,t,r)=>new Ee({left:e,right:t,typeName:Ue.ZodIntersection,...j(r)});class Se extends A{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.array)return $(r,{code:v.invalid_type,expected:y.array,received:r.parsedType}),S;if(r.data.length<this._def.items.length)return $(r,{code:v.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),S;!this._def.rest&&r.data.length>this._def.items.length&&($(r,{code:v.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 C(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(n).then(e=>E.mergeArray(t,e)):E.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new Se({...this._def,rest:e})}}Se.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Se({items:e,typeName:Ue.ZodTuple,rest:null,...j(t)})};class Te extends A{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!==y.map)return $(r,{code:v.invalid_type,expected:y.map,received:r.parsedType}),S;const n=this._def.keyType,s=this._def.valueType,a=[...r.data.entries()].map(([e,t],a)=>({key:n._parse(new C(r,e,r.path,[a,"key"])),value:s._parse(new C(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 S;"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 S;"dirty"!==n.status&&"dirty"!==s.status||t.dirty(),e.set(n.value,s.value)}return{status:t.value,value:e}}}}Te.create=(e,t,r)=>new Te({valueType:t,keyType:e,typeName:Ue.ZodMap,...j(r)});class xe extends A{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.set)return $(r,{code:v.invalid_type,expected:y.set,received:r.parsedType}),S;const n=this._def;null!==n.minSize&&r.data.size<n.minSize.value&&($(r,{code:v.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&&($(r,{code:v.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 S;"dirty"===n.status&&t.dirty(),r.add(n.value)}return{status:t.value,value:r}}const o=[...r.data.values()].map((e,t)=>s._parse(new C(r,e,r.path,t)));return r.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(e,t){return new xe({...this._def,minSize:{value:e,message:R.toString(t)}})}max(e,t){return new xe({...this._def,maxSize:{value:e,message:R.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}xe.create=(e,t)=>new xe({valueType:e,minSize:null,maxSize:null,typeName:Ue.ZodSet,...j(t)});class Ne extends A{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})}}Ne.create=(e,t)=>new Ne({getter:e,typeName:Ue.ZodLazy,...j(t)});let Oe=class extends A{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return $(t,{received:t.data,code:v.invalid_literal,expected:this._def.value}),S}return{status:"valid",value:e.data}}get value(){return this._def.value}};function Pe(e,t){return new Ie({values:e,typeName:Ue.ZodEnum,...j(t)})}Oe.create=(e,t)=>new Oe({value:e,typeName:Ue.ZodLiteral,...j(t)});let Ie=class e extends A{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),r=this._def.values;return $(t,{expected:m.joinValues(r),received:t.parsedType,code:v.invalid_type}),S}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 $(t,{received:t.data,code:v.invalid_enum_value,options:r}),S}return x(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})}};Ie.create=Pe;class Re extends A{_parse(e){const t=m.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){const e=m.objectValues(t);return $(r,{expected:m.joinValues(e),received:r.parsedType,code:v.invalid_type}),S}if(this._cache||(this._cache=new Set(m.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=m.objectValues(t);return $(r,{received:r.data,code:v.invalid_enum_value,options:e}),S}return x(e.data)}get enum(){return this._def.values}}Re.create=(e,t)=>new Re({values:e,typeName:Ue.ZodNativeEnum,...j(t)});class Ce extends A{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.promise&&!1===t.common.async)return $(t,{code:v.invalid_type,expected:y.promise,received:t.parsedType}),S;const r=t.parsedType===y.promise?t.data:Promise.resolve(t.data);return x(r.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ce.create=(e,t)=>new Ce({type:e,typeName:Ue.ZodPromise,...j(t)});class ze extends A{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ue.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=>{$(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 S;const n=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===n.status?S:"dirty"===n.status||"dirty"===t.value?T(n.value):n});{if("aborted"===t.value)return S;const n=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===n.status?S:"dirty"===n.status||"dirty"===t.value?T(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?S:("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?S:("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(!P(e))return S;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=>P(e)?Promise.resolve(n.transform(e.value,s)).then(e=>({status:t.value,value:e})):S)}m.assertNever(n)}}ze.create=(e,t,r)=>new ze({schema:e,typeName:Ue.ZodEffects,effect:t,...j(r)}),ze.createWithPreprocess=(e,t,r)=>new ze({schema:t,effect:{type:"preprocess",transform:e},typeName:Ue.ZodEffects,...j(r)});let je=class extends A{_parse(e){return this._getType(e)===y.undefined?x(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};je.create=(e,t)=>new je({innerType:e,typeName:Ue.ZodOptional,...j(t)});let Ae=class extends A{_parse(e){return this._getType(e)===y.null?x(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ae.create=(e,t)=>new Ae({innerType:e,typeName:Ue.ZodNullable,...j(t)});let Me=class extends A{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Me.create=(e,t)=>new Me({innerType:e,typeName:Ue.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...j(t)});let Ze=class extends A{_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 I(n)?n.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new w(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new w(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Ze.create=(e,t)=>new Ze({innerType:e,typeName:Ue.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...j(t)});class De extends A{_parse(e){if(this._getType(e)!==y.nan){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.nan,received:t.parsedType}),S}return{status:"valid",value:e.data}}}De.create=e=>new De({typeName:Ue.ZodNaN,...j(e)});class Le extends A{_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 Fe extends A{_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?S:"dirty"===e.status?(t.dirty(),T(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?S:"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 Fe({in:e,out:t,typeName:Ue.ZodPipeline})}}let qe=class extends A{_parse(e){const t=this._def.innerType._parse(e),r=e=>(P(e)&&(e.value=Object.freeze(e.value)),e);return I(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}};var Ue;qe.create=(e,t)=>new qe({innerType:e,typeName:Ue.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"}(Ue||(Ue={})),ye.create,ve.create;const Ve=be.create;function He(e,t,r){function n(r,n){if(r._zod||Object.defineProperty(r,"_zod",{value:{def:n,constr:o,traits:new Set},enumerable:!1}),r._zod.traits.has(e))return;r._zod.traits.add(e),t(r,n);const s=o.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 o(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(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>!!(r?.Parent&&t instanceof r.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}ke.create,Ee.create,Se.create,Ie.create,Ce.create,je.create,Ae.create;class Ke extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Je extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Be={};function Ge(e){return Be}function We(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 Xe(e,t){return"bigint"==typeof t?t.toString():t}function Ye(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Qe(e){return null==e}function et(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}const tt=Symbol("evaluating");function rt(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==tt)return void 0===n&&(n=tt,n=r()),n},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function nt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function st(...e){const t={};for(const r of e){const e=Object.getOwnPropertyDescriptors(r);Object.assign(t,e)}return Object.defineProperties({},t)}function at(e){return JSON.stringify(e)}const ot="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function it(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const ct=Ye(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function dt(e){if(!1===it(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!==it(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function ut(e){return dt(e)?{...e}:Array.isArray(e)?[...e]:e}const lt=new Set(["string","number","symbol"]);function pt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ht(e,t,r){const n=new e._zod.constr(t??e._zod.def);return t&&!r?.parent||(n._zod.parent=e),n}function ft(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 mt={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 gt(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 yt(e,t){return t.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(e),t})}function _t(e){return"string"==typeof e?e:e?.message}function vt(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const s=_t(e.inst?._zod.def?.error?.(e))??_t(t?.error?.(e))??_t(r.customError?.(e))??_t(r.localeError?.(e))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function wt(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function bt(...e){const[t,r,n]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:n}:{...t}}const kt=(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,Xe,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$t=He("$ZodError",kt),Et=He("$ZodError",kt,{Parent:Error}),St=e=>(t,r,n,s)=>{const a=n?Object.assign(n,{async:!1}):{async:!1},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise)throw new Ke;if(o.issues.length){const t=new(s?.Err??e)(o.issues.map(e=>vt(e,a,Ge())));throw ot(t,s?.callee),t}return o.value},Tt=St(Et),xt=e=>async(t,r,n,s)=>{const a=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){const t=new(s?.Err??e)(o.issues.map(e=>vt(e,a,Ge())));throw ot(t,s?.callee),t}return o.value},Nt=xt(Et),Ot=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 Ke;return a.issues.length?{success:!1,error:new(e??$t)(a.issues.map(e=>vt(e,s,Ge())))}:{success:!0,data:a.value}},Pt=Ot(Et),It=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=>vt(e,s,Ge())))}:{success:!0,data:a.value}},Rt=It(Et),Ct=e=>(t,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return St(e)(t,r,s)},zt=e=>(t,r,n)=>St(e)(t,r,n),jt=e=>async(t,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return xt(e)(t,r,s)},At=e=>async(t,r,n)=>xt(e)(t,r,n),Mt=e=>(t,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ot(e)(t,r,s)},Zt=e=>(t,r,n)=>Ot(e)(t,r,n),Dt=e=>async(t,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return It(e)(t,r,s)},Lt=e=>async(t,r,n)=>It(e)(t,r,n),Ft=/^[cC][^\s-]{8,}$/,qt=/^[0-9a-z]+$/,Ut=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Vt=/^[0-9a-vA-V]{20}$/,Ht=/^[A-Za-z0-9]{27}$/,Kt=/^[a-zA-Z0-9_-]{21}$/,Jt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Bt=/^([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})$/,Gt=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)$/,Wt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,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])$/,Yt=/^(([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}|:))$/,Qt=/^((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])$/,er=/^(([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])$/,tr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,rr=/^[A-Za-z0-9_-]*$/,nr=/^\+[1-9]\d{6,14}$/,sr="(?:(?:\\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])))",ar=new RegExp(`^${sr}$`);function or(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 ir=/^-?\d+$/,cr=/^-?\d+(?:\.\d+)?$/,dr=/^(?:true|false)$/i,ur=/^null$/i,lr=/^[^A-Z]*$/,pr=/^[^a-z]*$/,hr=He("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),fr={number:"number",bigint:"bigint",object:"date"},mr=He("$ZodCheckLessThan",(e,t)=>{hr.init(e,t);const r=fr[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})}}),gr=He("$ZodCheckGreaterThan",(e,t)=>{hr.init(e,t);const r=fr[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})}}),yr=He("$ZodCheckMultipleOf",(e,t)=>{hr.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})}}),_r=He("$ZodCheckNumberFormat",(e,t)=>{hr.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[s,a]=mt[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=ir)}),e._zod.check=o=>{const i=o.value;if(r){if(!Number.isInteger(i))return void o.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:i,inst:e});if(!Number.isSafeInteger(i))return void(i>0?o.issues.push({input:i,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}):o.issues.push({input:i,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}))}i<s&&o.issues.push({origin:"number",input:i,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort}),i>a&&o.issues.push({origin:"number",input:i,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),vr=He("$ZodCheckMaxLength",(e,t)=>{var r;hr.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!Qe(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=wt(n);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),wr=He("$ZodCheckMinLength",(e,t)=>{var r;hr.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!Qe(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=wt(n);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),br=He("$ZodCheckLengthEquals",(e,t)=>{var r;hr.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!Qe(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=wt(n),o=s>t.length;r.issues.push({origin:a,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),kr=He("$ZodCheckStringFormat",(e,t)=>{var r,n;hr.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=()=>{})}),$r=He("$ZodCheckRegex",(e,t)=>{kr.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})}}),Er=He("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=lr),kr.init(e,t)}),Sr=He("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=pr),kr.init(e,t)}),Tr=He("$ZodCheckIncludes",(e,t)=>{hr.init(e,t);const r=pt(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})}}),xr=He("$ZodCheckStartsWith",(e,t)=>{hr.init(e,t);const r=new RegExp(`^${pt(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})}}),Nr=He("$ZodCheckEndsWith",(e,t)=>{hr.init(e,t);const r=new RegExp(`.*${pt(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})}}),Or=He("$ZodCheckOverwrite",(e,t)=>{hr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class Pr{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 Ir={major:4,minor:3,patch:6},Rr=He("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ir;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=gt(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,o=a._zod.check(e);if(o instanceof Promise&&!1===r?.async)throw new Ke;if(n||o instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(s||(s=gt(e,t)))});else{if(e.issues.length===t)continue;s||(s=gt(e,t))}}return n?n.then(()=>e):e},r=(r,s,a)=>{if(gt(r))return r.aborted=!0,r;const o=t(s,n,a);if(o instanceof Promise){if(!1===a.async)throw new Ke;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,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 o=e._zod.parse(s,a);if(o instanceof Promise){if(!1===a.async)throw new Ke;return o.then(e=>t(e,n,a))}return t(o,n,a)}}rt(e,"~standard",()=>({validate:t=>{try{const r=Pt(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return Rt(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),Cr=He("$ZodString",(e,t)=>{var r;Rr.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}}),zr=He("$ZodStringFormat",(e,t)=>{kr.init(e,t),Cr.init(e,t)}),jr=He("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Bt),zr.init(e,t)}),Ar=He("$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=Gt(e))}else t.pattern??(t.pattern=Gt());zr.init(e,t)}),Mr=He("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Wt),zr.init(e,t)}),Zr=He("$ZodURL",(e,t)=>{zr.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})}}}),Dr=He("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),zr.init(e,t)}),Lr=He("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Kt),zr.init(e,t)}),Fr=He("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Ft),zr.init(e,t)}),qr=He("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=qt),zr.init(e,t)}),Ur=He("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ut),zr.init(e,t)}),Vr=He("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Vt),zr.init(e,t)}),Hr=He("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ht),zr.init(e,t)}),Kr=He("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=or({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(`^${sr}T(?:${n})$`)}(t)),zr.init(e,t)}),Jr=He("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ar),zr.init(e,t)}),Br=He("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${or(t)}$`)),zr.init(e,t)}),Gr=He("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Jt),zr.init(e,t)}),Wr=He("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Xt),zr.init(e,t),e._zod.bag.format="ipv4"}),Xr=He("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Yt),zr.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})}}}),Yr=He("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Qt),zr.init(e,t)}),Qr=He("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=er),zr.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 en(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const tn=He("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=tr),zr.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{en(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),rn=He("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=rr),zr.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{(function(e){if(!rr.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return en(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})}}),nn=He("$ZodE164",(e,t)=>{t.pattern??(t.pattern=nr),zr.init(e,t)}),sn=He("$ZodJWT",(e,t)=>{zr.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})}}),an=He("$ZodNumber",(e,t)=>{Rr.init(e,t),e._zod.pattern=e._zod.bag.pattern??cr,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}}),on=He("$ZodNumberFormat",(e,t)=>{_r.init(e,t),an.init(e,t)}),cn=He("$ZodBoolean",(e,t)=>{Rr.init(e,t),e._zod.pattern=dr,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}}),dn=He("$ZodNull",(e,t)=>{Rr.init(e,t),e._zod.pattern=ur,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}}),un=He("$ZodUnknown",(e,t)=>{Rr.init(e,t),e._zod.parse=e=>e}),ln=He("$ZodNever",(e,t)=>{Rr.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function pn(e,t,r){e.issues.length&&t.issues.push(...yt(r,e.issues)),t.value[r]=e.value}const hn=He("$ZodArray",(e,t)=>{Rr.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 o=s[e],i=t.element._zod.run({value:o,issues:[]},n);i instanceof Promise?a.push(i.then(t=>pn(t,r,e))):pn(i,r,e)}return a.length?Promise.all(a).then(()=>r):r}});function fn(e,t,r,n,s){if(e.issues.length){if(s&&!(r in n))return;t.issues.push(...yt(r,e.issues))}void 0===e.value?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function mn(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 gn(e,t,r,n,s,a){const o=[],i=s.keySet,c=s.catchall._zod,d=c.def.type,u="optional"===c.optout;for(const s in t){if(i.has(s))continue;if("never"===d){o.push(s);continue}const a=c.run({value:t[s],issues:[]},n);a instanceof Promise?e.push(a.then(e=>fn(e,r,s,t,u))):fn(a,r,s,t,u)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>r):r}const yn=He("$ZodObject",(e,t)=>{Rr.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=Ye(()=>mn(t));rt(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=it,a=t.catchall;let o;e._zod.parse=(t,r)=>{o??(o=n.value);const i=t.value;if(!s(i))return t.issues.push({expected:"object",code:"invalid_type",input:i,inst:e}),t;t.value={};const c=[],d=o.shape;for(const e of o.keys){const n=d[e],s="optional"===n._zod.optout,a=n._zod.run({value:i[e],issues:[]},r);a instanceof Promise?c.push(a.then(r=>fn(r,t,e,i,s))):fn(a,t,e,i,s)}return a?gn(c,i,t,r,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),_n=He("$ZodObjectJIT",(e,t)=>{yn.init(e,t);const r=e._zod.parse,n=Ye(()=>mn(t));let s;const a=it,o=!Be.jitless,i=o&&ct.value,c=t.catchall;let d;e._zod.parse=(u,l)=>{d??(d=n.value);const p=u.value;return a(p)?o&&i&&!1===l?.async&&!0!==l.jitless?(s||(s=(e=>{const t=new Pr(["shape","payload","ctx"]),r=n.value,s=e=>{const t=at(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const a=Object.create(null);let o=0;for(const e of r.keys)a[e]="key_"+o++;t.write("const newResult = {};");for(const n of r.keys){const r=a[n],o=at(n),i=e[n],c="optional"===i?._zod?.optout;t.write(`const ${r} = ${s(n)};`),c?t.write(`\n if (${r}.issues.length) {\n if (${o} in input) {\n payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${o}, ...iss.path] : [${o}]\n })));\n }\n }\n \n if (${r}.value === undefined) {\n if (${o} in input) {\n newResult[${o}] = undefined;\n }\n } else {\n newResult[${o}] = ${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 ? [${o}, ...iss.path] : [${o}]\n })));\n }\n \n if (${r}.value === undefined) {\n if (${o} in input) {\n newResult[${o}] = undefined;\n }\n } else {\n newResult[${o}] = ${r}.value;\n }\n \n `)}t.write("payload.value = newResult;"),t.write("return payload;");const i=t.compile();return(t,r)=>i(e,t,r)})(t.shape)),u=s(u,l),c?gn([],p,u,l,d,e):u):r(u,l):(u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u)}});function vn(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=>!gt(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=>vt(e,n,Ge())))}),t)}const wn=He("$ZodUnion",(e,t)=>{Rr.init(e,t),rt(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),rt(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),rt(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),rt(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=>et(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 o=!1;const i=[];for(const e of t.options){const t=e._zod.run({value:s.value,issues:[]},a);if(t instanceof Promise)i.push(t),o=!0;else{if(0===t.issues.length)return t;i.push(t)}}return o?Promise.all(i).then(t=>vn(t,s,e,a)):vn(i,s,e,a)}}),bn=He("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,wn.init(e,t);const r=e._zod.parse;rt(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=Ye(()=>{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 o=s.value;if(!it(o))return s.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),s;const i=n.value.get(o?.[t.discriminator]);return i?i._zod.run(s,a):t.unionFallback?r(s,a):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),s)}}),kn=He("$ZodIntersection",(e,t)=>{Rr.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])=>En(e,t,r)):En(e,s,a)}});function $n(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(dt(e)&&dt(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=$n(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=$n(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 En(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}),gt(e))return e;const o=$n(t.value,r.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const Sn=He("$ZodRecord",(e,t)=>{Rr.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!dt(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),r;const a=[],o=t.keyType._zod.values;if(o){r.value={};const i=new Set;for(const e of o)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){i.add("number"==typeof e?e.toString():e);const o=t.valueType._zod.run({value:s[e],issues:[]},n);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&r.issues.push(...yt(e,t.issues)),r.value[e]=t.value})):(o.issues.length&&r.issues.push(...yt(e,o.issues)),r.value[e]=o.value)}let c;for(const e in s)i.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 o of Reflect.ownKeys(s)){if("__proto__"===o)continue;let i=t.keyType._zod.run({value:o,issues:[]},n);if(i instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof o&&cr.test(o)&&i.issues.length){const e=t.keyType._zod.run({value:Number(o),issues:[]},n);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(i=e)}if(i.issues.length){"loose"===t.mode?r.value[o]=s[o]:r.issues.push({code:"invalid_key",origin:"record",issues:i.issues.map(e=>vt(e,n,Ge())),input:o,path:[o],inst:e});continue}const c=t.valueType._zod.run({value:s[o],issues:[]},n);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&r.issues.push(...yt(o,e.issues)),r.value[i.value]=e.value})):(c.issues.length&&r.issues.push(...yt(o,c.issues)),r.value[i.value]=c.value)}}return a.length?Promise.all(a).then(()=>r):r}}),Tn=He("$ZodEnum",(e,t)=>{Rr.init(e,t);const r=We(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(e=>lt.has(typeof e)).map(e=>"string"==typeof e?pt(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}}),xn=He("$ZodLiteral",(e,t)=>{if(Rr.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?pt(e):e?pt(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}}),Nn=He("$ZodTransform",(e,t)=>{Rr.init(e,t),e._zod.parse=(r,n)=>{if("backward"===n.direction)throw new Je(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 Ke;return r.value=s,r}});function On(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const Pn=He("$ZodOptional",(e,t)=>{Rr.init(e,t),e._zod.optin="optional",e._zod.optout="optional",rt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),rt(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${et(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=>On(t,e.value)):On(n,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,r)}}),In=He("$ZodExactOptional",(e,t)=>{Pn.init(e,t),rt(e._zod,"values",()=>t.innerType._zod.values),rt(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),Rn=He("$ZodNullable",(e,t)=>{Rr.init(e,t),rt(e._zod,"optin",()=>t.innerType._zod.optin),rt(e._zod,"optout",()=>t.innerType._zod.optout),rt(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${et(e.source)}|null)$`):void 0}),rt(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)}),Cn=He("$ZodDefault",(e,t)=>{Rr.init(e,t),e._zod.optin="optional",rt(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=>zn(e,t)):zn(n,t)}});function zn(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const jn=He("$ZodPrefault",(e,t)=>{Rr.init(e,t),e._zod.optin="optional",rt(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))}),An=He("$ZodNonOptional",(e,t)=>{Rr.init(e,t),rt(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=>Mn(t,e)):Mn(s,e)}});function Mn(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 Zn=He("$ZodCatch",(e,t)=>{Rr.init(e,t),rt(e._zod,"optin",()=>t.innerType._zod.optin),rt(e._zod,"optout",()=>t.innerType._zod.optout),rt(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=>vt(e,r,Ge()))},input:e.value}),e.issues=[]),e)):(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>vt(e,r,Ge()))},input:e.value}),e.issues=[]),e)}}),Dn=He("$ZodPipe",(e,t)=>{Rr.init(e,t),rt(e._zod,"values",()=>t.in._zod.values),rt(e._zod,"optin",()=>t.in._zod.optin),rt(e._zod,"optout",()=>t.out._zod.optout),rt(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=>Ln(e,t.in,r)):Ln(n,t.in,r)}const n=t.in._zod.run(e,r);return n instanceof Promise?n.then(e=>Ln(e,t.out,r)):Ln(n,t.out,r)}});function Ln(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const Fn=He("$ZodReadonly",(e,t)=>{Rr.init(e,t),rt(e._zod,"propValues",()=>t.innerType._zod.propValues),rt(e._zod,"values",()=>t.innerType._zod.values),rt(e._zod,"optin",()=>t.innerType?._zod?.optin),rt(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(qn):qn(n)}});function qn(e){return e.value=Object.freeze(e.value),e}const Un=He("$ZodCustom",(e,t)=>{hr.init(e,t),Rr.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=>Vn(t,r,n,e));Vn(s,r,n,e)}});function Vn(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(bt(e))}}var Hn;(Hn=globalThis).__zod_globalRegistry??(Hn.__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 Kn=globalThis.__zod_globalRegistry;function Jn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ft(t)})}function Bn(e,t){return new mr({check:"less_than",...ft(t),value:e,inclusive:!1})}function Gn(e,t){return new mr({check:"less_than",...ft(t),value:e,inclusive:!0})}function Wn(e,t){return new gr({check:"greater_than",...ft(t),value:e,inclusive:!1})}function Xn(e,t){return new gr({check:"greater_than",...ft(t),value:e,inclusive:!0})}function Yn(e,t){return new yr({check:"multiple_of",...ft(t),value:e})}function Qn(e,t){return new vr({check:"max_length",...ft(t),maximum:e})}function es(e,t){return new wr({check:"min_length",...ft(t),minimum:e})}function ts(e,t){return new br({check:"length_equals",...ft(t),length:e})}function rs(e){return new Or({check:"overwrite",tx:e})}function ns(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??Kn,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 ss(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 o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o);const i=e._zod.toJSONSchema?.();if(i)o.schema=i;else{const n={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,n);else{const r=o.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&&(o.ref||(o.ref=a),ss(a,t,n),t.seen.get(a).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),"input"===t.io&&is(e)&&(delete o.schema.examples,delete o.schema.default),"input"===t.io&&o.schema._prefault&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function as(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 o=n.schema;for(const e in o)delete o[e];o.$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 os(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},o=r.ref;if(r.ref=null,o){n(o);const r=e.seen.get(o),i=r.schema;if(!i.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(s,i):(s.allOf=s.allOf??[],s.allOf.push(i)),Object.assign(s,a),t._zod.parent===o)for(const e in s)"$ref"!==e&&"allOf"!==e&&(e in a||delete s[e]);if(i.$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 i=t._zod.parent;if(i&&i!==o){n(i);const t=e.seen.get(i);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:cs(t,"input",e.processors),output:cs(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch(e){throw new Error("Error converting schema to JSON.")}}function is(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 is(n.element,r);if("set"===n.type)return is(n.valueType,r);if("lazy"===n.type)return is(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 is(n.innerType,r);if("intersection"===n.type)return is(n.left,r)||is(n.right,r);if("record"===n.type||"map"===n.type)return is(n.keyType,r)||is(n.valueType,r);if("pipe"===n.type)return is(n.in,r)||is(n.out,r);if("object"===n.type){for(const e in n.shape)if(is(n.shape[e],r))return!0;return!1}if("union"===n.type){for(const e of n.options)if(is(e,r))return!0;return!1}if("tuple"===n.type){for(const e of n.items)if(is(e,r))return!0;return!(!n.rest||!is(n.rest,r))}return!1}const cs=(e,t,r={})=>n=>{const{libraryOptions:s,target:a}=n??{},o=ns({...s??{},target:a,io:t,processors:r});return ss(e,o),as(o,e),os(o,e)},ds={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},us=(e,t,r,n)=>{const s=r;s.type="string";const{minimum:a,maximum:o,format:i,patterns:c,contentEncoding:d}=e._zod.bag;if("number"==typeof a&&(s.minLength=a),"number"==typeof o&&(s.maxLength=o),i&&(s.format=ds[i]??i,""===s.format&&delete s.format,"time"===i&&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}))])}},ls=(e,t,r,n)=>{const s=r,{minimum:a,maximum:o,format:i,multipleOf:c,exclusiveMaximum:d,exclusiveMinimum:u}=e._zod.bag;"string"==typeof i&&i.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 o&&(s.maximum=o,"number"==typeof d&&"draft-04"!==t.target&&(d<=o?delete s.maximum:delete s.exclusiveMaximum)),"number"==typeof c&&(s.multipleOf=c)},ps=(e,t,r,n)=>{r.type="boolean"},hs=(e,t,r,n)=>{"openapi-3.0"===t.target?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},fs=(e,t,r,n)=>{r.not={}},ms=(e,t,r,n)=>{const s=We(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},gs=(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},ys=(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")},_s=(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")},vs=(e,t,r,n)=>{const s=r,a=e._zod.def,{minimum:o,maximum:i}=e._zod.bag;"number"==typeof o&&(s.minItems=o),"number"==typeof i&&(s.maxItems=i),s.type="array",s.items=ss(a.element,t,{...n,path:[...n.path,"items"]})},ws=(e,t,r,n)=>{const s=r,a=e._zod.def;s.type="object",s.properties={};const o=a.shape;for(const e in o)s.properties[e]=ss(o[e],t,{...n,path:[...n.path,"properties",e]});const i=new Set(Object.keys(o)),c=new Set([...i].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=ss(a.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):"output"===t.io&&(s.additionalProperties=!1)},bs=(e,t,r,n)=>{const s=e._zod.def,a=!1===s.inclusive,o=s.options.map((e,r)=>ss(e,t,{...n,path:[...n.path,a?"oneOf":"anyOf",r]}));a?r.oneOf=o:r.anyOf=o},ks=(e,t,r,n)=>{const s=e._zod.def,a=ss(s.left,t,{...n,path:[...n.path,"allOf",0]}),o=ss(s.right,t,{...n,path:[...n.path,"allOf",1]}),i=e=>"allOf"in e&&1===Object.keys(e).length,c=[...i(a)?a.allOf:[a],...i(o)?o.allOf:[o]];r.allOf=c},$s=(e,t,r,n)=>{const s=r,a=e._zod.def;s.type="object";const o=a.keyType,i=o._zod.bag,c=i?.patterns;if("loose"===a.mode&&c&&c.size>0){const e=ss(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=ss(a.keyType,t,{...n,path:[...n.path,"propertyNames"]})),s.additionalProperties=ss(a.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const d=o._zod.values;if(d){const e=[...d].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(s.required=e)}},Es=(e,t,r,n)=>{const s=e._zod.def,a=ss(s.innerType,t,n),o=t.seen.get(e);"openapi-3.0"===t.target?(o.ref=s.innerType,r.nullable=!0):r.anyOf=[a,{type:"null"}]},Ss=(e,t,r,n)=>{const s=e._zod.def;ss(s.innerType,t,n),t.seen.get(e).ref=s.innerType},Ts=(e,t,r,n)=>{const s=e._zod.def;ss(s.innerType,t,n),t.seen.get(e).ref=s.innerType,r.default=JSON.parse(JSON.stringify(s.defaultValue))},xs=(e,t,r,n)=>{const s=e._zod.def;ss(s.innerType,t,n),t.seen.get(e).ref=s.innerType,"input"===t.io&&(r._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},Ns=(e,t,r,n)=>{const s=e._zod.def;let a;ss(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},Os=(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;ss(a,t,n),t.seen.get(e).ref=a},Ps=(e,t,r,n)=>{const s=e._zod.def;ss(s.innerType,t,n),t.seen.get(e).ref=s.innerType,r.readOnly=!0},Is=(e,t,r,n)=>{const s=e._zod.def;ss(s.innerType,t,n),t.seen.get(e).ref=s.innerType},Rs={string:us,number:ls,boolean:ps,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:hs,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:fs,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:ms,literal:gs,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:o,maximum:i,mime:c}=e._zod.bag;void 0!==o&&(a.minLength=o),void 0!==i&&(a.maxLength=i),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:ys,function:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Function types cannot be represented in JSON Schema")},transform:_s,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:vs,object:ws,union:bs,intersection:ks,tuple:(e,t,r,n)=>{const s=r,a=e._zod.def;s.type="array";const o="draft-2020-12"===t.target?"prefixItems":"items",i="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",c=a.items.map((e,r)=>ss(e,t,{...n,path:[...n.path,o,r]})),d=a.rest?ss(a.rest,t,{...n,path:[...n.path,i,..."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:$s,nullable:Es,nonoptional:Ss,default:Ts,prefault:xs,catch:Ns,pipe:Os,readonly:Ps,promise:(e,t,r,n)=>{const s=e._zod.def;ss(s.innerType,t,n),t.seen.get(e).ref=s.innerType},optional:Is,lazy:(e,t,r,n)=>{const s=e._zod.innerType;ss(s,t,n),t.seen.get(e).ref=s}},Cs=He("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");Rr.init(e,t),e.def=t,e.type=t.type,e.parse=(t,r)=>Tt(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>Pt(e,t,r),e.parseAsync=async(t,r)=>Nt(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>Rt(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)=>ht(e,t,r),e.brand=()=>e,e.register=(t,r)=>(t.add(e,r),e),e.apply=t=>t(e)}),zs=He("ZodMiniObject",(e,t)=>{yn.init(e,t),Cs.init(e,t),rt(e,"shape",()=>t.shape)});function js(e,t){const r={type:"object",shape:e??{},...ft(t)};return new zs(r)}function As(e){return!!e._zod}function Ms(e){const t=Object.values(e);if(0===t.length)return js({});const r=t.every(As),n=t.every(e=>!As(e));if(r)return js(e);if(n)return Ve(e);throw new Error("Mixed Zod versions detected in object shape.")}function Zs(e,t){return As(e)?Pt(e,t):e.safeParse(t)}async function Ds(e,t){if(As(e))return await Rt(e,t);const r=e;return await r.safeParseAsync(t)}function Ls(e){if(!e)return;let t;if(As(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 Fs(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 Ms(e)}}if(As(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 qs(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 Us(e){if(As(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 Vs=He("ZodISODateTime",(e,t)=>{Kr.init(e,t),pa.init(e,t)});function Hs(e){return function(e,t){return new Vs({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ft(t)})}(0,e)}const Ks=He("ZodISODate",(e,t)=>{Jr.init(e,t),pa.init(e,t)});const Js=He("ZodISOTime",(e,t)=>{Br.init(e,t),pa.init(e,t)});const Bs=He("ZodISODuration",(e,t)=>{Gr.init(e,t),pa.init(e,t)});const Gs=He("ZodError",(e,t)=>{$t.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,Xe,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Xe,2)}},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),Ws=St(Gs),Xs=xt(Gs),Ys=Ot(Gs),Qs=It(Gs),ea=Ct(Gs),ta=zt(Gs),ra=jt(Gs),na=At(Gs),sa=Mt(Gs),aa=Zt(Gs),oa=Dt(Gs),ia=Lt(Gs),ca=He("ZodType",(e,t)=>(Rr.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:cs(e,"input"),output:cs(e,"output")}}),e.toJSONSchema=((e,t={})=>r=>{const n=ns({...r,processors:t});return ss(e,n),as(n,e),os(n,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(st(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)=>ht(e,t,r),e.brand=()=>e,e.register=(t,r)=>(t.add(e,r),e),e.parse=(t,r)=>Ws(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>Ys(e,t,r),e.parseAsync=async(t,r)=>Xs(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>Qs(e,t,r),e.spa=e.safeParseAsync,e.encode=(t,r)=>ea(e,t,r),e.decode=(t,r)=>ta(e,t,r),e.encodeAsync=async(t,r)=>ra(e,t,r),e.decodeAsync=async(t,r)=>na(e,t,r),e.safeEncode=(t,r)=>sa(e,t,r),e.safeDecode=(t,r)=>aa(e,t,r),e.safeEncodeAsync=async(t,r)=>oa(e,t,r),e.safeDecodeAsync=async(t,r)=>ia(e,t,r),e.refine=(t,r)=>e.check(function(e,t={}){return function(e,t,r){return new bo({type:"custom",check:"custom",fn:t,...ft(r)})}(0,e,t)}(t,r)),e.superRefine=t=>e.check(function(e){const t=function(e){const t=new hr({check:"custom",...ft(void 0)});return t._zod.check=e,t}(r=>(r.addIssue=e=>{if("string"==typeof e)r.issues.push(bt(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(bt(n))}},e(r.value,r)));return t}(t)),e.overwrite=t=>e.check(rs(t)),e.optional=()=>uo(e),e.exactOptional=()=>new lo({type:"optional",innerType:e}),e.nullable=()=>ho(e),e.nullish=()=>uo(ho(e)),e.nonoptional=t=>function(e,t){return new go({type:"nonoptional",innerType:e,...ft(t)})}(e,t),e.array=()=>Va(e),e.or=t=>Ga([e,t]),e.and=t=>Qa(e,t),e.transform=t=>vo(e,io(t)),e.default=t=>{return r=t,new fo({type:"default",innerType:e,get defaultValue(){return"function"==typeof r?r():ut(r)}});var r},e.prefault=t=>{return r=t,new mo({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof r?r():ut(r)}});var r},e.catch=t=>{return new yo({type:"catch",innerType:e,catchValue:"function"==typeof(r=t)?r:()=>r});var r},e.pipe=t=>vo(e,t),e.readonly=()=>new wo({type:"readonly",innerType:e}),e.describe=t=>{const r=e.clone();return Kn.add(r,{description:t}),r},Object.defineProperty(e,"description",{get:()=>Kn.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return Kn.get(e);const r=e.clone();return Kn.add(r,t[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),da=He("_ZodString",(e,t)=>{Cr.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>us(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 $r({check:"string_format",format:"regex",...ft(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new Tr({check:"string_format",format:"includes",...ft(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new xr({check:"string_format",format:"starts_with",...ft(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Nr({check:"string_format",format:"ends_with",...ft(t),suffix:e})}(...t)),e.min=(...t)=>e.check(es(...t)),e.max=(...t)=>e.check(Qn(...t)),e.length=(...t)=>e.check(ts(...t)),e.nonempty=(...t)=>e.check(es(1,...t)),e.lowercase=t=>e.check(function(e){return new Er({check:"string_format",format:"lowercase",...ft(e)})}(t)),e.uppercase=t=>e.check(function(e){return new Sr({check:"string_format",format:"uppercase",...ft(e)})}(t)),e.trim=()=>e.check(rs(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return rs(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(rs(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(rs(e=>e.toUpperCase())),e.slugify=()=>e.check(rs(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}),ua=He("ZodString",(e,t)=>{Cr.init(e,t),da.init(e,t),e.email=t=>e.check(function(e,t){return new ha({type:"string",format:"email",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.url=t=>e.check(function(e,t){return new ga({type:"string",format:"url",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.jwt=t=>e.check(function(e,t){return new Ia({type:"string",format:"jwt",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.emoji=t=>e.check(function(e,t){return new ya({type:"string",format:"emoji",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.guid=t=>e.check(Jn(fa,t)),e.uuid=t=>e.check(function(e,t){return new ma({type:"string",format:"uuid",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.uuidv4=t=>e.check(function(e,t){return new ma({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ft(t)})}(0,t)),e.uuidv6=t=>e.check(function(e,t){return new ma({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ft(t)})}(0,t)),e.uuidv7=t=>e.check(function(e,t){return new ma({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ft(t)})}(0,t)),e.nanoid=t=>e.check(function(e,t){return new _a({type:"string",format:"nanoid",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.guid=t=>e.check(Jn(fa,t)),e.cuid=t=>e.check(function(e,t){return new va({type:"string",format:"cuid",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.cuid2=t=>e.check(function(e,t){return new wa({type:"string",format:"cuid2",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.ulid=t=>e.check(function(e,t){return new ba({type:"string",format:"ulid",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.base64=t=>e.check(function(e,t){return new Na({type:"string",format:"base64",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.base64url=t=>e.check(function(e,t){return new Oa({type:"string",format:"base64url",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.xid=t=>e.check(function(e,t){return new ka({type:"string",format:"xid",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.ksuid=t=>e.check(function(e,t){return new $a({type:"string",format:"ksuid",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.ipv4=t=>e.check(function(e,t){return new Ea({type:"string",format:"ipv4",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.ipv6=t=>e.check(function(e,t){return new Sa({type:"string",format:"ipv6",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.cidrv4=t=>e.check(function(e,t){return new Ta({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.cidrv6=t=>e.check(function(e,t){return new xa({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.e164=t=>e.check(function(e,t){return new Pa({type:"string",format:"e164",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.datetime=t=>e.check(Hs(t)),e.date=t=>e.check(function(e){return function(e,t){return new Ks({type:"string",format:"date",check:"string_format",...ft(t)})}(0,e)}(t)),e.time=t=>e.check(function(e){return function(e,t){return new Js({type:"string",format:"time",check:"string_format",precision:null,...ft(t)})}(0,e)}(t)),e.duration=t=>e.check(function(e){return function(e,t){return new Bs({type:"string",format:"duration",check:"string_format",...ft(t)})}(0,e)}(t))});function la(e){return function(e,t){return new ua({type:"string",...ft(t)})}(0,e)}const pa=He("ZodStringFormat",(e,t)=>{zr.init(e,t),da.init(e,t)}),ha=He("ZodEmail",(e,t)=>{Mr.init(e,t),pa.init(e,t)}),fa=He("ZodGUID",(e,t)=>{jr.init(e,t),pa.init(e,t)}),ma=He("ZodUUID",(e,t)=>{Ar.init(e,t),pa.init(e,t)}),ga=He("ZodURL",(e,t)=>{Zr.init(e,t),pa.init(e,t)}),ya=He("ZodEmoji",(e,t)=>{Dr.init(e,t),pa.init(e,t)}),_a=He("ZodNanoID",(e,t)=>{Lr.init(e,t),pa.init(e,t)}),va=He("ZodCUID",(e,t)=>{Fr.init(e,t),pa.init(e,t)}),wa=He("ZodCUID2",(e,t)=>{qr.init(e,t),pa.init(e,t)}),ba=He("ZodULID",(e,t)=>{Ur.init(e,t),pa.init(e,t)}),ka=He("ZodXID",(e,t)=>{Vr.init(e,t),pa.init(e,t)}),$a=He("ZodKSUID",(e,t)=>{Hr.init(e,t),pa.init(e,t)}),Ea=He("ZodIPv4",(e,t)=>{Wr.init(e,t),pa.init(e,t)}),Sa=He("ZodIPv6",(e,t)=>{Xr.init(e,t),pa.init(e,t)}),Ta=He("ZodCIDRv4",(e,t)=>{Yr.init(e,t),pa.init(e,t)}),xa=He("ZodCIDRv6",(e,t)=>{Qr.init(e,t),pa.init(e,t)}),Na=He("ZodBase64",(e,t)=>{tn.init(e,t),pa.init(e,t)}),Oa=He("ZodBase64URL",(e,t)=>{rn.init(e,t),pa.init(e,t)}),Pa=He("ZodE164",(e,t)=>{nn.init(e,t),pa.init(e,t)}),Ia=He("ZodJWT",(e,t)=>{sn.init(e,t),pa.init(e,t)}),Ra=He("ZodNumber",(e,t)=>{an.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ls(e,t,r),e.gt=(t,r)=>e.check(Wn(t,r)),e.gte=(t,r)=>e.check(Xn(t,r)),e.min=(t,r)=>e.check(Xn(t,r)),e.lt=(t,r)=>e.check(Bn(t,r)),e.lte=(t,r)=>e.check(Gn(t,r)),e.max=(t,r)=>e.check(Gn(t,r)),e.int=t=>e.check(ja(t)),e.safe=t=>e.check(ja(t)),e.positive=t=>e.check(Wn(0,t)),e.nonnegative=t=>e.check(Xn(0,t)),e.negative=t=>e.check(Bn(0,t)),e.nonpositive=t=>e.check(Gn(0,t)),e.multipleOf=(t,r)=>e.check(Yn(t,r)),e.step=(t,r)=>e.check(Yn(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 Ca(e){return function(e,t){return new Ra({type:"number",checks:[],...ft(t)})}(0,e)}const za=He("ZodNumberFormat",(e,t)=>{on.init(e,t),Ra.init(e,t)});function ja(e){return function(e,t){return new za({type:"number",check:"number_format",abort:!1,format:"safeint",...ft(t)})}(0,e)}const Aa=He("ZodBoolean",(e,t)=>{cn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(e,t,r)=>ps(0,0,t)});function Ma(e){return function(e,t){return new Aa({type:"boolean",...ft(t)})}(0,e)}const Za=He("ZodNull",(e,t)=>{dn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(e,t,r)=>hs(0,e,t)});function Da(e){return function(e,t){return new Za({type:"null",...ft(t)})}(0,e)}const La=He("ZodUnknown",(e,t)=>{un.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(e,t,r)=>{}});function Fa(){return new La({type:"unknown"})}const qa=He("ZodNever",(e,t)=>{ln.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(e,t,r)=>fs(0,0,t)});const Ua=He("ZodArray",(e,t)=>{hn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>vs(e,t,r,n),e.element=t.element,e.min=(t,r)=>e.check(es(t,r)),e.nonempty=t=>e.check(es(1,t)),e.max=(t,r)=>e.check(Qn(t,r)),e.length=(t,r)=>e.check(ts(t,r)),e.unwrap=()=>e.element});function Va(e,t){return function(e,t,r){return new Ua({type:"array",element:t,...ft(r)})}(0,e,t)}const Ha=He("ZodObject",(e,t)=>{_n.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ws(e,t,r,n),rt(e,"shape",()=>t.shape),e.keyof=()=>no(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Fa()}),e.loose=()=>e.clone({...e._zod.def,catchall:Fa()}),e.strict=()=>{return e.clone({...e._zod.def,catchall:function(e,t){return new qa({type:"never",...ft(t)})}(0,t)});var t},e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!dt(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=st(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return nt(this,"shape",r),r}});return ht(e,n)}(e,t),e.safeExtend=t=>function(e,t){if(!dt(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=st(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return nt(this,"shape",r),r}});return ht(e,r)}(e,t),e.merge=t=>function(e,t){const r=st(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return nt(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return ht(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 ht(e,st(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 nt(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=st(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 nt(this,"shape",n),n},checks:[]});return ht(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=st(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 nt(this,"shape",s),s},checks:[]});return ht(t,s)}(co,e,t[0]),e.required=(...t)=>function(e,t,r){const n=st(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 nt(this,"shape",s),s}});return ht(t,n)}(go,e,t[0])});function Ka(e,t){const r={type:"object",shape:e??{},...ft(t)};return new Ha(r)}function Ja(e,t){return new Ha({type:"object",shape:e,catchall:Fa(),...ft(t)})}const Ba=He("ZodUnion",(e,t)=>{wn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>bs(e,t,r,n),e.options=t.options});function Ga(e,t){return new Ba({type:"union",options:e,...ft(t)})}const Wa=He("ZodDiscriminatedUnion",(e,t)=>{Ba.init(e,t),bn.init(e,t)});function Xa(e,t,r){return new Wa({type:"union",options:t,discriminator:e,...ft(r)})}const Ya=He("ZodIntersection",(e,t)=>{kn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ks(e,t,r,n)});function Qa(e,t){return new Ya({type:"intersection",left:e,right:t})}const eo=He("ZodRecord",(e,t)=>{Sn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>$s(e,t,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function to(e,t,r){return new eo({type:"record",keyType:e,valueType:t,...ft(r)})}const ro=He("ZodEnum",(e,t)=>{Tn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ms(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 ro({...t,checks:[],...ft(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 ro({...t,checks:[],...ft(n),entries:s})}});function no(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new ro({type:"enum",entries:r,...ft(t)})}const so=He("ZodLiteral",(e,t)=>{xn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>gs(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 ao(e,t){return new so({type:"literal",values:Array.isArray(e)?e:[e],...ft(t)})}const oo=He("ZodTransform",(e,t)=>{Nn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(e,t,r)=>_s(0,e),e._zod.parse=(r,n)=>{if("backward"===n.direction)throw new Je(e.constructor.name);r.addIssue=n=>{if("string"==typeof n)r.issues.push(bt(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(bt(t))}};const s=t.transform(r.value,r);return s instanceof Promise?s.then(e=>(r.value=e,r)):(r.value=s,r)}});function io(e){return new oo({type:"transform",transform:e})}const co=He("ZodOptional",(e,t)=>{Pn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Is(e,t,0,n),e.unwrap=()=>e._zod.def.innerType});function uo(e){return new co({type:"optional",innerType:e})}const lo=He("ZodExactOptional",(e,t)=>{In.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Is(e,t,0,n),e.unwrap=()=>e._zod.def.innerType}),po=He("ZodNullable",(e,t)=>{Rn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Es(e,t,r,n),e.unwrap=()=>e._zod.def.innerType});function ho(e){return new po({type:"nullable",innerType:e})}const fo=He("ZodDefault",(e,t)=>{Cn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Ts(e,t,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),mo=He("ZodPrefault",(e,t)=>{jn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>xs(e,t,r,n),e.unwrap=()=>e._zod.def.innerType}),go=He("ZodNonOptional",(e,t)=>{An.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Ss(e,t,0,n),e.unwrap=()=>e._zod.def.innerType}),yo=He("ZodCatch",(e,t)=>{Zn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Ns(e,t,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),_o=He("ZodPipe",(e,t)=>{Dn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Os(e,t,0,n),e.in=t.in,e.out=t.out});function vo(e,t){return new _o({type:"pipe",in:e,out:t})}const wo=He("ZodReadonly",(e,t)=>{Fn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Ps(e,t,r,n),e.unwrap=()=>e._zod.def.innerType}),bo=He("ZodCustom",(e,t)=>{Un.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(e,t,r)=>ys(0,e)});function ko(e,t){return vo(io(e),t)}const $o="2025-11-25",Eo=[$o,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],So="io.modelcontextprotocol/related-task",To="2.0",xo=function(e,t,r){const n=ft(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})}(bo,0,void 0);const No=Ga([la(),Ca().int()]),Oo=la();Ja({ttl:Ga([Ca(),Da()]).optional(),pollInterval:Ca().optional()});const Po=Ka({ttl:Ca().optional()}),Io=Ka({taskId:la()}),Ro=Ja({progressToken:No.optional(),[So]:Io.optional()}),Co=Ka({_meta:Ro.optional()}),zo=Co.extend({task:Po.optional()}),jo=Ka({method:la(),params:Co.loose().optional()}),Ao=Ka({_meta:Ro.optional()}),Mo=Ka({method:la(),params:Ao.loose().optional()}),Zo=Ja({_meta:Ro.optional()}),Do=Ga([la(),Ca().int()]),Lo=Ka({jsonrpc:ao(To),id:Do,...jo.shape}).strict(),Fo=e=>Lo.safeParse(e).success,qo=Ka({jsonrpc:ao(To),...Mo.shape}).strict(),Uo=Ka({jsonrpc:ao(To),id:Do,result:Zo}).strict(),Vo=e=>Uo.safeParse(e).success;var Ho;!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"}(Ho||(Ho={}));const Ko=Ka({jsonrpc:ao(To),id:Do.optional(),error:Ka({code:Ca().int(),message:la(),data:Fa().optional()})}).strict(),Jo=Ga([Lo,qo,Uo,Ko]);Ga([Uo,Ko]);const Bo=Zo.strict(),Go=Ao.extend({requestId:Do.optional(),reason:la().optional()}),Wo=Mo.extend({method:ao("notifications/cancelled"),params:Go}),Xo=Ka({src:la(),mimeType:la().optional(),sizes:Va(la()).optional(),theme:no(["light","dark"]).optional()}),Yo=Ka({icons:Va(Xo).optional()}),Qo=Ka({name:la(),title:la().optional()}),ei=Qo.extend({...Qo.shape,...Yo.shape,version:la(),websiteUrl:la().optional(),description:la().optional()}),ti=Qa(Ka({applyDefaults:Ma().optional()}),to(la(),Fa())),ri=ko(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,Qa(Ka({form:ti.optional(),url:xo.optional()}),to(la(),Fa()).optional())),ni=Ja({list:xo.optional(),cancel:xo.optional(),requests:Ja({sampling:Ja({createMessage:xo.optional()}).optional(),elicitation:Ja({create:xo.optional()}).optional()}).optional()}),si=Ja({list:xo.optional(),cancel:xo.optional(),requests:Ja({tools:Ja({call:xo.optional()}).optional()}).optional()}),ai=Ka({experimental:to(la(),xo).optional(),sampling:Ka({context:xo.optional(),tools:xo.optional()}).optional(),elicitation:ri.optional(),roots:Ka({listChanged:Ma().optional()}).optional(),tasks:ni.optional()}),oi=Co.extend({protocolVersion:la(),capabilities:ai,clientInfo:ei}),ii=jo.extend({method:ao("initialize"),params:oi}),ci=Ka({experimental:to(la(),xo).optional(),logging:xo.optional(),completions:xo.optional(),prompts:Ka({listChanged:Ma().optional()}).optional(),resources:Ka({subscribe:Ma().optional(),listChanged:Ma().optional()}).optional(),tools:Ka({listChanged:Ma().optional()}).optional(),tasks:si.optional()}),di=Zo.extend({protocolVersion:la(),capabilities:ci,serverInfo:ei,instructions:la().optional()}),ui=Mo.extend({method:ao("notifications/initialized"),params:Ao.optional()}),li=jo.extend({method:ao("ping"),params:Co.optional()}),pi=Ka({progress:Ca(),total:uo(Ca()),message:uo(la())}),hi=Ka({...Ao.shape,...pi.shape,progressToken:No}),fi=Mo.extend({method:ao("notifications/progress"),params:hi}),mi=Co.extend({cursor:Oo.optional()}),gi=jo.extend({params:mi.optional()}),yi=Zo.extend({nextCursor:Oo.optional()}),_i=no(["working","input_required","completed","failed","cancelled"]),vi=Ka({taskId:la(),status:_i,ttl:Ga([Ca(),Da()]),createdAt:la(),lastUpdatedAt:la(),pollInterval:uo(Ca()),statusMessage:uo(la())}),wi=Zo.extend({task:vi}),bi=Ao.merge(vi),ki=Mo.extend({method:ao("notifications/tasks/status"),params:bi}),$i=jo.extend({method:ao("tasks/get"),params:Co.extend({taskId:la()})}),Ei=Zo.merge(vi),Si=jo.extend({method:ao("tasks/result"),params:Co.extend({taskId:la()})});Zo.loose();const Ti=gi.extend({method:ao("tasks/list")}),xi=yi.extend({tasks:Va(vi)}),Ni=jo.extend({method:ao("tasks/cancel"),params:Co.extend({taskId:la()})}),Oi=Zo.merge(vi),Pi=Ka({uri:la(),mimeType:uo(la()),_meta:to(la(),Fa()).optional()}),Ii=Pi.extend({text:la()}),Ri=la().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Ci=Pi.extend({blob:Ri}),zi=no(["user","assistant"]),ji=Ka({audience:Va(zi).optional(),priority:Ca().min(0).max(1).optional(),lastModified:Hs({offset:!0}).optional()}),Ai=Ka({...Qo.shape,...Yo.shape,uri:la(),description:uo(la()),mimeType:uo(la()),annotations:ji.optional(),_meta:uo(Ja({}))}),Mi=Ka({...Qo.shape,...Yo.shape,uriTemplate:la(),description:uo(la()),mimeType:uo(la()),annotations:ji.optional(),_meta:uo(Ja({}))}),Zi=gi.extend({method:ao("resources/list")}),Di=yi.extend({resources:Va(Ai)}),Li=gi.extend({method:ao("resources/templates/list")}),Fi=yi.extend({resourceTemplates:Va(Mi)}),qi=Co.extend({uri:la()}),Ui=qi,Vi=jo.extend({method:ao("resources/read"),params:Ui}),Hi=Zo.extend({contents:Va(Ga([Ii,Ci]))}),Ki=Mo.extend({method:ao("notifications/resources/list_changed"),params:Ao.optional()}),Ji=qi,Bi=jo.extend({method:ao("resources/subscribe"),params:Ji}),Gi=qi,Wi=jo.extend({method:ao("resources/unsubscribe"),params:Gi}),Xi=Ao.extend({uri:la()}),Yi=Mo.extend({method:ao("notifications/resources/updated"),params:Xi}),Qi=Ka({name:la(),description:uo(la()),required:uo(Ma())}),ec=Ka({...Qo.shape,...Yo.shape,description:uo(la()),arguments:uo(Va(Qi)),_meta:uo(Ja({}))}),tc=gi.extend({method:ao("prompts/list")}),rc=yi.extend({prompts:Va(ec)}),nc=Co.extend({name:la(),arguments:to(la(),la()).optional()}),sc=jo.extend({method:ao("prompts/get"),params:nc}),ac=Ka({type:ao("text"),text:la(),annotations:ji.optional(),_meta:to(la(),Fa()).optional()}),oc=Ka({type:ao("image"),data:Ri,mimeType:la(),annotations:ji.optional(),_meta:to(la(),Fa()).optional()}),ic=Ka({type:ao("audio"),data:Ri,mimeType:la(),annotations:ji.optional(),_meta:to(la(),Fa()).optional()}),cc=Ka({type:ao("tool_use"),name:la(),id:la(),input:to(la(),Fa()),_meta:to(la(),Fa()).optional()}),dc=Ka({type:ao("resource"),resource:Ga([Ii,Ci]),annotations:ji.optional(),_meta:to(la(),Fa()).optional()}),uc=Ga([ac,oc,ic,Ai.extend({type:ao("resource_link")}),dc]),lc=Ka({role:zi,content:uc}),pc=Zo.extend({description:la().optional(),messages:Va(lc)}),hc=Mo.extend({method:ao("notifications/prompts/list_changed"),params:Ao.optional()}),fc=Ka({title:la().optional(),readOnlyHint:Ma().optional(),destructiveHint:Ma().optional(),idempotentHint:Ma().optional(),openWorldHint:Ma().optional()}),mc=Ka({taskSupport:no(["required","optional","forbidden"]).optional()}),gc=Ka({...Qo.shape,...Yo.shape,description:la().optional(),inputSchema:Ka({type:ao("object"),properties:to(la(),xo).optional(),required:Va(la()).optional()}).catchall(Fa()),outputSchema:Ka({type:ao("object"),properties:to(la(),xo).optional(),required:Va(la()).optional()}).catchall(Fa()).optional(),annotations:fc.optional(),execution:mc.optional(),_meta:to(la(),Fa()).optional()}),yc=gi.extend({method:ao("tools/list")}),_c=yi.extend({tools:Va(gc)}),vc=Zo.extend({content:Va(uc).default([]),structuredContent:to(la(),Fa()).optional(),isError:Ma().optional()});vc.or(Zo.extend({toolResult:Fa()}));const wc=zo.extend({name:la(),arguments:to(la(),Fa()).optional()}),bc=jo.extend({method:ao("tools/call"),params:wc}),kc=Mo.extend({method:ao("notifications/tools/list_changed"),params:Ao.optional()});Ka({autoRefresh:Ma().default(!0),debounceMs:Ca().int().nonnegative().default(300)});const $c=no(["debug","info","notice","warning","error","critical","alert","emergency"]),Ec=Co.extend({level:$c}),Sc=jo.extend({method:ao("logging/setLevel"),params:Ec}),Tc=Ao.extend({level:$c,logger:la().optional(),data:Fa()}),xc=Mo.extend({method:ao("notifications/message"),params:Tc}),Nc=Ka({name:la().optional()}),Oc=Ka({hints:Va(Nc).optional(),costPriority:Ca().min(0).max(1).optional(),speedPriority:Ca().min(0).max(1).optional(),intelligencePriority:Ca().min(0).max(1).optional()}),Pc=Ka({mode:no(["auto","required","none"]).optional()}),Ic=Ka({type:ao("tool_result"),toolUseId:la().describe("The unique identifier for the corresponding tool call."),content:Va(uc).default([]),structuredContent:Ka({}).loose().optional(),isError:Ma().optional(),_meta:to(la(),Fa()).optional()}),Rc=Xa("type",[ac,oc,ic]),Cc=Xa("type",[ac,oc,ic,cc,Ic]),zc=Ka({role:zi,content:Ga([Cc,Va(Cc)]),_meta:to(la(),Fa()).optional()}),jc=zo.extend({messages:Va(zc),modelPreferences:Oc.optional(),systemPrompt:la().optional(),includeContext:no(["none","thisServer","allServers"]).optional(),temperature:Ca().optional(),maxTokens:Ca().int(),stopSequences:Va(la()).optional(),metadata:xo.optional(),tools:Va(gc).optional(),toolChoice:Pc.optional()}),Ac=jo.extend({method:ao("sampling/createMessage"),params:jc}),Mc=Zo.extend({model:la(),stopReason:uo(no(["endTurn","stopSequence","maxTokens"]).or(la())),role:zi,content:Rc}),Zc=Zo.extend({model:la(),stopReason:uo(no(["endTurn","stopSequence","maxTokens","toolUse"]).or(la())),role:zi,content:Ga([Cc,Va(Cc)])}),Dc=Ka({type:ao("boolean"),title:la().optional(),description:la().optional(),default:Ma().optional()}),Lc=Ka({type:ao("string"),title:la().optional(),description:la().optional(),minLength:Ca().optional(),maxLength:Ca().optional(),format:no(["email","uri","date","date-time"]).optional(),default:la().optional()}),Fc=Ka({type:no(["number","integer"]),title:la().optional(),description:la().optional(),minimum:Ca().optional(),maximum:Ca().optional(),default:Ca().optional()}),qc=Ka({type:ao("string"),title:la().optional(),description:la().optional(),enum:Va(la()),default:la().optional()}),Uc=Ka({type:ao("string"),title:la().optional(),description:la().optional(),oneOf:Va(Ka({const:la(),title:la()})),default:la().optional()}),Vc=Ka({type:ao("string"),title:la().optional(),description:la().optional(),enum:Va(la()),enumNames:Va(la()).optional(),default:la().optional()}),Hc=Ga([qc,Uc]),Kc=Ga([Ka({type:ao("array"),title:la().optional(),description:la().optional(),minItems:Ca().optional(),maxItems:Ca().optional(),items:Ka({type:ao("string"),enum:Va(la())}),default:Va(la()).optional()}),Ka({type:ao("array"),title:la().optional(),description:la().optional(),minItems:Ca().optional(),maxItems:Ca().optional(),items:Ka({anyOf:Va(Ka({const:la(),title:la()}))}),default:Va(la()).optional()})]),Jc=Ga([Vc,Hc,Kc]),Bc=Ga([Jc,Dc,Lc,Fc]),Gc=Ga([zo.extend({mode:ao("form").optional(),message:la(),requestedSchema:Ka({type:ao("object"),properties:to(la(),Bc),required:Va(la()).optional()})}),zo.extend({mode:ao("url"),message:la(),elicitationId:la(),url:la().url()})]),Wc=jo.extend({method:ao("elicitation/create"),params:Gc}),Xc=Ao.extend({elicitationId:la()}),Yc=Mo.extend({method:ao("notifications/elicitation/complete"),params:Xc}),Qc=Zo.extend({action:no(["accept","decline","cancel"]),content:ko(e=>null===e?void 0:e,to(la(),Ga([la(),Ca(),Ma(),Va(la())])).optional())}),ed=Ka({type:ao("ref/resource"),uri:la()}),td=Ka({type:ao("ref/prompt"),name:la()}),rd=Co.extend({ref:Ga([td,ed]),argument:Ka({name:la(),value:la()}),context:Ka({arguments:to(la(),la()).optional()}).optional()}),nd=jo.extend({method:ao("completion/complete"),params:rd}),sd=Zo.extend({completion:Ja({values:Va(la()).max(100),total:uo(Ca().int()),hasMore:uo(Ma())})}),ad=Ka({uri:la().startsWith("file://"),name:la().optional(),_meta:to(la(),Fa()).optional()}),od=jo.extend({method:ao("roots/list"),params:Co.optional()}),id=Zo.extend({roots:Va(ad)}),cd=Mo.extend({method:ao("notifications/roots/list_changed"),params:Ao.optional()});Ga([li,ii,nd,Sc,sc,tc,Zi,Li,Vi,Bi,Wi,bc,yc,$i,Si,Ti,Ni]),Ga([Wo,fi,ui,cd,ki]),Ga([Bo,Mc,Zc,Qc,id,Ei,xi,wi]),Ga([li,Ac,Wc,od,$i,Si,Ti,Ni]),Ga([Wo,fi,xc,Yi,Ki,kc,hc,ki,Yc]),Ga([Bo,di,sd,pc,rc,Di,Fi,Hi,vc,_c,Ei,xi,wi]);class dd 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===Ho.UrlElicitationRequired&&r){const e=r;if(e.elicitations)return new ud(e.elicitations,t)}return new dd(e,t,r)}}class ud extends dd{constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(Ho.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}function ld(e){return"completed"===e||"failed"===e||"cancelled"===e}const pd=Symbol("Let zodToJsonSchema decide on which parser to use"),hd={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 fd(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function md(e,t,r,n,s){e[t]=r,fd(e,t,n,s)}const gd=(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 yd(e){if("openAi"!==e.target)return{};const t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===e.$refStrategy?gd(t,e.currentPath):t.join("/")}}function _d(e,t){return Vd(e.type._def,t)}function vd(e,t,r){const n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((r,n)=>vd(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 wd(e,t)}}const wd=(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":md(r,"minimum",n.value,n.message,t);break;case"max":md(r,"maximum",n.value,n.message,t)}return r};let bd;const kd=/^[cC][^\s-]{8,}$/,$d=/^[0-9a-z]+$/,Ed=/^[0-9A-HJKMNP-TV-Z]{26}$/,Sd=/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,Td=()=>(void 0===bd&&(bd=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),bd),xd=/^(?:(?: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])$/,Nd=/^(([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])$/,Od=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Pd=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Id=/^[a-zA-Z0-9_-]{21}$/,Rd=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;function Cd(e,t){const r={type:"string"};if(e.checks)for(const n of e.checks)switch(n.kind){case"min":md(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,n.value):n.value,n.message,t);break;case"max":md(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":Ad(r,"email",n.message,t);break;case"format:idn-email":Ad(r,"idn-email",n.message,t);break;case"pattern:zod":Md(r,Sd,n.message,t)}break;case"url":Ad(r,"uri",n.message,t);break;case"uuid":Ad(r,"uuid",n.message,t);break;case"regex":Md(r,n.regex,n.message,t);break;case"cuid":Md(r,kd,n.message,t);break;case"cuid2":Md(r,$d,n.message,t);break;case"startsWith":Md(r,RegExp(`^${zd(n.value,t)}`),n.message,t);break;case"endsWith":Md(r,RegExp(`${zd(n.value,t)}$`),n.message,t);break;case"datetime":Ad(r,"date-time",n.message,t);break;case"date":Ad(r,"date",n.message,t);break;case"time":Ad(r,"time",n.message,t);break;case"duration":Ad(r,"duration",n.message,t);break;case"length":md(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,n.value):n.value,n.message,t),md(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"includes":Md(r,RegExp(zd(n.value,t)),n.message,t);break;case"ip":"v6"!==n.version&&Ad(r,"ipv4",n.message,t),"v4"!==n.version&&Ad(r,"ipv6",n.message,t);break;case"base64url":Md(r,Pd,n.message,t);break;case"jwt":Md(r,Rd,n.message,t);break;case"cidr":"v6"!==n.version&&Md(r,xd,n.message,t),"v4"!==n.version&&Md(r,Nd,n.message,t);break;case"emoji":Md(r,Td(),n.message,t);break;case"ulid":Md(r,Ed,n.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":Ad(r,"binary",n.message,t);break;case"contentEncoding:base64":md(r,"contentEncoding","base64",n.message,t);break;case"pattern:zod":Md(r,Od,n.message,t)}break;case"nanoid":Md(r,Id,n.message,t)}return r}function zd(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 Ad(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}}})):md(e,"format",t,r,n)}function Md(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:Zd(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):md(e,"pattern",Zd(t,n),r,n)}function Zd(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 o="",i=!1,c=!1,d=!1;for(let e=0;e<a.length;e++)if(i)o+=a[e],i=!1;else{if(r)if(c){if(a[e].match(/[a-z]/)){d?(o+=a[e],o+=`${a[e-2]}-${a[e]}`.toUpperCase(),d=!1):"-"===a[e+1]&&a[e+2]?.match(/[a-z]/)?(o+=a[e],d=!0):o+=`${a[e]}${a[e].toUpperCase()}`;continue}}else if(a[e].match(/[a-z]/)){o+=`[${a[e]}${a[e].toUpperCase()}]`;continue}if(n){if("^"===a[e]){o+="(^|(?<=[\r\n]))";continue}if("$"===a[e]){o+="($|(?=[\r\n]))";continue}}s&&"."===a[e]?o+=c?`${a[e]}\r\n`:`[${a[e]}\r\n]`:(o+=a[e],"\\"===a[e]?i=!0:c&&"]"===a[e]?c=!1:c||"["!==a[e]||(c=!0))}try{new RegExp(o)}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 o}function Dd(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===Ue.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,n)=>({...r,[n]:Vd(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??yd(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};const r={type:"object",additionalProperties:Vd(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if("openApi3"===t.target)return r;if(e.keyType?._def.typeName===Ue.ZodString&&e.keyType._def.checks?.length){const{type:n,...s}=Cd(e.keyType._def,t);return{...r,propertyNames:s}}if(e.keyType?._def.typeName===Ue.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===Ue.ZodBranded&&e.keyType._def.type._def.typeName===Ue.ZodString&&e.keyType._def.type._def.checks?.length){const{type:n,...s}=_d(e.keyType._def,t);return{...r,propertyNames:s}}return r}const Ld={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},Fd=(e,t)=>{const r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,r)=>Vd(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 qd(e){try{return e.isOptional()}catch{return!0}}const Ud=(e,t,r)=>{switch(t){case Ue.ZodString:return Cd(e,r);case Ue.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",fd(r,"type",n.message,t);break;case"min":"jsonSchema7"===t.target?n.inclusive?md(r,"minimum",n.value,n.message,t):md(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),md(r,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?md(r,"maximum",n.value,n.message,t):md(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),md(r,"maximum",n.value,n.message,t));break;case"multipleOf":md(r,"multipleOf",n.value,n.message,t)}return r}(e,r);case Ue.ZodObject:return function(e,t){const r="openAi"===t.target,n={type:"object",properties:{}},s=[],a=e.shape();for(const e in a){let o=a[e];if(void 0===o||void 0===o._def)continue;let i=qd(o);i&&r&&("ZodOptional"===o._def.typeName&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),i=!1);const c=Vd(o._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==c&&(n.properties[e]=c,i||s.push(e))}s.length&&(n.required=s);const o=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return Vd(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!==o&&(n.additionalProperties=o),n}(e,r);case Ue.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?md(r,"minimum",n.value,n.message,t):md(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),md(r,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?md(r,"maximum",n.value,n.message,t):md(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),md(r,"maximum",n.value,n.message,t));break;case"multipleOf":md(r,"multipleOf",n.value,n.message,t)}return r}(e,r);case Ue.ZodBoolean:return{type:"boolean"};case Ue.ZodDate:return vd(e,r);case Ue.ZodUndefined:return function(e){return{not:yd(e)}}(r);case Ue.ZodNull:return function(e){return"openApi3"===e.target?{enum:["null"],nullable:!0}:{type:"null"}}(r);case Ue.ZodArray:return function(e,t){const r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==Ue.ZodAny&&(r.items=Vd(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&md(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&md(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(md(r,"minItems",e.exactLength.value,e.exactLength.message,t),md(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}(e,r);case Ue.ZodUnion:case Ue.ZodDiscriminatedUnion:return function(e,t){if("openApi3"===t.target)return Fd(e,t);const r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(e=>e._def.typeName in Ld&&(!e._def.checks||!e._def.checks.length))){const e=r.reduce((e,t)=>{const r=Ld[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 Fd(e,t)}(e,r);case Ue.ZodIntersection:return function(e,t){const r=[Vd(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Vd(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 Ue.ZodTuple:return function(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,r)=>Vd(e._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:Vd(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,r)=>Vd(e._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])}}(e,r);case Ue.ZodRecord:return Dd(e,r);case Ue.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 Ue.ZodEnum:return function(e){return{type:"string",enum:Array.from(e.values)}}(e);case Ue.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 Ue.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:Ld[e.innerType._def.typeName],nullable:!0}:{type:[Ld[e.innerType._def.typeName],"null"]};if("openApi3"===t.target){const r=Vd(e.innerType._def,{...t,currentPath:[...t.currentPath]});return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&{...r,nullable:!0}}const r=Vd(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}(e,r);case Ue.ZodOptional:return((e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return Vd(e.innerType._def,t);const r=Vd(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:yd(t)},r]}:yd(t)})(e,r);case Ue.ZodMap:return function(e,t){return"record"===t.mapStrategy?Dd(e,t):{type:"array",maxItems:125,items:{type:"array",items:[Vd(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||yd(t),Vd(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||yd(t)],minItems:2,maxItems:2}}}(e,r);case Ue.ZodSet:return function(e,t){const r={type:"array",uniqueItems:!0,items:Vd(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&md(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&md(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}(e,r);case Ue.ZodLazy:return()=>e.getter()._def;case Ue.ZodPromise:return function(e,t){return Vd(e.type._def,t)}(e,r);case Ue.ZodNaN:case Ue.ZodNever:return function(e){return"openAi"===e.target?void 0:{not:yd({...e,currentPath:[...e.currentPath,"not"]})}}(r);case Ue.ZodEffects:return function(e,t){return"input"===t.effectStrategy?Vd(e.schema._def,t):yd(t)}(e,r);case Ue.ZodAny:return yd(r);case Ue.ZodUnknown:return function(e){return yd(e)}(r);case Ue.ZodDefault:return function(e,t){return{...Vd(e.innerType._def,t),default:e.defaultValue()}}(e,r);case Ue.ZodBranded:return _d(e,r);case Ue.ZodReadonly:case Ue.ZodCatch:return((e,t)=>Vd(e.innerType._def,t))(e,r);case Ue.ZodPipeline:return((e,t)=>{if("input"===t.pipeStrategy)return Vd(e.in._def,t);if("output"===t.pipeStrategy)return Vd(e.out._def,t);const r=Vd(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[r,Vd(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]})].filter(e=>void 0!==e)}})(e,r);case Ue.ZodFunction:case Ue.ZodVoid:case Ue.ZodSymbol:default:return}};function Vd(e,t,r=!1){const n=t.seen.get(e);if(t.override){const s=t.override?.(e,t,n,r);if(s!==pd)return s}if(n&&!r){const e=Hd(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=Ud(e,e.typeName,t),o="function"==typeof a?Vd(a(),t):a;if(o&&Kd(e,t,o),t.postProcess){const r=t.postProcess(o,e,t);return s.jsonSchema=o,r}return s.jsonSchema=o,o}const Hd=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:gd(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`),yd(t)):"seen"===t.$refStrategy?yd(t):void 0}},Kd=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);function Jd(e,t){return As(e)?function(e,t){if("_idmap"in e){const r=e,n=ns({...t,processors:Rs}),s={};for(const e of r._idmap.entries()){const[t,r]=e;ss(r,n)}const a={},o={registry:r,uri:t?.uri,defs:s};n.external=o;for(const e of r._idmap.entries()){const[t,r]=e;as(n,r),a[t]=os(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=ns({...t,processors:Rs});return ss(e,r),as(r,e),os(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?{...hd,name:e}:{...hd,...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]:Vd(n._def,{...r,currentPath:[...r.basePath,r.definitionPath,t]},!0)??yd(r)}),{}):void 0;const s="title"===t?.nameStrategy?void 0:t?.name,a=Vd(e._def,void 0===s?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??yd(r),o=void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==o&&(a.title=o),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 i=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?i.$schema="http://json-schema.org/draft-07/schema#":"jsonSchema2019-09"!==r.target&&"openAi"!==r.target||(i.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===r.target&&("anyOf"in i||"oneOf"in i||"allOf"in i||"type"in i&&Array.isArray(i.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),i})(e,{strictUnions:t?.strictUnions??!0,pipeStrategy:t?.pipeStrategy??"input"});var r}function Bd(e){const t=Ls(e),r=t?.method;if(!r)throw new Error("Schema is missing a method literal");const n=Us(r);if("string"!=typeof n)throw new Error("Schema method literal must be a string");return n}function Gd(e,t){const r=Zs(e,t);if(!r.success)throw r.error;return r.data}class Wd{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(Wo,e=>{this._oncancel(e)}),this.setNotificationHandler(fi,e=>{this._onprogress(e)}),this.setRequestHandler(li,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler($i,async(e,t)=>{const r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new dd(Ho.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(Si,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 dd(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 dd(Ho.InvalidParams,`Task not found: ${n}`);if(!ld(s.status))return await this._waitForTaskUpdate(n,t.signal),await r();if(ld(s.status)){const e=await this._taskStore.getTaskResult(n,t.sessionId);return this._clearTaskQueue(n),{...e,_meta:{...e._meta,[So]:{taskId:n}}}}return await r()};return await r()}),this.setRequestHandler(Ti,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 dd(Ho.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(Ni,async(e,t)=>{try{const r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new dd(Ho.InvalidParams,`Task not found: ${e.params.taskId}`);if(ld(r.status))throw new dd(Ho.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 dd(Ho.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...n}}catch(e){if(e instanceof dd)throw e;throw new dd(Ho.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),dd.fromError(Ho.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),Vo(e)||(r=e,Ko.safeParse(r).success)?this._onresponse(e):Fo(e)?this._onrequest(e,t):(e=>qo.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=dd.fromError(Ho.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?.[So]?.taskId;if(void 0===r){const t={jsonrpc:"2.0",id:e.id,error:{code:Ho.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 o=(i=e.params,zo.safeParse(i).success?e.params.task:void 0);var i;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 o=a.relatedTask?.taskId??s;return o&&c&&await c.updateTaskStatus(o,"input_required"),await this.request(t,r,a)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&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:Ho.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),o=this._timeoutInfo.get(n);if(o&&a&&o.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(Vo(e)?r(e):r(new dd(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(Vo(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),Vo(e)?n(e):n(dd.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 dd?e:new dd(Ho.InternalError,String(e))}}return}let s;try{const n=await this.request(e,wi,r);if(!n.task)throw new dd(Ho.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},ld(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 dd(Ho.InternalError,`Task ${s} failed`)}:"cancelled"===e.status&&(yield{type:"error",error:new dd(Ho.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 dd?e:new dd(Ho.InternalError,String(e))}}}request(e,t,r){const{relatedRequestId:n,resumptionToken:s,onresumptiontoken:a,task:o,relatedTask:i}=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),o&&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}}),o&&(p.params={...p.params,task:o}),i&&(p.params={...p.params,_meta:{...p.params?._meta||{},[So]:i}});const h=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 dd?e:new dd(Ho.RequestTimeout,String(e));d(t)};this._responseHandlers.set(l,e=>{if(!r?.signal?.aborted){if(e instanceof Error)return d(e);try{const r=Zs(t,e.result);r.success?c(r.data):d(r.error)}catch(e){d(e)}}}),r?.signal?.addEventListener("abort",()=>{h(r?.signal?.reason)});const f=r?.timeout??6e4;this._setupTimeout(l,f,r?.maxTotalTimeout,()=>h(dd.fromError(Ho.RequestTimeout,"Request timed out",{timeout:f})),r?.resetTimeoutOnProgress??!1);const m=i?.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},Ei,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},xi,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},Oi,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||{},[So]: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||{},[So]: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||{},[So]:t.relatedTask}}}),await this._transport.send(n,t)}setRequestHandler(e,t){const r=Bd(e);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(r,n)=>{const s=Gd(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=Bd(e);this._notificationHandlers.set(r,r=>{const n=Gd(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&&Fo(t.message)){const r=t.message.id,n=this._requestResolvers.get(r);n?(n(new dd(Ho.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 dd(Ho.InvalidRequest,"Request cancelled"));const s=setTimeout(e,r);t.addEventListener("abort",()=>{clearTimeout(s),n(new dd(Ho.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 dd(Ho.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=ki.parse({method:"notifications/tasks/status",params:a});await this.notification(t),ld(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 dd(Ho.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(ld(a.status))throw new dd(Ho.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 o=await r.getTask(e,t);if(o){const t=ki.parse({method:"notifications/tasks/status",params:o});await this.notification(t),ld(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>r.listTasks(e,t)}}}function Xd(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function Yd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qd,eu={exports:{}},tu={},ru={},nu={},su={},au={},ou={};function iu(){return Qd||(Qd=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;)i(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 o(e,...t){const r=[d(e[0])];let s=0;for(;s<t.length;)r.push(a),i(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 i(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=o,e.addCodeArg=i,e.strConcat=function(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${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())}}(ou)),ou}var cu,du,uu={};function lu(){return cu||(cu=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const t=iu();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 o=t._`\n`;e.ValueScope=class extends s{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o: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 o=this._values[s];if(o){const e=o.get(a);if(e)return e}else o=this._values[s]=new Map;o.set(a,n);const i=this._scope[s]||(this._scope[s]=[]),c=i.length;return i[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,o={},i){let c=t.nil;for(const d in s){const u=s[d];if(!u)continue;const l=o[d]=o[d]||new Map;u.forEach(s=>{if(l.has(s))return;l.set(s,n.Started);let o=a(s);if(o){const r=this.opts.es5?e.varKinds.var:e.varKinds.const;c=t._`${c}${r} ${s} = ${o};${this.opts._n}`}else{if(!(o=null==i?void 0:i(s)))throw new r(s);c=t._`${c}${o}${this.opts._n}`}l.set(s,n.Completed)})}return c}}}(uu)),uu}function pu(){return du||(du=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=iu(),r=lu();var n=iu();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=lu();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 o 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 i 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 i{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 h 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 f extends h{render(e){return"{"+e._n+super.render(e)+"}"+e._n}}class m extends h{}class g extends f{}g.kind="else";class y extends f{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 f{}_.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 f{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 h{render(e){return"return "+super.render(e)}}$.kind="return";class E extends f{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 S extends f{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}S.kind="catch";class T extends f{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._`!${j(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 o(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 i(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 o=this._scope.toName(e);return this._for(new w(a,o,t,n),()=>s(o))}forOf(e,n,s,a=r.varKinds.const){const o=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(o,t._`${e}[${r}]`),s(o)})}return this._for(new b("of",a,o,n),()=>s(o))}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 o=this._scope.toName(e);return this._for(new b("in",a,o,n),()=>s(o))}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 E;if(this._blockNode(n),this.code(e),t){const e=this.name("e");this._currNode=n.catch=new S(e),t(e)}return r&&(this._currNode=n.finally=new T,this.code(r)),this._endBlockNode(S,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 C=z(e.operators.OR);function z(e){return(r,n)=>r===t.nil?n:n===t.nil?r:t._`${j(r)} ${e} ${j(n)}`}function j(e){return e instanceof t.Name?e:t._`(${e})`}e.or=function(...e){return e.reduce(C)}}(au)),au}var hu,fu={};function mu(){if(hu)return fu;hu=1,Object.defineProperty(fu,"__esModule",{value:!0}),fu.checkStrictMode=fu.getErrorPath=fu.Type=fu.useFunc=fu.setEvaluated=fu.evaluatedPropsToName=fu.mergeEvaluated=fu.eachItem=fu.unescapeJsonPointer=fu.escapeJsonPointer=fu.escapeFragment=fu.unescapeFragment=fu.schemaRefOrVal=fu.schemaHasRulesButRef=fu.schemaHasRules=fu.checkUnknownRules=fu.alwaysValidSchema=fu.toHash=void 0;const e=pu(),t=iu();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 o({mergeNames:t,mergeToName:r,mergeValues:n,resultToName:s}){return(a,o,i,c)=>{const d=void 0===i?o:i instanceof e.Name?(o instanceof e.Name?t(a,o,i):r(a,o,i),i):o instanceof e.Name?(r(a,i,o),o):n(o,i);return c!==e.Name||d instanceof e.Name?d:s(a,d)}}function i(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))}fu.toHash=function(e){const t={};for(const r of e)t[r]=!0;return t},fu.alwaysValidSchema=function(e,t){return"boolean"==typeof t?t:0===Object.keys(t).length||(r(e,t),!n(t,e.self.RULES.all))},fu.checkUnknownRules=r,fu.schemaHasRules=n,fu.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},fu.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)}`},fu.unescapeFragment=function(e){return a(decodeURIComponent(e))},fu.escapeFragment=function(e){return encodeURIComponent(s(e))},fu.escapeJsonPointer=s,fu.unescapeJsonPointer=a,fu.eachItem=function(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)},fu.mergeEvaluated={props:o({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:i}),items:o({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)})},fu.evaluatedPropsToName=i,fu.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 fu.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||(fu.Type=u={})),fu.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)},fu.checkStrictMode=l,fu}var gu,yu,_u,vu={};function wu(){if(gu)return vu;gu=1,Object.defineProperty(vu,"__esModule",{value:!0});const e=pu(),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 vu.default=t,vu}function bu(){return yu||(yu=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=pu(),r=mu(),n=wu();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,o,c){const{it:d}=r,{gen:u,compositeRule:l,allErrors:p}=d,h=i(r,n,o);(null!=c?c:l||p)?s(u,h):a(d,t._`[${h}]`)},e.reportExtraError=function(t,r=e.keywordError,o){const{it:c}=t,{gen:d,compositeRule:u,allErrors:l}=c;s(d,i(t,r,o)),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:o,it:i}){if(void 0===o)throw new Error("ajv implementation error");const c=e.name("err");e.forRange("i",o,n.default.errors,o=>{e.const(c,t._`${n.default.vErrors}[${o}]`),e.if(t._`${c}.instancePath === undefined`,()=>e.assign(t._`${c}.instancePath`,(0,t.strConcat)(n.default.instancePath,i.errorPath))),e.assign(t._`${c}.schemaPath`,t.str`${i.errSchemaPath}/${r}`),i.opts.verbose&&(e.assign(t._`${c}.schema`,s),e.assign(t._`${c}.data`,a))})};const o={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 i(e,r,s){const{createErrors:a}=e.it;return!1===a?t._`{}`:function(e,r,s={}){const{gen:a,it:i}=e,u=[c(i,s),d(e,s)];return function(e,{params:r,message:s},a){const{keyword:i,data:c,schemaValue:d,it:u}=e,{opts:l,propertyName:p,topSchemaRef:h,schemaPath:f}=u;a.push([o.keyword,i],[o.params,"function"==typeof r?r(e):r||t._`{}`]),l.messages&&a.push([o.message,"function"==typeof s?s(e):s]),l.verbose&&a.push([o.schema,d],[o.parentSchema,t._`${h}${f}`],[n.default.data,c]),p&&a.push([o.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 i=a?n:t.str`${n}/${e}`;return s&&(i=t.str`${i}${(0,r.getErrorPath)(s,r.Type.Str)}`),[o.schemaPath,i]}}(su)),su}var ku,$u={},Eu={};function Su(){if(ku)return Eu;ku=1,Object.defineProperty(Eu,"__esModule",{value:!0}),Eu.getRules=Eu.isJSONType=void 0;const e=new Set(["string","number","integer","boolean","null","object","array"]);return Eu.isJSONType=function(t){return"string"==typeof t&&e.has(t)},Eu.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:{}}},Eu}var Tu,xu,Nu={};function Ou(){if(Tu)return Nu;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 Tu=1,Object.defineProperty(Nu,"__esModule",{value:!0}),Nu.shouldUseRule=Nu.shouldUseGroup=Nu.schemaHasRulesForType=void 0,Nu.schemaHasRulesForType=function({schema:t,self:r},n){const s=r.RULES.types[n];return s&&!0!==s&&e(t,s)},Nu.shouldUseGroup=e,Nu.shouldUseRule=t,Nu}function Pu(){if(xu)return $u;xu=1,Object.defineProperty($u,"__esModule",{value:!0}),$u.reportTypeError=$u.checkDataTypes=$u.checkDataType=$u.coerceAndCheckDataType=$u.getJSONTypes=$u.getSchemaTypes=$u.DataType=void 0;const e=Su(),t=Ou(),r=bu(),n=pu(),s=mu();var a;function o(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||($u.DataType=a={})),$u.getSchemaTypes=function(e){const t=o(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},$u.getJSONTypes=o,$u.coerceAndCheckDataType=function(e,r){const{gen:s,data:o,opts:c}=e,u=function(e,t){return t?e.filter(e=>i.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,o,c.strictNumbers,a.Wrong);s.if(t,()=>{u.length?function(e,t,r){const{gen:s,data:a,opts:o}=e,c=s.let("dataType",n._`typeof ${a}`),u=s.let("coerced",n._`undefined`);"array"===o.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,o.strictNumbers),()=>s.assign(u,a))),s.if(n._`${u} !== undefined`);for(const e of r)(i.has(e)||"array"===e&&"array"===o.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,readFileSync as o,writeFileSync as i}from"fs";import c,{dirname as d}from"path";import u from"os";import l from"better-sqlite3";import p from"simple-git";import{cwd as h}from"process";import{fileURLToPath as f}from"url";import"child_process";var m,g;!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}(m||(m={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(g||(g={}));const y=m.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),_=e=>{switch(typeof e){case"undefined":return y.undefined;case"string":return y.string;case"number":return Number.isNaN(e)?y.nan:y.number;case"boolean":return y.boolean;case"function":return y.function;case"bigint":return y.bigint;case"symbol":return y.symbol;case"object":return Array.isArray(e)?y.array:null===e?y.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?y.promise:"undefined"!=typeof Map&&e instanceof Map?y.map:"undefined"!=typeof Set&&e instanceof Set?y.set:"undefined"!=typeof Date&&e instanceof Date?y.date:y.object;default:return y.unknown}},v=m.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class w 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 w))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,m.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()}}w.create=e=>new w(e);const b=(e,t)=>{let r;switch(e.code){case v.invalid_type:r=e.received===y.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case v.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,m.jsonStringifyReplacer)}`;break;case v.unrecognized_keys:r=`Unrecognized key(s) in object: ${m.joinValues(e.keys,", ")}`;break;case v.invalid_union:r="Invalid input";break;case v.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${m.joinValues(e.options)}`;break;case v.invalid_enum_value:r=`Invalid enum value. Expected ${m.joinValues(e.options)}, received '${e.received}'`;break;case v.invalid_arguments:r="Invalid function arguments";break;case v.invalid_return_type:r="Invalid function return type";break;case v.invalid_date:r="Invalid date";break;case v.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}"`:m.assertNever(e.validation):r="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case v.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 v.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 v.custom:r="Invalid input";break;case v.invalid_intersection_types:r="Intersection results could not be merged";break;case v.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case v.not_finite:r="Number must be finite";break;default:r=t.defaultError,m.assertNever(e)}return{message:r}};let k=b;function $(e,t){const r=k,n=(e=>{const{data:t,path:r,errorMaps:n,issueData:s}=e,a=[...r,...s.path||[]],o={...s,path:a};if(void 0!==s.message)return{...s,path:a,message:s.message};let i="";const c=n.filter(e=>!!e).slice().reverse();for(const e of c)i=e(o,{data:t,defaultError:i}).message;return{...s,path:a,message:i}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===b?void 0:b].filter(e=>!!e)});e.common.issues.push(n)}class S{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 E;"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 S.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 E;if("aborted"===s.status)return E;"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 E=Object.freeze({status:"aborted"}),T=e=>({status:"dirty",value:e}),x=e=>({status:"valid",value:e}),N=e=>"aborted"===e.status,O=e=>"dirty"===e.status,P=e=>"valid"===e.status,I=e=>"undefined"!=typeof Promise&&e instanceof Promise;var R;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(R||(R={}));class z{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(P(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 w(e.common.issues);return this._error=t,this._error}}};function C(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 A=class{get description(){return this._def.description}_getType(e){return _(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:_(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new S,ctx:{common:e.parent.common,data:e.data,parsedType:_(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(I(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:_(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:_(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:t});return P(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=>P(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:_(e)},n=this._parse({data:e,path:r.path,parent:r}),s=await(I(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:v.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:Ue.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 Ce.create(this,this._def)}nullable(){return Ae.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ve.create(this)}promise(){return ze.create(this,this._def)}or(e){return ke.create([this,e],this._def)}and(e){return Se.create(this,e,this._def)}transform(e){return new je({...C(this._def),schema:this,typeName:Ue.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Me({...C(this._def),innerType:this,defaultValue:t,typeName:Ue.ZodDefault})}brand(){return new Le({typeName:Ue.ZodBranded,type:this,...C(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Ze({...C(this._def),innerType:this,catchValue:t,typeName:Ue.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Fe.create(this,e)}readonly(){return qe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const M=/^c[^\s-]{8,}$/i,Z=/^[0-9a-z]+$/,D=/^[0-9A-HJKMNP-TV-Z]{26}$/i,L=/^[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,F=/^[a-z0-9_-]{21}$/i,q=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,U=/^[-+]?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)?)??$/,V=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let H;const J=/^(?:(?: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])$/,K=/^(?:(?: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])$/,B=/^(([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]))$/,G=/^(([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])$/,W=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,X=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Y="((\\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])))",Q=new RegExp(`^${Y}$`);function ee(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 te(e){return new RegExp(`^${ee(e)}$`)}function re(e){let t=`${Y}T${ee(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 ne(e,t){return!("v4"!==t&&t||!J.test(e))||!("v6"!==t&&t||!B.test(e))}function se(e,t){if(!q.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 ae(e,t){return!("v4"!==t&&t||!K.test(e))||!("v6"!==t&&t||!G.test(e))}let oe=class e extends A{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==y.string){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.string,received:t.parsedType}),E}const t=new S;let r;for(const n of this._def.checks)if("min"===n.kind)e.data.length<n.value&&(r=this._getOrReturnCtx(e,r),$(r,{code:v.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),$(r,{code:v.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?$(r,{code:v.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):a&&$(r,{code:v.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if("email"===n.kind)V.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"email",code:v.invalid_string,message:n.message}),t.dirty());else if("emoji"===n.kind)H||(H=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),H.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"emoji",code:v.invalid_string,message:n.message}),t.dirty());else if("uuid"===n.kind)L.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"uuid",code:v.invalid_string,message:n.message}),t.dirty());else if("nanoid"===n.kind)F.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"nanoid",code:v.invalid_string,message:n.message}),t.dirty());else if("cuid"===n.kind)M.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"cuid",code:v.invalid_string,message:n.message}),t.dirty());else if("cuid2"===n.kind)Z.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"cuid2",code:v.invalid_string,message:n.message}),t.dirty());else if("ulid"===n.kind)D.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"ulid",code:v.invalid_string,message:n.message}),t.dirty());else if("url"===n.kind)try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),$(r,{validation:"url",code:v.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),$(r,{validation:"regex",code:v.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),$(r,{code:v.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),$(r,{code:v.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):"endsWith"===n.kind?e.data.endsWith(n.value)||(r=this._getOrReturnCtx(e,r),$(r,{code:v.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):"datetime"===n.kind?re(n).test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{code:v.invalid_string,validation:"datetime",message:n.message}),t.dirty()):"date"===n.kind?Q.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{code:v.invalid_string,validation:"date",message:n.message}),t.dirty()):"time"===n.kind?te(n).test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{code:v.invalid_string,validation:"time",message:n.message}),t.dirty()):"duration"===n.kind?U.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"duration",code:v.invalid_string,message:n.message}),t.dirty()):"ip"===n.kind?ne(e.data,n.version)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"ip",code:v.invalid_string,message:n.message}),t.dirty()):"jwt"===n.kind?se(e.data,n.alg)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"jwt",code:v.invalid_string,message:n.message}),t.dirty()):"cidr"===n.kind?ae(e.data,n.version)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"cidr",code:v.invalid_string,message:n.message}),t.dirty()):"base64"===n.kind?W.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"base64",code:v.invalid_string,message:n.message}),t.dirty()):"base64url"===n.kind?X.test(e.data)||(r=this._getOrReturnCtx(e,r),$(r,{validation:"base64url",code:v.invalid_string,message:n.message}),t.dirty()):m.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,r){return this.refinement(t=>e.test(t),{validation:t,code:v.invalid_string,...R.errToObj(r)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:"email",...R.errToObj(e)})}url(e){return this._addCheck({kind:"url",...R.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...R.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...R.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...R.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...R.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...R.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...R.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...R.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...R.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...R.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...R.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...R.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,...R.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,...R.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...R.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...R.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...R.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...R.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...R.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...R.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...R.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...R.errToObj(t)})}nonempty(e){return this.min(1,R.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 ie(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}oe.create=e=>new oe({checks:[],typeName:Ue.ZodString,coerce:e?.coerce??!1,...C(e)});let ce=class e extends A{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==y.number){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.number,received:t.parsedType}),E}let t;const r=new S;for(const n of this._def.checks)"int"===n.kind?m.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),$(t,{code:v.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),$(t,{code:v.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),$(t,{code:v.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),r.dirty()):"multipleOf"===n.kind?0!==ie(e.data,n.value)&&(t=this._getOrReturnCtx(e,t),$(t,{code:v.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),$(t,{code:v.not_finite,message:n.message}),r.dirty()):m.assertNever(n);return{status:r.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,R.toString(t))}gt(e,t){return this.setLimit("min",e,!1,R.toString(t))}lte(e,t){return this.setLimit("max",e,!0,R.toString(t))}lt(e,t){return this.setLimit("max",e,!1,R.toString(t))}setLimit(t,r,n,s){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:R.toString(s)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:"int",message:R.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:R.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:R.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:R.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:R.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:R.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:R.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:R.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:R.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&&m.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)}};ce.create=e=>new ce({checks:[],typeName:Ue.ZodNumber,coerce:e?.coerce||!1,...C(e)});class de extends A{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)!==y.bigint)return this._getInvalidInput(e);let t;const r=new S;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),$(t,{code:v.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),$(t,{code:v.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),$(t,{code:v.not_multiple_of,multipleOf:n.value,message:n.message}),r.dirty()):m.assertNever(n);return{status:r.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.bigint,received:t.parsedType}),E}gte(e,t){return this.setLimit("min",e,!0,R.toString(t))}gt(e,t){return this.setLimit("min",e,!1,R.toString(t))}lte(e,t){return this.setLimit("max",e,!0,R.toString(t))}lt(e,t){return this.setLimit("max",e,!1,R.toString(t))}setLimit(e,t,r,n){return new de({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:R.toString(n)}]})}_addCheck(e){return new de({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:R.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:R.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:R.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:R.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:R.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}}de.create=e=>new de({checks:[],typeName:Ue.ZodBigInt,coerce:e?.coerce??!1,...C(e)});let ue=class extends A{_parse(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==y.boolean){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.boolean,received:t.parsedType}),E}return x(e.data)}};ue.create=e=>new ue({typeName:Ue.ZodBoolean,coerce:e?.coerce||!1,...C(e)});class le extends A{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==y.date){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.date,received:t.parsedType}),E}if(Number.isNaN(e.data.getTime()))return $(this._getOrReturnCtx(e),{code:v.invalid_date}),E;const t=new S;let r;for(const n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(r=this._getOrReturnCtx(e,r),$(r,{code:v.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),$(r,{code:v.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):m.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new le({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:R.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:R.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}}le.create=e=>new le({checks:[],coerce:e?.coerce||!1,typeName:Ue.ZodDate,...C(e)});class pe extends A{_parse(e){if(this._getType(e)!==y.symbol){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.symbol,received:t.parsedType}),E}return x(e.data)}}pe.create=e=>new pe({typeName:Ue.ZodSymbol,...C(e)});class he extends A{_parse(e){if(this._getType(e)!==y.undefined){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.undefined,received:t.parsedType}),E}return x(e.data)}}he.create=e=>new he({typeName:Ue.ZodUndefined,...C(e)});let fe=class extends A{_parse(e){if(this._getType(e)!==y.null){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.null,received:t.parsedType}),E}return x(e.data)}};fe.create=e=>new fe({typeName:Ue.ZodNull,...C(e)});class me extends A{constructor(){super(...arguments),this._any=!0}_parse(e){return x(e.data)}}me.create=e=>new me({typeName:Ue.ZodAny,...C(e)});let ge=class extends A{constructor(){super(...arguments),this._unknown=!0}_parse(e){return x(e.data)}};ge.create=e=>new ge({typeName:Ue.ZodUnknown,...C(e)});let ye=class extends A{_parse(e){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.never,received:t.parsedType}),E}};ye.create=e=>new ye({typeName:Ue.ZodNever,...C(e)});class _e extends A{_parse(e){if(this._getType(e)!==y.undefined){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.void,received:t.parsedType}),E}return x(e.data)}}_e.create=e=>new _e({typeName:Ue.ZodVoid,...C(e)});let ve=class e extends A{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==y.array)return $(t,{code:v.invalid_type,expected:y.array,received:t.parsedType}),E;if(null!==n.exactLength){const e=t.data.length>n.exactLength.value,s=t.data.length<n.exactLength.value;(e||s)&&($(t,{code:e?v.too_big:v.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&&($(t,{code:v.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&&($(t,{code:v.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 z(t,e,t.path,r)))).then(e=>S.mergeArray(r,e));const s=[...t.data].map((e,r)=>n.type._parseSync(new z(t,e,t.path,r)));return S.mergeArray(r,s)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:R.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:R.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:R.toString(r)}})}nonempty(e){return this.min(1,e)}};function we(e){if(e instanceof be){const t={};for(const r in e.shape){const n=e.shape[r];t[r]=Ce.create(we(n))}return new be({...e._def,shape:()=>t})}return e instanceof ve?new ve({...e._def,type:we(e.element)}):e instanceof Ce?Ce.create(we(e.unwrap())):e instanceof Ae?Ae.create(we(e.unwrap())):e instanceof Ee?Ee.create(e.items.map(e=>we(e))):e}ve.create=(e,t)=>new ve({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ue.ZodArray,...C(t)});let be=class e extends A{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=m.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==y.object){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.object,received:t.parsedType}),E}const{status:t,ctx:r}=this._processInputParams(e),{shape:n,keys:s}=this._getCached(),a=[];if(!(this._def.catchall instanceof ye&&"strip"===this._def.unknownKeys))for(const e in r.data)s.includes(e)||a.push(e);const o=[];for(const e of s){const t=n[e],s=r.data[e];o.push({key:{status:"valid",value:e},value:t._parse(new z(r,s,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof ye){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of a)o.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)a.length>0&&($(r,{code:v.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];o.push({key:{status:"valid",value:t},value:e._parse(new z(r,n,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const e=[];for(const t of o){const r=await t.key,n=await t.value;e.push({key:r,value:n,alwaysSet:t.alwaysSet})}return e}).then(e=>S.mergeObjectSync(t,e)):S.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return R.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:R.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:Ue.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 m.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 m.objectKeys(this.shape))t[e]||(r[e]=this.shape[e]);return new e({...this._def,shape:()=>r})}deepPartial(){return we(this)}partial(t){const r={};for(const e of m.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 m.objectKeys(this.shape))if(t&&!t[e])r[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Ce;)t=t._def.innerType;r[e]=t}return new e({...this._def,shape:()=>r})}keyof(){return Pe(m.objectKeys(this.shape))}};be.create=(e,t)=>new be({shape:()=>e,unknownKeys:"strip",catchall:ye.create(),typeName:Ue.ZodObject,...C(t)}),be.strictCreate=(e,t)=>new be({shape:()=>e,unknownKeys:"strict",catchall:ye.create(),typeName:Ue.ZodObject,...C(t)}),be.lazycreate=(e,t)=>new be({shape:e,unknownKeys:"strip",catchall:ye.create(),typeName:Ue.ZodObject,...C(t)});let ke=class extends A{_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 w(e.ctx.common.issues));return $(t,{code:v.invalid_union,unionErrors:r}),E});{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 w(e));return $(t,{code:v.invalid_union,unionErrors:s}),E}}get options(){return this._def.options}};function $e(e,t){const r=_(e),n=_(t);if(e===t)return{valid:!0,data:e};if(r===y.object&&n===y.object){const r=m.objectKeys(t),n=m.objectKeys(e).filter(e=>-1!==r.indexOf(e)),s={...e,...t};for(const r of n){const n=$e(e[r],t[r]);if(!n.valid)return{valid:!1};s[r]=n.data}return{valid:!0,data:s}}if(r===y.array&&n===y.array){if(e.length!==t.length)return{valid:!1};const r=[];for(let n=0;n<e.length;n++){const s=$e(e[n],t[n]);if(!s.valid)return{valid:!1};r.push(s.data)}return{valid:!0,data:r}}return r===y.date&&n===y.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}ke.create=(e,t)=>new ke({options:e,typeName:Ue.ZodUnion,...C(t)});let Se=class extends A{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=(e,n)=>{if(N(e)||N(n))return E;const s=$e(e.value,n.value);return s.valid?((O(e)||O(n))&&t.dirty(),{status:t.value,value:s.data}):($(r,{code:v.invalid_intersection_types}),E)};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}))}};Se.create=(e,t,r)=>new Se({left:e,right:t,typeName:Ue.ZodIntersection,...C(r)});class Ee extends A{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.array)return $(r,{code:v.invalid_type,expected:y.array,received:r.parsedType}),E;if(r.data.length<this._def.items.length)return $(r,{code:v.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),E;!this._def.rest&&r.data.length>this._def.items.length&&($(r,{code:v.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 z(r,e,r.path,t)):null}).filter(e=>!!e);return r.common.async?Promise.all(n).then(e=>S.mergeArray(t,e)):S.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new Ee({...this._def,rest:e})}}Ee.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ee({items:e,typeName:Ue.ZodTuple,rest:null,...C(t)})};class Te extends A{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!==y.map)return $(r,{code:v.invalid_type,expected:y.map,received:r.parsedType}),E;const n=this._def.keyType,s=this._def.valueType,a=[...r.data.entries()].map(([e,t],a)=>({key:n._parse(new z(r,e,r.path,[a,"key"])),value:s._parse(new z(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 E;"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 E;"dirty"!==n.status&&"dirty"!==s.status||t.dirty(),e.set(n.value,s.value)}return{status:t.value,value:e}}}}Te.create=(e,t,r)=>new Te({valueType:t,keyType:e,typeName:Ue.ZodMap,...C(r)});class xe extends A{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==y.set)return $(r,{code:v.invalid_type,expected:y.set,received:r.parsedType}),E;const n=this._def;null!==n.minSize&&r.data.size<n.minSize.value&&($(r,{code:v.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&&($(r,{code:v.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 E;"dirty"===n.status&&t.dirty(),r.add(n.value)}return{status:t.value,value:r}}const o=[...r.data.values()].map((e,t)=>s._parse(new z(r,e,r.path,t)));return r.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(e,t){return new xe({...this._def,minSize:{value:e,message:R.toString(t)}})}max(e,t){return new xe({...this._def,maxSize:{value:e,message:R.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}xe.create=(e,t)=>new xe({valueType:e,minSize:null,maxSize:null,typeName:Ue.ZodSet,...C(t)});class Ne extends A{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})}}Ne.create=(e,t)=>new Ne({getter:e,typeName:Ue.ZodLazy,...C(t)});let Oe=class extends A{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return $(t,{received:t.data,code:v.invalid_literal,expected:this._def.value}),E}return{status:"valid",value:e.data}}get value(){return this._def.value}};function Pe(e,t){return new Ie({values:e,typeName:Ue.ZodEnum,...C(t)})}Oe.create=(e,t)=>new Oe({value:e,typeName:Ue.ZodLiteral,...C(t)});let Ie=class e extends A{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),r=this._def.values;return $(t,{expected:m.joinValues(r),received:t.parsedType,code:v.invalid_type}),E}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 $(t,{received:t.data,code:v.invalid_enum_value,options:r}),E}return x(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})}};Ie.create=Pe;class Re extends A{_parse(e){const t=m.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==y.string&&r.parsedType!==y.number){const e=m.objectValues(t);return $(r,{expected:m.joinValues(e),received:r.parsedType,code:v.invalid_type}),E}if(this._cache||(this._cache=new Set(m.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=m.objectValues(t);return $(r,{received:r.data,code:v.invalid_enum_value,options:e}),E}return x(e.data)}get enum(){return this._def.values}}Re.create=(e,t)=>new Re({values:e,typeName:Ue.ZodNativeEnum,...C(t)});class ze extends A{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==y.promise&&!1===t.common.async)return $(t,{code:v.invalid_type,expected:y.promise,received:t.parsedType}),E;const r=t.parsedType===y.promise?t.data:Promise.resolve(t.data);return x(r.then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}}ze.create=(e,t)=>new ze({type:e,typeName:Ue.ZodPromise,...C(t)});class je extends A{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ue.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=>{$(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 E;const n=await this._def.schema._parseAsync({data:e,path:r.path,parent:r});return"aborted"===n.status?E:"dirty"===n.status||"dirty"===t.value?T(n.value):n});{if("aborted"===t.value)return E;const n=this._def.schema._parseSync({data:e,path:r.path,parent:r});return"aborted"===n.status?E:"dirty"===n.status||"dirty"===t.value?T(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?E:("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?E:("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(!P(e))return E;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=>P(e)?Promise.resolve(n.transform(e.value,s)).then(e=>({status:t.value,value:e})):E)}m.assertNever(n)}}je.create=(e,t,r)=>new je({schema:e,typeName:Ue.ZodEffects,effect:t,...C(r)}),je.createWithPreprocess=(e,t,r)=>new je({schema:t,effect:{type:"preprocess",transform:e},typeName:Ue.ZodEffects,...C(r)});let Ce=class extends A{_parse(e){return this._getType(e)===y.undefined?x(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ce.create=(e,t)=>new Ce({innerType:e,typeName:Ue.ZodOptional,...C(t)});let Ae=class extends A{_parse(e){return this._getType(e)===y.null?x(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ae.create=(e,t)=>new Ae({innerType:e,typeName:Ue.ZodNullable,...C(t)});let Me=class extends A{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===y.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Me.create=(e,t)=>new Me({innerType:e,typeName:Ue.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...C(t)});let Ze=class extends A{_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 I(n)?n.then(e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new w(r.common.issues)},input:r.data})})):{status:"valid",value:"valid"===n.status?n.value:this._def.catchValue({get error(){return new w(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}};Ze.create=(e,t)=>new Ze({innerType:e,typeName:Ue.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...C(t)});class De extends A{_parse(e){if(this._getType(e)!==y.nan){const t=this._getOrReturnCtx(e);return $(t,{code:v.invalid_type,expected:y.nan,received:t.parsedType}),E}return{status:"valid",value:e.data}}}De.create=e=>new De({typeName:Ue.ZodNaN,...C(e)});class Le extends A{_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 Fe extends A{_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?E:"dirty"===e.status?(t.dirty(),T(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?E:"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 Fe({in:e,out:t,typeName:Ue.ZodPipeline})}}let qe=class extends A{_parse(e){const t=this._def.innerType._parse(e),r=e=>(P(e)&&(e.value=Object.freeze(e.value)),e);return I(t)?t.then(e=>r(e)):r(t)}unwrap(){return this._def.innerType}};var Ue;qe.create=(e,t)=>new qe({innerType:e,typeName:Ue.ZodReadonly,...C(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"}(Ue||(Ue={})),ye.create,ve.create;const Ve=be.create;function He(e,t,r){function n(r,n){if(r._zod||Object.defineProperty(r,"_zod",{value:{def:n,constr:o,traits:new Set},enumerable:!1}),r._zod.traits.has(e))return;r._zod.traits.add(e),t(r,n);const s=o.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 o(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(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>!!(r?.Parent&&t instanceof r.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}ke.create,Se.create,Ee.create,Ie.create,ze.create,Ce.create,Ae.create;class Je extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ke extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const Be={};function Ge(e){return Be}function We(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 Xe(e,t){return"bigint"==typeof t?t.toString():t}function Ye(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Qe(e){return null==e}function et(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}const tt=Symbol("evaluating");function rt(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==tt)return void 0===n&&(n=tt,n=r()),n},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function nt(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function st(...e){const t={};for(const r of e){const e=Object.getOwnPropertyDescriptors(r);Object.assign(t,e)}return Object.defineProperties({},t)}function at(e){return JSON.stringify(e)}const ot="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function it(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const ct=Ye(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function dt(e){if(!1===it(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!==it(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function ut(e){return dt(e)?{...e}:Array.isArray(e)?[...e]:e}const lt=new Set(["string","number","symbol"]);function pt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ht(e,t,r){const n=new e._zod.constr(t??e._zod.def);return t&&!r?.parent||(n._zod.parent=e),n}function ft(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 mt={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 gt(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 yt(e,t){return t.map(t=>{var r;return(r=t).path??(r.path=[]),t.path.unshift(e),t})}function _t(e){return"string"==typeof e?e:e?.message}function vt(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const s=_t(e.inst?._zod.def?.error?.(e))??_t(t?.error?.(e))??_t(r.customError?.(e))??_t(r.localeError?.(e))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function wt(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function bt(...e){const[t,r,n]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:n}:{...t}}const kt=(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,Xe,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},$t=He("$ZodError",kt),St=He("$ZodError",kt,{Parent:Error}),Et=e=>(t,r,n,s)=>{const a=n?Object.assign(n,{async:!1}):{async:!1},o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise)throw new Je;if(o.issues.length){const t=new(s?.Err??e)(o.issues.map(e=>vt(e,a,Ge())));throw ot(t,s?.callee),t}return o.value},Tt=Et(St),xt=e=>async(t,r,n,s)=>{const a=n?Object.assign(n,{async:!0}):{async:!0};let o=t._zod.run({value:r,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){const t=new(s?.Err??e)(o.issues.map(e=>vt(e,a,Ge())));throw ot(t,s?.callee),t}return o.value},Nt=xt(St),Ot=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 Je;return a.issues.length?{success:!1,error:new(e??$t)(a.issues.map(e=>vt(e,s,Ge())))}:{success:!0,data:a.value}},Pt=Ot(St),It=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=>vt(e,s,Ge())))}:{success:!0,data:a.value}},Rt=It(St),zt=e=>(t,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Et(e)(t,r,s)},jt=e=>(t,r,n)=>Et(e)(t,r,n),Ct=e=>async(t,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return xt(e)(t,r,s)},At=e=>async(t,r,n)=>xt(e)(t,r,n),Mt=e=>(t,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return Ot(e)(t,r,s)},Zt=e=>(t,r,n)=>Ot(e)(t,r,n),Dt=e=>async(t,r,n)=>{const s=n?Object.assign(n,{direction:"backward"}):{direction:"backward"};return It(e)(t,r,s)},Lt=e=>async(t,r,n)=>It(e)(t,r,n),Ft=/^[cC][^\s-]{8,}$/,qt=/^[0-9a-z]+$/,Ut=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Vt=/^[0-9a-vA-V]{20}$/,Ht=/^[A-Za-z0-9]{27}$/,Jt=/^[a-zA-Z0-9_-]{21}$/,Kt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Bt=/^([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})$/,Gt=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)$/,Wt=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,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])$/,Yt=/^(([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}|:))$/,Qt=/^((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])$/,er=/^(([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])$/,tr=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,rr=/^[A-Za-z0-9_-]*$/,nr=/^\+[1-9]\d{6,14}$/,sr="(?:(?:\\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])))",ar=new RegExp(`^${sr}$`);function or(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 ir=/^-?\d+$/,cr=/^-?\d+(?:\.\d+)?$/,dr=/^(?:true|false)$/i,ur=/^null$/i,lr=/^[^A-Z]*$/,pr=/^[^a-z]*$/,hr=He("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),fr={number:"number",bigint:"bigint",object:"date"},mr=He("$ZodCheckLessThan",(e,t)=>{hr.init(e,t);const r=fr[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})}}),gr=He("$ZodCheckGreaterThan",(e,t)=>{hr.init(e,t);const r=fr[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})}}),yr=He("$ZodCheckMultipleOf",(e,t)=>{hr.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})}}),_r=He("$ZodCheckNumberFormat",(e,t)=>{hr.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[s,a]=mt[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=ir)}),e._zod.check=o=>{const i=o.value;if(r){if(!Number.isInteger(i))return void o.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:i,inst:e});if(!Number.isSafeInteger(i))return void(i>0?o.issues.push({input:i,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}):o.issues.push({input:i,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}))}i<s&&o.issues.push({origin:"number",input:i,code:"too_small",minimum:s,inclusive:!0,inst:e,continue:!t.abort}),i>a&&o.issues.push({origin:"number",input:i,code:"too_big",maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),vr=He("$ZodCheckMaxLength",(e,t)=>{var r;hr.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!Qe(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=wt(n);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),wr=He("$ZodCheckMinLength",(e,t)=>{var r;hr.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!Qe(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=wt(n);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),br=He("$ZodCheckLengthEquals",(e,t)=>{var r;hr.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!Qe(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=wt(n),o=s>t.length;r.issues.push({origin:a,...o?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),kr=He("$ZodCheckStringFormat",(e,t)=>{var r,n;hr.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=()=>{})}),$r=He("$ZodCheckRegex",(e,t)=>{kr.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})}}),Sr=He("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=lr),kr.init(e,t)}),Er=He("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=pr),kr.init(e,t)}),Tr=He("$ZodCheckIncludes",(e,t)=>{hr.init(e,t);const r=pt(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})}}),xr=He("$ZodCheckStartsWith",(e,t)=>{hr.init(e,t);const r=new RegExp(`^${pt(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})}}),Nr=He("$ZodCheckEndsWith",(e,t)=>{hr.init(e,t);const r=new RegExp(`.*${pt(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})}}),Or=He("$ZodCheckOverwrite",(e,t)=>{hr.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class Pr{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 Ir={major:4,minor:3,patch:6},Rr=He("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ir;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=gt(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,o=a._zod.check(e);if(o instanceof Promise&&!1===r?.async)throw new Je;if(n||o instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(s||(s=gt(e,t)))});else{if(e.issues.length===t)continue;s||(s=gt(e,t))}}return n?n.then(()=>e):e},r=(r,s,a)=>{if(gt(r))return r.aborted=!0,r;const o=t(s,n,a);if(o instanceof Promise){if(!1===a.async)throw new Je;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,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 o=e._zod.parse(s,a);if(o instanceof Promise){if(!1===a.async)throw new Je;return o.then(e=>t(e,n,a))}return t(o,n,a)}}rt(e,"~standard",()=>({validate:t=>{try{const r=Pt(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return Rt(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),zr=He("$ZodString",(e,t)=>{var r;Rr.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=He("$ZodStringFormat",(e,t)=>{kr.init(e,t),zr.init(e,t)}),Cr=He("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Bt),jr.init(e,t)}),Ar=He("$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=Gt(e))}else t.pattern??(t.pattern=Gt());jr.init(e,t)}),Mr=He("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Wt),jr.init(e,t)}),Zr=He("$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})}}}),Dr=He("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),jr.init(e,t)}),Lr=He("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Jt),jr.init(e,t)}),Fr=He("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Ft),jr.init(e,t)}),qr=He("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=qt),jr.init(e,t)}),Ur=He("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ut),jr.init(e,t)}),Vr=He("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Vt),jr.init(e,t)}),Hr=He("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Ht),jr.init(e,t)}),Jr=He("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=or({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(`^${sr}T(?:${n})$`)}(t)),jr.init(e,t)}),Kr=He("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ar),jr.init(e,t)}),Br=He("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${or(t)}$`)),jr.init(e,t)}),Gr=He("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Kt),jr.init(e,t)}),Wr=He("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Xt),jr.init(e,t),e._zod.bag.format="ipv4"}),Xr=He("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Yt),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})}}}),Yr=He("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Qt),jr.init(e,t)}),Qr=He("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=er),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 en(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const tn=He("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=tr),jr.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{en(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),rn=He("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=rr),jr.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{(function(e){if(!rr.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return en(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})}}),nn=He("$ZodE164",(e,t)=>{t.pattern??(t.pattern=nr),jr.init(e,t)}),sn=He("$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})}}),an=He("$ZodNumber",(e,t)=>{Rr.init(e,t),e._zod.pattern=e._zod.bag.pattern??cr,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}}),on=He("$ZodNumberFormat",(e,t)=>{_r.init(e,t),an.init(e,t)}),cn=He("$ZodBoolean",(e,t)=>{Rr.init(e,t),e._zod.pattern=dr,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}}),dn=He("$ZodNull",(e,t)=>{Rr.init(e,t),e._zod.pattern=ur,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}}),un=He("$ZodUnknown",(e,t)=>{Rr.init(e,t),e._zod.parse=e=>e}),ln=He("$ZodNever",(e,t)=>{Rr.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function pn(e,t,r){e.issues.length&&t.issues.push(...yt(r,e.issues)),t.value[r]=e.value}const hn=He("$ZodArray",(e,t)=>{Rr.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 o=s[e],i=t.element._zod.run({value:o,issues:[]},n);i instanceof Promise?a.push(i.then(t=>pn(t,r,e))):pn(i,r,e)}return a.length?Promise.all(a).then(()=>r):r}});function fn(e,t,r,n,s){if(e.issues.length){if(s&&!(r in n))return;t.issues.push(...yt(r,e.issues))}void 0===e.value?r in n&&(t.value[r]=void 0):t.value[r]=e.value}function mn(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 gn(e,t,r,n,s,a){const o=[],i=s.keySet,c=s.catchall._zod,d=c.def.type,u="optional"===c.optout;for(const s in t){if(i.has(s))continue;if("never"===d){o.push(s);continue}const a=c.run({value:t[s],issues:[]},n);a instanceof Promise?e.push(a.then(e=>fn(e,r,s,t,u))):fn(a,r,s,t,u)}return o.length&&r.issues.push({code:"unrecognized_keys",keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>r):r}const yn=He("$ZodObject",(e,t)=>{Rr.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=Ye(()=>mn(t));rt(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=it,a=t.catchall;let o;e._zod.parse=(t,r)=>{o??(o=n.value);const i=t.value;if(!s(i))return t.issues.push({expected:"object",code:"invalid_type",input:i,inst:e}),t;t.value={};const c=[],d=o.shape;for(const e of o.keys){const n=d[e],s="optional"===n._zod.optout,a=n._zod.run({value:i[e],issues:[]},r);a instanceof Promise?c.push(a.then(r=>fn(r,t,e,i,s))):fn(a,t,e,i,s)}return a?gn(c,i,t,r,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),_n=He("$ZodObjectJIT",(e,t)=>{yn.init(e,t);const r=e._zod.parse,n=Ye(()=>mn(t));let s;const a=it,o=!Be.jitless,i=o&&ct.value,c=t.catchall;let d;e._zod.parse=(u,l)=>{d??(d=n.value);const p=u.value;return a(p)?o&&i&&!1===l?.async&&!0!==l.jitless?(s||(s=(e=>{const t=new Pr(["shape","payload","ctx"]),r=n.value,s=e=>{const t=at(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const a=Object.create(null);let o=0;for(const e of r.keys)a[e]="key_"+o++;t.write("const newResult = {};");for(const n of r.keys){const r=a[n],o=at(n),i=e[n],c="optional"===i?._zod?.optout;t.write(`const ${r} = ${s(n)};`),c?t.write(`\n if (${r}.issues.length) {\n if (${o} in input) {\n payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${o}, ...iss.path] : [${o}]\n })));\n }\n }\n \n if (${r}.value === undefined) {\n if (${o} in input) {\n newResult[${o}] = undefined;\n }\n } else {\n newResult[${o}] = ${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 ? [${o}, ...iss.path] : [${o}]\n })));\n }\n \n if (${r}.value === undefined) {\n if (${o} in input) {\n newResult[${o}] = undefined;\n }\n } else {\n newResult[${o}] = ${r}.value;\n }\n \n `)}t.write("payload.value = newResult;"),t.write("return payload;");const i=t.compile();return(t,r)=>i(e,t,r)})(t.shape)),u=s(u,l),c?gn([],p,u,l,d,e):u):r(u,l):(u.issues.push({expected:"object",code:"invalid_type",input:p,inst:e}),u)}});function vn(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=>!gt(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=>vt(e,n,Ge())))}),t)}const wn=He("$ZodUnion",(e,t)=>{Rr.init(e,t),rt(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),rt(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),rt(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),rt(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=>et(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 o=!1;const i=[];for(const e of t.options){const t=e._zod.run({value:s.value,issues:[]},a);if(t instanceof Promise)i.push(t),o=!0;else{if(0===t.issues.length)return t;i.push(t)}}return o?Promise.all(i).then(t=>vn(t,s,e,a)):vn(i,s,e,a)}}),bn=He("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,wn.init(e,t);const r=e._zod.parse;rt(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=Ye(()=>{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 o=s.value;if(!it(o))return s.issues.push({code:"invalid_type",expected:"object",input:o,inst:e}),s;const i=n.value.get(o?.[t.discriminator]);return i?i._zod.run(s,a):t.unionFallback?r(s,a):(s.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),s)}}),kn=He("$ZodIntersection",(e,t)=>{Rr.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])=>Sn(e,t,r)):Sn(e,s,a)}});function $n(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(dt(e)&&dt(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=$n(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=$n(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 Sn(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}),gt(e))return e;const o=$n(t.value,r.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const En=He("$ZodRecord",(e,t)=>{Rr.init(e,t),e._zod.parse=(r,n)=>{const s=r.value;if(!dt(s))return r.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),r;const a=[],o=t.keyType._zod.values;if(o){r.value={};const i=new Set;for(const e of o)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){i.add("number"==typeof e?e.toString():e);const o=t.valueType._zod.run({value:s[e],issues:[]},n);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&r.issues.push(...yt(e,t.issues)),r.value[e]=t.value})):(o.issues.length&&r.issues.push(...yt(e,o.issues)),r.value[e]=o.value)}let c;for(const e in s)i.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 o of Reflect.ownKeys(s)){if("__proto__"===o)continue;let i=t.keyType._zod.run({value:o,issues:[]},n);if(i instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if("string"==typeof o&&cr.test(o)&&i.issues.length){const e=t.keyType._zod.run({value:Number(o),issues:[]},n);if(e instanceof Promise)throw new Error("Async schemas not supported in object keys currently");0===e.issues.length&&(i=e)}if(i.issues.length){"loose"===t.mode?r.value[o]=s[o]:r.issues.push({code:"invalid_key",origin:"record",issues:i.issues.map(e=>vt(e,n,Ge())),input:o,path:[o],inst:e});continue}const c=t.valueType._zod.run({value:s[o],issues:[]},n);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&r.issues.push(...yt(o,e.issues)),r.value[i.value]=e.value})):(c.issues.length&&r.issues.push(...yt(o,c.issues)),r.value[i.value]=c.value)}}return a.length?Promise.all(a).then(()=>r):r}}),Tn=He("$ZodEnum",(e,t)=>{Rr.init(e,t);const r=We(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(e=>lt.has(typeof e)).map(e=>"string"==typeof e?pt(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}}),xn=He("$ZodLiteral",(e,t)=>{if(Rr.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?pt(e):e?pt(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}}),Nn=He("$ZodTransform",(e,t)=>{Rr.init(e,t),e._zod.parse=(r,n)=>{if("backward"===n.direction)throw new Ke(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 Je;return r.value=s,r}});function On(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const Pn=He("$ZodOptional",(e,t)=>{Rr.init(e,t),e._zod.optin="optional",e._zod.optout="optional",rt(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),rt(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${et(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=>On(t,e.value)):On(n,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,r)}}),In=He("$ZodExactOptional",(e,t)=>{Pn.init(e,t),rt(e._zod,"values",()=>t.innerType._zod.values),rt(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),Rn=He("$ZodNullable",(e,t)=>{Rr.init(e,t),rt(e._zod,"optin",()=>t.innerType._zod.optin),rt(e._zod,"optout",()=>t.innerType._zod.optout),rt(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${et(e.source)}|null)$`):void 0}),rt(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)}),zn=He("$ZodDefault",(e,t)=>{Rr.init(e,t),e._zod.optin="optional",rt(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 Cn=He("$ZodPrefault",(e,t)=>{Rr.init(e,t),e._zod.optin="optional",rt(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))}),An=He("$ZodNonOptional",(e,t)=>{Rr.init(e,t),rt(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=>Mn(t,e)):Mn(s,e)}});function Mn(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 Zn=He("$ZodCatch",(e,t)=>{Rr.init(e,t),rt(e._zod,"optin",()=>t.innerType._zod.optin),rt(e._zod,"optout",()=>t.innerType._zod.optout),rt(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=>vt(e,r,Ge()))},input:e.value}),e.issues=[]),e)):(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>vt(e,r,Ge()))},input:e.value}),e.issues=[]),e)}}),Dn=He("$ZodPipe",(e,t)=>{Rr.init(e,t),rt(e._zod,"values",()=>t.in._zod.values),rt(e._zod,"optin",()=>t.in._zod.optin),rt(e._zod,"optout",()=>t.out._zod.optout),rt(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=>Ln(e,t.in,r)):Ln(n,t.in,r)}const n=t.in._zod.run(e,r);return n instanceof Promise?n.then(e=>Ln(e,t.out,r)):Ln(n,t.out,r)}});function Ln(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const Fn=He("$ZodReadonly",(e,t)=>{Rr.init(e,t),rt(e._zod,"propValues",()=>t.innerType._zod.propValues),rt(e._zod,"values",()=>t.innerType._zod.values),rt(e._zod,"optin",()=>t.innerType?._zod?.optin),rt(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(qn):qn(n)}});function qn(e){return e.value=Object.freeze(e.value),e}const Un=He("$ZodCustom",(e,t)=>{hr.init(e,t),Rr.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=>Vn(t,r,n,e));Vn(s,r,n,e)}});function Vn(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(bt(e))}}var Hn;(Hn=globalThis).__zod_globalRegistry??(Hn.__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 Jn=globalThis.__zod_globalRegistry;function Kn(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...ft(t)})}function Bn(e,t){return new mr({check:"less_than",...ft(t),value:e,inclusive:!1})}function Gn(e,t){return new mr({check:"less_than",...ft(t),value:e,inclusive:!0})}function Wn(e,t){return new gr({check:"greater_than",...ft(t),value:e,inclusive:!1})}function Xn(e,t){return new gr({check:"greater_than",...ft(t),value:e,inclusive:!0})}function Yn(e,t){return new yr({check:"multiple_of",...ft(t),value:e})}function Qn(e,t){return new vr({check:"max_length",...ft(t),maximum:e})}function es(e,t){return new wr({check:"min_length",...ft(t),minimum:e})}function ts(e,t){return new br({check:"length_equals",...ft(t),length:e})}function rs(e){return new Or({check:"overwrite",tx:e})}function ns(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??Jn,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 ss(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 o={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,o);const i=e._zod.toJSONSchema?.();if(i)o.schema=i;else{const n={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,n);else{const r=o.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&&(o.ref||(o.ref=a),ss(a,t,n),t.seen.get(a).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),"input"===t.io&&is(e)&&(delete o.schema.examples,delete o.schema.default),"input"===t.io&&o.schema._prefault&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function as(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 o=n.schema;for(const e in o)delete o[e];o.$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 os(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},o=r.ref;if(r.ref=null,o){n(o);const r=e.seen.get(o),i=r.schema;if(!i.$ref||"draft-07"!==e.target&&"draft-04"!==e.target&&"openapi-3.0"!==e.target?Object.assign(s,i):(s.allOf=s.allOf??[],s.allOf.push(i)),Object.assign(s,a),t._zod.parent===o)for(const e in s)"$ref"!==e&&"allOf"!==e&&(e in a||delete s[e]);if(i.$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 i=t._zod.parent;if(i&&i!==o){n(i);const t=e.seen.get(i);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:cs(t,"input",e.processors),output:cs(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch(e){throw new Error("Error converting schema to JSON.")}}function is(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 is(n.element,r);if("set"===n.type)return is(n.valueType,r);if("lazy"===n.type)return is(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 is(n.innerType,r);if("intersection"===n.type)return is(n.left,r)||is(n.right,r);if("record"===n.type||"map"===n.type)return is(n.keyType,r)||is(n.valueType,r);if("pipe"===n.type)return is(n.in,r)||is(n.out,r);if("object"===n.type){for(const e in n.shape)if(is(n.shape[e],r))return!0;return!1}if("union"===n.type){for(const e of n.options)if(is(e,r))return!0;return!1}if("tuple"===n.type){for(const e of n.items)if(is(e,r))return!0;return!(!n.rest||!is(n.rest,r))}return!1}const cs=(e,t,r={})=>n=>{const{libraryOptions:s,target:a}=n??{},o=ns({...s??{},target:a,io:t,processors:r});return ss(e,o),as(o,e),os(o,e)},ds={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},us=(e,t,r,n)=>{const s=r;s.type="string";const{minimum:a,maximum:o,format:i,patterns:c,contentEncoding:d}=e._zod.bag;if("number"==typeof a&&(s.minLength=a),"number"==typeof o&&(s.maxLength=o),i&&(s.format=ds[i]??i,""===s.format&&delete s.format,"time"===i&&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}))])}},ls=(e,t,r,n)=>{const s=r,{minimum:a,maximum:o,format:i,multipleOf:c,exclusiveMaximum:d,exclusiveMinimum:u}=e._zod.bag;"string"==typeof i&&i.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 o&&(s.maximum=o,"number"==typeof d&&"draft-04"!==t.target&&(d<=o?delete s.maximum:delete s.exclusiveMaximum)),"number"==typeof c&&(s.multipleOf=c)},ps=(e,t,r,n)=>{r.type="boolean"},hs=(e,t,r,n)=>{"openapi-3.0"===t.target?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},fs=(e,t,r,n)=>{r.not={}},ms=(e,t,r,n)=>{const s=We(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},gs=(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},ys=(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Custom types cannot be represented in JSON Schema")},_s=(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Transforms cannot be represented in JSON Schema")},vs=(e,t,r,n)=>{const s=r,a=e._zod.def,{minimum:o,maximum:i}=e._zod.bag;"number"==typeof o&&(s.minItems=o),"number"==typeof i&&(s.maxItems=i),s.type="array",s.items=ss(a.element,t,{...n,path:[...n.path,"items"]})},ws=(e,t,r,n)=>{const s=r,a=e._zod.def;s.type="object",s.properties={};const o=a.shape;for(const e in o)s.properties[e]=ss(o[e],t,{...n,path:[...n.path,"properties",e]});const i=new Set(Object.keys(o)),c=new Set([...i].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=ss(a.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):"output"===t.io&&(s.additionalProperties=!1)},bs=(e,t,r,n)=>{const s=e._zod.def,a=!1===s.inclusive,o=s.options.map((e,r)=>ss(e,t,{...n,path:[...n.path,a?"oneOf":"anyOf",r]}));a?r.oneOf=o:r.anyOf=o},ks=(e,t,r,n)=>{const s=e._zod.def,a=ss(s.left,t,{...n,path:[...n.path,"allOf",0]}),o=ss(s.right,t,{...n,path:[...n.path,"allOf",1]}),i=e=>"allOf"in e&&1===Object.keys(e).length,c=[...i(a)?a.allOf:[a],...i(o)?o.allOf:[o]];r.allOf=c},$s=(e,t,r,n)=>{const s=r,a=e._zod.def;s.type="object";const o=a.keyType,i=o._zod.bag,c=i?.patterns;if("loose"===a.mode&&c&&c.size>0){const e=ss(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=ss(a.keyType,t,{...n,path:[...n.path,"propertyNames"]})),s.additionalProperties=ss(a.valueType,t,{...n,path:[...n.path,"additionalProperties"]});const d=o._zod.values;if(d){const e=[...d].filter(e=>"string"==typeof e||"number"==typeof e);e.length>0&&(s.required=e)}},Ss=(e,t,r,n)=>{const s=e._zod.def,a=ss(s.innerType,t,n),o=t.seen.get(e);"openapi-3.0"===t.target?(o.ref=s.innerType,r.nullable=!0):r.anyOf=[a,{type:"null"}]},Es=(e,t,r,n)=>{const s=e._zod.def;ss(s.innerType,t,n),t.seen.get(e).ref=s.innerType},Ts=(e,t,r,n)=>{const s=e._zod.def;ss(s.innerType,t,n),t.seen.get(e).ref=s.innerType,r.default=JSON.parse(JSON.stringify(s.defaultValue))},xs=(e,t,r,n)=>{const s=e._zod.def;ss(s.innerType,t,n),t.seen.get(e).ref=s.innerType,"input"===t.io&&(r._prefault=JSON.parse(JSON.stringify(s.defaultValue)))},Ns=(e,t,r,n)=>{const s=e._zod.def;let a;ss(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},Os=(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;ss(a,t,n),t.seen.get(e).ref=a},Ps=(e,t,r,n)=>{const s=e._zod.def;ss(s.innerType,t,n),t.seen.get(e).ref=s.innerType,r.readOnly=!0},Is=(e,t,r,n)=>{const s=e._zod.def;ss(s.innerType,t,n),t.seen.get(e).ref=s.innerType},Rs={string:us,number:ls,boolean:ps,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:hs,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:fs,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:ms,literal:gs,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:o,maximum:i,mime:c}=e._zod.bag;void 0!==o&&(a.minLength=o),void 0!==i&&(a.maxLength=i),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:ys,function:(e,t,r,n)=>{if("throw"===t.unrepresentable)throw new Error("Function types cannot be represented in JSON Schema")},transform:_s,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:vs,object:ws,union:bs,intersection:ks,tuple:(e,t,r,n)=>{const s=r,a=e._zod.def;s.type="array";const o="draft-2020-12"===t.target?"prefixItems":"items",i="draft-2020-12"===t.target||"openapi-3.0"===t.target?"items":"additionalItems",c=a.items.map((e,r)=>ss(e,t,{...n,path:[...n.path,o,r]})),d=a.rest?ss(a.rest,t,{...n,path:[...n.path,i,..."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:$s,nullable:Ss,nonoptional:Es,default:Ts,prefault:xs,catch:Ns,pipe:Os,readonly:Ps,promise:(e,t,r,n)=>{const s=e._zod.def;ss(s.innerType,t,n),t.seen.get(e).ref=s.innerType},optional:Is,lazy:(e,t,r,n)=>{const s=e._zod.innerType;ss(s,t,n),t.seen.get(e).ref=s}},zs=He("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");Rr.init(e,t),e.def=t,e.type=t.type,e.parse=(t,r)=>Tt(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>Pt(e,t,r),e.parseAsync=async(t,r)=>Nt(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>Rt(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)=>ht(e,t,r),e.brand=()=>e,e.register=(t,r)=>(t.add(e,r),e),e.apply=t=>t(e)}),js=He("ZodMiniObject",(e,t)=>{yn.init(e,t),zs.init(e,t),rt(e,"shape",()=>t.shape)});function Cs(e,t){const r={type:"object",shape:e??{},...ft(t)};return new js(r)}function As(e){return!!e._zod}function Ms(e){const t=Object.values(e);if(0===t.length)return Cs({});const r=t.every(As),n=t.every(e=>!As(e));if(r)return Cs(e);if(n)return Ve(e);throw new Error("Mixed Zod versions detected in object shape.")}function Zs(e,t){return As(e)?Pt(e,t):e.safeParse(t)}async function Ds(e,t){if(As(e))return await Rt(e,t);const r=e;return await r.safeParseAsync(t)}function Ls(e){if(!e)return;let t;if(As(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 Fs(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 Ms(e)}}if(As(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 qs(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 Us(e){if(As(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 Vs=He("ZodISODateTime",(e,t)=>{Jr.init(e,t),pa.init(e,t)});function Hs(e){return function(e,t){return new Vs({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...ft(t)})}(0,e)}const Js=He("ZodISODate",(e,t)=>{Kr.init(e,t),pa.init(e,t)});const Ks=He("ZodISOTime",(e,t)=>{Br.init(e,t),pa.init(e,t)});const Bs=He("ZodISODuration",(e,t)=>{Gr.init(e,t),pa.init(e,t)});const Gs=He("ZodError",(e,t)=>{$t.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,Xe,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,Xe,2)}},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),Ws=Et(Gs),Xs=xt(Gs),Ys=Ot(Gs),Qs=It(Gs),ea=zt(Gs),ta=jt(Gs),ra=Ct(Gs),na=At(Gs),sa=Mt(Gs),aa=Zt(Gs),oa=Dt(Gs),ia=Lt(Gs),ca=He("ZodType",(e,t)=>(Rr.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:cs(e,"input"),output:cs(e,"output")}}),e.toJSONSchema=((e,t={})=>r=>{const n=ns({...r,processors:t});return ss(e,n),as(n,e),os(n,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(st(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)=>ht(e,t,r),e.brand=()=>e,e.register=(t,r)=>(t.add(e,r),e),e.parse=(t,r)=>Ws(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>Ys(e,t,r),e.parseAsync=async(t,r)=>Xs(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>Qs(e,t,r),e.spa=e.safeParseAsync,e.encode=(t,r)=>ea(e,t,r),e.decode=(t,r)=>ta(e,t,r),e.encodeAsync=async(t,r)=>ra(e,t,r),e.decodeAsync=async(t,r)=>na(e,t,r),e.safeEncode=(t,r)=>sa(e,t,r),e.safeDecode=(t,r)=>aa(e,t,r),e.safeEncodeAsync=async(t,r)=>oa(e,t,r),e.safeDecodeAsync=async(t,r)=>ia(e,t,r),e.refine=(t,r)=>e.check(function(e,t={}){return function(e,t,r){return new bo({type:"custom",check:"custom",fn:t,...ft(r)})}(0,e,t)}(t,r)),e.superRefine=t=>e.check(function(e){const t=function(e){const t=new hr({check:"custom",...ft(void 0)});return t._zod.check=e,t}(r=>(r.addIssue=e=>{if("string"==typeof e)r.issues.push(bt(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(bt(n))}},e(r.value,r)));return t}(t)),e.overwrite=t=>e.check(rs(t)),e.optional=()=>uo(e),e.exactOptional=()=>new lo({type:"optional",innerType:e}),e.nullable=()=>ho(e),e.nullish=()=>uo(ho(e)),e.nonoptional=t=>function(e,t){return new go({type:"nonoptional",innerType:e,...ft(t)})}(e,t),e.array=()=>Va(e),e.or=t=>Ga([e,t]),e.and=t=>Qa(e,t),e.transform=t=>vo(e,io(t)),e.default=t=>{return r=t,new fo({type:"default",innerType:e,get defaultValue(){return"function"==typeof r?r():ut(r)}});var r},e.prefault=t=>{return r=t,new mo({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof r?r():ut(r)}});var r},e.catch=t=>{return new yo({type:"catch",innerType:e,catchValue:"function"==typeof(r=t)?r:()=>r});var r},e.pipe=t=>vo(e,t),e.readonly=()=>new wo({type:"readonly",innerType:e}),e.describe=t=>{const r=e.clone();return Jn.add(r,{description:t}),r},Object.defineProperty(e,"description",{get:()=>Jn.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return Jn.get(e);const r=e.clone();return Jn.add(r,t[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),da=He("_ZodString",(e,t)=>{zr.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>us(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 $r({check:"string_format",format:"regex",...ft(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new Tr({check:"string_format",format:"includes",...ft(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new xr({check:"string_format",format:"starts_with",...ft(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Nr({check:"string_format",format:"ends_with",...ft(t),suffix:e})}(...t)),e.min=(...t)=>e.check(es(...t)),e.max=(...t)=>e.check(Qn(...t)),e.length=(...t)=>e.check(ts(...t)),e.nonempty=(...t)=>e.check(es(1,...t)),e.lowercase=t=>e.check(function(e){return new Sr({check:"string_format",format:"lowercase",...ft(e)})}(t)),e.uppercase=t=>e.check(function(e){return new Er({check:"string_format",format:"uppercase",...ft(e)})}(t)),e.trim=()=>e.check(rs(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return rs(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(rs(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(rs(e=>e.toUpperCase())),e.slugify=()=>e.check(rs(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}),ua=He("ZodString",(e,t)=>{zr.init(e,t),da.init(e,t),e.email=t=>e.check(function(e,t){return new ha({type:"string",format:"email",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.url=t=>e.check(function(e,t){return new ga({type:"string",format:"url",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.jwt=t=>e.check(function(e,t){return new Ia({type:"string",format:"jwt",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.emoji=t=>e.check(function(e,t){return new ya({type:"string",format:"emoji",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.guid=t=>e.check(Kn(fa,t)),e.uuid=t=>e.check(function(e,t){return new ma({type:"string",format:"uuid",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.uuidv4=t=>e.check(function(e,t){return new ma({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...ft(t)})}(0,t)),e.uuidv6=t=>e.check(function(e,t){return new ma({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...ft(t)})}(0,t)),e.uuidv7=t=>e.check(function(e,t){return new ma({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...ft(t)})}(0,t)),e.nanoid=t=>e.check(function(e,t){return new _a({type:"string",format:"nanoid",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.guid=t=>e.check(Kn(fa,t)),e.cuid=t=>e.check(function(e,t){return new va({type:"string",format:"cuid",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.cuid2=t=>e.check(function(e,t){return new wa({type:"string",format:"cuid2",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.ulid=t=>e.check(function(e,t){return new ba({type:"string",format:"ulid",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.base64=t=>e.check(function(e,t){return new Na({type:"string",format:"base64",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.base64url=t=>e.check(function(e,t){return new Oa({type:"string",format:"base64url",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.xid=t=>e.check(function(e,t){return new ka({type:"string",format:"xid",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.ksuid=t=>e.check(function(e,t){return new $a({type:"string",format:"ksuid",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.ipv4=t=>e.check(function(e,t){return new Sa({type:"string",format:"ipv4",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.ipv6=t=>e.check(function(e,t){return new Ea({type:"string",format:"ipv6",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.cidrv4=t=>e.check(function(e,t){return new Ta({type:"string",format:"cidrv4",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.cidrv6=t=>e.check(function(e,t){return new xa({type:"string",format:"cidrv6",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.e164=t=>e.check(function(e,t){return new Pa({type:"string",format:"e164",check:"string_format",abort:!1,...ft(t)})}(0,t)),e.datetime=t=>e.check(Hs(t)),e.date=t=>e.check(function(e){return function(e,t){return new Js({type:"string",format:"date",check:"string_format",...ft(t)})}(0,e)}(t)),e.time=t=>e.check(function(e){return function(e,t){return new Ks({type:"string",format:"time",check:"string_format",precision:null,...ft(t)})}(0,e)}(t)),e.duration=t=>e.check(function(e){return function(e,t){return new Bs({type:"string",format:"duration",check:"string_format",...ft(t)})}(0,e)}(t))});function la(e){return function(e,t){return new ua({type:"string",...ft(t)})}(0,e)}const pa=He("ZodStringFormat",(e,t)=>{jr.init(e,t),da.init(e,t)}),ha=He("ZodEmail",(e,t)=>{Mr.init(e,t),pa.init(e,t)}),fa=He("ZodGUID",(e,t)=>{Cr.init(e,t),pa.init(e,t)}),ma=He("ZodUUID",(e,t)=>{Ar.init(e,t),pa.init(e,t)}),ga=He("ZodURL",(e,t)=>{Zr.init(e,t),pa.init(e,t)}),ya=He("ZodEmoji",(e,t)=>{Dr.init(e,t),pa.init(e,t)}),_a=He("ZodNanoID",(e,t)=>{Lr.init(e,t),pa.init(e,t)}),va=He("ZodCUID",(e,t)=>{Fr.init(e,t),pa.init(e,t)}),wa=He("ZodCUID2",(e,t)=>{qr.init(e,t),pa.init(e,t)}),ba=He("ZodULID",(e,t)=>{Ur.init(e,t),pa.init(e,t)}),ka=He("ZodXID",(e,t)=>{Vr.init(e,t),pa.init(e,t)}),$a=He("ZodKSUID",(e,t)=>{Hr.init(e,t),pa.init(e,t)}),Sa=He("ZodIPv4",(e,t)=>{Wr.init(e,t),pa.init(e,t)}),Ea=He("ZodIPv6",(e,t)=>{Xr.init(e,t),pa.init(e,t)}),Ta=He("ZodCIDRv4",(e,t)=>{Yr.init(e,t),pa.init(e,t)}),xa=He("ZodCIDRv6",(e,t)=>{Qr.init(e,t),pa.init(e,t)}),Na=He("ZodBase64",(e,t)=>{tn.init(e,t),pa.init(e,t)}),Oa=He("ZodBase64URL",(e,t)=>{rn.init(e,t),pa.init(e,t)}),Pa=He("ZodE164",(e,t)=>{nn.init(e,t),pa.init(e,t)}),Ia=He("ZodJWT",(e,t)=>{sn.init(e,t),pa.init(e,t)}),Ra=He("ZodNumber",(e,t)=>{an.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ls(e,t,r),e.gt=(t,r)=>e.check(Wn(t,r)),e.gte=(t,r)=>e.check(Xn(t,r)),e.min=(t,r)=>e.check(Xn(t,r)),e.lt=(t,r)=>e.check(Bn(t,r)),e.lte=(t,r)=>e.check(Gn(t,r)),e.max=(t,r)=>e.check(Gn(t,r)),e.int=t=>e.check(Ca(t)),e.safe=t=>e.check(Ca(t)),e.positive=t=>e.check(Wn(0,t)),e.nonnegative=t=>e.check(Xn(0,t)),e.negative=t=>e.check(Bn(0,t)),e.nonpositive=t=>e.check(Gn(0,t)),e.multipleOf=(t,r)=>e.check(Yn(t,r)),e.step=(t,r)=>e.check(Yn(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 za(e){return function(e,t){return new Ra({type:"number",checks:[],...ft(t)})}(0,e)}const ja=He("ZodNumberFormat",(e,t)=>{on.init(e,t),Ra.init(e,t)});function Ca(e){return function(e,t){return new ja({type:"number",check:"number_format",abort:!1,format:"safeint",...ft(t)})}(0,e)}const Aa=He("ZodBoolean",(e,t)=>{cn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(e,t,r)=>ps(0,0,t)});function Ma(e){return function(e,t){return new Aa({type:"boolean",...ft(t)})}(0,e)}const Za=He("ZodNull",(e,t)=>{dn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(e,t,r)=>hs(0,e,t)});function Da(e){return function(e,t){return new Za({type:"null",...ft(t)})}(0,e)}const La=He("ZodUnknown",(e,t)=>{un.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(e,t,r)=>{}});function Fa(){return new La({type:"unknown"})}const qa=He("ZodNever",(e,t)=>{ln.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(e,t,r)=>fs(0,0,t)});const Ua=He("ZodArray",(e,t)=>{hn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>vs(e,t,r,n),e.element=t.element,e.min=(t,r)=>e.check(es(t,r)),e.nonempty=t=>e.check(es(1,t)),e.max=(t,r)=>e.check(Qn(t,r)),e.length=(t,r)=>e.check(ts(t,r)),e.unwrap=()=>e.element});function Va(e,t){return function(e,t,r){return new Ua({type:"array",element:t,...ft(r)})}(0,e,t)}const Ha=He("ZodObject",(e,t)=>{_n.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ws(e,t,r,n),rt(e,"shape",()=>t.shape),e.keyof=()=>no(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Fa()}),e.loose=()=>e.clone({...e._zod.def,catchall:Fa()}),e.strict=()=>{return e.clone({...e._zod.def,catchall:function(e,t){return new qa({type:"never",...ft(t)})}(0,t)});var t},e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!dt(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=st(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return nt(this,"shape",r),r}});return ht(e,n)}(e,t),e.safeExtend=t=>function(e,t){if(!dt(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r=st(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t};return nt(this,"shape",r),r}});return ht(e,r)}(e,t),e.merge=t=>function(e,t){const r=st(e._zod.def,{get shape(){const r={...e._zod.def.shape,...t._zod.def.shape};return nt(this,"shape",r),r},get catchall(){return t._zod.def.catchall},checks:[]});return ht(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 ht(e,st(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 nt(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=st(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 nt(this,"shape",n),n},checks:[]});return ht(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=st(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 nt(this,"shape",s),s},checks:[]});return ht(t,s)}(co,e,t[0]),e.required=(...t)=>function(e,t,r){const n=st(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 nt(this,"shape",s),s}});return ht(t,n)}(go,e,t[0])});function Ja(e,t){const r={type:"object",shape:e??{},...ft(t)};return new Ha(r)}function Ka(e,t){return new Ha({type:"object",shape:e,catchall:Fa(),...ft(t)})}const Ba=He("ZodUnion",(e,t)=>{wn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>bs(e,t,r,n),e.options=t.options});function Ga(e,t){return new Ba({type:"union",options:e,...ft(t)})}const Wa=He("ZodDiscriminatedUnion",(e,t)=>{Ba.init(e,t),bn.init(e,t)});function Xa(e,t,r){return new Wa({type:"union",options:t,discriminator:e,...ft(r)})}const Ya=He("ZodIntersection",(e,t)=>{kn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ks(e,t,r,n)});function Qa(e,t){return new Ya({type:"intersection",left:e,right:t})}const eo=He("ZodRecord",(e,t)=>{En.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>$s(e,t,r,n),e.keyType=t.keyType,e.valueType=t.valueType});function to(e,t,r){return new eo({type:"record",keyType:e,valueType:t,...ft(r)})}const ro=He("ZodEnum",(e,t)=>{Tn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>ms(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 ro({...t,checks:[],...ft(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 ro({...t,checks:[],...ft(n),entries:s})}});function no(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new ro({type:"enum",entries:r,...ft(t)})}const so=He("ZodLiteral",(e,t)=>{xn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>gs(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 ao(e,t){return new so({type:"literal",values:Array.isArray(e)?e:[e],...ft(t)})}const oo=He("ZodTransform",(e,t)=>{Nn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(e,t,r)=>_s(0,e),e._zod.parse=(r,n)=>{if("backward"===n.direction)throw new Ke(e.constructor.name);r.addIssue=n=>{if("string"==typeof n)r.issues.push(bt(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(bt(t))}};const s=t.transform(r.value,r);return s instanceof Promise?s.then(e=>(r.value=e,r)):(r.value=s,r)}});function io(e){return new oo({type:"transform",transform:e})}const co=He("ZodOptional",(e,t)=>{Pn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Is(e,t,0,n),e.unwrap=()=>e._zod.def.innerType});function uo(e){return new co({type:"optional",innerType:e})}const lo=He("ZodExactOptional",(e,t)=>{In.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Is(e,t,0,n),e.unwrap=()=>e._zod.def.innerType}),po=He("ZodNullable",(e,t)=>{Rn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Ss(e,t,r,n),e.unwrap=()=>e._zod.def.innerType});function ho(e){return new po({type:"nullable",innerType:e})}const fo=He("ZodDefault",(e,t)=>{zn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Ts(e,t,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),mo=He("ZodPrefault",(e,t)=>{Cn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>xs(e,t,r,n),e.unwrap=()=>e._zod.def.innerType}),go=He("ZodNonOptional",(e,t)=>{An.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Es(e,t,0,n),e.unwrap=()=>e._zod.def.innerType}),yo=He("ZodCatch",(e,t)=>{Zn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Ns(e,t,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),_o=He("ZodPipe",(e,t)=>{Dn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Os(e,t,0,n),e.in=t.in,e.out=t.out});function vo(e,t){return new _o({type:"pipe",in:e,out:t})}const wo=He("ZodReadonly",(e,t)=>{Fn.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(t,r,n)=>Ps(e,t,r,n),e.unwrap=()=>e._zod.def.innerType}),bo=He("ZodCustom",(e,t)=>{Un.init(e,t),ca.init(e,t),e._zod.processJSONSchema=(e,t,r)=>ys(0,e)});function ko(e,t){return vo(io(e),t)}const $o="2025-11-25",So=[$o,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Eo="io.modelcontextprotocol/related-task",To="2.0",xo=function(e,t,r){const n=ft(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})}(bo,0,void 0);const No=Ga([la(),za().int()]),Oo=la();Ka({ttl:Ga([za(),Da()]).optional(),pollInterval:za().optional()});const Po=Ja({ttl:za().optional()}),Io=Ja({taskId:la()}),Ro=Ka({progressToken:No.optional(),[Eo]:Io.optional()}),zo=Ja({_meta:Ro.optional()}),jo=zo.extend({task:Po.optional()}),Co=Ja({method:la(),params:zo.loose().optional()}),Ao=Ja({_meta:Ro.optional()}),Mo=Ja({method:la(),params:Ao.loose().optional()}),Zo=Ka({_meta:Ro.optional()}),Do=Ga([la(),za().int()]),Lo=Ja({jsonrpc:ao(To),id:Do,...Co.shape}).strict(),Fo=e=>Lo.safeParse(e).success,qo=Ja({jsonrpc:ao(To),...Mo.shape}).strict(),Uo=Ja({jsonrpc:ao(To),id:Do,result:Zo}).strict(),Vo=e=>Uo.safeParse(e).success;var Ho;!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"}(Ho||(Ho={}));const Jo=Ja({jsonrpc:ao(To),id:Do.optional(),error:Ja({code:za().int(),message:la(),data:Fa().optional()})}).strict(),Ko=Ga([Lo,qo,Uo,Jo]);Ga([Uo,Jo]);const Bo=Zo.strict(),Go=Ao.extend({requestId:Do.optional(),reason:la().optional()}),Wo=Mo.extend({method:ao("notifications/cancelled"),params:Go}),Xo=Ja({src:la(),mimeType:la().optional(),sizes:Va(la()).optional(),theme:no(["light","dark"]).optional()}),Yo=Ja({icons:Va(Xo).optional()}),Qo=Ja({name:la(),title:la().optional()}),ei=Qo.extend({...Qo.shape,...Yo.shape,version:la(),websiteUrl:la().optional(),description:la().optional()}),ti=Qa(Ja({applyDefaults:Ma().optional()}),to(la(),Fa())),ri=ko(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,Qa(Ja({form:ti.optional(),url:xo.optional()}),to(la(),Fa()).optional())),ni=Ka({list:xo.optional(),cancel:xo.optional(),requests:Ka({sampling:Ka({createMessage:xo.optional()}).optional(),elicitation:Ka({create:xo.optional()}).optional()}).optional()}),si=Ka({list:xo.optional(),cancel:xo.optional(),requests:Ka({tools:Ka({call:xo.optional()}).optional()}).optional()}),ai=Ja({experimental:to(la(),xo).optional(),sampling:Ja({context:xo.optional(),tools:xo.optional()}).optional(),elicitation:ri.optional(),roots:Ja({listChanged:Ma().optional()}).optional(),tasks:ni.optional()}),oi=zo.extend({protocolVersion:la(),capabilities:ai,clientInfo:ei}),ii=Co.extend({method:ao("initialize"),params:oi}),ci=Ja({experimental:to(la(),xo).optional(),logging:xo.optional(),completions:xo.optional(),prompts:Ja({listChanged:Ma().optional()}).optional(),resources:Ja({subscribe:Ma().optional(),listChanged:Ma().optional()}).optional(),tools:Ja({listChanged:Ma().optional()}).optional(),tasks:si.optional()}),di=Zo.extend({protocolVersion:la(),capabilities:ci,serverInfo:ei,instructions:la().optional()}),ui=Mo.extend({method:ao("notifications/initialized"),params:Ao.optional()}),li=Co.extend({method:ao("ping"),params:zo.optional()}),pi=Ja({progress:za(),total:uo(za()),message:uo(la())}),hi=Ja({...Ao.shape,...pi.shape,progressToken:No}),fi=Mo.extend({method:ao("notifications/progress"),params:hi}),mi=zo.extend({cursor:Oo.optional()}),gi=Co.extend({params:mi.optional()}),yi=Zo.extend({nextCursor:Oo.optional()}),_i=no(["working","input_required","completed","failed","cancelled"]),vi=Ja({taskId:la(),status:_i,ttl:Ga([za(),Da()]),createdAt:la(),lastUpdatedAt:la(),pollInterval:uo(za()),statusMessage:uo(la())}),wi=Zo.extend({task:vi}),bi=Ao.merge(vi),ki=Mo.extend({method:ao("notifications/tasks/status"),params:bi}),$i=Co.extend({method:ao("tasks/get"),params:zo.extend({taskId:la()})}),Si=Zo.merge(vi),Ei=Co.extend({method:ao("tasks/result"),params:zo.extend({taskId:la()})});Zo.loose();const Ti=gi.extend({method:ao("tasks/list")}),xi=yi.extend({tasks:Va(vi)}),Ni=Co.extend({method:ao("tasks/cancel"),params:zo.extend({taskId:la()})}),Oi=Zo.merge(vi),Pi=Ja({uri:la(),mimeType:uo(la()),_meta:to(la(),Fa()).optional()}),Ii=Pi.extend({text:la()}),Ri=la().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),zi=Pi.extend({blob:Ri}),ji=no(["user","assistant"]),Ci=Ja({audience:Va(ji).optional(),priority:za().min(0).max(1).optional(),lastModified:Hs({offset:!0}).optional()}),Ai=Ja({...Qo.shape,...Yo.shape,uri:la(),description:uo(la()),mimeType:uo(la()),annotations:Ci.optional(),_meta:uo(Ka({}))}),Mi=Ja({...Qo.shape,...Yo.shape,uriTemplate:la(),description:uo(la()),mimeType:uo(la()),annotations:Ci.optional(),_meta:uo(Ka({}))}),Zi=gi.extend({method:ao("resources/list")}),Di=yi.extend({resources:Va(Ai)}),Li=gi.extend({method:ao("resources/templates/list")}),Fi=yi.extend({resourceTemplates:Va(Mi)}),qi=zo.extend({uri:la()}),Ui=qi,Vi=Co.extend({method:ao("resources/read"),params:Ui}),Hi=Zo.extend({contents:Va(Ga([Ii,zi]))}),Ji=Mo.extend({method:ao("notifications/resources/list_changed"),params:Ao.optional()}),Ki=qi,Bi=Co.extend({method:ao("resources/subscribe"),params:Ki}),Gi=qi,Wi=Co.extend({method:ao("resources/unsubscribe"),params:Gi}),Xi=Ao.extend({uri:la()}),Yi=Mo.extend({method:ao("notifications/resources/updated"),params:Xi}),Qi=Ja({name:la(),description:uo(la()),required:uo(Ma())}),ec=Ja({...Qo.shape,...Yo.shape,description:uo(la()),arguments:uo(Va(Qi)),_meta:uo(Ka({}))}),tc=gi.extend({method:ao("prompts/list")}),rc=yi.extend({prompts:Va(ec)}),nc=zo.extend({name:la(),arguments:to(la(),la()).optional()}),sc=Co.extend({method:ao("prompts/get"),params:nc}),ac=Ja({type:ao("text"),text:la(),annotations:Ci.optional(),_meta:to(la(),Fa()).optional()}),oc=Ja({type:ao("image"),data:Ri,mimeType:la(),annotations:Ci.optional(),_meta:to(la(),Fa()).optional()}),ic=Ja({type:ao("audio"),data:Ri,mimeType:la(),annotations:Ci.optional(),_meta:to(la(),Fa()).optional()}),cc=Ja({type:ao("tool_use"),name:la(),id:la(),input:to(la(),Fa()),_meta:to(la(),Fa()).optional()}),dc=Ja({type:ao("resource"),resource:Ga([Ii,zi]),annotations:Ci.optional(),_meta:to(la(),Fa()).optional()}),uc=Ga([ac,oc,ic,Ai.extend({type:ao("resource_link")}),dc]),lc=Ja({role:ji,content:uc}),pc=Zo.extend({description:la().optional(),messages:Va(lc)}),hc=Mo.extend({method:ao("notifications/prompts/list_changed"),params:Ao.optional()}),fc=Ja({title:la().optional(),readOnlyHint:Ma().optional(),destructiveHint:Ma().optional(),idempotentHint:Ma().optional(),openWorldHint:Ma().optional()}),mc=Ja({taskSupport:no(["required","optional","forbidden"]).optional()}),gc=Ja({...Qo.shape,...Yo.shape,description:la().optional(),inputSchema:Ja({type:ao("object"),properties:to(la(),xo).optional(),required:Va(la()).optional()}).catchall(Fa()),outputSchema:Ja({type:ao("object"),properties:to(la(),xo).optional(),required:Va(la()).optional()}).catchall(Fa()).optional(),annotations:fc.optional(),execution:mc.optional(),_meta:to(la(),Fa()).optional()}),yc=gi.extend({method:ao("tools/list")}),_c=yi.extend({tools:Va(gc)}),vc=Zo.extend({content:Va(uc).default([]),structuredContent:to(la(),Fa()).optional(),isError:Ma().optional()});vc.or(Zo.extend({toolResult:Fa()}));const wc=jo.extend({name:la(),arguments:to(la(),Fa()).optional()}),bc=Co.extend({method:ao("tools/call"),params:wc}),kc=Mo.extend({method:ao("notifications/tools/list_changed"),params:Ao.optional()});Ja({autoRefresh:Ma().default(!0),debounceMs:za().int().nonnegative().default(300)});const $c=no(["debug","info","notice","warning","error","critical","alert","emergency"]),Sc=zo.extend({level:$c}),Ec=Co.extend({method:ao("logging/setLevel"),params:Sc}),Tc=Ao.extend({level:$c,logger:la().optional(),data:Fa()}),xc=Mo.extend({method:ao("notifications/message"),params:Tc}),Nc=Ja({name:la().optional()}),Oc=Ja({hints:Va(Nc).optional(),costPriority:za().min(0).max(1).optional(),speedPriority:za().min(0).max(1).optional(),intelligencePriority:za().min(0).max(1).optional()}),Pc=Ja({mode:no(["auto","required","none"]).optional()}),Ic=Ja({type:ao("tool_result"),toolUseId:la().describe("The unique identifier for the corresponding tool call."),content:Va(uc).default([]),structuredContent:Ja({}).loose().optional(),isError:Ma().optional(),_meta:to(la(),Fa()).optional()}),Rc=Xa("type",[ac,oc,ic]),zc=Xa("type",[ac,oc,ic,cc,Ic]),jc=Ja({role:ji,content:Ga([zc,Va(zc)]),_meta:to(la(),Fa()).optional()}),Cc=jo.extend({messages:Va(jc),modelPreferences:Oc.optional(),systemPrompt:la().optional(),includeContext:no(["none","thisServer","allServers"]).optional(),temperature:za().optional(),maxTokens:za().int(),stopSequences:Va(la()).optional(),metadata:xo.optional(),tools:Va(gc).optional(),toolChoice:Pc.optional()}),Ac=Co.extend({method:ao("sampling/createMessage"),params:Cc}),Mc=Zo.extend({model:la(),stopReason:uo(no(["endTurn","stopSequence","maxTokens"]).or(la())),role:ji,content:Rc}),Zc=Zo.extend({model:la(),stopReason:uo(no(["endTurn","stopSequence","maxTokens","toolUse"]).or(la())),role:ji,content:Ga([zc,Va(zc)])}),Dc=Ja({type:ao("boolean"),title:la().optional(),description:la().optional(),default:Ma().optional()}),Lc=Ja({type:ao("string"),title:la().optional(),description:la().optional(),minLength:za().optional(),maxLength:za().optional(),format:no(["email","uri","date","date-time"]).optional(),default:la().optional()}),Fc=Ja({type:no(["number","integer"]),title:la().optional(),description:la().optional(),minimum:za().optional(),maximum:za().optional(),default:za().optional()}),qc=Ja({type:ao("string"),title:la().optional(),description:la().optional(),enum:Va(la()),default:la().optional()}),Uc=Ja({type:ao("string"),title:la().optional(),description:la().optional(),oneOf:Va(Ja({const:la(),title:la()})),default:la().optional()}),Vc=Ja({type:ao("string"),title:la().optional(),description:la().optional(),enum:Va(la()),enumNames:Va(la()).optional(),default:la().optional()}),Hc=Ga([qc,Uc]),Jc=Ga([Ja({type:ao("array"),title:la().optional(),description:la().optional(),minItems:za().optional(),maxItems:za().optional(),items:Ja({type:ao("string"),enum:Va(la())}),default:Va(la()).optional()}),Ja({type:ao("array"),title:la().optional(),description:la().optional(),minItems:za().optional(),maxItems:za().optional(),items:Ja({anyOf:Va(Ja({const:la(),title:la()}))}),default:Va(la()).optional()})]),Kc=Ga([Vc,Hc,Jc]),Bc=Ga([Kc,Dc,Lc,Fc]),Gc=Ga([jo.extend({mode:ao("form").optional(),message:la(),requestedSchema:Ja({type:ao("object"),properties:to(la(),Bc),required:Va(la()).optional()})}),jo.extend({mode:ao("url"),message:la(),elicitationId:la(),url:la().url()})]),Wc=Co.extend({method:ao("elicitation/create"),params:Gc}),Xc=Ao.extend({elicitationId:la()}),Yc=Mo.extend({method:ao("notifications/elicitation/complete"),params:Xc}),Qc=Zo.extend({action:no(["accept","decline","cancel"]),content:ko(e=>null===e?void 0:e,to(la(),Ga([la(),za(),Ma(),Va(la())])).optional())}),ed=Ja({type:ao("ref/resource"),uri:la()}),td=Ja({type:ao("ref/prompt"),name:la()}),rd=zo.extend({ref:Ga([td,ed]),argument:Ja({name:la(),value:la()}),context:Ja({arguments:to(la(),la()).optional()}).optional()}),nd=Co.extend({method:ao("completion/complete"),params:rd}),sd=Zo.extend({completion:Ka({values:Va(la()).max(100),total:uo(za().int()),hasMore:uo(Ma())})}),ad=Ja({uri:la().startsWith("file://"),name:la().optional(),_meta:to(la(),Fa()).optional()}),od=Co.extend({method:ao("roots/list"),params:zo.optional()}),id=Zo.extend({roots:Va(ad)}),cd=Mo.extend({method:ao("notifications/roots/list_changed"),params:Ao.optional()});Ga([li,ii,nd,Ec,sc,tc,Zi,Li,Vi,Bi,Wi,bc,yc,$i,Ei,Ti,Ni]),Ga([Wo,fi,ui,cd,ki]),Ga([Bo,Mc,Zc,Qc,id,Si,xi,wi]),Ga([li,Ac,Wc,od,$i,Ei,Ti,Ni]),Ga([Wo,fi,xc,Yi,Ji,kc,hc,ki,Yc]),Ga([Bo,di,sd,pc,rc,Di,Fi,Hi,vc,_c,Si,xi,wi]);class dd 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===Ho.UrlElicitationRequired&&r){const e=r;if(e.elicitations)return new ud(e.elicitations,t)}return new dd(e,t,r)}}class ud extends dd{constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(Ho.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}function ld(e){return"completed"===e||"failed"===e||"cancelled"===e}const pd=Symbol("Let zodToJsonSchema decide on which parser to use"),hd={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 fd(e,t,r,n){n?.errorMessages&&r&&(e.errorMessage={...e.errorMessage,[t]:r})}function md(e,t,r,n,s){e[t]=r,fd(e,t,n,s)}const gd=(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 yd(e){if("openAi"!==e.target)return{};const t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:"relative"===e.$refStrategy?gd(t,e.currentPath):t.join("/")}}function _d(e,t){return Vd(e.type._def,t)}function vd(e,t,r){const n=r??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((r,n)=>vd(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 wd(e,t)}}const wd=(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":md(r,"minimum",n.value,n.message,t);break;case"max":md(r,"maximum",n.value,n.message,t)}return r};let bd;const kd=/^[cC][^\s-]{8,}$/,$d=/^[0-9a-z]+$/,Sd=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ed=/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,Td=()=>(void 0===bd&&(bd=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),bd),xd=/^(?:(?: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])$/,Nd=/^(([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])$/,Od=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Pd=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Id=/^[a-zA-Z0-9_-]{21}$/,Rd=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;function zd(e,t){const r={type:"string"};if(e.checks)for(const n of e.checks)switch(n.kind){case"min":md(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,n.value):n.value,n.message,t);break;case"max":md(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":Ad(r,"email",n.message,t);break;case"format:idn-email":Ad(r,"idn-email",n.message,t);break;case"pattern:zod":Md(r,Ed,n.message,t)}break;case"url":Ad(r,"uri",n.message,t);break;case"uuid":Ad(r,"uuid",n.message,t);break;case"regex":Md(r,n.regex,n.message,t);break;case"cuid":Md(r,kd,n.message,t);break;case"cuid2":Md(r,$d,n.message,t);break;case"startsWith":Md(r,RegExp(`^${jd(n.value,t)}`),n.message,t);break;case"endsWith":Md(r,RegExp(`${jd(n.value,t)}$`),n.message,t);break;case"datetime":Ad(r,"date-time",n.message,t);break;case"date":Ad(r,"date",n.message,t);break;case"time":Ad(r,"time",n.message,t);break;case"duration":Ad(r,"duration",n.message,t);break;case"length":md(r,"minLength","number"==typeof r.minLength?Math.max(r.minLength,n.value):n.value,n.message,t),md(r,"maxLength","number"==typeof r.maxLength?Math.min(r.maxLength,n.value):n.value,n.message,t);break;case"includes":Md(r,RegExp(jd(n.value,t)),n.message,t);break;case"ip":"v6"!==n.version&&Ad(r,"ipv4",n.message,t),"v4"!==n.version&&Ad(r,"ipv6",n.message,t);break;case"base64url":Md(r,Pd,n.message,t);break;case"jwt":Md(r,Rd,n.message,t);break;case"cidr":"v6"!==n.version&&Md(r,xd,n.message,t),"v4"!==n.version&&Md(r,Nd,n.message,t);break;case"emoji":Md(r,Td(),n.message,t);break;case"ulid":Md(r,Sd,n.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":Ad(r,"binary",n.message,t);break;case"contentEncoding:base64":md(r,"contentEncoding","base64",n.message,t);break;case"pattern:zod":Md(r,Od,n.message,t)}break;case"nanoid":Md(r,Id,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++)Cd.has(e[r])||(t+="\\"),t+=e[r];return t}(e):e}const Cd=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Ad(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}}})):md(e,"format",t,r,n)}function Md(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:Zd(t,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):md(e,"pattern",Zd(t,n),r,n)}function Zd(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 o="",i=!1,c=!1,d=!1;for(let e=0;e<a.length;e++)if(i)o+=a[e],i=!1;else{if(r)if(c){if(a[e].match(/[a-z]/)){d?(o+=a[e],o+=`${a[e-2]}-${a[e]}`.toUpperCase(),d=!1):"-"===a[e+1]&&a[e+2]?.match(/[a-z]/)?(o+=a[e],d=!0):o+=`${a[e]}${a[e].toUpperCase()}`;continue}}else if(a[e].match(/[a-z]/)){o+=`[${a[e]}${a[e].toUpperCase()}]`;continue}if(n){if("^"===a[e]){o+="(^|(?<=[\r\n]))";continue}if("$"===a[e]){o+="($|(?=[\r\n]))";continue}}s&&"."===a[e]?o+=c?`${a[e]}\r\n`:`[${a[e]}\r\n]`:(o+=a[e],"\\"===a[e]?i=!0:c&&"]"===a[e]?c=!1:c||"["!==a[e]||(c=!0))}try{new RegExp(o)}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 o}function Dd(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===Ue.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce((r,n)=>({...r,[n]:Vd(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??yd(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};const r={type:"object",additionalProperties:Vd(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??t.allowedAdditionalProperties};if("openApi3"===t.target)return r;if(e.keyType?._def.typeName===Ue.ZodString&&e.keyType._def.checks?.length){const{type:n,...s}=zd(e.keyType._def,t);return{...r,propertyNames:s}}if(e.keyType?._def.typeName===Ue.ZodEnum)return{...r,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===Ue.ZodBranded&&e.keyType._def.type._def.typeName===Ue.ZodString&&e.keyType._def.type._def.checks?.length){const{type:n,...s}=_d(e.keyType._def,t);return{...r,propertyNames:s}}return r}const Ld={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"},Fd=(e,t)=>{const r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,r)=>Vd(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 qd(e){try{return e.isOptional()}catch{return!0}}const Ud=(e,t,r)=>{switch(t){case Ue.ZodString:return zd(e,r);case Ue.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",fd(r,"type",n.message,t);break;case"min":"jsonSchema7"===t.target?n.inclusive?md(r,"minimum",n.value,n.message,t):md(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),md(r,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?md(r,"maximum",n.value,n.message,t):md(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),md(r,"maximum",n.value,n.message,t));break;case"multipleOf":md(r,"multipleOf",n.value,n.message,t)}return r}(e,r);case Ue.ZodObject:return function(e,t){const r="openAi"===t.target,n={type:"object",properties:{}},s=[],a=e.shape();for(const e in a){let o=a[e];if(void 0===o||void 0===o._def)continue;let i=qd(o);i&&r&&("ZodOptional"===o._def.typeName&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),i=!1);const c=Vd(o._def,{...t,currentPath:[...t.currentPath,"properties",e],propertyPath:[...t.currentPath,"properties",e]});void 0!==c&&(n.properties[e]=c,i||s.push(e))}s.length&&(n.required=s);const o=function(e,t){if("ZodNever"!==e.catchall._def.typeName)return Vd(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!==o&&(n.additionalProperties=o),n}(e,r);case Ue.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?md(r,"minimum",n.value,n.message,t):md(r,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(r.exclusiveMinimum=!0),md(r,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?md(r,"maximum",n.value,n.message,t):md(r,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(r.exclusiveMaximum=!0),md(r,"maximum",n.value,n.message,t));break;case"multipleOf":md(r,"multipleOf",n.value,n.message,t)}return r}(e,r);case Ue.ZodBoolean:return{type:"boolean"};case Ue.ZodDate:return vd(e,r);case Ue.ZodUndefined:return function(e){return{not:yd(e)}}(r);case Ue.ZodNull:return function(e){return"openApi3"===e.target?{enum:["null"],nullable:!0}:{type:"null"}}(r);case Ue.ZodArray:return function(e,t){const r={type:"array"};return e.type?._def&&e.type?._def?.typeName!==Ue.ZodAny&&(r.items=Vd(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&md(r,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&md(r,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(md(r,"minItems",e.exactLength.value,e.exactLength.message,t),md(r,"maxItems",e.exactLength.value,e.exactLength.message,t)),r}(e,r);case Ue.ZodUnion:case Ue.ZodDiscriminatedUnion:return function(e,t){if("openApi3"===t.target)return Fd(e,t);const r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(e=>e._def.typeName in Ld&&(!e._def.checks||!e._def.checks.length))){const e=r.reduce((e,t)=>{const r=Ld[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 Fd(e,t)}(e,r);case Ue.ZodIntersection:return function(e,t){const r=[Vd(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),Vd(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 Ue.ZodTuple:return function(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((e,r)=>Vd(e._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[]),additionalItems:Vd(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,r)=>Vd(e._def,{...t,currentPath:[...t.currentPath,"items",`${r}`]})).reduce((e,t)=>void 0===t?e:[...e,t],[])}}(e,r);case Ue.ZodRecord:return Dd(e,r);case Ue.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 Ue.ZodEnum:return function(e){return{type:"string",enum:Array.from(e.values)}}(e);case Ue.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 Ue.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:Ld[e.innerType._def.typeName],nullable:!0}:{type:[Ld[e.innerType._def.typeName],"null"]};if("openApi3"===t.target){const r=Vd(e.innerType._def,{...t,currentPath:[...t.currentPath]});return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&{...r,nullable:!0}}const r=Vd(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}(e,r);case Ue.ZodOptional:return((e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return Vd(e.innerType._def,t);const r=Vd(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return r?{anyOf:[{not:yd(t)},r]}:yd(t)})(e,r);case Ue.ZodMap:return function(e,t){return"record"===t.mapStrategy?Dd(e,t):{type:"array",maxItems:125,items:{type:"array",items:[Vd(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||yd(t),Vd(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||yd(t)],minItems:2,maxItems:2}}}(e,r);case Ue.ZodSet:return function(e,t){const r={type:"array",uniqueItems:!0,items:Vd(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&md(r,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&md(r,"maxItems",e.maxSize.value,e.maxSize.message,t),r}(e,r);case Ue.ZodLazy:return()=>e.getter()._def;case Ue.ZodPromise:return function(e,t){return Vd(e.type._def,t)}(e,r);case Ue.ZodNaN:case Ue.ZodNever:return function(e){return"openAi"===e.target?void 0:{not:yd({...e,currentPath:[...e.currentPath,"not"]})}}(r);case Ue.ZodEffects:return function(e,t){return"input"===t.effectStrategy?Vd(e.schema._def,t):yd(t)}(e,r);case Ue.ZodAny:return yd(r);case Ue.ZodUnknown:return function(e){return yd(e)}(r);case Ue.ZodDefault:return function(e,t){return{...Vd(e.innerType._def,t),default:e.defaultValue()}}(e,r);case Ue.ZodBranded:return _d(e,r);case Ue.ZodReadonly:case Ue.ZodCatch:return((e,t)=>Vd(e.innerType._def,t))(e,r);case Ue.ZodPipeline:return((e,t)=>{if("input"===t.pipeStrategy)return Vd(e.in._def,t);if("output"===t.pipeStrategy)return Vd(e.out._def,t);const r=Vd(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[r,Vd(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]})].filter(e=>void 0!==e)}})(e,r);case Ue.ZodFunction:case Ue.ZodVoid:case Ue.ZodSymbol:default:return}};function Vd(e,t,r=!1){const n=t.seen.get(e);if(t.override){const s=t.override?.(e,t,n,r);if(s!==pd)return s}if(n&&!r){const e=Hd(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=Ud(e,e.typeName,t),o="function"==typeof a?Vd(a(),t):a;if(o&&Jd(e,t,o),t.postProcess){const r=t.postProcess(o,e,t);return s.jsonSchema=o,r}return s.jsonSchema=o,o}const Hd=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:gd(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`),yd(t)):"seen"===t.$refStrategy?yd(t):void 0}},Jd=(e,t,r)=>(e.description&&(r.description=e.description,t.markdownDescription&&(r.markdownDescription=e.description)),r);function Kd(e,t){return As(e)?function(e,t){if("_idmap"in e){const r=e,n=ns({...t,processors:Rs}),s={};for(const e of r._idmap.entries()){const[t,r]=e;ss(r,n)}const a={},o={registry:r,uri:t?.uri,defs:s};n.external=o;for(const e of r._idmap.entries()){const[t,r]=e;as(n,r),a[t]=os(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=ns({...t,processors:Rs});return ss(e,r),as(r,e),os(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?{...hd,name:e}:{...hd,...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]:Vd(n._def,{...r,currentPath:[...r.basePath,r.definitionPath,t]},!0)??yd(r)}),{}):void 0;const s="title"===t?.nameStrategy?void 0:t?.name,a=Vd(e._def,void 0===s?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??yd(r),o=void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==o&&(a.title=o),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 i=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?i.$schema="http://json-schema.org/draft-07/schema#":"jsonSchema2019-09"!==r.target&&"openAi"!==r.target||(i.$schema="https://json-schema.org/draft/2019-09/schema#"),"openAi"===r.target&&("anyOf"in i||"oneOf"in i||"allOf"in i||"type"in i&&Array.isArray(i.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),i})(e,{strictUnions:t?.strictUnions??!0,pipeStrategy:t?.pipeStrategy??"input"});var r}function Bd(e){const t=Ls(e),r=t?.method;if(!r)throw new Error("Schema is missing a method literal");const n=Us(r);if("string"!=typeof n)throw new Error("Schema method literal must be a string");return n}function Gd(e,t){const r=Zs(e,t);if(!r.success)throw r.error;return r.data}class Wd{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(Wo,e=>{this._oncancel(e)}),this.setNotificationHandler(fi,e=>{this._onprogress(e)}),this.setRequestHandler(li,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler($i,async(e,t)=>{const r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new dd(Ho.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(Ei,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 dd(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 dd(Ho.InvalidParams,`Task not found: ${n}`);if(!ld(s.status))return await this._waitForTaskUpdate(n,t.signal),await r();if(ld(s.status)){const e=await this._taskStore.getTaskResult(n,t.sessionId);return this._clearTaskQueue(n),{...e,_meta:{...e._meta,[Eo]:{taskId:n}}}}return await r()};return await r()}),this.setRequestHandler(Ti,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 dd(Ho.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(Ni,async(e,t)=>{try{const r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new dd(Ho.InvalidParams,`Task not found: ${e.params.taskId}`);if(ld(r.status))throw new dd(Ho.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 dd(Ho.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...n}}catch(e){if(e instanceof dd)throw e;throw new dd(Ho.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),dd.fromError(Ho.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),Vo(e)||(r=e,Jo.safeParse(r).success)?this._onresponse(e):Fo(e)?this._onrequest(e,t):(e=>qo.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=dd.fromError(Ho.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?.[Eo]?.taskId;if(void 0===r){const t={jsonrpc:"2.0",id:e.id,error:{code:Ho.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 o=(i=e.params,jo.safeParse(i).success?e.params.task:void 0);var i;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 o=a.relatedTask?.taskId??s;return o&&c&&await c.updateTaskStatus(o,"input_required"),await this.request(t,r,a)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&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:Ho.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),o=this._timeoutInfo.get(n);if(o&&a&&o.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(Vo(e)?r(e):r(new dd(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(Vo(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),Vo(e)?n(e):n(dd.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 dd?e:new dd(Ho.InternalError,String(e))}}return}let s;try{const n=await this.request(e,wi,r);if(!n.task)throw new dd(Ho.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},ld(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 dd(Ho.InternalError,`Task ${s} failed`)}:"cancelled"===e.status&&(yield{type:"error",error:new dd(Ho.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 dd?e:new dd(Ho.InternalError,String(e))}}}request(e,t,r){const{relatedRequestId:n,resumptionToken:s,onresumptiontoken:a,task:o,relatedTask:i}=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),o&&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}}),o&&(p.params={...p.params,task:o}),i&&(p.params={...p.params,_meta:{...p.params?._meta||{},[Eo]:i}});const h=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 dd?e:new dd(Ho.RequestTimeout,String(e));d(t)};this._responseHandlers.set(l,e=>{if(!r?.signal?.aborted){if(e instanceof Error)return d(e);try{const r=Zs(t,e.result);r.success?c(r.data):d(r.error)}catch(e){d(e)}}}),r?.signal?.addEventListener("abort",()=>{h(r?.signal?.reason)});const f=r?.timeout??6e4;this._setupTimeout(l,f,r?.maxTotalTimeout,()=>h(dd.fromError(Ho.RequestTimeout,"Request timed out",{timeout:f})),r?.resetTimeoutOnProgress??!1);const m=i?.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},Si,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},xi,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},Oi,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||{},[Eo]: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||{},[Eo]: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||{},[Eo]:t.relatedTask}}}),await this._transport.send(n,t)}setRequestHandler(e,t){const r=Bd(e);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(r,n)=>{const s=Gd(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=Bd(e);this._notificationHandlers.set(r,r=>{const n=Gd(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&&Fo(t.message)){const r=t.message.id,n=this._requestResolvers.get(r);n?(n(new dd(Ho.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 dd(Ho.InvalidRequest,"Request cancelled"));const s=setTimeout(e,r);t.addEventListener("abort",()=>{clearTimeout(s),n(new dd(Ho.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 dd(Ho.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=ki.parse({method:"notifications/tasks/status",params:a});await this.notification(t),ld(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 dd(Ho.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(ld(a.status))throw new dd(Ho.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 o=await r.getTask(e,t);if(o){const t=ki.parse({method:"notifications/tasks/status",params:o});await this.notification(t),ld(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>r.listTasks(e,t)}}}function Xd(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}function Yd(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Qd,eu={exports:{}},tu={},ru={},nu={},su={},au={},ou={};function iu(){return Qd||(Qd=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;)i(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 o(e,...t){const r=[d(e[0])];let s=0;for(;s<t.length;)r.push(a),i(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 i(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=o,e.addCodeArg=i,e.strConcat=function(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${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())}}(ou)),ou}var cu,du,uu={};function lu(){return cu||(cu=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const t=iu();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 o=t._`\n`;e.ValueScope=class extends s{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?o: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 o=this._values[s];if(o){const e=o.get(a);if(e)return e}else o=this._values[s]=new Map;o.set(a,n);const i=this._scope[s]||(this._scope[s]=[]),c=i.length;return i[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,o={},i){let c=t.nil;for(const d in s){const u=s[d];if(!u)continue;const l=o[d]=o[d]||new Map;u.forEach(s=>{if(l.has(s))return;l.set(s,n.Started);let o=a(s);if(o){const r=this.opts.es5?e.varKinds.var:e.varKinds.const;c=t._`${c}${r} ${s} = ${o};${this.opts._n}`}else{if(!(o=null==i?void 0:i(s)))throw new r(s);c=t._`${c}${o}${this.opts._n}`}l.set(s,n.Completed)})}return c}}}(uu)),uu}function pu(){return du||(du=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=iu(),r=lu();var n=iu();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=lu();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 o 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 i 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 i{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 h 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 f extends h{render(e){return"{"+e._n+super.render(e)+"}"+e._n}}class m extends h{}class g extends f{}g.kind="else";class y extends f{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 f{}_.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 f{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 h{render(e){return"return "+super.render(e)}}$.kind="return";class S extends f{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 f{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}E.kind="catch";class T extends f{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 o(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 i(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 o=this._scope.toName(e);return this._for(new w(a,o,t,n),()=>s(o))}forOf(e,n,s,a=r.varKinds.const){const o=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(o,t._`${e}[${r}]`),s(o)})}return this._for(new b("of",a,o,n),()=>s(o))}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 o=this._scope.toName(e);return this._for(new b("in",a,o,n),()=>s(o))}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=j(e.operators.AND);e.and=function(...e){return e.reduce(R)};const z=j(e.operators.OR);function j(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(z)}}(au)),au}var hu,fu={};function mu(){if(hu)return fu;hu=1,Object.defineProperty(fu,"__esModule",{value:!0}),fu.checkStrictMode=fu.getErrorPath=fu.Type=fu.useFunc=fu.setEvaluated=fu.evaluatedPropsToName=fu.mergeEvaluated=fu.eachItem=fu.unescapeJsonPointer=fu.escapeJsonPointer=fu.escapeFragment=fu.unescapeFragment=fu.schemaRefOrVal=fu.schemaHasRulesButRef=fu.schemaHasRules=fu.checkUnknownRules=fu.alwaysValidSchema=fu.toHash=void 0;const e=pu(),t=iu();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 o({mergeNames:t,mergeToName:r,mergeValues:n,resultToName:s}){return(a,o,i,c)=>{const d=void 0===i?o:i instanceof e.Name?(o instanceof e.Name?t(a,o,i):r(a,o,i),i):o instanceof e.Name?(r(a,i,o),o):n(o,i);return c!==e.Name||d instanceof e.Name?d:s(a,d)}}function i(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))}fu.toHash=function(e){const t={};for(const r of e)t[r]=!0;return t},fu.alwaysValidSchema=function(e,t){return"boolean"==typeof t?t:0===Object.keys(t).length||(r(e,t),!n(t,e.self.RULES.all))},fu.checkUnknownRules=r,fu.schemaHasRules=n,fu.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},fu.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)}`},fu.unescapeFragment=function(e){return a(decodeURIComponent(e))},fu.escapeFragment=function(e){return encodeURIComponent(s(e))},fu.escapeJsonPointer=s,fu.unescapeJsonPointer=a,fu.eachItem=function(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)},fu.mergeEvaluated={props:o({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:i}),items:o({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)})},fu.evaluatedPropsToName=i,fu.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 fu.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||(fu.Type=u={})),fu.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)},fu.checkStrictMode=l,fu}var gu,yu,_u,vu={};function wu(){if(gu)return vu;gu=1,Object.defineProperty(vu,"__esModule",{value:!0});const e=pu(),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 vu.default=t,vu}function bu(){return yu||(yu=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=pu(),r=mu(),n=wu();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,o,c){const{it:d}=r,{gen:u,compositeRule:l,allErrors:p}=d,h=i(r,n,o);(null!=c?c:l||p)?s(u,h):a(d,t._`[${h}]`)},e.reportExtraError=function(t,r=e.keywordError,o){const{it:c}=t,{gen:d,compositeRule:u,allErrors:l}=c;s(d,i(t,r,o)),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:o,it:i}){if(void 0===o)throw new Error("ajv implementation error");const c=e.name("err");e.forRange("i",o,n.default.errors,o=>{e.const(c,t._`${n.default.vErrors}[${o}]`),e.if(t._`${c}.instancePath === undefined`,()=>e.assign(t._`${c}.instancePath`,(0,t.strConcat)(n.default.instancePath,i.errorPath))),e.assign(t._`${c}.schemaPath`,t.str`${i.errSchemaPath}/${r}`),i.opts.verbose&&(e.assign(t._`${c}.schema`,s),e.assign(t._`${c}.data`,a))})};const o={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 i(e,r,s){const{createErrors:a}=e.it;return!1===a?t._`{}`:function(e,r,s={}){const{gen:a,it:i}=e,u=[c(i,s),d(e,s)];return function(e,{params:r,message:s},a){const{keyword:i,data:c,schemaValue:d,it:u}=e,{opts:l,propertyName:p,topSchemaRef:h,schemaPath:f}=u;a.push([o.keyword,i],[o.params,"function"==typeof r?r(e):r||t._`{}`]),l.messages&&a.push([o.message,"function"==typeof s?s(e):s]),l.verbose&&a.push([o.schema,d],[o.parentSchema,t._`${h}${f}`],[n.default.data,c]),p&&a.push([o.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 i=a?n:t.str`${n}/${e}`;return s&&(i=t.str`${i}${(0,r.getErrorPath)(s,r.Type.Str)}`),[o.schemaPath,i]}}(su)),su}var ku,$u={},Su={};function Eu(){if(ku)return Su;ku=1,Object.defineProperty(Su,"__esModule",{value:!0}),Su.getRules=Su.isJSONType=void 0;const e=new Set(["string","number","integer","boolean","null","object","array"]);return Su.isJSONType=function(t){return"string"==typeof t&&e.has(t)},Su.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:{}}},Su}var Tu,xu,Nu={};function Ou(){if(Tu)return Nu;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 Tu=1,Object.defineProperty(Nu,"__esModule",{value:!0}),Nu.shouldUseRule=Nu.shouldUseGroup=Nu.schemaHasRulesForType=void 0,Nu.schemaHasRulesForType=function({schema:t,self:r},n){const s=r.RULES.types[n];return s&&!0!==s&&e(t,s)},Nu.shouldUseGroup=e,Nu.shouldUseRule=t,Nu}function Pu(){if(xu)return $u;xu=1,Object.defineProperty($u,"__esModule",{value:!0}),$u.reportTypeError=$u.checkDataTypes=$u.checkDataType=$u.coerceAndCheckDataType=$u.getJSONTypes=$u.getSchemaTypes=$u.DataType=void 0;const e=Eu(),t=Ou(),r=bu(),n=pu(),s=mu();var a;function o(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||($u.DataType=a={})),$u.getSchemaTypes=function(e){const t=o(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},$u.getJSONTypes=o,$u.coerceAndCheckDataType=function(e,r){const{gen:s,data:o,opts:c}=e,u=function(e,t){return t?e.filter(e=>i.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,o,c.strictNumbers,a.Wrong);s.if(t,()=>{u.length?function(e,t,r){const{gen:s,data:a,opts:o}=e,c=s.let("dataType",n._`typeof ${a}`),u=s.let("coerced",n._`undefined`);"array"===o.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,o.strictNumbers),()=>s.assign(u,a))),s.if(n._`${u} !== undefined`);for(const e of r)(i.has(e)||"array"===e&&"array"===o.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 i=new Set(["string","number","integer","boolean","null"]);function c(e,t,r,s=a.Correct){const o=s===a.Correct?n.operators.EQ:n.operators.NEQ;let i;switch(e){case"null":return n._`${t} ${o} null`;case"array":i=n._`Array.isArray(${t})`;break;case"object":i=n._`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":i=c(n._`!(${t} % 1) && !isNaN(${t})`);break;case"number":i=c();break;default:return n._`typeof ${t} ${o} ${e}`}return s===a.Correct?i:(0,n.not)(i);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 o;const i=(0,s.toHash)(e);if(i.array&&i.object){const e=n._`typeof ${t} != "object"`;o=i.null?e:n._`!${t} || ${e}`,delete i.null,delete i.array,delete i.object}else o=n.nil;i.number&&delete i.integer;for(const e in i)o=(0,n.and)(o,c(e,t,r,a));return o}$u.checkDataType=c,$u.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 $u.reportTypeError=l,$u}var Iu,Ru,Cu,zu={},ju={},Au={};function Mu(){if(Ru)return Au;Ru=1,Object.defineProperty(Au,"__esModule",{value:!0}),Au.validateUnion=Au.validateArray=Au.usePattern=Au.callValidateCode=Au.schemaProperties=Au.allSchemaProperties=Au.noPropertyInData=Au.propertyInData=Au.isOwnProperty=Au.hasPropFunc=Au.reportMissingProp=Au.checkMissingProp=Au.checkReportMissingProp=void 0;const e=pu(),t=mu(),r=wu(),n=mu();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 o(t,r,n,s){const o=e._`${r}${(0,e.getProperty)(n)} === undefined`;return s?(0,e.or)(o,(0,e.not)(a(t,r,n))):o}function i(e){return e?Object.keys(e).filter(e=>"__proto__"!==e):[]}Au.checkReportMissingProp=function(t,r){const{gen:n,data:s,it:a}=t;n.if(o(n,s,r,a.opts.ownProperties),()=>{t.setParams({missingProperty:e._`${r}`},!0),t.error()})},Au.checkMissingProp=function({gen:t,data:r,it:{opts:n}},s,a){return(0,e.or)(...s.map(s=>(0,e.and)(o(t,r,s,n.ownProperties),e._`${a} = ${s}`)))},Au.reportMissingProp=function(e,t){e.setParams({missingProperty:t},!0),e.error()},Au.hasPropFunc=s,Au.isOwnProperty=a,Au.propertyInData=function(t,r,n,s){const o=e._`${r}${(0,e.getProperty)(n)} !== undefined`;return s?e._`${o} && ${a(t,r,n)}`:o},Au.noPropertyInData=o,Au.allSchemaProperties=i,Au.schemaProperties=function(e,r){return i(r).filter(n=>!(0,t.alwaysValidSchema)(e,r[n]))},Au.callValidateCode=function({schemaCode:t,data:n,it:{gen:s,topSchemaRef:a,schemaPath:o,errorPath:i},it:c},d,u,l){const p=l?e._`${t}, ${n}, ${a}${o}`:n,h=[[r.default.instancePath,(0,e.strConcat)(r.default.instancePath,i)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&h.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const f=e._`${p}, ${s.object(...h)}`;return u!==e.nil?e._`${d}.call(${u}, ${f})`:e._`${d}(${f})`};const c=e._`new RegExp`;return Au.usePattern=function({gen:t,it:{opts:r}},s){const a=r.unicodeRegExp?"u":"",{regExp:o}=r.code,i=o(s,a);return t.scopeValue("pattern",{key:i.toString(),ref:i,code:e._`${"new RegExp"===o.code?c:(0,n.useFunc)(t,o)}(${s}, ${a})`})},Au.validateArray=function(r){const{gen:n,data:s,keyword:a,it:o}=r,i=n.name("valid");if(o.allErrors){const e=n.let("valid",!0);return c(()=>n.assign(e,!1)),e}return n.var(i,!0),c(()=>n.break()),i;function c(o){const c=n.const("len",e._`${s}.length`);n.forRange("i",0,c,s=>{r.subschema({keyword:a,dataProp:s,dataPropType:t.Type.Num},i),n.if((0,e.not)(i),o)})}},Au.validateUnion=function(r){const{gen:n,schema:s,keyword:a,it:o}=r;if(!Array.isArray(s))throw new Error("ajv implementation error");if(s.some(e=>(0,t.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;const i=n.let("valid",!1),c=n.name("_valid");n.block(()=>s.forEach((t,s)=>{const o=r.subschema({keyword:a,schemaProp:s,compositeRule:!0},c);n.assign(i,e._`${i} || ${c}`),r.mergeValidEvaluated(o,c)||n.if((0,e.not)(i))})),r.result(i,()=>r.reset(),()=>r.error(!0))},Au}var Zu,Du,Lu,Fu={},qu={};function Uu(){return Lu||(Lu=1,Du=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 o=a[s];if(!e(t[o],r[o]))return!1}return!0}return t!=t&&r!=r}),Du}var Vu,Hu,Ku,Ju={exports:{}};function Bu(){if(Vu)return Ju.exports;Vu=1;var e=Ju.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,o,i,c,d,u,l,p){if(o&&"object"==typeof o&&!Array.isArray(o)){for(var h in s(o,i,c,d,u,l,p),o){var f=o[h];if(Array.isArray(f)){if(h in e.arrayKeywords)for(var m=0;m<f.length;m++)t(n,s,a,f[m],i+"/"+h+"/"+m,c,i,h,o,m)}else if(h in e.propsKeywords){if(f&&"object"==typeof f)for(var g in f)t(n,s,a,f[g],i+"/"+h+"/"+r(g),c,i,h,o,g)}else(h in e.keywords||n.allKeys&&!(h in e.skipKeywords))&&t(n,s,a,f,i+"/"+h,c,i,h,o)}a(o,i,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},Ju.exports}function Gu(){if(Hu)return qu;Hu=1,Object.defineProperty(qu,"__esModule",{value:!0}),qu.getSchemaRefs=qu.resolveUrl=qu.normalizeId=qu._getFullPath=qu.getFullPath=qu.inlineRef=void 0;const e=mu(),t=Uu(),r=Bu(),n=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);qu.inlineRef=function(e,t=!0){return"boolean"==typeof e||(!0===t?!a(e):!!t&&o(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 o(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+=o(e)),r===1/0))return 1/0}return r}function i(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]+"#"}qu.getFullPath=i,qu._getFullPath=c;const d=/#\/?$/;function u(e){return e?e.replace(d,""):""}qu.normalizeId=u,qu.resolveUrl=function(e,t,r){return r=u(r),e.resolve(t,r)};const l=/^[a-z_][-a-z0-9._]*$/i;return qu.getSchemaRefs=function(e,n){if("boolean"==typeof e)return{};const{schemaId:s,uriResolver:a}=this.opts,o=u(e[s]||n),c={"":o},d=i(a,o,!1),p={},h=new Set;return r(e,{allKeys:!0},(e,t,r,n)=>{if(void 0===n)return;const a=d+t;let o=c[n];function i(t){const r=this.opts.uriResolver.resolve;if(t=u(o?r(o,t):t),h.has(t))throw m(t);h.add(t);let n=this.refs[t];return"string"==typeof n&&(n=this.refs[n]),"object"==typeof n?f(e,n.schema,t):t!==u(a)&&("#"===t[0]?(f(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}"`);i.call(this,`#${e}`)}}"string"==typeof e[s]&&(o=i.call(this,e[s])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),c[t]=o}),p;function f(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`)}},qu}function Wu(){if(Ku)return ru;Ku=1,Object.defineProperty(ru,"__esModule",{value:!0}),ru.getData=ru.KeywordCxt=ru.validateFunctionCode=void 0;const e=function(){if(_u)return nu;_u=1,Object.defineProperty(nu,"__esModule",{value:!0}),nu.boolOrEmptySchema=nu.topBoolOrEmptySchema=void 0;const e=bu(),t=pu(),r=wu(),n={message:"boolean schema is false"};function s(t,r){const{gen:s,data:a}=t,o={gen:s,keyword:"false schema",data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,e.reportError)(o,n,void 0,r)}return nu.topBoolOrEmptySchema=function(e){const{gen:n,schema:a,validateName:o}=e;!1===a?s(e,!1):"object"==typeof a&&!0===a.$async?n.return(r.default.data):(n.assign(t._`${o}.errors`,null),n.return(!0))},nu.boolOrEmptySchema=function(e,t){const{gen:r,schema:n}=e;!1===n?(r.var(t,!1),s(e)):r.var(t,!0)},nu}(),t=Pu(),r=Ou(),n=Pu(),s=function(){if(Iu)return zu;Iu=1,Object.defineProperty(zu,"__esModule",{value:!0}),zu.assignDefaults=void 0;const e=pu(),t=mu();function r(r,n,s){const{gen:a,compositeRule:o,data:i,opts:c}=r;if(void 0===s)return;const d=e._`${i}${(0,e.getProperty)(n)}`;if(o)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 zu.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))},zu}(),a=function(){if(Cu)return ju;Cu=1,Object.defineProperty(ju,"__esModule",{value:!0}),ju.validateKeywordUsage=ju.validSchemaType=ju.funcKeywordCode=ju.macroKeywordCode=void 0;const e=pu(),t=wu(),r=Mu(),n=bu();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:o,parentSchema:i,it:c}=t,d=r.macro.call(c.self,o,i,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(o,i){var c;const{gen:d,keyword:u,schema:l,parentSchema:p,$data:h,it:f}=o;!function({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}(f,i);const m=!h&&i.compile?i.compile.call(f.self,l,p,f):i.validate,g=a(d,u,m),y=d.let("valid");function _(n=(i.async?e._`await `:e.nil)){const s=f.opts.passContext?t.default.this:t.default.self,a=!("compile"in i&&!h||!1===i.schema);d.assign(y,e._`${n}${(0,r.callValidateCode)(o,g,s,a)}`,i.modifying)}function v(t){var r;d.if((0,e.not)(null!==(r=i.valid)&&void 0!==r?r:y),t)}o.block$data(y,function(){if(!1===i.errors)_(),i.modifying&&s(o),v(()=>o.error());else{const r=i.async?function(){const t=d.let("ruleErrs",null);return d.try(()=>_(e._`await `),r=>d.assign(y,!1).if(e._`${r} instanceof ${f.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}();i.modifying&&s(o),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())}(o,r))}}),o.ok(null!==(c=i.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 o=s.dependencies;if(null==o?void 0:o.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw new Error(`parent schema must have dependencies of ${a}: ${o.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}(),o=function(){if(Zu)return Fu;Zu=1,Object.defineProperty(Fu,"__esModule",{value:!0}),Fu.extendSubschemaMode=Fu.extendSubschemaData=Fu.getSubschema=void 0;const e=pu(),t=mu();return Fu.getSubschema=function(r,{keyword:n,schemaProp:s,schema:a,schemaPath:o,errSchemaPath:i,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===o||void 0===i||void 0===c)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')},Fu.extendSubschemaData=function(r,n,{dataProp:s,dataPropType:a,data:o,dataTypes:i,propertyName:c}){if(void 0!==o&&void 0!==s)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:d}=n;if(void 0!==s){const{errorPath:o,dataPathArr:i,opts:c}=n;u(d.let("data",e._`${n.data}${(0,e.getProperty)(s)}`,!0)),r.errorPath=e.str`${o}${(0,t.getErrorPath)(s,a,c.jsPropertySyntax)}`,r.parentDataProperty=e._`${s}`,r.dataPathArr=[...i,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!==o&&(u(o instanceof e.Name?o:d.let("data",o,!0)),void 0!==c&&(r.propertyName=c)),i&&(r.dataTypes=i)},Fu.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},Fu}(),i=pu(),c=wu(),d=Gu(),u=mu(),l=bu();function p({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},a){s.code.es5?e.func(t,i._`${c.default.data}, ${c.default.valCxt}`,n.$async,()=>{e.code(i._`"use strict"; ${h(r,s)}`),function(e,t){e.if(c.default.valCxt,()=>{e.var(c.default.instancePath,i._`${c.default.valCxt}.${c.default.instancePath}`),e.var(c.default.parentData,i._`${c.default.valCxt}.${c.default.parentData}`),e.var(c.default.parentDataProperty,i._`${c.default.valCxt}.${c.default.parentDataProperty}`),e.var(c.default.rootData,i._`${c.default.valCxt}.${c.default.rootData}`),t.dynamicRef&&e.var(c.default.dynamicAnchors,i._`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{e.var(c.default.instancePath,i._`""`),e.var(c.default.parentData,i._`undefined`),e.var(c.default.parentDataProperty,i._`undefined`),e.var(c.default.rootData,c.default.data),t.dynamicRef&&e.var(c.default.dynamicAnchors,i._`{}`)})}(e,s),e.code(a)}):e.func(t,i._`${c.default.data}, ${function(e){return i._`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${e.dynamicRef?i._`, ${c.default.dynamicAnchors}={}`:i.nil}}={}`}(s)}`,n.$async,()=>e.code(h(r,s)).code(a))}function h(e,t){const r="object"==typeof e&&e[t.schemaId];return r&&(t.code.source||t.code.process)?i._`/*# sourceURL=${r} */`:i.nil}function f({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(i._`${c.default.self}.logger.log(${a})`);else if("function"==typeof s.$comment){const r=i.str`${n}/$comment`,s=e.scopeValue("root",{ref:t.root});e.code(i._`${c.default.self}.opts.$comment(${a}, ${r}, ${s}.schema)`)}}function v(e,t,s,a){const{gen:o,schema:d,data:l,allErrors:p,opts:h,self:f}=e,{RULES:m}=f;function g(u){(0,r.shouldUseGroup)(d,u)&&(u.type?(o.if((0,n.checkDataType)(u.type,l,h.strictNumbers)),w(e,u),1===t.length&&t[0]===u.type&&s&&(o.else(),(0,n.reportTypeError)(e)),o.endIf()):w(e,u),p||o.if(i._`${c.default.errors} === ${a||0}`))}!d.$ref||!h.ignoreKeywordsWithRef&&(0,u.schemaHasRulesButRef)(d,m)?(h.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),o.block(()=>{for(const e of m.rules)g(e);g(m.post)})):o.block(()=>E(e,"$ref",m.all.$ref.definition))}function w(e,t){const{gen:n,schema:a,opts:{useDefaults:o}}=e;o&&(0,s.assignDefaults)(e,t.type),n.block(()=>{for(const n of t.rules)(0,r.shouldUseRule)(a,n)&&E(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)}ru.validateFunctionCode=function(t){m(t)&&(g(t),f(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",i._`${r}.evaluated`),t.if(i._`${e.evaluated}.dynamicProps`,()=>t.assign(i._`${e.evaluated}.props`,i._`undefined`)),t.if(i._`${e.evaluated}.dynamicItems`,()=>t.assign(i._`${e.evaluated}.items`,i._`undefined`))}(e),y(e),function(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:a}=e;r.$async?t.if(i._`${c.default.errors} === 0`,()=>t.return(c.default.data),()=>t.throw(i._`new ${s}(${c.default.vErrors})`)):(t.assign(i._`${n}.errors`,c.default.vErrors),a.unevaluated&&function({gen:e,evaluated:t,props:r,items:n}){r instanceof i.Name&&e.assign(i._`${t}.props`,r),n instanceof i.Name&&e.assign(i._`${t}.items`,n)}(e),t.return(i._`${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,i.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,i.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(i._`${t} !== undefined && (${(0,i.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=i.nil){this.gen.block(()=>{this.check$data(e,r),t()})}check$data(e=i.nil,t=i.nil){if(!this.$data)return;const{gen:r,schemaCode:n,schemaType:s,def:a}=this;r.if((0,i.or)(i._`${n} === undefined`,t)),e!==i.nil&&r.assign(e,!0),(s.length||a.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),e!==i.nil&&r.assign(e,!1)),r.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:r,def:s,it:a}=this;return(0,i.or)(function(){if(r.length){if(!(t instanceof i.Name))throw new Error("ajv implementation error");const e=Array.isArray(r)?r:[r];return i._`${(0,n.checkDataTypes)(e,t,a.opts.strictNumbers,n.DataType.Wrong)}`}return i.nil}(),function(){if(s.validateSchema){const r=e.scopeValue("validate$data",{ref:s.validateSchema});return i._`!${r}(${t})`}return i.nil}())}subschema(t,r){const n=(0,o.getSubschema)(this.it,t);(0,o.extendSubschemaData)(n,this.it,t),(0,o.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return function(t,r){m(t)&&(g(t),f(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,i._`${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,i.Name)),!0}}function E(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)}ru.KeywordCxt=$;const S=/^\/(?:[^~]|~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(!S.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);s=e,a=c.default.rootData}else{const o=T.exec(e);if(!o)throw new Error(`Invalid JSON-pointer: ${e}`);const i=+o[1];if(s=o[2],"#"===s){if(i>=t)throw new Error(l("property/index",i));return n[t-i]}if(i>t)throw new Error(l("data",i));if(a=r[t-i],!s)return a}let o=a;const d=s.split("/");for(const e of d)e&&(a=i._`${a}${(0,i.getProperty)((0,u.unescapeJsonPointer)(e))}`,o=i._`${o} && ${a}`);return o;function l(e,r){return`Cannot access ${e} ${r} levels up, current level is ${t}`}}return ru.getData=x,ru}var Xu,Yu={};function Qu(){if(Xu)return Yu;Xu=1,Object.defineProperty(Yu,"__esModule",{value:!0});class e extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}}return Yu.default=e,Yu}var el,tl={};function rl(){if(el)return tl;el=1,Object.defineProperty(tl,"__esModule",{value:!0});const e=Gu();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 tl.default=t,tl}var nl,sl={};function al(){if(nl)return sl;nl=1,Object.defineProperty(sl,"__esModule",{value:!0}),sl.resolveSchema=sl.getCompilingSchema=sl.resolveRef=sl.compileSchema=sl.SchemaEnv=void 0;const e=pu(),t=Qu(),r=wu(),n=Gu(),s=mu(),a=Wu();class o{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 i(s){const o=d.call(this,s);if(o)return o;const i=(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 h;s.$async&&(h=p.scopeValue("Error",{ref:t.default,code:e._`require("ajv/dist/runtime/validation_error").default`}));const f=p.scopeName("validate");s.validateName=f;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:f,ValidationError:h,schema:s.schema,schemaEnv:s,rootId:i,baseId:s.baseId||i,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(f,{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:f,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:i.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 f.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 f.call(this,r,t)}if("object"==typeof(null==d?void 0:d.schema)){if(d.validate||i.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 o({schema:t,schemaId:r,root:e,baseId:a})}return f.call(this,r,d)}}sl.SchemaEnv=o,sl.compileSchema=i,sl.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 i=l.call(this,e,r);if(void 0===i){const n=null===(s=e.localRefs)||void 0===s?void 0:s[r],{schemaId:a}=this.opts;n&&(i=new o({schema:n,schemaId:a,root:e,baseId:t}))}return void 0!==i?e.refs[r]=c.call(this,i):void 0},sl.getCompilingSchema=d,sl.resolveSchema=p;const h=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function f(e,{baseId:t,schema:r,root:a}){var i;if("/"!==(null===(i=e.fragment)||void 0===i?void 0:i[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 o="object"==typeof(r=e)&&r[this.opts.schemaId];!h.has(a)&&o&&(t=(0,n.resolveUrl)(this.opts.uriResolver,t,o))}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 o({schema:r,schemaId:d,root:a,baseId:t}),c.schema!==c.root.schema?c:void 0}return sl}var ol,il,cl,dl,ul,ll,pl,hl={$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},fl={},ml={exports:{}};function gl(){if(il)return ol;il=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 o(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:""},o=[],i=[];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(i,o,n))break;u=s}else i.push(a);else{if(!0===c&&(d=!0),!u(i,o,n))break;if(++t>7){n.error=!0;break}r>0&&":"===e[r-1]&&(c=!0),o.push(":")}}return i.length&&(u===s?n.zone=i.join(""):d?o.push(i.join("")):o.push(r(i))),n.address=o.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 ol={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=o(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:o,stringArrayToHexStripped:r},ol}function yl(){return pl||(pl=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=Wu();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=pu();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=Qu(),s=rl(),a=Su(),o=al(),i=pu(),c=Gu(),d=Pu(),u=mu(),l=hl,p=function(){if(ll)return fl;ll=1,Object.defineProperty(fl,"__esModule",{value:!0});const e=function(){if(ul)return ml.exports;ul=1;const{normalizeIPv6:e,removeDotSegments:t,recomposeAuthority:r,normalizeComponentEncoding:n,isIPv4:s,nonSimpleDomain:a}=gl(),{SCHEMES:o,getSchemeHandler:i}=function(){if(dl)return cl;dl=1;const{isUUID:e}=gl(),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 o={scheme:"http",domainHost:!0,parse:s,serialize:a},i={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:o,https:{scheme:"https",domainHost:o.domainHost,parse:s,serialize:a},ws:i,wss:{scheme:"wss",domainHost:i.domainHost,parse:i.parse,serialize:i.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,o=e.nss;return a.path=`${n||t.nid}:${o}`,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),cl={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),o=[],c=i(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&&o.push(s.scheme,":");const d=r(s);if(void 0!==d&&("suffix"!==a.reference&&o.push("//"),o.push(d),s.path&&"/"!==s.path[0]&&o.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)),o.push(e)}return void 0!==s.query&&o.push("?",s.query),void 0!==s.fragment&&o.push("#",s.fragment),o.join("")}const u=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function l(t,r){const n=Object.assign({},r),o={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(o.scheme=d[1],o.userinfo=d[3],o.host=d[4],o.port=parseInt(d[5],10),o.path=d[6]||"",o.query=d[7],o.fragment=d[8],isNaN(o.port)&&(o.port=d[5]),o.host)if(!1===s(o.host)){const t=e(o.host);o.host=t.host.toLowerCase(),c=t.isIPV6}else c=!0;void 0!==o.scheme||void 0!==o.userinfo||void 0!==o.host||void 0!==o.port||void 0!==o.query||o.path?void 0===o.scheme?o.reference="relative":void 0===o.fragment?o.reference="absolute":o.reference="uri":o.reference="same-document",n.reference&&"suffix"!==n.reference&&n.reference!==o.reference&&(o.error=o.error||"URI is not a "+n.reference+" reference.");const r=i(n.scheme||o.scheme);if(!(n.unicodeSupport||r&&r.unicodeSupport)&&o.host&&(n.domainHost||r&&r.domainHost)&&!1===c&&a(o.host))try{o.host=URL.domainToASCII(o.host.toLowerCase())}catch(e){o.error=o.error||"Host's domain name can not be converted to ASCII: "+e}(!r||r&&!r.skipNormalize)&&(-1!==t.indexOf("%")&&(void 0!==o.scheme&&(o.scheme=unescape(o.scheme)),void 0!==o.host&&(o.host=unescape(o.host))),o.path&&(o.path=escape(unescape(o.path))),o.fragment&&(o.fragment=encodeURI(decodeURIComponent(o.fragment)))),r&&r.parse&&r.parse(o,n)}else o.error=o.error||"URI can not be parsed.";return o}const p={SCHEMES:o,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 ml.exports=p,ml.exports.default=p,ml.exports.fastUri=p,ml.exports}();return e.code='require("ajv/dist/runtime/uri").default',fl.default=e,fl}(),h=(e,t)=>new RegExp(e,t);h.code="new RegExp";const f=["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,o,i,c,d,u,l,f,m,g,y,_,v,w,b,k,$,E,S,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:h,R=null!==(s=e.uriResolver)&&void 0!==s?s:p.default;return{strictSchema:null===(o=null!==(a=e.strictSchema)&&void 0!==a?a:N)||void 0===o||o,strictNumbers:null===(c=null!==(i=e.strictNumbers)&&void 0!==i?i:N)||void 0===c||c,strictTypes:null!==(u=null!==(d=e.strictTypes)&&void 0!==d?d:N)&&void 0!==u?u:"log",strictTuples:null!==(f=null!==(l=e.strictTuples)&&void 0!==l?l:N)&&void 0!==f?f:"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===(E=e.validateSchema)||void 0===E||E,validateFormats:null===(S=e.validateFormats)||void 0===S||S,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 i.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=S.call(this),e.formats&&$.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&E.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||o.call(this,r)}async function a(e){e&&!this.getSchema(e)&&await n.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof s.default))throw t;return i.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function i({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 o.SchemaEnv({schema:{},schemaId:r});if(t=o.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]=C(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:i}=this.opts;if("object"==typeof e)a=e[i];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 o.SchemaEnv({schema:e,schemaId:i,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):o.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{o.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 E(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 S(){const e={...this.opts};for(const t of f)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 o=s?a.post:a.rules.find(({type:e})=>e===r);if(o||(o={type:r,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;const i={keyword:e,definition:{...t,type:(0,d.getJSONTypes)(t.type),schemaType:(0,d.getJSONTypes)(t.schemaType)}};t.before?P.call(this,o,i,t.before):o.rules.push(i),a.all[e]=i,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=C(t)),e.validateSchema=this.compile(t,!0))}const R={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function C(e){return{anyOf:[e,R]}}}(tu)),tu}var _l,vl,wl,bl={},kl={},$l={},El={};var Sl,Tl,xl,Nl,Ol={},Pl={},Il={},Rl={},Cl={};var zl,jl,Al,Ml={},Zl={},Dl={};var Ll,Fl,ql,Ul={},Vl={},Hl={};function Kl(){if(Fl)return Hl;Fl=1,Object.defineProperty(Hl,"__esModule",{value:!0});const e=Uu();return e.code='require("ajv/dist/runtime/equal").default',Hl.default=e,Hl}function Jl(){if(ql)return Vl;ql=1,Object.defineProperty(Vl,"__esModule",{value:!0});const e=Pu(),t=pu(),r=mu(),n=Kl(),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:o,$data:i,schema:c,parentSchema:d,schemaCode:u,it:l}=s;if(!i&&!c)return;const p=a.let("valid"),h=d.items?(0,e.getSchemaTypes)(d.items):[];function f(r,n){const i=a.name("item"),c=(0,e.checkDataTypes)(h,i,l.opts.strictNumbers,e.DataType.Wrong),d=a.const("indices",t._`{}`);a.for(t._`;${r}--;`,()=>{a.let(i,t._`${o}[${r}]`),a.if(c,t._`continue`),h.length>1&&a.if(t._`typeof ${i} == "string"`,t._`${i} += "_"`),a.if(t._`typeof ${d}[${i}] == "number"`,()=>{a.assign(n,t._`${d}[${i}]`),s.error(),a.assign(p,!1).break()}).code(t._`${d}[${i}] = ${r}`)})}function m(e,i){const c=(0,r.useFunc)(a,n.default),d=a.name("outer");a.label(d).for(t._`;${e}--;`,()=>a.for(t._`${i} = ${e}; ${i}--;`,()=>a.if(t._`${c}(${o}[${e}], ${o}[${i}])`,()=>{s.error(),a.assign(p,!1).break(d)})))}s.block$data(p,function(){const e=a.let("i",t._`${o}.length`),r=a.let("j");s.setParams({i:e,j:r}),a.assign(p,!0),a.if(t._`${e} > 1`,()=>(h.length>0&&!h.some(e=>"object"===e||"array"===e)?f:m)(e,r))},t._`${u} === false`),s.ok(p)}};return Vl.default=s,Vl}var Bl,Gl,Wl,Xl={},Yl={};function Ql(){if(Wl)return Ol;Wl=1,Object.defineProperty(Ol,"__esModule",{value:!0});const e=function(){if(Sl)return Pl;Sl=1,Object.defineProperty(Pl,"__esModule",{value:!0});const e=pu(),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 Pl.default=s,Pl}(),t=function(){if(Tl)return Il;Tl=1,Object.defineProperty(Il,"__esModule",{value:!0});const e=pu(),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,o=a.opts.multipleOfPrecision,i=r.let("res"),c=o?e._`Math.abs(Math.round(${i}) - ${i}) > 1e-${o}`:e._`${i} !== parseInt(${i})`;t.fail$data(e._`(${s} === 0 || (${i} = ${n}/${s}, ${c}))`)}};return Il.default=t,Il}(),r=function(){if(Nl)return Rl;Nl=1,Object.defineProperty(Rl,"__esModule",{value:!0});const e=pu(),t=mu(),r=function(){if(xl)return Cl;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 xl=1,Object.defineProperty(Cl,"__esModule",{value:!0}),Cl.default=e,e.code='require("ajv/dist/runtime/ucs2length").default',Cl}(),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:o,it:i}=n,c="maxLength"===s?e.operators.GT:e.operators.LT,d=!1===i.opts.unicode?e._`${a}.length`:e._`${(0,t.useFunc)(n.gen,r.default)}(${a})`;n.fail$data(e._`${d} ${c} ${o}`)}};return Rl.default=s,Rl}(),n=function(){if(zl)return Ml;zl=1,Object.defineProperty(Ml,"__esModule",{value:!0});const e=Mu(),t=pu(),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:o,it:i}=r,c=i.opts.unicodeRegExp?"u":"",d=s?t._`(new RegExp(${o}, ${c}))`:(0,e.usePattern)(r,a);r.fail$data(t._`!${d}.test(${n})`)}};return Ml.default=r,Ml}(),s=function(){if(jl)return Zl;jl=1,Object.defineProperty(Zl,"__esModule",{value:!0});const e=pu(),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 Zl.default=r,Zl}(),a=function(){if(Al)return Dl;Al=1,Object.defineProperty(Dl,"__esModule",{value:!0});const e=Mu(),t=pu(),r=mu(),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:o,data:i,$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,o,()=>{s.assign(a,(0,e.propertyInData)(s,i,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",o,t=>{n.setParams({missingProperty:t}),s.if((0,e.noPropertyInData)(s,i,t,u.ownProperties),()=>n.error())})}}};return Dl.default=n,Dl}(),o=function(){if(Ll)return Ul;Ll=1,Object.defineProperty(Ul,"__esModule",{value:!0});const e=pu(),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 Ul.default=r,Ul}(),i=Jl(),c=function(){if(Bl)return Xl;Bl=1,Object.defineProperty(Xl,"__esModule",{value:!0});const e=pu(),t=mu(),r=Kl(),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:o,schemaCode:i,schema:c}=n;o||c&&"object"==typeof c?n.fail$data(e._`!${(0,t.useFunc)(s,r.default)}(${a}, ${i})`):n.fail(e._`${c} !== ${a}`)}};return Xl.default=n,Xl}(),d=function(){if(Gl)return Yl;Gl=1,Object.defineProperty(Yl,"__esModule",{value:!0});const e=pu(),t=mu(),r=Kl(),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:o,schema:i,schemaCode:c,it:d}=n;if(!o&&0===i.length)throw new Error("enum must have non-empty array");const u=i.length>=d.opts.loopEnum;let l;const p=()=>null!=l?l:l=(0,t.useFunc)(s,r.default);let h;if(u||o)h=s.let("valid"),n.block$data(h,function(){s.assign(h,!1),s.forOf("v",c,t=>s.if(e._`${p()}(${a}, ${t})`,()=>s.assign(h,!0).break()))});else{if(!Array.isArray(i))throw new Error("ajv implementation error");const t=s.const("vSchema",c);h=(0,e.or)(...i.map((r,n)=>function(t,r){const n=i[r];return"object"==typeof n&&null!==n?e._`${p()}(${a}, ${t}[${r}])`:e._`${a} === ${n}`}(t,n)))}n.pass(h)}};return Yl.default=n,Yl}(),u=[e.default,t.default,r.default,n.default,s.default,a.default,o.default,i.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},c.default,d.default];return Ol.default=u,Ol}var ep,tp={},rp={};function np(){if(ep)return rp;ep=1,Object.defineProperty(rp,"__esModule",{value:!0}),rp.validateAdditionalItems=void 0;const e=pu(),t=mu(),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:o,keyword:i,it:c}=r;c.items=!0;const d=s.const("len",e._`${o}.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:i,dataProp:n,dataPropType:t.Type.Num},a),c.allErrors||s.if((0,e.not)(a),()=>s.break())})}(a)),r.ok(a)}}return rp.validateAdditionalItems=n,rp.default=r,rp}var sp,ap,op={},ip={};function cp(){if(sp)return ip;sp=1,Object.defineProperty(ip,"__esModule",{value:!0}),ip.validateTuple=void 0;const e=pu(),t=mu(),r=Mu(),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:o,data:i,keyword:c,it:d}=r;!function(e){const{opts:r,errSchemaPath:a}=d,o=s.length,i=o===e.minItems&&(o===e.maxItems||!1===e[n]);if(r.strictTuples&&!i){const e=`"${c}" is ${o}-tuple, but minItems or maxItems/${n} are not specified or different at path "${a}"`;(0,t.checkStrictMode)(d,e,r.strictTuples)}}(o),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._`${i}.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 ip.validateTuple=s,ip.default=n,ip}var dp,up,lp={},pp={};var hp,fp={};var mp,gp,yp={},_p={};function vp(){if(gp)return _p;gp=1,Object.defineProperty(_p,"__esModule",{value:!0});const e=Mu(),t=pu(),r=wu(),n=mu(),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:o,parentSchema:i,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,o))return;const h=(0,e.allSchemaProperties)(i.properties),f=(0,e.allSchemaProperties)(i.patternProperties);function m(e){a.code(t._`delete ${c}[${e}]`)}function g(e){if("all"===p.removeAdditional||p.removeAdditional&&!1===o)m(e);else{if(!1===o)return s.setParams({additionalProperty:e}),s.error(),void(l||a.break());if("object"==typeof o&&!(0,n.alwaysValidSchema)(u,o)){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=>{h.length||f.length?a.if(function(r){let o;if(h.length>8){const t=(0,n.schemaRefOrVal)(u,i.properties,"properties");o=(0,e.isOwnProperty)(a,t,r)}else o=h.length?(0,t.or)(...h.map(e=>t._`${r} === ${e}`)):t.nil;return f.length&&(o=(0,t.or)(o,...f.map(n=>t._`${(0,e.usePattern)(s,n)}.test(${r})`))),(0,t.not)(o)}(r),()=>g(r)):g(r)}),s.ok(t._`${d} === ${r.default.errors}`)}};return _p.default=s,_p}var wp,bp,kp,$p,Ep,Sp,Tp,xp,Np,Op={},Pp={},Ip={},Rp={},Cp={},zp={},jp={},Ap={};function Mp(){if(Np)return tp;Np=1,Object.defineProperty(tp,"__esModule",{value:!0});const e=np(),t=function(){if(ap)return op;ap=1,Object.defineProperty(op,"__esModule",{value:!0});const e=cp(),t={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,e.validateTuple)(t,"items")};return op.default=t,op}(),r=cp(),n=function(){if(dp)return lp;dp=1,Object.defineProperty(lp,"__esModule",{value:!0});const e=pu(),t=mu(),r=Mu(),n=np(),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:o}=e,{prefixItems:i}=a;o.items=!0,(0,t.alwaysValidSchema)(o,s)||(i?(0,n.validateAdditionalItems)(e,i):e.ok((0,r.validateArray)(e)))}};return lp.default=s,lp}(),s=function(){if(up)return pp;up=1,Object.defineProperty(pp,"__esModule",{value:!0});const e=pu(),t=mu(),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:o,it:i}=r;let c,d;const{minContains:u,maxContains:l}=a;i.opts.next?(c=void 0===u?1:u,d=l):c=1;const p=n.const("len",e._`${o}.length`);if(r.setParams({min:c,max:d}),void 0===d&&0===c)return void(0,t.checkStrictMode)(i,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==d&&c>d)return(0,t.checkStrictMode)(i,'"minContains" > "maxContains" is always invalid'),void r.fail();if((0,t.alwaysValidSchema)(i,s)){let t=e._`${p} >= ${c}`;return void 0!==d&&(t=e._`${t} && ${p} <= ${d}`),void r.pass(t)}i.items=!0;const h=n.name("valid");function f(){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(h,!0).break()):(n.if(e._`${t} > ${d}`,()=>n.assign(h,!1).break()),1===c?n.assign(h,!0):n.if(e._`${t} >= ${c}`,()=>n.assign(h,!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(h,()=>n.if(h,()=>n.break())):0===c?(n.let(h,!0),void 0!==d&&n.if(e._`${o}.length > 0`,f)):(n.let(h,!1),f()),r.result(h,()=>r.reset())}};return pp.default=r,pp}(),a=(hp||(hp=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=pu(),r=mu(),n=Mu();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 i=new Set(["string","number","integer","boolean","null"]);function c(e,t,r,s=a.Correct){const o=s===a.Correct?n.operators.EQ:n.operators.NEQ;let i;switch(e){case"null":return n._`${t} ${o} null`;case"array":i=n._`Array.isArray(${t})`;break;case"object":i=n._`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":i=c(n._`!(${t} % 1) && !isNaN(${t})`);break;case"number":i=c();break;default:return n._`typeof ${t} ${o} ${e}`}return s===a.Correct?i:(0,n.not)(i);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 o;const i=(0,s.toHash)(e);if(i.array&&i.object){const e=n._`typeof ${t} != "object"`;o=i.null?e:n._`!${t} || ${e}`,delete i.null,delete i.array,delete i.object}else o=n.nil;i.number&&delete i.integer;for(const e in i)o=(0,n.and)(o,c(e,t,r,a));return o}$u.checkDataType=c,$u.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 $u.reportTypeError=l,$u}var Iu,Ru,zu,ju={},Cu={},Au={};function Mu(){if(Ru)return Au;Ru=1,Object.defineProperty(Au,"__esModule",{value:!0}),Au.validateUnion=Au.validateArray=Au.usePattern=Au.callValidateCode=Au.schemaProperties=Au.allSchemaProperties=Au.noPropertyInData=Au.propertyInData=Au.isOwnProperty=Au.hasPropFunc=Au.reportMissingProp=Au.checkMissingProp=Au.checkReportMissingProp=void 0;const e=pu(),t=mu(),r=wu(),n=mu();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 o(t,r,n,s){const o=e._`${r}${(0,e.getProperty)(n)} === undefined`;return s?(0,e.or)(o,(0,e.not)(a(t,r,n))):o}function i(e){return e?Object.keys(e).filter(e=>"__proto__"!==e):[]}Au.checkReportMissingProp=function(t,r){const{gen:n,data:s,it:a}=t;n.if(o(n,s,r,a.opts.ownProperties),()=>{t.setParams({missingProperty:e._`${r}`},!0),t.error()})},Au.checkMissingProp=function({gen:t,data:r,it:{opts:n}},s,a){return(0,e.or)(...s.map(s=>(0,e.and)(o(t,r,s,n.ownProperties),e._`${a} = ${s}`)))},Au.reportMissingProp=function(e,t){e.setParams({missingProperty:t},!0),e.error()},Au.hasPropFunc=s,Au.isOwnProperty=a,Au.propertyInData=function(t,r,n,s){const o=e._`${r}${(0,e.getProperty)(n)} !== undefined`;return s?e._`${o} && ${a(t,r,n)}`:o},Au.noPropertyInData=o,Au.allSchemaProperties=i,Au.schemaProperties=function(e,r){return i(r).filter(n=>!(0,t.alwaysValidSchema)(e,r[n]))},Au.callValidateCode=function({schemaCode:t,data:n,it:{gen:s,topSchemaRef:a,schemaPath:o,errorPath:i},it:c},d,u,l){const p=l?e._`${t}, ${n}, ${a}${o}`:n,h=[[r.default.instancePath,(0,e.strConcat)(r.default.instancePath,i)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&h.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const f=e._`${p}, ${s.object(...h)}`;return u!==e.nil?e._`${d}.call(${u}, ${f})`:e._`${d}(${f})`};const c=e._`new RegExp`;return Au.usePattern=function({gen:t,it:{opts:r}},s){const a=r.unicodeRegExp?"u":"",{regExp:o}=r.code,i=o(s,a);return t.scopeValue("pattern",{key:i.toString(),ref:i,code:e._`${"new RegExp"===o.code?c:(0,n.useFunc)(t,o)}(${s}, ${a})`})},Au.validateArray=function(r){const{gen:n,data:s,keyword:a,it:o}=r,i=n.name("valid");if(o.allErrors){const e=n.let("valid",!0);return c(()=>n.assign(e,!1)),e}return n.var(i,!0),c(()=>n.break()),i;function c(o){const c=n.const("len",e._`${s}.length`);n.forRange("i",0,c,s=>{r.subschema({keyword:a,dataProp:s,dataPropType:t.Type.Num},i),n.if((0,e.not)(i),o)})}},Au.validateUnion=function(r){const{gen:n,schema:s,keyword:a,it:o}=r;if(!Array.isArray(s))throw new Error("ajv implementation error");if(s.some(e=>(0,t.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;const i=n.let("valid",!1),c=n.name("_valid");n.block(()=>s.forEach((t,s)=>{const o=r.subschema({keyword:a,schemaProp:s,compositeRule:!0},c);n.assign(i,e._`${i} || ${c}`),r.mergeValidEvaluated(o,c)||n.if((0,e.not)(i))})),r.result(i,()=>r.reset(),()=>r.error(!0))},Au}var Zu,Du,Lu,Fu={},qu={};function Uu(){return Lu||(Lu=1,Du=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 o=a[s];if(!e(t[o],r[o]))return!1}return!0}return t!=t&&r!=r}),Du}var Vu,Hu,Ju,Ku={exports:{}};function Bu(){if(Vu)return Ku.exports;Vu=1;var e=Ku.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,o,i,c,d,u,l,p){if(o&&"object"==typeof o&&!Array.isArray(o)){for(var h in s(o,i,c,d,u,l,p),o){var f=o[h];if(Array.isArray(f)){if(h in e.arrayKeywords)for(var m=0;m<f.length;m++)t(n,s,a,f[m],i+"/"+h+"/"+m,c,i,h,o,m)}else if(h in e.propsKeywords){if(f&&"object"==typeof f)for(var g in f)t(n,s,a,f[g],i+"/"+h+"/"+r(g),c,i,h,o,g)}else(h in e.keywords||n.allKeys&&!(h in e.skipKeywords))&&t(n,s,a,f,i+"/"+h,c,i,h,o)}a(o,i,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},Ku.exports}function Gu(){if(Hu)return qu;Hu=1,Object.defineProperty(qu,"__esModule",{value:!0}),qu.getSchemaRefs=qu.resolveUrl=qu.normalizeId=qu._getFullPath=qu.getFullPath=qu.inlineRef=void 0;const e=mu(),t=Uu(),r=Bu(),n=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);qu.inlineRef=function(e,t=!0){return"boolean"==typeof e||(!0===t?!a(e):!!t&&o(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 o(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+=o(e)),r===1/0))return 1/0}return r}function i(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]+"#"}qu.getFullPath=i,qu._getFullPath=c;const d=/#\/?$/;function u(e){return e?e.replace(d,""):""}qu.normalizeId=u,qu.resolveUrl=function(e,t,r){return r=u(r),e.resolve(t,r)};const l=/^[a-z_][-a-z0-9._]*$/i;return qu.getSchemaRefs=function(e,n){if("boolean"==typeof e)return{};const{schemaId:s,uriResolver:a}=this.opts,o=u(e[s]||n),c={"":o},d=i(a,o,!1),p={},h=new Set;return r(e,{allKeys:!0},(e,t,r,n)=>{if(void 0===n)return;const a=d+t;let o=c[n];function i(t){const r=this.opts.uriResolver.resolve;if(t=u(o?r(o,t):t),h.has(t))throw m(t);h.add(t);let n=this.refs[t];return"string"==typeof n&&(n=this.refs[n]),"object"==typeof n?f(e,n.schema,t):t!==u(a)&&("#"===t[0]?(f(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}"`);i.call(this,`#${e}`)}}"string"==typeof e[s]&&(o=i.call(this,e[s])),g.call(this,e.$anchor),g.call(this,e.$dynamicAnchor),c[t]=o}),p;function f(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`)}},qu}function Wu(){if(Ju)return ru;Ju=1,Object.defineProperty(ru,"__esModule",{value:!0}),ru.getData=ru.KeywordCxt=ru.validateFunctionCode=void 0;const e=function(){if(_u)return nu;_u=1,Object.defineProperty(nu,"__esModule",{value:!0}),nu.boolOrEmptySchema=nu.topBoolOrEmptySchema=void 0;const e=bu(),t=pu(),r=wu(),n={message:"boolean schema is false"};function s(t,r){const{gen:s,data:a}=t,o={gen:s,keyword:"false schema",data:a,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,e.reportError)(o,n,void 0,r)}return nu.topBoolOrEmptySchema=function(e){const{gen:n,schema:a,validateName:o}=e;!1===a?s(e,!1):"object"==typeof a&&!0===a.$async?n.return(r.default.data):(n.assign(t._`${o}.errors`,null),n.return(!0))},nu.boolOrEmptySchema=function(e,t){const{gen:r,schema:n}=e;!1===n?(r.var(t,!1),s(e)):r.var(t,!0)},nu}(),t=Pu(),r=Ou(),n=Pu(),s=function(){if(Iu)return ju;Iu=1,Object.defineProperty(ju,"__esModule",{value:!0}),ju.assignDefaults=void 0;const e=pu(),t=mu();function r(r,n,s){const{gen:a,compositeRule:o,data:i,opts:c}=r;if(void 0===s)return;const d=e._`${i}${(0,e.getProperty)(n)}`;if(o)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(zu)return Cu;zu=1,Object.defineProperty(Cu,"__esModule",{value:!0}),Cu.validateKeywordUsage=Cu.validSchemaType=Cu.funcKeywordCode=Cu.macroKeywordCode=void 0;const e=pu(),t=wu(),r=Mu(),n=bu();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 Cu.macroKeywordCode=function(t,r){const{gen:n,keyword:s,schema:o,parentSchema:i,it:c}=t,d=r.macro.call(c.self,o,i,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))},Cu.funcKeywordCode=function(o,i){var c;const{gen:d,keyword:u,schema:l,parentSchema:p,$data:h,it:f}=o;!function({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}(f,i);const m=!h&&i.compile?i.compile.call(f.self,l,p,f):i.validate,g=a(d,u,m),y=d.let("valid");function _(n=(i.async?e._`await `:e.nil)){const s=f.opts.passContext?t.default.this:t.default.self,a=!("compile"in i&&!h||!1===i.schema);d.assign(y,e._`${n}${(0,r.callValidateCode)(o,g,s,a)}`,i.modifying)}function v(t){var r;d.if((0,e.not)(null!==(r=i.valid)&&void 0!==r?r:y),t)}o.block$data(y,function(){if(!1===i.errors)_(),i.modifying&&s(o),v(()=>o.error());else{const r=i.async?function(){const t=d.let("ruleErrs",null);return d.try(()=>_(e._`await `),r=>d.assign(y,!1).if(e._`${r} instanceof ${f.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}();i.modifying&&s(o),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())}(o,r))}}),o.ok(null!==(c=i.valid)&&void 0!==c?c:y)},Cu.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)},Cu.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 o=s.dependencies;if(null==o?void 0:o.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw new Error(`parent schema must have dependencies of ${a}: ${o.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)}},Cu}(),o=function(){if(Zu)return Fu;Zu=1,Object.defineProperty(Fu,"__esModule",{value:!0}),Fu.extendSubschemaMode=Fu.extendSubschemaData=Fu.getSubschema=void 0;const e=pu(),t=mu();return Fu.getSubschema=function(r,{keyword:n,schemaProp:s,schema:a,schemaPath:o,errSchemaPath:i,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===o||void 0===i||void 0===c)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')},Fu.extendSubschemaData=function(r,n,{dataProp:s,dataPropType:a,data:o,dataTypes:i,propertyName:c}){if(void 0!==o&&void 0!==s)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:d}=n;if(void 0!==s){const{errorPath:o,dataPathArr:i,opts:c}=n;u(d.let("data",e._`${n.data}${(0,e.getProperty)(s)}`,!0)),r.errorPath=e.str`${o}${(0,t.getErrorPath)(s,a,c.jsPropertySyntax)}`,r.parentDataProperty=e._`${s}`,r.dataPathArr=[...i,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!==o&&(u(o instanceof e.Name?o:d.let("data",o,!0)),void 0!==c&&(r.propertyName=c)),i&&(r.dataTypes=i)},Fu.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},Fu}(),i=pu(),c=wu(),d=Gu(),u=mu(),l=bu();function p({gen:e,validateName:t,schema:r,schemaEnv:n,opts:s},a){s.code.es5?e.func(t,i._`${c.default.data}, ${c.default.valCxt}`,n.$async,()=>{e.code(i._`"use strict"; ${h(r,s)}`),function(e,t){e.if(c.default.valCxt,()=>{e.var(c.default.instancePath,i._`${c.default.valCxt}.${c.default.instancePath}`),e.var(c.default.parentData,i._`${c.default.valCxt}.${c.default.parentData}`),e.var(c.default.parentDataProperty,i._`${c.default.valCxt}.${c.default.parentDataProperty}`),e.var(c.default.rootData,i._`${c.default.valCxt}.${c.default.rootData}`),t.dynamicRef&&e.var(c.default.dynamicAnchors,i._`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{e.var(c.default.instancePath,i._`""`),e.var(c.default.parentData,i._`undefined`),e.var(c.default.parentDataProperty,i._`undefined`),e.var(c.default.rootData,c.default.data),t.dynamicRef&&e.var(c.default.dynamicAnchors,i._`{}`)})}(e,s),e.code(a)}):e.func(t,i._`${c.default.data}, ${function(e){return i._`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${e.dynamicRef?i._`, ${c.default.dynamicAnchors}={}`:i.nil}}={}`}(s)}`,n.$async,()=>e.code(h(r,s)).code(a))}function h(e,t){const r="object"==typeof e&&e[t.schemaId];return r&&(t.code.source||t.code.process)?i._`/*# sourceURL=${r} */`:i.nil}function f({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(i._`${c.default.self}.logger.log(${a})`);else if("function"==typeof s.$comment){const r=i.str`${n}/$comment`,s=e.scopeValue("root",{ref:t.root});e.code(i._`${c.default.self}.opts.$comment(${a}, ${r}, ${s}.schema)`)}}function v(e,t,s,a){const{gen:o,schema:d,data:l,allErrors:p,opts:h,self:f}=e,{RULES:m}=f;function g(u){(0,r.shouldUseGroup)(d,u)&&(u.type?(o.if((0,n.checkDataType)(u.type,l,h.strictNumbers)),w(e,u),1===t.length&&t[0]===u.type&&s&&(o.else(),(0,n.reportTypeError)(e)),o.endIf()):w(e,u),p||o.if(i._`${c.default.errors} === ${a||0}`))}!d.$ref||!h.ignoreKeywordsWithRef&&(0,u.schemaHasRulesButRef)(d,m)?(h.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),o.block(()=>{for(const e of m.rules)g(e);g(m.post)})):o.block(()=>S(e,"$ref",m.all.$ref.definition))}function w(e,t){const{gen:n,schema:a,opts:{useDefaults:o}}=e;o&&(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)}ru.validateFunctionCode=function(t){m(t)&&(g(t),f(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",i._`${r}.evaluated`),t.if(i._`${e.evaluated}.dynamicProps`,()=>t.assign(i._`${e.evaluated}.props`,i._`undefined`)),t.if(i._`${e.evaluated}.dynamicItems`,()=>t.assign(i._`${e.evaluated}.items`,i._`undefined`))}(e),y(e),function(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:s,opts:a}=e;r.$async?t.if(i._`${c.default.errors} === 0`,()=>t.return(c.default.data),()=>t.throw(i._`new ${s}(${c.default.vErrors})`)):(t.assign(i._`${n}.errors`,c.default.vErrors),a.unevaluated&&function({gen:e,evaluated:t,props:r,items:n}){r instanceof i.Name&&e.assign(i._`${t}.props`,r),n instanceof i.Name&&e.assign(i._`${t}.items`,n)}(e),t.return(i._`${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,i.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,i.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(i._`${t} !== undefined && (${(0,i.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=i.nil){this.gen.block(()=>{this.check$data(e,r),t()})}check$data(e=i.nil,t=i.nil){if(!this.$data)return;const{gen:r,schemaCode:n,schemaType:s,def:a}=this;r.if((0,i.or)(i._`${n} === undefined`,t)),e!==i.nil&&r.assign(e,!0),(s.length||a.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),e!==i.nil&&r.assign(e,!1)),r.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:r,def:s,it:a}=this;return(0,i.or)(function(){if(r.length){if(!(t instanceof i.Name))throw new Error("ajv implementation error");const e=Array.isArray(r)?r:[r];return i._`${(0,n.checkDataTypes)(e,t,a.opts.strictNumbers,n.DataType.Wrong)}`}return i.nil}(),function(){if(s.validateSchema){const r=e.scopeValue("validate$data",{ref:s.validateSchema});return i._`!${r}(${t})`}return i.nil}())}subschema(t,r){const n=(0,o.getSubschema)(this.it,t);(0,o.extendSubschemaData)(n,this.it,t),(0,o.extendSubschemaMode)(n,t);const s={...this.it,...n,items:void 0,props:void 0};return function(t,r){m(t)&&(g(t),f(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,i._`${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,i.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)}ru.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 o=T.exec(e);if(!o)throw new Error(`Invalid JSON-pointer: ${e}`);const i=+o[1];if(s=o[2],"#"===s){if(i>=t)throw new Error(l("property/index",i));return n[t-i]}if(i>t)throw new Error(l("data",i));if(a=r[t-i],!s)return a}let o=a;const d=s.split("/");for(const e of d)e&&(a=i._`${a}${(0,i.getProperty)((0,u.unescapeJsonPointer)(e))}`,o=i._`${o} && ${a}`);return o;function l(e,r){return`Cannot access ${e} ${r} levels up, current level is ${t}`}}return ru.getData=x,ru}var Xu,Yu={};function Qu(){if(Xu)return Yu;Xu=1,Object.defineProperty(Yu,"__esModule",{value:!0});class e extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}}return Yu.default=e,Yu}var el,tl={};function rl(){if(el)return tl;el=1,Object.defineProperty(tl,"__esModule",{value:!0});const e=Gu();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 tl.default=t,tl}var nl,sl={};function al(){if(nl)return sl;nl=1,Object.defineProperty(sl,"__esModule",{value:!0}),sl.resolveSchema=sl.getCompilingSchema=sl.resolveRef=sl.compileSchema=sl.SchemaEnv=void 0;const e=pu(),t=Qu(),r=wu(),n=Gu(),s=mu(),a=Wu();class o{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 i(s){const o=d.call(this,s);if(o)return o;const i=(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 h;s.$async&&(h=p.scopeValue("Error",{ref:t.default,code:e._`require("ajv/dist/runtime/validation_error").default`}));const f=p.scopeName("validate");s.validateName=f;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:f,ValidationError:h,schema:s.schema,schemaEnv:s,rootId:i,baseId:s.baseId||i,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(f,{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:f,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:i.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 f.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 f.call(this,r,t)}if("object"==typeof(null==d?void 0:d.schema)){if(d.validate||i.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 o({schema:t,schemaId:r,root:e,baseId:a})}return f.call(this,r,d)}}sl.SchemaEnv=o,sl.compileSchema=i,sl.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 i=l.call(this,e,r);if(void 0===i){const n=null===(s=e.localRefs)||void 0===s?void 0:s[r],{schemaId:a}=this.opts;n&&(i=new o({schema:n,schemaId:a,root:e,baseId:t}))}return void 0!==i?e.refs[r]=c.call(this,i):void 0},sl.getCompilingSchema=d,sl.resolveSchema=p;const h=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function f(e,{baseId:t,schema:r,root:a}){var i;if("/"!==(null===(i=e.fragment)||void 0===i?void 0:i[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 o="object"==typeof(r=e)&&r[this.opts.schemaId];!h.has(a)&&o&&(t=(0,n.resolveUrl)(this.opts.uriResolver,t,o))}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 o({schema:r,schemaId:d,root:a,baseId:t}),c.schema!==c.root.schema?c:void 0}return sl}var ol,il,cl,dl,ul,ll,pl,hl={$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},fl={},ml={exports:{}};function gl(){if(il)return ol;il=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 o(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:""},o=[],i=[];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(i,o,n))break;u=s}else i.push(a);else{if(!0===c&&(d=!0),!u(i,o,n))break;if(++t>7){n.error=!0;break}r>0&&":"===e[r-1]&&(c=!0),o.push(":")}}return i.length&&(u===s?n.zone=i.join(""):d?o.push(i.join("")):o.push(r(i))),n.address=o.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 ol={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=o(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:o,stringArrayToHexStripped:r},ol}function yl(){return pl||(pl=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=Wu();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=pu();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=Qu(),s=rl(),a=Eu(),o=al(),i=pu(),c=Gu(),d=Pu(),u=mu(),l=hl,p=function(){if(ll)return fl;ll=1,Object.defineProperty(fl,"__esModule",{value:!0});const e=function(){if(ul)return ml.exports;ul=1;const{normalizeIPv6:e,removeDotSegments:t,recomposeAuthority:r,normalizeComponentEncoding:n,isIPv4:s,nonSimpleDomain:a}=gl(),{SCHEMES:o,getSchemeHandler:i}=function(){if(dl)return cl;dl=1;const{isUUID:e}=gl(),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 o={scheme:"http",domainHost:!0,parse:s,serialize:a},i={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:o,https:{scheme:"https",domainHost:o.domainHost,parse:s,serialize:a},ws:i,wss:{scheme:"wss",domainHost:i.domainHost,parse:i.parse,serialize:i.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,o=e.nss;return a.path=`${n||t.nid}:${o}`,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),cl={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),o=[],c=i(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&&o.push(s.scheme,":");const d=r(s);if(void 0!==d&&("suffix"!==a.reference&&o.push("//"),o.push(d),s.path&&"/"!==s.path[0]&&o.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)),o.push(e)}return void 0!==s.query&&o.push("?",s.query),void 0!==s.fragment&&o.push("#",s.fragment),o.join("")}const u=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function l(t,r){const n=Object.assign({},r),o={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(o.scheme=d[1],o.userinfo=d[3],o.host=d[4],o.port=parseInt(d[5],10),o.path=d[6]||"",o.query=d[7],o.fragment=d[8],isNaN(o.port)&&(o.port=d[5]),o.host)if(!1===s(o.host)){const t=e(o.host);o.host=t.host.toLowerCase(),c=t.isIPV6}else c=!0;void 0!==o.scheme||void 0!==o.userinfo||void 0!==o.host||void 0!==o.port||void 0!==o.query||o.path?void 0===o.scheme?o.reference="relative":void 0===o.fragment?o.reference="absolute":o.reference="uri":o.reference="same-document",n.reference&&"suffix"!==n.reference&&n.reference!==o.reference&&(o.error=o.error||"URI is not a "+n.reference+" reference.");const r=i(n.scheme||o.scheme);if(!(n.unicodeSupport||r&&r.unicodeSupport)&&o.host&&(n.domainHost||r&&r.domainHost)&&!1===c&&a(o.host))try{o.host=URL.domainToASCII(o.host.toLowerCase())}catch(e){o.error=o.error||"Host's domain name can not be converted to ASCII: "+e}(!r||r&&!r.skipNormalize)&&(-1!==t.indexOf("%")&&(void 0!==o.scheme&&(o.scheme=unescape(o.scheme)),void 0!==o.host&&(o.host=unescape(o.host))),o.path&&(o.path=escape(unescape(o.path))),o.fragment&&(o.fragment=encodeURI(decodeURIComponent(o.fragment)))),r&&r.parse&&r.parse(o,n)}else o.error=o.error||"URI can not be parsed.";return o}const p={SCHEMES:o,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 ml.exports=p,ml.exports.default=p,ml.exports.fastUri=p,ml.exports}();return e.code='require("ajv/dist/runtime/uri").default',fl.default=e,fl}(),h=(e,t)=>new RegExp(e,t);h.code="new RegExp";const f=["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,o,i,c,d,u,l,f,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:h,R=null!==(s=e.uriResolver)&&void 0!==s?s:p.default;return{strictSchema:null===(o=null!==(a=e.strictSchema)&&void 0!==a?a:N)||void 0===o||o,strictNumbers:null===(c=null!==(i=e.strictNumbers)&&void 0!==i?i:N)||void 0===c||c,strictTypes:null!==(u=null!==(d=e.strictTypes)&&void 0!==d?d:N)&&void 0!==u?u:"log",strictTuples:null!==(f=null!==(l=e.strictTuples)&&void 0!==l?l:N)&&void 0!==f?f:"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 i.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||o.call(this,r)}async function a(e){e&&!this.getSchema(e)&&await n.call(this,{$ref:e},!0)}async function o(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof s.default))throw t;return i.call(this,t),await c.call(this,t.missingSchema),o.call(this,e)}}function i({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 o.SchemaEnv({schema:{},schemaId:r});if(t=o.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]=z(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:i}=this.opts;if("object"==typeof e)a=e[i];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 o.SchemaEnv({schema:e,schemaId:i,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):o.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{o.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 f)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 o=s?a.post:a.rules.find(({type:e})=>e===r);if(o||(o={type:r,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;const i={keyword:e,definition:{...t,type:(0,d.getJSONTypes)(t.type),schemaType:(0,d.getJSONTypes)(t.schemaType)}};t.before?P.call(this,o,i,t.before):o.rules.push(i),a.all[e]=i,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=z(t)),e.validateSchema=this.compile(t,!0))}const R={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function z(e){return{anyOf:[e,R]}}}(tu)),tu}var _l,vl,wl,bl={},kl={},$l={},Sl={};var El,Tl,xl,Nl,Ol={},Pl={},Il={},Rl={},zl={};var jl,Cl,Al,Ml={},Zl={},Dl={};var Ll,Fl,ql,Ul={},Vl={},Hl={};function Jl(){if(Fl)return Hl;Fl=1,Object.defineProperty(Hl,"__esModule",{value:!0});const e=Uu();return e.code='require("ajv/dist/runtime/equal").default',Hl.default=e,Hl}function Kl(){if(ql)return Vl;ql=1,Object.defineProperty(Vl,"__esModule",{value:!0});const e=Pu(),t=pu(),r=mu(),n=Jl(),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:o,$data:i,schema:c,parentSchema:d,schemaCode:u,it:l}=s;if(!i&&!c)return;const p=a.let("valid"),h=d.items?(0,e.getSchemaTypes)(d.items):[];function f(r,n){const i=a.name("item"),c=(0,e.checkDataTypes)(h,i,l.opts.strictNumbers,e.DataType.Wrong),d=a.const("indices",t._`{}`);a.for(t._`;${r}--;`,()=>{a.let(i,t._`${o}[${r}]`),a.if(c,t._`continue`),h.length>1&&a.if(t._`typeof ${i} == "string"`,t._`${i} += "_"`),a.if(t._`typeof ${d}[${i}] == "number"`,()=>{a.assign(n,t._`${d}[${i}]`),s.error(),a.assign(p,!1).break()}).code(t._`${d}[${i}] = ${r}`)})}function m(e,i){const c=(0,r.useFunc)(a,n.default),d=a.name("outer");a.label(d).for(t._`;${e}--;`,()=>a.for(t._`${i} = ${e}; ${i}--;`,()=>a.if(t._`${c}(${o}[${e}], ${o}[${i}])`,()=>{s.error(),a.assign(p,!1).break(d)})))}s.block$data(p,function(){const e=a.let("i",t._`${o}.length`),r=a.let("j");s.setParams({i:e,j:r}),a.assign(p,!0),a.if(t._`${e} > 1`,()=>(h.length>0&&!h.some(e=>"object"===e||"array"===e)?f:m)(e,r))},t._`${u} === false`),s.ok(p)}};return Vl.default=s,Vl}var Bl,Gl,Wl,Xl={},Yl={};function Ql(){if(Wl)return Ol;Wl=1,Object.defineProperty(Ol,"__esModule",{value:!0});const e=function(){if(El)return Pl;El=1,Object.defineProperty(Pl,"__esModule",{value:!0});const e=pu(),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 Pl.default=s,Pl}(),t=function(){if(Tl)return Il;Tl=1,Object.defineProperty(Il,"__esModule",{value:!0});const e=pu(),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,o=a.opts.multipleOfPrecision,i=r.let("res"),c=o?e._`Math.abs(Math.round(${i}) - ${i}) > 1e-${o}`:e._`${i} !== parseInt(${i})`;t.fail$data(e._`(${s} === 0 || (${i} = ${n}/${s}, ${c}))`)}};return Il.default=t,Il}(),r=function(){if(Nl)return Rl;Nl=1,Object.defineProperty(Rl,"__esModule",{value:!0});const e=pu(),t=mu(),r=function(){if(xl)return zl;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 xl=1,Object.defineProperty(zl,"__esModule",{value:!0}),zl.default=e,e.code='require("ajv/dist/runtime/ucs2length").default',zl}(),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:o,it:i}=n,c="maxLength"===s?e.operators.GT:e.operators.LT,d=!1===i.opts.unicode?e._`${a}.length`:e._`${(0,t.useFunc)(n.gen,r.default)}(${a})`;n.fail$data(e._`${d} ${c} ${o}`)}};return Rl.default=s,Rl}(),n=function(){if(jl)return Ml;jl=1,Object.defineProperty(Ml,"__esModule",{value:!0});const e=Mu(),t=pu(),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:o,it:i}=r,c=i.opts.unicodeRegExp?"u":"",d=s?t._`(new RegExp(${o}, ${c}))`:(0,e.usePattern)(r,a);r.fail$data(t._`!${d}.test(${n})`)}};return Ml.default=r,Ml}(),s=function(){if(Cl)return Zl;Cl=1,Object.defineProperty(Zl,"__esModule",{value:!0});const e=pu(),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 Zl.default=r,Zl}(),a=function(){if(Al)return Dl;Al=1,Object.defineProperty(Dl,"__esModule",{value:!0});const e=Mu(),t=pu(),r=mu(),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:o,data:i,$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,o,()=>{s.assign(a,(0,e.propertyInData)(s,i,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",o,t=>{n.setParams({missingProperty:t}),s.if((0,e.noPropertyInData)(s,i,t,u.ownProperties),()=>n.error())})}}};return Dl.default=n,Dl}(),o=function(){if(Ll)return Ul;Ll=1,Object.defineProperty(Ul,"__esModule",{value:!0});const e=pu(),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 Ul.default=r,Ul}(),i=Kl(),c=function(){if(Bl)return Xl;Bl=1,Object.defineProperty(Xl,"__esModule",{value:!0});const e=pu(),t=mu(),r=Jl(),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:o,schemaCode:i,schema:c}=n;o||c&&"object"==typeof c?n.fail$data(e._`!${(0,t.useFunc)(s,r.default)}(${a}, ${i})`):n.fail(e._`${c} !== ${a}`)}};return Xl.default=n,Xl}(),d=function(){if(Gl)return Yl;Gl=1,Object.defineProperty(Yl,"__esModule",{value:!0});const e=pu(),t=mu(),r=Jl(),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:o,schema:i,schemaCode:c,it:d}=n;if(!o&&0===i.length)throw new Error("enum must have non-empty array");const u=i.length>=d.opts.loopEnum;let l;const p=()=>null!=l?l:l=(0,t.useFunc)(s,r.default);let h;if(u||o)h=s.let("valid"),n.block$data(h,function(){s.assign(h,!1),s.forOf("v",c,t=>s.if(e._`${p()}(${a}, ${t})`,()=>s.assign(h,!0).break()))});else{if(!Array.isArray(i))throw new Error("ajv implementation error");const t=s.const("vSchema",c);h=(0,e.or)(...i.map((r,n)=>function(t,r){const n=i[r];return"object"==typeof n&&null!==n?e._`${p()}(${a}, ${t}[${r}])`:e._`${a} === ${n}`}(t,n)))}n.pass(h)}};return Yl.default=n,Yl}(),u=[e.default,t.default,r.default,n.default,s.default,a.default,o.default,i.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},c.default,d.default];return Ol.default=u,Ol}var ep,tp={},rp={};function np(){if(ep)return rp;ep=1,Object.defineProperty(rp,"__esModule",{value:!0}),rp.validateAdditionalItems=void 0;const e=pu(),t=mu(),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:o,keyword:i,it:c}=r;c.items=!0;const d=s.const("len",e._`${o}.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:i,dataProp:n,dataPropType:t.Type.Num},a),c.allErrors||s.if((0,e.not)(a),()=>s.break())})}(a)),r.ok(a)}}return rp.validateAdditionalItems=n,rp.default=r,rp}var sp,ap,op={},ip={};function cp(){if(sp)return ip;sp=1,Object.defineProperty(ip,"__esModule",{value:!0}),ip.validateTuple=void 0;const e=pu(),t=mu(),r=Mu(),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:o,data:i,keyword:c,it:d}=r;!function(e){const{opts:r,errSchemaPath:a}=d,o=s.length,i=o===e.minItems&&(o===e.maxItems||!1===e[n]);if(r.strictTuples&&!i){const e=`"${c}" is ${o}-tuple, but minItems or maxItems/${n} are not specified or different at path "${a}"`;(0,t.checkStrictMode)(d,e,r.strictTuples)}}(o),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._`${i}.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 ip.validateTuple=s,ip.default=n,ip}var dp,up,lp={},pp={};var hp,fp={};var mp,gp,yp={},_p={};function vp(){if(gp)return _p;gp=1,Object.defineProperty(_p,"__esModule",{value:!0});const e=Mu(),t=pu(),r=wu(),n=mu(),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:o,parentSchema:i,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,o))return;const h=(0,e.allSchemaProperties)(i.properties),f=(0,e.allSchemaProperties)(i.patternProperties);function m(e){a.code(t._`delete ${c}[${e}]`)}function g(e){if("all"===p.removeAdditional||p.removeAdditional&&!1===o)m(e);else{if(!1===o)return s.setParams({additionalProperty:e}),s.error(),void(l||a.break());if("object"==typeof o&&!(0,n.alwaysValidSchema)(u,o)){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=>{h.length||f.length?a.if(function(r){let o;if(h.length>8){const t=(0,n.schemaRefOrVal)(u,i.properties,"properties");o=(0,e.isOwnProperty)(a,t,r)}else o=h.length?(0,t.or)(...h.map(e=>t._`${r} === ${e}`)):t.nil;return f.length&&(o=(0,t.or)(o,...f.map(n=>t._`${(0,e.usePattern)(s,n)}.test(${r})`))),(0,t.not)(o)}(r),()=>g(r)):g(r)}),s.ok(t._`${d} === ${r.default.errors}`)}};return _p.default=s,_p}var wp,bp,kp,$p,Sp,Ep,Tp,xp,Np,Op={},Pp={},Ip={},Rp={},zp={},jp={},Cp={},Ap={};function Mp(){if(Np)return tp;Np=1,Object.defineProperty(tp,"__esModule",{value:!0});const e=np(),t=function(){if(ap)return op;ap=1,Object.defineProperty(op,"__esModule",{value:!0});const e=cp(),t={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,e.validateTuple)(t,"items")};return op.default=t,op}(),r=cp(),n=function(){if(dp)return lp;dp=1,Object.defineProperty(lp,"__esModule",{value:!0});const e=pu(),t=mu(),r=Mu(),n=np(),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:o}=e,{prefixItems:i}=a;o.items=!0,(0,t.alwaysValidSchema)(o,s)||(i?(0,n.validateAdditionalItems)(e,i):e.ok((0,r.validateArray)(e)))}};return lp.default=s,lp}(),s=function(){if(up)return pp;up=1,Object.defineProperty(pp,"__esModule",{value:!0});const e=pu(),t=mu(),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:o,it:i}=r;let c,d;const{minContains:u,maxContains:l}=a;i.opts.next?(c=void 0===u?1:u,d=l):c=1;const p=n.const("len",e._`${o}.length`);if(r.setParams({min:c,max:d}),void 0===d&&0===c)return void(0,t.checkStrictMode)(i,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==d&&c>d)return(0,t.checkStrictMode)(i,'"minContains" > "maxContains" is always invalid'),void r.fail();if((0,t.alwaysValidSchema)(i,s)){let t=e._`${p} >= ${c}`;return void 0!==d&&(t=e._`${t} && ${p} <= ${d}`),void r.pass(t)}i.items=!0;const h=n.name("valid");function f(){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(h,!0).break()):(n.if(e._`${t} > ${d}`,()=>n.assign(h,!1).break()),1===c?n.assign(h,!0):n.if(e._`${t} >= ${c}`,()=>n.assign(h,!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(h,()=>n.if(h,()=>n.break())):0===c?(n.let(h,!0),void 0!==d&&n.if(e._`${o}.length > 0`,f)):(n.let(h,!1),f()),r.result(h,()=>r.reset())}};return pp.default=r,pp}(),a=(hp||(hp=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=pu(),r=mu(),n=Mu();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),o(e,r)}};function a(e,r=e.schema){const{gen:s,data:a,it:o}=e;if(0===Object.keys(r).length)return;const i=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,o.opts.ownProperties);e.setParams({property:c,depsCount:d.length,deps:d.join(", ")}),o.allErrors?s.if(u,()=>{for(const t of d)(0,n.checkReportMissingProp)(e,t)}):(s.if(t._`${u} && (${(0,n.checkMissingProp)(e,d,i)})`),(0,n.reportMissingProp)(e,i),s.else())}}function o(e,t=e.schema){const{gen:s,data:a,keyword:o,it:i}=e,c=s.name("valid");for(const d in t)(0,r.alwaysValidSchema)(i,t[d])||(s.if((0,n.propertyInData)(s,a,d,i.opts.ownProperties),()=>{const t=e.subschema({keyword:o,schemaProp:d},c);e.mergeValidEvaluated(t,c)},()=>s.var(c,!0)),e.ok(c))}e.validatePropertyDeps=a,e.validateSchemaDeps=o,e.default=s}(fp)),fp),o=function(){if(mp)return yp;mp=1,Object.defineProperty(yp,"__esModule",{value:!0});const e=pu(),t=mu(),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:o}=r;if((0,t.alwaysValidSchema)(o,s))return;const i=n.name("valid");n.forIn("key",a,t=>{r.setParams({propertyName:t}),r.subschema({keyword:"propertyNames",data:t,dataTypes:["string"],propertyName:t,compositeRule:!0},i),n.if((0,e.not)(i),()=>{r.error(!0),o.allErrors||n.break()})}),r.ok(i)}};return yp.default=r,yp}(),i=vp(),c=function(){if(wp)return Op;wp=1,Object.defineProperty(Op,"__esModule",{value:!0});const e=Wu(),t=Mu(),r=mu(),n=vp(),s={keyword:"properties",type:"object",schemaType:"object",code(s){const{gen:a,schema:o,parentSchema:i,data:c,it:d}=s;"all"===d.opts.removeAdditional&&void 0===i.additionalProperties&&n.default.code(new e.KeywordCxt(d,n.default,"additionalProperties"));const u=(0,t.allSchemaProperties)(o);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,o[e]));if(0===l.length)return;const p=a.name("valid");for(const e of l)h(e)?f(e):(a.if((0,t.propertyInData)(a,c,e,d.opts.ownProperties)),f(e),d.allErrors||a.else().var(p,!0),a.endIf()),s.it.definedProperties.add(e),s.ok(p);function h(e){return d.opts.useDefaults&&!d.compositeRule&&void 0!==o[e].default}function f(e){s.subschema({keyword:"properties",schemaProp:e,dataProp:e},p)}}};return Op.default=s,Op}(),d=function(){if(bp)return Pp;bp=1,Object.defineProperty(Pp,"__esModule",{value:!0});const e=Mu(),t=pu(),r=mu(),n=mu(),s={keyword:"patternProperties",type:"object",schemaType:"object",code(s){const{gen:a,schema:o,data:i,parentSchema:c,it:d}=s,{opts:u}=d,l=(0,e.allSchemaProperties)(o),p=l.filter(e=>(0,r.alwaysValidSchema)(d,o[e]));if(0===l.length||p.length===l.length&&(!d.opts.unevaluated||!0===d.props))return;const h=u.strictSchema&&!u.allowMatchingProperties&&c.properties,f=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 h)new RegExp(e).test(t)&&(0,r.checkStrictMode)(d,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function y(r){a.forIn("key",i,o=>{a.if(t._`${(0,e.usePattern)(s,r)}.test(${o})`,()=>{const e=p.includes(r);e||s.subschema({keyword:"patternProperties",schemaProp:r,dataProp:o,dataPropType:n.Type.Str},f),d.opts.unevaluated&&!0!==m?a.assign(t._`${m}[${o}]`,!0):e||d.allErrors||a.if((0,t.not)(f),()=>a.break())})})}!function(){for(const e of l)h&&g(e),d.allErrors?y(e):(a.var(f,!0),y(e),a.if(f))}()}};return Pp.default=s,Pp}(),u=function(){if(kp)return Ip;kp=1,Object.defineProperty(Ip,"__esModule",{value:!0});const e=mu(),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 Ip.default=t,Ip}(),l=function(){if($p)return Rp;$p=1,Object.defineProperty(Rp,"__esModule",{value:!0});const e={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Mu().validateUnion,error:{message:"must match a schema in anyOf"}};return Rp.default=e,Rp}(),p=function(){if(Ep)return Cp;Ep=1,Object.defineProperty(Cp,"__esModule",{value:!0});const e=pu(),t=mu(),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:o}=r;if(!Array.isArray(s))throw new Error("ajv implementation error");if(o.opts.discriminator&&a.discriminator)return;const i=s,c=n.let("valid",!1),d=n.let("passing",null),u=n.name("_valid");r.setParams({passing:d}),n.block(function(){i.forEach((s,a)=>{let i;(0,t.alwaysValidSchema)(o,s)?n.var(u,!0):i=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),i&&r.mergeEvaluated(i,e.Name)})})}),r.result(c,()=>r.reset(),()=>r.error(!0))}};return Cp.default=r,Cp}(),h=function(){if(Sp)return zp;Sp=1,Object.defineProperty(zp,"__esModule",{value:!0});const e=mu(),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 o=t.subschema({keyword:"allOf",schemaProp:n},a);t.ok(a),t.mergeEvaluated(o)})}};return zp.default=t,zp}(),f=function(){if(Tp)return jp;Tp=1,Object.defineProperty(jp,"__esModule",{value:!0});const e=pu(),t=mu(),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:o}=r;void 0===a.then&&void 0===a.else&&(0,t.checkStrictMode)(o,'"if" without "then" and "else" is ignored');const i=n(o,"then"),c=n(o,"else");if(!i&&!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(),i&&c){const e=s.let("ifClause");r.setParams({ifClause:e}),s.if(u,l("then",e),l("else",e))}else i?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(xp)return Ap;xp=1,Object.defineProperty(Ap,"__esModule",{value:!0});const e=mu(),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 Ap.default=t,Ap}();return tp.default=function(g=!1){const y=[u.default,l.default,p.default,h.default,f.default,m.default,o.default,i.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},tp}var Zp,Dp,Lp={},Fp={};function qp(){if(Zp)return Fp;Zp=1,Object.defineProperty(Fp,"__esModule",{value:!0});const e=pu(),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:o,schemaCode:i,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}),o=n.const("fDef",e._`${a}[${i}]`),c=n.let("fType"),u=n.let("format");n.if(e._`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>n.assign(c,e._`${o}.type || "string"`).assign(u,e._`${o}.validate`),()=>n.assign(c,e._`"string"`).assign(u,o)),t.fail$data((0,e.or)(!1===d.strictSchema?e.nil:e._`${i} && !${u}`,function(){const t=l.$async?e._`(${o}.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[o];if(!a)return void function(){if(!1!==d.strictSchema)throw new Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}p.logger.warn(e())}();if(!0===a)return;const[i,c,h]=function(t){const r=t instanceof RegExp?(0,e.regexpCode)(t):d.code.formats?e._`${d.code.formats}${(0,e.getProperty)(o)}`:void 0,s=n.scopeValue("formats",{key:o,ref:t,code:r});return"object"!=typeof t||t instanceof RegExp?["string",t,s]:[t.type||"string",t.validate,e._`${s}.validate`]}(a);i===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 ${h}(${s})`}return"function"==typeof c?e._`${h}(${s})`:e._`${h}.test(${s})`}())}())}};return Fp.default=t,Fp}var Up,Vp,Hp={};function Kp(){if(Vp)return bl;Vp=1,Object.defineProperty(bl,"__esModule",{value:!0});const e=function(){if(wl)return kl;wl=1,Object.defineProperty(kl,"__esModule",{value:!0});const e=function(){if(_l)return $l;_l=1,Object.defineProperty($l,"__esModule",{value:!0});const e={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};return $l.default=e,$l}(),t=function(){if(vl)return El;vl=1,Object.defineProperty(El,"__esModule",{value:!0}),El.callRef=El.getValidate=void 0;const e=rl(),t=Mu(),r=pu(),n=wu(),s=al(),a=mu(),o={keyword:"$ref",schemaType:"string",code(t){const{gen:n,schema:a,it:o}=t,{baseId:d,schemaEnv:u,validateName:l,opts:p,self:h}=o,{root:f}=u;if(("#"===a||"#/"===a)&&d===f.baseId)return function(){if(u===f)return c(t,l,u,u.$async);const e=n.scopeValue("root",{ref:f});return c(t,r._`${e}.validate`,f,f.$async)}();const m=s.resolveRef.call(h,f,d,a);if(void 0===m)throw new e.default(o.opts.uriResolver,d,a);return m instanceof s.SchemaEnv?function(e){const r=i(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}),o=n.name("valid"),i=t.subschema({schema:e,dataTypes:[],schemaPath:r.nil,topSchemaRef:s,errSchemaPath:a},o);t.mergeEvaluated(i),t.ok(o)}(m)}};function i(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,o,i){const{gen:c,it:d}=e,{allErrors:u,schemaEnv:l,opts:p}=d,h=p.passContext?n.default.this:r.nil;function f(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==o?void 0:o.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)}}i?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,h)}`),m(s),u||c.assign(n,!0)},e=>{c.if(r._`!(${e} instanceof ${d.ValidationError})`,()=>c.throw(e)),f(e),u||c.assign(n,!1)}),e.ok(n)}():e.result((0,t.callValidateCode)(e,s,h),()=>m(s),()=>f(s))}return El.getValidate=i,El.callRef=c,El.default=o,El}(),r=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",e.default,t.default];return kl.default=r,kl}(),t=Ql(),r=Mp(),n=function(){if(Dp)return Lp;Dp=1,Object.defineProperty(Lp,"__esModule",{value:!0});const e=[qp().default];return Lp.default=e,Lp}(),s=(Up||(Up=1,Object.defineProperty(Hp,"__esModule",{value:!0}),Hp.contentVocabulary=Hp.metadataVocabulary=void 0,Hp.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],Hp.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]),Hp),a=[e.default,t.default,(0,r.default)(),n.default,s.metadataVocabulary,s.contentVocabulary];return bl.default=a,bl}var Jp,Bp,Gp={},Wp={};var Xp,Yp={$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 Qp(){return Xp||(Xp=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=yl(),n=Kp(),s=function(){if(Bp)return Gp;Bp=1,Object.defineProperty(Gp,"__esModule",{value:!0});const e=pu(),t=(Jp||(Jp=1,Object.defineProperty(Wp,"__esModule",{value:!0}),Wp.DiscrError=void 0,function(e){e.Tag="tag",e.Mapping="mapping"}(r||(Wp.DiscrError=r={}))),Wp);var r;const n=al(),s=rl(),a=mu(),o={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:o,data:i,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 h=o.let("valid",!1),f=o.const("tag",e._`${i}${(0,e.getProperty)(p)}`);function m(t){const n=o.name("valid"),s=r.subschema({keyword:"oneOf",schemaProp:t},n);return r.mergeEvaluated(s,e.Name),n}o.if(e._`typeof ${f} == "string"`,()=>function(){const i=function(){var e;const t={},r=i(d);let o=!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 h=null===(e=null==d?void 0:d.properties)||void 0===e?void 0:e[p];if("object"!=typeof h)throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${p}"`);o=o&&(r||i(d)),c(h,t)}if(!o)throw new Error(`discriminator: "${p}" must be required`);return t;function i({required:e}){return Array.isArray(e)&&e.includes(p)}function c(e,t){if(e.const)h(e.const,t);else{if(!e.enum)throw new Error(`discriminator: "properties/${p}" must have "const" or "enum"`);for(const r of e.enum)h(r,t)}}function h(e,r){if("string"!=typeof e||e in t)throw new Error(`discriminator: "${p}" values must be unique strings`);t[e]=r}}();o.if(!1);for(const t in i)o.elseIf(e._`${f} === ${t}`),o.assign(h,m(i[t]));o.else(),r.error(!1,{discrError:t.DiscrError.Mapping,tag:f,tagName:p}),o.endIf()}(),()=>r.error(!1,{discrError:t.DiscrError.Tag,tag:f,tagName:p})),r.ok(h)}};return Gp.default=o,Gp}(),a=Yp,o=["/properties"],i="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,o):a;this.addMetaSchema(e,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var d=Wu();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return d.KeywordCxt}});var u=pu();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=Qu();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return l.default}});var p=rl();Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return p.default}})}(eu,eu.exports)),eu.exports}var eh,th,rh,nh=Yd(Qp()),sh={exports:{}},ah={},oh={},ih=(rh||(rh=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=(eh||(eh=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(i(!0),c),"date-time":t(l(!0),p),"iso-time":t(i(),d),"iso-date-time":t(l(),h),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:function(e){return f.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,h),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],o=+t[3];return a>=1&&a<=12&&o>=1&&o<=(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 o=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function i(e){return function(t){const r=o.exec(t);if(!r)return!1;const n=+r[1],s=+r[2],a=+r[3],i=r[4],c="-"===r[5]?-1:1,d=+(r[6]||0),u=+(r[7]||0);if(d>23||u>59||e&&!i)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=o.exec(e),n=o.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=i(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 h(e,t){if(!e||!t)return;const[r,n]=e.split(u),[s,o]=t.split(u),i=a(r,s);return void 0!==i?i||c(n,o):void 0}const f=/\/|:/,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/}(ah)),ah),n=(th||(th=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=Qp(),r=pu(),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:o,keyword:i,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}, ${o}) ${s[i].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(`"${i}": 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)}(oh)),oh),s=pu(),a=new s.Name("fullFormats"),o=new s.Name("fastFormats"),i=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,r.fullFormats,a),e;const[s,i]="fast"===t.mode?[r.fastFormats,o]:[r.fullFormats,a];return c(e,t.formats||r.formatNames,s,i),t.keywords&&(0,n.default)(e),e};function c(e,t,r,n){var a,o;null!==(a=(o=e.opts.code).formats)&&void 0!==a||(o.formats=s._`require("ajv-formats/dist/formats").${n}`);for(const n of t)e.addFormat(n,r[n])}i.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=i,Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}(sh,sh.exports)),sh.exports),ch=Yd(ih);class dh{constructor(e){this._ajv=e??function(){const e=new nh({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return ch(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 uh{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 lh extends Wd{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map($c.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 dh,this.setRequestHandler(ii,e=>this._oninitialize(e)),this.setNotificationHandler(ui,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Sc,async(e,t)=>{const r=t.sessionId||t.requestInfo?.headers["mcp-session-id"]||void 0,{level:n}=e.params,s=$c.safeParse(n);return s.success&&this._loggingLevels.set(r,s.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new uh(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];Xd(a)&&Xd(s)?r[n]={...a,...s}:r[n]=s}return r}(this._capabilities,e)}setRequestHandler(e,t){const r=Ls(e),n=r?.method;if(!n)throw new Error("Schema is missing a method literal");let s;if(As(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=Zs(bc,e);if(!n.success){const e=n.error instanceof Error?n.error.message:String(n.error);throw new dd(Ho.InvalidParams,`Invalid tools/call request: ${e}`)}const{params:s}=n.data,a=await Promise.resolve(t(e,r));if(s.task){const e=Zs(wi,a);if(!e.success){const t=e.error instanceof Error?e.error.message:String(e.error);throw new dd(Ho.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}const o=Zs(vc,a);if(!o.success){const e=o.error instanceof Error?o.error.message:String(o.error);throw new dd(Ho.InvalidParams,`Invalid tools/call result: ${e}`)}return o.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:Eo.includes(t)?t:$o,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"},Bo)}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]:[],o=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(!o)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(o){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},Zc,t):this.request({method:"sampling/createMessage",params:e},Mc,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},Qc,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},Qc,t);if("accept"===n.action&&n.content&&r.requestedSchema)try{const e=this._jsonSchemaValidator.getValidator(r.requestedSchema)(n.content);if(!e.valid)throw new dd(Ho.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){if(e instanceof dd)throw e;throw new dd(Ho.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},id,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 ph=Symbol.for("mcp.completable");function hh(e){return!!e&&"object"==typeof e&&ph in e}var fh;!function(e){e.Completable="McpCompletable"}(fh||(fh={}));const mh=/^[A-Za-z0-9._-]{1,128}$/;function gh(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"),!mh.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 yh{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 _h{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 lh(e,t)}get experimental(){return this._experimental||(this._experimental={tasks:new yh(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Eh(yc)),this.server.assertCanSetRequestHandler(Eh(bc)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(yc,()=>({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=Fs(t.inputSchema);return e?Jd(e,{strictUnions:!0,pipeStrategy:"input"}):vh})(),annotations:t.annotations,execution:t.execution,_meta:t._meta};if(t.outputSchema){const e=Fs(t.outputSchema);e&&(r.outputSchema=Jd(e,{strictUnions:!0,pipeStrategy:"output"}))}return r})})),this.server.setRequestHandler(bc,async(e,t)=>{try{const r=this._registeredTools[e.params.name];if(!r)throw new dd(Ho.InvalidParams,`Tool ${e.params.name} not found`);if(!r.enabled)throw new dd(Ho.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 dd(Ho.InternalError,`Tool ${e.params.name} has taskSupport '${s}' but was not registered with registerToolTask`);if("required"===s&&!n)throw new dd(Ho.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if("optional"===s&&!n&&a)return await this.handleAutomaticTaskPolling(r,e,t);const o=await this.validateToolInput(r,e.params.arguments,e.params.name),i=await this.executeToolHandler(r,o,t);return n||await this.validateToolOutput(r,i,e.params.name),i}catch(e){if(e instanceof dd&&e.code===Ho.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=Fs(e.inputSchema)??e.inputSchema,s=await Ds(n,t);if(!s.success){const e=qs("error"in s?s.error:"Unknown error");throw new dd(Ho.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 dd(Ho.InvalidParams,`Output validation error: Tool ${r} has an output schema but no structured content was provided`);const n=Fs(e.outputSchema),s=await Ds(n,t.structuredContent);if(!s.success){const e=qs("error"in s?s.error:"Unknown error");throw new dd(Ho.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},o=n?await Promise.resolve(s.createTask(n,a)):await Promise.resolve(s.createTask(a)),i=o.task.taskId;let c=o.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(i);if(!e)throw new dd(Ho.InternalError,`Task ${i} not found during polling`);c=e}return await r.taskStore.getTaskResult(i)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Eh(nd)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(nd,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 dd(Ho.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,t){const r=this._registeredPrompts[t.name];if(!r)throw new dd(Ho.InvalidParams,`Prompt ${t.name} not found`);if(!r.enabled)throw new dd(Ho.InvalidParams,`Prompt ${t.name} disabled`);if(!r.argsSchema)return Th;const n=Ls(r.argsSchema),s=n?.[e.params.argument.name];if(!hh(s))return Th;const a=function(e){const t=e[ph];return t?.complete}(s);return a?Sh(await a(e.params.argument.value,e.params.context)):Th}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 Th;throw new dd(Ho.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}const n=r.resourceTemplate.completeCallback(e.params.argument.name);return n?Sh(await n(e.params.argument.value,e.params.context)):Th}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Eh(Zi)),this.server.assertCanSetRequestHandler(Eh(Li)),this.server.assertCanSetRequestHandler(Eh(Vi)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Zi,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(Li,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler(Vi,async(e,t)=>{const r=new URL(e.params.uri),n=this._registeredResources[r.toString()];if(n){if(!n.enabled)throw new dd(Ho.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 dd(Ho.InvalidParams,`Resource ${r} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Eh(tc)),this.server.assertCanSetRequestHandler(Eh(sc)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(tc,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,title:t.title,description:t.description,arguments:t.argsSchema?$h(t.argsSchema):void 0}))})),this.server.setRequestHandler(sc,async(e,t)=>{const r=this._registeredPrompts[e.params.name];if(!r)throw new dd(Ho.InvalidParams,`Prompt ${e.params.name} not found`);if(!r.enabled)throw new dd(Ho.InvalidParams,`Prompt ${e.params.name} disabled`);if(r.argsSchema){const n=Fs(r.argsSchema),s=await Ds(n,e.params.arguments);if(!s.success){const t=qs("error"in s?s.error:"Unknown error");throw new dd(Ho.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${t}`)}const a=s.data,o=r.callback;return await Promise.resolve(o(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 o=r.uriTemplate.variableNames;return Array.isArray(o)&&o.some(e=>!!r.completeCallback(e))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(t,r,n,s,a){const o={title:r,description:n,argsSchema:void 0===s?void 0:Ms(s),callback:a,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:e=>{void 0!==e.name&&e.name!==t&&(delete this._registeredPrompts[t],e.name&&(this._registeredPrompts[e.name]=o)),void 0!==e.title&&(o.title=e.title),void 0!==e.description&&(o.description=e.description),void 0!==e.argsSchema&&(o.argsSchema=Ms(e.argsSchema)),void 0!==e.callback&&(o.callback=e.callback),void 0!==e.enabled&&(o.enabled=e.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[t]=o,s&&Object.values(s).some(t=>hh(t instanceof e?t._def?.innerType:t))&&this.setCompletionRequestHandler(),o}_createRegisteredTool(e,t,r,n,s,a,o,i,c){gh(e);const d={title:t,description:r,inputSchema:kh(n),outputSchema:kh(s),annotations:a,execution:o,_meta:i,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&&gh(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=Ms(t.paramsSchema)),void 0!==t.outputSchema&&(d.outputSchema=Ms(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];bh(e)?(n=t.shift(),t.length>1&&"object"==typeof t[0]&&null!==t[0]&&!bh(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:o,annotations:i,_meta:c}=t;return this._createRegisteredTool(e,n,s,a,o,i,{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,o=this._createRegisteredPrompt(e,n,s,a,r);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}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 vh={type:"object",properties:{}};function wh(e){return null!==e&&"object"==typeof e&&"parse"in e&&"function"==typeof e.parse&&"safeParse"in e&&"function"==typeof e.safeParse}function bh(e){return"object"==typeof e&&null!==e&&!function(e){return"_def"in e||"_zod"in e||wh(e)}(e)&&(0===Object.keys(e).length||Object.values(e).some(wh))}function kh(e){if(e)return bh(e)?Ms(e):e}function $h(e){const t=Ls(e);return t?Object.entries(t).map(([e,t])=>{const r=function(e){return e.description}(t),n=function(e){if(As(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 Eh(e){const t=Ls(e),r=t?.method;if(!r)throw new Error("Schema is missing a method literal");const n=Us(r);if("string"==typeof n)return n;throw new Error("Schema method literal must be a string")}function Sh(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}const Th={completion:{values:[],hasMore:!1}};class xh{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 Jo.parse(JSON.parse(e))}(t)}clear(){this._buffer=void 0}}class Nh{constructor(e=r.stdin,t=r.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new xh,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 Oh={logging:{level:"DEBUG"},db:{path:c.join(u.homedir(),".knowledge-bank","knowledge.db"),configs:["journal_mode = WAL","foreign_keys = ON"]},tmp:c.join(u.homedir(),".knowledge-bank","tmp")};let Ph=null;function Ih(){if(null===Ph){const e=process.env.KNOWLEDGE_CONF_DIR||c.join(u.homedir(),".knowledge-bank"),t=c.join(e,"config.json");Ph={...Oh,...n.existsSync(t)?JSON.parse(n.readFileSync(t,"utf-8")):{}}}return Ph}const Rh=Ih(),Ch={DEBUG:"DEBUG",INFO:"INFO",WARN:"WARN",ERROR:"ERROR"},zh=Object.values(Ch);class jh{constructor(e,t){this.loggerName=t;const r=Rh.logging.path||c.join(u.homedir(),".knowledge-bank","logs");n.mkdirSync(r,{recursive:!0}),this.loggerFile=c.join(r,`${e}.log`),this.logLevel=Rh.logging.level.toUpperCase()||Ch.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=zh.indexOf(this.logLevel);return zh.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(Ch.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(Ch.ERROR,e,r)}else this.writeMessage(Ch.ERROR,e,t)}logWarn(e,t=null){this.writeMessage(Ch.WARN,e,t)}logDebug(e,t=null){this.writeMessage(Ch.DEBUG,e,t)}}function Ah(e,t){return new jh(e,t)}const Mh=Ih();class Zh{constructor(){this.dbPath=Mh.db.path,this.db=null,this.transactionDepth=0}initialize(){const e=d(this.dbPath);return s(e)||a(e,{recursive:!0}),this.db=new l(this.dbPath),Mh.db.configs.forEach(e=>{this.db.pragma(e)}),this}getConnection(){return this.db||this.initialize(),this.db}beginTransaction(){return 0===this.transactionDepth&&this.getConnection().prepare("BEGIN").run(),this.transactionDepth++,this}commit(){return this.transactionDepth--,0===this.transactionDepth&&this.getConnection().prepare("COMMIT").run(),this}rollback(){return this.transactionDepth--,0===this.transactionDepth&&this.getConnection().prepare("ROLLBACK").run(),this}transaction(e){this.beginTransaction();try{const t=e(this.getConnection());return this.commit(),t}catch(e){throw this.rollback(),e}}close(){return this.db&&(this.db.close(),this.db=null),this}exists(){return s(this.dbPath)}getPath(){return this.dbPath}}let Dh=null;const Lh=["personal","project","organization"],Fh=["developer","architect","reviewer","ai"],qh=["code_pattern","tool_usage","architecture","config","pitfall","api_usage","exploration"],Uh=["draft","suggested","verified"],Vh={knowledge_item:`\n CREATE TABLE IF NOT EXISTS knowledge_item (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\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 (${Lh.map(e=>`'${e}'`).join(", ")})),\n source_type TEXT NOT NULL CHECK(source_type IN (${Fh.map(e=>`'${e}'`).join(", ")})),\n knowledge_type TEXT NOT NULL CHECK(knowledge_type IN (${qh.map(e=>`'${e}'`).join(", ")})),\n status TEXT NOT NULL DEFAULT 'draft' CHECK(status IN (${Uh.map(e=>`'${e}'`).join(", ")})),\n\n -- Association information\n repository_id INTEGER,\n session_id TEXT NOT NULL,\n\n -- Source tracking\n source_file TEXT,\n commit_hash TEXT,\n contributor TEXT,\n\n -- Timestamps\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n\n FOREIGN KEY (repository_id) REFERENCES repository(id)\n )\n `,repository:"\n CREATE TABLE IF NOT EXISTS repository (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n\n name TEXT NOT NULL,\n remote_url TEXT UNIQUE NOT NULL,\n local_path TEXT,\n\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n )\n ",session:"\n CREATE TABLE IF NOT EXISTS session (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n\n session_id TEXT UNIQUE NOT NULL,\n repository_id INTEGER,\n\n -- Session basic information\n working_directory TEXT NOT NULL,\n branch TEXT,\n username TEXT,\n\n -- Environment information (stored as JSON)\n env TEXT,\n\n -- Configuration information (stored as JSON)\n config TEXT,\n\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n\n FOREIGN KEY (repository_id) REFERENCES repository(id)\n )\n ",hook_event:"\n CREATE TABLE IF NOT EXISTS hook_event (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n\n session_id TEXT NOT NULL,\n\n -- Hook information\n name TEXT NOT NULL,\n input TEXT NOT NULL,\n output TEXT,\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 ",sync_status:`\n CREATE TABLE IF NOT EXISTS sync_status (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n\n repository_id INTEGER,\n\n last_sync_at INTEGER,\n last_pull_at INTEGER,\n last_push_at INTEGER,\n\n remote_url TEXT,\n sync_protocol TEXT CHECK(sync_protocol IN (${["http","ftp","sftp"].map(e=>`'${e}'`).join(", ")})),\n\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n\n FOREIGN KEY (repository_id) REFERENCES repository(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 "},Hh={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 "},Kh={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_repo:"CREATE INDEX IF NOT EXISTS idx_knowledge_repo ON knowledge_item(repository_id)",idx_knowledge_session:"CREATE INDEX IF NOT EXISTS idx_knowledge_session ON knowledge_item(session_id)",idx_session_repo:"CREATE INDEX IF NOT EXISTS idx_session_repo ON session(repository_id)",idx_session_id:"CREATE INDEX IF NOT EXISTS idx_session_id ON session(session_id)",idx_hook_event_session:"CREATE INDEX IF NOT EXISTS idx_hook_event_session ON hook_event(session_id)",idx_hook_event_type:"CREATE INDEX IF NOT EXISTS idx_hook_event_type ON hook_event(name)",idx_sync_repo:"CREATE INDEX IF NOT EXISTS idx_sync_repo ON sync_status(repository_id)"},Jh=Ah("knowledge-repository","knowledge-repository");class Bh{constructor(e){this.database=e,this.db=e.getConnection()}create(e){const t=Date.now(),r=this.db.prepare("\n INSERT INTO knowledge_item (\n title, summary, content,\n scope, source_type, knowledge_type, status,\n repository_id, session_id,\n source_file, commit_hash, contributor,\n created_at, updated_at\n ) VALUES (\n @title, @summary, @content,\n @scope, @source_type, @knowledge_type, @status,\n @repository_id, @session_id,\n @source_file, @commit_hash, @contributor,\n @created_at, @updated_at\n )\n ").run({...e,status:e.status||Uh.DRAFT,created_at:t,updated_at:t});return this.findById(r.lastInsertRowid)}findById(e){return this.db.prepare("SELECT * FROM knowledge_item WHERE id = ?").get(e)}findByRepository(e,t=null){return t?this.db.prepare("SELECT * FROM knowledge_item WHERE repository_id = ? AND scope = ? ORDER BY updated_at DESC").all(e,t):this.db.prepare("SELECT * FROM knowledge_item WHERE repository_id = ? ORDER BY updated_at DESC").all(e)}findByScope(e){return this.db.prepare("SELECT * FROM knowledge_item WHERE scope = ? ORDER BY updated_at DESC").all(e)}findByStatus(e){return this.db.prepare("SELECT * FROM knowledge_item WHERE status = ? ORDER BY updated_at DESC").all(e)}findByKnowledgeType(e){return this.db.prepare("SELECT * FROM knowledge_item WHERE knowledge_type = ? ORDER BY updated_at DESC").all(e)}findBySession(e){return this.db.prepare("SELECT * FROM knowledge_item WHERE session_id = ?").all(e)}findRelevant(e,t=5){return this.db.prepare("\n SELECT * FROM knowledge_item\n WHERE repository_id = ? OR scope = 'organization'\n ORDER BY\n CASE status\n WHEN 'verified' THEN 3\n WHEN 'suggested' THEN 2\n WHEN 'draft' THEN 1\n END DESC,\n updated_at DESC\n LIMIT ?\n ").all(e,t)}update(e,t){const r=Date.now(),n=Object.keys(t).map(e=>`${e} = @${e}`).join(", ");return this.db.prepare(`\n UPDATE knowledge_item\n SET ${n}, updated_at = @updated_at\n WHERE id = @id\n `).run({...t,id:e,updated_at:r}),this.findById(e)}updateStatus(e,t){return this.update(e,{status:t})}delete(e){return this.db.prepare("DELETE FROM knowledge_item WHERE id = ?").run(e)}count(e={}){let t="SELECT COUNT(*) as count FROM knowledge_item";const r=[],n=[];return e.scope&&(r.push("scope = ?"),n.push(e.scope)),e.status&&(r.push("status = ?"),n.push(e.status)),e.knowledge_type&&(r.push("knowledge_type = ?"),n.push(e.knowledge_type)),e.repository_id&&(r.push("repository_id = ?"),n.push(e.repository_id)),r.length>0&&(t+=` WHERE ${r.join(" AND ")}`),this.db.prepare(t).get(...n).count}findAll(e=100,t=0){return this.db.prepare("SELECT * FROM knowledge_item ORDER BY updated_at DESC LIMIT ? OFFSET ?").all(e,t)}search(e,t=10){const r=Array.isArray(e)?e.map(e=>`"${e}"`).join(" OR "):`"${e}"`;return Jh.logDebug("Searching knowledge items with query: ",r),this.db.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 ?\n ").all(r,t)}}class Gh{constructor(e){this.database=e,this.db=e.getConnection()}create(e){const t=Date.now(),r=this.db.prepare("\n INSERT INTO repository (\n name, remote_url, local_path,\n created_at, updated_at\n ) VALUES (\n @name, @remote_url, @local_path,\n @created_at, @updated_at\n )\n ").run({...e,created_at:t,updated_at:t});return this.findById(r.lastInsertRowid)}findById(e){return this.db.prepare("SELECT * FROM repository WHERE id = ?").get(e)}findByRemoteUrl(e){return this.db.prepare("SELECT * FROM repository WHERE remote_url = ?").get(e)}findByPath(e){return this.db.prepare("SELECT * FROM repository WHERE local_path = ?").get(e)}findByName(e){return this.db.prepare("SELECT * FROM repository WHERE name = ?").get(e)}getOrCreate(e,t,r=null){let n=this.findByRemoteUrl(e);return n?r&&n.local_path!==r&&(n=this.update(n.id,{local_path:r})):n=this.create({name:t,remote_url:e,local_path:r}),n}update(e,t){const r=Date.now(),n=Object.keys(t).map(e=>`${e} = @${e}`).join(", ");return this.db.prepare(`\n UPDATE repository\n SET ${n}, updated_at = @updated_at\n WHERE id = @id\n `).run({...t,id:e,updated_at:r}),this.findById(e)}delete(e){return this.db.prepare("DELETE FROM repository WHERE id = ?").run(e)}findAll(){return this.db.prepare("SELECT * FROM repository ORDER BY updated_at DESC").all()}count(){return this.db.prepare("SELECT COUNT(*) as count FROM repository").get().count}}class Wh{constructor(e){this.database=e,this.db=e.getConnection()}create(e){const t=Date.now(),r=this.db.prepare("\n INSERT INTO sync_status (\n repository_id,\n last_sync_at, last_pull_at, last_push_at,\n remote_url, sync_protocol,\n created_at, updated_at\n ) VALUES (\n @repository_id,\n @last_sync_at, @last_pull_at, @last_push_at,\n @remote_url, @sync_protocol,\n @created_at, @updated_at\n )\n ").run({repository_id:e.repository_id||null,last_sync_at:e.last_sync_at||null,last_pull_at:e.last_pull_at||null,last_push_at:e.last_push_at||null,remote_url:e.remote_url||null,sync_protocol:e.sync_protocol||null,created_at:t,updated_at:t});return this.findById(r.lastInsertRowid)}findById(e){return this.db.prepare("SELECT * FROM sync_status WHERE id = ?").get(e)}findByRepository(e){return this.db.prepare("SELECT * FROM sync_status WHERE repository_id = ?").get(e)}findGlobal(){return this.db.prepare("SELECT * FROM sync_status WHERE repository_id IS NULL").get()}getOrCreate(e,t={}){let r=e?this.findByRepository(e):this.findGlobal();return r||(r=this.create({repository_id:e,...t})),r}update(e,t){const r=Date.now(),n=Object.keys(t).map(e=>`${e} = @${e}`).join(", ");return this.db.prepare(`\n UPDATE sync_status\n SET ${n}, updated_at = @updated_at\n WHERE id = @id\n `).run({...t,id:e,updated_at:r}),this.findById(e)}recordPull(e){const t=this.getOrCreate(e),r=Date.now();return this.update(t.id,{last_pull_at:r,last_sync_at:r})}recordPush(e){const t=this.getOrCreate(e),r=Date.now();return this.update(t.id,{last_push_at:r,last_sync_at:r})}recordSync(e){const t=this.getOrCreate(e),r=Date.now();return this.update(t.id,{last_pull_at:r,last_push_at:r,last_sync_at:r})}updateConfig(e,t){const r=this.getOrCreate(e);return this.update(r.id,{remote_url:t.remote_url,sync_protocol:t.sync_protocol})}delete(e){return this.db.prepare("DELETE FROM sync_status WHERE id = ?").run(e)}findAll(){return this.db.prepare("SELECT * FROM sync_status ORDER BY updated_at DESC").all()}needsSync(e,t=36e5){const r=e?this.findByRepository(e):this.findGlobal();return!r||!r.last_sync_at||Date.now()-r.last_sync_at>t}getStats(){return{total:this.db.prepare("SELECT COUNT(*) as count FROM sync_status").get().count,with_remote:this.db.prepare("SELECT COUNT(*) as count FROM sync_status WHERE remote_url IS NOT NULL").get().count,recent_syncs_24h:this.db.prepare("\n SELECT COUNT(*) as count FROM sync_status\n WHERE last_sync_at > ?\n ").get(Date.now()-864e5).count}}}Ah("common","common");const Xh=f(import.meta.url),Yh=c.dirname(Xh);c.join(Yh,"..","claude-marketplace");const Qh=function(){const e=c.join(Yh,"package.json"),t=c.join(".","package.json");return n.existsSync(e)?JSON.parse(o(e,"utf8")):JSON.parse(o(t,"utf8"))}();c.join(u.homedir(),".claude","settings.local.json");class ef{constructor(e=null){this.repoPath=e||h(),this.git=p(this.repoPath)}getCurrentBranch(){return this.git.branchLocal().then(e=>e.current).catch(e=>{throw new Error(`Failed to get current branch: ${e.message}`)})}getRemoteUrl(e="origin"){return this.git.getRemotes(!0).then(t=>{const r=t.find(t=>t.name===e);if(!r)throw new Error(`Remote '${e}' not found`);return r.refs.fetch||r.refs.push}).catch(e=>{throw new Error(`Failed to get remote URL: ${e.message}`)})}getMainBranch(){return this.git.branchLocal().then(e=>{const t=e.all;return t.includes("main")?"main":t.includes("master")?"master":t[0]||"main"}).catch(()=>"main")}isOnMainBranch(){return this.getCurrentBranch().then(e=>this.getMainBranch().then(t=>e===t))}getCurrentCommitHash(){return this.git.revparse(["HEAD"]).then(e=>e.trim()).catch(e=>{throw new Error(`Failed to get commit hash: ${e.message}`)})}getCommitAuthor(e="HEAD"){return this.git.show(["-s","--format=%an <%ae>",e]).then(e=>e.trim()).catch(e=>{throw new Error(`Failed to get commit author: ${e.message}`)})}isBranchMergedToMain(e){return this.getMainBranch().then(t=>this.git.branch(["--merged",t]).then(t=>t.all.map(e=>e.replace("*","").trim()).includes(e))).catch(e=>(console.error(`Failed to check merge status: ${e.message}`),!1))}getRepoRoot(){return this.git.revparse(["--show-toplevel"]).then(e=>e.trim()).catch(e=>{throw new Error(`Failed to get repo root: ${e.message}`)})}isGitRepository(){return this.git.checkIsRepo().catch(()=>!1)}getStatus(){return this.git.status().catch(e=>{throw new Error(`Failed to get git status: ${e.message}`)})}getAllBranches(){return this.git.branchLocal().then(e=>e.all).catch(e=>{throw new Error(`Failed to get branches: ${e.message}`)})}getRepositoryName(){return this.getRemoteUrl().then(e=>{const t=e.match(/([^/:]+?)(?:\.git)?$/);return t?t[1]:"unknown"}).catch(()=>"unknown")}getUserName(){return this.git.getConfig("user.name").then(e=>e.value||process.env.USER||process.env.USERNAME||"unknown_user").catch(()=>"unknown")}getUserInfo(){return Promise.all([this.git.getConfig("user.name").catch(()=>({value:null})),this.git.getConfig("user.email").catch(()=>({value:null}))]).then(([e,t])=>({name:e.value||"unknown",email:t.value||"unknown"}))}}class tf{constructor(e,t){this.gitUtils=e,this.repositoryRepo=t}getCurrentRepository(){return Promise.all([this.gitUtils.getRemoteUrl(),this.gitUtils.getRepositoryName(),this.gitUtils.getRepoRoot()]).then(([e,t,r])=>this.getOrCreateRepository(e,t,r)).catch(e=>{throw new Error(`Failed to get current repository: ${e.message}`)})}getOrCreateRepository(e,t,r=null){return Promise.resolve(this.repositoryRepo.getOrCreate(e,t,r))}getRepository(e){return Promise.resolve(this.repositoryRepo.findById(e))}getRepositoryByUrl(e){return Promise.resolve(this.repositoryRepo.findByRemoteUrl(e))}getAllRepositories(){return Promise.resolve(this.repositoryRepo.findAll())}updateRepository(e,t){return Promise.resolve(this.repositoryRepo.update(e,t))}deleteRepository(e){return Promise.resolve(this.repositoryRepo.delete(e))}getRepositoryStats(e){return Promise.resolve({total_repositories:this.repositoryRepo.count()})}}class rf{constructor(e){this.gitUtils=e}validateBranchForSession(){return this.gitUtils.getCurrentBranch().then(e=>this.gitUtils.getMainBranch().then(t=>e===t?{valid:!1,branch:e,message:`Cannot start session on main branch '${e}'. Please create a feature branch first.\n\nExample:\n git checkout -b feature/my-feature\n claude "your prompt here"`}:{valid:!0,branch:e,message:`Session validated on branch '${e}'`})).catch(e=>(console.warn(`Branch validation warning: ${e.message}`),{valid:!0,branch:"unknown",message:`Branch validation skipped: ${e.message}`}))}isMainBranch(){return this.gitUtils.isOnMainBranch().catch(()=>!1)}}const nf=new class{constructor(){this.database=(Dh||(Dh=new Zh),Dh),this.initialized=!1}initialize(){this.initialized||(this.database.initialize(),this.initialized=!0)}async prepare(){this.initialize(),function(e){Object.values(Vh).forEach(t=>{e.prepare(t).run()}),Object.values(Kh).forEach(t=>{e.prepare(t).run()}),Object.values(Hh).forEach(t=>{e.prepare(t).run()});const t=e.prepare("SELECT COUNT(*) as count FROM knowledge_item_fts").get(),r=e.prepare("SELECT COUNT(*) as count FROM knowledge_item").get();r.count>0&&0===t.count&&(console.log("Populating FTS index from existing data..."),e.prepare("\n INSERT INTO knowledge_item_fts(rowid, title, summary, content)\n SELECT id, title, summary, content FROM knowledge_item\n ").run(),console.log(`FTS index populated with ${r.count} items`))}(this.database.getConnection())}getConnection(){return this.initialize(),this.database.getConnection()}close(){this.database&&(this.database.close(),this.initialized=!1)}},sf=new class{constructor(e){this.dbService=e,this._repositoryRepo=null,this._syncRepo=null}get repositoryRepo(){return this._repositoryRepo||(this._repositoryRepo=new Gh(this.dbService.database)),this._repositoryRepo}get syncRepo(){return this._syncRepo||(this._syncRepo=new Wh(this.dbService.database)),this._syncRepo}}(nf),af=new class{constructor(e){this.dbService=e,this._knowledgeRepo=null}get knowledgeRepo(){return this._knowledgeRepo||(this._knowledgeRepo=new Bh(this.dbService.database)),this._knowledgeRepo}}(nf),of=new class{constructor(e){this.gitUtils=new ef,this.repositoryManager=new tf(this.gitUtils,e),this.branchValidator=new rf(this.gitUtils)}}(sf.repositoryRepo);sf.gitService=of;class cf{constructor(){this.logger=Ah("knowledge-management","knowledge-management"),this.knowledgeService=af}getRepositoryId(){return process.env.CLAUDE_SESSION_REPOSITORYID}getSessionId(){return process.env.CLAUDE_SESSION_ID}buildUpdateData(e){const t={};return["title","summary","content","scope","source_type","knowledge_type","status","source_file","commit_hash","contributor"].forEach(r=>{void 0!==e[r]&&(t[r]=e[r])}),t}aggregateByStatus(e,t){e.forEach(e=>{t.by_status[e]=this.knowledgeService.knowledgeRepo.count({status:e})})}aggregateByScope(e,t){e.forEach(e=>{t.by_scope[e]=this.knowledgeService.knowledgeRepo.count({scope:e})})}aggregateByType(e,t){e.forEach(e=>{t.by_type[e]=this.knowledgeService.knowledgeRepo.count({knowledge_type:e})})}async create(e){this.logger.logDebug("Creating new knowledge item",e);const t=this.knowledgeService.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,commit_hash:e.commit_hash,contributor:e.contributor,repository_id:e.repository_id||this.getRepositoryId(),session_id:e.session_id||this.getSessionId()});return this.logger.logDebug(`✓ Knowledge item created with ID: ${t.id}`),t}async update(e,t){this.logger.logInfo(`Updating knowledge item ${e}...`);const r=this.buildUpdateData(t),n=this.knowledgeService.knowledgeRepo.update(e,r);return this.logger.logInfo(`✓ Knowledge item ${e} updated`),n}async delete(e){this.logger.logInfo(`Deleting knowledge item ${e}...`),this.knowledgeService.knowledgeRepo.delete(e),this.logger.logInfo(`✓ Knowledge item ${e} deleted`)}async get(e){return this.knowledgeService.knowledgeRepo.findById(e)||(this.logger.logWarn(`Knowledge item ${e} not found`),null)}async list(e={}){if(e.scope)return this.knowledgeService.knowledgeRepo.findByScope(e.scope);if(e.status)return this.knowledgeService.knowledgeRepo.findByStatus(e.status);if(e.knowledge_type)return this.knowledgeService.knowledgeRepo.findByKnowledgeType(e.knowledge_type);const t=e.limit||100,r=e.offset||0;return this.knowledgeService.knowledgeRepo.findAll(t,r)}async search(e,t=10){return this.knowledgeService.knowledgeRepo.search(e,t)}async updateStatus(e,t){this.logger.logInfo(`Updating status of knowledge item ${e} to ${t}...`);const r=this.knowledgeService.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.knowledgeService.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 df{static exists(e){return s(e)}static writeJson(e,t){const r=d(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=d(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.commit_hash?`**Commit Hash:** ${e.commit_hash}`:""}\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,commit_hash:e.commit_hash||null,contributor:e.contributor||null}}}const uf=Ih(),lf=Ah("mcp-server","mcp-server");class pf{constructor(){this.knowledgeManagement=new cf,this.tempDir=uf.tmp,this.server=new _h({name:"knowledge-bank",version:Qh.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"),repository_id:t.number().describe("Repository 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(Lh).optional().describe("Scope of knowledge"),source_type:t.enum(Fh).optional().describe("Source type"),knowledge_type:t.enum(qh).optional().describe("Knowledge type"),status:t.enum(Uh).optional().describe("Status of knowledge"),source_file:t.string().optional().describe("Source file path (optional)"),commit_hash:t.string().optional().describe("Commit hash (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(Lh).optional().describe("Scope of knowledge"),source_type:t.enum(Fh).optional().describe("Source type"),knowledge_type:t.enum(qh).optional().describe("Knowledge type"),status:t.enum(Uh).optional().describe("Status of knowledge"),source_file:t.string().optional().describe("Source file path"),commit_hash:t.string().optional().describe("Commit hash"),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(Lh).optional().describe("Filter by scope"),status:t.enum(Uh).optional().describe("Filter by status"),knowledge_type:t.enum(qh).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(Uh).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=c.join(this.tempDir,e.from);if(!df.exists(r))return{content:[{type:"text",text:JSON.stringify({error:`File not found: ${r}`},null,2)}],isError:!0};try{t=df.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 of.repositoryManager.getCurrentRepository(),n=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,commit_hash:t.commit_hash,contributor:t.contributor,repository_id:r.id,session_id:process.env.CLAUDE_SESSION_ID||t.session_id||"unknown-session"});if(e.from){const t=c.join(this.tempDir,e.from);return{content:[{type:"text",text:JSON.stringify({id:n.id,title:n.title,message:`Knowledge item created from ${e.from}`,file_path:t},null,2)}]}}return{content:[{type:"text",text:JSON.stringify(n,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=c.join(this.tempDir,e.to),n=df.formatKnowledgeAsMarkdown(t);return df.writeMarkdown(r,n),{content:[{type:"text",text:JSON.stringify({success:!0,message:`Knowledge item ${e.id} saved to ${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=c.join(this.tempDir,r);if(!df.exists(e))return{content:[{type:"text",text:JSON.stringify({error:`File not found: ${e}`},null,2)}],isError:!0};try{s={...df.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(a,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=c.join(this.tempDir,t),s=n.map(e=>df.extractKnowledgeForJson(e));return df.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=c.join(this.tempDir,t),a=s.map(e=>df.extractKnowledgeForJson(e));return df.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 Nh;await this.server.connect(e),lf.logWarn(`Knowledge Bank MCP server running under ${process.cwd()}`)}}export{pf 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),o(e,r)}};function a(e,r=e.schema){const{gen:s,data:a,it:o}=e;if(0===Object.keys(r).length)return;const i=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,o.opts.ownProperties);e.setParams({property:c,depsCount:d.length,deps:d.join(", ")}),o.allErrors?s.if(u,()=>{for(const t of d)(0,n.checkReportMissingProp)(e,t)}):(s.if(t._`${u} && (${(0,n.checkMissingProp)(e,d,i)})`),(0,n.reportMissingProp)(e,i),s.else())}}function o(e,t=e.schema){const{gen:s,data:a,keyword:o,it:i}=e,c=s.name("valid");for(const d in t)(0,r.alwaysValidSchema)(i,t[d])||(s.if((0,n.propertyInData)(s,a,d,i.opts.ownProperties),()=>{const t=e.subschema({keyword:o,schemaProp:d},c);e.mergeValidEvaluated(t,c)},()=>s.var(c,!0)),e.ok(c))}e.validatePropertyDeps=a,e.validateSchemaDeps=o,e.default=s}(fp)),fp),o=function(){if(mp)return yp;mp=1,Object.defineProperty(yp,"__esModule",{value:!0});const e=pu(),t=mu(),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:o}=r;if((0,t.alwaysValidSchema)(o,s))return;const i=n.name("valid");n.forIn("key",a,t=>{r.setParams({propertyName:t}),r.subschema({keyword:"propertyNames",data:t,dataTypes:["string"],propertyName:t,compositeRule:!0},i),n.if((0,e.not)(i),()=>{r.error(!0),o.allErrors||n.break()})}),r.ok(i)}};return yp.default=r,yp}(),i=vp(),c=function(){if(wp)return Op;wp=1,Object.defineProperty(Op,"__esModule",{value:!0});const e=Wu(),t=Mu(),r=mu(),n=vp(),s={keyword:"properties",type:"object",schemaType:"object",code(s){const{gen:a,schema:o,parentSchema:i,data:c,it:d}=s;"all"===d.opts.removeAdditional&&void 0===i.additionalProperties&&n.default.code(new e.KeywordCxt(d,n.default,"additionalProperties"));const u=(0,t.allSchemaProperties)(o);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,o[e]));if(0===l.length)return;const p=a.name("valid");for(const e of l)h(e)?f(e):(a.if((0,t.propertyInData)(a,c,e,d.opts.ownProperties)),f(e),d.allErrors||a.else().var(p,!0),a.endIf()),s.it.definedProperties.add(e),s.ok(p);function h(e){return d.opts.useDefaults&&!d.compositeRule&&void 0!==o[e].default}function f(e){s.subschema({keyword:"properties",schemaProp:e,dataProp:e},p)}}};return Op.default=s,Op}(),d=function(){if(bp)return Pp;bp=1,Object.defineProperty(Pp,"__esModule",{value:!0});const e=Mu(),t=pu(),r=mu(),n=mu(),s={keyword:"patternProperties",type:"object",schemaType:"object",code(s){const{gen:a,schema:o,data:i,parentSchema:c,it:d}=s,{opts:u}=d,l=(0,e.allSchemaProperties)(o),p=l.filter(e=>(0,r.alwaysValidSchema)(d,o[e]));if(0===l.length||p.length===l.length&&(!d.opts.unevaluated||!0===d.props))return;const h=u.strictSchema&&!u.allowMatchingProperties&&c.properties,f=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 h)new RegExp(e).test(t)&&(0,r.checkStrictMode)(d,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function y(r){a.forIn("key",i,o=>{a.if(t._`${(0,e.usePattern)(s,r)}.test(${o})`,()=>{const e=p.includes(r);e||s.subschema({keyword:"patternProperties",schemaProp:r,dataProp:o,dataPropType:n.Type.Str},f),d.opts.unevaluated&&!0!==m?a.assign(t._`${m}[${o}]`,!0):e||d.allErrors||a.if((0,t.not)(f),()=>a.break())})})}!function(){for(const e of l)h&&g(e),d.allErrors?y(e):(a.var(f,!0),y(e),a.if(f))}()}};return Pp.default=s,Pp}(),u=function(){if(kp)return Ip;kp=1,Object.defineProperty(Ip,"__esModule",{value:!0});const e=mu(),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 Ip.default=t,Ip}(),l=function(){if($p)return Rp;$p=1,Object.defineProperty(Rp,"__esModule",{value:!0});const e={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Mu().validateUnion,error:{message:"must match a schema in anyOf"}};return Rp.default=e,Rp}(),p=function(){if(Sp)return zp;Sp=1,Object.defineProperty(zp,"__esModule",{value:!0});const e=pu(),t=mu(),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:o}=r;if(!Array.isArray(s))throw new Error("ajv implementation error");if(o.opts.discriminator&&a.discriminator)return;const i=s,c=n.let("valid",!1),d=n.let("passing",null),u=n.name("_valid");r.setParams({passing:d}),n.block(function(){i.forEach((s,a)=>{let i;(0,t.alwaysValidSchema)(o,s)?n.var(u,!0):i=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),i&&r.mergeEvaluated(i,e.Name)})})}),r.result(c,()=>r.reset(),()=>r.error(!0))}};return zp.default=r,zp}(),h=function(){if(Ep)return jp;Ep=1,Object.defineProperty(jp,"__esModule",{value:!0});const e=mu(),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 o=t.subschema({keyword:"allOf",schemaProp:n},a);t.ok(a),t.mergeEvaluated(o)})}};return jp.default=t,jp}(),f=function(){if(Tp)return Cp;Tp=1,Object.defineProperty(Cp,"__esModule",{value:!0});const e=pu(),t=mu(),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:o}=r;void 0===a.then&&void 0===a.else&&(0,t.checkStrictMode)(o,'"if" without "then" and "else" is ignored');const i=n(o,"then"),c=n(o,"else");if(!i&&!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(),i&&c){const e=s.let("ifClause");r.setParams({ifClause:e}),s.if(u,l("then",e),l("else",e))}else i?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 Cp.default=r,Cp}(),m=function(){if(xp)return Ap;xp=1,Object.defineProperty(Ap,"__esModule",{value:!0});const e=mu(),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 Ap.default=t,Ap}();return tp.default=function(g=!1){const y=[u.default,l.default,p.default,h.default,f.default,m.default,o.default,i.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},tp}var Zp,Dp,Lp={},Fp={};function qp(){if(Zp)return Fp;Zp=1,Object.defineProperty(Fp,"__esModule",{value:!0});const e=pu(),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:o,schemaCode:i,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}),o=n.const("fDef",e._`${a}[${i}]`),c=n.let("fType"),u=n.let("format");n.if(e._`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>n.assign(c,e._`${o}.type || "string"`).assign(u,e._`${o}.validate`),()=>n.assign(c,e._`"string"`).assign(u,o)),t.fail$data((0,e.or)(!1===d.strictSchema?e.nil:e._`${i} && !${u}`,function(){const t=l.$async?e._`(${o}.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[o];if(!a)return void function(){if(!1!==d.strictSchema)throw new Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}p.logger.warn(e())}();if(!0===a)return;const[i,c,h]=function(t){const r=t instanceof RegExp?(0,e.regexpCode)(t):d.code.formats?e._`${d.code.formats}${(0,e.getProperty)(o)}`:void 0,s=n.scopeValue("formats",{key:o,ref:t,code:r});return"object"!=typeof t||t instanceof RegExp?["string",t,s]:[t.type||"string",t.validate,e._`${s}.validate`]}(a);i===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 ${h}(${s})`}return"function"==typeof c?e._`${h}(${s})`:e._`${h}.test(${s})`}())}())}};return Fp.default=t,Fp}var Up,Vp,Hp={};function Jp(){if(Vp)return bl;Vp=1,Object.defineProperty(bl,"__esModule",{value:!0});const e=function(){if(wl)return kl;wl=1,Object.defineProperty(kl,"__esModule",{value:!0});const e=function(){if(_l)return $l;_l=1,Object.defineProperty($l,"__esModule",{value:!0});const e={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};return $l.default=e,$l}(),t=function(){if(vl)return Sl;vl=1,Object.defineProperty(Sl,"__esModule",{value:!0}),Sl.callRef=Sl.getValidate=void 0;const e=rl(),t=Mu(),r=pu(),n=wu(),s=al(),a=mu(),o={keyword:"$ref",schemaType:"string",code(t){const{gen:n,schema:a,it:o}=t,{baseId:d,schemaEnv:u,validateName:l,opts:p,self:h}=o,{root:f}=u;if(("#"===a||"#/"===a)&&d===f.baseId)return function(){if(u===f)return c(t,l,u,u.$async);const e=n.scopeValue("root",{ref:f});return c(t,r._`${e}.validate`,f,f.$async)}();const m=s.resolveRef.call(h,f,d,a);if(void 0===m)throw new e.default(o.opts.uriResolver,d,a);return m instanceof s.SchemaEnv?function(e){const r=i(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}),o=n.name("valid"),i=t.subschema({schema:e,dataTypes:[],schemaPath:r.nil,topSchemaRef:s,errSchemaPath:a},o);t.mergeEvaluated(i),t.ok(o)}(m)}};function i(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,o,i){const{gen:c,it:d}=e,{allErrors:u,schemaEnv:l,opts:p}=d,h=p.passContext?n.default.this:r.nil;function f(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==o?void 0:o.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)}}i?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,h)}`),m(s),u||c.assign(n,!0)},e=>{c.if(r._`!(${e} instanceof ${d.ValidationError})`,()=>c.throw(e)),f(e),u||c.assign(n,!1)}),e.ok(n)}():e.result((0,t.callValidateCode)(e,s,h),()=>m(s),()=>f(s))}return Sl.getValidate=i,Sl.callRef=c,Sl.default=o,Sl}(),r=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",e.default,t.default];return kl.default=r,kl}(),t=Ql(),r=Mp(),n=function(){if(Dp)return Lp;Dp=1,Object.defineProperty(Lp,"__esModule",{value:!0});const e=[qp().default];return Lp.default=e,Lp}(),s=(Up||(Up=1,Object.defineProperty(Hp,"__esModule",{value:!0}),Hp.contentVocabulary=Hp.metadataVocabulary=void 0,Hp.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],Hp.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]),Hp),a=[e.default,t.default,(0,r.default)(),n.default,s.metadataVocabulary,s.contentVocabulary];return bl.default=a,bl}var Kp,Bp,Gp={},Wp={};var Xp,Yp={$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 Qp(){return Xp||(Xp=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=yl(),n=Jp(),s=function(){if(Bp)return Gp;Bp=1,Object.defineProperty(Gp,"__esModule",{value:!0});const e=pu(),t=(Kp||(Kp=1,Object.defineProperty(Wp,"__esModule",{value:!0}),Wp.DiscrError=void 0,function(e){e.Tag="tag",e.Mapping="mapping"}(r||(Wp.DiscrError=r={}))),Wp);var r;const n=al(),s=rl(),a=mu(),o={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:o,data:i,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 h=o.let("valid",!1),f=o.const("tag",e._`${i}${(0,e.getProperty)(p)}`);function m(t){const n=o.name("valid"),s=r.subschema({keyword:"oneOf",schemaProp:t},n);return r.mergeEvaluated(s,e.Name),n}o.if(e._`typeof ${f} == "string"`,()=>function(){const i=function(){var e;const t={},r=i(d);let o=!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 h=null===(e=null==d?void 0:d.properties)||void 0===e?void 0:e[p];if("object"!=typeof h)throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${p}"`);o=o&&(r||i(d)),c(h,t)}if(!o)throw new Error(`discriminator: "${p}" must be required`);return t;function i({required:e}){return Array.isArray(e)&&e.includes(p)}function c(e,t){if(e.const)h(e.const,t);else{if(!e.enum)throw new Error(`discriminator: "properties/${p}" must have "const" or "enum"`);for(const r of e.enum)h(r,t)}}function h(e,r){if("string"!=typeof e||e in t)throw new Error(`discriminator: "${p}" values must be unique strings`);t[e]=r}}();o.if(!1);for(const t in i)o.elseIf(e._`${f} === ${t}`),o.assign(h,m(i[t]));o.else(),r.error(!1,{discrError:t.DiscrError.Mapping,tag:f,tagName:p}),o.endIf()}(),()=>r.error(!1,{discrError:t.DiscrError.Tag,tag:f,tagName:p})),r.ok(h)}};return Gp.default=o,Gp}(),a=Yp,o=["/properties"],i="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,o):a;this.addMetaSchema(e,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var d=Wu();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return d.KeywordCxt}});var u=pu();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=Qu();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return l.default}});var p=rl();Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return p.default}})}(eu,eu.exports)),eu.exports}var eh,th,rh,nh=Yd(Qp()),sh={exports:{}},ah={},oh={},ih=(rh||(rh=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=(eh||(eh=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(i(!0),c),"date-time":t(l(!0),p),"iso-time":t(i(),d),"iso-date-time":t(l(),h),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:function(e){return f.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,h),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],o=+t[3];return a>=1&&a<=12&&o>=1&&o<=(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 o=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function i(e){return function(t){const r=o.exec(t);if(!r)return!1;const n=+r[1],s=+r[2],a=+r[3],i=r[4],c="-"===r[5]?-1:1,d=+(r[6]||0),u=+(r[7]||0);if(d>23||u>59||e&&!i)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=o.exec(e),n=o.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=i(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 h(e,t){if(!e||!t)return;const[r,n]=e.split(u),[s,o]=t.split(u),i=a(r,s);return void 0!==i?i||c(n,o):void 0}const f=/\/|:/,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/}(ah)),ah),n=(th||(th=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.formatLimitDefinition=void 0;const t=Qp(),r=pu(),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:o,keyword:i,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}, ${o}) ${s[i].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(`"${i}": 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)}(oh)),oh),s=pu(),a=new s.Name("fullFormats"),o=new s.Name("fastFormats"),i=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,r.fullFormats,a),e;const[s,i]="fast"===t.mode?[r.fastFormats,o]:[r.fullFormats,a];return c(e,t.formats||r.formatNames,s,i),t.keywords&&(0,n.default)(e),e};function c(e,t,r,n){var a,o;null!==(a=(o=e.opts.code).formats)&&void 0!==a||(o.formats=s._`require("ajv-formats/dist/formats").${n}`);for(const n of t)e.addFormat(n,r[n])}i.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=i,Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}(sh,sh.exports)),sh.exports),ch=Yd(ih);class dh{constructor(e){this._ajv=e??function(){const e=new nh({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return ch(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 uh{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 lh extends Wd{constructor(e,t){super(t),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map($c.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 dh,this.setRequestHandler(ii,e=>this._oninitialize(e)),this.setNotificationHandler(ui,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Ec,async(e,t)=>{const r=t.sessionId||t.requestInfo?.headers["mcp-session-id"]||void 0,{level:n}=e.params,s=$c.safeParse(n);return s.success&&this._loggingLevels.set(r,s.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new uh(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];Xd(a)&&Xd(s)?r[n]={...a,...s}:r[n]=s}return r}(this._capabilities,e)}setRequestHandler(e,t){const r=Ls(e),n=r?.method;if(!n)throw new Error("Schema is missing a method literal");let s;if(As(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=Zs(bc,e);if(!n.success){const e=n.error instanceof Error?n.error.message:String(n.error);throw new dd(Ho.InvalidParams,`Invalid tools/call request: ${e}`)}const{params:s}=n.data,a=await Promise.resolve(t(e,r));if(s.task){const e=Zs(wi,a);if(!e.success){const t=e.error instanceof Error?e.error.message:String(e.error);throw new dd(Ho.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}const o=Zs(vc,a);if(!o.success){const e=o.error instanceof Error?o.error.message:String(o.error);throw new dd(Ho.InvalidParams,`Invalid tools/call result: ${e}`)}return o.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:So.includes(t)?t:$o,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"},Bo)}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]:[],o=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(!o)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(o){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},Zc,t):this.request({method:"sampling/createMessage",params:e},Mc,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},Qc,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},Qc,t);if("accept"===n.action&&n.content&&r.requestedSchema)try{const e=this._jsonSchemaValidator.getValidator(r.requestedSchema)(n.content);if(!e.valid)throw new dd(Ho.InvalidParams,`Elicitation response content does not match requested schema: ${e.errorMessage}`)}catch(e){if(e instanceof dd)throw e;throw new dd(Ho.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},id,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 ph=Symbol.for("mcp.completable");function hh(e){return!!e&&"object"==typeof e&&ph in e}var fh;!function(e){e.Completable="McpCompletable"}(fh||(fh={}));const mh=/^[A-Za-z0-9._-]{1,128}$/;function gh(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"),!mh.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 yh{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 _h{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 lh(e,t)}get experimental(){return this._experimental||(this._experimental={tasks:new yh(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Sh(yc)),this.server.assertCanSetRequestHandler(Sh(bc)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(yc,()=>({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=Fs(t.inputSchema);return e?Kd(e,{strictUnions:!0,pipeStrategy:"input"}):vh})(),annotations:t.annotations,execution:t.execution,_meta:t._meta};if(t.outputSchema){const e=Fs(t.outputSchema);e&&(r.outputSchema=Kd(e,{strictUnions:!0,pipeStrategy:"output"}))}return r})})),this.server.setRequestHandler(bc,async(e,t)=>{try{const r=this._registeredTools[e.params.name];if(!r)throw new dd(Ho.InvalidParams,`Tool ${e.params.name} not found`);if(!r.enabled)throw new dd(Ho.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 dd(Ho.InternalError,`Tool ${e.params.name} has taskSupport '${s}' but was not registered with registerToolTask`);if("required"===s&&!n)throw new dd(Ho.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if("optional"===s&&!n&&a)return await this.handleAutomaticTaskPolling(r,e,t);const o=await this.validateToolInput(r,e.params.arguments,e.params.name),i=await this.executeToolHandler(r,o,t);return n||await this.validateToolOutput(r,i,e.params.name),i}catch(e){if(e instanceof dd&&e.code===Ho.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=Fs(e.inputSchema)??e.inputSchema,s=await Ds(n,t);if(!s.success){const e=qs("error"in s?s.error:"Unknown error");throw new dd(Ho.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 dd(Ho.InvalidParams,`Output validation error: Tool ${r} has an output schema but no structured content was provided`);const n=Fs(e.outputSchema),s=await Ds(n,t.structuredContent);if(!s.success){const e=qs("error"in s?s.error:"Unknown error");throw new dd(Ho.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},o=n?await Promise.resolve(s.createTask(n,a)):await Promise.resolve(s.createTask(a)),i=o.task.taskId;let c=o.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(i);if(!e)throw new dd(Ho.InternalError,`Task ${i} not found during polling`);c=e}return await r.taskStore.getTaskResult(i)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Sh(nd)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(nd,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 dd(Ho.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,t){const r=this._registeredPrompts[t.name];if(!r)throw new dd(Ho.InvalidParams,`Prompt ${t.name} not found`);if(!r.enabled)throw new dd(Ho.InvalidParams,`Prompt ${t.name} disabled`);if(!r.argsSchema)return Th;const n=Ls(r.argsSchema),s=n?.[e.params.argument.name];if(!hh(s))return Th;const a=function(e){const t=e[ph];return t?.complete}(s);return a?Eh(await a(e.params.argument.value,e.params.context)):Th}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 Th;throw new dd(Ho.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}const n=r.resourceTemplate.completeCallback(e.params.argument.name);return n?Eh(await n(e.params.argument.value,e.params.context)):Th}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Sh(Zi)),this.server.assertCanSetRequestHandler(Sh(Li)),this.server.assertCanSetRequestHandler(Sh(Vi)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Zi,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(Li,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([e,t])=>({name:e,uriTemplate:t.resourceTemplate.uriTemplate.toString(),...t.metadata}))})),this.server.setRequestHandler(Vi,async(e,t)=>{const r=new URL(e.params.uri),n=this._registeredResources[r.toString()];if(n){if(!n.enabled)throw new dd(Ho.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 dd(Ho.InvalidParams,`Resource ${r} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Sh(tc)),this.server.assertCanSetRequestHandler(Sh(sc)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(tc,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,t])=>({name:e,title:t.title,description:t.description,arguments:t.argsSchema?$h(t.argsSchema):void 0}))})),this.server.setRequestHandler(sc,async(e,t)=>{const r=this._registeredPrompts[e.params.name];if(!r)throw new dd(Ho.InvalidParams,`Prompt ${e.params.name} not found`);if(!r.enabled)throw new dd(Ho.InvalidParams,`Prompt ${e.params.name} disabled`);if(r.argsSchema){const n=Fs(r.argsSchema),s=await Ds(n,e.params.arguments);if(!s.success){const t=qs("error"in s?s.error:"Unknown error");throw new dd(Ho.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${t}`)}const a=s.data,o=r.callback;return await Promise.resolve(o(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 o=r.uriTemplate.variableNames;return Array.isArray(o)&&o.some(e=>!!r.completeCallback(e))&&this.setCompletionRequestHandler(),a}_createRegisteredPrompt(t,r,n,s,a){const o={title:r,description:n,argsSchema:void 0===s?void 0:Ms(s),callback:a,enabled:!0,disable:()=>o.update({enabled:!1}),enable:()=>o.update({enabled:!0}),remove:()=>o.update({name:null}),update:e=>{void 0!==e.name&&e.name!==t&&(delete this._registeredPrompts[t],e.name&&(this._registeredPrompts[e.name]=o)),void 0!==e.title&&(o.title=e.title),void 0!==e.description&&(o.description=e.description),void 0!==e.argsSchema&&(o.argsSchema=Ms(e.argsSchema)),void 0!==e.callback&&(o.callback=e.callback),void 0!==e.enabled&&(o.enabled=e.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[t]=o,s&&Object.values(s).some(t=>hh(t instanceof e?t._def?.innerType:t))&&this.setCompletionRequestHandler(),o}_createRegisteredTool(e,t,r,n,s,a,o,i,c){gh(e);const d={title:t,description:r,inputSchema:kh(n),outputSchema:kh(s),annotations:a,execution:o,_meta:i,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&&gh(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=Ms(t.paramsSchema)),void 0!==t.outputSchema&&(d.outputSchema=Ms(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];bh(e)?(n=t.shift(),t.length>1&&"object"==typeof t[0]&&null!==t[0]&&!bh(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:o,annotations:i,_meta:c}=t;return this._createRegisteredTool(e,n,s,a,o,i,{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,o=this._createRegisteredPrompt(e,n,s,a,r);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),o}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 vh={type:"object",properties:{}};function wh(e){return null!==e&&"object"==typeof e&&"parse"in e&&"function"==typeof e.parse&&"safeParse"in e&&"function"==typeof e.safeParse}function bh(e){return"object"==typeof e&&null!==e&&!function(e){return"_def"in e||"_zod"in e||wh(e)}(e)&&(0===Object.keys(e).length||Object.values(e).some(wh))}function kh(e){if(e)return bh(e)?Ms(e):e}function $h(e){const t=Ls(e);return t?Object.entries(t).map(([e,t])=>{const r=function(e){return e.description}(t),n=function(e){if(As(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 Sh(e){const t=Ls(e),r=t?.method;if(!r)throw new Error("Schema is missing a method literal");const n=Us(r);if("string"==typeof n)return n;throw new Error("Schema method literal must be a string")}function Eh(e){return{completion:{values:e.slice(0,100),total:e.length,hasMore:e.length>100}}}const Th={completion:{values:[],hasMore:!1}};class xh{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 Ko.parse(JSON.parse(e))}(t)}clear(){this._buffer=void 0}}class Nh{constructor(e=r.stdin,t=r.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new xh,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 Oh={logging:{level:"DEBUG"},db:{path:c.join(u.homedir(),".knowledge-bank","knowledge.db"),configs:["journal_mode = WAL","foreign_keys = ON"]},tmp:c.join(u.homedir(),".knowledge-bank","tmp")};let Ph=null;function Ih(){if(null===Ph){const e=process.env.KNOWLEDGE_CONF_DIR||c.join(u.homedir(),".knowledge-bank"),t=c.join(e,"config.json");Ph={...Oh,...n.existsSync(t)?JSON.parse(n.readFileSync(t,"utf-8")):{}}}return Ph}const Rh=Ih(),zh={DEBUG:"DEBUG",INFO:"INFO",WARN:"WARN",ERROR:"ERROR"},jh=Object.values(zh);class Ch{constructor(e,t){this.loggerName=t;const r=Rh.logging.path||c.join(u.homedir(),".knowledge-bank","logs");n.mkdirSync(r,{recursive:!0}),this.loggerFile=c.join(r,`${e}.log`),this.logLevel=Rh.logging.level.toUpperCase()||zh.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=jh.indexOf(this.logLevel);return jh.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(zh.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(zh.ERROR,e,r)}else this.writeMessage(zh.ERROR,e,t)}logWarn(e,t=null){this.writeMessage(zh.WARN,e,t)}logDebug(e,t=null){this.writeMessage(zh.DEBUG,e,t)}}function Ah(e,t){return new Ch(e,t)}const Mh=Ih();class Zh{constructor(){this.dbPath=Mh.db.path,this.db=null,this.transactionDepth=0}initialize(){const e=d(this.dbPath);return s(e)||a(e,{recursive:!0}),this.db=new l(this.dbPath),Mh.db.configs.forEach(e=>{this.db.pragma(e)}),this}getConnection(){return this.db||this.initialize(),this.db}beginTransaction(){return 0===this.transactionDepth&&this.getConnection().prepare("BEGIN").run(),this.transactionDepth++,this}commit(){return this.transactionDepth--,0===this.transactionDepth&&this.getConnection().prepare("COMMIT").run(),this}rollback(){return this.transactionDepth--,0===this.transactionDepth&&this.getConnection().prepare("ROLLBACK").run(),this}transaction(e){this.beginTransaction();try{const t=e(this.getConnection());return this.commit(),t}catch(e){throw this.rollback(),e}}close(){return this.db&&(this.db.close(),this.db=null),this}exists(){return s(this.dbPath)}getPath(){return this.dbPath}}let Dh=null;const Lh=["personal","project","organization"],Fh=["developer","architect","reviewer","ai"],qh=["code_pattern","tool_usage","architecture","config","pitfall","api_usage","exploration"],Uh=["draft","suggested","verified"],Vh={knowledge_item:`\n CREATE TABLE IF NOT EXISTS knowledge_item (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\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 (${Lh.map(e=>`'${e}'`).join(", ")})),\n source_type TEXT NOT NULL CHECK(source_type IN (${Fh.map(e=>`'${e}'`).join(", ")})),\n knowledge_type TEXT NOT NULL CHECK(knowledge_type IN (${qh.map(e=>`'${e}'`).join(", ")})),\n status TEXT NOT NULL DEFAULT 'draft' CHECK(status IN (${Uh.map(e=>`'${e}'`).join(", ")})),\n\n -- Association information\n repository_id INTEGER,\n session_id TEXT NOT NULL,\n\n -- Source tracking\n source_file TEXT,\n commit_hash TEXT,\n contributor TEXT,\n\n -- Timestamps\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n\n FOREIGN KEY (repository_id) REFERENCES repository(id)\n )\n `,repository:"\n CREATE TABLE IF NOT EXISTS repository (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n\n name TEXT NOT NULL,\n remote_url TEXT UNIQUE NOT NULL,\n local_path TEXT,\n\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL\n )\n ",session:"\n CREATE TABLE IF NOT EXISTS session (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n\n session_id TEXT UNIQUE NOT NULL,\n repository_id INTEGER,\n\n -- Session basic information\n working_directory TEXT NOT NULL,\n branch TEXT,\n username TEXT,\n\n -- Environment information (stored as JSON)\n env TEXT,\n\n -- Configuration information (stored as JSON)\n config TEXT,\n\n created_at INTEGER NOT NULL,\n updated_at INTEGER NOT NULL,\n\n FOREIGN KEY (repository_id) REFERENCES repository(id)\n )\n ",hook_event:"\n CREATE TABLE IF NOT EXISTS hook_event (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n\n session_id TEXT NOT NULL,\n\n -- Hook information\n name TEXT NOT NULL,\n input TEXT NOT NULL,\n output TEXT,\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 "},Hh={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 "},Jh={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_repo:"CREATE INDEX IF NOT EXISTS idx_knowledge_repo ON knowledge_item(repository_id)",idx_knowledge_session:"CREATE INDEX IF NOT EXISTS idx_knowledge_session ON knowledge_item(session_id)",idx_session_repo:"CREATE INDEX IF NOT EXISTS idx_session_repo ON session(repository_id)",idx_session_id:"CREATE INDEX IF NOT EXISTS idx_session_id ON session(session_id)",idx_hook_event_session:"CREATE INDEX IF NOT EXISTS idx_hook_event_session ON hook_event(session_id)",idx_hook_event_type:"CREATE INDEX IF NOT EXISTS idx_hook_event_type ON hook_event(name)"},Kh=Ah("knowledge-repository","knowledge-repository");class Bh{constructor(e){this.database=e,this.db=e.getConnection()}create(e){const t=Date.now(),r=this.db.prepare("\n INSERT INTO knowledge_item (\n title, summary, content,\n scope, source_type, knowledge_type, status,\n repository_id, session_id,\n source_file, commit_hash, contributor,\n created_at, updated_at\n ) VALUES (\n @title, @summary, @content,\n @scope, @source_type, @knowledge_type, @status,\n @repository_id, @session_id,\n @source_file, @commit_hash, @contributor,\n @created_at, @updated_at\n )\n ").run({...e,status:e.status||Uh.DRAFT,created_at:t,updated_at:t});return this.findById(r.lastInsertRowid)}findById(e){return this.db.prepare("SELECT * FROM knowledge_item WHERE id = ?").get(e)}findByRepository(e,t=null){return t?this.db.prepare("SELECT * FROM knowledge_item WHERE repository_id = ? AND scope = ? ORDER BY updated_at DESC").all(e,t):this.db.prepare("SELECT * FROM knowledge_item WHERE repository_id = ? ORDER BY updated_at DESC").all(e)}findByScope(e){return this.db.prepare("SELECT * FROM knowledge_item WHERE scope = ? ORDER BY updated_at DESC").all(e)}findByStatus(e){return this.db.prepare("SELECT * FROM knowledge_item WHERE status = ? ORDER BY updated_at DESC").all(e)}findByKnowledgeType(e){return this.db.prepare("SELECT * FROM knowledge_item WHERE knowledge_type = ? ORDER BY updated_at DESC").all(e)}findBySession(e){return this.db.prepare("SELECT * FROM knowledge_item WHERE session_id = ?").all(e)}findRelevant(e,t=5){return this.db.prepare("\n SELECT * FROM knowledge_item\n WHERE repository_id = ? OR scope = 'organization'\n ORDER BY\n CASE status\n WHEN 'verified' THEN 3\n WHEN 'suggested' THEN 2\n WHEN 'draft' THEN 1\n END DESC,\n updated_at DESC\n LIMIT ?\n ").all(e,t)}update(e,t){const r=Date.now(),n=Object.keys(t).map(e=>`${e} = @${e}`).join(", ");return this.db.prepare(`\n UPDATE knowledge_item\n SET ${n}, updated_at = @updated_at\n WHERE id = @id\n `).run({...t,id:e,updated_at:r}),this.findById(e)}updateStatus(e,t){return this.update(e,{status:t})}delete(e){return this.db.prepare("DELETE FROM knowledge_item WHERE id = ?").run(e)}count(e={}){let t="SELECT COUNT(*) as count FROM knowledge_item";const r=[],n=[];return e.scope&&(r.push("scope = ?"),n.push(e.scope)),e.status&&(r.push("status = ?"),n.push(e.status)),e.knowledge_type&&(r.push("knowledge_type = ?"),n.push(e.knowledge_type)),e.repository_id&&(r.push("repository_id = ?"),n.push(e.repository_id)),r.length>0&&(t+=` WHERE ${r.join(" AND ")}`),this.db.prepare(t).get(...n).count}findAll(e=100,t=0){return this.db.prepare("SELECT * FROM knowledge_item ORDER BY updated_at DESC LIMIT ? OFFSET ?").all(e,t)}search(e,t=10){const r=Array.isArray(e)?e.map(e=>`"${e}"`).join(" OR "):`"${e}"`;return Kh.logDebug("Searching knowledge items with query: ",r),this.db.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 ?\n ").all(r,t)}}class Gh{constructor(e){this.database=e,this.db=e.getConnection()}create(e){const t=Date.now(),r=this.db.prepare("\n INSERT INTO repository (\n name, remote_url, local_path,\n created_at, updated_at\n ) VALUES (\n @name, @remote_url, @local_path,\n @created_at, @updated_at\n )\n ").run({...e,created_at:t,updated_at:t});return this.findById(r.lastInsertRowid)}findById(e){return this.db.prepare("SELECT * FROM repository WHERE id = ?").get(e)}findByRemoteUrl(e){return this.db.prepare("SELECT * FROM repository WHERE remote_url = ?").get(e)}findByPath(e){return this.db.prepare("SELECT * FROM repository WHERE local_path = ?").get(e)}findByName(e){return this.db.prepare("SELECT * FROM repository WHERE name = ?").get(e)}getOrCreate(e,t,r=null){let n=this.findByRemoteUrl(e);return n?r&&n.local_path!==r&&(n=this.update(n.id,{local_path:r})):n=this.create({name:t,remote_url:e,local_path:r}),n}update(e,t){const r=Date.now(),n=Object.keys(t).map(e=>`${e} = @${e}`).join(", ");return this.db.prepare(`\n UPDATE repository\n SET ${n}, updated_at = @updated_at\n WHERE id = @id\n `).run({...t,id:e,updated_at:r}),this.findById(e)}delete(e){return this.db.prepare("DELETE FROM repository WHERE id = ?").run(e)}findAll(){return this.db.prepare("SELECT * FROM repository ORDER BY updated_at DESC").all()}count(){return this.db.prepare("SELECT COUNT(*) as count FROM repository").get().count}}Ah("common","common");const Wh=f(import.meta.url),Xh=c.dirname(Wh);c.join(Xh,"..","claude-marketplace");const Yh=function(){const e=c.join(Xh,"package.json"),t=c.join(".","package.json");return n.existsSync(e)?JSON.parse(o(e,"utf8")):JSON.parse(o(t,"utf8"))}();c.join(u.homedir(),".claude","settings.local.json");class Qh{constructor(e=null){this.repoPath=e||h(),this.git=p(this.repoPath)}getCurrentBranch(){return this.git.branchLocal().then(e=>e.current).catch(e=>{throw new Error(`Failed to get current branch: ${e.message}`)})}getRemoteUrl(e="origin"){return this.git.getRemotes(!0).then(t=>{const r=t.find(t=>t.name===e);if(!r)throw new Error(`Remote '${e}' not found`);return r.refs.fetch||r.refs.push}).catch(e=>{throw new Error(`Failed to get remote URL: ${e.message}`)})}getMainBranch(){return this.git.branchLocal().then(e=>{const t=e.all;return t.includes("main")?"main":t.includes("master")?"master":t[0]||"main"}).catch(()=>"main")}isOnMainBranch(){return this.getCurrentBranch().then(e=>this.getMainBranch().then(t=>e===t))}getCurrentCommitHash(){return this.git.revparse(["HEAD"]).then(e=>e.trim()).catch(e=>{throw new Error(`Failed to get commit hash: ${e.message}`)})}getCommitAuthor(e="HEAD"){return this.git.show(["-s","--format=%an <%ae>",e]).then(e=>e.trim()).catch(e=>{throw new Error(`Failed to get commit author: ${e.message}`)})}isBranchMergedToMain(e){return this.getMainBranch().then(t=>this.git.branch(["--merged",t]).then(t=>t.all.map(e=>e.replace("*","").trim()).includes(e))).catch(e=>(console.error(`Failed to check merge status: ${e.message}`),!1))}getRepoRoot(){return this.git.revparse(["--show-toplevel"]).then(e=>e.trim()).catch(e=>{throw new Error(`Failed to get repo root: ${e.message}`)})}isGitRepository(){return this.git.checkIsRepo().catch(()=>!1)}getStatus(){return this.git.status().catch(e=>{throw new Error(`Failed to get git status: ${e.message}`)})}getAllBranches(){return this.git.branchLocal().then(e=>e.all).catch(e=>{throw new Error(`Failed to get branches: ${e.message}`)})}getRepositoryName(){return this.getRemoteUrl().then(e=>{const t=e.match(/([^/:]+?)(?:\.git)?$/);return t?t[1]:"unknown"}).catch(()=>"unknown")}getUserName(){return this.git.getConfig("user.name").then(e=>e.value||process.env.USER||process.env.USERNAME||"unknown_user").catch(()=>"unknown")}getUserInfo(){return Promise.all([this.git.getConfig("user.name").catch(()=>({value:null})),this.git.getConfig("user.email").catch(()=>({value:null}))]).then(([e,t])=>({name:e.value||"unknown",email:t.value||"unknown"}))}}class ef{constructor(e,t){this.gitUtils=e,this.repositoryRepo=t}getCurrentRepository(){return Promise.all([this.gitUtils.getRemoteUrl(),this.gitUtils.getRepositoryName(),this.gitUtils.getRepoRoot()]).then(([e,t,r])=>this.getOrCreateRepository(e,t,r)).catch(e=>{throw new Error(`Failed to get current repository: ${e.message}`)})}getOrCreateRepository(e,t,r=null){return Promise.resolve(this.repositoryRepo.getOrCreate(e,t,r))}getRepository(e){return Promise.resolve(this.repositoryRepo.findById(e))}getRepositoryByUrl(e){return Promise.resolve(this.repositoryRepo.findByRemoteUrl(e))}getAllRepositories(){return Promise.resolve(this.repositoryRepo.findAll())}updateRepository(e,t){return Promise.resolve(this.repositoryRepo.update(e,t))}deleteRepository(e){return Promise.resolve(this.repositoryRepo.delete(e))}getRepositoryStats(e){return Promise.resolve({total_repositories:this.repositoryRepo.count()})}}class tf{constructor(e){this.gitUtils=e}validateBranchForSession(){return this.gitUtils.getCurrentBranch().then(e=>this.gitUtils.getMainBranch().then(t=>e===t?{valid:!1,branch:e,message:`Cannot start session on main branch '${e}'. Please create a feature branch first.\n\nExample:\n git checkout -b feature/my-feature\n claude "your prompt here"`}:{valid:!0,branch:e,message:`Session validated on branch '${e}'`})).catch(e=>(console.warn(`Branch validation warning: ${e.message}`),{valid:!0,branch:"unknown",message:`Branch validation skipped: ${e.message}`}))}isMainBranch(){return this.gitUtils.isOnMainBranch().catch(()=>!1)}}const rf=new class{constructor(){this.database=(Dh||(Dh=new Zh),Dh),this.initialized=!1}initialize(){this.initialized||(this.database.initialize(),this.initialized=!0)}async prepare(){this.initialize(),function(e){Object.values(Vh).forEach(t=>{e.prepare(t).run()}),Object.values(Jh).forEach(t=>{e.prepare(t).run()}),Object.values(Hh).forEach(t=>{e.prepare(t).run()});const t=e.prepare("SELECT COUNT(*) as count FROM knowledge_item_fts").get(),r=e.prepare("SELECT COUNT(*) as count FROM knowledge_item").get();r.count>0&&0===t.count&&(console.log("Populating FTS index from existing data..."),e.prepare("\n INSERT INTO knowledge_item_fts(rowid, title, summary, content)\n SELECT id, title, summary, content FROM knowledge_item\n ").run(),console.log(`FTS index populated with ${r.count} items`))}(this.database.getConnection())}getConnection(){return this.initialize(),this.database.getConnection()}close(){this.database&&(this.database.close(),this.initialized=!1)}},nf=new class{constructor(e){this.dbService=e,this._repositoryRepo=null}get repositoryRepo(){return this._repositoryRepo||(this._repositoryRepo=new Gh(this.dbService.database)),this._repositoryRepo}}(rf),sf=new class{constructor(e){this.dbService=e,this._knowledgeRepo=null}get knowledgeRepo(){return this._knowledgeRepo||(this._knowledgeRepo=new Bh(this.dbService.database)),this._knowledgeRepo}}(rf),af=new class{constructor(e){this.gitUtils=new Qh,this.repositoryManager=new ef(this.gitUtils,e),this.branchValidator=new tf(this.gitUtils)}}(nf.repositoryRepo);nf.gitService=af;class of{constructor(){this.logger=Ah("knowledge-management","knowledge-management"),this.knowledgeService=sf}getRepositoryId(){return process.env.CLAUDE_SESSION_REPOSITORYID}getSessionId(){return process.env.CLAUDE_SESSION_ID}buildUpdateData(e){const t={};return["title","summary","content","scope","source_type","knowledge_type","status","source_file","commit_hash","contributor"].forEach(r=>{void 0!==e[r]&&(t[r]=e[r])}),t}aggregateByStatus(e,t){e.forEach(e=>{t.by_status[e]=this.knowledgeService.knowledgeRepo.count({status:e})})}aggregateByScope(e,t){e.forEach(e=>{t.by_scope[e]=this.knowledgeService.knowledgeRepo.count({scope:e})})}aggregateByType(e,t){e.forEach(e=>{t.by_type[e]=this.knowledgeService.knowledgeRepo.count({knowledge_type:e})})}async create(e){this.logger.logDebug("Creating new knowledge item",e);const t=this.knowledgeService.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,commit_hash:e.commit_hash,contributor:e.contributor,repository_id:e.repository_id||this.getRepositoryId(),session_id:e.session_id||this.getSessionId()});return this.logger.logDebug(`✓ Knowledge item created with ID: ${t.id}`),t}async update(e,t){this.logger.logInfo(`Updating knowledge item ${e}...`);const r=this.buildUpdateData(t),n=this.knowledgeService.knowledgeRepo.update(e,r);return this.logger.logInfo(`✓ Knowledge item ${e} updated`),n}async delete(e){this.logger.logInfo(`Deleting knowledge item ${e}...`),this.knowledgeService.knowledgeRepo.delete(e),this.logger.logInfo(`✓ Knowledge item ${e} deleted`)}async get(e){return this.knowledgeService.knowledgeRepo.findById(e)||(this.logger.logWarn(`Knowledge item ${e} not found`),null)}async list(e={}){if(e.scope)return this.knowledgeService.knowledgeRepo.findByScope(e.scope);if(e.status)return this.knowledgeService.knowledgeRepo.findByStatus(e.status);if(e.knowledge_type)return this.knowledgeService.knowledgeRepo.findByKnowledgeType(e.knowledge_type);const t=e.limit||100,r=e.offset||0;return this.knowledgeService.knowledgeRepo.findAll(t,r)}async search(e,t=10){return this.knowledgeService.knowledgeRepo.search(e,t)}async updateStatus(e,t){this.logger.logInfo(`Updating status of knowledge item ${e} to ${t}...`);const r=this.knowledgeService.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.knowledgeService.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 cf{static exists(e){return s(e)}static writeJson(e,t){const r=d(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=d(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.commit_hash?`**Commit Hash:** ${e.commit_hash}`:""}\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,commit_hash:e.commit_hash||null,contributor:e.contributor||null}}}const df=Ih(),uf=Ah("mcp-server","mcp-server");class lf{constructor(){this.knowledgeManagement=new of,this.tempDir=c.join(df.tmp,function(e=0){const t=new Date;return t.setDate(t.getDate()-e),`${t.getFullYear()}${String(t.getMonth()+1).padStart(2,"0")}${String(t.getDate()).padStart(2,"0")}`}()),this.server=new _h({name:"knowledge-bank",version:Yh.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"),repository_id:t.number().describe("Repository 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(Lh).optional().describe("Scope of knowledge"),source_type:t.enum(Fh).optional().describe("Source type"),knowledge_type:t.enum(qh).optional().describe("Knowledge type"),status:t.enum(Uh).optional().describe("Status of knowledge"),source_file:t.string().optional().describe("Source file path (optional)"),commit_hash:t.string().optional().describe("Commit hash (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(Lh).optional().describe("Scope of knowledge"),source_type:t.enum(Fh).optional().describe("Source type"),knowledge_type:t.enum(qh).optional().describe("Knowledge type"),status:t.enum(Uh).optional().describe("Status of knowledge"),source_file:t.string().optional().describe("Source file path"),commit_hash:t.string().optional().describe("Commit hash"),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(Lh).optional().describe("Filter by scope"),status:t.enum(Uh).optional().describe("Filter by status"),knowledge_type:t.enum(qh).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(Uh).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=c.join(this.tempDir,e.from);if(!cf.exists(r))return{content:[{type:"text",text:JSON.stringify({error:`File not found: ${r}`},null,2)}],isError:!0};try{t=cf.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 af.repositoryManager.getCurrentRepository(),n=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,commit_hash:t.commit_hash,contributor:t.contributor,repository_id:r.id,session_id:process.env.CLAUDE_SESSION_ID||t.session_id||"unknown-session"});if(e.from){const t=c.join(this.tempDir,e.from);return{content:[{type:"text",text:JSON.stringify({id:n.id,title:n.title,message:`Knowledge item created from ${e.from}`,file_path:t},null,2)}]}}return{content:[{type:"text",text:JSON.stringify(n,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=c.join(this.tempDir,e.to),n=cf.formatKnowledgeAsMarkdown(t);return cf.writeMarkdown(r,n),{content:[{type:"text",text:JSON.stringify({success:!0,message:`Knowledge item ${e.id} saved to ${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=c.join(this.tempDir,r);if(!cf.exists(e))return{content:[{type:"text",text:JSON.stringify({error:`File not found: ${e}`},null,2)}],isError:!0};try{s={...cf.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(a,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=c.join(this.tempDir,t),s=n.map(e=>cf.extractKnowledgeForJson(e));return cf.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=c.join(this.tempDir,t),a=s.map(e=>cf.extractKnowledgeForJson(e));return cf.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 Nh;await this.server.connect(e),uf.logWarn(`Knowledge Bank MCP server running under ${process.cwd()}`)}}export{lf as KnowledgeBankMCPServer};
|