mboaai-sdk 1.0.14 → 1.0.16
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/mboaai-sdk.esm.js +2 -1
- package/dist/mboaai-sdk.umd.js +2 -1
- package/package.json +3 -1
package/dist/mboaai-sdk.esm.js
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
import{MCPClient as e}from"mcp-client";import t from"pkce-challenge";var s,a;!function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const s of e)t[s]=s;return t},e.getValidEnumValues=t=>{const s=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),a={};for(const e of s)a[e]=t[e];return e.objectValues(a)},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 s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.push(s);return t},e.find=(e,t)=>{for(const s of e)if(t(s))return s},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}(s||(s={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(a||(a={}));const n=s.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),r=e=>{switch(typeof e){case"undefined":return n.undefined;case"string":return n.string;case"number":return Number.isNaN(e)?n.nan:n.number;case"boolean":return n.boolean;case"function":return n.function;case"bigint":return n.bigint;case"symbol":return n.symbol;case"object":return Array.isArray(e)?n.array:null===e?n.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?n.promise:"undefined"!=typeof Map&&e instanceof Map?n.map:"undefined"!=typeof Set&&e instanceof Set?n.set:"undefined"!=typeof Date&&e instanceof Date?n.date:n.object;default:return n.unknown}},i=s.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 o 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},s={_errors:[]},a=e=>{for(const n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(a);else if("invalid_return_type"===n.code)a(n.returnTypeError);else if("invalid_arguments"===n.code)a(n.argumentsError);else if(0===n.path.length)s._errors.push(t(n));else{let e=s,a=0;for(;a<n.path.length;){const s=n.path[a];a===n.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(n))):e[s]=e[s]||{_errors:[]},e=e[s],a++}}};return a(this),s}static assert(e){if(!(e instanceof o))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,s.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},s=[];for(const a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):s.push(e(a));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}o.create=e=>new o(e);const d=(e,t)=>{let a;switch(e.code){case i.invalid_type:a=e.received===n.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case i.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(e.expected,s.jsonStringifyReplacer)}`;break;case i.unrecognized_keys:a=`Unrecognized key(s) in object: ${s.joinValues(e.keys,", ")}`;break;case i.invalid_union:a="Invalid input";break;case i.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${s.joinValues(e.options)}`;break;case i.invalid_enum_value:a=`Invalid enum value. Expected ${s.joinValues(e.options)}, received '${e.received}'`;break;case i.invalid_arguments:a="Invalid function arguments";break;case i.invalid_return_type:a="Invalid function return type";break;case i.invalid_date:a="Invalid date";break;case i.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(a=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(a=`${a} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?a=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?a=`Invalid input: must end with "${e.validation.endsWith}"`:s.assertNever(e.validation):a="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case i.too_small:a="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?`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 i.too_big:a="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 i.custom:a="Invalid input";break;case i.invalid_intersection_types:a="Intersection results could not be merged";break;case i.not_multiple_of:a=`Number must be a multiple of ${e.multipleOf}`;break;case i.not_finite:a="Number must be finite";break;default:a=t.defaultError,s.assertNever(e)}return{message:a}};let c=d;function u(e,t){const s=c,a=(e=>{const{data:t,path:s,errorMaps:a,issueData:n}=e,r=[...s,...n.path||[]],i={...n,path:r};if(void 0!==n.message)return{...n,path:r,message:n.message};let o="";const d=a.filter((e=>!!e)).slice().reverse();for(const e of d)o=e(i,{data:t,defaultError:o}).message;return{...n,path:r,message:o}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===d?void 0:d].filter((e=>!!e))});e.common.issues.push(a)}class l{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const a of t){if("aborted"===a.status)return h;"dirty"===a.status&&e.dirty(),s.push(a.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const e of t){const t=await e.key,a=await e.value;s.push({key:t,value:a})}return l.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const a of t){const{key:t,value:n}=a;if("aborted"===t.status)return h;if("aborted"===n.status)return h;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"===t.value||void 0===n.value&&!a.alwaysSet||(s[t.value]=n.value)}return{status:e.value,value:s}}}const h=Object.freeze({status:"aborted"}),p=e=>({status:"dirty",value:e}),m=e=>({status:"valid",value:e}),f=e=>"aborted"===e.status,_=e=>"dirty"===e.status,g=e=>"valid"===e.status,y=e=>"undefined"!=typeof Promise&&e instanceof Promise;var v;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(v||(v={}));class x{constructor(e,t,s,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=a}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 k=(e,t)=>{if(g(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 o(e.common.issues);return this._error=t,this._error}}};function w(e){if(!e)return{};const{errorMap:t,invalid_type_error:s,required_error:a,description:n}=e;if(t&&(s||a))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:n};return{errorMap:(t,n)=>{const{message:r}=e;return"invalid_enum_value"===t.code?{message:r??n.defaultError}:void 0===n.data?{message:r??a??n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:r??s??n.defaultError}},description:n}}class b{get description(){return this._def.description}_getType(e){return r(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new l,ctx:{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(y(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)},a=this._parseSync({data:e,path:s.path,parent:s});return k(s,a)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return g(s)?{value:s.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=>g(e)?{value:e.value}:{issues:t.common.issues}))}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)},a=this._parse({data:e,path:s.path,parent:s}),n=await(y(a)?a:Promise.resolve(a));return k(s,n)}refine(e,t){const s=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,a)=>{const n=e(t),r=()=>a.addIssue({code:i.custom,...s(t)});return"undefined"!=typeof Promise&&n instanceof Promise?n.then((e=>!!e||(r(),!1))):!!n||(r(),!1)}))}refinement(e,t){return this._refinement(((s,a)=>!!e(s)||(a.addIssue("function"==typeof t?t(s,a):t),!1)))}_refinement(e){return new we({schema:this,typeName:Ee.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 be.create(this,this._def)}nullable(){return Te.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ne.create(this)}promise(){return ke.create(this,this._def)}or(e){return oe.create([this,e],this._def)}and(e){return le.create(this,e,this._def)}transform(e){return new we({...w(this._def),schema:this,typeName:Ee.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Oe({...w(this._def),innerType:this,defaultValue:t,typeName:Ee.ZodDefault})}brand(){return new Ae({typeName:Ee.ZodBranded,type:this,...w(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Ce({...w(this._def),innerType:this,catchValue:t,typeName:Ee.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Ze.create(this,e)}readonly(){return Ie.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const T=/^c[^\s-]{8,}$/i,O=/^[0-9a-z]+$/,C=/^[0-9A-HJKMNP-TV-Z]{26}$/i,S=/^[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,A=/^[a-z0-9_-]{21}$/i,Z=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,I=/^[-+]?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)?)??$/,E=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let j;const R=/^(?:(?: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])$/,P=/^(?:(?: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])$/,N=/^(([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]))$/,$=/^(([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])$/,M=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,U=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,z="((\\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])))",L=new RegExp(`^${z}$`);function F(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function D(e){let t=`${z}T${F(e)}`;const s=[];return s.push(e.local?"Z?":"Z"),e.offset&&s.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${s.join("|")})`,new RegExp(`^${t}$`)}function V(e,t){if(!Z.test(e))return!1;try{const[s]=e.split("."),a=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),n=JSON.parse(atob(a));return"object"==typeof n&&null!==n&&((!("typ"in n)||"JWT"===n?.typ)&&(!!n.alg&&(!t||n.alg===t)))}catch{return!1}}function K(e,t){return!("v4"!==t&&t||!P.test(e))||!("v6"!==t&&t||!$.test(e))}class q extends b{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==n.string){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.string,received:t.parsedType}),h}const t=new l;let a;for(const n of this._def.checks)if("min"===n.kind)e.data.length<n.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:i.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&&(a=this._getOrReturnCtx(e,a),u(a,{code:i.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,r=e.data.length<n.value;(s||r)&&(a=this._getOrReturnCtx(e,a),s?u(a,{code:i.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):r&&u(a,{code:i.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if("email"===n.kind)E.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"email",code:i.invalid_string,message:n.message}),t.dirty());else if("emoji"===n.kind)j||(j=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),j.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"emoji",code:i.invalid_string,message:n.message}),t.dirty());else if("uuid"===n.kind)S.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"uuid",code:i.invalid_string,message:n.message}),t.dirty());else if("nanoid"===n.kind)A.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"nanoid",code:i.invalid_string,message:n.message}),t.dirty());else if("cuid"===n.kind)T.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cuid",code:i.invalid_string,message:n.message}),t.dirty());else if("cuid2"===n.kind)O.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cuid2",code:i.invalid_string,message:n.message}),t.dirty());else if("ulid"===n.kind)C.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"ulid",code:i.invalid_string,message:n.message}),t.dirty());else if("url"===n.kind)try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),u(a,{validation:"url",code:i.invalid_string,message:n.message}),t.dirty()}else if("regex"===n.kind){n.regex.lastIndex=0;n.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"regex",code:i.invalid_string,message:n.message}),t.dirty())}else if("trim"===n.kind)e.data=e.data.trim();else if("includes"===n.kind)e.data.includes(n.value,n.position)||(a=this._getOrReturnCtx(e,a),u(a,{code:i.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty());else if("toLowerCase"===n.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===n.kind)e.data=e.data.toUpperCase();else if("startsWith"===n.kind)e.data.startsWith(n.value)||(a=this._getOrReturnCtx(e,a),u(a,{code:i.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty());else if("endsWith"===n.kind)e.data.endsWith(n.value)||(a=this._getOrReturnCtx(e,a),u(a,{code:i.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty());else if("datetime"===n.kind){D(n).test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:i.invalid_string,validation:"datetime",message:n.message}),t.dirty())}else if("date"===n.kind){L.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:i.invalid_string,validation:"date",message:n.message}),t.dirty())}else if("time"===n.kind){new RegExp(`^${F(n)}$`).test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:i.invalid_string,validation:"time",message:n.message}),t.dirty())}else"duration"===n.kind?I.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"duration",code:i.invalid_string,message:n.message}),t.dirty()):"ip"===n.kind?(r=e.data,("v4"!==(o=n.version)&&o||!R.test(r))&&("v6"!==o&&o||!N.test(r))&&(a=this._getOrReturnCtx(e,a),u(a,{validation:"ip",code:i.invalid_string,message:n.message}),t.dirty())):"jwt"===n.kind?V(e.data,n.alg)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"jwt",code:i.invalid_string,message:n.message}),t.dirty()):"cidr"===n.kind?K(e.data,n.version)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cidr",code:i.invalid_string,message:n.message}),t.dirty()):"base64"===n.kind?M.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"base64",code:i.invalid_string,message:n.message}),t.dirty()):"base64url"===n.kind?U.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"base64url",code:i.invalid_string,message:n.message}),t.dirty()):s.assertNever(n);var r,o;return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement((t=>e.test(t)),{validation:t,code:i.invalid_string,...v.errToObj(s)})}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...v.errToObj(e)})}url(e){return this._addCheck({kind:"url",...v.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...v.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...v.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...v.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...v.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...v.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...v.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...v.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...v.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...v.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...v.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...v.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,...v.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,...v.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...v.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...v.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...v.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...v.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...v.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...v.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...v.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...v.errToObj(t)})}nonempty(e){return this.min(1,v.errToObj(e))}trim(){return new q({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new q({...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 W(e,t){const s=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=s>a?s:a;return Number.parseInt(e.toFixed(n).replace(".",""))%Number.parseInt(t.toFixed(n).replace(".",""))/10**n}q.create=e=>new q({checks:[],typeName:Ee.ZodString,coerce:e?.coerce??!1,...w(e)});class H extends b{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==n.number){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.number,received:t.parsedType}),h}let t;const a=new l;for(const n of this._def.checks)if("int"===n.kind)s.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),u(t,{code:i.invalid_type,expected:"integer",received:"float",message:n.message}),a.dirty());else if("min"===n.kind){(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:i.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty())}else if("max"===n.kind){(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:i.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty())}else"multipleOf"===n.kind?0!==W(e.data,n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:i.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),u(t,{code:i.not_finite,message:n.message}),a.dirty()):s.assertNever(n);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,s,a){return new H({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:v.toString(a)}]})}_addCheck(e){return new H({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:v.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:v.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"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&&s.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if("finite"===s.kind||"int"===s.kind||"multipleOf"===s.kind)return!0;"min"===s.kind?(null===t||s.value>t)&&(t=s.value):"max"===s.kind&&(null===e||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}H.create=e=>new H({checks:[],typeName:Ee.ZodNumber,coerce:e?.coerce||!1,...w(e)});class B extends b{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)!==n.bigint)return this._getInvalidInput(e);let t;const a=new l;for(const n of this._def.checks)if("min"===n.kind){(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:i.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty())}else if("max"===n.kind){(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:i.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty())}else"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),u(t,{code:i.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):s.assertNever(n);return{status:a.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.bigint,received:t.parsedType}),h}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,s,a){return new B({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:v.toString(a)}]})}_addCheck(e){return new B({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"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}}B.create=e=>new B({checks:[],typeName:Ee.ZodBigInt,coerce:e?.coerce??!1,...w(e)});class J extends b{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==n.boolean){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.boolean,received:t.parsedType}),h}return m(e.data)}}J.create=e=>new J({typeName:Ee.ZodBoolean,coerce:e?.coerce||!1,...w(e)});class G extends b{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==n.date){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.date,received:t.parsedType}),h}if(Number.isNaN(e.data.getTime())){return u(this._getOrReturnCtx(e),{code:i.invalid_date}),h}const t=new l;let a;for(const n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:i.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):"max"===n.kind?e.data.getTime()>n.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:i.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):s.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:v.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:v.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"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}}G.create=e=>new G({checks:[],coerce:e?.coerce||!1,typeName:Ee.ZodDate,...w(e)});class Y extends b{_parse(e){if(this._getType(e)!==n.symbol){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.symbol,received:t.parsedType}),h}return m(e.data)}}Y.create=e=>new Y({typeName:Ee.ZodSymbol,...w(e)});class X extends b{_parse(e){if(this._getType(e)!==n.undefined){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.undefined,received:t.parsedType}),h}return m(e.data)}}X.create=e=>new X({typeName:Ee.ZodUndefined,...w(e)});class Q extends b{_parse(e){if(this._getType(e)!==n.null){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.null,received:t.parsedType}),h}return m(e.data)}}Q.create=e=>new Q({typeName:Ee.ZodNull,...w(e)});class ee extends b{constructor(){super(...arguments),this._any=!0}_parse(e){return m(e.data)}}ee.create=e=>new ee({typeName:Ee.ZodAny,...w(e)});class te extends b{constructor(){super(...arguments),this._unknown=!0}_parse(e){return m(e.data)}}te.create=e=>new te({typeName:Ee.ZodUnknown,...w(e)});class se extends b{_parse(e){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.never,received:t.parsedType}),h}}se.create=e=>new se({typeName:Ee.ZodNever,...w(e)});class ae extends b{_parse(e){if(this._getType(e)!==n.undefined){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.void,received:t.parsedType}),h}return m(e.data)}}ae.create=e=>new ae({typeName:Ee.ZodVoid,...w(e)});class ne extends b{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),a=this._def;if(t.parsedType!==n.array)return u(t,{code:i.invalid_type,expected:n.array,received:t.parsedType}),h;if(null!==a.exactLength){const e=t.data.length>a.exactLength.value,n=t.data.length<a.exactLength.value;(e||n)&&(u(t,{code:e?i.too_big:i.too_small,minimum:n?a.exactLength.value:void 0,maximum:e?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),s.dirty())}if(null!==a.minLength&&t.data.length<a.minLength.value&&(u(t,{code:i.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),s.dirty()),null!==a.maxLength&&t.data.length>a.maxLength.value&&(u(t,{code:i.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map(((e,s)=>a.type._parseAsync(new x(t,e,t.path,s))))).then((e=>l.mergeArray(s,e)));const r=[...t.data].map(((e,s)=>a.type._parseSync(new x(t,e,t.path,s))));return l.mergeArray(s,r)}get element(){return this._def.type}min(e,t){return new ne({...this._def,minLength:{value:e,message:v.toString(t)}})}max(e,t){return new ne({...this._def,maxLength:{value:e,message:v.toString(t)}})}length(e,t){return new ne({...this._def,exactLength:{value:e,message:v.toString(t)}})}nonempty(e){return this.min(1,e)}}function re(e){if(e instanceof ie){const t={};for(const s in e.shape){const a=e.shape[s];t[s]=be.create(re(a))}return new ie({...e._def,shape:()=>t})}return e instanceof ne?new ne({...e._def,type:re(e.element)}):e instanceof be?be.create(re(e.unwrap())):e instanceof Te?Te.create(re(e.unwrap())):e instanceof he?he.create(e.items.map((e=>re(e)))):e}ne.create=(e,t)=>new ne({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ee.ZodArray,...w(t)});class ie extends b{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=s.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==n.object){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.object,received:t.parsedType}),h}const{status:t,ctx:s}=this._processInputParams(e),{shape:a,keys:r}=this._getCached(),o=[];if(!(this._def.catchall instanceof se&&"strip"===this._def.unknownKeys))for(const e in s.data)r.includes(e)||o.push(e);const d=[];for(const e of r){const t=a[e],n=s.data[e];d.push({key:{status:"valid",value:e},value:t._parse(new x(s,n,s.path,e)),alwaysSet:e in s.data})}if(this._def.catchall instanceof se){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of o)d.push({key:{status:"valid",value:e},value:{status:"valid",value:s.data[e]}});else if("strict"===e)o.length>0&&(u(s,{code:i.unrecognized_keys,keys:o}),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 o){const a=s.data[t];d.push({key:{status:"valid",value:t},value:e._parse(new x(s,a,s.path,t)),alwaysSet:t in s.data})}}return s.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of d){const s=await t.key,a=await t.value;e.push({key:s,value:a,alwaysSet:t.alwaysSet})}return e})).then((e=>l.mergeObjectSync(t,e))):l.mergeObjectSync(t,d)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new ie({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,s)=>{const a=this._def.errorMap?.(t,s).message??s.defaultError;return"unrecognized_keys"===t.code?{message:v.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new ie({...this._def,unknownKeys:"strip"})}passthrough(){return new ie({...this._def,unknownKeys:"passthrough"})}extend(e){return new ie({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ie({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ee.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ie({...this._def,catchall:e})}pick(e){const t={};for(const a of s.objectKeys(e))e[a]&&this.shape[a]&&(t[a]=this.shape[a]);return new ie({...this._def,shape:()=>t})}omit(e){const t={};for(const a of s.objectKeys(this.shape))e[a]||(t[a]=this.shape[a]);return new ie({...this._def,shape:()=>t})}deepPartial(){return re(this)}partial(e){const t={};for(const a of s.objectKeys(this.shape)){const s=this.shape[a];e&&!e[a]?t[a]=s:t[a]=s.optional()}return new ie({...this._def,shape:()=>t})}required(e){const t={};for(const a of s.objectKeys(this.shape))if(e&&!e[a])t[a]=this.shape[a];else{let e=this.shape[a];for(;e instanceof be;)e=e._def.innerType;t[a]=e}return new ie({...this._def,shape:()=>t})}keyof(){return ye(s.objectKeys(this.shape))}}ie.create=(e,t)=>new ie({shape:()=>e,unknownKeys:"strip",catchall:se.create(),typeName:Ee.ZodObject,...w(t)}),ie.strictCreate=(e,t)=>new ie({shape:()=>e,unknownKeys:"strict",catchall:se.create(),typeName:Ee.ZodObject,...w(t)}),ie.lazycreate=(e,t)=>new ie({shape:e,unknownKeys:"strip",catchall:se.create(),typeName:Ee.ZodObject,...w(t)});class oe extends b{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;if(t.common.async)return Promise.all(s.map((async e=>{const s={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const s of e)if("dirty"===s.result.status)return t.common.issues.push(...s.ctx.common.issues),s.result;const s=e.map((e=>new o(e.ctx.common.issues)));return u(t,{code:i.invalid_union,unionErrors:s}),h}));{let e;const a=[];for(const n of s){const s={...t,common:{...t.common,issues:[]},parent:null},r=n._parseSync({data:t.data,path:t.path,parent:s});if("valid"===r.status)return r;"dirty"!==r.status||e||(e={result:r,ctx:s}),s.common.issues.length&&a.push(s.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const n=a.map((e=>new o(e)));return u(t,{code:i.invalid_union,unionErrors:n}),h}}get options(){return this._def.options}}oe.create=(e,t)=>new oe({options:e,typeName:Ee.ZodUnion,...w(t)});const de=e=>e instanceof _e?de(e.schema):e instanceof we?de(e.innerType()):e instanceof ge?[e.value]:e instanceof ve?e.options:e instanceof xe?s.objectValues(e.enum):e instanceof Oe?de(e._def.innerType):e instanceof X?[void 0]:e instanceof Q?[null]:e instanceof be?[void 0,...de(e.unwrap())]:e instanceof Te?[null,...de(e.unwrap())]:e instanceof Ae||e instanceof Ie?de(e.unwrap()):e instanceof Ce?de(e._def.innerType):[];class ce extends b{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==n.object)return u(t,{code:i.invalid_type,expected:n.object,received:t.parsedType}),h;const s=this.discriminator,a=t.data[s],r=this.optionsMap.get(a);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(u(t,{code:i.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),h)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const a=new Map;for(const s of t){const t=de(s.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of t){if(a.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);a.set(n,s)}}return new ce({typeName:Ee.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...w(s)})}}function ue(e,t){const a=r(e),i=r(t);if(e===t)return{valid:!0,data:e};if(a===n.object&&i===n.object){const a=s.objectKeys(t),n=s.objectKeys(e).filter((e=>-1!==a.indexOf(e))),r={...e,...t};for(const s of n){const a=ue(e[s],t[s]);if(!a.valid)return{valid:!1};r[s]=a.data}return{valid:!0,data:r}}if(a===n.array&&i===n.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let a=0;a<e.length;a++){const n=ue(e[a],t[a]);if(!n.valid)return{valid:!1};s.push(n.data)}return{valid:!0,data:s}}return a===n.date&&i===n.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}class le extends b{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=(e,a)=>{if(f(e)||f(a))return h;const n=ue(e.value,a.value);return n.valid?((_(e)||_(a))&&t.dirty(),{status:t.value,value:n.data}):(u(s,{code:i.invalid_intersection_types}),h)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then((([e,t])=>a(e,t))):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}le.create=(e,t,s)=>new le({left:e,right:t,typeName:Ee.ZodIntersection,...w(s)});class he extends b{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==n.array)return u(s,{code:i.invalid_type,expected:n.array,received:s.parsedType}),h;if(s.data.length<this._def.items.length)return u(s,{code:i.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),h;!this._def.rest&&s.data.length>this._def.items.length&&(u(s,{code:i.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map(((e,t)=>{const a=this._def.items[t]||this._def.rest;return a?a._parse(new x(s,e,s.path,t)):null})).filter((e=>!!e));return s.common.async?Promise.all(a).then((e=>l.mergeArray(t,e))):l.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new he({...this._def,rest:e})}}he.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new he({items:e,typeName:Ee.ZodTuple,rest:null,...w(t)})};class pe extends b{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==n.object)return u(s,{code:i.invalid_type,expected:n.object,received:s.parsedType}),h;const a=[],r=this._def.keyType,o=this._def.valueType;for(const e in s.data)a.push({key:r._parse(new x(s,e,s.path,e)),value:o._parse(new x(s,s.data[e],s.path,e)),alwaysSet:e in s.data});return s.common.async?l.mergeObjectAsync(t,a):l.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,s){return new pe(t instanceof b?{keyType:e,valueType:t,typeName:Ee.ZodRecord,...w(s)}:{keyType:q.create(),valueType:e,typeName:Ee.ZodRecord,...w(t)})}}class me extends b{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==n.map)return u(s,{code:i.invalid_type,expected:n.map,received:s.parsedType}),h;const a=this._def.keyType,r=this._def.valueType,o=[...s.data.entries()].map((([e,t],n)=>({key:a._parse(new x(s,e,s.path,[n,"key"])),value:r._parse(new x(s,t,s.path,[n,"value"]))})));if(s.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const s of o){const a=await s.key,n=await s.value;if("aborted"===a.status||"aborted"===n.status)return h;"dirty"!==a.status&&"dirty"!==n.status||t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const s of o){const a=s.key,n=s.value;if("aborted"===a.status||"aborted"===n.status)return h;"dirty"!==a.status&&"dirty"!==n.status||t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}}}me.create=(e,t,s)=>new me({valueType:t,keyType:e,typeName:Ee.ZodMap,...w(s)});class fe extends b{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==n.set)return u(s,{code:i.invalid_type,expected:n.set,received:s.parsedType}),h;const a=this._def;null!==a.minSize&&s.data.size<a.minSize.value&&(u(s,{code:i.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),null!==a.maxSize&&s.data.size>a.maxSize.value&&(u(s,{code:i.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const r=this._def.valueType;function o(e){const s=new Set;for(const a of e){if("aborted"===a.status)return h;"dirty"===a.status&&t.dirty(),s.add(a.value)}return{status:t.value,value:s}}const d=[...s.data.values()].map(((e,t)=>r._parse(new x(s,e,s.path,t))));return s.common.async?Promise.all(d).then((e=>o(e))):o(d)}min(e,t){return new fe({...this._def,minSize:{value:e,message:v.toString(t)}})}max(e,t){return new fe({...this._def,maxSize:{value:e,message:v.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}fe.create=(e,t)=>new fe({valueType:e,minSize:null,maxSize:null,typeName:Ee.ZodSet,...w(t)});class _e extends b{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})}}_e.create=(e,t)=>new _e({getter:e,typeName:Ee.ZodLazy,...w(t)});class ge extends b{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:i.invalid_literal,expected:this._def.value}),h}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ye(e,t){return new ve({values:e,typeName:Ee.ZodEnum,...w(t)})}ge.create=(e,t)=>new ge({value:e,typeName:Ee.ZodLiteral,...w(t)});class ve extends b{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),a=this._def.values;return u(t,{expected:s.joinValues(a),received:t.parsedType,code:i.invalid_type}),h}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return u(t,{received:t.data,code:i.invalid_enum_value,options:s}),h}return m(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ve.create(e,{...this._def,...t})}exclude(e,t=this._def){return ve.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}ve.create=ye;class xe extends b{_parse(e){const t=s.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==n.string&&a.parsedType!==n.number){const e=s.objectValues(t);return u(a,{expected:s.joinValues(e),received:a.parsedType,code:i.invalid_type}),h}if(this._cache||(this._cache=new Set(s.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=s.objectValues(t);return u(a,{received:a.data,code:i.invalid_enum_value,options:e}),h}return m(e.data)}get enum(){return this._def.values}}xe.create=(e,t)=>new xe({values:e,typeName:Ee.ZodNativeEnum,...w(t)});class ke extends b{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==n.promise&&!1===t.common.async)return u(t,{code:i.invalid_type,expected:n.promise,received:t.parsedType}),h;const s=t.parsedType===n.promise?t.data:Promise.resolve(t.data);return m(s.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}ke.create=(e,t)=>new ke({type:e,typeName:Ee.ZodPromise,...w(t)});class we extends b{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ee.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:a}=this._processInputParams(e),n=this._def.effect||null,r={addIssue:e=>{u(a,e),e.fatal?t.abort():t.dirty()},get path(){return a.path}};if(r.addIssue=r.addIssue.bind(r),"preprocess"===n.type){const e=n.transform(a.data,r);if(a.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return h;const s=await this._def.schema._parseAsync({data:e,path:a.path,parent:a});return"aborted"===s.status?h:"dirty"===s.status||"dirty"===t.value?p(s.value):s}));{if("aborted"===t.value)return h;const s=this._def.schema._parseSync({data:e,path:a.path,parent:a});return"aborted"===s.status?h:"dirty"===s.status||"dirty"===t.value?p(s.value):s}}if("refinement"===n.type){const e=e=>{const t=n.refinement(e,r);if(a.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===a.common.async){const s=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===s.status?h:("dirty"===s.status&&t.dirty(),e(s.value),{status:t.value,value:s.value})}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((s=>"aborted"===s.status?h:("dirty"===s.status&&t.dirty(),e(s.value).then((()=>({status:t.value,value:s.value}))))))}if("transform"===n.type){if(!1===a.common.async){const e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!g(e))return h;const s=n.transform(e.value,r);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((e=>g(e)?Promise.resolve(n.transform(e.value,r)).then((e=>({status:t.value,value:e}))):h))}s.assertNever(n)}}we.create=(e,t,s)=>new we({schema:e,typeName:Ee.ZodEffects,effect:t,...w(s)}),we.createWithPreprocess=(e,t,s)=>new we({schema:t,effect:{type:"preprocess",transform:e},typeName:Ee.ZodEffects,...w(s)});class be extends b{_parse(e){return this._getType(e)===n.undefined?m(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}be.create=(e,t)=>new be({innerType:e,typeName:Ee.ZodOptional,...w(t)});class Te extends b{_parse(e){return this._getType(e)===n.null?m(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Te.create=(e,t)=>new Te({innerType:e,typeName:Ee.ZodNullable,...w(t)});class Oe extends b{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===n.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Oe.create=(e,t)=>new Oe({innerType:e,typeName:Ee.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...w(t)});class Ce extends b{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return y(a)?a.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new o(s.common.issues)},input:s.data})}))):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new o(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Ce.create=(e,t)=>new Ce({innerType:e,typeName:Ee.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...w(t)});class Se extends b{_parse(e){if(this._getType(e)!==n.nan){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.nan,received:t.parsedType}),h}return{status:"valid",value:e.data}}}Se.create=e=>new Se({typeName:Ee.ZodNaN,...w(e)});class Ae extends b{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ze extends b{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?h:"dirty"===e.status?(t.dirty(),p(e.value)):this._def.out._parseAsync({data:e.value,path:s.path,parent:s})})()}{const e=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?h:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:s.path,parent:s})}}static create(e,t){return new Ze({in:e,out:t,typeName:Ee.ZodPipeline})}}class Ie extends b{_parse(e){const t=this._def.innerType._parse(e),s=e=>(g(e)&&(e.value=Object.freeze(e.value)),e);return y(t)?t.then((e=>s(e))):s(t)}unwrap(){return this._def.innerType}}var Ee;Ie.create=(e,t)=>new Ie({innerType:e,typeName:Ee.ZodReadonly,...w(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"}(Ee||(Ee={}));const je=q.create,Re=H.create,Pe=J.create,Ne=ee.create,$e=te.create;se.create;const Me=ne.create,Ue=ie.create,ze=oe.create,Le=ce.create;le.create,he.create;const Fe=pe.create,De=ge.create,Ve=ve.create;ke.create;const Ke=be.create;Te.create;const qe="2025-03-26",We="2.0",He=ze([je(),Re().int()]),Be=je(),Je=Ue({progressToken:Ke(He)}).passthrough(),Ge=Ue({_meta:Ke(Je)}).passthrough(),Ye=Ue({method:je(),params:Ke(Ge)}),Xe=Ue({_meta:Ke(Ue({}).passthrough())}).passthrough(),Qe=Ue({method:je(),params:Ke(Xe)}),et=Ue({_meta:Ke(Ue({}).passthrough())}).passthrough(),tt=ze([je(),Re().int()]),st=Ue({jsonrpc:De(We),id:tt}).merge(Ye).strict(),at=Ue({jsonrpc:De(We)}).merge(Qe).strict(),nt=Ue({jsonrpc:De(We),id:tt,result:et}).strict();var rt;!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"}(rt||(rt={}));const it=Ue({jsonrpc:De(We),id:tt,error:Ue({code:Re().int(),message:je(),data:Ke($e())})}).strict(),ot=ze([st,at,nt,it]),dt=et.strict(),ct=Qe.extend({method:De("notifications/cancelled"),params:Xe.extend({requestId:tt,reason:je().optional()})}),ut=Ue({name:je(),version:je()}).passthrough(),lt=Ue({experimental:Ke(Ue({}).passthrough()),sampling:Ke(Ue({}).passthrough()),roots:Ke(Ue({listChanged:Ke(Pe())}).passthrough())}).passthrough(),ht=Ye.extend({method:De("initialize"),params:Ge.extend({protocolVersion:je(),capabilities:lt,clientInfo:ut})}),pt=Ue({experimental:Ke(Ue({}).passthrough()),logging:Ke(Ue({}).passthrough()),completions:Ke(Ue({}).passthrough()),prompts:Ke(Ue({listChanged:Ke(Pe())}).passthrough()),resources:Ke(Ue({subscribe:Ke(Pe()),listChanged:Ke(Pe())}).passthrough()),tools:Ke(Ue({listChanged:Ke(Pe())}).passthrough())}).passthrough(),mt=et.extend({protocolVersion:je(),capabilities:pt,serverInfo:ut,instructions:Ke(je())}),ft=Qe.extend({method:De("notifications/initialized")}),_t=Ye.extend({method:De("ping")}),gt=Ue({progress:Re(),total:Ke(Re()),message:Ke(je())}).passthrough(),yt=Qe.extend({method:De("notifications/progress"),params:Xe.merge(gt).extend({progressToken:He})}),vt=Ye.extend({params:Ge.extend({cursor:Ke(Be)}).optional()}),xt=et.extend({nextCursor:Ke(Be)}),kt=Ue({uri:je(),mimeType:Ke(je())}).passthrough(),wt=kt.extend({text:je()}),bt=kt.extend({blob:je().base64()}),Tt=Ue({uri:je(),name:je(),description:Ke(je()),mimeType:Ke(je())}).passthrough(),Ot=Ue({uriTemplate:je(),name:je(),description:Ke(je()),mimeType:Ke(je())}).passthrough(),Ct=vt.extend({method:De("resources/list")}),St=xt.extend({resources:Me(Tt)}),At=vt.extend({method:De("resources/templates/list")}),Zt=xt.extend({resourceTemplates:Me(Ot)}),It=Ye.extend({method:De("resources/read"),params:Ge.extend({uri:je()})}),Et=et.extend({contents:Me(ze([wt,bt]))}),jt=Qe.extend({method:De("notifications/resources/list_changed")}),Rt=Ye.extend({method:De("resources/subscribe"),params:Ge.extend({uri:je()})}),Pt=Ye.extend({method:De("resources/unsubscribe"),params:Ge.extend({uri:je()})}),Nt=Qe.extend({method:De("notifications/resources/updated"),params:Xe.extend({uri:je()})}),$t=Ue({name:je(),description:Ke(je()),required:Ke(Pe())}).passthrough(),Mt=Ue({name:je(),description:Ke(je()),arguments:Ke(Me($t))}).passthrough(),Ut=vt.extend({method:De("prompts/list")}),zt=xt.extend({prompts:Me(Mt)}),Lt=Ye.extend({method:De("prompts/get"),params:Ge.extend({name:je(),arguments:Ke(Fe(je()))})}),Ft=Ue({type:De("text"),text:je()}).passthrough(),Dt=Ue({type:De("image"),data:je().base64(),mimeType:je()}).passthrough(),Vt=Ue({type:De("audio"),data:je().base64(),mimeType:je()}).passthrough(),Kt=Ue({type:De("resource"),resource:ze([wt,bt])}).passthrough(),qt=Ue({role:Ve(["user","assistant"]),content:ze([Ft,Dt,Vt,Kt])}).passthrough(),Wt=et.extend({description:Ke(je()),messages:Me(qt)}),Ht=Qe.extend({method:De("notifications/prompts/list_changed")}),Bt=Ue({title:Ke(je()),readOnlyHint:Ke(Pe()),destructiveHint:Ke(Pe()),idempotentHint:Ke(Pe()),openWorldHint:Ke(Pe())}).passthrough(),Jt=Ue({name:je(),description:Ke(je()),inputSchema:Ue({type:De("object"),properties:Ke(Ue({}).passthrough()),required:Ke(Me(je()))}).passthrough(),outputSchema:Ke(Ue({type:De("object"),properties:Ke(Ue({}).passthrough()),required:Ke(Me(je()))}).passthrough()),annotations:Ke(Bt)}).passthrough(),Gt=vt.extend({method:De("tools/list")}),Yt=xt.extend({tools:Me(Jt)}),Xt=et.extend({content:Me(ze([Ft,Dt,Vt,Kt])).default([]),structuredContent:Ue({}).passthrough().optional(),isError:Ke(Pe())});Xt.or(et.extend({toolResult:$e()}));const Qt=Ye.extend({method:De("tools/call"),params:Ge.extend({name:je(),arguments:Ke(Fe($e()))})}),es=Qe.extend({method:De("notifications/tools/list_changed")}),ts=Ve(["debug","info","notice","warning","error","critical","alert","emergency"]),ss=Ye.extend({method:De("logging/setLevel"),params:Ge.extend({level:ts})}),as=Qe.extend({method:De("notifications/message"),params:Xe.extend({level:ts,logger:Ke(je()),data:$e()})}),ns=Ue({name:je().optional()}).passthrough(),rs=Ue({hints:Ke(Me(ns)),costPriority:Ke(Re().min(0).max(1)),speedPriority:Ke(Re().min(0).max(1)),intelligencePriority:Ke(Re().min(0).max(1))}).passthrough(),is=Ue({role:Ve(["user","assistant"]),content:ze([Ft,Dt,Vt])}).passthrough(),os=Ye.extend({method:De("sampling/createMessage"),params:Ge.extend({messages:Me(is),systemPrompt:Ke(je()),includeContext:Ke(Ve(["none","thisServer","allServers"])),temperature:Ke(Re()),maxTokens:Re().int(),stopSequences:Ke(Me(je())),metadata:Ke(Ue({}).passthrough()),modelPreferences:Ke(rs)})}),ds=et.extend({model:je(),stopReason:Ke(Ve(["endTurn","stopSequence","maxTokens"]).or(je())),role:Ve(["user","assistant"]),content:Le("type",[Ft,Dt,Vt])}),cs=Ue({type:De("ref/resource"),uri:je()}).passthrough(),us=Ue({type:De("ref/prompt"),name:je()}).passthrough(),ls=Ye.extend({method:De("completion/complete"),params:Ge.extend({ref:ze([us,cs]),argument:Ue({name:je(),value:je()}).passthrough()})}),hs=et.extend({completion:Ue({values:Me(je()).max(100),total:Ke(Re().int()),hasMore:Ke(Pe())}).passthrough()}),ps=Ue({uri:je().startsWith("file://"),name:Ke(je())}).passthrough(),ms=Ye.extend({method:De("roots/list")}),fs=et.extend({roots:Me(ps)}),_s=Qe.extend({method:De("notifications/roots/list_changed")});ze([_t,ht,ls,ss,Lt,Ut,Ct,At,It,Rt,Pt,Qt,Gt]),ze([ct,yt,ft,_s]),ze([dt,ds,fs]),ze([_t,os,ms]),ze([ct,yt,as,Nt,jt,es,Ht]),ze([dt,mt,hs,Wt,zt,St,Zt,Et,Xt,Yt]);const gs=Ue({resource:je().url(),authorization_servers:Me(je().url()).optional(),jwks_uri:je().url().optional(),scopes_supported:Me(je()).optional(),bearer_methods_supported:Me(je()).optional(),resource_signing_alg_values_supported:Me(je()).optional(),resource_name:je().optional(),resource_documentation:je().optional(),resource_policy_uri:je().url().optional(),resource_tos_uri:je().url().optional(),tls_client_certificate_bound_access_tokens:Pe().optional(),authorization_details_types_supported:Me(je()).optional(),dpop_signing_alg_values_supported:Me(je()).optional(),dpop_bound_access_tokens_required:Pe().optional()}).passthrough(),ys=Ue({issuer:je(),authorization_endpoint:je(),token_endpoint:je(),registration_endpoint:je().optional(),scopes_supported:Me(je()).optional(),response_types_supported:Me(je()),response_modes_supported:Me(je()).optional(),grant_types_supported:Me(je()).optional(),token_endpoint_auth_methods_supported:Me(je()).optional(),token_endpoint_auth_signing_alg_values_supported:Me(je()).optional(),service_documentation:je().optional(),revocation_endpoint:je().optional(),revocation_endpoint_auth_methods_supported:Me(je()).optional(),revocation_endpoint_auth_signing_alg_values_supported:Me(je()).optional(),introspection_endpoint:je().optional(),introspection_endpoint_auth_methods_supported:Me(je()).optional(),introspection_endpoint_auth_signing_alg_values_supported:Me(je()).optional(),code_challenge_methods_supported:Me(je()).optional()}).passthrough(),vs=Ue({access_token:je(),token_type:je(),expires_in:Re().optional(),scope:je().optional(),refresh_token:je().optional()}).strip();Ue({error:je(),error_description:je().optional(),error_uri:je().optional()});const xs=Ue({redirect_uris:Me(je()).refine((e=>e.every((e=>URL.canParse(e)))),{message:"redirect_uris must contain valid URLs"}),token_endpoint_auth_method:je().optional(),grant_types:Me(je()).optional(),response_types:Me(je()).optional(),client_name:je().optional(),client_uri:je().optional(),logo_uri:je().optional(),scope:je().optional(),contacts:Me(je()).optional(),tos_uri:je().optional(),policy_uri:je().optional(),jwks_uri:je().optional(),jwks:Ne().optional(),software_id:je().optional(),software_version:je().optional()}).strip(),ks=Ue({client_id:je(),client_secret:je().optional(),client_id_issued_at:Re().optional(),client_secret_expires_at:Re().optional()}).strip(),ws=xs.merge(ks);Ue({error:je(),error_description:je().optional()}).strip(),Ue({token:je(),token_type_hint:je().optional()}).strip();class bs extends Error{constructor(e){super(null!=e?e:"Unauthorized")}}async function Ts(e,{serverUrl:s,authorizationCode:a,scope:n,resourceMetadataUrl:r}){let i=s;try{const e=await async function(e,t){var s;let a,n;a=new URL("/.well-known/oauth-protected-resource",e);try{n=await fetch(a,{headers:{"MCP-Protocol-Version":null!==(s=null==t?void 0:t.protocolVersion)&&void 0!==s?s:qe}})}catch(e){if(!(e instanceof TypeError))throw e;n=await fetch(a)}if(404===n.status)throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!n.ok)throw new Error(`HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`);return gs.parse(await n.json())}(r||s);e.authorization_servers&&e.authorization_servers.length>0&&(i=e.authorization_servers[0])}catch(e){console.warn("Could not load OAuth Protected Resource metadata, falling back to /.well-known/oauth-authorization-server",e)}const o=await async function(e,t){var s;const a=new URL("/.well-known/oauth-authorization-server",e);let n;try{n=await fetch(a,{headers:{"MCP-Protocol-Version":null!==(s=null==t?void 0:t.protocolVersion)&&void 0!==s?s:qe}})}catch(e){if(!(e instanceof TypeError))throw e;n=await fetch(a)}if(404===n.status)return;if(!n.ok)throw new Error(`HTTP ${n.status} trying to load well-known OAuth metadata`);return ys.parse(await n.json())}(i);let d=await Promise.resolve(e.clientInformation());if(!d){if(void 0!==a)throw new Error("Existing OAuth client information is required when exchanging an authorization code");if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const t=await async function(e,{metadata:t,clientMetadata:s}){let a;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");a=new URL(t.registration_endpoint)}else a=new URL("/register",e);const n=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!n.ok)throw new Error(`Dynamic client registration failed: HTTP ${n.status}`);return ws.parse(await n.json())}(i,{metadata:o,clientMetadata:e.clientMetadata});await e.saveClientInformation(t),d=t}if(void 0!==a){const t=await e.codeVerifier(),s=await async function(e,{metadata:t,clientInformation:s,authorizationCode:a,codeVerifier:n,redirectUri:r}){const i="authorization_code";let o;if(t){if(o=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(i))throw new Error(`Incompatible auth server: does not support grant type ${i}`)}else o=new URL("/token",e);const d=new URLSearchParams({grant_type:i,client_id:s.client_id,code:a,code_verifier:n,redirect_uri:String(r)});s.client_secret&&d.set("client_secret",s.client_secret);const c=await fetch(o,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:d});if(!c.ok)throw new Error(`Token exchange failed: HTTP ${c.status}`);return vs.parse(await c.json())}(i,{metadata:o,clientInformation:d,authorizationCode:a,codeVerifier:t,redirectUri:e.redirectUrl});return await e.saveTokens(s),"AUTHORIZED"}const c=await e.tokens();if(null==c?void 0:c.refresh_token)try{const t=await async function(e,{metadata:t,clientInformation:s,refreshToken:a}){const n="refresh_token";let r;if(t){if(r=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(n))throw new Error(`Incompatible auth server: does not support grant type ${n}`)}else r=new URL("/token",e);const i=new URLSearchParams({grant_type:n,client_id:s.client_id,refresh_token:a});s.client_secret&&i.set("client_secret",s.client_secret);const o=await fetch(r,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i});if(!o.ok)throw new Error(`Token refresh failed: HTTP ${o.status}`);return vs.parse({refresh_token:a,...await o.json()})}(i,{metadata:o,clientInformation:d,refreshToken:c.refresh_token});return await e.saveTokens(t),"AUTHORIZED"}catch(e){console.error("Could not refresh OAuth tokens:",e)}const u=e.state?await e.state():void 0,{authorizationUrl:l,codeVerifier:h}=await async function(e,{metadata:s,clientInformation:a,redirectUrl:n,scope:r,state:i}){const o="code",d="S256";let c;if(s){if(c=new URL(s.authorization_endpoint),!s.response_types_supported.includes(o))throw new Error(`Incompatible auth server: does not support response type ${o}`);if(!s.code_challenge_methods_supported||!s.code_challenge_methods_supported.includes(d))throw new Error(`Incompatible auth server: does not support code challenge method ${d}`)}else c=new URL("/authorize",e);const u=await t(),l=u.code_verifier,h=u.code_challenge;c.searchParams.set("response_type",o),c.searchParams.set("client_id",a.client_id),c.searchParams.set("code_challenge",h),c.searchParams.set("code_challenge_method",d),c.searchParams.set("redirect_uri",String(n)),i&&c.searchParams.set("state",i);r&&c.searchParams.set("scope",r);return{authorizationUrl:c,codeVerifier:l}}(i,{metadata:o,clientInformation:d,state:u,redirectUrl:e.redirectUrl,scope:n||e.clientMetadata.scope});return await e.saveCodeVerifier(h),await e.redirectToAuthorization(l),"REDIRECT"}class Os extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function Cs(e){}function Ss(e){if("function"==typeof e)throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=Cs,onError:s=Cs,onRetry:a=Cs,onComment:n}=e;let r,i="",o=!0,d="",c="";function u(e){if(""===e)return d.length>0&&t({id:r,event:c||void 0,data:d.endsWith("\n")?d.slice(0,-1):d}),r=void 0,d="",void(c="");if(e.startsWith(":"))return void(n&&n(e.slice(e.startsWith(": ")?2:1)));const s=e.indexOf(":");if(-1===s)l(e,"",e);else{const t=e.slice(0,s),a=" "===e[s+1]?2:1;l(t,e.slice(s+a),e)}}function l(e,t,n){switch(e){case"event":c=t;break;case"data":d=`${d}${t}\n`;break;case"id":r=t.includes("\0")?void 0:t;break;case"retry":/^\d+$/.test(t)?a(parseInt(t,10)):s(new Os(`Invalid \`retry\` value: "${t}"`,{type:"invalid-retry",value:t,line:n}));break;default:s(new Os(`Unknown field "${e.length>20?`${e.slice(0,20)}…`:e}"`,{type:"unknown-field",field:e,value:t,line:n}))}}return{feed:function(e){const t=o?e.replace(/^\xEF\xBB\xBF/,""):e,[s,a]=function(e){const t=[];let s="",a=0;for(;a<e.length;){const n=e.indexOf("\r",a),r=e.indexOf("\n",a);let i=-1;if(-1!==n&&-1!==r?i=Math.min(n,r):-1!==n?i=n:-1!==r&&(i=r),-1===i){s=e.slice(a);break}{const s=e.slice(a,i);t.push(s),a=i+1,"\r"===e[a-1]&&"\n"===e[a]&&a++}}return[t,s]}(`${i}${t}`);for(const e of s)u(e);i=a,o=!1},reset:function(e={}){i&&e.consume&&u(i),o=!0,r=void 0,d="",c="",i=""}}}class As extends TransformStream{constructor({onError:e,onRetry:t,onComment:s}={}){let a;super({start(n){a=Ss({onEvent:e=>{n.enqueue(e)},onError(t){"terminate"===e?n.error(t):"function"==typeof e&&e(t)},onRetry:t,onComment:s})},transform(e){a.feed(e)}})}}const Zs={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Is extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}}class Es{constructor(e,t){var s;this._url=e,this._resourceMetadataUrl=void 0,this._requestInit=null==t?void 0:t.requestInit,this._authProvider=null==t?void 0:t.authProvider,this._sessionId=null==t?void 0:t.sessionId,this._reconnectionOptions=null!==(s=null==t?void 0:t.reconnectionOptions)&&void 0!==s?s:Zs}async _authThenStart(){var e;if(!this._authProvider)throw new bs("No auth provider");let t;try{t=await Ts(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl})}catch(t){throw null===(e=this.onerror)||void 0===e||e.call(this,t),t}if("AUTHORIZED"!==t)throw new bs;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var e;const t={};if(this._authProvider){const e=await this._authProvider.tokens();e&&(t.Authorization=`Bearer ${e.access_token}`)}return this._sessionId&&(t["mcp-session-id"]=this._sessionId),new Headers({...t,...null===(e=this._requestInit)||void 0===e?void 0:e.headers})}async _startOrAuthSse(e){var t,s;const{resumptionToken:a}=e;try{const s=await this._commonHeaders();s.set("Accept","text/event-stream"),a&&s.set("last-event-id",a);const n=await fetch(this._url,{method:"GET",headers:s,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal});if(!n.ok){if(401===n.status&&this._authProvider)return await this._authThenStart();if(405===n.status)return;throw new Is(n.status,`Failed to open SSE stream: ${n.statusText}`)}this._handleSseStream(n.body,e)}catch(e){throw null===(s=this.onerror)||void 0===s||s.call(this,e),e}}_getNextReconnectionDelay(e){const t=this._reconnectionOptions.initialReconnectionDelay,s=this._reconnectionOptions.reconnectionDelayGrowFactor,a=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(s,e),a)}_scheduleReconnection(e,t=0){var s;const a=this._reconnectionOptions.maxRetries;if(a>0&&t>=a)return void(null===(s=this.onerror)||void 0===s||s.call(this,new Error(`Maximum reconnection attempts (${a}) exceeded.`)));const n=this._getNextReconnectionDelay(t);setTimeout((()=>{this._startOrAuthSse(e).catch((s=>{var a;null===(a=this.onerror)||void 0===a||a.call(this,new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(e,t+1)}))}),n)}_handleSseStream(e,t){if(!e)return;const{onresumptiontoken:s,replayMessageId:a}=t;let n;(async()=>{var t,r,i,o,d;try{const i=e.pipeThrough(new TextDecoderStream).pipeThrough(new As).getReader();for(;;){const{value:e,done:o}=await i.read();if(o)break;if(e.id&&(n=e.id,null==s||s(e.id)),!e.event||"message"===e.event)try{const s=ot.parse(JSON.parse(e.data));void 0!==a&&(d=s,nt.safeParse(d).success)&&(s.id=a),null===(t=this.onmessage)||void 0===t||t.call(this,s)}catch(e){null===(r=this.onerror)||void 0===r||r.call(this,e)}}}catch(e){if(null===(i=this.onerror)||void 0===i||i.call(this,new Error(`SSE stream disconnected: ${e}`)),this._abortController&&!this._abortController.signal.aborted&&void 0!==n)try{this._scheduleReconnection({resumptionToken:n,onresumptiontoken:s,replayMessageId:a},0)}catch(e){null===(o=this.onerror)||void 0===o||o.call(this,new Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new bs("No auth provider");if("AUTHORIZED"!==await Ts(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl}))throw new bs("Failed to authorize")}async close(){var e,t;null===(e=this._abortController)||void 0===e||e.abort(),null===(t=this.onclose)||void 0===t||t.call(this)}async send(e,t){var s,a,n,r;try{const{resumptionToken:n,onresumptiontoken:i}=t||{};if(n)return void this._startOrAuthSse({resumptionToken:n,replayMessageId:(r=e,st.safeParse(r).success?e.id:void 0)}).catch((e=>{var t;return null===(t=this.onerror)||void 0===t?void 0:t.call(this,e)}));const o=await this._commonHeaders();o.set("content-type","application/json"),o.set("accept","application/json, text/event-stream");const d={...this._requestInit,method:"POST",headers:o,body:JSON.stringify(e),signal:null===(s=this._abortController)||void 0===s?void 0:s.signal},c=await fetch(this._url,d),u=c.headers.get("mcp-session-id");if(u&&(this._sessionId=u),!c.ok){if(401===c.status&&this._authProvider){this._resourceMetadataUrl=function(e){const t=e.headers.get("WWW-Authenticate");if(!t)return;const[s,a]=t.split(" ");if("bearer"!==s.toLowerCase()||!a)return void console.log("Invalid WWW-Authenticate header format, expected 'Bearer'");const n=/resource_metadata="([^"]*)"/.exec(t);if(n)try{return new URL(n[1])}catch(e){return void console.log("Invalid resource metadata url: ",n[1])}}(c);if("AUTHORIZED"!==await Ts(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl}))throw new bs;return this.send(e)}const t=await c.text().catch((()=>null));throw new Error(`Error POSTing to endpoint (HTTP ${c.status}): ${t}`)}if(202===c.status)return void((e=>ft.safeParse(e).success)(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch((e=>{var t;return null===(t=this.onerror)||void 0===t?void 0:t.call(this,e)})));const l=(Array.isArray(e)?e:[e]).filter((e=>"method"in e&&"id"in e&&void 0!==e.id)).length>0,h=c.headers.get("content-type");if(l)if(null==h?void 0:h.includes("text/event-stream"))this._handleSseStream(c.body,{onresumptiontoken:i});else{if(!(null==h?void 0:h.includes("application/json")))throw new Is(-1,`Unexpected content type: ${h}`);{const e=await c.json(),t=Array.isArray(e)?e.map((e=>ot.parse(e))):[ot.parse(e)];for(const e of t)null===(a=this.onmessage)||void 0===a||a.call(this,e)}}}catch(e){throw null===(n=this.onerror)||void 0===n||n.call(this,e),e}}get sessionId(){return this._sessionId}async terminateSession(){var e,t;if(this._sessionId)try{const t=await this._commonHeaders(),s={...this._requestInit,method:"DELETE",headers:t,signal:null===(e=this._abortController)||void 0===e?void 0:e.signal},a=await fetch(this._url,s);if(!a.ok&&405!==a.status)throw new Is(a.status,`Failed to terminate session: ${a.statusText}`);this._sessionId=void 0}catch(e){throw null===(t=this.onerror)||void 0===t||t.call(this,e),e}}}class js{static async init(t){if(!(null==t?void 0:t.apiKey))throw new Error("MboaAI-SDK: apiKey is required");if(js.ready)return;const{apiKey:s,mcpUrl:a="https://api.filparty.com:8001/mcp",name:n="MboaAI-SDK",version:r="1.0.0",defaultType:i="standard"}=t;js.client=new e({name:n,version:r}),await js.client.connect(new Es(new URL(a),{requestInit:{headers:{"x-api-key":s}}})),js.apiKey=s,js.defaultType=i,js.ready=!0}static async translate(e,t,s){var a,n,r;if(!js.ready)throw new Error("MboaAI-SDK: call init() first");const i=`Translate "${e}" into ${t} for ${null!=s?s:js.defaultType}`;try{const t=await js.client.callTool({name:"run_translate",arguments:{message:i,api_key:js.apiKey}}),s=String(null!==(r=null===(n=null===(a=null==t?void 0:t.content)||void 0===a?void 0:a[0])||void 0===n?void 0:n.text)&&void 0!==r?r:"");if((e=>{const t=e.trim().charAt(0);return"{"===t||"["===t})(s))try{const t=JSON.parse(s);return t.reply||t.text||e}catch(e){}return s||e}catch(t){return console.error("[MboaAI-SDK] translate error → returning source",t),e}}}js.ready=!1,js.defaultType="standard",js.apiKey="","undefined"!=typeof window&&(window.MboaAI=window.MboaAI||{},window.MboaAI.T=js);export{js as T,js as default};
|
1
|
+
import e from"pkce-challenge";var t,r;!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]])),a={};for(const e of r)a[e]=t[e];return e.objectValues(a)},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}(t||(t={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(r||(r={}));const a=t.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),s=e=>{switch(typeof e){case"undefined":return a.undefined;case"string":return a.string;case"number":return Number.isNaN(e)?a.nan:a.number;case"boolean":return a.boolean;case"function":return a.function;case"bigint":return a.bigint;case"symbol":return a.symbol;case"object":return Array.isArray(e)?a.array:null===e?a.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?a.promise:"undefined"!=typeof Map&&e instanceof Map?a.map:"undefined"!=typeof Set&&e instanceof Set?a.set:"undefined"!=typeof Date&&e instanceof Date?a.date:a.object;default:return a.unknown}},i=t.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 o 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:[]},a=e=>{for(const s of e.issues)if("invalid_union"===s.code)s.unionErrors.map(a);else if("invalid_return_type"===s.code)a(s.returnTypeError);else if("invalid_arguments"===s.code)a(s.argumentsError);else if(0===s.path.length)r._errors.push(t(s));else{let e=r,a=0;for(;a<s.path.length;){const r=s.path[a];a===s.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(s))):e[r]=e[r]||{_errors:[]},e=e[r],a++}}};return a(this),r}static assert(e){if(!(e instanceof o))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,t.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},r=[];for(const a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):r.push(e(a));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}o.create=e=>new o(e);const n=(e,r)=>{let s;switch(e.code){case i.invalid_type:s=e.received===a.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case i.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(e.expected,t.jsonStringifyReplacer)}`;break;case i.unrecognized_keys:s=`Unrecognized key(s) in object: ${t.joinValues(e.keys,", ")}`;break;case i.invalid_union:s="Invalid input";break;case i.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${t.joinValues(e.options)}`;break;case i.invalid_enum_value:s=`Invalid enum value. Expected ${t.joinValues(e.options)}, received '${e.received}'`;break;case i.invalid_arguments:s="Invalid function arguments";break;case i.invalid_return_type:s="Invalid function return type";break;case i.invalid_date:s="Invalid date";break;case i.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(s=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(s=`${s} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?s=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?s=`Invalid input: must end with "${e.validation.endsWith}"`:t.assertNever(e.validation):s="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case i.too_small:s="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?`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 i.too_big:s="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 i.custom:s="Invalid input";break;case i.invalid_intersection_types:s="Intersection results could not be merged";break;case i.not_multiple_of:s=`Number must be a multiple of ${e.multipleOf}`;break;case i.not_finite:s="Number must be finite";break;default:s=r.defaultError,t.assertNever(e)}return{message:s}};let l=n;function c(e,t){const r=l,a=(e=>{const{data:t,path:r,errorMaps:a,issueData:s}=e,i=[...r,...s.path||[]],o={...s,path:i};if(void 0!==s.message)return{...s,path:i,message:s.message};let n="";const l=a.filter((e=>!!e)).slice().reverse();for(const e of l)n=e(o,{data:t,defaultError:n}).message;return{...s,path:i,message:n}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===n?void 0:n].filter((e=>!!e))});e.common.issues.push(a)}class d{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 a of t){if("aborted"===a.status)return u;"dirty"===a.status&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const e of t){const t=await e.key,a=await e.value;r.push({key:t,value:a})}return d.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const a of t){const{key:t,value:s}=a;if("aborted"===t.status)return u;if("aborted"===s.status)return u;"dirty"===t.status&&e.dirty(),"dirty"===s.status&&e.dirty(),"__proto__"===t.value||void 0===s.value&&!a.alwaysSet||(r[t.value]=s.value)}return{status:e.value,value:r}}}const u=Object.freeze({status:"aborted"}),h=e=>({status:"dirty",value:e}),p=e=>({status:"valid",value:e}),m=e=>"aborted"===e.status,f=e=>"dirty"===e.status,v=e=>"valid"===e.status,y=e=>"undefined"!=typeof Promise&&e instanceof Promise;var g;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(g||(g={}));class _{constructor(e,t,r,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=a}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 w=(e,t)=>{if(v(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 o(e.common.issues);return this._error=t,this._error}}};function b(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:a,description:s}=e;if(t&&(r||a))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:s};return{errorMap:(t,s)=>{const{message:i}=e;return"invalid_enum_value"===t.code?{message:i??s.defaultError}:void 0===s.data?{message:i??a??s.defaultError}:"invalid_type"!==t.code?{message:s.defaultError}:{message:i??r??s.defaultError}},description:s}}class P{get description(){return this._def.description}_getType(e){return s(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:s(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new d,ctx:{common:e.parent.common,data:e.data,parsedType:s(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(y(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:s(e)},a=this._parseSync({data:e,path:r.path,parent:r});return w(r,a)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:s(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:t});return v(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=>v(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:s(e)},a=this._parse({data:e,path:r.path,parent:r}),i=await(y(a)?a:Promise.resolve(a));return w(r,i)}refine(e,t){const r=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,a)=>{const s=e(t),o=()=>a.addIssue({code:i.custom,...r(t)});return"undefined"!=typeof Promise&&s instanceof Promise?s.then((e=>!!e||(o(),!1))):!!s||(o(),!1)}))}refinement(e,t){return this._refinement(((r,a)=>!!e(r)||(a.addIssue("function"==typeof t?t(r,a):t),!1)))}_refinement(e){return new be({schema:this,typeName:$e.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 Pe.create(this,this._def)}nullable(){return Ee.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ae.create(this)}promise(){return we.create(this,this._def)}or(e){return oe.create([this,e],this._def)}and(e){return de.create(this,e,this._def)}transform(e){return new be({...b(this._def),schema:this,typeName:$e.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new xe({...b(this._def),innerType:this,defaultValue:t,typeName:$e.ZodDefault})}brand(){return new Re({typeName:$e.ZodBranded,type:this,...b(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new ke({...b(this._def),innerType:this,catchValue:t,typeName:$e.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Oe.create(this,e)}readonly(){return Te.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const E=/^c[^\s-]{8,}$/i,x=/^[0-9a-z]+$/,k=/^[0-9A-HJKMNP-TV-Z]{26}$/i,S=/^[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,R=/^[a-z0-9_-]{21}$/i,O=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,T=/^[-+]?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)?)??$/,$=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let I;const C=/^(?:(?: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])$/,F=/^(([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]))$/,A=/^(([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])$/,D=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,N=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,q="((\\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])))",L=new RegExp(`^${q}$`);function z(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function Z(e){let t=`${q}T${z(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 M(e,t){if(!O.test(e))return!1;try{const[r]=e.split("."),a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(a));return"object"==typeof s&&null!==s&&((!("typ"in s)||"JWT"===s?.typ)&&(!!s.alg&&(!t||s.alg===t)))}catch{return!1}}function U(e,t){return!("v4"!==t&&t||!j.test(e))||!("v6"!==t&&t||!A.test(e))}class V extends P{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==a.string){const t=this._getOrReturnCtx(e);return c(t,{code:i.invalid_type,expected:a.string,received:t.parsedType}),u}const r=new d;let s;for(const a of this._def.checks)if("min"===a.kind)e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),c(s,{code:i.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if("max"===a.kind)e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),c(s,{code:i.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if("length"===a.kind){const t=e.data.length>a.value,o=e.data.length<a.value;(t||o)&&(s=this._getOrReturnCtx(e,s),t?c(s,{code:i.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&c(s,{code:i.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if("email"===a.kind)$.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"email",code:i.invalid_string,message:a.message}),r.dirty());else if("emoji"===a.kind)I||(I=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),I.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"emoji",code:i.invalid_string,message:a.message}),r.dirty());else if("uuid"===a.kind)S.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"uuid",code:i.invalid_string,message:a.message}),r.dirty());else if("nanoid"===a.kind)R.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"nanoid",code:i.invalid_string,message:a.message}),r.dirty());else if("cuid"===a.kind)E.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"cuid",code:i.invalid_string,message:a.message}),r.dirty());else if("cuid2"===a.kind)x.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"cuid2",code:i.invalid_string,message:a.message}),r.dirty());else if("ulid"===a.kind)k.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"ulid",code:i.invalid_string,message:a.message}),r.dirty());else if("url"===a.kind)try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),c(s,{validation:"url",code:i.invalid_string,message:a.message}),r.dirty()}else if("regex"===a.kind){a.regex.lastIndex=0;a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"regex",code:i.invalid_string,message:a.message}),r.dirty())}else if("trim"===a.kind)e.data=e.data.trim();else if("includes"===a.kind)e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),c(s,{code:i.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty());else if("toLowerCase"===a.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===a.kind)e.data=e.data.toUpperCase();else if("startsWith"===a.kind)e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),c(s,{code:i.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty());else if("endsWith"===a.kind)e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),c(s,{code:i.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty());else if("datetime"===a.kind){Z(a).test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{code:i.invalid_string,validation:"datetime",message:a.message}),r.dirty())}else if("date"===a.kind){L.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{code:i.invalid_string,validation:"date",message:a.message}),r.dirty())}else if("time"===a.kind){new RegExp(`^${z(a)}$`).test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{code:i.invalid_string,validation:"time",message:a.message}),r.dirty())}else"duration"===a.kind?T.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"duration",code:i.invalid_string,message:a.message}),r.dirty()):"ip"===a.kind?(o=e.data,("v4"!==(n=a.version)&&n||!C.test(o))&&("v6"!==n&&n||!F.test(o))&&(s=this._getOrReturnCtx(e,s),c(s,{validation:"ip",code:i.invalid_string,message:a.message}),r.dirty())):"jwt"===a.kind?M(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"jwt",code:i.invalid_string,message:a.message}),r.dirty()):"cidr"===a.kind?U(e.data,a.version)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"cidr",code:i.invalid_string,message:a.message}),r.dirty()):"base64"===a.kind?D.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"base64",code:i.invalid_string,message:a.message}),r.dirty()):"base64url"===a.kind?N.test(e.data)||(s=this._getOrReturnCtx(e,s),c(s,{validation:"base64url",code:i.invalid_string,message:a.message}),r.dirty()):t.assertNever(a);var o,n;return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement((t=>e.test(t)),{validation:t,code:i.invalid_string,...g.errToObj(r)})}_addCheck(e){return new V({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...g.errToObj(e)})}url(e){return this._addCheck({kind:"url",...g.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...g.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...g.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...g.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...g.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...g.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...g.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...g.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...g.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...g.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,...g.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,...g.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...g.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...g.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...g.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...g.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...g.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...g.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...g.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...g.errToObj(t)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new V({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new V({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new V({...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 H(e,t){const r=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,s=r>a?r:a;return Number.parseInt(e.toFixed(s).replace(".",""))%Number.parseInt(t.toFixed(s).replace(".",""))/10**s}V.create=e=>new V({checks:[],typeName:$e.ZodString,coerce:e?.coerce??!1,...b(e)});class Q extends P{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==a.number){const t=this._getOrReturnCtx(e);return c(t,{code:i.invalid_type,expected:a.number,received:t.parsedType}),u}let r;const s=new d;for(const a of this._def.checks)if("int"===a.kind)t.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),c(r,{code:i.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty());else if("min"===a.kind){(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),c(r,{code:i.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty())}else if("max"===a.kind){(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),c(r,{code:i.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty())}else"multipleOf"===a.kind?0!==H(e.data,a.value)&&(r=this._getOrReturnCtx(e,r),c(r,{code:i.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):"finite"===a.kind?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),c(r,{code:i.not_finite,message:a.message}),s.dirty()):t.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,g.toString(t))}gt(e,t){return this.setLimit("min",e,!1,g.toString(t))}lte(e,t){return this.setLimit("max",e,!0,g.toString(t))}lt(e,t){return this.setLimit("max",e,!1,g.toString(t))}setLimit(e,t,r,a){return new Q({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:g.toString(a)}]})}_addCheck(e){return new Q({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:g.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:g.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.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&&t.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)}}Q.create=e=>new Q({checks:[],typeName:$e.ZodNumber,coerce:e?.coerce||!1,...b(e)});class K extends P{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)!==a.bigint)return this._getInvalidInput(e);let r;const s=new d;for(const a of this._def.checks)if("min"===a.kind){(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),c(r,{code:i.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty())}else if("max"===a.kind){(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),c(r,{code:i.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty())}else"multipleOf"===a.kind?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),c(r,{code:i.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):t.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return c(t,{code:i.invalid_type,expected:a.bigint,received:t.parsedType}),u}gte(e,t){return this.setLimit("min",e,!0,g.toString(t))}gt(e,t){return this.setLimit("min",e,!1,g.toString(t))}lte(e,t){return this.setLimit("max",e,!0,g.toString(t))}lt(e,t){return this.setLimit("max",e,!1,g.toString(t))}setLimit(e,t,r,a){return new K({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:g.toString(a)}]})}_addCheck(e){return new K({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:g.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}}K.create=e=>new K({checks:[],typeName:$e.ZodBigInt,coerce:e?.coerce??!1,...b(e)});class B extends P{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==a.boolean){const t=this._getOrReturnCtx(e);return c(t,{code:i.invalid_type,expected:a.boolean,received:t.parsedType}),u}return p(e.data)}}B.create=e=>new B({typeName:$e.ZodBoolean,coerce:e?.coerce||!1,...b(e)});class W extends P{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==a.date){const t=this._getOrReturnCtx(e);return c(t,{code:i.invalid_type,expected:a.date,received:t.parsedType}),u}if(Number.isNaN(e.data.getTime())){return c(this._getOrReturnCtx(e),{code:i.invalid_date}),u}const r=new d;let s;for(const a of this._def.checks)"min"===a.kind?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),c(s,{code:i.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):"max"===a.kind?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),c(s,{code:i.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):t.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:g.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:g.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}}W.create=e=>new W({checks:[],coerce:e?.coerce||!1,typeName:$e.ZodDate,...b(e)});class J extends P{_parse(e){if(this._getType(e)!==a.symbol){const t=this._getOrReturnCtx(e);return c(t,{code:i.invalid_type,expected:a.symbol,received:t.parsedType}),u}return p(e.data)}}J.create=e=>new J({typeName:$e.ZodSymbol,...b(e)});class G extends P{_parse(e){if(this._getType(e)!==a.undefined){const t=this._getOrReturnCtx(e);return c(t,{code:i.invalid_type,expected:a.undefined,received:t.parsedType}),u}return p(e.data)}}G.create=e=>new G({typeName:$e.ZodUndefined,...b(e)});class Y extends P{_parse(e){if(this._getType(e)!==a.null){const t=this._getOrReturnCtx(e);return c(t,{code:i.invalid_type,expected:a.null,received:t.parsedType}),u}return p(e.data)}}Y.create=e=>new Y({typeName:$e.ZodNull,...b(e)});class X extends P{constructor(){super(...arguments),this._any=!0}_parse(e){return p(e.data)}}X.create=e=>new X({typeName:$e.ZodAny,...b(e)});class ee extends P{constructor(){super(...arguments),this._unknown=!0}_parse(e){return p(e.data)}}ee.create=e=>new ee({typeName:$e.ZodUnknown,...b(e)});class te extends P{_parse(e){const t=this._getOrReturnCtx(e);return c(t,{code:i.invalid_type,expected:a.never,received:t.parsedType}),u}}te.create=e=>new te({typeName:$e.ZodNever,...b(e)});class re extends P{_parse(e){if(this._getType(e)!==a.undefined){const t=this._getOrReturnCtx(e);return c(t,{code:i.invalid_type,expected:a.void,received:t.parsedType}),u}return p(e.data)}}re.create=e=>new re({typeName:$e.ZodVoid,...b(e)});class ae extends P{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),s=this._def;if(t.parsedType!==a.array)return c(t,{code:i.invalid_type,expected:a.array,received:t.parsedType}),u;if(null!==s.exactLength){const e=t.data.length>s.exactLength.value,a=t.data.length<s.exactLength.value;(e||a)&&(c(t,{code:e?i.too_big:i.too_small,minimum:a?s.exactLength.value:void 0,maximum:e?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),r.dirty())}if(null!==s.minLength&&t.data.length<s.minLength.value&&(c(t,{code:i.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),r.dirty()),null!==s.maxLength&&t.data.length>s.maxLength.value&&(c(t,{code:i.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map(((e,r)=>s.type._parseAsync(new _(t,e,t.path,r))))).then((e=>d.mergeArray(r,e)));const o=[...t.data].map(((e,r)=>s.type._parseSync(new _(t,e,t.path,r))));return d.mergeArray(r,o)}get element(){return this._def.type}min(e,t){return new ae({...this._def,minLength:{value:e,message:g.toString(t)}})}max(e,t){return new ae({...this._def,maxLength:{value:e,message:g.toString(t)}})}length(e,t){return new ae({...this._def,exactLength:{value:e,message:g.toString(t)}})}nonempty(e){return this.min(1,e)}}function se(e){if(e instanceof ie){const t={};for(const r in e.shape){const a=e.shape[r];t[r]=Pe.create(se(a))}return new ie({...e._def,shape:()=>t})}return e instanceof ae?new ae({...e._def,type:se(e.element)}):e instanceof Pe?Pe.create(se(e.unwrap())):e instanceof Ee?Ee.create(se(e.unwrap())):e instanceof ue?ue.create(e.items.map((e=>se(e)))):e}ae.create=(e,t)=>new ae({type:e,minLength:null,maxLength:null,exactLength:null,typeName:$e.ZodArray,...b(t)});class ie extends P{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(),r=t.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==a.object){const t=this._getOrReturnCtx(e);return c(t,{code:i.invalid_type,expected:a.object,received:t.parsedType}),u}const{status:t,ctx:r}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),n=[];if(!(this._def.catchall instanceof te&&"strip"===this._def.unknownKeys))for(const e in r.data)o.includes(e)||n.push(e);const l=[];for(const e of o){const t=s[e],a=r.data[e];l.push({key:{status:"valid",value:e},value:t._parse(new _(r,a,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof te){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of n)l.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)n.length>0&&(c(r,{code:i.unrecognized_keys,keys:n}),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 n){const a=r.data[t];l.push({key:{status:"valid",value:t},value:e._parse(new _(r,a,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of l){const r=await t.key,a=await t.value;e.push({key:r,value:a,alwaysSet:t.alwaysSet})}return e})).then((e=>d.mergeObjectSync(t,e))):d.mergeObjectSync(t,l)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new ie({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{const a=this._def.errorMap?.(t,r).message??r.defaultError;return"unrecognized_keys"===t.code?{message:g.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new ie({...this._def,unknownKeys:"strip"})}passthrough(){return new ie({...this._def,unknownKeys:"passthrough"})}extend(e){return new ie({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ie({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:$e.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ie({...this._def,catchall:e})}pick(e){const r={};for(const a of t.objectKeys(e))e[a]&&this.shape[a]&&(r[a]=this.shape[a]);return new ie({...this._def,shape:()=>r})}omit(e){const r={};for(const a of t.objectKeys(this.shape))e[a]||(r[a]=this.shape[a]);return new ie({...this._def,shape:()=>r})}deepPartial(){return se(this)}partial(e){const r={};for(const a of t.objectKeys(this.shape)){const t=this.shape[a];e&&!e[a]?r[a]=t:r[a]=t.optional()}return new ie({...this._def,shape:()=>r})}required(e){const r={};for(const a of t.objectKeys(this.shape))if(e&&!e[a])r[a]=this.shape[a];else{let e=this.shape[a];for(;e instanceof Pe;)e=e._def.innerType;r[a]=e}return new ie({...this._def,shape:()=>r})}keyof(){return ye(t.objectKeys(this.shape))}}ie.create=(e,t)=>new ie({shape:()=>e,unknownKeys:"strip",catchall:te.create(),typeName:$e.ZodObject,...b(t)}),ie.strictCreate=(e,t)=>new ie({shape:()=>e,unknownKeys:"strict",catchall:te.create(),typeName:$e.ZodObject,...b(t)}),ie.lazycreate=(e,t)=>new ie({shape:e,unknownKeys:"strip",catchall:te.create(),typeName:$e.ZodObject,...b(t)});class oe extends P{_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 o(e.ctx.common.issues)));return c(t,{code:i.invalid_union,unionErrors:r}),u}));{let e;const a=[];for(const s of r){const r={...t,common:{...t.common,issues:[]},parent:null},i=s._parseSync({data:t.data,path:t.path,parent:r});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:r}),r.common.issues.length&&a.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const s=a.map((e=>new o(e)));return c(t,{code:i.invalid_union,unionErrors:s}),u}}get options(){return this._def.options}}oe.create=(e,t)=>new oe({options:e,typeName:$e.ZodUnion,...b(t)});const ne=e=>e instanceof fe?ne(e.schema):e instanceof be?ne(e.innerType()):e instanceof ve?[e.value]:e instanceof ge?e.options:e instanceof _e?t.objectValues(e.enum):e instanceof xe?ne(e._def.innerType):e instanceof G?[void 0]:e instanceof Y?[null]:e instanceof Pe?[void 0,...ne(e.unwrap())]:e instanceof Ee?[null,...ne(e.unwrap())]:e instanceof Re||e instanceof Te?ne(e.unwrap()):e instanceof ke?ne(e._def.innerType):[];class le extends P{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==a.object)return c(t,{code:i.invalid_type,expected:a.object,received:t.parsedType}),u;const r=this.discriminator,s=t.data[r],o=this.optionsMap.get(s);return o?t.common.async?o._parseAsync({data:t.data,path:t.path,parent:t}):o._parseSync({data:t.data,path:t.path,parent:t}):(c(t,{code:i.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),u)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const a=new Map;for(const r of t){const t=ne(r.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const s of t){if(a.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);a.set(s,r)}}return new le({typeName:$e.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...b(r)})}}function ce(e,r){const i=s(e),o=s(r);if(e===r)return{valid:!0,data:e};if(i===a.object&&o===a.object){const a=t.objectKeys(r),s=t.objectKeys(e).filter((e=>-1!==a.indexOf(e))),i={...e,...r};for(const t of s){const a=ce(e[t],r[t]);if(!a.valid)return{valid:!1};i[t]=a.data}return{valid:!0,data:i}}if(i===a.array&&o===a.array){if(e.length!==r.length)return{valid:!1};const t=[];for(let a=0;a<e.length;a++){const s=ce(e[a],r[a]);if(!s.valid)return{valid:!1};t.push(s.data)}return{valid:!0,data:t}}return i===a.date&&o===a.date&&+e===+r?{valid:!0,data:e}:{valid:!1}}class de extends P{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=(e,a)=>{if(m(e)||m(a))return u;const s=ce(e.value,a.value);return s.valid?((f(e)||f(a))&&t.dirty(),{status:t.value,value:s.data}):(c(r,{code:i.invalid_intersection_types}),u)};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])=>a(e,t))):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}de.create=(e,t,r)=>new de({left:e,right:t,typeName:$e.ZodIntersection,...b(r)});class ue extends P{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==a.array)return c(r,{code:i.invalid_type,expected:a.array,received:r.parsedType}),u;if(r.data.length<this._def.items.length)return c(r,{code:i.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),u;!this._def.rest&&r.data.length>this._def.items.length&&(c(r,{code:i.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...r.data].map(((e,t)=>{const a=this._def.items[t]||this._def.rest;return a?a._parse(new _(r,e,r.path,t)):null})).filter((e=>!!e));return r.common.async?Promise.all(s).then((e=>d.mergeArray(t,e))):d.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new ue({...this._def,rest:e})}}ue.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ue({items:e,typeName:$e.ZodTuple,rest:null,...b(t)})};class he extends P{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!==a.object)return c(r,{code:i.invalid_type,expected:a.object,received:r.parsedType}),u;const s=[],o=this._def.keyType,n=this._def.valueType;for(const e in r.data)s.push({key:o._parse(new _(r,e,r.path,e)),value:n._parse(new _(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?d.mergeObjectAsync(t,s):d.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,r){return new he(t instanceof P?{keyType:e,valueType:t,typeName:$e.ZodRecord,...b(r)}:{keyType:V.create(),valueType:e,typeName:$e.ZodRecord,...b(t)})}}class pe extends P{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!==a.map)return c(r,{code:i.invalid_type,expected:a.map,received:r.parsedType}),u;const s=this._def.keyType,o=this._def.valueType,n=[...r.data.entries()].map((([e,t],a)=>({key:s._parse(new _(r,e,r.path,[a,"key"])),value:o._parse(new _(r,t,r.path,[a,"value"]))})));if(r.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const r of n){const a=await r.key,s=await r.value;if("aborted"===a.status||"aborted"===s.status)return u;"dirty"!==a.status&&"dirty"!==s.status||t.dirty(),e.set(a.value,s.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const r of n){const a=r.key,s=r.value;if("aborted"===a.status||"aborted"===s.status)return u;"dirty"!==a.status&&"dirty"!==s.status||t.dirty(),e.set(a.value,s.value)}return{status:t.value,value:e}}}}pe.create=(e,t,r)=>new pe({valueType:t,keyType:e,typeName:$e.ZodMap,...b(r)});class me extends P{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==a.set)return c(r,{code:i.invalid_type,expected:a.set,received:r.parsedType}),u;const s=this._def;null!==s.minSize&&r.data.size<s.minSize.value&&(c(r,{code:i.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),null!==s.maxSize&&r.data.size>s.maxSize.value&&(c(r,{code:i.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const o=this._def.valueType;function n(e){const r=new Set;for(const a of e){if("aborted"===a.status)return u;"dirty"===a.status&&t.dirty(),r.add(a.value)}return{status:t.value,value:r}}const l=[...r.data.values()].map(((e,t)=>o._parse(new _(r,e,r.path,t))));return r.common.async?Promise.all(l).then((e=>n(e))):n(l)}min(e,t){return new me({...this._def,minSize:{value:e,message:g.toString(t)}})}max(e,t){return new me({...this._def,maxSize:{value:e,message:g.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}me.create=(e,t)=>new me({valueType:e,minSize:null,maxSize:null,typeName:$e.ZodSet,...b(t)});class fe extends P{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})}}fe.create=(e,t)=>new fe({getter:e,typeName:$e.ZodLazy,...b(t)});class ve extends P{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return c(t,{received:t.data,code:i.invalid_literal,expected:this._def.value}),u}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ye(e,t){return new ge({values:e,typeName:$e.ZodEnum,...b(t)})}ve.create=(e,t)=>new ve({value:e,typeName:$e.ZodLiteral,...b(t)});class ge extends P{_parse(e){if("string"!=typeof e.data){const r=this._getOrReturnCtx(e),a=this._def.values;return c(r,{expected:t.joinValues(a),received:r.parsedType,code:i.invalid_type}),u}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 c(t,{received:t.data,code:i.invalid_enum_value,options:r}),u}return p(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ge.create(e,{...this._def,...t})}exclude(e,t=this._def){return ge.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}ge.create=ye;class _e extends P{_parse(e){const r=t.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==a.string&&s.parsedType!==a.number){const e=t.objectValues(r);return c(s,{expected:t.joinValues(e),received:s.parsedType,code:i.invalid_type}),u}if(this._cache||(this._cache=new Set(t.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=t.objectValues(r);return c(s,{received:s.data,code:i.invalid_enum_value,options:e}),u}return p(e.data)}get enum(){return this._def.values}}_e.create=(e,t)=>new _e({values:e,typeName:$e.ZodNativeEnum,...b(t)});class we extends P{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==a.promise&&!1===t.common.async)return c(t,{code:i.invalid_type,expected:a.promise,received:t.parsedType}),u;const r=t.parsedType===a.promise?t.data:Promise.resolve(t.data);return p(r.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}we.create=(e,t)=>new we({type:e,typeName:$e.ZodPromise,...b(t)});class be extends P{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$e.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:a}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:e=>{c(a,e),e.fatal?r.abort():r.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),"preprocess"===s.type){const e=s.transform(a.data,i);if(a.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===r.value)return u;const t=await this._def.schema._parseAsync({data:e,path:a.path,parent:a});return"aborted"===t.status?u:"dirty"===t.status||"dirty"===r.value?h(t.value):t}));{if("aborted"===r.value)return u;const t=this._def.schema._parseSync({data:e,path:a.path,parent:a});return"aborted"===t.status?u:"dirty"===t.status||"dirty"===r.value?h(t.value):t}}if("refinement"===s.type){const e=e=>{const t=s.refinement(e,i);if(a.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===a.common.async){const t=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===t.status?u:("dirty"===t.status&&r.dirty(),e(t.value),{status:r.value,value:t.value})}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((t=>"aborted"===t.status?u:("dirty"===t.status&&r.dirty(),e(t.value).then((()=>({status:r.value,value:t.value}))))))}if("transform"===s.type){if(!1===a.common.async){const e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!v(e))return u;const t=s.transform(e.value,i);if(t instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:t}}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((e=>v(e)?Promise.resolve(s.transform(e.value,i)).then((e=>({status:r.value,value:e}))):u))}t.assertNever(s)}}be.create=(e,t,r)=>new be({schema:e,typeName:$e.ZodEffects,effect:t,...b(r)}),be.createWithPreprocess=(e,t,r)=>new be({schema:t,effect:{type:"preprocess",transform:e},typeName:$e.ZodEffects,...b(r)});class Pe extends P{_parse(e){return this._getType(e)===a.undefined?p(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Pe.create=(e,t)=>new Pe({innerType:e,typeName:$e.ZodOptional,...b(t)});class Ee extends P{_parse(e){return this._getType(e)===a.null?p(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ee.create=(e,t)=>new Ee({innerType:e,typeName:$e.ZodNullable,...b(t)});class xe extends P{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===a.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}xe.create=(e,t)=>new xe({innerType:e,typeName:$e.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...b(t)});class ke extends P{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return y(a)?a.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new o(r.common.issues)},input:r.data})}))):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new o(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}ke.create=(e,t)=>new ke({innerType:e,typeName:$e.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...b(t)});class Se extends P{_parse(e){if(this._getType(e)!==a.nan){const t=this._getOrReturnCtx(e);return c(t,{code:i.invalid_type,expected:a.nan,received:t.parsedType}),u}return{status:"valid",value:e.data}}}Se.create=e=>new Se({typeName:$e.ZodNaN,...b(e)});class Re extends P{_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 Oe extends P{_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?u:"dirty"===e.status?(t.dirty(),h(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?u:"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 Oe({in:e,out:t,typeName:$e.ZodPipeline})}}class Te extends P{_parse(e){const t=this._def.innerType._parse(e),r=e=>(v(e)&&(e.value=Object.freeze(e.value)),e);return y(t)?t.then((e=>r(e))):r(t)}unwrap(){return this._def.innerType}}var $e;Te.create=(e,t)=>new Te({innerType:e,typeName:$e.ZodReadonly,...b(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"}($e||($e={}));const Ie=V.create,Ce=Q.create,je=B.create,Fe=X.create,Ae=ee.create;te.create;const De=ae.create,Ne=ie.create,qe=oe.create,Le=le.create;de.create,ue.create;const ze=he.create,Ze=ve.create,Me=ge.create;we.create;const Ue=Pe.create;Ee.create;const Ve="2025-03-26",He=[Ve,"2024-11-05","2024-10-07"],Qe="2.0",Ke=qe([Ie(),Ce().int()]),Be=Ie(),We=Ne({progressToken:Ue(Ke)}).passthrough(),Je=Ne({_meta:Ue(We)}).passthrough(),Ge=Ne({method:Ie(),params:Ue(Je)}),Ye=Ne({_meta:Ue(Ne({}).passthrough())}).passthrough(),Xe=Ne({method:Ie(),params:Ue(Ye)}),et=Ne({_meta:Ue(Ne({}).passthrough())}).passthrough(),tt=qe([Ie(),Ce().int()]),rt=Ne({jsonrpc:Ze(Qe),id:tt}).merge(Ge).strict(),at=e=>rt.safeParse(e).success,st=Ne({jsonrpc:Ze(Qe)}).merge(Xe).strict(),it=Ne({jsonrpc:Ze(Qe),id:tt,result:et}).strict(),ot=e=>it.safeParse(e).success;var nt;!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"}(nt||(nt={}));const lt=Ne({jsonrpc:Ze(Qe),id:tt,error:Ne({code:Ce().int(),message:Ie(),data:Ue(Ae())})}).strict(),ct=qe([rt,st,it,lt]),dt=et.strict(),ut=Xe.extend({method:Ze("notifications/cancelled"),params:Ye.extend({requestId:tt,reason:Ie().optional()})}),ht=Ne({name:Ie(),version:Ie()}).passthrough(),pt=Ne({experimental:Ue(Ne({}).passthrough()),sampling:Ue(Ne({}).passthrough()),roots:Ue(Ne({listChanged:Ue(je())}).passthrough())}).passthrough(),mt=Ge.extend({method:Ze("initialize"),params:Je.extend({protocolVersion:Ie(),capabilities:pt,clientInfo:ht})}),ft=Ne({experimental:Ue(Ne({}).passthrough()),logging:Ue(Ne({}).passthrough()),completions:Ue(Ne({}).passthrough()),prompts:Ue(Ne({listChanged:Ue(je())}).passthrough()),resources:Ue(Ne({subscribe:Ue(je()),listChanged:Ue(je())}).passthrough()),tools:Ue(Ne({listChanged:Ue(je())}).passthrough())}).passthrough(),vt=et.extend({protocolVersion:Ie(),capabilities:ft,serverInfo:ht,instructions:Ue(Ie())}),yt=Xe.extend({method:Ze("notifications/initialized")}),gt=Ge.extend({method:Ze("ping")}),_t=Ne({progress:Ce(),total:Ue(Ce()),message:Ue(Ie())}).passthrough(),wt=Xe.extend({method:Ze("notifications/progress"),params:Ye.merge(_t).extend({progressToken:Ke})}),bt=Ge.extend({params:Je.extend({cursor:Ue(Be)}).optional()}),Pt=et.extend({nextCursor:Ue(Be)}),Et=Ne({uri:Ie(),mimeType:Ue(Ie())}).passthrough(),xt=Et.extend({text:Ie()}),kt=Et.extend({blob:Ie().base64()}),St=Ne({uri:Ie(),name:Ie(),description:Ue(Ie()),mimeType:Ue(Ie())}).passthrough(),Rt=Ne({uriTemplate:Ie(),name:Ie(),description:Ue(Ie()),mimeType:Ue(Ie())}).passthrough(),Ot=bt.extend({method:Ze("resources/list")}),Tt=Pt.extend({resources:De(St)}),$t=bt.extend({method:Ze("resources/templates/list")}),It=Pt.extend({resourceTemplates:De(Rt)}),Ct=Ge.extend({method:Ze("resources/read"),params:Je.extend({uri:Ie()})}),jt=et.extend({contents:De(qe([xt,kt]))}),Ft=Xe.extend({method:Ze("notifications/resources/list_changed")}),At=Ge.extend({method:Ze("resources/subscribe"),params:Je.extend({uri:Ie()})}),Dt=Ge.extend({method:Ze("resources/unsubscribe"),params:Je.extend({uri:Ie()})}),Nt=Xe.extend({method:Ze("notifications/resources/updated"),params:Ye.extend({uri:Ie()})}),qt=Ne({name:Ie(),description:Ue(Ie()),required:Ue(je())}).passthrough(),Lt=Ne({name:Ie(),description:Ue(Ie()),arguments:Ue(De(qt))}).passthrough(),zt=bt.extend({method:Ze("prompts/list")}),Zt=Pt.extend({prompts:De(Lt)}),Mt=Ge.extend({method:Ze("prompts/get"),params:Je.extend({name:Ie(),arguments:Ue(ze(Ie()))})}),Ut=Ne({type:Ze("text"),text:Ie()}).passthrough(),Vt=Ne({type:Ze("image"),data:Ie().base64(),mimeType:Ie()}).passthrough(),Ht=Ne({type:Ze("audio"),data:Ie().base64(),mimeType:Ie()}).passthrough(),Qt=Ne({type:Ze("resource"),resource:qe([xt,kt])}).passthrough(),Kt=Ne({role:Me(["user","assistant"]),content:qe([Ut,Vt,Ht,Qt])}).passthrough(),Bt=et.extend({description:Ue(Ie()),messages:De(Kt)}),Wt=Xe.extend({method:Ze("notifications/prompts/list_changed")}),Jt=Ne({title:Ue(Ie()),readOnlyHint:Ue(je()),destructiveHint:Ue(je()),idempotentHint:Ue(je()),openWorldHint:Ue(je())}).passthrough(),Gt=Ne({name:Ie(),description:Ue(Ie()),inputSchema:Ne({type:Ze("object"),properties:Ue(Ne({}).passthrough()),required:Ue(De(Ie()))}).passthrough(),outputSchema:Ue(Ne({type:Ze("object"),properties:Ue(Ne({}).passthrough()),required:Ue(De(Ie()))}).passthrough()),annotations:Ue(Jt)}).passthrough(),Yt=bt.extend({method:Ze("tools/list")}),Xt=Pt.extend({tools:De(Gt)}),er=et.extend({content:De(qe([Ut,Vt,Ht,Qt])).default([]),structuredContent:Ne({}).passthrough().optional(),isError:Ue(je())});er.or(et.extend({toolResult:Ae()}));const tr=Ge.extend({method:Ze("tools/call"),params:Je.extend({name:Ie(),arguments:Ue(ze(Ae()))})}),rr=Xe.extend({method:Ze("notifications/tools/list_changed")}),ar=Me(["debug","info","notice","warning","error","critical","alert","emergency"]),sr=Ge.extend({method:Ze("logging/setLevel"),params:Je.extend({level:ar})}),ir=Xe.extend({method:Ze("notifications/message"),params:Ye.extend({level:ar,logger:Ue(Ie()),data:Ae()})}),or=Ne({name:Ie().optional()}).passthrough(),nr=Ne({hints:Ue(De(or)),costPriority:Ue(Ce().min(0).max(1)),speedPriority:Ue(Ce().min(0).max(1)),intelligencePriority:Ue(Ce().min(0).max(1))}).passthrough(),lr=Ne({role:Me(["user","assistant"]),content:qe([Ut,Vt,Ht])}).passthrough(),cr=Ge.extend({method:Ze("sampling/createMessage"),params:Je.extend({messages:De(lr),systemPrompt:Ue(Ie()),includeContext:Ue(Me(["none","thisServer","allServers"])),temperature:Ue(Ce()),maxTokens:Ce().int(),stopSequences:Ue(De(Ie())),metadata:Ue(Ne({}).passthrough()),modelPreferences:Ue(nr)})}),dr=et.extend({model:Ie(),stopReason:Ue(Me(["endTurn","stopSequence","maxTokens"]).or(Ie())),role:Me(["user","assistant"]),content:Le("type",[Ut,Vt,Ht])}),ur=Ne({type:Ze("ref/resource"),uri:Ie()}).passthrough(),hr=Ne({type:Ze("ref/prompt"),name:Ie()}).passthrough(),pr=Ge.extend({method:Ze("completion/complete"),params:Je.extend({ref:qe([hr,ur]),argument:Ne({name:Ie(),value:Ie()}).passthrough()})}),mr=et.extend({completion:Ne({values:De(Ie()).max(100),total:Ue(Ce().int()),hasMore:Ue(je())}).passthrough()}),fr=Ne({uri:Ie().startsWith("file://"),name:Ue(Ie())}).passthrough(),vr=Ge.extend({method:Ze("roots/list")}),yr=et.extend({roots:De(fr)}),gr=Xe.extend({method:Ze("notifications/roots/list_changed")});qe([gt,mt,pr,sr,Mt,zt,Ot,$t,Ct,At,Dt,tr,Yt]),qe([ut,wt,yt,gr]),qe([dt,dr,yr]),qe([gt,cr,vr]),qe([ut,wt,ir,Nt,Ft,rr,Wt]),qe([dt,vt,mr,Bt,Zt,Tt,It,jt,er,Xt]);class _r extends Error{constructor(e,t,r){super(`MCP error ${e}: ${t}`),this.code=e,this.data=r,this.name="McpError"}}class wr{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.setNotificationHandler(ut,(e=>{const t=this._requestHandlerAbortControllers.get(e.params.requestId);null==t||t.abort(e.params.reason)})),this.setNotificationHandler(wt,(e=>{this._onprogress(e)})),this.setRequestHandler(gt,(e=>({})))}_setupTimeout(e,t,r,a,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(a,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:s,onTimeout:a})}_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),new _r(nt.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,this._transport.onclose=()=>{this._onclose()},this._transport.onerror=e=>{this._onerror(e)},this._transport.onmessage=(e,t)=>{var r;ot(e)||(r=e,lt.safeParse(r).success)?this._onresponse(e):at(e)?this._onrequest(e,t):(e=>st.safeParse(e).success)(e)?this._onnotification(e):this._onerror(new Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){var e;const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,null===(e=this.onclose)||void 0===e||e.call(this);const r=new _r(nt.ConnectionClosed,"Connection closed");for(const e of t.values())e(r)}_onerror(e){var t;null===(t=this.onerror)||void 0===t||t.call(this,e)}_onnotification(e){var t;const r=null!==(t=this._notificationHandlers.get(e.method))&&void 0!==t?t:this.fallbackNotificationHandler;void 0!==r&&Promise.resolve().then((()=>r(e))).catch((e=>this._onerror(new Error(`Uncaught error in notification handler: ${e}`))))}_onrequest(e,t){var r,a,s,i;const o=null!==(r=this._requestHandlers.get(e.method))&&void 0!==r?r:this.fallbackRequestHandler;if(void 0===o)return void(null===(a=this._transport)||void 0===a||a.send({jsonrpc:"2.0",id:e.id,error:{code:nt.MethodNotFound,message:"Method not found"}}).catch((e=>this._onerror(new Error(`Failed to send an error response: ${e}`)))));const n=new AbortController;this._requestHandlerAbortControllers.set(e.id,n);const l={signal:n.signal,sessionId:null===(s=this._transport)||void 0===s?void 0:s.sessionId,_meta:null===(i=e.params)||void 0===i?void 0:i._meta,sendNotification:t=>this.notification(t,{relatedRequestId:e.id}),sendRequest:(t,r,a)=>this.request(t,r,{...a,relatedRequestId:e.id}),authInfo:null==t?void 0:t.authInfo,requestId:e.id};Promise.resolve().then((()=>o(e,l))).then((t=>{var r;if(!n.signal.aborted)return null===(r=this._transport)||void 0===r?void 0:r.send({result:t,jsonrpc:"2.0",id:e.id})}),(t=>{var r,a;if(!n.signal.aborted)return null===(r=this._transport)||void 0===r?void 0:r.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:nt.InternalError,message:null!==(a=t.message)&&void 0!==a?a:"Internal error"}})})).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,a=Number(t),s=this._progressHandlers.get(a);if(!s)return void this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));const i=this._responseHandlers.get(a),o=this._timeoutInfo.get(a);if(o&&i&&o.resetTimeoutOnProgress)try{this._resetTimeout(a)}catch(e){return void i(e)}s(r)}_onresponse(e){const t=Number(e.id),r=this._responseHandlers.get(t);if(void 0!==r)if(this._responseHandlers.delete(t),this._progressHandlers.delete(t),this._cleanupTimeout(t),ot(e))r(e);else{r(new _r(e.error.code,e.error.message,e.error.data))}else this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`))}get transport(){return this._transport}async close(){var e;await(null===(e=this._transport)||void 0===e?void 0:e.close())}request(e,t,r){const{relatedRequestId:a,resumptionToken:s,onresumptiontoken:i}=null!=r?r:{};return new Promise(((o,n)=>{var l,c,d,u,h,p;if(!this._transport)return void n(new Error("Not connected"));!0===(null===(l=this._options)||void 0===l?void 0:l.enforceStrictCapabilities)&&this.assertCapabilityForMethod(e.method),null===(c=null==r?void 0:r.signal)||void 0===c||c.throwIfAborted();const m=this._requestMessageId++,f={...e,jsonrpc:"2.0",id:m};(null==r?void 0:r.onprogress)&&(this._progressHandlers.set(m,r.onprogress),f.params={...e.params,_meta:{...(null===(d=e.params)||void 0===d?void 0:d._meta)||{},progressToken:m}});const v=e=>{var t;this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),null===(t=this._transport)||void 0===t||t.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(e)}},{relatedRequestId:a,resumptionToken:s,onresumptiontoken:i}).catch((e=>this._onerror(new Error(`Failed to send cancellation: ${e}`)))),n(e)};this._responseHandlers.set(m,(e=>{var a;if(!(null===(a=null==r?void 0:r.signal)||void 0===a?void 0:a.aborted)){if(e instanceof Error)return n(e);try{const r=t.parse(e.result);o(r)}catch(e){n(e)}}})),null===(u=null==r?void 0:r.signal)||void 0===u||u.addEventListener("abort",(()=>{var e;v(null===(e=null==r?void 0:r.signal)||void 0===e?void 0:e.reason)}));const y=null!==(h=null==r?void 0:r.timeout)&&void 0!==h?h:6e4;this._setupTimeout(m,y,null==r?void 0:r.maxTotalTimeout,(()=>v(new _r(nt.RequestTimeout,"Request timed out",{timeout:y}))),null!==(p=null==r?void 0:r.resetTimeoutOnProgress)&&void 0!==p&&p),this._transport.send(f,{relatedRequestId:a,resumptionToken:s,onresumptiontoken:i}).catch((e=>{this._cleanupTimeout(m),n(e)}))}))}async notification(e,t){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const r={...e,jsonrpc:"2.0"};await this._transport.send(r,t)}setRequestHandler(e,t){const r=e.shape.method.value;this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,((r,a)=>Promise.resolve(t(e.parse(r),a))))}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){this._notificationHandlers.set(e.shape.method.value,(r=>Promise.resolve(t(e.parse(r)))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function br(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Pr={exports:{}};
|
2
|
+
/** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */!function(e){function t(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];if(t.length>1){t[0]=t[0].slice(0,-1);for(var a=t.length-1,s=1;s<a;++s)t[s]=t[s].slice(1,-1);return t[a]=t[a].slice(1),t.join("")}return t[0]}function r(e){return"(?:"+e+")"}function a(e){return void 0===e?"undefined":null===e?"null":Object.prototype.toString.call(e).split(" ").pop().split("]").shift().toLowerCase()}function s(e){return e.toUpperCase()}function i(e){return null!=e?e instanceof Array?e:"number"!=typeof e.length||e.split||e.setInterval||e.call?[e]:Array.prototype.slice.call(e):[]}function o(e,t){var r=e;if(t)for(var a in t)r[a]=t[a];return r}function n(e){var a="[A-Za-z]",s="[0-9]",i=t(s,"[A-Fa-f]"),o=r(r("%[EFef]"+i+"%"+i+i+"%"+i+i)+"|"+r("%[89A-Fa-f]"+i+"%"+i+i)+"|"+r("%"+i+i)),n="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",l=t("[\\:\\/\\?\\#\\[\\]\\@]",n),c=e?"[\\uE000-\\uF8FF]":"[]",d=t(a,s,"[\\-\\.\\_\\~]",e?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]");r(a+t(a,s,"[\\+\\-\\.]")+"*"),r(r(o+"|"+t(d,n,"[\\:]"))+"*");var u=r(r("25[0-5]")+"|"+r("2[0-4]"+s)+"|"+r("1"+s+s)+"|"+r("0?[1-9]"+s)+"|0?0?"+s),h=r(u+"\\."+u+"\\."+u+"\\."+u),p=r(i+"{1,4}"),m=r(r(p+"\\:"+p)+"|"+h),f=r(r(p+"\\:")+"{6}"+m),v=r("\\:\\:"+r(p+"\\:")+"{5}"+m),y=r(r(p)+"?\\:\\:"+r(p+"\\:")+"{4}"+m),g=r(r(r(p+"\\:")+"{0,1}"+p)+"?\\:\\:"+r(p+"\\:")+"{3}"+m),_=r(r(r(p+"\\:")+"{0,2}"+p)+"?\\:\\:"+r(p+"\\:")+"{2}"+m),w=r(r(r(p+"\\:")+"{0,3}"+p)+"?\\:\\:"+p+"\\:"+m),b=r(r(r(p+"\\:")+"{0,4}"+p)+"?\\:\\:"+m),P=r(r(r(p+"\\:")+"{0,5}"+p)+"?\\:\\:"+p),E=r(r(r(p+"\\:")+"{0,6}"+p)+"?\\:\\:"),x=r([f,v,y,g,_,w,b,P,E].join("|")),k=r(r(d+"|"+o)+"+");r("[vV]"+i+"+\\."+t(d,n,"[\\:]")+"+"),r(r(o+"|"+t(d,n))+"*");var S=r(o+"|"+t(d,n,"[\\:\\@]"));return r(r(o+"|"+t(d,n,"[\\@]"))+"+"),r(r(S+"|"+t("[\\/\\?]",c))+"*"),{NOT_SCHEME:new RegExp(t("[^]",a,s,"[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(t("[^\\%\\:]",d,n),"g"),NOT_HOST:new RegExp(t("[^\\%\\[\\]\\:]",d,n),"g"),NOT_PATH:new RegExp(t("[^\\%\\/\\:\\@]",d,n),"g"),NOT_PATH_NOSCHEME:new RegExp(t("[^\\%\\/\\@]",d,n),"g"),NOT_QUERY:new RegExp(t("[^\\%]",d,n,"[\\:\\@\\/\\?]",c),"g"),NOT_FRAGMENT:new RegExp(t("[^\\%]",d,n,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(t("[^]",d,n),"g"),UNRESERVED:new RegExp(d,"g"),OTHER_CHARS:new RegExp(t("[^\\%]",d,l),"g"),PCT_ENCODED:new RegExp(o,"g"),IPV4ADDRESS:new RegExp("^("+h+")$"),IPV6ADDRESS:new RegExp("^\\[?("+x+")"+r(r("\\%25|\\%(?!"+i+"{2})")+"("+k+")")+"?\\]?$")}}var l=n(!1),c=n(!0),d=function(){function e(e,t){var r=[],a=!0,s=!1,i=void 0;try{for(var o,n=e[Symbol.iterator]();!(a=(o=n.next()).done)&&(r.push(o.value),!t||r.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{!a&&n.return&&n.return()}finally{if(s)throw i}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),u=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},h=2147483647,p=36,m=1,f=26,v=38,y=700,g=72,_=128,w="-",b=/^xn--/,P=/[^\0-\x7E]/,E=/[\x2E\u3002\uFF0E\uFF61]/g,x={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},k=p-m,S=Math.floor,R=String.fromCharCode;function O(e){throw new RangeError(x[e])}function T(e,t){for(var r=[],a=e.length;a--;)r[a]=t(e[a]);return r}function $(e,t){var r=e.split("@"),a="";return r.length>1&&(a=r[0]+"@",e=r[1]),a+T((e=e.replace(E,".")).split("."),t).join(".")}function I(e){for(var t=[],r=0,a=e.length;r<a;){var s=e.charCodeAt(r++);if(s>=55296&&s<=56319&&r<a){var i=e.charCodeAt(r++);56320==(64512&i)?t.push(((1023&s)<<10)+(1023&i)+65536):(t.push(s),r--)}else t.push(s)}return t}var C=function(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:p},j=function(e,t){return e+22+75*(e<26)-((0!=t)<<5)},F=function(e,t,r){var a=0;for(e=r?S(e/y):e>>1,e+=S(e/t);e>k*f>>1;a+=p)e=S(e/k);return S(a+(k+1)*e/(e+v))},A=function(e){var t=[],r=e.length,a=0,s=_,i=g,o=e.lastIndexOf(w);o<0&&(o=0);for(var n=0;n<o;++n)e.charCodeAt(n)>=128&&O("not-basic"),t.push(e.charCodeAt(n));for(var l=o>0?o+1:0;l<r;){for(var c=a,d=1,u=p;;u+=p){l>=r&&O("invalid-input");var v=C(e.charCodeAt(l++));(v>=p||v>S((h-a)/d))&&O("overflow"),a+=v*d;var y=u<=i?m:u>=i+f?f:u-i;if(v<y)break;var b=p-y;d>S(h/b)&&O("overflow"),d*=b}var P=t.length+1;i=F(a-c,P,0==c),S(a/P)>h-s&&O("overflow"),s+=S(a/P),a%=P,t.splice(a++,0,s)}return String.fromCodePoint.apply(String,t)},D=function(e){var t=[],r=(e=I(e)).length,a=_,s=0,i=g,o=!0,n=!1,l=void 0;try{for(var c,d=e[Symbol.iterator]();!(o=(c=d.next()).done);o=!0){var u=c.value;u<128&&t.push(R(u))}}catch(e){n=!0,l=e}finally{try{!o&&d.return&&d.return()}finally{if(n)throw l}}var v=t.length,y=v;for(v&&t.push(w);y<r;){var b=h,P=!0,E=!1,x=void 0;try{for(var k,T=e[Symbol.iterator]();!(P=(k=T.next()).done);P=!0){var $=k.value;$>=a&&$<b&&(b=$)}}catch(e){E=!0,x=e}finally{try{!P&&T.return&&T.return()}finally{if(E)throw x}}var C=y+1;b-a>S((h-s)/C)&&O("overflow"),s+=(b-a)*C,a=b;var A=!0,D=!1,N=void 0;try{for(var q,L=e[Symbol.iterator]();!(A=(q=L.next()).done);A=!0){var z=q.value;if(z<a&&++s>h&&O("overflow"),z==a){for(var Z=s,M=p;;M+=p){var U=M<=i?m:M>=i+f?f:M-i;if(Z<U)break;var V=Z-U,H=p-U;t.push(R(j(U+V%H,0))),Z=S(V/H)}t.push(R(j(Z,0))),i=F(s,C,y==v),s=0,++y}}}catch(e){D=!0,N=e}finally{try{!A&&L.return&&L.return()}finally{if(D)throw N}}++s,++a}return t.join("")},N=function(e){return $(e,(function(e){return b.test(e)?A(e.slice(4).toLowerCase()):e}))},q=function(e){return $(e,(function(e){return P.test(e)?"xn--"+D(e):e}))},L={version:"2.1.0",ucs2:{decode:I,encode:function(e){return String.fromCodePoint.apply(String,u(e))}},decode:A,encode:D,toASCII:q,toUnicode:N},z={};function Z(e){var t=e.charCodeAt(0);return t<16?"%0"+t.toString(16).toUpperCase():t<128?"%"+t.toString(16).toUpperCase():t<2048?"%"+(t>>6|192).toString(16).toUpperCase()+"%"+(63&t|128).toString(16).toUpperCase():"%"+(t>>12|224).toString(16).toUpperCase()+"%"+(t>>6&63|128).toString(16).toUpperCase()+"%"+(63&t|128).toString(16).toUpperCase()}function M(e){for(var t="",r=0,a=e.length;r<a;){var s=parseInt(e.substr(r+1,2),16);if(s<128)t+=String.fromCharCode(s),r+=3;else if(s>=194&&s<224){if(a-r>=6){var i=parseInt(e.substr(r+4,2),16);t+=String.fromCharCode((31&s)<<6|63&i)}else t+=e.substr(r,6);r+=6}else if(s>=224){if(a-r>=9){var o=parseInt(e.substr(r+4,2),16),n=parseInt(e.substr(r+7,2),16);t+=String.fromCharCode((15&s)<<12|(63&o)<<6|63&n)}else t+=e.substr(r,9);r+=9}else t+=e.substr(r,3),r+=3}return t}function U(e,t){function r(e){var r=M(e);return r.match(t.UNRESERVED)?r:e}return e.scheme&&(e.scheme=String(e.scheme).replace(t.PCT_ENCODED,r).toLowerCase().replace(t.NOT_SCHEME,"")),void 0!==e.userinfo&&(e.userinfo=String(e.userinfo).replace(t.PCT_ENCODED,r).replace(t.NOT_USERINFO,Z).replace(t.PCT_ENCODED,s)),void 0!==e.host&&(e.host=String(e.host).replace(t.PCT_ENCODED,r).toLowerCase().replace(t.NOT_HOST,Z).replace(t.PCT_ENCODED,s)),void 0!==e.path&&(e.path=String(e.path).replace(t.PCT_ENCODED,r).replace(e.scheme?t.NOT_PATH:t.NOT_PATH_NOSCHEME,Z).replace(t.PCT_ENCODED,s)),void 0!==e.query&&(e.query=String(e.query).replace(t.PCT_ENCODED,r).replace(t.NOT_QUERY,Z).replace(t.PCT_ENCODED,s)),void 0!==e.fragment&&(e.fragment=String(e.fragment).replace(t.PCT_ENCODED,r).replace(t.NOT_FRAGMENT,Z).replace(t.PCT_ENCODED,s)),e}function V(e){return e.replace(/^0*(.*)/,"$1")||"0"}function H(e,t){var r=e.match(t.IPV4ADDRESS)||[],a=d(r,2)[1];return a?a.split(".").map(V).join("."):e}function Q(e,t){var r=e.match(t.IPV6ADDRESS)||[],a=d(r,3),s=a[1],i=a[2];if(s){for(var o=s.toLowerCase().split("::").reverse(),n=d(o,2),l=n[0],c=n[1],u=c?c.split(":").map(V):[],h=l.split(":").map(V),p=t.IPV4ADDRESS.test(h[h.length-1]),m=p?7:8,f=h.length-m,v=Array(m),y=0;y<m;++y)v[y]=u[y]||h[f+y]||"";p&&(v[m-1]=H(v[m-1],t));var g=v.reduce((function(e,t,r){if(!t||"0"===t){var a=e[e.length-1];a&&a.index+a.length===r?a.length++:e.push({index:r,length:1})}return e}),[]).sort((function(e,t){return t.length-e.length}))[0],_=void 0;if(g&&g.length>1){var w=v.slice(0,g.index),b=v.slice(g.index+g.length);_=w.join(":")+"::"+b.join(":")}else _=v.join(":");return i&&(_+="%"+i),_}return e}var K=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,B=void 0==="".match(/(){0}/)[1];function W(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={},a=!1!==t.iri?c:l;"suffix"===t.reference&&(e=(t.scheme?t.scheme+":":"")+"//"+e);var s=e.match(K);if(s){B?(r.scheme=s[1],r.userinfo=s[3],r.host=s[4],r.port=parseInt(s[5],10),r.path=s[6]||"",r.query=s[7],r.fragment=s[8],isNaN(r.port)&&(r.port=s[5])):(r.scheme=s[1]||void 0,r.userinfo=-1!==e.indexOf("@")?s[3]:void 0,r.host=-1!==e.indexOf("//")?s[4]:void 0,r.port=parseInt(s[5],10),r.path=s[6]||"",r.query=-1!==e.indexOf("?")?s[7]:void 0,r.fragment=-1!==e.indexOf("#")?s[8]:void 0,isNaN(r.port)&&(r.port=e.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?s[4]:void 0)),r.host&&(r.host=Q(H(r.host,a),a)),void 0!==r.scheme||void 0!==r.userinfo||void 0!==r.host||void 0!==r.port||r.path||void 0!==r.query?void 0===r.scheme?r.reference="relative":void 0===r.fragment?r.reference="absolute":r.reference="uri":r.reference="same-document",t.reference&&"suffix"!==t.reference&&t.reference!==r.reference&&(r.error=r.error||"URI is not a "+t.reference+" reference.");var i=z[(t.scheme||r.scheme||"").toLowerCase()];if(t.unicodeSupport||i&&i.unicodeSupport)U(r,a);else{if(r.host&&(t.domainHost||i&&i.domainHost))try{r.host=L.toASCII(r.host.replace(a.PCT_ENCODED,M).toLowerCase())}catch(e){r.error=r.error||"Host's domain name can not be converted to ASCII via punycode: "+e}U(r,l)}i&&i.parse&&i.parse(r,t)}else r.error=r.error||"URI can not be parsed.";return r}function J(e,t){var r=!1!==t.iri?c:l,a=[];return void 0!==e.userinfo&&(a.push(e.userinfo),a.push("@")),void 0!==e.host&&a.push(Q(H(String(e.host),r),r).replace(r.IPV6ADDRESS,(function(e,t,r){return"["+t+(r?"%25"+r:"")+"]"}))),"number"!=typeof e.port&&"string"!=typeof e.port||(a.push(":"),a.push(String(e.port))),a.length?a.join(""):void 0}var G=/^\.\.?\//,Y=/^\/\.(\/|$)/,X=/^\/\.\.(\/|$)/,ee=/^\/?(?:.|\n)*?(?=\/|$)/;function te(e){for(var t=[];e.length;)if(e.match(G))e=e.replace(G,"");else if(e.match(Y))e=e.replace(Y,"/");else if(e.match(X))e=e.replace(X,"/"),t.pop();else if("."===e||".."===e)e="";else{var r=e.match(ee);if(!r)throw new Error("Unexpected dot segment condition");var a=r[0];e=e.slice(a.length),t.push(a)}return t.join("")}function re(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.iri?c:l,a=[],s=z[(t.scheme||e.scheme||"").toLowerCase()];if(s&&s.serialize&&s.serialize(e,t),e.host)if(r.IPV6ADDRESS.test(e.host));else if(t.domainHost||s&&s.domainHost)try{e.host=t.iri?L.toUnicode(e.host):L.toASCII(e.host.replace(r.PCT_ENCODED,M).toLowerCase())}catch(r){e.error=e.error||"Host's domain name can not be converted to "+(t.iri?"Unicode":"ASCII")+" via punycode: "+r}U(e,r),"suffix"!==t.reference&&e.scheme&&(a.push(e.scheme),a.push(":"));var i=J(e,t);if(void 0!==i&&("suffix"!==t.reference&&a.push("//"),a.push(i),e.path&&"/"!==e.path.charAt(0)&&a.push("/")),void 0!==e.path){var o=e.path;t.absolutePath||s&&s.absolutePath||(o=te(o)),void 0===i&&(o=o.replace(/^\/\//,"/%2F")),a.push(o)}return void 0!==e.query&&(a.push("?"),a.push(e.query)),void 0!==e.fragment&&(a.push("#"),a.push(e.fragment)),a.join("")}function ae(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a={};return arguments[3]||(e=W(re(e,r),r),t=W(re(t,r),r)),!(r=r||{}).tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=te(t.path||""),a.query=t.query):(void 0!==t.userinfo||void 0!==t.host||void 0!==t.port?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=te(t.path||""),a.query=t.query):(t.path?("/"===t.path.charAt(0)?a.path=te(t.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)+t.path:a.path=t.path:a.path="/"+t.path,a.path=te(a.path)),a.query=t.query):(a.path=e.path,void 0!==t.query?a.query=t.query:a.query=e.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function se(e,t,r){var a=o({scheme:"null"},r);return re(ae(W(e,a),W(t,a),a,!0),a)}function ie(e,t){return"string"==typeof e?e=re(W(e,t),t):"object"===a(e)&&(e=W(re(e,t),t)),e}function oe(e,t,r){return"string"==typeof e?e=re(W(e,r),r):"object"===a(e)&&(e=re(e,r)),"string"==typeof t?t=re(W(t,r),r):"object"===a(t)&&(t=re(t,r)),e===t}function ne(e,t){return e&&e.toString().replace(t&&t.iri?c.ESCAPE:l.ESCAPE,Z)}function le(e,t){return e&&e.toString().replace(t&&t.iri?c.PCT_ENCODED:l.PCT_ENCODED,M)}var ce={scheme:"http",domainHost:!0,parse:function(e,t){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e},serialize:function(e,t){var r="https"===String(e.scheme).toLowerCase();return e.port!==(r?443:80)&&""!==e.port||(e.port=void 0),e.path||(e.path="/"),e}},de={scheme:"https",domainHost:ce.domainHost,parse:ce.parse,serialize:ce.serialize};function ue(e){return"boolean"==typeof e.secure?e.secure:"wss"===String(e.scheme).toLowerCase()}var he={scheme:"ws",domainHost:!0,parse:function(e,t){var r=e;return r.secure=ue(r),r.resourceName=(r.path||"/")+(r.query?"?"+r.query:""),r.path=void 0,r.query=void 0,r},serialize:function(e,t){if(e.port!==(ue(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){var r=e.resourceName.split("?"),a=d(r,2),s=a[0],i=a[1];e.path=s&&"/"!==s?s:void 0,e.query=i,e.resourceName=void 0}return e.fragment=void 0,e}},pe={scheme:"wss",domainHost:he.domainHost,parse:he.parse,serialize:he.serialize},me={},fe="[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]",ve="[0-9A-Fa-f]",ye=r(r("%[EFef]"+ve+"%"+ve+ve+"%"+ve+ve)+"|"+r("%[89A-Fa-f]"+ve+"%"+ve+ve)+"|"+r("%"+ve+ve)),ge="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",_e=t("[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",'[\\"\\\\]'),we="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",be=new RegExp(fe,"g"),Pe=new RegExp(ye,"g"),Ee=new RegExp(t("[^]",ge,"[\\.]",'[\\"]',_e),"g"),xe=new RegExp(t("[^]",fe,we),"g"),ke=xe;function Se(e){var t=M(e);return t.match(be)?t:e}var Re={scheme:"mailto",parse:function(e,t){var r=e,a=r.to=r.path?r.path.split(","):[];if(r.path=void 0,r.query){for(var s=!1,i={},o=r.query.split("&"),n=0,l=o.length;n<l;++n){var c=o[n].split("=");switch(c[0]){case"to":for(var d=c[1].split(","),u=0,h=d.length;u<h;++u)a.push(d[u]);break;case"subject":r.subject=le(c[1],t);break;case"body":r.body=le(c[1],t);break;default:s=!0,i[le(c[0],t)]=le(c[1],t)}}s&&(r.headers=i)}r.query=void 0;for(var p=0,m=a.length;p<m;++p){var f=a[p].split("@");if(f[0]=le(f[0]),t.unicodeSupport)f[1]=le(f[1],t).toLowerCase();else try{f[1]=L.toASCII(le(f[1],t).toLowerCase())}catch(e){r.error=r.error||"Email address's domain name can not be converted to ASCII via punycode: "+e}a[p]=f.join("@")}return r},serialize:function(e,t){var r=e,a=i(e.to);if(a){for(var o=0,n=a.length;o<n;++o){var l=String(a[o]),c=l.lastIndexOf("@"),d=l.slice(0,c).replace(Pe,Se).replace(Pe,s).replace(Ee,Z),u=l.slice(c+1);try{u=t.iri?L.toUnicode(u):L.toASCII(le(u,t).toLowerCase())}catch(e){r.error=r.error||"Email address's domain name can not be converted to "+(t.iri?"Unicode":"ASCII")+" via punycode: "+e}a[o]=d+"@"+u}r.path=a.join(",")}var h=e.headers=e.headers||{};e.subject&&(h.subject=e.subject),e.body&&(h.body=e.body);var p=[];for(var m in h)h[m]!==me[m]&&p.push(m.replace(Pe,Se).replace(Pe,s).replace(xe,Z)+"="+h[m].replace(Pe,Se).replace(Pe,s).replace(ke,Z));return p.length&&(r.query=p.join("&")),r}},Oe=/^([^\:]+)\:(.*)/,Te={scheme:"urn",parse:function(e,t){var r=e.path&&e.path.match(Oe),a=e;if(r){var s=t.scheme||a.scheme||"urn",i=r[1].toLowerCase(),o=r[2],n=s+":"+(t.nid||i),l=z[n];a.nid=i,a.nss=o,a.path=void 0,l&&(a=l.parse(a,t))}else a.error=a.error||"URN can not be parsed.";return a},serialize:function(e,t){var r=t.scheme||e.scheme||"urn",a=e.nid,s=r+":"+(t.nid||a),i=z[s];i&&(e=i.serialize(e,t));var o=e,n=e.nss;return o.path=(a||t.nid)+":"+n,o}},$e=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,Ie={scheme:"urn:uuid",parse:function(e,t){var r=e;return r.uuid=r.nss,r.nss=void 0,t.tolerant||r.uuid&&r.uuid.match($e)||(r.error=r.error||"UUID is not valid."),r},serialize:function(e,t){var r=e;return r.nss=(e.uuid||"").toLowerCase(),r}};z[ce.scheme]=ce,z[de.scheme]=de,z[he.scheme]=he,z[pe.scheme]=pe,z[Re.scheme]=Re,z[Te.scheme]=Te,z[Ie.scheme]=Ie,e.SCHEMES=z,e.pctEncChar=Z,e.pctDecChars=M,e.parse=W,e.removeDotSegments=te,e.serialize=re,e.resolveComponents=ae,e.resolve=se,e.normalize=ie,e.equal=oe,e.escapeComponent=ne,e.unescapeComponent=le,Object.defineProperty(e,"__esModule",{value:!0})}(Pr.exports);var Er=Pr.exports,xr=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 a,s,i;if(Array.isArray(t)){if((a=t.length)!=r.length)return!1;for(s=a;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((a=(i=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(s=a;0!==s--;)if(!Object.prototype.hasOwnProperty.call(r,i[s]))return!1;for(s=a;0!==s--;){var o=i[s];if(!e(t[o],r[o]))return!1}return!0}return t!=t&&r!=r},kr={copy:function(e,t){for(var r in t=t||{},e)t[r]=e[r];return t},checkDataType:Sr,checkDataTypes:function(e,t,r){if(1===e.length)return Sr(e[0],t,r,!0);var a="",s=Or(e);for(var i in s.array&&s.object&&(a=s.null?"(":"(!"+t+" || ",a+="typeof "+t+' !== "object")',delete s.null,delete s.array,delete s.object),s.number&&delete s.integer,s)a+=(a?" && ":"")+Sr(i,t,r,!0);return a},coerceToTypes:function(e,t){if(Array.isArray(t)){for(var r=[],a=0;a<t.length;a++){var s=t[a];(Rr[s]||"array"===e&&"array"===s)&&(r[r.length]=s)}if(r.length)return r}else{if(Rr[t])return[t];if("array"===e&&"array"===t)return["array"]}},toHash:Or,getProperty:Ir,escapeQuotes:Cr,equal:xr,ucs2length:function(e){for(var t,r=0,a=e.length,s=0;s<a;)r++,(t=e.charCodeAt(s++))>=55296&&t<=56319&&s<a&&56320==(64512&(t=e.charCodeAt(s)))&&s++;return r},varOccurences:function(e,t){t+="[^0-9]";var r=e.match(new RegExp(t,"g"));return r?r.length:0},varReplace:function(e,t,r){return t+="([^0-9])",r=r.replace(/\$/g,"$$$$"),e.replace(new RegExp(t,"g"),r+"$1")},schemaHasRules:function(e,t){if("boolean"==typeof e)return!e;for(var r in e)if(t[r])return!0},schemaHasRulesExcept:function(e,t,r){if("boolean"==typeof e)return!e&&"not"!=r;for(var a in e)if(a!=r&&t[a])return!0},schemaUnknownRules:function(e,t){if("boolean"==typeof e)return;for(var r in e)if(!t[r])return r},toQuotedString:jr,getPathExpr:function(e,t,r,a){return Dr(e,r?"'/' + "+t+(a?"":".replace(/~/g, '~0').replace(/\\//g, '~1')"):a?"'[' + "+t+" + ']'":"'[\\'' + "+t+" + '\\']'")},getPath:function(e,t,r){var a=jr(r?"/"+Nr(t):Ir(t));return Dr(e,a)},getData:function(e,t,r){var a,s,i,o;if(""===e)return"rootData";if("/"==e[0]){if(!Fr.test(e))throw new Error("Invalid JSON-pointer: "+e);s=e,i="rootData"}else{if(!(o=e.match(Ar)))throw new Error("Invalid JSON-pointer: "+e);if(a=+o[1],"#"==(s=o[2])){if(a>=t)throw new Error("Cannot access property/index "+a+" levels up, current level is "+t);return r[t-a]}if(a>t)throw new Error("Cannot access data "+a+" levels up, current level is "+t);if(i="data"+(t-a||""),!s)return i}for(var n=i,l=s.split("/"),c=0;c<l.length;c++){var d=l[c];d&&(n+=" && "+(i+=Ir(qr(d))))}return n},unescapeFragment:function(e){return qr(decodeURIComponent(e))},unescapeJsonPointer:qr,escapeFragment:function(e){return encodeURIComponent(Nr(e))},escapeJsonPointer:Nr};function Sr(e,t,r,a){var s=a?" !== ":" === ",i=a?" || ":" && ",o=a?"!":"",n=a?"":"!";switch(e){case"null":return t+s+"null";case"array":return o+"Array.isArray("+t+")";case"object":return"("+o+t+i+"typeof "+t+s+'"object"'+i+n+"Array.isArray("+t+"))";case"integer":return"(typeof "+t+s+'"number"'+i+n+"("+t+" % 1)"+i+t+s+t+(r?i+o+"isFinite("+t+")":"")+")";case"number":return"(typeof "+t+s+'"'+e+'"'+(r?i+o+"isFinite("+t+")":"")+")";default:return"typeof "+t+s+'"'+e+'"'}}var Rr=Or(["string","number","integer","boolean","null"]);function Or(e){for(var t={},r=0;r<e.length;r++)t[e[r]]=!0;return t}var Tr=/^[a-z$_][a-z$_0-9]*$/i,$r=/'|\\/g;function Ir(e){return"number"==typeof e?"["+e+"]":Tr.test(e)?"."+e:"['"+Cr(e)+"']"}function Cr(e){return e.replace($r,"\\$&").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\f/g,"\\f").replace(/\t/g,"\\t")}function jr(e){return"'"+Cr(e)+"'"}var Fr=/^\/(?:[^~]|~0|~1)*$/,Ar=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Dr(e,t){return'""'==e?t:(e+" + "+t).replace(/([^\\])' \+ '/g,"$1")}function Nr(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function qr(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}var Lr=kr,zr=function(e){Lr.copy(e,this)};var Zr={exports:{}},Mr=Zr.exports=function(e,t,r){"function"==typeof t&&(r=t,t={}),Ur(t,"function"==typeof(r=t.cb||r)?r:r.pre||function(){},r.post||function(){},e,"",e)};function Ur(e,t,r,a,s,i,o,n,l,c){if(a&&"object"==typeof a&&!Array.isArray(a)){for(var d in t(a,s,i,o,n,l,c),a){var u=a[d];if(Array.isArray(u)){if(d in Mr.arrayKeywords)for(var h=0;h<u.length;h++)Ur(e,t,r,u[h],s+"/"+d+"/"+h,i,s,d,a,h)}else if(d in Mr.propsKeywords){if(u&&"object"==typeof u)for(var p in u)Ur(e,t,r,u[p],s+"/"+d+"/"+p.replace(/~/g,"~0").replace(/\//g,"~1"),i,s,d,a,p)}else(d in Mr.keywords||e.allKeys&&!(d in Mr.skipKeywords))&&Ur(e,t,r,u,s+"/"+d,i,s,d,a)}r(a,s,i,o,n,l,c)}}Mr.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0},Mr.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},Mr.propsKeywords={definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},Mr.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};var Vr=Zr.exports,Hr=Er,Qr=xr,Kr=kr,Br=zr,Wr=Vr,Jr=Gr;function Gr(e,t,r){var a=this._refs[r];if("string"==typeof a){if(!this._refs[a])return Gr.call(this,e,t,a);a=this._refs[a]}if((a=a||this._schemas[r])instanceof Br)return aa(a.schema,this._opts.inlineRefs)?a.schema:a.validate||this._compile(a);var s,i,o,n=Yr.call(this,t,r);return n&&(s=n.schema,t=n.root,o=n.baseId),s instanceof Br?i=s.validate||e.call(this,s.schema,t,void 0,o):void 0!==s&&(i=aa(s,this._opts.inlineRefs)?s:e.call(this,s,t,void 0,o)),i}function Yr(e,t){var r=Hr.parse(t),a=na(r),s=oa(this._getId(e.schema));if(0===Object.keys(e.schema).length||a!==s){var i=ca(a),o=this._refs[i];if("string"==typeof o)return Xr.call(this,e,o,r);if(o instanceof Br)o.validate||this._compile(o),e=o;else{if(!((o=this._schemas[i])instanceof Br))return;if(o.validate||this._compile(o),i==ca(t))return{schema:o,root:e,baseId:s};e=o}if(!e.schema)return;s=oa(this._getId(e.schema))}return ta.call(this,r,s,e.schema,e)}function Xr(e,t,r){var a=Yr.call(this,e,t);if(a){var s=a.schema,i=a.baseId;e=a.root;var o=this._getId(s);return o&&(i=da(i,o)),ta.call(this,r,i,s,e)}}Gr.normalizeId=ca,Gr.fullPath=oa,Gr.url=da,Gr.ids=function(e){var t=ca(this._getId(e)),r={"":t},a={"":oa(t,!1)},s={},i=this;return Wr(e,{allKeys:!0},(function(e,t,o,n,l,c,d){if(""!==t){var u=i._getId(e),h=r[n],p=a[n]+"/"+l;if(void 0!==d&&(p+="/"+("number"==typeof d?d:Kr.escapeFragment(d))),"string"==typeof u){u=h=ca(h?Hr.resolve(h,u):u);var m=i._refs[u];if("string"==typeof m&&(m=i._refs[m]),m&&m.schema){if(!Qr(e,m.schema))throw new Error('id "'+u+'" resolves to more than one schema')}else if(u!=ca(p))if("#"==u[0]){if(s[u]&&!Qr(e,s[u]))throw new Error('id "'+u+'" resolves to more than one schema');s[u]=e}else i._refs[u]=p}r[t]=h,a[t]=p}})),s},Gr.inlineRef=aa,Gr.schema=Yr;var ea=Kr.toHash(["properties","patternProperties","enum","dependencies","definitions"]);function ta(e,t,r,a){if(e.fragment=e.fragment||"","/"==e.fragment.slice(0,1)){for(var s=e.fragment.split("/"),i=1;i<s.length;i++){var o=s[i];if(o){if(void 0===(r=r[o=Kr.unescapeFragment(o)]))break;var n;if(!ea[o]&&((n=this._getId(r))&&(t=da(t,n)),r.$ref)){var l=da(t,r.$ref),c=Yr.call(this,a,l);c&&(r=c.schema,a=c.root,t=c.baseId)}}}return void 0!==r&&r!==a.schema?{schema:r,root:a,baseId:t}:void 0}}var ra=Kr.toHash(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum"]);function aa(e,t){return!1!==t&&(void 0===t||!0===t?sa(e):t?ia(e)<=t:void 0)}function sa(e){var t;if(Array.isArray(e)){for(var r=0;r<e.length;r++)if("object"==typeof(t=e[r])&&!sa(t))return!1}else for(var a in e){if("$ref"==a)return!1;if("object"==typeof(t=e[a])&&!sa(t))return!1}return!0}function ia(e){var t,r=0;if(Array.isArray(e)){for(var a=0;a<e.length;a++)if("object"==typeof(t=e[a])&&(r+=ia(t)),r==1/0)return 1/0}else for(var s in e){if("$ref"==s)return 1/0;if(ra[s])r++;else if("object"==typeof(t=e[s])&&(r+=ia(t)+1),r==1/0)return 1/0}return r}function oa(e,t){return!1!==t&&(e=ca(e)),na(Hr.parse(e))}function na(e){return Hr.serialize(e).split("#")[0]+"#"}var la=/#\/?$/;function ca(e){return e?e.replace(la,""):""}function da(e,t){return t=ca(t),Hr.resolve(e,t)}var ua=Jr,ha={Validation:ma((function(e){this.message="validation failed",this.errors=e,this.ajv=this.validation=!0})),MissingRef:ma(pa)};function pa(e,t,r){this.message=r||pa.message(e,t),this.missingRef=ua.url(e,t),this.missingSchema=ua.normalizeId(ua.fullPath(this.missingRef))}function ma(e){return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}pa.message=function(e,t){return"can't resolve reference "+t+" from id "+e};var fa=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var r,a="boolean"==typeof t.cycles&&t.cycles,s=t.cmp&&(r=t.cmp,function(e){return function(t,a){var s={key:t,value:e[t]},i={key:a,value:e[a]};return r(s,i)}}),i=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var r,o;if(Array.isArray(t)){for(o="[",r=0;r<t.length;r++)r&&(o+=","),o+=e(t[r])||"null";return o+"]"}if(null===t)return"null";if(-1!==i.indexOf(t)){if(a)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var n=i.push(t)-1,l=Object.keys(t).sort(s&&s(t));for(o="",r=0;r<l.length;r++){var c=l[r],d=e(t[c]);d&&(o&&(o+=","),o+=JSON.stringify(c)+":"+d)}return i.splice(n,1),"{"+o+"}"}}(e)},va=function(e,t,r){var a="",s=!0===e.schema.$async,i=e.util.schemaHasRulesExcept(e.schema,e.RULES.all,"$ref"),o=e.self._getId(e.schema);if(e.opts.strictKeywords){var n=e.util.schemaUnknownRules(e.schema,e.RULES.keywords);if(n){var l="unknown keyword: "+n;if("log"!==e.opts.strictKeywords)throw new Error(l);e.logger.warn(l)}}if(e.isTop&&(a+=" var validate = ",s&&(e.async=!0,a+="async "),a+="function(data, dataPath, parentData, parentDataProperty, rootData) { 'use strict'; ",o&&(e.opts.sourceCode||e.opts.processCode)&&(a+=" /*# sourceURL="+o+" */ ")),"boolean"==typeof e.schema||!i&&!e.schema.$ref){t="false schema";var c=e.level,d=e.dataLevel,u=e.schema[t],h=e.schemaPath+e.util.getProperty(t),p=e.errSchemaPath+"/"+t,m=!e.opts.allErrors,f="data"+(d||""),v="valid"+c;if(!1===e.schema){e.isTop?m=!0:a+=" var "+v+" = false; ",(J=J||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'false schema' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(p)+" , params: {} ",!1!==e.opts.messages&&(a+=" , message: 'boolean schema is false' "),e.opts.verbose&&(a+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+f+" "),a+=" } "):a+=" {} ";var y=a;a=J.pop(),!e.compositeRule&&m?e.async?a+=" throw new ValidationError(["+y+"]); ":a+=" validate.errors = ["+y+"]; return false; ":a+=" var err = "+y+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else e.isTop?a+=s?" return data; ":" validate.errors = null; return true; ":a+=" var "+v+" = true; ";return e.isTop&&(a+=" }; return validate; "),a}if(e.isTop){var g=e.isTop;c=e.level=0,d=e.dataLevel=0,f="data";if(e.rootId=e.resolve.fullPath(e.self._getId(e.root.schema)),e.baseId=e.baseId||e.rootId,delete e.isTop,e.dataPathArr=[""],void 0!==e.schema.default&&e.opts.useDefaults&&e.opts.strictDefaults){var _="default is ignored in the schema root";if("log"!==e.opts.strictDefaults)throw new Error(_);e.logger.warn(_)}a+=" var vErrors = null; ",a+=" var errors = 0; ",a+=" if (rootData === undefined) rootData = data; "}else{c=e.level,f="data"+((d=e.dataLevel)||"");if(o&&(e.baseId=e.resolve.url(e.baseId,o)),s&&!e.async)throw new Error("async schema in sync schema");a+=" var errs_"+c+" = errors;"}v="valid"+c,m=!e.opts.allErrors;var w="",b="",P=e.schema.type,E=Array.isArray(P);if(P&&e.opts.nullable&&!0===e.schema.nullable&&(E?-1==P.indexOf("null")&&(P=P.concat("null")):"null"!=P&&(P=[P,"null"],E=!0)),E&&1==P.length&&(P=P[0],E=!1),e.schema.$ref&&i){if("fail"==e.opts.extendRefs)throw new Error('$ref: validation keywords used in schema at path "'+e.errSchemaPath+'" (see option extendRefs)');!0!==e.opts.extendRefs&&(i=!1,e.logger.warn('$ref: keywords ignored in schema at path "'+e.errSchemaPath+'"'))}if(e.schema.$comment&&e.opts.$comment&&(a+=" "+e.RULES.all.$comment.code(e,"$comment")),P){if(e.opts.coerceTypes)var x=e.util.coerceToTypes(e.opts.coerceTypes,P);var k=e.RULES.types[P];if(x||E||!0===k||k&&!G(k)){h=e.schemaPath+".type",p=e.errSchemaPath+"/type",h=e.schemaPath+".type",p=e.errSchemaPath+"/type";var S=E?"checkDataTypes":"checkDataType";if(a+=" if ("+e.util[S](P,f,e.opts.strictNumbers,!0)+") { ",x){var R="dataType"+c,O="coerced"+c;a+=" var "+R+" = typeof "+f+"; var "+O+" = undefined; ","array"==e.opts.coerceTypes&&(a+=" if ("+R+" == 'object' && Array.isArray("+f+") && "+f+".length == 1) { "+f+" = "+f+"[0]; "+R+" = typeof "+f+"; if ("+e.util.checkDataType(e.schema.type,f,e.opts.strictNumbers)+") "+O+" = "+f+"; } "),a+=" if ("+O+" !== undefined) ; ";var T=x;if(T)for(var $,I=-1,C=T.length-1;I<C;)"string"==($=T[I+=1])?a+=" else if ("+R+" == 'number' || "+R+" == 'boolean') "+O+" = '' + "+f+"; else if ("+f+" === null) "+O+" = ''; ":"number"==$||"integer"==$?(a+=" else if ("+R+" == 'boolean' || "+f+" === null || ("+R+" == 'string' && "+f+" && "+f+" == +"+f+" ","integer"==$&&(a+=" && !("+f+" % 1)"),a+=")) "+O+" = +"+f+"; "):"boolean"==$?a+=" else if ("+f+" === 'false' || "+f+" === 0 || "+f+" === null) "+O+" = false; else if ("+f+" === 'true' || "+f+" === 1) "+O+" = true; ":"null"==$?a+=" else if ("+f+" === '' || "+f+" === 0 || "+f+" === false) "+O+" = null; ":"array"==e.opts.coerceTypes&&"array"==$&&(a+=" else if ("+R+" == 'string' || "+R+" == 'number' || "+R+" == 'boolean' || "+f+" == null) "+O+" = ["+f+"]; ");a+=" else { ",(J=J||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'type' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(p)+" , params: { type: '",a+=E?""+P.join(","):""+P,a+="' } ",!1!==e.opts.messages&&(a+=" , message: 'should be ",a+=E?""+P.join(","):""+P,a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+h+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+f+" "),a+=" } "):a+=" {} ";y=a;a=J.pop(),!e.compositeRule&&m?e.async?a+=" throw new ValidationError(["+y+"]); ":a+=" validate.errors = ["+y+"]; return false; ":a+=" var err = "+y+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } if ("+O+" !== undefined) { ";var j=d?"data"+(d-1||""):"parentData";a+=" "+f+" = "+O+"; ",d||(a+="if ("+j+" !== undefined)"),a+=" "+j+"["+(d?e.dataPathArr[d]:"parentDataProperty")+"] = "+O+"; } "}else{(J=J||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'type' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(p)+" , params: { type: '",a+=E?""+P.join(","):""+P,a+="' } ",!1!==e.opts.messages&&(a+=" , message: 'should be ",a+=E?""+P.join(","):""+P,a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+h+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+f+" "),a+=" } "):a+=" {} ";y=a;a=J.pop(),!e.compositeRule&&m?e.async?a+=" throw new ValidationError(["+y+"]); ":a+=" validate.errors = ["+y+"]; return false; ":a+=" var err = "+y+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}a+=" } "}}if(e.schema.$ref&&!i)a+=" "+e.RULES.all.$ref.code(e,"$ref")+" ",m&&(a+=" } if (errors === ",a+=g?"0":"errs_"+c,a+=") { ",b+="}");else{var F=e.RULES;if(F)for(var A=-1,D=F.length-1;A<D;)if(G(k=F[A+=1])){if(k.type&&(a+=" if ("+e.util.checkDataType(k.type,f,e.opts.strictNumbers)+") { "),e.opts.useDefaults)if("object"==k.type&&e.schema.properties){u=e.schema.properties;var N=Object.keys(u);if(N)for(var q,L=-1,z=N.length-1;L<z;){if(void 0!==(U=u[q=N[L+=1]]).default){var Z=f+e.util.getProperty(q);if(e.compositeRule){if(e.opts.strictDefaults){_="default is ignored for: "+Z;if("log"!==e.opts.strictDefaults)throw new Error(_);e.logger.warn(_)}}else a+=" if ("+Z+" === undefined ","empty"==e.opts.useDefaults&&(a+=" || "+Z+" === null || "+Z+" === '' "),a+=" ) "+Z+" = ","shared"==e.opts.useDefaults?a+=" "+e.useDefault(U.default)+" ":a+=" "+JSON.stringify(U.default)+" ",a+="; "}}}else if("array"==k.type&&Array.isArray(e.schema.items)){var M=e.schema.items;if(M){I=-1;for(var U,V=M.length-1;I<V;)if(void 0!==(U=M[I+=1]).default){Z=f+"["+I+"]";if(e.compositeRule){if(e.opts.strictDefaults){_="default is ignored for: "+Z;if("log"!==e.opts.strictDefaults)throw new Error(_);e.logger.warn(_)}}else a+=" if ("+Z+" === undefined ","empty"==e.opts.useDefaults&&(a+=" || "+Z+" === null || "+Z+" === '' "),a+=" ) "+Z+" = ","shared"==e.opts.useDefaults?a+=" "+e.useDefault(U.default)+" ":a+=" "+JSON.stringify(U.default)+" ",a+="; "}}}var H=k.rules;if(H)for(var Q,K=-1,B=H.length-1;K<B;)if(Y(Q=H[K+=1])){var W=Q.code(e,Q.keyword,k.type);W&&(a+=" "+W+" ",m&&(w+="}"))}if(m&&(a+=" "+w+" ",w=""),k.type&&(a+=" } ",P&&P===k.type&&!x)){a+=" else { ";var J;h=e.schemaPath+".type",p=e.errSchemaPath+"/type";(J=J||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'type' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(p)+" , params: { type: '",a+=E?""+P.join(","):""+P,a+="' } ",!1!==e.opts.messages&&(a+=" , message: 'should be ",a+=E?""+P.join(","):""+P,a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+h+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+f+" "),a+=" } "):a+=" {} ";y=a;a=J.pop(),!e.compositeRule&&m?e.async?a+=" throw new ValidationError(["+y+"]); ":a+=" validate.errors = ["+y+"]; return false; ":a+=" var err = "+y+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } "}m&&(a+=" if (errors === ",a+=g?"0":"errs_"+c,a+=") { ",b+="}")}}function G(e){for(var t=e.rules,r=0;r<t.length;r++)if(Y(t[r]))return!0}function Y(t){return void 0!==e.schema[t.keyword]||t.implements&&function(t){for(var r=t.implements,a=0;a<r.length;a++)if(void 0!==e.schema[r[a]])return!0}(t)}return m&&(a+=" "+b+" "),g?(s?(a+=" if (errors === 0) return data; ",a+=" else throw new ValidationError(vErrors); "):(a+=" validate.errors = vErrors; ",a+=" return errors === 0; "),a+=" }; return validate;"):a+=" var "+v+" = errors === errs_"+c+";",a},ya=Jr,ga=kr,_a=ha,wa=fa,ba=va,Pa=ga.ucs2length,Ea=xr,xa=_a.Validation,ka=function e(t,r,a,s){var i=this,o=this._opts,n=[void 0],l={},c=[],d={},u=[],h={},p=[];r=r||{schema:t,refVal:n,refs:l};var m=Sa.call(this,t,r,s),f=this._compilations[m.index];if(m.compiling)return f.callValidate=function e(){var t=f.validate,r=t.apply(this,arguments);return e.errors=t.errors,r};var v=this._formats,y=this.RULES;try{var g=w(t,r,a,s);f.validate=g;var _=f.callValidate;return _&&(_.schema=g.schema,_.errors=null,_.refs=g.refs,_.refVal=g.refVal,_.root=g.root,_.$async=g.$async,o.sourceCode&&(_.source=g.source)),g}finally{Ra.call(this,t,r,s)}function w(t,a,s,d){var h=!a||a&&a.schema==t;if(a.schema!=r.schema)return e.call(i,t,a,s,d);var m,f=!0===t.$async,g=ba({isTop:!0,schema:t,isRoot:h,baseId:d,root:a,schemaPath:"",errSchemaPath:"#",errorPath:'""',MissingRefError:_a.MissingRef,RULES:y,validate:ba,util:ga,resolve:ya,resolveRef:b,usePattern:x,useDefault:k,useCustomRule:S,opts:o,formats:v,logger:i.logger,self:i});g=ja(n,Ia)+ja(c,Ta)+ja(u,$a)+ja(p,Ca)+g,o.processCode&&(g=o.processCode(g,t));try{m=new Function("self","RULES","formats","root","refVal","defaults","customRules","equal","ucs2length","ValidationError",g)(i,y,v,r,n,u,p,Ea,Pa,xa),n[0]=m}catch(e){throw i.logger.error("Error compiling schema, function code:",g),e}return m.schema=t,m.errors=null,m.refs=l,m.refVal=n,m.root=h?m:a,f&&(m.$async=!0),!0===o.sourceCode&&(m.source={code:g,patterns:c,defaults:u}),m}function b(t,s,c){s=ya.url(t,s);var d,u,h=l[s];if(void 0!==h)return E(d=n[h],u="refVal["+h+"]");if(!c&&r.refs){var p=r.refs[s];if(void 0!==p)return E(d=r.refVal[p],u=P(s,d))}u=P(s);var m=ya.call(i,w,r,s);if(void 0===m){var f=a&&a[s];f&&(m=ya.inlineRef(f,o.inlineRefs)?f:e.call(i,f,r,a,t))}if(void 0!==m)return function(e,t){var r=l[e];n[r]=t}(s,m),E(m,u);!function(e){delete l[e]}(s)}function P(e,t){var r=n.length;return n[r]=t,l[e]=r,"refVal"+r}function E(e,t){return"object"==typeof e||"boolean"==typeof e?{code:t,schema:e,inline:!0}:{code:t,$async:e&&!!e.$async}}function x(e){var t=d[e];return void 0===t&&(t=d[e]=c.length,c[t]=e),"pattern"+t}function k(e){switch(typeof e){case"boolean":case"number":return""+e;case"string":return ga.toQuotedString(e);case"object":if(null===e)return"null";var t=wa(e),r=h[t];return void 0===r&&(r=h[t]=u.length,u[r]=e),"default"+r}}function S(e,t,r,a){if(!1!==i._opts.validateSchema){var s=e.definition.dependencies;if(s&&!s.every((function(e){return Object.prototype.hasOwnProperty.call(r,e)})))throw new Error("parent schema must have all required keywords: "+s.join(","));var n=e.definition.validateSchema;if(n)if(!n(t)){var l="keyword schema is invalid: "+i.errorsText(n.errors);if("log"!=i._opts.validateSchema)throw new Error(l);i.logger.error(l)}}var c,d=e.definition.compile,u=e.definition.inline,h=e.definition.macro;if(d)c=d.call(i,t,r,a);else if(h)c=h.call(i,t,r,a),!1!==o.validateSchema&&i.validateSchema(c,!0);else if(u)c=u.call(i,a,e.keyword,t,r);else if(!(c=e.definition.validate))return;if(void 0===c)throw new Error('custom keyword "'+e.keyword+'"failed to compile');var m=p.length;return p[m]=c,{code:"customRule"+m,validate:c}}};function Sa(e,t,r){var a=Oa.call(this,e,t,r);return a>=0?{index:a,compiling:!0}:(a=this._compilations.length,this._compilations[a]={schema:e,root:t,baseId:r},{index:a,compiling:!1})}function Ra(e,t,r){var a=Oa.call(this,e,t,r);a>=0&&this._compilations.splice(a,1)}function Oa(e,t,r){for(var a=0;a<this._compilations.length;a++){var s=this._compilations[a];if(s.schema==e&&s.root==t&&s.baseId==r)return a}return-1}function Ta(e,t){return"var pattern"+e+" = new RegExp("+ga.toQuotedString(t[e])+");"}function $a(e){return"var default"+e+" = defaults["+e+"];"}function Ia(e,t){return void 0===t[e]?"":"var refVal"+e+" = refVal["+e+"];"}function Ca(e){return"var customRule"+e+" = customRules["+e+"];"}function ja(e,t){if(!e.length)return"";for(var r="",a=0;a<e.length;a++)r+=t(a,e);return r}var Fa={exports:{}},Aa=Fa.exports=function(){this._cache={}};Aa.prototype.put=function(e,t){this._cache[e]=t},Aa.prototype.get=function(e){return this._cache[e]},Aa.prototype.del=function(e){delete this._cache[e]},Aa.prototype.clear=function(){this._cache={}};var Da=Fa.exports,Na=kr,qa=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,La=[0,31,28,31,30,31,30,31,31,30,31,30,31],za=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,Za=/^(?=.{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,Ma=/^(?:[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,Ua=/^(?:(?:[^\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,Va=/^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,Ha=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Qa=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Ka=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Ba=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Wa=Ja;function Ja(e){return e="full"==e?"full":"fast",Na.copy(Ja[e])}function Ga(e){var t=e.match(qa);if(!t)return!1;var r=+t[1],a=+t[2],s=+t[3];return a>=1&&a<=12&&s>=1&&s<=(2==a&&function(e){return e%4==0&&(e%100!=0||e%400==0)}(r)?29:La[a])}function Ya(e,t){var r=e.match(za);if(!r)return!1;var a=r[1],s=r[2],i=r[3],o=r[5];return(a<=23&&s<=59&&i<=59||23==a&&59==s&&60==i)&&(!t||o)}Ja.fast={date:/^\d\d\d\d-[0-1]\d-[0-3]\d$/,time:/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,"date-time":/^\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,uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,"uri-template":Ua,url:Va,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,hostname:Za,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[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}))|:)))(?:%.+)?\s*$/i,regex:rs,uuid:Ha,"json-pointer":Qa,"json-pointer-uri-fragment":Ka,"relative-json-pointer":Ba},Ja.full={date:Ga,time:Ya,"date-time":function(e){var t=e.split(Xa);return 2==t.length&&Ga(t[0])&&Ya(t[1],!0)},uri:function(e){return es.test(e)&&Ma.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":Ua,url:Va,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:Za,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[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}))|:)))(?:%.+)?\s*$/i,regex:rs,uuid:Ha,"json-pointer":Qa,"json-pointer-uri-fragment":Ka,"relative-json-pointer":Ba};var Xa=/t|\s/i;var es=/\/|:/;var ts=/[^\\]\\Z/;function rs(e){if(ts.test(e))return!1;try{return new RegExp(e),!0}catch(e){return!1}}var as=function(e,t,r){var a,s=" ",i=e.level,o=e.dataLevel,n=e.schema[t],l=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,u="data"+(o||""),h=e.opts.$data&&n&&n.$data;h?(s+=" var schema"+i+" = "+e.util.getData(n.$data,o,e.dataPathArr)+"; ",a="schema"+i):a=n;var p="maximum"==t,m=p?"exclusiveMaximum":"exclusiveMinimum",f=e.schema[m],v=e.opts.$data&&f&&f.$data,y=p?"<":">",g=p?">":"<",_=void 0;if(!h&&"number"!=typeof n&&void 0!==n)throw new Error(t+" must be number");if(!v&&void 0!==f&&"number"!=typeof f&&"boolean"!=typeof f)throw new Error(m+" must be number or boolean");if(v){var w=e.util.getData(f.$data,o,e.dataPathArr),b="exclusive"+i,P="exclType"+i,E="exclIsNumber"+i,x="' + "+(R="op"+i)+" + '";s+=" var schemaExcl"+i+" = "+w+"; ",s+=" var "+b+"; var "+P+" = typeof "+(w="schemaExcl"+i)+"; if ("+P+" != 'boolean' && "+P+" != 'undefined' && "+P+" != 'number') { ";var k;_=m;(k=k||[]).push(s),s="",!1!==e.createErrors?(s+=" { keyword: '"+(_||"_exclusiveLimit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: {} ",!1!==e.opts.messages&&(s+=" , message: '"+m+" should be boolean' "),e.opts.verbose&&(s+=" , schema: validate.schema"+l+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var S=s;s=k.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } else if ( ",h&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),s+=" "+P+" == 'number' ? ( ("+b+" = "+a+" === undefined || "+w+" "+y+"= "+a+") ? "+u+" "+g+"= "+w+" : "+u+" "+g+" "+a+" ) : ( ("+b+" = "+w+" === true) ? "+u+" "+g+"= "+a+" : "+u+" "+g+" "+a+" ) || "+u+" !== "+u+") { var op"+i+" = "+b+" ? '"+y+"' : '"+y+"='; ",void 0===n&&(_=m,c=e.errSchemaPath+"/"+m,a=w,h=v)}else{x=y;if((E="number"==typeof f)&&h){var R="'"+x+"'";s+=" if ( ",h&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),s+=" ( "+a+" === undefined || "+f+" "+y+"= "+a+" ? "+u+" "+g+"= "+f+" : "+u+" "+g+" "+a+" ) || "+u+" !== "+u+") { "}else{E&&void 0===n?(b=!0,_=m,c=e.errSchemaPath+"/"+m,a=f,g+="="):(E&&(a=Math[p?"min":"max"](f,n)),f===(!E||a)?(b=!0,_=m,c=e.errSchemaPath+"/"+m,g+="="):(b=!1,x+="="));R="'"+x+"'";s+=" if ( ",h&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),s+=" "+u+" "+g+" "+a+" || "+u+" !== "+u+") { "}}_=_||t,(k=k||[]).push(s),s="",!1!==e.createErrors?(s+=" { keyword: '"+(_||"_limit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { comparison: "+R+", limit: "+a+", exclusive: "+b+" } ",!1!==e.opts.messages&&(s+=" , message: 'should be "+x+" ",s+=h?"' + "+a:a+"'"),e.opts.verbose&&(s+=" , schema: ",s+=h?"validate.schema"+l:""+n,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";S=s;return s=k.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } ",d&&(s+=" else { "),s},ss=function(e,t,r){var a,s=" ",i=e.level,o=e.dataLevel,n=e.schema[t],l=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,u="data"+(o||""),h=e.opts.$data&&n&&n.$data;if(h?(s+=" var schema"+i+" = "+e.util.getData(n.$data,o,e.dataPathArr)+"; ",a="schema"+i):a=n,!h&&"number"!=typeof n)throw new Error(t+" must be number");s+="if ( ",h&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),s+=" "+u+".length "+("maxItems"==t?">":"<")+" "+a+") { ";var p=t,m=m||[];m.push(s),s="",!1!==e.createErrors?(s+=" { keyword: '"+(p||"_limitItems")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { limit: "+a+" } ",!1!==e.opts.messages&&(s+=" , message: 'should NOT have ",s+="maxItems"==t?"more":"fewer",s+=" than ",s+=h?"' + "+a+" + '":""+n,s+=" items' "),e.opts.verbose&&(s+=" , schema: ",s+=h?"validate.schema"+l:""+n,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var f=s;return s=m.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+f+"]); ":s+=" validate.errors = ["+f+"]; return false; ":s+=" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",d&&(s+=" else { "),s},is=function(e,t,r){var a,s=" ",i=e.level,o=e.dataLevel,n=e.schema[t],l=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,u="data"+(o||""),h=e.opts.$data&&n&&n.$data;if(h?(s+=" var schema"+i+" = "+e.util.getData(n.$data,o,e.dataPathArr)+"; ",a="schema"+i):a=n,!h&&"number"!=typeof n)throw new Error(t+" must be number");var p="maxLength"==t?">":"<";s+="if ( ",h&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),!1===e.opts.unicode?s+=" "+u+".length ":s+=" ucs2length("+u+") ",s+=" "+p+" "+a+") { ";var m=t,f=f||[];f.push(s),s="",!1!==e.createErrors?(s+=" { keyword: '"+(m||"_limitLength")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { limit: "+a+" } ",!1!==e.opts.messages&&(s+=" , message: 'should NOT be ",s+="maxLength"==t?"longer":"shorter",s+=" than ",s+=h?"' + "+a+" + '":""+n,s+=" characters' "),e.opts.verbose&&(s+=" , schema: ",s+=h?"validate.schema"+l:""+n,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var v=s;return s=f.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+v+"]); ":s+=" validate.errors = ["+v+"]; return false; ":s+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",d&&(s+=" else { "),s},os=function(e,t,r){var a,s=" ",i=e.level,o=e.dataLevel,n=e.schema[t],l=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,u="data"+(o||""),h=e.opts.$data&&n&&n.$data;if(h?(s+=" var schema"+i+" = "+e.util.getData(n.$data,o,e.dataPathArr)+"; ",a="schema"+i):a=n,!h&&"number"!=typeof n)throw new Error(t+" must be number");s+="if ( ",h&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),s+=" Object.keys("+u+").length "+("maxProperties"==t?">":"<")+" "+a+") { ";var p=t,m=m||[];m.push(s),s="",!1!==e.createErrors?(s+=" { keyword: '"+(p||"_limitProperties")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { limit: "+a+" } ",!1!==e.opts.messages&&(s+=" , message: 'should NOT have ",s+="maxProperties"==t?"more":"fewer",s+=" than ",s+=h?"' + "+a+" + '":""+n,s+=" properties' "),e.opts.verbose&&(s+=" , schema: ",s+=h?"validate.schema"+l:""+n,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var f=s;return s=m.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+f+"]); ":s+=" validate.errors = ["+f+"]; return false; ":s+=" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",d&&(s+=" else { "),s},ns={$ref:function(e,t,r){var a,s,i=" ",o=e.level,n=e.dataLevel,l=e.schema[t],c=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,u="data"+(n||""),h="valid"+o;if("#"==l||"#/"==l)e.isRoot?(a=e.async,s="validate"):(a=!0===e.root.schema.$async,s="root.refVal[0]");else{var p=e.resolveRef(e.baseId,l,e.isRoot);if(void 0===p){var m=e.MissingRefError.message(e.baseId,l);if("fail"==e.opts.missingRefs){e.logger.error(m),(g=g||[]).push(i),i="",!1!==e.createErrors?(i+=" { keyword: '$ref' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { ref: '"+e.util.escapeQuotes(l)+"' } ",!1!==e.opts.messages&&(i+=" , message: 'can\\'t resolve reference "+e.util.escapeQuotes(l)+"' "),e.opts.verbose&&(i+=" , schema: "+e.util.toQuotedString(l)+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),i+=" } "):i+=" {} ";var f=i;i=g.pop(),!e.compositeRule&&d?e.async?i+=" throw new ValidationError(["+f+"]); ":i+=" validate.errors = ["+f+"]; return false; ":i+=" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",d&&(i+=" if (false) { ")}else{if("ignore"!=e.opts.missingRefs)throw new e.MissingRefError(e.baseId,l,m);e.logger.warn(m),d&&(i+=" if (true) { ")}}else if(p.inline){var v=e.util.copy(e);v.level++;var y="valid"+v.level;v.schema=p.schema,v.schemaPath="",v.errSchemaPath=l,i+=" "+e.validate(v).replace(/validate\.schema/g,p.code)+" ",d&&(i+=" if ("+y+") { ")}else a=!0===p.$async||e.async&&!1!==p.$async,s=p.code}if(s){var g;(g=g||[]).push(i),i="",e.opts.passContext?i+=" "+s+".call(this, ":i+=" "+s+"( ",i+=" "+u+", (dataPath || '')",'""'!=e.errorPath&&(i+=" + "+e.errorPath);var _=i+=" , "+(n?"data"+(n-1||""):"parentData")+" , "+(n?e.dataPathArr[n]:"parentDataProperty")+", rootData) ";if(i=g.pop(),a){if(!e.async)throw new Error("async schema referenced by sync schema");d&&(i+=" var "+h+"; "),i+=" try { await "+_+"; ",d&&(i+=" "+h+" = true; "),i+=" } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ",d&&(i+=" "+h+" = false; "),i+=" } ",d&&(i+=" if ("+h+") { ")}else i+=" if (!"+_+") { if (vErrors === null) vErrors = "+s+".errors; else vErrors = vErrors.concat("+s+".errors); errors = vErrors.length; } ",d&&(i+=" else { ")}return i},allOf:function(e,t,r){var a=" ",s=e.schema[t],i=e.schemaPath+e.util.getProperty(t),o=e.errSchemaPath+"/"+t,n=!e.opts.allErrors,l=e.util.copy(e),c="";l.level++;var d="valid"+l.level,u=l.baseId,h=!0,p=s;if(p)for(var m,f=-1,v=p.length-1;f<v;)m=p[f+=1],(e.opts.strictKeywords?"object"==typeof m&&Object.keys(m).length>0||!1===m:e.util.schemaHasRules(m,e.RULES.all))&&(h=!1,l.schema=m,l.schemaPath=i+"["+f+"]",l.errSchemaPath=o+"/"+f,a+=" "+e.validate(l)+" ",l.baseId=u,n&&(a+=" if ("+d+") { ",c+="}"));return n&&(a+=h?" if (true) { ":" "+c.slice(0,-1)+" "),a},anyOf:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="valid"+s,h="errs__"+s,p=e.util.copy(e),m="";p.level++;var f="valid"+p.level,v=o.every((function(t){return e.opts.strictKeywords?"object"==typeof t&&Object.keys(t).length>0||!1===t:e.util.schemaHasRules(t,e.RULES.all)}));if(v){var y=p.baseId;a+=" var "+h+" = errors; var "+u+" = false; ";var g=e.compositeRule;e.compositeRule=p.compositeRule=!0;var _=o;if(_)for(var w,b=-1,P=_.length-1;b<P;)w=_[b+=1],p.schema=w,p.schemaPath=n+"["+b+"]",p.errSchemaPath=l+"/"+b,a+=" "+e.validate(p)+" ",p.baseId=y,a+=" "+u+" = "+u+" || "+f+"; if (!"+u+") { ",m+="}";e.compositeRule=p.compositeRule=g,a+=" "+m+" if (!"+u+") { var err = ",!1!==e.createErrors?(a+=" { keyword: 'anyOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: {} ",!1!==e.opts.messages&&(a+=" , message: 'should match some schema in anyOf' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&c&&(e.async?a+=" throw new ValidationError(vErrors); ":a+=" validate.errors = vErrors; return false; "),a+=" } else { errors = "+h+"; if (vErrors !== null) { if ("+h+") vErrors.length = "+h+"; else vErrors = null; } ",e.opts.allErrors&&(a+=" } ")}else c&&(a+=" if (true) { ");return a},$comment:function(e,t,r){var a=" ",s=e.schema[t],i=e.errSchemaPath+"/"+t;e.opts.allErrors;var o=e.util.toQuotedString(s);return!0===e.opts.$comment?a+=" console.log("+o+");":"function"==typeof e.opts.$comment&&(a+=" self._opts.$comment("+o+", "+e.util.toQuotedString(i)+", validate.root.schema);"),a},const:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="valid"+s,h=e.opts.$data&&o&&o.$data;h&&(a+=" var schema"+s+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; "),h||(a+=" var schema"+s+" = validate.schema"+n+";"),a+="var "+u+" = equal("+d+", schema"+s+"); if (!"+u+") { ";var p=p||[];p.push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'const' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { allowedValue: schema"+s+" } ",!1!==e.opts.messages&&(a+=" , message: 'should be equal to constant' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var m=a;return a=p.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+m+"]); ":a+=" validate.errors = ["+m+"]; return false; ":a+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" }",c&&(a+=" else { "),a},contains:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="valid"+s,h="errs__"+s,p=e.util.copy(e);p.level++;var m="valid"+p.level,f="i"+s,v=p.dataLevel=e.dataLevel+1,y="data"+v,g=e.baseId,_=e.opts.strictKeywords?"object"==typeof o&&Object.keys(o).length>0||!1===o:e.util.schemaHasRules(o,e.RULES.all);if(a+="var "+h+" = errors;var "+u+";",_){var w=e.compositeRule;e.compositeRule=p.compositeRule=!0,p.schema=o,p.schemaPath=n,p.errSchemaPath=l,a+=" var "+m+" = false; for (var "+f+" = 0; "+f+" < "+d+".length; "+f+"++) { ",p.errorPath=e.util.getPathExpr(e.errorPath,f,e.opts.jsonPointers,!0);var b=d+"["+f+"]";p.dataPathArr[v]=f;var P=e.validate(p);p.baseId=g,e.util.varOccurences(P,y)<2?a+=" "+e.util.varReplace(P,y,b)+" ":a+=" var "+y+" = "+b+"; "+P+" ",a+=" if ("+m+") break; } ",e.compositeRule=p.compositeRule=w,a+=" if (!"+m+") {"}else a+=" if ("+d+".length == 0) {";var E=E||[];E.push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'contains' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: {} ",!1!==e.opts.messages&&(a+=" , message: 'should contain a valid item' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var x=a;return a=E.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+x+"]); ":a+=" validate.errors = ["+x+"]; return false; ":a+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } else { ",_&&(a+=" errors = "+h+"; if (vErrors !== null) { if ("+h+") vErrors.length = "+h+"; else vErrors = null; } "),e.opts.allErrors&&(a+=" } "),a},dependencies:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="errs__"+s,h=e.util.copy(e),p="";h.level++;var m="valid"+h.level,f={},v={},y=e.opts.ownProperties;for(b in o)if("__proto__"!=b){var g=o[b],_=Array.isArray(g)?v:f;_[b]=g}a+="var "+u+" = errors;";var w=e.errorPath;for(var b in a+="var missing"+s+";",v)if((_=v[b]).length){if(a+=" if ( "+d+e.util.getProperty(b)+" !== undefined ",y&&(a+=" && Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(b)+"') "),c){a+=" && ( ";var P=_;if(P)for(var E=-1,x=P.length-1;E<x;){$=P[E+=1],E&&(a+=" || "),a+=" ( ( "+(F=d+(j=e.util.getProperty($)))+" === undefined ",y&&(a+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes($)+"') "),a+=") && (missing"+s+" = "+e.util.toQuotedString(e.opts.jsonPointers?$:j)+") ) "}a+=")) { ";var k="missing"+s,S="' + "+k+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(w,k,!0):w+" + "+k);var R=R||[];R.push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { property: '"+e.util.escapeQuotes(b)+"', missingProperty: '"+S+"', depsCount: "+_.length+", deps: '"+e.util.escapeQuotes(1==_.length?_[0]:_.join(", "))+"' } ",!1!==e.opts.messages&&(a+=" , message: 'should have ",1==_.length?a+="property "+e.util.escapeQuotes(_[0]):a+="properties "+e.util.escapeQuotes(_.join(", ")),a+=" when property "+e.util.escapeQuotes(b)+" is present' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var O=a;a=R.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+O+"]); ":a+=" validate.errors = ["+O+"]; return false; ":a+=" var err = "+O+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else{a+=" ) { ";var T=_;if(T)for(var $,I=-1,C=T.length-1;I<C;){$=T[I+=1];var j=e.util.getProperty($),F=(S=e.util.escapeQuotes($),d+j);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(w,$,e.opts.jsonPointers)),a+=" if ( "+F+" === undefined ",y&&(a+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes($)+"') "),a+=") { var err = ",!1!==e.createErrors?(a+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { property: '"+e.util.escapeQuotes(b)+"', missingProperty: '"+S+"', depsCount: "+_.length+", deps: '"+e.util.escapeQuotes(1==_.length?_[0]:_.join(", "))+"' } ",!1!==e.opts.messages&&(a+=" , message: 'should have ",1==_.length?a+="property "+e.util.escapeQuotes(_[0]):a+="properties "+e.util.escapeQuotes(_.join(", ")),a+=" when property "+e.util.escapeQuotes(b)+" is present' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}a+=" } ",c&&(p+="}",a+=" else { ")}e.errorPath=w;var A=h.baseId;for(var b in f){g=f[b];(e.opts.strictKeywords?"object"==typeof g&&Object.keys(g).length>0||!1===g:e.util.schemaHasRules(g,e.RULES.all))&&(a+=" "+m+" = true; if ( "+d+e.util.getProperty(b)+" !== undefined ",y&&(a+=" && Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(b)+"') "),a+=") { ",h.schema=g,h.schemaPath=n+e.util.getProperty(b),h.errSchemaPath=l+"/"+e.util.escapeFragment(b),a+=" "+e.validate(h)+" ",h.baseId=A,a+=" } ",c&&(a+=" if ("+m+") { ",p+="}"))}return c&&(a+=" "+p+" if ("+u+" == errors) {"),a},enum:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="valid"+s,h=e.opts.$data&&o&&o.$data;h&&(a+=" var schema"+s+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ");var p="i"+s,m="schema"+s;h||(a+=" var "+m+" = validate.schema"+n+";"),a+="var "+u+";",h&&(a+=" if (schema"+s+" === undefined) "+u+" = true; else if (!Array.isArray(schema"+s+")) "+u+" = false; else {"),a+=u+" = false;for (var "+p+"=0; "+p+"<"+m+".length; "+p+"++) if (equal("+d+", "+m+"["+p+"])) { "+u+" = true; break; }",h&&(a+=" } "),a+=" if (!"+u+") { ";var f=f||[];f.push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'enum' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { allowedValues: schema"+s+" } ",!1!==e.opts.messages&&(a+=" , message: 'should be equal to one of the allowed values' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var v=a;return a=f.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+v+"]); ":a+=" validate.errors = ["+v+"]; return false; ":a+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" }",c&&(a+=" else { "),a},format:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||"");if(!1===e.opts.format)return c&&(a+=" if (true) { "),a;var u,h=e.opts.$data&&o&&o.$data;h?(a+=" var schema"+s+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",u="schema"+s):u=o;var p=e.opts.unknownFormats,m=Array.isArray(p);if(h){a+=" var "+(f="format"+s)+" = formats["+u+"]; var "+(v="isObject"+s)+" = typeof "+f+" == 'object' && !("+f+" instanceof RegExp) && "+f+".validate; var "+(y="formatType"+s)+" = "+v+" && "+f+".type || 'string'; if ("+v+") { ",e.async&&(a+=" var async"+s+" = "+f+".async; "),a+=" "+f+" = "+f+".validate; } if ( ",h&&(a+=" ("+u+" !== undefined && typeof "+u+" != 'string') || "),a+=" (","ignore"!=p&&(a+=" ("+u+" && !"+f+" ",m&&(a+=" && self._opts.unknownFormats.indexOf("+u+") == -1 "),a+=") || "),a+=" ("+f+" && "+y+" == '"+r+"' && !(typeof "+f+" == 'function' ? ",e.async?a+=" (async"+s+" ? await "+f+"("+d+") : "+f+"("+d+")) ":a+=" "+f+"("+d+") ",a+=" : "+f+".test("+d+"))))) {"}else{var f;if(!(f=e.formats[o])){if("ignore"==p)return e.logger.warn('unknown format "'+o+'" ignored in schema at path "'+e.errSchemaPath+'"'),c&&(a+=" if (true) { "),a;if(m&&p.indexOf(o)>=0)return c&&(a+=" if (true) { "),a;throw new Error('unknown format "'+o+'" is used in schema at path "'+e.errSchemaPath+'"')}var v,y=(v="object"==typeof f&&!(f instanceof RegExp)&&f.validate)&&f.type||"string";if(v){var g=!0===f.async;f=f.validate}if(y!=r)return c&&(a+=" if (true) { "),a;if(g){if(!e.async)throw new Error("async format in sync schema");a+=" if (!(await "+(_="formats"+e.util.getProperty(o)+".validate")+"("+d+"))) { "}else{a+=" if (! ";var _="formats"+e.util.getProperty(o);v&&(_+=".validate"),a+="function"==typeof f?" "+_+"("+d+") ":" "+_+".test("+d+") ",a+=") { "}}var w=w||[];w.push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'format' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { format: ",a+=h?""+u:""+e.util.toQuotedString(o),a+=" } ",!1!==e.opts.messages&&(a+=" , message: 'should match format \"",a+=h?"' + "+u+" + '":""+e.util.escapeQuotes(o),a+="\"' "),e.opts.verbose&&(a+=" , schema: ",a+=h?"validate.schema"+n:""+e.util.toQuotedString(o),a+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var b=a;return a=w.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+b+"]); ":a+=" validate.errors = ["+b+"]; return false; ":a+=" var err = "+b+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } ",c&&(a+=" else { "),a},if:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="valid"+s,h="errs__"+s,p=e.util.copy(e);p.level++;var m="valid"+p.level,f=e.schema.then,v=e.schema.else,y=void 0!==f&&(e.opts.strictKeywords?"object"==typeof f&&Object.keys(f).length>0||!1===f:e.util.schemaHasRules(f,e.RULES.all)),g=void 0!==v&&(e.opts.strictKeywords?"object"==typeof v&&Object.keys(v).length>0||!1===v:e.util.schemaHasRules(v,e.RULES.all)),_=p.baseId;if(y||g){var w;p.createErrors=!1,p.schema=o,p.schemaPath=n,p.errSchemaPath=l,a+=" var "+h+" = errors; var "+u+" = true; ";var b=e.compositeRule;e.compositeRule=p.compositeRule=!0,a+=" "+e.validate(p)+" ",p.baseId=_,p.createErrors=!0,a+=" errors = "+h+"; if (vErrors !== null) { if ("+h+") vErrors.length = "+h+"; else vErrors = null; } ",e.compositeRule=p.compositeRule=b,y?(a+=" if ("+m+") { ",p.schema=e.schema.then,p.schemaPath=e.schemaPath+".then",p.errSchemaPath=e.errSchemaPath+"/then",a+=" "+e.validate(p)+" ",p.baseId=_,a+=" "+u+" = "+m+"; ",y&&g?a+=" var "+(w="ifClause"+s)+" = 'then'; ":w="'then'",a+=" } ",g&&(a+=" else { ")):a+=" if (!"+m+") { ",g&&(p.schema=e.schema.else,p.schemaPath=e.schemaPath+".else",p.errSchemaPath=e.errSchemaPath+"/else",a+=" "+e.validate(p)+" ",p.baseId=_,a+=" "+u+" = "+m+"; ",y&&g?a+=" var "+(w="ifClause"+s)+" = 'else'; ":w="'else'",a+=" } "),a+=" if (!"+u+") { var err = ",!1!==e.createErrors?(a+=" { keyword: 'if' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { failingKeyword: "+w+" } ",!1!==e.opts.messages&&(a+=" , message: 'should match \"' + "+w+" + '\" schema' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&c&&(e.async?a+=" throw new ValidationError(vErrors); ":a+=" validate.errors = vErrors; return false; "),a+=" } ",c&&(a+=" else { ")}else c&&(a+=" if (true) { ");return a},items:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="valid"+s,h="errs__"+s,p=e.util.copy(e),m="";p.level++;var f="valid"+p.level,v="i"+s,y=p.dataLevel=e.dataLevel+1,g="data"+y,_=e.baseId;if(a+="var "+h+" = errors;var "+u+";",Array.isArray(o)){var w=e.schema.additionalItems;if(!1===w){a+=" "+u+" = "+d+".length <= "+o.length+"; ";var b=l;l=e.errSchemaPath+"/additionalItems",a+=" if (!"+u+") { ";var P=P||[];P.push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'additionalItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { limit: "+o.length+" } ",!1!==e.opts.messages&&(a+=" , message: 'should NOT have more than "+o.length+" items' "),e.opts.verbose&&(a+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var E=a;a=P.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+E+"]); ":a+=" validate.errors = ["+E+"]; return false; ":a+=" var err = "+E+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } ",l=b,c&&(m+="}",a+=" else { ")}var x=o;if(x)for(var k,S=-1,R=x.length-1;S<R;)if(k=x[S+=1],e.opts.strictKeywords?"object"==typeof k&&Object.keys(k).length>0||!1===k:e.util.schemaHasRules(k,e.RULES.all)){a+=" "+f+" = true; if ("+d+".length > "+S+") { ";var O=d+"["+S+"]";p.schema=k,p.schemaPath=n+"["+S+"]",p.errSchemaPath=l+"/"+S,p.errorPath=e.util.getPathExpr(e.errorPath,S,e.opts.jsonPointers,!0),p.dataPathArr[y]=S;var T=e.validate(p);p.baseId=_,e.util.varOccurences(T,g)<2?a+=" "+e.util.varReplace(T,g,O)+" ":a+=" var "+g+" = "+O+"; "+T+" ",a+=" } ",c&&(a+=" if ("+f+") { ",m+="}")}if("object"==typeof w&&(e.opts.strictKeywords?"object"==typeof w&&Object.keys(w).length>0||!1===w:e.util.schemaHasRules(w,e.RULES.all))){p.schema=w,p.schemaPath=e.schemaPath+".additionalItems",p.errSchemaPath=e.errSchemaPath+"/additionalItems",a+=" "+f+" = true; if ("+d+".length > "+o.length+") { for (var "+v+" = "+o.length+"; "+v+" < "+d+".length; "+v+"++) { ",p.errorPath=e.util.getPathExpr(e.errorPath,v,e.opts.jsonPointers,!0);O=d+"["+v+"]";p.dataPathArr[y]=v;T=e.validate(p);p.baseId=_,e.util.varOccurences(T,g)<2?a+=" "+e.util.varReplace(T,g,O)+" ":a+=" var "+g+" = "+O+"; "+T+" ",c&&(a+=" if (!"+f+") break; "),a+=" } } ",c&&(a+=" if ("+f+") { ",m+="}")}}else if(e.opts.strictKeywords?"object"==typeof o&&Object.keys(o).length>0||!1===o:e.util.schemaHasRules(o,e.RULES.all)){p.schema=o,p.schemaPath=n,p.errSchemaPath=l,a+=" for (var "+v+" = 0; "+v+" < "+d+".length; "+v+"++) { ",p.errorPath=e.util.getPathExpr(e.errorPath,v,e.opts.jsonPointers,!0);O=d+"["+v+"]";p.dataPathArr[y]=v;T=e.validate(p);p.baseId=_,e.util.varOccurences(T,g)<2?a+=" "+e.util.varReplace(T,g,O)+" ":a+=" var "+g+" = "+O+"; "+T+" ",c&&(a+=" if (!"+f+") break; "),a+=" }"}return c&&(a+=" "+m+" if ("+h+" == errors) {"),a},maximum:as,minimum:as,maxItems:ss,minItems:ss,maxLength:is,minLength:is,maxProperties:os,minProperties:os,multipleOf:function(e,t,r){var a,s=" ",i=e.level,o=e.dataLevel,n=e.schema[t],l=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,u="data"+(o||""),h=e.opts.$data&&n&&n.$data;if(h?(s+=" var schema"+i+" = "+e.util.getData(n.$data,o,e.dataPathArr)+"; ",a="schema"+i):a=n,!h&&"number"!=typeof n)throw new Error(t+" must be number");s+="var division"+i+";if (",h&&(s+=" "+a+" !== undefined && ( typeof "+a+" != 'number' || "),s+=" (division"+i+" = "+u+" / "+a+", ",e.opts.multipleOfPrecision?s+=" Math.abs(Math.round(division"+i+") - division"+i+") > 1e-"+e.opts.multipleOfPrecision+" ":s+=" division"+i+" !== parseInt(division"+i+") ",s+=" ) ",h&&(s+=" ) "),s+=" ) { ";var p=p||[];p.push(s),s="",!1!==e.createErrors?(s+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { multipleOf: "+a+" } ",!1!==e.opts.messages&&(s+=" , message: 'should be multiple of ",s+=h?"' + "+a:a+"'"),e.opts.verbose&&(s+=" , schema: ",s+=h?"validate.schema"+l:""+n,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var m=s;return s=p.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+m+"]); ":s+=" validate.errors = ["+m+"]; return false; ":s+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",d&&(s+=" else { "),s},not:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="errs__"+s,h=e.util.copy(e);h.level++;var p="valid"+h.level;if(e.opts.strictKeywords?"object"==typeof o&&Object.keys(o).length>0||!1===o:e.util.schemaHasRules(o,e.RULES.all)){h.schema=o,h.schemaPath=n,h.errSchemaPath=l,a+=" var "+u+" = errors; ";var m,f=e.compositeRule;e.compositeRule=h.compositeRule=!0,h.createErrors=!1,h.opts.allErrors&&(m=h.opts.allErrors,h.opts.allErrors=!1),a+=" "+e.validate(h)+" ",h.createErrors=!0,m&&(h.opts.allErrors=m),e.compositeRule=h.compositeRule=f,a+=" if ("+p+") { ";var v=v||[];v.push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: {} ",!1!==e.opts.messages&&(a+=" , message: 'should NOT be valid' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var y=a;a=v.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+y+"]); ":a+=" validate.errors = ["+y+"]; return false; ":a+=" var err = "+y+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } else { errors = "+u+"; if (vErrors !== null) { if ("+u+") vErrors.length = "+u+"; else vErrors = null; } ",e.opts.allErrors&&(a+=" } ")}else a+=" var err = ",!1!==e.createErrors?(a+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: {} ",!1!==e.opts.messages&&(a+=" , message: 'should NOT be valid' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",c&&(a+=" if (false) { ");return a},oneOf:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="valid"+s,h="errs__"+s,p=e.util.copy(e),m="";p.level++;var f="valid"+p.level,v=p.baseId,y="prevValid"+s,g="passingSchemas"+s;a+="var "+h+" = errors , "+y+" = false , "+u+" = false , "+g+" = null; ";var _=e.compositeRule;e.compositeRule=p.compositeRule=!0;var w=o;if(w)for(var b,P=-1,E=w.length-1;P<E;)b=w[P+=1],(e.opts.strictKeywords?"object"==typeof b&&Object.keys(b).length>0||!1===b:e.util.schemaHasRules(b,e.RULES.all))?(p.schema=b,p.schemaPath=n+"["+P+"]",p.errSchemaPath=l+"/"+P,a+=" "+e.validate(p)+" ",p.baseId=v):a+=" var "+f+" = true; ",P&&(a+=" if ("+f+" && "+y+") { "+u+" = false; "+g+" = ["+g+", "+P+"]; } else { ",m+="}"),a+=" if ("+f+") { "+u+" = "+y+" = true; "+g+" = "+P+"; }";return e.compositeRule=p.compositeRule=_,a+=m+"if (!"+u+") { var err = ",!1!==e.createErrors?(a+=" { keyword: 'oneOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { passingSchemas: "+g+" } ",!1!==e.opts.messages&&(a+=" , message: 'should match exactly one schema in oneOf' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&c&&(e.async?a+=" throw new ValidationError(vErrors); ":a+=" validate.errors = vErrors; return false; "),a+="} else { errors = "+h+"; if (vErrors !== null) { if ("+h+") vErrors.length = "+h+"; else vErrors = null; }",e.opts.allErrors&&(a+=" } "),a},pattern:function(e,t,r){var a,s=" ",i=e.level,o=e.dataLevel,n=e.schema[t],l=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,u="data"+(o||""),h=e.opts.$data&&n&&n.$data;h?(s+=" var schema"+i+" = "+e.util.getData(n.$data,o,e.dataPathArr)+"; ",a="schema"+i):a=n,s+="if ( ",h&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'string') || "),s+=" !"+(h?"(new RegExp("+a+"))":e.usePattern(n))+".test("+u+") ) { ";var p=p||[];p.push(s),s="",!1!==e.createErrors?(s+=" { keyword: 'pattern' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { pattern: ",s+=h?""+a:""+e.util.toQuotedString(n),s+=" } ",!1!==e.opts.messages&&(s+=" , message: 'should match pattern \"",s+=h?"' + "+a+" + '":""+e.util.escapeQuotes(n),s+="\"' "),e.opts.verbose&&(s+=" , schema: ",s+=h?"validate.schema"+l:""+e.util.toQuotedString(n),s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var m=s;return s=p.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+m+"]); ":s+=" validate.errors = ["+m+"]; return false; ":s+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",d&&(s+=" else { "),s},properties:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="errs__"+s,h=e.util.copy(e),p="";h.level++;var m="valid"+h.level,f="key"+s,v="idx"+s,y=h.dataLevel=e.dataLevel+1,g="data"+y,_="dataProperties"+s,w=Object.keys(o||{}).filter(j),b=e.schema.patternProperties||{},P=Object.keys(b).filter(j),E=e.schema.additionalProperties,x=w.length||P.length,k=!1===E,S="object"==typeof E&&Object.keys(E).length,R=e.opts.removeAdditional,O=k||S||R,T=e.opts.ownProperties,$=e.baseId,I=e.schema.required;if(I&&(!e.opts.$data||!I.$data)&&I.length<e.opts.loopRequired)var C=e.util.toHash(I);function j(e){return"__proto__"!==e}if(a+="var "+u+" = errors;var "+m+" = true;",T&&(a+=" var "+_+" = undefined;"),O){if(a+=T?" "+_+" = "+_+" || Object.keys("+d+"); for (var "+v+"=0; "+v+"<"+_+".length; "+v+"++) { var "+f+" = "+_+"["+v+"]; ":" for (var "+f+" in "+d+") { ",x){if(a+=" var isAdditional"+s+" = !(false ",w.length)if(w.length>8)a+=" || validate.schema"+n+".hasOwnProperty("+f+") ";else{var F=w;if(F)for(var A=-1,D=F.length-1;A<D;)W=F[A+=1],a+=" || "+f+" == "+e.util.toQuotedString(W)+" "}if(P.length){var N=P;if(N)for(var q=-1,L=N.length-1;q<L;)ie=N[q+=1],a+=" || "+e.usePattern(ie)+".test("+f+") "}a+=" ); if (isAdditional"+s+") { "}if("all"==R)a+=" delete "+d+"["+f+"]; ";else{var z=e.errorPath,Z="' + "+f+" + '";if(e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(e.errorPath,f,e.opts.jsonPointers)),k)if(R)a+=" delete "+d+"["+f+"]; ";else{a+=" "+m+" = false; ";var M=l;l=e.errSchemaPath+"/additionalProperties",(re=re||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'additionalProperties' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { additionalProperty: '"+Z+"' } ",!1!==e.opts.messages&&(a+=" , message: '",e.opts._errorDataPathProperty?a+="is an invalid additional property":a+="should NOT have additional properties",a+="' "),e.opts.verbose&&(a+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var U=a;a=re.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+U+"]); ":a+=" validate.errors = ["+U+"]; return false; ":a+=" var err = "+U+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",l=M,c&&(a+=" break; ")}else if(S)if("failing"==R){a+=" var "+u+" = errors; ";var V=e.compositeRule;e.compositeRule=h.compositeRule=!0,h.schema=E,h.schemaPath=e.schemaPath+".additionalProperties",h.errSchemaPath=e.errSchemaPath+"/additionalProperties",h.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,f,e.opts.jsonPointers);var H=d+"["+f+"]";h.dataPathArr[y]=f;var Q=e.validate(h);h.baseId=$,e.util.varOccurences(Q,g)<2?a+=" "+e.util.varReplace(Q,g,H)+" ":a+=" var "+g+" = "+H+"; "+Q+" ",a+=" if (!"+m+") { errors = "+u+"; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete "+d+"["+f+"]; } ",e.compositeRule=h.compositeRule=V}else{h.schema=E,h.schemaPath=e.schemaPath+".additionalProperties",h.errSchemaPath=e.errSchemaPath+"/additionalProperties",h.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,f,e.opts.jsonPointers);H=d+"["+f+"]";h.dataPathArr[y]=f;Q=e.validate(h);h.baseId=$,e.util.varOccurences(Q,g)<2?a+=" "+e.util.varReplace(Q,g,H)+" ":a+=" var "+g+" = "+H+"; "+Q+" ",c&&(a+=" if (!"+m+") break; ")}e.errorPath=z}x&&(a+=" } "),a+=" } ",c&&(a+=" if ("+m+") { ",p+="}")}var K=e.opts.useDefaults&&!e.compositeRule;if(w.length){var B=w;if(B)for(var W,J=-1,G=B.length-1;J<G;){var Y=o[W=B[J+=1]];if(e.opts.strictKeywords?"object"==typeof Y&&Object.keys(Y).length>0||!1===Y:e.util.schemaHasRules(Y,e.RULES.all)){var X=e.util.getProperty(W),ee=(H=d+X,K&&void 0!==Y.default);h.schema=Y,h.schemaPath=n+X,h.errSchemaPath=l+"/"+e.util.escapeFragment(W),h.errorPath=e.util.getPath(e.errorPath,W,e.opts.jsonPointers),h.dataPathArr[y]=e.util.toQuotedString(W);Q=e.validate(h);if(h.baseId=$,e.util.varOccurences(Q,g)<2){Q=e.util.varReplace(Q,g,H);var te=H}else{te=g;a+=" var "+g+" = "+H+"; "}if(ee)a+=" "+Q+" ";else{if(C&&C[W]){a+=" if ( "+te+" === undefined ",T&&(a+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(W)+"') "),a+=") { "+m+" = false; ";z=e.errorPath,M=l;var re,ae=e.util.escapeQuotes(W);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(z,W,e.opts.jsonPointers)),l=e.errSchemaPath+"/required",(re=re||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { missingProperty: '"+ae+"' } ",!1!==e.opts.messages&&(a+=" , message: '",e.opts._errorDataPathProperty?a+="is a required property":a+="should have required property \\'"+ae+"\\'",a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";U=a;a=re.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+U+"]); ":a+=" validate.errors = ["+U+"]; return false; ":a+=" var err = "+U+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",l=M,e.errorPath=z,a+=" } else { "}else c?(a+=" if ( "+te+" === undefined ",T&&(a+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(W)+"') "),a+=") { "+m+" = true; } else { "):(a+=" if ("+te+" !== undefined ",T&&(a+=" && Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(W)+"') "),a+=" ) { ");a+=" "+Q+" } "}}c&&(a+=" if ("+m+") { ",p+="}")}}if(P.length){var se=P;if(se)for(var ie,oe=-1,ne=se.length-1;oe<ne;){Y=b[ie=se[oe+=1]];if(e.opts.strictKeywords?"object"==typeof Y&&Object.keys(Y).length>0||!1===Y:e.util.schemaHasRules(Y,e.RULES.all)){h.schema=Y,h.schemaPath=e.schemaPath+".patternProperties"+e.util.getProperty(ie),h.errSchemaPath=e.errSchemaPath+"/patternProperties/"+e.util.escapeFragment(ie),a+=T?" "+_+" = "+_+" || Object.keys("+d+"); for (var "+v+"=0; "+v+"<"+_+".length; "+v+"++) { var "+f+" = "+_+"["+v+"]; ":" for (var "+f+" in "+d+") { ",a+=" if ("+e.usePattern(ie)+".test("+f+")) { ",h.errorPath=e.util.getPathExpr(e.errorPath,f,e.opts.jsonPointers);H=d+"["+f+"]";h.dataPathArr[y]=f;Q=e.validate(h);h.baseId=$,e.util.varOccurences(Q,g)<2?a+=" "+e.util.varReplace(Q,g,H)+" ":a+=" var "+g+" = "+H+"; "+Q+" ",c&&(a+=" if (!"+m+") break; "),a+=" } ",c&&(a+=" else "+m+" = true; "),a+=" } ",c&&(a+=" if ("+m+") { ",p+="}")}}}return c&&(a+=" "+p+" if ("+u+" == errors) {"),a},propertyNames:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="errs__"+s,h=e.util.copy(e);h.level++;var p="valid"+h.level;if(a+="var "+u+" = errors;",e.opts.strictKeywords?"object"==typeof o&&Object.keys(o).length>0||!1===o:e.util.schemaHasRules(o,e.RULES.all)){h.schema=o,h.schemaPath=n,h.errSchemaPath=l;var m="key"+s,f="idx"+s,v="i"+s,y="' + "+m+" + '",g="data"+(h.dataLevel=e.dataLevel+1),_="dataProperties"+s,w=e.opts.ownProperties,b=e.baseId;w&&(a+=" var "+_+" = undefined; "),a+=w?" "+_+" = "+_+" || Object.keys("+d+"); for (var "+f+"=0; "+f+"<"+_+".length; "+f+"++) { var "+m+" = "+_+"["+f+"]; ":" for (var "+m+" in "+d+") { ",a+=" var startErrs"+s+" = errors; ";var P=m,E=e.compositeRule;e.compositeRule=h.compositeRule=!0;var x=e.validate(h);h.baseId=b,e.util.varOccurences(x,g)<2?a+=" "+e.util.varReplace(x,g,P)+" ":a+=" var "+g+" = "+P+"; "+x+" ",e.compositeRule=h.compositeRule=E,a+=" if (!"+p+") { for (var "+v+"=startErrs"+s+"; "+v+"<errors; "+v+"++) { vErrors["+v+"].propertyName = "+m+"; } var err = ",!1!==e.createErrors?(a+=" { keyword: 'propertyNames' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { propertyName: '"+y+"' } ",!1!==e.opts.messages&&(a+=" , message: 'property name \\'"+y+"\\' is invalid' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&c&&(e.async?a+=" throw new ValidationError(vErrors); ":a+=" validate.errors = vErrors; return false; "),c&&(a+=" break; "),a+=" } }"}return c&&(a+=" if ("+u+" == errors) {"),a},required:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="valid"+s,h=e.opts.$data&&o&&o.$data;h&&(a+=" var schema"+s+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ");var p="schema"+s;if(!h)if(o.length<e.opts.loopRequired&&e.schema.properties&&Object.keys(e.schema.properties).length){var m=[],f=o;if(f)for(var v,y=-1,g=f.length-1;y<g;){v=f[y+=1];var _=e.schema.properties[v];_&&(e.opts.strictKeywords?"object"==typeof _&&Object.keys(_).length>0||!1===_:e.util.schemaHasRules(_,e.RULES.all))||(m[m.length]=v)}}else m=o;if(h||m.length){var w=e.errorPath,b=h||m.length>=e.opts.loopRequired,P=e.opts.ownProperties;if(c)if(a+=" var missing"+s+"; ",b){h||(a+=" var "+p+" = validate.schema"+n+"; ");var E="' + "+(T="schema"+s+"["+(S="i"+s)+"]")+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(w,T,e.opts.jsonPointers)),a+=" var "+u+" = true; ",h&&(a+=" if (schema"+s+" === undefined) "+u+" = true; else if (!Array.isArray(schema"+s+")) "+u+" = false; else {"),a+=" for (var "+S+" = 0; "+S+" < "+p+".length; "+S+"++) { "+u+" = "+d+"["+p+"["+S+"]] !== undefined ",P&&(a+=" && Object.prototype.hasOwnProperty.call("+d+", "+p+"["+S+"]) "),a+="; if (!"+u+") break; } ",h&&(a+=" } "),a+=" if (!"+u+") { ",(O=O||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { missingProperty: '"+E+"' } ",!1!==e.opts.messages&&(a+=" , message: '",e.opts._errorDataPathProperty?a+="is a required property":a+="should have required property \\'"+E+"\\'",a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var x=a;a=O.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+x+"]); ":a+=" validate.errors = ["+x+"]; return false; ":a+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } else { "}else{a+=" if ( ";var k=m;if(k)for(var S=-1,R=k.length-1;S<R;){I=k[S+=1],S&&(a+=" || "),a+=" ( ( "+(A=d+(F=e.util.getProperty(I)))+" === undefined ",P&&(a+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(I)+"') "),a+=") && (missing"+s+" = "+e.util.toQuotedString(e.opts.jsonPointers?I:F)+") ) "}a+=") { ";var O;E="' + "+(T="missing"+s)+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(w,T,!0):w+" + "+T),(O=O||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { missingProperty: '"+E+"' } ",!1!==e.opts.messages&&(a+=" , message: '",e.opts._errorDataPathProperty?a+="is a required property":a+="should have required property \\'"+E+"\\'",a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";x=a;a=O.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+x+"]); ":a+=" validate.errors = ["+x+"]; return false; ":a+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } else { "}else if(b){h||(a+=" var "+p+" = validate.schema"+n+"; ");var T;E="' + "+(T="schema"+s+"["+(S="i"+s)+"]")+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(w,T,e.opts.jsonPointers)),h&&(a+=" if ("+p+" && !Array.isArray("+p+")) { var err = ",!1!==e.createErrors?(a+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { missingProperty: '"+E+"' } ",!1!==e.opts.messages&&(a+=" , message: '",e.opts._errorDataPathProperty?a+="is a required property":a+="should have required property \\'"+E+"\\'",a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if ("+p+" !== undefined) { "),a+=" for (var "+S+" = 0; "+S+" < "+p+".length; "+S+"++) { if ("+d+"["+p+"["+S+"]] === undefined ",P&&(a+=" || ! Object.prototype.hasOwnProperty.call("+d+", "+p+"["+S+"]) "),a+=") { var err = ",!1!==e.createErrors?(a+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { missingProperty: '"+E+"' } ",!1!==e.opts.messages&&(a+=" , message: '",e.opts._errorDataPathProperty?a+="is a required property":a+="should have required property \\'"+E+"\\'",a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ",h&&(a+=" } ")}else{var $=m;if($)for(var I,C=-1,j=$.length-1;C<j;){I=$[C+=1];var F=e.util.getProperty(I),A=(E=e.util.escapeQuotes(I),d+F);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(w,I,e.opts.jsonPointers)),a+=" if ( "+A+" === undefined ",P&&(a+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(I)+"') "),a+=") { var err = ",!1!==e.createErrors?(a+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { missingProperty: '"+E+"' } ",!1!==e.opts.messages&&(a+=" , message: '",e.opts._errorDataPathProperty?a+="is a required property":a+="should have required property \\'"+E+"\\'",a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}e.errorPath=w}else c&&(a+=" if (true) {");return a},uniqueItems:function(e,t,r){var a,s=" ",i=e.level,o=e.dataLevel,n=e.schema[t],l=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,u="data"+(o||""),h="valid"+i,p=e.opts.$data&&n&&n.$data;if(p?(s+=" var schema"+i+" = "+e.util.getData(n.$data,o,e.dataPathArr)+"; ",a="schema"+i):a=n,(n||p)&&!1!==e.opts.uniqueItems){p&&(s+=" var "+h+"; if ("+a+" === false || "+a+" === undefined) "+h+" = true; else if (typeof "+a+" != 'boolean') "+h+" = false; else { "),s+=" var i = "+u+".length , "+h+" = true , j; if (i > 1) { ";var m=e.schema.items&&e.schema.items.type,f=Array.isArray(m);if(!m||"object"==m||"array"==m||f&&(m.indexOf("object")>=0||m.indexOf("array")>=0))s+=" outer: for (;i--;) { for (j = i; j--;) { if (equal("+u+"[i], "+u+"[j])) { "+h+" = false; break outer; } } } ";else{s+=" var itemIndices = {}, item; for (;i--;) { var item = "+u+"[i]; ";var v="checkDataType"+(f?"s":"");s+=" if ("+e.util[v](m,"item",e.opts.strictNumbers,!0)+") continue; ",f&&(s+=" if (typeof item == 'string') item = '\"' + item; "),s+=" if (typeof itemIndices[item] == 'number') { "+h+" = false; j = itemIndices[item]; break; } itemIndices[item] = i; } "}s+=" } ",p&&(s+=" } "),s+=" if (!"+h+") { ";var y=y||[];y.push(s),s="",!1!==e.createErrors?(s+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { i: i, j: j } ",!1!==e.opts.messages&&(s+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),e.opts.verbose&&(s+=" , schema: ",s+=p?"validate.schema"+l:""+n,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var g=s;s=y.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+g+"]); ":s+=" validate.errors = ["+g+"]; return false; ":s+=" var err = "+g+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } ",d&&(s+=" else { ")}else d&&(s+=" if (true) { ");return s},validate:va},ls=ns,cs=kr.toHash,ds=["multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","additionalItems","maxItems","minItems","uniqueItems","maxProperties","minProperties","required","additionalProperties","enum","format","const"],us=ha.MissingRef,hs=function e(t,r,a){var s=this;if("function"!=typeof this._opts.loadSchema)throw new Error("options.loadSchema should be a function");"function"==typeof r&&(a=r,r=void 0);var i=o(t).then((function(){var e=s._addSchema(t,void 0,r);return e.validate||n(e)}));a&&i.then((function(e){a(null,e)}),a);return i;function o(t){var r=t.$schema;return r&&!s.getSchema(r)?e.call(s,{$ref:r},!0):Promise.resolve()}function n(e){try{return s._compile(e)}catch(t){if(t instanceof us)return function(t){var a=t.missingSchema;if(c(a))throw new Error("Schema "+a+" is loaded but "+t.missingRef+" cannot be resolved");var i=s._loadingSchemas[a];i||(i=s._loadingSchemas[a]=s._opts.loadSchema(a)).then(l,l);return i.then((function(e){if(!c(a))return o(e).then((function(){c(a)||s.addSchema(e,a,void 0,r)}))})).then((function(){return n(e)}));function l(){delete s._loadingSchemas[a]}function c(e){return s._refs[e]||s._schemas[e]}}(t);throw t}}};var ps={$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},ms=ps,fs={$id:"https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js",definitions:{simpleTypes:ms.definitions.simpleTypes},type:"object",dependencies:{schema:["validate"],$data:["validate"],statements:["inline"],valid:{not:{required:["macro"]}}},properties:{type:ms.properties.type,schema:{type:"boolean"},statements:{type:"boolean"},dependencies:{type:"array",items:{type:"string"}},metaSchema:{type:"object"},modifying:{type:"boolean"},valid:{type:"boolean"},$data:{type:"boolean"},async:{type:"boolean"},errors:{anyOf:[{type:"boolean"},{const:"full"}]}}},vs=/^[a-z_$][a-z0-9_$-]*$/i,ys=function(e,t,r){var a,s,i=" ",o=e.level,n=e.dataLevel,l=e.schema[t],c=e.schemaPath+e.util.getProperty(t),d=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,h="data"+(n||""),p="valid"+o,m="errs__"+o,f=e.opts.$data&&l&&l.$data;f?(i+=" var schema"+o+" = "+e.util.getData(l.$data,n,e.dataPathArr)+"; ",s="schema"+o):s=l;var v,y,g,_,w,b=this,P="definition"+o,E=b.definition,x="";if(f&&E.$data){w="keywordValidate"+o;var k=E.validateSchema;i+=" var "+P+" = RULES.custom['"+t+"'].definition; var "+w+" = "+P+".validate;"}else{if(!(_=e.useCustomRule(b,l,e.schema,e)))return;s="validate.schema"+c,w=_.code,v=E.compile,y=E.inline,g=E.macro}var S=w+".errors",R="i"+o,O="ruleErr"+o,T=E.async;if(T&&!e.async)throw new Error("async keyword in sync schema");if(y||g||(i+=S+" = null;"),i+="var "+m+" = errors;var "+p+";",f&&E.$data&&(x+="}",i+=" if ("+s+" === undefined) { "+p+" = true; } else { ",k&&(x+="}",i+=" "+p+" = "+P+".validateSchema("+s+"); if ("+p+") { ")),y)E.statements?i+=" "+_.validate+" ":i+=" "+p+" = "+_.validate+"; ";else if(g){var $=e.util.copy(e);x="";$.level++;var I="valid"+$.level;$.schema=_.validate,$.schemaPath="";var C=e.compositeRule;e.compositeRule=$.compositeRule=!0;var j=e.validate($).replace(/validate\.schema/g,w);e.compositeRule=$.compositeRule=C,i+=" "+j}else{(N=N||[]).push(i),i="",i+=" "+w+".call( ",e.opts.passContext?i+="this":i+="self",v||!1===E.schema?i+=" , "+h+" ":i+=" , "+s+" , "+h+" , validate.schema"+e.schemaPath+" ",i+=" , (dataPath || '')",'""'!=e.errorPath&&(i+=" + "+e.errorPath);var F=n?"data"+(n-1||""):"parentData",A=n?e.dataPathArr[n]:"parentDataProperty",D=i+=" , "+F+" , "+A+" , rootData ) ";i=N.pop(),!1===E.errors?(i+=" "+p+" = ",T&&(i+="await "),i+=D+"; "):i+=T?" var "+(S="customErrors"+o)+" = null; try { "+p+" = await "+D+"; } catch (e) { "+p+" = false; if (e instanceof ValidationError) "+S+" = e.errors; else throw e; } ":" "+S+" = null; "+p+" = "+D+"; "}if(E.modifying&&(i+=" if ("+F+") "+h+" = "+F+"["+A+"];"),i+=""+x,E.valid)u&&(i+=" if (true) { ");else{var N;i+=" if ( ",void 0===E.valid?(i+=" !",i+=g?""+I:""+p):i+=" "+!E.valid+" ",i+=") { ",a=b.keyword,(N=N||[]).push(i),i="",(N=N||[]).push(i),i="",!1!==e.createErrors?(i+=" { keyword: '"+(a||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { keyword: '"+b.keyword+"' } ",!1!==e.opts.messages&&(i+=" , message: 'should pass \""+b.keyword+"\" keyword validation' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),i+=" } "):i+=" {} ";var q=i;i=N.pop(),!e.compositeRule&&u?e.async?i+=" throw new ValidationError(["+q+"]); ":i+=" validate.errors = ["+q+"]; return false; ":i+=" var err = "+q+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";var L=i;i=N.pop(),y?E.errors?"full"!=E.errors&&(i+=" for (var "+R+"="+m+"; "+R+"<errors; "+R+"++) { var "+O+" = vErrors["+R+"]; if ("+O+".dataPath === undefined) "+O+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+O+".schemaPath === undefined) { "+O+'.schemaPath = "'+d+'"; } ',e.opts.verbose&&(i+=" "+O+".schema = "+s+"; "+O+".data = "+h+"; "),i+=" } "):!1===E.errors?i+=" "+L+" ":(i+=" if ("+m+" == errors) { "+L+" } else { for (var "+R+"="+m+"; "+R+"<errors; "+R+"++) { var "+O+" = vErrors["+R+"]; if ("+O+".dataPath === undefined) "+O+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+O+".schemaPath === undefined) { "+O+'.schemaPath = "'+d+'"; } ',e.opts.verbose&&(i+=" "+O+".schema = "+s+"; "+O+".data = "+h+"; "),i+=" } } "):g?(i+=" var err = ",!1!==e.createErrors?(i+=" { keyword: '"+(a||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { keyword: '"+b.keyword+"' } ",!1!==e.opts.messages&&(i+=" , message: 'should pass \""+b.keyword+"\" keyword validation' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),i+=" } "):i+=" {} ",i+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&u&&(e.async?i+=" throw new ValidationError(vErrors); ":i+=" validate.errors = vErrors; return false; ")):!1===E.errors?i+=" "+L+" ":(i+=" if (Array.isArray("+S+")) { if (vErrors === null) vErrors = "+S+"; else vErrors = vErrors.concat("+S+"); errors = vErrors.length; for (var "+R+"="+m+"; "+R+"<errors; "+R+"++) { var "+O+" = vErrors["+R+"]; if ("+O+".dataPath === undefined) "+O+".dataPath = (dataPath || '') + "+e.errorPath+"; "+O+'.schemaPath = "'+d+'"; ',e.opts.verbose&&(i+=" "+O+".schema = "+s+"; "+O+".data = "+h+"; "),i+=" } } else { "+L+" } "),i+=" } ",u&&(i+=" else { ")}return i},gs=fs,_s={add:function(e,t){var r=this.RULES;if(r.keywords[e])throw new Error("Keyword "+e+" is already defined");if(!vs.test(e))throw new Error("Keyword "+e+" is not a valid identifier");if(t){this.validateKeyword(t,!0);var a=t.type;if(Array.isArray(a))for(var s=0;s<a.length;s++)o(e,a[s],t);else o(e,a,t);var i=t.metaSchema;i&&(t.$data&&this._opts.$data&&(i={anyOf:[i,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]}),t.validateSchema=this.compile(i,!0))}function o(e,t,a){for(var s,i=0;i<r.length;i++){var o=r[i];if(o.type==t){s=o;break}}s||(s={type:t,rules:[]},r.push(s));var n={keyword:e,definition:a,custom:!0,code:ys,implements:a.implements};s.rules.push(n),r.custom[e]=n}return r.keywords[e]=r.all[e]=!0,this},get:function(e){var t=this.RULES.custom[e];return t?t.definition:this.RULES.keywords[e]||!1},remove:function(e){var t=this.RULES;delete t.keywords[e],delete t.all[e],delete t.custom[e];for(var r=0;r<t.length;r++)for(var a=t[r].rules,s=0;s<a.length;s++)if(a[s].keyword==e){a.splice(s,1);break}return this},validate:function e(t,r){e.errors=null;var a=this._validateKeyword=this._validateKeyword||this.compile(gs,!0);if(a(t))return!0;if(e.errors=a.errors,r)throw new Error("custom keyword definition is invalid: "+this.errorsText(a.errors));return!1}};var ws={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON Schema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1},bs=ka,Ps=Jr,Es=Da,xs=zr,ks=fa,Ss=Wa,Rs=function(){var e=[{type:"number",rules:[{maximum:["exclusiveMaximum"]},{minimum:["exclusiveMinimum"]},"multipleOf","format"]},{type:"string",rules:["maxLength","minLength","pattern","format"]},{type:"array",rules:["maxItems","minItems","items","contains","uniqueItems"]},{type:"object",rules:["maxProperties","minProperties","required","dependencies","propertyNames",{properties:["additionalProperties","patternProperties"]}]},{rules:["$ref","const","enum","not","anyOf","oneOf","allOf","if"]}],t=["type","$comment"];return e.all=cs(t),e.types=cs(["number","integer","string","array","object","boolean","null"]),e.forEach((function(r){r.rules=r.rules.map((function(r){var a;if("object"==typeof r){var s=Object.keys(r)[0];a=r[s],r=s,a.forEach((function(r){t.push(r),e.all[r]=!0}))}return t.push(r),e.all[r]={keyword:r,code:ls[r],implements:a}})),e.all.$comment={keyword:"$comment",code:ls.$comment},r.type&&(e.types[r.type]=r)})),e.keywords=cs(t.concat(["$schema","$id","id","$data","$async","title","description","default","definitions","examples","readOnly","writeOnly","contentMediaType","contentEncoding","additionalItems","then","else"])),e.custom={},e},Os=function(e,t){for(var r=0;r<t.length;r++){e=JSON.parse(JSON.stringify(e));var a,s=t[r].split("/"),i=e;for(a=1;a<s.length;a++)i=i[s[a]];for(a=0;a<ds.length;a++){var o=ds[a],n=i[o];n&&(i[o]={anyOf:[n,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]})}}return e},Ts=kr,$s=Ds;Ds.prototype.validate=function(e,t){var r;if("string"==typeof e){if(!(r=this.getSchema(e)))throw new Error('no schema with key or ref "'+e+'"')}else{var a=this._addSchema(e);r=a.validate||this._compile(a)}var s=r(t);!0!==r.$async&&(this.errors=r.errors);return s},Ds.prototype.compile=function(e,t){var r=this._addSchema(e,void 0,t);return r.validate||this._compile(r)},Ds.prototype.addSchema=function(e,t,r,a){if(Array.isArray(e)){for(var s=0;s<e.length;s++)this.addSchema(e[s],void 0,r,a);return this}var i=this._getId(e);if(void 0!==i&&"string"!=typeof i)throw new Error("schema id must be string");return Ms(this,t=Ps.normalizeId(t||i)),this._schemas[t]=this._addSchema(e,r,a,!0),this},Ds.prototype.addMetaSchema=function(e,t,r){return this.addSchema(e,t,r,!0),this},Ds.prototype.validateSchema=function(e,t){var r=e.$schema;if(void 0!==r&&"string"!=typeof r)throw new Error("$schema must be a string");if(r=r||this._opts.defaultMeta||function(e){var t=e._opts.meta;return e._opts.defaultMeta="object"==typeof t?e._getId(t)||t:e.getSchema(js)?js:void 0,e._opts.defaultMeta}(this),!r)return this.logger.warn("meta-schema not available"),this.errors=null,!0;var a=this.validate(r,e);if(!a&&t){var s="schema is invalid: "+this.errorsText();if("log"!=this._opts.validateSchema)throw new Error(s);this.logger.error(s)}return a},Ds.prototype.getSchema=function(e){var t=Ns(this,e);switch(typeof t){case"object":return t.validate||this._compile(t);case"string":return this.getSchema(t);case"undefined":return function(e,t){var r=Ps.schema.call(e,{schema:{}},t);if(r){var a=r.schema,s=r.root,i=r.baseId,o=bs.call(e,a,s,void 0,i);return e._fragments[t]=new xs({ref:t,fragment:!0,schema:a,root:s,baseId:i,validate:o}),o}}(this,e)}},Ds.prototype.removeSchema=function(e){if(e instanceof RegExp)return qs(this,this._schemas,e),qs(this,this._refs,e),this;switch(typeof e){case"undefined":return qs(this,this._schemas),qs(this,this._refs),this._cache.clear(),this;case"string":var t=Ns(this,e);return t&&this._cache.del(t.cacheKey),delete this._schemas[e],delete this._refs[e],this;case"object":var r=this._opts.serialize,a=r?r(e):e;this._cache.del(a);var s=this._getId(e);s&&(s=Ps.normalizeId(s),delete this._schemas[s],delete this._refs[s])}return this},Ds.prototype.addFormat=function(e,t){"string"==typeof t&&(t=new RegExp(t));return this._formats[e]=t,this},Ds.prototype.errorsText=function(e,t){if(!(e=e||this.errors))return"No errors";for(var r=void 0===(t=t||{}).separator?", ":t.separator,a=void 0===t.dataVar?"data":t.dataVar,s="",i=0;i<e.length;i++){var o=e[i];o&&(s+=a+o.dataPath+" "+o.message+r)}return s.slice(0,-r.length)},Ds.prototype._addSchema=function(e,t,r,a){if("object"!=typeof e&&"boolean"!=typeof e)throw new Error("schema should be object or boolean");var s=this._opts.serialize,i=s?s(e):e,o=this._cache.get(i);if(o)return o;a=a||!1!==this._opts.addUsedSchema;var n=Ps.normalizeId(this._getId(e));n&&a&&Ms(this,n);var l,c=!1!==this._opts.validateSchema&&!t;c&&!(l=n&&n==Ps.normalizeId(e.$schema))&&this.validateSchema(e,!0);var d=Ps.ids.call(this,e),u=new xs({id:n,schema:e,localRefs:d,cacheKey:i,meta:r});"#"!=n[0]&&a&&(this._refs[n]=u);this._cache.put(i,u),c&&l&&this.validateSchema(e,!0);return u},Ds.prototype._compile=function(e,t){if(e.compiling)return e.validate=s,s.schema=e.schema,s.errors=null,s.root=t||s,!0===e.schema.$async&&(s.$async=!0),s;var r,a;e.compiling=!0,e.meta&&(r=this._opts,this._opts=this._metaOpts);try{a=bs.call(this,e.schema,t,e.localRefs)}catch(t){throw delete e.validate,t}finally{e.compiling=!1,e.meta&&(this._opts=r)}return e.validate=a,e.refs=a.refs,e.refVal=a.refVal,e.root=a.root,a;function s(){var t=e.validate,r=t.apply(this,arguments);return s.errors=t.errors,r}},Ds.prototype.compileAsync=hs;var Is=_s;Ds.prototype.addKeyword=Is.add,Ds.prototype.getKeyword=Is.get,Ds.prototype.removeKeyword=Is.remove,Ds.prototype.validateKeyword=Is.validate;var Cs=ha;Ds.ValidationError=Cs.Validation,Ds.MissingRefError=Cs.MissingRef,Ds.$dataMetaSchema=Os;var js="http://json-schema.org/draft-07/schema",Fs=["removeAdditional","useDefaults","coerceTypes","strictDefaults"],As=["/properties"];function Ds(e){if(!(this instanceof Ds))return new Ds(e);e=this._opts=Ts.copy(e)||{},function(e){var t=e._opts.logger;if(!1===t)e.logger={log:Us,warn:Us,error:Us};else{if(void 0===t&&(t=console),!("object"==typeof t&&t.log&&t.warn&&t.error))throw new Error("logger must implement log, warn and error methods");e.logger=t}}(this),this._schemas={},this._refs={},this._fragments={},this._formats=Ss(e.format),this._cache=e.cache||new Es,this._loadingSchemas={},this._compilations=[],this.RULES=Rs(),this._getId=function(e){switch(e.schemaId){case"auto":return Zs;case"id":return Ls;default:return zs}}(e),e.loopRequired=e.loopRequired||1/0,"property"==e.errorDataPath&&(e._errorDataPathProperty=!0),void 0===e.serialize&&(e.serialize=ks),this._metaOpts=function(e){for(var t=Ts.copy(e._opts),r=0;r<Fs.length;r++)delete t[Fs[r]];return t}(this),e.formats&&function(e){for(var t in e._opts.formats){var r=e._opts.formats[t];e.addFormat(t,r)}}(this),e.keywords&&function(e){for(var t in e._opts.keywords){var r=e._opts.keywords[t];e.addKeyword(t,r)}}(this),function(e){var t;e._opts.$data&&(t=ws,e.addMetaSchema(t,t.$id,!0));if(!1===e._opts.meta)return;var r=ps;e._opts.$data&&(r=Os(r,As));e.addMetaSchema(r,js,!0),e._refs["http://json-schema.org/schema"]=js}(this),"object"==typeof e.meta&&this.addMetaSchema(e.meta),e.nullable&&this.addKeyword("nullable",{metaSchema:{type:"boolean"}}),function(e){var t=e._opts.schemas;if(!t)return;if(Array.isArray(t))e.addSchema(t);else for(var r in t)e.addSchema(t[r],r)}(this)}function Ns(e,t){return t=Ps.normalizeId(t),e._schemas[t]||e._refs[t]||e._fragments[t]}function qs(e,t,r){for(var a in t){var s=t[a];s.meta||r&&!r.test(a)||(e._cache.del(s.cacheKey),delete t[a])}}function Ls(e){return e.$id&&this.logger.warn("schema $id ignored",e.$id),e.id}function zs(e){return e.id&&this.logger.warn("schema id ignored",e.id),e.$id}function Zs(e){if(e.$id&&e.id&&e.$id!=e.id)throw new Error("schema $id is different from id");return e.$id||e.id}function Ms(e,t){if(e._schemas[t]||e._refs[t])throw new Error('schema with key or id "'+t+'" already exists')}function Us(){}var Vs=br($s);class Hs extends wr{constructor(e,t){var r;super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._capabilities=null!==(r=null==t?void 0:t.capabilities)&&void 0!==r?r:{},this._ajv=new Vs}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");var t,r;this._capabilities=(t=this._capabilities,r=e,Object.entries(r).reduce(((e,[t,r])=>(e[t]=r&&"object"==typeof r&&e[t]?{...e[t],...r}:r,e)),{...t}))}assertCapability(e,t){var r;if(!(null===(r=this._serverCapabilities)||void 0===r?void 0:r[e]))throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),void 0===e.sessionId)try{const e=await this.request({method:"initialize",params:{protocolVersion:Ve,capabilities:this._capabilities,clientInfo:this._clientInfo}},vt,t);if(void 0===e)throw new Error(`Server sent invalid initialize result: ${e}`);if(!He.includes(e.protocolVersion))throw new Error(`Server's protocol version is not supported: ${e.protocolVersion}`);this._serverCapabilities=e.capabilities,this._serverVersion=e.serverInfo,this._instructions=e.instructions,await this.notification({method:"notifications/initialized"})}catch(e){throw this.close(),e}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){var t,r,a,s,i;switch(e){case"logging/setLevel":if(!(null===(t=this._serverCapabilities)||void 0===t?void 0:t.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!(null===(r=this._serverCapabilities)||void 0===r?void 0:r.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!(null===(a=this._serverCapabilities)||void 0===a?void 0:a.resources))throw new Error(`Server does not support resources (required for ${e})`);if("resources/subscribe"===e&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!(null===(s=this._serverCapabilities)||void 0===s?void 0:s.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!(null===(i=this._serverCapabilities)||void 0===i?void 0:i.completions))throw new Error(`Server does not support completions (required for ${e})`)}}assertNotificationCapability(e){var t;if("notifications/roots/list_changed"===e)if(!(null===(t=this._capabilities.roots)||void 0===t?void 0:t.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`)}}async ping(e){return this.request({method:"ping"},dt,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},mr,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},dt,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},Bt,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},Zt,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},Tt,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},It,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},jt,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},dt,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},dt,t)}async callTool(e,t=er,r){const a=await this.request({method:"tools/call",params:e},t,r),s=this.getToolOutputValidator(e.name);if(s){if(!a.structuredContent&&!a.isError)throw new _r(nt.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(a.structuredContent)try{if(!s(a.structuredContent))throw new _r(nt.InvalidParams,`Structured content does not match the tool's output schema: ${this._ajv.errorsText(s.errors)}`)}catch(e){if(e instanceof _r)throw e;throw new _r(nt.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return a}cacheToolOutputSchemas(e){this._cachedToolOutputValidators.clear();for(const t of e)if(t.outputSchema)try{const e=this._ajv.compile(t.outputSchema);this._cachedToolOutputValidators.set(t.name,e)}catch(e){console.warn(`Failed to compile output schema for tool ${t.name}: ${e}`)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){const r=await this.request({method:"tools/list",params:e},Xt,t);return this.cacheToolOutputSchemas(r.tools),r}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}const Qs=Ne({resource:Ie().url(),authorization_servers:De(Ie().url()).optional(),jwks_uri:Ie().url().optional(),scopes_supported:De(Ie()).optional(),bearer_methods_supported:De(Ie()).optional(),resource_signing_alg_values_supported:De(Ie()).optional(),resource_name:Ie().optional(),resource_documentation:Ie().optional(),resource_policy_uri:Ie().url().optional(),resource_tos_uri:Ie().url().optional(),tls_client_certificate_bound_access_tokens:je().optional(),authorization_details_types_supported:De(Ie()).optional(),dpop_signing_alg_values_supported:De(Ie()).optional(),dpop_bound_access_tokens_required:je().optional()}).passthrough(),Ks=Ne({issuer:Ie(),authorization_endpoint:Ie(),token_endpoint:Ie(),registration_endpoint:Ie().optional(),scopes_supported:De(Ie()).optional(),response_types_supported:De(Ie()),response_modes_supported:De(Ie()).optional(),grant_types_supported:De(Ie()).optional(),token_endpoint_auth_methods_supported:De(Ie()).optional(),token_endpoint_auth_signing_alg_values_supported:De(Ie()).optional(),service_documentation:Ie().optional(),revocation_endpoint:Ie().optional(),revocation_endpoint_auth_methods_supported:De(Ie()).optional(),revocation_endpoint_auth_signing_alg_values_supported:De(Ie()).optional(),introspection_endpoint:Ie().optional(),introspection_endpoint_auth_methods_supported:De(Ie()).optional(),introspection_endpoint_auth_signing_alg_values_supported:De(Ie()).optional(),code_challenge_methods_supported:De(Ie()).optional()}).passthrough(),Bs=Ne({access_token:Ie(),token_type:Ie(),expires_in:Ce().optional(),scope:Ie().optional(),refresh_token:Ie().optional()}).strip();Ne({error:Ie(),error_description:Ie().optional(),error_uri:Ie().optional()});const Ws=Ne({redirect_uris:De(Ie()).refine((e=>e.every((e=>URL.canParse(e)))),{message:"redirect_uris must contain valid URLs"}),token_endpoint_auth_method:Ie().optional(),grant_types:De(Ie()).optional(),response_types:De(Ie()).optional(),client_name:Ie().optional(),client_uri:Ie().optional(),logo_uri:Ie().optional(),scope:Ie().optional(),contacts:De(Ie()).optional(),tos_uri:Ie().optional(),policy_uri:Ie().optional(),jwks_uri:Ie().optional(),jwks:Fe().optional(),software_id:Ie().optional(),software_version:Ie().optional()}).strip(),Js=Ne({client_id:Ie(),client_secret:Ie().optional(),client_id_issued_at:Ce().optional(),client_secret_expires_at:Ce().optional()}).strip(),Gs=Ws.merge(Js);Ne({error:Ie(),error_description:Ie().optional()}).strip(),Ne({token:Ie(),token_type_hint:Ie().optional()}).strip();class Ys extends Error{constructor(e){super(null!=e?e:"Unauthorized")}}async function Xs(t,{serverUrl:r,authorizationCode:a,scope:s,resourceMetadataUrl:i}){let o=r;try{const e=await async function(e,t){var r;let a,s;a=new URL("/.well-known/oauth-protected-resource",e);try{s=await fetch(a,{headers:{"MCP-Protocol-Version":null!==(r=null==t?void 0:t.protocolVersion)&&void 0!==r?r:Ve}})}catch(e){if(!(e instanceof TypeError))throw e;s=await fetch(a)}if(404===s.status)throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!s.ok)throw new Error(`HTTP ${s.status} trying to load well-known OAuth protected resource metadata.`);return Qs.parse(await s.json())}(i||r);e.authorization_servers&&e.authorization_servers.length>0&&(o=e.authorization_servers[0])}catch(e){console.warn("Could not load OAuth Protected Resource metadata, falling back to /.well-known/oauth-authorization-server",e)}const n=await async function(e,t){var r;const a=new URL("/.well-known/oauth-authorization-server",e);let s;try{s=await fetch(a,{headers:{"MCP-Protocol-Version":null!==(r=null==t?void 0:t.protocolVersion)&&void 0!==r?r:Ve}})}catch(e){if(!(e instanceof TypeError))throw e;s=await fetch(a)}if(404===s.status)return;if(!s.ok)throw new Error(`HTTP ${s.status} trying to load well-known OAuth metadata`);return Ks.parse(await s.json())}(o);let l=await Promise.resolve(t.clientInformation());if(!l){if(void 0!==a)throw new Error("Existing OAuth client information is required when exchanging an authorization code");if(!t.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const e=await async function(e,{metadata:t,clientMetadata:r}){let a;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");a=new URL(t.registration_endpoint)}else a=new URL("/register",e);const s=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok)throw new Error(`Dynamic client registration failed: HTTP ${s.status}`);return Gs.parse(await s.json())}(o,{metadata:n,clientMetadata:t.clientMetadata});await t.saveClientInformation(e),l=e}if(void 0!==a){const e=await t.codeVerifier(),r=await async function(e,{metadata:t,clientInformation:r,authorizationCode:a,codeVerifier:s,redirectUri:i}){const o="authorization_code";let n;if(t){if(n=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(o))throw new Error(`Incompatible auth server: does not support grant type ${o}`)}else n=new URL("/token",e);const l=new URLSearchParams({grant_type:o,client_id:r.client_id,code:a,code_verifier:s,redirect_uri:String(i)});r.client_secret&&l.set("client_secret",r.client_secret);const c=await fetch(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:l});if(!c.ok)throw new Error(`Token exchange failed: HTTP ${c.status}`);return Bs.parse(await c.json())}(o,{metadata:n,clientInformation:l,authorizationCode:a,codeVerifier:e,redirectUri:t.redirectUrl});return await t.saveTokens(r),"AUTHORIZED"}const c=await t.tokens();if(null==c?void 0:c.refresh_token)try{const e=await async function(e,{metadata:t,clientInformation:r,refreshToken:a}){const s="refresh_token";let i;if(t){if(i=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(s))throw new Error(`Incompatible auth server: does not support grant type ${s}`)}else i=new URL("/token",e);const o=new URLSearchParams({grant_type:s,client_id:r.client_id,refresh_token:a});r.client_secret&&o.set("client_secret",r.client_secret);const n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o});if(!n.ok)throw new Error(`Token refresh failed: HTTP ${n.status}`);return Bs.parse({refresh_token:a,...await n.json()})}(o,{metadata:n,clientInformation:l,refreshToken:c.refresh_token});return await t.saveTokens(e),"AUTHORIZED"}catch(e){console.error("Could not refresh OAuth tokens:",e)}const d=t.state?await t.state():void 0,{authorizationUrl:u,codeVerifier:h}=await async function(t,{metadata:r,clientInformation:a,redirectUrl:s,scope:i,state:o}){const n="code",l="S256";let c;if(r){if(c=new URL(r.authorization_endpoint),!r.response_types_supported.includes(n))throw new Error(`Incompatible auth server: does not support response type ${n}`);if(!r.code_challenge_methods_supported||!r.code_challenge_methods_supported.includes(l))throw new Error(`Incompatible auth server: does not support code challenge method ${l}`)}else c=new URL("/authorize",t);const d=await e(),u=d.code_verifier,h=d.code_challenge;c.searchParams.set("response_type",n),c.searchParams.set("client_id",a.client_id),c.searchParams.set("code_challenge",h),c.searchParams.set("code_challenge_method",l),c.searchParams.set("redirect_uri",String(s)),o&&c.searchParams.set("state",o);i&&c.searchParams.set("scope",i);return{authorizationUrl:c,codeVerifier:u}}(o,{metadata:n,clientInformation:l,state:d,redirectUrl:t.redirectUrl,scope:s||t.clientMetadata.scope});return await t.saveCodeVerifier(h),await t.redirectToAuthorization(u),"REDIRECT"}class ei extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function ti(e){}function ri(e){if("function"==typeof e)throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=ti,onError:r=ti,onRetry:a=ti,onComment:s}=e;let i,o="",n=!0,l="",c="";function d(e){if(""===e)return l.length>0&&t({id:i,event:c||void 0,data:l.endsWith("\n")?l.slice(0,-1):l}),i=void 0,l="",void(c="");if(e.startsWith(":"))return void(s&&s(e.slice(e.startsWith(": ")?2:1)));const r=e.indexOf(":");if(-1===r)u(e,"",e);else{const t=e.slice(0,r),a=" "===e[r+1]?2:1;u(t,e.slice(r+a),e)}}function u(e,t,s){switch(e){case"event":c=t;break;case"data":l=`${l}${t}\n`;break;case"id":i=t.includes("\0")?void 0:t;break;case"retry":/^\d+$/.test(t)?a(parseInt(t,10)):r(new ei(`Invalid \`retry\` value: "${t}"`,{type:"invalid-retry",value:t,line:s}));break;default:r(new ei(`Unknown field "${e.length>20?`${e.slice(0,20)}…`:e}"`,{type:"unknown-field",field:e,value:t,line:s}))}}return{feed:function(e){const t=n?e.replace(/^\xEF\xBB\xBF/,""):e,[r,a]=function(e){const t=[];let r="",a=0;for(;a<e.length;){const s=e.indexOf("\r",a),i=e.indexOf("\n",a);let o=-1;if(-1!==s&&-1!==i?o=Math.min(s,i):-1!==s?o=s:-1!==i&&(o=i),-1===o){r=e.slice(a);break}{const r=e.slice(a,o);t.push(r),a=o+1,"\r"===e[a-1]&&"\n"===e[a]&&a++}}return[t,r]}(`${o}${t}`);for(const e of r)d(e);o=a,n=!1},reset:function(e={}){o&&e.consume&&d(o),n=!0,i=void 0,l="",c="",o=""}}}class ai extends TransformStream{constructor({onError:e,onRetry:t,onComment:r}={}){let a;super({start(s){a=ri({onEvent:e=>{s.enqueue(e)},onError(t){"terminate"===e?s.error(t):"function"==typeof e&&e(t)},onRetry:t,onComment:r})},transform(e){a.feed(e)}})}}const si={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class ii extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}}class oi{constructor(e,t){var r;this._url=e,this._resourceMetadataUrl=void 0,this._requestInit=null==t?void 0:t.requestInit,this._authProvider=null==t?void 0:t.authProvider,this._sessionId=null==t?void 0:t.sessionId,this._reconnectionOptions=null!==(r=null==t?void 0:t.reconnectionOptions)&&void 0!==r?r:si}async _authThenStart(){var e;if(!this._authProvider)throw new Ys("No auth provider");let t;try{t=await Xs(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl})}catch(t){throw null===(e=this.onerror)||void 0===e||e.call(this,t),t}if("AUTHORIZED"!==t)throw new Ys;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var e;const t={};if(this._authProvider){const e=await this._authProvider.tokens();e&&(t.Authorization=`Bearer ${e.access_token}`)}return this._sessionId&&(t["mcp-session-id"]=this._sessionId),new Headers({...t,...null===(e=this._requestInit)||void 0===e?void 0:e.headers})}async _startOrAuthSse(e){var t,r;const{resumptionToken:a}=e;try{const r=await this._commonHeaders();r.set("Accept","text/event-stream"),a&&r.set("last-event-id",a);const s=await fetch(this._url,{method:"GET",headers:r,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal});if(!s.ok){if(401===s.status&&this._authProvider)return await this._authThenStart();if(405===s.status)return;throw new ii(s.status,`Failed to open SSE stream: ${s.statusText}`)}this._handleSseStream(s.body,e)}catch(e){throw null===(r=this.onerror)||void 0===r||r.call(this,e),e}}_getNextReconnectionDelay(e){const t=this._reconnectionOptions.initialReconnectionDelay,r=this._reconnectionOptions.reconnectionDelayGrowFactor,a=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(r,e),a)}_scheduleReconnection(e,t=0){var r;const a=this._reconnectionOptions.maxRetries;if(a>0&&t>=a)return void(null===(r=this.onerror)||void 0===r||r.call(this,new Error(`Maximum reconnection attempts (${a}) exceeded.`)));const s=this._getNextReconnectionDelay(t);setTimeout((()=>{this._startOrAuthSse(e).catch((r=>{var a;null===(a=this.onerror)||void 0===a||a.call(this,new Error(`Failed to reconnect SSE stream: ${r instanceof Error?r.message:String(r)}`)),this._scheduleReconnection(e,t+1)}))}),s)}_handleSseStream(e,t){if(!e)return;const{onresumptiontoken:r,replayMessageId:a}=t;let s;(async()=>{var t,i,o,n;try{const o=e.pipeThrough(new TextDecoderStream).pipeThrough(new ai).getReader();for(;;){const{value:e,done:n}=await o.read();if(n)break;if(e.id&&(s=e.id,null==r||r(e.id)),!e.event||"message"===e.event)try{const r=ct.parse(JSON.parse(e.data));void 0!==a&&ot(r)&&(r.id=a),null===(t=this.onmessage)||void 0===t||t.call(this,r)}catch(e){null===(i=this.onerror)||void 0===i||i.call(this,e)}}}catch(e){if(null===(o=this.onerror)||void 0===o||o.call(this,new Error(`SSE stream disconnected: ${e}`)),this._abortController&&!this._abortController.signal.aborted&&void 0!==s)try{this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:a},0)}catch(e){null===(n=this.onerror)||void 0===n||n.call(this,new Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new Ys("No auth provider");if("AUTHORIZED"!==await Xs(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl}))throw new Ys("Failed to authorize")}async close(){var e,t;null===(e=this._abortController)||void 0===e||e.abort(),null===(t=this.onclose)||void 0===t||t.call(this)}async send(e,t){var r,a,s,i;try{const{resumptionToken:s,onresumptiontoken:o}=t||{};if(s)return void this._startOrAuthSse({resumptionToken:s,replayMessageId:at(e)?e.id:void 0}).catch((e=>{var t;return null===(t=this.onerror)||void 0===t?void 0:t.call(this,e)}));const n=await this._commonHeaders();n.set("content-type","application/json"),n.set("accept","application/json, text/event-stream");const l={...this._requestInit,method:"POST",headers:n,body:JSON.stringify(e),signal:null===(r=this._abortController)||void 0===r?void 0:r.signal},c=await fetch(this._url,l),d=c.headers.get("mcp-session-id");if(d&&(this._sessionId=d),!c.ok){if(401===c.status&&this._authProvider){this._resourceMetadataUrl=function(e){const t=e.headers.get("WWW-Authenticate");if(!t)return;const[r,a]=t.split(" ");if("bearer"!==r.toLowerCase()||!a)return void console.log("Invalid WWW-Authenticate header format, expected 'Bearer'");const s=/resource_metadata="([^"]*)"/.exec(t);if(s)try{return new URL(s[1])}catch(e){return void console.log("Invalid resource metadata url: ",s[1])}}(c);if("AUTHORIZED"!==await Xs(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl}))throw new Ys;return this.send(e)}const t=await c.text().catch((()=>null));throw new Error(`Error POSTing to endpoint (HTTP ${c.status}): ${t}`)}if(202===c.status)return i=e,void(yt.safeParse(i).success&&this._startOrAuthSse({resumptionToken:void 0}).catch((e=>{var t;return null===(t=this.onerror)||void 0===t?void 0:t.call(this,e)})));const u=(Array.isArray(e)?e:[e]).filter((e=>"method"in e&&"id"in e&&void 0!==e.id)).length>0,h=c.headers.get("content-type");if(u)if(null==h?void 0:h.includes("text/event-stream"))this._handleSseStream(c.body,{onresumptiontoken:o});else{if(!(null==h?void 0:h.includes("application/json")))throw new ii(-1,`Unexpected content type: ${h}`);{const e=await c.json(),t=Array.isArray(e)?e.map((e=>ct.parse(e))):[ct.parse(e)];for(const e of t)null===(a=this.onmessage)||void 0===a||a.call(this,e)}}}catch(e){throw null===(s=this.onerror)||void 0===s||s.call(this,e),e}}get sessionId(){return this._sessionId}async terminateSession(){var e,t;if(this._sessionId)try{const t=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:t,signal:null===(e=this._abortController)||void 0===e?void 0:e.signal},a=await fetch(this._url,r);if(!a.ok&&405!==a.status)throw new ii(a.status,`Failed to terminate session: ${a.statusText}`);this._sessionId=void 0}catch(e){throw null===(t=this.onerror)||void 0===t||t.call(this,e),e}}}class ni{static async init(e){if(!(null==e?void 0:e.apiKey))throw new Error("MboaAI-SDK: apiKey is required");if(ni.ready)return;const{apiKey:t,mcpUrl:r="https://api.filparty.com:8001/mcp",name:a="MboaAI-SDK",version:s="1.0.0",defaultType:i="standard"}=e,o=new oi(new URL(r),{requestInit:{headers:{"x-api-key":t}}}),n=new Hs({name:a,version:s});await n.connect(o),ni.client=n,ni.apiKey=t,ni.defaultType=i,ni.ready=!0}static async translate(e,t,r){var a,s;if(!ni.ready)throw new Error("MboaAI-SDK: call init() first");const i=`Translate "${e}" into ${t} for ${null!=r?r:ni.defaultType}`;try{const t=await ni.client.callTool({name:"run_translate",arguments:{message:i,api_key:ni.apiKey}}),r=null==t?void 0:t.content,o=String(null!==(s=null===(a=null==r?void 0:r[0])||void 0===a?void 0:a.text)&&void 0!==s?s:"");if((e=>{const t=e.trim().charAt(0);return"{"===t||"["===t})(o))try{const t=JSON.parse(o);return t.reply||t.text||e}catch(e){}return o||e}catch(t){return console.error("[MboaAI-SDK] translate error → returning source",t),e}}}ni.ready=!1,ni.defaultType="standard",ni.apiKey="","undefined"!=typeof window&&(window.MboaAI=window.MboaAI||{},window.MboaAI.T=ni);export{ni as T,ni as default};
|