import e from"child_process";import t from"path";import r from"fs";import n from"node:process";import{PassThrough as o}from"node:stream";const s=Object.freeze({status:"aborted"});function a(e,t,r){function n(r,n){var o;Object.defineProperty(r,"_zod",{value:r._zod??{},enumerable:!1}),(o=r._zod).traits??(o.traits=new Set),r._zod.traits.add(e),t(r,n);for(const e in a.prototype)e in r||Object.defineProperty(r,e,{value:a.prototype[e].bind(r)});r._zod.constr=a,r._zod.def=n}const o=r?.Parent??Object;class s extends o{}function a(e){var t;const o=r?.Parent?new s:this;n(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const e of o._zod.deferred)e();return o}return Object.defineProperty(s,"name",{value:e}),Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:t=>!!(r?.Parent&&t instanceof r.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}class i extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const c={};function u(e){return c}function d(e,t){return"bigint"==typeof t?t.toString():t}function l(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function p(e){return null==e}function h(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function f(e,t,r){Object.defineProperty(e,t,{get(){{const n=r();return e[t]=n,n}},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function m(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function _(e){return JSON.stringify(e)}const y=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function v(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const g=l(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function w(e){if(!1===v(e))return!1;const t=e.constructor;if(void 0===t)return!0;const r=t.prototype;return!1!==v(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}const $=new Set(["string","number","symbol"]);function b(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k(e,t,r){const n=new e._zod.constr(t??e._zod.def);return t&&!r?.parent||(n._zod.parent=e),n}function E(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const S={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function P(e,t=0){for(let r=t;r{var r;return(r=t).path??(r.path=[]),t.path.unshift(e),t})}function x(e){return"string"==typeof e?e:e?.message}function I(e,t,r){const n={...e,path:e.path??[]};if(!e.message){const o=x(e.inst?._zod.def?.error?.(e))??x(t?.error?.(e))??x(r.customError?.(e))??x(r.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function C(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function z(...e){const[t,r,n]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:n}:{...t}}const N=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get:()=>JSON.stringify(t,d,2),enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},R=a("$ZodError",N),O=a("$ZodError",N,{Parent:Error});const j=e=>(t,r,n,o)=>{const s=n?Object.assign(n,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new i;if(a.issues.length){const t=new(o?.Err??e)(a.issues.map(e=>I(e,s,u())));throw y(t,o?.callee),t}return a.value},A=e=>async(t,r,n,o)=>{const s=n?Object.assign(n,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const t=new(o?.Err??e)(a.issues.map(e=>I(e,s,u())));throw y(t,o?.callee),t}return a.value},M=e=>(t,r,n)=>{const o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new i;return s.issues.length?{success:!1,error:new(e??R)(s.issues.map(e=>I(e,o,u())))}:{success:!0,data:s.value}},q=M(O),U=e=>async(t,r,n)=>{const o=n?Object.assign(n,{async:!0}):{async:!0};let s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(e=>I(e,o,u())))}:{success:!0,data:s.value}},D=U(O),V=/^[cC][^\s-]{8,}$/,F=/^[0-9a-z]+$/,L=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Z=/^[0-9a-vA-V]{20}$/,H=/^[A-Za-z0-9]{27}$/,K=/^[a-zA-Z0-9_-]{21}$/,W=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,G=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,J=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/,B=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const Q=/^(?:(?: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])$/,Y=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,X=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ee=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,te=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,re=/^[A-Za-z0-9_-]*$/,ne=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,oe=/^\+(?:[0-9]){6,14}[0-9]$/,se="(?:(?:\\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])))",ae=new RegExp(`^${se}$`);function ie(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const ce=/^\d+$/,ue=/^-?\d+(?:\.\d+)?/i,de=/true|false/i,le=/null/i,pe=/^[^A-Z]*$/,he=/^[^a-z]*$/,fe=a("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),me={number:"number",bigint:"bigint",object:"date"},_e=a("$ZodCheckLessThan",(e,t)=>{fe.init(e,t);const r=me[typeof t.value];e._zod.onattach.push(e=>{const r=e._zod.bag,n=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value{(t.inclusive?n.value<=t.value:n.value{fe.init(e,t);const r=me[typeof t.value];e._zod.onattach.push(e=>{const r=e._zod.bag,n=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>n&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ve=a("$ZodCheckMultipleOf",(e,t)=>{fe.init(e,t),e._zod.onattach.push(e=>{var r;(r=e._zod.bag).multipleOf??(r.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof r.value?r.value%t.value===BigInt(0):0===function(e,t){const r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n;return Number.parseInt(e.toFixed(o).replace(".",""))%Number.parseInt(t.toFixed(o).replace(".",""))/10**o}(r.value,t.value))||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),ge=a("$ZodCheckNumberFormat",(e,t)=>{fe.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),n=r?"int":"number",[o,s]=S[t.format];e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,n.minimum=o,n.maximum=s,r&&(n.pattern=ce)}),e._zod.check=a=>{const i=a.value;if(r){if(!Number.isInteger(i))return void a.issues.push({expected:n,format:t.format,code:"invalid_type",input:i,inst:e});if(!Number.isSafeInteger(i))return void(i>0?a.issues.push({input:i,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):a.issues.push({input:i,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}))}is&&a.issues.push({origin:"number",input:i,code:"too_big",maximum:s,inst:e})}}),we=a("$ZodCheckMaxLength",(e,t)=>{var r;fe.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!p(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum{const n=r.value;if(n.length<=t.maximum)return;const o=C(n);r.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),$e=a("$ZodCheckMinLength",(e,t)=>{var r;fe.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!p(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{const n=r.value;if(n.length>=t.minimum)return;const o=C(n);r.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),be=a("$ZodCheckLengthEquals",(e,t)=>{var r;fe.init(e,t),(r=e._zod.def).when??(r.when=e=>{const t=e.value;return!p(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const r=e._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=r=>{const n=r.value,o=n.length;if(o===t.length)return;const s=C(n),a=o>t.length;r.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),ke=a("$ZodCheckStringFormat",(e,t)=>{var r,n;fe.init(e,t),e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Ee=a("$ZodCheckRegex",(e,t)=>{ke.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Se=a("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=pe),ke.init(e,t)}),Pe=a("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=he),ke.init(e,t)}),Te=a("$ZodCheckIncludes",(e,t)=>{fe.init(e,t);const r=b(t.includes),n=new RegExp("number"==typeof t.position?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),xe=a("$ZodCheckStartsWith",(e,t)=>{fe.init(e,t);const r=new RegExp(`^${b(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Ie=a("$ZodCheckEndsWith",(e,t)=>{fe.init(e,t);const r=new RegExp(`.*${b(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),Ce=a("$ZodCheckOverwrite",(e,t)=>{fe.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class ze{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length)),n=t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e);for(const e of n)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const Ne={major:4,minor:0,patch:0},Re=a("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ne;const n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(const t of n)for(const r of t._zod.onattach)r(e);if(0===n.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const t=(e,t,r)=>{let n,o=P(e);for(const s of t){if(s._zod.def.when){if(!s._zod.def.when(e))continue}else if(o)continue;const t=e.issues.length,a=s._zod.check(e);if(a instanceof Promise&&!1===r?.async)throw new i;if(n||a instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await a;e.issues.length!==t&&(o||(o=P(e,t)))});else{if(e.issues.length===t)continue;o||(o=P(e,t))}}return n?n.then(()=>e):e};e._zod.run=(r,o)=>{const s=e._zod.parse(r,o);if(s instanceof Promise){if(!1===o.async)throw new i;return s.then(e=>t(e,n,o))}return t(s,n,o)}}e["~standard"]={validate:t=>{try{const r=q(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return D(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),Oe=a("$ZodString",(e,t)=>{var r;Re.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(r=e._zod.bag,new RegExp(`^${r?`[\\s\\S]{${r?.minimum??0},${r?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(n){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),je=a("$ZodStringFormat",(e,t)=>{ke.init(e,t),Oe.init(e,t)}),Ae=a("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=G),je.init(e,t)}),Me=a("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=J(e))}else t.pattern??(t.pattern=J());je.init(e,t)}),qe=a("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=B),je.init(e,t)}),Ue=a("$ZodURL",(e,t)=>{je.init(e,t),e._zod.check=r=>{try{const n=r.value,o=new URL(n),s=o.href;return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:ne.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),void(!n.endsWith("/")&&s.endsWith("/")?r.value=s.slice(0,-1):r.value=s)}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),De=a("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),je.init(e,t)}),Ve=a("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=K),je.init(e,t)}),Fe=a("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=V),je.init(e,t)}),Le=a("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=F),je.init(e,t)}),Ze=a("$ZodULID",(e,t)=>{t.pattern??(t.pattern=L),je.init(e,t)}),He=a("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Z),je.init(e,t)}),Ke=a("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=H),je.init(e,t)}),We=a("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=ie({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-]\\d{2}:\\d{2})");const n=`${t}(?:${r.join("|")})`;return new RegExp(`^${se}T(?:${n})$`)}(t)),je.init(e,t)}),Ge=a("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=ae),je.init(e,t)}),Je=a("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${ie(t)}$`)),je.init(e,t)}),Be=a("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=W),je.init(e,t)}),Qe=a("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Q),je.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv4"})}),Ye=a("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Y),je.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Xe=a("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=X),je.init(e,t)}),et=a("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ee),je.init(e,t),e._zod.check=r=>{const[n,o]=r.value.split("/");try{if(!o)throw new Error;const e=Number(o);if(`${e}`!==o)throw new Error;if(e<0||e>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function tt(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const rt=a("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=te),je.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{tt(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});const nt=a("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=re),je.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{(function(e){if(!re.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return tt(t.padEnd(4*Math.ceil(t.length/4),"="))})(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),ot=a("$ZodE164",(e,t)=>{t.pattern??(t.pattern=oe),je.init(e,t)});const st=a("$ZodJWT",(e,t)=>{je.init(e,t),e._zod.check=r=>{(function(e,t=null){try{const r=e.split(".");if(3!==r.length)return!1;const[n]=r;if(!n)return!1;const o=JSON.parse(atob(n));return!("typ"in o&&"JWT"!==o?.typ||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}})(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),at=a("$ZodNumber",(e,t)=>{Re.init(e,t),e._zod.pattern=e._zod.bag.pattern??ue,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch(e){}const o=r.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return r;const s="number"==typeof o?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),it=a("$ZodNumber",(e,t)=>{ge.init(e,t),at.init(e,t)}),ct=a("$ZodBoolean",(e,t)=>{Re.init(e,t),e._zod.pattern=de,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Boolean(r.value)}catch(e){}const o=r.value;return"boolean"==typeof o||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),ut=a("$ZodNull",(e,t)=>{Re.init(e,t),e._zod.pattern=le,e._zod.values=new Set([null]),e._zod.parse=(t,r)=>{const n=t.value;return null===n||t.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),t}}),dt=a("$ZodAny",(e,t)=>{Re.init(e,t),e._zod.parse=e=>e}),lt=a("$ZodUnknown",(e,t)=>{Re.init(e,t),e._zod.parse=e=>e}),pt=a("$ZodNever",(e,t)=>{Re.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function ht(e,t,r){e.issues.length&&t.issues.push(...T(r,e.issues)),t.value[r]=e.value}const ft=a("$ZodArray",(e,t)=>{Re.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);const s=[];for(let e=0;eht(t,r,e))):ht(i,r,e)}return s.length?Promise.all(s).then(()=>r):r}});function mt(e,t,r){e.issues.length&&t.issues.push(...T(r,e.issues)),t.value[r]=e.value}function _t(e,t,r,n){e.issues.length?void 0===n[r]?t.value[r]=r in n?void 0:e.value:t.issues.push(...T(r,e.issues)):void 0===e.value?r in n&&(t.value[r]=void 0):t.value[r]=e.value}const yt=a("$ZodObject",(e,t)=>{Re.init(e,t);const r=l(()=>{const e=Object.keys(t.shape);for(const r of e)if(!(t.shape[r]instanceof Re))throw new Error(`Invalid element at key "${r}": expected a Zod schema`);const r=(n=t.shape,Object.keys(n).filter(e=>"optional"===n[e]._zod.optin&&"optional"===n[e]._zod.optout));var n;return{shape:t.shape,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}});f(e._zod,"propValues",()=>{const e=t.shape,r={};for(const t in e){const n=e[t]._zod;if(n.values){r[t]??(r[t]=new Set);for(const e of n.values)r[t].add(e)}}return r});let n;const o=v,s=!c.jitless,a=s&&g.value,i=t.catchall;let u;e._zod.parse=(c,d)=>{u??(u=r.value);const l=c.value;if(!o(l))return c.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),c;const p=[];if(s&&a&&!1===d?.async&&!0!==d.jitless)n||(n=(e=>{const t=new ze(["shape","payload","ctx"]),n=r.value,o=e=>{const t=_(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const s=Object.create(null);let a=0;for(const e of n.keys)s[e]="key_"+a++;t.write("const newResult = {}");for(const e of n.keys)if(n.optionalKeys.has(e)){const r=s[e];t.write(`const ${r} = ${o(e)};`);const n=_(e);t.write(`\n if (${r}.issues.length) {\n if (input[${n}] === undefined) {\n if (${n} in input) {\n newResult[${n}] = undefined;\n }\n } else {\n payload.issues = payload.issues.concat(\n ${r}.issues.map((iss) => ({\n ...iss,\n path: iss.path ? [${n}, ...iss.path] : [${n}],\n }))\n );\n }\n } else if (${r}.value === undefined) {\n if (${n} in input) newResult[${n}] = undefined;\n } else {\n newResult[${n}] = ${r}.value;\n }\n `)}else{const r=s[e];t.write(`const ${r} = ${o(e)};`),t.write(`\n if (${r}.issues.length) payload.issues = payload.issues.concat(${r}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${_(e)}, ...iss.path] : [${_(e)}]\n })));`),t.write(`newResult[${_(e)}] = ${r}.value`)}t.write("payload.value = newResult;"),t.write("return payload;");const i=t.compile();return(t,r)=>i(e,t,r)})(t.shape)),c=n(c,d);else{c.value={};const e=u.shape;for(const t of u.keys){const r=e[t],n=r._zod.run({value:l[t],issues:[]},d),o="optional"===r._zod.optin&&"optional"===r._zod.optout;n instanceof Promise?p.push(n.then(e=>o?_t(e,c,t,l):mt(e,c,t))):o?_t(n,c,t,l):mt(n,c,t)}}if(!i)return p.length?Promise.all(p).then(()=>c):c;const h=[],f=u.keySet,m=i._zod,y=m.def.type;for(const e of Object.keys(l)){if(f.has(e))continue;if("never"===y){h.push(e);continue}const t=m.run({value:l[e],issues:[]},d);t instanceof Promise?p.push(t.then(t=>mt(t,c,e))):mt(t,c,e)}return h.length&&c.issues.push({code:"unrecognized_keys",keys:h,input:l,inst:e}),p.length?Promise.all(p).then(()=>c):c}});function vt(e,t,r,n){for(const r of e)if(0===r.issues.length)return t.value=r.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(e=>e.issues.map(e=>I(e,n,u())))}),t}const gt=a("$ZodUnion",(e,t)=>{Re.init(e,t),f(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),f(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),f(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),f(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>h(e.source)).join("|")})$`)}}),e._zod.parse=(r,n)=>{let o=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:r.value,issues:[]},n);if(t instanceof Promise)s.push(t),o=!0;else{if(0===t.issues.length)return t;s.push(t)}}return o?Promise.all(s).then(t=>vt(t,r,e,n)):vt(s,r,e,n)}}),wt=a("$ZodDiscriminatedUnion",(e,t)=>{gt.init(e,t);const r=e._zod.parse;f(e._zod,"propValues",()=>{const e={};for(const r of t.options){const n=r._zod.propValues;if(!n||0===Object.keys(n).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(const[t,r]of Object.entries(n)){e[t]||(e[t]=new Set);for(const n of r)e[t].add(n)}}return e});const n=l(()=>{const e=t.options,r=new Map;for(const n of e){const e=n._zod.propValues[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const t of e){if(r.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);r.set(t,n)}}return r});e._zod.parse=(o,s)=>{const a=o.value;if(!v(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const i=n.value.get(a?.[t.discriminator]);return i?i._zod.run(o,s):t.unionFallback?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:a,path:[t.discriminator],inst:e}),o)}}),$t=a("$ZodIntersection",(e,t)=>{Re.init(e,t),e._zod.parse=(e,r)=>{const n=e.value,o=t.left._zod.run({value:n,issues:[]},r),s=t.right._zod.run({value:n,issues:[]},r);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([t,r])=>kt(e,t,r)):kt(e,o,s)}});function bt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(w(e)&&w(t)){const r=Object.keys(t),n=Object.keys(e).filter(e=>-1!==r.indexOf(e)),o={...e,...t};for(const r of n){const n=bt(e[r],t[r]);if(!n.valid)return{valid:!1,mergeErrorPath:[r,...n.mergeErrorPath]};o[r]=n.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let n=0;n{Re.init(e,t),e._zod.parse=(r,n)=>{const o=r.value;if(!w(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;const s=[];if(t.keyType._zod.values){const a=t.keyType._zod.values;r.value={};for(const e of a)if("string"==typeof e||"number"==typeof e||"symbol"==typeof e){const a=t.valueType._zod.run({value:o[e],issues:[]},n);a instanceof Promise?s.push(a.then(t=>{t.issues.length&&r.issues.push(...T(e,t.issues)),r.value[e]=t.value})):(a.issues.length&&r.issues.push(...T(e,a.issues)),r.value[e]=a.value)}let i;for(const e in o)a.has(e)||(i=i??[],i.push(e));i&&i.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:i})}else{r.value={};for(const a of Reflect.ownKeys(o)){if("__proto__"===a)continue;const i=t.keyType._zod.run({value:a,issues:[]},n);if(i instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(i.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:i.issues.map(e=>I(e,n,u())),input:a,path:[a],inst:e}),r.value[i.value]=i.value;continue}const c=t.valueType._zod.run({value:o[a],issues:[]},n);c instanceof Promise?s.push(c.then(e=>{e.issues.length&&r.issues.push(...T(a,e.issues)),r.value[i.value]=e.value})):(c.issues.length&&r.issues.push(...T(a,c.issues)),r.value[i.value]=c.value)}}return s.length?Promise.all(s).then(()=>r):r}}),St=a("$ZodEnum",(e,t)=>{Re.init(e,t);const r=function(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(e=>$.has(typeof e)).map(e=>"string"==typeof e?b(e):e.toString()).join("|")})$`),e._zod.parse=(t,n)=>{const o=t.value;return e._zod.values.has(o)||t.issues.push({code:"invalid_value",values:r,input:o,inst:e}),t}}),Pt=a("$ZodLiteral",(e,t)=>{Re.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?b(e):e?e.toString():String(e)).join("|")})$`),e._zod.parse=(r,n)=>{const o=r.value;return e._zod.values.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),Tt=a("$ZodTransform",(e,t)=>{Re.init(e,t),e._zod.parse=(e,r)=>{const n=t.transform(e.value,e);if(r.async){return(n instanceof Promise?n:Promise.resolve(n)).then(t=>(e.value=t,e))}if(n instanceof Promise)throw new i;return e.value=n,e}}),xt=a("$ZodOptional",(e,t)=>{Re.init(e,t),e._zod.optin="optional",e._zod.optout="optional",f(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),f(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${h(e.source)})?$`):void 0}),e._zod.parse=(e,r)=>"optional"===t.innerType._zod.optin?t.innerType._zod.run(e,r):void 0===e.value?e:t.innerType._zod.run(e,r)}),It=a("$ZodNullable",(e,t)=>{Re.init(e,t),f(e._zod,"optin",()=>t.innerType._zod.optin),f(e._zod,"optout",()=>t.innerType._zod.optout),f(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${h(e.source)}|null)$`):void 0}),f(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,r)=>null===e.value?e:t.innerType._zod.run(e,r)}),Ct=a("$ZodDefault",(e,t)=>{Re.init(e,t),e._zod.optin="optional",f(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>{if(void 0===e.value)return e.value=t.defaultValue,e;const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(e=>zt(e,t)):zt(n,t)}});function zt(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Nt=a("$ZodPrefault",(e,t)=>{Re.init(e,t),e._zod.optin="optional",f(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>(void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),Rt=a("$ZodNonOptional",(e,t)=>{Re.init(e,t),f(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(r,n)=>{const o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(t=>Ot(t,e)):Ot(o,e)}});function Ot(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const jt=a("$ZodCatch",(e,t)=>{Re.init(e,t),e._zod.optin="optional",f(e._zod,"optout",()=>t.innerType._zod.optout),f(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>{const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(n=>(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>I(e,r,u()))},input:e.value}),e.issues=[]),e)):(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>I(e,r,u()))},input:e.value}),e.issues=[]),e)}}),At=a("$ZodPipe",(e,t)=>{Re.init(e,t),f(e._zod,"values",()=>t.in._zod.values),f(e._zod,"optin",()=>t.in._zod.optin),f(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(e,r)=>{const n=t.in._zod.run(e,r);return n instanceof Promise?n.then(e=>Mt(e,t,r)):Mt(n,t,r)}});function Mt(e,t,r){return P(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}const qt=a("$ZodReadonly",(e,t)=>{Re.init(e,t),f(e._zod,"propValues",()=>t.innerType._zod.propValues),f(e._zod,"values",()=>t.innerType._zod.values),f(e._zod,"optin",()=>t.innerType._zod.optin),f(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(e,r)=>{const n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(Ut):Ut(n)}});function Ut(e){return e.value=Object.freeze(e.value),e}const Dt=a("$ZodCustom",(e,t)=>{fe.init(e,t),Re.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=r=>{const n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(t=>Vt(t,r,n,e));Vt(o,r,n,e)}});function Vt(e,t,r,n){if(!e){const e={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(e.params=n._zod.def.params),t.issues.push(z(e))}}class Ft{constructor(){this._map=new Map,this._idmap=new Map}add(e,...t){const r=t[0];if(this._map.set(e,r),r&&"object"==typeof r&&"id"in r){if(this._idmap.has(r.id))throw new Error(`ID ${r.id} already exists in the registry`);this._idmap.set(r.id,e)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const r={...this.get(t)??{}};return delete r.id,{...r,...this._map.get(e)}}return this._map.get(e)}has(e){return this._map.has(e)}}function Lt(){return new Ft}const Zt=Lt();function Ht(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...E(t)})}function Kt(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...E(t)})}function Wt(e,t){return new _e({check:"less_than",...E(t),value:e,inclusive:!1})}function Gt(e,t){return new _e({check:"less_than",...E(t),value:e,inclusive:!0})}function Jt(e,t){return new ye({check:"greater_than",...E(t),value:e,inclusive:!1})}function Bt(e,t){return new ye({check:"greater_than",...E(t),value:e,inclusive:!0})}function Qt(e,t){return new ve({check:"multiple_of",...E(t),value:e})}function Yt(e,t){return new we({check:"max_length",...E(t),maximum:e})}function Xt(e,t){return new $e({check:"min_length",...E(t),minimum:e})}function er(e,t){return new be({check:"length_equals",...E(t),length:e})}function tr(e){return new Ce({check:"overwrite",tx:e})}function rr(e){return!!e._zod}function nr(e,t){if(rr(e)){return q(e,t)}return e.safeParse(t)}function or(e){if(!e)return;let t;if(rr(e)){const r=e;t=r._zod?.def?.shape}else{t=e.shape}if(t){if("function"==typeof t)try{return t()}catch{return}return t}}const sr=a("ZodISODateTime",(e,t)=>{We.init(e,t),br.init(e,t)});function ar(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...E(t)})}(sr,e)}const ir=a("ZodISODate",(e,t)=>{Ge.init(e,t),br.init(e,t)});function cr(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...E(t)})}(ir,e)}const ur=a("ZodISOTime",(e,t)=>{Je.init(e,t),br.init(e,t)});function dr(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...E(t)})}(ur,e)}const lr=a("ZodISODuration",(e,t)=>{Be.init(e,t),br.init(e,t)});function pr(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...E(t)})}(lr,e)}const hr=a("ZodError",(e,t)=>{R.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t){const r=t||function(e){return e.message},n={_errors:[]},o=e=>{for(const t of e.issues)if("invalid_union"===t.code&&t.errors.length)t.errors.map(e=>o({issues:e}));else if("invalid_key"===t.code)o({issues:t.issues});else if("invalid_element"===t.code)o({issues:t.issues});else if(0===t.path.length)n._errors.push(r(t));else{let e=n,o=0;for(;ofunction(e,t=e=>e.message){const r={},n=[];for(const o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}(e,t)},addIssue:{value:t=>e.issues.push(t)},addIssues:{value:t=>e.issues.push(...t)},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),fr=j(hr),mr=A(hr),_r=M(hr),yr=U(hr),vr=a("ZodType",(e,t)=>(Re.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),e.clone=(t,r)=>k(e,t,r),e.brand=()=>e,e.register=(t,r)=>(t.add(e,r),e),e.parse=(t,r)=>fr(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>_r(e,t,r),e.parseAsync=async(t,r)=>mr(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>yr(e,t,r),e.spa=e.safeParseAsync,e.refine=(t,r)=>e.check(function(e,t={}){return function(e,t,r){return new e({type:"custom",check:"custom",fn:t,...E(r)})}(Nn,e,t)}(t,r)),e.superRefine=t=>e.check(function(e){const t=function(e){const t=new fe({check:"custom"});return t._zod.check=e,t}(r=>(r.addIssue=e=>{if("string"==typeof e)r.issues.push(z(e,r.value,t._zod.def));else{const n=e;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=r.value),n.inst??(n.inst=t),n.continue??(n.continue=!t._zod.def.abort),r.issues.push(z(n))}},e(r.value,r)));return t}(t)),e.overwrite=t=>e.check(tr(t)),e.optional=()=>bn(e),e.nullable=()=>En(e),e.nullish=()=>bn(En(e)),e.nonoptional=t=>function(e,t){return new Tn({type:"nonoptional",innerType:e,...E(t)})}(e,t),e.array=()=>rn(e),e.or=t=>cn([e,t]),e.and=t=>pn(e,t),e.transform=t=>Cn(e,wn(t)),e.default=t=>{return r=t,new Sn({type:"default",innerType:e,get defaultValue(){return"function"==typeof r?r():r}});var r},e.prefault=t=>{return r=t,new Pn({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof r?r():r}});var r},e.catch=t=>{return new xn({type:"catch",innerType:e,catchValue:"function"==typeof(r=t)?r:()=>r});var r},e.pipe=t=>Cn(e,t),e.readonly=()=>new zn({type:"readonly",innerType:e}),e.describe=t=>{const r=e.clone();return Zt.add(r,{description:t}),r},Object.defineProperty(e,"description",{get:()=>Zt.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return Zt.get(e);const r=e.clone();return Zt.add(r,t[0]),r},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),gr=a("_ZodString",(e,t)=>{Oe.init(e,t),vr.init(e,t);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new Ee({check:"string_format",format:"regex",...E(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new Te({check:"string_format",format:"includes",...E(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new xe({check:"string_format",format:"starts_with",...E(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Ie({check:"string_format",format:"ends_with",...E(t),suffix:e})}(...t)),e.min=(...t)=>e.check(Xt(...t)),e.max=(...t)=>e.check(Yt(...t)),e.length=(...t)=>e.check(er(...t)),e.nonempty=(...t)=>e.check(Xt(1,...t)),e.lowercase=t=>e.check(function(e){return new Se({check:"string_format",format:"lowercase",...E(e)})}(t)),e.uppercase=t=>e.check(function(e){return new Pe({check:"string_format",format:"uppercase",...E(e)})}(t)),e.trim=()=>e.check(tr(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return tr(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(tr(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(tr(e=>e.toUpperCase()))}),wr=a("ZodString",(e,t)=>{Oe.init(e,t),gr.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...E(t)})}(kr,t)),e.url=t=>e.check(Kt(Pr,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...E(t)})}(Vr,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...E(t)})}(Tr,t)),e.guid=t=>e.check(Ht(Er,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...E(t)})}(Sr,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...E(t)})}(Sr,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...E(t)})}(Sr,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...E(t)})}(Sr,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...E(t)})}(xr,t)),e.guid=t=>e.check(Ht(Er,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...E(t)})}(Ir,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...E(t)})}(Cr,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...E(t)})}(zr,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...E(t)})}(qr,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...E(t)})}(Ur,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...E(t)})}(Nr,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...E(t)})}(Rr,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...E(t)})}(Or,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...E(t)})}(jr,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...E(t)})}(Ar,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...E(t)})}(Mr,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...E(t)})}(Dr,t)),e.datetime=t=>e.check(ar(t)),e.date=t=>e.check(cr(t)),e.time=t=>e.check(dr(t)),e.duration=t=>e.check(pr(t))});function $r(e){return function(e,t){return new e({type:"string",...E(t)})}(wr,e)}const br=a("ZodStringFormat",(e,t)=>{je.init(e,t),gr.init(e,t)}),kr=a("ZodEmail",(e,t)=>{qe.init(e,t),br.init(e,t)}),Er=a("ZodGUID",(e,t)=>{Ae.init(e,t),br.init(e,t)}),Sr=a("ZodUUID",(e,t)=>{Me.init(e,t),br.init(e,t)}),Pr=a("ZodURL",(e,t)=>{Ue.init(e,t),br.init(e,t)});const Tr=a("ZodEmoji",(e,t)=>{De.init(e,t),br.init(e,t)}),xr=a("ZodNanoID",(e,t)=>{Ve.init(e,t),br.init(e,t)}),Ir=a("ZodCUID",(e,t)=>{Fe.init(e,t),br.init(e,t)}),Cr=a("ZodCUID2",(e,t)=>{Le.init(e,t),br.init(e,t)}),zr=a("ZodULID",(e,t)=>{Ze.init(e,t),br.init(e,t)}),Nr=a("ZodXID",(e,t)=>{He.init(e,t),br.init(e,t)}),Rr=a("ZodKSUID",(e,t)=>{Ke.init(e,t),br.init(e,t)}),Or=a("ZodIPv4",(e,t)=>{Qe.init(e,t),br.init(e,t)}),jr=a("ZodIPv6",(e,t)=>{Ye.init(e,t),br.init(e,t)}),Ar=a("ZodCIDRv4",(e,t)=>{Xe.init(e,t),br.init(e,t)}),Mr=a("ZodCIDRv6",(e,t)=>{et.init(e,t),br.init(e,t)}),qr=a("ZodBase64",(e,t)=>{rt.init(e,t),br.init(e,t)}),Ur=a("ZodBase64URL",(e,t)=>{nt.init(e,t),br.init(e,t)}),Dr=a("ZodE164",(e,t)=>{ot.init(e,t),br.init(e,t)}),Vr=a("ZodJWT",(e,t)=>{st.init(e,t),br.init(e,t)}),Fr=a("ZodNumber",(e,t)=>{at.init(e,t),vr.init(e,t),e.gt=(t,r)=>e.check(Jt(t,r)),e.gte=(t,r)=>e.check(Bt(t,r)),e.min=(t,r)=>e.check(Bt(t,r)),e.lt=(t,r)=>e.check(Wt(t,r)),e.lte=(t,r)=>e.check(Gt(t,r)),e.max=(t,r)=>e.check(Gt(t,r)),e.int=t=>e.check(Hr(t)),e.safe=t=>e.check(Hr(t)),e.positive=t=>e.check(Jt(0,t)),e.nonnegative=t=>e.check(Bt(0,t)),e.negative=t=>e.check(Wt(0,t)),e.nonpositive=t=>e.check(Gt(0,t)),e.multipleOf=(t,r)=>e.check(Qt(t,r)),e.step=(t,r)=>e.check(Qt(t,r)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function Lr(e){return function(e,t){return new e({type:"number",checks:[],...E(t)})}(Fr,e)}const Zr=a("ZodNumberFormat",(e,t)=>{it.init(e,t),Fr.init(e,t)});function Hr(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...E(t)})}(Zr,e)}const Kr=a("ZodBoolean",(e,t)=>{ct.init(e,t),vr.init(e,t)});function Wr(e){return function(e,t){return new e({type:"boolean",...E(t)})}(Kr,e)}const Gr=a("ZodNull",(e,t)=>{ut.init(e,t),vr.init(e,t)});function Jr(e){return function(e,t){return new e({type:"null",...E(t)})}(Gr,e)}const Br=a("ZodAny",(e,t)=>{dt.init(e,t),vr.init(e,t)});const Qr=a("ZodUnknown",(e,t)=>{lt.init(e,t),vr.init(e,t)});function Yr(){return new Qr({type:"unknown"})}const Xr=a("ZodNever",(e,t)=>{pt.init(e,t),vr.init(e,t)});function en(e){return function(e,t){return new e({type:"never",...E(t)})}(Xr,e)}const tn=a("ZodArray",(e,t)=>{ft.init(e,t),vr.init(e,t),e.element=t.element,e.min=(t,r)=>e.check(Xt(t,r)),e.nonempty=t=>e.check(Xt(1,t)),e.max=(t,r)=>e.check(Yt(t,r)),e.length=(t,r)=>e.check(er(t,r)),e.unwrap=()=>e.element});function rn(e,t){return function(e,t,r){return new e({type:"array",element:t,...E(r)})}(tn,e,t)}const nn=a("ZodObject",(e,t)=>{yt.init(e,t),vr.init(e,t),f(e,"shape",()=>t.shape),e.keyof=()=>_n(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Yr()}),e.loose=()=>e.clone({...e._zod.def,catchall:Yr()}),e.strict=()=>e.clone({...e._zod.def,catchall:en()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!w(t))throw new Error("Invalid input to extend: expected a plain object");const r={...e._zod.def,get shape(){const r={...e._zod.def.shape,...t};return m(this,"shape",r),r},checks:[]};return k(e,r)}(e,t),e.merge=t=>{return n=t,k(r=e,{...r._zod.def,get shape(){const e={...r._zod.def.shape,...n._zod.def.shape};return m(this,"shape",e),e},catchall:n._zod.def.catchall,checks:[]});var r,n},e.pick=t=>function(e,t){const r={},n=e._zod.def;for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&(r[e]=n.shape[e])}return k(e,{...e._zod.def,shape:r,checks:[]})}(e,t),e.omit=t=>function(e,t){const r={...e._zod.def.shape},n=e._zod.def;for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return k(e,{...e._zod.def,shape:r,checks:[]})}(e,t),e.partial=(...t)=>function(e,t,r){const n=t._zod.def.shape,o={...n};if(r)for(const t in r){if(!(t in n))throw new Error(`Unrecognized key: "${t}"`);r[t]&&(o[t]=e?new e({type:"optional",innerType:n[t]}):n[t])}else for(const t in n)o[t]=e?new e({type:"optional",innerType:n[t]}):n[t];return k(t,{...t._zod.def,shape:o,checks:[]})}($n,e,t[0]),e.required=(...t)=>function(e,t,r){const n=t._zod.def.shape,o={...n};if(r)for(const t in r){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);r[t]&&(o[t]=new e({type:"nonoptional",innerType:n[t]}))}else for(const t in n)o[t]=new e({type:"nonoptional",innerType:n[t]});return k(t,{...t._zod.def,shape:o,checks:[]})}(Tn,e,t[0])});function on(e,t){const r={type:"object",get shape(){return m(this,"shape",{...e}),this.shape},...E(t)};return new nn(r)}function sn(e,t){return new nn({type:"object",get shape(){return m(this,"shape",{...e}),this.shape},catchall:Yr(),...E(t)})}const an=a("ZodUnion",(e,t)=>{gt.init(e,t),vr.init(e,t),e.options=t.options});function cn(e,t){return new an({type:"union",options:e,...E(t)})}const un=a("ZodDiscriminatedUnion",(e,t)=>{an.init(e,t),wt.init(e,t)});function dn(e,t,r){return new un({type:"union",options:t,discriminator:e,...E(r)})}const ln=a("ZodIntersection",(e,t)=>{$t.init(e,t),vr.init(e,t)});function pn(e,t){return new ln({type:"intersection",left:e,right:t})}const hn=a("ZodRecord",(e,t)=>{Et.init(e,t),vr.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function fn(e,t,r){return new hn({type:"record",keyType:e,valueType:t,...E(r)})}const mn=a("ZodEnum",(e,t)=>{St.init(e,t),vr.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(e,n)=>{const o={};for(const n of e){if(!r.has(n))throw new Error(`Key ${n} not found in enum`);o[n]=t.entries[n]}return new mn({...t,checks:[],...E(n),entries:o})},e.exclude=(e,n)=>{const o={...t.entries};for(const t of e){if(!r.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new mn({...t,checks:[],...E(n),entries:o})}});function _n(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new mn({type:"enum",entries:r,...E(t)})}const yn=a("ZodLiteral",(e,t)=>{Pt.init(e,t),vr.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function vn(e,t){return new yn({type:"literal",values:Array.isArray(e)?e:[e],...E(t)})}const gn=a("ZodTransform",(e,t)=>{Tt.init(e,t),vr.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=n=>{if("string"==typeof n)r.issues.push(z(n,r.value,t));else{const t=n;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=r.value),t.inst??(t.inst=e),t.continue??(t.continue=!0),r.issues.push(z(t))}};const o=t.transform(r.value,r);return o instanceof Promise?o.then(e=>(r.value=e,r)):(r.value=o,r)}});function wn(e){return new gn({type:"transform",transform:e})}const $n=a("ZodOptional",(e,t)=>{xt.init(e,t),vr.init(e,t),e.unwrap=()=>e._zod.def.innerType});function bn(e){return new $n({type:"optional",innerType:e})}const kn=a("ZodNullable",(e,t)=>{It.init(e,t),vr.init(e,t),e.unwrap=()=>e._zod.def.innerType});function En(e){return new kn({type:"nullable",innerType:e})}const Sn=a("ZodDefault",(e,t)=>{Ct.init(e,t),vr.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});const Pn=a("ZodPrefault",(e,t)=>{Nt.init(e,t),vr.init(e,t),e.unwrap=()=>e._zod.def.innerType});const Tn=a("ZodNonOptional",(e,t)=>{Rt.init(e,t),vr.init(e,t),e.unwrap=()=>e._zod.def.innerType});const xn=a("ZodCatch",(e,t)=>{jt.init(e,t),vr.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});const In=a("ZodPipe",(e,t)=>{At.init(e,t),vr.init(e,t),e.in=t.in,e.out=t.out});function Cn(e,t){return new In({type:"pipe",in:e,out:t})}const zn=a("ZodReadonly",(e,t)=>{qt.init(e,t),vr.init(e,t)});const Nn=a("ZodCustom",(e,t)=>{Dt.init(e,t),vr.init(e,t)});function Rn(e,t){return Cn(wn(e),t)}const On="custom";const jn="2025-11-25",An="2025-03-26",Mn=[jn,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],qn="io.modelcontextprotocol/related-task",Un="2.0",Dn=function(e,t,r){const n=E(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}(Nn,(e=>null!==e&&("object"==typeof e||"function"==typeof e))??(()=>!0),Vn);var Vn;const Fn=cn([$r(),Lr().int()]),Ln=$r(),Zn=sn({ttl:cn([Lr(),Jr()]).optional(),pollInterval:Lr().optional()}),Hn=on({ttl:Lr().optional()}),Kn=on({taskId:$r()}),Wn=sn({progressToken:Fn.optional(),[qn]:Kn.optional()}),Gn=on({_meta:Wn.optional()}),Jn=Gn.extend({task:Hn.optional()}),Bn=e=>Jn.safeParse(e).success,Qn=on({method:$r(),params:Gn.loose().optional()}),Yn=on({_meta:Wn.optional()}),Xn=on({method:$r(),params:Yn.loose().optional()}),eo=sn({_meta:Wn.optional()}),to=cn([$r(),Lr().int()]),ro=on({jsonrpc:vn(Un),id:to,...Qn.shape}).strict(),no=e=>ro.safeParse(e).success,oo=on({jsonrpc:vn(Un),...Xn.shape}).strict(),so=e=>oo.safeParse(e).success,ao=on({jsonrpc:vn(Un),id:to,result:eo}).strict(),io=e=>ao.safeParse(e).success,co=io;var uo;!function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"}(uo||(uo={}));const lo=on({jsonrpc:vn(Un),id:to.optional(),error:on({code:Lr().int(),message:$r(),data:Yr().optional()})}).strict(),po=lo,ho=e=>lo.safeParse(e).success,fo=ho,mo=cn([ro,oo,ao,lo]),_o=cn([ao,lo]),yo=eo.strict(),vo=Yn.extend({requestId:to.optional(),reason:$r().optional()}),go=Xn.extend({method:vn("notifications/cancelled"),params:vo}),wo=on({src:$r(),mimeType:$r().optional(),sizes:rn($r()).optional(),theme:_n(["light","dark"]).optional()}),$o=on({icons:rn(wo).optional()}),bo=on({name:$r(),title:$r().optional()}),ko=bo.extend({...bo.shape,...$o.shape,version:$r(),websiteUrl:$r().optional(),description:$r().optional()}),Eo=pn(on({applyDefaults:Wr().optional()}),fn($r(),Yr())),So=Rn(e=>e&&"object"==typeof e&&!Array.isArray(e)&&0===Object.keys(e).length?{form:{}}:e,pn(on({form:Eo.optional(),url:Dn.optional()}),fn($r(),Yr()).optional())),Po=sn({list:Dn.optional(),cancel:Dn.optional(),requests:sn({sampling:sn({createMessage:Dn.optional()}).optional(),elicitation:sn({create:Dn.optional()}).optional()}).optional()}),To=sn({list:Dn.optional(),cancel:Dn.optional(),requests:sn({tools:sn({call:Dn.optional()}).optional()}).optional()}),xo=on({experimental:fn($r(),Dn).optional(),sampling:on({context:Dn.optional(),tools:Dn.optional()}).optional(),elicitation:So.optional(),roots:on({listChanged:Wr().optional()}).optional(),tasks:Po.optional()}),Io=Gn.extend({protocolVersion:$r(),capabilities:xo,clientInfo:ko}),Co=Qn.extend({method:vn("initialize"),params:Io}),zo=e=>Co.safeParse(e).success,No=on({experimental:fn($r(),Dn).optional(),logging:Dn.optional(),completions:Dn.optional(),prompts:on({listChanged:Wr().optional()}).optional(),resources:on({subscribe:Wr().optional(),listChanged:Wr().optional()}).optional(),tools:on({listChanged:Wr().optional()}).optional(),tasks:To.optional()}),Ro=eo.extend({protocolVersion:$r(),capabilities:No,serverInfo:ko,instructions:$r().optional()}),Oo=Xn.extend({method:vn("notifications/initialized"),params:Yn.optional()}),jo=e=>Oo.safeParse(e).success,Ao=Qn.extend({method:vn("ping"),params:Gn.optional()}),Mo=on({progress:Lr(),total:bn(Lr()),message:bn($r())}),qo=on({...Yn.shape,...Mo.shape,progressToken:Fn}),Uo=Xn.extend({method:vn("notifications/progress"),params:qo}),Do=Gn.extend({cursor:Ln.optional()}),Vo=Qn.extend({params:Do.optional()}),Fo=eo.extend({nextCursor:Ln.optional()}),Lo=_n(["working","input_required","completed","failed","cancelled"]),Zo=on({taskId:$r(),status:Lo,ttl:cn([Lr(),Jr()]),createdAt:$r(),lastUpdatedAt:$r(),pollInterval:bn(Lr()),statusMessage:bn($r())}),Ho=eo.extend({task:Zo}),Ko=Yn.merge(Zo),Wo=Xn.extend({method:vn("notifications/tasks/status"),params:Ko}),Go=Qn.extend({method:vn("tasks/get"),params:Gn.extend({taskId:$r()})}),Jo=eo.merge(Zo),Bo=Qn.extend({method:vn("tasks/result"),params:Gn.extend({taskId:$r()})}),Qo=eo.loose(),Yo=Vo.extend({method:vn("tasks/list")}),Xo=Fo.extend({tasks:rn(Zo)}),es=Qn.extend({method:vn("tasks/cancel"),params:Gn.extend({taskId:$r()})}),ts=eo.merge(Zo),rs=on({uri:$r(),mimeType:bn($r()),_meta:fn($r(),Yr()).optional()}),ns=rs.extend({text:$r()}),os=$r().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),ss=rs.extend({blob:os}),as=_n(["user","assistant"]),is=on({audience:rn(as).optional(),priority:Lr().min(0).max(1).optional(),lastModified:ar({offset:!0}).optional()}),cs=on({...bo.shape,...$o.shape,uri:$r(),description:bn($r()),mimeType:bn($r()),annotations:is.optional(),_meta:bn(sn({}))}),us=on({...bo.shape,...$o.shape,uriTemplate:$r(),description:bn($r()),mimeType:bn($r()),annotations:is.optional(),_meta:bn(sn({}))}),ds=Vo.extend({method:vn("resources/list")}),ls=Fo.extend({resources:rn(cs)}),ps=Vo.extend({method:vn("resources/templates/list")}),hs=Fo.extend({resourceTemplates:rn(us)}),fs=Gn.extend({uri:$r()}),ms=fs,_s=Qn.extend({method:vn("resources/read"),params:ms}),ys=eo.extend({contents:rn(cn([ns,ss]))}),vs=Xn.extend({method:vn("notifications/resources/list_changed"),params:Yn.optional()}),gs=fs,ws=Qn.extend({method:vn("resources/subscribe"),params:gs}),$s=fs,bs=Qn.extend({method:vn("resources/unsubscribe"),params:$s}),ks=Yn.extend({uri:$r()}),Es=Xn.extend({method:vn("notifications/resources/updated"),params:ks}),Ss=on({name:$r(),description:bn($r()),required:bn(Wr())}),Ps=on({...bo.shape,...$o.shape,description:bn($r()),arguments:bn(rn(Ss)),_meta:bn(sn({}))}),Ts=Vo.extend({method:vn("prompts/list")}),xs=Fo.extend({prompts:rn(Ps)}),Is=Gn.extend({name:$r(),arguments:fn($r(),$r()).optional()}),Cs=Qn.extend({method:vn("prompts/get"),params:Is}),zs=on({type:vn("text"),text:$r(),annotations:is.optional(),_meta:fn($r(),Yr()).optional()}),Ns=on({type:vn("image"),data:os,mimeType:$r(),annotations:is.optional(),_meta:fn($r(),Yr()).optional()}),Rs=on({type:vn("audio"),data:os,mimeType:$r(),annotations:is.optional(),_meta:fn($r(),Yr()).optional()}),Os=on({type:vn("tool_use"),name:$r(),id:$r(),input:fn($r(),Yr()),_meta:fn($r(),Yr()).optional()}),js=on({type:vn("resource"),resource:cn([ns,ss]),annotations:is.optional(),_meta:fn($r(),Yr()).optional()}),As=cs.extend({type:vn("resource_link")}),Ms=cn([zs,Ns,Rs,As,js]),qs=on({role:as,content:Ms}),Us=eo.extend({description:$r().optional(),messages:rn(qs)}),Ds=Xn.extend({method:vn("notifications/prompts/list_changed"),params:Yn.optional()}),Vs=on({title:$r().optional(),readOnlyHint:Wr().optional(),destructiveHint:Wr().optional(),idempotentHint:Wr().optional(),openWorldHint:Wr().optional()}),Fs=on({taskSupport:_n(["required","optional","forbidden"]).optional()}),Ls=on({...bo.shape,...$o.shape,description:$r().optional(),inputSchema:on({type:vn("object"),properties:fn($r(),Dn).optional(),required:rn($r()).optional()}).catchall(Yr()),outputSchema:on({type:vn("object"),properties:fn($r(),Dn).optional(),required:rn($r()).optional()}).catchall(Yr()).optional(),annotations:Vs.optional(),execution:Fs.optional(),_meta:fn($r(),Yr()).optional()}),Zs=Vo.extend({method:vn("tools/list")}),Hs=Fo.extend({tools:rn(Ls)}),Ks=eo.extend({content:rn(Ms).default([]),structuredContent:fn($r(),Yr()).optional(),isError:Wr().optional()}),Ws=Ks.or(eo.extend({toolResult:Yr()})),Gs=Jn.extend({name:$r(),arguments:fn($r(),Yr()).optional()}),Js=Qn.extend({method:vn("tools/call"),params:Gs}),Bs=Xn.extend({method:vn("notifications/tools/list_changed"),params:Yn.optional()}),Qs=on({autoRefresh:Wr().default(!0),debounceMs:Lr().int().nonnegative().default(300)}),Ys=_n(["debug","info","notice","warning","error","critical","alert","emergency"]),Xs=Gn.extend({level:Ys}),ea=Qn.extend({method:vn("logging/setLevel"),params:Xs}),ta=Yn.extend({level:Ys,logger:$r().optional(),data:Yr()}),ra=Xn.extend({method:vn("notifications/message"),params:ta}),na=on({name:$r().optional()}),oa=on({hints:rn(na).optional(),costPriority:Lr().min(0).max(1).optional(),speedPriority:Lr().min(0).max(1).optional(),intelligencePriority:Lr().min(0).max(1).optional()}),sa=on({mode:_n(["auto","required","none"]).optional()}),aa=on({type:vn("tool_result"),toolUseId:$r().describe("The unique identifier for the corresponding tool call."),content:rn(Ms).default([]),structuredContent:on({}).loose().optional(),isError:Wr().optional(),_meta:fn($r(),Yr()).optional()}),ia=dn("type",[zs,Ns,Rs]),ca=dn("type",[zs,Ns,Rs,Os,aa]),ua=on({role:as,content:cn([ca,rn(ca)]),_meta:fn($r(),Yr()).optional()}),da=Jn.extend({messages:rn(ua),modelPreferences:oa.optional(),systemPrompt:$r().optional(),includeContext:_n(["none","thisServer","allServers"]).optional(),temperature:Lr().optional(),maxTokens:Lr().int(),stopSequences:rn($r()).optional(),metadata:Dn.optional(),tools:rn(Ls).optional(),toolChoice:sa.optional()}),la=Qn.extend({method:vn("sampling/createMessage"),params:da}),pa=eo.extend({model:$r(),stopReason:bn(_n(["endTurn","stopSequence","maxTokens"]).or($r())),role:as,content:ia}),ha=eo.extend({model:$r(),stopReason:bn(_n(["endTurn","stopSequence","maxTokens","toolUse"]).or($r())),role:as,content:cn([ca,rn(ca)])}),fa=on({type:vn("boolean"),title:$r().optional(),description:$r().optional(),default:Wr().optional()}),ma=on({type:vn("string"),title:$r().optional(),description:$r().optional(),minLength:Lr().optional(),maxLength:Lr().optional(),format:_n(["email","uri","date","date-time"]).optional(),default:$r().optional()}),_a=on({type:_n(["number","integer"]),title:$r().optional(),description:$r().optional(),minimum:Lr().optional(),maximum:Lr().optional(),default:Lr().optional()}),ya=on({type:vn("string"),title:$r().optional(),description:$r().optional(),enum:rn($r()),default:$r().optional()}),va=on({type:vn("string"),title:$r().optional(),description:$r().optional(),oneOf:rn(on({const:$r(),title:$r()})),default:$r().optional()}),ga=on({type:vn("string"),title:$r().optional(),description:$r().optional(),enum:rn($r()),enumNames:rn($r()).optional(),default:$r().optional()}),wa=cn([ya,va]),$a=on({type:vn("array"),title:$r().optional(),description:$r().optional(),minItems:Lr().optional(),maxItems:Lr().optional(),items:on({type:vn("string"),enum:rn($r())}),default:rn($r()).optional()}),ba=on({type:vn("array"),title:$r().optional(),description:$r().optional(),minItems:Lr().optional(),maxItems:Lr().optional(),items:on({anyOf:rn(on({const:$r(),title:$r()}))}),default:rn($r()).optional()}),ka=cn([$a,ba]),Ea=cn([ga,wa,ka]),Sa=cn([Ea,fa,ma,_a]),Pa=Jn.extend({mode:vn("form").optional(),message:$r(),requestedSchema:on({type:vn("object"),properties:fn($r(),Sa),required:rn($r()).optional()})}),Ta=Jn.extend({mode:vn("url"),message:$r(),elicitationId:$r(),url:$r().url()}),xa=cn([Pa,Ta]),Ia=Qn.extend({method:vn("elicitation/create"),params:xa}),Ca=Yn.extend({elicitationId:$r()}),za=Xn.extend({method:vn("notifications/elicitation/complete"),params:Ca}),Na=eo.extend({action:_n(["accept","decline","cancel"]),content:Rn(e=>null===e?void 0:e,fn($r(),cn([$r(),Lr(),Wr(),rn($r())])).optional())}),Ra=on({type:vn("ref/resource"),uri:$r()}),Oa=Ra,ja=on({type:vn("ref/prompt"),name:$r()}),Aa=Gn.extend({ref:cn([ja,Ra]),argument:on({name:$r(),value:$r()}),context:on({arguments:fn($r(),$r()).optional()}).optional()}),Ma=Qn.extend({method:vn("completion/complete"),params:Aa});function qa(e){if("ref/prompt"!==e.params.ref.type)throw new TypeError(`Expected CompleteRequestPrompt, but got ${e.params.ref.type}`)}function Ua(e){if("ref/resource"!==e.params.ref.type)throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${e.params.ref.type}`)}const Da=eo.extend({completion:sn({values:rn($r()).max(100),total:bn(Lr().int()),hasMore:bn(Wr())})}),Va=on({uri:$r().startsWith("file://"),name:$r().optional(),_meta:fn($r(),Yr()).optional()}),Fa=Qn.extend({method:vn("roots/list"),params:Gn.optional()}),La=eo.extend({roots:rn(Va)}),Za=Xn.extend({method:vn("notifications/roots/list_changed"),params:Yn.optional()}),Ha=cn([Ao,Co,Ma,ea,Cs,Ts,ds,ps,_s,ws,bs,Js,Zs,Go,Bo,Yo,es]),Ka=cn([go,Uo,Oo,Za,Wo]),Wa=cn([yo,pa,ha,Na,La,Jo,Xo,Ho]),Ga=cn([Ao,la,Ia,Fa,Go,Bo,Yo,es]),Ja=cn([go,Uo,ra,Es,vs,Bs,Ds,Wo,za]),Ba=cn([yo,Ro,Da,Us,xs,ls,hs,ys,Ks,Hs,Jo,Xo,Ho]);class Qa extends Error{constructor(e,t,r){super(`MCP error ${e}: ${t}`),this.code=e,this.data=r,this.name="McpError"}static fromError(e,t,r){if(e===uo.UrlElicitationRequired&&r){const e=r;if(e.elicitations)return new Ya(e.elicitations,t)}return new Qa(e,t,r)}}class Ya extends Qa{constructor(e,t=`URL elicitation${e.length>1?"s":""} required`){super(uo.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}function Xa(e){return"completed"===e||"failed"===e||"cancelled"===e}function ei(e){const t=or(e),r=t?.method;if(!r)throw new Error("Schema is missing a method literal");const n=function(e){if(rr(e)){const t=e,r=t._zod?.def;if(r){if(void 0!==r.value)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}}const t=e._def;if(t){if(void 0!==t.value)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}const r=e.value;if(void 0!==r)return r}(r);if("string"!=typeof n)throw new Error("Schema method literal must be a string");return n}function ti(e,t){const r=nr(e,t);if(!r.success)throw r.error;return r.data}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");class ri{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(go,e=>{this._oncancel(e)}),this.setNotificationHandler(Uo,e=>{this._onprogress(e)}),this.setRequestHandler(Ao,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Go,async(e,t)=>{const r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new Qa(uo.InvalidParams,"Failed to retrieve task: Task not found");return{...r}}),this.setRequestHandler(Bo,async(e,t)=>{const r=async()=>{const n=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(n,t.sessionId);){if("response"===e.type||"error"===e.type){const t=e.message,r=t.id,n=this._requestResolvers.get(r);if(n)if(this._requestResolvers.delete(r),"response"===e.type)n(t);else{const e=t;n(new Qa(e.error.code,e.error.message,e.error.data))}else{const t="response"===e.type?"Response":"Error";this._onerror(new Error(`${t} handler missing for request ${r}`))}continue}await(this._transport?.send(e.message,{relatedRequestId:t.requestId}))}}const o=await this._taskStore.getTask(n,t.sessionId);if(!o)throw new Qa(uo.InvalidParams,`Task not found: ${n}`);if(!Xa(o.status))return await this._waitForTaskUpdate(n,t.signal),await r();if(Xa(o.status)){const e=await this._taskStore.getTaskResult(n,t.sessionId);return this._clearTaskQueue(n),{...e,_meta:{...e._meta,[qn]:{taskId:n}}}}return await r()};return await r()}),this.setRequestHandler(Yo,async(e,t)=>{try{const{tasks:r,nextCursor:n}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:r,nextCursor:n,_meta:{}}}catch(e){throw new Qa(uo.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(es,async(e,t)=>{try{const r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new Qa(uo.InvalidParams,`Task not found: ${e.params.taskId}`);if(Xa(r.status))throw new Qa(uo.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,"cancelled","Client cancelled task execution.",t.sessionId),this._clearTaskQueue(e.params.taskId);const n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new Qa(uo.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...n}}catch(e){if(e instanceof Qa)throw e;throw new Qa(uo.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;const t=this._requestHandlerAbortControllers.get(e.params.requestId);t?.abort(e.params.reason)}_setupTimeout(e,t,r,n,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(n,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:o,onTimeout:n})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const r=Date.now()-t.startTime;if(t.maxTotalTimeout&&r>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),Qa.fromError(uo.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:r});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;const t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};const r=this.transport?.onerror;this._transport.onerror=e=>{r?.(e),this._onerror(e)};const n=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{n?.(e,t),io(e)||ho(e)?this._onresponse(e):no(e)?this._onrequest(e,t):so(e)?this._onnotification(e):this._onerror(new Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();const t=Qa.fromError(uo.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const r of e.values())r(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){const t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;void 0!==t&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(new Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){const r=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,n=this._transport,o=e.params?._meta?.[qn]?.taskId;if(void 0===r){const t={jsonrpc:"2.0",id:e.id,error:{code:uo.MethodNotFound,message:"Method not found"}};return void(o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:t,timestamp:Date.now()},n?.sessionId).catch(e=>this._onerror(new Error(`Failed to enqueue error response: ${e}`))):n?.send(t).catch(e=>this._onerror(new Error(`Failed to send an error response: ${e}`))))}const s=new AbortController;this._requestHandlerAbortControllers.set(e.id,s);const a=Bn(e.params)?e.params.task:void 0,i=this._taskStore?this.requestTaskStore(e,n?.sessionId):void 0,c={signal:s.signal,sessionId:n?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{const r={relatedRequestId:e.id};o&&(r.relatedTask={taskId:o}),await this.notification(t,r)},sendRequest:async(t,r,n)=>{const s={...n,relatedRequestId:e.id};o&&!s.relatedTask&&(s.relatedTask={taskId:o});const a=s.relatedTask?.taskId??o;return a&&i&&await i.updateTaskStatus(a,"input_required"),await this.request(t,r,s)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:o,taskStore:i,taskRequestedTtl:a?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>r(e,c)).then(async t=>{if(s.signal.aborted)return;const r={result:t,jsonrpc:"2.0",id:e.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:r,timestamp:Date.now()},n?.sessionId):await(n?.send(r))},async t=>{if(s.signal.aborted)return;const r={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:uo.InternalError,message:t.message??"Internal error",...void 0!==t.data&&{data:t.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:r,timestamp:Date.now()},n?.sessionId):await(n?.send(r))}).catch(e=>this._onerror(new Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){const{progressToken:t,...r}=e.params,n=Number(t),o=this._progressHandlers.get(n);if(!o)return void this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));const s=this._responseHandlers.get(n),a=this._timeoutInfo.get(n);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(e){return this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),void s(e)}o(r)}_onresponse(e){const t=Number(e.id),r=this._requestResolvers.get(t);if(r){if(this._requestResolvers.delete(t),io(e))r(e);else{r(new Qa(e.error.code,e.error.message,e.error.data))}return}const n=this._responseHandlers.get(t);if(void 0===n)return void this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));this._responseHandlers.delete(t),this._cleanupTimeout(t);let o=!1;if(io(e)&&e.result&&"object"==typeof e.result){const r=e.result;if(r.task&&"object"==typeof r.task){const e=r.task;"string"==typeof e.taskId&&(o=!0,this._taskProgressTokens.set(e.taskId,t))}}if(o||this._progressHandlers.delete(t),io(e))n(e);else{n(Qa.fromError(e.error.code,e.error.message,e.error.data))}}get transport(){return this._transport}async close(){await(this._transport?.close())}async*requestStream(e,t,r){const{task:n}=r??{};if(!n){try{const n=await this.request(e,t,r);yield{type:"result",result:n}}catch(e){yield{type:"error",error:e instanceof Qa?e:new Qa(uo.InternalError,String(e))}}return}let o;try{const n=await this.request(e,Ho,r);if(!n.task)throw new Qa(uo.InternalError,"Task creation did not return a task");for(o=n.task.taskId,yield{type:"taskCreated",task:n.task};;){const e=await this.getTask({taskId:o},r);if(yield{type:"taskStatus",task:e},Xa(e.status)){if("completed"===e.status){const e=await this.getTaskResult({taskId:o},t,r);yield{type:"result",result:e}}else"failed"===e.status?yield{type:"error",error:new Qa(uo.InternalError,`Task ${o} failed`)}:"cancelled"===e.status&&(yield{type:"error",error:new Qa(uo.InternalError,`Task ${o} was cancelled`)});return}if("input_required"===e.status){const e=await this.getTaskResult({taskId:o},t,r);return void(yield{type:"result",result:e})}const n=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,n)),r?.signal?.throwIfAborted()}}catch(e){yield{type:"error",error:e instanceof Qa?e:new Qa(uo.InternalError,String(e))}}}request(e,t,r){const{relatedRequestId:n,resumptionToken:o,onresumptiontoken:s,task:a,relatedTask:i}=r??{};return new Promise((c,u)=>{const d=e=>{u(e)};if(!this._transport)return void d(new Error("Not connected"));if(!0===this._options?.enforceStrictCapabilities)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(e){return void d(e)}r?.signal?.throwIfAborted();const l=this._requestMessageId++,p={...e,jsonrpc:"2.0",id:l};r?.onprogress&&(this._progressHandlers.set(l,r.onprogress),p.params={...e.params,_meta:{...e.params?._meta||{},progressToken:l}}),a&&(p.params={...p.params,task:a}),i&&(p.params={...p.params,_meta:{...p.params?._meta||{},[qn]:i}});const h=e=>{this._responseHandlers.delete(l),this._progressHandlers.delete(l),this._cleanupTimeout(l),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:l,reason:String(e)}},{relatedRequestId:n,resumptionToken:o,onresumptiontoken:s}).catch(e=>this._onerror(new Error(`Failed to send cancellation: ${e}`)));const t=e instanceof Qa?e:new Qa(uo.RequestTimeout,String(e));u(t)};this._responseHandlers.set(l,e=>{if(!r?.signal?.aborted){if(e instanceof Error)return u(e);try{const r=nr(t,e.result);r.success?c(r.data):u(r.error)}catch(e){u(e)}}}),r?.signal?.addEventListener("abort",()=>{h(r?.signal?.reason)});const f=r?.timeout??6e4;this._setupTimeout(l,f,r?.maxTotalTimeout,()=>h(Qa.fromError(uo.RequestTimeout,"Request timed out",{timeout:f})),r?.resetTimeoutOnProgress??!1);const m=i?.taskId;if(m){const e=e=>{const t=this._responseHandlers.get(l);t?t(e):this._onerror(new Error(`Response handler missing for side-channeled request ${l}`))};this._requestResolvers.set(l,e),this._enqueueTaskMessage(m,{type:"request",message:p,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(l),u(e)})}else this._transport.send(p,{relatedRequestId:n,resumptionToken:o,onresumptiontoken:s}).catch(e=>{this._cleanupTimeout(l),u(e)})})}async getTask(e,t){return this.request({method:"tasks/get",params:e},Jo,t)}async getTaskResult(e,t,r){return this.request({method:"tasks/result",params:e},t,r)}async listTasks(e,t){return this.request({method:"tasks/list",params:e},Xo,t)}async cancelTask(e,t){return this.request({method:"tasks/cancel",params:e},ts,t)}async notification(e,t){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const r=t?.relatedTask?.taskId;if(r){const n={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[qn]:t.relatedTask}}};return void await this._enqueueTaskMessage(r,{type:"notification",message:n,timestamp:Date.now()})}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;return this._pendingDebouncedNotifications.add(e.method),void Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let r={...e,jsonrpc:"2.0"};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[qn]:t.relatedTask}}}),this._transport?.send(r,t).catch(e=>this._onerror(e))})}let n={...e,jsonrpc:"2.0"};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[qn]:t.relatedTask}}}),await this._transport.send(n,t)}setRequestHandler(e,t){const r=ei(e);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(r,n)=>{const o=ti(e,r);return Promise.resolve(t(o,n))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){const r=ei(e);this._notificationHandlers.set(r,r=>{const n=ti(e,r);return Promise.resolve(t(n))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){const t=this._taskProgressTokens.get(e);void 0!==t&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,r){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const n=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,r,n)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){const r=await this._taskMessageQueue.dequeueAll(e,t);for(const t of r)if("request"===t.type&&no(t.message)){const r=t.message.id,n=this._requestResolvers.get(r);n?(n(new Qa(uo.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(r)):this._onerror(new Error(`Resolver missing for request ${r} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let r=this._options?.defaultTaskPollInterval??1e3;try{const t=await(this._taskStore?.getTask(e));t?.pollInterval&&(r=t.pollInterval)}catch{}return new Promise((e,n)=>{if(t.aborted)return void n(new Qa(uo.InvalidRequest,"Request cancelled"));const o=setTimeout(e,r);t.addEventListener("abort",()=>{clearTimeout(o),n(new Qa(uo.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,t){const r=this._taskStore;if(!r)throw new Error("No task store configured");return{createTask:async n=>{if(!e)throw new Error("No request provided");return await r.createTask(n,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{const n=await r.getTask(e,t);if(!n)throw new Qa(uo.InvalidParams,"Failed to retrieve task: Task not found");return n},storeTaskResult:async(e,n,o)=>{await r.storeTaskResult(e,n,o,t);const s=await r.getTask(e,t);if(s){const t=Wo.parse({method:"notifications/tasks/status",params:s});await this.notification(t),Xa(s.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>r.getTaskResult(e,t),updateTaskStatus:async(e,n,o)=>{const s=await r.getTask(e,t);if(!s)throw new Qa(uo.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(Xa(s.status))throw new Qa(uo.InvalidParams,`Cannot update task "${e}" from terminal status "${s.status}" to "${n}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await r.updateTaskStatus(e,n,o,t);const a=await r.getTask(e,t);if(a){const t=Wo.parse({method:"notifications/tasks/status",params:a});await this.notification(t),Xa(a.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>r.listTasks(e,t)}}}function ni(e){return null!==e&&"object"==typeof e&&!Array.isArray(e)}var oi="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function si(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ai,ii={exports:{}},ci={},ui={},di={},li={},pi={},hi={};function fi(){return ai||(ai=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(e){super(),this._items="string"==typeof e?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const e=this._items[0];return""===e||'""'===e}get str(){var e;return null!==(e=this._str)&&void 0!==e?e:this._str=this._items.reduce((e,t)=>`${e}${t}`,"")}get names(){var e;return null!==(e=this._names)&&void 0!==e?e:this._names=this._items.reduce((e,t)=>(t instanceof r&&(e[t.str]=(e[t.str]||0)+1),e),{})}}function o(e,...t){const r=[e[0]];let o=0;for(;o{if(void 0===r.scopePath)throw new Error(`CodeGen: name "${r}" has no value`);return t._`${e}${r.scopePath}`})}scopeCode(e=this._values,t,r){return this._reduceValues(e,e=>{if(void 0===e.value)throw new Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,r)}_reduceValues(o,s,a={},i){let c=t.nil;for(const u in o){const d=o[u];if(!d)continue;const l=a[u]=a[u]||new Map;d.forEach(o=>{if(l.has(o))return;l.set(o,n.Started);let a=s(o);if(a){const r=this.opts.es5?e.varKinds.var:e.varKinds.const;c=t._`${c}${r} ${o} = ${a};${this.opts._n}`}else{if(!(a=null==i?void 0:i(o)))throw new r(o);c=t._`${c}${a}${this.opts._n}`}l.set(o,n.Completed)})}return c}}}(yi)),yi}function gi(){return _i||(_i=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=fi(),r=vi();var n=fi();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var o=vi();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return o.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return o.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return o.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return o.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class s{optimizeNodes(){return this}optimizeNames(e,t){return this}}class a extends s{constructor(e,t,r){super(),this.varKind=e,this.name=t,this.rhs=r}render({es5:e,_n:t}){const n=e?r.varKinds.var:this.varKind,o=void 0===this.rhs?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&(this.rhs=I(this.rhs,e,t)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class i extends s{constructor(e,t,r){super(),this.lhs=e,this.rhs=t,this.sideEffects=r}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof t.Name)||e[this.lhs.str]||this.sideEffects)return this.rhs=I(this.rhs,e,r),this}get names(){return x(this.lhs instanceof t.Name?{}:{...this.lhs.names},this.rhs)}}class c extends i{constructor(e,t,r,n){super(e,r,n),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}}class u extends s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}}class d extends s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}}class l extends s{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}}class p extends s{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=I(this.code,e,t),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class h extends s{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,r)=>t+r.render(e),"")}optimizeNodes(){const{nodes:e}=this;let t=e.length;for(;t--;){const r=e[t].optimizeNodes();Array.isArray(r)?e.splice(t,1,...r):r?e[t]=r:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){const{nodes:r}=this;let n=r.length;for(;n--;){const o=r[n];o.optimizeNames(e,t)||(C(e,o.names),r.splice(n,1))}return r.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>T(e,t.names),{})}}class f extends h{render(e){return"{"+e._n+super.render(e)+"}"+e._n}}class m extends h{}class _ extends f{}_.kind="else";class y extends f{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+="else "+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();const e=this.condition;if(!0===e)return this.nodes;let t=this.else;if(t){const e=t.optimizeNodes();t=this.else=Array.isArray(e)?new _(e):e}return t?!1===e?t instanceof y?t:t.nodes:this.nodes.length?this:new y(z(e),t instanceof y?[t]:t.nodes):!1!==e&&this.nodes.length?this:void 0}optimizeNames(e,t){var r;if(this.else=null===(r=this.else)||void 0===r?void 0:r.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=I(this.condition,e,t),this}get names(){const e=super.names;return x(e,this.condition),this.else&&T(e,this.else.names),e}}y.kind="if";class v extends f{}v.kind="for";class g extends v{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=I(this.iteration,e,t),this}get names(){return T(super.names,this.iteration.names)}}class w extends v{constructor(e,t,r,n){super(),this.varKind=e,this.name=t,this.from=r,this.to=n}render(e){const t=e.es5?r.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${t} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){const e=x(super.names,this.from);return x(e,this.to)}}class $ extends v{constructor(e,t,r,n){super(),this.loop=e,this.varKind=t,this.name=r,this.iterable=n}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=I(this.iterable,e,t),this}get names(){return T(super.names,this.iterable.names)}}class b extends f{constructor(e,t,r){super(),this.name=e,this.args=t,this.async=r}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}}b.kind="func";class k extends h{render(e){return"return "+super.render(e)}}k.kind="return";class E extends f{render(e){let t="try"+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),null===(e=this.catch)||void 0===e||e.optimizeNodes(),null===(t=this.finally)||void 0===t||t.optimizeNodes(),this}optimizeNames(e,t){var r,n;return super.optimizeNames(e,t),null===(r=this.catch)||void 0===r||r.optimizeNames(e,t),null===(n=this.finally)||void 0===n||n.optimizeNames(e,t),this}get names(){const e=super.names;return this.catch&&T(e,this.catch.names),this.finally&&T(e,this.finally.names),e}}class S extends f{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}}S.kind="catch";class P extends f{render(e){return"finally"+super.render(e)}}P.kind="finally";function T(e,t){for(const r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function x(e,r){return r instanceof t._CodeOrName?T(e,r.names):e}function I(e,r,n){return e instanceof t.Name?s(e):(o=e)instanceof t._Code&&o._items.some(e=>e instanceof t.Name&&1===r[e.str]&&void 0!==n[e.str])?new t._Code(e._items.reduce((e,r)=>(r instanceof t.Name&&(r=s(r)),r instanceof t._Code?e.push(...r._items):e.push(r),e),[])):e;var o;function s(e){const t=n[e.str];return void 0===t||1!==r[e.str]?e:(delete r[e.str],t)}}function C(e,t){for(const r in t)e[r]=(e[r]||0)-(t[r]||0)}function z(e){return"boolean"==typeof e||"number"==typeof e||null===e?!e:t._`!${j(e)}`}e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?"\n":""},this._extScope=e,this._scope=new r.Scope({parent:e}),this._nodes=[new m]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){const r=this._extScope.value(e,t);return(this._values[r.prefix]||(this._values[r.prefix]=new Set)).add(r),r}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,r,n){const o=this._scope.toName(t);return void 0!==r&&n&&(this._constants[o.str]=r),this._leafNode(new a(e,o,r)),o}const(e,t,n){return this._def(r.varKinds.const,e,t,n)}let(e,t,n){return this._def(r.varKinds.let,e,t,n)}var(e,t,n){return this._def(r.varKinds.var,e,t,n)}assign(e,t,r){return this._leafNode(new i(e,t,r))}add(t,r){return this._leafNode(new c(t,e.operators.ADD,r))}code(e){return"function"==typeof e?e():e!==t.nil&&this._leafNode(new p(e)),this}object(...e){const r=["{"];for(const[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,t.addCodeArg)(r,o));return r.push("}"),new t._Code(r)}if(e,t,r){if(this._blockNode(new y(e)),t&&r)this.code(t).else().code(r).endIf();else if(t)this.code(t).endIf();else if(r)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new y(e))}else(){return this._elseNode(new _)}endIf(){return this._endBlockNode(y,_)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new g(e),t)}forRange(e,t,n,o,s=(this.opts.es5?r.varKinds.var:r.varKinds.let)){const a=this._scope.toName(e);return this._for(new w(s,a,t,n),()=>o(a))}forOf(e,n,o,s=r.varKinds.const){const a=this._scope.toName(e);if(this.opts.es5){const e=n instanceof t.Name?n:this.var("_arr",n);return this.forRange("_i",0,t._`${e}.length`,r=>{this.var(a,t._`${e}[${r}]`),o(a)})}return this._for(new $("of",s,a,n),()=>o(a))}forIn(e,n,o,s=(this.opts.es5?r.varKinds.var:r.varKinds.const)){if(this.opts.ownProperties)return this.forOf(e,t._`Object.keys(${n})`,o);const a=this._scope.toName(e);return this._for(new $("in",s,a,n),()=>o(a))}endFor(){return this._endBlockNode(v)}label(e){return this._leafNode(new u(e))}break(e){return this._leafNode(new d(e))}return(e){const t=new k;if(this._blockNode(t),this.code(e),1!==t.nodes.length)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(k)}try(e,t,r){if(!t&&!r)throw new Error('CodeGen: "try" without "catch" and "finally"');const n=new E;if(this._blockNode(n),this.code(e),t){const e=this.name("e");this._currNode=n.catch=new S(e),t(e)}return r&&(this._currNode=n.finally=new P,this.code(r)),this._endBlockNode(S,P)}throw(e){return this._leafNode(new l(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){const t=this._blockStarts.pop();if(void 0===t)throw new Error("CodeGen: not in self-balancing block");const r=this._nodes.length-t;if(r<0||void 0!==e&&r!==e)throw new Error(`CodeGen: wrong number of nodes: ${r} vs ${e} expected`);return this._nodes.length=t,this}func(e,r=t.nil,n,o){return this._blockNode(new b(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(b)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){const r=this._currNode;if(r instanceof e||t&&r instanceof t)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){const t=this._currNode;if(!(t instanceof y))throw new Error('CodeGen: "else" without "if"');return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){const e=this._nodes;return e[e.length-1]}set _currNode(e){const t=this._nodes;t[t.length-1]=e}},e.not=z;const N=O(e.operators.AND);e.and=function(...e){return e.reduce(N)};const R=O(e.operators.OR);function O(e){return(r,n)=>r===t.nil?n:n===t.nil?r:t._`${j(r)} ${e} ${j(n)}`}function j(e){return e instanceof t.Name?e:t._`(${e})`}e.or=function(...e){return e.reduce(R)}}(pi)),pi}var wi,$i={};function bi(){if(wi)return $i;wi=1,Object.defineProperty($i,"__esModule",{value:!0}),$i.checkStrictMode=$i.getErrorPath=$i.Type=$i.useFunc=$i.setEvaluated=$i.evaluatedPropsToName=$i.mergeEvaluated=$i.eachItem=$i.unescapeJsonPointer=$i.escapeJsonPointer=$i.escapeFragment=$i.unescapeFragment=$i.schemaRefOrVal=$i.schemaHasRulesButRef=$i.schemaHasRules=$i.checkUnknownRules=$i.alwaysValidSchema=$i.toHash=void 0;const e=gi(),t=fi();function r(e,t=e.schema){const{opts:r,self:n}=e;if(!r.strictSchema)return;if("boolean"==typeof t)return;const o=n.RULES.keywords;for(const r in t)o[r]||l(e,`unknown keyword: "${r}"`)}function n(e,t){if("boolean"==typeof e)return!e;for(const r in e)if(t[r])return!0;return!1}function o(e){return"number"==typeof e?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}function s(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function a({mergeNames:t,mergeToName:r,mergeValues:n,resultToName:o}){return(s,a,i,c)=>{const u=void 0===i?a:i instanceof e.Name?(a instanceof e.Name?t(s,a,i):r(s,a,i),i):a instanceof e.Name?(r(s,i,a),a):n(a,i);return c!==e.Name||u instanceof e.Name?u:o(s,u)}}function i(t,r){if(!0===r)return t.var("props",!0);const n=t.var("props",e._`{}`);return void 0!==r&&c(t,n,r),n}function c(t,r,n){Object.keys(n).forEach(n=>t.assign(e._`${r}${(0,e.getProperty)(n)}`,!0))}$i.toHash=function(e){const t={};for(const r of e)t[r]=!0;return t},$i.alwaysValidSchema=function(e,t){return"boolean"==typeof t?t:0===Object.keys(t).length||(r(e,t),!n(t,e.self.RULES.all))},$i.checkUnknownRules=r,$i.schemaHasRules=n,$i.schemaHasRulesButRef=function(e,t){if("boolean"==typeof e)return!e;for(const r in e)if("$ref"!==r&&t.all[r])return!0;return!1},$i.schemaRefOrVal=function({topSchemaRef:t,schemaPath:r},n,o,s){if(!s){if("number"==typeof n||"boolean"==typeof n)return n;if("string"==typeof n)return e._`${n}`}return e._`${t}${r}${(0,e.getProperty)(o)}`},$i.unescapeFragment=function(e){return s(decodeURIComponent(e))},$i.escapeFragment=function(e){return encodeURIComponent(o(e))},$i.escapeJsonPointer=o,$i.unescapeJsonPointer=s,$i.eachItem=function(e,t){if(Array.isArray(e))for(const r of e)t(r);else t(e)},$i.mergeEvaluated={props:a({mergeNames:(t,r,n)=>t.if(e._`${n} !== true && ${r} !== undefined`,()=>{t.if(e._`${r} === true`,()=>t.assign(n,!0),()=>t.assign(n,e._`${n} || {}`).code(e._`Object.assign(${n}, ${r})`))}),mergeToName:(t,r,n)=>t.if(e._`${n} !== true`,()=>{!0===r?t.assign(n,!0):(t.assign(n,e._`${n} || {}`),c(t,n,r))}),mergeValues:(e,t)=>!0===e||{...e,...t},resultToName:i}),items:a({mergeNames:(t,r,n)=>t.if(e._`${n} !== true && ${r} !== undefined`,()=>t.assign(n,e._`${r} === true ? true : ${n} > ${r} ? ${n} : ${r}`)),mergeToName:(t,r,n)=>t.if(e._`${n} !== true`,()=>t.assign(n,!0===r||e._`${n} > ${r} ? ${n} : ${r}`)),mergeValues:(e,t)=>!0===e||Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})},$i.evaluatedPropsToName=i,$i.setEvaluated=c;const u={};var d;function l(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,!0===r)throw new Error(t);e.self.logger.warn(t)}}return $i.useFunc=function(e,r){return e.scopeValue("func",{ref:r,code:u[r.code]||(u[r.code]=new t._Code(r.code))})},function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"}(d||($i.Type=d={})),$i.getErrorPath=function(t,r,n){if(t instanceof e.Name){const o=r===d.Num;return n?o?e._`"[" + ${t} + "]"`:e._`"['" + ${t} + "']"`:o?e._`"/" + ${t}`:e._`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return n?(0,e.getProperty)(t).toString():"/"+o(t)},$i.checkStrictMode=l,$i}var ki,Ei,Si,Pi={};function Ti(){if(ki)return Pi;ki=1,Object.defineProperty(Pi,"__esModule",{value:!0});const e=gi(),t={data:new e.Name("data"),valCxt:new e.Name("valCxt"),instancePath:new e.Name("instancePath"),parentData:new e.Name("parentData"),parentDataProperty:new e.Name("parentDataProperty"),rootData:new e.Name("rootData"),dynamicAnchors:new e.Name("dynamicAnchors"),vErrors:new e.Name("vErrors"),errors:new e.Name("errors"),this:new e.Name("this"),self:new e.Name("self"),scope:new e.Name("scope"),json:new e.Name("json"),jsonPos:new e.Name("jsonPos"),jsonLen:new e.Name("jsonLen"),jsonPart:new e.Name("jsonPart")};return Pi.default=t,Pi}function xi(){return Ei||(Ei=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=gi(),r=bi(),n=Ti();function o(e,r){const o=e.const("err",r);e.if(t._`${n.default.vErrors} === null`,()=>e.assign(n.default.vErrors,t._`[${o}]`),t._`${n.default.vErrors}.push(${o})`),e.code(t._`${n.default.errors}++`)}function s(e,r){const{gen:n,validateName:o,schemaEnv:s}=e;s.$async?n.throw(t._`new ${e.ValidationError}(${r})`):(n.assign(t._`${o}.errors`,r),n.return(!1))}e.keywordError={message:({keyword:e})=>t.str`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:r})=>r?t.str`"${e}" keyword must be ${r} ($data)`:t.str`"${e}" keyword is invalid ($data)`},e.reportError=function(r,n=e.keywordError,a,c){const{it:u}=r,{gen:d,compositeRule:l,allErrors:p}=u,h=i(r,n,a);(null!=c?c:l||p)?o(d,h):s(u,t._`[${h}]`)},e.reportExtraError=function(t,r=e.keywordError,a){const{it:c}=t,{gen:u,compositeRule:d,allErrors:l}=c;o(u,i(t,r,a)),d||l||s(c,n.default.vErrors)},e.resetErrorsCount=function(e,r){e.assign(n.default.errors,r),e.if(t._`${n.default.vErrors} !== null`,()=>e.if(r,()=>e.assign(t._`${n.default.vErrors}.length`,r),()=>e.assign(n.default.vErrors,null)))},e.extendErrors=function({gen:e,keyword:r,schemaValue:o,data:s,errsCount:a,it:i}){if(void 0===a)throw new Error("ajv implementation error");const c=e.name("err");e.forRange("i",a,n.default.errors,a=>{e.const(c,t._`${n.default.vErrors}[${a}]`),e.if(t._`${c}.instancePath === undefined`,()=>e.assign(t._`${c}.instancePath`,(0,t.strConcat)(n.default.instancePath,i.errorPath))),e.assign(t._`${c}.schemaPath`,t.str`${i.errSchemaPath}/${r}`),i.opts.verbose&&(e.assign(t._`${c}.schema`,o),e.assign(t._`${c}.data`,s))})};const a={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function i(e,r,o){const{createErrors:s}=e.it;return!1===s?t._`{}`:function(e,r,o={}){const{gen:s,it:i}=e,d=[c(i,o),u(e,o)];return function(e,{params:r,message:o},s){const{keyword:i,data:c,schemaValue:u,it:d}=e,{opts:l,propertyName:p,topSchemaRef:h,schemaPath:f}=d;s.push([a.keyword,i],[a.params,"function"==typeof r?r(e):r||t._`{}`]),l.messages&&s.push([a.message,"function"==typeof o?o(e):o]);l.verbose&&s.push([a.schema,u],[a.parentSchema,t._`${h}${f}`],[n.default.data,c]);p&&s.push([a.propertyName,p])}(e,r,d),s.object(...d)}(e,r,o)}function c({errorPath:e},{instancePath:o}){const s=o?t.str`${e}${(0,r.getErrorPath)(o,r.Type.Str)}`:e;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,s)]}function u({keyword:e,it:{errSchemaPath:n}},{schemaPath:o,parentSchema:s}){let i=s?n:t.str`${n}/${e}`;return o&&(i=t.str`${i}${(0,r.getErrorPath)(o,r.Type.Str)}`),[a.schemaPath,i]}}(li)),li}var Ii,Ci={},zi={};function Ni(){if(Ii)return zi;Ii=1,Object.defineProperty(zi,"__esModule",{value:!0}),zi.getRules=zi.isJSONType=void 0;const e=new Set(["string","number","integer","boolean","null","object","array"]);return zi.isJSONType=function(t){return"string"==typeof t&&e.has(t)},zi.getRules=function(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}},zi}var Ri,Oi,ji={};function Ai(){if(Ri)return ji;function e(e,r){return r.rules.some(r=>t(e,r))}function t(e,t){var r;return void 0!==e[t.keyword]||(null===(r=t.definition.implements)||void 0===r?void 0:r.some(t=>void 0!==e[t]))}return Ri=1,Object.defineProperty(ji,"__esModule",{value:!0}),ji.shouldUseRule=ji.shouldUseGroup=ji.schemaHasRulesForType=void 0,ji.schemaHasRulesForType=function({schema:t,self:r},n){const o=r.RULES.types[n];return o&&!0!==o&&e(t,o)},ji.shouldUseGroup=e,ji.shouldUseRule=t,ji}function Mi(){if(Oi)return Ci;Oi=1,Object.defineProperty(Ci,"__esModule",{value:!0}),Ci.reportTypeError=Ci.checkDataTypes=Ci.checkDataType=Ci.coerceAndCheckDataType=Ci.getJSONTypes=Ci.getSchemaTypes=Ci.DataType=void 0;const e=Ni(),t=Ai(),r=xi(),n=gi(),o=bi();var s;function a(t){const r=Array.isArray(t)?t:t?[t]:[];if(r.every(e.isJSONType))return r;throw new Error("type must be JSONType or JSONType[]: "+r.join(","))}!function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"}(s||(Ci.DataType=s={})),Ci.getSchemaTypes=function(e){const t=a(e.type);if(t.includes("null")){if(!1===e.nullable)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&void 0!==e.nullable)throw new Error('"nullable" cannot be used without "type"');!0===e.nullable&&t.push("null")}return t},Ci.getJSONTypes=a,Ci.coerceAndCheckDataType=function(e,r){const{gen:o,data:a,opts:c}=e,d=function(e,t){return t?e.filter(e=>i.has(e)||"array"===t&&"array"===e):[]}(r,c.coerceTypes),p=r.length>0&&!(0===d.length&&1===r.length&&(0,t.schemaHasRulesForType)(e,r[0]));if(p){const t=u(r,a,c.strictNumbers,s.Wrong);o.if(t,()=>{d.length?function(e,t,r){const{gen:o,data:s,opts:a}=e,c=o.let("dataType",n._`typeof ${s}`),d=o.let("coerced",n._`undefined`);"array"===a.coerceTypes&&o.if(n._`${c} == 'object' && Array.isArray(${s}) && ${s}.length == 1`,()=>o.assign(s,n._`${s}[0]`).assign(c,n._`typeof ${s}`).if(u(t,s,a.strictNumbers),()=>o.assign(d,s)));o.if(n._`${d} !== undefined`);for(const e of r)(i.has(e)||"array"===e&&"array"===a.coerceTypes)&&p(e);function p(e){switch(e){case"string":return void o.elseIf(n._`${c} == "number" || ${c} == "boolean"`).assign(d,n._`"" + ${s}`).elseIf(n._`${s} === null`).assign(d,n._`""`);case"number":return void o.elseIf(n._`${c} == "boolean" || ${s} === null || (${c} == "string" && ${s} && ${s} == +${s})`).assign(d,n._`+${s}`);case"integer":return void o.elseIf(n._`${c} === "boolean" || ${s} === null || (${c} === "string" && ${s} && ${s} == +${s} && !(${s} % 1))`).assign(d,n._`+${s}`);case"boolean":return void o.elseIf(n._`${s} === "false" || ${s} === 0 || ${s} === null`).assign(d,!1).elseIf(n._`${s} === "true" || ${s} === 1`).assign(d,!0);case"null":return o.elseIf(n._`${s} === "" || ${s} === 0 || ${s} === false`),void o.assign(d,null);case"array":o.elseIf(n._`${c} === "string" || ${c} === "number" || ${c} === "boolean" || ${s} === null`).assign(d,n._`[${s}]`)}}o.else(),l(e),o.endIf(),o.if(n._`${d} !== undefined`,()=>{o.assign(s,d),function({gen:e,parentData:t,parentDataProperty:r},o){e.if(n._`${t} !== undefined`,()=>e.assign(n._`${t}[${r}]`,o))}(e,d)})}(e,r,d):l(e)})}return p};const i=new Set(["string","number","integer","boolean","null"]);function c(e,t,r,o=s.Correct){const a=o===s.Correct?n.operators.EQ:n.operators.NEQ;let i;switch(e){case"null":return n._`${t} ${a} null`;case"array":i=n._`Array.isArray(${t})`;break;case"object":i=n._`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":i=c(n._`!(${t} % 1) && !isNaN(${t})`);break;case"number":i=c();break;default:return n._`typeof ${t} ${a} ${e}`}return o===s.Correct?i:(0,n.not)(i);function c(e=n.nil){return(0,n.and)(n._`typeof ${t} == "number"`,e,r?n._`isFinite(${t})`:n.nil)}}function u(e,t,r,s){if(1===e.length)return c(e[0],t,r,s);let a;const i=(0,o.toHash)(e);if(i.array&&i.object){const e=n._`typeof ${t} != "object"`;a=i.null?e:n._`!${t} || ${e}`,delete i.null,delete i.array,delete i.object}else a=n.nil;i.number&&delete i.integer;for(const e in i)a=(0,n.and)(a,c(e,t,r,s));return a}Ci.checkDataType=c,Ci.checkDataTypes=u;const d={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>"string"==typeof e?n._`{type: ${e}}`:n._`{type: ${t}}`};function l(e){const t=function(e){const{gen:t,data:r,schema:n}=e,s=(0,o.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:s,schemaValue:s,parentSchema:n,params:{},it:e}}(e);(0,r.reportError)(t,d)}return Ci.reportTypeError=l,Ci}var qi,Ui={};var Di,Vi,Fi={},Li={};function Zi(){if(Di)return Li;Di=1,Object.defineProperty(Li,"__esModule",{value:!0}),Li.validateUnion=Li.validateArray=Li.usePattern=Li.callValidateCode=Li.schemaProperties=Li.allSchemaProperties=Li.noPropertyInData=Li.propertyInData=Li.isOwnProperty=Li.hasPropFunc=Li.reportMissingProp=Li.checkMissingProp=Li.checkReportMissingProp=void 0;const e=gi(),t=bi(),r=Ti(),n=bi();function o(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:e._`Object.prototype.hasOwnProperty`})}function s(t,r,n){return e._`${o(t)}.call(${r}, ${n})`}function a(t,r,n,o){const a=e._`${r}${(0,e.getProperty)(n)} === undefined`;return o?(0,e.or)(a,(0,e.not)(s(t,r,n))):a}function i(e){return e?Object.keys(e).filter(e=>"__proto__"!==e):[]}Li.checkReportMissingProp=function(t,r){const{gen:n,data:o,it:s}=t;n.if(a(n,o,r,s.opts.ownProperties),()=>{t.setParams({missingProperty:e._`${r}`},!0),t.error()})},Li.checkMissingProp=function({gen:t,data:r,it:{opts:n}},o,s){return(0,e.or)(...o.map(o=>(0,e.and)(a(t,r,o,n.ownProperties),e._`${s} = ${o}`)))},Li.reportMissingProp=function(e,t){e.setParams({missingProperty:t},!0),e.error()},Li.hasPropFunc=o,Li.isOwnProperty=s,Li.propertyInData=function(t,r,n,o){const a=e._`${r}${(0,e.getProperty)(n)} !== undefined`;return o?e._`${a} && ${s(t,r,n)}`:a},Li.noPropertyInData=a,Li.allSchemaProperties=i,Li.schemaProperties=function(e,r){return i(r).filter(n=>!(0,t.alwaysValidSchema)(e,r[n]))},Li.callValidateCode=function({schemaCode:t,data:n,it:{gen:o,topSchemaRef:s,schemaPath:a,errorPath:i},it:c},u,d,l){const p=l?e._`${t}, ${n}, ${s}${a}`:n,h=[[r.default.instancePath,(0,e.strConcat)(r.default.instancePath,i)],[r.default.parentData,c.parentData],[r.default.parentDataProperty,c.parentDataProperty],[r.default.rootData,r.default.rootData]];c.opts.dynamicRef&&h.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const f=e._`${p}, ${o.object(...h)}`;return d!==e.nil?e._`${u}.call(${d}, ${f})`:e._`${u}(${f})`};const c=e._`new RegExp`;return Li.usePattern=function({gen:t,it:{opts:r}},o){const s=r.unicodeRegExp?"u":"",{regExp:a}=r.code,i=a(o,s);return t.scopeValue("pattern",{key:i.toString(),ref:i,code:e._`${"new RegExp"===a.code?c:(0,n.useFunc)(t,a)}(${o}, ${s})`})},Li.validateArray=function(r){const{gen:n,data:o,keyword:s,it:a}=r,i=n.name("valid");if(a.allErrors){const e=n.let("valid",!0);return c(()=>n.assign(e,!1)),e}return n.var(i,!0),c(()=>n.break()),i;function c(a){const c=n.const("len",e._`${o}.length`);n.forRange("i",0,c,o=>{r.subschema({keyword:s,dataProp:o,dataPropType:t.Type.Num},i),n.if((0,e.not)(i),a)})}},Li.validateUnion=function(r){const{gen:n,schema:o,keyword:s,it:a}=r;if(!Array.isArray(o))throw new Error("ajv implementation error");if(o.some(e=>(0,t.alwaysValidSchema)(a,e))&&!a.opts.unevaluated)return;const i=n.let("valid",!1),c=n.name("_valid");n.block(()=>o.forEach((t,o)=>{const a=r.subschema({keyword:s,schemaProp:o,compositeRule:!0},c);n.assign(i,e._`${i} || ${c}`);r.mergeValidEvaluated(a,c)||n.if((0,e.not)(i))})),r.result(i,()=>r.reset(),()=>r.error(!0))},Li}function Hi(){if(Vi)return Fi;Vi=1,Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.validateKeywordUsage=Fi.validSchemaType=Fi.funcKeywordCode=Fi.macroKeywordCode=void 0;const e=gi(),t=Ti(),r=Zi(),n=xi();function o(t){const{gen:r,data:n,it:o}=t;r.if(o.parentData,()=>r.assign(n,e._`${o.parentData}[${o.parentDataProperty}]`))}function s(t,r,n){if(void 0===n)throw new Error(`keyword "${r}" failed to compile`);return t.scopeValue("keyword","function"==typeof n?{ref:n}:{ref:n,code:(0,e.stringify)(n)})}return Fi.macroKeywordCode=function(t,r){const{gen:n,keyword:o,schema:a,parentSchema:i,it:c}=t,u=r.macro.call(c.self,a,i,c),d=s(n,o,u);!1!==c.opts.validateSchema&&c.self.validateSchema(u,!0);const l=n.name("valid");t.subschema({schema:u,schemaPath:e.nil,errSchemaPath:`${c.errSchemaPath}/${o}`,topSchemaRef:d,compositeRule:!0},l),t.pass(l,()=>t.error(!0))},Fi.funcKeywordCode=function(a,i){var c;const{gen:u,keyword:d,schema:l,parentSchema:p,$data:h,it:f}=a;!function({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}(f,i);const m=!h&&i.compile?i.compile.call(f.self,l,p,f):i.validate,_=s(u,d,m),y=u.let("valid");function v(n=(i.async?e._`await `:e.nil)){const o=f.opts.passContext?t.default.this:t.default.self,s=!("compile"in i&&!h||!1===i.schema);u.assign(y,e._`${n}${(0,r.callValidateCode)(a,_,o,s)}`,i.modifying)}function g(t){var r;u.if((0,e.not)(null!==(r=i.valid)&&void 0!==r?r:y),t)}a.block$data(y,function(){if(!1===i.errors)v(),i.modifying&&o(a),g(()=>a.error());else{const r=i.async?function(){const t=u.let("ruleErrs",null);return u.try(()=>v(e._`await `),r=>u.assign(y,!1).if(e._`${r} instanceof ${f.ValidationError}`,()=>u.assign(t,e._`${r}.errors`),()=>u.throw(r))),t}():function(){const t=e._`${_}.errors`;return u.assign(t,null),v(e.nil),t}();i.modifying&&o(a),g(()=>function(r,o){const{gen:s}=r;s.if(e._`Array.isArray(${o})`,()=>{s.assign(t.default.vErrors,e._`${t.default.vErrors} === null ? ${o} : ${t.default.vErrors}.concat(${o})`).assign(t.default.errors,e._`${t.default.vErrors}.length`),(0,n.extendErrors)(r)},()=>r.error())}(a,r))}}),a.ok(null!==(c=i.valid)&&void 0!==c?c:y)},Fi.validSchemaType=function(e,t,r=!1){return!t.length||t.some(t=>"array"===t?Array.isArray(e):"object"===t?e&&"object"==typeof e&&!Array.isArray(e):typeof e==t||r&&void 0===e)},Fi.validateKeywordUsage=function({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");const a=o.dependencies;if(null==a?void 0:a.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw new Error(`parent schema must have dependencies of ${s}: ${a.join(",")}`);if(o.validateSchema){if(!o.validateSchema(e[s])){const e=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if("log"!==t.validateSchema)throw new Error(e);r.logger.error(e)}}},Fi}var Ki,Wi={};var Gi,Ji,Bi={};function Qi(){return Ji||(Ji=1,Gi=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if((n=t.length)!=r.length)return!1;for(o=n;0!==o--;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((n=(s=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(o=n;0!==o--;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;0!==o--;){var a=s[o];if(!e(t[a],r[a]))return!1}return!0}return t!=t&&r!=r}),Gi}var Yi,Xi,ec,tc={exports:{}};function rc(){if(Yi)return tc.exports;Yi=1;var e=tc.exports=function(e,r,n){"function"==typeof r&&(n=r,r={}),t(r,"function"==typeof(n=r.cb||n)?n:n.pre||function(){},n.post||function(){},e,"",e)};function t(n,o,s,a,i,c,u,d,l,p){if(a&&"object"==typeof a&&!Array.isArray(a)){for(var h in o(a,i,c,u,d,l,p),a){var f=a[h];if(Array.isArray(f)){if(h in e.arrayKeywords)for(var m=0;mr+=a(e)),r===1/0))return 1/0}return r}function i(e,t="",r){!1!==r&&(t=d(t));const n=e.parse(t);return c(e,n)}function c(e,t){return e.serialize(t).split("#")[0]+"#"}Bi.getFullPath=i,Bi._getFullPath=c;const u=/#\/?$/;function d(e){return e?e.replace(u,""):""}Bi.normalizeId=d,Bi.resolveUrl=function(e,t,r){return r=d(r),e.resolve(t,r)};const l=/^[a-z_][-a-z0-9._]*$/i;return Bi.getSchemaRefs=function(e,n){if("boolean"==typeof e)return{};const{schemaId:o,uriResolver:s}=this.opts,a=d(e[o]||n),c={"":a},u=i(s,a,!1),p={},h=new Set;return r(e,{allKeys:!0},(e,t,r,n)=>{if(void 0===n)return;const s=u+t;let a=c[n];function i(t){const r=this.opts.uriResolver.resolve;if(t=d(a?r(a,t):t),h.has(t))throw m(t);h.add(t);let n=this.refs[t];return"string"==typeof n&&(n=this.refs[n]),"object"==typeof n?f(e,n.schema,t):t!==d(s)&&("#"===t[0]?(f(e,p[t],t),p[t]=e):this.refs[t]=s),t}function _(e){if("string"==typeof e){if(!l.test(e))throw new Error(`invalid anchor "${e}"`);i.call(this,`#${e}`)}}"string"==typeof e[o]&&(a=i.call(this,e[o])),_.call(this,e.$anchor),_.call(this,e.$dynamicAnchor),c[t]=a}),p;function f(e,r,n){if(void 0!==r&&!t(e,r))throw m(n)}function m(e){return new Error(`reference "${e}" resolves to more than one schema`)}},Bi}function oc(){if(ec)return ui;ec=1,Object.defineProperty(ui,"__esModule",{value:!0}),ui.getData=ui.KeywordCxt=ui.validateFunctionCode=void 0;const e=function(){if(Si)return di;Si=1,Object.defineProperty(di,"__esModule",{value:!0}),di.boolOrEmptySchema=di.topBoolOrEmptySchema=void 0;const e=xi(),t=gi(),r=Ti(),n={message:"boolean schema is false"};function o(t,r){const{gen:o,data:s}=t,a={gen:o,keyword:"false schema",data:s,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,e.reportError)(a,n,void 0,r)}return di.topBoolOrEmptySchema=function(e){const{gen:n,schema:s,validateName:a}=e;!1===s?o(e,!1):"object"==typeof s&&!0===s.$async?n.return(r.default.data):(n.assign(t._`${a}.errors`,null),n.return(!0))},di.boolOrEmptySchema=function(e,t){const{gen:r,schema:n}=e;!1===n?(r.var(t,!1),o(e)):r.var(t,!0)},di}(),t=Mi(),r=Ai(),n=Mi(),o=function(){if(qi)return Ui;qi=1,Object.defineProperty(Ui,"__esModule",{value:!0}),Ui.assignDefaults=void 0;const e=gi(),t=bi();function r(r,n,o){const{gen:s,compositeRule:a,data:i,opts:c}=r;if(void 0===o)return;const u=e._`${i}${(0,e.getProperty)(n)}`;if(a)return void(0,t.checkStrictMode)(r,`default is ignored for: ${u}`);let d=e._`${u} === undefined`;"empty"===c.useDefaults&&(d=e._`${d} || ${u} === null || ${u} === ""`),s.if(d,e._`${u} = ${(0,e.stringify)(o)}`)}return Ui.assignDefaults=function(e,t){const{properties:n,items:o}=e.schema;if("object"===t&&n)for(const t in n)r(e,t,n[t].default);else"array"===t&&Array.isArray(o)&&o.forEach((t,n)=>r(e,n,t.default))},Ui}(),s=Hi(),a=function(){if(Ki)return Wi;Ki=1,Object.defineProperty(Wi,"__esModule",{value:!0}),Wi.extendSubschemaMode=Wi.extendSubschemaData=Wi.getSubschema=void 0;const e=gi(),t=bi();return Wi.getSubschema=function(r,{keyword:n,schemaProp:o,schema:s,schemaPath:a,errSchemaPath:i,topSchemaRef:c}){if(void 0!==n&&void 0!==s)throw new Error('both "keyword" and "schema" passed, only one allowed');if(void 0!==n){const s=r.schema[n];return void 0===o?{schema:s,schemaPath:e._`${r.schemaPath}${(0,e.getProperty)(n)}`,errSchemaPath:`${r.errSchemaPath}/${n}`}:{schema:s[o],schemaPath:e._`${r.schemaPath}${(0,e.getProperty)(n)}${(0,e.getProperty)(o)}`,errSchemaPath:`${r.errSchemaPath}/${n}/${(0,t.escapeFragment)(o)}`}}if(void 0!==s){if(void 0===a||void 0===i||void 0===c)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:s,schemaPath:a,topSchemaRef:c,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')},Wi.extendSubschemaData=function(r,n,{dataProp:o,dataPropType:s,data:a,dataTypes:i,propertyName:c}){if(void 0!==a&&void 0!==o)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:u}=n;if(void 0!==o){const{errorPath:a,dataPathArr:i,opts:c}=n;d(u.let("data",e._`${n.data}${(0,e.getProperty)(o)}`,!0)),r.errorPath=e.str`${a}${(0,t.getErrorPath)(o,s,c.jsPropertySyntax)}`,r.parentDataProperty=e._`${o}`,r.dataPathArr=[...i,r.parentDataProperty]}function d(e){r.data=e,r.dataLevel=n.dataLevel+1,r.dataTypes=[],n.definedProperties=new Set,r.parentData=n.data,r.dataNames=[...n.dataNames,e]}void 0!==a&&(d(a instanceof e.Name?a:u.let("data",a,!0)),void 0!==c&&(r.propertyName=c)),i&&(r.dataTypes=i)},Wi.extendSubschemaMode=function(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){void 0!==n&&(e.compositeRule=n),void 0!==o&&(e.createErrors=o),void 0!==s&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r},Wi}(),i=gi(),c=Ti(),u=nc(),d=bi(),l=xi();function p({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,i._`${c.default.data}, ${c.default.valCxt}`,n.$async,()=>{e.code(i._`"use strict"; ${h(r,o)}`),function(e,t){e.if(c.default.valCxt,()=>{e.var(c.default.instancePath,i._`${c.default.valCxt}.${c.default.instancePath}`),e.var(c.default.parentData,i._`${c.default.valCxt}.${c.default.parentData}`),e.var(c.default.parentDataProperty,i._`${c.default.valCxt}.${c.default.parentDataProperty}`),e.var(c.default.rootData,i._`${c.default.valCxt}.${c.default.rootData}`),t.dynamicRef&&e.var(c.default.dynamicAnchors,i._`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{e.var(c.default.instancePath,i._`""`),e.var(c.default.parentData,i._`undefined`),e.var(c.default.parentDataProperty,i._`undefined`),e.var(c.default.rootData,c.default.data),t.dynamicRef&&e.var(c.default.dynamicAnchors,i._`{}`)})}(e,o),e.code(s)}):e.func(t,i._`${c.default.data}, ${function(e){return i._`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${e.dynamicRef?i._`, ${c.default.dynamicAnchors}={}`:i.nil}}={}`}(o)}`,n.$async,()=>e.code(h(r,o)).code(s))}function h(e,t){const r="object"==typeof e&&e[t.schemaId];return r&&(t.code.source||t.code.process)?i._`/*# sourceURL=${r} */`:i.nil}function f(t,r){_(t)&&(y(t),m(t))?function(e,t){const{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&g(e);(function(e){const t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,u.resolveUrl)(e.opts.uriResolver,e.baseId,t))})(e),function(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}(e);const s=n.const("_errs",c.default.errors);v(e,s),n.var(t,i._`${s} === ${c.default.errors}`)}(t,r):(0,e.boolOrEmptySchema)(t,r)}function m({schema:e,self:t}){if("boolean"==typeof e)return!e;for(const r in e)if(t.RULES.all[r])return!0;return!1}function _(e){return"boolean"!=typeof e.schema}function y(e){(0,d.checkUnknownRules)(e),function(e){const{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}(e)}function v(e,r){if(e.opts.jtd)return w(e,[],!1,r);const n=(0,t.getSchemaTypes)(e.schema);w(e,n,!(0,t.coerceAndCheckDataType)(e,n),r)}function g({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){const s=r.$comment;if(!0===o.$comment)e.code(i._`${c.default.self}.logger.log(${s})`);else if("function"==typeof o.$comment){const r=i.str`${n}/$comment`,o=e.scopeValue("root",{ref:t.root});e.code(i._`${c.default.self}.opts.$comment(${s}, ${r}, ${o}.schema)`)}}function w(e,t,o,s){const{gen:a,schema:u,data:l,allErrors:p,opts:h,self:f}=e,{RULES:m}=f;function _(d){(0,r.shouldUseGroup)(u,d)&&(d.type?(a.if((0,n.checkDataType)(d.type,l,h.strictNumbers)),$(e,d),1===t.length&&t[0]===d.type&&o&&(a.else(),(0,n.reportTypeError)(e)),a.endIf()):$(e,d),p||a.if(i._`${c.default.errors} === ${s||0}`))}!u.$ref||!h.ignoreKeywordsWithRef&&(0,d.schemaHasRulesButRef)(u,m)?(h.jtd||function(e,t){if(e.schemaEnv.meta||!e.opts.strictTypes)return;(function(e,t){if(!t.length)return;if(!e.dataTypes.length)return void(e.dataTypes=t);t.forEach(t=>{k(e.dataTypes,t)||E(e,`type "${t}" not allowed by context "${e.dataTypes.join(",")}"`)}),function(e,t){const r=[];for(const n of e.dataTypes)k(t,n)?r.push(n):t.includes("integer")&&"number"===n&&r.push("integer");e.dataTypes=r}(e,t)})(e,t),e.opts.allowUnionTypes||function(e,t){t.length>1&&(2!==t.length||!t.includes("null"))&&E(e,"use allowUnionTypes to allow union type keyword")}(e,t);!function(e,t){const n=e.self.RULES.all;for(const o in n){const s=n[o];if("object"==typeof s&&(0,r.shouldUseRule)(e.schema,s)){const{type:r}=s.definition;r.length&&!r.some(e=>b(t,e))&&E(e,`missing type "${r.join(",")}" for keyword "${o}"`)}}}(e,e.dataTypes)}(e,t),a.block(()=>{for(const e of m.rules)_(e);_(m.post)})):a.block(()=>P(e,"$ref",m.all.$ref.definition))}function $(e,t){const{gen:n,schema:s,opts:{useDefaults:a}}=e;a&&(0,o.assignDefaults)(e,t.type),n.block(()=>{for(const n of t.rules)(0,r.shouldUseRule)(s,n)&&P(e,n.keyword,n.definition,t.type)})}function b(e,t){return e.includes(t)||"number"===t&&e.includes("integer")}function k(e,t){return e.includes(t)||"integer"===t&&e.includes("number")}function E(e,t){t+=` at "${e.schemaEnv.baseId+e.errSchemaPath}" (strictTypes)`,(0,d.checkStrictMode)(e,t,e.opts.strictTypes)}ui.validateFunctionCode=function(t){_(t)&&(y(t),m(t))?function(e){const{schema:t,opts:r,gen:n}=e;p(e,()=>{r.$comment&&t.$comment&&g(e),function(e){const{schema:t,opts:r}=e;void 0!==t.default&&r.useDefaults&&r.strictSchema&&(0,d.checkStrictMode)(e,"default is ignored in the schema root")}(e),n.let(c.default.vErrors,null),n.let(c.default.errors,0),r.unevaluated&&function(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",i._`${r}.evaluated`),t.if(i._`${e.evaluated}.dynamicProps`,()=>t.assign(i._`${e.evaluated}.props`,i._`undefined`)),t.if(i._`${e.evaluated}.dynamicItems`,()=>t.assign(i._`${e.evaluated}.items`,i._`undefined`))}(e),v(e),function(e){const{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if(i._`${c.default.errors} === 0`,()=>t.return(c.default.data),()=>t.throw(i._`new ${o}(${c.default.vErrors})`)):(t.assign(i._`${n}.errors`,c.default.vErrors),s.unevaluated&&function({gen:e,evaluated:t,props:r,items:n}){r instanceof i.Name&&e.assign(i._`${t}.props`,r);n instanceof i.Name&&e.assign(i._`${t}.items`,n)}(e),t.return(i._`${c.default.errors} === 0`))}(e)})}(t):p(t,()=>(0,e.topBoolOrEmptySchema)(t))};class S{constructor(e,t,r){if((0,s.validateKeywordUsage)(e,t,r),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=r,this.data=e.data,this.schema=e.schema[r],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,d.schemaRefOrVal)(e,this.schema,r,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const("vSchema",I(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,s.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw new Error(`${r} value must be ${JSON.stringify(t.schemaType)}`);("code"in t?t.trackErrors:!1!==t.errors)&&(this.errsCount=e.gen.const("_errs",c.default.errors))}result(e,t,r){this.failResult((0,i.not)(e),t,r)}failResult(e,t,r){this.gen.if(e),r?r():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,i.not)(e),void 0,t)}fail(e){if(void 0===e)return this.error(),void(this.allErrors||this.gen.if(!1));this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);const{schemaCode:t}=this;this.fail(i._`${t} !== undefined && (${(0,i.or)(this.invalid$data(),e)})`)}error(e,t,r){if(t)return this.setParams(t),this._error(e,r),void this.setParams({});this._error(e,r)}_error(e,t){(e?l.reportExtraError:l.reportError)(this,this.def.error,t)}$dataError(){(0,l.reportError)(this,this.def.$dataError||l.keyword$DataError)}reset(){if(void 0===this.errsCount)throw new Error('add "trackErrors" to keyword definition');(0,l.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,r=i.nil){this.gen.block(()=>{this.check$data(e,r),t()})}check$data(e=i.nil,t=i.nil){if(!this.$data)return;const{gen:r,schemaCode:n,schemaType:o,def:s}=this;r.if((0,i.or)(i._`${n} === undefined`,t)),e!==i.nil&&r.assign(e,!0),(o.length||s.validateSchema)&&(r.elseIf(this.invalid$data()),this.$dataError(),e!==i.nil&&r.assign(e,!1)),r.else()}invalid$data(){const{gen:e,schemaCode:t,schemaType:r,def:o,it:s}=this;return(0,i.or)(function(){if(r.length){if(!(t instanceof i.Name))throw new Error("ajv implementation error");const e=Array.isArray(r)?r:[r];return i._`${(0,n.checkDataTypes)(e,t,s.opts.strictNumbers,n.DataType.Wrong)}`}return i.nil}(),function(){if(o.validateSchema){const r=e.scopeValue("validate$data",{ref:o.validateSchema});return i._`!${r}(${t})`}return i.nil}())}subschema(e,t){const r=(0,a.getSubschema)(this.it,e);(0,a.extendSubschemaData)(r,this.it,e),(0,a.extendSubschemaMode)(r,e);const n={...this.it,...r,items:void 0,props:void 0};return f(n,t),n}mergeEvaluated(e,t){const{it:r,gen:n}=this;r.opts.unevaluated&&(!0!==r.props&&void 0!==e.props&&(r.props=d.mergeEvaluated.props(n,e.props,r.props,t)),!0!==r.items&&void 0!==e.items&&(r.items=d.mergeEvaluated.items(n,e.items,r.items,t)))}mergeValidEvaluated(e,t){const{it:r,gen:n}=this;if(r.opts.unevaluated&&(!0!==r.props||!0!==r.items))return n.if(t,()=>this.mergeEvaluated(e,i.Name)),!0}}function P(e,t,r,n){const o=new S(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,s.funcKeywordCode)(o,r):"macro"in r?(0,s.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,s.funcKeywordCode)(o,r)}ui.KeywordCxt=S;const T=/^\/(?:[^~]|~0|~1)*$/,x=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function I(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(""===e)return c.default.rootData;if("/"===e[0]){if(!T.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=c.default.rootData}else{const a=x.exec(e);if(!a)throw new Error(`Invalid JSON-pointer: ${e}`);const i=+a[1];if(o=a[2],"#"===o){if(i>=t)throw new Error(l("property/index",i));return n[t-i]}if(i>t)throw new Error(l("data",i));if(s=r[t-i],!o)return s}let a=s;const u=o.split("/");for(const e of u)e&&(s=i._`${s}${(0,i.getProperty)((0,d.unescapeJsonPointer)(e))}`,a=i._`${a} && ${s}`);return a;function l(e,r){return`Cannot access ${e} ${r} levels up, current level is ${t}`}}return ui.getData=I,ui}var sc,ac={};function ic(){if(sc)return ac;sc=1,Object.defineProperty(ac,"__esModule",{value:!0});class e extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}}return ac.default=e,ac}var cc,uc={};function dc(){if(cc)return uc;cc=1,Object.defineProperty(uc,"__esModule",{value:!0});const e=nc();class t extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,e.resolveUrl)(t,r,n),this.missingSchema=(0,e.normalizeId)((0,e.getFullPath)(t,this.missingRef))}}return uc.default=t,uc}var lc,pc={};function hc(){if(lc)return pc;lc=1,Object.defineProperty(pc,"__esModule",{value:!0}),pc.resolveSchema=pc.getCompilingSchema=pc.resolveRef=pc.compileSchema=pc.SchemaEnv=void 0;const e=gi(),t=ic(),r=Ti(),n=nc(),o=bi(),s=oc();class a{constructor(e){var t;let r;this.refs={},this.dynamicAnchors={},"object"==typeof e.schema&&(r=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=null!==(t=e.baseId)&&void 0!==t?t:(0,n.normalizeId)(null==r?void 0:r[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=null==r?void 0:r.$async,this.refs={}}}function i(o){const a=u.call(this,o);if(a)return a;const i=(0,n.getFullPath)(this.opts.uriResolver,o.root.baseId),{es5:c,lines:d}=this.opts.code,{ownProperties:l}=this.opts,p=new e.CodeGen(this.scope,{es5:c,lines:d,ownProperties:l});let h;o.$async&&(h=p.scopeValue("Error",{ref:t.default,code:e._`require("ajv/dist/runtime/validation_error").default`}));const f=p.scopeName("validate");o.validateName=f;const m={gen:p,allErrors:this.opts.allErrors,data:r.default.data,parentData:r.default.parentData,parentDataProperty:r.default.parentDataProperty,dataNames:[r.default.data],dataPathArr:[e.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:p.scopeValue("schema",!0===this.opts.code.source?{ref:o.schema,code:(0,e.stringify)(o.schema)}:{ref:o.schema}),validateName:f,ValidationError:h,schema:o.schema,schemaEnv:o,rootId:i,baseId:o.baseId||i,schemaPath:e.nil,errSchemaPath:o.schemaPath||(this.opts.jtd?"":"#"),errorPath:e._`""`,opts:this.opts,self:this};let _;try{this._compilations.add(o),(0,s.validateFunctionCode)(m),p.optimize(this.opts.code.optimize);const t=p.toString();_=`${p.scopeRefs(r.default.scope)}return ${t}`,this.opts.code.process&&(_=this.opts.code.process(_,o));const n=new Function(`${r.default.self}`,`${r.default.scope}`,_)(this,this.scope.get());if(this.scope.value(f,{ref:n}),n.errors=null,n.schema=o.schema,n.schemaEnv=o,o.$async&&(n.$async=!0),!0===this.opts.code.source&&(n.source={validateName:f,validateCode:t,scopeValues:p._values}),this.opts.unevaluated){const{props:t,items:r}=m;n.evaluated={props:t instanceof e.Name?void 0:t,items:r instanceof e.Name?void 0:r,dynamicProps:t instanceof e.Name,dynamicItems:r instanceof e.Name},n.source&&(n.source.evaluated=(0,e.stringify)(n.evaluated))}return o.validate=n,o}catch(e){throw delete o.validate,delete o.validateName,_&&this.logger.error("Error compiling schema, function code:",_),e}finally{this._compilations.delete(o)}}function c(e){return(0,n.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:i.call(this,e)}function u(e){for(const t of this._compilations)if(d(t,e))return t}function d(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function l(e,t){let r;for(;"string"==typeof(r=this.refs[t]);)t=r;return r||this.schemas[t]||p.call(this,e,t)}function p(e,t){const r=this.opts.uriResolver.parse(t),o=(0,n._getFullPath)(this.opts.uriResolver,r);let s=(0,n.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&o===s)return f.call(this,r,e);const c=(0,n.normalizeId)(o),u=this.refs[c]||this.schemas[c];if("string"==typeof u){const t=p.call(this,e,u);if("object"!=typeof(null==t?void 0:t.schema))return;return f.call(this,r,t)}if("object"==typeof(null==u?void 0:u.schema)){if(u.validate||i.call(this,u),c===(0,n.normalizeId)(t)){const{schema:t}=u,{schemaId:r}=this.opts,o=t[r];return o&&(s=(0,n.resolveUrl)(this.opts.uriResolver,s,o)),new a({schema:t,schemaId:r,root:e,baseId:s})}return f.call(this,r,u)}}pc.SchemaEnv=a,pc.compileSchema=i,pc.resolveRef=function(e,t,r){var o;r=(0,n.resolveUrl)(this.opts.uriResolver,t,r);const s=e.refs[r];if(s)return s;let i=l.call(this,e,r);if(void 0===i){const n=null===(o=e.localRefs)||void 0===o?void 0:o[r],{schemaId:s}=this.opts;n&&(i=new a({schema:n,schemaId:s,root:e,baseId:t}))}return void 0!==i?e.refs[r]=c.call(this,i):void 0},pc.getCompilingSchema=u,pc.resolveSchema=p;const h=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function f(e,{baseId:t,schema:r,root:s}){var i;if("/"!==(null===(i=e.fragment)||void 0===i?void 0:i[0]))return;for(const s of e.fragment.slice(1).split("/")){if("boolean"==typeof r)return;const e=r[(0,o.unescapeFragment)(s)];if(void 0===e)return;const a="object"==typeof(r=e)&&r[this.opts.schemaId];!h.has(s)&&a&&(t=(0,n.resolveUrl)(this.opts.uriResolver,t,a))}let c;if("boolean"!=typeof r&&r.$ref&&!(0,o.schemaHasRulesButRef)(r,this.RULES)){const e=(0,n.resolveUrl)(this.opts.uriResolver,t,r.$ref);c=p.call(this,s,e)}const{schemaId:u}=this.opts;return c=c||new a({schema:r,schemaId:u,root:s,baseId:t}),c.schema!==c.root.schema?c:void 0}return pc}var fc,mc,_c,yc,vc,gc,wc,$c={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1},bc={},kc={exports:{}};function Ec(){if(mc)return fc;mc=1;const e=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),t=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function r(e){let t="",r=0,n=0;for(n=0;n=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}const n=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function o(e){return e.length=0,!0}function s(e,t,n){if(e.length){const o=r(e);if(""===o)return n.error=!0,!1;t.push(o),e.length=0}return!0}function a(e){if(function(e,t){let r=0;for(let n=0;n7){n.error=!0;break}r>0&&":"===e[r-1]&&(c=!0),a.push(":")}}return i.length&&(d===o?n.zone=i.join(""):u?a.push(i.join("")):a.push(r(i))),n.address=a.join(""),n}(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,r=t.address;return t.zone&&(e+="%"+t.zone,r+="%25"+t.zone),{host:e,isIPV6:!0,escapedHost:r}}}return fc={nonSimpleDomain:n,recomposeAuthority:function(e){const r=[];if(void 0!==e.userinfo&&(r.push(e.userinfo),r.push("@")),void 0!==e.host){let n=unescape(e.host);if(!t(n)){const t=a(n);n=!0===t.isIPV6?`[${t.escapedHost}]`:e.host}r.push(n)}return"number"!=typeof e.port&&"string"!=typeof e.port||(r.push(":"),r.push(String(e.port))),r.length?r.join(""):void 0},normalizeComponentEncoding:function(e,t){const r=!0!==t?escape:unescape;return void 0!==e.scheme&&(e.scheme=r(e.scheme)),void 0!==e.userinfo&&(e.userinfo=r(e.userinfo)),void 0!==e.host&&(e.host=r(e.host)),void 0!==e.path&&(e.path=r(e.path)),void 0!==e.query&&(e.query=r(e.query)),void 0!==e.fragment&&(e.fragment=r(e.fragment)),e},removeDotSegments:function(e){let t=e;const r=[];let n=-1,o=0;for(;o=t.length;){if(1===o){if("."===t)break;if("/"===t){r.push("/");break}r.push(t);break}if(2===o){if("."===t[0]){if("."===t[1])break;if("/"===t[1]){t=t.slice(2);continue}}else if("/"===t[0]&&("."===t[1]||"/"===t[1])){r.push("/");break}}else if(3===o&&"/.."===t){0!==r.length&&r.pop(),r.push("/");break}if("."===t[0]){if("."===t[1]){if("/"===t[2]){t=t.slice(3);continue}}else if("/"===t[1]){t=t.slice(2);continue}}else if("/"===t[0]&&"."===t[1]){if("/"===t[2]){t=t.slice(2);continue}if("."===t[2]&&"/"===t[3]){t=t.slice(3),0!==r.length&&r.pop();continue}}if(-1===(n=t.indexOf("/",1))){r.push(t);break}r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")},isIPv4:t,isUUID:e,normalizeIPv6:a,stringArrayToHexStripped:r},fc}function Sc(){if(vc)return kc.exports;vc=1;const{normalizeIPv6:e,removeDotSegments:t,recomposeAuthority:r,normalizeComponentEncoding:n,isIPv4:o,nonSimpleDomain:s}=Ec(),{SCHEMES:a,getSchemeHandler:i}=function(){if(yc)return _c;yc=1;const{isUUID:e}=Ec(),t=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,r=["http","https","ws","wss","urn","urn:uuid"];function n(e){return!0===e.secure||!1!==e.secure&&!!e.scheme&&!(3!==e.scheme.length||"w"!==e.scheme[0]&&"W"!==e.scheme[0]||"s"!==e.scheme[1]&&"S"!==e.scheme[1]||"s"!==e.scheme[2]&&"S"!==e.scheme[2])}function o(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function s(e){const t="https"===String(e.scheme).toLowerCase();return e.port!==(t?443:80)&&""!==e.port||(e.port=void 0),e.path||(e.path="/"),e}const a={scheme:"http",domainHost:!0,parse:o,serialize:s},i={scheme:"ws",domainHost:!0,parse:function(e){return e.secure=n(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e},serialize:function(e){if(e.port!==(n(e)?443:80)&&""!==e.port||(e.port=void 0),"boolean"==typeof e.secure&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){const[t,r]=e.resourceName.split("?");e.path=t&&"/"!==t?t:void 0,e.query=r,e.resourceName=void 0}return e.fragment=void 0,e}},c={http:a,https:{scheme:"https",domainHost:a.domainHost,parse:o,serialize:s},ws:i,wss:{scheme:"wss",domainHost:i.domainHost,parse:i.parse,serialize:i.serialize},urn:{scheme:"urn",parse:function(e,r){if(!e.path)return e.error="URN can not be parsed",e;const n=e.path.match(t);if(n){const t=r.scheme||e.scheme||"urn";e.nid=n[1].toLowerCase(),e.nss=n[2];const o=u(`${t}:${r.nid||e.nid}`);e.path=void 0,o&&(e=o.parse(e,r))}else e.error=e.error||"URN can not be parsed.";return e},serialize:function(e,t){if(void 0===e.nid)throw new Error("URN without nid cannot be serialized");const r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=u(`${r}:${t.nid||n}`);o&&(e=o.serialize(e,t));const s=e,a=e.nss;return s.path=`${n||t.nid}:${a}`,t.skipEscape=!0,s},skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:function(t,r){const n=t;return n.uuid=n.nss,n.nss=void 0,r.tolerant||n.uuid&&e(n.uuid)||(n.error=n.error||"UUID is not valid."),n},serialize:function(e){const t=e;return t.nss=(e.uuid||"").toLowerCase(),t},skipNormalize:!0}};function u(e){return e&&(c[e]||c[e.toLowerCase()])||void 0}return Object.setPrototypeOf(c,null),_c={wsIsSecure:n,SCHEMES:c,isValidSchemeName:function(e){return-1!==r.indexOf(e)},getSchemeHandler:u}}();function c(e,r,n,o){const s={};return o||(e=l(u(e,n),n),r=l(u(r,n),n)),!(n=n||{}).tolerant&&r.scheme?(s.scheme=r.scheme,s.userinfo=r.userinfo,s.host=r.host,s.port=r.port,s.path=t(r.path||""),s.query=r.query):(void 0!==r.userinfo||void 0!==r.host||void 0!==r.port?(s.userinfo=r.userinfo,s.host=r.host,s.port=r.port,s.path=t(r.path||""),s.query=r.query):(r.path?("/"===r.path[0]?s.path=t(r.path):(void 0===e.userinfo&&void 0===e.host&&void 0===e.port||e.path?e.path?s.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+r.path:s.path=r.path:s.path="/"+r.path,s.path=t(s.path)),s.query=r.query):(s.path=e.path,void 0!==r.query?s.query=r.query:s.query=e.query),s.userinfo=e.userinfo,s.host=e.host,s.port=e.port),s.scheme=e.scheme),s.fragment=r.fragment,s}function u(e,n){const o={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},s=Object.assign({},n),a=[],c=i(s.scheme||o.scheme);c&&c.serialize&&c.serialize(o,s),void 0!==o.path&&(s.skipEscape?o.path=unescape(o.path):(o.path=escape(o.path),void 0!==o.scheme&&(o.path=o.path.split("%3A").join(":")))),"suffix"!==s.reference&&o.scheme&&a.push(o.scheme,":");const u=r(o);if(void 0!==u&&("suffix"!==s.reference&&a.push("//"),a.push(u),o.path&&"/"!==o.path[0]&&a.push("/")),void 0!==o.path){let e=o.path;s.absolutePath||c&&c.absolutePath||(e=t(e)),void 0===u&&"/"===e[0]&&"/"===e[1]&&(e="/%2F"+e.slice(2)),a.push(e)}return void 0!==o.query&&a.push("?",o.query),void 0!==o.fragment&&a.push("#",o.fragment),a.join("")}const d=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function l(t,r){const n=Object.assign({},r),a={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let c=!1;"suffix"===n.reference&&(t=n.scheme?n.scheme+":"+t:"//"+t);const u=t.match(d);if(u){if(a.scheme=u[1],a.userinfo=u[3],a.host=u[4],a.port=parseInt(u[5],10),a.path=u[6]||"",a.query=u[7],a.fragment=u[8],isNaN(a.port)&&(a.port=u[5]),a.host){if(!1===o(a.host)){const t=e(a.host);a.host=t.host.toLowerCase(),c=t.isIPV6}else c=!0}void 0!==a.scheme||void 0!==a.userinfo||void 0!==a.host||void 0!==a.port||void 0!==a.query||a.path?void 0===a.scheme?a.reference="relative":void 0===a.fragment?a.reference="absolute":a.reference="uri":a.reference="same-document",n.reference&&"suffix"!==n.reference&&n.reference!==a.reference&&(a.error=a.error||"URI is not a "+n.reference+" reference.");const r=i(n.scheme||a.scheme);if(!(n.unicodeSupport||r&&r.unicodeSupport)&&a.host&&(n.domainHost||r&&r.domainHost)&&!1===c&&s(a.host))try{a.host=URL.domainToASCII(a.host.toLowerCase())}catch(e){a.error=a.error||"Host's domain name can not be converted to ASCII: "+e}(!r||r&&!r.skipNormalize)&&(-1!==t.indexOf("%")&&(void 0!==a.scheme&&(a.scheme=unescape(a.scheme)),void 0!==a.host&&(a.host=unescape(a.host))),a.path&&(a.path=escape(unescape(a.path))),a.fragment&&(a.fragment=encodeURI(decodeURIComponent(a.fragment)))),r&&r.parse&&r.parse(a,n)}else a.error=a.error||"URI can not be parsed.";return a}const p={SCHEMES:a,normalize:function(e,t){return"string"==typeof e?e=u(l(e,t),t):"object"==typeof e&&(e=l(u(e,t),t)),e},resolve:function(e,t,r){const n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=c(l(e,n),l(t,n),n,!0);return n.skipEscape=!0,u(o,n)},resolveComponent:c,equal:function(e,t,r){return"string"==typeof e?(e=unescape(e),e=u(n(l(e,r),!0),{...r,skipEscape:!0})):"object"==typeof e&&(e=u(n(e,!0),{...r,skipEscape:!0})),"string"==typeof t?(t=unescape(t),t=u(n(l(t,r),!0),{...r,skipEscape:!0})):"object"==typeof t&&(t=u(n(t,!0),{...r,skipEscape:!0})),e.toLowerCase()===t.toLowerCase()},serialize:u,parse:l};return kc.exports=p,kc.exports.default=p,kc.exports.fastUri=p,kc.exports}function Pc(){return wc||(wc=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=oc();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return t.KeywordCxt}});var r=gi();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return r._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return r.str}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return r.stringify}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return r.nil}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return r.Name}}),Object.defineProperty(e,"CodeGen",{enumerable:!0,get:function(){return r.CodeGen}});const n=ic(),o=dc(),s=Ni(),a=hc(),i=gi(),c=nc(),u=Mi(),d=bi(),l=$c,p=function(){if(gc)return bc;gc=1,Object.defineProperty(bc,"__esModule",{value:!0});const e=Sc();return e.code='require("ajv/dist/runtime/uri").default',bc.default=e,bc}(),h=(e,t)=>new RegExp(e,t);h.code="new RegExp";const f=["removeAdditional","useDefaults","coerceTypes"],m=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),_={errorDataPath:"",format:"`validateFormats: false` can be used instead.",nullable:'"nullable" keyword is supported by default.',jsonPointers:"Deprecated jsPropertySyntax can be used instead.",extendRefs:"Deprecated ignoreKeywordsWithRef can be used instead.",missingRefs:"Pass empty schema with $id that should be ignored to ajv.addSchema.",processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:'"uniqueItems" keyword is always validated.',unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:"Map is used as cache, schema object as key.",serialize:"Map is used as cache, schema object as key.",ajvErrors:"It is default now."},y={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};function v(e){var t,r,n,o,s,a,i,c,u,d,l,f,m,_,y,v,g,w,$,b,k,E,S,P,T;const x=e.strict,I=null===(t=e.code)||void 0===t?void 0:t.optimize,C=!0===I||void 0===I?1:I||0,z=null!==(n=null===(r=e.code)||void 0===r?void 0:r.regExp)&&void 0!==n?n:h,N=null!==(o=e.uriResolver)&&void 0!==o?o:p.default;return{strictSchema:null===(a=null!==(s=e.strictSchema)&&void 0!==s?s:x)||void 0===a||a,strictNumbers:null===(c=null!==(i=e.strictNumbers)&&void 0!==i?i:x)||void 0===c||c,strictTypes:null!==(d=null!==(u=e.strictTypes)&&void 0!==u?u:x)&&void 0!==d?d:"log",strictTuples:null!==(f=null!==(l=e.strictTuples)&&void 0!==l?l:x)&&void 0!==f?f:"log",strictRequired:null!==(_=null!==(m=e.strictRequired)&&void 0!==m?m:x)&&void 0!==_&&_,code:e.code?{...e.code,optimize:C,regExp:z}:{optimize:C,regExp:z},loopRequired:null!==(y=e.loopRequired)&&void 0!==y?y:200,loopEnum:null!==(v=e.loopEnum)&&void 0!==v?v:200,meta:null===(g=e.meta)||void 0===g||g,messages:null===(w=e.messages)||void 0===w||w,inlineRefs:null===($=e.inlineRefs)||void 0===$||$,schemaId:null!==(b=e.schemaId)&&void 0!==b?b:"$id",addUsedSchema:null===(k=e.addUsedSchema)||void 0===k||k,validateSchema:null===(E=e.validateSchema)||void 0===E||E,validateFormats:null===(S=e.validateFormats)||void 0===S||S,unicodeRegExp:null===(P=e.unicodeRegExp)||void 0===P||P,int32range:null===(T=e.int32range)||void 0===T||T,uriResolver:N}}class g{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...v(e)};const{es5:t,lines:r}=this.opts.code;this.scope=new i.ValueScope({scope:{},prefixes:m,es5:t,lines:r}),this.logger=function(e){if(!1===e)return P;if(void 0===e)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}(e.logger);const n=e.validateFormats;e.validateFormats=!1,this.RULES=(0,s.getRules)(),w.call(this,_,e,"NOT SUPPORTED"),w.call(this,y,e,"DEPRECATED","warn"),this._metaOpts=S.call(this),e.formats&&k.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&E.call(this,e.keywords),"object"==typeof e.meta&&this.addMetaSchema(e.meta),b.call(this),e.validateFormats=n}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:e,meta:t,schemaId:r}=this.opts;let n=l;"id"===r&&(n={...l},n.id=n.$id,delete n.$id),t&&e&&this.addMetaSchema(n,n[r],!1)}defaultMeta(){const{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta="object"==typeof e?e[t]||e:void 0}validate(e,t){let r;if("string"==typeof e){if(r=this.getSchema(e),!r)throw new Error(`no schema with key or ref "${e}"`)}else r=this.compile(e);const n=r(t);return"$async"in r||(this.errors=r.errors),n}compile(e,t){const r=this._addSchema(e,t);return r.validate||this._compileSchemaEnv(r)}compileAsync(e,t){if("function"!=typeof this.opts.loadSchema)throw new Error("options.loadSchema should be a function");const{loadSchema:r}=this.opts;return n.call(this,e,t);async function n(e,t){await s.call(this,e.$schema);const r=this._addSchema(e,t);return r.validate||a.call(this,r)}async function s(e){e&&!this.getSchema(e)&&await n.call(this,{$ref:e},!0)}async function a(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof o.default))throw t;return i.call(this,t),await c.call(this,t.missingSchema),a.call(this,e)}}function i({missingSchema:e,missingRef:t}){if(this.refs[e])throw new Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){const r=await u.call(this,e);this.refs[e]||await s.call(this,r.$schema),this.refs[e]||this.addSchema(r,e,t)}async function u(e){const t=this._loading[e];if(t)return t;try{return await(this._loading[e]=r(e))}finally{delete this._loading[e]}}}addSchema(e,t,r,n=this.opts.validateSchema){if(Array.isArray(e)){for(const t of e)this.addSchema(t,void 0,r,n);return this}let o;if("object"==typeof e){const{schemaId:t}=this.opts;if(o=e[t],void 0!==o&&"string"!=typeof o)throw new Error(`schema ${t} must be string`)}return t=(0,c.normalizeId)(t||o),this._checkUnique(t),this.schemas[t]=this._addSchema(e,r,t,n,!0),this}addMetaSchema(e,t,r=this.opts.validateSchema){return this.addSchema(e,t,!0,r),this}validateSchema(e,t){if("boolean"==typeof e)return!0;let r;if(r=e.$schema,void 0!==r&&"string"!=typeof r)throw new Error("$schema must be a string");if(r=r||this.opts.defaultMeta||this.defaultMeta(),!r)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const n=this.validate(r,e);if(!n&&t){const e="schema is invalid: "+this.errorsText();if("log"!==this.opts.validateSchema)throw new Error(e);this.logger.error(e)}return n}getSchema(e){let t;for(;"string"==typeof(t=$.call(this,e));)e=t;if(void 0===t){const{schemaId:r}=this.opts,n=new a.SchemaEnv({schema:{},schemaId:r});if(t=a.resolveSchema.call(this,n,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const t=$.call(this,e);return"object"==typeof t&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{const t=e;this._cache.delete(t);let r=e[this.opts.schemaId];return r&&(r=(0,c.normalizeId)(r),delete this.schemas[r],delete this.refs[r]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(const t of e)this.addKeyword(t);return this}addKeyword(e,t){let r;if("string"==typeof e)r=e,"object"==typeof t&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),t.keyword=r);else{if("object"!=typeof e||void 0!==t)throw new Error("invalid addKeywords parameters");if(r=(t=e).keyword,Array.isArray(r)&&!r.length)throw new Error("addKeywords: keyword must be string or non-empty array")}if(x.call(this,r,t),!t)return(0,d.eachItem)(r,e=>I.call(this,e)),this;z.call(this,t);const n={...t,type:(0,u.getJSONTypes)(t.type),schemaType:(0,u.getJSONTypes)(t.schemaType)};return(0,d.eachItem)(r,0===n.type.length?e=>I.call(this,e,n):e=>n.type.forEach(t=>I.call(this,e,n,t))),this}getKeyword(e){const t=this.RULES.all[e];return"object"==typeof t?t.definition:!!t}removeKeyword(e){const{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(const r of t.rules){const t=r.rules.findIndex(t=>t.keyword===e);t>=0&&r.rules.splice(t,1)}return this}addFormat(e,t){return"string"==typeof t&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=", ",dataVar:r="data"}={}){return e&&0!==e.length?e.map(e=>`${r}${e.instancePath} ${e.message}`).reduce((e,r)=>e+t+r):"No errors"}$dataMetaSchema(e,t){const r=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(const n of t){const t=n.split("/").slice(1);let o=e;for(const e of t)o=o[e];for(const e in r){const t=r[e];if("object"!=typeof t)continue;const{$data:n}=t.definition,s=o[e];n&&s&&(o[e]=R(s))}}return e}_removeAllSchemas(e,t){for(const r in e){const n=e[r];t&&!t.test(r)||("string"==typeof n?delete e[r]:n&&!n.meta&&(this._cache.delete(n.schema),delete e[r]))}}_addSchema(e,t,r,n=this.opts.validateSchema,o=this.opts.addUsedSchema){let s;const{schemaId:i}=this.opts;if("object"==typeof e)s=e[i];else{if(this.opts.jtd)throw new Error("schema must be object");if("boolean"!=typeof e)throw new Error("schema must be object or boolean")}let u=this._cache.get(e);if(void 0!==u)return u;r=(0,c.normalizeId)(s||r);const d=c.getSchemaRefs.call(this,e,r);return u=new a.SchemaEnv({schema:e,schemaId:i,meta:t,baseId:r,localRefs:d}),this._cache.set(u.schema,u),o&&!r.startsWith("#")&&(r&&this._checkUnique(r),this.refs[r]=u),n&&this.validateSchema(e,!0),u}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):a.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){const t=this.opts;this.opts=this._metaOpts;try{a.compileSchema.call(this,e)}finally{this.opts=t}}}function w(e,t,r,n="error"){for(const o in e){const s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function $(e){return e=(0,c.normalizeId)(e),this.schemas[e]||this.refs[e]}function b(){const e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(const t in e)this.addSchema(e[t],t)}function k(){for(const e in this.opts.formats){const t=this.opts.formats[e];t&&this.addFormat(e,t)}}function E(e){if(Array.isArray(e))this.addVocabulary(e);else{this.logger.warn("keywords option as map is deprecated, pass array");for(const t in e){const r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}}function S(){const e={...this.opts};for(const t of f)delete e[t];return e}g.ValidationError=n.default,g.MissingRefError=o.default,e.default=g;const P={log(){},warn(){},error(){}};const T=/^[a-z_$][a-z0-9_$:-]*$/i;function x(e,t){const{RULES:r}=this;if((0,d.eachItem)(e,e=>{if(r.keywords[e])throw new Error(`Keyword ${e} is already defined`);if(!T.test(e))throw new Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!("code"in t)&&!("validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function I(e,t,r){var n;const o=null==t?void 0:t.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:s}=this;let a=o?s.post:s.rules.find(({type:e})=>e===r);if(a||(a={type:r,rules:[]},s.rules.push(a)),s.keywords[e]=!0,!t)return;const i={keyword:e,definition:{...t,type:(0,u.getJSONTypes)(t.type),schemaType:(0,u.getJSONTypes)(t.schemaType)}};t.before?C.call(this,a,i,t.before):a.rules.push(i),s.all[e]=i,null===(n=t.implements)||void 0===n||n.forEach(e=>this.addKeyword(e))}function C(e,t,r){const n=e.rules.findIndex(e=>e.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function z(e){let{metaSchema:t}=e;void 0!==t&&(e.$data&&this.opts.$data&&(t=R(t)),e.validateSchema=this.compile(t,!0))}const N={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function R(e){return{anyOf:[e,N]}}}(ci)),ci}var Tc,xc={},Ic={},Cc={};var zc,Nc,Rc={};function Oc(){if(Nc)return Ic;Nc=1,Object.defineProperty(Ic,"__esModule",{value:!0});const e=function(){if(Tc)return Cc;Tc=1,Object.defineProperty(Cc,"__esModule",{value:!0});const e={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};return Cc.default=e,Cc}(),t=function(){if(zc)return Rc;zc=1,Object.defineProperty(Rc,"__esModule",{value:!0}),Rc.callRef=Rc.getValidate=void 0;const e=dc(),t=Zi(),r=gi(),n=Ti(),o=hc(),s=bi(),a={keyword:"$ref",schemaType:"string",code(t){const{gen:n,schema:s,it:a}=t,{baseId:u,schemaEnv:d,validateName:l,opts:p,self:h}=a,{root:f}=d;if(("#"===s||"#/"===s)&&u===f.baseId)return function(){if(d===f)return c(t,l,d,d.$async);const e=n.scopeValue("root",{ref:f});return c(t,r._`${e}.validate`,f,f.$async)}();const m=o.resolveRef.call(h,f,u,s);if(void 0===m)throw new e.default(a.opts.uriResolver,u,s);return m instanceof o.SchemaEnv?function(e){const r=i(t,e);c(t,r,e,e.$async)}(m):function(e){const o=n.scopeValue("schema",!0===p.code.source?{ref:e,code:(0,r.stringify)(e)}:{ref:e}),a=n.name("valid"),i=t.subschema({schema:e,dataTypes:[],schemaPath:r.nil,topSchemaRef:o,errSchemaPath:s},a);t.mergeEvaluated(i),t.ok(a)}(m)}};function i(e,t){const{gen:n}=e;return t.validate?n.scopeValue("validate",{ref:t.validate}):r._`${n.scopeValue("wrapper",{ref:t})}.validate`}function c(e,o,a,i){const{gen:c,it:u}=e,{allErrors:d,schemaEnv:l,opts:p}=u,h=p.passContext?n.default.this:r.nil;function f(e){const t=r._`${e}.errors`;c.assign(n.default.vErrors,r._`${n.default.vErrors} === null ? ${t} : ${n.default.vErrors}.concat(${t})`),c.assign(n.default.errors,r._`${n.default.vErrors}.length`)}function m(e){var t;if(!u.opts.unevaluated)return;const n=null===(t=null==a?void 0:a.validate)||void 0===t?void 0:t.evaluated;if(!0!==u.props)if(n&&!n.dynamicProps)void 0!==n.props&&(u.props=s.mergeEvaluated.props(c,n.props,u.props));else{const t=c.var("props",r._`${e}.evaluated.props`);u.props=s.mergeEvaluated.props(c,t,u.props,r.Name)}if(!0!==u.items)if(n&&!n.dynamicItems)void 0!==n.items&&(u.items=s.mergeEvaluated.items(c,n.items,u.items));else{const t=c.var("items",r._`${e}.evaluated.items`);u.items=s.mergeEvaluated.items(c,t,u.items,r.Name)}}i?function(){if(!l.$async)throw new Error("async schema referenced by sync schema");const n=c.let("valid");c.try(()=>{c.code(r._`await ${(0,t.callValidateCode)(e,o,h)}`),m(o),d||c.assign(n,!0)},e=>{c.if(r._`!(${e} instanceof ${u.ValidationError})`,()=>c.throw(e)),f(e),d||c.assign(n,!1)}),e.ok(n)}():e.result((0,t.callValidateCode)(e,o,h),()=>m(o),()=>f(o))}return Rc.getValidate=i,Rc.callRef=c,Rc.default=a,Rc}(),r=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",e.default,t.default];return Ic.default=r,Ic}var jc,Ac={},Mc={};var qc,Uc={};var Dc,Vc,Fc={},Lc={};function Zc(){if(Vc)return Fc;Vc=1,Object.defineProperty(Fc,"__esModule",{value:!0});const e=gi(),t=bi(),r=function(){if(Dc)return Lc;function e(e){const t=e.length;let r,n=0,o=0;for(;o=55296&&r<=56319&&oe._`{limit: ${t}}`},o={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:n,code(n){const{keyword:o,data:s,schemaCode:a,it:i}=n,c="maxLength"===o?e.operators.GT:e.operators.LT,u=!1===i.opts.unicode?e._`${s}.length`:e._`${(0,t.useFunc)(n.gen,r.default)}(${s})`;n.fail$data(e._`${u} ${c} ${a}`)}};return Fc.default=o,Fc}var Hc,Kc={};var Wc,Gc={};var Jc,Bc={};function Qc(){if(Jc)return Bc;Jc=1,Object.defineProperty(Bc,"__esModule",{value:!0});const e=Zi(),t=gi(),r=bi(),n={keyword:"required",type:"object",schemaType:"array",$data:!0,error:{message:({params:{missingProperty:e}})=>t.str`must have required property '${e}'`,params:({params:{missingProperty:e}})=>t._`{missingProperty: ${e}}`},code(n){const{gen:o,schema:s,schemaCode:a,data:i,$data:c,it:u}=n,{opts:d}=u;if(!c&&0===s.length)return;const l=s.length>=d.loopRequired;if(u.allErrors?function(){if(l||c)n.block$data(t.nil,p);else for(const t of s)(0,e.checkReportMissingProp)(n,t)}():function(){const r=o.let("missing");if(l||c){const s=o.let("valid",!0);n.block$data(s,()=>function(r,s){n.setParams({missingProperty:r}),o.forOf(r,a,()=>{o.assign(s,(0,e.propertyInData)(o,i,r,d.ownProperties)),o.if((0,t.not)(s),()=>{n.error(),o.break()})},t.nil)}(r,s)),n.ok(s)}else o.if((0,e.checkMissingProp)(n,s,r)),(0,e.reportMissingProp)(n,r),o.else()}(),d.strictRequired){const e=n.parentSchema.properties,{definedProperties:t}=n.it;for(const n of s)if(void 0===(null==e?void 0:e[n])&&!t.has(n)){const e=`required property "${n}" is not defined at "${u.schemaEnv.baseId+u.errSchemaPath}" (strictRequired)`;(0,r.checkStrictMode)(u,e,u.opts.strictRequired)}}function p(){o.forOf("prop",a,t=>{n.setParams({missingProperty:t}),o.if((0,e.noPropertyInData)(o,i,t,d.ownProperties),()=>n.error())})}}};return Bc.default=n,Bc}var Yc,Xc={};var eu,tu,ru={},nu={};function ou(){if(eu)return nu;eu=1,Object.defineProperty(nu,"__esModule",{value:!0});const e=Qi();return e.code='require("ajv/dist/runtime/equal").default',nu.default=e,nu}function su(){if(tu)return ru;tu=1,Object.defineProperty(ru,"__esModule",{value:!0});const e=Mi(),t=gi(),r=bi(),n=ou(),o={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:{message:({params:{i:e,j:r}})=>t.str`must NOT have duplicate items (items ## ${r} and ${e} are identical)`,params:({params:{i:e,j:r}})=>t._`{i: ${e}, j: ${r}}`},code(o){const{gen:s,data:a,$data:i,schema:c,parentSchema:u,schemaCode:d,it:l}=o;if(!i&&!c)return;const p=s.let("valid"),h=u.items?(0,e.getSchemaTypes)(u.items):[];function f(r,n){const i=s.name("item"),c=(0,e.checkDataTypes)(h,i,l.opts.strictNumbers,e.DataType.Wrong),u=s.const("indices",t._`{}`);s.for(t._`;${r}--;`,()=>{s.let(i,t._`${a}[${r}]`),s.if(c,t._`continue`),h.length>1&&s.if(t._`typeof ${i} == "string"`,t._`${i} += "_"`),s.if(t._`typeof ${u}[${i}] == "number"`,()=>{s.assign(n,t._`${u}[${i}]`),o.error(),s.assign(p,!1).break()}).code(t._`${u}[${i}] = ${r}`)})}function m(e,i){const c=(0,r.useFunc)(s,n.default),u=s.name("outer");s.label(u).for(t._`;${e}--;`,()=>s.for(t._`${i} = ${e}; ${i}--;`,()=>s.if(t._`${c}(${a}[${e}], ${a}[${i}])`,()=>{o.error(),s.assign(p,!1).break(u)})))}o.block$data(p,function(){const e=s.let("i",t._`${a}.length`),r=s.let("j");o.setParams({i:e,j:r}),s.assign(p,!0),s.if(t._`${e} > 1`,()=>(h.length>0&&!h.some(e=>"object"===e||"array"===e)?f:m)(e,r))},t._`${d} === false`),o.ok(p)}};return ru.default=o,ru}var au,iu={};var cu,uu,du={};function lu(){if(cu)return du;cu=1,Object.defineProperty(du,"__esModule",{value:!0});const e=gi(),t=bi(),r=ou(),n={keyword:"enum",schemaType:"array",$data:!0,error:{message:"must be equal to one of the allowed values",params:({schemaCode:t})=>e._`{allowedValues: ${t}}`},code(n){const{gen:o,data:s,$data:a,schema:i,schemaCode:c,it:u}=n;if(!a&&0===i.length)throw new Error("enum must have non-empty array");const d=i.length>=u.opts.loopEnum;let l;const p=()=>null!=l?l:l=(0,t.useFunc)(o,r.default);let h;if(d||a)h=o.let("valid"),n.block$data(h,function(){o.assign(h,!1),o.forOf("v",c,t=>o.if(e._`${p()}(${s}, ${t})`,()=>o.assign(h,!0).break()))});else{if(!Array.isArray(i))throw new Error("ajv implementation error");const t=o.const("vSchema",c);h=(0,e.or)(...i.map((r,n)=>function(t,r){const n=i[r];return"object"==typeof n&&null!==n?e._`${p()}(${s}, ${t}[${r}])`:e._`${s} === ${n}`}(t,n)))}n.pass(h)}};return du.default=n,du}function pu(){if(uu)return Ac;uu=1,Object.defineProperty(Ac,"__esModule",{value:!0});const e=function(){if(jc)return Mc;jc=1,Object.defineProperty(Mc,"__esModule",{value:!0});const e=gi(),t=e.operators,r={maximum:{okStr:"<=",ok:t.LTE,fail:t.GT},minimum:{okStr:">=",ok:t.GTE,fail:t.LT},exclusiveMaximum:{okStr:"<",ok:t.LT,fail:t.GTE},exclusiveMinimum:{okStr:">",ok:t.GT,fail:t.LTE}},n={message:({keyword:t,schemaCode:n})=>e.str`must be ${r[t].okStr} ${n}`,params:({keyword:t,schemaCode:n})=>e._`{comparison: ${r[t].okStr}, limit: ${n}}`},o={keyword:Object.keys(r),type:"number",schemaType:"number",$data:!0,error:n,code(t){const{keyword:n,data:o,schemaCode:s}=t;t.fail$data(e._`${o} ${r[n].fail} ${s} || isNaN(${o})`)}};return Mc.default=o,Mc}(),t=function(){if(qc)return Uc;qc=1,Object.defineProperty(Uc,"__esModule",{value:!0});const e=gi(),t={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:{message:({schemaCode:t})=>e.str`must be multiple of ${t}`,params:({schemaCode:t})=>e._`{multipleOf: ${t}}`},code(t){const{gen:r,data:n,schemaCode:o,it:s}=t,a=s.opts.multipleOfPrecision,i=r.let("res"),c=a?e._`Math.abs(Math.round(${i}) - ${i}) > 1e-${a}`:e._`${i} !== parseInt(${i})`;t.fail$data(e._`(${o} === 0 || (${i} = ${n}/${o}, ${c}))`)}};return Uc.default=t,Uc}(),r=Zc(),n=function(){if(Hc)return Kc;Hc=1,Object.defineProperty(Kc,"__esModule",{value:!0});const e=Zi(),t=gi(),r={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:e})=>t.str`must match pattern "${e}"`,params:({schemaCode:e})=>t._`{pattern: ${e}}`},code(r){const{data:n,$data:o,schema:s,schemaCode:a,it:i}=r,c=i.opts.unicodeRegExp?"u":"",u=o?t._`(new RegExp(${a}, ${c}))`:(0,e.usePattern)(r,s);r.fail$data(t._`!${u}.test(${n})`)}};return Kc.default=r,Kc}(),o=function(){if(Wc)return Gc;Wc=1,Object.defineProperty(Gc,"__esModule",{value:!0});const e=gi(),t={message({keyword:t,schemaCode:r}){const n="maxProperties"===t?"more":"fewer";return e.str`must NOT have ${n} than ${r} properties`},params:({schemaCode:t})=>e._`{limit: ${t}}`},r={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:t,code(t){const{keyword:r,data:n,schemaCode:o}=t,s="maxProperties"===r?e.operators.GT:e.operators.LT;t.fail$data(e._`Object.keys(${n}).length ${s} ${o}`)}};return Gc.default=r,Gc}(),s=Qc(),a=function(){if(Yc)return Xc;Yc=1,Object.defineProperty(Xc,"__esModule",{value:!0});const e=gi(),t={message({keyword:t,schemaCode:r}){const n="maxItems"===t?"more":"fewer";return e.str`must NOT have ${n} than ${r} items`},params:({schemaCode:t})=>e._`{limit: ${t}}`},r={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:t,code(t){const{keyword:r,data:n,schemaCode:o}=t,s="maxItems"===r?e.operators.GT:e.operators.LT;t.fail$data(e._`${n}.length ${s} ${o}`)}};return Xc.default=r,Xc}(),i=su(),c=function(){if(au)return iu;au=1,Object.defineProperty(iu,"__esModule",{value:!0});const e=gi(),t=bi(),r=ou(),n={keyword:"const",$data:!0,error:{message:"must be equal to constant",params:({schemaCode:t})=>e._`{allowedValue: ${t}}`},code(n){const{gen:o,data:s,$data:a,schemaCode:i,schema:c}=n;a||c&&"object"==typeof c?n.fail$data(e._`!${(0,t.useFunc)(o,r.default)}(${s}, ${i})`):n.fail(e._`${c} !== ${s}`)}};return iu.default=n,iu}(),u=lu(),d=[e.default,t.default,r.default,n.default,o.default,s.default,a.default,i.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},c.default,u.default];return Ac.default=d,Ac}var hu,fu={},mu={};function _u(){if(hu)return mu;hu=1,Object.defineProperty(mu,"__esModule",{value:!0}),mu.validateAdditionalItems=void 0;const e=gi(),t=bi(),r={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:{message:({params:{len:t}})=>e.str`must NOT have more than ${t} items`,params:({params:{len:t}})=>e._`{limit: ${t}}`},code(e){const{parentSchema:r,it:o}=e,{items:s}=r;Array.isArray(s)?n(e,s):(0,t.checkStrictMode)(o,'"additionalItems" is ignored when "items" is not an array of schemas')}};function n(r,n){const{gen:o,schema:s,data:a,keyword:i,it:c}=r;c.items=!0;const u=o.const("len",e._`${a}.length`);if(!1===s)r.setParams({len:n.length}),r.pass(e._`${u} <= ${n.length}`);else if("object"==typeof s&&!(0,t.alwaysValidSchema)(c,s)){const s=o.var("valid",e._`${u} <= ${n.length}`);o.if((0,e.not)(s),()=>function(s){o.forRange("i",n.length,u,n=>{r.subschema({keyword:i,dataProp:n,dataPropType:t.Type.Num},s),c.allErrors||o.if((0,e.not)(s),()=>o.break())})}(s)),r.ok(s)}}return mu.validateAdditionalItems=n,mu.default=r,mu}var yu,vu,gu={},wu={};function $u(){if(yu)return wu;yu=1,Object.defineProperty(wu,"__esModule",{value:!0}),wu.validateTuple=void 0;const e=gi(),t=bi(),r=Zi(),n={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:n,it:s}=e;if(Array.isArray(n))return o(e,"additionalItems",n);s.items=!0,(0,t.alwaysValidSchema)(s,n)||e.ok((0,r.validateArray)(e))}};function o(r,n,o=r.schema){const{gen:s,parentSchema:a,data:i,keyword:c,it:u}=r;!function(e){const{opts:r,errSchemaPath:s}=u,a=o.length,i=a===e.minItems&&(a===e.maxItems||!1===e[n]);if(r.strictTuples&&!i){const e=`"${c}" is ${a}-tuple, but minItems or maxItems/${n} are not specified or different at path "${s}"`;(0,t.checkStrictMode)(u,e,r.strictTuples)}}(a),u.opts.unevaluated&&o.length&&!0!==u.items&&(u.items=t.mergeEvaluated.items(s,o.length,u.items));const d=s.name("valid"),l=s.const("len",e._`${i}.length`);o.forEach((n,o)=>{(0,t.alwaysValidSchema)(u,n)||(s.if(e._`${l} > ${o}`,()=>r.subschema({keyword:c,schemaProp:o,dataProp:o},d)),r.ok(d))})}return wu.validateTuple=o,wu.default=n,wu}var bu,ku={};var Eu,Su={};function Pu(){if(Eu)return Su;Eu=1,Object.defineProperty(Su,"__esModule",{value:!0});const e=gi(),t=bi(),r={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:{message:({params:{min:t,max:r}})=>void 0===r?e.str`must contain at least ${t} valid item(s)`:e.str`must contain at least ${t} and no more than ${r} valid item(s)`,params:({params:{min:t,max:r}})=>void 0===r?e._`{minContains: ${t}}`:e._`{minContains: ${t}, maxContains: ${r}}`},code(r){const{gen:n,schema:o,parentSchema:s,data:a,it:i}=r;let c,u;const{minContains:d,maxContains:l}=s;i.opts.next?(c=void 0===d?1:d,u=l):c=1;const p=n.const("len",e._`${a}.length`);if(r.setParams({min:c,max:u}),void 0===u&&0===c)return void(0,t.checkStrictMode)(i,'"minContains" == 0 without "maxContains": "contains" keyword ignored');if(void 0!==u&&c>u)return(0,t.checkStrictMode)(i,'"minContains" > "maxContains" is always invalid'),void r.fail();if((0,t.alwaysValidSchema)(i,o)){let t=e._`${p} >= ${c}`;return void 0!==u&&(t=e._`${t} && ${p} <= ${u}`),void r.pass(t)}i.items=!0;const h=n.name("valid");function f(){const t=n.name("_valid"),r=n.let("count",0);m(t,()=>n.if(t,()=>function(t){n.code(e._`${t}++`),void 0===u?n.if(e._`${t} >= ${c}`,()=>n.assign(h,!0).break()):(n.if(e._`${t} > ${u}`,()=>n.assign(h,!1).break()),1===c?n.assign(h,!0):n.if(e._`${t} >= ${c}`,()=>n.assign(h,!0)))}(r)))}function m(e,o){n.forRange("i",0,p,n=>{r.subschema({keyword:"contains",dataProp:n,dataPropType:t.Type.Num,compositeRule:!0},e),o()})}void 0===u&&1===c?m(h,()=>n.if(h,()=>n.break())):0===c?(n.let(h,!0),void 0!==u&&n.if(e._`${a}.length > 0`,f)):(n.let(h,!1),f()),r.result(h,()=>r.reset())}};return Su.default=r,Su}var Tu,xu={};function Iu(){return Tu||(Tu=1,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;const t=gi(),r=bi(),n=Zi();e.error={message:({params:{property:e,depsCount:r,deps:n}})=>{const o=1===r?"property":"properties";return t.str`must have ${o} ${n} when property ${e} is present`},params:({params:{property:e,depsCount:r,deps:n,missingProperty:o}})=>t._`{property: ${e}, missingProperty: ${o}, depsCount: ${r}, deps: ${n}}`};const o={keyword:"dependencies",type:"object",schemaType:"object",error:e.error,code(e){const[t,r]=function({schema:e}){const t={},r={};for(const n in e){if("__proto__"===n)continue;(Array.isArray(e[n])?t:r)[n]=e[n]}return[t,r]}(e);s(e,t),a(e,r)}};function s(e,r=e.schema){const{gen:o,data:s,it:a}=e;if(0===Object.keys(r).length)return;const i=o.let("missing");for(const c in r){const u=r[c];if(0===u.length)continue;const d=(0,n.propertyInData)(o,s,c,a.opts.ownProperties);e.setParams({property:c,depsCount:u.length,deps:u.join(", ")}),a.allErrors?o.if(d,()=>{for(const t of u)(0,n.checkReportMissingProp)(e,t)}):(o.if(t._`${d} && (${(0,n.checkMissingProp)(e,u,i)})`),(0,n.reportMissingProp)(e,i),o.else())}}function a(e,t=e.schema){const{gen:o,data:s,keyword:a,it:i}=e,c=o.name("valid");for(const u in t)(0,r.alwaysValidSchema)(i,t[u])||(o.if((0,n.propertyInData)(o,s,u,i.opts.ownProperties),()=>{const t=e.subschema({keyword:a,schemaProp:u},c);e.mergeValidEvaluated(t,c)},()=>o.var(c,!0)),e.ok(c))}e.validatePropertyDeps=s,e.validateSchemaDeps=a,e.default=o}(xu)),xu}var Cu,zu={};var Nu,Ru={};function Ou(){if(Nu)return Ru;Nu=1,Object.defineProperty(Ru,"__esModule",{value:!0});const e=Zi(),t=gi(),r=Ti(),n=bi(),o={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:{message:"must NOT have additional properties",params:({params:e})=>t._`{additionalProperty: ${e.additionalProperty}}`},code(o){const{gen:s,schema:a,parentSchema:i,data:c,errsCount:u,it:d}=o;if(!u)throw new Error("ajv implementation error");const{allErrors:l,opts:p}=d;if(d.props=!0,"all"!==p.removeAdditional&&(0,n.alwaysValidSchema)(d,a))return;const h=(0,e.allSchemaProperties)(i.properties),f=(0,e.allSchemaProperties)(i.patternProperties);function m(e){s.code(t._`delete ${c}[${e}]`)}function _(e){if("all"===p.removeAdditional||p.removeAdditional&&!1===a)m(e);else{if(!1===a)return o.setParams({additionalProperty:e}),o.error(),void(l||s.break());if("object"==typeof a&&!(0,n.alwaysValidSchema)(d,a)){const r=s.name("valid");"failing"===p.removeAdditional?(y(e,r,!1),s.if((0,t.not)(r),()=>{o.reset(),m(e)})):(y(e,r),l||s.if((0,t.not)(r),()=>s.break()))}}}function y(e,t,r){const s={keyword:"additionalProperties",dataProp:e,dataPropType:n.Type.Str};!1===r&&Object.assign(s,{compositeRule:!0,createErrors:!1,allErrors:!1}),o.subschema(s,t)}s.forIn("key",c,r=>{h.length||f.length?s.if(function(r){let a;if(h.length>8){const t=(0,n.schemaRefOrVal)(d,i.properties,"properties");a=(0,e.isOwnProperty)(s,t,r)}else a=h.length?(0,t.or)(...h.map(e=>t._`${r} === ${e}`)):t.nil;return f.length&&(a=(0,t.or)(a,...f.map(n=>t._`${(0,e.usePattern)(o,n)}.test(${r})`))),(0,t.not)(a)}(r),()=>_(r)):_(r)}),o.ok(t._`${u} === ${r.default.errors}`)}};return Ru.default=o,Ru}var ju,Au={};var Mu,qu={};var Uu,Du={};var Vu,Fu={};var Lu,Zu={};var Hu,Ku={};var Wu,Gu={};var Ju,Bu,Qu={};function Yu(){if(Bu)return fu;Bu=1,Object.defineProperty(fu,"__esModule",{value:!0});const e=_u(),t=function(){if(vu)return gu;vu=1,Object.defineProperty(gu,"__esModule",{value:!0});const e=$u(),t={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,e.validateTuple)(t,"items")};return gu.default=t,gu}(),r=$u(),n=function(){if(bu)return ku;bu=1,Object.defineProperty(ku,"__esModule",{value:!0});const e=gi(),t=bi(),r=Zi(),n=_u(),o={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:{message:({params:{len:t}})=>e.str`must NOT have more than ${t} items`,params:({params:{len:t}})=>e._`{limit: ${t}}`},code(e){const{schema:o,parentSchema:s,it:a}=e,{prefixItems:i}=s;a.items=!0,(0,t.alwaysValidSchema)(a,o)||(i?(0,n.validateAdditionalItems)(e,i):e.ok((0,r.validateArray)(e)))}};return ku.default=o,ku}(),o=Pu(),s=Iu(),a=function(){if(Cu)return zu;Cu=1,Object.defineProperty(zu,"__esModule",{value:!0});const e=gi(),t=bi(),r={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:{message:"property name must be valid",params:({params:t})=>e._`{propertyName: ${t.propertyName}}`},code(r){const{gen:n,schema:o,data:s,it:a}=r;if((0,t.alwaysValidSchema)(a,o))return;const i=n.name("valid");n.forIn("key",s,t=>{r.setParams({propertyName:t}),r.subschema({keyword:"propertyNames",data:t,dataTypes:["string"],propertyName:t,compositeRule:!0},i),n.if((0,e.not)(i),()=>{r.error(!0),a.allErrors||n.break()})}),r.ok(i)}};return zu.default=r,zu}(),i=Ou(),c=function(){if(ju)return Au;ju=1,Object.defineProperty(Au,"__esModule",{value:!0});const e=oc(),t=Zi(),r=bi(),n=Ou(),o={keyword:"properties",type:"object",schemaType:"object",code(o){const{gen:s,schema:a,parentSchema:i,data:c,it:u}=o;"all"===u.opts.removeAdditional&&void 0===i.additionalProperties&&n.default.code(new e.KeywordCxt(u,n.default,"additionalProperties"));const d=(0,t.allSchemaProperties)(a);for(const e of d)u.definedProperties.add(e);u.opts.unevaluated&&d.length&&!0!==u.props&&(u.props=r.mergeEvaluated.props(s,(0,r.toHash)(d),u.props));const l=d.filter(e=>!(0,r.alwaysValidSchema)(u,a[e]));if(0===l.length)return;const p=s.name("valid");for(const e of l)h(e)?f(e):(s.if((0,t.propertyInData)(s,c,e,u.opts.ownProperties)),f(e),u.allErrors||s.else().var(p,!0),s.endIf()),o.it.definedProperties.add(e),o.ok(p);function h(e){return u.opts.useDefaults&&!u.compositeRule&&void 0!==a[e].default}function f(e){o.subschema({keyword:"properties",schemaProp:e,dataProp:e},p)}}};return Au.default=o,Au}(),u=function(){if(Mu)return qu;Mu=1,Object.defineProperty(qu,"__esModule",{value:!0});const e=Zi(),t=gi(),r=bi(),n=bi(),o={keyword:"patternProperties",type:"object",schemaType:"object",code(o){const{gen:s,schema:a,data:i,parentSchema:c,it:u}=o,{opts:d}=u,l=(0,e.allSchemaProperties)(a),p=l.filter(e=>(0,r.alwaysValidSchema)(u,a[e]));if(0===l.length||p.length===l.length&&(!u.opts.unevaluated||!0===u.props))return;const h=d.strictSchema&&!d.allowMatchingProperties&&c.properties,f=s.name("valid");!0===u.props||u.props instanceof t.Name||(u.props=(0,n.evaluatedPropsToName)(s,u.props));const{props:m}=u;function _(e){for(const t in h)new RegExp(e).test(t)&&(0,r.checkStrictMode)(u,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function y(r){s.forIn("key",i,a=>{s.if(t._`${(0,e.usePattern)(o,r)}.test(${a})`,()=>{const e=p.includes(r);e||o.subschema({keyword:"patternProperties",schemaProp:r,dataProp:a,dataPropType:n.Type.Str},f),u.opts.unevaluated&&!0!==m?s.assign(t._`${m}[${a}]`,!0):e||u.allErrors||s.if((0,t.not)(f),()=>s.break())})})}!function(){for(const e of l)h&&_(e),u.allErrors?y(e):(s.var(f,!0),y(e),s.if(f))}()}};return qu.default=o,qu}(),d=function(){if(Uu)return Du;Uu=1,Object.defineProperty(Du,"__esModule",{value:!0});const e=bi(),t={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){const{gen:r,schema:n,it:o}=t;if((0,e.alwaysValidSchema)(o,n))return void t.fail();const s=r.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},s),t.failResult(s,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};return Du.default=t,Du}(),l=function(){if(Vu)return Fu;Vu=1,Object.defineProperty(Fu,"__esModule",{value:!0});const e={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Zi().validateUnion,error:{message:"must match a schema in anyOf"}};return Fu.default=e,Fu}(),p=function(){if(Lu)return Zu;Lu=1,Object.defineProperty(Zu,"__esModule",{value:!0});const e=gi(),t=bi(),r={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:{message:"must match exactly one schema in oneOf",params:({params:t})=>e._`{passingSchemas: ${t.passing}}`},code(r){const{gen:n,schema:o,parentSchema:s,it:a}=r;if(!Array.isArray(o))throw new Error("ajv implementation error");if(a.opts.discriminator&&s.discriminator)return;const i=o,c=n.let("valid",!1),u=n.let("passing",null),d=n.name("_valid");r.setParams({passing:u}),n.block(function(){i.forEach((o,s)=>{let i;(0,t.alwaysValidSchema)(a,o)?n.var(d,!0):i=r.subschema({keyword:"oneOf",schemaProp:s,compositeRule:!0},d),s>0&&n.if(e._`${d} && ${c}`).assign(c,!1).assign(u,e._`[${u}, ${s}]`).else(),n.if(d,()=>{n.assign(c,!0),n.assign(u,s),i&&r.mergeEvaluated(i,e.Name)})})}),r.result(c,()=>r.reset(),()=>r.error(!0))}};return Zu.default=r,Zu}(),h=function(){if(Hu)return Ku;Hu=1,Object.defineProperty(Ku,"__esModule",{value:!0});const e=bi(),t={keyword:"allOf",schemaType:"array",code(t){const{gen:r,schema:n,it:o}=t;if(!Array.isArray(n))throw new Error("ajv implementation error");const s=r.name("valid");n.forEach((r,n)=>{if((0,e.alwaysValidSchema)(o,r))return;const a=t.subschema({keyword:"allOf",schemaProp:n},s);t.ok(s),t.mergeEvaluated(a)})}};return Ku.default=t,Ku}(),f=function(){if(Wu)return Gu;Wu=1,Object.defineProperty(Gu,"__esModule",{value:!0});const e=gi(),t=bi(),r={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:{message:({params:t})=>e.str`must match "${t.ifClause}" schema`,params:({params:t})=>e._`{failingKeyword: ${t.ifClause}}`},code(r){const{gen:o,parentSchema:s,it:a}=r;void 0===s.then&&void 0===s.else&&(0,t.checkStrictMode)(a,'"if" without "then" and "else" is ignored');const i=n(a,"then"),c=n(a,"else");if(!i&&!c)return;const u=o.let("valid",!0),d=o.name("_valid");if(function(){const e=r.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},d);r.mergeEvaluated(e)}(),r.reset(),i&&c){const e=o.let("ifClause");r.setParams({ifClause:e}),o.if(d,l("then",e),l("else",e))}else i?o.if(d,l("then")):o.if((0,e.not)(d),l("else"));function l(t,n){return()=>{const s=r.subschema({keyword:t},d);o.assign(u,d),r.mergeValidEvaluated(s,u),n?o.assign(n,e._`${t}`):r.setParams({ifClause:t})}}r.pass(u,()=>r.error(!0))}};function n(e,r){const n=e.schema[r];return void 0!==n&&!(0,t.alwaysValidSchema)(e,n)}return Gu.default=r,Gu}(),m=function(){if(Ju)return Qu;Ju=1,Object.defineProperty(Qu,"__esModule",{value:!0});const e=bi(),t={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:r,it:n}){void 0===r.if&&(0,e.checkStrictMode)(n,`"${t}" without "if" is ignored`)}};return Qu.default=t,Qu}();return fu.default=function(_=!1){const y=[d.default,l.default,p.default,h.default,f.default,m.default,a.default,i.default,s.default,c.default,u.default];return _?y.push(t.default,n.default):y.push(e.default,r.default),y.push(o.default),y},fu}var Xu,ed,td={},rd={};function nd(){if(Xu)return rd;Xu=1,Object.defineProperty(rd,"__esModule",{value:!0});const e=gi(),t={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:{message:({schemaCode:t})=>e.str`must match format "${t}"`,params:({schemaCode:t})=>e._`{format: ${t}}`},code(t,r){const{gen:n,data:o,$data:s,schema:a,schemaCode:i,it:c}=t,{opts:u,errSchemaPath:d,schemaEnv:l,self:p}=c;u.validateFormats&&(s?function(){const s=n.scopeValue("formats",{ref:p.formats,code:u.code.formats}),a=n.const("fDef",e._`${s}[${i}]`),c=n.let("fType"),d=n.let("format");n.if(e._`typeof ${a} == "object" && !(${a} instanceof RegExp)`,()=>n.assign(c,e._`${a}.type || "string"`).assign(d,e._`${a}.validate`),()=>n.assign(c,e._`"string"`).assign(d,a)),t.fail$data((0,e.or)(!1===u.strictSchema?e.nil:e._`${i} && !${d}`,function(){const t=l.$async?e._`(${a}.async ? await ${d}(${o}) : ${d}(${o}))`:e._`${d}(${o})`,n=e._`(typeof ${d} == "function" ? ${t} : ${d}.test(${o}))`;return e._`${d} && ${d} !== true && ${c} === ${r} && !${n}`}()))}():function(){const s=p.formats[a];if(!s)return void function(){if(!1===u.strictSchema)return void p.logger.warn(e());throw new Error(e());function e(){return`unknown format "${a}" ignored in schema at path "${d}"`}}();if(!0===s)return;const[i,c,h]=function(t){const r=t instanceof RegExp?(0,e.regexpCode)(t):u.code.formats?e._`${u.code.formats}${(0,e.getProperty)(a)}`:void 0,o=n.scopeValue("formats",{key:a,ref:t,code:r});if("object"==typeof t&&!(t instanceof RegExp))return[t.type||"string",t.validate,e._`${o}.validate`];return["string",t,o]}(s);i===r&&t.pass(function(){if("object"==typeof s&&!(s instanceof RegExp)&&s.async){if(!l.$async)throw new Error("async format in sync schema");return e._`await ${h}(${o})`}return"function"==typeof c?e._`${h}(${o})`:e._`${h}.test(${o})`}())}())}};return rd.default=t,rd}var od,sd,ad={};function id(){if(sd)return xc;sd=1,Object.defineProperty(xc,"__esModule",{value:!0});const e=Oc(),t=pu(),r=Yu(),n=function(){if(ed)return td;ed=1,Object.defineProperty(td,"__esModule",{value:!0});const e=[nd().default];return td.default=e,td}(),o=(od||(od=1,Object.defineProperty(ad,"__esModule",{value:!0}),ad.contentVocabulary=ad.metadataVocabulary=void 0,ad.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],ad.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]),ad),s=[e.default,t.default,(0,r.default)(),n.default,o.metadataVocabulary,o.contentVocabulary];return xc.default=s,xc}var cd,ud,dd={},ld={};function pd(){if(ud)return dd;ud=1,Object.defineProperty(dd,"__esModule",{value:!0});const e=gi(),t=(cd||(cd=1,Object.defineProperty(ld,"__esModule",{value:!0}),ld.DiscrError=void 0,function(e){e.Tag="tag",e.Mapping="mapping"}(r||(ld.DiscrError=r={}))),ld);var r;const n=hc(),o=dc(),s=bi(),a={keyword:"discriminator",type:"object",schemaType:"object",error:{message:({params:{discrError:e,tagName:r}})=>e===t.DiscrError.Tag?`tag "${r}" must be string`:`value of tag "${r}" must be in oneOf`,params:({params:{discrError:t,tag:r,tagName:n}})=>e._`{error: ${t}, tag: ${n}, tagValue: ${r}}`},code(r){const{gen:a,data:i,schema:c,parentSchema:u,it:d}=r,{oneOf:l}=u;if(!d.opts.discriminator)throw new Error("discriminator: requires discriminator option");const p=c.propertyName;if("string"!=typeof p)throw new Error("discriminator: requires propertyName");if(c.mapping)throw new Error("discriminator: mapping is not supported");if(!l)throw new Error("discriminator: requires oneOf keyword");const h=a.let("valid",!1),f=a.const("tag",e._`${i}${(0,e.getProperty)(p)}`);function m(t){const n=a.name("valid"),o=r.subschema({keyword:"oneOf",schemaProp:t},n);return r.mergeEvaluated(o,e.Name),n}a.if(e._`typeof ${f} == "string"`,()=>function(){const i=function(){var e;const t={},r=i(u);let a=!0;for(let t=0;tr.error(!1,{discrError:t.DiscrError.Tag,tag:f,tagName:p})),r.ok(h)}};return dd.default=a,dd}var hd,fd={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0};function md(){return hd||(hd=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0}),t.MissingRefError=t.ValidationError=t.CodeGen=t.Name=t.nil=t.stringify=t.str=t._=t.KeywordCxt=t.Ajv=void 0;const r=Pc(),n=id(),o=pd(),s=fd,a=["/properties"],i="http://json-schema.org/draft-07/schema";class c extends r.default{_addVocabularies(){super._addVocabularies(),n.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(o.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const e=this.opts.$data?this.$dataMetaSchema(s,a):s;this.addMetaSchema(e,i,!1),this.refs["http://json-schema.org/schema"]=i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(i)?i:void 0)}}t.Ajv=c,e.exports=t=c,e.exports.Ajv=c,Object.defineProperty(t,"__esModule",{value:!0}),t.default=c;var u=oc();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var d=gi();Object.defineProperty(t,"_",{enumerable:!0,get:function(){return d._}}),Object.defineProperty(t,"str",{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(t,"stringify",{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(t,"nil",{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(t,"Name",{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(t,"CodeGen",{enumerable:!0,get:function(){return d.CodeGen}});var l=ic();Object.defineProperty(t,"ValidationError",{enumerable:!0,get:function(){return l.default}});var p=dc();Object.defineProperty(t,"MissingRefError",{enumerable:!0,get:function(){return p.default}})}(ii,ii.exports)),ii.exports}var _d,yd=md(),vd={exports:{}},gd={};var wd,$d,bd={};var kd=($d||($d=1,function(e,t){Object.defineProperty(t,"__esModule",{value:!0});const r=(_d||(_d=1,function(e){function t(e,t){return{validate:e,compare:t}}Object.defineProperty(e,"__esModule",{value:!0}),e.formatNames=e.fastFormats=e.fullFormats=void 0,e.fullFormats={date:t(o,s),time:t(i(!0),c),"date-time":t(l(!0),p),"iso-time":t(i(),u),"iso-date-time":t(l(),h),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:function(e){return f.test(e)&&m.test(e)},"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,url:/^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,ipv6:/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,regex:function(e){if(w.test(e))return!1;try{return new RegExp(e),!0}catch(e){return!1}},uuid:/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,"json-pointer":/^(?:\/(?:[^~/]|~0|~1)*)*$/,"json-pointer-uri-fragment":/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,"relative-json-pointer":/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,byte:function(e){return _.lastIndex=0,_.test(e)},int32:{type:"number",validate:function(e){return Number.isInteger(e)&&e<=v&&e>=y}},int64:{type:"number",validate:function(e){return Number.isInteger(e)}},float:{type:"number",validate:g},double:{type:"number",validate:g},password:!0,binary:!0},e.fastFormats={...e.fullFormats,date:t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,s),time:t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,c),"date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,p),"iso-time":t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,u),"iso-date-time":t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,h),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i},e.formatNames=Object.keys(e.fullFormats);const r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,n=[0,31,28,31,30,31,30,31,31,30,31,30,31];function o(e){const t=r.exec(e);if(!t)return!1;const o=+t[1],s=+t[2],a=+t[3];return s>=1&&s<=12&&a>=1&&a<=(2===s&&function(e){return e%4==0&&(e%100!=0||e%400==0)}(o)?29:n[s])}function s(e,t){if(e&&t)return e>t?1:e23||d>59||e&&!i)return!1;if(n<=23&&o<=59&&s<60)return!0;const l=o-d*c,p=n-u*c-(l<0?1:0);return(23===p||-1===p)&&(59===l||-1===l)&&s<61}}function c(e,t){if(!e||!t)return;const r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();return r&&n?r-n:void 0}function u(e,t){if(!e||!t)return;const r=a.exec(e),n=a.exec(t);return r&&n?(e=r[1]+r[2]+r[3])>(t=n[1]+n[2]+n[3])?1:e=",ok:n.GTE,fail:n.LT},formatExclusiveMaximum:{okStr:"<",ok:n.LT,fail:n.GTE},formatExclusiveMinimum:{okStr:">",ok:n.GT,fail:n.LTE}},s={message:({keyword:e,schemaCode:t})=>r.str`should be ${o[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>r._`{comparison: ${o[e].okStr}, limit: ${t}}`};e.formatLimitDefinition={keyword:Object.keys(o),type:"string",schemaType:"string",$data:!0,error:s,code(e){const{gen:n,data:s,schemaCode:a,keyword:i,it:c}=e,{opts:u,self:d}=c;if(!u.validateFormats)return;const l=new t.KeywordCxt(c,d.RULES.all.format.definition,"format");function p(e){return r._`${e}.compare(${s}, ${a}) ${o[i].fail} 0`}l.$data?function(){const t=n.scopeValue("formats",{ref:d.formats,code:u.code.formats}),o=n.const("fmt",r._`${t}[${l.schemaCode}]`);e.fail$data((0,r.or)(r._`typeof ${o} != "object"`,r._`${o} instanceof RegExp`,r._`typeof ${o}.compare != "function"`,p(o)))}():function(){const t=l.schema,o=d.formats[t];if(!o||!0===o)return;if("object"!=typeof o||o instanceof RegExp||"function"!=typeof o.compare)throw new Error(`"${i}": format "${t}" does not define "compare" function`);const s=n.scopeValue("formats",{key:t,ref:o,code:u.code.formats?r._`${u.code.formats}${(0,r.getProperty)(t)}`:void 0});e.fail$data(p(s))}()},dependencies:["format"]},e.default=t=>(t.addKeyword(e.formatLimitDefinition),t)}(bd)),bd),o=gi(),s=new o.Name("fullFormats"),a=new o.Name("fastFormats"),i=(e,t={keywords:!0})=>{if(Array.isArray(t))return c(e,t,r.fullFormats,s),e;const[o,i]="fast"===t.mode?[r.fastFormats,a]:[r.fullFormats,s];return c(e,t.formats||r.formatNames,o,i),t.keywords&&(0,n.default)(e),e};function c(e,t,r,n){var s,a;null!==(s=(a=e.opts.code).formats)&&void 0!==s||(a.formats=o._`require("ajv-formats/dist/formats").${n}`);for(const n of t)e.addFormat(n,r[n])}i.get=(e,t="full")=>{const n=("fast"===t?r.fastFormats:r.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n},e.exports=t=i,Object.defineProperty(t,"__esModule",{value:!0}),t.default=i}(vd,vd.exports)),vd.exports),Ed=si(kd);class Sd{constructor(e){this._ajv=e??function(){const e=new yd.Ajv({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return Ed(e),e}()}getValidator(e){const t="$id"in e&&"string"==typeof e.$id?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return e=>t(e)?{valid:!0,data:e,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(t.errors)}}}class Pd{constructor(e){this._client=e}async*callToolStream(e,t=Ks,r){const n=this._client,o={...r,task:r?.task??(n.isToolTask(e.name)?{}:void 0)},s=n.requestStream({method:"tools/call",params:e},t,o),a=n.getToolOutputValidator(e.name);for await(const t of s){if("result"===t.type&&a){const r=t.result;if(!r.structuredContent&&!r.isError)return void(yield{type:"error",error:new Qa(uo.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)});if(r.structuredContent)try{const e=a(r.structuredContent);if(!e.valid)return void(yield{type:"error",error:new Qa(uo.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)})}catch(e){return e instanceof Qa?void(yield{type:"error",error:e}):void(yield{type:"error",error:new Qa(uo.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)})}}yield t}}async getTask(e,t){return this._client.getTask({taskId:e},t)}async getTaskResult(e,t,r){return this._client.getTaskResult({taskId:e},t,r)}async listTasks(e,t){return this._client.listTasks(e?{cursor:e}:void 0,t)}async cancelTask(e,t){return this._client.cancelTask({taskId:e},t)}requestStream(e,t,r){return this._client.requestStream(e,t,r)}}function Td(e,t){if(e&&null!==t&&"object"==typeof t){if("object"===e.type&&e.properties&&"object"==typeof e.properties){const r=t,n=e.properties;for(const e of Object.keys(n)){const t=n[e];void 0===r[e]&&Object.prototype.hasOwnProperty.call(t,"default")&&(r[e]=t.default),void 0!==r[e]&&Td(t,r[e])}}if(Array.isArray(e.anyOf))for(const r of e.anyOf)"boolean"!=typeof r&&Td(r,t);if(Array.isArray(e.oneOf))for(const r of e.oneOf)"boolean"!=typeof r&&Td(r,t)}}function xd(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};const t=void 0!==e.form,r=void 0!==e.url;return{supportsFormMode:t||!t&&!r,supportsUrlMode:r}}class Id extends ri{constructor(e,t){super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=t?.capabilities??{},this._jsonSchemaValidator=t?.jsonSchemaValidator??new Sd,t?.listChanged&&(this._pendingListChangedConfig=t.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",Bs,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Ds,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",vs,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new Pd(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=function(e,t){const r={...e};for(const e in t){const n=e,o=t[n];if(void 0===o)continue;const s=r[n];ni(s)&&ni(o)?r[n]={...s,...o}:r[n]=o}return r}(this._capabilities,e)}setRequestHandler(e,t){const r=or(e),n=r?.method;if(!n)throw new Error("Schema is missing a method literal");let o;if(rr(n)){const e=n,t=e._zod?.def;o=t?.value??e.value}else{const e=n,t=e._def;o=t?.value??e.value}if("string"!=typeof o)throw new Error("Schema method literal must be a string");const s=o;if("elicitation/create"===s){const r=async(e,r)=>{const n=nr(Ia,e);if(!n.success){const e=n.error instanceof Error?n.error.message:String(n.error);throw new Qa(uo.InvalidParams,`Invalid elicitation request: ${e}`)}const{params:o}=n.data;o.mode=o.mode??"form";const{supportsFormMode:s,supportsUrlMode:a}=xd(this._capabilities.elicitation);if("form"===o.mode&&!s)throw new Qa(uo.InvalidParams,"Client does not support form-mode elicitation requests");if("url"===o.mode&&!a)throw new Qa(uo.InvalidParams,"Client does not support URL-mode elicitation requests");const i=await Promise.resolve(t(e,r));if(o.task){const e=nr(Ho,i);if(!e.success){const t=e.error instanceof Error?e.error.message:String(e.error);throw new Qa(uo.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}const c=nr(Na,i);if(!c.success){const e=c.error instanceof Error?c.error.message:String(c.error);throw new Qa(uo.InvalidParams,`Invalid elicitation result: ${e}`)}const u=c.data,d="form"===o.mode?o.requestedSchema:void 0;if("form"===o.mode&&"accept"===u.action&&u.content&&d&&this._capabilities.elicitation?.form?.applyDefaults)try{Td(d,u.content)}catch{}return u};return super.setRequestHandler(e,r)}if("sampling/createMessage"===s){const r=async(e,r)=>{const n=nr(la,e);if(!n.success){const e=n.error instanceof Error?n.error.message:String(n.error);throw new Qa(uo.InvalidParams,`Invalid sampling request: ${e}`)}const{params:o}=n.data,s=await Promise.resolve(t(e,r));if(o.task){const e=nr(Ho,s);if(!e.success){const t=e.error instanceof Error?e.error.message:String(e.error);throw new Qa(uo.InvalidParams,`Invalid task creation result: ${t}`)}return e.data}const a=nr(pa,s);if(!a.success){const e=a.error instanceof Error?a.error.message:String(a.error);throw new Qa(uo.InvalidParams,`Invalid sampling result: ${e}`)}return a.data};return super.setRequestHandler(e,r)}return super.setRequestHandler(e,t)}assertCapability(e,t){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){await this.internal_connect(e),void 0===e.sessionId&&await this.internal_start(e,t)}async internal_connect(e){await super.connect(e)}async internal_start(e,t){try{const r=await this.request({method:"initialize",params:{protocolVersion:jn,capabilities:this._capabilities,clientInfo:this._clientInfo}},Ro,t);if(void 0===r)throw new Error(`Server sent invalid initialize result: ${r}`);if(!Mn.includes(r.protocolVersion))throw new Error(`Server's protocol version is not supported: ${r.protocolVersion}`);this._serverCapabilities=r.capabilities,this._serverVersion=r.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(r.protocolVersion),this._instructions=r.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(e){throw this.close(),e}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){switch(e){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.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(!this._serverCapabilities?.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(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${e})`)}}assertNotificationCapability(e){if("notifications/roots/list_changed"===e)if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`)}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Client does not support tasks capability (required for ${e})`)}}assertTaskCapability(e){!function(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);if("tools/call"===t&&!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`)}(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&function(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`)}}(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},yo,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},Da,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},yo,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},Us,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},xs,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},ls,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},hs,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},ys,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},yo,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},yo,t)}async callTool(e,t=Ks,r){if(this.isToolTaskRequired(e.name))throw new Qa(uo.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);const n=await this.request({method:"tools/call",params:e},t,r),o=this.getToolOutputValidator(e.name);if(o){if(!n.structuredContent&&!n.isError)throw new Qa(uo.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(n.structuredContent)try{const e=o(n.structuredContent);if(!e.valid)throw new Qa(uo.InvalidParams,`Structured content does not match the tool's output schema: ${e.errorMessage}`)}catch(e){if(e instanceof Qa)throw e;throw new Qa(uo.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return n}isToolTask(e){return!!this._serverCapabilities?.tasks?.requests?.tools?.call&&this._cachedKnownTaskTools.has(e)}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(const t of e){if(t.outputSchema){const e=this._jsonSchemaValidator.getValidator(t.outputSchema);this._cachedToolOutputValidators.set(t.name,e)}const e=t.execution?.taskSupport;"required"!==e&&"optional"!==e||this._cachedKnownTaskTools.add(t.name),"required"===e&&this._cachedRequiredTaskTools.add(t.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){const r=await this.request({method:"tools/list",params:e},Hs,t);return this.cacheToolMetadata(r.tools),r}_setupListChangedHandler(e,t,r,n){const o=Qs.safeParse(r);if(!o.success)throw new Error(`Invalid ${e} listChanged options: ${o.error.message}`);if("function"!=typeof r.onChanged)throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:s,debounceMs:a}=o.data,{onChanged:i}=r,c=async()=>{if(s)try{const e=await n();i(null,e)}catch(e){const t=e instanceof Error?e:new Error(String(e));i(t,null)}else i(null,null)};this.setNotificationHandler(t,()=>{if(a){const t=this._listChangedDebounceTimers.get(e);t&&clearTimeout(t);const r=setTimeout(c,a);this._listChangedDebounceTimers.set(e,r)}else c()})}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}var Cd,zd,Nd,Rd,Od,jd,Ad,Md,qd={exports:{}};function Ud(){if(zd)return Cd;zd=1,Cd=n,n.sync=function(r,n){return t(e.statSync(r),r,n)};var e=r;function t(e,t,r){return!(!e.isSymbolicLink()&&!e.isFile())&&function(e,t){var r=void 0!==t.pathExt?t.pathExt:process.env.PATHEXT;if(!r)return!0;if(-1!==(r=r.split(";")).indexOf(""))return!0;for(var n=0;nObject.assign(new Error(`not found: ${e}`),{code:"ENOENT"}),a=(t,r)=>{const o=r.colon||n,s=t.match(/\//)||e&&t.match(/\\/)?[""]:[...e?[process.cwd()]:[],...(r.path||process.env.PATH||"").split(o)],a=e?r.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",i=e?a.split(o):[""];return e&&-1!==t.indexOf(".")&&""!==i[0]&&i.unshift(""),{pathEnv:s,pathExt:i,pathExtExe:a}},i=(e,t,n)=>{"function"==typeof t&&(n=t,t={}),t||(t={});const{pathEnv:i,pathExt:c,pathExtExe:u}=a(e,t),d=[],l=n=>new Promise((o,a)=>{if(n===i.length)return t.all&&d.length?o(d):a(s(e));const c=i[n],u=/^".*"$/.test(c)?c.slice(1,-1):c,l=r.join(u,e),h=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+l:l;o(p(h,n,0))}),p=(e,r,n)=>new Promise((s,a)=>{if(n===c.length)return s(l(r+1));const i=c[n];o(e+i,{pathExt:u},(o,a)=>{if(!o&&a){if(!t.all)return s(e+i);d.push(e+i)}return s(p(e,r,n+1))})});return n?l(0).then(e=>n(null,e),n):l(0)};return Ad=i,i.sync=(e,t)=>{t=t||{};const{pathEnv:n,pathExt:i,pathExtExe:c}=a(e,t),u=[];for(let s=0;s{const t=e.env||process.env;return"win32"!==(e.platform||process.platform)?"PATH":Object.keys(t).reverse().find(e=>"PATH"===e.toUpperCase())||"Path"};return Hd.exports=e,Hd.exports.default=e,Hd.exports}();function o(t,o){const s=t.options.env||process.env,a=process.cwd(),i=null!=t.options.cwd,c=i&&void 0!==process.chdir&&!process.chdir.disabled;if(c)try{process.chdir(t.options.cwd)}catch(e){}let u;try{u=r.sync(t.command,{path:s[n({env:s})],pathExt:o?e.delimiter:void 0})}catch(e){}finally{c&&process.chdir(a)}return u&&(u=e.resolve(i?t.options.cwd:"",u)),u}return Ld=function(e){return o(e)||o(e,!0)}}var Wd,Gd,Jd,Bd,Qd,Yd,Xd,el,tl,rl,nl,ol,sl={};function al(){return Jd?Gd:(Jd=1,Gd=/^#!(.*)/)}function il(){if(Qd)return Bd;Qd=1;const e=al();return Bd=(t="")=>{const r=t.match(e);if(!r)return null;const[n,o]=r[0].replace(/#! ?/,"").split(" "),s=n.split("/").pop();return"env"===s?o:o?`${s} ${o}`:s},Bd}function cl(){if(tl)return el;tl=1;const e=t,n=Kd(),o=function(){if(Wd)return sl;Wd=1;const e=/([()\][%!^"`<>&|;, *?])/g;return sl.command=function(t){return t.replace(e,"^$1")},sl.argument=function(t,r){return t=(t=`"${t=(t=(t=`${t}`).replace(/(?=(\\+?)?)\1"/g,'$1$1\\"')).replace(/(?=(\\+?)?)\1$/,"$1$1")}"`).replace(e,"^$1"),r&&(t=t.replace(e,"^$1")),t},sl}(),s=function(){if(Xd)return Yd;Xd=1;const e=r,t=il();return Yd=function(r){const n=Buffer.alloc(150);let o;try{o=e.openSync(r,"r"),e.readSync(o,n,0,150,0),e.closeSync(o)}catch(e){}return t(n.toString())}}(),a="win32"===process.platform,i=/\.(?:com|exe)$/i,c=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function u(t){if(!a)return t;const r=function(e){e.file=n(e);const t=e.file&&s(e.file);return t?(e.args.unshift(e.file),e.command=t,n(e)):e.file}(t),u=!i.test(r);if(t.options.forceShell||u){const n=c.test(r);t.command=e.normalize(t.command),t.command=o.command(t.command),t.args=t.args.map(e=>o.argument(e,n));const s=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${s}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}return el=function(e,t,r){t&&!Array.isArray(t)&&(r=t,t=null);const n={command:e,args:t=t?t.slice(0):[],options:r=Object.assign({},r),file:void 0,original:{command:e,args:t}};return r.shell?n:u(n)}}function ul(){if(nl)return rl;nl=1;const e="win32"===process.platform;function t(e,t){return Object.assign(new Error(`${t} ${e.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function r(r,n){return e&&1===r&&!n.file?t(n.original,"spawn"):null}return rl={hookChildProcess:function(t,n){if(!e)return;const o=t.emit;t.emit=function(e,s){if("exit"===e){const e=r(s,n);if(e)return o.call(t,"error",e)}return o.apply(t,arguments)}},verifyENOENT:r,verifyENOENTSync:function(r,n){return e&&1===r&&!n.file?t(n.original,"spawnSync"):null},notFoundError:t},rl}var dl=function(){if(ol)return qd.exports;ol=1;const t=e,r=cl(),n=ul();function o(e,o,s){const a=r(e,o,s),i=t.spawn(a.command,a.args,a.options);return n.hookChildProcess(i,a),i}return qd.exports=o,qd.exports.spawn=o,qd.exports.sync=function(e,o,s){const a=r(e,o,s),i=t.spawnSync(a.command,a.args,a.options);return i.error=i.error||n.verifyENOENTSync(i.status,a),i},qd.exports._parse=r,qd.exports._enoent=n,qd.exports}(),ll=si(dl);class pl{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;const e=this._buffer.indexOf("\n");if(-1===e)return null;const t=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),function(e){try{return mo.parse(JSON.parse(e))}catch(t){throw t instanceof SyntaxError&&t.message&&(t.message+=`. Original line: "${e}"`),t}}(t)}clear(){this._buffer=void 0}}const hl="win32"===n.platform?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function fl(){const e={};for(const t of hl){const r=n.env[t];void 0!==r&&(r.startsWith("()")||(e[t]=r))}return e}class ml{constructor(e){this._readBuffer=new pl,this._stderrStream=null,this._serverParams=e,"pipe"!==e.stderr&&"overlapped"!==e.stderr||(this._stderrStream=new o)}async start(){if(this._process)throw new Error("StdioClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((e,t)=>{this._process=ll(this._serverParams.command,this._serverParams.args??[],{env:{...fl(),...this._serverParams.env},stdio:["pipe","pipe",this._serverParams.stderr??"inherit"],shell:!1,windowsHide:"win32"===n.platform&&"type"in n,cwd:this._serverParams.cwd}),this._process.on("error",e=>{t(e),this.onerror?.(e)}),this._process.on("spawn",()=>{e()}),this._process.on("close",e=>{this._process=void 0,this.onclose?.()}),this._process.stdin?.on("error",e=>{this.onerror?.(e)}),this._process.stdout?.on("data",e=>{this._readBuffer.append(e),this.processReadBuffer()}),this._process.stdout?.on("error",e=>{this.onerror?.(e)}),this._stderrStream&&this._process.stderr&&this._process.stderr.pipe(this._stderrStream)})}get stderr(){return this._stderrStream?this._stderrStream:this._process?.stderr??null}get pid(){return this._process?.pid??null}processReadBuffer(){for(;;)try{const e=this._readBuffer.readMessage();if(null===e)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){if(this._process){const e=this._process;this._process=void 0;const t=new Promise(t=>{e.once("close",()=>{t()})});try{e.stdin?.end()}catch{}if(await Promise.race([t,new Promise(e=>setTimeout(e,2e3).unref())]),null===e.exitCode){try{e.kill("SIGTERM")}catch{}await Promise.race([t,new Promise(e=>setTimeout(e,2e3).unref())])}if(null===e.exitCode)try{e.kill("SIGKILL")}catch{}}this._readBuffer.clear()}send(e){return new Promise(t=>{if(!this._process?.stdin)throw new Error("Not connected");const r=function(e){return JSON.stringify(e)+"\n"}(e);this._process.stdin.write(r)?t():this._process.stdin.once("drain",t)})}}var _l=Object.defineProperty,yl=(e,t,r)=>((e,t,r)=>t in e?_l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class vl extends Error{constructor(e,t){super(e),yl(this,"type"),yl(this,"field"),yl(this,"value"),yl(this,"line"),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function gl(e){}function wl(e){const{onEvent:t=gl,onError:r=gl,onRetry:n=gl,onComment:o}=e;let s,a="",i=!0,c="",u="";function d(e){if(""===e)return c.length>0&&t({id:s,event:u||void 0,data:c.endsWith("\n")?c.slice(0,-1):c}),s=void 0,c="",void(u="");if(e.startsWith(":"))return void(o&&o(e.slice(e.startsWith(": ")?2:1)));const r=e.indexOf(":");if(-1!==r){const t=e.slice(0,r),n=" "===e[r+1]?2:1;return void l(t,e.slice(r+n),e)}l(e,"",e)}function l(e,t,o){switch(e){case"event":u=t;break;case"data":c=`${c}${t}\n`;break;case"id":s=t.includes("\0")?void 0:t;break;case"retry":/^\d+$/.test(t)?n(parseInt(t,10)):r(new vl(`Invalid \`retry\` value: "${t}"`,{type:"invalid-retry",value:t,line:o}));break;default:r(new vl(`Unknown field "${e.length>20?`${e.slice(0,20)}…`:e}"`,{type:"unknown-field",field:e,value:t,line:o}))}}return{feed:function(e){const t=i?e.replace(/^\xEF\xBB\xBF/,""):e,[r,n]=function(e){const t=[];let r="";const n=e.length;for(let o=0;o{throw TypeError(e)},Kl=(e,t,r)=>t.has(e)||Hl("Cannot "+r),Wl=(e,t,r)=>(Kl(e,t,"read from private field"),r?r.call(e):t.get(e)),Gl=(e,t,r)=>t.has(e)?Hl("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,r),Jl=(e,t,r,n)=>(Kl(e,t,"write to private field"),t.set(e,r),r),Bl=(e,t,r)=>(Kl(e,t,"access private method"),r);class Ql extends EventTarget{constructor(e,t){var r,n;super(),Gl(this,jl),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Gl(this,bl),Gl(this,kl),Gl(this,El),Gl(this,Sl),Gl(this,Pl),Gl(this,Tl),Gl(this,xl),Gl(this,Il,null),Gl(this,Cl),Gl(this,zl),Gl(this,Nl,null),Gl(this,Rl,null),Gl(this,Ol,null),Gl(this,Ml,async e=>{var t;Wl(this,zl).reset();const{body:r,redirected:n,status:o,headers:s}=e;if(204===o)return Bl(this,jl,Fl).call(this,"Server sent HTTP 204, not reconnecting",204),void this.close();if(Jl(this,El,n?new URL(e.url):void 0),200!==o)return void Bl(this,jl,Fl).call(this,`Non-200 status code (${o})`,o);if(!(s.get("content-type")||"").startsWith("text/event-stream"))return void Bl(this,jl,Fl).call(this,'Invalid content type, expected "text/event-stream"',o);if(Wl(this,bl)===this.CLOSED)return;Jl(this,bl,this.OPEN);const a=new Event("open");if(null==(t=Wl(this,Ol))||t.call(this,a),this.dispatchEvent(a),"object"!=typeof r||!r||!("getReader"in r))return Bl(this,jl,Fl).call(this,"Invalid response body, expected a web ReadableStream",o),void this.close();const i=new TextDecoder,c=r.getReader();let u=!0;do{const{done:e,value:t}=await c.read();t&&Wl(this,zl).feed(i.decode(t,{stream:!e})),e&&(u=!1,Wl(this,zl).reset(),Bl(this,jl,Ll).call(this))}while(u)}),Gl(this,ql,e=>{Jl(this,Cl,void 0),"AbortError"!==e.name&&"aborted"!==e.type&&Bl(this,jl,Ll).call(this)}),Gl(this,Dl,e=>{"string"==typeof e.id&&Jl(this,Il,e.id);const t=new MessageEvent(e.event||"message",{data:e.data,origin:Wl(this,El)?Wl(this,El).origin:Wl(this,kl).origin,lastEventId:e.id||""});Wl(this,Rl)&&(!e.event||"message"===e.event)&&Wl(this,Rl).call(this,t),this.dispatchEvent(t)}),Gl(this,Vl,e=>{Jl(this,Tl,e)}),Gl(this,Zl,()=>{Jl(this,xl,void 0),Wl(this,bl)===this.CONNECTING&&Bl(this,jl,Al).call(this)});try{if(e instanceof URL)Jl(this,kl,e);else{if("string"!=typeof e)throw new Error("Invalid URL");Jl(this,kl,new URL(e,function(){const e="document"in globalThis?globalThis.document:void 0;return e&&"object"==typeof e&&"baseURI"in e&&"string"==typeof e.baseURI?e.baseURI:void 0}()))}}catch{throw function(e){const t=globalThis.DOMException;return"function"==typeof t?new t(e,"SyntaxError"):new SyntaxError(e)}("An invalid or illegal string was specified")}Jl(this,zl,wl({onEvent:Wl(this,Dl),onRetry:Wl(this,Vl)})),Jl(this,bl,this.CONNECTING),Jl(this,Tl,3e3),Jl(this,Pl,null!=(r=null==t?void 0:t.fetch)?r:globalThis.fetch),Jl(this,Sl,null!=(n=null==t?void 0:t.withCredentials)&&n),Bl(this,jl,Al).call(this)}get readyState(){return Wl(this,bl)}get url(){return Wl(this,kl).href}get withCredentials(){return Wl(this,Sl)}get onerror(){return Wl(this,Nl)}set onerror(e){Jl(this,Nl,e)}get onmessage(){return Wl(this,Rl)}set onmessage(e){Jl(this,Rl,e)}get onopen(){return Wl(this,Ol)}set onopen(e){Jl(this,Ol,e)}addEventListener(e,t,r){const n=t;super.addEventListener(e,n,r)}removeEventListener(e,t,r){const n=t;super.removeEventListener(e,n,r)}close(){Wl(this,xl)&&clearTimeout(Wl(this,xl)),Wl(this,bl)!==this.CLOSED&&(Wl(this,Cl)&&Wl(this,Cl).abort(),Jl(this,bl,this.CLOSED),Jl(this,Cl,void 0))}}function Yl(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function Xl(e=fetch,t){return t?async(r,n)=>{const o={...t,...n,headers:n?.headers?{...Yl(t.headers),...Yl(n.headers)}:t.headers};return e(r,o)}:e}let ep;async function tp(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";let r="";const n=await async function(e){return(await ep).getRandomValues(new Uint8Array(e))}(e);for(let o=0;o128)throw`Expected a length between 43 and 128. Received ${e}.`;const t=await async function(e){return await tp(e)}(e);return{code_verifier:t,code_challenge:await async function(e){const t=await(await ep).subtle.digest("SHA-256",(new TextEncoder).encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}(t)}}bl=new WeakMap,kl=new WeakMap,El=new WeakMap,Sl=new WeakMap,Pl=new WeakMap,Tl=new WeakMap,xl=new WeakMap,Il=new WeakMap,Cl=new WeakMap,zl=new WeakMap,Nl=new WeakMap,Rl=new WeakMap,Ol=new WeakMap,jl=new WeakSet,Al=function(){Jl(this,bl,this.CONNECTING),Jl(this,Cl,new AbortController),Wl(this,Pl)(Wl(this,kl),Bl(this,jl,Ul).call(this)).then(Wl(this,Ml)).catch(Wl(this,ql))},Ml=new WeakMap,ql=new WeakMap,Ul=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Wl(this,Il)?{"Last-Event-ID":Wl(this,Il)}:void 0},cache:"no-store",signal:null==(e=Wl(this,Cl))?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},Dl=new WeakMap,Vl=new WeakMap,Fl=function(e,t){var r;Wl(this,bl)!==this.CLOSED&&Jl(this,bl,this.CLOSED);const n=new $l("error");n.code=t,n.message=e,null==(r=Wl(this,Nl))||r.call(this,n),this.dispatchEvent(n)},Ll=function(){var e;if(Wl(this,bl)===this.CLOSED)return;Jl(this,bl,this.CONNECTING);const t=new $l("error");null==(e=Wl(this,Nl))||e.call(this,t),this.dispatchEvent(t),Jl(this,xl,setTimeout(Wl(this,Zl),Wl(this,Tl)))},Zl=new WeakMap,Ql.CONNECTING=0,Ql.OPEN=1,Ql.CLOSED=2,ep=globalThis.crypto?.webcrypto??globalThis.crypto??import("node:crypto").then(e=>e.webcrypto);const np=Kt(Pr,op).superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:On,message:"URL must be parseable",fatal:!0}),s}).refine(e=>{const t=new URL(e);return"javascript:"!==t.protocol&&"data:"!==t.protocol&&"vbscript:"!==t.protocol},{message:"URL cannot use javascript:, data:, or vbscript: scheme"});var op;const sp=sn({resource:$r().url(),authorization_servers:rn(np).optional(),jwks_uri:$r().url().optional(),scopes_supported:rn($r()).optional(),bearer_methods_supported:rn($r()).optional(),resource_signing_alg_values_supported:rn($r()).optional(),resource_name:$r().optional(),resource_documentation:$r().optional(),resource_policy_uri:$r().url().optional(),resource_tos_uri:$r().url().optional(),tls_client_certificate_bound_access_tokens:Wr().optional(),authorization_details_types_supported:rn($r()).optional(),dpop_signing_alg_values_supported:rn($r()).optional(),dpop_bound_access_tokens_required:Wr().optional()}),ap=sn({issuer:$r(),authorization_endpoint:np,token_endpoint:np,registration_endpoint:np.optional(),scopes_supported:rn($r()).optional(),response_types_supported:rn($r()),response_modes_supported:rn($r()).optional(),grant_types_supported:rn($r()).optional(),token_endpoint_auth_methods_supported:rn($r()).optional(),token_endpoint_auth_signing_alg_values_supported:rn($r()).optional(),service_documentation:np.optional(),revocation_endpoint:np.optional(),revocation_endpoint_auth_methods_supported:rn($r()).optional(),revocation_endpoint_auth_signing_alg_values_supported:rn($r()).optional(),introspection_endpoint:$r().optional(),introspection_endpoint_auth_methods_supported:rn($r()).optional(),introspection_endpoint_auth_signing_alg_values_supported:rn($r()).optional(),code_challenge_methods_supported:rn($r()).optional(),client_id_metadata_document_supported:Wr().optional()}),ip=on({...sn({issuer:$r(),authorization_endpoint:np,token_endpoint:np,userinfo_endpoint:np.optional(),jwks_uri:np,registration_endpoint:np.optional(),scopes_supported:rn($r()).optional(),response_types_supported:rn($r()),response_modes_supported:rn($r()).optional(),grant_types_supported:rn($r()).optional(),acr_values_supported:rn($r()).optional(),subject_types_supported:rn($r()),id_token_signing_alg_values_supported:rn($r()),id_token_encryption_alg_values_supported:rn($r()).optional(),id_token_encryption_enc_values_supported:rn($r()).optional(),userinfo_signing_alg_values_supported:rn($r()).optional(),userinfo_encryption_alg_values_supported:rn($r()).optional(),userinfo_encryption_enc_values_supported:rn($r()).optional(),request_object_signing_alg_values_supported:rn($r()).optional(),request_object_encryption_alg_values_supported:rn($r()).optional(),request_object_encryption_enc_values_supported:rn($r()).optional(),token_endpoint_auth_methods_supported:rn($r()).optional(),token_endpoint_auth_signing_alg_values_supported:rn($r()).optional(),display_values_supported:rn($r()).optional(),claim_types_supported:rn($r()).optional(),claims_supported:rn($r()).optional(),service_documentation:$r().optional(),claims_locales_supported:rn($r()).optional(),ui_locales_supported:rn($r()).optional(),claims_parameter_supported:Wr().optional(),request_parameter_supported:Wr().optional(),request_uri_parameter_supported:Wr().optional(),require_request_uri_registration:Wr().optional(),op_policy_uri:np.optional(),op_tos_uri:np.optional(),client_id_metadata_document_supported:Wr().optional()}).shape,...ap.pick({code_challenge_methods_supported:!0}).shape}),cp=on({access_token:$r(),id_token:$r().optional(),token_type:$r(),expires_in:function(e){return function(e,t){return new e({type:"number",coerce:!0,checks:[],...E(t)})}(Fr,e)}().optional(),scope:$r().optional(),refresh_token:$r().optional()}).strip(),up=on({error:$r(),error_description:$r().optional(),error_uri:$r().optional()}),dp=np.optional().or(vn("").transform(()=>{})),lp=on({redirect_uris:rn(np),token_endpoint_auth_method:$r().optional(),grant_types:rn($r()).optional(),response_types:rn($r()).optional(),client_name:$r().optional(),client_uri:np.optional(),logo_uri:dp,scope:$r().optional(),contacts:rn($r()).optional(),tos_uri:dp,policy_uri:$r().optional(),jwks_uri:np.optional(),jwks:new Br({type:"any"}).optional(),software_id:$r().optional(),software_version:$r().optional(),software_statement:$r().optional()}).strip(),pp=on({client_id:$r(),client_secret:$r().optional(),client_id_issued_at:Lr().optional(),client_secret_expires_at:Lr().optional()}).strip(),hp=lp.merge(pp);on({error:$r(),error_description:$r().optional()}).strip(),on({token:$r(),token_type_hint:$r().optional()}).strip();class fp extends Error{constructor(e,t){super(e),this.errorUri=t,this.name=this.constructor.name}toResponseObject(){const e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}}class mp extends fp{}mp.errorCode="invalid_request";class _p extends fp{}_p.errorCode="invalid_client";class yp extends fp{}yp.errorCode="invalid_grant";class vp extends fp{}vp.errorCode="unauthorized_client";class gp extends fp{}gp.errorCode="unsupported_grant_type";class wp extends fp{}wp.errorCode="invalid_scope";class $p extends fp{}$p.errorCode="access_denied";class bp extends fp{}bp.errorCode="server_error";class kp extends fp{}kp.errorCode="temporarily_unavailable";class Ep extends fp{}Ep.errorCode="unsupported_response_type";class Sp extends fp{}Sp.errorCode="unsupported_token_type";class Pp extends fp{}Pp.errorCode="invalid_token";class Tp extends fp{}Tp.errorCode="method_not_allowed";class xp extends fp{}xp.errorCode="too_many_requests";class Ip extends fp{}Ip.errorCode="invalid_client_metadata";class Cp extends fp{}Cp.errorCode="insufficient_scope";class zp extends fp{}zp.errorCode="invalid_target";const Np={[mp.errorCode]:mp,[_p.errorCode]:_p,[yp.errorCode]:yp,[vp.errorCode]:vp,[gp.errorCode]:gp,[wp.errorCode]:wp,[$p.errorCode]:$p,[bp.errorCode]:bp,[kp.errorCode]:kp,[Ep.errorCode]:Ep,[Sp.errorCode]:Sp,[Pp.errorCode]:Pp,[Tp.errorCode]:Tp,[xp.errorCode]:xp,[Ip.errorCode]:Ip,[Cp.errorCode]:Cp,[zp.errorCode]:zp};class Rp extends Error{constructor(e){super(e??"Unauthorized")}}const Op="code",jp="S256";function Ap(e,t,r,n){const{client_id:o,client_secret:s}=t;switch(e){case"client_secret_basic":return void function(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");const n=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${n}`)}(o,s,r);case"client_secret_post":return void function(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}(o,s,n);case"none":return void function(e,t){t.set("client_id",e)}(o,n);default:throw new Error(`Unsupported client authentication method: ${e}`)}}async function Mp(e){const t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{const e=up.parse(JSON.parse(r)),{error:t,error_description:n,error_uri:o}=e;return new(Np[t]||bp)(n||"",o)}catch(e){return new bp(`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${e}. Raw body: ${r}`)}}async function qp(e,t){try{return await Up(e,t)}catch(r){if(r instanceof _p||r instanceof vp)return await(e.invalidateCredentials?.("all")),await Up(e,t);if(r instanceof yp)return await(e.invalidateCredentials?.("tokens")),await Up(e,t);throw r}}async function Up(e,{serverUrl:t,authorizationCode:r,scope:n,resourceMetadataUrl:o,fetchFn:s}){let a,i;try{a=await async function(e,t,r=fetch){const n=await async function(e,t,r,n){const o=new URL(e),s=n?.protocolVersion??jn;let a;if(n?.metadataUrl)a=new URL(n.metadataUrl);else{const e=function(e,t="",r={}){t.endsWith("/")&&(t=t.slice(0,-1));return r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}(t,o.pathname);a=new URL(e,n?.metadataServerUrl??o),a.search=o.search}let i=await Lp(a,s,r);if(!n?.metadataUrl&&function(e,t){return!e||e.status>=400&&e.status<500&&"/"!==t}(i,o.pathname)){const e=new URL(`/.well-known/${t}`,o);i=await Lp(e,s,r)}return i}(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!n||404===n.status)throw await(n?.body?.cancel()),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!n.ok)throw await(n.body?.cancel()),new Error(`HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`);return sp.parse(await n.json())}(t,{resourceMetadataUrl:o},s),a.authorization_servers&&a.authorization_servers.length>0&&(i=a.authorization_servers[0])}catch{}i||(i=new URL("/",t));const c=await async function(e,t,r){const n=function(e){const t="string"==typeof e?new URL(e):new URL(e.href);return t.hash="",t}(e);if(t.validateResourceURL)return await t.validateResourceURL(n,r?.resource);if(!r)return;if(!function({requestedResource:e,configuredResource:t}){const r="string"==typeof e?new URL(e):new URL(e.href),n="string"==typeof t?new URL(t):new URL(t.href);if(r.origin!==n.origin)return!1;if(r.pathname.length=400&&o.status<500)continue;throw new Error(`HTTP ${o.status} trying to load ${"oauth"===r?"OAuth":"OpenID provider"} metadata from ${e}`)}return"oauth"===r?ap.parse(await o.json()):ip.parse(await o.json())}}return}(i,{fetchFn:s});let d=await Promise.resolve(e.clientInformation());if(!d){if(void 0!==r)throw new Error("Existing OAuth client information is required when exchanging an authorization code");const t=!0===u?.client_id_metadata_document_supported,n=e.clientMetadataUrl;if(n&&!function(e){if(!e)return!1;try{const t=new URL(e);return"https:"===t.protocol&&"/"!==t.pathname}catch{return!1}}(n))throw new Ip(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${n}`);if(t&&n)d={client_id:n},await(e.saveClientInformation?.(d));else{if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const t=await async function(e,{metadata:t,clientMetadata:r,fetchFn:n}){let o;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");o=new URL(t.registration_endpoint)}else o=new URL("/register",e);const s=await(n??fetch)(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok)throw await Mp(s);return hp.parse(await s.json())}(i,{metadata:u,clientMetadata:e.clientMetadata,fetchFn:s});await e.saveClientInformation(t),d=t}}const l=!e.redirectUrl;if(void 0!==r||l){const t=await async function(e,t,{metadata:r,resource:n,authorizationCode:o,fetchFn:s}={}){const a=e.clientMetadata.scope;let i;e.prepareTokenRequest&&(i=await e.prepareTokenRequest(a));if(!i){if(!o)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");i=function(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}(o,await e.codeVerifier(),e.redirectUrl)}const c=await e.clientInformation();return Zp(t,{metadata:r,tokenRequestParams:i,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:s})}(e,i,{metadata:u,resource:c,authorizationCode:r,fetchFn:s});return await e.saveTokens(t),"AUTHORIZED"}const p=await e.tokens();if(p?.refresh_token)try{const t=await async function(e,{metadata:t,clientInformation:r,refreshToken:n,resource:o,addClientAuthentication:s,fetchFn:a}){const i=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),c=await Zp(e,{metadata:t,tokenRequestParams:i,clientInformation:r,addClientAuthentication:s,resource:o,fetchFn:a});return{refresh_token:n,...c}}(i,{metadata:u,clientInformation:d,refreshToken:p.refresh_token,resource:c,addClientAuthentication:e.addClientAuthentication,fetchFn:s});return await e.saveTokens(t),"AUTHORIZED"}catch(e){if(e instanceof fp&&!(e instanceof bp))throw e}const h=e.state?await e.state():void 0,{authorizationUrl:f,codeVerifier:m}=await async function(e,{metadata:t,clientInformation:r,redirectUrl:n,scope:o,state:s,resource:a}){let i;if(t){if(i=new URL(t.authorization_endpoint),!t.response_types_supported.includes(Op))throw new Error(`Incompatible auth server: does not support response type ${Op}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(jp))throw new Error(`Incompatible auth server: does not support code challenge method ${jp}`)}else i=new URL("/authorize",e);const c=await rp(),u=c.code_verifier,d=c.code_challenge;i.searchParams.set("response_type",Op),i.searchParams.set("client_id",r.client_id),i.searchParams.set("code_challenge",d),i.searchParams.set("code_challenge_method",jp),i.searchParams.set("redirect_uri",String(n)),s&&i.searchParams.set("state",s);o&&i.searchParams.set("scope",o);o?.includes("offline_access")&&i.searchParams.append("prompt","consent");a&&i.searchParams.set("resource",a.href);return{authorizationUrl:i,codeVerifier:u}}(i,{metadata:u,clientInformation:d,state:h,redirectUrl:e.redirectUrl,scope:n||a?.scopes_supported?.join(" ")||e.clientMetadata.scope,resource:c});return await e.saveCodeVerifier(m),await e.redirectToAuthorization(f),"REDIRECT"}function Dp(e){const t=e.headers.get("WWW-Authenticate");if(!t)return{};const[r,n]=t.split(" ");if("bearer"!==r.toLowerCase()||!n)return{};const o=Vp(e,"resource_metadata")||void 0;let s;if(o)try{s=new URL(o)}catch{}return{resourceMetadataUrl:s,scope:Vp(e,"scope")||void 0,error:Vp(e,"error")||void 0}}function Vp(e,t){const r=e.headers.get("WWW-Authenticate");if(!r)return null;const n=new RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),o=r.match(n);return o?o[1]||o[2]:null}async function Fp(e,t,r=fetch){try{return await r(e,{headers:t})}catch(n){if(n instanceof TypeError)return t?Fp(e,void 0,r):void 0;throw n}}async function Lp(e,t,r=fetch){const n={"MCP-Protocol-Version":t};return await Fp(e,n,r)}async function Zp(e,{metadata:t,tokenRequestParams:r,clientInformation:n,addClientAuthentication:o,resource:s,fetchFn:a}){const i=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(s&&r.set("resource",s.href),o)await o(c,r,i,t);else if(n){const e=function(e,t){const r=void 0!==e.client_secret;return 0===t.length?r?"client_secret_post":"none":"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&(n=e.token_endpoint_auth_method,["client_secret_basic","client_secret_post","none"].includes(n))&&t.includes(e.token_endpoint_auth_method)?e.token_endpoint_auth_method:r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none";var n}(n,t?.token_endpoint_auth_methods_supported??[]);Ap(e,n,c,r)}const u=await(a??fetch)(i,{method:"POST",headers:c,body:r});if(!u.ok)throw await Mp(u);return cp.parse(await u.json())}class Hp extends Error{constructor(e,t,r){super(`SSE error: ${t}`),this.code=e,this.event=r}}class Kp{constructor(e,t){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=t?.eventSourceInit,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=Xl(t?.fetch,t?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new Rp("No auth provider");let e;try{e=await qp(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if("AUTHORIZED"!==e)throw new Rp;return await this._startOrAuth()}async _commonHeaders(){const e={};if(this._authProvider){const t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);const t=Yl(this._requestInit?.headers);return new Headers({...e,...t})}_startOrAuth(){const e=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((t,r)=>{this._eventSource=new Ql(this._url.href,{...this._eventSourceInit,fetch:async(t,r)=>{const n=await this._commonHeaders();n.set("Accept","text/event-stream");const o=await e(t,{...r,headers:n});if(401===o.status&&o.headers.has("www-authenticate")){const{resourceMetadataUrl:e,scope:t}=Dp(o);this._resourceMetadataUrl=e,this._scope=t}return o}}),this._abortController=new AbortController,this._eventSource.onerror=e=>{if(401===e.code&&this._authProvider)return void this._authThenStart().then(t,r);const n=new Hp(e.code,e.message,e);r(n),this.onerror?.(n)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",e=>{const n=e;try{if(this._endpoint=new URL(n.data,this._url),this._endpoint.origin!==this._url.origin)throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`)}catch(e){return r(e),this.onerror?.(e),void this.close()}t()}),this._eventSource.onmessage=e=>{const t=e;let r;try{r=mo.parse(JSON.parse(t.data))}catch(e){return void this.onerror?.(e)}this.onmessage?.(r)}})}async start(){if(this._eventSource)throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");return await this._startOrAuth()}async finishAuth(e){if(!this._authProvider)throw new Rp("No auth provider");if("AUTHORIZED"!==await qp(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit}))throw new Rp("Failed to authorize")}async close(){this._abortController?.abort(),this._eventSource?.close(),this.onclose?.()}async send(e){if(!this._endpoint)throw new Error("Not connected");try{const t=await this._commonHeaders();t.set("content-type","application/json");const r={...this._requestInit,method:"POST",headers:t,body:JSON.stringify(e),signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._endpoint,r);if(!n.ok){const t=await n.text().catch(()=>null);if(401===n.status&&this._authProvider){const{resourceMetadataUrl:t,scope:r}=Dp(n);this._resourceMetadataUrl=t,this._scope=r;if("AUTHORIZED"!==await qp(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit}))throw new Rp;return this.send(e)}throw new Error(`Error POSTing to endpoint (HTTP ${n.status}): ${t}`)}await(n.body?.cancel())}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}}class Wp extends TransformStream{constructor({onError:e,onRetry:t,onComment:r}={}){let n;super({start(o){n=wl({onEvent:e=>{o.enqueue(e)},onError(t){"terminate"===e?o.error(t):"function"==typeof e&&e(t)},onRetry:t,onComment:r})},transform(e){n.feed(e)}})}}const Gp={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Jp extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}}class Bp{constructor(e,t){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=t?.requestInit,this._authProvider=t?.authProvider,this._fetch=t?.fetch,this._fetchWithInit=Xl(t?.fetch,t?.requestInit),this._sessionId=t?.sessionId,this._reconnectionOptions=t?.reconnectionOptions??Gp}async _authThenStart(){if(!this._authProvider)throw new Rp("No auth provider");let e;try{e=await qp(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(e){throw this.onerror?.(e),e}if("AUTHORIZED"!==e)throw new Rp;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){const e={};if(this._authProvider){const t=await this._authProvider.tokens();t&&(e.Authorization=`Bearer ${t.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);const t=Yl(this._requestInit?.headers);return new Headers({...e,...t})}async _startOrAuthSse(e){const{resumptionToken:t}=e;try{const r=await this._commonHeaders();r.set("Accept","text/event-stream"),t&&r.set("last-event-id",t);const n=await(this._fetch??fetch)(this._url,{method:"GET",headers:r,signal:this._abortController?.signal});if(!n.ok){if(await(n.body?.cancel()),401===n.status&&this._authProvider)return await this._authThenStart();if(405===n.status)return;throw new Jp(n.status,`Failed to open SSE stream: ${n.statusText}`)}this._handleSseStream(n.body,e,!0)}catch(e){throw this.onerror?.(e),e}}_getNextReconnectionDelay(e){if(void 0!==this._serverRetryMs)return this._serverRetryMs;const t=this._reconnectionOptions.initialReconnectionDelay,r=this._reconnectionOptions.reconnectionDelayGrowFactor,n=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(r,e),n)}_scheduleReconnection(e,t=0){const r=this._reconnectionOptions.maxRetries;if(t>=r)return void this.onerror?.(new Error(`Maximum reconnection attempts (${r}) exceeded.`));const n=this._getNextReconnectionDelay(t);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(r=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${r instanceof Error?r.message:String(r)}`)),this._scheduleReconnection(e,t+1)})},n)}_handleSseStream(e,t,r){if(!e)return;const{onresumptiontoken:n,replayMessageId:o}=t;let s,a=!1,i=!1;(async()=>{try{const t=e.pipeThrough(new TextDecoderStream).pipeThrough(new Wp({onRetry:e=>{this._serverRetryMs=e}})).getReader();for(;;){const{value:e,done:r}=await t.read();if(r)break;if(e.id&&(s=e.id,a=!0,n?.(e.id)),e.data&&(!e.event||"message"===e.event))try{const t=mo.parse(JSON.parse(e.data));io(t)&&(i=!0,void 0!==o&&(t.id=o)),this.onmessage?.(t)}catch(e){this.onerror?.(e)}}(r||a)&&!i&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:s,onresumptiontoken:n,replayMessageId:o},0)}catch(e){this.onerror?.(new Error(`SSE stream disconnected: ${e}`));if((r||a)&&!i&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:s,onresumptiontoken:n,replayMessageId:o},0)}catch(e){this.onerror?.(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 Rp("No auth provider");if("AUTHORIZED"!==await qp(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit}))throw new Rp("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(e,t){try{const{resumptionToken:r,onresumptiontoken:n}=t||{};if(r)return void this._startOrAuthSse({resumptionToken:r,replayMessageId:no(e)?e.id:void 0}).catch(e=>this.onerror?.(e));const o=await this._commonHeaders();o.set("content-type","application/json"),o.set("accept","application/json, text/event-stream");const s={...this._requestInit,method:"POST",headers:o,body:JSON.stringify(e),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._url,s),i=a.headers.get("mcp-session-id");if(i&&(this._sessionId=i),!a.ok){const t=await a.text().catch(()=>null);if(401===a.status&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Jp(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:t,scope:r}=Dp(a);this._resourceMetadataUrl=t,this._scope=r;if("AUTHORIZED"!==await qp(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit}))throw new Rp;return this._hasCompletedAuthFlow=!0,this.send(e)}if(403===a.status&&this._authProvider){const{resourceMetadataUrl:t,scope:r,error:n}=Dp(a);if("insufficient_scope"===n){const n=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===n)throw new Jp(403,"Server returned 403 after trying upscoping");r&&(this._scope=r),t&&(this._resourceMetadataUrl=t),this._lastUpscopingHeader=n??void 0;if("AUTHORIZED"!==await qp(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch}))throw new Rp;return this.send(e)}}throw new Jp(a.status,`Error POSTing to endpoint: ${t}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,202===a.status)return await(a.body?.cancel()),void(jo(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(e=>this.onerror?.(e)));const c=(Array.isArray(e)?e:[e]).filter(e=>"method"in e&&"id"in e&&void 0!==e.id).length>0,u=a.headers.get("content-type");if(c)if(u?.includes("text/event-stream"))this._handleSseStream(a.body,{onresumptiontoken:n},!1);else{if(!u?.includes("application/json"))throw await(a.body?.cancel()),new Jp(-1,`Unexpected content type: ${u}`);{const e=await a.json(),t=Array.isArray(e)?e.map(e=>mo.parse(e)):[mo.parse(e)];for(const e of t)this.onmessage?.(e)}}else await(a.body?.cancel())}catch(e){throw this.onerror?.(e),e}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{const e=await this._commonHeaders(),t={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},r=await(this._fetch??fetch)(this._url,t);if(await(r.body?.cancel()),!r.ok&&405!==r.status)throw new Jp(r.status,`Failed to terminate session: ${r.statusText}`);this._sessionId=void 0}catch(e){throw this.onerror?.(e),e}}setProtocolVersion(e){this._protocolVersion=e}get protocolVersion(){return this._protocolVersion}async resumeStream(e,t){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:t?.onresumptiontoken})}}class Qp{constructor(e){this._url=e}start(){if(this._socket)throw new Error("WebSocketClientTransport already started! If using Client class, note that connect() calls start() automatically.");return new Promise((e,t)=>{this._socket=new WebSocket(this._url,"mcp"),this._socket.onerror=e=>{const r="error"in e?e.error:new Error(`WebSocket error: ${JSON.stringify(e)}`);t(r),this.onerror?.(r)},this._socket.onopen=()=>{e()},this._socket.onclose=()=>{this.onclose?.()},this._socket.onmessage=e=>{let t;try{t=mo.parse(JSON.parse(e.data))}catch(e){return void this.onerror?.(e)}this.onmessage?.(t)}})}async close(){this._socket?.close()}send(e){return new Promise((t,r)=>{this._socket?(this._socket?.send(JSON.stringify(e)),t()):r(new Error("Not connected"))})}}export{Sd as AjvJsonSchemaValidator,is as AnnotationsSchema,Rs as AudioContentSchema,bo as BaseMetadataSchema,ss as BlobResourceContentsSchema,fa as BooleanSchemaSchema,Gs as CallToolRequestParamsSchema,Js as CallToolRequestSchema,Ks as CallToolResultSchema,es as CancelTaskRequestSchema,ts as CancelTaskResultSchema,vo as CancelledNotificationParamsSchema,go as CancelledNotificationSchema,Id as Client,xo as ClientCapabilitiesSchema,Ka as ClientNotificationSchema,Ha as ClientRequestSchema,Wa as ClientResultSchema,Po as ClientTasksCapabilitySchema,Ws as CompatibilityCallToolResultSchema,Aa as CompleteRequestParamsSchema,Ma as CompleteRequestSchema,Da as CompleteResultSchema,Ms as ContentBlockSchema,da as CreateMessageRequestParamsSchema,la as CreateMessageRequestSchema,pa as CreateMessageResultSchema,ha as CreateMessageResultWithToolsSchema,Ho as CreateTaskResultSchema,Ln as CursorSchema,hl as DEFAULT_INHERITED_ENV_VARS,An as DEFAULT_NEGOTIATED_PROTOCOL_VERSION,Pa as ElicitRequestFormParamsSchema,xa as ElicitRequestParamsSchema,Ia as ElicitRequestSchema,Ta as ElicitRequestURLParamsSchema,Na as ElicitResultSchema,Ca as ElicitationCompleteNotificationParamsSchema,za as ElicitationCompleteNotificationSchema,js as EmbeddedResourceSchema,yo as EmptyResultSchema,Ea as EnumSchemaSchema,uo as ErrorCode,Is as GetPromptRequestParamsSchema,Cs as GetPromptRequestSchema,Us as GetPromptResultSchema,Bo as GetTaskPayloadRequestSchema,Qo as GetTaskPayloadResultSchema,Go as GetTaskRequestSchema,Jo as GetTaskResultSchema,wo as IconSchema,$o as IconsSchema,Ns as ImageContentSchema,ko as ImplementationSchema,Io as InitializeRequestParamsSchema,Co as InitializeRequestSchema,Ro as InitializeResultSchema,Oo as InitializedNotificationSchema,lo as JSONRPCErrorResponseSchema,po as JSONRPCErrorSchema,mo as JSONRPCMessageSchema,oo as JSONRPCNotificationSchema,ro as JSONRPCRequestSchema,_o as JSONRPCResponseSchema,ao as JSONRPCResultResponseSchema,Un as JSONRPC_VERSION,jn as LATEST_PROTOCOL_VERSION,ga as LegacyTitledEnumSchemaSchema,Qs as ListChangedOptionsBaseSchema,Ts as ListPromptsRequestSchema,xs as ListPromptsResultSchema,ps as ListResourceTemplatesRequestSchema,hs as ListResourceTemplatesResultSchema,ds as ListResourcesRequestSchema,ls as ListResourcesResultSchema,Fa as ListRootsRequestSchema,La as ListRootsResultSchema,Yo as ListTasksRequestSchema,Xo as ListTasksResultSchema,Zs as ListToolsRequestSchema,Hs as ListToolsResultSchema,Ys as LoggingLevelSchema,ta as LoggingMessageNotificationParamsSchema,ra as LoggingMessageNotificationSchema,Qa as McpError,na as ModelHintSchema,oa as ModelPreferencesSchema,ka as MultiSelectEnumSchemaSchema,Xn as NotificationSchema,_a as NumberSchemaSchema,Do as PaginatedRequestParamsSchema,Vo as PaginatedRequestSchema,Fo as PaginatedResultSchema,Ao as PingRequestSchema,Sa as PrimitiveSchemaDefinitionSchema,qo as ProgressNotificationParamsSchema,Uo as ProgressNotificationSchema,Mo as ProgressSchema,Fn as ProgressTokenSchema,Ss as PromptArgumentSchema,Ds as PromptListChangedNotificationSchema,qs as PromptMessageSchema,ja as PromptReferenceSchema,Ps as PromptSchema,qn as RELATED_TASK_META_KEY,ms as ReadResourceRequestParamsSchema,_s as ReadResourceRequestSchema,ys as ReadResourceResultSchema,Kn as RelatedTaskMetadataSchema,to as RequestIdSchema,Qn as RequestSchema,rs as ResourceContentsSchema,As as ResourceLinkSchema,vs as ResourceListChangedNotificationSchema,Oa as ResourceReferenceSchema,fs as ResourceRequestParamsSchema,cs as ResourceSchema,Ra as ResourceTemplateReferenceSchema,us as ResourceTemplateSchema,ks as ResourceUpdatedNotificationParamsSchema,Es as ResourceUpdatedNotificationSchema,eo as ResultSchema,as as RoleSchema,Va as RootSchema,Za as RootsListChangedNotificationSchema,Kp as SSEClientTransport,Mn as SUPPORTED_PROTOCOL_VERSIONS,ia as SamplingContentSchema,ca as SamplingMessageContentBlockSchema,ua as SamplingMessageSchema,No as ServerCapabilitiesSchema,Ja as ServerNotificationSchema,Ga as ServerRequestSchema,Ba as ServerResultSchema,To as ServerTasksCapabilitySchema,Xs as SetLevelRequestParamsSchema,ea as SetLevelRequestSchema,wa as SingleSelectEnumSchemaSchema,Hp as SseError,ml as StdioClientTransport,Bp as StreamableHTTPClientTransport,Jp as StreamableHTTPError,ma as StringSchemaSchema,gs as SubscribeRequestParamsSchema,ws as SubscribeRequestSchema,Jn as TaskAugmentedRequestParamsSchema,Zn as TaskCreationParamsSchema,Hn as TaskMetadataSchema,Zo as TaskSchema,Ko as TaskStatusNotificationParamsSchema,Wo as TaskStatusNotificationSchema,Lo as TaskStatusSchema,zs as TextContentSchema,ns as TextResourceContentsSchema,ba as TitledMultiSelectEnumSchemaSchema,va as TitledSingleSelectEnumSchemaSchema,Vs as ToolAnnotationsSchema,sa as ToolChoiceSchema,Fs as ToolExecutionSchema,Bs as ToolListChangedNotificationSchema,aa as ToolResultContentSchema,Ls as ToolSchema,Os as ToolUseContentSchema,$s as UnsubscribeRequestParamsSchema,bs as UnsubscribeRequestSchema,$a as UntitledMultiSelectEnumSchemaSchema,ya as UntitledSingleSelectEnumSchemaSchema,Ya as UrlElicitationRequiredError,Qp as WebSocketClientTransport,qa as assertCompleteRequestPrompt,Ua as assertCompleteRequestResourceTemplate,fl as getDefaultEnvironment,xd as getSupportedElicitationModes,zo as isInitializeRequest,jo as isInitializedNotification,fo as isJSONRPCError,ho as isJSONRPCErrorResponse,so as isJSONRPCNotification,no as isJSONRPCRequest,co as isJSONRPCResponse,io as isJSONRPCResultResponse,Bn as isTaskAugmentedRequestParams}; //# sourceMappingURL=index.mjs.map