@swifty.js/swifty 0.0.23 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-RABW3Z3R.js → agent-24XMR2WX.js} +1 -1
- package/dist/{anthropic-V22T6E6E.js → anthropic-7QRAPLOY.js} +1 -1
- package/dist/{chunk-Y43POSIW.js → chunk-EMNNDZ4Z.js} +6 -6
- package/dist/{chunk-MJR2C7S7.js → chunk-MWZIARZE.js} +1 -1
- package/dist/{chunk-OCQ6TYLT.js → chunk-VQUWSKQQ.js} +1 -1
- package/dist/{chunk-CV7OKXYC.js → chunk-W37Y53LX.js} +1 -1
- package/dist/lib/{agent-GHXYOARN.js → agent-U42LS73D.js} +2 -2
- package/dist/lib/{anthropic-7YEN2QTU.js → anthropic-RYPJDHQM.js} +3 -3
- package/dist/lib/{chunk-7IZEK7X5.js → chunk-2AUSNVIB.js} +2 -2
- package/dist/lib/{chunk-BN4Q54G2.js → chunk-2QILP24G.js} +44 -20
- package/dist/lib/{chunk-CYDNMEBC.js → chunk-3LU4APFB.js} +1 -1
- package/dist/lib/{chunk-BO76JDFZ.js → chunk-XFSN4LMA.js} +1 -1
- package/dist/lib/{chunk-MF3YLQDS.js → chunk-XG6NELJH.js} +1 -1
- package/dist/lib/index.js +10 -10
- package/dist/lib/{openai-RDHZFJUT.js → openai-VX5VBXZ4.js} +2 -2
- package/dist/main.js +162 -168
- package/dist/{openai-6NWVJ5LI.js → openai-6MXNADYN.js} +1 -1
- package/dist/{server-KQTLAXC6.js → server-ORARCYIX.js} +3 -3
- package/package.json +3 -4
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __swiftyCreateRequire } from "node:module";
|
|
3
3
|
const require = __swiftyCreateRequire(import.meta.url);
|
|
4
|
-
import{b as Gl,i as fo}from"./chunk-OCQ6TYLT.js";import{a as er,b as mo}from"./chunk-MJR2C7S7.js";import{a as Ue,b as xl,c as uo,d as Ao}from"./chunk-CV7OKXYC.js";import{e as Hl,f as tr}from"./chunk-NR62AA5K.js";import{a as Ll}from"./chunk-QN27QEFS.js";import{a as We}from"./chunk-7MHXMDYC.js";import{A as zl,B as Ul,C as $,D as C,I as R,J as Fl,K as Ol,L as Gr,N as O,P as tt,Q as Hr,R as S,S as po,a as bl,d as Tl,e as Se,f as Rl,g as Dl,h as A,i as $l,j as J,k as K,l as Pl,m as jl,n as ne,o as _,p as k,q as le,r as re,s as ei,t as ti,u as X,v as Te,w as b,x as oe,y as Nl,z as ri}from"./chunk-SIWLMWHH.js";import{a as go,b as Yl,c as Jl,f as Wl}from"./chunk-A2VR3BC4.js";import{a as ql}from"./chunk-E55KH72M.js";import{a as ft,b as Q,d as lo}from"./chunk-X3UA5OZL.js";var os=Q(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.regexpCode=W.getEsmExportName=W.getProperty=W.safeStringify=W.stringify=W.strConcat=W.addCodeArg=W.str=W._=W.nil=W._Code=W.Name=W.IDENTIFIER=W._CodeOrName=void 0;var rs=class{};W._CodeOrName=rs;W.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Rt=class extends rs{constructor(e){if(super(),!W.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};W.Name=Rt;var Pe=class extends rs{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,s)=>`${r}${s}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,s)=>(s instanceof Rt&&(r[s.str]=(r[s.str]||0)+1),r),{})}};W._Code=Pe;W.nil=new Pe("");function hu(t,...e){let r=[t[0]],s=0;for(;s<e.length;)Ri(r,e[s]),r.push(t[++s]);return new Pe(r)}W._=hu;var Ti=new Pe("+");function Eu(t,...e){let r=[ss(t[0])],s=0;for(;s<e.length;)r.push(Ti),Ri(r,e[s]),r.push(Ti,ss(t[++s]));return hE(r),new Pe(r)}W.str=Eu;function Ri(t,e){e instanceof Pe?t.push(...e._items):e instanceof Rt?t.push(e):t.push(wE(e))}W.addCodeArg=Ri;function hE(t){let e=1;for(;e<t.length-1;){if(t[e]===Ti){let r=EE(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function EE(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Rt||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof Rt))return`"${t}${e.slice(1)}`}function yE(t,e){return e.emptyStr()?t:t.emptyStr()?e:Eu`${t}${e}`}W.strConcat=yE;function wE(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:ss(Array.isArray(t)?t.join(","):t)}function CE(t){return new Pe(ss(t))}W.stringify=CE;function ss(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}W.safeStringify=ss;function IE(t){return typeof t=="string"&&W.IDENTIFIER.test(t)?new Pe(`.${t}`):hu`[${t}]`}W.getProperty=IE;function BE(t){if(typeof t=="string"&&W.IDENTIFIER.test(t))return new Pe(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}W.getEsmExportName=BE;function QE(t){return new Pe(t.toString())}W.regexpCode=QE});var Pi=Q(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Me.ValueScope=Me.ValueScopeName=Me.Scope=Me.varKinds=Me.UsedValueState=void 0;var ke=os(),Di=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},bo;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(bo||(Me.UsedValueState=bo={}));Me.varKinds={const:new ke.Name("const"),let:new ke.Name("let"),var:new ke.Name("var")};var xo=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof ke.Name?e:this.name(e)}name(e){return new ke.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,s;if(!((s=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||s===void 0)&&s.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Me.Scope=xo;var To=class extends ke.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:s}){this.value=e,this.scopePath=(0,ke._)`.${new ke.Name(r)}[${s}]`}};Me.ValueScopeName=To;var _E=(0,ke._)`\n`,$i=class extends xo{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?_E:ke.nil}}get(){return this._scope}name(e){return new To(e,this._newName(e))}value(e,r){var s;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:n}=o,i=(s=r.key)!==null&&s!==void 0?s:r.ref,a=this._values[n];if(a){let l=a.get(i);if(l)return l}else a=this._values[n]=new Map;a.set(i,o);let c=this._scope[n]||(this._scope[n]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:n,itemIndex:u}),o}getValue(e,r){let s=this._values[e];if(s)return s.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,s=>{if(s.scopePath===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return(0,ke._)`${e}${s.scopePath}`})}scopeCode(e=this._values,r,s){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,s)}_reduceValues(e,r,s={},o){let n=ke.nil;for(let i in e){let a=e[i];if(!a)continue;let c=s[i]=s[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,bo.Started);let l=r(u);if(l){let d=this.opts.es5?Me.varKinds.var:Me.varKinds.const;n=(0,ke._)`${n}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))n=(0,ke._)`${n}${l}${this.opts._n}`;else throw new Di(u);c.set(u,bo.Completed)})}return n}};Me.ValueScope=$i});var U=Q(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.or=F.and=F.not=F.CodeGen=F.operators=F.varKinds=F.ValueScopeName=F.ValueScope=F.Scope=F.Name=F.regexpCode=F.stringify=F.getProperty=F.nil=F.strConcat=F.str=F._=void 0;var G=os(),Fe=Pi(),yt=os();Object.defineProperty(F,"_",{enumerable:!0,get:function(){return yt._}});Object.defineProperty(F,"str",{enumerable:!0,get:function(){return yt.str}});Object.defineProperty(F,"strConcat",{enumerable:!0,get:function(){return yt.strConcat}});Object.defineProperty(F,"nil",{enumerable:!0,get:function(){return yt.nil}});Object.defineProperty(F,"getProperty",{enumerable:!0,get:function(){return yt.getProperty}});Object.defineProperty(F,"stringify",{enumerable:!0,get:function(){return yt.stringify}});Object.defineProperty(F,"regexpCode",{enumerable:!0,get:function(){return yt.regexpCode}});Object.defineProperty(F,"Name",{enumerable:!0,get:function(){return yt.Name}});var Po=Pi();Object.defineProperty(F,"Scope",{enumerable:!0,get:function(){return Po.Scope}});Object.defineProperty(F,"ValueScope",{enumerable:!0,get:function(){return Po.ValueScope}});Object.defineProperty(F,"ValueScopeName",{enumerable:!0,get:function(){return Po.ValueScopeName}});Object.defineProperty(F,"varKinds",{enumerable:!0,get:function(){return Po.varKinds}});F.operators={GT:new G._Code(">"),GTE:new G._Code(">="),LT:new G._Code("<"),LTE:new G._Code("<="),EQ:new G._Code("==="),NEQ:new G._Code("!=="),NOT:new G._Code("!"),OR:new G._Code("||"),AND:new G._Code("&&"),ADD:new G._Code("+")};var st=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},ji=class extends st{constructor(e,r,s){super(),this.varKind=e,this.name=r,this.rhs=s}render({es5:e,_n:r}){let s=e?Fe.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${s} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=ar(this.rhs,e,r)),this}get names(){return this.rhs instanceof G._CodeOrName?this.rhs.names:{}}},Ro=class extends st{constructor(e,r,s){super(),this.lhs=e,this.rhs=r,this.sideEffects=s}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof G.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=ar(this.rhs,e,r),this}get names(){let e=this.lhs instanceof G.Name?{}:{...this.lhs.names};return $o(e,this.rhs)}},Ni=class extends Ro{constructor(e,r,s,o){super(e,s,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},zi=class extends st{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Ui=class extends st{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Fi=class extends st{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Oi=class extends st{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=ar(this.code,e,r),this}get names(){return this.code instanceof G._CodeOrName?this.code.names:{}}},ns=class extends st{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,s)=>r+s.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let s=e[r].optimizeNodes();Array.isArray(s)?e.splice(r,1,...s):s?e[r]=s:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:s}=this,o=s.length;for(;o--;){let n=s[o];n.optimizeNames(e,r)||(SE(e,n.names),s.splice(o,1))}return s.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Pt(e,r.names),{})}},ot=class extends ns{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Li=class extends ns{},ir=class extends ot{};ir.kind="else";var Dt=class t extends ot{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let s=r.optimizeNodes();r=this.else=Array.isArray(s)?new ir(s):s}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(yu(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var s;if(this.else=(s=this.else)===null||s===void 0?void 0:s.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=ar(this.condition,e,r),this}get names(){let e=super.names;return $o(e,this.condition),this.else&&Pt(e,this.else.names),e}};Dt.kind="if";var $t=class extends ot{};$t.kind="for";var qi=class extends $t{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=ar(this.iteration,e,r),this}get names(){return Pt(super.names,this.iteration.names)}},Gi=class extends $t{constructor(e,r,s,o){super(),this.varKind=e,this.name=r,this.from=s,this.to=o}render(e){let r=e.es5?Fe.varKinds.var:this.varKind,{name:s,from:o,to:n}=this;return`for(${r} ${s}=${o}; ${s}<${n}; ${s}++)`+super.render(e)}get names(){let e=$o(super.names,this.from);return $o(e,this.to)}},Do=class extends $t{constructor(e,r,s,o){super(),this.loop=e,this.varKind=r,this.name=s,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=ar(this.iterable,e,r),this}get names(){return Pt(super.names,this.iterable.names)}},is=class extends ot{constructor(e,r,s){super(),this.name=e,this.args=r,this.async=s}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};is.kind="func";var as=class extends ns{render(e){return"return "+super.render(e)}};as.kind="return";var Hi=class extends ot{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var s,o;return super.optimizeNames(e,r),(s=this.catch)===null||s===void 0||s.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Pt(e,this.catch.names),this.finally&&Pt(e,this.finally.names),e}},cs=class extends ot{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};cs.kind="catch";var ls=class extends ot{render(e){return"finally"+super.render(e)}};ls.kind="finally";var Yi=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
4
|
+
import{b as Gl,i as fo}from"./chunk-VQUWSKQQ.js";import{a as er,b as mo}from"./chunk-MWZIARZE.js";import{a as Ue,b as xl,c as uo,d as Ao}from"./chunk-W37Y53LX.js";import{e as Hl,f as tr}from"./chunk-NR62AA5K.js";import{a as Ll}from"./chunk-QN27QEFS.js";import{a as We}from"./chunk-7MHXMDYC.js";import{A as zl,B as Ul,C as $,D as C,I as R,J as Fl,K as Ol,L as Gr,N as O,P as tt,Q as Hr,R as S,S as po,a as bl,d as Tl,e as Se,f as Rl,g as Dl,h as A,i as $l,j as J,k as K,l as Pl,m as jl,n as ne,o as _,p as k,q as le,r as re,s as ei,t as ti,u as X,v as Te,w as b,x as oe,y as Nl,z as ri}from"./chunk-SIWLMWHH.js";import{a as go,b as Yl,c as Jl,f as Wl}from"./chunk-A2VR3BC4.js";import{a as ql}from"./chunk-E55KH72M.js";import{a as ft,b as Q,d as lo}from"./chunk-X3UA5OZL.js";var os=Q(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.regexpCode=W.getEsmExportName=W.getProperty=W.safeStringify=W.stringify=W.strConcat=W.addCodeArg=W.str=W._=W.nil=W._Code=W.Name=W.IDENTIFIER=W._CodeOrName=void 0;var rs=class{};W._CodeOrName=rs;W.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Rt=class extends rs{constructor(e){if(super(),!W.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};W.Name=Rt;var Pe=class extends rs{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,s)=>`${r}${s}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,s)=>(s instanceof Rt&&(r[s.str]=(r[s.str]||0)+1),r),{})}};W._Code=Pe;W.nil=new Pe("");function hu(t,...e){let r=[t[0]],s=0;for(;s<e.length;)Ri(r,e[s]),r.push(t[++s]);return new Pe(r)}W._=hu;var Ti=new Pe("+");function Eu(t,...e){let r=[ss(t[0])],s=0;for(;s<e.length;)r.push(Ti),Ri(r,e[s]),r.push(Ti,ss(t[++s]));return hE(r),new Pe(r)}W.str=Eu;function Ri(t,e){e instanceof Pe?t.push(...e._items):e instanceof Rt?t.push(e):t.push(wE(e))}W.addCodeArg=Ri;function hE(t){let e=1;for(;e<t.length-1;){if(t[e]===Ti){let r=EE(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function EE(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Rt||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof Rt))return`"${t}${e.slice(1)}`}function yE(t,e){return e.emptyStr()?t:t.emptyStr()?e:Eu`${t}${e}`}W.strConcat=yE;function wE(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:ss(Array.isArray(t)?t.join(","):t)}function CE(t){return new Pe(ss(t))}W.stringify=CE;function ss(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}W.safeStringify=ss;function IE(t){return typeof t=="string"&&W.IDENTIFIER.test(t)?new Pe(`.${t}`):hu`[${t}]`}W.getProperty=IE;function BE(t){if(typeof t=="string"&&W.IDENTIFIER.test(t))return new Pe(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}W.getEsmExportName=BE;function QE(t){return new Pe(t.toString())}W.regexpCode=QE});var Pi=Q(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Me.ValueScope=Me.ValueScopeName=Me.Scope=Me.varKinds=Me.UsedValueState=void 0;var ke=os(),Di=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},bo;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(bo||(Me.UsedValueState=bo={}));Me.varKinds={const:new ke.Name("const"),let:new ke.Name("let"),var:new ke.Name("var")};var xo=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof ke.Name?e:this.name(e)}name(e){return new ke.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,s;if(!((s=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||s===void 0)&&s.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Me.Scope=xo;var To=class extends ke.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:s}){this.value=e,this.scopePath=(0,ke._)`.${new ke.Name(r)}[${s}]`}};Me.ValueScopeName=To;var _E=(0,ke._)`\n`,$i=class extends xo{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?_E:ke.nil}}get(){return this._scope}name(e){return new To(e,this._newName(e))}value(e,r){var s;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:n}=o,i=(s=r.key)!==null&&s!==void 0?s:r.ref,a=this._values[n];if(a){let l=a.get(i);if(l)return l}else a=this._values[n]=new Map;a.set(i,o);let c=this._scope[n]||(this._scope[n]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:n,itemIndex:u}),o}getValue(e,r){let s=this._values[e];if(s)return s.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,s=>{if(s.scopePath===void 0)throw new Error(`CodeGen: name "${s}" has no value`);return(0,ke._)`${e}${s.scopePath}`})}scopeCode(e=this._values,r,s){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,s)}_reduceValues(e,r,s={},o){let n=ke.nil;for(let i in e){let a=e[i];if(!a)continue;let c=s[i]=s[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,bo.Started);let l=r(u);if(l){let d=this.opts.es5?Me.varKinds.var:Me.varKinds.const;n=(0,ke._)`${n}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))n=(0,ke._)`${n}${l}${this.opts._n}`;else throw new Di(u);c.set(u,bo.Completed)})}return n}};Me.ValueScope=$i});var U=Q(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.or=F.and=F.not=F.CodeGen=F.operators=F.varKinds=F.ValueScopeName=F.ValueScope=F.Scope=F.Name=F.regexpCode=F.stringify=F.getProperty=F.nil=F.strConcat=F.str=F._=void 0;var G=os(),Fe=Pi(),yt=os();Object.defineProperty(F,"_",{enumerable:!0,get:function(){return yt._}});Object.defineProperty(F,"str",{enumerable:!0,get:function(){return yt.str}});Object.defineProperty(F,"strConcat",{enumerable:!0,get:function(){return yt.strConcat}});Object.defineProperty(F,"nil",{enumerable:!0,get:function(){return yt.nil}});Object.defineProperty(F,"getProperty",{enumerable:!0,get:function(){return yt.getProperty}});Object.defineProperty(F,"stringify",{enumerable:!0,get:function(){return yt.stringify}});Object.defineProperty(F,"regexpCode",{enumerable:!0,get:function(){return yt.regexpCode}});Object.defineProperty(F,"Name",{enumerable:!0,get:function(){return yt.Name}});var Po=Pi();Object.defineProperty(F,"Scope",{enumerable:!0,get:function(){return Po.Scope}});Object.defineProperty(F,"ValueScope",{enumerable:!0,get:function(){return Po.ValueScope}});Object.defineProperty(F,"ValueScopeName",{enumerable:!0,get:function(){return Po.ValueScopeName}});Object.defineProperty(F,"varKinds",{enumerable:!0,get:function(){return Po.varKinds}});F.operators={GT:new G._Code(">"),GTE:new G._Code(">="),LT:new G._Code("<"),LTE:new G._Code("<="),EQ:new G._Code("==="),NEQ:new G._Code("!=="),NOT:new G._Code("!"),OR:new G._Code("||"),AND:new G._Code("&&"),ADD:new G._Code("+")};var st=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},ji=class extends st{constructor(e,r,s){super(),this.varKind=e,this.name=r,this.rhs=s}render({es5:e,_n:r}){let s=e?Fe.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${s} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=ar(this.rhs,e,r)),this}get names(){return this.rhs instanceof G._CodeOrName?this.rhs.names:{}}},Ro=class extends st{constructor(e,r,s){super(),this.lhs=e,this.rhs=r,this.sideEffects=s}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof G.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=ar(this.rhs,e,r),this}get names(){let e=this.lhs instanceof G.Name?{}:{...this.lhs.names};return $o(e,this.rhs)}},Ni=class extends Ro{constructor(e,r,s,o){super(e,s,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},zi=class extends st{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Ui=class extends st{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Fi=class extends st{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Oi=class extends st{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=ar(this.code,e,r),this}get names(){return this.code instanceof G._CodeOrName?this.code.names:{}}},ns=class extends st{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,s)=>r+s.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let s=e[r].optimizeNodes();Array.isArray(s)?e.splice(r,1,...s):s?e[r]=s:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:s}=this,o=s.length;for(;o--;){let n=s[o];n.optimizeNames(e,r)||(SE(e,n.names),s.splice(o,1))}return s.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Pt(e,r.names),{})}},ot=class extends ns{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Li=class extends ns{},ir=class extends ot{};ir.kind="else";var Dt=class t extends ot{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let s=r.optimizeNodes();r=this.else=Array.isArray(s)?new ir(s):s}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(yu(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var s;if(this.else=(s=this.else)===null||s===void 0?void 0:s.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=ar(this.condition,e,r),this}get names(){let e=super.names;return $o(e,this.condition),this.else&&Pt(e,this.else.names),e}};Dt.kind="if";var $t=class extends ot{};$t.kind="for";var qi=class extends $t{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=ar(this.iteration,e,r),this}get names(){return Pt(super.names,this.iteration.names)}},Gi=class extends $t{constructor(e,r,s,o){super(),this.varKind=e,this.name=r,this.from=s,this.to=o}render(e){let r=e.es5?Fe.varKinds.var:this.varKind,{name:s,from:o,to:n}=this;return`for(${r} ${s}=${o}; ${s}<${n}; ${s}++)`+super.render(e)}get names(){let e=$o(super.names,this.from);return $o(e,this.to)}},Do=class extends $t{constructor(e,r,s,o){super(),this.loop=e,this.varKind=r,this.name=s,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=ar(this.iterable,e,r),this}get names(){return Pt(super.names,this.iterable.names)}},is=class extends ot{constructor(e,r,s){super(),this.name=e,this.args=r,this.async=s}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};is.kind="func";var as=class extends ns{render(e){return"return "+super.render(e)}};as.kind="return";var Hi=class extends ot{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var s,o;return super.optimizeNames(e,r),(s=this.catch)===null||s===void 0||s.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Pt(e,this.catch.names),this.finally&&Pt(e,this.finally.names),e}},cs=class extends ot{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};cs.kind="catch";var ls=class extends ot{render(e){return"finally"+super.render(e)}};ls.kind="finally";var Yi=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
5
5
|
`:""},this._extScope=e,this._scope=new Fe.Scope({parent:e}),this._nodes=[new Li]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let s=this._extScope.value(e,r);return(this._values[s.prefix]||(this._values[s.prefix]=new Set)).add(s),s}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,s,o){let n=this._scope.toName(r);return s!==void 0&&o&&(this._constants[n.str]=s),this._leafNode(new ji(e,n,s)),n}const(e,r,s){return this._def(Fe.varKinds.const,e,r,s)}let(e,r,s){return this._def(Fe.varKinds.let,e,r,s)}var(e,r,s){return this._def(Fe.varKinds.var,e,r,s)}assign(e,r,s){return this._leafNode(new Ro(e,r,s))}add(e,r){return this._leafNode(new Ni(e,F.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==G.nil&&this._leafNode(new Oi(e)),this}object(...e){let r=["{"];for(let[s,o]of e)r.length>1&&r.push(","),r.push(s),(s!==o||this.opts.es5)&&(r.push(":"),(0,G.addCodeArg)(r,o));return r.push("}"),new G._Code(r)}if(e,r,s){if(this._blockNode(new Dt(e)),r&&s)this.code(r).else().code(s).endIf();else if(r)this.code(r).endIf();else if(s)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new Dt(e))}else(){return this._elseNode(new ir)}endIf(){return this._endBlockNode(Dt,ir)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new qi(e),r)}forRange(e,r,s,o,n=this.opts.es5?Fe.varKinds.var:Fe.varKinds.let){let i=this._scope.toName(e);return this._for(new Gi(n,i,r,s),()=>o(i))}forOf(e,r,s,o=Fe.varKinds.const){let n=this._scope.toName(e);if(this.opts.es5){let i=r instanceof G.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,G._)`${i}.length`,a=>{this.var(n,(0,G._)`${i}[${a}]`),s(n)})}return this._for(new Do("of",o,n,r),()=>s(n))}forIn(e,r,s,o=this.opts.es5?Fe.varKinds.var:Fe.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,G._)`Object.keys(${r})`,s);let n=this._scope.toName(e);return this._for(new Do("in",o,n,r),()=>s(n))}endFor(){return this._endBlockNode($t)}label(e){return this._leafNode(new zi(e))}break(e){return this._leafNode(new Ui(e))}return(e){let r=new as;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(as)}try(e,r,s){if(!r&&!s)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Hi;if(this._blockNode(o),this.code(e),r){let n=this.name("e");this._currNode=o.catch=new cs(n),r(n)}return s&&(this._currNode=o.finally=new ls,this.code(s)),this._endBlockNode(cs,ls)}throw(e){return this._leafNode(new Fi(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let s=this._nodes.length-r;if(s<0||e!==void 0&&s!==e)throw new Error(`CodeGen: wrong number of nodes: ${s} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=G.nil,s,o){return this._blockNode(new is(e,r,s)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(is)}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,r){let s=this._currNode;if(s instanceof e||r&&s instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof Dt))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};F.CodeGen=Yi;function Pt(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function $o(t,e){return e instanceof G._CodeOrName?Pt(t,e.names):t}function ar(t,e,r){if(t instanceof G.Name)return s(t);if(!o(t))return t;return new G._Code(t._items.reduce((n,i)=>(i instanceof G.Name&&(i=s(i)),i instanceof G._Code?n.push(...i._items):n.push(i),n),[]));function s(n){let i=r[n.str];return i===void 0||e[n.str]!==1?n:(delete e[n.str],i)}function o(n){return n instanceof G._Code&&n._items.some(i=>i instanceof G.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function SE(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function yu(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,G._)`!${Ji(t)}`}F.not=yu;var kE=wu(F.operators.AND);function ME(...t){return t.reduce(kE)}F.and=ME;var vE=wu(F.operators.OR);function bE(...t){return t.reduce(vE)}F.or=bE;function wu(t){return(e,r)=>e===G.nil?r:r===G.nil?e:(0,G._)`${Ji(e)} ${t} ${Ji(r)}`}function Ji(t){return t instanceof G.Name?t:(0,G._)`(${t})`}});var H=Q(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.checkStrictMode=L.getErrorPath=L.Type=L.useFunc=L.setEvaluated=L.evaluatedPropsToName=L.mergeEvaluated=L.eachItem=L.unescapeJsonPointer=L.escapeJsonPointer=L.escapeFragment=L.unescapeFragment=L.schemaRefOrVal=L.schemaHasRulesButRef=L.schemaHasRules=L.checkUnknownRules=L.alwaysValidSchema=L.toHash=void 0;var Z=U(),xE=os();function TE(t){let e={};for(let r of t)e[r]=!0;return e}L.toHash=TE;function RE(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Bu(t,e),!Qu(e,t.self.RULES.all))}L.alwaysValidSchema=RE;function Bu(t,e=t.schema){let{opts:r,self:s}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=s.RULES.keywords;for(let n in e)o[n]||ku(t,`unknown keyword: "${n}"`)}L.checkUnknownRules=Bu;function Qu(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}L.schemaHasRules=Qu;function DE(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}L.schemaHasRulesButRef=DE;function $E({topSchemaRef:t,schemaPath:e},r,s,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Z._)`${r}`}return(0,Z._)`${t}${e}${(0,Z.getProperty)(s)}`}L.schemaRefOrVal=$E;function PE(t){return _u(decodeURIComponent(t))}L.unescapeFragment=PE;function jE(t){return encodeURIComponent(Vi(t))}L.escapeFragment=jE;function Vi(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}L.escapeJsonPointer=Vi;function _u(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}L.unescapeJsonPointer=_u;function NE(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}L.eachItem=NE;function Cu({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:s}){return(o,n,i,a)=>{let c=i===void 0?n:i instanceof Z.Name?(n instanceof Z.Name?t(o,n,i):e(o,n,i),i):n instanceof Z.Name?(e(o,i,n),n):r(n,i);return a===Z.Name&&!(c instanceof Z.Name)?s(o,c):c}}L.mergeEvaluated={props:Cu({mergeNames:(t,e,r)=>t.if((0,Z._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,Z._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,Z._)`${r} || {}`).code((0,Z._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,Z._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,Z._)`${r} || {}`),Ki(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:Su}),items:Cu({mergeNames:(t,e,r)=>t.if((0,Z._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,Z._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,Z._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,Z._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function Su(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,Z._)`{}`);return e!==void 0&&Ki(t,r,e),r}L.evaluatedPropsToName=Su;function Ki(t,e,r){Object.keys(r).forEach(s=>t.assign((0,Z._)`${e}${(0,Z.getProperty)(s)}`,!0))}L.setEvaluated=Ki;var Iu={};function zE(t,e){return t.scopeValue("func",{ref:e,code:Iu[e.code]||(Iu[e.code]=new xE._Code(e.code))})}L.useFunc=zE;var Wi;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Wi||(L.Type=Wi={}));function UE(t,e,r){if(t instanceof Z.Name){let s=e===Wi.Num;return r?s?(0,Z._)`"[" + ${t} + "]"`:(0,Z._)`"['" + ${t} + "']"`:s?(0,Z._)`"/" + ${t}`:(0,Z._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Z.getProperty)(t).toString():"/"+Vi(t)}L.getErrorPath=UE;function ku(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}L.checkStrictMode=ku});var nt=Q(Zi=>{"use strict";Object.defineProperty(Zi,"__esModule",{value:!0});var ye=U(),FE={data:new ye.Name("data"),valCxt:new ye.Name("valCxt"),instancePath:new ye.Name("instancePath"),parentData:new ye.Name("parentData"),parentDataProperty:new ye.Name("parentDataProperty"),rootData:new ye.Name("rootData"),dynamicAnchors:new ye.Name("dynamicAnchors"),vErrors:new ye.Name("vErrors"),errors:new ye.Name("errors"),this:new ye.Name("this"),self:new ye.Name("self"),scope:new ye.Name("scope"),json:new ye.Name("json"),jsonPos:new ye.Name("jsonPos"),jsonLen:new ye.Name("jsonLen"),jsonPart:new ye.Name("jsonPart")};Zi.default=FE});var us=Q(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.extendErrors=we.resetErrorsCount=we.reportExtraError=we.reportError=we.keyword$DataError=we.keywordError=void 0;var Y=U(),jo=H(),Be=nt();we.keywordError={message:({keyword:t})=>(0,Y.str)`must pass "${t}" keyword validation`};we.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,Y.str)`"${t}" keyword must be ${e} ($data)`:(0,Y.str)`"${t}" keyword is invalid ($data)`};function OE(t,e=we.keywordError,r,s){let{it:o}=t,{gen:n,compositeRule:i,allErrors:a}=o,c=bu(t,e,r);s??(i||a)?Mu(n,c):vu(o,(0,Y._)`[${c}]`)}we.reportError=OE;function LE(t,e=we.keywordError,r){let{it:s}=t,{gen:o,compositeRule:n,allErrors:i}=s,a=bu(t,e,r);Mu(o,a),n||i||vu(s,Be.default.vErrors)}we.reportExtraError=LE;function qE(t,e){t.assign(Be.default.errors,e),t.if((0,Y._)`${Be.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,Y._)`${Be.default.vErrors}.length`,e),()=>t.assign(Be.default.vErrors,null)))}we.resetErrorsCount=qE;function GE({gen:t,keyword:e,schemaValue:r,data:s,errsCount:o,it:n}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,Be.default.errors,a=>{t.const(i,(0,Y._)`${Be.default.vErrors}[${a}]`),t.if((0,Y._)`${i}.instancePath === undefined`,()=>t.assign((0,Y._)`${i}.instancePath`,(0,Y.strConcat)(Be.default.instancePath,n.errorPath))),t.assign((0,Y._)`${i}.schemaPath`,(0,Y.str)`${n.errSchemaPath}/${e}`),n.opts.verbose&&(t.assign((0,Y._)`${i}.schema`,r),t.assign((0,Y._)`${i}.data`,s))})}we.extendErrors=GE;function Mu(t,e){let r=t.const("err",e);t.if((0,Y._)`${Be.default.vErrors} === null`,()=>t.assign(Be.default.vErrors,(0,Y._)`[${r}]`),(0,Y._)`${Be.default.vErrors}.push(${r})`),t.code((0,Y._)`${Be.default.errors}++`)}function vu(t,e){let{gen:r,validateName:s,schemaEnv:o}=t;o.$async?r.throw((0,Y._)`new ${t.ValidationError}(${e})`):(r.assign((0,Y._)`${s}.errors`,e),r.return(!1))}var jt={keyword:new Y.Name("keyword"),schemaPath:new Y.Name("schemaPath"),params:new Y.Name("params"),propertyName:new Y.Name("propertyName"),message:new Y.Name("message"),schema:new Y.Name("schema"),parentSchema:new Y.Name("parentSchema")};function bu(t,e,r){let{createErrors:s}=t.it;return s===!1?(0,Y._)`{}`:HE(t,e,r)}function HE(t,e,r={}){let{gen:s,it:o}=t,n=[YE(o,r),JE(t,r)];return WE(t,e,n),s.object(...n)}function YE({errorPath:t},{instancePath:e}){let r=e?(0,Y.str)`${t}${(0,jo.getErrorPath)(e,jo.Type.Str)}`:t;return[Be.default.instancePath,(0,Y.strConcat)(Be.default.instancePath,r)]}function JE({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:s}){let o=s?e:(0,Y.str)`${e}/${t}`;return r&&(o=(0,Y.str)`${o}${(0,jo.getErrorPath)(r,jo.Type.Str)}`),[jt.schemaPath,o]}function WE(t,{params:e,message:r},s){let{keyword:o,data:n,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;s.push([jt.keyword,o],[jt.params,typeof e=="function"?e(t):e||(0,Y._)`{}`]),c.messages&&s.push([jt.message,typeof r=="function"?r(t):r]),c.verbose&&s.push([jt.schema,i],[jt.parentSchema,(0,Y._)`${l}${d}`],[Be.default.data,n]),u&&s.push([jt.propertyName,u])}});var Tu=Q(cr=>{"use strict";Object.defineProperty(cr,"__esModule",{value:!0});cr.boolOrEmptySchema=cr.topBoolOrEmptySchema=void 0;var VE=us(),KE=U(),ZE=nt(),XE={message:"boolean schema is false"};function ey(t){let{gen:e,schema:r,validateName:s}=t;r===!1?xu(t,!1):typeof r=="object"&&r.$async===!0?e.return(ZE.default.data):(e.assign((0,KE._)`${s}.errors`,null),e.return(!0))}cr.topBoolOrEmptySchema=ey;function ty(t,e){let{gen:r,schema:s}=t;s===!1?(r.var(e,!1),xu(t)):r.var(e,!0)}cr.boolOrEmptySchema=ty;function xu(t,e){let{gen:r,data:s}=t,o={gen:r,keyword:"false schema",data:s,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,VE.reportError)(o,XE,void 0,e)}});var Xi=Q(lr=>{"use strict";Object.defineProperty(lr,"__esModule",{value:!0});lr.getRules=lr.isJSONType=void 0;var ry=["string","number","integer","boolean","null","object","array"],sy=new Set(ry);function oy(t){return typeof t=="string"&&sy.has(t)}lr.isJSONType=oy;function ny(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}lr.getRules=ny});var ea=Q(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.shouldUseRule=wt.shouldUseGroup=wt.schemaHasRulesForType=void 0;function iy({schema:t,self:e},r){let s=e.RULES.types[r];return s&&s!==!0&&Ru(t,s)}wt.schemaHasRulesForType=iy;function Ru(t,e){return e.rules.some(r=>Du(t,r))}wt.shouldUseGroup=Ru;function Du(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(s=>t[s]!==void 0))}wt.shouldUseRule=Du});var ds=Q(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.reportTypeError=Ce.checkDataTypes=Ce.checkDataType=Ce.coerceAndCheckDataType=Ce.getJSONTypes=Ce.getSchemaTypes=Ce.DataType=void 0;var ay=Xi(),cy=ea(),ly=us(),N=U(),$u=H(),ur;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(ur||(Ce.DataType=ur={}));function uy(t){let e=Pu(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}Ce.getSchemaTypes=uy;function Pu(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(ay.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Ce.getJSONTypes=Pu;function dy(t,e){let{gen:r,data:s,opts:o}=t,n=Ay(e,o.coerceTypes),i=e.length>0&&!(n.length===0&&e.length===1&&(0,cy.schemaHasRulesForType)(t,e[0]));if(i){let a=ra(e,s,o.strictNumbers,ur.Wrong);r.if(a,()=>{n.length?py(t,e,n):sa(t)})}return i}Ce.coerceAndCheckDataType=dy;var ju=new Set(["string","number","integer","boolean","null"]);function Ay(t,e){return e?t.filter(r=>ju.has(r)||e==="array"&&r==="array"):[]}function py(t,e,r){let{gen:s,data:o,opts:n}=t,i=s.let("dataType",(0,N._)`typeof ${o}`),a=s.let("coerced",(0,N._)`undefined`);n.coerceTypes==="array"&&s.if((0,N._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>s.assign(o,(0,N._)`${o}[0]`).assign(i,(0,N._)`typeof ${o}`).if(ra(e,o,n.strictNumbers),()=>s.assign(a,o))),s.if((0,N._)`${a} !== undefined`);for(let u of r)(ju.has(u)||u==="array"&&n.coerceTypes==="array")&&c(u);s.else(),sa(t),s.endIf(),s.if((0,N._)`${a} !== undefined`,()=>{s.assign(o,a),my(t,a)});function c(u){switch(u){case"string":s.elseIf((0,N._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,N._)`"" + ${o}`).elseIf((0,N._)`${o} === null`).assign(a,(0,N._)`""`);return;case"number":s.elseIf((0,N._)`${i} == "boolean" || ${o} === null
|
|
6
6
|
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,N._)`+${o}`);return;case"integer":s.elseIf((0,N._)`${i} === "boolean" || ${o} === null
|
|
7
7
|
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,N._)`+${o}`);return;case"boolean":s.elseIf((0,N._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,N._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":s.elseIf((0,N._)`${o} === "" || ${o} === 0 || ${o} === false`),s.assign(a,null);return;case"array":s.elseIf((0,N._)`${i} === "string" || ${i} === "number"
|
|
8
8
|
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,N._)`[${o}]`)}}}function my({gen:t,parentData:e,parentDataProperty:r},s){t.if((0,N._)`${e} !== undefined`,()=>t.assign((0,N._)`${e}[${r}]`,s))}function ta(t,e,r,s=ur.Correct){let o=s===ur.Correct?N.operators.EQ:N.operators.NEQ,n;switch(t){case"null":return(0,N._)`${e} ${o} null`;case"array":n=(0,N._)`Array.isArray(${e})`;break;case"object":n=(0,N._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":n=i((0,N._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":n=i();break;default:return(0,N._)`typeof ${e} ${o} ${t}`}return s===ur.Correct?n:(0,N.not)(n);function i(a=N.nil){return(0,N.and)((0,N._)`typeof ${e} == "number"`,a,r?(0,N._)`isFinite(${e})`:N.nil)}}Ce.checkDataType=ta;function ra(t,e,r,s){if(t.length===1)return ta(t[0],e,r,s);let o,n=(0,$u.toHash)(t);if(n.array&&n.object){let i=(0,N._)`typeof ${e} != "object"`;o=n.null?i:(0,N._)`!${e} || ${i}`,delete n.null,delete n.array,delete n.object}else o=N.nil;n.number&&delete n.integer;for(let i in n)o=(0,N.and)(o,ta(i,e,r,s));return o}Ce.checkDataTypes=ra;var fy={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,N._)`{type: ${t}}`:(0,N._)`{type: ${e}}`};function sa(t){let e=gy(t);(0,ly.reportError)(e,fy)}Ce.reportTypeError=sa;function gy(t){let{gen:e,data:r,schema:s}=t,o=(0,$u.schemaRefOrVal)(t,s,"type");return{gen:e,keyword:"type",data:r,schema:s.type,schemaCode:o,schemaValue:o,parentSchema:s,params:{},it:t}}});var zu=Q(No=>{"use strict";Object.defineProperty(No,"__esModule",{value:!0});No.assignDefaults=void 0;var dr=U(),hy=H();function Ey(t,e){let{properties:r,items:s}=t.schema;if(e==="object"&&r)for(let o in r)Nu(t,o,r[o].default);else e==="array"&&Array.isArray(s)&&s.forEach((o,n)=>Nu(t,n,o.default))}No.assignDefaults=Ey;function Nu(t,e,r){let{gen:s,compositeRule:o,data:n,opts:i}=t;if(r===void 0)return;let a=(0,dr._)`${n}${(0,dr.getProperty)(e)}`;if(o){(0,hy.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,dr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,dr._)`${c} || ${a} === null || ${a} === ""`),s.if(c,(0,dr._)`${a} = ${(0,dr.stringify)(r)}`)}});var je=Q(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.validateUnion=V.validateArray=V.usePattern=V.callValidateCode=V.schemaProperties=V.allSchemaProperties=V.noPropertyInData=V.propertyInData=V.isOwnProperty=V.hasPropFunc=V.reportMissingProp=V.checkMissingProp=V.checkReportMissingProp=void 0;var ee=U(),oa=H(),Ct=nt(),yy=H();function wy(t,e){let{gen:r,data:s,it:o}=t;r.if(ia(r,s,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,ee._)`${e}`},!0),t.error()})}V.checkReportMissingProp=wy;function Cy({gen:t,data:e,it:{opts:r}},s,o){return(0,ee.or)(...s.map(n=>(0,ee.and)(ia(t,e,n,r.ownProperties),(0,ee._)`${o} = ${n}`)))}V.checkMissingProp=Cy;function Iy(t,e){t.setParams({missingProperty:e},!0),t.error()}V.reportMissingProp=Iy;function Uu(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,ee._)`Object.prototype.hasOwnProperty`})}V.hasPropFunc=Uu;function na(t,e,r){return(0,ee._)`${Uu(t)}.call(${e}, ${r})`}V.isOwnProperty=na;function By(t,e,r,s){let o=(0,ee._)`${e}${(0,ee.getProperty)(r)} !== undefined`;return s?(0,ee._)`${o} && ${na(t,e,r)}`:o}V.propertyInData=By;function ia(t,e,r,s){let o=(0,ee._)`${e}${(0,ee.getProperty)(r)} === undefined`;return s?(0,ee.or)(o,(0,ee.not)(na(t,e,r))):o}V.noPropertyInData=ia;function Fu(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}V.allSchemaProperties=Fu;function Qy(t,e){return Fu(e).filter(r=>!(0,oa.alwaysValidSchema)(t,e[r]))}V.schemaProperties=Qy;function _y({schemaCode:t,data:e,it:{gen:r,topSchemaRef:s,schemaPath:o,errorPath:n},it:i},a,c,u){let l=u?(0,ee._)`${t}, ${e}, ${s}${o}`:e,d=[[Ct.default.instancePath,(0,ee.strConcat)(Ct.default.instancePath,n)],[Ct.default.parentData,i.parentData],[Ct.default.parentDataProperty,i.parentDataProperty],[Ct.default.rootData,Ct.default.rootData]];i.opts.dynamicRef&&d.push([Ct.default.dynamicAnchors,Ct.default.dynamicAnchors]);let p=(0,ee._)`${l}, ${r.object(...d)}`;return c!==ee.nil?(0,ee._)`${a}.call(${c}, ${p})`:(0,ee._)`${a}(${p})`}V.callValidateCode=_y;var Sy=(0,ee._)`new RegExp`;function ky({gen:t,it:{opts:e}},r){let s=e.unicodeRegExp?"u":"",{regExp:o}=e.code,n=o(r,s);return t.scopeValue("pattern",{key:n.toString(),ref:n,code:(0,ee._)`${o.code==="new RegExp"?Sy:(0,yy.useFunc)(t,o)}(${r}, ${s})`})}V.usePattern=ky;function My(t){let{gen:e,data:r,keyword:s,it:o}=t,n=e.name("valid");if(o.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(n,!0),i(()=>e.break()),n;function i(a){let c=e.const("len",(0,ee._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:s,dataProp:u,dataPropType:oa.Type.Num},n),e.if((0,ee.not)(n),a)})}}V.validateArray=My;function vy(t){let{gen:e,schema:r,keyword:s,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,oa.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:s,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,ee._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,ee.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}V.validateUnion=vy});var qu=Q(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});Ve.validateKeywordUsage=Ve.validSchemaType=Ve.funcKeywordCode=Ve.macroKeywordCode=void 0;var Qe=U(),Nt=nt(),by=je(),xy=us();function Ty(t,e){let{gen:r,keyword:s,schema:o,parentSchema:n,it:i}=t,a=e.macro.call(i.self,o,n,i),c=Lu(r,s,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:Qe.nil,errSchemaPath:`${i.errSchemaPath}/${s}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}Ve.macroKeywordCode=Ty;function Ry(t,e){var r;let{gen:s,keyword:o,schema:n,parentSchema:i,$data:a,it:c}=t;$y(c,e);let u=!a&&e.compile?e.compile.call(c.self,n,i,c):e.validate,l=Lu(s,o,u),d=s.let("valid");t.block$data(d,p),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function p(){if(e.errors===!1)f(),e.modifying&&Ou(t),h(()=>t.error());else{let y=e.async?m():g();e.modifying&&Ou(t),h(()=>Dy(t,y))}}function m(){let y=s.let("ruleErrs",null);return s.try(()=>f((0,Qe._)`await `),w=>s.assign(d,!1).if((0,Qe._)`${w} instanceof ${c.ValidationError}`,()=>s.assign(y,(0,Qe._)`${w}.errors`),()=>s.throw(w))),y}function g(){let y=(0,Qe._)`${l}.errors`;return s.assign(y,null),f(Qe.nil),y}function f(y=e.async?(0,Qe._)`await `:Qe.nil){let w=c.opts.passContext?Nt.default.this:Nt.default.self,I=!("compile"in e&&!a||e.schema===!1);s.assign(d,(0,Qe._)`${y}${(0,by.callValidateCode)(t,l,w,I)}`,e.modifying)}function h(y){var w;s.if((0,Qe.not)((w=e.valid)!==null&&w!==void 0?w:d),y)}}Ve.funcKeywordCode=Ry;function Ou(t){let{gen:e,data:r,it:s}=t;e.if(s.parentData,()=>e.assign(r,(0,Qe._)`${s.parentData}[${s.parentDataProperty}]`))}function Dy(t,e){let{gen:r}=t;r.if((0,Qe._)`Array.isArray(${e})`,()=>{r.assign(Nt.default.vErrors,(0,Qe._)`${Nt.default.vErrors} === null ? ${e} : ${Nt.default.vErrors}.concat(${e})`).assign(Nt.default.errors,(0,Qe._)`${Nt.default.vErrors}.length`),(0,xy.extendErrors)(t)},()=>t.error())}function $y({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Lu(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Qe.stringify)(r)})}function Py(t,e,r=!1){return!e.length||e.some(s=>s==="array"?Array.isArray(t):s==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==s||r&&typeof t>"u")}Ve.validSchemaType=Py;function jy({schema:t,opts:e,self:r,errSchemaPath:s},o,n){if(Array.isArray(o.keyword)?!o.keyword.includes(n):o.keyword!==n)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${n}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[n])){let c=`keyword "${n}" value is invalid at path "${s}": `+r.errorsText(o.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}Ve.validateKeywordUsage=jy});var Hu=Q(It=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});It.extendSubschemaMode=It.extendSubschemaData=It.getSubschema=void 0;var Ke=U(),Gu=H();function Ny(t,{keyword:e,schemaProp:r,schema:s,schemaPath:o,errSchemaPath:n,topSchemaRef:i}){if(e!==void 0&&s!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,Ke._)`${t.schemaPath}${(0,Ke.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Ke._)`${t.schemaPath}${(0,Ke.getProperty)(e)}${(0,Ke.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Gu.escapeFragment)(r)}`}}if(s!==void 0){if(o===void 0||n===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:s,schemaPath:o,topSchemaRef:i,errSchemaPath:n}}throw new Error('either "keyword" or "schema" must be passed')}It.getSubschema=Ny;function zy(t,e,{dataProp:r,dataPropType:s,data:o,dataTypes:n,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=e,p=a.let("data",(0,Ke._)`${e.data}${(0,Ke.getProperty)(r)}`,!0);c(p),t.errorPath=(0,Ke.str)`${u}${(0,Gu.getErrorPath)(r,s,d.jsPropertySyntax)}`,t.parentDataProperty=(0,Ke._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof Ke.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(t.propertyName=i)}n&&(t.dataTypes=n);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}It.extendSubschemaData=zy;function Uy(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:s,createErrors:o,allErrors:n}){s!==void 0&&(t.compositeRule=s),o!==void 0&&(t.createErrors=o),n!==void 0&&(t.allErrors=n),t.jtdDiscriminator=e,t.jtdMetadata=r}It.extendSubschemaMode=Uy});var aa=Q((CT,Yu)=>{"use strict";Yu.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var s,o,n;if(Array.isArray(e)){if(s=e.length,s!=r.length)return!1;for(o=s;o--!==0;)if(!t(e[o],r[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(n=Object.keys(e),s=n.length,s!==Object.keys(r).length)return!1;for(o=s;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,n[o]))return!1;for(o=s;o--!==0;){var i=n[o];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var Wu=Q((IT,Ju)=>{"use strict";var Bt=Ju.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var s=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};zo(e,s,o,t,"",t)};Bt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Bt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Bt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Bt.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function zo(t,e,r,s,o,n,i,a,c,u){if(s&&typeof s=="object"&&!Array.isArray(s)){e(s,o,n,i,a,c,u);for(var l in s){var d=s[l];if(Array.isArray(d)){if(l in Bt.arrayKeywords)for(var p=0;p<d.length;p++)zo(t,e,r,d[p],o+"/"+l+"/"+p,n,o,l,s,p)}else if(l in Bt.propsKeywords){if(d&&typeof d=="object")for(var m in d)zo(t,e,r,d[m],o+"/"+l+"/"+Fy(m),n,o,l,s,m)}else(l in Bt.keywords||t.allKeys&&!(l in Bt.skipKeywords))&&zo(t,e,r,d,o+"/"+l,n,o,l,s)}r(s,o,n,i,a,c,u)}}function Fy(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var As=Q(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.getSchemaRefs=ve.resolveUrl=ve.normalizeId=ve._getFullPath=ve.getFullPath=ve.inlineRef=void 0;var Oy=H(),Ly=aa(),qy=Wu(),Gy=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Hy(t,e=!0){return typeof t=="boolean"?!0:e===!0?!ca(t):e?Vu(t)<=e:!1}ve.inlineRef=Hy;var Yy=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function ca(t){for(let e in t){if(Yy.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(ca)||typeof r=="object"&&ca(r))return!0}return!1}function Vu(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!Gy.has(r)&&(typeof t[r]=="object"&&(0,Oy.eachItem)(t[r],s=>e+=Vu(s)),e===1/0))return 1/0}return e}function Ku(t,e="",r){r!==!1&&(e=Ar(e));let s=t.parse(e);return Zu(t,s)}ve.getFullPath=Ku;function Zu(t,e){return t.serialize(e).split("#")[0]+"#"}ve._getFullPath=Zu;var Jy=/#\/?$/;function Ar(t){return t?t.replace(Jy,""):""}ve.normalizeId=Ar;function Wy(t,e,r){return r=Ar(r),t.resolve(e,r)}ve.resolveUrl=Wy;var Vy=/^[a-z_][-a-z0-9._]*$/i;function Ky(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:s}=this.opts,o=Ar(t[r]||e),n={"":o},i=Ku(s,o,!1),a={},c=new Set;return qy(t,{allKeys:!0},(d,p,m,g)=>{if(g===void 0)return;let f=i+p,h=n[g];typeof d[r]=="string"&&(h=y.call(this,d[r])),w.call(this,d.$anchor),w.call(this,d.$dynamicAnchor),n[p]=h;function y(I){let v=this.opts.uriResolver.resolve;if(I=Ar(h?v(h,I):I),c.has(I))throw l(I);c.add(I);let E=this.refs[I];return typeof E=="string"&&(E=this.refs[E]),typeof E=="object"?u(d,E.schema,I):I!==Ar(f)&&(I[0]==="#"?(u(d,a[I],I),a[I]=d):this.refs[I]=f),I}function w(I){if(typeof I=="string"){if(!Vy.test(I))throw new Error(`invalid anchor "${I}"`);y.call(this,`#${I}`)}}}),a;function u(d,p,m){if(p!==void 0&&!Ly(d,p))throw l(m)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}ve.getSchemaRefs=Ky});var fs=Q(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.getData=Qt.KeywordCxt=Qt.validateFunctionCode=void 0;var sd=Tu(),Xu=ds(),ua=ea(),Uo=ds(),Zy=zu(),ms=qu(),la=Hu(),x=U(),j=nt(),Xy=As(),it=H(),ps=us();function ew(t){if(id(t)&&(ad(t),nd(t))){sw(t);return}od(t,()=>(0,sd.topBoolOrEmptySchema)(t))}Qt.validateFunctionCode=ew;function od({gen:t,validateName:e,schema:r,schemaEnv:s,opts:o},n){o.code.es5?t.func(e,(0,x._)`${j.default.data}, ${j.default.valCxt}`,s.$async,()=>{t.code((0,x._)`"use strict"; ${ed(r,o)}`),rw(t,o),t.code(n)}):t.func(e,(0,x._)`${j.default.data}, ${tw(o)}`,s.$async,()=>t.code(ed(r,o)).code(n))}function tw(t){return(0,x._)`{${j.default.instancePath}="", ${j.default.parentData}, ${j.default.parentDataProperty}, ${j.default.rootData}=${j.default.data}${t.dynamicRef?(0,x._)`, ${j.default.dynamicAnchors}={}`:x.nil}}={}`}function rw(t,e){t.if(j.default.valCxt,()=>{t.var(j.default.instancePath,(0,x._)`${j.default.valCxt}.${j.default.instancePath}`),t.var(j.default.parentData,(0,x._)`${j.default.valCxt}.${j.default.parentData}`),t.var(j.default.parentDataProperty,(0,x._)`${j.default.valCxt}.${j.default.parentDataProperty}`),t.var(j.default.rootData,(0,x._)`${j.default.valCxt}.${j.default.rootData}`),e.dynamicRef&&t.var(j.default.dynamicAnchors,(0,x._)`${j.default.valCxt}.${j.default.dynamicAnchors}`)},()=>{t.var(j.default.instancePath,(0,x._)`""`),t.var(j.default.parentData,(0,x._)`undefined`),t.var(j.default.parentDataProperty,(0,x._)`undefined`),t.var(j.default.rootData,j.default.data),e.dynamicRef&&t.var(j.default.dynamicAnchors,(0,x._)`{}`)})}function sw(t){let{schema:e,opts:r,gen:s}=t;od(t,()=>{r.$comment&&e.$comment&&ld(t),cw(t),s.let(j.default.vErrors,null),s.let(j.default.errors,0),r.unevaluated&&ow(t),cd(t),dw(t)})}function ow(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,x._)`${r}.evaluated`),e.if((0,x._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,x._)`${t.evaluated}.props`,(0,x._)`undefined`)),e.if((0,x._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,x._)`${t.evaluated}.items`,(0,x._)`undefined`))}function ed(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,x._)`/*# sourceURL=${r} */`:x.nil}function nw(t,e){if(id(t)&&(ad(t),nd(t))){iw(t,e);return}(0,sd.boolOrEmptySchema)(t,e)}function nd({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function id(t){return typeof t.schema!="boolean"}function iw(t,e){let{schema:r,gen:s,opts:o}=t;o.$comment&&r.$comment&&ld(t),lw(t),uw(t);let n=s.const("_errs",j.default.errors);cd(t,n),s.var(e,(0,x._)`${n} === ${j.default.errors}`)}function ad(t){(0,it.checkUnknownRules)(t),aw(t)}function cd(t,e){if(t.opts.jtd)return td(t,[],!1,e);let r=(0,Xu.getSchemaTypes)(t.schema),s=(0,Xu.coerceAndCheckDataType)(t,r);td(t,r,!s,e)}function aw(t){let{schema:e,errSchemaPath:r,opts:s,self:o}=t;e.$ref&&s.ignoreKeywordsWithRef&&(0,it.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function cw(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,it.checkStrictMode)(t,"default is ignored in the schema root")}function lw(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,Xy.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function uw(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function ld({gen:t,schemaEnv:e,schema:r,errSchemaPath:s,opts:o}){let n=r.$comment;if(o.$comment===!0)t.code((0,x._)`${j.default.self}.logger.log(${n})`);else if(typeof o.$comment=="function"){let i=(0,x.str)`${s}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,x._)`${j.default.self}.opts.$comment(${n}, ${i}, ${a}.schema)`)}}function dw(t){let{gen:e,schemaEnv:r,validateName:s,ValidationError:o,opts:n}=t;r.$async?e.if((0,x._)`${j.default.errors} === 0`,()=>e.return(j.default.data),()=>e.throw((0,x._)`new ${o}(${j.default.vErrors})`)):(e.assign((0,x._)`${s}.errors`,j.default.vErrors),n.unevaluated&&Aw(t),e.return((0,x._)`${j.default.errors} === 0`))}function Aw({gen:t,evaluated:e,props:r,items:s}){r instanceof x.Name&&t.assign((0,x._)`${e}.props`,r),s instanceof x.Name&&t.assign((0,x._)`${e}.items`,s)}function td(t,e,r,s){let{gen:o,schema:n,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(n.$ref&&(c.ignoreKeywordsWithRef||!(0,it.schemaHasRulesButRef)(n,l))){o.block(()=>dd(t,"$ref",l.all.$ref.definition));return}c.jtd||pw(t,e),o.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,ua.shouldUseGroup)(n,p)&&(p.type?(o.if((0,Uo.checkDataType)(p.type,i,c.strictNumbers)),rd(t,p),e.length===1&&e[0]===p.type&&r&&(o.else(),(0,Uo.reportTypeError)(t)),o.endIf()):rd(t,p),a||o.if((0,x._)`${j.default.errors} === ${s||0}`))}}function rd(t,e){let{gen:r,schema:s,opts:{useDefaults:o}}=t;o&&(0,Zy.assignDefaults)(t,e.type),r.block(()=>{for(let n of e.rules)(0,ua.shouldUseRule)(s,n)&&dd(t,n.keyword,n.definition,e.type)})}function pw(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(mw(t,e),t.opts.allowUnionTypes||fw(t,e),gw(t,t.dataTypes))}function mw(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{ud(t.dataTypes,r)||da(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),Ew(t,e)}}function fw(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&da(t,"use allowUnionTypes to allow union type keyword")}function gw(t,e){let r=t.self.RULES.all;for(let s in r){let o=r[s];if(typeof o=="object"&&(0,ua.shouldUseRule)(t.schema,o)){let{type:n}=o.definition;n.length&&!n.some(i=>hw(e,i))&&da(t,`missing type "${n.join(",")}" for keyword "${s}"`)}}}function hw(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function ud(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function Ew(t,e){let r=[];for(let s of t.dataTypes)ud(e,s)?r.push(s):e.includes("integer")&&s==="number"&&r.push("integer");t.dataTypes=r}function da(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,it.checkStrictMode)(t,e,t.opts.strictTypes)}var Fo=class{constructor(e,r,s){if((0,ms.validateKeywordUsage)(e,r,s),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=s,this.data=e.data,this.schema=e.schema[s],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,it.schemaRefOrVal)(e,this.schema,s,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",Ad(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,ms.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${s} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",j.default.errors))}result(e,r,s){this.failResult((0,x.not)(e),r,s)}failResult(e,r,s){this.gen.if(e),s?s():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,x.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,x._)`${r} !== undefined && (${(0,x.or)(this.invalid$data(),e)})`)}error(e,r,s){if(r){this.setParams(r),this._error(e,s),this.setParams({});return}this._error(e,s)}_error(e,r){(e?ps.reportExtraError:ps.reportError)(this,this.def.error,r)}$dataError(){(0,ps.reportError)(this,this.def.$dataError||ps.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,ps.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,s=x.nil){this.gen.block(()=>{this.check$data(e,s),r()})}check$data(e=x.nil,r=x.nil){if(!this.$data)return;let{gen:s,schemaCode:o,schemaType:n,def:i}=this;s.if((0,x.or)((0,x._)`${o} === undefined`,r)),e!==x.nil&&s.assign(e,!0),(n.length||i.validateSchema)&&(s.elseIf(this.invalid$data()),this.$dataError(),e!==x.nil&&s.assign(e,!1)),s.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:s,def:o,it:n}=this;return(0,x.or)(i(),a());function i(){if(s.length){if(!(r instanceof x.Name))throw new Error("ajv implementation error");let c=Array.isArray(s)?s:[s];return(0,x._)`${(0,Uo.checkDataTypes)(c,r,n.opts.strictNumbers,Uo.DataType.Wrong)}`}return x.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,x._)`!${c}(${r})`}return x.nil}}subschema(e,r){let s=(0,la.getSubschema)(this.it,e);(0,la.extendSubschemaData)(s,this.it,e),(0,la.extendSubschemaMode)(s,e);let o={...this.it,...s,items:void 0,props:void 0};return nw(o,r),o}mergeEvaluated(e,r){let{it:s,gen:o}=this;s.opts.unevaluated&&(s.props!==!0&&e.props!==void 0&&(s.props=it.mergeEvaluated.props(o,e.props,s.props,r)),s.items!==!0&&e.items!==void 0&&(s.items=it.mergeEvaluated.items(o,e.items,s.items,r)))}mergeValidEvaluated(e,r){let{it:s,gen:o}=this;if(s.opts.unevaluated&&(s.props!==!0||s.items!==!0))return o.if(r,()=>this.mergeEvaluated(e,x.Name)),!0}};Qt.KeywordCxt=Fo;function dd(t,e,r,s){let o=new Fo(t,r,e);"code"in r?r.code(o,s):o.$data&&r.validate?(0,ms.funcKeywordCode)(o,r):"macro"in r?(0,ms.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,ms.funcKeywordCode)(o,r)}var yw=/^\/(?:[^~]|~0|~1)*$/,ww=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Ad(t,{dataLevel:e,dataNames:r,dataPathArr:s}){let o,n;if(t==="")return j.default.rootData;if(t[0]==="/"){if(!yw.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,n=j.default.rootData}else{let u=ww.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=e)throw new Error(c("property/index",l));return s[e-l]}if(l>e)throw new Error(c("data",l));if(n=r[e-l],!o)return n}let i=n,a=o.split("/");for(let u of a)u&&(n=(0,x._)`${n}${(0,x.getProperty)((0,it.unescapeJsonPointer)(u))}`,i=(0,x._)`${i} && ${n}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}Qt.getData=Ad});var Oo=Q(pa=>{"use strict";Object.defineProperty(pa,"__esModule",{value:!0});var Aa=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};pa.default=Aa});var gs=Q(ga=>{"use strict";Object.defineProperty(ga,"__esModule",{value:!0});var ma=As(),fa=class extends Error{constructor(e,r,s,o){super(o||`can't resolve reference ${s} from id ${r}`),this.missingRef=(0,ma.resolveUrl)(e,r,s),this.missingSchema=(0,ma.normalizeId)((0,ma.getFullPath)(e,this.missingRef))}};ga.default=fa});var qo=Q(Ne=>{"use strict";Object.defineProperty(Ne,"__esModule",{value:!0});Ne.resolveSchema=Ne.getCompilingSchema=Ne.resolveRef=Ne.compileSchema=Ne.SchemaEnv=void 0;var Oe=U(),Cw=Oo(),zt=nt(),Le=As(),pd=H(),Iw=fs(),pr=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let s;typeof e.schema=="object"&&(s=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,Le.normalizeId)(s?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=s?.$async,this.refs={}}};Ne.SchemaEnv=pr;function Ea(t){let e=md.call(this,t);if(e)return e;let r=(0,Le.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:s,lines:o}=this.opts.code,{ownProperties:n}=this.opts,i=new Oe.CodeGen(this.scope,{es5:s,lines:o,ownProperties:n}),a;t.$async&&(a=i.scopeValue("Error",{ref:Cw.default,code:(0,Oe._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:zt.default.data,parentData:zt.default.parentData,parentDataProperty:zt.default.parentDataProperty,dataNames:[zt.default.data],dataPathArr:[Oe.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,Oe.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:Oe.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Oe._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,Iw.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(zt.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let m=new Function(`${zt.default.self}`,`${zt.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:m}),m.errors=null,m.schema=t.schema,m.schemaEnv=t,t.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:g,items:f}=u;m.evaluated={props:g instanceof Oe.Name?void 0:g,items:f instanceof Oe.Name?void 0:f,dynamicProps:g instanceof Oe.Name,dynamicItems:f instanceof Oe.Name},m.source&&(m.source.evaluated=(0,Oe.stringify)(m.evaluated))}return t.validate=m,t}catch(d){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(t)}}Ne.compileSchema=Ea;function Bw(t,e,r){var s;r=(0,Le.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let n=Sw.call(this,t,r);if(n===void 0){let i=(s=t.localRefs)===null||s===void 0?void 0:s[r],{schemaId:a}=this.opts;i&&(n=new pr({schema:i,schemaId:a,root:t,baseId:e}))}if(n!==void 0)return t.refs[r]=Qw.call(this,n)}Ne.resolveRef=Bw;function Qw(t){return(0,Le.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Ea.call(this,t)}function md(t){for(let e of this._compilations)if(_w(e,t))return e}Ne.getCompilingSchema=md;function _w(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Sw(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Lo.call(this,t,e)}function Lo(t,e){let r=this.opts.uriResolver.parse(e),s=(0,Le._getFullPath)(this.opts.uriResolver,r),o=(0,Le.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&s===o)return ha.call(this,r,t);let n=(0,Le.normalizeId)(s),i=this.refs[n]||this.schemas[n];if(typeof i=="string"){let a=Lo.call(this,t,i);return typeof a?.schema!="object"?void 0:ha.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Ea.call(this,i),n===(0,Le.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,Le.resolveUrl)(this.opts.uriResolver,o,u)),new pr({schema:a,schemaId:c,root:t,baseId:o})}return ha.call(this,r,i)}}Ne.resolveSchema=Lo;var kw=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function ha(t,{baseId:e,schema:r,root:s}){var o;if(((o=t.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,pd.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!kw.has(a)&&u&&(e=(0,Le.resolveUrl)(this.opts.uriResolver,e,u))}let n;if(typeof r!="boolean"&&r.$ref&&!(0,pd.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Le.resolveUrl)(this.opts.uriResolver,e,r.$ref);n=Lo.call(this,s,a)}let{schemaId:i}=this.opts;if(n=n||new pr({schema:r,schemaId:i,root:s,baseId:e}),n.schema!==n.root.schema)return n}});var fd=Q((MT,Mw)=>{Mw.exports={$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}});var Ca=Q((vT,Cd)=>{"use strict";var vw=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),hd=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),ya=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Ed=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),bw=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function wa(t){let e="",r=0,s=0;for(s=0;s<t.length;s++)if(r=t[s].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[s];break}for(s+=1;s<t.length;s++){if(r=t[s].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[s]}return e}var xw=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function gd(t){return t.length=0,!0}function Tw(t,e,r){if(t.length){let s=wa(t);if(s!=="")e.push(s);else return r.error=!0,!1;t.length=0}return!0}function Rw(t){let e=0,r={error:!1,address:"",zone:""},s=[],o=[],n=!1,i=!1,a=Tw;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(n===!0&&(i=!0),!a(o,s,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(n=!0),s.push(":");continue}else if(u==="%"){if(!a(o,s,r))break;a=gd}else{o.push(u);continue}}return o.length&&(a===gd?r.zone=o.join(""):i?s.push(o.join("")):s.push(wa(o))),r.address=s.join(""),r}function yd(t){if(Dw(t,":")<2)return{host:t,isIPV6:!1};let e=Rw(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,s=e.address;return e.zone&&(r+="%"+e.zone,s+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:s}}}function Dw(t,e){let r=0;for(let s=0;s<t.length;s++)t[s]===e&&r++;return r}function $w(t){let e=t,r=[],s=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((s=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,s)),e=e.slice(s)}return r.join("")}var Pw={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},jw=/[@/?#:]/g,Nw=/[@/?#]/g;function wd(t,e){let r=e?Nw:jw;return r.lastIndex=0,t.replace(r,s=>Pw[s])}function zw(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let s=0;s<t.length;s++){if(t[s]==="%"&&s+2<t.length){let o=t.slice(s+1,s+3);if(ya(o)){let n=o.toUpperCase(),i=String.fromCharCode(parseInt(n,16));e&&Ed(i)?r+=i:r+="%"+n,s+=2;continue}}r+=t[s]}return r}function Uw(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let s=t.slice(r+1,r+3);if(ya(s)){let o=s.toUpperCase(),n=String.fromCharCode(parseInt(o,16));n!=="."&&Ed(n)?e+=n:e+="%"+o,r+=2;continue}}bw(t[r])?e+=t[r]:e+=escape(t[r])}return e}function Fw(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let s=t.slice(r+1,r+3);if(ya(s)){e+="%"+s.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function Ow(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!hd(r)){let s=yd(r);s.isIPV6===!0?r=`[${s.escapedHost}]`:r=wd(r,!1)}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}Cd.exports={nonSimpleDomain:xw,recomposeAuthority:Ow,reescapeHostDelimiters:wd,normalizePercentEncoding:zw,normalizePathEncoding:Uw,escapePreservingEscapes:Fw,removeDotSegments:$w,isIPv4:hd,isUUID:vw,normalizeIPv6:yd,stringArrayToHexStripped:wa}});var Sd=Q((bT,_d)=>{"use strict";var{isUUID:Lw}=Ca(),qw=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,Gw=["http","https","ws","wss","urn","urn:uuid"];function Hw(t){return Gw.indexOf(t)!==-1}function Ia(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function Id(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function Bd(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function Yw(t){return t.secure=Ia(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function Jw(t){if((t.port===(Ia(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function Ww(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(qw);if(r){let s=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${s}:${e.nid||t.nid}`,n=Ba(o);t.path=void 0,n&&(t=n.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function Vw(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",s=t.nid.toLowerCase(),o=`${r}:${e.nid||s}`,n=Ba(o);n&&(t=n.serialize(t,e));let i=t,a=t.nss;return i.path=`${s||e.nid}:${a}`,e.skipEscape=!0,i}function Kw(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!Lw(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Zw(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var Qd={scheme:"http",domainHost:!0,parse:Id,serialize:Bd},Xw={scheme:"https",domainHost:Qd.domainHost,parse:Id,serialize:Bd},Go={scheme:"ws",domainHost:!0,parse:Yw,serialize:Jw},eC={scheme:"wss",domainHost:Go.domainHost,parse:Go.parse,serialize:Go.serialize},tC={scheme:"urn",parse:Ww,serialize:Vw,skipNormalize:!0},rC={scheme:"urn:uuid",parse:Kw,serialize:Zw,skipNormalize:!0},Ho={http:Qd,https:Xw,ws:Go,wss:eC,urn:tC,"urn:uuid":rC};Object.setPrototypeOf(Ho,null);function Ba(t){return t&&(Ho[t]||Ho[t.toLowerCase()])||void 0}_d.exports={wsIsSecure:Ia,SCHEMES:Ho,isValidSchemeName:Hw,getSchemeHandler:Ba}});var Td=Q((xT,Yo)=>{"use strict";var{normalizeIPv6:sC,removeDotSegments:hs,recomposeAuthority:oC,normalizePercentEncoding:nC,normalizePathEncoding:iC,escapePreservingEscapes:aC,reescapeHostDelimiters:cC,isIPv4:lC,nonSimpleDomain:uC}=Ca(),{SCHEMES:dC,getSchemeHandler:Md}=Sd();function AC(t,e){return typeof t=="string"?t=EC(t,e):typeof t=="object"&&(t=mr(Ut(t,e),e)),t}function pC(t,e,r){let s=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=vd(mr(t,s),mr(e,s),s,!0);return s.skipEscape=!0,Ut(o,s)}function vd(t,e,r,s){let o={};return s||(t=mr(Ut(t,r),r),e=mr(Ut(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=hs(e.path||""),o.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=hs(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=hs(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?o.path="/"+e.path:t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path,o.path=hs(o.path)),o.query=e.query):(o.path=t.path,e.query!==void 0?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function mC(t,e,r){let s=kd(t,r),o=kd(e,r);return s!==void 0&&o!==void 0&&s.toLowerCase()===o.toLowerCase()}function Ut(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},s=Object.assign({},e),o=[],n=Md(s.scheme||r.scheme);n&&n.serialize&&n.serialize(r,s),r.path!==void 0&&(s.skipEscape?r.path=nC(r.path):(r.path=aC(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),s.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=oC(r);if(i!==void 0&&(s.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!s.absolutePath&&(!n||!n.absolutePath)&&(a=hs(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var fC=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,gC=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/;function hC(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function bd(t,e){let r=Object.assign({},e),s={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,n=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let i=t.match(gC);i!==null&&i[1].indexOf("\\")!==-1&&(s.error="URI authority must not contain a literal backslash.",o=!0);let a=t.match(fC);if(a){s.scheme=a[1],s.userinfo=a[3],s.host=a[4],s.port=parseInt(a[5],10),s.path=a[6]||"",s.query=a[7],s.fragment=a[8],isNaN(s.port)&&(s.port=a[5]);let c=hC(s,a);if(c!==void 0&&(s.error=s.error||c,o=!0),s.host)if(lC(s.host)===!1){let d=sC(s.host);s.host=d.host.toLowerCase(),n=d.isIPV6}else n=!0;s.scheme===void 0&&s.userinfo===void 0&&s.host===void 0&&s.port===void 0&&s.query===void 0&&!s.path?s.reference="same-document":s.scheme===void 0?s.reference="relative":s.fragment===void 0?s.reference="absolute":s.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==s.reference&&(s.error=s.error||"URI is not a "+r.reference+" reference.");let u=Md(r.scheme||s.scheme);if(!r.unicodeSupport&&(!u||!u.unicodeSupport)&&s.host&&(r.domainHost||u&&u.domainHost)&&n===!1&&uC(s.host))try{s.host=new URL("http://"+s.host).hostname}catch(l){s.error=s.error||"Host's domain name can not be converted to ASCII: "+l}if((!u||u&&!u.skipNormalize)&&(t.indexOf("%")!==-1&&(s.scheme!==void 0&&(s.scheme=unescape(s.scheme)),s.host!==void 0&&(s.host=cC(unescape(s.host),n))),s.path&&(s.path=iC(s.path)),s.fragment))try{s.fragment=encodeURI(decodeURIComponent(s.fragment))}catch{s.error=s.error||"URI malformed"}u&&u.parse&&u.parse(s,r)}else s.error=s.error||"URI can not be parsed.";return{parsed:s,malformedAuthorityOrPort:o}}function mr(t,e){return bd(t,e).parsed}function EC(t,e){return xd(t,e).normalized}function xd(t,e){let{parsed:r,malformedAuthorityOrPort:s}=bd(t,e);return{normalized:s?t:Ut(r,e),malformedAuthorityOrPort:s}}function kd(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:s}=xd(t,e);return s?void 0:r}if(typeof t=="object")return Ut(t,e)}var Qa={SCHEMES:dC,normalize:AC,resolve:pC,resolveComponent:vd,equal:mC,serialize:Ut,parse:mr};Yo.exports=Qa;Yo.exports.default=Qa;Yo.exports.fastUri=Qa});var Dd=Q(_a=>{"use strict";Object.defineProperty(_a,"__esModule",{value:!0});var Rd=Td();Rd.code='require("ajv/dist/runtime/uri").default';_a.default=Rd});var Od=Q(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.CodeGen=ge.Name=ge.nil=ge.stringify=ge.str=ge._=ge.KeywordCxt=void 0;var yC=fs();Object.defineProperty(ge,"KeywordCxt",{enumerable:!0,get:function(){return yC.KeywordCxt}});var fr=U();Object.defineProperty(ge,"_",{enumerable:!0,get:function(){return fr._}});Object.defineProperty(ge,"str",{enumerable:!0,get:function(){return fr.str}});Object.defineProperty(ge,"stringify",{enumerable:!0,get:function(){return fr.stringify}});Object.defineProperty(ge,"nil",{enumerable:!0,get:function(){return fr.nil}});Object.defineProperty(ge,"Name",{enumerable:!0,get:function(){return fr.Name}});Object.defineProperty(ge,"CodeGen",{enumerable:!0,get:function(){return fr.CodeGen}});var wC=Oo(),zd=gs(),CC=Xi(),Es=qo(),IC=U(),ys=As(),Jo=ds(),ka=H(),$d=fd(),BC=Dd(),Ud=(t,e)=>new RegExp(t,e);Ud.code="new RegExp";var QC=["removeAdditional","useDefaults","coerceTypes"],_C=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),SC={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."},kC={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Pd=200;function MC(t){var e,r,s,o,n,i,a,c,u,l,d,p,m,g,f,h,y,w,I,v,E,B,M,z,D;let ce=t.strict,qr=(e=t.code)===null||e===void 0?void 0:e.optimize,ao=qr===!0||qr===void 0?1:qr||0,co=(s=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&s!==void 0?s:Ud,mt=(o=t.uriResolver)!==null&&o!==void 0?o:BC.default;return{strictSchema:(i=(n=t.strictSchema)!==null&&n!==void 0?n:ce)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:ce)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:ce)!==null&&l!==void 0?l:"log",strictTuples:(p=(d=t.strictTuples)!==null&&d!==void 0?d:ce)!==null&&p!==void 0?p:"log",strictRequired:(g=(m=t.strictRequired)!==null&&m!==void 0?m:ce)!==null&&g!==void 0?g:!1,code:t.code?{...t.code,optimize:ao,regExp:co}:{optimize:ao,regExp:co},loopRequired:(f=t.loopRequired)!==null&&f!==void 0?f:Pd,loopEnum:(h=t.loopEnum)!==null&&h!==void 0?h:Pd,meta:(y=t.meta)!==null&&y!==void 0?y:!0,messages:(w=t.messages)!==null&&w!==void 0?w:!0,inlineRefs:(I=t.inlineRefs)!==null&&I!==void 0?I:!0,schemaId:(v=t.schemaId)!==null&&v!==void 0?v:"$id",addUsedSchema:(E=t.addUsedSchema)!==null&&E!==void 0?E:!0,validateSchema:(B=t.validateSchema)!==null&&B!==void 0?B:!0,validateFormats:(M=t.validateFormats)!==null&&M!==void 0?M:!0,unicodeRegExp:(z=t.unicodeRegExp)!==null&&z!==void 0?z:!0,int32range:(D=t.int32range)!==null&&D!==void 0?D:!0,uriResolver:mt}}var ws=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...MC(e)};let{es5:r,lines:s}=this.opts.code;this.scope=new IC.ValueScope({scope:{},prefixes:_C,es5:r,lines:s}),this.logger=DC(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,CC.getRules)(),jd.call(this,SC,e,"NOT SUPPORTED"),jd.call(this,kC,e,"DEPRECATED","warn"),this._metaOpts=TC.call(this),e.formats&&bC.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&xC.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),vC.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:s}=this.opts,o=$d;s==="id"&&(o={...$d},o.id=o.$id,delete o.$id),r&&e&&this.addMetaSchema(o,o[s],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let s;if(typeof e=="string"){if(s=this.getSchema(e),!s)throw new Error(`no schema with key or ref "${e}"`)}else s=this.compile(e);let o=s(r);return"$async"in s||(this.errors=s.errors),o}compile(e,r){let s=this._addSchema(e,r);return s.validate||this._compileSchemaEnv(s)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:s}=this.opts;return o.call(this,e,r);async function o(l,d){await n.call(this,l.$schema);let p=this._addSchema(l,d);return p.validate||i.call(this,p)}async function n(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof zd.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await n.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=s(l))}finally{delete this._loading[l]}}}addSchema(e,r,s,o=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,s,o);return this}let n;if(typeof e=="object"){let{schemaId:i}=this.opts;if(n=e[i],n!==void 0&&typeof n!="string")throw new Error(`schema ${i} must be string`)}return r=(0,ys.normalizeId)(r||n),this._checkUnique(r),this.schemas[r]=this._addSchema(e,s,r,o,!0),this}addMetaSchema(e,r,s=this.opts.validateSchema){return this.addSchema(e,r,!0,s),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let s;if(s=e.$schema,s!==void 0&&typeof s!="string")throw new Error("$schema must be a string");if(s=s||this.opts.defaultMeta||this.defaultMeta(),!s)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(s,e);if(!o&&r){let n="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(n);else throw new Error(n)}return o}getSchema(e){let r;for(;typeof(r=Nd.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:s}=this.opts,o=new Es.SchemaEnv({schema:{},schemaId:s});if(r=Es.resolveSchema.call(this,o,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}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":{let r=Nd.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let s=e[this.opts.schemaId];return s&&(s=(0,ys.normalizeId)(s),delete this.schemas[s],delete this.refs[s]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let s;if(typeof e=="string")s=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=s);else if(typeof e=="object"&&r===void 0){if(r=e,s=r.keyword,Array.isArray(s)&&!s.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(PC.call(this,s,r),!r)return(0,ka.eachItem)(s,n=>Sa.call(this,n)),this;NC.call(this,r);let o={...r,type:(0,Jo.getJSONTypes)(r.type),schemaType:(0,Jo.getJSONTypes)(r.schemaType)};return(0,ka.eachItem)(s,o.type.length===0?n=>Sa.call(this,n,o):n=>o.type.forEach(i=>Sa.call(this,n,o,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let s of r.rules){let o=s.rules.findIndex(n=>n.keyword===e);o>=0&&s.rules.splice(o,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:s="data"}={}){return!e||e.length===0?"No errors":e.map(o=>`${s}${o.instancePath} ${o.message}`).reduce((o,n)=>o+r+n)}$dataMetaSchema(e,r){let s=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let o of r){let n=o.split("/").slice(1),i=e;for(let a of n)i=i[a];for(let a in s){let c=s[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=Fd(l))}}return e}_removeAllSchemas(e,r){for(let s in e){let o=e[s];(!r||r.test(s))&&(typeof o=="string"?delete e[s]:o&&!o.meta&&(this._cache.delete(o.schema),delete e[s]))}}_addSchema(e,r,s,o=this.opts.validateSchema,n=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;s=(0,ys.normalizeId)(i||s);let u=ys.getSchemaRefs.call(this,e,s);return c=new Es.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:s,localRefs:u}),this._cache.set(c.schema,c),n&&!s.startsWith("#")&&(s&&this._checkUnique(s),this.refs[s]=c),o&&this.validateSchema(e,!0),c}_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):Es.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{Es.compileSchema.call(this,e)}finally{this.opts=r}}};ws.ValidationError=wC.default;ws.MissingRefError=zd.default;ge.default=ws;function jd(t,e,r,s="error"){for(let o in t){let n=o;n in e&&this.logger[s](`${r}: option ${o}. ${t[n]}`)}}function Nd(t){return t=(0,ys.normalizeId)(t),this.schemas[t]||this.refs[t]}function vC(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function bC(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function xC(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function TC(){let t={...this.opts};for(let e of QC)delete t[e];return t}var RC={log(){},warn(){},error(){}};function DC(t){if(t===!1)return RC;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var $C=/^[a-z_$][a-z0-9_$:-]*$/i;function PC(t,e){let{RULES:r}=this;if((0,ka.eachItem)(t,s=>{if(r.keywords[s])throw new Error(`Keyword ${s} is already defined`);if(!$C.test(s))throw new Error(`Keyword ${s} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function Sa(t,e,r){var s;let o=e?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:n}=this,i=o?n.post:n.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},n.rules.push(i)),n.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,Jo.getJSONTypes)(e.type),schemaType:(0,Jo.getJSONTypes)(e.schemaType)}};e.before?jC.call(this,i,a,e.before):i.rules.push(a),n.all[t]=a,(s=e.implements)===null||s===void 0||s.forEach(c=>this.addKeyword(c))}function jC(t,e,r){let s=t.rules.findIndex(o=>o.keyword===r);s>=0?t.rules.splice(s,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function NC(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=Fd(e)),t.validateSchema=this.compile(e,!0))}var zC={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Fd(t){return{anyOf:[t,zC]}}});var Ld=Q(Ma=>{"use strict";Object.defineProperty(Ma,"__esModule",{value:!0});var UC={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Ma.default=UC});var Yd=Q(Ft=>{"use strict";Object.defineProperty(Ft,"__esModule",{value:!0});Ft.callRef=Ft.getValidate=void 0;var FC=gs(),qd=je(),be=U(),gr=nt(),Gd=qo(),Wo=H(),OC={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:s}=t,{baseId:o,schemaEnv:n,validateName:i,opts:a,self:c}=s,{root:u}=n;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=Gd.resolveRef.call(c,u,o,r);if(l===void 0)throw new FC.default(s.opts.uriResolver,o,r);if(l instanceof Gd.SchemaEnv)return p(l);return m(l);function d(){if(n===u)return Vo(t,i,n,n.$async);let g=e.scopeValue("root",{ref:u});return Vo(t,(0,be._)`${g}.validate`,u,u.$async)}function p(g){let f=Hd(t,g);Vo(t,f,g,g.$async)}function m(g){let f=e.scopeValue("schema",a.code.source===!0?{ref:g,code:(0,be.stringify)(g)}:{ref:g}),h=e.name("valid"),y=t.subschema({schema:g,dataTypes:[],schemaPath:be.nil,topSchemaRef:f,errSchemaPath:r},h);t.mergeEvaluated(y),t.ok(h)}}};function Hd(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,be._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Ft.getValidate=Hd;function Vo(t,e,r,s){let{gen:o,it:n}=t,{allErrors:i,schemaEnv:a,opts:c}=n,u=c.passContext?gr.default.this:be.nil;s?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let g=o.let("valid");o.try(()=>{o.code((0,be._)`await ${(0,qd.callValidateCode)(t,e,u)}`),m(e),i||o.assign(g,!0)},f=>{o.if((0,be._)`!(${f} instanceof ${n.ValidationError})`,()=>o.throw(f)),p(f),i||o.assign(g,!1)}),t.ok(g)}function d(){t.result((0,qd.callValidateCode)(t,e,u),()=>m(e),()=>p(e))}function p(g){let f=(0,be._)`${g}.errors`;o.assign(gr.default.vErrors,(0,be._)`${gr.default.vErrors} === null ? ${f} : ${gr.default.vErrors}.concat(${f})`),o.assign(gr.default.errors,(0,be._)`${gr.default.vErrors}.length`)}function m(g){var f;if(!n.opts.unevaluated)return;let h=(f=r?.validate)===null||f===void 0?void 0:f.evaluated;if(n.props!==!0)if(h&&!h.dynamicProps)h.props!==void 0&&(n.props=Wo.mergeEvaluated.props(o,h.props,n.props));else{let y=o.var("props",(0,be._)`${g}.evaluated.props`);n.props=Wo.mergeEvaluated.props(o,y,n.props,be.Name)}if(n.items!==!0)if(h&&!h.dynamicItems)h.items!==void 0&&(n.items=Wo.mergeEvaluated.items(o,h.items,n.items));else{let y=o.var("items",(0,be._)`${g}.evaluated.items`);n.items=Wo.mergeEvaluated.items(o,y,n.items,be.Name)}}}Ft.callRef=Vo;Ft.default=OC});var Jd=Q(va=>{"use strict";Object.defineProperty(va,"__esModule",{value:!0});var LC=Ld(),qC=Yd(),GC=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",LC.default,qC.default];va.default=GC});var Wd=Q(ba=>{"use strict";Object.defineProperty(ba,"__esModule",{value:!0});var Ko=U(),_t=Ko.operators,Zo={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}},HC={message:({keyword:t,schemaCode:e})=>(0,Ko.str)`must be ${Zo[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Ko._)`{comparison: ${Zo[t].okStr}, limit: ${e}}`},YC={keyword:Object.keys(Zo),type:"number",schemaType:"number",$data:!0,error:HC,code(t){let{keyword:e,data:r,schemaCode:s}=t;t.fail$data((0,Ko._)`${r} ${Zo[e].fail} ${s} || isNaN(${r})`)}};ba.default=YC});var Vd=Q(xa=>{"use strict";Object.defineProperty(xa,"__esModule",{value:!0});var Cs=U(),JC={message:({schemaCode:t})=>(0,Cs.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Cs._)`{multipleOf: ${t}}`},WC={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:JC,code(t){let{gen:e,data:r,schemaCode:s,it:o}=t,n=o.opts.multipleOfPrecision,i=e.let("res"),a=n?(0,Cs._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${n}`:(0,Cs._)`${i} !== parseInt(${i})`;t.fail$data((0,Cs._)`(${s} === 0 || (${i} = ${r}/${s}, ${a}))`)}};xa.default=WC});var Zd=Q(Ta=>{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});function Kd(t){let e=t.length,r=0,s=0,o;for(;s<e;)r++,o=t.charCodeAt(s++),o>=55296&&o<=56319&&s<e&&(o=t.charCodeAt(s),(o&64512)===56320&&s++);return r}Ta.default=Kd;Kd.code='require("ajv/dist/runtime/ucs2length").default'});var Xd=Q(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});var Ot=U(),VC=H(),KC=Zd(),ZC={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,Ot.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,Ot._)`{limit: ${t}}`},XC={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:ZC,code(t){let{keyword:e,data:r,schemaCode:s,it:o}=t,n=e==="maxLength"?Ot.operators.GT:Ot.operators.LT,i=o.opts.unicode===!1?(0,Ot._)`${r}.length`:(0,Ot._)`${(0,VC.useFunc)(t.gen,KC.default)}(${r})`;t.fail$data((0,Ot._)`${i} ${n} ${s}`)}};Ra.default=XC});var eA=Q(Da=>{"use strict";Object.defineProperty(Da,"__esModule",{value:!0});var eI=je(),tI=H(),hr=U(),rI={message:({schemaCode:t})=>(0,hr.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,hr._)`{pattern: ${t}}`},sI={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:rI,code(t){let{gen:e,data:r,$data:s,schema:o,schemaCode:n,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(s){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,hr._)`new RegExp`:(0,tI.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,hr._)`${u}(${n}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,hr._)`!${l}`)}else{let c=(0,eI.usePattern)(t,o);t.fail$data((0,hr._)`!${c}.test(${r})`)}}};Da.default=sI});var tA=Q($a=>{"use strict";Object.defineProperty($a,"__esModule",{value:!0});var Is=U(),oI={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,Is.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Is._)`{limit: ${t}}`},nI={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:oI,code(t){let{keyword:e,data:r,schemaCode:s}=t,o=e==="maxProperties"?Is.operators.GT:Is.operators.LT;t.fail$data((0,Is._)`Object.keys(${r}).length ${o} ${s}`)}};$a.default=nI});var rA=Q(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});var Bs=je(),Qs=U(),iI=H(),aI={message:({params:{missingProperty:t}})=>(0,Qs.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Qs._)`{missingProperty: ${t}}`},cI={keyword:"required",type:"object",schemaType:"array",$data:!0,error:aI,code(t){let{gen:e,schema:r,schemaCode:s,data:o,$data:n,it:i}=t,{opts:a}=i;if(!n&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let m=t.parentSchema.properties,{definedProperties:g}=t.it;for(let f of r)if(m?.[f]===void 0&&!g.has(f)){let h=i.schemaEnv.baseId+i.errSchemaPath,y=`required property "${f}" is not defined at "${h}" (strictRequired)`;(0,iI.checkStrictMode)(i,y,i.opts.strictRequired)}}function u(){if(c||n)t.block$data(Qs.nil,d);else for(let m of r)(0,Bs.checkReportMissingProp)(t,m)}function l(){let m=e.let("missing");if(c||n){let g=e.let("valid",!0);t.block$data(g,()=>p(m,g)),t.ok(g)}else e.if((0,Bs.checkMissingProp)(t,r,m)),(0,Bs.reportMissingProp)(t,m),e.else()}function d(){e.forOf("prop",s,m=>{t.setParams({missingProperty:m}),e.if((0,Bs.noPropertyInData)(e,o,m,a.ownProperties),()=>t.error())})}function p(m,g){t.setParams({missingProperty:m}),e.forOf(m,s,()=>{e.assign(g,(0,Bs.propertyInData)(e,o,m,a.ownProperties)),e.if((0,Qs.not)(g),()=>{t.error(),e.break()})},Qs.nil)}}};Pa.default=cI});var sA=Q(ja=>{"use strict";Object.defineProperty(ja,"__esModule",{value:!0});var _s=U(),lI={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,_s.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,_s._)`{limit: ${t}}`},uI={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:lI,code(t){let{keyword:e,data:r,schemaCode:s}=t,o=e==="maxItems"?_s.operators.GT:_s.operators.LT;t.fail$data((0,_s._)`${r}.length ${o} ${s}`)}};ja.default=uI});var Xo=Q(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});var oA=aa();oA.code='require("ajv/dist/runtime/equal").default';Na.default=oA});var nA=Q(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});var za=ds(),he=U(),dI=H(),AI=Xo(),pI={message:({params:{i:t,j:e}})=>(0,he.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,he._)`{i: ${t}, j: ${e}}`},mI={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:pI,code(t){let{gen:e,data:r,$data:s,schema:o,parentSchema:n,schemaCode:i,it:a}=t;if(!s&&!o)return;let c=e.let("valid"),u=n.items?(0,za.getSchemaTypes)(n.items):[];t.block$data(c,l,(0,he._)`${i} === false`),t.ok(c);function l(){let g=e.let("i",(0,he._)`${r}.length`),f=e.let("j");t.setParams({i:g,j:f}),e.assign(c,!0),e.if((0,he._)`${g} > 1`,()=>(d()?p:m)(g,f))}function d(){return u.length>0&&!u.some(g=>g==="object"||g==="array")}function p(g,f){let h=e.name("item"),y=(0,za.checkDataTypes)(u,h,a.opts.strictNumbers,za.DataType.Wrong),w=e.const("indices",(0,he._)`{}`);e.for((0,he._)`;${g}--;`,()=>{e.let(h,(0,he._)`${r}[${g}]`),e.if(y,(0,he._)`continue`),u.length>1&&e.if((0,he._)`typeof ${h} == "string"`,(0,he._)`${h} += "_"`),e.if((0,he._)`typeof ${w}[${h}] == "number"`,()=>{e.assign(f,(0,he._)`${w}[${h}]`),t.error(),e.assign(c,!1).break()}).code((0,he._)`${w}[${h}] = ${g}`)})}function m(g,f){let h=(0,dI.useFunc)(e,AI.default),y=e.name("outer");e.label(y).for((0,he._)`;${g}--;`,()=>e.for((0,he._)`${f} = ${g}; ${f}--;`,()=>e.if((0,he._)`${h}(${r}[${g}], ${r}[${f}])`,()=>{t.error(),e.assign(c,!1).break(y)})))}}};Ua.default=mI});var iA=Q(Oa=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});var Fa=U(),fI=H(),gI=Xo(),hI={message:"must be equal to constant",params:({schemaCode:t})=>(0,Fa._)`{allowedValue: ${t}}`},EI={keyword:"const",$data:!0,error:hI,code(t){let{gen:e,data:r,$data:s,schemaCode:o,schema:n}=t;s||n&&typeof n=="object"?t.fail$data((0,Fa._)`!${(0,fI.useFunc)(e,gI.default)}(${r}, ${o})`):t.fail((0,Fa._)`${n} !== ${r}`)}};Oa.default=EI});var aA=Q(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});var Ss=U(),yI=H(),wI=Xo(),CI={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Ss._)`{allowedValues: ${t}}`},II={keyword:"enum",schemaType:"array",$data:!0,error:CI,code(t){let{gen:e,data:r,$data:s,schema:o,schemaCode:n,it:i}=t;if(!s&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,yI.useFunc)(e,wI.default)),l;if(a||s)l=e.let("valid"),t.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let m=e.const("vSchema",n);l=(0,Ss.or)(...o.map((g,f)=>p(m,f)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",n,m=>e.if((0,Ss._)`${u()}(${r}, ${m})`,()=>e.assign(l,!0).break()))}function p(m,g){let f=o[g];return typeof f=="object"&&f!==null?(0,Ss._)`${u()}(${r}, ${m}[${g}])`:(0,Ss._)`${r} === ${f}`}}};La.default=II});var cA=Q(qa=>{"use strict";Object.defineProperty(qa,"__esModule",{value:!0});var BI=Wd(),QI=Vd(),_I=Xd(),SI=eA(),kI=tA(),MI=rA(),vI=sA(),bI=nA(),xI=iA(),TI=aA(),RI=[BI.default,QI.default,_I.default,SI.default,kI.default,MI.default,vI.default,bI.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},xI.default,TI.default];qa.default=RI});var Ha=Q(ks=>{"use strict";Object.defineProperty(ks,"__esModule",{value:!0});ks.validateAdditionalItems=void 0;var Lt=U(),Ga=H(),DI={message:({params:{len:t}})=>(0,Lt.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Lt._)`{limit: ${t}}`},$I={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:DI,code(t){let{parentSchema:e,it:r}=t,{items:s}=e;if(!Array.isArray(s)){(0,Ga.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}lA(t,s)}};function lA(t,e){let{gen:r,schema:s,data:o,keyword:n,it:i}=t;i.items=!0;let a=r.const("len",(0,Lt._)`${o}.length`);if(s===!1)t.setParams({len:e.length}),t.pass((0,Lt._)`${a} <= ${e.length}`);else if(typeof s=="object"&&!(0,Ga.alwaysValidSchema)(i,s)){let u=r.var("valid",(0,Lt._)`${a} <= ${e.length}`);r.if((0,Lt.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:n,dataProp:l,dataPropType:Ga.Type.Num},u),i.allErrors||r.if((0,Lt.not)(u),()=>r.break())})}}ks.validateAdditionalItems=lA;ks.default=$I});var Ya=Q(Ms=>{"use strict";Object.defineProperty(Ms,"__esModule",{value:!0});Ms.validateTuple=void 0;var uA=U(),en=H(),PI=je(),jI={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return dA(t,"additionalItems",e);r.items=!0,!(0,en.alwaysValidSchema)(r,e)&&t.ok((0,PI.validateArray)(t))}};function dA(t,e,r=t.schema){let{gen:s,parentSchema:o,data:n,keyword:i,it:a}=t;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=en.mergeEvaluated.items(s,r.length,a.items));let c=s.name("valid"),u=s.const("len",(0,uA._)`${n}.length`);r.forEach((d,p)=>{(0,en.alwaysValidSchema)(a,d)||(s.if((0,uA._)`${u} > ${p}`,()=>t.subschema({keyword:i,schemaProp:p,dataProp:p},c)),t.ok(c))});function l(d){let{opts:p,errSchemaPath:m}=a,g=r.length,f=g===d.minItems&&(g===d.maxItems||d[e]===!1);if(p.strictTuples&&!f){let h=`"${i}" is ${g}-tuple, but minItems or maxItems/${e} are not specified or different at path "${m}"`;(0,en.checkStrictMode)(a,h,p.strictTuples)}}}Ms.validateTuple=dA;Ms.default=jI});var AA=Q(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});var NI=Ya(),zI={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,NI.validateTuple)(t,"items")};Ja.default=zI});var mA=Q(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});var pA=U(),UI=H(),FI=je(),OI=Ha(),LI={message:({params:{len:t}})=>(0,pA.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,pA._)`{limit: ${t}}`},qI={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:LI,code(t){let{schema:e,parentSchema:r,it:s}=t,{prefixItems:o}=r;s.items=!0,!(0,UI.alwaysValidSchema)(s,e)&&(o?(0,OI.validateAdditionalItems)(t,o):t.ok((0,FI.validateArray)(t)))}};Wa.default=qI});var fA=Q(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});var ze=U(),tn=H(),GI={message:({params:{min:t,max:e}})=>e===void 0?(0,ze.str)`must contain at least ${t} valid item(s)`:(0,ze.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,ze._)`{minContains: ${t}}`:(0,ze._)`{minContains: ${t}, maxContains: ${e}}`},HI={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:GI,code(t){let{gen:e,schema:r,parentSchema:s,data:o,it:n}=t,i,a,{minContains:c,maxContains:u}=s;n.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=e.const("len",(0,ze._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,tn.checkStrictMode)(n,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,tn.checkStrictMode)(n,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,tn.alwaysValidSchema)(n,r)){let f=(0,ze._)`${l} >= ${i}`;a!==void 0&&(f=(0,ze._)`${f} && ${l} <= ${a}`),t.pass(f);return}n.items=!0;let d=e.name("valid");a===void 0&&i===1?m(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,ze._)`${o}.length > 0`,p)):(e.let(d,!1),p()),t.result(d,()=>t.reset());function p(){let f=e.name("_valid"),h=e.let("count",0);m(f,()=>e.if(f,()=>g(h)))}function m(f,h){e.forRange("i",0,l,y=>{t.subschema({keyword:"contains",dataProp:y,dataPropType:tn.Type.Num,compositeRule:!0},f),h()})}function g(f){e.code((0,ze._)`${f}++`),a===void 0?e.if((0,ze._)`${f} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,ze._)`${f} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,ze._)`${f} >= ${i}`,()=>e.assign(d,!0)))}}};Va.default=HI});var EA=Q(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.validateSchemaDeps=Ze.validatePropertyDeps=Ze.error=void 0;var Ka=U(),YI=H(),vs=je();Ze.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let s=e===1?"property":"properties";return(0,Ka.str)`must have ${s} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:s}})=>(0,Ka._)`{property: ${t},
|
|
9
9
|
missingProperty: ${s},
|
|
10
10
|
depsCount: ${e},
|
|
11
|
-
deps: ${r}}`};var JI={keyword:"dependencies",type:"object",schemaType:"object",error:Ze.error,code(t){let[e,r]=WI(t);gA(t,e),hA(t,r)}};function WI({schema:t}){let e={},r={};for(let s in t){if(s==="__proto__")continue;let o=Array.isArray(t[s])?e:r;o[s]=t[s]}return[e,r]}function gA(t,e=t.schema){let{gen:r,data:s,it:o}=t;if(Object.keys(e).length===0)return;let n=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,vs.propertyInData)(r,s,i,o.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,vs.checkReportMissingProp)(t,u)}):(r.if((0,Ka._)`${c} && (${(0,vs.checkMissingProp)(t,a,n)})`),(0,vs.reportMissingProp)(t,n),r.else())}}Ze.validatePropertyDeps=gA;function hA(t,e=t.schema){let{gen:r,data:s,keyword:o,it:n}=t,i=r.name("valid");for(let a in e)(0,YI.alwaysValidSchema)(n,e[a])||(r.if((0,vs.propertyInData)(r,s,a,n.opts.ownProperties),()=>{let c=t.subschema({keyword:o,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}Ze.validateSchemaDeps=hA;Ze.default=JI});var wA=Q(Za=>{"use strict";Object.defineProperty(Za,"__esModule",{value:!0});var yA=U(),VI=H(),KI={message:"property name must be valid",params:({params:t})=>(0,yA._)`{propertyName: ${t.propertyName}}`},ZI={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:KI,code(t){let{gen:e,schema:r,data:s,it:o}=t;if((0,VI.alwaysValidSchema)(o,r))return;let n=e.name("valid");e.forIn("key",s,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},n),e.if((0,yA.not)(n),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(n)}};Za.default=ZI});var ec=Q(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});var rn=je(),qe=U(),XI=nt(),sn=H(),eB={message:"must NOT have additional properties",params:({params:t})=>(0,qe._)`{additionalProperty: ${t.additionalProperty}}`},tB={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:eB,code(t){let{gen:e,schema:r,parentSchema:s,data:o,errsCount:n,it:i}=t;if(!n)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,sn.alwaysValidSchema)(i,r))return;let u=(0,rn.allSchemaProperties)(s.properties),l=(0,rn.allSchemaProperties)(s.patternProperties);d(),t.ok((0,qe._)`${n} === ${XI.default.errors}`);function d(){e.forIn("key",o,h=>{!u.length&&!l.length?g(h):e.if(p(h),()=>g(h))})}function p(h){let y;if(u.length>8){let w=(0,sn.schemaRefOrVal)(i,s.properties,"properties");y=(0,rn.isOwnProperty)(e,w,h)}else u.length?y=(0,qe.or)(...u.map(w=>(0,qe._)`${h} === ${w}`)):y=qe.nil;return l.length&&(y=(0,qe.or)(y,...l.map(w=>(0,qe._)`${(0,rn.usePattern)(t,w)}.test(${h})`))),(0,qe.not)(y)}function m(h){e.code((0,qe._)`delete ${o}[${h}]`)}function g(h){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){m(h);return}if(r===!1){t.setParams({additionalProperty:h}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,sn.alwaysValidSchema)(i,r)){let y=e.name("valid");c.removeAdditional==="failing"?(f(h,y,!1),e.if((0,qe.not)(y),()=>{t.reset(),m(h)})):(f(h,y),a||e.if((0,qe.not)(y),()=>e.break()))}}function f(h,y,w){let I={keyword:"additionalProperties",dataProp:h,dataPropType:sn.Type.Str};w===!1&&Object.assign(I,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(I,y)}}};Xa.default=tB});var BA=Q(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});var rB=fs(),CA=je(),tc=H(),IA=ec(),sB={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:s,data:o,it:n}=t;n.opts.removeAdditional==="all"&&s.additionalProperties===void 0&&IA.default.code(new rB.KeywordCxt(n,IA.default,"additionalProperties"));let i=(0,CA.allSchemaProperties)(r);for(let d of i)n.definedProperties.add(d);n.opts.unevaluated&&i.length&&n.props!==!0&&(n.props=tc.mergeEvaluated.props(e,(0,tc.toHash)(i),n.props));let a=i.filter(d=>!(0,tc.alwaysValidSchema)(n,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,CA.propertyInData)(e,o,d,n.opts.ownProperties)),l(d),n.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return n.opts.useDefaults&&!n.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};rc.default=sB});var kA=Q(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});var QA=je(),on=U(),_A=H(),SA=H(),oB={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:s,parentSchema:o,it:n}=t,{opts:i}=n,a=(0,QA.allSchemaProperties)(r),c=a.filter(f=>(0,_A.alwaysValidSchema)(n,r[f]));if(a.length===0||c.length===a.length&&(!n.opts.unevaluated||n.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=e.name("valid");n.props!==!0&&!(n.props instanceof on.Name)&&(n.props=(0,SA.evaluatedPropsToName)(e,n.props));let{props:d}=n;p();function p(){for(let f of a)u&&m(f),n.allErrors?g(f):(e.var(l,!0),g(f),e.if(l))}function m(f){for(let h in u)new RegExp(f).test(h)&&(0,_A.checkStrictMode)(n,`property ${h} matches pattern ${f} (use allowMatchingProperties)`)}function g(f){e.forIn("key",s,h=>{e.if((0,on._)`${(0,QA.usePattern)(t,f)}.test(${h})`,()=>{let y=c.includes(f);y||t.subschema({keyword:"patternProperties",schemaProp:f,dataProp:h,dataPropType:SA.Type.Str},l),n.opts.unevaluated&&d!==!0?e.assign((0,on._)`${d}[${h}]`,!0):!y&&!n.allErrors&&e.if((0,on.not)(l),()=>e.break())})})}}};sc.default=oB});var MA=Q(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});var nB=H(),iB={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:s}=t;if((0,nB.alwaysValidSchema)(s,r)){t.fail();return}let o=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),t.failResult(o,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};oc.default=iB});var vA=Q(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});var aB=je(),cB={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:aB.validateUnion,error:{message:"must match a schema in anyOf"}};nc.default=cB});var bA=Q(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});var nn=U(),lB=H(),uB={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,nn._)`{passingSchemas: ${t.passing}}`},dB={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:uB,code(t){let{gen:e,schema:r,parentSchema:s,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&s.discriminator)return;let n=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){n.forEach((l,d)=>{let p;(0,lB.alwaysValidSchema)(o,l)?e.var(c,!0):p=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,nn._)`${c} && ${i}`).assign(i,!1).assign(a,(0,nn._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),p&&t.mergeEvaluated(p,nn.Name)})})}}};ic.default=dB});var xA=Q(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});var AB=H(),pB={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=e.name("valid");r.forEach((n,i)=>{if((0,AB.alwaysValidSchema)(s,n))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};ac.default=pB});var DA=Q(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});var an=U(),RA=H(),mB={message:({params:t})=>(0,an.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,an._)`{failingKeyword: ${t.ifClause}}`},fB={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:mB,code(t){let{gen:e,parentSchema:r,it:s}=t;r.then===void 0&&r.else===void 0&&(0,RA.checkStrictMode)(s,'"if" without "then" and "else" is ignored');let o=TA(s,"then"),n=TA(s,"else");if(!o&&!n)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),o&&n){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else o?e.if(a,u("then")):e.if((0,an.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,d){return()=>{let p=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(p,i),d?e.assign(d,(0,an._)`${l}`):t.setParams({ifClause:l})}}}};function TA(t,e){let r=t.schema[e];return r!==void 0&&!(0,RA.alwaysValidSchema)(t,r)}cc.default=fB});var $A=Q(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});var gB=H(),hB={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,gB.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};lc.default=hB});var PA=Q(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});var EB=Ha(),yB=AA(),wB=Ya(),CB=mA(),IB=fA(),BB=EA(),QB=wA(),_B=ec(),SB=BA(),kB=kA(),MB=MA(),vB=vA(),bB=bA(),xB=xA(),TB=DA(),RB=$A();function DB(t=!1){let e=[MB.default,vB.default,bB.default,xB.default,TB.default,RB.default,QB.default,_B.default,BB.default,SB.default,kB.default];return t?e.push(yB.default,CB.default):e.push(EB.default,wB.default),e.push(IB.default),e}uc.default=DB});var jA=Q(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});var ie=U(),$B={message:({schemaCode:t})=>(0,ie.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,ie._)`{format: ${t}}`},PB={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:$B,code(t,e){let{gen:r,data:s,$data:o,schema:n,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?p():m();function p(){let g=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),f=r.const("fDef",(0,ie._)`${g}[${i}]`),h=r.let("fType"),y=r.let("format");r.if((0,ie._)`typeof ${f} == "object" && !(${f} instanceof RegExp)`,()=>r.assign(h,(0,ie._)`${f}.type || "string"`).assign(y,(0,ie._)`${f}.validate`),()=>r.assign(h,(0,ie._)`"string"`).assign(y,f)),t.fail$data((0,ie.or)(w(),I()));function w(){return c.strictSchema===!1?ie.nil:(0,ie._)`${i} && !${y}`}function I(){let v=l.$async?(0,ie._)`(${f}.async ? await ${y}(${s}) : ${y}(${s}))`:(0,ie._)`${y}(${s})`,E=(0,ie._)`(typeof ${y} == "function" ? ${v} : ${y}.test(${s}))`;return(0,ie._)`${y} && ${y} !== true && ${h} === ${e} && !${E}`}}function m(){let g=d.formats[n];if(!g){w();return}if(g===!0)return;let[f,h,y]=I(g);f===e&&t.pass(v());function w(){if(c.strictSchema===!1){d.logger.warn(E());return}throw new Error(E());function E(){return`unknown format "${n}" ignored in schema at path "${u}"`}}function I(E){let B=E instanceof RegExp?(0,ie.regexpCode)(E):c.code.formats?(0,ie._)`${c.code.formats}${(0,ie.getProperty)(n)}`:void 0,M=r.scopeValue("formats",{key:n,ref:E,code:B});return typeof E=="object"&&!(E instanceof RegExp)?[E.type||"string",E.validate,(0,ie._)`${M}.validate`]:["string",E,M]}function v(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ie._)`await ${y}(${s})`}return typeof h=="function"?(0,ie._)`${y}(${s})`:(0,ie._)`${y}.test(${s})`}}}};dc.default=PB});var NA=Q(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});var jB=jA(),NB=[jB.default];Ac.default=NB});var zA=Q(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});Er.contentVocabulary=Er.metadataVocabulary=void 0;Er.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Er.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var FA=Q(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});var zB=Jd(),UB=cA(),FB=PA(),OB=NA(),UA=zA(),LB=[zB.default,UB.default,(0,FB.default)(),OB.default,UA.metadataVocabulary,UA.contentVocabulary];pc.default=LB});var LA=Q(cn=>{"use strict";Object.defineProperty(cn,"__esModule",{value:!0});cn.DiscrError=void 0;var OA;(function(t){t.Tag="tag",t.Mapping="mapping"})(OA||(cn.DiscrError=OA={}))});var GA=Q(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});var yr=U(),mc=LA(),qA=qo(),qB=gs(),GB=H(),HB={message:({params:{discrError:t,tagName:e}})=>t===mc.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,yr._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},YB={keyword:"discriminator",type:"object",schemaType:"object",error:HB,code(t){let{gen:e,data:r,schema:s,parentSchema:o,it:n}=t,{oneOf:i}=o;if(!n.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=s.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(s.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,yr._)`${r}${(0,yr.getProperty)(a)}`);e.if((0,yr._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:mc.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let m=p();e.if(!1);for(let g in m)e.elseIf((0,yr._)`${u} === ${g}`),e.assign(c,d(m[g]));e.else(),t.error(!1,{discrError:mc.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(m){let g=e.name("valid"),f=t.subschema({keyword:"oneOf",schemaProp:m},g);return t.mergeEvaluated(f,yr.Name),g}function p(){var m;let g={},f=y(o),h=!0;for(let v=0;v<i.length;v++){let E=i[v];if(E?.$ref&&!(0,GB.schemaHasRulesButRef)(E,n.self.RULES)){let M=E.$ref;if(E=qA.resolveRef.call(n.self,n.schemaEnv.root,n.baseId,M),E instanceof qA.SchemaEnv&&(E=E.schema),E===void 0)throw new qB.default(n.opts.uriResolver,n.baseId,M)}let B=(m=E?.properties)===null||m===void 0?void 0:m[a];if(typeof B!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);h=h&&(f||y(E)),w(B,v)}if(!h)throw new Error(`discriminator: "${a}" must be required`);return g;function y({required:v}){return Array.isArray(v)&&v.includes(a)}function w(v,E){if(v.const)I(v.const,E);else if(v.enum)for(let B of v.enum)I(B,E);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function I(v,E){if(typeof v!="string"||v in g)throw new Error(`discriminator: "${a}" values must be unique strings`);g[v]=E}}}};fc.default=YB});var HA=Q((yR,JB)=>{JB.exports={$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}});var hc=Q((te,gc)=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.MissingRefError=te.ValidationError=te.CodeGen=te.Name=te.nil=te.stringify=te.str=te._=te.KeywordCxt=te.Ajv=void 0;var WB=Od(),VB=FA(),KB=GA(),YA=HA(),ZB=["/properties"],ln="http://json-schema.org/draft-07/schema",wr=class extends WB.default{_addVocabularies(){super._addVocabularies(),VB.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(KB.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(YA,ZB):YA;this.addMetaSchema(e,ln,!1),this.refs["http://json-schema.org/schema"]=ln}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(ln)?ln:void 0)}};te.Ajv=wr;gc.exports=te=wr;gc.exports.Ajv=wr;Object.defineProperty(te,"__esModule",{value:!0});te.default=wr;var XB=fs();Object.defineProperty(te,"KeywordCxt",{enumerable:!0,get:function(){return XB.KeywordCxt}});var Cr=U();Object.defineProperty(te,"_",{enumerable:!0,get:function(){return Cr._}});Object.defineProperty(te,"str",{enumerable:!0,get:function(){return Cr.str}});Object.defineProperty(te,"stringify",{enumerable:!0,get:function(){return Cr.stringify}});Object.defineProperty(te,"nil",{enumerable:!0,get:function(){return Cr.nil}});Object.defineProperty(te,"Name",{enumerable:!0,get:function(){return Cr.Name}});Object.defineProperty(te,"CodeGen",{enumerable:!0,get:function(){return Cr.CodeGen}});var eQ=Oo();Object.defineProperty(te,"ValidationError",{enumerable:!0,get:function(){return eQ.default}});var tQ=gs();Object.defineProperty(te,"MissingRefError",{enumerable:!0,get:function(){return tQ.default}})});var tp=Q(et=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.formatNames=et.fastFormats=et.fullFormats=void 0;function Xe(t,e){return{validate:t,compare:e}}et.fullFormats={date:Xe(KA,Cc),time:Xe(yc(!0),Ic),"date-time":Xe(JA(!0),XA),"iso-time":Xe(yc(),ZA),"iso-date-time":Xe(JA(),ep),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:aQ,"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:mQ,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:cQ,int32:{type:"number",validate:dQ},int64:{type:"number",validate:AQ},float:{type:"number",validate:VA},double:{type:"number",validate:VA},password:!0,binary:!0};et.fastFormats={...et.fullFormats,date:Xe(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Cc),time:Xe(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Ic),"date-time":Xe(/^\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,XA),"iso-time":Xe(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,ZA),"iso-date-time":Xe(/^\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,ep),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};et.formatNames=Object.keys(et.fullFormats);function rQ(t){return t%4===0&&(t%100!==0||t%400===0)}var sQ=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,oQ=[0,31,28,31,30,31,30,31,31,30,31,30,31];function KA(t){let e=sQ.exec(t);if(!e)return!1;let r=+e[1],s=+e[2],o=+e[3];return s>=1&&s<=12&&o>=1&&o<=(s===2&&rQ(r)?29:oQ[s])}function Cc(t,e){if(t&&e)return t>e?1:t<e?-1:0}var Ec=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function yc(t){return function(r){let s=Ec.exec(r);if(!s)return!1;let o=+s[1],n=+s[2],i=+s[3],a=s[4],c=s[5]==="-"?-1:1,u=+(s[6]||0),l=+(s[7]||0);if(u>23||l>59||t&&!a)return!1;if(o<=23&&n<=59&&i<60)return!0;let d=n-l*c,p=o-u*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&i<61}}function Ic(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),s=new Date("2020-01-01T"+e).valueOf();if(r&&s)return r-s}function ZA(t,e){if(!(t&&e))return;let r=Ec.exec(t),s=Ec.exec(e);if(r&&s)return t=r[1]+r[2]+r[3],e=s[1]+s[2]+s[3],t>e?1:t<e?-1:0}var wc=/t|\s/i;function JA(t){let e=yc(t);return function(s){let o=s.split(wc);return o.length===2&&KA(o[0])&&e(o[1])}}function XA(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),s=new Date(e).valueOf();if(r&&s)return r-s}function ep(t,e){if(!(t&&e))return;let[r,s]=t.split(wc),[o,n]=e.split(wc),i=Cc(r,o);if(i!==void 0)return i||Ic(s,n)}var nQ=/\/|:/,iQ=/^(?:[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;function aQ(t){return nQ.test(t)&&iQ.test(t)}var WA=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function cQ(t){return WA.lastIndex=0,WA.test(t)}var lQ=-(2**31),uQ=2**31-1;function dQ(t){return Number.isInteger(t)&&t<=uQ&&t>=lQ}function AQ(t){return Number.isInteger(t)}function VA(){return!0}var pQ=/[^\\]\\Z/;function mQ(t){if(pQ.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var rp=Q(Ir=>{"use strict";Object.defineProperty(Ir,"__esModule",{value:!0});Ir.formatLimitDefinition=void 0;var fQ=hc(),Ge=U(),St=Ge.operators,un={formatMaximum:{okStr:"<=",ok:St.LTE,fail:St.GT},formatMinimum:{okStr:">=",ok:St.GTE,fail:St.LT},formatExclusiveMaximum:{okStr:"<",ok:St.LT,fail:St.GTE},formatExclusiveMinimum:{okStr:">",ok:St.GT,fail:St.LTE}},gQ={message:({keyword:t,schemaCode:e})=>(0,Ge.str)`should be ${un[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Ge._)`{comparison: ${un[t].okStr}, limit: ${e}}`};Ir.formatLimitDefinition={keyword:Object.keys(un),type:"string",schemaType:"string",$data:!0,error:gQ,code(t){let{gen:e,data:r,schemaCode:s,keyword:o,it:n}=t,{opts:i,self:a}=n;if(!i.validateFormats)return;let c=new fQ.KeywordCxt(n,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let p=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),m=e.const("fmt",(0,Ge._)`${p}[${c.schemaCode}]`);t.fail$data((0,Ge.or)((0,Ge._)`typeof ${m} != "object"`,(0,Ge._)`${m} instanceof RegExp`,(0,Ge._)`typeof ${m}.compare != "function"`,d(m)))}function l(){let p=c.schema,m=a.formats[p];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let g=e.scopeValue("formats",{key:p,ref:m,code:i.code.formats?(0,Ge._)`${i.code.formats}${(0,Ge.getProperty)(p)}`:void 0});t.fail$data(d(g))}function d(p){return(0,Ge._)`${p}.compare(${r}, ${s}) ${un[o].fail} 0`}},dependencies:["format"]};var hQ=t=>(t.addKeyword(Ir.formatLimitDefinition),t);Ir.default=hQ});var ip=Q((bs,np)=>{"use strict";Object.defineProperty(bs,"__esModule",{value:!0});var Br=tp(),EQ=rp(),Bc=U(),sp=new Bc.Name("fullFormats"),yQ=new Bc.Name("fastFormats"),Qc=(t,e={keywords:!0})=>{if(Array.isArray(e))return op(t,e,Br.fullFormats,sp),t;let[r,s]=e.mode==="fast"?[Br.fastFormats,yQ]:[Br.fullFormats,sp],o=e.formats||Br.formatNames;return op(t,o,r,s),e.keywords&&(0,EQ.default)(t),t};Qc.get=(t,e="full")=>{let s=(e==="fast"?Br.fastFormats:Br.fullFormats)[t];if(!s)throw new Error(`Unknown format "${t}"`);return s};function op(t,e,r,s){var o,n;(o=(n=t.opts.code).formats)!==null&&o!==void 0||(n.formats=(0,Bc._)`require("ajv-formats/dist/formats").${s}`);for(let i of e)t.addFormat(i,r[i])}np.exports=bs=Qc;Object.defineProperty(bs,"__esModule",{value:!0});bs.default=Qc});var $p=Q((tD,Dp)=>{"use strict";Dp.exports=Rp;Rp.sync=KQ;var xp=ft("fs");function VQ(t,e){var r=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var s=0;s<r.length;s++){var o=r[s].toLowerCase();if(o&&t.substr(-o.length).toLowerCase()===o)return!0}return!1}function Tp(t,e,r){return!t.isSymbolicLink()&&!t.isFile()?!1:VQ(e,r)}function Rp(t,e,r){xp.stat(t,function(s,o){r(s,s?!1:Tp(o,t,e))})}function KQ(t,e){return Tp(xp.statSync(t),t,e)}});var Up=Q((rD,zp)=>{"use strict";zp.exports=jp;jp.sync=ZQ;var Pp=ft("fs");function jp(t,e,r){Pp.stat(t,function(s,o){r(s,s?!1:Np(o,e))})}function ZQ(t,e){return Np(Pp.statSync(t),e)}function Np(t,e){return t.isFile()&&XQ(t,e)}function XQ(t,e){var r=t.mode,s=t.uid,o=t.gid,n=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),i=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),u=parseInt("001",8),l=a|c,d=r&u||r&c&&o===i||r&a&&s===n||r&l&&n===0;return d}});var Op=Q((oD,Fp)=>{"use strict";var sD=ft("fs"),Cn;process.platform==="win32"||global.TESTING_WINDOWS?Cn=$p():Cn=Up();Fp.exports=qc;qc.sync=e_;function qc(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(s,o){qc(t,e||{},function(n,i){n?o(n):s(i)})})}Cn(t,e||{},function(s,o){s&&(s.code==="EACCES"||e&&e.ignoreErrors)&&(s=null,o=!1),r(s,o)})}function e_(t,e){try{return Cn.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var Wp=Q((nD,Jp)=>{"use strict";var xr=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Lp=ft("path"),t_=xr?";":":",qp=Op(),Gp=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),Hp=(t,e)=>{let r=e.colon||t_,s=t.match(/\//)||xr&&t.match(/\\/)?[""]:[...xr?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],o=xr?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",n=xr?o.split(r):[""];return xr&&t.indexOf(".")!==-1&&n[0]!==""&&n.unshift(""),{pathEnv:s,pathExt:n,pathExtExe:o}},Yp=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});let{pathEnv:s,pathExt:o,pathExtExe:n}=Hp(t,e),i=[],a=u=>new Promise((l,d)=>{if(u===s.length)return e.all&&i.length?l(i):d(Gp(t));let p=s[u],m=/^".*"$/.test(p)?p.slice(1,-1):p,g=Lp.join(m,t),f=!m&&/^\.[\\\/]/.test(t)?t.slice(0,2)+g:g;l(c(f,u,0))}),c=(u,l,d)=>new Promise((p,m)=>{if(d===o.length)return p(a(l+1));let g=o[d];qp(u+g,{pathExt:n},(f,h)=>{if(!f&&h)if(e.all)i.push(u+g);else return p(u+g);return p(c(u,l,d+1))})});return r?a(0).then(u=>r(null,u),r):a(0)},r_=(t,e)=>{e=e||{};let{pathEnv:r,pathExt:s,pathExtExe:o}=Hp(t,e),n=[];for(let i=0;i<r.length;i++){let a=r[i],c=/^".*"$/.test(a)?a.slice(1,-1):a,u=Lp.join(c,t),l=!c&&/^\.[\\\/]/.test(t)?t.slice(0,2)+u:u;for(let d=0;d<s.length;d++){let p=l+s[d];try{if(qp.sync(p,{pathExt:o}))if(e.all)n.push(p);else return p}catch{}}}if(e.all&&n.length)return n;if(e.nothrow)return null;throw Gp(t)};Jp.exports=Yp;Yp.sync=r_});var Kp=Q((iD,Gc)=>{"use strict";var Vp=(t={})=>{let e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(s=>s.toUpperCase()==="PATH")||"Path"};Gc.exports=Vp;Gc.exports.default=Vp});var tm=Q((aD,em)=>{"use strict";var Zp=ft("path"),s_=Wp(),o_=Kp();function Xp(t,e){let r=t.options.env||process.env,s=process.cwd(),o=t.options.cwd!=null,n=o&&process.chdir!==void 0&&!process.chdir.disabled;if(n)try{process.chdir(t.options.cwd)}catch{}let i;try{i=s_.sync(t.command,{path:r[o_({env:r})],pathExt:e?Zp.delimiter:void 0})}catch{}finally{n&&process.chdir(s)}return i&&(i=Zp.resolve(o?t.options.cwd:"",i)),i}function n_(t){return Xp(t)||Xp(t,!0)}em.exports=n_});var rm=Q((cD,Yc)=>{"use strict";var Hc=/([()\][%!^"`<>&|;, *?])/g;function i_(t){return t=t.replace(Hc,"^$1"),t}function a_(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(Hc,"^$1"),e&&(t=t.replace(Hc,"^$1")),t}Yc.exports.command=i_;Yc.exports.argument=a_});var om=Q((lD,sm)=>{"use strict";sm.exports=/^#!(.*)/});var im=Q((uD,nm)=>{"use strict";var c_=om();nm.exports=(t="")=>{let e=t.match(c_);if(!e)return null;let[r,s]=e[0].replace(/#! ?/,"").split(" "),o=r.split("/").pop();return o==="env"?s:s?`${o} ${s}`:o}});var cm=Q((dD,am)=>{"use strict";var Jc=ft("fs"),l_=im();function u_(t){let r=Buffer.alloc(150),s;try{s=Jc.openSync(t,"r"),Jc.readSync(s,r,0,150,0),Jc.closeSync(s)}catch{}return l_(r.toString())}am.exports=u_});var Am=Q((AD,dm)=>{"use strict";var d_=ft("path"),lm=tm(),um=rm(),A_=cm(),p_=process.platform==="win32",m_=/\.(?:com|exe)$/i,f_=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function g_(t){t.file=lm(t);let e=t.file&&A_(t.file);return e?(t.args.unshift(t.file),t.command=e,lm(t)):t.file}function h_(t){if(!p_)return t;let e=g_(t),r=!m_.test(e);if(t.options.forceShell||r){let s=f_.test(e);t.command=d_.normalize(t.command),t.command=um.command(t.command),t.args=t.args.map(n=>um.argument(n,s));let o=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${o}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function E_(t,e,r){e&&!Array.isArray(e)&&(r=e,e=null),e=e?e.slice(0):[],r=Object.assign({},r);let s={command:t,args:e,options:r,file:void 0,original:{command:t,args:e}};return r.shell?s:h_(s)}dm.exports=E_});var fm=Q((pD,mm)=>{"use strict";var Wc=process.platform==="win32";function Vc(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function y_(t,e){if(!Wc)return;let r=t.emit;t.emit=function(s,o){if(s==="exit"){let n=pm(o,e);if(n)return r.call(t,"error",n)}return r.apply(t,arguments)}}function pm(t,e){return Wc&&t===1&&!e.file?Vc(e.original,"spawn"):null}function w_(t,e){return Wc&&t===1&&!e.file?Vc(e.original,"spawnSync"):null}mm.exports={hookChildProcess:y_,verifyENOENT:pm,verifyENOENTSync:w_,notFoundError:Vc}});var Em=Q((mD,Tr)=>{"use strict";var gm=ft("child_process"),Kc=Am(),Zc=fm();function hm(t,e,r){let s=Kc(t,e,r),o=gm.spawn(s.command,s.args,s.options);return Zc.hookChildProcess(o,s),o}function C_(t,e,r){let s=Kc(t,e,r),o=gm.spawnSync(s.command,s.args,s.options);return o.error=o.error||Zc.verifyENOENTSync(o.status,s),o}Tr.exports=hm;Tr.exports.spawn=hm;Tr.exports.sync=C_;Tr.exports._parse=Kc;Tr.exports._enoent=Zc});var Qm=Q(el=>{"use strict";var Cm=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,k_=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,Im=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,M_=/\\([\u000b\u0020-\u00ff])/g,v_=/([\\"])/g,Bm=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;el.format=b_;el.parse=x_;function b_(t){if(!t||typeof t!="object")throw new TypeError("argument obj is required");var e=t.parameters,r=t.type;if(!r||!Bm.test(r))throw new TypeError("invalid type");var s=r;if(e&&typeof e=="object")for(var o,n=Object.keys(e).sort(),i=0;i<n.length;i++){if(o=n[i],!Im.test(o))throw new TypeError("invalid parameter name");s+="; "+o+"="+R_(e[o])}return s}function x_(t){if(!t)throw new TypeError("argument string is required");var e=typeof t=="object"?T_(t):t;if(typeof e!="string")throw new TypeError("argument string is required to be a string");var r=e.indexOf(";"),s=r!==-1?e.slice(0,r).trim():e.trim();if(!Bm.test(s))throw new TypeError("invalid media type");var o=new D_(s.toLowerCase());if(r!==-1){var n,i,a;for(Cm.lastIndex=r;i=Cm.exec(e);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,n=i[1].toLowerCase(),a=i[2],a.charCodeAt(0)===34&&(a=a.slice(1,-1),a.indexOf("\\")!==-1&&(a=a.replace(M_,"$1"))),o.parameters[n]=a}if(r!==e.length)throw new TypeError("invalid parameter format")}return o}function T_(t){var e;if(typeof t.getHeader=="function"?e=t.getHeader("content-type"):typeof t.headers=="object"&&(e=t.headers&&t.headers["content-type"]),typeof e!="string")throw new TypeError("content-type header is missing from object");return e}function R_(t){var e=String(t);if(Im.test(e))return e;if(e.length>0&&!k_.test(e))throw new TypeError("invalid parameter value");return'"'+e.replace(v_,"\\$1")+'"'}function D_(t){this.parameters=Object.create(null),this.type=t}});async function si(t,e){switch(t.protocol){case"anthropic":{let{AnthropicClient:r}=await import("./anthropic-V22T6E6E.js");return new r(t,e)}case"openai":{let{OpenAIClient:r}=await import("./openai-6NWVJ5LI.js");return new r(t,e)}case"openai-compat":{let{OpenAICompatClient:r}=await import("./openai-6NWVJ5LI.js");return new r(t,e)}default:throw new Error(`Unknown protocol: ${String(t.protocol)}`)}}var sr="2025-11-25";var Vl=[sr,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],gt="io.modelcontextprotocol/related-task",Eo="2.0",ue=Nl(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Kl=re([A(),J().int()]),Zl=A(),yv=le({ttl:J().optional(),pollInterval:J().optional()}),Fg=k({ttl:J().optional()}),Og=k({taskId:A()}),ni=le({progressToken:Kl.optional(),[gt]:Og.optional()}),Re=k({_meta:ni.optional()}),Yr=Re.extend({task:Fg.optional()}),Xl=t=>Yr.safeParse(t).success,pe=k({method:A(),params:Re.loose().optional()}),De=k({_meta:ni.optional()}),$e=k({method:A(),params:De.loose().optional()}),me=le({_meta:ni.optional()}),yo=re([A(),J().int()]),eu=k({jsonrpc:b(Eo),id:yo,...pe.shape}).strict(),Jr=t=>eu.safeParse(t).success,tu=k({jsonrpc:b(Eo),...$e.shape}).strict(),ru=t=>tu.safeParse(t).success,ii=k({jsonrpc:b(Eo),id:yo,result:me}).strict(),bt=t=>ii.safeParse(t).success;var P;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(P||(P={}));var ai=k({jsonrpc:b(Eo),id:yo.optional(),error:k({code:J().int(),message:A(),data:ne().optional()})}).strict();var su=t=>ai.safeParse(t).success;var ht=re([eu,tu,ii,ai]),wv=re([ii,ai]),xt=me.strict(),Lg=De.extend({requestId:yo.optional(),reason:A().optional()}),wo=$e.extend({method:b("notifications/cancelled"),params:Lg}),qg=k({src:A(),mimeType:A().optional(),sizes:_(A()).optional(),theme:Te(["light","dark"]).optional()}),Wr=k({icons:_(qg).optional()}),rr=k({name:A(),title:A().optional()}),ou=rr.extend({...rr.shape,...Wr.shape,version:A(),websiteUrl:A().optional(),description:A().optional()}),Gg=ti(k({applyDefaults:K().optional()}),X(A(),ne())),Hg=ri(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,ti(k({form:Gg.optional(),url:ue.optional()}),X(A(),ne()).optional())),Yg=le({list:ue.optional(),cancel:ue.optional(),requests:le({sampling:le({createMessage:ue.optional()}).optional(),elicitation:le({create:ue.optional()}).optional()}).optional()}),Jg=le({list:ue.optional(),cancel:ue.optional(),requests:le({tools:le({call:ue.optional()}).optional()}).optional()}),Wg=k({experimental:X(A(),ue).optional(),sampling:k({context:ue.optional(),tools:ue.optional()}).optional(),elicitation:Hg.optional(),roots:k({listChanged:K().optional()}).optional(),tasks:Yg.optional(),extensions:X(A(),ue).optional()}),Vg=Re.extend({protocolVersion:A(),capabilities:Wg,clientInfo:ou}),Kg=pe.extend({method:b("initialize"),params:Vg});var Zg=k({experimental:X(A(),ue).optional(),logging:ue.optional(),completions:ue.optional(),prompts:k({listChanged:K().optional()}).optional(),resources:k({subscribe:K().optional(),listChanged:K().optional()}).optional(),tools:k({listChanged:K().optional()}).optional(),tasks:Jg.optional(),extensions:X(A(),ue).optional()}),ci=me.extend({protocolVersion:A(),capabilities:Zg,serverInfo:ou,instructions:A().optional()}),nu=$e.extend({method:b("notifications/initialized"),params:De.optional()}),iu=t=>nu.safeParse(t).success,Co=pe.extend({method:b("ping"),params:Re.optional()}),Xg=k({progress:J(),total:oe(J()),message:oe(A())}),eh=k({...De.shape,...Xg.shape,progressToken:Kl}),Io=$e.extend({method:b("notifications/progress"),params:eh}),th=Re.extend({cursor:Zl.optional()}),Vr=pe.extend({params:th.optional()}),Kr=me.extend({nextCursor:Zl.optional()}),rh=Te(["working","input_required","completed","failed","cancelled"]),Zr=k({taskId:A(),status:rh,ttl:re([J(),Pl()]),createdAt:A(),lastUpdatedAt:A(),pollInterval:oe(J()),statusMessage:oe(A())}),Tt=me.extend({task:Zr}),sh=De.merge(Zr),Xr=$e.extend({method:b("notifications/tasks/status"),params:sh}),Bo=pe.extend({method:b("tasks/get"),params:Re.extend({taskId:A()})}),Qo=me.merge(Zr),_o=pe.extend({method:b("tasks/result"),params:Re.extend({taskId:A()})}),Cv=me.loose(),So=Vr.extend({method:b("tasks/list")}),ko=Kr.extend({tasks:_(Zr)}),Mo=pe.extend({method:b("tasks/cancel"),params:Re.extend({taskId:A()})}),au=me.merge(Zr),cu=k({uri:A(),mimeType:oe(A()),_meta:X(A(),ne()).optional()}),lu=cu.extend({text:A()}),li=A().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),uu=cu.extend({blob:li}),es=Te(["user","assistant"]),or=k({audience:_(es).optional(),priority:J().min(0).max(1).optional(),lastModified:Tl.datetime({offset:!0}).optional()}),du=k({...rr.shape,...Wr.shape,uri:A(),description:oe(A()),mimeType:oe(A()),size:oe(J()),annotations:or.optional(),_meta:oe(le({}))}),oh=k({...rr.shape,...Wr.shape,uriTemplate:A(),description:oe(A()),mimeType:oe(A()),annotations:or.optional(),_meta:oe(le({}))}),nh=Vr.extend({method:b("resources/list")}),ui=Kr.extend({resources:_(du)}),ih=Vr.extend({method:b("resources/templates/list")}),di=Kr.extend({resourceTemplates:_(oh)}),Ai=Re.extend({uri:A()}),ah=Ai,ch=pe.extend({method:b("resources/read"),params:ah}),pi=me.extend({contents:_(re([lu,uu]))}),mi=$e.extend({method:b("notifications/resources/list_changed"),params:De.optional()}),lh=Ai,uh=pe.extend({method:b("resources/subscribe"),params:lh}),dh=Ai,Ah=pe.extend({method:b("resources/unsubscribe"),params:dh}),ph=De.extend({uri:A()}),mh=$e.extend({method:b("notifications/resources/updated"),params:ph}),fh=k({name:A(),description:oe(A()),required:oe(K())}),gh=k({...rr.shape,...Wr.shape,description:oe(A()),arguments:oe(_(fh)),_meta:oe(le({}))}),hh=Vr.extend({method:b("prompts/list")}),fi=Kr.extend({prompts:_(gh)}),Eh=Re.extend({name:A(),arguments:X(A(),A()).optional()}),yh=pe.extend({method:b("prompts/get"),params:Eh}),gi=k({type:b("text"),text:A(),annotations:or.optional(),_meta:X(A(),ne()).optional()}),hi=k({type:b("image"),data:li,mimeType:A(),annotations:or.optional(),_meta:X(A(),ne()).optional()}),Ei=k({type:b("audio"),data:li,mimeType:A(),annotations:or.optional(),_meta:X(A(),ne()).optional()}),wh=k({type:b("tool_use"),name:A(),id:A(),input:X(A(),ne()),_meta:X(A(),ne()).optional()}),Ch=k({type:b("resource"),resource:re([lu,uu]),annotations:or.optional(),_meta:X(A(),ne()).optional()}),Ih=du.extend({type:b("resource_link")}),yi=re([gi,hi,Ei,Ih,Ch]),Bh=k({role:es,content:yi}),wi=me.extend({description:A().optional(),messages:_(Bh)}),Ci=$e.extend({method:b("notifications/prompts/list_changed"),params:De.optional()}),Qh=k({title:A().optional(),readOnlyHint:K().optional(),destructiveHint:K().optional(),idempotentHint:K().optional(),openWorldHint:K().optional()}),_h=k({taskSupport:Te(["required","optional","forbidden"]).optional()}),Au=k({...rr.shape,...Wr.shape,description:A().optional(),inputSchema:k({type:b("object"),properties:X(A(),ue).optional(),required:_(A()).optional()}).catchall(ne()),outputSchema:k({type:b("object"),properties:X(A(),ue).optional(),required:_(A()).optional()}).catchall(ne()).optional(),annotations:Qh.optional(),execution:_h.optional(),_meta:X(A(),ne()).optional()}),Sh=Vr.extend({method:b("tools/list")}),Ii=Kr.extend({tools:_(Au)}),nr=me.extend({content:_(yi).default([]),structuredContent:X(A(),ne()).optional(),isError:K().optional()}),Iv=nr.or(me.extend({toolResult:ne()})),kh=Yr.extend({name:A(),arguments:X(A(),ne()).optional()}),Mh=pe.extend({method:b("tools/call"),params:kh}),Bi=$e.extend({method:b("notifications/tools/list_changed"),params:De.optional()}),pu=k({autoRefresh:K().default(!0),debounceMs:J().int().nonnegative().default(300)}),mu=Te(["debug","info","notice","warning","error","critical","alert","emergency"]),vh=Re.extend({level:mu}),bh=pe.extend({method:b("logging/setLevel"),params:vh}),xh=De.extend({level:mu,logger:A().optional(),data:ne()}),Th=$e.extend({method:b("notifications/message"),params:xh}),Rh=k({name:A().optional()}),Dh=k({hints:_(Rh).optional(),costPriority:J().min(0).max(1).optional(),speedPriority:J().min(0).max(1).optional(),intelligencePriority:J().min(0).max(1).optional()}),$h=k({mode:Te(["auto","required","none"]).optional()}),Ph=k({type:b("tool_result"),toolUseId:A().describe("The unique identifier for the corresponding tool call."),content:_(yi).default([]),structuredContent:k({}).loose().optional(),isError:K().optional(),_meta:X(A(),ne()).optional()}),jh=ei("type",[gi,hi,Ei]),ho=ei("type",[gi,hi,Ei,wh,Ph]),Nh=k({role:es,content:re([ho,_(ho)]),_meta:X(A(),ne()).optional()}),zh=Yr.extend({messages:_(Nh),modelPreferences:Dh.optional(),systemPrompt:A().optional(),includeContext:Te(["none","thisServer","allServers"]).optional(),temperature:J().optional(),maxTokens:J().int(),stopSequences:_(A()).optional(),metadata:ue.optional(),tools:_(Au).optional(),toolChoice:$h.optional()}),Qi=pe.extend({method:b("sampling/createMessage"),params:zh}),_i=me.extend({model:A(),stopReason:oe(Te(["endTurn","stopSequence","maxTokens"]).or(A())),role:es,content:jh}),Si=me.extend({model:A(),stopReason:oe(Te(["endTurn","stopSequence","maxTokens","toolUse"]).or(A())),role:es,content:re([ho,_(ho)])}),Uh=k({type:b("boolean"),title:A().optional(),description:A().optional(),default:K().optional()}),Fh=k({type:b("string"),title:A().optional(),description:A().optional(),minLength:J().optional(),maxLength:J().optional(),format:Te(["email","uri","date","date-time"]).optional(),default:A().optional()}),Oh=k({type:Te(["number","integer"]),title:A().optional(),description:A().optional(),minimum:J().optional(),maximum:J().optional(),default:J().optional()}),Lh=k({type:b("string"),title:A().optional(),description:A().optional(),enum:_(A()),default:A().optional()}),qh=k({type:b("string"),title:A().optional(),description:A().optional(),oneOf:_(k({const:A(),title:A()})),default:A().optional()}),Gh=k({type:b("string"),title:A().optional(),description:A().optional(),enum:_(A()),enumNames:_(A()).optional(),default:A().optional()}),Hh=re([Lh,qh]),Yh=k({type:b("array"),title:A().optional(),description:A().optional(),minItems:J().optional(),maxItems:J().optional(),items:k({type:b("string"),enum:_(A())}),default:_(A()).optional()}),Jh=k({type:b("array"),title:A().optional(),description:A().optional(),minItems:J().optional(),maxItems:J().optional(),items:k({anyOf:_(k({const:A(),title:A()}))}),default:_(A()).optional()}),Wh=re([Yh,Jh]),Vh=re([Gh,Hh,Wh]),Kh=re([Vh,Uh,Fh,Oh]),Zh=Yr.extend({mode:b("form").optional(),message:A(),requestedSchema:k({type:b("object"),properties:X(A(),Kh),required:_(A()).optional()})}),Xh=Yr.extend({mode:b("url"),message:A(),elicitationId:A(),url:A().url()}),eE=re([Zh,Xh]),ki=pe.extend({method:b("elicitation/create"),params:eE}),tE=De.extend({elicitationId:A()}),rE=$e.extend({method:b("notifications/elicitation/complete"),params:tE}),Mi=me.extend({action:Te(["accept","decline","cancel"]),content:ri(t=>t===null?void 0:t,X(A(),re([A(),J(),K(),_(A())])).optional())}),sE=k({type:b("ref/resource"),uri:A()});var oE=k({type:b("ref/prompt"),name:A()}),nE=Re.extend({ref:re([oE,sE]),argument:k({name:A(),value:A()}),context:k({arguments:X(A(),A()).optional()}).optional()}),iE=pe.extend({method:b("completion/complete"),params:nE});var vi=me.extend({completion:le({values:_(A()).max(100),total:oe(J().int()),hasMore:oe(K())})}),aE=k({uri:A().startsWith("file://"),name:A().optional(),_meta:X(A(),ne()).optional()}),cE=pe.extend({method:b("roots/list"),params:Re.optional()}),lE=me.extend({roots:_(aE)}),uE=$e.extend({method:b("notifications/roots/list_changed"),params:De.optional()}),Bv=re([Co,Kg,iE,bh,yh,hh,nh,ih,ch,uh,Ah,Mh,Sh,Bo,_o,So,Mo]),Qv=re([wo,Io,nu,uE,Xr]),_v=re([xt,_i,Si,Mi,lE,Qo,ko,Tt]),Sv=re([Co,Qi,ki,cE,Bo,_o,So,Mo]),kv=re([wo,Io,Th,mh,mi,Bi,Ci,Xr,rE]),Mv=re([xt,ci,vi,wi,fi,ui,di,pi,nr,Ii,Qo,ko,Tt]),T=class t extends Error{constructor(e,r,s){super(`MCP error ${e}: ${r}`),this.code=e,this.data=s,this.name="McpError"}static fromError(e,r,s){if(e===P.UrlElicitationRequired&&s){let o=s;if(o.elicitations)return new oi(o.elicitations,r)}return new t(e,r,s)}},oi=class extends T{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(P.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function Et(t){return t==="completed"||t==="failed"||t==="cancelled"}var ab=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function bi(t){let r=uo(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let s=Ao(r);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function xi(t,e){let r=Ue(t,e);if(!r.success)throw r.error;return r.data}var gE=6e4,vo=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(wo,r=>{this._oncancel(r)}),this.setNotificationHandler(Io,r=>{this._onprogress(r)}),this.setRequestHandler(Co,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Bo,async(r,s)=>{let o=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!o)throw new T(P.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(_o,async(r,s)=>{let o=async()=>{let n=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(n,s.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,p=new T(d.error.code,d.error.message,d.error.data);l(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:s.requestId})}}let i=await this._taskStore.getTask(n,s.sessionId);if(!i)throw new T(P.InvalidParams,`Task not found: ${n}`);if(!Et(i.status))return await this._waitForTaskUpdate(n,s.signal),await o();if(Et(i.status)){let a=await this._taskStore.getTaskResult(n,s.sessionId);return this._clearTaskQueue(n),{...a,_meta:{...a._meta,[gt]:{taskId:n}}}}return await o()};return await o()}),this.setRequestHandler(So,async(r,s)=>{try{let{tasks:o,nextCursor:n}=await this._taskStore.listTasks(r.params?.cursor,s.sessionId);return{tasks:o,nextCursor:n,_meta:{}}}catch(o){throw new T(P.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Mo,async(r,s)=>{try{let o=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!o)throw new T(P.InvalidParams,`Task not found: ${r.params.taskId}`);if(Et(o.status))throw new T(P.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(r.params.taskId);let n=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!n)throw new T(P.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...n}}catch(o){throw o instanceof T?o:new T(P.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,s,o,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:s,resetTimeoutOnProgress:n,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let s=Date.now()-r.startTime;if(r.maxTotalTimeout&&s>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),T.fromError(P.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:s});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let s=this.transport?.onerror;this._transport.onerror=n=>{s?.(n),this._onerror(n)};let o=this._transport?.onmessage;this._transport.onmessage=(n,i)=>{o?.(n,i),bt(n)||su(n)?this._onresponse(n):Jr(n)?this._onrequest(n,i):ru(n)?this._onnotification(n):this._onerror(new Error(`Unknown message type: ${JSON.stringify(n)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let s of this._timeoutInfo.values())clearTimeout(s.timeoutId);this._timeoutInfo.clear();for(let s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();let r=T.fromError(P.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let s of e.values())s(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,r){let s=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,n=e.params?._meta?.[gt]?.taskId;if(s===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:P.MethodNotFound,message:"Method not found"}};n&&this._taskMessageQueue?this._enqueueTaskMessage(n,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=Xl(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};n&&(d.relatedTask={taskId:n}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(i.signal.aborted)throw new T(P.ConnectionClosed,"Request was cancelled");let m={...p,relatedRequestId:e.id};n&&!m.relatedTask&&(m.relatedTask={taskId:n});let g=m.relatedTask?.taskId??n;return g&&c&&await c.updateTaskStatus(g,"input_required"),await this.request(l,d,m)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:n,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};n&&this._taskMessageQueue?await this._enqueueTaskMessage(n,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:P.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};n&&this._taskMessageQueue?await this._enqueueTaskMessage(n,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...s}=e.params,o=Number(r),n=this._progressHandlers.get(o);if(!n){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}n(s)}_onresponse(e){let r=Number(e.id),s=this._requestResolvers.get(r);if(s){if(this._requestResolvers.delete(r),bt(e))s(e);else{let i=new T(e.error.code,e.error.message,e.error.data);s(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let n=!1;if(bt(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(n=!0,this._taskProgressTokens.set(a.taskId,r))}}if(n||this._progressHandlers.delete(r),bt(e))o(e);else{let i=T.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,s){let{task:o}=s??{};if(!o){try{yield{type:"result",result:await this.request(e,r,s)}}catch(i){yield{type:"error",error:i instanceof T?i:new T(P.InternalError,String(i))}}return}let n;try{let i=await this.request(e,Tt,s);if(i.task)n=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new T(P.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:n},s);if(yield{type:"taskStatus",task:a},Et(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:n},r,s)}:a.status==="failed"?yield{type:"error",error:new T(P.InternalError,`Task ${n} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new T(P.InternalError,`Task ${n} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:n},r,s)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),s?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof T?i:new T(P.InternalError,String(i))}}}request(e,r,s){let{relatedRequestId:o,resumptionToken:n,onresumptiontoken:i,task:a,relatedTask:c}=s??{};return new Promise((u,l)=>{let d=w=>{l(w)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(w){d(w);return}s?.signal?.throwIfAborted();let p=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:p};s?.onprogress&&(this._progressHandlers.set(p,s.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),a&&(m.params={...m.params,task:a}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[gt]:c}});let g=w=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(w)}},{relatedRequestId:o,resumptionToken:n,onresumptiontoken:i}).catch(v=>this._onerror(new Error(`Failed to send cancellation: ${v}`)));let I=w instanceof T?w:new T(P.RequestTimeout,String(w));l(I)};this._responseHandlers.set(p,w=>{if(!s?.signal?.aborted){if(w instanceof Error)return l(w);try{let I=Ue(r,w.result);I.success?u(I.data):l(I.error)}catch(I){l(I)}}}),s?.signal?.addEventListener("abort",()=>{g(s?.signal?.reason)});let f=s?.timeout??gE,h=()=>g(T.fromError(P.RequestTimeout,"Request timed out",{timeout:f}));this._setupTimeout(p,f,s?.maxTotalTimeout,h,s?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let w=I=>{let v=this._responseHandlers.get(p);v?v(I):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,w),this._enqueueTaskMessage(y,{type:"request",message:m,timestamp:Date.now()}).catch(I=>{this._cleanupTimeout(p),l(I)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:n,onresumptiontoken:i}).catch(w=>{this._cleanupTimeout(p),l(w)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Qo,r)}async getTaskResult(e,r,s){return this.request({method:"tasks/result",params:e},r,s)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},ko,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},au,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let s=r?.relatedTask?.taskId;if(s){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[gt]:r.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[gt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[gt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let s=bi(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(o,n)=>{let i=xi(e,o);return Promise.resolve(r(i,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,r){let s=bi(e);this._notificationHandlers.set(s,o=>{let n=xi(e,o);return Promise.resolve(r(n))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,s){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,s,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let s=await this._taskMessageQueue.dequeueAll(e,r);for(let o of s)if(o.type==="request"&&Jr(o.message)){let n=o.message.id,i=this._requestResolvers.get(n);i?(i(new T(P.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(n)):this._onerror(new Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let s=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(s=o.pollInterval)}catch{}return new Promise((o,n)=>{if(r.aborted){n(new T(P.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,s);r.addEventListener("abort",()=>{clearTimeout(i),n(new T(P.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await s.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let n=await s.getTask(o,r);if(!n)throw new T(P.InvalidParams,"Failed to retrieve task: Task not found");return n},storeTaskResult:async(o,n,i)=>{await s.storeTaskResult(o,n,i,r);let a=await s.getTask(o,r);if(a){let c=Xr.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Et(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>s.getTaskResult(o,r),updateTaskStatus:async(o,n,i)=>{let a=await s.getTask(o,r);if(!a)throw new T(P.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Et(a.status))throw new T(P.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${n}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(o,n,i,r);let c=await s.getTask(o,r);if(c){let u=Xr.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Et(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>s.listTasks(o,r)}}};function fu(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function gu(t,e){let r={...t};for(let s in e){let o=s,n=e[o];if(n===void 0)continue;let i=r[o];fu(i)&&fu(n)?r[o]={...i,...n}:r[o]=n}return r}var ap=lo(hc(),1),cp=lo(ip(),1);function wQ(){let t=new ap.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,cp.default)(t),t}var dn=class{constructor(e){this._ajv=e??wQ()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return s=>r(s)?{valid:!0,data:s,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var An=class{constructor(e){this._client=e}async*callToolStream(e,r=nr,s){let o=this._client,n={...s,task:s?.task??(o.isToolTask(e.name)?{}:void 0)},i=o.requestStream({method:"tools/call",params:e},r,n),a=o.getToolOutputValidator(e.name);for await(let c of i){if(c.type==="result"&&a){let u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new T(P.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{let l=a(u.structuredContent);if(!l.valid){yield{type:"error",error:new T(P.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof T){yield{type:"error",error:l};return}yield{type:"error",error:new T(P.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield c}}async getTask(e,r){return this._client.getTask({taskId:e},r)}async getTaskResult(e,r,s){return this._client.getTaskResult({taskId:e},r,s)}async listTasks(e,r){return this._client.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._client.cancelTask({taskId:e},r)}requestStream(e,r,s){return this._client.requestStream(e,r,s)}};function lp(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function up(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}function pn(t,e){if(!(!t||e===null||typeof e!="object")){if(t.type==="object"&&t.properties&&typeof t.properties=="object"){let r=e,s=t.properties;for(let o of Object.keys(s)){let n=s[o];r[o]===void 0&&Object.prototype.hasOwnProperty.call(n,"default")&&(r[o]=n.default),r[o]!==void 0&&pn(n,r[o])}}if(Array.isArray(t.anyOf))for(let r of t.anyOf)typeof r!="boolean"&&pn(r,e);if(Array.isArray(t.oneOf))for(let r of t.oneOf)typeof r!="boolean"&&pn(r,e)}}function CQ(t){if(!t)return{supportsFormMode:!1,supportsUrlMode:!1};let e=t.form!==void 0,r=t.url!==void 0;return{supportsFormMode:e||!e&&!r,supportsUrlMode:r}}var mn=class extends vo{constructor(e,r){super(r),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=r?.capabilities??{},this._jsonSchemaValidator=r?.jsonSchemaValidator??new dn,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",Bi,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Ci,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",mi,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new An(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=gu(this._capabilities,e)}setRequestHandler(e,r){let o=uo(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let n=Ao(o);if(typeof n!="string")throw new Error("Schema method literal must be a string");let i=n;if(i==="elicitation/create"){let a=async(c,u)=>{let l=Ue(ki,c);if(!l.success){let w=l.error instanceof Error?l.error.message:String(l.error);throw new T(P.InvalidParams,`Invalid elicitation request: ${w}`)}let{params:d}=l.data;d.mode=d.mode??"form";let{supportsFormMode:p,supportsUrlMode:m}=CQ(this._capabilities.elicitation);if(d.mode==="form"&&!p)throw new T(P.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!m)throw new T(P.InvalidParams,"Client does not support URL-mode elicitation requests");let g=await Promise.resolve(r(c,u));if(d.task){let w=Ue(Tt,g);if(!w.success){let I=w.error instanceof Error?w.error.message:String(w.error);throw new T(P.InvalidParams,`Invalid task creation result: ${I}`)}return w.data}let f=Ue(Mi,g);if(!f.success){let w=f.error instanceof Error?f.error.message:String(f.error);throw new T(P.InvalidParams,`Invalid elicitation result: ${w}`)}let h=f.data,y=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&h.action==="accept"&&h.content&&y&&this._capabilities.elicitation?.form?.applyDefaults)try{pn(y,h.content)}catch{}return h};return super.setRequestHandler(e,a)}if(i==="sampling/createMessage"){let a=async(c,u)=>{let l=Ue(Qi,c);if(!l.success){let h=l.error instanceof Error?l.error.message:String(l.error);throw new T(P.InvalidParams,`Invalid sampling request: ${h}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let h=Ue(Tt,p);if(!h.success){let y=h.error instanceof Error?h.error.message:String(h.error);throw new T(P.InvalidParams,`Invalid task creation result: ${y}`)}return h.data}let g=d.tools||d.toolChoice?Si:_i,f=Ue(g,p);if(!f.success){let h=f.error instanceof Error?f.error.message:String(f.error);throw new T(P.InvalidParams,`Invalid sampling result: ${h}`)}return f.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapability(e,r){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${r})`)}async connect(e,r){if(await super.connect(e),e.sessionId===void 0)try{let s=await this.request({method:"initialize",params:{protocolVersion:sr,capabilities:this._capabilities,clientInfo:this._clientInfo}},ci,r);if(s===void 0)throw new Error(`Server sent invalid initialize result: ${s}`);if(!Vl.includes(s.protocolVersion))throw new Error(`Server's protocol version is not supported: ${s.protocolVersion}`);this._serverCapabilities=s.capabilities,this._serverVersion=s.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(s.protocolVersion),this._instructions=s.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(s){throw this.close(),s}}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(e==="resources/subscribe"&&!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})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}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})`);break;case"ping":break}}assertTaskCapability(e){lp(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&up(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},xt,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},vi,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},xt,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},wi,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},fi,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},ui,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},di,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},pi,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},xt,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},xt,r)}async callTool(e,r=nr,s){if(this.isToolTaskRequired(e.name))throw new T(P.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let o=await this.request({method:"tools/call",params:e},r,s),n=this.getToolOutputValidator(e.name);if(n){if(!o.structuredContent&&!o.isError)throw new T(P.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(o.structuredContent)try{let i=n(o.structuredContent);if(!i.valid)throw new T(P.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof T?i:new T(P.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return o}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let r of e){if(r.outputSchema){let o=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,o)}let s=r.execution?.taskSupport;(s==="required"||s==="optional")&&this._cachedKnownTaskTools.add(r.name),s==="required"&&this._cachedRequiredTaskTools.add(r.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,r){let s=await this.request({method:"tools/list",params:e},Ii,r);return this.cacheToolMetadata(s.tools),s}_setupListChangedHandler(e,r,s,o){let n=pu.safeParse(s);if(!n.success)throw new Error(`Invalid ${e} listChanged options: ${n.error.message}`);if(typeof s.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:a}=n.data,{onChanged:c}=s,u=async()=>{if(!i){c(null,null);return}try{let d=await o();c(null,d)}catch(d){let p=d instanceof Error?d:new Error(String(d));c(p,null)}},l=()=>{if(a){let d=this._listChangedDebounceTimers.get(e);d&&clearTimeout(d);let p=setTimeout(u,a);this._listChangedDebounceTimers.set(e,p)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var xs=class extends Error{constructor(e,r){super(e),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}},dp=10,IQ=13,qt=32;function _c(t){}function fn(t){if(typeof t=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:e=_c,onError:r=_c,onRetry:s=_c,onComment:o,maxBufferSize:n}=t,i=[],a=0,c=!0,u,l="",d=0,p,m=!1;function g(E){if(m)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,E.charCodeAt(0)===239&&E.charCodeAt(1)===187&&E.charCodeAt(2)===191&&(E=E.slice(3))),i.length===0){let z=h(E);z!==""&&(i.push(z),a=z.length),f();return}if(E.indexOf(`
|
|
11
|
+
deps: ${r}}`};var JI={keyword:"dependencies",type:"object",schemaType:"object",error:Ze.error,code(t){let[e,r]=WI(t);gA(t,e),hA(t,r)}};function WI({schema:t}){let e={},r={};for(let s in t){if(s==="__proto__")continue;let o=Array.isArray(t[s])?e:r;o[s]=t[s]}return[e,r]}function gA(t,e=t.schema){let{gen:r,data:s,it:o}=t;if(Object.keys(e).length===0)return;let n=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,vs.propertyInData)(r,s,i,o.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,vs.checkReportMissingProp)(t,u)}):(r.if((0,Ka._)`${c} && (${(0,vs.checkMissingProp)(t,a,n)})`),(0,vs.reportMissingProp)(t,n),r.else())}}Ze.validatePropertyDeps=gA;function hA(t,e=t.schema){let{gen:r,data:s,keyword:o,it:n}=t,i=r.name("valid");for(let a in e)(0,YI.alwaysValidSchema)(n,e[a])||(r.if((0,vs.propertyInData)(r,s,a,n.opts.ownProperties),()=>{let c=t.subschema({keyword:o,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}Ze.validateSchemaDeps=hA;Ze.default=JI});var wA=Q(Za=>{"use strict";Object.defineProperty(Za,"__esModule",{value:!0});var yA=U(),VI=H(),KI={message:"property name must be valid",params:({params:t})=>(0,yA._)`{propertyName: ${t.propertyName}}`},ZI={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:KI,code(t){let{gen:e,schema:r,data:s,it:o}=t;if((0,VI.alwaysValidSchema)(o,r))return;let n=e.name("valid");e.forIn("key",s,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},n),e.if((0,yA.not)(n),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(n)}};Za.default=ZI});var ec=Q(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});var rn=je(),qe=U(),XI=nt(),sn=H(),eB={message:"must NOT have additional properties",params:({params:t})=>(0,qe._)`{additionalProperty: ${t.additionalProperty}}`},tB={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:eB,code(t){let{gen:e,schema:r,parentSchema:s,data:o,errsCount:n,it:i}=t;if(!n)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,sn.alwaysValidSchema)(i,r))return;let u=(0,rn.allSchemaProperties)(s.properties),l=(0,rn.allSchemaProperties)(s.patternProperties);d(),t.ok((0,qe._)`${n} === ${XI.default.errors}`);function d(){e.forIn("key",o,h=>{!u.length&&!l.length?g(h):e.if(p(h),()=>g(h))})}function p(h){let y;if(u.length>8){let w=(0,sn.schemaRefOrVal)(i,s.properties,"properties");y=(0,rn.isOwnProperty)(e,w,h)}else u.length?y=(0,qe.or)(...u.map(w=>(0,qe._)`${h} === ${w}`)):y=qe.nil;return l.length&&(y=(0,qe.or)(y,...l.map(w=>(0,qe._)`${(0,rn.usePattern)(t,w)}.test(${h})`))),(0,qe.not)(y)}function m(h){e.code((0,qe._)`delete ${o}[${h}]`)}function g(h){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){m(h);return}if(r===!1){t.setParams({additionalProperty:h}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,sn.alwaysValidSchema)(i,r)){let y=e.name("valid");c.removeAdditional==="failing"?(f(h,y,!1),e.if((0,qe.not)(y),()=>{t.reset(),m(h)})):(f(h,y),a||e.if((0,qe.not)(y),()=>e.break()))}}function f(h,y,w){let I={keyword:"additionalProperties",dataProp:h,dataPropType:sn.Type.Str};w===!1&&Object.assign(I,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(I,y)}}};Xa.default=tB});var BA=Q(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});var rB=fs(),CA=je(),tc=H(),IA=ec(),sB={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:s,data:o,it:n}=t;n.opts.removeAdditional==="all"&&s.additionalProperties===void 0&&IA.default.code(new rB.KeywordCxt(n,IA.default,"additionalProperties"));let i=(0,CA.allSchemaProperties)(r);for(let d of i)n.definedProperties.add(d);n.opts.unevaluated&&i.length&&n.props!==!0&&(n.props=tc.mergeEvaluated.props(e,(0,tc.toHash)(i),n.props));let a=i.filter(d=>!(0,tc.alwaysValidSchema)(n,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,CA.propertyInData)(e,o,d,n.opts.ownProperties)),l(d),n.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return n.opts.useDefaults&&!n.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};rc.default=sB});var kA=Q(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});var QA=je(),on=U(),_A=H(),SA=H(),oB={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:s,parentSchema:o,it:n}=t,{opts:i}=n,a=(0,QA.allSchemaProperties)(r),c=a.filter(f=>(0,_A.alwaysValidSchema)(n,r[f]));if(a.length===0||c.length===a.length&&(!n.opts.unevaluated||n.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=e.name("valid");n.props!==!0&&!(n.props instanceof on.Name)&&(n.props=(0,SA.evaluatedPropsToName)(e,n.props));let{props:d}=n;p();function p(){for(let f of a)u&&m(f),n.allErrors?g(f):(e.var(l,!0),g(f),e.if(l))}function m(f){for(let h in u)new RegExp(f).test(h)&&(0,_A.checkStrictMode)(n,`property ${h} matches pattern ${f} (use allowMatchingProperties)`)}function g(f){e.forIn("key",s,h=>{e.if((0,on._)`${(0,QA.usePattern)(t,f)}.test(${h})`,()=>{let y=c.includes(f);y||t.subschema({keyword:"patternProperties",schemaProp:f,dataProp:h,dataPropType:SA.Type.Str},l),n.opts.unevaluated&&d!==!0?e.assign((0,on._)`${d}[${h}]`,!0):!y&&!n.allErrors&&e.if((0,on.not)(l),()=>e.break())})})}}};sc.default=oB});var MA=Q(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});var nB=H(),iB={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:s}=t;if((0,nB.alwaysValidSchema)(s,r)){t.fail();return}let o=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),t.failResult(o,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};oc.default=iB});var vA=Q(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});var aB=je(),cB={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:aB.validateUnion,error:{message:"must match a schema in anyOf"}};nc.default=cB});var bA=Q(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});var nn=U(),lB=H(),uB={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,nn._)`{passingSchemas: ${t.passing}}`},dB={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:uB,code(t){let{gen:e,schema:r,parentSchema:s,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&s.discriminator)return;let n=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){n.forEach((l,d)=>{let p;(0,lB.alwaysValidSchema)(o,l)?e.var(c,!0):p=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,nn._)`${c} && ${i}`).assign(i,!1).assign(a,(0,nn._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),p&&t.mergeEvaluated(p,nn.Name)})})}}};ic.default=dB});var xA=Q(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});var AB=H(),pB={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:s}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=e.name("valid");r.forEach((n,i)=>{if((0,AB.alwaysValidSchema)(s,n))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};ac.default=pB});var DA=Q(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});var an=U(),RA=H(),mB={message:({params:t})=>(0,an.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,an._)`{failingKeyword: ${t.ifClause}}`},fB={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:mB,code(t){let{gen:e,parentSchema:r,it:s}=t;r.then===void 0&&r.else===void 0&&(0,RA.checkStrictMode)(s,'"if" without "then" and "else" is ignored');let o=TA(s,"then"),n=TA(s,"else");if(!o&&!n)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),o&&n){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else o?e.if(a,u("then")):e.if((0,an.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,d){return()=>{let p=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(p,i),d?e.assign(d,(0,an._)`${l}`):t.setParams({ifClause:l})}}}};function TA(t,e){let r=t.schema[e];return r!==void 0&&!(0,RA.alwaysValidSchema)(t,r)}cc.default=fB});var $A=Q(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});var gB=H(),hB={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,gB.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};lc.default=hB});var PA=Q(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});var EB=Ha(),yB=AA(),wB=Ya(),CB=mA(),IB=fA(),BB=EA(),QB=wA(),_B=ec(),SB=BA(),kB=kA(),MB=MA(),vB=vA(),bB=bA(),xB=xA(),TB=DA(),RB=$A();function DB(t=!1){let e=[MB.default,vB.default,bB.default,xB.default,TB.default,RB.default,QB.default,_B.default,BB.default,SB.default,kB.default];return t?e.push(yB.default,CB.default):e.push(EB.default,wB.default),e.push(IB.default),e}uc.default=DB});var jA=Q(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});var ie=U(),$B={message:({schemaCode:t})=>(0,ie.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,ie._)`{format: ${t}}`},PB={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:$B,code(t,e){let{gen:r,data:s,$data:o,schema:n,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?p():m();function p(){let g=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),f=r.const("fDef",(0,ie._)`${g}[${i}]`),h=r.let("fType"),y=r.let("format");r.if((0,ie._)`typeof ${f} == "object" && !(${f} instanceof RegExp)`,()=>r.assign(h,(0,ie._)`${f}.type || "string"`).assign(y,(0,ie._)`${f}.validate`),()=>r.assign(h,(0,ie._)`"string"`).assign(y,f)),t.fail$data((0,ie.or)(w(),I()));function w(){return c.strictSchema===!1?ie.nil:(0,ie._)`${i} && !${y}`}function I(){let v=l.$async?(0,ie._)`(${f}.async ? await ${y}(${s}) : ${y}(${s}))`:(0,ie._)`${y}(${s})`,E=(0,ie._)`(typeof ${y} == "function" ? ${v} : ${y}.test(${s}))`;return(0,ie._)`${y} && ${y} !== true && ${h} === ${e} && !${E}`}}function m(){let g=d.formats[n];if(!g){w();return}if(g===!0)return;let[f,h,y]=I(g);f===e&&t.pass(v());function w(){if(c.strictSchema===!1){d.logger.warn(E());return}throw new Error(E());function E(){return`unknown format "${n}" ignored in schema at path "${u}"`}}function I(E){let B=E instanceof RegExp?(0,ie.regexpCode)(E):c.code.formats?(0,ie._)`${c.code.formats}${(0,ie.getProperty)(n)}`:void 0,M=r.scopeValue("formats",{key:n,ref:E,code:B});return typeof E=="object"&&!(E instanceof RegExp)?[E.type||"string",E.validate,(0,ie._)`${M}.validate`]:["string",E,M]}function v(){if(typeof g=="object"&&!(g instanceof RegExp)&&g.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ie._)`await ${y}(${s})`}return typeof h=="function"?(0,ie._)`${y}(${s})`:(0,ie._)`${y}.test(${s})`}}}};dc.default=PB});var NA=Q(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});var jB=jA(),NB=[jB.default];Ac.default=NB});var zA=Q(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});Er.contentVocabulary=Er.metadataVocabulary=void 0;Er.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Er.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var FA=Q(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});var zB=Jd(),UB=cA(),FB=PA(),OB=NA(),UA=zA(),LB=[zB.default,UB.default,(0,FB.default)(),OB.default,UA.metadataVocabulary,UA.contentVocabulary];pc.default=LB});var LA=Q(cn=>{"use strict";Object.defineProperty(cn,"__esModule",{value:!0});cn.DiscrError=void 0;var OA;(function(t){t.Tag="tag",t.Mapping="mapping"})(OA||(cn.DiscrError=OA={}))});var GA=Q(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});var yr=U(),mc=LA(),qA=qo(),qB=gs(),GB=H(),HB={message:({params:{discrError:t,tagName:e}})=>t===mc.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,yr._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},YB={keyword:"discriminator",type:"object",schemaType:"object",error:HB,code(t){let{gen:e,data:r,schema:s,parentSchema:o,it:n}=t,{oneOf:i}=o;if(!n.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=s.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(s.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,yr._)`${r}${(0,yr.getProperty)(a)}`);e.if((0,yr._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:mc.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let m=p();e.if(!1);for(let g in m)e.elseIf((0,yr._)`${u} === ${g}`),e.assign(c,d(m[g]));e.else(),t.error(!1,{discrError:mc.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(m){let g=e.name("valid"),f=t.subschema({keyword:"oneOf",schemaProp:m},g);return t.mergeEvaluated(f,yr.Name),g}function p(){var m;let g={},f=y(o),h=!0;for(let v=0;v<i.length;v++){let E=i[v];if(E?.$ref&&!(0,GB.schemaHasRulesButRef)(E,n.self.RULES)){let M=E.$ref;if(E=qA.resolveRef.call(n.self,n.schemaEnv.root,n.baseId,M),E instanceof qA.SchemaEnv&&(E=E.schema),E===void 0)throw new qB.default(n.opts.uriResolver,n.baseId,M)}let B=(m=E?.properties)===null||m===void 0?void 0:m[a];if(typeof B!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);h=h&&(f||y(E)),w(B,v)}if(!h)throw new Error(`discriminator: "${a}" must be required`);return g;function y({required:v}){return Array.isArray(v)&&v.includes(a)}function w(v,E){if(v.const)I(v.const,E);else if(v.enum)for(let B of v.enum)I(B,E);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function I(v,E){if(typeof v!="string"||v in g)throw new Error(`discriminator: "${a}" values must be unique strings`);g[v]=E}}}};fc.default=YB});var HA=Q((yR,JB)=>{JB.exports={$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}});var hc=Q((te,gc)=>{"use strict";Object.defineProperty(te,"__esModule",{value:!0});te.MissingRefError=te.ValidationError=te.CodeGen=te.Name=te.nil=te.stringify=te.str=te._=te.KeywordCxt=te.Ajv=void 0;var WB=Od(),VB=FA(),KB=GA(),YA=HA(),ZB=["/properties"],ln="http://json-schema.org/draft-07/schema",wr=class extends WB.default{_addVocabularies(){super._addVocabularies(),VB.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(KB.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(YA,ZB):YA;this.addMetaSchema(e,ln,!1),this.refs["http://json-schema.org/schema"]=ln}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(ln)?ln:void 0)}};te.Ajv=wr;gc.exports=te=wr;gc.exports.Ajv=wr;Object.defineProperty(te,"__esModule",{value:!0});te.default=wr;var XB=fs();Object.defineProperty(te,"KeywordCxt",{enumerable:!0,get:function(){return XB.KeywordCxt}});var Cr=U();Object.defineProperty(te,"_",{enumerable:!0,get:function(){return Cr._}});Object.defineProperty(te,"str",{enumerable:!0,get:function(){return Cr.str}});Object.defineProperty(te,"stringify",{enumerable:!0,get:function(){return Cr.stringify}});Object.defineProperty(te,"nil",{enumerable:!0,get:function(){return Cr.nil}});Object.defineProperty(te,"Name",{enumerable:!0,get:function(){return Cr.Name}});Object.defineProperty(te,"CodeGen",{enumerable:!0,get:function(){return Cr.CodeGen}});var eQ=Oo();Object.defineProperty(te,"ValidationError",{enumerable:!0,get:function(){return eQ.default}});var tQ=gs();Object.defineProperty(te,"MissingRefError",{enumerable:!0,get:function(){return tQ.default}})});var tp=Q(et=>{"use strict";Object.defineProperty(et,"__esModule",{value:!0});et.formatNames=et.fastFormats=et.fullFormats=void 0;function Xe(t,e){return{validate:t,compare:e}}et.fullFormats={date:Xe(KA,Cc),time:Xe(yc(!0),Ic),"date-time":Xe(JA(!0),XA),"iso-time":Xe(yc(),ZA),"iso-date-time":Xe(JA(),ep),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:aQ,"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:mQ,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:cQ,int32:{type:"number",validate:dQ},int64:{type:"number",validate:AQ},float:{type:"number",validate:VA},double:{type:"number",validate:VA},password:!0,binary:!0};et.fastFormats={...et.fullFormats,date:Xe(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Cc),time:Xe(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Ic),"date-time":Xe(/^\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,XA),"iso-time":Xe(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,ZA),"iso-date-time":Xe(/^\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,ep),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};et.formatNames=Object.keys(et.fullFormats);function rQ(t){return t%4===0&&(t%100!==0||t%400===0)}var sQ=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,oQ=[0,31,28,31,30,31,30,31,31,30,31,30,31];function KA(t){let e=sQ.exec(t);if(!e)return!1;let r=+e[1],s=+e[2],o=+e[3];return s>=1&&s<=12&&o>=1&&o<=(s===2&&rQ(r)?29:oQ[s])}function Cc(t,e){if(t&&e)return t>e?1:t<e?-1:0}var Ec=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function yc(t){return function(r){let s=Ec.exec(r);if(!s)return!1;let o=+s[1],n=+s[2],i=+s[3],a=s[4],c=s[5]==="-"?-1:1,u=+(s[6]||0),l=+(s[7]||0);if(u>23||l>59||t&&!a)return!1;if(o<=23&&n<=59&&i<60)return!0;let d=n-l*c,p=o-u*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&i<61}}function Ic(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),s=new Date("2020-01-01T"+e).valueOf();if(r&&s)return r-s}function ZA(t,e){if(!(t&&e))return;let r=Ec.exec(t),s=Ec.exec(e);if(r&&s)return t=r[1]+r[2]+r[3],e=s[1]+s[2]+s[3],t>e?1:t<e?-1:0}var wc=/t|\s/i;function JA(t){let e=yc(t);return function(s){let o=s.split(wc);return o.length===2&&KA(o[0])&&e(o[1])}}function XA(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),s=new Date(e).valueOf();if(r&&s)return r-s}function ep(t,e){if(!(t&&e))return;let[r,s]=t.split(wc),[o,n]=e.split(wc),i=Cc(r,o);if(i!==void 0)return i||Ic(s,n)}var nQ=/\/|:/,iQ=/^(?:[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;function aQ(t){return nQ.test(t)&&iQ.test(t)}var WA=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function cQ(t){return WA.lastIndex=0,WA.test(t)}var lQ=-(2**31),uQ=2**31-1;function dQ(t){return Number.isInteger(t)&&t<=uQ&&t>=lQ}function AQ(t){return Number.isInteger(t)}function VA(){return!0}var pQ=/[^\\]\\Z/;function mQ(t){if(pQ.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var rp=Q(Ir=>{"use strict";Object.defineProperty(Ir,"__esModule",{value:!0});Ir.formatLimitDefinition=void 0;var fQ=hc(),Ge=U(),St=Ge.operators,un={formatMaximum:{okStr:"<=",ok:St.LTE,fail:St.GT},formatMinimum:{okStr:">=",ok:St.GTE,fail:St.LT},formatExclusiveMaximum:{okStr:"<",ok:St.LT,fail:St.GTE},formatExclusiveMinimum:{okStr:">",ok:St.GT,fail:St.LTE}},gQ={message:({keyword:t,schemaCode:e})=>(0,Ge.str)`should be ${un[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Ge._)`{comparison: ${un[t].okStr}, limit: ${e}}`};Ir.formatLimitDefinition={keyword:Object.keys(un),type:"string",schemaType:"string",$data:!0,error:gQ,code(t){let{gen:e,data:r,schemaCode:s,keyword:o,it:n}=t,{opts:i,self:a}=n;if(!i.validateFormats)return;let c=new fQ.KeywordCxt(n,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let p=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),m=e.const("fmt",(0,Ge._)`${p}[${c.schemaCode}]`);t.fail$data((0,Ge.or)((0,Ge._)`typeof ${m} != "object"`,(0,Ge._)`${m} instanceof RegExp`,(0,Ge._)`typeof ${m}.compare != "function"`,d(m)))}function l(){let p=c.schema,m=a.formats[p];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let g=e.scopeValue("formats",{key:p,ref:m,code:i.code.formats?(0,Ge._)`${i.code.formats}${(0,Ge.getProperty)(p)}`:void 0});t.fail$data(d(g))}function d(p){return(0,Ge._)`${p}.compare(${r}, ${s}) ${un[o].fail} 0`}},dependencies:["format"]};var hQ=t=>(t.addKeyword(Ir.formatLimitDefinition),t);Ir.default=hQ});var ip=Q((bs,np)=>{"use strict";Object.defineProperty(bs,"__esModule",{value:!0});var Br=tp(),EQ=rp(),Bc=U(),sp=new Bc.Name("fullFormats"),yQ=new Bc.Name("fastFormats"),Qc=(t,e={keywords:!0})=>{if(Array.isArray(e))return op(t,e,Br.fullFormats,sp),t;let[r,s]=e.mode==="fast"?[Br.fastFormats,yQ]:[Br.fullFormats,sp],o=e.formats||Br.formatNames;return op(t,o,r,s),e.keywords&&(0,EQ.default)(t),t};Qc.get=(t,e="full")=>{let s=(e==="fast"?Br.fastFormats:Br.fullFormats)[t];if(!s)throw new Error(`Unknown format "${t}"`);return s};function op(t,e,r,s){var o,n;(o=(n=t.opts.code).formats)!==null&&o!==void 0||(n.formats=(0,Bc._)`require("ajv-formats/dist/formats").${s}`);for(let i of e)t.addFormat(i,r[i])}np.exports=bs=Qc;Object.defineProperty(bs,"__esModule",{value:!0});bs.default=Qc});var $p=Q((tD,Dp)=>{"use strict";Dp.exports=Rp;Rp.sync=KQ;var xp=ft("fs");function VQ(t,e){var r=e.pathExt!==void 0?e.pathExt:process.env.PATHEXT;if(!r||(r=r.split(";"),r.indexOf("")!==-1))return!0;for(var s=0;s<r.length;s++){var o=r[s].toLowerCase();if(o&&t.substr(-o.length).toLowerCase()===o)return!0}return!1}function Tp(t,e,r){return!t.isSymbolicLink()&&!t.isFile()?!1:VQ(e,r)}function Rp(t,e,r){xp.stat(t,function(s,o){r(s,s?!1:Tp(o,t,e))})}function KQ(t,e){return Tp(xp.statSync(t),t,e)}});var Up=Q((rD,zp)=>{"use strict";zp.exports=jp;jp.sync=ZQ;var Pp=ft("fs");function jp(t,e,r){Pp.stat(t,function(s,o){r(s,s?!1:Np(o,e))})}function ZQ(t,e){return Np(Pp.statSync(t),e)}function Np(t,e){return t.isFile()&&XQ(t,e)}function XQ(t,e){var r=t.mode,s=t.uid,o=t.gid,n=e.uid!==void 0?e.uid:process.getuid&&process.getuid(),i=e.gid!==void 0?e.gid:process.getgid&&process.getgid(),a=parseInt("100",8),c=parseInt("010",8),u=parseInt("001",8),l=a|c,d=r&u||r&c&&o===i||r&a&&s===n||r&l&&n===0;return d}});var Op=Q((oD,Fp)=>{"use strict";var sD=ft("fs"),Cn;process.platform==="win32"||global.TESTING_WINDOWS?Cn=$p():Cn=Up();Fp.exports=qc;qc.sync=e_;function qc(t,e,r){if(typeof e=="function"&&(r=e,e={}),!r){if(typeof Promise!="function")throw new TypeError("callback not provided");return new Promise(function(s,o){qc(t,e||{},function(n,i){n?o(n):s(i)})})}Cn(t,e||{},function(s,o){s&&(s.code==="EACCES"||e&&e.ignoreErrors)&&(s=null,o=!1),r(s,o)})}function e_(t,e){try{return Cn.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var Wp=Q((nD,Jp)=>{"use strict";var xr=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",Lp=ft("path"),t_=xr?";":":",qp=Op(),Gp=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),Hp=(t,e)=>{let r=e.colon||t_,s=t.match(/\//)||xr&&t.match(/\\/)?[""]:[...xr?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],o=xr?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",n=xr?o.split(r):[""];return xr&&t.indexOf(".")!==-1&&n[0]!==""&&n.unshift(""),{pathEnv:s,pathExt:n,pathExtExe:o}},Yp=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});let{pathEnv:s,pathExt:o,pathExtExe:n}=Hp(t,e),i=[],a=u=>new Promise((l,d)=>{if(u===s.length)return e.all&&i.length?l(i):d(Gp(t));let p=s[u],m=/^".*"$/.test(p)?p.slice(1,-1):p,g=Lp.join(m,t),f=!m&&/^\.[\\\/]/.test(t)?t.slice(0,2)+g:g;l(c(f,u,0))}),c=(u,l,d)=>new Promise((p,m)=>{if(d===o.length)return p(a(l+1));let g=o[d];qp(u+g,{pathExt:n},(f,h)=>{if(!f&&h)if(e.all)i.push(u+g);else return p(u+g);return p(c(u,l,d+1))})});return r?a(0).then(u=>r(null,u),r):a(0)},r_=(t,e)=>{e=e||{};let{pathEnv:r,pathExt:s,pathExtExe:o}=Hp(t,e),n=[];for(let i=0;i<r.length;i++){let a=r[i],c=/^".*"$/.test(a)?a.slice(1,-1):a,u=Lp.join(c,t),l=!c&&/^\.[\\\/]/.test(t)?t.slice(0,2)+u:u;for(let d=0;d<s.length;d++){let p=l+s[d];try{if(qp.sync(p,{pathExt:o}))if(e.all)n.push(p);else return p}catch{}}}if(e.all&&n.length)return n;if(e.nothrow)return null;throw Gp(t)};Jp.exports=Yp;Yp.sync=r_});var Kp=Q((iD,Gc)=>{"use strict";var Vp=(t={})=>{let e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(s=>s.toUpperCase()==="PATH")||"Path"};Gc.exports=Vp;Gc.exports.default=Vp});var tm=Q((aD,em)=>{"use strict";var Zp=ft("path"),s_=Wp(),o_=Kp();function Xp(t,e){let r=t.options.env||process.env,s=process.cwd(),o=t.options.cwd!=null,n=o&&process.chdir!==void 0&&!process.chdir.disabled;if(n)try{process.chdir(t.options.cwd)}catch{}let i;try{i=s_.sync(t.command,{path:r[o_({env:r})],pathExt:e?Zp.delimiter:void 0})}catch{}finally{n&&process.chdir(s)}return i&&(i=Zp.resolve(o?t.options.cwd:"",i)),i}function n_(t){return Xp(t)||Xp(t,!0)}em.exports=n_});var rm=Q((cD,Yc)=>{"use strict";var Hc=/([()\][%!^"`<>&|;, *?])/g;function i_(t){return t=t.replace(Hc,"^$1"),t}function a_(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(Hc,"^$1"),e&&(t=t.replace(Hc,"^$1")),t}Yc.exports.command=i_;Yc.exports.argument=a_});var om=Q((lD,sm)=>{"use strict";sm.exports=/^#!(.*)/});var im=Q((uD,nm)=>{"use strict";var c_=om();nm.exports=(t="")=>{let e=t.match(c_);if(!e)return null;let[r,s]=e[0].replace(/#! ?/,"").split(" "),o=r.split("/").pop();return o==="env"?s:s?`${o} ${s}`:o}});var cm=Q((dD,am)=>{"use strict";var Jc=ft("fs"),l_=im();function u_(t){let r=Buffer.alloc(150),s;try{s=Jc.openSync(t,"r"),Jc.readSync(s,r,0,150,0),Jc.closeSync(s)}catch{}return l_(r.toString())}am.exports=u_});var Am=Q((AD,dm)=>{"use strict";var d_=ft("path"),lm=tm(),um=rm(),A_=cm(),p_=process.platform==="win32",m_=/\.(?:com|exe)$/i,f_=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function g_(t){t.file=lm(t);let e=t.file&&A_(t.file);return e?(t.args.unshift(t.file),t.command=e,lm(t)):t.file}function h_(t){if(!p_)return t;let e=g_(t),r=!m_.test(e);if(t.options.forceShell||r){let s=f_.test(e);t.command=d_.normalize(t.command),t.command=um.command(t.command),t.args=t.args.map(n=>um.argument(n,s));let o=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${o}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function E_(t,e,r){e&&!Array.isArray(e)&&(r=e,e=null),e=e?e.slice(0):[],r=Object.assign({},r);let s={command:t,args:e,options:r,file:void 0,original:{command:t,args:e}};return r.shell?s:h_(s)}dm.exports=E_});var fm=Q((pD,mm)=>{"use strict";var Wc=process.platform==="win32";function Vc(t,e){return Object.assign(new Error(`${e} ${t.command} ENOENT`),{code:"ENOENT",errno:"ENOENT",syscall:`${e} ${t.command}`,path:t.command,spawnargs:t.args})}function y_(t,e){if(!Wc)return;let r=t.emit;t.emit=function(s,o){if(s==="exit"){let n=pm(o,e);if(n)return r.call(t,"error",n)}return r.apply(t,arguments)}}function pm(t,e){return Wc&&t===1&&!e.file?Vc(e.original,"spawn"):null}function w_(t,e){return Wc&&t===1&&!e.file?Vc(e.original,"spawnSync"):null}mm.exports={hookChildProcess:y_,verifyENOENT:pm,verifyENOENTSync:w_,notFoundError:Vc}});var Em=Q((mD,Tr)=>{"use strict";var gm=ft("child_process"),Kc=Am(),Zc=fm();function hm(t,e,r){let s=Kc(t,e,r),o=gm.spawn(s.command,s.args,s.options);return Zc.hookChildProcess(o,s),o}function C_(t,e,r){let s=Kc(t,e,r),o=gm.spawnSync(s.command,s.args,s.options);return o.error=o.error||Zc.verifyENOENTSync(o.status,s),o}Tr.exports=hm;Tr.exports.spawn=hm;Tr.exports.sync=C_;Tr.exports._parse=Kc;Tr.exports._enoent=Zc});var Qm=Q(el=>{"use strict";var Cm=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,k_=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,Im=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,M_=/\\([\u000b\u0020-\u00ff])/g,v_=/([\\"])/g,Bm=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;el.format=b_;el.parse=x_;function b_(t){if(!t||typeof t!="object")throw new TypeError("argument obj is required");var e=t.parameters,r=t.type;if(!r||!Bm.test(r))throw new TypeError("invalid type");var s=r;if(e&&typeof e=="object")for(var o,n=Object.keys(e).sort(),i=0;i<n.length;i++){if(o=n[i],!Im.test(o))throw new TypeError("invalid parameter name");s+="; "+o+"="+R_(e[o])}return s}function x_(t){if(!t)throw new TypeError("argument string is required");var e=typeof t=="object"?T_(t):t;if(typeof e!="string")throw new TypeError("argument string is required to be a string");var r=e.indexOf(";"),s=r!==-1?e.slice(0,r).trim():e.trim();if(!Bm.test(s))throw new TypeError("invalid media type");var o=new D_(s.toLowerCase());if(r!==-1){var n,i,a;for(Cm.lastIndex=r;i=Cm.exec(e);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,n=i[1].toLowerCase(),a=i[2],a.charCodeAt(0)===34&&(a=a.slice(1,-1),a.indexOf("\\")!==-1&&(a=a.replace(M_,"$1"))),o.parameters[n]=a}if(r!==e.length)throw new TypeError("invalid parameter format")}return o}function T_(t){var e;if(typeof t.getHeader=="function"?e=t.getHeader("content-type"):typeof t.headers=="object"&&(e=t.headers&&t.headers["content-type"]),typeof e!="string")throw new TypeError("content-type header is missing from object");return e}function R_(t){var e=String(t);if(Im.test(e))return e;if(e.length>0&&!k_.test(e))throw new TypeError("invalid parameter value");return'"'+e.replace(v_,"\\$1")+'"'}function D_(t){this.parameters=Object.create(null),this.type=t}});async function si(t,e){switch(t.protocol){case"anthropic":{let{AnthropicClient:r}=await import("./anthropic-7QRAPLOY.js");return new r(t,e)}case"openai":{let{OpenAIClient:r}=await import("./openai-6MXNADYN.js");return new r(t,e)}case"openai-compat":{let{OpenAICompatClient:r}=await import("./openai-6MXNADYN.js");return new r(t,e)}default:throw new Error(`Unknown protocol: ${String(t.protocol)}`)}}var sr="2025-11-25";var Vl=[sr,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],gt="io.modelcontextprotocol/related-task",Eo="2.0",ue=Nl(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Kl=re([A(),J().int()]),Zl=A(),yv=le({ttl:J().optional(),pollInterval:J().optional()}),Fg=k({ttl:J().optional()}),Og=k({taskId:A()}),ni=le({progressToken:Kl.optional(),[gt]:Og.optional()}),Re=k({_meta:ni.optional()}),Yr=Re.extend({task:Fg.optional()}),Xl=t=>Yr.safeParse(t).success,pe=k({method:A(),params:Re.loose().optional()}),De=k({_meta:ni.optional()}),$e=k({method:A(),params:De.loose().optional()}),me=le({_meta:ni.optional()}),yo=re([A(),J().int()]),eu=k({jsonrpc:b(Eo),id:yo,...pe.shape}).strict(),Jr=t=>eu.safeParse(t).success,tu=k({jsonrpc:b(Eo),...$e.shape}).strict(),ru=t=>tu.safeParse(t).success,ii=k({jsonrpc:b(Eo),id:yo,result:me}).strict(),bt=t=>ii.safeParse(t).success;var P;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(P||(P={}));var ai=k({jsonrpc:b(Eo),id:yo.optional(),error:k({code:J().int(),message:A(),data:ne().optional()})}).strict();var su=t=>ai.safeParse(t).success;var ht=re([eu,tu,ii,ai]),wv=re([ii,ai]),xt=me.strict(),Lg=De.extend({requestId:yo.optional(),reason:A().optional()}),wo=$e.extend({method:b("notifications/cancelled"),params:Lg}),qg=k({src:A(),mimeType:A().optional(),sizes:_(A()).optional(),theme:Te(["light","dark"]).optional()}),Wr=k({icons:_(qg).optional()}),rr=k({name:A(),title:A().optional()}),ou=rr.extend({...rr.shape,...Wr.shape,version:A(),websiteUrl:A().optional(),description:A().optional()}),Gg=ti(k({applyDefaults:K().optional()}),X(A(),ne())),Hg=ri(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,ti(k({form:Gg.optional(),url:ue.optional()}),X(A(),ne()).optional())),Yg=le({list:ue.optional(),cancel:ue.optional(),requests:le({sampling:le({createMessage:ue.optional()}).optional(),elicitation:le({create:ue.optional()}).optional()}).optional()}),Jg=le({list:ue.optional(),cancel:ue.optional(),requests:le({tools:le({call:ue.optional()}).optional()}).optional()}),Wg=k({experimental:X(A(),ue).optional(),sampling:k({context:ue.optional(),tools:ue.optional()}).optional(),elicitation:Hg.optional(),roots:k({listChanged:K().optional()}).optional(),tasks:Yg.optional(),extensions:X(A(),ue).optional()}),Vg=Re.extend({protocolVersion:A(),capabilities:Wg,clientInfo:ou}),Kg=pe.extend({method:b("initialize"),params:Vg});var Zg=k({experimental:X(A(),ue).optional(),logging:ue.optional(),completions:ue.optional(),prompts:k({listChanged:K().optional()}).optional(),resources:k({subscribe:K().optional(),listChanged:K().optional()}).optional(),tools:k({listChanged:K().optional()}).optional(),tasks:Jg.optional(),extensions:X(A(),ue).optional()}),ci=me.extend({protocolVersion:A(),capabilities:Zg,serverInfo:ou,instructions:A().optional()}),nu=$e.extend({method:b("notifications/initialized"),params:De.optional()}),iu=t=>nu.safeParse(t).success,Co=pe.extend({method:b("ping"),params:Re.optional()}),Xg=k({progress:J(),total:oe(J()),message:oe(A())}),eh=k({...De.shape,...Xg.shape,progressToken:Kl}),Io=$e.extend({method:b("notifications/progress"),params:eh}),th=Re.extend({cursor:Zl.optional()}),Vr=pe.extend({params:th.optional()}),Kr=me.extend({nextCursor:Zl.optional()}),rh=Te(["working","input_required","completed","failed","cancelled"]),Zr=k({taskId:A(),status:rh,ttl:re([J(),Pl()]),createdAt:A(),lastUpdatedAt:A(),pollInterval:oe(J()),statusMessage:oe(A())}),Tt=me.extend({task:Zr}),sh=De.merge(Zr),Xr=$e.extend({method:b("notifications/tasks/status"),params:sh}),Bo=pe.extend({method:b("tasks/get"),params:Re.extend({taskId:A()})}),Qo=me.merge(Zr),_o=pe.extend({method:b("tasks/result"),params:Re.extend({taskId:A()})}),Cv=me.loose(),So=Vr.extend({method:b("tasks/list")}),ko=Kr.extend({tasks:_(Zr)}),Mo=pe.extend({method:b("tasks/cancel"),params:Re.extend({taskId:A()})}),au=me.merge(Zr),cu=k({uri:A(),mimeType:oe(A()),_meta:X(A(),ne()).optional()}),lu=cu.extend({text:A()}),li=A().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),uu=cu.extend({blob:li}),es=Te(["user","assistant"]),or=k({audience:_(es).optional(),priority:J().min(0).max(1).optional(),lastModified:Tl.datetime({offset:!0}).optional()}),du=k({...rr.shape,...Wr.shape,uri:A(),description:oe(A()),mimeType:oe(A()),size:oe(J()),annotations:or.optional(),_meta:oe(le({}))}),oh=k({...rr.shape,...Wr.shape,uriTemplate:A(),description:oe(A()),mimeType:oe(A()),annotations:or.optional(),_meta:oe(le({}))}),nh=Vr.extend({method:b("resources/list")}),ui=Kr.extend({resources:_(du)}),ih=Vr.extend({method:b("resources/templates/list")}),di=Kr.extend({resourceTemplates:_(oh)}),Ai=Re.extend({uri:A()}),ah=Ai,ch=pe.extend({method:b("resources/read"),params:ah}),pi=me.extend({contents:_(re([lu,uu]))}),mi=$e.extend({method:b("notifications/resources/list_changed"),params:De.optional()}),lh=Ai,uh=pe.extend({method:b("resources/subscribe"),params:lh}),dh=Ai,Ah=pe.extend({method:b("resources/unsubscribe"),params:dh}),ph=De.extend({uri:A()}),mh=$e.extend({method:b("notifications/resources/updated"),params:ph}),fh=k({name:A(),description:oe(A()),required:oe(K())}),gh=k({...rr.shape,...Wr.shape,description:oe(A()),arguments:oe(_(fh)),_meta:oe(le({}))}),hh=Vr.extend({method:b("prompts/list")}),fi=Kr.extend({prompts:_(gh)}),Eh=Re.extend({name:A(),arguments:X(A(),A()).optional()}),yh=pe.extend({method:b("prompts/get"),params:Eh}),gi=k({type:b("text"),text:A(),annotations:or.optional(),_meta:X(A(),ne()).optional()}),hi=k({type:b("image"),data:li,mimeType:A(),annotations:or.optional(),_meta:X(A(),ne()).optional()}),Ei=k({type:b("audio"),data:li,mimeType:A(),annotations:or.optional(),_meta:X(A(),ne()).optional()}),wh=k({type:b("tool_use"),name:A(),id:A(),input:X(A(),ne()),_meta:X(A(),ne()).optional()}),Ch=k({type:b("resource"),resource:re([lu,uu]),annotations:or.optional(),_meta:X(A(),ne()).optional()}),Ih=du.extend({type:b("resource_link")}),yi=re([gi,hi,Ei,Ih,Ch]),Bh=k({role:es,content:yi}),wi=me.extend({description:A().optional(),messages:_(Bh)}),Ci=$e.extend({method:b("notifications/prompts/list_changed"),params:De.optional()}),Qh=k({title:A().optional(),readOnlyHint:K().optional(),destructiveHint:K().optional(),idempotentHint:K().optional(),openWorldHint:K().optional()}),_h=k({taskSupport:Te(["required","optional","forbidden"]).optional()}),Au=k({...rr.shape,...Wr.shape,description:A().optional(),inputSchema:k({type:b("object"),properties:X(A(),ue).optional(),required:_(A()).optional()}).catchall(ne()),outputSchema:k({type:b("object"),properties:X(A(),ue).optional(),required:_(A()).optional()}).catchall(ne()).optional(),annotations:Qh.optional(),execution:_h.optional(),_meta:X(A(),ne()).optional()}),Sh=Vr.extend({method:b("tools/list")}),Ii=Kr.extend({tools:_(Au)}),nr=me.extend({content:_(yi).default([]),structuredContent:X(A(),ne()).optional(),isError:K().optional()}),Iv=nr.or(me.extend({toolResult:ne()})),kh=Yr.extend({name:A(),arguments:X(A(),ne()).optional()}),Mh=pe.extend({method:b("tools/call"),params:kh}),Bi=$e.extend({method:b("notifications/tools/list_changed"),params:De.optional()}),pu=k({autoRefresh:K().default(!0),debounceMs:J().int().nonnegative().default(300)}),mu=Te(["debug","info","notice","warning","error","critical","alert","emergency"]),vh=Re.extend({level:mu}),bh=pe.extend({method:b("logging/setLevel"),params:vh}),xh=De.extend({level:mu,logger:A().optional(),data:ne()}),Th=$e.extend({method:b("notifications/message"),params:xh}),Rh=k({name:A().optional()}),Dh=k({hints:_(Rh).optional(),costPriority:J().min(0).max(1).optional(),speedPriority:J().min(0).max(1).optional(),intelligencePriority:J().min(0).max(1).optional()}),$h=k({mode:Te(["auto","required","none"]).optional()}),Ph=k({type:b("tool_result"),toolUseId:A().describe("The unique identifier for the corresponding tool call."),content:_(yi).default([]),structuredContent:k({}).loose().optional(),isError:K().optional(),_meta:X(A(),ne()).optional()}),jh=ei("type",[gi,hi,Ei]),ho=ei("type",[gi,hi,Ei,wh,Ph]),Nh=k({role:es,content:re([ho,_(ho)]),_meta:X(A(),ne()).optional()}),zh=Yr.extend({messages:_(Nh),modelPreferences:Dh.optional(),systemPrompt:A().optional(),includeContext:Te(["none","thisServer","allServers"]).optional(),temperature:J().optional(),maxTokens:J().int(),stopSequences:_(A()).optional(),metadata:ue.optional(),tools:_(Au).optional(),toolChoice:$h.optional()}),Qi=pe.extend({method:b("sampling/createMessage"),params:zh}),_i=me.extend({model:A(),stopReason:oe(Te(["endTurn","stopSequence","maxTokens"]).or(A())),role:es,content:jh}),Si=me.extend({model:A(),stopReason:oe(Te(["endTurn","stopSequence","maxTokens","toolUse"]).or(A())),role:es,content:re([ho,_(ho)])}),Uh=k({type:b("boolean"),title:A().optional(),description:A().optional(),default:K().optional()}),Fh=k({type:b("string"),title:A().optional(),description:A().optional(),minLength:J().optional(),maxLength:J().optional(),format:Te(["email","uri","date","date-time"]).optional(),default:A().optional()}),Oh=k({type:Te(["number","integer"]),title:A().optional(),description:A().optional(),minimum:J().optional(),maximum:J().optional(),default:J().optional()}),Lh=k({type:b("string"),title:A().optional(),description:A().optional(),enum:_(A()),default:A().optional()}),qh=k({type:b("string"),title:A().optional(),description:A().optional(),oneOf:_(k({const:A(),title:A()})),default:A().optional()}),Gh=k({type:b("string"),title:A().optional(),description:A().optional(),enum:_(A()),enumNames:_(A()).optional(),default:A().optional()}),Hh=re([Lh,qh]),Yh=k({type:b("array"),title:A().optional(),description:A().optional(),minItems:J().optional(),maxItems:J().optional(),items:k({type:b("string"),enum:_(A())}),default:_(A()).optional()}),Jh=k({type:b("array"),title:A().optional(),description:A().optional(),minItems:J().optional(),maxItems:J().optional(),items:k({anyOf:_(k({const:A(),title:A()}))}),default:_(A()).optional()}),Wh=re([Yh,Jh]),Vh=re([Gh,Hh,Wh]),Kh=re([Vh,Uh,Fh,Oh]),Zh=Yr.extend({mode:b("form").optional(),message:A(),requestedSchema:k({type:b("object"),properties:X(A(),Kh),required:_(A()).optional()})}),Xh=Yr.extend({mode:b("url"),message:A(),elicitationId:A(),url:A().url()}),eE=re([Zh,Xh]),ki=pe.extend({method:b("elicitation/create"),params:eE}),tE=De.extend({elicitationId:A()}),rE=$e.extend({method:b("notifications/elicitation/complete"),params:tE}),Mi=me.extend({action:Te(["accept","decline","cancel"]),content:ri(t=>t===null?void 0:t,X(A(),re([A(),J(),K(),_(A())])).optional())}),sE=k({type:b("ref/resource"),uri:A()});var oE=k({type:b("ref/prompt"),name:A()}),nE=Re.extend({ref:re([oE,sE]),argument:k({name:A(),value:A()}),context:k({arguments:X(A(),A()).optional()}).optional()}),iE=pe.extend({method:b("completion/complete"),params:nE});var vi=me.extend({completion:le({values:_(A()).max(100),total:oe(J().int()),hasMore:oe(K())})}),aE=k({uri:A().startsWith("file://"),name:A().optional(),_meta:X(A(),ne()).optional()}),cE=pe.extend({method:b("roots/list"),params:Re.optional()}),lE=me.extend({roots:_(aE)}),uE=$e.extend({method:b("notifications/roots/list_changed"),params:De.optional()}),Bv=re([Co,Kg,iE,bh,yh,hh,nh,ih,ch,uh,Ah,Mh,Sh,Bo,_o,So,Mo]),Qv=re([wo,Io,nu,uE,Xr]),_v=re([xt,_i,Si,Mi,lE,Qo,ko,Tt]),Sv=re([Co,Qi,ki,cE,Bo,_o,So,Mo]),kv=re([wo,Io,Th,mh,mi,Bi,Ci,Xr,rE]),Mv=re([xt,ci,vi,wi,fi,ui,di,pi,nr,Ii,Qo,ko,Tt]),T=class t extends Error{constructor(e,r,s){super(`MCP error ${e}: ${r}`),this.code=e,this.data=s,this.name="McpError"}static fromError(e,r,s){if(e===P.UrlElicitationRequired&&s){let o=s;if(o.elicitations)return new oi(o.elicitations,r)}return new t(e,r,s)}},oi=class extends T{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(P.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function Et(t){return t==="completed"||t==="failed"||t==="cancelled"}var ab=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function bi(t){let r=uo(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let s=Ao(r);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function xi(t,e){let r=Ue(t,e);if(!r.success)throw r.error;return r.data}var gE=6e4,vo=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(wo,r=>{this._oncancel(r)}),this.setNotificationHandler(Io,r=>{this._onprogress(r)}),this.setRequestHandler(Co,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Bo,async(r,s)=>{let o=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!o)throw new T(P.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(_o,async(r,s)=>{let o=async()=>{let n=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(n,s.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,p=new T(d.error.code,d.error.message,d.error.data);l(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:s.requestId})}}let i=await this._taskStore.getTask(n,s.sessionId);if(!i)throw new T(P.InvalidParams,`Task not found: ${n}`);if(!Et(i.status))return await this._waitForTaskUpdate(n,s.signal),await o();if(Et(i.status)){let a=await this._taskStore.getTaskResult(n,s.sessionId);return this._clearTaskQueue(n),{...a,_meta:{...a._meta,[gt]:{taskId:n}}}}return await o()};return await o()}),this.setRequestHandler(So,async(r,s)=>{try{let{tasks:o,nextCursor:n}=await this._taskStore.listTasks(r.params?.cursor,s.sessionId);return{tasks:o,nextCursor:n,_meta:{}}}catch(o){throw new T(P.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Mo,async(r,s)=>{try{let o=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!o)throw new T(P.InvalidParams,`Task not found: ${r.params.taskId}`);if(Et(o.status))throw new T(P.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(r.params.taskId);let n=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!n)throw new T(P.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...n}}catch(o){throw o instanceof T?o:new T(P.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,s,o,n=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:s,resetTimeoutOnProgress:n,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let s=Date.now()-r.startTime;if(r.maxTotalTimeout&&s>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),T.fromError(P.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:s});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let s=this.transport?.onerror;this._transport.onerror=n=>{s?.(n),this._onerror(n)};let o=this._transport?.onmessage;this._transport.onmessage=(n,i)=>{o?.(n,i),bt(n)||su(n)?this._onresponse(n):Jr(n)?this._onrequest(n,i):ru(n)?this._onnotification(n):this._onerror(new Error(`Unknown message type: ${JSON.stringify(n)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let s of this._timeoutInfo.values())clearTimeout(s.timeoutId);this._timeoutInfo.clear();for(let s of this._requestHandlerAbortControllers.values())s.abort();this._requestHandlerAbortControllers.clear();let r=T.fromError(P.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let s of e.values())s(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(s=>this._onerror(new Error(`Uncaught error in notification handler: ${s}`)))}_onrequest(e,r){let s=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,n=e.params?._meta?.[gt]?.taskId;if(s===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:P.MethodNotFound,message:"Method not found"}};n&&this._taskMessageQueue?this._enqueueTaskMessage(n,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=Xl(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};n&&(d.relatedTask={taskId:n}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(i.signal.aborted)throw new T(P.ConnectionClosed,"Request was cancelled");let m={...p,relatedRequestId:e.id};n&&!m.relatedTask&&(m.relatedTask={taskId:n});let g=m.relatedTask?.taskId??n;return g&&c&&await c.updateTaskStatus(g,"input_required"),await this.request(l,d,m)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:n,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};n&&this._taskMessageQueue?await this._enqueueTaskMessage(n,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:P.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};n&&this._taskMessageQueue?await this._enqueueTaskMessage(n,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...s}=e.params,o=Number(r),n=this._progressHandlers.get(o);if(!n){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}n(s)}_onresponse(e){let r=Number(e.id),s=this._requestResolvers.get(r);if(s){if(this._requestResolvers.delete(r),bt(e))s(e);else{let i=new T(e.error.code,e.error.message,e.error.data);s(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let n=!1;if(bt(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(n=!0,this._taskProgressTokens.set(a.taskId,r))}}if(n||this._progressHandlers.delete(r),bt(e))o(e);else{let i=T.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,s){let{task:o}=s??{};if(!o){try{yield{type:"result",result:await this.request(e,r,s)}}catch(i){yield{type:"error",error:i instanceof T?i:new T(P.InternalError,String(i))}}return}let n;try{let i=await this.request(e,Tt,s);if(i.task)n=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new T(P.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:n},s);if(yield{type:"taskStatus",task:a},Et(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:n},r,s)}:a.status==="failed"?yield{type:"error",error:new T(P.InternalError,`Task ${n} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new T(P.InternalError,`Task ${n} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:n},r,s)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),s?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof T?i:new T(P.InternalError,String(i))}}}request(e,r,s){let{relatedRequestId:o,resumptionToken:n,onresumptiontoken:i,task:a,relatedTask:c}=s??{};return new Promise((u,l)=>{let d=w=>{l(w)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(w){d(w);return}s?.signal?.throwIfAborted();let p=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:p};s?.onprogress&&(this._progressHandlers.set(p,s.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),a&&(m.params={...m.params,task:a}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[gt]:c}});let g=w=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(w)}},{relatedRequestId:o,resumptionToken:n,onresumptiontoken:i}).catch(v=>this._onerror(new Error(`Failed to send cancellation: ${v}`)));let I=w instanceof T?w:new T(P.RequestTimeout,String(w));l(I)};this._responseHandlers.set(p,w=>{if(!s?.signal?.aborted){if(w instanceof Error)return l(w);try{let I=Ue(r,w.result);I.success?u(I.data):l(I.error)}catch(I){l(I)}}}),s?.signal?.addEventListener("abort",()=>{g(s?.signal?.reason)});let f=s?.timeout??gE,h=()=>g(T.fromError(P.RequestTimeout,"Request timed out",{timeout:f}));this._setupTimeout(p,f,s?.maxTotalTimeout,h,s?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let w=I=>{let v=this._responseHandlers.get(p);v?v(I):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,w),this._enqueueTaskMessage(y,{type:"request",message:m,timestamp:Date.now()}).catch(I=>{this._cleanupTimeout(p),l(I)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:n,onresumptiontoken:i}).catch(w=>{this._cleanupTimeout(p),l(w)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Qo,r)}async getTaskResult(e,r,s){return this.request({method:"tasks/result",params:e},r,s)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},ko,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},au,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let s=r?.relatedTask?.taskId;if(s){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[gt]:r.relatedTask}}};await this._enqueueTaskMessage(s,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[gt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[gt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let s=bi(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(o,n)=>{let i=xi(e,o);return Promise.resolve(r(i,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,r){let s=bi(e);this._notificationHandlers.set(s,o=>{let n=xi(e,o);return Promise.resolve(r(n))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,s){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,s,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let s=await this._taskMessageQueue.dequeueAll(e,r);for(let o of s)if(o.type==="request"&&Jr(o.message)){let n=o.message.id,i=this._requestResolvers.get(n);i?(i(new T(P.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(n)):this._onerror(new Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let s=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(s=o.pollInterval)}catch{}return new Promise((o,n)=>{if(r.aborted){n(new T(P.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,s);r.addEventListener("abort",()=>{clearTimeout(i),n(new T(P.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await s.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let n=await s.getTask(o,r);if(!n)throw new T(P.InvalidParams,"Failed to retrieve task: Task not found");return n},storeTaskResult:async(o,n,i)=>{await s.storeTaskResult(o,n,i,r);let a=await s.getTask(o,r);if(a){let c=Xr.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Et(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>s.getTaskResult(o,r),updateTaskStatus:async(o,n,i)=>{let a=await s.getTask(o,r);if(!a)throw new T(P.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Et(a.status))throw new T(P.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${n}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(o,n,i,r);let c=await s.getTask(o,r);if(c){let u=Xr.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Et(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>s.listTasks(o,r)}}};function fu(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function gu(t,e){let r={...t};for(let s in e){let o=s,n=e[o];if(n===void 0)continue;let i=r[o];fu(i)&&fu(n)?r[o]={...i,...n}:r[o]=n}return r}var ap=lo(hc(),1),cp=lo(ip(),1);function wQ(){let t=new ap.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,cp.default)(t),t}var dn=class{constructor(e){this._ajv=e??wQ()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return s=>r(s)?{valid:!0,data:s,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var An=class{constructor(e){this._client=e}async*callToolStream(e,r=nr,s){let o=this._client,n={...s,task:s?.task??(o.isToolTask(e.name)?{}:void 0)},i=o.requestStream({method:"tools/call",params:e},r,n),a=o.getToolOutputValidator(e.name);for await(let c of i){if(c.type==="result"&&a){let u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new T(P.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{let l=a(u.structuredContent);if(!l.valid){yield{type:"error",error:new T(P.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof T){yield{type:"error",error:l};return}yield{type:"error",error:new T(P.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield c}}async getTask(e,r){return this._client.getTask({taskId:e},r)}async getTaskResult(e,r,s){return this._client.getTaskResult({taskId:e},r,s)}async listTasks(e,r){return this._client.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._client.cancelTask({taskId:e},r)}requestStream(e,r,s){return this._client.requestStream(e,r,s)}};function lp(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function up(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}function pn(t,e){if(!(!t||e===null||typeof e!="object")){if(t.type==="object"&&t.properties&&typeof t.properties=="object"){let r=e,s=t.properties;for(let o of Object.keys(s)){let n=s[o];r[o]===void 0&&Object.prototype.hasOwnProperty.call(n,"default")&&(r[o]=n.default),r[o]!==void 0&&pn(n,r[o])}}if(Array.isArray(t.anyOf))for(let r of t.anyOf)typeof r!="boolean"&&pn(r,e);if(Array.isArray(t.oneOf))for(let r of t.oneOf)typeof r!="boolean"&&pn(r,e)}}function CQ(t){if(!t)return{supportsFormMode:!1,supportsUrlMode:!1};let e=t.form!==void 0,r=t.url!==void 0;return{supportsFormMode:e||!e&&!r,supportsUrlMode:r}}var mn=class extends vo{constructor(e,r){super(r),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._cachedKnownTaskTools=new Set,this._cachedRequiredTaskTools=new Set,this._listChangedDebounceTimers=new Map,this._capabilities=r?.capabilities??{},this._jsonSchemaValidator=r?.jsonSchemaValidator??new dn,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",Bi,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Ci,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",mi,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new An(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=gu(this._capabilities,e)}setRequestHandler(e,r){let o=uo(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let n=Ao(o);if(typeof n!="string")throw new Error("Schema method literal must be a string");let i=n;if(i==="elicitation/create"){let a=async(c,u)=>{let l=Ue(ki,c);if(!l.success){let w=l.error instanceof Error?l.error.message:String(l.error);throw new T(P.InvalidParams,`Invalid elicitation request: ${w}`)}let{params:d}=l.data;d.mode=d.mode??"form";let{supportsFormMode:p,supportsUrlMode:m}=CQ(this._capabilities.elicitation);if(d.mode==="form"&&!p)throw new T(P.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!m)throw new T(P.InvalidParams,"Client does not support URL-mode elicitation requests");let g=await Promise.resolve(r(c,u));if(d.task){let w=Ue(Tt,g);if(!w.success){let I=w.error instanceof Error?w.error.message:String(w.error);throw new T(P.InvalidParams,`Invalid task creation result: ${I}`)}return w.data}let f=Ue(Mi,g);if(!f.success){let w=f.error instanceof Error?f.error.message:String(f.error);throw new T(P.InvalidParams,`Invalid elicitation result: ${w}`)}let h=f.data,y=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&h.action==="accept"&&h.content&&y&&this._capabilities.elicitation?.form?.applyDefaults)try{pn(y,h.content)}catch{}return h};return super.setRequestHandler(e,a)}if(i==="sampling/createMessage"){let a=async(c,u)=>{let l=Ue(Qi,c);if(!l.success){let h=l.error instanceof Error?l.error.message:String(l.error);throw new T(P.InvalidParams,`Invalid sampling request: ${h}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let h=Ue(Tt,p);if(!h.success){let y=h.error instanceof Error?h.error.message:String(h.error);throw new T(P.InvalidParams,`Invalid task creation result: ${y}`)}return h.data}let g=d.tools||d.toolChoice?Si:_i,f=Ue(g,p);if(!f.success){let h=f.error instanceof Error?f.error.message:String(f.error);throw new T(P.InvalidParams,`Invalid sampling result: ${h}`)}return f.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapability(e,r){if(!this._serverCapabilities?.[e])throw new Error(`Server does not support ${e} (required for ${r})`)}async connect(e,r){if(await super.connect(e),e.sessionId===void 0)try{let s=await this.request({method:"initialize",params:{protocolVersion:sr,capabilities:this._capabilities,clientInfo:this._clientInfo}},ci,r);if(s===void 0)throw new Error(`Server sent invalid initialize result: ${s}`);if(!Vl.includes(s.protocolVersion))throw new Error(`Server's protocol version is not supported: ${s.protocolVersion}`);this._serverCapabilities=s.capabilities,this._serverVersion=s.serverInfo,e.setProtocolVersion&&e.setProtocolVersion(s.protocolVersion),this._instructions=s.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(s){throw this.close(),s}}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(e==="resources/subscribe"&&!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})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${e})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}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})`);break;case"ping":break}}assertTaskCapability(e){lp(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&up(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},xt,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},vi,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},xt,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},wi,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},fi,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},ui,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},di,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},pi,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},xt,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},xt,r)}async callTool(e,r=nr,s){if(this.isToolTaskRequired(e.name))throw new T(P.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let o=await this.request({method:"tools/call",params:e},r,s),n=this.getToolOutputValidator(e.name);if(n){if(!o.structuredContent&&!o.isError)throw new T(P.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(o.structuredContent)try{let i=n(o.structuredContent);if(!i.valid)throw new T(P.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof T?i:new T(P.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return o}isToolTask(e){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(e):!1}isToolTaskRequired(e){return this._cachedRequiredTaskTools.has(e)}cacheToolMetadata(e){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let r of e){if(r.outputSchema){let o=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,o)}let s=r.execution?.taskSupport;(s==="required"||s==="optional")&&this._cachedKnownTaskTools.add(r.name),s==="required"&&this._cachedRequiredTaskTools.add(r.name)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,r){let s=await this.request({method:"tools/list",params:e},Ii,r);return this.cacheToolMetadata(s.tools),s}_setupListChangedHandler(e,r,s,o){let n=pu.safeParse(s);if(!n.success)throw new Error(`Invalid ${e} listChanged options: ${n.error.message}`);if(typeof s.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:a}=n.data,{onChanged:c}=s,u=async()=>{if(!i){c(null,null);return}try{let d=await o();c(null,d)}catch(d){let p=d instanceof Error?d:new Error(String(d));c(p,null)}},l=()=>{if(a){let d=this._listChangedDebounceTimers.get(e);d&&clearTimeout(d);let p=setTimeout(u,a);this._listChangedDebounceTimers.set(e,p)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var xs=class extends Error{constructor(e,r){super(e),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}},dp=10,IQ=13,qt=32;function _c(t){}function fn(t){if(typeof t=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:e=_c,onError:r=_c,onRetry:s=_c,onComment:o,maxBufferSize:n}=t,i=[],a=0,c=!0,u,l="",d=0,p,m=!1;function g(E){if(m)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,E.charCodeAt(0)===239&&E.charCodeAt(1)===187&&E.charCodeAt(2)===191&&(E=E.slice(3))),i.length===0){let z=h(E);z!==""&&(i.push(z),a=z.length),f();return}if(E.indexOf(`
|
|
12
12
|
`)===-1&&E.indexOf("\r")===-1){i.push(E),a+=E.length,f();return}i.push(E);let B=i.join("");i.length=0,a=0;let M=h(B);M!==""&&(i.push(M),a=M.length),f()}function f(){n!==void 0&&(a+l.length<=n||(m=!0,i.length=0,a=0,u=void 0,l="",d=0,p=void 0,r(new xs(`Buffered data exceeded max buffer size of ${n} characters`,{type:"max-buffer-size-exceeded"}))))}function h(E){let B=0;if(E.indexOf("\r")===-1){let M=E.indexOf(`
|
|
13
13
|
`,B);for(;M!==-1;){if(B===M){d>0&&e({id:u,event:p,data:l}),u=void 0,l="",d=0,p=void 0,B=M+1,M=E.indexOf(`
|
|
14
14
|
`,B);continue}let z=E.charCodeAt(B);if(Ap(E,B,z)){let D=E.charCodeAt(B+5)===qt?B+6:B+5,ce=E.slice(D,M);if(d===0&&E.charCodeAt(M+1)===dp){e({id:u,event:p,data:ce}),u=void 0,l="",p=void 0,B=M+2,M=E.indexOf(`
|
|
@@ -19,7 +19,7 @@ ${ce}`,d++}else pp(E,B,z)?p=E.slice(E.charCodeAt(B+6)===qt?B+7:B+6,M)||void 0:y(
|
|
|
19
19
|
${vl}`,d++;return}if(pp(E,B,z)){p=E.slice(E.charCodeAt(B+6)===qt?B+7:B+6,M)||void 0;return}if(z===105&&E.charCodeAt(B+1)===100&&E.charCodeAt(B+2)===58){let mt=E.slice(E.charCodeAt(B+3)===qt?B+4:B+3,M);u=mt.includes("\0")?void 0:mt;return}if(z===58){if(o){let mt=E.slice(B,M);o(mt.slice(E.charCodeAt(B+1)===qt?2:1))}return}let D=E.slice(B,M),ce=D.indexOf(":");if(ce===-1){w(D,"",D);return}let qr=D.slice(0,ce),ao=D.charCodeAt(ce+1)===qt?2:1,co=D.slice(ce+ao);w(qr,co,D)}function w(E,B,M){switch(E){case"event":p=B||void 0;break;case"data":l=d===0?B:`${l}
|
|
20
20
|
${B}`,d++;break;case"id":u=B.includes("\0")?void 0:B;break;case"retry":/^\d+$/.test(B)?s(parseInt(B,10)):r(new xs(`Invalid \`retry\` value: "${B}"`,{type:"invalid-retry",value:B,line:M}));break;default:r(new xs(`Unknown field "${E.length>20?`${E.slice(0,20)}\u2026`:E}"`,{type:"unknown-field",field:E,value:B,line:M}));break}}function I(){d>0&&e({id:u,event:p,data:l}),u=void 0,l="",d=0,p=void 0}function v(E={}){if(E.consume&&i.length>0){let B=i.join("");y(B,0,B.length)}c=!0,u=void 0,l="",d=0,p=void 0,i.length=0,a=0,m=!1}return{feed:g,reset:v}}function Ap(t,e,r){return r===100&&t.charCodeAt(e+1)===97&&t.charCodeAt(e+2)===116&&t.charCodeAt(e+3)===97&&t.charCodeAt(e+4)===58}function pp(t,e,r){return r===101&&t.charCodeAt(e+1)===118&&t.charCodeAt(e+2)===101&&t.charCodeAt(e+3)===110&&t.charCodeAt(e+4)===116&&t.charCodeAt(e+5)===58}var hn=class extends Event{constructor(e,r){var s,o;super(e),this.code=(s=r?.code)!=null?s:void 0,this.message=(o=r?.message)!=null?o:void 0}[Symbol.for("nodejs.util.inspect.custom")](e,r,s){return s(mp(this),r)}[Symbol.for("Deno.customInspect")](e,r){return e(mp(this),r)}};function BQ(t){let e=globalThis.DOMException;return typeof e=="function"?new e(t,"SyntaxError"):new SyntaxError(t)}function Sc(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(Sc).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${Sc(t.cause)}`:t.message:`${t}`}function mp(t){return{type:t.type,message:t.message,code:t.code,defaultPrevented:t.defaultPrevented,cancelable:t.cancelable,timeStamp:t.timeStamp}}var gp=t=>{throw TypeError(t)},Dc=(t,e,r)=>e.has(t)||gp("Cannot "+r),q=(t,e,r)=>(Dc(t,e,"read from private field"),r?r.call(t):e.get(t)),de=(t,e,r)=>e.has(t)?gp("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),se=(t,e,r,s)=>(Dc(t,e,"write to private field"),e.set(t,r),r),at=(t,e,r)=>(Dc(t,e,"access private method"),r),xe,Gt,Qr,gn,En,Ds,kr,$s,kt,_r,Mr,Sr,Ts,He,kc,Mc,vc,fp,bc,xc,Rs,Tc,Rc,Ht=class extends EventTarget{constructor(e,r){var s,o;super(),de(this,He),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,de(this,xe),de(this,Gt),de(this,Qr),de(this,gn),de(this,En),de(this,Ds),de(this,kr),de(this,$s,null),de(this,kt),de(this,_r),de(this,Mr,null),de(this,Sr,null),de(this,Ts,null),de(this,Mc,async n=>{var i;q(this,_r).reset();let{body:a,redirected:c,status:u,headers:l}=n;if(u===204){at(this,He,Rs).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?se(this,Qr,new URL(n.url)):se(this,Qr,void 0),u!==200){at(this,He,Rs).call(this,`Non-200 status code (${u})`,u);return}if(!(l.get("content-type")||"").startsWith("text/event-stream")){at(this,He,Rs).call(this,'Invalid content type, expected "text/event-stream"',u);return}if(q(this,xe)===this.CLOSED)return;se(this,xe,this.OPEN);let d=new Event("open");if((i=q(this,Ts))==null||i.call(this,d),this.dispatchEvent(d),typeof a!="object"||!a||!("getReader"in a)){at(this,He,Rs).call(this,"Invalid response body, expected a web ReadableStream",u),this.close();return}let p=new TextDecoder,m=a.getReader(),g=!0;do{let{done:f,value:h}=await m.read();h&&q(this,_r).feed(p.decode(h,{stream:!f})),f&&(g=!1,q(this,_r).reset(),at(this,He,Tc).call(this))}while(g)}),de(this,vc,n=>{se(this,kt,void 0),!(n.name==="AbortError"||n.type==="aborted")&&at(this,He,Tc).call(this,Sc(n))}),de(this,bc,n=>{typeof n.id=="string"&&se(this,$s,n.id);let i=new MessageEvent(n.event||"message",{data:n.data,origin:q(this,Qr)?q(this,Qr).origin:q(this,Gt).origin,lastEventId:n.id||""});q(this,Sr)&&(!n.event||n.event==="message")&&q(this,Sr).call(this,i),this.dispatchEvent(i)}),de(this,xc,n=>{se(this,Ds,n)}),de(this,Rc,()=>{se(this,kr,void 0),q(this,xe)===this.CONNECTING&&at(this,He,kc).call(this)});try{if(e instanceof URL)se(this,Gt,e);else if(typeof e=="string")se(this,Gt,new URL(e,QQ()));else throw new Error("Invalid URL")}catch{throw BQ("An invalid or illegal string was specified")}se(this,_r,fn({onEvent:q(this,bc),onRetry:q(this,xc)})),se(this,xe,this.CONNECTING),se(this,Ds,3e3),se(this,En,(s=r?.fetch)!=null?s:globalThis.fetch),se(this,gn,(o=r?.withCredentials)!=null?o:!1),at(this,He,kc).call(this)}get readyState(){return q(this,xe)}get url(){return q(this,Gt).href}get withCredentials(){return q(this,gn)}get onerror(){return q(this,Mr)}set onerror(e){se(this,Mr,e)}get onmessage(){return q(this,Sr)}set onmessage(e){se(this,Sr,e)}get onopen(){return q(this,Ts)}set onopen(e){se(this,Ts,e)}addEventListener(e,r,s){let o=r;super.addEventListener(e,o,s)}removeEventListener(e,r,s){let o=r;super.removeEventListener(e,o,s)}close(){q(this,kr)&&clearTimeout(q(this,kr)),q(this,xe)!==this.CLOSED&&(q(this,kt)&&q(this,kt).abort(),se(this,xe,this.CLOSED),se(this,kt,void 0))}};xe=new WeakMap,Gt=new WeakMap,Qr=new WeakMap,gn=new WeakMap,En=new WeakMap,Ds=new WeakMap,kr=new WeakMap,$s=new WeakMap,kt=new WeakMap,_r=new WeakMap,Mr=new WeakMap,Sr=new WeakMap,Ts=new WeakMap,He=new WeakSet,kc=function(){se(this,xe,this.CONNECTING),se(this,kt,new AbortController),q(this,En)(q(this,Gt),at(this,He,fp).call(this)).then(q(this,Mc)).catch(q(this,vc))},Mc=new WeakMap,vc=new WeakMap,fp=function(){var t;let e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...q(this,$s)?{"Last-Event-ID":q(this,$s)}:void 0},cache:"no-store",signal:(t=q(this,kt))==null?void 0:t.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},bc=new WeakMap,xc=new WeakMap,Rs=function(t,e){var r;q(this,xe)!==this.CLOSED&&se(this,xe,this.CLOSED);let s=new hn("error",{code:e,message:t});(r=q(this,Mr))==null||r.call(this,s),this.dispatchEvent(s)},Tc=function(t,e){var r;if(q(this,xe)===this.CLOSED)return;se(this,xe,this.CONNECTING);let s=new hn("error",{code:e,message:t});(r=q(this,Mr))==null||r.call(this,s),this.dispatchEvent(s),se(this,kr,setTimeout(q(this,Rc),q(this,Ds)))},Rc=new WeakMap,Ht.CONNECTING=0,Ht.OPEN=1,Ht.CLOSED=2;function QQ(){let t="document"in globalThis?globalThis.document:void 0;return t&&typeof t=="object"&&"baseURI"in t&&typeof t.baseURI=="string"?t.baseURI:void 0}function vr(t){return t?t instanceof Headers?Object.fromEntries(t.entries()):Array.isArray(t)?Object.fromEntries(t):{...t}:{}}function yn(t=fetch,e){return e?async(r,s)=>{let o={...e,...s,headers:s?.headers?{...vr(e.headers),...vr(s.headers)}:e.headers};return t(r,o)}:t}var $c;$c=globalThis.crypto?.webcrypto??globalThis.crypto??import("crypto").then(t=>t.webcrypto);async function _Q(t){return(await $c).getRandomValues(new Uint8Array(t))}async function SQ(t){let e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%e.length,s="";for(;s.length<t;){let o=await _Q(t-s.length);for(let n of o)n<r&&(s+=e[n%e.length])}return s}async function kQ(t){return await SQ(t)}async function MQ(t){let e=await(await $c).subtle.digest("SHA-256",new TextEncoder().encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function Pc(t){if(t||(t=43),t<43||t>128)throw`Expected a length between 43 and 128. Received ${t}.`;let e=await kQ(t),r=await MQ(e);return{code_verifier:e,code_challenge:r}}var Ee=$l().superRefine((t,e)=>{if(!URL.canParse(t))return e.addIssue({code:zl.custom,message:"URL must be parseable",fatal:!0}),bl}).refine(t=>{let e=new URL(t);return e.protocol!=="javascript:"&&e.protocol!=="data:"&&e.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),Ep=le({resource:A().url(),authorization_servers:_(Ee).optional(),jwks_uri:A().url().optional(),scopes_supported:_(A()).optional(),bearer_methods_supported:_(A()).optional(),resource_signing_alg_values_supported:_(A()).optional(),resource_name:A().optional(),resource_documentation:A().optional(),resource_policy_uri:A().url().optional(),resource_tos_uri:A().url().optional(),tls_client_certificate_bound_access_tokens:K().optional(),authorization_details_types_supported:_(A()).optional(),dpop_signing_alg_values_supported:_(A()).optional(),dpop_bound_access_tokens_required:K().optional()}),jc=le({issuer:A(),authorization_endpoint:Ee,token_endpoint:Ee,registration_endpoint:Ee.optional(),scopes_supported:_(A()).optional(),response_types_supported:_(A()),response_modes_supported:_(A()).optional(),grant_types_supported:_(A()).optional(),token_endpoint_auth_methods_supported:_(A()).optional(),token_endpoint_auth_signing_alg_values_supported:_(A()).optional(),service_documentation:Ee.optional(),revocation_endpoint:Ee.optional(),revocation_endpoint_auth_methods_supported:_(A()).optional(),revocation_endpoint_auth_signing_alg_values_supported:_(A()).optional(),introspection_endpoint:A().optional(),introspection_endpoint_auth_methods_supported:_(A()).optional(),introspection_endpoint_auth_signing_alg_values_supported:_(A()).optional(),code_challenge_methods_supported:_(A()).optional(),client_id_metadata_document_supported:K().optional()}),vQ=le({issuer:A(),authorization_endpoint:Ee,token_endpoint:Ee,userinfo_endpoint:Ee.optional(),jwks_uri:Ee,registration_endpoint:Ee.optional(),scopes_supported:_(A()).optional(),response_types_supported:_(A()),response_modes_supported:_(A()).optional(),grant_types_supported:_(A()).optional(),acr_values_supported:_(A()).optional(),subject_types_supported:_(A()),id_token_signing_alg_values_supported:_(A()),id_token_encryption_alg_values_supported:_(A()).optional(),id_token_encryption_enc_values_supported:_(A()).optional(),userinfo_signing_alg_values_supported:_(A()).optional(),userinfo_encryption_alg_values_supported:_(A()).optional(),userinfo_encryption_enc_values_supported:_(A()).optional(),request_object_signing_alg_values_supported:_(A()).optional(),request_object_encryption_alg_values_supported:_(A()).optional(),request_object_encryption_enc_values_supported:_(A()).optional(),token_endpoint_auth_methods_supported:_(A()).optional(),token_endpoint_auth_signing_alg_values_supported:_(A()).optional(),display_values_supported:_(A()).optional(),claim_types_supported:_(A()).optional(),claims_supported:_(A()).optional(),service_documentation:A().optional(),claims_locales_supported:_(A()).optional(),ui_locales_supported:_(A()).optional(),claims_parameter_supported:K().optional(),request_parameter_supported:K().optional(),request_uri_parameter_supported:K().optional(),require_request_uri_registration:K().optional(),op_policy_uri:Ee.optional(),op_tos_uri:Ee.optional(),client_id_metadata_document_supported:K().optional()}),yp=k({...vQ.shape,...jc.pick({code_challenge_methods_supported:!0}).shape}),wp=k({access_token:A(),id_token:A().optional(),token_type:A(),expires_in:Ul.number().optional(),scope:A().optional(),refresh_token:A().optional()}).strip(),Cp=k({error:A(),error_description:A().optional(),error_uri:A().optional()}),hp=Ee.optional().or(b("").transform(()=>{})),bQ=k({redirect_uris:_(Ee),token_endpoint_auth_method:A().optional(),grant_types:_(A()).optional(),response_types:_(A()).optional(),client_name:A().optional(),client_uri:Ee.optional(),logo_uri:hp,scope:A().optional(),contacts:_(A()).optional(),tos_uri:hp,policy_uri:A().optional(),jwks_uri:Ee.optional(),jwks:jl().optional(),software_id:A().optional(),software_version:A().optional(),software_statement:A().optional()}).strip(),xQ=k({client_id:A(),client_secret:A().optional(),client_id_issued_at:J().optional(),client_secret_expires_at:J().optional()}).strip(),Ip=bQ.merge(xQ),NR=k({error:A(),error_description:A().optional()}).strip(),zR=k({token:A(),token_type_hint:A().optional()}).strip();function Bp(t){let e=typeof t=="string"?new URL(t):new URL(t.href);return e.hash="",e}function Qp({requestedResource:t,configuredResource:e}){let r=typeof t=="string"?new URL(t):new URL(t.href),s=typeof e=="string"?new URL(e):new URL(e.href);if(r.origin!==s.origin||r.pathname.length<s.pathname.length)return!1;let o=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",n=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return o.startsWith(n)}var ae=class extends Error{constructor(e,r){super(e),this.errorUri=r,this.name=this.constructor.name}toResponseObject(){let e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}get errorCode(){return this.constructor.errorCode}},Ps=class extends ae{};Ps.errorCode="invalid_request";var Yt=class extends ae{};Yt.errorCode="invalid_client";var Jt=class extends ae{};Jt.errorCode="invalid_grant";var Wt=class extends ae{};Wt.errorCode="unauthorized_client";var js=class extends ae{};js.errorCode="unsupported_grant_type";var Ns=class extends ae{};Ns.errorCode="invalid_scope";var zs=class extends ae{};zs.errorCode="access_denied";var ct=class extends ae{};ct.errorCode="server_error";var Us=class extends ae{};Us.errorCode="temporarily_unavailable";var Fs=class extends ae{};Fs.errorCode="unsupported_response_type";var Os=class extends ae{};Os.errorCode="unsupported_token_type";var Ls=class extends ae{};Ls.errorCode="invalid_token";var qs=class extends ae{};qs.errorCode="method_not_allowed";var Gs=class extends ae{};Gs.errorCode="too_many_requests";var Vt=class extends ae{};Vt.errorCode="invalid_client_metadata";var Hs=class extends ae{};Hs.errorCode="insufficient_scope";var Ys=class extends ae{};Ys.errorCode="invalid_target";var _p={[Ps.errorCode]:Ps,[Yt.errorCode]:Yt,[Jt.errorCode]:Jt,[Wt.errorCode]:Wt,[js.errorCode]:js,[Ns.errorCode]:Ns,[zs.errorCode]:zs,[ct.errorCode]:ct,[Us.errorCode]:Us,[Fs.errorCode]:Fs,[Os.errorCode]:Os,[Ls.errorCode]:Ls,[qs.errorCode]:qs,[Gs.errorCode]:Gs,[Vt.errorCode]:Vt,[Hs.errorCode]:Hs,[Ys.errorCode]:Ys};var _e=class extends Error{constructor(e){super(e??"Unauthorized")}};function TQ(t){return["client_secret_basic","client_secret_post","none"].includes(t)}var Nc="code",zc="S256";function RQ(t,e){let r=t.client_secret!==void 0;return"token_endpoint_auth_method"in t&&t.token_endpoint_auth_method&&TQ(t.token_endpoint_auth_method)&&(e.length===0||e.includes(t.token_endpoint_auth_method))?t.token_endpoint_auth_method:e.length===0?r?"client_secret_basic":"none":r&&e.includes("client_secret_basic")?"client_secret_basic":r&&e.includes("client_secret_post")?"client_secret_post":e.includes("none")?"none":r?"client_secret_post":"none"}function DQ(t,e,r,s){let{client_id:o,client_secret:n}=e;switch(t){case"client_secret_basic":$Q(o,n,r);return;case"client_secret_post":PQ(o,n,s);return;case"none":jQ(o,s);return;default:throw new Error(`Unsupported client authentication method: ${t}`)}}function $Q(t,e,r){if(!e)throw new Error("client_secret_basic authentication requires a client_secret");let s=btoa(`${t}:${e}`);r.set("Authorization",`Basic ${s}`)}function PQ(t,e,r){r.set("client_id",t),e&&r.set("client_secret",e)}function jQ(t,e){e.set("client_id",t)}async function kp(t){let e=t instanceof Response?t.status:void 0,r=t instanceof Response?await t.text():t;try{let s=Cp.parse(JSON.parse(r)),{error:o,error_description:n,error_uri:i}=s,a=_p[o]||ct;return new a(n||"",i)}catch(s){let o=`${e?`HTTP ${e}: `:""}Invalid OAuth error response: ${s}. Raw body: ${r}`;return new ct(o)}}async function lt(t,e){try{return await Uc(t,e)}catch(r){if(r instanceof Yt||r instanceof Wt)return await t.invalidateCredentials?.("all"),await Uc(t,e);if(r instanceof Jt)return await t.invalidateCredentials?.("tokens"),await Uc(t,e);throw r}}async function Uc(t,{serverUrl:e,authorizationCode:r,scope:s,resourceMetadataUrl:o,fetchFn:n}){let i=await t.discoveryState?.(),a,c,u,l=o;if(!l&&i?.resourceMetadataUrl&&(l=new URL(i.resourceMetadataUrl)),i?.authorizationServerUrl){if(c=i.authorizationServerUrl,a=i.resourceMetadata,u=i.authorizationServerMetadata??await vp(c,{fetchFn:n}),!a)try{a=await Mp(e,{resourceMetadataUrl:l},n)}catch{}(u!==i.authorizationServerMetadata||a!==i.resourceMetadata)&&await t.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}else{let I=await qQ(e,{resourceMetadataUrl:l,fetchFn:n});c=I.authorizationServerUrl,u=I.authorizationServerMetadata,a=I.resourceMetadata,await t.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}let d=await zQ(e,t,a),p=s||a?.scopes_supported?.join(" ")||t.clientMetadata.scope,m=await Promise.resolve(t.clientInformation());if(!m){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let I=u?.client_id_metadata_document_supported===!0,v=t.clientMetadataUrl;if(v&&!NQ(v))throw new Vt(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${v}`);if(I&&v)m={client_id:v},await t.saveClientInformation?.(m);else{if(!t.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");let B=await WQ(c,{metadata:u,clientMetadata:t.clientMetadata,scope:p,fetchFn:n});await t.saveClientInformation(B),m=B}}let g=!t.redirectUrl;if(r!==void 0||g){let I=await JQ(t,c,{metadata:u,resource:d,authorizationCode:r,fetchFn:n});return await t.saveTokens(I),"AUTHORIZED"}let f=await t.tokens();if(f?.refresh_token)try{let I=await YQ(c,{metadata:u,clientInformation:m,refreshToken:f.refresh_token,resource:d,addClientAuthentication:t.addClientAuthentication,fetchFn:n});return await t.saveTokens(I),"AUTHORIZED"}catch(I){if(!(!(I instanceof ae)||I instanceof ct))throw I}let h=t.state?await t.state():void 0,{authorizationUrl:y,codeVerifier:w}=await GQ(c,{metadata:u,clientInformation:m,state:h,redirectUrl:t.redirectUrl,scope:p,resource:d});return await t.saveCodeVerifier(w),await t.redirectToAuthorization(y),"REDIRECT"}function NQ(t){if(!t)return!1;try{let e=new URL(t);return e.protocol==="https:"&&e.pathname!=="/"}catch{return!1}}async function zQ(t,e,r){let s=Bp(t);if(e.validateResourceURL)return await e.validateResourceURL(s,r?.resource);if(r){if(!Qp({requestedResource:s,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${s} (or origin)`);return new URL(r.resource)}}function br(t){let e=t.headers.get("WWW-Authenticate");if(!e)return{};let[r,s]=e.split(" ");if(r.toLowerCase()!=="bearer"||!s)return{};let o=Fc(t,"resource_metadata")||void 0,n;if(o)try{n=new URL(o)}catch{}let i=Fc(t,"scope")||void 0,a=Fc(t,"error")||void 0;return{resourceMetadataUrl:n,scope:i,error:a}}function Fc(t,e){let r=t.headers.get("WWW-Authenticate");if(!r)return null;let s=new RegExp(`${e}=(?:"([^"]+)"|([^\\s,]+))`),o=r.match(s);return o?o[1]||o[2]:null}async function Mp(t,e,r=fetch){let s=await OQ(t,"oauth-protected-resource",r,{protocolVersion:e?.protocolVersion,metadataUrl:e?.resourceMetadataUrl});if(!s||s.status===404)throw await s?.body?.cancel(),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!s.ok)throw await s.body?.cancel(),new Error(`HTTP ${s.status} trying to load well-known OAuth protected resource metadata.`);return Ep.parse(await s.json())}async function Oc(t,e,r=fetch){try{return await r(t,{headers:e})}catch(s){if(s instanceof TypeError)return e?Oc(t,void 0,r):void 0;throw s}}function UQ(t,e="",r={}){return e.endsWith("/")&&(e=e.slice(0,-1)),r.prependPathname?`${e}/.well-known/${t}`:`/.well-known/${t}${e}`}async function Sp(t,e,r=fetch){return await Oc(t,{"MCP-Protocol-Version":e},r)}function FQ(t,e){return!t||t.status>=400&&t.status<500&&e!=="/"}async function OQ(t,e,r,s){let o=new URL(t),n=s?.protocolVersion??sr,i;if(s?.metadataUrl)i=new URL(s.metadataUrl);else{let c=UQ(e,o.pathname);i=new URL(c,s?.metadataServerUrl??o),i.search=o.search}let a=await Sp(i,n,r);if(!s?.metadataUrl&&FQ(a,o.pathname)){let c=new URL(`/.well-known/${e}`,o);a=await Sp(c,n,r)}return a}function LQ(t){let e=typeof t=="string"?new URL(t):t,r=e.pathname!=="/",s=[];if(!r)return s.push({url:new URL("/.well-known/oauth-authorization-server",e.origin),type:"oauth"}),s.push({url:new URL("/.well-known/openid-configuration",e.origin),type:"oidc"}),s;let o=e.pathname;return o.endsWith("/")&&(o=o.slice(0,-1)),s.push({url:new URL(`/.well-known/oauth-authorization-server${o}`,e.origin),type:"oauth"}),s.push({url:new URL(`/.well-known/openid-configuration${o}`,e.origin),type:"oidc"}),s.push({url:new URL(`${o}/.well-known/openid-configuration`,e.origin),type:"oidc"}),s}async function vp(t,{fetchFn:e=fetch,protocolVersion:r=sr}={}){let s={"MCP-Protocol-Version":r,Accept:"application/json"},o=LQ(t);for(let{url:n,type:i}of o){let a=await Oc(n,s,e);if(a){if(!a.ok){if(await a.body?.cancel(),a.status>=400&&a.status<500)continue;throw new Error(`HTTP ${a.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${n}`)}return i==="oauth"?jc.parse(await a.json()):yp.parse(await a.json())}}}async function qQ(t,e){let r,s;try{r=await Mp(t,{resourceMetadataUrl:e?.resourceMetadataUrl},e?.fetchFn),r.authorization_servers&&r.authorization_servers.length>0&&(s=r.authorization_servers[0])}catch{}s||(s=String(new URL("/",t)));let o=await vp(s,{fetchFn:e?.fetchFn});return{authorizationServerUrl:s,authorizationServerMetadata:o,resourceMetadata:r}}async function GQ(t,{metadata:e,clientInformation:r,redirectUrl:s,scope:o,state:n,resource:i}){let a;if(e){if(a=new URL(e.authorization_endpoint),!e.response_types_supported.includes(Nc))throw new Error(`Incompatible auth server: does not support response type ${Nc}`);if(e.code_challenge_methods_supported&&!e.code_challenge_methods_supported.includes(zc))throw new Error(`Incompatible auth server: does not support code challenge method ${zc}`)}else a=new URL("/authorize",t);let c=await Pc(),u=c.code_verifier,l=c.code_challenge;return a.searchParams.set("response_type",Nc),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",l),a.searchParams.set("code_challenge_method",zc),a.searchParams.set("redirect_uri",String(s)),n&&a.searchParams.set("state",n),o&&a.searchParams.set("scope",o),o?.includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",i.href),{authorizationUrl:a,codeVerifier:u}}function HQ(t,e,r){return new URLSearchParams({grant_type:"authorization_code",code:t,code_verifier:e,redirect_uri:String(r)})}async function bp(t,{metadata:e,tokenRequestParams:r,clientInformation:s,addClientAuthentication:o,resource:n,fetchFn:i}){let a=e?.token_endpoint?new URL(e.token_endpoint):new URL("/token",t),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(n&&r.set("resource",n.href),o)await o(c,r,a,e);else if(s){let l=e?.token_endpoint_auth_methods_supported??[],d=RQ(s,l);DQ(d,s,c,r)}let u=await(i??fetch)(a,{method:"POST",headers:c,body:r});if(!u.ok)throw await kp(u);return wp.parse(await u.json())}async function YQ(t,{metadata:e,clientInformation:r,refreshToken:s,resource:o,addClientAuthentication:n,fetchFn:i}){let a=new URLSearchParams({grant_type:"refresh_token",refresh_token:s}),c=await bp(t,{metadata:e,tokenRequestParams:a,clientInformation:r,addClientAuthentication:n,resource:o,fetchFn:i});return{refresh_token:s,...c}}async function JQ(t,e,{metadata:r,resource:s,authorizationCode:o,fetchFn:n}={}){let i=t.clientMetadata.scope,a;if(t.prepareTokenRequest&&(a=await t.prepareTokenRequest(i)),!a){if(!o)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!t.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");let u=await t.codeVerifier();a=HQ(o,u,t.redirectUrl)}let c=await t.clientInformation();return bp(e,{metadata:r,tokenRequestParams:a,clientInformation:c??void 0,addClientAuthentication:t.addClientAuthentication,resource:s,fetchFn:n})}async function WQ(t,{metadata:e,clientMetadata:r,scope:s,fetchFn:o}){let n;if(e){if(!e.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");n=new URL(e.registration_endpoint)}else n=new URL("/register",t);let i=await(o??fetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...s!==void 0?{scope:s}:{}})});if(!i.ok)throw await kp(i);return Ip.parse(await i.json())}var Lc=class extends Error{constructor(e,r,s){super(`SSE error: ${r}`),this.code=e,this.event=s}},wn=class{constructor(e,r){this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._eventSourceInit=r?.eventSourceInit,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=yn(r?.fetch,r?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new _e("No auth provider");let e;try{e=await lt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(e!=="AUTHORIZED")throw new _e;return await this._startOrAuth()}async _commonHeaders(){let e={};if(this._authProvider){let s=await this._authProvider.tokens();s&&(e.Authorization=`Bearer ${s.access_token}`)}this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);let r=vr(this._requestInit?.headers);return new Headers({...e,...r})}_startOrAuth(){let e=this?._eventSourceInit?.fetch??this._fetch??fetch;return new Promise((r,s)=>{this._eventSource=new Ht(this._url.href,{...this._eventSourceInit,fetch:async(o,n)=>{let i=await this._commonHeaders();i.set("Accept","text/event-stream");let a=await e(o,{...n,headers:i});if(a.status===401&&a.headers.has("www-authenticate")){let{resourceMetadataUrl:c,scope:u}=br(a);this._resourceMetadataUrl=c,this._scope=u}return a}}),this._abortController=new AbortController,this._eventSource.onerror=o=>{if(o.code===401&&this._authProvider){this._authThenStart().then(r,s);return}let n=new Lc(o.code,o.message,o);s(n),this.onerror?.(n)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",o=>{let n=o;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(i){s(i),this.onerror?.(i),this.close();return}r()}),this._eventSource.onmessage=o=>{let n=o,i;try{i=ht.parse(JSON.parse(n.data))}catch(a){this.onerror?.(a);return}this.onmessage?.(i)}})}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 _e("No auth provider");if(await lt(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new _e("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{let r=await this._commonHeaders();r.set("content-type","application/json");let s={...this._requestInit,method:"POST",headers:r,body:JSON.stringify(e),signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._endpoint,s);if(!o.ok){let n=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){let{resourceMetadataUrl:i,scope:a}=br(o);if(this._resourceMetadataUrl=i,this._scope=a,await lt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new _e;return this.send(e)}throw new Error(`Error POSTing to endpoint (HTTP ${o.status}): ${n}`)}await o.body?.cancel()}catch(r){throw this.onerror?.(r),r}}setProtocolVersion(e){this._protocolVersion=e}};var wm=lo(Em(),1);import Xc from"process";import{PassThrough as Q_}from"stream";var I_=10*1024*1024,In=class{constructor(e){this._maxBufferSize=e?.maxBufferSize??I_}append(e){if((this._buffer?.length??0)+e.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
21
21
|
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),B_(r)}clear(){this._buffer=void 0}};function B_(t){return ht.parse(JSON.parse(t))}function ym(t){return JSON.stringify(t)+`
|
|
22
|
-
`}var __=Xc.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function S_(){let t={};for(let e of __){let r=Xc.env[e];r!==void 0&&(r.startsWith("()")||(t[e]=r))}return t}var Bn=class{constructor(e){this._stderrStream=null,this._serverParams=e,this._readBuffer=new In({maxBufferSize:e.maxBufferSize}),(e.stderr==="pipe"||e.stderr==="overlapped")&&(this._stderrStream=new Q_)}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,r)=>{this._process=(0,wm.default)(this._serverParams.command,this._serverParams.args??[],{env:{...S_(),...this._serverParams.env},stdio:["pipe","pipe",this._serverParams.stderr??"inherit"],shell:!1,windowsHide:Xc.platform==="win32",cwd:this._serverParams.cwd}),this._process.on("error",s=>{r(s),this.onerror?.(s)}),this._process.on("spawn",()=>{e()}),this._process.on("close",s=>{this._process=void 0,this.onclose?.()}),this._process.stdin?.on("error",s=>{this.onerror?.(s)}),this._process.stdout?.on("data",s=>{try{this._readBuffer.append(s),this.processReadBuffer()}catch(o){this.onerror?.(o),this.close().catch(()=>{})}}),this._process.stdout?.on("error",s=>{this.onerror?.(s)}),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{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){if(this._process){let e=this._process;this._process=void 0;let r=new Promise(s=>{e.once("close",()=>{s()})});try{e.stdin?.end()}catch{}if(await Promise.race([r,new Promise(s=>setTimeout(s,2e3).unref())]),e.exitCode===null){try{e.kill("SIGTERM")}catch{}await Promise.race([r,new Promise(s=>setTimeout(s,2e3).unref())])}if(e.exitCode===null)try{e.kill("SIGKILL")}catch{}}this._readBuffer.clear()}send(e){return new Promise(r=>{if(!this._process?.stdin)throw new Error("Not connected");let s=ym(e);this._process.stdin.write(s)?r():this._process.stdin.once("drain",r)})}};var _m=lo(Qm(),1);function Sm(t){if(t)try{return _m.default.parse(t).type}catch{let e=(t.split(";",1)[0]??"").trim().toLowerCase();return e===""||t.slice(e.length).includes(",")?void 0:e}}var Qn=class extends TransformStream{constructor({onError:e,onRetry:r,onComment:s,maxBufferSize:o}={}){let n;super({start(i){n=fn({onEvent:a=>{i.enqueue(a)},onError(a){typeof e=="function"&&e(a),(e==="terminate"||a.type==="max-buffer-size-exceeded")&&i.error(a)},onRetry:r,onComment:s,maxBufferSize:o})},transform(i){n.feed(i)}})}};var $_={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},Mt=class extends Error{constructor(e,r){super(`Streamable HTTP error: ${r}`),this.code=e}},_n=class{constructor(e,r){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=yn(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??$_}async _authThenStart(){if(!this._authProvider)throw new _e("No auth provider");let e;try{e=await lt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(e!=="AUTHORIZED")throw new _e;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let s=await this._authProvider.tokens();s&&(e.Authorization=`Bearer ${s.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);let r=vr(this._requestInit?.headers);return new Headers({...e,...r})}async _startOrAuthSse(e){let{resumptionToken:r}=e;try{let s=await this._commonHeaders();s.set("Accept","text/event-stream"),r&&s.set("last-event-id",r);let o=await(this._fetch??fetch)(this._url,{method:"GET",headers:s,signal:this._abortController?.signal});if(!o.ok){if(await o.body?.cancel(),o.status===401&&this._authProvider)return await this._authThenStart();if(o.status===405)return;throw new Mt(o.status,`Failed to open SSE stream: ${o.statusText}`)}this._handleSseStream(o.body,e,!0)}catch(s){throw this.onerror?.(s),s}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,s=this._reconnectionOptions.reconnectionDelayGrowFactor,o=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(s,e),o)}_scheduleReconnection(e,r=0){let s=this._reconnectionOptions.maxRetries;if(r>=s){this.onerror?.(new Error(`Maximum reconnection attempts (${s}) exceeded.`));return}let o=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,r+1)})},o)}_handleSseStream(e,r,s){if(!e)return;let{onresumptiontoken:o,replayMessageId:n}=r,i,a=!1,c=!1;(async()=>{try{let l=e.pipeThrough(new TextDecoderStream).pipeThrough(new Qn({onRetry:m=>{this._serverRetryMs=m}})).getReader();for(;;){let{value:m,done:g}=await l.read();if(g)break;if(m.id&&(i=m.id,a=!0,o?.(m.id)),!!m.data&&(!m.event||m.event==="message"))try{let f=ht.parse(JSON.parse(m.data));bt(f)&&(c=!0,n!==void 0&&(f.id=n)),this.onmessage?.(f)}catch(f){this.onerror?.(f)}}(s||a)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:n},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(s||a)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:n},0)}catch(m){this.onerror?.(new Error(`Failed to reconnect: ${m instanceof Error?m.message:String(m)}`))}}})()}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 _e("No auth provider");if(await lt(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new _e("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(e,r){try{let{resumptionToken:s,onresumptiontoken:o}=r||{};if(s){this._startOrAuthSse({resumptionToken:s,replayMessageId:Jr(e)?e.id:void 0}).catch(m=>this.onerror?.(m));return}let n=await this._commonHeaders();n.set("content-type","application/json"),n.set("accept","application/json, text/event-stream");let i={...this._requestInit,method:"POST",headers:n,body:JSON.stringify(e),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._url,i),c=a.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!a.ok){let m=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Mt(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:g,scope:f}=br(a);if(this._resourceMetadataUrl=g,this._scope=f,await lt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new _e;return this._hasCompletedAuthFlow=!0,this.send(e)}if(a.status===403&&this._authProvider){let{resourceMetadataUrl:g,scope:f,error:h}=br(a);if(h==="insufficient_scope"){let y=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===y)throw new Mt(403,"Server returned 403 after trying upscoping");if(f&&(this._scope=f),g&&(this._resourceMetadataUrl=g),this._lastUpscopingHeader=y??void 0,await lt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new _e;return this.send(e)}}throw new Mt(a.status,`Error POSTing to endpoint: ${m}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),iu(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(m=>this.onerror?.(m));return}let l=(Array.isArray(e)?e:[e]).filter(m=>"method"in m&&"id"in m&&m.id!==void 0).length>0,d=a.headers.get("content-type"),p=Sm(d);if(l)if(p==="text/event-stream")this._handleSseStream(a.body,{onresumptiontoken:o},!1);else if(p==="application/json"){let m=await a.json(),g=Array.isArray(m)?m.map(f=>ht.parse(f)):[ht.parse(m)];for(let f of g)this.onmessage?.(f)}else throw await a.body?.cancel(),new Mt(-1,`Unexpected content type: ${d}`);else await a.body?.cancel()}catch(s){throw this.onerror?.(s),s}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},s=await(this._fetch??fetch)(this._url,r);if(await s.body?.cancel(),!s.ok&&s.status!==405)throw new Mt(s.status,`Failed to terminate session: ${s.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,r){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:r?.onresumptiontoken})}};import{readFileSync as P_,statSync as j_}from"fs";import{extname as N_}from"path";import tl from"sharp";var z_=R({module:"images"});function km(t){if(t==="image/png"||t==="image/jpeg"||t==="image/gif"||t==="image/webp")return t;throw new Error(`Unsupported image media type: "${t}"`)}var ol=5*1024*1024,rl=ol*3/4,vt=2e3,$D=10,Rr=class extends Error{constructor(e){super(e),this.name="ImageTooLargeError"}},U_={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp"};function F_(t){return U_[N_(t).toLowerCase()]??null}function Mm(t){return F_(t)!==null}function O_(t){return t.length>=8&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71?"image/png":t.length>=3&&t[0]===255&&t[1]===216&&t[2]===255?"image/jpeg":t.length>=6&&t[0]===71&&t[1]===73&&t[2]===70?"image/gif":t.length>=12&&t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80?"image/webp":null}async function vm(t){if(!j_(t).isFile())throw new Error(`Not a file: ${t}`);let r=P_(t),s=O_(r);if(!s)throw new Error(`File ${t} has an image extension but its contents are not a supported image format (png/jpeg/gif/webp)`);let o=await nl(r,s);return{mediaType:o.mediaType,data:o.data,sourcePath:t,byteLength:o.byteLength}}function sl(t,e){return{data:t.toString("base64"),mediaType:e,byteLength:t.length}}function Js(t){return`${(t/(1024*1024)).toFixed(1)}MB`}async function nl(t,e){if(t.length===0)throw new Rr("Image file is empty (0 bytes)");if(t.length<=rl)return sl(t,e);try{return await L_(t,e)}catch(r){throw r instanceof Rr?r:(z_.warn({err:r},"sharp compression failed"),new Rr(`Image is ${Js(t.length)} raw (${Js(t.length*4/3)} base64-encoded, API limit ${Js(ol)}) and compression failed. Please provide a smaller image.`))}}async function L_(t,e){let r=await tl(t).metadata(),s=r.width??vt,o=r.height??vt;s>vt&&(o=Math.max(1,Math.round(o*vt/s)),s=vt),o>vt&&(s=Math.max(1,Math.round(s*vt/o)),o=vt);let n=e==="image/png"||e==="image/gif";for(let i=0;i<3;i++){if(n){let a=await tl(t).resize(s,o,{fit:"inside",withoutEnlargement:!0}).png({compressionLevel:8,palette:!0}).toBuffer();if(a.length<=rl)return sl(a,"image/png")}for(let a of[80,60,40,20]){let c=await tl(t).resize(s,o,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:a}).toBuffer();if(c.length<=rl)return sl(c,"image/jpeg")}s=Math.max(1,Math.round(s/2)),o=Math.max(1,Math.round(o/2))}throw new Rr(`Unable to compress image (${Js(t.length)} raw) under the ${Js(ol)} API limit. Please provide a smaller image.`)}import{readFileSync as q_}from"fs";import bm from"path";import{fileURLToPath as G_}from"url";var H_=$.object({version:$.string()});function Y_(){return"0.0.23"}var xm=Y_();var Rm=R({module:"mcp"});function Tm(t){return t.replace(/\$\{(\w+)\}|\$(\w+)/g,(e,r,s)=>process.env[r||s]??"")}function J_(t){let e={};for(let[r,s]of Object.entries(t))e[r]=s??"";return e}var W_=new Set(["image/png","image/jpeg","image/gif","image/webp"]);async function V_(t){let e=[],r=[],s=!1;for(let n of t){let i=Ol(n)?n:{};if(i.type==="image"&&typeof i.data=="string"&&typeof i.mimeType=="string"&&W_.has(i.mimeType))try{let u=await nl(Buffer.from(i.data,"base64"),km(i.mimeType));r.push({type:"image",source:{type:"base64",media_type:u.mediaType,data:u.data}}),e.push(`[Image: ${u.mediaType}]`),s=!0;continue}catch(u){Rm.warn({err:u},"mcp image dropped (too large to fit the API limit)");let l="[note: an image returned by the tool was too large and was dropped]";e.push(l),r.push({type:"text",text:l});continue}if(i.type==="image"){let l=`[Unsupported image: ${typeof i.mimeType=="string"?i.mimeType:"unknown"}]`;e.push(l),r.push({type:"text",text:l});continue}let a=JSON.stringify(n),c=i.type==="text"&&typeof i.text=="string"?i.text:typeof a=="string"?a:String(n);e.push(c),r.push({type:"text",text:c})}let o=e.join(`
|
|
22
|
+
`}var __=Xc.platform==="win32"?["APPDATA","HOMEDRIVE","HOMEPATH","LOCALAPPDATA","PATH","PROCESSOR_ARCHITECTURE","SYSTEMDRIVE","SYSTEMROOT","TEMP","USERNAME","USERPROFILE","PROGRAMFILES"]:["HOME","LOGNAME","PATH","SHELL","TERM","USER"];function S_(){let t={};for(let e of __){let r=Xc.env[e];r!==void 0&&(r.startsWith("()")||(t[e]=r))}return t}var Bn=class{constructor(e){this._stderrStream=null,this._serverParams=e,this._readBuffer=new In({maxBufferSize:e.maxBufferSize}),(e.stderr==="pipe"||e.stderr==="overlapped")&&(this._stderrStream=new Q_)}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,r)=>{this._process=(0,wm.default)(this._serverParams.command,this._serverParams.args??[],{env:{...S_(),...this._serverParams.env},stdio:["pipe","pipe",this._serverParams.stderr??"inherit"],shell:!1,windowsHide:Xc.platform==="win32",cwd:this._serverParams.cwd}),this._process.on("error",s=>{r(s),this.onerror?.(s)}),this._process.on("spawn",()=>{e()}),this._process.on("close",s=>{this._process=void 0,this.onclose?.()}),this._process.stdin?.on("error",s=>{this.onerror?.(s)}),this._process.stdout?.on("data",s=>{try{this._readBuffer.append(s),this.processReadBuffer()}catch(o){this.onerror?.(o),this.close().catch(()=>{})}}),this._process.stdout?.on("error",s=>{this.onerror?.(s)}),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{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){if(this._process){let e=this._process;this._process=void 0;let r=new Promise(s=>{e.once("close",()=>{s()})});try{e.stdin?.end()}catch{}if(await Promise.race([r,new Promise(s=>setTimeout(s,2e3).unref())]),e.exitCode===null){try{e.kill("SIGTERM")}catch{}await Promise.race([r,new Promise(s=>setTimeout(s,2e3).unref())])}if(e.exitCode===null)try{e.kill("SIGKILL")}catch{}}this._readBuffer.clear()}send(e){return new Promise(r=>{if(!this._process?.stdin)throw new Error("Not connected");let s=ym(e);this._process.stdin.write(s)?r():this._process.stdin.once("drain",r)})}};var _m=lo(Qm(),1);function Sm(t){if(t)try{return _m.default.parse(t).type}catch{let e=(t.split(";",1)[0]??"").trim().toLowerCase();return e===""||t.slice(e.length).includes(",")?void 0:e}}var Qn=class extends TransformStream{constructor({onError:e,onRetry:r,onComment:s,maxBufferSize:o}={}){let n;super({start(i){n=fn({onEvent:a=>{i.enqueue(a)},onError(a){typeof e=="function"&&e(a),(e==="terminate"||a.type==="max-buffer-size-exceeded")&&i.error(a)},onRetry:r,onComment:s,maxBufferSize:o})},transform(i){n.feed(i)}})}};var $_={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},Mt=class extends Error{constructor(e,r){super(`Streamable HTTP error: ${r}`),this.code=e}},_n=class{constructor(e,r){this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=yn(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??$_}async _authThenStart(){if(!this._authProvider)throw new _e("No auth provider");let e;try{e=await lt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(e!=="AUTHORIZED")throw new _e;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let e={};if(this._authProvider){let s=await this._authProvider.tokens();s&&(e.Authorization=`Bearer ${s.access_token}`)}this._sessionId&&(e["mcp-session-id"]=this._sessionId),this._protocolVersion&&(e["mcp-protocol-version"]=this._protocolVersion);let r=vr(this._requestInit?.headers);return new Headers({...e,...r})}async _startOrAuthSse(e){let{resumptionToken:r}=e;try{let s=await this._commonHeaders();s.set("Accept","text/event-stream"),r&&s.set("last-event-id",r);let o=await(this._fetch??fetch)(this._url,{method:"GET",headers:s,signal:this._abortController?.signal});if(!o.ok){if(await o.body?.cancel(),o.status===401&&this._authProvider)return await this._authThenStart();if(o.status===405)return;throw new Mt(o.status,`Failed to open SSE stream: ${o.statusText}`)}this._handleSseStream(o.body,e,!0)}catch(s){throw this.onerror?.(s),s}}_getNextReconnectionDelay(e){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,s=this._reconnectionOptions.reconnectionDelayGrowFactor,o=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(s,e),o)}_scheduleReconnection(e,r=0){let s=this._reconnectionOptions.maxRetries;if(r>=s){this.onerror?.(new Error(`Maximum reconnection attempts (${s}) exceeded.`));return}let o=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(e).catch(n=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${n instanceof Error?n.message:String(n)}`)),this._scheduleReconnection(e,r+1)})},o)}_handleSseStream(e,r,s){if(!e)return;let{onresumptiontoken:o,replayMessageId:n}=r,i,a=!1,c=!1;(async()=>{try{let l=e.pipeThrough(new TextDecoderStream).pipeThrough(new Qn({onRetry:m=>{this._serverRetryMs=m}})).getReader();for(;;){let{value:m,done:g}=await l.read();if(g)break;if(m.id&&(i=m.id,a=!0,o?.(m.id)),!!m.data&&(!m.event||m.event==="message"))try{let f=ht.parse(JSON.parse(m.data));bt(f)&&(c=!0,n!==void 0&&(f.id=n)),this.onmessage?.(f)}catch(f){this.onerror?.(f)}}(s||a)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:n},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(s||a)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:n},0)}catch(m){this.onerror?.(new Error(`Failed to reconnect: ${m instanceof Error?m.message:String(m)}`))}}})()}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 _e("No auth provider");if(await lt(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new _e("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(e,r){try{let{resumptionToken:s,onresumptiontoken:o}=r||{};if(s){this._startOrAuthSse({resumptionToken:s,replayMessageId:Jr(e)?e.id:void 0}).catch(m=>this.onerror?.(m));return}let n=await this._commonHeaders();n.set("content-type","application/json"),n.set("accept","application/json, text/event-stream");let i={...this._requestInit,method:"POST",headers:n,body:JSON.stringify(e),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._url,i),c=a.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!a.ok){let m=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Mt(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:g,scope:f}=br(a);if(this._resourceMetadataUrl=g,this._scope=f,await lt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new _e;return this._hasCompletedAuthFlow=!0,this.send(e)}if(a.status===403&&this._authProvider){let{resourceMetadataUrl:g,scope:f,error:h}=br(a);if(h==="insufficient_scope"){let y=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===y)throw new Mt(403,"Server returned 403 after trying upscoping");if(f&&(this._scope=f),g&&(this._resourceMetadataUrl=g),this._lastUpscopingHeader=y??void 0,await lt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new _e;return this.send(e)}}throw new Mt(a.status,`Error POSTing to endpoint: ${m}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),iu(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(m=>this.onerror?.(m));return}let l=(Array.isArray(e)?e:[e]).filter(m=>"method"in m&&"id"in m&&m.id!==void 0).length>0,d=a.headers.get("content-type"),p=Sm(d);if(l)if(p==="text/event-stream")this._handleSseStream(a.body,{onresumptiontoken:o},!1);else if(p==="application/json"){let m=await a.json(),g=Array.isArray(m)?m.map(f=>ht.parse(f)):[ht.parse(m)];for(let f of g)this.onmessage?.(f)}else throw await a.body?.cancel(),new Mt(-1,`Unexpected content type: ${d}`);else await a.body?.cancel()}catch(s){throw this.onerror?.(s),s}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let e=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:e,signal:this._abortController?.signal},s=await(this._fetch??fetch)(this._url,r);if(await s.body?.cancel(),!s.ok&&s.status!==405)throw new Mt(s.status,`Failed to terminate session: ${s.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,r){await this._startOrAuthSse({resumptionToken:e,onresumptiontoken:r?.onresumptiontoken})}};import{readFileSync as P_,statSync as j_}from"fs";import{extname as N_}from"path";import tl from"sharp";var z_=R({module:"images"});function km(t){if(t==="image/png"||t==="image/jpeg"||t==="image/gif"||t==="image/webp")return t;throw new Error(`Unsupported image media type: "${t}"`)}var ol=5*1024*1024,rl=ol*3/4,vt=2e3,$D=10,Rr=class extends Error{constructor(e){super(e),this.name="ImageTooLargeError"}},U_={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp"};function F_(t){return U_[N_(t).toLowerCase()]??null}function Mm(t){return F_(t)!==null}function O_(t){return t.length>=8&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71?"image/png":t.length>=3&&t[0]===255&&t[1]===216&&t[2]===255?"image/jpeg":t.length>=6&&t[0]===71&&t[1]===73&&t[2]===70?"image/gif":t.length>=12&&t[0]===82&&t[1]===73&&t[2]===70&&t[3]===70&&t[8]===87&&t[9]===69&&t[10]===66&&t[11]===80?"image/webp":null}async function vm(t){if(!j_(t).isFile())throw new Error(`Not a file: ${t}`);let r=P_(t),s=O_(r);if(!s)throw new Error(`File ${t} has an image extension but its contents are not a supported image format (png/jpeg/gif/webp)`);let o=await nl(r,s);return{mediaType:o.mediaType,data:o.data,sourcePath:t,byteLength:o.byteLength}}function sl(t,e){return{data:t.toString("base64"),mediaType:e,byteLength:t.length}}function Js(t){return`${(t/(1024*1024)).toFixed(1)}MB`}async function nl(t,e){if(t.length===0)throw new Rr("Image file is empty (0 bytes)");if(t.length<=rl)return sl(t,e);try{return await L_(t,e)}catch(r){throw r instanceof Rr?r:(z_.warn({err:r},"sharp compression failed"),new Rr(`Image is ${Js(t.length)} raw (${Js(t.length*4/3)} base64-encoded, API limit ${Js(ol)}) and compression failed. Please provide a smaller image.`))}}async function L_(t,e){let r=await tl(t).metadata(),s=r.width??vt,o=r.height??vt;s>vt&&(o=Math.max(1,Math.round(o*vt/s)),s=vt),o>vt&&(s=Math.max(1,Math.round(s*vt/o)),o=vt);let n=e==="image/png"||e==="image/gif";for(let i=0;i<3;i++){if(n){let a=await tl(t).resize(s,o,{fit:"inside",withoutEnlargement:!0}).png({compressionLevel:8,palette:!0}).toBuffer();if(a.length<=rl)return sl(a,"image/png")}for(let a of[80,60,40,20]){let c=await tl(t).resize(s,o,{fit:"inside",withoutEnlargement:!0}).jpeg({quality:a}).toBuffer();if(c.length<=rl)return sl(c,"image/jpeg")}s=Math.max(1,Math.round(s/2)),o=Math.max(1,Math.round(o/2))}throw new Rr(`Unable to compress image (${Js(t.length)} raw) under the ${Js(ol)} API limit. Please provide a smaller image.`)}import{readFileSync as q_}from"fs";import bm from"path";import{fileURLToPath as G_}from"url";var H_=$.object({version:$.string()});function Y_(){return"0.0.25"}var xm=Y_();var Rm=R({module:"mcp"});function Tm(t){return t.replace(/\$\{(\w+)\}|\$(\w+)/g,(e,r,s)=>process.env[r||s]??"")}function J_(t){let e={};for(let[r,s]of Object.entries(t))e[r]=s??"";return e}var W_=new Set(["image/png","image/jpeg","image/gif","image/webp"]);async function V_(t){let e=[],r=[],s=!1;for(let n of t){let i=Ol(n)?n:{};if(i.type==="image"&&typeof i.data=="string"&&typeof i.mimeType=="string"&&W_.has(i.mimeType))try{let u=await nl(Buffer.from(i.data,"base64"),km(i.mimeType));r.push({type:"image",source:{type:"base64",media_type:u.mediaType,data:u.data}}),e.push(`[Image: ${u.mediaType}]`),s=!0;continue}catch(u){Rm.warn({err:u},"mcp image dropped (too large to fit the API limit)");let l="[note: an image returned by the tool was too large and was dropped]";e.push(l),r.push({type:"text",text:l});continue}if(i.type==="image"){let l=`[Unsupported image: ${typeof i.mimeType=="string"?i.mimeType:"unknown"}]`;e.push(l),r.push({type:"text",text:l});continue}let a=JSON.stringify(n),c=i.type==="text"&&typeof i.text=="string"?i.text:typeof a=="string"?a:String(n);e.push(c),r.push({type:"text",text:c})}let o=e.join(`
|
|
23
23
|
`);return s?{output:o,contentBlocks:r}:{output:o}}var Sn=class{name;config;client=null;transport=null;constructor(e){this.name=e.name,this.config=e}async connect(){if(this.config.command){let e=process.env;if(this.config.env)for(let[r,s]of Object.entries(this.config.env))e[r]=Tm(s);this.transport=new Bn({command:this.config.command,args:this.config.args??[],env:J_(e),stderr:"ignore"})}else if(this.config.url){let e=new URL(this.config.url),r={};if(this.config.headers)for(let[o,n]of Object.entries(this.config.headers))r[o]=Tm(n);let s={requestInit:{headers:r}};this.transport=this.config.transport==="sse"?new wn(e,s):new _n(e,s)}else throw new Error(`MCP server '${this.name}': needs either 'command' (stdio) or 'url' (http/sse)`);this.client=new mn({name:"swifty",version:xm},{}),await this.client.connect(this.transport)}getInstructions(){return this.client?.getInstructions()??""}async listTools(){if(!this.client)throw new Error("Not connected");return(await this.client.listTools()).tools.map(({name:r,description:s,inputSchema:{properties:o,...n}})=>({name:r,description:s??"",inputSchema:{...n,properties:o??{}}}))}async callTool(e,r){if(!this.client)throw new Error("Not connected");let s=await this.client.callTool({name:e,arguments:r});return{...s.content&&Array.isArray(s.content)?await V_(s.content):{output:JSON.stringify(s)},isError:s.isError===!0}}async disconnect(){try{await this.client?.close()}catch(e){Rm.error({err:e},"mcp operation failed")}this.client=null,this.transport=null}};var K_=R({module:"mcp"}),Dm=class{clients=new Map;async connectAll(e){let r={tools:[],servers:[],errors:[],instructions:[]};for(let s of e){if(this.clients.has(s.name))continue;let o=new Sn(s);try{await o.connect();let n=await o.listTools();this.clients.set(s.name,o),r.servers.push(s.name);for(let a of n)r.tools.push({serverName:s.name,tool:a});let i=o.getInstructions();i&&r.instructions.push({serverName:s.name,text:i})}catch(n){K_.error({err:n},"mcp operation failed"),r.errors.push({serverName:s.name,error:O(n)}),await o.disconnect()}}return r}getClient(e){return this.clients.get(e)}connectedServers(){return[...this.clients.keys()]}missingServers(e){return e.filter(r=>!this.clients.has(r.name)).map(r=>r.name)}async disconnectAll(){for(let e of this.clients.values())await e.disconnect();this.clients.clear()}};import{execSync as Lm}from"child_process";import{platform as Z_,arch as X_}from"os";function $m(){return{name:"Identity",priority:0,content:`You are Swifty, an AI programming assistant running in a terminal.
|
|
24
24
|
You assist users with software engineering tasks, including writing code, debugging, refactoring, explaining code, and executing commands.
|
|
25
25
|
|
|
@@ -370,11 +370,11 @@ ${s.content.replace(/\n+$/,"")}`)}return r.join(`
|
|
|
370
370
|
|
|
371
371
|
`)}function tv(t){let e=[],r=new Set;try{let o=bg();Lr(e,r,At(o,".swifty","SWIFTY.md")),Lr(e,r,At(o,".swifty","AGENTS.md"))}catch(o){pt.error({err:o},"memory operation failed")}let s=ov(t);for(let o of s)Lr(e,r,At(o,"SWIFTY.md")),Lr(e,r,At(o,"AGENTS.md")),Lr(e,r,At(o,".swifty","SWIFTY.md"));return Lr(e,r,At(t,"SWIFTY.local.md")),e}function Lr(t,e,r){let s;try{s=Ml(r)}catch(i){pt.error({err:i},"memory operation failed");return}if(e.has(s)||!vg(s))return;let o;try{o=Mg(s,"utf-8")}catch(i){pt.error({err:i},"memory operation failed");return}e.add(s);let n=xg(o,Xn(s),e,0);t.push({path:s,content:n})}function xg(t,e,r,s){if(s>ev)return t;let o=t.split(`
|
|
372
372
|
`),n=[],i=!1;for(let a of o){let c=a.trim();if(c.startsWith("```")){i=!i,n.push(a);continue}if(!i){let u=rv(c);if(u){let l=sv(u,e);if(l){let d;try{d=Ml(l)}catch(p){pt.error({err:p},"memory operation failed"),n.push(a);continue}if(!r.has(d))try{let p=Mg(d,"utf-8");r.add(d),n.push(`<!-- included from ${u} -->`),n.push(xg(p,Xn(d),r,s+1));continue}catch(p){pt.error({err:p},"memory operation failed")}}}}n.push(a)}return n.join(`
|
|
373
|
-
`)}function rv(t){if(!t.startsWith("@")||t.startsWith("@@"))return"";let e=t.slice(1);return!e||/[\s\t]/.test(e)?"":e.startsWith("./")||e.startsWith("../")||e.startsWith("~/")||e.startsWith("/")?e:""}function sv(t,e){if(t.startsWith("~/"))try{return At(bg(),t.slice(2))}catch(r){return pt.error({err:r},"memory operation failed"),""}return ZM(t)?t:At(e,t)}function ov(t){let e;try{e=Ml(t)}catch(n){return pt.error({err:n},"memory operation failed"),[t]}let r=nv(e);if(!r)return[e];let s=[],o=e;for(;s.unshift(o),o!==r;){let n=Xn(o);if(n===o)break;o=n}return s}function nv(t){let e=t;for(;;){try{let s=At(e,".git");if(vg(s))return e}catch(s){pt.error({err:s},"memory operation failed")}let r=Xn(e);if(r===e)return"";e=r}}import{readFileSync as iv,writeFileSync as av,mkdirSync as cv,existsSync as lv}from"fs";import{join as uv,dirname as dv}from"path";var Av=R({module:"todo"}),pv=C.enum(["pending","in_progress","completed"]),mv=C.object({id:C.string(),subject:C.string(),description:C.string(),status:pv,owner:C.string().optional(),activeForm:C.string().optional(),blocks:C.array(C.string()),blockedBy:C.array(C.string()),metadata:C.record(C.string(),C.unknown())}),Tg=class{filePath;constructor(e,r){this.filePath=uv(e,".swifty","tasks",`${r}.json`)}load(){if(!lv(this.filePath))return[];try{let e=iv(this.filePath,"utf-8"),r=JSON.parse(e);return Se(C.array(mv),r)}catch(e){return Av.error({err:e},"todo operation failed"),[]}}save(e){cv(dv(this.filePath),{recursive:!0}),av(this.filePath,JSON.stringify(e,null,2),"utf-8")}};var Rg=class{tasks=new Map;nextId=1;store;constructor(e){e&&this.useStore(e)}useStore(e){this.store=e,this.tasks.clear();let r=0;for(let s of e.load()){this.tasks.set(s.id,s);let o=parseInt(s.id,10);!Number.isNaN(o)&&o>r&&(r=o)}this.nextId=r+1}persist(){this.store?.save([...this.tasks.values()])}create(e,r,s){let o={id:String(this.nextId++),subject:e,description:r,status:"pending",activeForm:s,blocks:[],blockedBy:[],metadata:{}};return this.tasks.set(o.id,o),this.persist(),o}get(e){return this.tasks.get(e)}list(){return[...this.tasks.values()]}update(e,r){let s=this.tasks.get(e);if(s)return s={...s,...r},this.tasks.set(e,s),this.persist(),s}delete(e){let r=this.tasks.delete(e);return r&&this.persist(),r}addBlocks(e,r){let s=this.tasks.get(e);if(s){for(let o of r){s.blocks.includes(o)||s.blocks.push(o);let n=this.tasks.get(o);n&&!n.blockedBy.includes(e)&&n.blockedBy.push(e)}this.persist()}}addBlockedBy(e,r){let s=this.tasks.get(e);if(s){for(let o of r){s.blockedBy.includes(o)||s.blockedBy.push(o);let n=this.tasks.get(o);n&&!n.blocks.includes(e)&&n.blocks.push(e)}this.persist()}}};var
|
|
374
|
-
`),isError:!1})}},jg=class{name="TaskUpdate";description="Update a task's status, subject, or other fields.";category="read";list;constructor(e){this.list=e}schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{taskId:{type:"string",description:"Task ID"},status:{type:"string",description:"New status: pending, in_progress, completed, deleted"},subject:{type:"string",description:"New subject"},description:{type:"string",description:"New description"},owner:{type:"string",description:"New owner"},addBlocks:{type:"array",items:{type:"string"},description:"Tasks this one blocks"},addBlockedBy:{type:"array",items:{type:"string"},description:"Tasks blocking this one"}},required:["taskId"]}}}async execute(e,r){let s=await xl(fv,r);if(!s.success)return{output:O(s.error),isError:!0};let{taskId:o,status:n,subject:i,description:a,owner:c,addBlocks:u,addBlockedBy:l}=s.data;if(!o)return Promise.resolve({output:"Error: taskId is required",isError:!0});if(n==="deleted")return this.list.delete(o),Promise.resolve({output:`Task #${o} deleted`,isError:!1});let d={};return n&&(d.status=n),i&&(d.subject=i),a&&(d.description=a),c&&(d.owner=c),this.list.update(o,d)?(u&&this.list.addBlocks(o,u),l&&this.list.addBlockedBy(o,l),{output:`Updated task #${o} status`,isError:!1}):{output:"Task not found",isError:!0}}},fv=C.object({taskId:C.string(),subject:C.string().optional(),description:C.string().optional(),status:C.enum(["pending","in_progress","completed","deleted"]).optional(),owner:C.string().optional(),addBlocks:C.array(C.string()).optional(),addBlockedBy:C.array(C.string()).optional()});var gv=$.object({label:$.string(),description:$.string().optional()}),hv=$.object({question:$.string(),header:$.string(),options:$.array(gv),multiSelect:$.boolean()}),Ng=class{constructor(e){this.ask=e}ask;name="AskUserQuestion";description=`
|
|
373
|
+
`)}function rv(t){if(!t.startsWith("@")||t.startsWith("@@"))return"";let e=t.slice(1);return!e||/[\s\t]/.test(e)?"":e.startsWith("./")||e.startsWith("../")||e.startsWith("~/")||e.startsWith("/")?e:""}function sv(t,e){if(t.startsWith("~/"))try{return At(bg(),t.slice(2))}catch(r){return pt.error({err:r},"memory operation failed"),""}return ZM(t)?t:At(e,t)}function ov(t){let e;try{e=Ml(t)}catch(n){return pt.error({err:n},"memory operation failed"),[t]}let r=nv(e);if(!r)return[e];let s=[],o=e;for(;s.unshift(o),o!==r;){let n=Xn(o);if(n===o)break;o=n}return s}function nv(t){let e=t;for(;;){try{let s=At(e,".git");if(vg(s))return e}catch(s){pt.error({err:s},"memory operation failed")}let r=Xn(e);if(r===e)return"";e=r}}import{readFileSync as iv,writeFileSync as av,mkdirSync as cv,existsSync as lv}from"fs";import{join as uv,dirname as dv}from"path";var Av=R({module:"todo"}),pv=C.enum(["pending","in_progress","completed"]),mv=C.object({id:C.string(),subject:C.string(),description:C.string(),status:pv,owner:C.string().optional(),activeForm:C.string().optional(),blocks:C.array(C.string()),blockedBy:C.array(C.string()),metadata:C.record(C.string(),C.unknown())}),Tg=class{filePath;constructor(e,r){this.filePath=uv(e,".swifty","tasks",`${r}.json`)}load(){if(!lv(this.filePath))return[];try{let e=iv(this.filePath,"utf-8"),r=JSON.parse(e);return Se(C.array(mv),r)}catch(e){return Av.error({err:e},"todo operation failed"),[]}}save(e){cv(dv(this.filePath),{recursive:!0}),av(this.filePath,JSON.stringify(e,null,2),"utf-8")}};var Rg=class{tasks=new Map;nextId=1;store;constructor(e){e&&this.useStore(e)}useStore(e){this.store=e,this.tasks.clear();let r=0;for(let s of e.load()){this.tasks.set(s.id,s);let o=parseInt(s.id,10);!Number.isNaN(o)&&o>r&&(r=o)}this.nextId=r+1}persist(){this.store?.save([...this.tasks.values()])}create(e,r,s){let o={id:String(this.nextId++),subject:e,description:r,status:"pending",activeForm:s,blocks:[],blockedBy:[],metadata:{}};return this.tasks.set(o.id,o),this.persist(),o}get(e){return this.tasks.get(e)}list(){return[...this.tasks.values()]}update(e,r){let s=this.tasks.get(e);if(s)return s={...s,...r},this.tasks.set(e,s),this.persist(),s}delete(e){let r=this.tasks.delete(e);return r&&this.persist(),r}addBlocks(e,r){let s=this.tasks.get(e);if(s){for(let o of r){s.blocks.includes(o)||s.blocks.push(o);let n=this.tasks.get(o);n&&!n.blockedBy.includes(e)&&n.blockedBy.push(e)}this.persist()}}addBlockedBy(e,r){let s=this.tasks.get(e);if(s){for(let o of r){s.blockedBy.includes(o)||s.blockedBy.push(o);let n=this.tasks.get(o);n&&!n.blocks.includes(e)&&n.blocks.push(e)}this.persist()}}};var fv=$.object({label:$.string(),description:$.string().optional()}),gv=$.object({question:$.string(),header:$.string(),options:$.array(fv),multiSelect:$.boolean()}),Dg=class{constructor(e){this.ask=e}ask;name="AskUserQuestion";description=`
|
|
375
374
|
Ask the user 1 to 4 single-choice or multiple-choices questions and wait for their answers. Each question needs 1 to 4 options; an "Other" option for custom input is added automatically.
|
|
376
375
|
Set "multiSelect: true" when choices are not mutually exclusive (single-choice), set "multiSelect: false" otherwise (multiple-choices).
|
|
377
|
-
`;category="read";schema(){let e={type:"object",properties:{questions:{type:"array",description:"question",minItems:1,maxItems:4,items:{type:"object",properties:{question:{type:"string",description:"The question to ask"},header:{type:"string",description:"Short label/category (<=12 chars)"},options:{type:"array",description:"options",minItems:2,maxItems:4,items:{type:"object",properties:{label:{type:"string",description:"label"},description:{type:"string",description:"description"}},required:["label"]}},multiSelect:{type:"boolean",description:"Set to true for multiple-choice, false for single-choice"}},required:["question","header","options","multiSelect"]}}},required:["questions"]};return{name:this.name,description:this.description,input_schema:e}}async execute(e,r){let{success:s,data:o,error:n}=await Dl($.object({questions:$.array(
|
|
376
|
+
`;category="read";schema(){let e={type:"object",properties:{questions:{type:"array",description:"question",minItems:1,maxItems:4,items:{type:"object",properties:{question:{type:"string",description:"The question to ask"},header:{type:"string",description:"Short label/category (<=12 chars)"},options:{type:"array",description:"options",minItems:2,maxItems:4,items:{type:"object",properties:{label:{type:"string",description:"label"},description:{type:"string",description:"description"}},required:["label"]}},multiSelect:{type:"boolean",description:"Set to true for multiple-choice, false for single-choice"}},required:["question","header","options","multiSelect"]}}},required:["questions"]};return{name:this.name,description:this.description,input_schema:e}}async execute(e,r){let{success:s,data:o,error:n}=await Dl($.object({questions:$.array(gv)}),r);if(!s)return{output:n.message,isError:!0};let i=o.questions;if(!Array.isArray(i)||i.length<1||i.length>4)return{output:"Error: must have 1-4 questions",isError:!0};for(let u of i)if(!Array.isArray(u.options)||u.options.length<2||u.options.length>4)return{output:`Error: question '${u.question}' must have 2-4 options`,isError:!0};let a=await this.ask(i);return{output:`User has answered your questions: ${Object.entries(a).map(([u,l])=>`"${u}" = "${l}"`).join(", ")}. You can now continue with the user's answers`,isError:!1}}};var $g=class{name="TaskCreate";description="Create a new task to track work.";category="read";list;constructor(e){this.list=e}schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{subject:{type:"string",description:"Brief task title"},description:{type:"string",description:"What needs to be done"},activeForm:{type:"string",description:"Present continuous form for spinner"}},required:["subject","description"]}}}execute(e,r){let s=S(r,"subject"),o=S(r,"description"),n=S(r,"activeForm")||void 0;if(!s)return Promise.resolve({output:"Error: subject is required",isError:!0});let i=this.list.create(s,o,n);return Promise.resolve({output:`Task #${i.id} created successfully: ${i.subject}`,isError:!1})}},Pg=class{name="TaskGet";description="Get a task by its ID.";category="read";list;constructor(e){this.list=e}schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{taskId:{type:"string",description:"Task ID"}},required:["taskId"]}}}execute(e,r){let s=S(r,"taskId"),o=this.list.get(s);return o?Promise.resolve({output:JSON.stringify(o,null,2),isError:!1}):Promise.resolve({output:"Task not found",isError:!0})}},jg=class{name="TaskList";description="List all tasks.";category="read";list;constructor(e){this.list=e}schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{}}}}execute(){let e=this.list.list();if(e.length===0)return Promise.resolve({output:"No tasks found",isError:!1});let r=e.map(s=>`#${s.id}. [${s.status}] ${s.subject}${s.owner?` (${s.owner})`:""}`);return Promise.resolve({output:r.join(`
|
|
377
|
+
`),isError:!1})}},Ng=class{name="TaskUpdate";description="Update a task's status, subject, or other fields.";category="read";list;constructor(e){this.list=e}schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{taskId:{type:"string",description:"Task ID"},status:{type:"string",description:"New status: pending, in_progress, completed, deleted"},subject:{type:"string",description:"New subject"},description:{type:"string",description:"New description"},owner:{type:"string",description:"New owner"},addBlocks:{type:"array",items:{type:"string"},description:"Tasks this one blocks"},addBlockedBy:{type:"array",items:{type:"string"},description:"Tasks blocking this one"}},required:["taskId"]}}}async execute(e,r){let s=await xl(hv,r);if(!s.success)return{output:O(s.error),isError:!0};let{taskId:o,status:n,subject:i,description:a,owner:c,addBlocks:u,addBlockedBy:l}=s.data;if(!o)return Promise.resolve({output:"Error: taskId is required",isError:!0});if(n==="deleted")return this.list.delete(o),Promise.resolve({output:`Task #${o} deleted`,isError:!1});let d={};return n&&(d.status=n),i&&(d.subject=i),a&&(d.description=a),c&&(d.owner=c),this.list.update(o,d)?(u&&this.list.addBlocks(o,u),l&&this.list.addBlockedBy(o,l),{output:`Updated task #${o} status`,isError:!1}):{output:"Task not found",isError:!0}}},hv=C.object({taskId:C.string(),subject:C.string().optional(),description:C.string().optional(),status:C.enum(["pending","in_progress","completed","deleted"]).optional(),owner:C.string().optional(),addBlocks:C.array(C.string()).optional(),addBlockedBy:C.array(C.string()).optional()});var zg=class{name="ExitPlanMode";description=`
|
|
378
378
|
Exit plan mode and present the plan for user approval.
|
|
379
379
|
Call this when your plan is complete and written to the plan file.
|
|
380
380
|
`;category="read";isPlanMode=null;planExists=null;schema(){let e={type:"object",properties:{}};return{name:this.name,description:this.description,input_schema:e}}execute(e,r){return this.isPlanMode&&!this.isPlanMode()?Promise.resolve({output:"You are not in plan mode. This tool is only for exiting plan mode after writing a plan.",isError:!0}):this.planExists&&!this.planExists()?Promise.resolve({output:"No plan file found. Please write your plan to the plan file before calling ExitPlanMode.",isError:!0}):Promise.resolve({output:"Plan mode will be exited after this turn. The user will be shown the plan approval dialog. Do not call any more tools \u2014 end your turn now.",isError:!1})}};export{si as a,ht as b,mn as c,Qm as d,$D as e,Mm as f,vm as g,xm as h,Dm as i,qm as j,Gm as k,Rn as l,Dn as m,$n as n,Pn as o,Zm as p,Xm as q,Tn as r,ef as s,tf as t,rf as u,mf as v,gf as w,Z$ as x,eP as y,tP as z,hf as A,gl as B,nP as C,Ks as D,EP as E,yP as F,Pf as G,Gf as H,zn as I,Vf as J,Zf as K,Un as L,eg as M,tg as N,Fn as O,On as P,Ln as Q,cg as R,CN as S,ug as T,dg as U,Ag as V,pg as W,mg as X,zN as Y,UN as Z,YN as _,xM as $,wg as aa,Cg as ba,oz as ca,Kn as da,kg as ea,$z as fa,Tg as ga,Rg as ha,Dg as ia,$g as ja,Pg as ka,jg as la,Ng as ma,zg as na};
|