@yukino.js/yukino 0.0.3-dev → 0.0.4

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.
Files changed (34) hide show
  1. package/README.md +5 -14
  2. package/dist/{acp-J6EPN6TP.js → acp-JCR6GVC3.js} +1 -1
  3. package/dist/{agent-LA65FOAB.js → agent-56R4TACG.js} +1 -1
  4. package/dist/{anthropic-YP6DY2F3.js → anthropic-CEUDAJL2.js} +1 -1
  5. package/dist/{chunk-675L7SRF.js → chunk-6DXHDARX.js} +9 -9
  6. package/dist/chunk-7DLUKIPE.js +5 -0
  7. package/dist/{chunk-7CVY4FXY.js → chunk-JNCMSXQZ.js} +1 -1
  8. package/dist/{chunk-ZQP5DTJA.js → chunk-RCXKUD3Y.js} +1 -1
  9. package/dist/{chunk-P77AEADG.js → chunk-SAJCBGHL.js} +1 -1
  10. package/dist/{chunk-CT773IEX.js → chunk-U2CS2E2F.js} +3 -3
  11. package/dist/{chunk-2UNWKNDU.js → chunk-UPNNYP7M.js} +1 -1
  12. package/dist/{chunk-Y6COQ5UY.js → chunk-XO7ITAWR.js} +1 -1
  13. package/dist/{chunk-JEOQXHOX.js → chunk-ZETIYALB.js} +2 -2
  14. package/dist/lib/{agent-KDWPLLAV.js → agent-INEHZXP3.js} +3 -3
  15. package/dist/lib/{anthropic-OJALXK4E.js → anthropic-MSGL4VBM.js} +2 -2
  16. package/dist/lib/{chunk-SS7OJYHN.js → chunk-BMODZ6SU.js} +4 -4
  17. package/dist/lib/{chunk-77FSPN6Y.js → chunk-DF3ITW4K.js} +8 -8
  18. package/dist/lib/{chunk-2DEH6DOX.js → chunk-E6VFL5IO.js} +1 -1
  19. package/dist/lib/{chunk-7G4AI2PP.js → chunk-ENTAZT2J.js} +1 -1
  20. package/dist/lib/{chunk-ZF52ER22.js → chunk-MDX24JQ5.js} +1 -1
  21. package/dist/lib/{chunk-WOMWIFSN.js → chunk-P3HXGEQQ.js} +2 -2
  22. package/dist/lib/index.d.ts +42 -42
  23. package/dist/lib/index.js +43 -43
  24. package/dist/lib/{openai-FB7BBZVN.js → openai-DL5VBJR4.js} +2 -2
  25. package/dist/lib/{permissions-BZRN4RES.js → permissions-Q4FBU5VD.js} +1 -1
  26. package/dist/lib/{providers-7ZGRBCQ4.js → providers-SMRZVJ7O.js} +1 -1
  27. package/dist/main.js +221 -225
  28. package/dist/{openai-2FE77NB2.js → openai-AQNX24XU.js} +1 -1
  29. package/dist/{permissions-R7P7RWZU.js → permissions-VCDMNX3L.js} +1 -1
  30. package/dist/{providers-EZFC2EPW.js → providers-FZUDVU4M.js} +1 -1
  31. package/dist/{server-54LNMGWU.js → server-VLJWUETV.js} +1 -1
  32. package/package.json +3 -11
  33. package/dist/chunk-M5H5EYXN.js +0 -5
  34. package/postinstall.mjs +0 -80
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __yukinoCreateRequire } from "node:module";
3
3
  const require = __yukinoCreateRequire(import.meta.url);
4
- import{a as No,c as Ah,d as Oh,g as Ih}from"./chunk-HLE7243Q.js";import{A as $h,E as Ph,F as Ch,H as Rh,J as zo,f as Mo,j as xh,k as Th,l as Eh,m as Oo,o as Kr}from"./chunk-JEOQXHOX.js";import{a as _h}from"./chunk-7CVY4FXY.js";import{b as Io}from"./chunk-OFC2GD5K.js";import{a as ft,b as ih,c as Eo,d as $o,e as Co,f as Ro,g as Ja,i as mh,j as gh,l as yh,m as wh,s as bh,t as vh}from"./chunk-M5H5EYXN.js";import{e as Mh,f as Zr}from"./chunk-ZQP5DTJA.js";import{a as ec}from"./chunk-Y6COQ5UY.js";import{a as Ye,f as z,g as Ao,h as Xa,j as Qa,k as Sh,l as kh,m as Hs,o as A,r as It,s as Gs,t as $,u as Yt}from"./chunk-2UNWKNDU.js";import{A as hh,B as ph,C as fh,D as y,a as oh,d as tt,e as Po,f as ah,g as b,h as ch,i as V,k as Y,l as lh,m as uh,n as ce,o as E,p as P,q as he,r as se,s as Ka,t as Za,u as ee,v as Je,w as R,x as ae,y as dh,z as Ya}from"./chunk-GYBJR2RB.js";import{a as Zt,c as T,e as To}from"./chunk-7MKA3SHV.js";var nn=T(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.regexpCode=K.getEsmExportName=K.getProperty=K.safeStringify=K.stringify=K.strConcat=K.addCodeArg=K.str=K._=K.nil=K._Code=K.Name=K.IDENTIFIER=K._CodeOrName=void 0;var rn=class{};K._CodeOrName=rn;K.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Sr=class extends rn{constructor(e){if(super(),!K.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}}};K.Name=Sr;var nt=class extends rn{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 Sr&&(r[s.str]=(r[s.str]||0)+1),r),{})}};K._Code=nt;K.nil=new nt("");function rp(t,...e){let r=[t[0]],s=0;for(;s<e.length;)Mc(r,e[s]),r.push(t[++s]);return new nt(r)}K._=rp;var Rc=new nt("+");function sp(t,...e){let r=[sn(t[0])],s=0;for(;s<e.length;)r.push(Rc),Mc(r,e[s]),r.push(Rc,sn(t[++s]));return aS(r),new nt(r)}K.str=sp;function Mc(t,e){e instanceof nt?t.push(...e._items):e instanceof Sr?t.push(e):t.push(uS(e))}K.addCodeArg=Mc;function aS(t){let e=1;for(;e<t.length-1;){if(t[e]===Rc){let r=cS(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function cS(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Sr||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 Sr))return`"${t}${e.slice(1)}`}function lS(t,e){return e.emptyStr()?t:t.emptyStr()?e:sp`${t}${e}`}K.strConcat=lS;function uS(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:sn(Array.isArray(t)?t.join(","):t)}function dS(t){return new nt(sn(t))}K.stringify=dS;function sn(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}K.safeStringify=sn;function hS(t){return typeof t=="string"&&K.IDENTIFIER.test(t)?new nt(`.${t}`):rp`[${t}]`}K.getProperty=hS;function pS(t){if(typeof t=="string"&&K.IDENTIFIER.test(t))return new nt(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}K.getEsmExportName=pS;function fS(t){return new nt(t.toString())}K.regexpCode=fS});var Ic=T(Be=>{"use strict";Object.defineProperty(Be,"__esModule",{value:!0});Be.ValueScope=Be.ValueScopeName=Be.Scope=Be.varKinds=Be.UsedValueState=void 0;var Ue=nn(),Ac=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Yo;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Yo||(Be.UsedValueState=Yo={}));Be.varKinds={const:new Ue.Name("const"),let:new Ue.Name("let"),var:new Ue.Name("var")};var Jo=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Ue.Name?e:this.name(e)}name(e){return new Ue.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}}};Be.Scope=Jo;var Xo=class extends Ue.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:s}){this.value=e,this.scopePath=(0,Ue._)`.${new Ue.Name(r)}[${s}]`}};Be.ValueScopeName=Xo;var mS=(0,Ue._)`\n`,Oc=class extends Jo{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?mS:Ue.nil}}get(){return this._scope}name(e){return new Xo(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 n=this.toName(e),{prefix:o}=n,i=(s=r.key)!==null&&s!==void 0?s:r.ref,a=this._values[o];if(a){let u=a.get(i);if(u)return u}else a=this._values[o]=new Map;a.set(i,n);let c=this._scope[o]||(this._scope[o]=[]),l=c.length;return c[l]=r.ref,n.setValue(r,{property:o,itemIndex:l}),n}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,Ue._)`${e}${s.scopePath}`})}scopeCode(e=this._values,r,s){return this._reduceValues(e,n=>{if(n.value===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return n.value.code},r,s)}_reduceValues(e,r,s={},n){let o=Ue.nil;for(let i in e){let a=e[i];if(!a)continue;let c=s[i]=s[i]||new Map;a.forEach(l=>{if(c.has(l))return;c.set(l,Yo.Started);let u=r(l);if(u){let d=this.opts.es5?Be.varKinds.var:Be.varKinds.const;o=(0,Ue._)`${o}${d} ${l} = ${u};${this.opts._n}`}else if(u=n?.(l))o=(0,Ue._)`${o}${u}${this.opts._n}`;else throw new Ac(l);c.set(l,Yo.Completed)})}return o}};Be.ValueScope=Oc});var L=T(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 W=nn(),mt=Ic(),er=nn();Object.defineProperty(F,"_",{enumerable:!0,get:function(){return er._}});Object.defineProperty(F,"str",{enumerable:!0,get:function(){return er.str}});Object.defineProperty(F,"strConcat",{enumerable:!0,get:function(){return er.strConcat}});Object.defineProperty(F,"nil",{enumerable:!0,get:function(){return er.nil}});Object.defineProperty(F,"getProperty",{enumerable:!0,get:function(){return er.getProperty}});Object.defineProperty(F,"stringify",{enumerable:!0,get:function(){return er.stringify}});Object.defineProperty(F,"regexpCode",{enumerable:!0,get:function(){return er.regexpCode}});Object.defineProperty(F,"Name",{enumerable:!0,get:function(){return er.Name}});var ri=Ic();Object.defineProperty(F,"Scope",{enumerable:!0,get:function(){return ri.Scope}});Object.defineProperty(F,"ValueScope",{enumerable:!0,get:function(){return ri.ValueScope}});Object.defineProperty(F,"ValueScopeName",{enumerable:!0,get:function(){return ri.ValueScopeName}});Object.defineProperty(F,"varKinds",{enumerable:!0,get:function(){return ri.varKinds}});F.operators={GT:new W._Code(">"),GTE:new W._Code(">="),LT:new W._Code("<"),LTE:new W._Code("<="),EQ:new W._Code("==="),NEQ:new W._Code("!=="),NOT:new W._Code("!"),OR:new W._Code("||"),AND:new W._Code("&&"),ADD:new W._Code("+")};var Nt=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},zc=class extends Nt{constructor(e,r,s){super(),this.varKind=e,this.name=r,this.rhs=s}render({es5:e,_n:r}){let s=e?mt.varKinds.var:this.varKind,n=this.rhs===void 0?"":` = ${this.rhs}`;return`${s} ${this.name}${n};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=ts(this.rhs,e,r)),this}get names(){return this.rhs instanceof W._CodeOrName?this.rhs.names:{}}},Qo=class extends Nt{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 W.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=ts(this.rhs,e,r),this}get names(){let e=this.lhs instanceof W.Name?{}:{...this.lhs.names};return ti(e,this.rhs)}},Nc=class extends Qo{constructor(e,r,s,n){super(e,s,n),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},jc=class extends Nt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Dc=class extends Nt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},qc=class extends Nt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Lc=class extends Nt{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=ts(this.code,e,r),this}get names(){return this.code instanceof W._CodeOrName?this.code.names:{}}},on=class extends Nt{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,n=s.length;for(;n--;){let o=s[n];o.optimizeNames(e,r)||(gS(e,o.names),s.splice(n,1))}return s.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Tr(e,r.names),{})}},jt=class extends on{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Fc=class extends on{},es=class extends jt{};es.kind="else";var kr=class t extends jt{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 es(s):s}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(np(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=ts(this.condition,e,r),this}get names(){let e=super.names;return ti(e,this.condition),this.else&&Tr(e,this.else.names),e}};kr.kind="if";var xr=class extends jt{};xr.kind="for";var Uc=class extends xr{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=ts(this.iteration,e,r),this}get names(){return Tr(super.names,this.iteration.names)}},Bc=class extends xr{constructor(e,r,s,n){super(),this.varKind=e,this.name=r,this.from=s,this.to=n}render(e){let r=e.es5?mt.varKinds.var:this.varKind,{name:s,from:n,to:o}=this;return`for(${r} ${s}=${n}; ${s}<${o}; ${s}++)`+super.render(e)}get names(){let e=ti(super.names,this.from);return ti(e,this.to)}},ei=class extends xr{constructor(e,r,s,n){super(),this.loop=e,this.varKind=r,this.name=s,this.iterable=n}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=ts(this.iterable,e,r),this}get names(){return Tr(super.names,this.iterable.names)}},an=class extends jt{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)}};an.kind="func";var cn=class extends on{render(e){return"return "+super.render(e)}};cn.kind="return";var Wc=class extends jt{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,n;return super.optimizeNames(e,r),(s=this.catch)===null||s===void 0||s.optimizeNames(e,r),(n=this.finally)===null||n===void 0||n.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Tr(e,this.catch.names),this.finally&&Tr(e,this.finally.names),e}},ln=class extends jt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};ln.kind="catch";var un=class extends jt{render(e){return"finally"+super.render(e)}};un.kind="finally";var Hc=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
4
+ import{a as No,c as Ah,d as Oh,g as Ih}from"./chunk-HLE7243Q.js";import{A as $h,E as Ph,F as Ch,H as Rh,J as zo,f as Mo,j as xh,k as Th,l as Eh,m as Oo,o as Kr}from"./chunk-ZETIYALB.js";import{a as _h}from"./chunk-JNCMSXQZ.js";import{b as Io}from"./chunk-OFC2GD5K.js";import{a as ft,b as ih,c as Eo,d as $o,e as Co,f as Ro,g as Ja,i as mh,j as gh,l as yh,m as wh,s as bh,t as vh}from"./chunk-7DLUKIPE.js";import{e as Mh,f as Zr}from"./chunk-RCXKUD3Y.js";import{a as ec}from"./chunk-XO7ITAWR.js";import{a as Ye,f as z,g as Ao,h as Xa,j as Qa,k as Sh,l as kh,m as Hs,o as A,q as It,r as Gs,s as $,t as Yt}from"./chunk-UPNNYP7M.js";import{A as hh,B as ph,C as fh,D as y,a as oh,d as tt,e as Po,f as ah,g as b,h as ch,i as V,k as Y,l as lh,m as uh,n as ce,o as E,p as P,q as he,r as se,s as Ka,t as Za,u as ee,v as Je,w as R,x as ae,y as dh,z as Ya}from"./chunk-GYBJR2RB.js";import{a as Zt,c as T,e as To}from"./chunk-7MKA3SHV.js";var nn=T(K=>{"use strict";Object.defineProperty(K,"__esModule",{value:!0});K.regexpCode=K.getEsmExportName=K.getProperty=K.safeStringify=K.stringify=K.strConcat=K.addCodeArg=K.str=K._=K.nil=K._Code=K.Name=K.IDENTIFIER=K._CodeOrName=void 0;var rn=class{};K._CodeOrName=rn;K.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Sr=class extends rn{constructor(e){if(super(),!K.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}}};K.Name=Sr;var nt=class extends rn{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 Sr&&(r[s.str]=(r[s.str]||0)+1),r),{})}};K._Code=nt;K.nil=new nt("");function rp(t,...e){let r=[t[0]],s=0;for(;s<e.length;)Mc(r,e[s]),r.push(t[++s]);return new nt(r)}K._=rp;var Rc=new nt("+");function sp(t,...e){let r=[sn(t[0])],s=0;for(;s<e.length;)r.push(Rc),Mc(r,e[s]),r.push(Rc,sn(t[++s]));return aS(r),new nt(r)}K.str=sp;function Mc(t,e){e instanceof nt?t.push(...e._items):e instanceof Sr?t.push(e):t.push(uS(e))}K.addCodeArg=Mc;function aS(t){let e=1;for(;e<t.length-1;){if(t[e]===Rc){let r=cS(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function cS(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Sr||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 Sr))return`"${t}${e.slice(1)}`}function lS(t,e){return e.emptyStr()?t:t.emptyStr()?e:sp`${t}${e}`}K.strConcat=lS;function uS(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:sn(Array.isArray(t)?t.join(","):t)}function dS(t){return new nt(sn(t))}K.stringify=dS;function sn(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}K.safeStringify=sn;function hS(t){return typeof t=="string"&&K.IDENTIFIER.test(t)?new nt(`.${t}`):rp`[${t}]`}K.getProperty=hS;function pS(t){if(typeof t=="string"&&K.IDENTIFIER.test(t))return new nt(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}K.getEsmExportName=pS;function fS(t){return new nt(t.toString())}K.regexpCode=fS});var Ic=T(Be=>{"use strict";Object.defineProperty(Be,"__esModule",{value:!0});Be.ValueScope=Be.ValueScopeName=Be.Scope=Be.varKinds=Be.UsedValueState=void 0;var Ue=nn(),Ac=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Yo;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Yo||(Be.UsedValueState=Yo={}));Be.varKinds={const:new Ue.Name("const"),let:new Ue.Name("let"),var:new Ue.Name("var")};var Jo=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Ue.Name?e:this.name(e)}name(e){return new Ue.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}}};Be.Scope=Jo;var Xo=class extends Ue.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:s}){this.value=e,this.scopePath=(0,Ue._)`.${new Ue.Name(r)}[${s}]`}};Be.ValueScopeName=Xo;var mS=(0,Ue._)`\n`,Oc=class extends Jo{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?mS:Ue.nil}}get(){return this._scope}name(e){return new Xo(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 n=this.toName(e),{prefix:o}=n,i=(s=r.key)!==null&&s!==void 0?s:r.ref,a=this._values[o];if(a){let u=a.get(i);if(u)return u}else a=this._values[o]=new Map;a.set(i,n);let c=this._scope[o]||(this._scope[o]=[]),l=c.length;return c[l]=r.ref,n.setValue(r,{property:o,itemIndex:l}),n}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,Ue._)`${e}${s.scopePath}`})}scopeCode(e=this._values,r,s){return this._reduceValues(e,n=>{if(n.value===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return n.value.code},r,s)}_reduceValues(e,r,s={},n){let o=Ue.nil;for(let i in e){let a=e[i];if(!a)continue;let c=s[i]=s[i]||new Map;a.forEach(l=>{if(c.has(l))return;c.set(l,Yo.Started);let u=r(l);if(u){let d=this.opts.es5?Be.varKinds.var:Be.varKinds.const;o=(0,Ue._)`${o}${d} ${l} = ${u};${this.opts._n}`}else if(u=n?.(l))o=(0,Ue._)`${o}${u}${this.opts._n}`;else throw new Ac(l);c.set(l,Yo.Completed)})}return o}};Be.ValueScope=Oc});var L=T(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 W=nn(),mt=Ic(),er=nn();Object.defineProperty(F,"_",{enumerable:!0,get:function(){return er._}});Object.defineProperty(F,"str",{enumerable:!0,get:function(){return er.str}});Object.defineProperty(F,"strConcat",{enumerable:!0,get:function(){return er.strConcat}});Object.defineProperty(F,"nil",{enumerable:!0,get:function(){return er.nil}});Object.defineProperty(F,"getProperty",{enumerable:!0,get:function(){return er.getProperty}});Object.defineProperty(F,"stringify",{enumerable:!0,get:function(){return er.stringify}});Object.defineProperty(F,"regexpCode",{enumerable:!0,get:function(){return er.regexpCode}});Object.defineProperty(F,"Name",{enumerable:!0,get:function(){return er.Name}});var ri=Ic();Object.defineProperty(F,"Scope",{enumerable:!0,get:function(){return ri.Scope}});Object.defineProperty(F,"ValueScope",{enumerable:!0,get:function(){return ri.ValueScope}});Object.defineProperty(F,"ValueScopeName",{enumerable:!0,get:function(){return ri.ValueScopeName}});Object.defineProperty(F,"varKinds",{enumerable:!0,get:function(){return ri.varKinds}});F.operators={GT:new W._Code(">"),GTE:new W._Code(">="),LT:new W._Code("<"),LTE:new W._Code("<="),EQ:new W._Code("==="),NEQ:new W._Code("!=="),NOT:new W._Code("!"),OR:new W._Code("||"),AND:new W._Code("&&"),ADD:new W._Code("+")};var Nt=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},zc=class extends Nt{constructor(e,r,s){super(),this.varKind=e,this.name=r,this.rhs=s}render({es5:e,_n:r}){let s=e?mt.varKinds.var:this.varKind,n=this.rhs===void 0?"":` = ${this.rhs}`;return`${s} ${this.name}${n};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=ts(this.rhs,e,r)),this}get names(){return this.rhs instanceof W._CodeOrName?this.rhs.names:{}}},Qo=class extends Nt{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 W.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=ts(this.rhs,e,r),this}get names(){let e=this.lhs instanceof W.Name?{}:{...this.lhs.names};return ti(e,this.rhs)}},Nc=class extends Qo{constructor(e,r,s,n){super(e,s,n),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},jc=class extends Nt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Dc=class extends Nt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},qc=class extends Nt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Lc=class extends Nt{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=ts(this.code,e,r),this}get names(){return this.code instanceof W._CodeOrName?this.code.names:{}}},on=class extends Nt{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,n=s.length;for(;n--;){let o=s[n];o.optimizeNames(e,r)||(gS(e,o.names),s.splice(n,1))}return s.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Tr(e,r.names),{})}},jt=class extends on{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Fc=class extends on{},es=class extends jt{};es.kind="else";var kr=class t extends jt{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 es(s):s}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(np(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=ts(this.condition,e,r),this}get names(){let e=super.names;return ti(e,this.condition),this.else&&Tr(e,this.else.names),e}};kr.kind="if";var xr=class extends jt{};xr.kind="for";var Uc=class extends xr{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=ts(this.iteration,e,r),this}get names(){return Tr(super.names,this.iteration.names)}},Bc=class extends xr{constructor(e,r,s,n){super(),this.varKind=e,this.name=r,this.from=s,this.to=n}render(e){let r=e.es5?mt.varKinds.var:this.varKind,{name:s,from:n,to:o}=this;return`for(${r} ${s}=${n}; ${s}<${o}; ${s}++)`+super.render(e)}get names(){let e=ti(super.names,this.from);return ti(e,this.to)}},ei=class extends xr{constructor(e,r,s,n){super(),this.loop=e,this.varKind=r,this.name=s,this.iterable=n}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=ts(this.iterable,e,r),this}get names(){return Tr(super.names,this.iterable.names)}},an=class extends jt{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)}};an.kind="func";var cn=class extends on{render(e){return"return "+super.render(e)}};cn.kind="return";var Wc=class extends jt{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,n;return super.optimizeNames(e,r),(s=this.catch)===null||s===void 0||s.optimizeNames(e,r),(n=this.finally)===null||n===void 0||n.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Tr(e,this.catch.names),this.finally&&Tr(e,this.finally.names),e}},ln=class extends jt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};ln.kind="catch";var un=class extends jt{render(e){return"finally"+super.render(e)}};un.kind="finally";var Hc=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
5
5
  `:""},this._extScope=e,this._scope=new mt.Scope({parent:e}),this._nodes=[new Fc]}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,n){let o=this._scope.toName(r);return s!==void 0&&n&&(this._constants[o.str]=s),this._leafNode(new zc(e,o,s)),o}const(e,r,s){return this._def(mt.varKinds.const,e,r,s)}let(e,r,s){return this._def(mt.varKinds.let,e,r,s)}var(e,r,s){return this._def(mt.varKinds.var,e,r,s)}assign(e,r,s){return this._leafNode(new Qo(e,r,s))}add(e,r){return this._leafNode(new Nc(e,F.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==W.nil&&this._leafNode(new Lc(e)),this}object(...e){let r=["{"];for(let[s,n]of e)r.length>1&&r.push(","),r.push(s),(s!==n||this.opts.es5)&&(r.push(":"),(0,W.addCodeArg)(r,n));return r.push("}"),new W._Code(r)}if(e,r,s){if(this._blockNode(new kr(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 kr(e))}else(){return this._elseNode(new es)}endIf(){return this._endBlockNode(kr,es)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Uc(e),r)}forRange(e,r,s,n,o=this.opts.es5?mt.varKinds.var:mt.varKinds.let){let i=this._scope.toName(e);return this._for(new Bc(o,i,r,s),()=>n(i))}forOf(e,r,s,n=mt.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let i=r instanceof W.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,W._)`${i}.length`,a=>{this.var(o,(0,W._)`${i}[${a}]`),s(o)})}return this._for(new ei("of",n,o,r),()=>s(o))}forIn(e,r,s,n=this.opts.es5?mt.varKinds.var:mt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,W._)`Object.keys(${r})`,s);let o=this._scope.toName(e);return this._for(new ei("in",n,o,r),()=>s(o))}endFor(){return this._endBlockNode(xr)}label(e){return this._leafNode(new jc(e))}break(e){return this._leafNode(new Dc(e))}return(e){let r=new cn;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(cn)}try(e,r,s){if(!r&&!s)throw new Error('CodeGen: "try" without "catch" and "finally"');let n=new Wc;if(this._blockNode(n),this.code(e),r){let o=this.name("e");this._currNode=n.catch=new ln(o),r(o)}return s&&(this._currNode=n.finally=new un,this.code(s)),this._endBlockNode(ln,un)}throw(e){return this._leafNode(new qc(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=W.nil,s,n){return this._blockNode(new an(e,r,s)),n&&this.code(n).endFunc(),this}endFunc(){return this._endBlockNode(an)}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 kr))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=Hc;function Tr(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function ti(t,e){return e instanceof W._CodeOrName?Tr(t,e.names):t}function ts(t,e,r){if(t instanceof W.Name)return s(t);if(!n(t))return t;return new W._Code(t._items.reduce((o,i)=>(i instanceof W.Name&&(i=s(i)),i instanceof W._Code?o.push(...i._items):o.push(i),o),[]));function s(o){let i=r[o.str];return i===void 0||e[o.str]!==1?o:(delete e[o.str],i)}function n(o){return o instanceof W._Code&&o._items.some(i=>i instanceof W.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function gS(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function np(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,W._)`!${Gc(t)}`}F.not=np;var yS=op(F.operators.AND);function wS(...t){return t.reduce(yS)}F.and=wS;var bS=op(F.operators.OR);function vS(...t){return t.reduce(bS)}F.or=vS;function op(t){return(e,r)=>e===W.nil?r:r===W.nil?e:(0,W._)`${Gc(e)} ${t} ${Gc(r)}`}function Gc(t){return t instanceof W.Name?t:(0,W._)`(${t})`}});var H=T(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.checkStrictMode=U.getErrorPath=U.Type=U.useFunc=U.setEvaluated=U.evaluatedPropsToName=U.mergeEvaluated=U.eachItem=U.unescapeJsonPointer=U.escapeJsonPointer=U.escapeFragment=U.unescapeFragment=U.schemaRefOrVal=U.schemaHasRulesButRef=U.schemaHasRules=U.checkUnknownRules=U.alwaysValidSchema=U.toHash=void 0;var J=L(),_S=nn();function SS(t){let e={};for(let r of t)e[r]=!0;return e}U.toHash=SS;function kS(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(cp(t,e),!lp(e,t.self.RULES.all))}U.alwaysValidSchema=kS;function cp(t,e=t.schema){let{opts:r,self:s}=t;if(!r.strictSchema||typeof e=="boolean")return;let n=s.RULES.keywords;for(let o in e)n[o]||hp(t,`unknown keyword: "${o}"`)}U.checkUnknownRules=cp;function lp(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}U.schemaHasRules=lp;function xS(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}U.schemaHasRulesButRef=xS;function TS({topSchemaRef:t,schemaPath:e},r,s,n){if(!n){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,J._)`${r}`}return(0,J._)`${t}${e}${(0,J.getProperty)(s)}`}U.schemaRefOrVal=TS;function ES(t){return up(decodeURIComponent(t))}U.unescapeFragment=ES;function $S(t){return encodeURIComponent(Kc(t))}U.escapeFragment=$S;function Kc(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}U.escapeJsonPointer=Kc;function up(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}U.unescapeJsonPointer=up;function PS(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}U.eachItem=PS;function ip({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:s}){return(n,o,i,a)=>{let c=i===void 0?o:i instanceof J.Name?(o instanceof J.Name?t(n,o,i):e(n,o,i),i):o instanceof J.Name?(e(n,i,o),o):r(o,i);return a===J.Name&&!(c instanceof J.Name)?s(n,c):c}}U.mergeEvaluated={props:ip({mergeNames:(t,e,r)=>t.if((0,J._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,J._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,J._)`${r} || {}`).code((0,J._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,J._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,J._)`${r} || {}`),Zc(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:dp}),items:ip({mergeNames:(t,e,r)=>t.if((0,J._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,J._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,J._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,J._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function dp(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,J._)`{}`);return e!==void 0&&Zc(t,r,e),r}U.evaluatedPropsToName=dp;function Zc(t,e,r){Object.keys(r).forEach(s=>t.assign((0,J._)`${e}${(0,J.getProperty)(s)}`,!0))}U.setEvaluated=Zc;var ap={};function CS(t,e){return t.scopeValue("func",{ref:e,code:ap[e.code]||(ap[e.code]=new _S._Code(e.code))})}U.useFunc=CS;var Vc;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Vc||(U.Type=Vc={}));function RS(t,e,r){if(t instanceof J.Name){let s=e===Vc.Num;return r?s?(0,J._)`"[" + ${t} + "]"`:(0,J._)`"['" + ${t} + "']"`:s?(0,J._)`"/" + ${t}`:(0,J._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,J.getProperty)(t).toString():"/"+Kc(t)}U.getErrorPath=RS;function hp(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}U.checkStrictMode=hp});var Dt=T(Yc=>{"use strict";Object.defineProperty(Yc,"__esModule",{value:!0});var Ee=L(),MS={data:new Ee.Name("data"),valCxt:new Ee.Name("valCxt"),instancePath:new Ee.Name("instancePath"),parentData:new Ee.Name("parentData"),parentDataProperty:new Ee.Name("parentDataProperty"),rootData:new Ee.Name("rootData"),dynamicAnchors:new Ee.Name("dynamicAnchors"),vErrors:new Ee.Name("vErrors"),errors:new Ee.Name("errors"),this:new Ee.Name("this"),self:new Ee.Name("self"),scope:new Ee.Name("scope"),json:new Ee.Name("json"),jsonPos:new Ee.Name("jsonPos"),jsonLen:new Ee.Name("jsonLen"),jsonPart:new Ee.Name("jsonPart")};Yc.default=MS});var dn=T($e=>{"use strict";Object.defineProperty($e,"__esModule",{value:!0});$e.extendErrors=$e.resetErrorsCount=$e.reportExtraError=$e.reportError=$e.keyword$DataError=$e.keywordError=void 0;var G=L(),si=H(),Ie=Dt();$e.keywordError={message:({keyword:t})=>(0,G.str)`must pass "${t}" keyword validation`};$e.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,G.str)`"${t}" keyword must be ${e} ($data)`:(0,G.str)`"${t}" keyword is invalid ($data)`};function AS(t,e=$e.keywordError,r,s){let{it:n}=t,{gen:o,compositeRule:i,allErrors:a}=n,c=mp(t,e,r);s??(i||a)?pp(o,c):fp(n,(0,G._)`[${c}]`)}$e.reportError=AS;function OS(t,e=$e.keywordError,r){let{it:s}=t,{gen:n,compositeRule:o,allErrors:i}=s,a=mp(t,e,r);pp(n,a),o||i||fp(s,Ie.default.vErrors)}$e.reportExtraError=OS;function IS(t,e){t.assign(Ie.default.errors,e),t.if((0,G._)`${Ie.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,G._)`${Ie.default.vErrors}.length`,e),()=>t.assign(Ie.default.vErrors,null)))}$e.resetErrorsCount=IS;function zS({gen:t,keyword:e,schemaValue:r,data:s,errsCount:n,it:o}){if(n===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",n,Ie.default.errors,a=>{t.const(i,(0,G._)`${Ie.default.vErrors}[${a}]`),t.if((0,G._)`${i}.instancePath === undefined`,()=>t.assign((0,G._)`${i}.instancePath`,(0,G.strConcat)(Ie.default.instancePath,o.errorPath))),t.assign((0,G._)`${i}.schemaPath`,(0,G.str)`${o.errSchemaPath}/${e}`),o.opts.verbose&&(t.assign((0,G._)`${i}.schema`,r),t.assign((0,G._)`${i}.data`,s))})}$e.extendErrors=zS;function pp(t,e){let r=t.const("err",e);t.if((0,G._)`${Ie.default.vErrors} === null`,()=>t.assign(Ie.default.vErrors,(0,G._)`[${r}]`),(0,G._)`${Ie.default.vErrors}.push(${r})`),t.code((0,G._)`${Ie.default.errors}++`)}function fp(t,e){let{gen:r,validateName:s,schemaEnv:n}=t;n.$async?r.throw((0,G._)`new ${t.ValidationError}(${e})`):(r.assign((0,G._)`${s}.errors`,e),r.return(!1))}var Er={keyword:new G.Name("keyword"),schemaPath:new G.Name("schemaPath"),params:new G.Name("params"),propertyName:new G.Name("propertyName"),message:new G.Name("message"),schema:new G.Name("schema"),parentSchema:new G.Name("parentSchema")};function mp(t,e,r){let{createErrors:s}=t.it;return s===!1?(0,G._)`{}`:NS(t,e,r)}function NS(t,e,r={}){let{gen:s,it:n}=t,o=[jS(n,r),DS(t,r)];return qS(t,e,o),s.object(...o)}function jS({errorPath:t},{instancePath:e}){let r=e?(0,G.str)`${t}${(0,si.getErrorPath)(e,si.Type.Str)}`:t;return[Ie.default.instancePath,(0,G.strConcat)(Ie.default.instancePath,r)]}function DS({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:s}){let n=s?e:(0,G.str)`${e}/${t}`;return r&&(n=(0,G.str)`${n}${(0,si.getErrorPath)(r,si.Type.Str)}`),[Er.schemaPath,n]}function qS(t,{params:e,message:r},s){let{keyword:n,data:o,schemaValue:i,it:a}=t,{opts:c,propertyName:l,topSchemaRef:u,schemaPath:d}=a;s.push([Er.keyword,n],[Er.params,typeof e=="function"?e(t):e||(0,G._)`{}`]),c.messages&&s.push([Er.message,typeof r=="function"?r(t):r]),c.verbose&&s.push([Er.schema,i],[Er.parentSchema,(0,G._)`${u}${d}`],[Ie.default.data,o]),l&&s.push([Er.propertyName,l])}});var yp=T(rs=>{"use strict";Object.defineProperty(rs,"__esModule",{value:!0});rs.boolOrEmptySchema=rs.topBoolOrEmptySchema=void 0;var LS=dn(),FS=L(),US=Dt(),BS={message:"boolean schema is false"};function WS(t){let{gen:e,schema:r,validateName:s}=t;r===!1?gp(t,!1):typeof r=="object"&&r.$async===!0?e.return(US.default.data):(e.assign((0,FS._)`${s}.errors`,null),e.return(!0))}rs.topBoolOrEmptySchema=WS;function HS(t,e){let{gen:r,schema:s}=t;s===!1?(r.var(e,!1),gp(t)):r.var(e,!0)}rs.boolOrEmptySchema=HS;function gp(t,e){let{gen:r,data:s}=t,n={gen:r,keyword:"false schema",data:s,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,LS.reportError)(n,BS,void 0,e)}});var Jc=T(ss=>{"use strict";Object.defineProperty(ss,"__esModule",{value:!0});ss.getRules=ss.isJSONType=void 0;var GS=["string","number","integer","boolean","null","object","array"],VS=new Set(GS);function KS(t){return typeof t=="string"&&VS.has(t)}ss.isJSONType=KS;function ZS(){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:{}}}ss.getRules=ZS});var Xc=T(tr=>{"use strict";Object.defineProperty(tr,"__esModule",{value:!0});tr.shouldUseRule=tr.shouldUseGroup=tr.schemaHasRulesForType=void 0;function YS({schema:t,self:e},r){let s=e.RULES.types[r];return s&&s!==!0&&wp(t,s)}tr.schemaHasRulesForType=YS;function wp(t,e){return e.rules.some(r=>bp(t,r))}tr.shouldUseGroup=wp;function bp(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))}tr.shouldUseRule=bp});var hn=T(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.reportTypeError=Pe.checkDataTypes=Pe.checkDataType=Pe.coerceAndCheckDataType=Pe.getJSONTypes=Pe.getSchemaTypes=Pe.DataType=void 0;var JS=Jc(),XS=Xc(),QS=dn(),q=L(),vp=H(),ns;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(ns||(Pe.DataType=ns={}));function ek(t){let e=_p(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}Pe.getSchemaTypes=ek;function _p(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(JS.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Pe.getJSONTypes=_p;function tk(t,e){let{gen:r,data:s,opts:n}=t,o=rk(e,n.coerceTypes),i=e.length>0&&!(o.length===0&&e.length===1&&(0,XS.schemaHasRulesForType)(t,e[0]));if(i){let a=el(e,s,n.strictNumbers,ns.Wrong);r.if(a,()=>{o.length?sk(t,e,o):tl(t)})}return i}Pe.coerceAndCheckDataType=tk;var Sp=new Set(["string","number","integer","boolean","null"]);function rk(t,e){return e?t.filter(r=>Sp.has(r)||e==="array"&&r==="array"):[]}function sk(t,e,r){let{gen:s,data:n,opts:o}=t,i=s.let("dataType",(0,q._)`typeof ${n}`),a=s.let("coerced",(0,q._)`undefined`);o.coerceTypes==="array"&&s.if((0,q._)`${i} == 'object' && Array.isArray(${n}) && ${n}.length == 1`,()=>s.assign(n,(0,q._)`${n}[0]`).assign(i,(0,q._)`typeof ${n}`).if(el(e,n,o.strictNumbers),()=>s.assign(a,n))),s.if((0,q._)`${a} !== undefined`);for(let l of r)(Sp.has(l)||l==="array"&&o.coerceTypes==="array")&&c(l);s.else(),tl(t),s.endIf(),s.if((0,q._)`${a} !== undefined`,()=>{s.assign(n,a),nk(t,a)});function c(l){switch(l){case"string":s.elseIf((0,q._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,q._)`"" + ${n}`).elseIf((0,q._)`${n} === null`).assign(a,(0,q._)`""`);return;case"number":s.elseIf((0,q._)`${i} == "boolean" || ${n} === null
6
6
  || (${i} == "string" && ${n} && ${n} == +${n})`).assign(a,(0,q._)`+${n}`);return;case"integer":s.elseIf((0,q._)`${i} === "boolean" || ${n} === null
7
7
  || (${i} === "string" && ${n} && ${n} == +${n} && !(${n} % 1))`).assign(a,(0,q._)`+${n}`);return;case"boolean":s.elseIf((0,q._)`${n} === "false" || ${n} === 0 || ${n} === null`).assign(a,!1).elseIf((0,q._)`${n} === "true" || ${n} === 1`).assign(a,!0);return;case"null":s.elseIf((0,q._)`${n} === "" || ${n} === 0 || ${n} === false`),s.assign(a,null);return;case"array":s.elseIf((0,q._)`${i} === "string" || ${i} === "number"
8
8
  || ${i} === "boolean" || ${n} === null`).assign(a,(0,q._)`[${n}]`)}}}function nk({gen:t,parentData:e,parentDataProperty:r},s){t.if((0,q._)`${e} !== undefined`,()=>t.assign((0,q._)`${e}[${r}]`,s))}function Qc(t,e,r,s=ns.Correct){let n=s===ns.Correct?q.operators.EQ:q.operators.NEQ,o;switch(t){case"null":return(0,q._)`${e} ${n} null`;case"array":o=(0,q._)`Array.isArray(${e})`;break;case"object":o=(0,q._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":o=i((0,q._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":o=i();break;default:return(0,q._)`typeof ${e} ${n} ${t}`}return s===ns.Correct?o:(0,q.not)(o);function i(a=q.nil){return(0,q.and)((0,q._)`typeof ${e} == "number"`,a,r?(0,q._)`isFinite(${e})`:q.nil)}}Pe.checkDataType=Qc;function el(t,e,r,s){if(t.length===1)return Qc(t[0],e,r,s);let n,o=(0,vp.toHash)(t);if(o.array&&o.object){let i=(0,q._)`typeof ${e} != "object"`;n=o.null?i:(0,q._)`!${e} || ${i}`,delete o.null,delete o.array,delete o.object}else n=q.nil;o.number&&delete o.integer;for(let i in o)n=(0,q.and)(n,Qc(i,e,r,s));return n}Pe.checkDataTypes=el;var ok={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,q._)`{type: ${t}}`:(0,q._)`{type: ${e}}`};function tl(t){let e=ik(t);(0,QS.reportError)(e,ok)}Pe.reportTypeError=tl;function ik(t){let{gen:e,data:r,schema:s}=t,n=(0,vp.schemaRefOrVal)(t,s,"type");return{gen:e,keyword:"type",data:r,schema:s.type,schemaCode:n,schemaValue:n,parentSchema:s,params:{},it:t}}});var xp=T(ni=>{"use strict";Object.defineProperty(ni,"__esModule",{value:!0});ni.assignDefaults=void 0;var os=L(),ak=H();function ck(t,e){let{properties:r,items:s}=t.schema;if(e==="object"&&r)for(let n in r)kp(t,n,r[n].default);else e==="array"&&Array.isArray(s)&&s.forEach((n,o)=>kp(t,o,n.default))}ni.assignDefaults=ck;function kp(t,e,r){let{gen:s,compositeRule:n,data:o,opts:i}=t;if(r===void 0)return;let a=(0,os._)`${o}${(0,os.getProperty)(e)}`;if(n){(0,ak.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,os._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,os._)`${c} || ${a} === null || ${a} === ""`),s.if(c,(0,os._)`${a} = ${(0,os.stringify)(r)}`)}});var ot=T(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.validateUnion=Z.validateArray=Z.usePattern=Z.callValidateCode=Z.schemaProperties=Z.allSchemaProperties=Z.noPropertyInData=Z.propertyInData=Z.isOwnProperty=Z.hasPropFunc=Z.reportMissingProp=Z.checkMissingProp=Z.checkReportMissingProp=void 0;var te=L(),rl=H(),rr=Dt(),lk=H();function uk(t,e){let{gen:r,data:s,it:n}=t;r.if(nl(r,s,e,n.opts.ownProperties),()=>{t.setParams({missingProperty:(0,te._)`${e}`},!0),t.error()})}Z.checkReportMissingProp=uk;function dk({gen:t,data:e,it:{opts:r}},s,n){return(0,te.or)(...s.map(o=>(0,te.and)(nl(t,e,o,r.ownProperties),(0,te._)`${n} = ${o}`)))}Z.checkMissingProp=dk;function hk(t,e){t.setParams({missingProperty:e},!0),t.error()}Z.reportMissingProp=hk;function Tp(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,te._)`Object.prototype.hasOwnProperty`})}Z.hasPropFunc=Tp;function sl(t,e,r){return(0,te._)`${Tp(t)}.call(${e}, ${r})`}Z.isOwnProperty=sl;function pk(t,e,r,s){let n=(0,te._)`${e}${(0,te.getProperty)(r)} !== undefined`;return s?(0,te._)`${n} && ${sl(t,e,r)}`:n}Z.propertyInData=pk;function nl(t,e,r,s){let n=(0,te._)`${e}${(0,te.getProperty)(r)} === undefined`;return s?(0,te.or)(n,(0,te.not)(sl(t,e,r))):n}Z.noPropertyInData=nl;function Ep(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}Z.allSchemaProperties=Ep;function fk(t,e){return Ep(e).filter(r=>!(0,rl.alwaysValidSchema)(t,e[r]))}Z.schemaProperties=fk;function mk({schemaCode:t,data:e,it:{gen:r,topSchemaRef:s,schemaPath:n,errorPath:o},it:i},a,c,l){let u=l?(0,te._)`${t}, ${e}, ${s}${n}`:e,d=[[rr.default.instancePath,(0,te.strConcat)(rr.default.instancePath,o)],[rr.default.parentData,i.parentData],[rr.default.parentDataProperty,i.parentDataProperty],[rr.default.rootData,rr.default.rootData]];i.opts.dynamicRef&&d.push([rr.default.dynamicAnchors,rr.default.dynamicAnchors]);let h=(0,te._)`${u}, ${r.object(...d)}`;return c!==te.nil?(0,te._)`${a}.call(${c}, ${h})`:(0,te._)`${a}(${h})`}Z.callValidateCode=mk;var gk=(0,te._)`new RegExp`;function yk({gen:t,it:{opts:e}},r){let s=e.unicodeRegExp?"u":"",{regExp:n}=e.code,o=n(r,s);return t.scopeValue("pattern",{key:o.toString(),ref:o,code:(0,te._)`${n.code==="new RegExp"?gk:(0,lk.useFunc)(t,n)}(${r}, ${s})`})}Z.usePattern=yk;function wk(t){let{gen:e,data:r,keyword:s,it:n}=t,o=e.name("valid");if(n.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(o,!0),i(()=>e.break()),o;function i(a){let c=e.const("len",(0,te._)`${r}.length`);e.forRange("i",0,c,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:rl.Type.Num},o),e.if((0,te.not)(o),a)})}}Z.validateArray=wk;function bk(t){let{gen:e,schema:r,keyword:s,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,rl.alwaysValidSchema)(n,c))&&!n.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,l)=>{let u=t.subschema({keyword:s,schemaProp:l,compositeRule:!0},a);e.assign(i,(0,te._)`${i} || ${a}`),t.mergeValidEvaluated(u,a)||e.if((0,te.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}Z.validateUnion=bk});var Cp=T($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.validateKeywordUsage=$t.validSchemaType=$t.funcKeywordCode=$t.macroKeywordCode=void 0;var ze=L(),$r=Dt(),vk=ot(),_k=dn();function Sk(t,e){let{gen:r,keyword:s,schema:n,parentSchema:o,it:i}=t,a=e.macro.call(i.self,n,o,i),c=Pp(r,s,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let l=r.name("valid");t.subschema({schema:a,schemaPath:ze.nil,errSchemaPath:`${i.errSchemaPath}/${s}`,topSchemaRef:c,compositeRule:!0},l),t.pass(l,()=>t.error(!0))}$t.macroKeywordCode=Sk;function kk(t,e){var r;let{gen:s,keyword:n,schema:o,parentSchema:i,$data:a,it:c}=t;Tk(c,e);let l=!a&&e.compile?e.compile.call(c.self,o,i,c):e.validate,u=Pp(s,n,l),d=s.let("valid");t.block$data(d,h),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function h(){if(e.errors===!1)f(),e.modifying&&$p(t),g(()=>t.error());else{let w=e.async?p():m();e.modifying&&$p(t),g(()=>xk(t,w))}}function p(){let w=s.let("ruleErrs",null);return s.try(()=>f((0,ze._)`await `),v=>s.assign(d,!1).if((0,ze._)`${v} instanceof ${c.ValidationError}`,()=>s.assign(w,(0,ze._)`${v}.errors`),()=>s.throw(v))),w}function m(){let w=(0,ze._)`${u}.errors`;return s.assign(w,null),f(ze.nil),w}function f(w=e.async?(0,ze._)`await `:ze.nil){let v=c.opts.passContext?$r.default.this:$r.default.self,S=!("compile"in e&&!a||e.schema===!1);s.assign(d,(0,ze._)`${w}${(0,vk.callValidateCode)(t,u,v,S)}`,e.modifying)}function g(w){var v;s.if((0,ze.not)((v=e.valid)!==null&&v!==void 0?v:d),w)}}$t.funcKeywordCode=kk;function $p(t){let{gen:e,data:r,it:s}=t;e.if(s.parentData,()=>e.assign(r,(0,ze._)`${s.parentData}[${s.parentDataProperty}]`))}function xk(t,e){let{gen:r}=t;r.if((0,ze._)`Array.isArray(${e})`,()=>{r.assign($r.default.vErrors,(0,ze._)`${$r.default.vErrors} === null ? ${e} : ${$r.default.vErrors}.concat(${e})`).assign($r.default.errors,(0,ze._)`${$r.default.vErrors}.length`),(0,_k.extendErrors)(t)},()=>t.error())}function Tk({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Pp(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,ze.stringify)(r)})}function Ek(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")}$t.validSchemaType=Ek;function $k({schema:t,opts:e,self:r,errSchemaPath:s},n,o){if(Array.isArray(n.keyword)?!n.keyword.includes(o):n.keyword!==o)throw new Error("ajv implementation error");let i=n.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${o}: ${i.join(",")}`);if(n.validateSchema&&!n.validateSchema(t[o])){let c=`keyword "${o}" value is invalid at path "${s}": `+r.errorsText(n.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}$t.validateKeywordUsage=$k});var Mp=T(sr=>{"use strict";Object.defineProperty(sr,"__esModule",{value:!0});sr.extendSubschemaMode=sr.extendSubschemaData=sr.getSubschema=void 0;var Pt=L(),Rp=H();function Pk(t,{keyword:e,schemaProp:r,schema:s,schemaPath:n,errSchemaPath:o,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,Pt._)`${t.schemaPath}${(0,Pt.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Pt._)`${t.schemaPath}${(0,Pt.getProperty)(e)}${(0,Pt.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Rp.escapeFragment)(r)}`}}if(s!==void 0){if(n===void 0||o===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:s,schemaPath:n,topSchemaRef:i,errSchemaPath:o}}throw new Error('either "keyword" or "schema" must be passed')}sr.getSubschema=Pk;function Ck(t,e,{dataProp:r,dataPropType:s,data:n,dataTypes:o,propertyName:i}){if(n!==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:l,dataPathArr:u,opts:d}=e,h=a.let("data",(0,Pt._)`${e.data}${(0,Pt.getProperty)(r)}`,!0);c(h),t.errorPath=(0,Pt.str)`${l}${(0,Rp.getErrorPath)(r,s,d.jsPropertySyntax)}`,t.parentDataProperty=(0,Pt._)`${r}`,t.dataPathArr=[...u,t.parentDataProperty]}if(n!==void 0){let l=n instanceof Pt.Name?n:a.let("data",n,!0);c(l),i!==void 0&&(t.propertyName=i)}o&&(t.dataTypes=o);function c(l){t.data=l,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,l]}}sr.extendSubschemaData=Ck;function Rk(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:s,createErrors:n,allErrors:o}){s!==void 0&&(t.compositeRule=s),n!==void 0&&(t.createErrors=n),o!==void 0&&(t.allErrors=o),t.jtdDiscriminator=e,t.jtdMetadata=r}sr.extendSubschemaMode=Rk});var ol=T((hL,Ap)=>{"use strict";Ap.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,n,o;if(Array.isArray(e)){if(s=e.length,s!=r.length)return!1;for(n=s;n--!==0;)if(!t(e[n],r[n]))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(o=Object.keys(e),s=o.length,s!==Object.keys(r).length)return!1;for(n=s;n--!==0;)if(!Object.prototype.hasOwnProperty.call(r,o[n]))return!1;for(n=s;n--!==0;){var i=o[n];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var Ip=T((pL,Op)=>{"use strict";var nr=Op.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var s=typeof r=="function"?r:r.pre||function(){},n=r.post||function(){};oi(e,s,n,t,"",t)};nr.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};nr.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};nr.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};nr.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 oi(t,e,r,s,n,o,i,a,c,l){if(s&&typeof s=="object"&&!Array.isArray(s)){e(s,n,o,i,a,c,l);for(var u in s){var d=s[u];if(Array.isArray(d)){if(u in nr.arrayKeywords)for(var h=0;h<d.length;h++)oi(t,e,r,d[h],n+"/"+u+"/"+h,o,n,u,s,h)}else if(u in nr.propsKeywords){if(d&&typeof d=="object")for(var p in d)oi(t,e,r,d[p],n+"/"+u+"/"+Mk(p),o,n,u,s,p)}else(u in nr.keywords||t.allKeys&&!(u in nr.skipKeywords))&&oi(t,e,r,d,n+"/"+u,o,n,u,s)}r(s,n,o,i,a,c,l)}}function Mk(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var pn=T(We=>{"use strict";Object.defineProperty(We,"__esModule",{value:!0});We.getSchemaRefs=We.resolveUrl=We.normalizeId=We._getFullPath=We.getFullPath=We.inlineRef=void 0;var Ak=H(),Ok=ol(),Ik=Ip(),zk=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Nk(t,e=!0){return typeof t=="boolean"?!0:e===!0?!il(t):e?zp(t)<=e:!1}We.inlineRef=Nk;var jk=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function il(t){for(let e in t){if(jk.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(il)||typeof r=="object"&&il(r))return!0}return!1}function zp(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!zk.has(r)&&(typeof t[r]=="object"&&(0,Ak.eachItem)(t[r],s=>e+=zp(s)),e===1/0))return 1/0}return e}function Np(t,e="",r){r!==!1&&(e=is(e));let s=t.parse(e);return jp(t,s)}We.getFullPath=Np;function jp(t,e){return t.serialize(e).split("#")[0]+"#"}We._getFullPath=jp;var Dk=/#\/?$/;function is(t){return t?t.replace(Dk,""):""}We.normalizeId=is;function qk(t,e,r){return r=is(r),t.resolve(e,r)}We.resolveUrl=qk;var Lk=/^[a-z_][-a-z0-9._]*$/i;function Fk(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:s}=this.opts,n=is(t[r]||e),o={"":n},i=Np(s,n,!1),a={},c=new Set;return Ik(t,{allKeys:!0},(d,h,p,m)=>{if(m===void 0)return;let f=i+h,g=o[m];typeof d[r]=="string"&&(g=w.call(this,d[r])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),o[h]=g;function w(S){let x=this.opts.uriResolver.resolve;if(S=is(g?x(g,S):S),c.has(S))throw u(S);c.add(S);let _=this.refs[S];return typeof _=="string"&&(_=this.refs[_]),typeof _=="object"?l(d,_.schema,S):S!==is(f)&&(S[0]==="#"?(l(d,a[S],S),a[S]=d):this.refs[S]=f),S}function v(S){if(typeof S=="string"){if(!Lk.test(S))throw new Error(`invalid anchor "${S}"`);w.call(this,`#${S}`)}}}),a;function l(d,h,p){if(h!==void 0&&!Ok(d,h))throw u(p)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}We.getSchemaRefs=Fk});var gn=T(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});or.getData=or.KeywordCxt=or.validateFunctionCode=void 0;var Up=yp(),Dp=hn(),cl=Xc(),ii=hn(),Uk=xp(),mn=Cp(),al=Mp(),M=L(),j=Dt(),Bk=pn(),qt=H(),fn=dn();function Wk(t){if(Hp(t)&&(Gp(t),Wp(t))){Vk(t);return}Bp(t,()=>(0,Up.topBoolOrEmptySchema)(t))}or.validateFunctionCode=Wk;function Bp({gen:t,validateName:e,schema:r,schemaEnv:s,opts:n},o){n.code.es5?t.func(e,(0,M._)`${j.default.data}, ${j.default.valCxt}`,s.$async,()=>{t.code((0,M._)`"use strict"; ${qp(r,n)}`),Gk(t,n),t.code(o)}):t.func(e,(0,M._)`${j.default.data}, ${Hk(n)}`,s.$async,()=>t.code(qp(r,n)).code(o))}function Hk(t){return(0,M._)`{${j.default.instancePath}="", ${j.default.parentData}, ${j.default.parentDataProperty}, ${j.default.rootData}=${j.default.data}${t.dynamicRef?(0,M._)`, ${j.default.dynamicAnchors}={}`:M.nil}}={}`}function Gk(t,e){t.if(j.default.valCxt,()=>{t.var(j.default.instancePath,(0,M._)`${j.default.valCxt}.${j.default.instancePath}`),t.var(j.default.parentData,(0,M._)`${j.default.valCxt}.${j.default.parentData}`),t.var(j.default.parentDataProperty,(0,M._)`${j.default.valCxt}.${j.default.parentDataProperty}`),t.var(j.default.rootData,(0,M._)`${j.default.valCxt}.${j.default.rootData}`),e.dynamicRef&&t.var(j.default.dynamicAnchors,(0,M._)`${j.default.valCxt}.${j.default.dynamicAnchors}`)},()=>{t.var(j.default.instancePath,(0,M._)`""`),t.var(j.default.parentData,(0,M._)`undefined`),t.var(j.default.parentDataProperty,(0,M._)`undefined`),t.var(j.default.rootData,j.default.data),e.dynamicRef&&t.var(j.default.dynamicAnchors,(0,M._)`{}`)})}function Vk(t){let{schema:e,opts:r,gen:s}=t;Bp(t,()=>{r.$comment&&e.$comment&&Kp(t),Xk(t),s.let(j.default.vErrors,null),s.let(j.default.errors,0),r.unevaluated&&Kk(t),Vp(t),tx(t)})}function Kk(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,M._)`${r}.evaluated`),e.if((0,M._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,M._)`${t.evaluated}.props`,(0,M._)`undefined`)),e.if((0,M._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,M._)`${t.evaluated}.items`,(0,M._)`undefined`))}function qp(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,M._)`/*# sourceURL=${r} */`:M.nil}function Zk(t,e){if(Hp(t)&&(Gp(t),Wp(t))){Yk(t,e);return}(0,Up.boolOrEmptySchema)(t,e)}function Wp({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 Hp(t){return typeof t.schema!="boolean"}function Yk(t,e){let{schema:r,gen:s,opts:n}=t;n.$comment&&r.$comment&&Kp(t),Qk(t),ex(t);let o=s.const("_errs",j.default.errors);Vp(t,o),s.var(e,(0,M._)`${o} === ${j.default.errors}`)}function Gp(t){(0,qt.checkUnknownRules)(t),Jk(t)}function Vp(t,e){if(t.opts.jtd)return Lp(t,[],!1,e);let r=(0,Dp.getSchemaTypes)(t.schema),s=(0,Dp.coerceAndCheckDataType)(t,r);Lp(t,r,!s,e)}function Jk(t){let{schema:e,errSchemaPath:r,opts:s,self:n}=t;e.$ref&&s.ignoreKeywordsWithRef&&(0,qt.schemaHasRulesButRef)(e,n.RULES)&&n.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Xk(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,qt.checkStrictMode)(t,"default is ignored in the schema root")}function Qk(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,Bk.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function ex(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function Kp({gen:t,schemaEnv:e,schema:r,errSchemaPath:s,opts:n}){let o=r.$comment;if(n.$comment===!0)t.code((0,M._)`${j.default.self}.logger.log(${o})`);else if(typeof n.$comment=="function"){let i=(0,M.str)`${s}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,M._)`${j.default.self}.opts.$comment(${o}, ${i}, ${a}.schema)`)}}function tx(t){let{gen:e,schemaEnv:r,validateName:s,ValidationError:n,opts:o}=t;r.$async?e.if((0,M._)`${j.default.errors} === 0`,()=>e.return(j.default.data),()=>e.throw((0,M._)`new ${n}(${j.default.vErrors})`)):(e.assign((0,M._)`${s}.errors`,j.default.vErrors),o.unevaluated&&rx(t),e.return((0,M._)`${j.default.errors} === 0`))}function rx({gen:t,evaluated:e,props:r,items:s}){r instanceof M.Name&&t.assign((0,M._)`${e}.props`,r),s instanceof M.Name&&t.assign((0,M._)`${e}.items`,s)}function Lp(t,e,r,s){let{gen:n,schema:o,data:i,allErrors:a,opts:c,self:l}=t,{RULES:u}=l;if(o.$ref&&(c.ignoreKeywordsWithRef||!(0,qt.schemaHasRulesButRef)(o,u))){n.block(()=>Yp(t,"$ref",u.all.$ref.definition));return}c.jtd||sx(t,e),n.block(()=>{for(let h of u.rules)d(h);d(u.post)});function d(h){(0,cl.shouldUseGroup)(o,h)&&(h.type?(n.if((0,ii.checkDataType)(h.type,i,c.strictNumbers)),Fp(t,h),e.length===1&&e[0]===h.type&&r&&(n.else(),(0,ii.reportTypeError)(t)),n.endIf()):Fp(t,h),a||n.if((0,M._)`${j.default.errors} === ${s||0}`))}}function Fp(t,e){let{gen:r,schema:s,opts:{useDefaults:n}}=t;n&&(0,Uk.assignDefaults)(t,e.type),r.block(()=>{for(let o of e.rules)(0,cl.shouldUseRule)(s,o)&&Yp(t,o.keyword,o.definition,e.type)})}function sx(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(nx(t,e),t.opts.allowUnionTypes||ox(t,e),ix(t,t.dataTypes))}function nx(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{Zp(t.dataTypes,r)||ll(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),cx(t,e)}}function ox(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&ll(t,"use allowUnionTypes to allow union type keyword")}function ix(t,e){let r=t.self.RULES.all;for(let s in r){let n=r[s];if(typeof n=="object"&&(0,cl.shouldUseRule)(t.schema,n)){let{type:o}=n.definition;o.length&&!o.some(i=>ax(e,i))&&ll(t,`missing type "${o.join(",")}" for keyword "${s}"`)}}}function ax(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function Zp(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function cx(t,e){let r=[];for(let s of t.dataTypes)Zp(e,s)?r.push(s):e.includes("integer")&&s==="number"&&r.push("integer");t.dataTypes=r}function ll(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,qt.checkStrictMode)(t,e,t.opts.strictTypes)}var ai=class{constructor(e,r,s){if((0,mn.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,qt.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",Jp(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,mn.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,M.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,M.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,M._)`${r} !== undefined && (${(0,M.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?fn.reportExtraError:fn.reportError)(this,this.def.error,r)}$dataError(){(0,fn.reportError)(this,this.def.$dataError||fn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,fn.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=M.nil){this.gen.block(()=>{this.check$data(e,s),r()})}check$data(e=M.nil,r=M.nil){if(!this.$data)return;let{gen:s,schemaCode:n,schemaType:o,def:i}=this;s.if((0,M.or)((0,M._)`${n} === undefined`,r)),e!==M.nil&&s.assign(e,!0),(o.length||i.validateSchema)&&(s.elseIf(this.invalid$data()),this.$dataError(),e!==M.nil&&s.assign(e,!1)),s.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:s,def:n,it:o}=this;return(0,M.or)(i(),a());function i(){if(s.length){if(!(r instanceof M.Name))throw new Error("ajv implementation error");let c=Array.isArray(s)?s:[s];return(0,M._)`${(0,ii.checkDataTypes)(c,r,o.opts.strictNumbers,ii.DataType.Wrong)}`}return M.nil}function a(){if(n.validateSchema){let c=e.scopeValue("validate$data",{ref:n.validateSchema});return(0,M._)`!${c}(${r})`}return M.nil}}subschema(e,r){let s=(0,al.getSubschema)(this.it,e);(0,al.extendSubschemaData)(s,this.it,e),(0,al.extendSubschemaMode)(s,e);let n={...this.it,...s,items:void 0,props:void 0};return Zk(n,r),n}mergeEvaluated(e,r){let{it:s,gen:n}=this;s.opts.unevaluated&&(s.props!==!0&&e.props!==void 0&&(s.props=qt.mergeEvaluated.props(n,e.props,s.props,r)),s.items!==!0&&e.items!==void 0&&(s.items=qt.mergeEvaluated.items(n,e.items,s.items,r)))}mergeValidEvaluated(e,r){let{it:s,gen:n}=this;if(s.opts.unevaluated&&(s.props!==!0||s.items!==!0))return n.if(r,()=>this.mergeEvaluated(e,M.Name)),!0}};or.KeywordCxt=ai;function Yp(t,e,r,s){let n=new ai(t,r,e);"code"in r?r.code(n,s):n.$data&&r.validate?(0,mn.funcKeywordCode)(n,r):"macro"in r?(0,mn.macroKeywordCode)(n,r):(r.compile||r.validate)&&(0,mn.funcKeywordCode)(n,r)}var lx=/^\/(?:[^~]|~0|~1)*$/,ux=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Jp(t,{dataLevel:e,dataNames:r,dataPathArr:s}){let n,o;if(t==="")return j.default.rootData;if(t[0]==="/"){if(!lx.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);n=t,o=j.default.rootData}else{let l=ux.exec(t);if(!l)throw new Error(`Invalid JSON-pointer: ${t}`);let u=+l[1];if(n=l[2],n==="#"){if(u>=e)throw new Error(c("property/index",u));return s[e-u]}if(u>e)throw new Error(c("data",u));if(o=r[e-u],!n)return o}let i=o,a=n.split("/");for(let l of a)l&&(o=(0,M._)`${o}${(0,M.getProperty)((0,qt.unescapeJsonPointer)(l))}`,i=(0,M._)`${i} && ${o}`);return i;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${e}`}}or.getData=Jp});var ci=T(dl=>{"use strict";Object.defineProperty(dl,"__esModule",{value:!0});var ul=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};dl.default=ul});var yn=T(fl=>{"use strict";Object.defineProperty(fl,"__esModule",{value:!0});var hl=pn(),pl=class extends Error{constructor(e,r,s,n){super(n||`can't resolve reference ${s} from id ${r}`),this.missingRef=(0,hl.resolveUrl)(e,r,s),this.missingSchema=(0,hl.normalizeId)((0,hl.getFullPath)(e,this.missingRef))}};fl.default=pl});var ui=T(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.resolveSchema=it.getCompilingSchema=it.resolveRef=it.compileSchema=it.SchemaEnv=void 0;var gt=L(),dx=ci(),Pr=Dt(),yt=pn(),Xp=H(),hx=gn(),as=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,yt.normalizeId)(s?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=s?.$async,this.refs={}}};it.SchemaEnv=as;function gl(t){let e=Qp.call(this,t);if(e)return e;let r=(0,yt.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:s,lines:n}=this.opts.code,{ownProperties:o}=this.opts,i=new gt.CodeGen(this.scope,{es5:s,lines:n,ownProperties:o}),a;t.$async&&(a=i.scopeValue("Error",{ref:dx.default,code:(0,gt._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let l={gen:i,allErrors:this.opts.allErrors,data:Pr.default.data,parentData:Pr.default.parentData,parentDataProperty:Pr.default.parentDataProperty,dataNames:[Pr.default.data],dataPathArr:[gt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,gt.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:gt.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,gt._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(t),(0,hx.validateFunctionCode)(l),i.optimize(this.opts.code.optimize);let d=i.toString();u=`${i.scopeRefs(Pr.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,t));let p=new Function(`${Pr.default.self}`,`${Pr.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=t.schema,p.schemaEnv=t,t.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:m,items:f}=l;p.evaluated={props:m instanceof gt.Name?void 0:m,items:f instanceof gt.Name?void 0:f,dynamicProps:m instanceof gt.Name,dynamicItems:f instanceof gt.Name},p.source&&(p.source.evaluated=(0,gt.stringify)(p.evaluated))}return t.validate=p,t}catch(d){throw delete t.validate,delete t.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(t)}}it.compileSchema=gl;function px(t,e,r){var s;r=(0,yt.resolveUrl)(this.opts.uriResolver,e,r);let n=t.refs[r];if(n)return n;let o=gx.call(this,t,r);if(o===void 0){let i=(s=t.localRefs)===null||s===void 0?void 0:s[r],{schemaId:a}=this.opts;i&&(o=new as({schema:i,schemaId:a,root:t,baseId:e}))}if(o!==void 0)return t.refs[r]=fx.call(this,o)}it.resolveRef=px;function fx(t){return(0,yt.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:gl.call(this,t)}function Qp(t){for(let e of this._compilations)if(mx(e,t))return e}it.getCompilingSchema=Qp;function mx(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function gx(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||li.call(this,t,e)}function li(t,e){let r=this.opts.uriResolver.parse(e),s=(0,yt._getFullPath)(this.opts.uriResolver,r),n=(0,yt.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&s===n)return ml.call(this,r,t);let o=(0,yt.normalizeId)(s),i=this.refs[o]||this.schemas[o];if(typeof i=="string"){let a=li.call(this,t,i);return typeof a?.schema!="object"?void 0:ml.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||gl.call(this,i),o===(0,yt.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,l=a[c];return l&&(n=(0,yt.resolveUrl)(this.opts.uriResolver,n,l)),new as({schema:a,schemaId:c,root:t,baseId:n})}return ml.call(this,r,i)}}it.resolveSchema=li;var yx=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function ml(t,{baseId:e,schema:r,root:s}){var n;if(((n=t.fragment)===null||n===void 0?void 0:n[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,Xp.unescapeFragment)(a)];if(c===void 0)return;r=c;let l=typeof r=="object"&&r[this.opts.schemaId];!yx.has(a)&&l&&(e=(0,yt.resolveUrl)(this.opts.uriResolver,e,l))}let o;if(typeof r!="boolean"&&r.$ref&&!(0,Xp.schemaHasRulesButRef)(r,this.RULES)){let a=(0,yt.resolveUrl)(this.opts.uriResolver,e,r.$ref);o=li.call(this,s,a)}let{schemaId:i}=this.opts;if(o=o||new as({schema:r,schemaId:i,root:s,baseId:e}),o.schema!==o.root.schema)return o}});var ef=T((bL,wx)=>{wx.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 Sl=T((vL,cf)=>{"use strict";var bx=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),wl=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),vx=RegExp.prototype.test.bind(/^\d*$/u),Cr=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),bl=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),rf=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),vl=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),_x=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),He=new Array(256);{let t="0123456789ABCDEF";for(let e=0;e<256;e++)He[e]="%"+t[e>>4]+t[e&15]}function Ce(t){return t<2048?He[192|t>>6]+He[128|t&63]:t<65536?He[224|t>>12]+He[128|t>>6&63]+He[128|t&63]:He[240|t>>18]+He[128|t>>12&63]+He[128|t>>6&63]+He[128|t&63]}function Sx(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 kx=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),xx=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),Tx=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),Ex=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function $x(t){if(t.length===0)return!1;for(let e=0;e<t.length;e++)if(!Tx(t[e])){if(t[e]==="%"&&e+2<t.length&&Cr(t.slice(e+1,e+3))){e+=2;continue}return!1}return!0}function tf(t){let e=-1,r=0,s=-1,n=0;for(let a=0;a<t.length;a++)t[a]==="0"?(s===-1&&(s=a),n++,n>r&&(r=n,e=s)):(s=-1,n=0);if(r<2)return t.join(":");let o=t.slice(0,e).join(":"),i=t.slice(e+r).join(":");return o+"::"+i}function Px(t){let e=t.indexOf("::");if(e!==-1&&t.indexOf("::",e+1)!==-1)return;let r=e===-1?t.split(":"):t.slice(0,e).split(":"),s=e===-1?[]:t.slice(e+2).split(":");e!==-1&&(r.length===1&&r[0]===""&&(r.length=0),s.length===1&&s[0]===""&&(s.length=0));let n=r.concat(s),o=0;for(let a=0;a<n.length;a++){let c=n[a];if(c==="")return;if(c.indexOf(".")!==-1){if(a!==n.length-1||e!==-1&&s.length===0||!wl(c))return;o+=2;continue}if(!kx(c))return;n[a]=parseInt(c,16).toString(16),o++}if(e===-1)return o!==8?void 0:tf(n);if(o>=8)return;let i=n.slice(0,r.length);for(let a=o;a<8;a++)i.push("0");for(let a=r.length;a<n.length;a++)i.push(n[a]);return tf(i)}function yl(t){let e=t[0]==="["&&t[t.length-1]==="]";if((t[0]==="["||t[t.length-1]==="]")&&!e)return{host:t,isIPV6:!1,error:!0};let s=e?t.slice(1,-1):t;if(e&&xx(s))return s=s.toLowerCase(),{host:`[${s}]`,escapedHost:s,isIPV6:!1,isIPVFuture:!0};if(Cx(s,":")<2)return{host:t,isIPV6:!1,error:e};let n="",o=s.indexOf("%");if(o!==-1){let a=s.slice(o,o+3).toLowerCase()==="%25"?3:1;if(n=s.slice(o+a),!$x(n))return{host:t,isIPV6:!1,error:!0};s=s.slice(0,o)}let i=Px(s);return i===void 0?{host:t,isIPV6:!1,error:!0}:{host:i+(n?"%"+n:""),escapedHost:i+(n?"%25"+n:""),isIPV6:!0}}function Cx(t,e){let r=0;for(let s=0;s<t.length;s++)t[s]===e&&r++;return r}function Rx(t){let e=t,r=[],s=-1,n=0;for(;n=e.length;){if(n===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(n===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(n===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 Mx={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},Ax=/[@/?#:]/g,Ox=/[@/?#]/g;function sf(t,e){let r=e?Ox:Ax;return r.lastIndex=0,t.replace(r,s=>Mx[s])}function nf(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 n=t.slice(s+1,s+3);if(Cr(n)){let o=n.toUpperCase(),i=String.fromCharCode(parseInt(o,16));e&&bl(i)?r+=i:r+="%"+o,s+=2;continue}}r+=t[s]}return r}function Ix(t){let e="";for(let r=0;r<t.length;r++){let s=t[r];if(s==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Cr(n)){let o=n.toUpperCase(),i=String.fromCharCode(parseInt(o,16));i!=="."&&bl(i)?e+=i:e+="%"+o,r+=2;continue}}if(rf(s))e+=s;else{let n=t.charCodeAt(r);if(n<128)e+=af(n)?s:He[n];else if(n<55296||n>57343)e+=Ce(n);else if(n<=56319&&r+1<t.length){let o=t.charCodeAt(r+1);o>=56320&&o<=57343?(e+=Ce(65536+(n-55296<<10)+(o-56320)),r++):e+=Ce(65533)}else e+=Ce(65533)}}return e}function zx(t,e=!1){let r="",s=e&&t[0]!=="/";for(let n=0;n<t.length;n++){let o=t[n];if(o==="%"&&n+2<t.length){let i=t.slice(n+1,n+3);if(Cr(i)){r+="%"+i.toUpperCase(),n+=2;continue}}if(o==="/"&&(s=!1),rf(o)&&(o!==":"||!s))r+=o;else{let i=t.charCodeAt(n);if(i<128)r+=He[i];else if(i<55296||i>57343)r+=Ce(i);else if(i<=56319&&n+1<t.length){let a=t.charCodeAt(n+1);a>=56320&&a<=57343?(r+=Ce(65536+(i-55296<<10)+(a-56320)),n++):r+=Ce(65533)}else r+=Ce(65533)}}return r}function _l(t,e){let r="";for(let s=0;s<t.length;s++){let n=t[s];if(n==="%"&&s+2<t.length){let o=t.slice(s+1,s+3);if(Cr(o)){r+="%"+o.toUpperCase(),s+=2;continue}}if(e(n))r+=n;else{let o=t.charCodeAt(s);if(o<128)r+=He[o];else if(o<55296||o>57343)r+=Ce(o);else if(o<=56319&&s+1<t.length){let i=t.charCodeAt(s+1);i>=56320&&i<=57343?(r+=Ce(65536+(o-55296<<10)+(i-56320)),s++):r+=Ce(65533)}else r+=Ce(65533)}}return r}function of(t){return _l(t,_x)}function Nx(t){return _l(t,vl)}function jx(t){return _l(t,vl)}function af(t){return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===42||t===43||t===45||t===46||t===47||t===64||t===95}function Dx(t){let e="";for(let r=0;r<t.length;r++){let s=t[r];if(s==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Cr(n)){let o=n.toUpperCase(),i=String.fromCharCode(parseInt(o,16));bl(i)?e+=i:e+="%"+o,r+=2;continue}}if(vl(s))e+=s;else{let n=t.charCodeAt(r);if(n<128)e+=af(n)?s:He[n];else if(n<55296||n>57343)e+=Ce(n);else if(n<=56319&&r+1<t.length){let o=t.charCodeAt(r+1);o>=56320&&o<=57343?(e+=Ce(65536+(n-55296<<10)+(o-56320)),r++):e+=Ce(65533)}else e+=Ce(65533)}}return e}function qx(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(Cr(s)){e+="%"+s.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function Lx(t){let e=[];if(t.userinfo!==void 0&&(e.push(of(t.userinfo)),e.push("@")),t.host!==void 0){let r=t.host;if(!wl(r)){let s=yl(r);s.isIPV6!==!0&&s.isIPVFuture!==!0&&(r=nf(r,!0),s=yl(r)),s.isIPV6===!0||s.isIPVFuture===!0?r=`[${s.escapedHost}]`:r=sf(r,!1)}e.push(r)}if(typeof t.port=="number"||typeof t.port=="string"){let r=String(t.port);if(!vx(r))throw new TypeError("URI port is malformed.");e.push(":"),e.push(r)}return e.length?e.join(""):void 0}cf.exports={nonSimpleDomain:Ex,recomposeAuthority:Lx,reescapeHostDelimiters:sf,normalizePercentEncoding:nf,normalizePathEncoding:Ix,serializePathEncoding:zx,normalizeQueryFragmentEncoding:Dx,encodeUserinfo:of,encodeQuery:Nx,encodeFragment:jx,escapePreservingEscapes:qx,removeDotSegments:Rx,isIPv4:wl,isUUID:bx,normalizeIPv6:yl,stringArrayToHexStripped:Sx}});var pf=T((_L,hf)=>{"use strict";var{isUUID:Fx}=Sl(),Ux=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,Bx=["http","https","ws","wss","urn","urn:uuid"];function Wx(t){return Bx.indexOf(t)!==-1}function kl(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 lf(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function uf(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 Hx(t){return t.secure=kl(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function Gx(t){if((t.port===(kl(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=t.resourceName.indexOf("?"),r=e===-1?t.resourceName:t.resourceName.slice(0,e);t.path=r&&r!=="/"?r:void 0,t.query=e===-1?void 0:t.resourceName.slice(e+1),t.resourceName=void 0}return t.fragment=void 0,t}function Vx(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(Ux);if(r&&r[0]===t.path){let s=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let n=`${s}:${e.nid||t.nid}`,o=xl(n);t.path=void 0,o&&(t=o.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function Kx(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(),n=`${r}:${e.nid||s}`,o=xl(n);o&&(t=o.serialize(t,e));let i=t,a=t.nss;return i.path=`${s||e.nid}:${a}`,e.skipEscape=!0,i}function Zx(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!Fx(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Yx(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var df={scheme:"http",domainHost:!0,parse:lf,serialize:uf},Jx={scheme:"https",domainHost:df.domainHost,parse:lf,serialize:uf},di={scheme:"ws",domainHost:!0,parse:Hx,serialize:Gx},Xx={scheme:"wss",domainHost:di.domainHost,parse:di.parse,serialize:di.serialize},Qx={scheme:"urn",parse:Vx,serialize:Kx,skipNormalize:!0},eT={scheme:"urn:uuid",parse:Zx,serialize:Yx,skipNormalize:!0},hi={http:df,https:Jx,ws:di,wss:Xx,urn:Qx,"urn:uuid":eT};Object.setPrototypeOf(hi,null);function xl(t){return t&&(hi[t]||hi[t.toLowerCase()])||void 0}hf.exports={wsIsSecure:kl,SCHEMES:hi,isValidSchemeName:Wx,getSchemeHandler:xl}});var Ef=T((SL,mi)=>{"use strict";var{normalizeIPv6:wf,removeDotSegments:bn,recomposeAuthority:tT,normalizePercentEncoding:Tl,normalizePathEncoding:rT,serializePathEncoding:ff,normalizeQueryFragmentEncoding:mf,encodeQuery:sT,encodeFragment:nT,reescapeHostDelimiters:oT,isIPv4:bf,nonSimpleDomain:iT}=Sl(),{SCHEMES:vf,getSchemeHandler:El}=pf(),_f=/^[A-Za-z][A-Za-z0-9+.-]*$/u,Sf="URI scheme is malformed.";function gf(t){let e=unescape(String(t));if(!_f.test(e))throw new TypeError(Sf);return e}function aT(t,e){return typeof t=="string"?t=mT(t,e):typeof t=="object"&&(t=fi(Rr(t,e),e)),t}function cT(t,e,r){let s=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:l}=pi(t,s),{parsed:u,malformedAuthorityOrPort:d,malformedPercentEncoding:h,malformedSchemeSpecific:p,malformedHost:m,malformedScheme:f}=pi(e,s);if(o||d||i||h||a||p||c||m||l||f)throw new Error(n.error||u.error||"URI is malformed.");let g=kf(n,u,s,!0),w=El(r&&r.scheme||g.scheme),v=g.host,S=v!==void 0&&v!==""&&(bf(v)||wf(v).isIPV6);xf(g,r||{},w,S);let x=v&&v.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(v);if(g.error&&!x)throw new Error(g.error);return s.skipEscape=!0,Rr(g,s)}function kf(t,e,r,s){let n={};return s||(t=fi(Rr(t,r),r),e=fi(Rr(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(n.scheme=e.scheme,n.userinfo=e.userinfo,n.host=e.host,n.port=e.port,n.path=bn(e.path||""),n.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(n.userinfo=e.userinfo,n.host=e.host,n.port=e.port,n.path=bn(e.path||""),n.query=e.query):(e.path?(e.path[0]==="/"?n.path=bn(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?n.path="/"+e.path:t.path?n.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:n.path=e.path,n.path=bn(n.path)),n.query=e.query):(n.path=t.path,e.query!==void 0?n.query=e.query:n.query=t.query),n.userinfo=t.userinfo,n.host=t.host,n.port=t.port),n.scheme=t.scheme),n.fragment=e.fragment,n}function lT(t,e,r){let s=yf(t,r),n=yf(e,r);return s!==void 0&&n!==void 0&&s===n}function Rr(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),n=[];r.scheme&&(r.scheme=gf(r.scheme));let o=El(s.scheme||r.scheme);o&&o.serialize&&o.serialize(r,s);let i=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,a=!s.skipEscape&&r.scheme===void 0&&!i;r.path!==void 0&&(s.skipEscape?r.path=Tl(r.path):r.path=ff(r.path,a)),s.reference!=="suffix"&&r.scheme&&(r.scheme=gf(r.scheme),n.push(r.scheme,":"));let c=tT(r);if(c!==void 0&&(s.reference!=="suffix"&&n.push("//"),n.push(c),r.path&&r.path[0]!=="/"&&n.push("/")),r.path!==void 0){let l=r.path;!s.absolutePath&&(!o||!o.absolutePath)&&(l=bn(l)),a&&(l=ff(l,!0)),c===void 0&&l[0]==="/"&&l[1]==="/"&&(l="/%2F"+l.slice(2)),n.push(l)}return r.query!==void 0&&n.push("?",sT(r.query)),r.fragment!==void 0&&n.push("#",nT(r.fragment)),n.join("")}var uT=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,dT=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,hT=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function pT(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 wn(t){if(t===void 0)return!1;let e=t.indexOf("%");for(;e!==-1;){if(e+2>=t.length||!/^[\da-f]{2}$/iu.test(t.slice(e+1,e+3)))return!0;e=t.indexOf("%",e+3)}return!1}function $l(t){return t[0]==="["&&t[t.length-1]==="]"}function fT(t){let e=t[4];return wn(t[3])||e!==void 0&&!$l(e)&&wn(e)||wn(t[6])||wn(t[7])||wn(t[8])}function xf(t,e,r,s){if(!e.unicodeSupport&&(!r||!r.unicodeSupport)&&t.host&&!$l(t.host)&&(e.domainHost||r&&r.domainHost)&&s===!1&&iT(t.host))try{t.host=new URL("http://"+t.host).hostname}catch(n){return t.error=t.error||"Host's domain name can not be converted to ASCII: "+n,!0}return!1}function pi(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},n=!1,o=!1,i=!1,a=!1,c=!1,l=!1,u=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let d=t.match(dT);d!==null&&d[1].indexOf("\\")!==-1&&(s.error="URI authority must not contain a literal backslash.",n=!0);let h=t.match(hT);if(h!==null){let m=h[1],f=m.replace(/[\t\n\r]/g,"");f.length>=2&&(f.slice(0,2)!=="//"?(s.error=s.error||"URI authority must not contain a literal backslash.",n=!0):m.length!==f.length&&(s.error=s.error||"URI authority introducer must not contain whitespace.",n=!0))}let p=t.match(uT);if(p){if(s.scheme=p[1],s.userinfo=p[3],s.host=p[4],s.port=parseInt(p[5],10),s.path=p[6]||"",s.query=p[7],s.fragment=p[8],s.scheme!==void 0){let g=unescape(s.scheme);_f.test(g)?s.scheme=g.toLowerCase():(s.error=s.error||Sf,l=!0)}o=fT(p),o&&(s.error=s.error||"URI contains malformed percent-encoding."),isNaN(s.port)&&(s.port=p[5]);let m=pT(s,p);if(m!==void 0&&(s.error=s.error||m,n=!0),s.host)if(bf(s.host)===!1){let w=$l(s.host),v=s.host.indexOf("[")!==-1||s.host.indexOf("]")!==-1,S=wf(s.host);u=S.isIPV6||S.isIPVFuture===!0,c=v&&(!w||S.error===!0),s.host=u?S.host:S.host.toLowerCase(),c&&(s.error=s.error||"URI host is malformed.",n=!0)}else u=!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 f=El(r.scheme||s.scheme);if(c||(a=xf(s,r,f,u)),t.indexOf("%")!==-1&&s.host!==void 0&&!c){let g=u?s.host:Tl(s.host,!0);u||(g=Tl(g.toLowerCase())),s.host=oT(g,u)}(!f||f&&!f.skipNormalize)&&(s.path&&(s.path=rT(s.path)),s.query&&(s.query=mf(s.query)),s.fragment&&(s.fragment=mf(s.fragment))),f&&f.parse&&(f.parse(s,r),f===vf.urn&&s.nid===void 0&&(i=!0))}else s.error=s.error||"URI can not be parsed.";return{parsed:s,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:l}}function fi(t,e){return pi(t,e).parsed}function mT(t,e){return Tf(t,e).normalized}function Tf(t,e){let{parsed:r,malformedAuthorityOrPort:s,malformedPercentEncoding:n,malformedSchemeSpecific:o,malformedHost:i,malformedScheme:a}=pi(t,e);return{normalized:s||n||o||i||a?t:Rr(r,e),malformedAuthorityOrPort:s,malformedPercentEncoding:n,malformedSchemeSpecific:o,malformedHost:i,malformedScheme:a}}function yf(t,e){if(typeof t!="string"&&typeof t!="object")return;let r;try{r=typeof t=="string"?t:Rr(t,e)}catch{return}let{normalized:s,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:c}=Tf(r,e);return n||o||i||a||c?void 0:s}var Pl={SCHEMES:vf,normalize:aT,resolve:cT,resolveComponent:kf,equal:lT,serialize:Rr,parse:fi};mi.exports=Pl;mi.exports.default=Pl;mi.exports.fastUri=Pl});var Pf=T(Cl=>{"use strict";Object.defineProperty(Cl,"__esModule",{value:!0});var $f=Ef();$f.code='require("ajv/dist/runtime/uri").default';Cl.default=$f});var Nf=T(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});ke.CodeGen=ke.Name=ke.nil=ke.stringify=ke.str=ke._=ke.KeywordCxt=void 0;var gT=gn();Object.defineProperty(ke,"KeywordCxt",{enumerable:!0,get:function(){return gT.KeywordCxt}});var cs=L();Object.defineProperty(ke,"_",{enumerable:!0,get:function(){return cs._}});Object.defineProperty(ke,"str",{enumerable:!0,get:function(){return cs.str}});Object.defineProperty(ke,"stringify",{enumerable:!0,get:function(){return cs.stringify}});Object.defineProperty(ke,"nil",{enumerable:!0,get:function(){return cs.nil}});Object.defineProperty(ke,"Name",{enumerable:!0,get:function(){return cs.Name}});Object.defineProperty(ke,"CodeGen",{enumerable:!0,get:function(){return cs.CodeGen}});var yT=ci(),Of=yn(),wT=Jc(),vn=ui(),bT=L(),_n=pn(),gi=hn(),Ml=H(),Cf=ef(),vT=Pf(),If=(t,e)=>new RegExp(t,e);If.code="new RegExp";var _T=["removeAdditional","useDefaults","coerceTypes"],ST=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),kT={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."},xT={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Rf=200;function TT(t){var e,r,s,n,o,i,a,c,l,u,d,h,p,m,f,g,w,v,S,x,_,k,C,D,I;let X=t.strict,ht=(e=t.code)===null||e===void 0?void 0:e.optimize,Tt=ht===!0||ht===void 0?1:ht||0,Et=(s=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&s!==void 0?s:If,Oe=(n=t.uriResolver)!==null&&n!==void 0?n:vT.default;return{strictSchema:(i=(o=t.strictSchema)!==null&&o!==void 0?o:X)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:X)!==null&&c!==void 0?c:!0,strictTypes:(u=(l=t.strictTypes)!==null&&l!==void 0?l:X)!==null&&u!==void 0?u:"log",strictTuples:(h=(d=t.strictTuples)!==null&&d!==void 0?d:X)!==null&&h!==void 0?h:"log",strictRequired:(m=(p=t.strictRequired)!==null&&p!==void 0?p:X)!==null&&m!==void 0?m:!1,code:t.code?{...t.code,optimize:Tt,regExp:Et}:{optimize:Tt,regExp:Et},loopRequired:(f=t.loopRequired)!==null&&f!==void 0?f:Rf,loopEnum:(g=t.loopEnum)!==null&&g!==void 0?g:Rf,meta:(w=t.meta)!==null&&w!==void 0?w:!0,messages:(v=t.messages)!==null&&v!==void 0?v:!0,inlineRefs:(S=t.inlineRefs)!==null&&S!==void 0?S:!0,schemaId:(x=t.schemaId)!==null&&x!==void 0?x:"$id",addUsedSchema:(_=t.addUsedSchema)!==null&&_!==void 0?_:!0,validateSchema:(k=t.validateSchema)!==null&&k!==void 0?k:!0,validateFormats:(C=t.validateFormats)!==null&&C!==void 0?C:!0,unicodeRegExp:(D=t.unicodeRegExp)!==null&&D!==void 0?D:!0,int32range:(I=t.int32range)!==null&&I!==void 0?I:!0,uriResolver:Oe}}var Sn=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,...TT(e)};let{es5:r,lines:s}=this.opts.code;this.scope=new bT.ValueScope({scope:{},prefixes:ST,es5:r,lines:s}),this.logger=MT(e.logger);let n=e.validateFormats;e.validateFormats=!1,this.RULES=(0,wT.getRules)(),Mf.call(this,kT,e,"NOT SUPPORTED"),Mf.call(this,xT,e,"DEPRECATED","warn"),this._metaOpts=CT.call(this),e.formats&&$T.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&PT.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),ET.call(this),e.validateFormats=n}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:s}=this.opts,n=Cf;s==="id"&&(n={...Cf},n.id=n.$id,delete n.$id),r&&e&&this.addMetaSchema(n,n[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 n=s(r);return"$async"in s||(this.errors=s.errors),n}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 n.call(this,e,r);async function n(u,d){await o.call(this,u.$schema);let h=this._addSchema(u,d);return h.validate||i.call(this,h)}async function o(u){u&&!this.getSchema(u)&&await n.call(this,{$ref:u},!0)}async function i(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof Of.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,u)}}function a({missingSchema:u,missingRef:d}){if(this.refs[u])throw new Error(`AnySchema ${u} is loaded but ${d} cannot be resolved`)}async function c(u){let d=await l.call(this,u);this.refs[u]||await o.call(this,d.$schema),this.refs[u]||this.addSchema(d,u,r)}async function l(u){let d=this._loading[u];if(d)return d;try{return await(this._loading[u]=s(u))}finally{delete this._loading[u]}}}addSchema(e,r,s,n=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,s,n);return this}let o;if(typeof e=="object"){let{schemaId:i}=this.opts;if(o=e[i],o!==void 0&&typeof o!="string")throw new Error(`schema ${i} must be string`)}return r=(0,_n.normalizeId)(r||o),this._checkUnique(r),this.schemas[r]=this._addSchema(e,s,r,n,!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 n=this.validate(s,e);if(!n&&r){let o="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(o);else throw new Error(o)}return n}getSchema(e){let r;for(;typeof(r=Af.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:s}=this.opts,n=new vn.SchemaEnv({schema:{},schemaId:s});if(r=vn.resolveSchema.call(this,n,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=Af.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,_n.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(OT.call(this,s,r),!r)return(0,Ml.eachItem)(s,o=>Rl.call(this,o)),this;zT.call(this,r);let n={...r,type:(0,gi.getJSONTypes)(r.type),schemaType:(0,gi.getJSONTypes)(r.schemaType)};return(0,Ml.eachItem)(s,n.type.length===0?o=>Rl.call(this,o,n):o=>n.type.forEach(i=>Rl.call(this,o,n,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 n=s.rules.findIndex(o=>o.keyword===e);n>=0&&s.rules.splice(n,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(n=>`${s}${n.instancePath} ${n.message}`).reduce((n,o)=>n+r+o)}$dataMetaSchema(e,r){let s=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let n of r){let o=n.split("/").slice(1),i=e;for(let a of o)i=i[a];for(let a in s){let c=s[a];if(typeof c!="object")continue;let{$data:l}=c.definition,u=i[a];l&&u&&(i[a]=zf(u))}}return e}_removeAllSchemas(e,r){for(let s in e){let n=e[s];(!r||r.test(s))&&(typeof n=="string"?delete e[s]:n&&!n.meta&&(this._cache.delete(n.schema),delete e[s]))}}_addSchema(e,r,s,n=this.opts.validateSchema,o=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,_n.normalizeId)(i||s);let l=_n.getSchemaRefs.call(this,e,s);return c=new vn.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:s,localRefs:l}),this._cache.set(c.schema,c),o&&!s.startsWith("#")&&(s&&this._checkUnique(s),this.refs[s]=c),n&&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):vn.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{vn.compileSchema.call(this,e)}finally{this.opts=r}}};Sn.ValidationError=yT.default;Sn.MissingRefError=Of.default;ke.default=Sn;function Mf(t,e,r,s="error"){for(let n in t){let o=n;o in e&&this.logger[s](`${r}: option ${n}. ${t[o]}`)}}function Af(t){return t=(0,_n.normalizeId)(t),this.schemas[t]||this.refs[t]}function ET(){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 $T(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function PT(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 CT(){let t={...this.opts};for(let e of _T)delete t[e];return t}var RT={log(){},warn(){},error(){}};function MT(t){if(t===!1)return RT;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 AT=/^[a-z_$][a-z0-9_$:-]*$/i;function OT(t,e){let{RULES:r}=this;if((0,Ml.eachItem)(t,s=>{if(r.keywords[s])throw new Error(`Keyword ${s} is already defined`);if(!AT.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 Rl(t,e,r){var s;let n=e?.post;if(r&&n)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:o}=this,i=n?o.post:o.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},o.rules.push(i)),o.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,gi.getJSONTypes)(e.type),schemaType:(0,gi.getJSONTypes)(e.schemaType)}};e.before?IT.call(this,i,a,e.before):i.rules.push(a),o.all[t]=a,(s=e.implements)===null||s===void 0||s.forEach(c=>this.addKeyword(c))}function IT(t,e,r){let s=t.rules.findIndex(n=>n.keyword===r);s>=0?t.rules.splice(s,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function zT(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=zf(e)),t.validateSchema=this.compile(e,!0))}var NT={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function zf(t){return{anyOf:[t,NT]}}});var jf=T(Al=>{"use strict";Object.defineProperty(Al,"__esModule",{value:!0});var jT={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Al.default=jT});var Ff=T(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.callRef=Mr.getValidate=void 0;var DT=yn(),Df=ot(),Ge=L(),ls=Dt(),qf=ui(),yi=H(),qT={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:s}=t,{baseId:n,schemaEnv:o,validateName:i,opts:a,self:c}=s,{root:l}=o;if((r==="#"||r==="#/")&&n===l.baseId)return d();let u=qf.resolveRef.call(c,l,n,r);if(u===void 0)throw new DT.default(s.opts.uriResolver,n,r);if(u instanceof qf.SchemaEnv)return h(u);return p(u);function d(){if(o===l)return wi(t,i,o,o.$async);let m=e.scopeValue("root",{ref:l});return wi(t,(0,Ge._)`${m}.validate`,l,l.$async)}function h(m){let f=Lf(t,m);wi(t,f,m,m.$async)}function p(m){let f=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Ge.stringify)(m)}:{ref:m}),g=e.name("valid"),w=t.subschema({schema:m,dataTypes:[],schemaPath:Ge.nil,topSchemaRef:f,errSchemaPath:r},g);t.mergeEvaluated(w),t.ok(g)}}};function Lf(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Ge._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Mr.getValidate=Lf;function wi(t,e,r,s){let{gen:n,it:o}=t,{allErrors:i,schemaEnv:a,opts:c}=o,l=c.passContext?ls.default.this:Ge.nil;s?u():d();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=n.let("valid");n.try(()=>{n.code((0,Ge._)`await ${(0,Df.callValidateCode)(t,e,l)}`),p(e),i||n.assign(m,!0)},f=>{n.if((0,Ge._)`!(${f} instanceof ${o.ValidationError})`,()=>n.throw(f)),h(f),i||n.assign(m,!1)}),t.ok(m)}function d(){t.result((0,Df.callValidateCode)(t,e,l),()=>p(e),()=>h(e))}function h(m){let f=(0,Ge._)`${m}.errors`;n.assign(ls.default.vErrors,(0,Ge._)`${ls.default.vErrors} === null ? ${f} : ${ls.default.vErrors}.concat(${f})`),n.assign(ls.default.errors,(0,Ge._)`${ls.default.vErrors}.length`)}function p(m){var f;if(!o.opts.unevaluated)return;let g=(f=r?.validate)===null||f===void 0?void 0:f.evaluated;if(o.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(o.props=yi.mergeEvaluated.props(n,g.props,o.props));else{let w=n.var("props",(0,Ge._)`${m}.evaluated.props`);o.props=yi.mergeEvaluated.props(n,w,o.props,Ge.Name)}if(o.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(o.items=yi.mergeEvaluated.items(n,g.items,o.items));else{let w=n.var("items",(0,Ge._)`${m}.evaluated.items`);o.items=yi.mergeEvaluated.items(n,w,o.items,Ge.Name)}}}Mr.callRef=wi;Mr.default=qT});var Uf=T(Ol=>{"use strict";Object.defineProperty(Ol,"__esModule",{value:!0});var LT=jf(),FT=Ff(),UT=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",LT.default,FT.default];Ol.default=UT});var Bf=T(Il=>{"use strict";Object.defineProperty(Il,"__esModule",{value:!0});var bi=L(),ir=bi.operators,vi={maximum:{okStr:"<=",ok:ir.LTE,fail:ir.GT},minimum:{okStr:">=",ok:ir.GTE,fail:ir.LT},exclusiveMaximum:{okStr:"<",ok:ir.LT,fail:ir.GTE},exclusiveMinimum:{okStr:">",ok:ir.GT,fail:ir.LTE}},BT={message:({keyword:t,schemaCode:e})=>(0,bi.str)`must be ${vi[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,bi._)`{comparison: ${vi[t].okStr}, limit: ${e}}`},WT={keyword:Object.keys(vi),type:"number",schemaType:"number",$data:!0,error:BT,code(t){let{keyword:e,data:r,schemaCode:s}=t;t.fail$data((0,bi._)`${r} ${vi[e].fail} ${s} || isNaN(${r})`)}};Il.default=WT});var Wf=T(zl=>{"use strict";Object.defineProperty(zl,"__esModule",{value:!0});var kn=L(),HT={message:({schemaCode:t})=>(0,kn.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,kn._)`{multipleOf: ${t}}`},GT={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:HT,code(t){let{gen:e,data:r,schemaCode:s,it:n}=t,o=n.opts.multipleOfPrecision,i=e.let("res"),a=o?(0,kn._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${o}`:(0,kn._)`${i} !== parseInt(${i})`;t.fail$data((0,kn._)`(${s} === 0 || (${i} = ${r}/${s}, ${a}))`)}};zl.default=GT});var Gf=T(Nl=>{"use strict";Object.defineProperty(Nl,"__esModule",{value:!0});function Hf(t){let e=t.length,r=0,s=0,n;for(;s<e;)r++,n=t.charCodeAt(s++),n>=55296&&n<=56319&&s<e&&(n=t.charCodeAt(s),(n&64512)===56320&&s++);return r}Nl.default=Hf;Hf.code='require("ajv/dist/runtime/ucs2length").default'});var Vf=T(jl=>{"use strict";Object.defineProperty(jl,"__esModule",{value:!0});var Ar=L(),VT=H(),KT=Gf(),ZT={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,Ar.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,Ar._)`{limit: ${t}}`},YT={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:ZT,code(t){let{keyword:e,data:r,schemaCode:s,it:n}=t,o=e==="maxLength"?Ar.operators.GT:Ar.operators.LT,i=n.opts.unicode===!1?(0,Ar._)`${r}.length`:(0,Ar._)`${(0,VT.useFunc)(t.gen,KT.default)}(${r})`;t.fail$data((0,Ar._)`${i} ${o} ${s}`)}};jl.default=YT});var Kf=T(Dl=>{"use strict";Object.defineProperty(Dl,"__esModule",{value:!0});var JT=ot(),XT=H(),us=L(),QT={message:({schemaCode:t})=>(0,us.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,us._)`{pattern: ${t}}`},eE={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:QT,code(t){let{gen:e,data:r,$data:s,schema:n,schemaCode:o,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(s){let{regExp:c}=i.opts.code,l=c.code==="new RegExp"?(0,us._)`new RegExp`:(0,XT.useFunc)(e,c),u=e.let("valid");e.try(()=>e.assign(u,(0,us._)`${l}(${o}, ${a}).test(${r})`),()=>e.assign(u,!1)),t.fail$data((0,us._)`!${u}`)}else{let c=(0,JT.usePattern)(t,n);t.fail$data((0,us._)`!${c}.test(${r})`)}}};Dl.default=eE});var Zf=T(ql=>{"use strict";Object.defineProperty(ql,"__esModule",{value:!0});var xn=L(),tE={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,xn.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,xn._)`{limit: ${t}}`},rE={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:tE,code(t){let{keyword:e,data:r,schemaCode:s}=t,n=e==="maxProperties"?xn.operators.GT:xn.operators.LT;t.fail$data((0,xn._)`Object.keys(${r}).length ${n} ${s}`)}};ql.default=rE});var Yf=T(Ll=>{"use strict";Object.defineProperty(Ll,"__esModule",{value:!0});var Tn=ot(),En=L(),sE=H(),nE={message:({params:{missingProperty:t}})=>(0,En.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,En._)`{missingProperty: ${t}}`},oE={keyword:"required",type:"object",schemaType:"array",$data:!0,error:nE,code(t){let{gen:e,schema:r,schemaCode:s,data:n,$data:o,it:i}=t,{opts:a}=i;if(!o&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?l():u(),a.strictRequired){let p=t.parentSchema.properties,{definedProperties:m}=t.it;for(let f of r)if(p?.[f]===void 0&&!m.has(f)){let g=i.schemaEnv.baseId+i.errSchemaPath,w=`required property "${f}" is not defined at "${g}" (strictRequired)`;(0,sE.checkStrictMode)(i,w,i.opts.strictRequired)}}function l(){if(c||o)t.block$data(En.nil,d);else for(let p of r)(0,Tn.checkReportMissingProp)(t,p)}function u(){let p=e.let("missing");if(c||o){let m=e.let("valid",!0);t.block$data(m,()=>h(p,m)),t.ok(m)}else e.if((0,Tn.checkMissingProp)(t,r,p)),(0,Tn.reportMissingProp)(t,p),e.else()}function d(){e.forOf("prop",s,p=>{t.setParams({missingProperty:p}),e.if((0,Tn.noPropertyInData)(e,n,p,a.ownProperties),()=>t.error())})}function h(p,m){t.setParams({missingProperty:p}),e.forOf(p,s,()=>{e.assign(m,(0,Tn.propertyInData)(e,n,p,a.ownProperties)),e.if((0,En.not)(m),()=>{t.error(),e.break()})},En.nil)}}};Ll.default=oE});var Jf=T(Fl=>{"use strict";Object.defineProperty(Fl,"__esModule",{value:!0});var $n=L(),iE={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,$n.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,$n._)`{limit: ${t}}`},aE={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:iE,code(t){let{keyword:e,data:r,schemaCode:s}=t,n=e==="maxItems"?$n.operators.GT:$n.operators.LT;t.fail$data((0,$n._)`${r}.length ${n} ${s}`)}};Fl.default=aE});var _i=T(Ul=>{"use strict";Object.defineProperty(Ul,"__esModule",{value:!0});var Xf=ol();Xf.code='require("ajv/dist/runtime/equal").default';Ul.default=Xf});var Qf=T(Wl=>{"use strict";Object.defineProperty(Wl,"__esModule",{value:!0});var Bl=hn(),xe=L(),cE=H(),lE=_i(),uE={message:({params:{i:t,j:e}})=>(0,xe.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,xe._)`{i: ${t}, j: ${e}}`},dE={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:uE,code(t){let{gen:e,data:r,$data:s,schema:n,parentSchema:o,schemaCode:i,it:a}=t;if(!s&&!n)return;let c=e.let("valid"),l=o.items?(0,Bl.getSchemaTypes)(o.items):[];t.block$data(c,u,(0,xe._)`${i} === false`),t.ok(c);function u(){let m=e.let("i",(0,xe._)`${r}.length`),f=e.let("j");t.setParams({i:m,j:f}),e.assign(c,!0),e.if((0,xe._)`${m} > 1`,()=>(d()?h:p)(m,f))}function d(){return l.length>0&&!l.some(m=>m==="object"||m==="array")}function h(m,f){let g=e.name("item"),w=(0,Bl.checkDataTypes)(l,g,a.opts.strictNumbers,Bl.DataType.Wrong),v=e.const("indices",(0,xe._)`{}`);e.for((0,xe._)`;${m}--;`,()=>{e.let(g,(0,xe._)`${r}[${m}]`),e.if(w,(0,xe._)`continue`),l.length>1&&e.if((0,xe._)`typeof ${g} == "string"`,(0,xe._)`${g} += "_"`),e.if((0,xe._)`typeof ${v}[${g}] == "number"`,()=>{e.assign(f,(0,xe._)`${v}[${g}]`),t.error(),e.assign(c,!1).break()}).code((0,xe._)`${v}[${g}] = ${m}`)})}function p(m,f){let g=(0,cE.useFunc)(e,lE.default),w=e.name("outer");e.label(w).for((0,xe._)`;${m}--;`,()=>e.for((0,xe._)`${f} = ${m}; ${f}--;`,()=>e.if((0,xe._)`${g}(${r}[${m}], ${r}[${f}])`,()=>{t.error(),e.assign(c,!1).break(w)})))}}};Wl.default=dE});var em=T(Gl=>{"use strict";Object.defineProperty(Gl,"__esModule",{value:!0});var Hl=L(),hE=H(),pE=_i(),fE={message:"must be equal to constant",params:({schemaCode:t})=>(0,Hl._)`{allowedValue: ${t}}`},mE={keyword:"const",$data:!0,error:fE,code(t){let{gen:e,data:r,$data:s,schemaCode:n,schema:o}=t;s||o&&typeof o=="object"?t.fail$data((0,Hl._)`!${(0,hE.useFunc)(e,pE.default)}(${r}, ${n})`):t.fail((0,Hl._)`${o} !== ${r}`)}};Gl.default=mE});var tm=T(Vl=>{"use strict";Object.defineProperty(Vl,"__esModule",{value:!0});var Pn=L(),gE=H(),yE=_i(),wE={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Pn._)`{allowedValues: ${t}}`},bE={keyword:"enum",schemaType:"array",$data:!0,error:wE,code(t){let{gen:e,data:r,$data:s,schema:n,schemaCode:o,it:i}=t;if(!s&&n.length===0)throw new Error("enum must have non-empty array");let a=n.length>=i.opts.loopEnum,c,l=()=>c??(c=(0,gE.useFunc)(e,yE.default)),u;if(a||s)u=e.let("valid"),t.block$data(u,d);else{if(!Array.isArray(n))throw new Error("ajv implementation error");let p=e.const("vSchema",o);u=(0,Pn.or)(...n.map((m,f)=>h(p,f)))}t.pass(u);function d(){e.assign(u,!1),e.forOf("v",o,p=>e.if((0,Pn._)`${l()}(${r}, ${p})`,()=>e.assign(u,!0).break()))}function h(p,m){let f=n[m];return typeof f=="object"&&f!==null?(0,Pn._)`${l()}(${r}, ${p}[${m}])`:(0,Pn._)`${r} === ${f}`}}};Vl.default=bE});var rm=T(Kl=>{"use strict";Object.defineProperty(Kl,"__esModule",{value:!0});var vE=Bf(),_E=Wf(),SE=Vf(),kE=Kf(),xE=Zf(),TE=Yf(),EE=Jf(),$E=Qf(),PE=em(),CE=tm(),RE=[vE.default,_E.default,SE.default,kE.default,xE.default,TE.default,EE.default,$E.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},PE.default,CE.default];Kl.default=RE});var Yl=T(Cn=>{"use strict";Object.defineProperty(Cn,"__esModule",{value:!0});Cn.validateAdditionalItems=void 0;var Or=L(),Zl=H(),ME={message:({params:{len:t}})=>(0,Or.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Or._)`{limit: ${t}}`},AE={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:ME,code(t){let{parentSchema:e,it:r}=t,{items:s}=e;if(!Array.isArray(s)){(0,Zl.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}sm(t,s)}};function sm(t,e){let{gen:r,schema:s,data:n,keyword:o,it:i}=t;i.items=!0;let a=r.const("len",(0,Or._)`${n}.length`);if(s===!1)t.setParams({len:e.length}),t.pass((0,Or._)`${a} <= ${e.length}`);else if(typeof s=="object"&&!(0,Zl.alwaysValidSchema)(i,s)){let l=r.var("valid",(0,Or._)`${a} <= ${e.length}`);r.if((0,Or.not)(l),()=>c(l)),t.ok(l)}function c(l){r.forRange("i",e.length,a,u=>{t.subschema({keyword:o,dataProp:u,dataPropType:Zl.Type.Num},l),i.allErrors||r.if((0,Or.not)(l),()=>r.break())})}}Cn.validateAdditionalItems=sm;Cn.default=AE});var Jl=T(Rn=>{"use strict";Object.defineProperty(Rn,"__esModule",{value:!0});Rn.validateTuple=void 0;var nm=L(),Si=H(),OE=ot(),IE={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return om(t,"additionalItems",e);r.items=!0,!(0,Si.alwaysValidSchema)(r,e)&&t.ok((0,OE.validateArray)(t))}};function om(t,e,r=t.schema){let{gen:s,parentSchema:n,data:o,keyword:i,it:a}=t;u(n),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=Si.mergeEvaluated.items(s,r.length,a.items));let c=s.name("valid"),l=s.const("len",(0,nm._)`${o}.length`);r.forEach((d,h)=>{(0,Si.alwaysValidSchema)(a,d)||(s.if((0,nm._)`${l} > ${h}`,()=>t.subschema({keyword:i,schemaProp:h,dataProp:h},c)),t.ok(c))});function u(d){let{opts:h,errSchemaPath:p}=a,m=r.length,f=m===d.minItems&&(m===d.maxItems||d[e]===!1);if(h.strictTuples&&!f){let g=`"${i}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${p}"`;(0,Si.checkStrictMode)(a,g,h.strictTuples)}}}Rn.validateTuple=om;Rn.default=IE});var im=T(Xl=>{"use strict";Object.defineProperty(Xl,"__esModule",{value:!0});var zE=Jl(),NE={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,zE.validateTuple)(t,"items")};Xl.default=NE});var cm=T(Ql=>{"use strict";Object.defineProperty(Ql,"__esModule",{value:!0});var am=L(),jE=H(),DE=ot(),qE=Yl(),LE={message:({params:{len:t}})=>(0,am.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,am._)`{limit: ${t}}`},FE={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:LE,code(t){let{schema:e,parentSchema:r,it:s}=t,{prefixItems:n}=r;s.items=!0,!(0,jE.alwaysValidSchema)(s,e)&&(n?(0,qE.validateAdditionalItems)(t,n):t.ok((0,DE.validateArray)(t)))}};Ql.default=FE});var lm=T(eu=>{"use strict";Object.defineProperty(eu,"__esModule",{value:!0});var at=L(),ki=H(),UE={message:({params:{min:t,max:e}})=>e===void 0?(0,at.str)`must contain at least ${t} valid item(s)`:(0,at.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,at._)`{minContains: ${t}}`:(0,at._)`{minContains: ${t}, maxContains: ${e}}`},BE={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:UE,code(t){let{gen:e,schema:r,parentSchema:s,data:n,it:o}=t,i,a,{minContains:c,maxContains:l}=s;o.opts.next?(i=c===void 0?1:c,a=l):i=1;let u=e.const("len",(0,at._)`${n}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,ki.checkStrictMode)(o,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,ki.checkStrictMode)(o,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,ki.alwaysValidSchema)(o,r)){let f=(0,at._)`${u} >= ${i}`;a!==void 0&&(f=(0,at._)`${f} && ${u} <= ${a}`),t.pass(f);return}o.items=!0;let d=e.name("valid");a===void 0&&i===1?p(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,at._)`${n}.length > 0`,h)):(e.let(d,!1),h()),t.result(d,()=>t.reset());function h(){let f=e.name("_valid"),g=e.let("count",0);p(f,()=>e.if(f,()=>m(g)))}function p(f,g){e.forRange("i",0,u,w=>{t.subschema({keyword:"contains",dataProp:w,dataPropType:ki.Type.Num,compositeRule:!0},f),g()})}function m(f){e.code((0,at._)`${f}++`),a===void 0?e.if((0,at._)`${f} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,at._)`${f} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,at._)`${f} >= ${i}`,()=>e.assign(d,!0)))}}};eu.default=BE});var hm=T(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.validateSchemaDeps=Ct.validatePropertyDeps=Ct.error=void 0;var tu=L(),WE=H(),Mn=ot();Ct.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let s=e===1?"property":"properties";return(0,tu.str)`must have ${s} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:s}})=>(0,tu._)`{property: ${t},
9
9
  missingProperty: ${s},
10
10
  depsCount: ${e},
11
- deps: ${r}}`};var HE={keyword:"dependencies",type:"object",schemaType:"object",error:Ct.error,code(t){let[e,r]=GE(t);um(t,e),dm(t,r)}};function GE({schema:t}){let e={},r={};for(let s in t){if(s==="__proto__")continue;let n=Array.isArray(t[s])?e:r;n[s]=t[s]}return[e,r]}function um(t,e=t.schema){let{gen:r,data:s,it:n}=t;if(Object.keys(e).length===0)return;let o=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,Mn.propertyInData)(r,s,i,n.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),n.allErrors?r.if(c,()=>{for(let l of a)(0,Mn.checkReportMissingProp)(t,l)}):(r.if((0,tu._)`${c} && (${(0,Mn.checkMissingProp)(t,a,o)})`),(0,Mn.reportMissingProp)(t,o),r.else())}}Ct.validatePropertyDeps=um;function dm(t,e=t.schema){let{gen:r,data:s,keyword:n,it:o}=t,i=r.name("valid");for(let a in e)(0,WE.alwaysValidSchema)(o,e[a])||(r.if((0,Mn.propertyInData)(r,s,a,o.opts.ownProperties),()=>{let c=t.subschema({keyword:n,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}Ct.validateSchemaDeps=dm;Ct.default=HE});var fm=T(ru=>{"use strict";Object.defineProperty(ru,"__esModule",{value:!0});var pm=L(),VE=H(),KE={message:"property name must be valid",params:({params:t})=>(0,pm._)`{propertyName: ${t.propertyName}}`},ZE={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:KE,code(t){let{gen:e,schema:r,data:s,it:n}=t;if((0,VE.alwaysValidSchema)(n,r))return;let o=e.name("valid");e.forIn("key",s,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},o),e.if((0,pm.not)(o),()=>{t.error(!0),n.allErrors||e.break()})}),t.ok(o)}};ru.default=ZE});var nu=T(su=>{"use strict";Object.defineProperty(su,"__esModule",{value:!0});var xi=ot(),wt=L(),YE=Dt(),Ti=H(),JE={message:"must NOT have additional properties",params:({params:t})=>(0,wt._)`{additionalProperty: ${t.additionalProperty}}`},XE={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:JE,code(t){let{gen:e,schema:r,parentSchema:s,data:n,errsCount:o,it:i}=t;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,Ti.alwaysValidSchema)(i,r))return;let l=(0,xi.allSchemaProperties)(s.properties),u=(0,xi.allSchemaProperties)(s.patternProperties);d(),t.ok((0,wt._)`${o} === ${YE.default.errors}`);function d(){e.forIn("key",n,g=>{!l.length&&!u.length?m(g):e.if(h(g),()=>m(g))})}function h(g){let w;if(l.length>8){let v=(0,Ti.schemaRefOrVal)(i,s.properties,"properties");w=(0,xi.isOwnProperty)(e,v,g)}else l.length?w=(0,wt.or)(...l.map(v=>(0,wt._)`${g} === ${v}`)):w=wt.nil;return u.length&&(w=(0,wt.or)(w,...u.map(v=>(0,wt._)`${(0,xi.usePattern)(t,v)}.test(${g})`))),(0,wt.not)(w)}function p(g){e.code((0,wt._)`delete ${n}[${g}]`)}function m(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(g);return}if(r===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,Ti.alwaysValidSchema)(i,r)){let w=e.name("valid");c.removeAdditional==="failing"?(f(g,w,!1),e.if((0,wt.not)(w),()=>{t.reset(),p(g)})):(f(g,w),a||e.if((0,wt.not)(w),()=>e.break()))}}function f(g,w,v){let S={keyword:"additionalProperties",dataProp:g,dataPropType:Ti.Type.Str};v===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(S,w)}}};su.default=XE});var ym=T(iu=>{"use strict";Object.defineProperty(iu,"__esModule",{value:!0});var QE=gn(),mm=ot(),ou=H(),gm=nu(),e$={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:s,data:n,it:o}=t;o.opts.removeAdditional==="all"&&s.additionalProperties===void 0&&gm.default.code(new QE.KeywordCxt(o,gm.default,"additionalProperties"));let i=(0,mm.allSchemaProperties)(r);for(let d of i)o.definedProperties.add(d);o.opts.unevaluated&&i.length&&o.props!==!0&&(o.props=ou.mergeEvaluated.props(e,(0,ou.toHash)(i),o.props));let a=i.filter(d=>!(0,ou.alwaysValidSchema)(o,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)l(d)?u(d):(e.if((0,mm.propertyInData)(e,n,d,o.opts.ownProperties)),u(d),o.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function l(d){return o.opts.useDefaults&&!o.compositeRule&&r[d].default!==void 0}function u(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};iu.default=e$});var _m=T(au=>{"use strict";Object.defineProperty(au,"__esModule",{value:!0});var wm=ot(),Ei=L(),bm=H(),vm=H(),t$={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:s,parentSchema:n,it:o}=t,{opts:i}=o,a=(0,wm.allSchemaProperties)(r),c=a.filter(f=>(0,bm.alwaysValidSchema)(o,r[f]));if(a.length===0||c.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let l=i.strictSchema&&!i.allowMatchingProperties&&n.properties,u=e.name("valid");o.props!==!0&&!(o.props instanceof Ei.Name)&&(o.props=(0,vm.evaluatedPropsToName)(e,o.props));let{props:d}=o;h();function h(){for(let f of a)l&&p(f),o.allErrors?m(f):(e.var(u,!0),m(f),e.if(u))}function p(f){for(let g in l)new RegExp(f).test(g)&&(0,bm.checkStrictMode)(o,`property ${g} matches pattern ${f} (use allowMatchingProperties)`)}function m(f){e.forIn("key",s,g=>{e.if((0,Ei._)`${(0,wm.usePattern)(t,f)}.test(${g})`,()=>{let w=c.includes(f);w||t.subschema({keyword:"patternProperties",schemaProp:f,dataProp:g,dataPropType:vm.Type.Str},u),o.opts.unevaluated&&d!==!0?e.assign((0,Ei._)`${d}[${g}]`,!0):!w&&!o.allErrors&&e.if((0,Ei.not)(u),()=>e.break())})})}}};au.default=t$});var Sm=T(cu=>{"use strict";Object.defineProperty(cu,"__esModule",{value:!0});var r$=H(),s$={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:s}=t;if((0,r$.alwaysValidSchema)(s,r)){t.fail();return}let n=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},n),t.failResult(n,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};cu.default=s$});var km=T(lu=>{"use strict";Object.defineProperty(lu,"__esModule",{value:!0});var n$=ot(),o$={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:n$.validateUnion,error:{message:"must match a schema in anyOf"}};lu.default=o$});var xm=T(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});var $i=L(),i$=H(),a$={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,$i._)`{passingSchemas: ${t.passing}}`},c$={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:a$,code(t){let{gen:e,schema:r,parentSchema:s,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(n.opts.discriminator&&s.discriminator)return;let o=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(l),t.result(i,()=>t.reset(),()=>t.error(!0));function l(){o.forEach((u,d)=>{let h;(0,i$.alwaysValidSchema)(n,u)?e.var(c,!0):h=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,$i._)`${c} && ${i}`).assign(i,!1).assign(a,(0,$i._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),h&&t.mergeEvaluated(h,$i.Name)})})}}};uu.default=c$});var Tm=T(du=>{"use strict";Object.defineProperty(du,"__esModule",{value:!0});var l$=H(),u$={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 n=e.name("valid");r.forEach((o,i)=>{if((0,l$.alwaysValidSchema)(s,o))return;let a=t.subschema({keyword:"allOf",schemaProp:i},n);t.ok(n),t.mergeEvaluated(a)})}};du.default=u$});var Pm=T(hu=>{"use strict";Object.defineProperty(hu,"__esModule",{value:!0});var Pi=L(),$m=H(),d$={message:({params:t})=>(0,Pi.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Pi._)`{failingKeyword: ${t.ifClause}}`},h$={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:d$,code(t){let{gen:e,parentSchema:r,it:s}=t;r.then===void 0&&r.else===void 0&&(0,$m.checkStrictMode)(s,'"if" without "then" and "else" is ignored');let n=Em(s,"then"),o=Em(s,"else");if(!n&&!o)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),n&&o){let u=e.let("ifClause");t.setParams({ifClause:u}),e.if(a,l("then",u),l("else",u))}else n?e.if(a,l("then")):e.if((0,Pi.not)(a),l("else"));t.pass(i,()=>t.error(!0));function c(){let u=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(u)}function l(u,d){return()=>{let h=t.subschema({keyword:u},a);e.assign(i,a),t.mergeValidEvaluated(h,i),d?e.assign(d,(0,Pi._)`${u}`):t.setParams({ifClause:u})}}}};function Em(t,e){let r=t.schema[e];return r!==void 0&&!(0,$m.alwaysValidSchema)(t,r)}hu.default=h$});var Cm=T(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});var p$=H(),f$={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,p$.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};pu.default=f$});var Rm=T(fu=>{"use strict";Object.defineProperty(fu,"__esModule",{value:!0});var m$=Yl(),g$=im(),y$=Jl(),w$=cm(),b$=lm(),v$=hm(),_$=fm(),S$=nu(),k$=ym(),x$=_m(),T$=Sm(),E$=km(),$$=xm(),P$=Tm(),C$=Pm(),R$=Cm();function M$(t=!1){let e=[T$.default,E$.default,$$.default,P$.default,C$.default,R$.default,_$.default,S$.default,v$.default,k$.default,x$.default];return t?e.push(g$.default,w$.default):e.push(m$.default,y$.default),e.push(b$.default),e}fu.default=M$});var Mm=T(mu=>{"use strict";Object.defineProperty(mu,"__esModule",{value:!0});var le=L(),A$={message:({schemaCode:t})=>(0,le.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,le._)`{format: ${t}}`},O$={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:A$,code(t,e){let{gen:r,data:s,$data:n,schema:o,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=a;if(!c.validateFormats)return;n?h():p();function h(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),f=r.const("fDef",(0,le._)`${m}[${i}]`),g=r.let("fType"),w=r.let("format");r.if((0,le._)`typeof ${f} == "object" && !(${f} instanceof RegExp)`,()=>r.assign(g,(0,le._)`${f}.type || "string"`).assign(w,(0,le._)`${f}.validate`),()=>r.assign(g,(0,le._)`"string"`).assign(w,f)),t.fail$data((0,le.or)(v(),S()));function v(){return c.strictSchema===!1?le.nil:(0,le._)`${i} && !${w}`}function S(){let x=u.$async?(0,le._)`(${f}.async ? await ${w}(${s}) : ${w}(${s}))`:(0,le._)`${w}(${s})`,_=(0,le._)`(typeof ${w} == "function" ? ${x} : ${w}.test(${s}))`;return(0,le._)`${w} && ${w} !== true && ${g} === ${e} && !${_}`}}function p(){let m=d.formats[o];if(!m){v();return}if(m===!0)return;let[f,g,w]=S(m);f===e&&t.pass(x());function v(){if(c.strictSchema===!1){d.logger.warn(_());return}throw new Error(_());function _(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function S(_){let k=_ instanceof RegExp?(0,le.regexpCode)(_):c.code.formats?(0,le._)`${c.code.formats}${(0,le.getProperty)(o)}`:void 0,C=r.scopeValue("formats",{key:o,ref:_,code:k});return typeof _=="object"&&!(_ instanceof RegExp)?[_.type||"string",_.validate,(0,le._)`${C}.validate`]:["string",_,C]}function x(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!u.$async)throw new Error("async format in sync schema");return(0,le._)`await ${w}(${s})`}return typeof g=="function"?(0,le._)`${w}(${s})`:(0,le._)`${w}.test(${s})`}}}};mu.default=O$});var Am=T(gu=>{"use strict";Object.defineProperty(gu,"__esModule",{value:!0});var I$=Mm(),z$=[I$.default];gu.default=z$});var Om=T(ds=>{"use strict";Object.defineProperty(ds,"__esModule",{value:!0});ds.contentVocabulary=ds.metadataVocabulary=void 0;ds.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];ds.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var zm=T(yu=>{"use strict";Object.defineProperty(yu,"__esModule",{value:!0});var N$=Uf(),j$=rm(),D$=Rm(),q$=Am(),Im=Om(),L$=[N$.default,j$.default,(0,D$.default)(),q$.default,Im.metadataVocabulary,Im.contentVocabulary];yu.default=L$});var jm=T(Ci=>{"use strict";Object.defineProperty(Ci,"__esModule",{value:!0});Ci.DiscrError=void 0;var Nm;(function(t){t.Tag="tag",t.Mapping="mapping"})(Nm||(Ci.DiscrError=Nm={}))});var qm=T(bu=>{"use strict";Object.defineProperty(bu,"__esModule",{value:!0});var hs=L(),wu=jm(),Dm=ui(),F$=yn(),U$=H(),B$={message:({params:{discrError:t,tagName:e}})=>t===wu.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,hs._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},W$={keyword:"discriminator",type:"object",schemaType:"object",error:B$,code(t){let{gen:e,data:r,schema:s,parentSchema:n,it:o}=t,{oneOf:i}=n;if(!o.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),l=e.const("tag",(0,hs._)`${r}${(0,hs.getProperty)(a)}`);e.if((0,hs._)`typeof ${l} == "string"`,()=>u(),()=>t.error(!1,{discrError:wu.DiscrError.Tag,tag:l,tagName:a})),t.ok(c);function u(){let p=h();e.if(!1);for(let m in p)e.elseIf((0,hs._)`${l} === ${m}`),e.assign(c,d(p[m]));e.else(),t.error(!1,{discrError:wu.DiscrError.Mapping,tag:l,tagName:a}),e.endIf()}function d(p){let m=e.name("valid"),f=t.subschema({keyword:"oneOf",schemaProp:p},m);return t.mergeEvaluated(f,hs.Name),m}function h(){var p;let m={},f=w(n),g=!0;for(let x=0;x<i.length;x++){let _=i[x];if(_?.$ref&&!(0,U$.schemaHasRulesButRef)(_,o.self.RULES)){let C=_.$ref;if(_=Dm.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,C),_ instanceof Dm.SchemaEnv&&(_=_.schema),_===void 0)throw new F$.default(o.opts.uriResolver,o.baseId,C)}let k=(p=_?.properties)===null||p===void 0?void 0:p[a];if(typeof k!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(f||w(_)),v(k,x)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return m;function w({required:x}){return Array.isArray(x)&&x.includes(a)}function v(x,_){if(x.const)S(x.const,_);else if(x.enum)for(let k of x.enum)S(k,_);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function S(x,_){if(typeof x!="string"||x in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[x]=_}}}};bu.default=W$});var Lm=T((uF,H$)=>{H$.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 _u=T((re,vu)=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.MissingRefError=re.ValidationError=re.CodeGen=re.Name=re.nil=re.stringify=re.str=re._=re.KeywordCxt=re.Ajv=void 0;var G$=Nf(),V$=zm(),K$=qm(),Fm=Lm(),Z$=["/properties"],Ri="http://json-schema.org/draft-07/schema",ps=class extends G$.default{_addVocabularies(){super._addVocabularies(),V$.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(K$.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(Fm,Z$):Fm;this.addMetaSchema(e,Ri,!1),this.refs["http://json-schema.org/schema"]=Ri}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Ri)?Ri:void 0)}};re.Ajv=ps;vu.exports=re=ps;vu.exports.Ajv=ps;Object.defineProperty(re,"__esModule",{value:!0});re.default=ps;var Y$=gn();Object.defineProperty(re,"KeywordCxt",{enumerable:!0,get:function(){return Y$.KeywordCxt}});var fs=L();Object.defineProperty(re,"_",{enumerable:!0,get:function(){return fs._}});Object.defineProperty(re,"str",{enumerable:!0,get:function(){return fs.str}});Object.defineProperty(re,"stringify",{enumerable:!0,get:function(){return fs.stringify}});Object.defineProperty(re,"nil",{enumerable:!0,get:function(){return fs.nil}});Object.defineProperty(re,"Name",{enumerable:!0,get:function(){return fs.Name}});Object.defineProperty(re,"CodeGen",{enumerable:!0,get:function(){return fs.CodeGen}});var J$=ci();Object.defineProperty(re,"ValidationError",{enumerable:!0,get:function(){return J$.default}});var X$=yn();Object.defineProperty(re,"MissingRefError",{enumerable:!0,get:function(){return X$.default}})});var Zm=T(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.formatNames=Mt.fastFormats=Mt.fullFormats=void 0;function Rt(t,e){return{validate:t,compare:e}}Mt.fullFormats={date:Rt(Hm,Tu),time:Rt(ku(!0),Eu),"date-time":Rt(Um(!0),Vm),"iso-time":Rt(ku(),Gm),"iso-date-time":Rt(Um(),Km),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:nP,"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:dP,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:oP,int32:{type:"number",validate:cP},int64:{type:"number",validate:lP},float:{type:"number",validate:Wm},double:{type:"number",validate:Wm},password:!0,binary:!0};Mt.fastFormats={...Mt.fullFormats,date:Rt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Tu),time:Rt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Eu),"date-time":Rt(/^\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,Vm),"iso-time":Rt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Gm),"iso-date-time":Rt(/^\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,Km),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};Mt.formatNames=Object.keys(Mt.fullFormats);function Q$(t){return t%4===0&&(t%100!==0||t%400===0)}var eP=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,tP=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Hm(t){let e=eP.exec(t);if(!e)return!1;let r=+e[1],s=+e[2],n=+e[3];return s>=1&&s<=12&&n>=1&&n<=(s===2&&Q$(r)?29:tP[s])}function Tu(t,e){if(t&&e)return t>e?1:t<e?-1:0}var Su=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function ku(t){return function(r){let s=Su.exec(r);if(!s)return!1;let n=+s[1],o=+s[2],i=+s[3],a=s[4],c=s[5]==="-"?-1:1,l=+(s[6]||0),u=+(s[7]||0);if(l>23||u>59||t&&!a)return!1;if(n<=23&&o<=59&&i<60)return!0;let d=o-u*c,h=n-l*c-(d<0?1:0);return(h===23||h===-1)&&(d===59||d===-1)&&i<61}}function Eu(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 Gm(t,e){if(!(t&&e))return;let r=Su.exec(t),s=Su.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 xu=/t|\s/i;function Um(t){let e=ku(t);return function(s){let n=s.split(xu);return n.length===2&&Hm(n[0])&&e(n[1])}}function Vm(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),s=new Date(e).valueOf();if(r&&s)return r-s}function Km(t,e){if(!(t&&e))return;let[r,s]=t.split(xu),[n,o]=e.split(xu),i=Tu(r,n);if(i!==void 0)return i||Eu(s,o)}var rP=/\/|:/,sP=/^(?:[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 nP(t){return rP.test(t)&&sP.test(t)}var Bm=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function oP(t){return Bm.lastIndex=0,Bm.test(t)}var iP=-(2**31),aP=2**31-1;function cP(t){return Number.isInteger(t)&&t<=aP&&t>=iP}function lP(t){return Number.isInteger(t)}function Wm(){return!0}var uP=/[^\\]\\Z/;function dP(t){if(uP.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var Ym=T(ms=>{"use strict";Object.defineProperty(ms,"__esModule",{value:!0});ms.formatLimitDefinition=void 0;var hP=_u(),bt=L(),ar=bt.operators,Mi={formatMaximum:{okStr:"<=",ok:ar.LTE,fail:ar.GT},formatMinimum:{okStr:">=",ok:ar.GTE,fail:ar.LT},formatExclusiveMaximum:{okStr:"<",ok:ar.LT,fail:ar.GTE},formatExclusiveMinimum:{okStr:">",ok:ar.GT,fail:ar.LTE}},pP={message:({keyword:t,schemaCode:e})=>(0,bt.str)`should be ${Mi[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,bt._)`{comparison: ${Mi[t].okStr}, limit: ${e}}`};ms.formatLimitDefinition={keyword:Object.keys(Mi),type:"string",schemaType:"string",$data:!0,error:pP,code(t){let{gen:e,data:r,schemaCode:s,keyword:n,it:o}=t,{opts:i,self:a}=o;if(!i.validateFormats)return;let c=new hP.KeywordCxt(o,a.RULES.all.format.definition,"format");c.$data?l():u();function l(){let h=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),p=e.const("fmt",(0,bt._)`${h}[${c.schemaCode}]`);t.fail$data((0,bt.or)((0,bt._)`typeof ${p} != "object"`,(0,bt._)`${p} instanceof RegExp`,(0,bt._)`typeof ${p}.compare != "function"`,d(p)))}function u(){let h=c.schema,p=a.formats[h];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${n}": format "${h}" does not define "compare" function`);let m=e.scopeValue("formats",{key:h,ref:p,code:i.code.formats?(0,bt._)`${i.code.formats}${(0,bt.getProperty)(h)}`:void 0});t.fail$data(d(m))}function d(h){return(0,bt._)`${h}.compare(${r}, ${s}) ${Mi[n].fail} 0`}},dependencies:["format"]};var fP=t=>(t.addKeyword(ms.formatLimitDefinition),t);ms.default=fP});var eg=T((An,Qm)=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});var gs=Zm(),mP=Ym(),$u=L(),Jm=new $u.Name("fullFormats"),gP=new $u.Name("fastFormats"),Pu=(t,e={keywords:!0})=>{if(Array.isArray(e))return Xm(t,e,gs.fullFormats,Jm),t;let[r,s]=e.mode==="fast"?[gs.fastFormats,gP]:[gs.fullFormats,Jm],n=e.formats||gs.formatNames;return Xm(t,n,r,s),e.keywords&&(0,mP.default)(t),t};Pu.get=(t,e="full")=>{let s=(e==="fast"?gs.fastFormats:gs.fullFormats)[t];if(!s)throw new Error(`Unknown format "${t}"`);return s};function Xm(t,e,r,s){var n,o;(n=(o=t.opts.code).formats)!==null&&n!==void 0||(o.formats=(0,$u._)`require("ajv-formats/dist/formats").${s}`);for(let i of e)t.addFormat(i,r[i])}Qm.exports=An=Pu;Object.defineProperty(An,"__esModule",{value:!0});An.default=Pu});var Cg=T((GF,Pg)=>{"use strict";Pg.exports=$g;$g.sync=KP;var Tg=Zt("fs");function VP(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 n=r[s].toLowerCase();if(n&&t.substr(-n.length).toLowerCase()===n)return!0}return!1}function Eg(t,e,r){return!t.isSymbolicLink()&&!t.isFile()?!1:VP(e,r)}function $g(t,e,r){Tg.stat(t,function(s,n){r(s,s?!1:Eg(n,t,e))})}function KP(t,e){return Eg(Tg.statSync(t),t,e)}});var Ig=T((VF,Og)=>{"use strict";Og.exports=Mg;Mg.sync=ZP;var Rg=Zt("fs");function Mg(t,e,r){Rg.stat(t,function(s,n){r(s,s?!1:Ag(n,e))})}function ZP(t,e){return Ag(Rg.statSync(t),e)}function Ag(t,e){return t.isFile()&&YP(t,e)}function YP(t,e){var r=t.mode,s=t.uid,n=t.gid,o=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),l=parseInt("001",8),u=a|c,d=r&l||r&c&&n===i||r&a&&s===o||r&u&&o===0;return d}});var Ng=T((ZF,zg)=>{"use strict";var KF=Zt("fs"),Ui;process.platform==="win32"||global.TESTING_WINDOWS?Ui=Cg():Ui=Ig();zg.exports=Ku;Ku.sync=JP;function Ku(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,n){Ku(t,e||{},function(o,i){o?n(o):s(i)})})}Ui(t,e||{},function(s,n){s&&(s.code==="EACCES"||e&&e.ignoreErrors)&&(s=null,n=!1),r(s,n)})}function JP(t,e){try{return Ui.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var Bg=T((YF,Ug)=>{"use strict";var xs=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",jg=Zt("path"),XP=xs?";":":",Dg=Ng(),qg=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),Lg=(t,e)=>{let r=e.colon||XP,s=t.match(/\//)||xs&&t.match(/\\/)?[""]:[...xs?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],n=xs?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=xs?n.split(r):[""];return xs&&t.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:s,pathExt:o,pathExtExe:n}},Fg=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});let{pathEnv:s,pathExt:n,pathExtExe:o}=Lg(t,e),i=[],a=l=>new Promise((u,d)=>{if(l===s.length)return e.all&&i.length?u(i):d(qg(t));let h=s[l],p=/^".*"$/.test(h)?h.slice(1,-1):h,m=jg.join(p,t),f=!p&&/^\.[\\\/]/.test(t)?t.slice(0,2)+m:m;u(c(f,l,0))}),c=(l,u,d)=>new Promise((h,p)=>{if(d===n.length)return h(a(u+1));let m=n[d];Dg(l+m,{pathExt:o},(f,g)=>{if(!f&&g)if(e.all)i.push(l+m);else return h(l+m);return h(c(l,u,d+1))})});return r?a(0).then(l=>r(null,l),r):a(0)},QP=(t,e)=>{e=e||{};let{pathEnv:r,pathExt:s,pathExtExe:n}=Lg(t,e),o=[];for(let i=0;i<r.length;i++){let a=r[i],c=/^".*"$/.test(a)?a.slice(1,-1):a,l=jg.join(c,t),u=!c&&/^\.[\\\/]/.test(t)?t.slice(0,2)+l:l;for(let d=0;d<s.length;d++){let h=u+s[d];try{if(Dg.sync(h,{pathExt:n}))if(e.all)o.push(h);else return h}catch{}}}if(e.all&&o.length)return o;if(e.nothrow)return null;throw qg(t)};Ug.exports=Fg;Fg.sync=QP});var Hg=T((JF,Zu)=>{"use strict";var Wg=(t={})=>{let e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(s=>s.toUpperCase()==="PATH")||"Path"};Zu.exports=Wg;Zu.exports.default=Wg});var Zg=T((XF,Kg)=>{"use strict";var Gg=Zt("path"),eC=Bg(),tC=Hg();function Vg(t,e){let r=t.options.env||process.env,s=process.cwd(),n=t.options.cwd!=null,o=n&&process.chdir!==void 0&&!process.chdir.disabled;if(o)try{process.chdir(t.options.cwd)}catch{}let i;try{i=eC.sync(t.command,{path:r[tC({env:r})],pathExt:e?Gg.delimiter:void 0})}catch{}finally{o&&process.chdir(s)}return i&&(i=Gg.resolve(n?t.options.cwd:"",i)),i}function rC(t){return Vg(t)||Vg(t,!0)}Kg.exports=rC});var Yg=T((QF,Ju)=>{"use strict";var Yu=/([()\][%!^"`<>&|;, *?])/g;function sC(t){return t=t.replace(Yu,"^$1"),t}function nC(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(Yu,"^$1"),e&&(t=t.replace(Yu,"^$1")),t}Ju.exports.command=sC;Ju.exports.argument=nC});var Xg=T((eU,Jg)=>{"use strict";Jg.exports=/^#!(.*)/});var ey=T((tU,Qg)=>{"use strict";var oC=Xg();Qg.exports=(t="")=>{let e=t.match(oC);if(!e)return null;let[r,s]=e[0].replace(/#! ?/,"").split(" "),n=r.split("/").pop();return n==="env"?s:s?`${n} ${s}`:n}});var ry=T((rU,ty)=>{"use strict";var Xu=Zt("fs"),iC=ey();function aC(t){let r=Buffer.alloc(150),s;try{s=Xu.openSync(t,"r"),Xu.readSync(s,r,0,150,0),Xu.closeSync(s)}catch{}return iC(r.toString())}ty.exports=aC});var iy=T((sU,oy)=>{"use strict";var cC=Zt("path"),sy=Zg(),ny=Yg(),lC=ry(),uC=process.platform==="win32",dC=/\.(?:com|exe)$/i,hC=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function pC(t){t.file=sy(t);let e=t.file&&lC(t.file);return e?(t.args.unshift(t.file),t.command=e,sy(t)):t.file}function fC(t){if(!uC)return t;let e=pC(t),r=!dC.test(e);if(t.options.forceShell||r){let s=hC.test(e);t.command=cC.normalize(t.command),t.command=ny.command(t.command),t.args=t.args.map(o=>ny.argument(o,s));let n=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${n}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function mC(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:fC(s)}oy.exports=mC});var ly=T((nU,cy)=>{"use strict";var Qu=process.platform==="win32";function ed(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 gC(t,e){if(!Qu)return;let r=t.emit;t.emit=function(s,n){if(s==="exit"){let o=ay(n,e);if(o)return r.call(t,"error",o)}return r.apply(t,arguments)}}function ay(t,e){return Qu&&t===1&&!e.file?ed(e.original,"spawn"):null}function yC(t,e){return Qu&&t===1&&!e.file?ed(e.original,"spawnSync"):null}cy.exports={hookChildProcess:gC,verifyENOENT:ay,verifyENOENTSync:yC,notFoundError:ed}});var hy=T((oU,Ts)=>{"use strict";var uy=Zt("child_process"),td=iy(),rd=ly();function dy(t,e,r){let s=td(t,e,r),n=uy.spawn(s.command,s.args,s.options);return rd.hookChildProcess(n,s),n}function wC(t,e,r){let s=td(t,e,r),n=uy.spawnSync(s.command,s.args,s.options);return n.error=n.error||rd.verifyENOENTSync(n.status,s),n}Ts.exports=dy;Ts.exports.spawn=dy;Ts.exports.sync=wC;Ts.exports._parse=td;Ts.exports._enoent=rd});var wy=T(nd=>{"use strict";var my=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,xC=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,gy=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,TC=/\\([\u000b\u0020-\u00ff])/g,EC=/([\\"])/g,yy=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;nd.format=$C;nd.parse=PC;function $C(t){if(!t||typeof t!="object")throw new TypeError("argument obj is required");var e=t.parameters,r=t.type;if(!r||!yy.test(r))throw new TypeError("invalid type");var s=r;if(e&&typeof e=="object")for(var n,o=Object.keys(e).sort(),i=0;i<o.length;i++){if(n=o[i],!gy.test(n))throw new TypeError("invalid parameter name");s+="; "+n+"="+RC(e[n])}return s}function PC(t){if(!t)throw new TypeError("argument string is required");var e=typeof t=="object"?CC(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(!yy.test(s))throw new TypeError("invalid media type");var n=new MC(s.toLowerCase());if(r!==-1){var o,i,a;for(my.lastIndex=r;i=my.exec(e);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,o=i[1].toLowerCase(),a=i[2],a.charCodeAt(0)===34&&(a=a.slice(1,-1),a.indexOf("\\")!==-1&&(a=a.replace(TC,"$1"))),n.parameters[o]=a}if(r!==e.length)throw new TypeError("invalid parameter format")}return n}function CC(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 RC(t){var e=String(t);if(gy.test(e))return e;if(e.length>0&&!xC.test(e))throw new TypeError("invalid parameter value");return'"'+e.replace(EC,"\\$1")+'"'}function MC(t){this.parameters=Object.create(null),this.type=t}});async function tc(t,e){switch(t.protocol){case"anthropic":{let{AnthropicClient:r}=await import("./anthropic-YP6DY2F3.js");return Mo(new r(t,e),{model:t.model,protocol:t.protocol})}case"openai":{let{OpenAIClient:r}=await import("./openai-2FE77NB2.js");return Mo(new r(t,e),{model:t.model,protocol:t.protocol})}case"openai-compat":{let{OpenAICompatClient:r}=await import("./openai-2FE77NB2.js");return Mo(new r(t,e),{model:t.model,protocol:t.protocol})}default:throw new Error(`Unknown protocol: ${String(t.protocol)}`)}}import{isDeepStrictEqual as jC}from"util";var Jr="2025-11-25";var zh=[Jr,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Jt="io.modelcontextprotocol/related-task",Do="2.0",pe=dh(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Nh=se([b(),V().int()]),jh=b(),uN=he({ttl:V().optional(),pollInterval:V().optional()}),M0=P({ttl:V().optional()}),A0=P({taskId:b()}),sc=he({progressToken:Nh.optional(),[Jt]:A0.optional()}),Xe=P({_meta:sc.optional()}),Vs=Xe.extend({task:M0.optional()}),Dh=t=>Vs.safeParse(t).success,ve=P({method:b(),params:Xe.loose().optional()}),rt=P({_meta:sc.optional()}),st=P({method:b(),params:rt.loose().optional()}),_e=he({_meta:sc.optional()}),qo=se([b(),V().int()]),qh=P({jsonrpc:R(Do),id:qo,...ve.shape}).strict(),Ks=t=>qh.safeParse(t).success,Lh=P({jsonrpc:R(Do),...st.shape}).strict(),Fh=t=>Lh.safeParse(t).success,nc=P({jsonrpc:R(Do),id:qo,result:_e}).strict(),br=t=>nc.safeParse(t).success;var N;(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"})(N||(N={}));var oc=P({jsonrpc:R(Do),id:qo.optional(),error:P({code:V().int(),message:b(),data:ce().optional()})}).strict();var Uh=t=>oc.safeParse(t).success;var Xt=se([qh,Lh,nc,oc]),dN=se([nc,oc]),vr=_e.strict(),O0=rt.extend({requestId:qo.optional(),reason:b().optional()}),Lo=st.extend({method:R("notifications/cancelled"),params:O0}),I0=P({src:b(),mimeType:b().optional(),sizes:E(b()).optional(),theme:Je(["light","dark"]).optional()}),Zs=P({icons:E(I0).optional()}),Yr=P({name:b(),title:b().optional()}),Bh=Yr.extend({...Yr.shape,...Zs.shape,version:b(),websiteUrl:b().optional(),description:b().optional()}),z0=Za(P({applyDefaults:Y().optional()}),ee(b(),ce())),N0=Ya(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,Za(P({form:z0.optional(),url:pe.optional()}),ee(b(),ce()).optional())),j0=he({list:pe.optional(),cancel:pe.optional(),requests:he({sampling:he({createMessage:pe.optional()}).optional(),elicitation:he({create:pe.optional()}).optional()}).optional()}),D0=he({list:pe.optional(),cancel:pe.optional(),requests:he({tools:he({call:pe.optional()}).optional()}).optional()}),q0=P({experimental:ee(b(),pe).optional(),sampling:P({context:pe.optional(),tools:pe.optional()}).optional(),elicitation:N0.optional(),roots:P({listChanged:Y().optional()}).optional(),tasks:j0.optional(),extensions:ee(b(),pe).optional()}),L0=Xe.extend({protocolVersion:b(),capabilities:q0,clientInfo:Bh}),F0=ve.extend({method:R("initialize"),params:L0});var U0=P({experimental:ee(b(),pe).optional(),logging:pe.optional(),completions:pe.optional(),prompts:P({listChanged:Y().optional()}).optional(),resources:P({subscribe:Y().optional(),listChanged:Y().optional()}).optional(),tools:P({listChanged:Y().optional()}).optional(),tasks:D0.optional(),extensions:ee(b(),pe).optional()}),ic=_e.extend({protocolVersion:b(),capabilities:U0,serverInfo:Bh,instructions:b().optional()}),Wh=st.extend({method:R("notifications/initialized"),params:rt.optional()}),Hh=t=>Wh.safeParse(t).success,Fo=ve.extend({method:R("ping"),params:Xe.optional()}),B0=P({progress:V(),total:ae(V()),message:ae(b())}),W0=P({...rt.shape,...B0.shape,progressToken:Nh}),Uo=st.extend({method:R("notifications/progress"),params:W0}),H0=Xe.extend({cursor:jh.optional()}),Ys=ve.extend({params:H0.optional()}),Js=_e.extend({nextCursor:jh.optional()}),G0=Je(["working","input_required","completed","failed","cancelled"]),Xs=P({taskId:b(),status:G0,ttl:se([V(),lh()]),createdAt:b(),lastUpdatedAt:b(),pollInterval:ae(V()),statusMessage:ae(b())}),_r=_e.extend({task:Xs}),V0=rt.merge(Xs),Qs=st.extend({method:R("notifications/tasks/status"),params:V0}),Bo=ve.extend({method:R("tasks/get"),params:Xe.extend({taskId:b()})}),Wo=_e.merge(Xs),Ho=ve.extend({method:R("tasks/result"),params:Xe.extend({taskId:b()})}),hN=_e.loose(),Go=Ys.extend({method:R("tasks/list")}),Vo=Js.extend({tasks:E(Xs)}),Ko=ve.extend({method:R("tasks/cancel"),params:Xe.extend({taskId:b()})}),Gh=_e.merge(Xs),Vh=P({uri:b(),mimeType:ae(b()),_meta:ee(b(),ce()).optional()}),Kh=Vh.extend({text:b()}),ac=b().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Zh=Vh.extend({blob:ac}),en=Je(["user","assistant"]),Xr=P({audience:E(en).optional(),priority:V().min(0).max(1).optional(),lastModified:ph.datetime({offset:!0}).optional()}),Yh=P({...Yr.shape,...Zs.shape,uri:b(),description:ae(b()),mimeType:ae(b()),size:ae(V()),annotations:Xr.optional(),_meta:ae(he({}))}),K0=P({...Yr.shape,...Zs.shape,uriTemplate:b(),description:ae(b()),mimeType:ae(b()),annotations:Xr.optional(),_meta:ae(he({}))}),Z0=Ys.extend({method:R("resources/list")}),cc=Js.extend({resources:E(Yh)}),Y0=Ys.extend({method:R("resources/templates/list")}),lc=Js.extend({resourceTemplates:E(K0)}),uc=Xe.extend({uri:b()}),J0=uc,X0=ve.extend({method:R("resources/read"),params:J0}),dc=_e.extend({contents:E(se([Kh,Zh]))}),hc=st.extend({method:R("notifications/resources/list_changed"),params:rt.optional()}),Q0=uc,e_=ve.extend({method:R("resources/subscribe"),params:Q0}),t_=uc,r_=ve.extend({method:R("resources/unsubscribe"),params:t_}),s_=rt.extend({uri:b()}),n_=st.extend({method:R("notifications/resources/updated"),params:s_}),o_=P({name:b(),description:ae(b()),required:ae(Y())}),i_=P({...Yr.shape,...Zs.shape,description:ae(b()),arguments:ae(E(o_)),_meta:ae(he({}))}),a_=Ys.extend({method:R("prompts/list")}),pc=Js.extend({prompts:E(i_)}),c_=Xe.extend({name:b(),arguments:ee(b(),b()).optional()}),l_=ve.extend({method:R("prompts/get"),params:c_}),fc=P({type:R("text"),text:b(),annotations:Xr.optional(),_meta:ee(b(),ce()).optional()}),mc=P({type:R("image"),data:ac,mimeType:b(),annotations:Xr.optional(),_meta:ee(b(),ce()).optional()}),gc=P({type:R("audio"),data:ac,mimeType:b(),annotations:Xr.optional(),_meta:ee(b(),ce()).optional()}),u_=P({type:R("tool_use"),name:b(),id:b(),input:ee(b(),ce()),_meta:ee(b(),ce()).optional()}),d_=P({type:R("resource"),resource:se([Kh,Zh]),annotations:Xr.optional(),_meta:ee(b(),ce()).optional()}),h_=Yh.extend({type:R("resource_link")}),yc=se([fc,mc,gc,h_,d_]),p_=P({role:en,content:yc}),wc=_e.extend({description:b().optional(),messages:E(p_)}),bc=st.extend({method:R("notifications/prompts/list_changed"),params:rt.optional()}),f_=P({title:b().optional(),readOnlyHint:Y().optional(),destructiveHint:Y().optional(),idempotentHint:Y().optional(),openWorldHint:Y().optional()}),m_=P({taskSupport:Je(["required","optional","forbidden"]).optional()}),Jh=P({...Yr.shape,...Zs.shape,description:b().optional(),inputSchema:P({type:R("object"),properties:ee(b(),pe).optional(),required:E(b()).optional()}).catchall(ce()),outputSchema:P({type:R("object"),properties:ee(b(),pe).optional(),required:E(b()).optional()}).catchall(ce()).optional(),annotations:f_.optional(),execution:m_.optional(),_meta:ee(b(),ce()).optional()}),g_=Ys.extend({method:R("tools/list")}),vc=Js.extend({tools:E(Jh)}),Qr=_e.extend({content:E(yc).default([]),structuredContent:ee(b(),ce()).optional(),isError:Y().optional()}),pN=Qr.or(_e.extend({toolResult:ce()})),y_=Vs.extend({name:b(),arguments:ee(b(),ce()).optional()}),w_=ve.extend({method:R("tools/call"),params:y_}),_c=st.extend({method:R("notifications/tools/list_changed"),params:rt.optional()}),Xh=P({autoRefresh:Y().default(!0),debounceMs:V().int().nonnegative().default(300)}),Qh=Je(["debug","info","notice","warning","error","critical","alert","emergency"]),b_=Xe.extend({level:Qh}),v_=ve.extend({method:R("logging/setLevel"),params:b_}),__=rt.extend({level:Qh,logger:b().optional(),data:ce()}),S_=st.extend({method:R("notifications/message"),params:__}),k_=P({name:b().optional()}),x_=P({hints:E(k_).optional(),costPriority:V().min(0).max(1).optional(),speedPriority:V().min(0).max(1).optional(),intelligencePriority:V().min(0).max(1).optional()}),T_=P({mode:Je(["auto","required","none"]).optional()}),E_=P({type:R("tool_result"),toolUseId:b().describe("The unique identifier for the corresponding tool call."),content:E(yc).default([]),structuredContent:P({}).loose().optional(),isError:Y().optional(),_meta:ee(b(),ce()).optional()}),$_=Ka("type",[fc,mc,gc]),jo=Ka("type",[fc,mc,gc,u_,E_]),P_=P({role:en,content:se([jo,E(jo)]),_meta:ee(b(),ce()).optional()}),C_=Vs.extend({messages:E(P_),modelPreferences:x_.optional(),systemPrompt:b().optional(),includeContext:Je(["none","thisServer","allServers"]).optional(),temperature:V().optional(),maxTokens:V().int(),stopSequences:E(b()).optional(),metadata:pe.optional(),tools:E(Jh).optional(),toolChoice:T_.optional()}),Sc=ve.extend({method:R("sampling/createMessage"),params:C_}),kc=_e.extend({model:b(),stopReason:ae(Je(["endTurn","stopSequence","maxTokens"]).or(b())),role:en,content:$_}),xc=_e.extend({model:b(),stopReason:ae(Je(["endTurn","stopSequence","maxTokens","toolUse"]).or(b())),role:en,content:se([jo,E(jo)])}),R_=P({type:R("boolean"),title:b().optional(),description:b().optional(),default:Y().optional()}),M_=P({type:R("string"),title:b().optional(),description:b().optional(),minLength:V().optional(),maxLength:V().optional(),format:Je(["email","uri","date","date-time"]).optional(),default:b().optional()}),A_=P({type:Je(["number","integer"]),title:b().optional(),description:b().optional(),minimum:V().optional(),maximum:V().optional(),default:V().optional()}),O_=P({type:R("string"),title:b().optional(),description:b().optional(),enum:E(b()),default:b().optional()}),I_=P({type:R("string"),title:b().optional(),description:b().optional(),oneOf:E(P({const:b(),title:b()})),default:b().optional()}),z_=P({type:R("string"),title:b().optional(),description:b().optional(),enum:E(b()),enumNames:E(b()).optional(),default:b().optional()}),N_=se([O_,I_]),j_=P({type:R("array"),title:b().optional(),description:b().optional(),minItems:V().optional(),maxItems:V().optional(),items:P({type:R("string"),enum:E(b())}),default:E(b()).optional()}),D_=P({type:R("array"),title:b().optional(),description:b().optional(),minItems:V().optional(),maxItems:V().optional(),items:P({anyOf:E(P({const:b(),title:b()}))}),default:E(b()).optional()}),q_=se([j_,D_]),L_=se([z_,N_,q_]),F_=se([L_,R_,M_,A_]),U_=Vs.extend({mode:R("form").optional(),message:b(),requestedSchema:P({type:R("object"),properties:ee(b(),F_),required:E(b()).optional()})}),B_=Vs.extend({mode:R("url"),message:b(),elicitationId:b(),url:b().url()}),W_=se([U_,B_]),Tc=ve.extend({method:R("elicitation/create"),params:W_}),H_=rt.extend({elicitationId:b()}),G_=st.extend({method:R("notifications/elicitation/complete"),params:H_}),Ec=_e.extend({action:Je(["accept","decline","cancel"]),content:Ya(t=>t===null?void 0:t,ee(b(),se([b(),V(),Y(),E(b())])).optional())}),V_=P({type:R("ref/resource"),uri:b()});var K_=P({type:R("ref/prompt"),name:b()}),Z_=Xe.extend({ref:se([K_,V_]),argument:P({name:b(),value:b()}),context:P({arguments:ee(b(),b()).optional()}).optional()}),Y_=ve.extend({method:R("completion/complete"),params:Z_});var $c=_e.extend({completion:he({values:E(b()).max(100),total:ae(V().int()),hasMore:ae(Y())})}),J_=P({uri:b().startsWith("file://"),name:b().optional(),_meta:ee(b(),ce()).optional()}),X_=ve.extend({method:R("roots/list"),params:Xe.optional()}),Q_=_e.extend({roots:E(J_)}),eS=st.extend({method:R("notifications/roots/list_changed"),params:rt.optional()}),fN=se([Fo,F0,Y_,v_,l_,a_,Z0,Y0,X0,e_,r_,w_,g_,Bo,Ho,Go,Ko]),mN=se([Lo,Uo,Wh,eS,Qs]),gN=se([vr,kc,xc,Ec,Q_,Wo,Vo,_r]),yN=se([Fo,Sc,Tc,X_,Bo,Ho,Go,Ko]),wN=se([Lo,Uo,S_,n_,hc,_c,bc,Qs,G_]),bN=se([vr,ic,$c,wc,pc,cc,lc,dc,Qr,vc,Wo,Vo,_r]),O=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===N.UrlElicitationRequired&&s){let n=s;if(n.elicitations)return new rc(n.elicitations,r)}return new t(e,r,s)}},rc=class extends O{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(N.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function Qt(t){return t==="completed"||t==="failed"||t==="cancelled"}var XN=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Pc(t){let r=Eo(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let s=$o(r);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function Cc(t,e){let r=ft(t,e);if(!r.success)throw r.error;return r.data}var iS=6e4,Zo=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(Lo,r=>{this._oncancel(r)}),this.setNotificationHandler(Uo,r=>{this._onprogress(r)}),this.setRequestHandler(Fo,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Bo,async(r,s)=>{let n=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!n)throw new O(N.InvalidParams,"Failed to retrieve task: Task not found");return{...n}}),this.setRequestHandler(Ho,async(r,s)=>{let n=async()=>{let o=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,s.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,l=c.id,u=this._requestResolvers.get(l);if(u)if(this._requestResolvers.delete(l),a.type==="response")u(c);else{let d=c,h=new O(d.error.code,d.error.message,d.error.data);u(h)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${l}`))}continue}await this._transport?.send(a.message,{relatedRequestId:s.requestId})}}let i=await this._taskStore.getTask(o,s.sessionId);if(!i)throw new O(N.InvalidParams,`Task not found: ${o}`);if(!Qt(i.status))return await this._waitForTaskUpdate(o,s.signal),await n();if(Qt(i.status)){let a=await this._taskStore.getTaskResult(o,s.sessionId);return this._clearTaskQueue(o),{...a,_meta:{...a._meta,[Jt]:{taskId:o}}}}return await n()};return await n()}),this.setRequestHandler(Go,async(r,s)=>{try{let{tasks:n,nextCursor:o}=await this._taskStore.listTasks(r.params?.cursor,s.sessionId);return{tasks:n,nextCursor:o,_meta:{}}}catch(n){throw new O(N.InvalidParams,`Failed to list tasks: ${n instanceof Error?n.message:String(n)}`)}}),this.setRequestHandler(Ko,async(r,s)=>{try{let n=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!n)throw new O(N.InvalidParams,`Task not found: ${r.params.taskId}`);if(Qt(n.status))throw new O(N.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(r.params.taskId);let o=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!o)throw new O(N.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(n){throw n instanceof O?n:new O(N.InvalidRequest,`Failed to cancel task: ${n instanceof Error?n.message:String(n)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,s,n,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(n,r),startTime:Date.now(),timeout:r,maxTotalTimeout:s,resetTimeoutOnProgress:o,onTimeout:n})}_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),O.fromError(N.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=o=>{s?.(o),this._onerror(o)};let n=this._transport?.onmessage;this._transport.onmessage=(o,i)=>{n?.(o,i),br(o)||Uh(o)?this._onresponse(o):Ks(o)?this._onrequest(o,i):Fh(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},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=O.fromError(N.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,n=this._transport,o=e.params?._meta?.[Jt]?.taskId;if(s===void 0){let u={jsonrpc:"2.0",id:e.id,error:{code:N.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:u,timestamp:Date.now()},n?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):n?.send(u).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=Dh(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,n?.sessionId):void 0,l={signal:i.signal,sessionId:n?.sessionId,_meta:e.params?._meta,sendNotification:async u=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};o&&(d.relatedTask={taskId:o}),await this.notification(u,d)},sendRequest:async(u,d,h)=>{if(i.signal.aborted)throw new O(N.ConnectionClosed,"Request was cancelled");let p={...h,relatedRequestId:e.id};o&&!p.relatedTask&&(p.relatedTask={taskId:o});let m=p.relatedTask?.taskId??o;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(u,d,p)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,l)).then(async u=>{if(i.signal.aborted)return;let d={result:u,jsonrpc:"2.0",id:e.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:d,timestamp:Date.now()},n?.sessionId):await n?.send(d)},async u=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(u.code)?u.code:N.InternalError,message:u.message??"Internal error",...u.data!==void 0&&{data:u.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:d,timestamp:Date.now()},n?.sessionId):await n?.send(d)}).catch(u=>this._onerror(new Error(`Failed to send response: ${u}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...s}=e.params,n=Number(r),o=this._progressHandlers.get(n);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(n),a=this._timeoutInfo.get(n);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(c){this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),i(c);return}o(s)}_onresponse(e){let r=Number(e.id),s=this._requestResolvers.get(r);if(s){if(this._requestResolvers.delete(r),br(e))s(e);else{let i=new O(e.error.code,e.error.message,e.error.data);s(i)}return}let n=this._responseHandlers.get(r);if(n===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 o=!1;if(br(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"&&(o=!0,this._taskProgressTokens.set(a.taskId,r))}}if(o||this._progressHandlers.delete(r),br(e))n(e);else{let i=O.fromError(e.error.code,e.error.message,e.error.data);n(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,s){let{task:n}=s??{};if(!n){try{yield{type:"result",result:await this.request(e,r,s)}}catch(i){yield{type:"error",error:i instanceof O?i:new O(N.InternalError,String(i))}}return}let o;try{let i=await this.request(e,_r,s);if(i.task)o=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new O(N.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:o},s);if(yield{type:"taskStatus",task:a},Qt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,s)}:a.status==="failed"?yield{type:"error",error:new O(N.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new O(N.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,s)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(l=>setTimeout(l,c)),s?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof O?i:new O(N.InternalError,String(i))}}}request(e,r,s){let{relatedRequestId:n,resumptionToken:o,onresumptiontoken:i,task:a,relatedTask:c}=s??{};return new Promise((l,u)=>{let d=v=>{u(v)};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(v){d(v);return}s?.signal?.throwIfAborted();let h=this._requestMessageId++,p={...e,jsonrpc:"2.0",id:h};s?.onprogress&&(this._progressHandlers.set(h,s.onprogress),p.params={...e.params,_meta:{...e.params?._meta||{},progressToken:h}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[Jt]:c}});let m=v=>{this._responseHandlers.delete(h),this._progressHandlers.delete(h),this._cleanupTimeout(h),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:h,reason:String(v)}},{relatedRequestId:n,resumptionToken:o,onresumptiontoken:i}).catch(x=>this._onerror(new Error(`Failed to send cancellation: ${x}`)));let S=v instanceof O?v:new O(N.RequestTimeout,String(v));u(S)};this._responseHandlers.set(h,v=>{if(!s?.signal?.aborted){if(v instanceof Error)return u(v);try{let S=ft(r,v.result);S.success?l(S.data):u(S.error)}catch(S){u(S)}}}),s?.signal?.addEventListener("abort",()=>{m(s?.signal?.reason)});let f=s?.timeout??iS,g=()=>m(O.fromError(N.RequestTimeout,"Request timed out",{timeout:f}));this._setupTimeout(h,f,s?.maxTotalTimeout,g,s?.resetTimeoutOnProgress??!1);let w=c?.taskId;if(w){let v=S=>{let x=this._responseHandlers.get(h);x?x(S):this._onerror(new Error(`Response handler missing for side-channeled request ${h}`))};this._requestResolvers.set(h,v),this._enqueueTaskMessage(w,{type:"request",message:p,timestamp:Date.now()}).catch(S=>{this._cleanupTimeout(h),u(S)})}else this._transport.send(p,{relatedRequestId:n,resumptionToken:o,onresumptiontoken:i}).catch(v=>{this._cleanupTimeout(h),u(v)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Wo,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},Vo,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},Gh,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||{},[Jt]: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||{},[Jt]: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||{},[Jt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let s=Pc(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(n,o)=>{let i=Cc(e,n);return Promise.resolve(r(i,o))})}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=Pc(e);this._notificationHandlers.set(s,n=>{let o=Cc(e,n);return Promise.resolve(r(o))})}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 n=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,s,n)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let s=await this._taskMessageQueue.dequeueAll(e,r);for(let n of s)if(n.type==="request"&&Ks(n.message)){let o=n.message.id,i=this._requestResolvers.get(o);i?(i(new O(N.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let s=this._options?.defaultTaskPollInterval??1e3;try{let n=await this._taskStore?.getTask(e);n?.pollInterval&&(s=n.pollInterval)}catch{}return new Promise((n,o)=>{if(r.aborted){o(new O(N.InvalidRequest,"Request cancelled"));return}let i=setTimeout(n,s);r.addEventListener("abort",()=>{clearTimeout(i),o(new O(N.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async n=>{if(!e)throw new Error("No request provided");return await s.createTask(n,e.id,{method:e.method,params:e.params},r)},getTask:async n=>{let o=await s.getTask(n,r);if(!o)throw new O(N.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(n,o,i)=>{await s.storeTaskResult(n,o,i,r);let a=await s.getTask(n,r);if(a){let c=Qs.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Qt(a.status)&&this._cleanupTaskProgressHandler(n)}},getTaskResult:n=>s.getTaskResult(n,r),updateTaskStatus:async(n,o,i)=>{let a=await s.getTask(n,r);if(!a)throw new O(N.InvalidParams,`Task "${n}" not found - it may have been cleaned up`);if(Qt(a.status))throw new O(N.InvalidParams,`Cannot update task "${n}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(n,o,i,r);let c=await s.getTask(n,r);if(c){let l=Qs.parse({method:"notifications/tasks/status",params:c});await this.notification(l),Qt(c.status)&&this._cleanupTaskProgressHandler(n)}},listTasks:n=>s.listTasks(n,r)}}};function ep(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function tp(t,e){let r={...t};for(let s in e){let n=s,o=e[n];if(o===void 0)continue;let i=r[n];ep(i)&&ep(o)?r[n]={...i,...o}:r[n]=o}return r}var tg=To(_u(),1),rg=To(eg(),1);function yP(){let t=new tg.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,rg.default)(t),t}var Ai=class{constructor(e){this._ajv=e??yP()}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 Oi=class{constructor(e){this._client=e}async*callToolStream(e,r=Qr,s){let n=this._client,o={...s,task:s?.task??(n.isToolTask(e.name)?{}:void 0)},i=n.requestStream({method:"tools/call",params:e},r,o),a=n.getToolOutputValidator(e.name);for await(let c of i){if(c.type==="result"&&a){let l=c.result;if(!l.structuredContent&&!l.isError){yield{type:"error",error:new O(N.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(l.structuredContent)try{let u=a(l.structuredContent);if(!u.valid){yield{type:"error",error:new O(N.InvalidParams,`Structured content does not match the tool's output schema: ${u.errorMessage}`)};return}}catch(u){if(u instanceof O){yield{type:"error",error:u};return}yield{type:"error",error:new O(N.InvalidParams,`Failed to validate structured content: ${u instanceof Error?u.message:String(u)}`)};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 sg(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 ng(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 Ii(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 n of Object.keys(s)){let o=s[n];r[n]===void 0&&Object.prototype.hasOwnProperty.call(o,"default")&&(r[n]=o.default),r[n]!==void 0&&Ii(o,r[n])}}if(Array.isArray(t.anyOf))for(let r of t.anyOf)typeof r!="boolean"&&Ii(r,e);if(Array.isArray(t.oneOf))for(let r of t.oneOf)typeof r!="boolean"&&Ii(r,e)}}function wP(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 zi=class extends Zo{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 Ai,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",_c,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",bc,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",hc,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new Oi(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=tp(this._capabilities,e)}setRequestHandler(e,r){let n=Eo(e)?.method;if(!n)throw new Error("Schema is missing a method literal");let o=$o(n);if(typeof o!="string")throw new Error("Schema method literal must be a string");let i=o;if(i==="elicitation/create"){let a=async(c,l)=>{let u=ft(Tc,c);if(!u.success){let v=u.error instanceof Error?u.error.message:String(u.error);throw new O(N.InvalidParams,`Invalid elicitation request: ${v}`)}let{params:d}=u.data;d.mode=d.mode??"form";let{supportsFormMode:h,supportsUrlMode:p}=wP(this._capabilities.elicitation);if(d.mode==="form"&&!h)throw new O(N.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!p)throw new O(N.InvalidParams,"Client does not support URL-mode elicitation requests");let m=await Promise.resolve(r(c,l));if(d.task){let v=ft(_r,m);if(!v.success){let S=v.error instanceof Error?v.error.message:String(v.error);throw new O(N.InvalidParams,`Invalid task creation result: ${S}`)}return v.data}let f=ft(Ec,m);if(!f.success){let v=f.error instanceof Error?f.error.message:String(f.error);throw new O(N.InvalidParams,`Invalid elicitation result: ${v}`)}let g=f.data,w=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&g.action==="accept"&&g.content&&w&&this._capabilities.elicitation?.form?.applyDefaults)try{Ii(w,g.content)}catch{}return g};return super.setRequestHandler(e,a)}if(i==="sampling/createMessage"){let a=async(c,l)=>{let u=ft(Sc,c);if(!u.success){let g=u.error instanceof Error?u.error.message:String(u.error);throw new O(N.InvalidParams,`Invalid sampling request: ${g}`)}let{params:d}=u.data,h=await Promise.resolve(r(c,l));if(d.task){let g=ft(_r,h);if(!g.success){let w=g.error instanceof Error?g.error.message:String(g.error);throw new O(N.InvalidParams,`Invalid task creation result: ${w}`)}return g.data}let m=d.tools||d.toolChoice?xc:kc,f=ft(m,h);if(!f.success){let g=f.error instanceof Error?f.error.message:String(f.error);throw new O(N.InvalidParams,`Invalid sampling result: ${g}`)}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:Jr,capabilities:this._capabilities,clientInfo:this._clientInfo}},ic,r);if(s===void 0)throw new Error(`Server sent invalid initialize result: ${s}`);if(!zh.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){sg(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&ng(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},vr,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},$c,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},vr,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},wc,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},pc,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},cc,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},lc,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},dc,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},vr,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},vr,r)}async callTool(e,r=Qr,s){if(this.isToolTaskRequired(e.name))throw new O(N.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let n=await this.request({method:"tools/call",params:e},r,s),o=this.getToolOutputValidator(e.name);if(o){if(!n.structuredContent&&!n.isError)throw new O(N.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(n.structuredContent)try{let i=o(n.structuredContent);if(!i.valid)throw new O(N.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof O?i:new O(N.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return n}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 n=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,n)}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},vc,r);return this.cacheToolMetadata(s.tools),s}_setupListChangedHandler(e,r,s,n){let o=Xh.safeParse(s);if(!o.success)throw new Error(`Invalid ${e} listChanged options: ${o.error.message}`);if(typeof s.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:a}=o.data,{onChanged:c}=s,l=async()=>{if(!i){c(null,null);return}try{let d=await n();c(null,d)}catch(d){let h=d instanceof Error?d:new Error(String(d));c(h,null)}},u=()=>{if(a){let d=this._listChangedDebounceTimers.get(e);d&&clearTimeout(d);let h=setTimeout(l,a);this._listChangedDebounceTimers.set(e,h)}else l()};this.setNotificationHandler(r,u)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var On=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}},og=10,bP=13,Ir=32;function Cu(t){}function Ni(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=Cu,onError:r=Cu,onRetry:s=Cu,onComment:n,maxBufferSize:o}=t,i=[],a=0,c=!0,l,u="",d=0,h,p=!1;function m(_){if(p)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,_.charCodeAt(0)===239&&_.charCodeAt(1)===187&&_.charCodeAt(2)===191&&(_=_.slice(3))),i.length===0){let D=g(_);D!==""&&(i.push(D),a=D.length),f();return}if(_.indexOf(`
11
+ deps: ${r}}`};var HE={keyword:"dependencies",type:"object",schemaType:"object",error:Ct.error,code(t){let[e,r]=GE(t);um(t,e),dm(t,r)}};function GE({schema:t}){let e={},r={};for(let s in t){if(s==="__proto__")continue;let n=Array.isArray(t[s])?e:r;n[s]=t[s]}return[e,r]}function um(t,e=t.schema){let{gen:r,data:s,it:n}=t;if(Object.keys(e).length===0)return;let o=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,Mn.propertyInData)(r,s,i,n.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),n.allErrors?r.if(c,()=>{for(let l of a)(0,Mn.checkReportMissingProp)(t,l)}):(r.if((0,tu._)`${c} && (${(0,Mn.checkMissingProp)(t,a,o)})`),(0,Mn.reportMissingProp)(t,o),r.else())}}Ct.validatePropertyDeps=um;function dm(t,e=t.schema){let{gen:r,data:s,keyword:n,it:o}=t,i=r.name("valid");for(let a in e)(0,WE.alwaysValidSchema)(o,e[a])||(r.if((0,Mn.propertyInData)(r,s,a,o.opts.ownProperties),()=>{let c=t.subschema({keyword:n,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}Ct.validateSchemaDeps=dm;Ct.default=HE});var fm=T(ru=>{"use strict";Object.defineProperty(ru,"__esModule",{value:!0});var pm=L(),VE=H(),KE={message:"property name must be valid",params:({params:t})=>(0,pm._)`{propertyName: ${t.propertyName}}`},ZE={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:KE,code(t){let{gen:e,schema:r,data:s,it:n}=t;if((0,VE.alwaysValidSchema)(n,r))return;let o=e.name("valid");e.forIn("key",s,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},o),e.if((0,pm.not)(o),()=>{t.error(!0),n.allErrors||e.break()})}),t.ok(o)}};ru.default=ZE});var nu=T(su=>{"use strict";Object.defineProperty(su,"__esModule",{value:!0});var xi=ot(),wt=L(),YE=Dt(),Ti=H(),JE={message:"must NOT have additional properties",params:({params:t})=>(0,wt._)`{additionalProperty: ${t.additionalProperty}}`},XE={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:JE,code(t){let{gen:e,schema:r,parentSchema:s,data:n,errsCount:o,it:i}=t;if(!o)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,Ti.alwaysValidSchema)(i,r))return;let l=(0,xi.allSchemaProperties)(s.properties),u=(0,xi.allSchemaProperties)(s.patternProperties);d(),t.ok((0,wt._)`${o} === ${YE.default.errors}`);function d(){e.forIn("key",n,g=>{!l.length&&!u.length?m(g):e.if(h(g),()=>m(g))})}function h(g){let w;if(l.length>8){let v=(0,Ti.schemaRefOrVal)(i,s.properties,"properties");w=(0,xi.isOwnProperty)(e,v,g)}else l.length?w=(0,wt.or)(...l.map(v=>(0,wt._)`${g} === ${v}`)):w=wt.nil;return u.length&&(w=(0,wt.or)(w,...u.map(v=>(0,wt._)`${(0,xi.usePattern)(t,v)}.test(${g})`))),(0,wt.not)(w)}function p(g){e.code((0,wt._)`delete ${n}[${g}]`)}function m(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(g);return}if(r===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,Ti.alwaysValidSchema)(i,r)){let w=e.name("valid");c.removeAdditional==="failing"?(f(g,w,!1),e.if((0,wt.not)(w),()=>{t.reset(),p(g)})):(f(g,w),a||e.if((0,wt.not)(w),()=>e.break()))}}function f(g,w,v){let S={keyword:"additionalProperties",dataProp:g,dataPropType:Ti.Type.Str};v===!1&&Object.assign(S,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(S,w)}}};su.default=XE});var ym=T(iu=>{"use strict";Object.defineProperty(iu,"__esModule",{value:!0});var QE=gn(),mm=ot(),ou=H(),gm=nu(),e$={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:s,data:n,it:o}=t;o.opts.removeAdditional==="all"&&s.additionalProperties===void 0&&gm.default.code(new QE.KeywordCxt(o,gm.default,"additionalProperties"));let i=(0,mm.allSchemaProperties)(r);for(let d of i)o.definedProperties.add(d);o.opts.unevaluated&&i.length&&o.props!==!0&&(o.props=ou.mergeEvaluated.props(e,(0,ou.toHash)(i),o.props));let a=i.filter(d=>!(0,ou.alwaysValidSchema)(o,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)l(d)?u(d):(e.if((0,mm.propertyInData)(e,n,d,o.opts.ownProperties)),u(d),o.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function l(d){return o.opts.useDefaults&&!o.compositeRule&&r[d].default!==void 0}function u(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};iu.default=e$});var _m=T(au=>{"use strict";Object.defineProperty(au,"__esModule",{value:!0});var wm=ot(),Ei=L(),bm=H(),vm=H(),t$={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:s,parentSchema:n,it:o}=t,{opts:i}=o,a=(0,wm.allSchemaProperties)(r),c=a.filter(f=>(0,bm.alwaysValidSchema)(o,r[f]));if(a.length===0||c.length===a.length&&(!o.opts.unevaluated||o.props===!0))return;let l=i.strictSchema&&!i.allowMatchingProperties&&n.properties,u=e.name("valid");o.props!==!0&&!(o.props instanceof Ei.Name)&&(o.props=(0,vm.evaluatedPropsToName)(e,o.props));let{props:d}=o;h();function h(){for(let f of a)l&&p(f),o.allErrors?m(f):(e.var(u,!0),m(f),e.if(u))}function p(f){for(let g in l)new RegExp(f).test(g)&&(0,bm.checkStrictMode)(o,`property ${g} matches pattern ${f} (use allowMatchingProperties)`)}function m(f){e.forIn("key",s,g=>{e.if((0,Ei._)`${(0,wm.usePattern)(t,f)}.test(${g})`,()=>{let w=c.includes(f);w||t.subschema({keyword:"patternProperties",schemaProp:f,dataProp:g,dataPropType:vm.Type.Str},u),o.opts.unevaluated&&d!==!0?e.assign((0,Ei._)`${d}[${g}]`,!0):!w&&!o.allErrors&&e.if((0,Ei.not)(u),()=>e.break())})})}}};au.default=t$});var Sm=T(cu=>{"use strict";Object.defineProperty(cu,"__esModule",{value:!0});var r$=H(),s$={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:s}=t;if((0,r$.alwaysValidSchema)(s,r)){t.fail();return}let n=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},n),t.failResult(n,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};cu.default=s$});var km=T(lu=>{"use strict";Object.defineProperty(lu,"__esModule",{value:!0});var n$=ot(),o$={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:n$.validateUnion,error:{message:"must match a schema in anyOf"}};lu.default=o$});var xm=T(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});var $i=L(),i$=H(),a$={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,$i._)`{passingSchemas: ${t.passing}}`},c$={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:a$,code(t){let{gen:e,schema:r,parentSchema:s,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(n.opts.discriminator&&s.discriminator)return;let o=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(l),t.result(i,()=>t.reset(),()=>t.error(!0));function l(){o.forEach((u,d)=>{let h;(0,i$.alwaysValidSchema)(n,u)?e.var(c,!0):h=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,$i._)`${c} && ${i}`).assign(i,!1).assign(a,(0,$i._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),h&&t.mergeEvaluated(h,$i.Name)})})}}};uu.default=c$});var Tm=T(du=>{"use strict";Object.defineProperty(du,"__esModule",{value:!0});var l$=H(),u$={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 n=e.name("valid");r.forEach((o,i)=>{if((0,l$.alwaysValidSchema)(s,o))return;let a=t.subschema({keyword:"allOf",schemaProp:i},n);t.ok(n),t.mergeEvaluated(a)})}};du.default=u$});var Pm=T(hu=>{"use strict";Object.defineProperty(hu,"__esModule",{value:!0});var Pi=L(),$m=H(),d$={message:({params:t})=>(0,Pi.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Pi._)`{failingKeyword: ${t.ifClause}}`},h$={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:d$,code(t){let{gen:e,parentSchema:r,it:s}=t;r.then===void 0&&r.else===void 0&&(0,$m.checkStrictMode)(s,'"if" without "then" and "else" is ignored');let n=Em(s,"then"),o=Em(s,"else");if(!n&&!o)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),n&&o){let u=e.let("ifClause");t.setParams({ifClause:u}),e.if(a,l("then",u),l("else",u))}else n?e.if(a,l("then")):e.if((0,Pi.not)(a),l("else"));t.pass(i,()=>t.error(!0));function c(){let u=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(u)}function l(u,d){return()=>{let h=t.subschema({keyword:u},a);e.assign(i,a),t.mergeValidEvaluated(h,i),d?e.assign(d,(0,Pi._)`${u}`):t.setParams({ifClause:u})}}}};function Em(t,e){let r=t.schema[e];return r!==void 0&&!(0,$m.alwaysValidSchema)(t,r)}hu.default=h$});var Cm=T(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});var p$=H(),f$={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,p$.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};pu.default=f$});var Rm=T(fu=>{"use strict";Object.defineProperty(fu,"__esModule",{value:!0});var m$=Yl(),g$=im(),y$=Jl(),w$=cm(),b$=lm(),v$=hm(),_$=fm(),S$=nu(),k$=ym(),x$=_m(),T$=Sm(),E$=km(),$$=xm(),P$=Tm(),C$=Pm(),R$=Cm();function M$(t=!1){let e=[T$.default,E$.default,$$.default,P$.default,C$.default,R$.default,_$.default,S$.default,v$.default,k$.default,x$.default];return t?e.push(g$.default,w$.default):e.push(m$.default,y$.default),e.push(b$.default),e}fu.default=M$});var Mm=T(mu=>{"use strict";Object.defineProperty(mu,"__esModule",{value:!0});var le=L(),A$={message:({schemaCode:t})=>(0,le.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,le._)`{format: ${t}}`},O$={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:A$,code(t,e){let{gen:r,data:s,$data:n,schema:o,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=a;if(!c.validateFormats)return;n?h():p();function h(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),f=r.const("fDef",(0,le._)`${m}[${i}]`),g=r.let("fType"),w=r.let("format");r.if((0,le._)`typeof ${f} == "object" && !(${f} instanceof RegExp)`,()=>r.assign(g,(0,le._)`${f}.type || "string"`).assign(w,(0,le._)`${f}.validate`),()=>r.assign(g,(0,le._)`"string"`).assign(w,f)),t.fail$data((0,le.or)(v(),S()));function v(){return c.strictSchema===!1?le.nil:(0,le._)`${i} && !${w}`}function S(){let x=u.$async?(0,le._)`(${f}.async ? await ${w}(${s}) : ${w}(${s}))`:(0,le._)`${w}(${s})`,_=(0,le._)`(typeof ${w} == "function" ? ${x} : ${w}.test(${s}))`;return(0,le._)`${w} && ${w} !== true && ${g} === ${e} && !${_}`}}function p(){let m=d.formats[o];if(!m){v();return}if(m===!0)return;let[f,g,w]=S(m);f===e&&t.pass(x());function v(){if(c.strictSchema===!1){d.logger.warn(_());return}throw new Error(_());function _(){return`unknown format "${o}" ignored in schema at path "${l}"`}}function S(_){let k=_ instanceof RegExp?(0,le.regexpCode)(_):c.code.formats?(0,le._)`${c.code.formats}${(0,le.getProperty)(o)}`:void 0,C=r.scopeValue("formats",{key:o,ref:_,code:k});return typeof _=="object"&&!(_ instanceof RegExp)?[_.type||"string",_.validate,(0,le._)`${C}.validate`]:["string",_,C]}function x(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!u.$async)throw new Error("async format in sync schema");return(0,le._)`await ${w}(${s})`}return typeof g=="function"?(0,le._)`${w}(${s})`:(0,le._)`${w}.test(${s})`}}}};mu.default=O$});var Am=T(gu=>{"use strict";Object.defineProperty(gu,"__esModule",{value:!0});var I$=Mm(),z$=[I$.default];gu.default=z$});var Om=T(ds=>{"use strict";Object.defineProperty(ds,"__esModule",{value:!0});ds.contentVocabulary=ds.metadataVocabulary=void 0;ds.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];ds.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var zm=T(yu=>{"use strict";Object.defineProperty(yu,"__esModule",{value:!0});var N$=Uf(),j$=rm(),D$=Rm(),q$=Am(),Im=Om(),L$=[N$.default,j$.default,(0,D$.default)(),q$.default,Im.metadataVocabulary,Im.contentVocabulary];yu.default=L$});var jm=T(Ci=>{"use strict";Object.defineProperty(Ci,"__esModule",{value:!0});Ci.DiscrError=void 0;var Nm;(function(t){t.Tag="tag",t.Mapping="mapping"})(Nm||(Ci.DiscrError=Nm={}))});var qm=T(bu=>{"use strict";Object.defineProperty(bu,"__esModule",{value:!0});var hs=L(),wu=jm(),Dm=ui(),F$=yn(),U$=H(),B$={message:({params:{discrError:t,tagName:e}})=>t===wu.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,hs._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},W$={keyword:"discriminator",type:"object",schemaType:"object",error:B$,code(t){let{gen:e,data:r,schema:s,parentSchema:n,it:o}=t,{oneOf:i}=n;if(!o.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),l=e.const("tag",(0,hs._)`${r}${(0,hs.getProperty)(a)}`);e.if((0,hs._)`typeof ${l} == "string"`,()=>u(),()=>t.error(!1,{discrError:wu.DiscrError.Tag,tag:l,tagName:a})),t.ok(c);function u(){let p=h();e.if(!1);for(let m in p)e.elseIf((0,hs._)`${l} === ${m}`),e.assign(c,d(p[m]));e.else(),t.error(!1,{discrError:wu.DiscrError.Mapping,tag:l,tagName:a}),e.endIf()}function d(p){let m=e.name("valid"),f=t.subschema({keyword:"oneOf",schemaProp:p},m);return t.mergeEvaluated(f,hs.Name),m}function h(){var p;let m={},f=w(n),g=!0;for(let x=0;x<i.length;x++){let _=i[x];if(_?.$ref&&!(0,U$.schemaHasRulesButRef)(_,o.self.RULES)){let C=_.$ref;if(_=Dm.resolveRef.call(o.self,o.schemaEnv.root,o.baseId,C),_ instanceof Dm.SchemaEnv&&(_=_.schema),_===void 0)throw new F$.default(o.opts.uriResolver,o.baseId,C)}let k=(p=_?.properties)===null||p===void 0?void 0:p[a];if(typeof k!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(f||w(_)),v(k,x)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return m;function w({required:x}){return Array.isArray(x)&&x.includes(a)}function v(x,_){if(x.const)S(x.const,_);else if(x.enum)for(let k of x.enum)S(k,_);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function S(x,_){if(typeof x!="string"||x in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[x]=_}}}};bu.default=W$});var Lm=T((uF,H$)=>{H$.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 _u=T((re,vu)=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.MissingRefError=re.ValidationError=re.CodeGen=re.Name=re.nil=re.stringify=re.str=re._=re.KeywordCxt=re.Ajv=void 0;var G$=Nf(),V$=zm(),K$=qm(),Fm=Lm(),Z$=["/properties"],Ri="http://json-schema.org/draft-07/schema",ps=class extends G$.default{_addVocabularies(){super._addVocabularies(),V$.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(K$.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(Fm,Z$):Fm;this.addMetaSchema(e,Ri,!1),this.refs["http://json-schema.org/schema"]=Ri}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Ri)?Ri:void 0)}};re.Ajv=ps;vu.exports=re=ps;vu.exports.Ajv=ps;Object.defineProperty(re,"__esModule",{value:!0});re.default=ps;var Y$=gn();Object.defineProperty(re,"KeywordCxt",{enumerable:!0,get:function(){return Y$.KeywordCxt}});var fs=L();Object.defineProperty(re,"_",{enumerable:!0,get:function(){return fs._}});Object.defineProperty(re,"str",{enumerable:!0,get:function(){return fs.str}});Object.defineProperty(re,"stringify",{enumerable:!0,get:function(){return fs.stringify}});Object.defineProperty(re,"nil",{enumerable:!0,get:function(){return fs.nil}});Object.defineProperty(re,"Name",{enumerable:!0,get:function(){return fs.Name}});Object.defineProperty(re,"CodeGen",{enumerable:!0,get:function(){return fs.CodeGen}});var J$=ci();Object.defineProperty(re,"ValidationError",{enumerable:!0,get:function(){return J$.default}});var X$=yn();Object.defineProperty(re,"MissingRefError",{enumerable:!0,get:function(){return X$.default}})});var Zm=T(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.formatNames=Mt.fastFormats=Mt.fullFormats=void 0;function Rt(t,e){return{validate:t,compare:e}}Mt.fullFormats={date:Rt(Hm,Tu),time:Rt(ku(!0),Eu),"date-time":Rt(Um(!0),Vm),"iso-time":Rt(ku(),Gm),"iso-date-time":Rt(Um(),Km),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:nP,"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:dP,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:oP,int32:{type:"number",validate:cP},int64:{type:"number",validate:lP},float:{type:"number",validate:Wm},double:{type:"number",validate:Wm},password:!0,binary:!0};Mt.fastFormats={...Mt.fullFormats,date:Rt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Tu),time:Rt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Eu),"date-time":Rt(/^\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,Vm),"iso-time":Rt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Gm),"iso-date-time":Rt(/^\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,Km),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};Mt.formatNames=Object.keys(Mt.fullFormats);function Q$(t){return t%4===0&&(t%100!==0||t%400===0)}var eP=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,tP=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Hm(t){let e=eP.exec(t);if(!e)return!1;let r=+e[1],s=+e[2],n=+e[3];return s>=1&&s<=12&&n>=1&&n<=(s===2&&Q$(r)?29:tP[s])}function Tu(t,e){if(t&&e)return t>e?1:t<e?-1:0}var Su=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function ku(t){return function(r){let s=Su.exec(r);if(!s)return!1;let n=+s[1],o=+s[2],i=+s[3],a=s[4],c=s[5]==="-"?-1:1,l=+(s[6]||0),u=+(s[7]||0);if(l>23||u>59||t&&!a)return!1;if(n<=23&&o<=59&&i<60)return!0;let d=o-u*c,h=n-l*c-(d<0?1:0);return(h===23||h===-1)&&(d===59||d===-1)&&i<61}}function Eu(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 Gm(t,e){if(!(t&&e))return;let r=Su.exec(t),s=Su.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 xu=/t|\s/i;function Um(t){let e=ku(t);return function(s){let n=s.split(xu);return n.length===2&&Hm(n[0])&&e(n[1])}}function Vm(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),s=new Date(e).valueOf();if(r&&s)return r-s}function Km(t,e){if(!(t&&e))return;let[r,s]=t.split(xu),[n,o]=e.split(xu),i=Tu(r,n);if(i!==void 0)return i||Eu(s,o)}var rP=/\/|:/,sP=/^(?:[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 nP(t){return rP.test(t)&&sP.test(t)}var Bm=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function oP(t){return Bm.lastIndex=0,Bm.test(t)}var iP=-(2**31),aP=2**31-1;function cP(t){return Number.isInteger(t)&&t<=aP&&t>=iP}function lP(t){return Number.isInteger(t)}function Wm(){return!0}var uP=/[^\\]\\Z/;function dP(t){if(uP.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var Ym=T(ms=>{"use strict";Object.defineProperty(ms,"__esModule",{value:!0});ms.formatLimitDefinition=void 0;var hP=_u(),bt=L(),ar=bt.operators,Mi={formatMaximum:{okStr:"<=",ok:ar.LTE,fail:ar.GT},formatMinimum:{okStr:">=",ok:ar.GTE,fail:ar.LT},formatExclusiveMaximum:{okStr:"<",ok:ar.LT,fail:ar.GTE},formatExclusiveMinimum:{okStr:">",ok:ar.GT,fail:ar.LTE}},pP={message:({keyword:t,schemaCode:e})=>(0,bt.str)`should be ${Mi[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,bt._)`{comparison: ${Mi[t].okStr}, limit: ${e}}`};ms.formatLimitDefinition={keyword:Object.keys(Mi),type:"string",schemaType:"string",$data:!0,error:pP,code(t){let{gen:e,data:r,schemaCode:s,keyword:n,it:o}=t,{opts:i,self:a}=o;if(!i.validateFormats)return;let c=new hP.KeywordCxt(o,a.RULES.all.format.definition,"format");c.$data?l():u();function l(){let h=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),p=e.const("fmt",(0,bt._)`${h}[${c.schemaCode}]`);t.fail$data((0,bt.or)((0,bt._)`typeof ${p} != "object"`,(0,bt._)`${p} instanceof RegExp`,(0,bt._)`typeof ${p}.compare != "function"`,d(p)))}function u(){let h=c.schema,p=a.formats[h];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${n}": format "${h}" does not define "compare" function`);let m=e.scopeValue("formats",{key:h,ref:p,code:i.code.formats?(0,bt._)`${i.code.formats}${(0,bt.getProperty)(h)}`:void 0});t.fail$data(d(m))}function d(h){return(0,bt._)`${h}.compare(${r}, ${s}) ${Mi[n].fail} 0`}},dependencies:["format"]};var fP=t=>(t.addKeyword(ms.formatLimitDefinition),t);ms.default=fP});var eg=T((An,Qm)=>{"use strict";Object.defineProperty(An,"__esModule",{value:!0});var gs=Zm(),mP=Ym(),$u=L(),Jm=new $u.Name("fullFormats"),gP=new $u.Name("fastFormats"),Pu=(t,e={keywords:!0})=>{if(Array.isArray(e))return Xm(t,e,gs.fullFormats,Jm),t;let[r,s]=e.mode==="fast"?[gs.fastFormats,gP]:[gs.fullFormats,Jm],n=e.formats||gs.formatNames;return Xm(t,n,r,s),e.keywords&&(0,mP.default)(t),t};Pu.get=(t,e="full")=>{let s=(e==="fast"?gs.fastFormats:gs.fullFormats)[t];if(!s)throw new Error(`Unknown format "${t}"`);return s};function Xm(t,e,r,s){var n,o;(n=(o=t.opts.code).formats)!==null&&n!==void 0||(o.formats=(0,$u._)`require("ajv-formats/dist/formats").${s}`);for(let i of e)t.addFormat(i,r[i])}Qm.exports=An=Pu;Object.defineProperty(An,"__esModule",{value:!0});An.default=Pu});var Cg=T((GF,Pg)=>{"use strict";Pg.exports=$g;$g.sync=KP;var Tg=Zt("fs");function VP(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 n=r[s].toLowerCase();if(n&&t.substr(-n.length).toLowerCase()===n)return!0}return!1}function Eg(t,e,r){return!t.isSymbolicLink()&&!t.isFile()?!1:VP(e,r)}function $g(t,e,r){Tg.stat(t,function(s,n){r(s,s?!1:Eg(n,t,e))})}function KP(t,e){return Eg(Tg.statSync(t),t,e)}});var Ig=T((VF,Og)=>{"use strict";Og.exports=Mg;Mg.sync=ZP;var Rg=Zt("fs");function Mg(t,e,r){Rg.stat(t,function(s,n){r(s,s?!1:Ag(n,e))})}function ZP(t,e){return Ag(Rg.statSync(t),e)}function Ag(t,e){return t.isFile()&&YP(t,e)}function YP(t,e){var r=t.mode,s=t.uid,n=t.gid,o=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),l=parseInt("001",8),u=a|c,d=r&l||r&c&&n===i||r&a&&s===o||r&u&&o===0;return d}});var Ng=T((ZF,zg)=>{"use strict";var KF=Zt("fs"),Ui;process.platform==="win32"||global.TESTING_WINDOWS?Ui=Cg():Ui=Ig();zg.exports=Ku;Ku.sync=JP;function Ku(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,n){Ku(t,e||{},function(o,i){o?n(o):s(i)})})}Ui(t,e||{},function(s,n){s&&(s.code==="EACCES"||e&&e.ignoreErrors)&&(s=null,n=!1),r(s,n)})}function JP(t,e){try{return Ui.sync(t,e||{})}catch(r){if(e&&e.ignoreErrors||r.code==="EACCES")return!1;throw r}}});var Bg=T((YF,Ug)=>{"use strict";var xs=process.platform==="win32"||process.env.OSTYPE==="cygwin"||process.env.OSTYPE==="msys",jg=Zt("path"),XP=xs?";":":",Dg=Ng(),qg=t=>Object.assign(new Error(`not found: ${t}`),{code:"ENOENT"}),Lg=(t,e)=>{let r=e.colon||XP,s=t.match(/\//)||xs&&t.match(/\\/)?[""]:[...xs?[process.cwd()]:[],...(e.path||process.env.PATH||"").split(r)],n=xs?e.pathExt||process.env.PATHEXT||".EXE;.CMD;.BAT;.COM":"",o=xs?n.split(r):[""];return xs&&t.indexOf(".")!==-1&&o[0]!==""&&o.unshift(""),{pathEnv:s,pathExt:o,pathExtExe:n}},Fg=(t,e,r)=>{typeof e=="function"&&(r=e,e={}),e||(e={});let{pathEnv:s,pathExt:n,pathExtExe:o}=Lg(t,e),i=[],a=l=>new Promise((u,d)=>{if(l===s.length)return e.all&&i.length?u(i):d(qg(t));let h=s[l],p=/^".*"$/.test(h)?h.slice(1,-1):h,m=jg.join(p,t),f=!p&&/^\.[\\\/]/.test(t)?t.slice(0,2)+m:m;u(c(f,l,0))}),c=(l,u,d)=>new Promise((h,p)=>{if(d===n.length)return h(a(u+1));let m=n[d];Dg(l+m,{pathExt:o},(f,g)=>{if(!f&&g)if(e.all)i.push(l+m);else return h(l+m);return h(c(l,u,d+1))})});return r?a(0).then(l=>r(null,l),r):a(0)},QP=(t,e)=>{e=e||{};let{pathEnv:r,pathExt:s,pathExtExe:n}=Lg(t,e),o=[];for(let i=0;i<r.length;i++){let a=r[i],c=/^".*"$/.test(a)?a.slice(1,-1):a,l=jg.join(c,t),u=!c&&/^\.[\\\/]/.test(t)?t.slice(0,2)+l:l;for(let d=0;d<s.length;d++){let h=u+s[d];try{if(Dg.sync(h,{pathExt:n}))if(e.all)o.push(h);else return h}catch{}}}if(e.all&&o.length)return o;if(e.nothrow)return null;throw qg(t)};Ug.exports=Fg;Fg.sync=QP});var Hg=T((JF,Zu)=>{"use strict";var Wg=(t={})=>{let e=t.env||process.env;return(t.platform||process.platform)!=="win32"?"PATH":Object.keys(e).reverse().find(s=>s.toUpperCase()==="PATH")||"Path"};Zu.exports=Wg;Zu.exports.default=Wg});var Zg=T((XF,Kg)=>{"use strict";var Gg=Zt("path"),eC=Bg(),tC=Hg();function Vg(t,e){let r=t.options.env||process.env,s=process.cwd(),n=t.options.cwd!=null,o=n&&process.chdir!==void 0&&!process.chdir.disabled;if(o)try{process.chdir(t.options.cwd)}catch{}let i;try{i=eC.sync(t.command,{path:r[tC({env:r})],pathExt:e?Gg.delimiter:void 0})}catch{}finally{o&&process.chdir(s)}return i&&(i=Gg.resolve(n?t.options.cwd:"",i)),i}function rC(t){return Vg(t)||Vg(t,!0)}Kg.exports=rC});var Yg=T((QF,Ju)=>{"use strict";var Yu=/([()\][%!^"`<>&|;, *?])/g;function sC(t){return t=t.replace(Yu,"^$1"),t}function nC(t,e){return t=`${t}`,t=t.replace(/(?=(\\+?)?)\1"/g,'$1$1\\"'),t=t.replace(/(?=(\\+?)?)\1$/,"$1$1"),t=`"${t}"`,t=t.replace(Yu,"^$1"),e&&(t=t.replace(Yu,"^$1")),t}Ju.exports.command=sC;Ju.exports.argument=nC});var Xg=T((eU,Jg)=>{"use strict";Jg.exports=/^#!(.*)/});var ey=T((tU,Qg)=>{"use strict";var oC=Xg();Qg.exports=(t="")=>{let e=t.match(oC);if(!e)return null;let[r,s]=e[0].replace(/#! ?/,"").split(" "),n=r.split("/").pop();return n==="env"?s:s?`${n} ${s}`:n}});var ry=T((rU,ty)=>{"use strict";var Xu=Zt("fs"),iC=ey();function aC(t){let r=Buffer.alloc(150),s;try{s=Xu.openSync(t,"r"),Xu.readSync(s,r,0,150,0),Xu.closeSync(s)}catch{}return iC(r.toString())}ty.exports=aC});var iy=T((sU,oy)=>{"use strict";var cC=Zt("path"),sy=Zg(),ny=Yg(),lC=ry(),uC=process.platform==="win32",dC=/\.(?:com|exe)$/i,hC=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function pC(t){t.file=sy(t);let e=t.file&&lC(t.file);return e?(t.args.unshift(t.file),t.command=e,sy(t)):t.file}function fC(t){if(!uC)return t;let e=pC(t),r=!dC.test(e);if(t.options.forceShell||r){let s=hC.test(e);t.command=cC.normalize(t.command),t.command=ny.command(t.command),t.args=t.args.map(o=>ny.argument(o,s));let n=[t.command].concat(t.args).join(" ");t.args=["/d","/s","/c",`"${n}"`],t.command=process.env.comspec||"cmd.exe",t.options.windowsVerbatimArguments=!0}return t}function mC(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:fC(s)}oy.exports=mC});var ly=T((nU,cy)=>{"use strict";var Qu=process.platform==="win32";function ed(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 gC(t,e){if(!Qu)return;let r=t.emit;t.emit=function(s,n){if(s==="exit"){let o=ay(n,e);if(o)return r.call(t,"error",o)}return r.apply(t,arguments)}}function ay(t,e){return Qu&&t===1&&!e.file?ed(e.original,"spawn"):null}function yC(t,e){return Qu&&t===1&&!e.file?ed(e.original,"spawnSync"):null}cy.exports={hookChildProcess:gC,verifyENOENT:ay,verifyENOENTSync:yC,notFoundError:ed}});var hy=T((oU,Ts)=>{"use strict";var uy=Zt("child_process"),td=iy(),rd=ly();function dy(t,e,r){let s=td(t,e,r),n=uy.spawn(s.command,s.args,s.options);return rd.hookChildProcess(n,s),n}function wC(t,e,r){let s=td(t,e,r),n=uy.spawnSync(s.command,s.args,s.options);return n.error=n.error||rd.verifyENOENTSync(n.status,s),n}Ts.exports=dy;Ts.exports.spawn=dy;Ts.exports.sync=wC;Ts.exports._parse=td;Ts.exports._enoent=rd});var wy=T(nd=>{"use strict";var my=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,xC=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,gy=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,TC=/\\([\u000b\u0020-\u00ff])/g,EC=/([\\"])/g,yy=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;nd.format=$C;nd.parse=PC;function $C(t){if(!t||typeof t!="object")throw new TypeError("argument obj is required");var e=t.parameters,r=t.type;if(!r||!yy.test(r))throw new TypeError("invalid type");var s=r;if(e&&typeof e=="object")for(var n,o=Object.keys(e).sort(),i=0;i<o.length;i++){if(n=o[i],!gy.test(n))throw new TypeError("invalid parameter name");s+="; "+n+"="+RC(e[n])}return s}function PC(t){if(!t)throw new TypeError("argument string is required");var e=typeof t=="object"?CC(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(!yy.test(s))throw new TypeError("invalid media type");var n=new MC(s.toLowerCase());if(r!==-1){var o,i,a;for(my.lastIndex=r;i=my.exec(e);){if(i.index!==r)throw new TypeError("invalid parameter format");r+=i[0].length,o=i[1].toLowerCase(),a=i[2],a.charCodeAt(0)===34&&(a=a.slice(1,-1),a.indexOf("\\")!==-1&&(a=a.replace(TC,"$1"))),n.parameters[o]=a}if(r!==e.length)throw new TypeError("invalid parameter format")}return n}function CC(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 RC(t){var e=String(t);if(gy.test(e))return e;if(e.length>0&&!xC.test(e))throw new TypeError("invalid parameter value");return'"'+e.replace(EC,"\\$1")+'"'}function MC(t){this.parameters=Object.create(null),this.type=t}});async function tc(t,e){switch(t.protocol){case"anthropic":{let{AnthropicClient:r}=await import("./anthropic-CEUDAJL2.js");return Mo(new r(t,e),{model:t.model,protocol:t.protocol})}case"openai":{let{OpenAIClient:r}=await import("./openai-AQNX24XU.js");return Mo(new r(t,e),{model:t.model,protocol:t.protocol})}case"openai-compat":{let{OpenAICompatClient:r}=await import("./openai-AQNX24XU.js");return Mo(new r(t,e),{model:t.model,protocol:t.protocol})}default:throw new Error(`Unknown protocol: ${String(t.protocol)}`)}}import{isDeepStrictEqual as jC}from"util";var Jr="2025-11-25";var zh=[Jr,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Jt="io.modelcontextprotocol/related-task",Do="2.0",pe=dh(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Nh=se([b(),V().int()]),jh=b(),uN=he({ttl:V().optional(),pollInterval:V().optional()}),M0=P({ttl:V().optional()}),A0=P({taskId:b()}),sc=he({progressToken:Nh.optional(),[Jt]:A0.optional()}),Xe=P({_meta:sc.optional()}),Vs=Xe.extend({task:M0.optional()}),Dh=t=>Vs.safeParse(t).success,ve=P({method:b(),params:Xe.loose().optional()}),rt=P({_meta:sc.optional()}),st=P({method:b(),params:rt.loose().optional()}),_e=he({_meta:sc.optional()}),qo=se([b(),V().int()]),qh=P({jsonrpc:R(Do),id:qo,...ve.shape}).strict(),Ks=t=>qh.safeParse(t).success,Lh=P({jsonrpc:R(Do),...st.shape}).strict(),Fh=t=>Lh.safeParse(t).success,nc=P({jsonrpc:R(Do),id:qo,result:_e}).strict(),br=t=>nc.safeParse(t).success;var N;(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"})(N||(N={}));var oc=P({jsonrpc:R(Do),id:qo.optional(),error:P({code:V().int(),message:b(),data:ce().optional()})}).strict();var Uh=t=>oc.safeParse(t).success;var Xt=se([qh,Lh,nc,oc]),dN=se([nc,oc]),vr=_e.strict(),O0=rt.extend({requestId:qo.optional(),reason:b().optional()}),Lo=st.extend({method:R("notifications/cancelled"),params:O0}),I0=P({src:b(),mimeType:b().optional(),sizes:E(b()).optional(),theme:Je(["light","dark"]).optional()}),Zs=P({icons:E(I0).optional()}),Yr=P({name:b(),title:b().optional()}),Bh=Yr.extend({...Yr.shape,...Zs.shape,version:b(),websiteUrl:b().optional(),description:b().optional()}),z0=Za(P({applyDefaults:Y().optional()}),ee(b(),ce())),N0=Ya(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,Za(P({form:z0.optional(),url:pe.optional()}),ee(b(),ce()).optional())),j0=he({list:pe.optional(),cancel:pe.optional(),requests:he({sampling:he({createMessage:pe.optional()}).optional(),elicitation:he({create:pe.optional()}).optional()}).optional()}),D0=he({list:pe.optional(),cancel:pe.optional(),requests:he({tools:he({call:pe.optional()}).optional()}).optional()}),q0=P({experimental:ee(b(),pe).optional(),sampling:P({context:pe.optional(),tools:pe.optional()}).optional(),elicitation:N0.optional(),roots:P({listChanged:Y().optional()}).optional(),tasks:j0.optional(),extensions:ee(b(),pe).optional()}),L0=Xe.extend({protocolVersion:b(),capabilities:q0,clientInfo:Bh}),F0=ve.extend({method:R("initialize"),params:L0});var U0=P({experimental:ee(b(),pe).optional(),logging:pe.optional(),completions:pe.optional(),prompts:P({listChanged:Y().optional()}).optional(),resources:P({subscribe:Y().optional(),listChanged:Y().optional()}).optional(),tools:P({listChanged:Y().optional()}).optional(),tasks:D0.optional(),extensions:ee(b(),pe).optional()}),ic=_e.extend({protocolVersion:b(),capabilities:U0,serverInfo:Bh,instructions:b().optional()}),Wh=st.extend({method:R("notifications/initialized"),params:rt.optional()}),Hh=t=>Wh.safeParse(t).success,Fo=ve.extend({method:R("ping"),params:Xe.optional()}),B0=P({progress:V(),total:ae(V()),message:ae(b())}),W0=P({...rt.shape,...B0.shape,progressToken:Nh}),Uo=st.extend({method:R("notifications/progress"),params:W0}),H0=Xe.extend({cursor:jh.optional()}),Ys=ve.extend({params:H0.optional()}),Js=_e.extend({nextCursor:jh.optional()}),G0=Je(["working","input_required","completed","failed","cancelled"]),Xs=P({taskId:b(),status:G0,ttl:se([V(),lh()]),createdAt:b(),lastUpdatedAt:b(),pollInterval:ae(V()),statusMessage:ae(b())}),_r=_e.extend({task:Xs}),V0=rt.merge(Xs),Qs=st.extend({method:R("notifications/tasks/status"),params:V0}),Bo=ve.extend({method:R("tasks/get"),params:Xe.extend({taskId:b()})}),Wo=_e.merge(Xs),Ho=ve.extend({method:R("tasks/result"),params:Xe.extend({taskId:b()})}),hN=_e.loose(),Go=Ys.extend({method:R("tasks/list")}),Vo=Js.extend({tasks:E(Xs)}),Ko=ve.extend({method:R("tasks/cancel"),params:Xe.extend({taskId:b()})}),Gh=_e.merge(Xs),Vh=P({uri:b(),mimeType:ae(b()),_meta:ee(b(),ce()).optional()}),Kh=Vh.extend({text:b()}),ac=b().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Zh=Vh.extend({blob:ac}),en=Je(["user","assistant"]),Xr=P({audience:E(en).optional(),priority:V().min(0).max(1).optional(),lastModified:ph.datetime({offset:!0}).optional()}),Yh=P({...Yr.shape,...Zs.shape,uri:b(),description:ae(b()),mimeType:ae(b()),size:ae(V()),annotations:Xr.optional(),_meta:ae(he({}))}),K0=P({...Yr.shape,...Zs.shape,uriTemplate:b(),description:ae(b()),mimeType:ae(b()),annotations:Xr.optional(),_meta:ae(he({}))}),Z0=Ys.extend({method:R("resources/list")}),cc=Js.extend({resources:E(Yh)}),Y0=Ys.extend({method:R("resources/templates/list")}),lc=Js.extend({resourceTemplates:E(K0)}),uc=Xe.extend({uri:b()}),J0=uc,X0=ve.extend({method:R("resources/read"),params:J0}),dc=_e.extend({contents:E(se([Kh,Zh]))}),hc=st.extend({method:R("notifications/resources/list_changed"),params:rt.optional()}),Q0=uc,e_=ve.extend({method:R("resources/subscribe"),params:Q0}),t_=uc,r_=ve.extend({method:R("resources/unsubscribe"),params:t_}),s_=rt.extend({uri:b()}),n_=st.extend({method:R("notifications/resources/updated"),params:s_}),o_=P({name:b(),description:ae(b()),required:ae(Y())}),i_=P({...Yr.shape,...Zs.shape,description:ae(b()),arguments:ae(E(o_)),_meta:ae(he({}))}),a_=Ys.extend({method:R("prompts/list")}),pc=Js.extend({prompts:E(i_)}),c_=Xe.extend({name:b(),arguments:ee(b(),b()).optional()}),l_=ve.extend({method:R("prompts/get"),params:c_}),fc=P({type:R("text"),text:b(),annotations:Xr.optional(),_meta:ee(b(),ce()).optional()}),mc=P({type:R("image"),data:ac,mimeType:b(),annotations:Xr.optional(),_meta:ee(b(),ce()).optional()}),gc=P({type:R("audio"),data:ac,mimeType:b(),annotations:Xr.optional(),_meta:ee(b(),ce()).optional()}),u_=P({type:R("tool_use"),name:b(),id:b(),input:ee(b(),ce()),_meta:ee(b(),ce()).optional()}),d_=P({type:R("resource"),resource:se([Kh,Zh]),annotations:Xr.optional(),_meta:ee(b(),ce()).optional()}),h_=Yh.extend({type:R("resource_link")}),yc=se([fc,mc,gc,h_,d_]),p_=P({role:en,content:yc}),wc=_e.extend({description:b().optional(),messages:E(p_)}),bc=st.extend({method:R("notifications/prompts/list_changed"),params:rt.optional()}),f_=P({title:b().optional(),readOnlyHint:Y().optional(),destructiveHint:Y().optional(),idempotentHint:Y().optional(),openWorldHint:Y().optional()}),m_=P({taskSupport:Je(["required","optional","forbidden"]).optional()}),Jh=P({...Yr.shape,...Zs.shape,description:b().optional(),inputSchema:P({type:R("object"),properties:ee(b(),pe).optional(),required:E(b()).optional()}).catchall(ce()),outputSchema:P({type:R("object"),properties:ee(b(),pe).optional(),required:E(b()).optional()}).catchall(ce()).optional(),annotations:f_.optional(),execution:m_.optional(),_meta:ee(b(),ce()).optional()}),g_=Ys.extend({method:R("tools/list")}),vc=Js.extend({tools:E(Jh)}),Qr=_e.extend({content:E(yc).default([]),structuredContent:ee(b(),ce()).optional(),isError:Y().optional()}),pN=Qr.or(_e.extend({toolResult:ce()})),y_=Vs.extend({name:b(),arguments:ee(b(),ce()).optional()}),w_=ve.extend({method:R("tools/call"),params:y_}),_c=st.extend({method:R("notifications/tools/list_changed"),params:rt.optional()}),Xh=P({autoRefresh:Y().default(!0),debounceMs:V().int().nonnegative().default(300)}),Qh=Je(["debug","info","notice","warning","error","critical","alert","emergency"]),b_=Xe.extend({level:Qh}),v_=ve.extend({method:R("logging/setLevel"),params:b_}),__=rt.extend({level:Qh,logger:b().optional(),data:ce()}),S_=st.extend({method:R("notifications/message"),params:__}),k_=P({name:b().optional()}),x_=P({hints:E(k_).optional(),costPriority:V().min(0).max(1).optional(),speedPriority:V().min(0).max(1).optional(),intelligencePriority:V().min(0).max(1).optional()}),T_=P({mode:Je(["auto","required","none"]).optional()}),E_=P({type:R("tool_result"),toolUseId:b().describe("The unique identifier for the corresponding tool call."),content:E(yc).default([]),structuredContent:P({}).loose().optional(),isError:Y().optional(),_meta:ee(b(),ce()).optional()}),$_=Ka("type",[fc,mc,gc]),jo=Ka("type",[fc,mc,gc,u_,E_]),P_=P({role:en,content:se([jo,E(jo)]),_meta:ee(b(),ce()).optional()}),C_=Vs.extend({messages:E(P_),modelPreferences:x_.optional(),systemPrompt:b().optional(),includeContext:Je(["none","thisServer","allServers"]).optional(),temperature:V().optional(),maxTokens:V().int(),stopSequences:E(b()).optional(),metadata:pe.optional(),tools:E(Jh).optional(),toolChoice:T_.optional()}),Sc=ve.extend({method:R("sampling/createMessage"),params:C_}),kc=_e.extend({model:b(),stopReason:ae(Je(["endTurn","stopSequence","maxTokens"]).or(b())),role:en,content:$_}),xc=_e.extend({model:b(),stopReason:ae(Je(["endTurn","stopSequence","maxTokens","toolUse"]).or(b())),role:en,content:se([jo,E(jo)])}),R_=P({type:R("boolean"),title:b().optional(),description:b().optional(),default:Y().optional()}),M_=P({type:R("string"),title:b().optional(),description:b().optional(),minLength:V().optional(),maxLength:V().optional(),format:Je(["email","uri","date","date-time"]).optional(),default:b().optional()}),A_=P({type:Je(["number","integer"]),title:b().optional(),description:b().optional(),minimum:V().optional(),maximum:V().optional(),default:V().optional()}),O_=P({type:R("string"),title:b().optional(),description:b().optional(),enum:E(b()),default:b().optional()}),I_=P({type:R("string"),title:b().optional(),description:b().optional(),oneOf:E(P({const:b(),title:b()})),default:b().optional()}),z_=P({type:R("string"),title:b().optional(),description:b().optional(),enum:E(b()),enumNames:E(b()).optional(),default:b().optional()}),N_=se([O_,I_]),j_=P({type:R("array"),title:b().optional(),description:b().optional(),minItems:V().optional(),maxItems:V().optional(),items:P({type:R("string"),enum:E(b())}),default:E(b()).optional()}),D_=P({type:R("array"),title:b().optional(),description:b().optional(),minItems:V().optional(),maxItems:V().optional(),items:P({anyOf:E(P({const:b(),title:b()}))}),default:E(b()).optional()}),q_=se([j_,D_]),L_=se([z_,N_,q_]),F_=se([L_,R_,M_,A_]),U_=Vs.extend({mode:R("form").optional(),message:b(),requestedSchema:P({type:R("object"),properties:ee(b(),F_),required:E(b()).optional()})}),B_=Vs.extend({mode:R("url"),message:b(),elicitationId:b(),url:b().url()}),W_=se([U_,B_]),Tc=ve.extend({method:R("elicitation/create"),params:W_}),H_=rt.extend({elicitationId:b()}),G_=st.extend({method:R("notifications/elicitation/complete"),params:H_}),Ec=_e.extend({action:Je(["accept","decline","cancel"]),content:Ya(t=>t===null?void 0:t,ee(b(),se([b(),V(),Y(),E(b())])).optional())}),V_=P({type:R("ref/resource"),uri:b()});var K_=P({type:R("ref/prompt"),name:b()}),Z_=Xe.extend({ref:se([K_,V_]),argument:P({name:b(),value:b()}),context:P({arguments:ee(b(),b()).optional()}).optional()}),Y_=ve.extend({method:R("completion/complete"),params:Z_});var $c=_e.extend({completion:he({values:E(b()).max(100),total:ae(V().int()),hasMore:ae(Y())})}),J_=P({uri:b().startsWith("file://"),name:b().optional(),_meta:ee(b(),ce()).optional()}),X_=ve.extend({method:R("roots/list"),params:Xe.optional()}),Q_=_e.extend({roots:E(J_)}),eS=st.extend({method:R("notifications/roots/list_changed"),params:rt.optional()}),fN=se([Fo,F0,Y_,v_,l_,a_,Z0,Y0,X0,e_,r_,w_,g_,Bo,Ho,Go,Ko]),mN=se([Lo,Uo,Wh,eS,Qs]),gN=se([vr,kc,xc,Ec,Q_,Wo,Vo,_r]),yN=se([Fo,Sc,Tc,X_,Bo,Ho,Go,Ko]),wN=se([Lo,Uo,S_,n_,hc,_c,bc,Qs,G_]),bN=se([vr,ic,$c,wc,pc,cc,lc,dc,Qr,vc,Wo,Vo,_r]),O=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===N.UrlElicitationRequired&&s){let n=s;if(n.elicitations)return new rc(n.elicitations,r)}return new t(e,r,s)}},rc=class extends O{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(N.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function Qt(t){return t==="completed"||t==="failed"||t==="cancelled"}var XN=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Pc(t){let r=Eo(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let s=$o(r);if(typeof s!="string")throw new Error("Schema method literal must be a string");return s}function Cc(t,e){let r=ft(t,e);if(!r.success)throw r.error;return r.data}var iS=6e4,Zo=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(Lo,r=>{this._oncancel(r)}),this.setNotificationHandler(Uo,r=>{this._onprogress(r)}),this.setRequestHandler(Fo,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Bo,async(r,s)=>{let n=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!n)throw new O(N.InvalidParams,"Failed to retrieve task: Task not found");return{...n}}),this.setRequestHandler(Ho,async(r,s)=>{let n=async()=>{let o=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,s.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,l=c.id,u=this._requestResolvers.get(l);if(u)if(this._requestResolvers.delete(l),a.type==="response")u(c);else{let d=c,h=new O(d.error.code,d.error.message,d.error.data);u(h)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${l}`))}continue}await this._transport?.send(a.message,{relatedRequestId:s.requestId})}}let i=await this._taskStore.getTask(o,s.sessionId);if(!i)throw new O(N.InvalidParams,`Task not found: ${o}`);if(!Qt(i.status))return await this._waitForTaskUpdate(o,s.signal),await n();if(Qt(i.status)){let a=await this._taskStore.getTaskResult(o,s.sessionId);return this._clearTaskQueue(o),{...a,_meta:{...a._meta,[Jt]:{taskId:o}}}}return await n()};return await n()}),this.setRequestHandler(Go,async(r,s)=>{try{let{tasks:n,nextCursor:o}=await this._taskStore.listTasks(r.params?.cursor,s.sessionId);return{tasks:n,nextCursor:o,_meta:{}}}catch(n){throw new O(N.InvalidParams,`Failed to list tasks: ${n instanceof Error?n.message:String(n)}`)}}),this.setRequestHandler(Ko,async(r,s)=>{try{let n=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!n)throw new O(N.InvalidParams,`Task not found: ${r.params.taskId}`);if(Qt(n.status))throw new O(N.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",s.sessionId),this._clearTaskQueue(r.params.taskId);let o=await this._taskStore.getTask(r.params.taskId,s.sessionId);if(!o)throw new O(N.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...o}}catch(n){throw n instanceof O?n:new O(N.InvalidRequest,`Failed to cancel task: ${n instanceof Error?n.message:String(n)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,s,n,o=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(n,r),startTime:Date.now(),timeout:r,maxTotalTimeout:s,resetTimeoutOnProgress:o,onTimeout:n})}_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),O.fromError(N.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=o=>{s?.(o),this._onerror(o)};let n=this._transport?.onmessage;this._transport.onmessage=(o,i)=>{n?.(o,i),br(o)||Uh(o)?this._onresponse(o):Ks(o)?this._onrequest(o,i):Fh(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},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=O.fromError(N.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,n=this._transport,o=e.params?._meta?.[Jt]?.taskId;if(s===void 0){let u={jsonrpc:"2.0",id:e.id,error:{code:N.MethodNotFound,message:"Method not found"}};o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:u,timestamp:Date.now()},n?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):n?.send(u).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=Dh(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,n?.sessionId):void 0,l={signal:i.signal,sessionId:n?.sessionId,_meta:e.params?._meta,sendNotification:async u=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};o&&(d.relatedTask={taskId:o}),await this.notification(u,d)},sendRequest:async(u,d,h)=>{if(i.signal.aborted)throw new O(N.ConnectionClosed,"Request was cancelled");let p={...h,relatedRequestId:e.id};o&&!p.relatedTask&&(p.relatedTask={taskId:o});let m=p.relatedTask?.taskId??o;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(u,d,p)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:o,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>s(e,l)).then(async u=>{if(i.signal.aborted)return;let d={result:u,jsonrpc:"2.0",id:e.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:d,timestamp:Date.now()},n?.sessionId):await n?.send(d)},async u=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(u.code)?u.code:N.InternalError,message:u.message??"Internal error",...u.data!==void 0&&{data:u.data}}};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"error",message:d,timestamp:Date.now()},n?.sessionId):await n?.send(d)}).catch(u=>this._onerror(new Error(`Failed to send response: ${u}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...s}=e.params,n=Number(r),o=this._progressHandlers.get(n);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(n),a=this._timeoutInfo.get(n);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(n)}catch(c){this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),i(c);return}o(s)}_onresponse(e){let r=Number(e.id),s=this._requestResolvers.get(r);if(s){if(this._requestResolvers.delete(r),br(e))s(e);else{let i=new O(e.error.code,e.error.message,e.error.data);s(i)}return}let n=this._responseHandlers.get(r);if(n===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 o=!1;if(br(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"&&(o=!0,this._taskProgressTokens.set(a.taskId,r))}}if(o||this._progressHandlers.delete(r),br(e))n(e);else{let i=O.fromError(e.error.code,e.error.message,e.error.data);n(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,s){let{task:n}=s??{};if(!n){try{yield{type:"result",result:await this.request(e,r,s)}}catch(i){yield{type:"error",error:i instanceof O?i:new O(N.InternalError,String(i))}}return}let o;try{let i=await this.request(e,_r,s);if(i.task)o=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new O(N.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:o},s);if(yield{type:"taskStatus",task:a},Qt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},r,s)}:a.status==="failed"?yield{type:"error",error:new O(N.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new O(N.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},r,s)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(l=>setTimeout(l,c)),s?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof O?i:new O(N.InternalError,String(i))}}}request(e,r,s){let{relatedRequestId:n,resumptionToken:o,onresumptiontoken:i,task:a,relatedTask:c}=s??{};return new Promise((l,u)=>{let d=v=>{u(v)};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(v){d(v);return}s?.signal?.throwIfAborted();let h=this._requestMessageId++,p={...e,jsonrpc:"2.0",id:h};s?.onprogress&&(this._progressHandlers.set(h,s.onprogress),p.params={...e.params,_meta:{...e.params?._meta||{},progressToken:h}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[Jt]:c}});let m=v=>{this._responseHandlers.delete(h),this._progressHandlers.delete(h),this._cleanupTimeout(h),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:h,reason:String(v)}},{relatedRequestId:n,resumptionToken:o,onresumptiontoken:i}).catch(x=>this._onerror(new Error(`Failed to send cancellation: ${x}`)));let S=v instanceof O?v:new O(N.RequestTimeout,String(v));u(S)};this._responseHandlers.set(h,v=>{if(!s?.signal?.aborted){if(v instanceof Error)return u(v);try{let S=ft(r,v.result);S.success?l(S.data):u(S.error)}catch(S){u(S)}}}),s?.signal?.addEventListener("abort",()=>{m(s?.signal?.reason)});let f=s?.timeout??iS,g=()=>m(O.fromError(N.RequestTimeout,"Request timed out",{timeout:f}));this._setupTimeout(h,f,s?.maxTotalTimeout,g,s?.resetTimeoutOnProgress??!1);let w=c?.taskId;if(w){let v=S=>{let x=this._responseHandlers.get(h);x?x(S):this._onerror(new Error(`Response handler missing for side-channeled request ${h}`))};this._requestResolvers.set(h,v),this._enqueueTaskMessage(w,{type:"request",message:p,timestamp:Date.now()}).catch(S=>{this._cleanupTimeout(h),u(S)})}else this._transport.send(p,{relatedRequestId:n,resumptionToken:o,onresumptiontoken:i}).catch(v=>{this._cleanupTimeout(h),u(v)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Wo,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},Vo,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},Gh,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||{},[Jt]: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||{},[Jt]: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||{},[Jt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let s=Pc(e);this.assertRequestHandlerCapability(s),this._requestHandlers.set(s,(n,o)=>{let i=Cc(e,n);return Promise.resolve(r(i,o))})}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=Pc(e);this._notificationHandlers.set(s,n=>{let o=Cc(e,n);return Promise.resolve(r(o))})}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 n=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,s,n)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let s=await this._taskMessageQueue.dequeueAll(e,r);for(let n of s)if(n.type==="request"&&Ks(n.message)){let o=n.message.id,i=this._requestResolvers.get(o);i?(i(new O(N.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let s=this._options?.defaultTaskPollInterval??1e3;try{let n=await this._taskStore?.getTask(e);n?.pollInterval&&(s=n.pollInterval)}catch{}return new Promise((n,o)=>{if(r.aborted){o(new O(N.InvalidRequest,"Request cancelled"));return}let i=setTimeout(n,s);r.addEventListener("abort",()=>{clearTimeout(i),o(new O(N.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let s=this._taskStore;if(!s)throw new Error("No task store configured");return{createTask:async n=>{if(!e)throw new Error("No request provided");return await s.createTask(n,e.id,{method:e.method,params:e.params},r)},getTask:async n=>{let o=await s.getTask(n,r);if(!o)throw new O(N.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(n,o,i)=>{await s.storeTaskResult(n,o,i,r);let a=await s.getTask(n,r);if(a){let c=Qs.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Qt(a.status)&&this._cleanupTaskProgressHandler(n)}},getTaskResult:n=>s.getTaskResult(n,r),updateTaskStatus:async(n,o,i)=>{let a=await s.getTask(n,r);if(!a)throw new O(N.InvalidParams,`Task "${n}" not found - it may have been cleaned up`);if(Qt(a.status))throw new O(N.InvalidParams,`Cannot update task "${n}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await s.updateTaskStatus(n,o,i,r);let c=await s.getTask(n,r);if(c){let l=Qs.parse({method:"notifications/tasks/status",params:c});await this.notification(l),Qt(c.status)&&this._cleanupTaskProgressHandler(n)}},listTasks:n=>s.listTasks(n,r)}}};function ep(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function tp(t,e){let r={...t};for(let s in e){let n=s,o=e[n];if(o===void 0)continue;let i=r[n];ep(i)&&ep(o)?r[n]={...i,...o}:r[n]=o}return r}var tg=To(_u(),1),rg=To(eg(),1);function yP(){let t=new tg.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,rg.default)(t),t}var Ai=class{constructor(e){this._ajv=e??yP()}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 Oi=class{constructor(e){this._client=e}async*callToolStream(e,r=Qr,s){let n=this._client,o={...s,task:s?.task??(n.isToolTask(e.name)?{}:void 0)},i=n.requestStream({method:"tools/call",params:e},r,o),a=n.getToolOutputValidator(e.name);for await(let c of i){if(c.type==="result"&&a){let l=c.result;if(!l.structuredContent&&!l.isError){yield{type:"error",error:new O(N.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(l.structuredContent)try{let u=a(l.structuredContent);if(!u.valid){yield{type:"error",error:new O(N.InvalidParams,`Structured content does not match the tool's output schema: ${u.errorMessage}`)};return}}catch(u){if(u instanceof O){yield{type:"error",error:u};return}yield{type:"error",error:new O(N.InvalidParams,`Failed to validate structured content: ${u instanceof Error?u.message:String(u)}`)};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 sg(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 ng(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 Ii(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 n of Object.keys(s)){let o=s[n];r[n]===void 0&&Object.prototype.hasOwnProperty.call(o,"default")&&(r[n]=o.default),r[n]!==void 0&&Ii(o,r[n])}}if(Array.isArray(t.anyOf))for(let r of t.anyOf)typeof r!="boolean"&&Ii(r,e);if(Array.isArray(t.oneOf))for(let r of t.oneOf)typeof r!="boolean"&&Ii(r,e)}}function wP(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 zi=class extends Zo{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 Ai,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",_c,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",bc,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",hc,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new Oi(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=tp(this._capabilities,e)}setRequestHandler(e,r){let n=Eo(e)?.method;if(!n)throw new Error("Schema is missing a method literal");let o=$o(n);if(typeof o!="string")throw new Error("Schema method literal must be a string");let i=o;if(i==="elicitation/create"){let a=async(c,l)=>{let u=ft(Tc,c);if(!u.success){let v=u.error instanceof Error?u.error.message:String(u.error);throw new O(N.InvalidParams,`Invalid elicitation request: ${v}`)}let{params:d}=u.data;d.mode=d.mode??"form";let{supportsFormMode:h,supportsUrlMode:p}=wP(this._capabilities.elicitation);if(d.mode==="form"&&!h)throw new O(N.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!p)throw new O(N.InvalidParams,"Client does not support URL-mode elicitation requests");let m=await Promise.resolve(r(c,l));if(d.task){let v=ft(_r,m);if(!v.success){let S=v.error instanceof Error?v.error.message:String(v.error);throw new O(N.InvalidParams,`Invalid task creation result: ${S}`)}return v.data}let f=ft(Ec,m);if(!f.success){let v=f.error instanceof Error?f.error.message:String(f.error);throw new O(N.InvalidParams,`Invalid elicitation result: ${v}`)}let g=f.data,w=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&g.action==="accept"&&g.content&&w&&this._capabilities.elicitation?.form?.applyDefaults)try{Ii(w,g.content)}catch{}return g};return super.setRequestHandler(e,a)}if(i==="sampling/createMessage"){let a=async(c,l)=>{let u=ft(Sc,c);if(!u.success){let g=u.error instanceof Error?u.error.message:String(u.error);throw new O(N.InvalidParams,`Invalid sampling request: ${g}`)}let{params:d}=u.data,h=await Promise.resolve(r(c,l));if(d.task){let g=ft(_r,h);if(!g.success){let w=g.error instanceof Error?g.error.message:String(g.error);throw new O(N.InvalidParams,`Invalid task creation result: ${w}`)}return g.data}let m=d.tools||d.toolChoice?xc:kc,f=ft(m,h);if(!f.success){let g=f.error instanceof Error?f.error.message:String(f.error);throw new O(N.InvalidParams,`Invalid sampling result: ${g}`)}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:Jr,capabilities:this._capabilities,clientInfo:this._clientInfo}},ic,r);if(s===void 0)throw new Error(`Server sent invalid initialize result: ${s}`);if(!zh.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){sg(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&ng(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},vr,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},$c,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},vr,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},wc,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},pc,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},cc,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},lc,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},dc,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},vr,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},vr,r)}async callTool(e,r=Qr,s){if(this.isToolTaskRequired(e.name))throw new O(N.InvalidRequest,`Tool "${e.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let n=await this.request({method:"tools/call",params:e},r,s),o=this.getToolOutputValidator(e.name);if(o){if(!n.structuredContent&&!n.isError)throw new O(N.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(n.structuredContent)try{let i=o(n.structuredContent);if(!i.valid)throw new O(N.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof O?i:new O(N.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return n}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 n=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,n)}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},vc,r);return this.cacheToolMetadata(s.tools),s}_setupListChangedHandler(e,r,s,n){let o=Xh.safeParse(s);if(!o.success)throw new Error(`Invalid ${e} listChanged options: ${o.error.message}`);if(typeof s.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:a}=o.data,{onChanged:c}=s,l=async()=>{if(!i){c(null,null);return}try{let d=await n();c(null,d)}catch(d){let h=d instanceof Error?d:new Error(String(d));c(h,null)}},u=()=>{if(a){let d=this._listChangedDebounceTimers.get(e);d&&clearTimeout(d);let h=setTimeout(l,a);this._listChangedDebounceTimers.set(e,h)}else l()};this.setNotificationHandler(r,u)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};var On=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}},og=10,bP=13,Ir=32;function Cu(t){}function Ni(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=Cu,onError:r=Cu,onRetry:s=Cu,onComment:n,maxBufferSize:o}=t,i=[],a=0,c=!0,l,u="",d=0,h,p=!1;function m(_){if(p)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,_.charCodeAt(0)===239&&_.charCodeAt(1)===187&&_.charCodeAt(2)===191&&(_=_.slice(3))),i.length===0){let D=g(_);D!==""&&(i.push(D),a=D.length),f();return}if(_.indexOf(`
12
12
  `)===-1&&_.indexOf("\r")===-1){i.push(_),a+=_.length,f();return}i.push(_);let k=i.join("");i.length=0,a=0;let C=g(k);C!==""&&(i.push(C),a=C.length),f()}function f(){o!==void 0&&(a+u.length<=o||(p=!0,i.length=0,a=0,l=void 0,u="",d=0,h=void 0,r(new On(`Buffered data exceeded max buffer size of ${o} characters`,{type:"max-buffer-size-exceeded"}))))}function g(_){let k=0;if(_.indexOf("\r")===-1){let C=_.indexOf(`
13
13
  `,k);for(;C!==-1;){if(k===C){d>0&&e({id:l,event:h,data:u}),l=void 0,u="",d=0,h=void 0,k=C+1,C=_.indexOf(`
14
14
  `,k);continue}let D=_.charCodeAt(k);if(ig(_,k,D)){let I=_.charCodeAt(k+5)===Ir?k+6:k+5,X=_.slice(I,C);if(d===0&&_.charCodeAt(C+1)===og){e({id:l,event:h,data:X}),l=void 0,u="",h=void 0,k=C+2,C=_.indexOf(`
@@ -102,7 +102,7 @@ Return a concise report of the result, relevant paths, checks actually run and r
102
102
  ${r}
103
103
  </assignment>`}var A1="[Interrupted]";async function G2(t,e,r,s,n,o,i,a,c,l,u={}){u.abortSignal?.throwIfAborted();let d=c??t.model,h=d?cw(d):n.model,p=jy(o);p.model=h;let m=t.systemPromptOverride??Dy(p),f={...n,model:h,thinking:r.getThinkingLevel?.()??n.thinking},g=d||t.systemPromptOverride?await tc(f,m):r,w=u.conversation?s:Ih(s,t.tools,t.disallowedTools,u.background??!1),v=u.permissionMode==="plan"?"plan":t.permissionMode??u.permissionMode??"acceptEdits",S=l??new Zr(o,v),x=u.conversation??new Kr;x.addSystemReminder(dw(t)),x.addUserMessage(e);let _=u.backgroundTasks===!1?null:new $s,k=new zo({client:g,registry:w,checker:S,conversation:x,workDir:o,maxIterations:t.maxTurns??200,abortSignal:u.abortSignal,onPermissionRequest:u.onPermissionRequest,fileStateCache:new As,instructions:Ey(o),contextWindow:bh(f),maxOutput:vh(f),taskManager:_,notificationFn:_?()=>_.drainNotifications().map(Ly):void 0}),C="",D=0;try{for await(let I of k.run())switch(I.type){case"stream_text":C+=I.text;break;case"tool_use":i?.({lastTool:I.toolName}),a?.({type:"tool_use",toolId:I.toolId,toolName:I.toolName,args:I.args});break;case"tool_result":a?.({type:"tool_result",toolId:I.toolId});break;case"usage":a?.({type:"usage",usage:{inputTokens:I.usage.inputTokens,outputTokens:I.usage.outputTokens}});break;case"turn_complete":i?.({turn:++D}),a?.({type:"turn_complete"});break;case"loop_complete":return I.stopReason==="interrupted"?`${C}${C?`
104
104
 
105
- `:""}${A1}`:C||"[No output]";case"error":throw I.error}return C||"[No output]"}finally{await _?.stopAll()}}var O1=new Set(["Agent","SendMessage","TaskStop","SyntheticOutput","TeamDelete"]);function I1(t){return O1.has(t)}function K2(t=!1){return t?I1:()=>!0}function Z2(t=!1){return t}var pw=class{constructor(e,r){this.teamManager=e;this.taskManager=r}teamManager;taskManager;name="TaskStop";description="Stop a running teammate or background task (Agent, Bash, PowerShell). Pass exactly one of teammate or task_id.";category="command";schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{teammate:{type:"string",description:"Name of the teammate to stop, exactly as it appears in the from= field of a task-notification"},task_id:{type:"string",description:"ID of a background task (Agent, Bash, PowerShell)"}}}}}async execute(e,r){let s=$(r,"teammate",""),n=$(r,"task_id","");if(!s&&!n||s&&n)return{output:"Error: pass exactly one of teammate or task_id",isError:!0};if(n){let o=e.taskManager?.get(n)?e.taskManager:this.taskManager,i=o?.get(n);return i?i.status!=="running"?{output:`Background task '${n}' is ${i.status}, nothing to stop`,isError:!1}:(await o?.stopAndWait(n),{output:`Background task '${n}' stopped.`,isError:!1}):{output:`Error: background task '${n}' not found`,isError:!0}}for(let o of this.teamManager.list()){let i=o.members.get(s);if(i)return i.active?(await o.stopMember(s),{output:`Teammate '${s}' in team '${o.name}' stopped.`,isError:!1}):{output:`Teammate '${s}' in team '${o.name}' is not running, nothing to stop`,isError:!1}}return{output:`Error: teammate '${s}' not found. Known teammates: ${this.knownMembers()}`,isError:!0}}knownMembers(){let e=[];for(let r of this.teamManager.list())for(let s of r.members.keys())e.push(s);return e.length>0?e.join(", "):"(none)"}};import{mkdirSync as IR,readFileSync as zR,rmSync as NR}from"fs";import{join as vd}from"path";import{execSync as aa,spawn as j1}from"child_process";var fw=z({module:"teams"});function gw(){return process.platform==="win32"?"in-process":D1()}function D1(){return process.env.TMUX?"tmux":process.env.ITERM_SESSION_ID?"iterm":"in-process"}function yw(t){return/^[A-Za-z0-9_/.:=-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}function mw(t){return[t.command,...t.args].map(yw).join(" ")}function ww(t){switch(t.mode){case"in-process":{let e=j1(t.command,t.args,{cwd:t.cwd,stdio:["pipe","pipe","pipe"],env:{...process.env,...t.env}});return{cancel:()=>e.kill("SIGTERM")}}case"tmux":{let e=`yukino-${Date.now().toString(36)}`,r=mw(t);try{aa(`tmux new-window -t "${e}" -n teammate "${r}"`,{cwd:t.cwd,encoding:"utf-8",stdio:["pipe","pipe","pipe"]})}catch(s){fw.error({err:s},"teams operation failed"),aa(`tmux new-session -d -s "${e}" -n teammate "${r}"`,{cwd:t.cwd,encoding:"utf-8",stdio:["pipe","pipe","pipe"]})}return{cancel:()=>{try{aa(`tmux kill-session -t "${e}"`,{stdio:["pipe","pipe","pipe"]})}catch(s){fw.error({err:s},"teams operation failed")}},paneId:e}}case"iterm":{let e=mw(t),o=['tell application "iTerm2"'," tell current window"," create tab with default profile",` tell current session to write text "${`cd ${yw(t.cwd)} && ${e}`.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`," end tell","end tell"].map(i=>`-e '${i.replace(/'/g,"'\\''")}'`).join(" ");return aa(`osascript ${o}`,{cwd:t.cwd,encoding:"utf-8",stdio:["pipe","pipe","pipe"]}),{cancel:()=>{}}}default:throw new Error(`Unknown team mode: ${String(t.mode)}`)}}import{readFileSync as L1,writeFileSync as F1,mkdirSync as U1,existsSync as B1,unlinkSync as vw,statSync as W1,openSync as H1,closeSync as G1}from"fs";import{join as V1}from"path";var Jn=z({module:"teams"}),K1=y.looseObject({from:y.string(),text:y.string(),timestamp:y.string(),read:y.boolean().optional(),type:y.string().optional(),requestId:y.string().optional(),approve:y.boolean().optional()}),bw=5e3,Z1=1e4,Y1=5,J1=80,X1=y.looseObject({errno:y.number().optional(),code:y.string().optional(),path:y.string().optional(),syscall:y.string().optional()});function Q1(t){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,t)}function eR(t){let e=Date.now()+bw,r=Y1;for(;;)try{let s=H1(t,"wx");G1(s);return}catch(s){Jn.error({err:s},"teams operation failed");let{data:n,success:o}=Po(X1,s),i="";if(o&&n.code&&(i=n.code),i!=="EEXIST")throw s;try{let a=W1(t);if(Date.now()-a.mtimeMs>Z1)try{vw(t);continue}catch(c){Jn.error({err:c},"teams operation failed")}}catch(a){Jn.error({err:a},"teams operation failed")}if(Date.now()>=e)throw new Error(`mailbox lock ${t}: timed out after ${String(bw)}ms, message not written`);Q1(r+Math.floor(Math.random()*r)),r=Math.min(r*2,J1)}}function tR(t){try{vw(t)}catch(e){Jn.error({err:e},"teams operation failed")}}function yd(t,e){let r=t+".lock";eR(r);try{return e()}finally{tR(r)}}var Xn=class{filePath;constructor(e,r){U1(e,{recursive:!0}),this.filePath=V1(e,`${r}.json`)}readAll(){if(!B1(this.filePath))return[];try{let e=JSON.parse(L1(this.filePath,"utf-8")),r=[];if(Array.isArray(e))for(let s of e){let n=K1.safeParse(s);n.success&&r.push(n.data)}return r}catch(e){return Jn.error({err:e},"teams operation failed"),[]}}writeAll(e){F1(this.filePath,JSON.stringify(e,null,2),"utf-8")}async send(e,r,s){let n=s??{from:e,text:r,timestamp:new Date().toISOString()};return n.read=!1,yd(this.filePath,()=>{let o=this.readAll();o.push(n),this.writeAll(o)}),Promise.resolve()}receiveSync(){return yd(this.filePath,()=>{let e=this.readAll(),r=e.filter(s=>!s.read);if(r.length>0){for(let s of e)s.read=!0;this.writeAll(e)}return r})}async receive(){return Promise.resolve(this.receiveSync())}unreadCount(){return this.readAll().filter(e=>!e.read).length}markAllRead(){yd(this.filePath,()=>{let e=this.readAll(),r=!1;for(let s of e)s.read||(s.read=!0,r=!0);r&&this.writeAll(e)})}async*poll(e=1e3){for(;;){let r=await this.receive();for(let s of r)yield s;await new Promise(s=>setTimeout(s,e))}}};var _w=y.looseObject({toolName:y.string(),input:y.record(y.string(),y.unknown()),activityDescription:y.string()}),sR=y.looseObject({toolId:y.string(),toolName:y.string()}),nR=y.looseObject({toolUseCount:y.number(),turnCount:y.number(),tokenCount:y.number(),activeTools:y.array(sR),lastActivity:_w.optional(),recentActivities:y.array(_w)}),oB=y.looseObject({name:y.string(),teamName:y.string(),status:y.enum(["running","idle","completed","failed","stopped"]),progress:nR,originToolCallId:y.string().optional(),startTime:y.number(),spinnerVerb:y.string(),lastMessage:y.string().optional()});function wd(){return{toolUseCount:0,turnCount:0,tokenCount:0,activeTools:[],lastActivity:void 0,recentActivities:[]}}function oR(t,e,r){t.toolUseCount++;let s={toolName:e,input:r,activityDescription:iR(e,r)};t.lastActivity=s,t.recentActivities.push(s),t.recentActivities.length>5&&t.recentActivities.shift()}function Sw(t,e,r,s){oR(t,r,s),t.activeTools=[...t.activeTools.filter(n=>n.toolId!==e),{toolId:e,toolName:r}]}function kw(t,e){t.activeTools=t.activeTools.filter(r=>r.toolId!==e)}function xw(t){t.turnCount++,t.activeTools=[]}function ca(t){t.activeTools=[]}function Tw(t,e,r){t.tokenCount+=e+r}function iR(t,e){switch(t){case"ReadFile":return`Reading ${$(e,"file_path","file")}`;case"EditFile":return`Editing ${$(e,"file_path","file")}`;case"WriteFile":return`Writing ${$(e,"file_path","file")}`;case"Bash":case"PowerShell":{let r=$(e,"command","");return`Running ${r.length>40?r.slice(0,40)+"...":r}`}case"Glob":return`Searching ${$(e,"pattern","files")}`;case"Grep":return`Grepping ${$(e,"pattern","pattern")}`;case"WebFetch":return`Fetching ${$(e,"url","page")}`;default:return t}}function iB(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"k":String(t)}import{readFileSync as cR,writeFileSync as lR,mkdirSync as uR,existsSync as dR}from"fs";import{dirname as hR}from"path";var pR=y.looseObject({id:y.string(),title:y.string(),description:y.string().default(""),status:y.string().default("pending"),assignee:y.string().default(""),blocks:y.array(y.string()).default([]),blocked_by:y.array(y.string()).default([]),created_by:y.string().default("")}),fR=y.looseObject({next_id:y.number().int().positive().default(1),tasks:y.array(pR).default([])}),Qn=class{path;nextId=1;tasks=[];constructor(e){this.path=e,this.load()}load(){if(dR(this.path))try{let e=JSON.parse(cR(this.path,"utf-8")),r=tt(fR,e);this.nextId=r.next_id,this.tasks=r.tasks.map(s=>({id:s.id,title:s.title,description:s.description,status:s.status,assignee:s.assignee,blocks:s.blocks,blockedBy:s.blocked_by,createdBy:s.created_by}))}catch{}}save(){uR(hR(this.path),{recursive:!0});let e={next_id:this.nextId,tasks:this.tasks.map(r=>({id:r.id,title:r.title,description:r.description,status:r.status,assignee:r.assignee,blocks:r.blocks,blocked_by:r.blockedBy,created_by:r.createdBy}))};lR(this.path,JSON.stringify(e,null,2),"utf-8")}create(e,r="",s="",n=[],o=[],i=""){let a={id:String(this.nextId++),title:e,description:r,status:"pending",assignee:s,blocks:[...n],blockedBy:[...o],createdBy:i};return this.tasks.push(a),this.save(),a}get(e){return this.load(),this.tasks.find(r=>r.id===e)}listTasks(e,r){return this.load(),this.tasks.filter(s=>!(e&&s.status!==e||r&&s.assignee!==r))}update(e,r){this.load();let s=this.tasks.find(n=>n.id===e);if(s){r.status!==void 0&&(s.status=r.status),r.assignee!==void 0&&(s.assignee=r.assignee),r.description!==void 0&&(s.description=r.description);for(let n of r.addBlocks??[])s.blocks.includes(n)||s.blocks.push(n);for(let n of r.addBlockedBy??[])s.blockedBy.includes(n)||s.blockedBy.push(n);return this.save(),s}}initEmpty(){this.tasks=[],this.nextId=1,this.save()}};import{existsSync as gR,mkdirSync as yR,readdirSync as wR,readFileSync as bR,writeFileSync as vR}from"fs";import{homedir as _R}from"os";import{dirname as SR,join as bd}from"path";var kR=y.looseObject({agentId:y.string(),name:y.string(),agentType:y.string().optional(),model:y.string().optional(),joinedAt:y.number(),worktreePath:y.string().optional(),backendType:y.string().optional(),isActive:y.boolean().optional()}),xR=y.looseObject({name:y.string(),description:y.string().optional(),createdAt:y.number(),leadAgentId:y.string(),members:y.array(kR)});function Ew(){return bd(_R(),".yukino","teams")}function TR(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function eo(t){return bd(Ew(),TR(t))}function $w(){try{return wR(Ew(),{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name)}catch{return[]}}function Pw(t){return bd(eo(t),"config.json")}function Cw(t){let e=Pw(t);if(!gR(e))return null;try{let r=JSON.parse(bR(e,"utf-8"));return xR.parse(r)}catch{return null}}function Rw(t,e){try{let r=Pw(t);yR(SR(r),{recursive:!0}),vR(r,JSON.stringify(e,null,2),"utf-8")}catch{}}import{mkdirSync as $R,readFileSync as mB,writeFileSync as PR,existsSync as gB}from"fs";import{join as Mw}from"path";var _B=z({module:"teams"}),CR=y.looseObject({tool_use_id:y.string(),tool_name:y.string(),arguments:y.record(y.string(),y.unknown())}),RR=y.looseObject({tool_use_id:y.string(),content:y.string(),is_error:y.boolean().optional()}),SB=y.looseObject({role:y.string(),content:y.string().optional(),tool_uses:y.array(CR).optional(),tool_results:y.array(RR).optional()});function MR(t){let e=[];for(let r of t.getMessages()){let s={role:r.role,content:Sh(r.content)};r.toolUses&&r.toolUses.length>0&&(s.tool_uses=r.toolUses.map(n=>({tool_use_id:n.toolUseId,tool_name:n.toolName,arguments:n.arguments}))),r.toolResults&&r.toolResults.length>0&&(s.tool_results=r.toolResults.map(n=>({tool_use_id:n.toolUseId,content:n.content,is_error:n.isError||void 0}))),e.push(s)}return e}function AR(t,e){return Mw(t,".yukino","teams",e,"transcripts")}function Aw(t,e,r,s){let n=AR(t,e);$R(n,{recursive:!0});let o=Mw(n,`${r}.json`),i=MR(s);return PR(o,JSON.stringify(i,null,2),"utf-8"),o}var Ow=z({module:"teams"}),la=class t{name;mode;members=new Map;leadMailbox;mailboxDir;workDir;leadAgentId="";description;createdAt=Math.floor(Date.now()/1e3);constructor(e,r,s){this.name=e,this.mode=r,this.workDir=s,this.mailboxDir=vd(eo(e),"inboxes"),IR(this.mailboxDir,{recursive:!0}),this.leadMailbox=new Xn(this.mailboxDir,"lead")}addMember(e){let r=new Xn(this.mailboxDir,e),s={name:e,active:!1,mailbox:r,agentId:e,joinedAt:Math.floor(Date.now()/1e3)};return this.members.set(e,s),this.persist(),s}setMemberMeta(e,r){let s=this.members.get(e);s&&(s.agentType=r.agentType,s.model=r.model,s.worktreePath=r.worktreePath,this.persist())}snapshot(){return{name:this.name,description:this.description,createdAt:this.createdAt,leadAgentId:this.leadAgentId,members:[...this.members.values()].map(e=>({agentId:e.agentId??e.name,name:e.name,agentType:e.agentType,model:e.model,joinedAt:e.joinedAt??0,worktreePath:e.worktreePath,backendType:this.mode,isActive:e.active}))}}persist(){Rw(this.name,this.snapshot())}static IDLE_POLL_INTERVAL_MS=500;static SHUTDOWN_PREFIX="[shutdown]";spawnTeammate(e,r,s,n,o,i){if(this.mode==="in-process"){this.spawnInProcess(e,r,s,n,i);return}try{this.spawnExternal(e,r,o,i)}catch{this.spawnInProcess(e,r,s,n,i)}}spawnExternal(e,r,s,n){let o=this.addMember(e);o.active=!0,Cs().register(e,e),o.uiState={name:e,teamName:this.name,status:"running",progress:wd(),...n?{originToolCallId:n}:{},startTime:Date.now(),spinnerVerb:Qa()};let i=process.argv[1]??"src/main.tsx",a={mode:this.mode,command:"node",args:["run",i,"--teammate","--team-dir",this.mailboxDir,"--team-name",this.name,"--member-name",e,"--task",r,...s?["--provider-base-url",s]:[],"--input-type=module"],cwd:this.workDir},{cancel:c,paneId:l}=ww(a);o.cancel=c,o.paneId=l,o.external=!0}spawnInProcess(e,r,s,n,o){let i=this.addMember(e);i.active=!0,i.checker=n;let a=new AbortController;i.cancel=()=>{a.abort()},Cs().register(e,e);let c={name:e,teamName:this.name,status:"running",progress:wd(),...o?{originToolCallId:o}:{},startTime:Date.now(),spinnerVerb:Qa()};i.uiState=c;let l=d=>{switch(d.type){case"tool_use":Sw(c.progress,d.toolId,d.toolName,d.args);break;case"tool_result":kw(c.progress,d.toolId);break;case"usage":Tw(c.progress,d.usage.inputTokens,d.usage.outputTokens);break;case"turn_complete":xw(c.progress);break}},u=(async()=>{let d=r,h="available";try{for(;i.active;){c.status="running";let p=await s(hw(this.name,e,d),l,a.signal);if(ca(c.progress),c.lastMessage=p.length>200?p.slice(0,200)+"...":p,a.signal.aborted||!i.active){c.status="stopped",await this.leadMailbox.send(e,`[idle] ${e} (reason: stopped)`);break}if(i.checker?.mode==="plan"){c.status="idle";let f=await this.runPlanApproval(i,this.readPlanForReview());if(f===null)break;d=f;continue}c.status="idle",await this.leadMailbox.send(e,`[idle] ${e} (reason: ${h})`),h="available";let m=await this.waitForNextPromptOrShutdown(i);if(m.shutdown||!i.active){let f=m.shutdown;if(f?.type===Fr){let g=Qi(i.name,f.requestId??"",!0,"acknowledged, shutting down");await this.leadMailbox.send(i.name,g.text,g)}break}d=m.prompt}c.status!=="stopped"&&(c.status="completed")}catch(p){a.signal.aborted||!i.active?(c.status="stopped",c.lastMessage="Stopped",await this.leadMailbox.send(e,`[idle] ${e} (reason: stopped)`)):(Ow.error({err:p},"teams operation failed"),c.status="failed",c.lastMessage=A(p),await this.leadMailbox.send(e,`[idle] ${e} (reason: failed)`))}finally{if(i.active=!1,ca(c.progress),c.status==="running"&&(c.status="idle"),i.conversation)try{Aw(this.workDir,this.name,e,i.conversation)}catch(p){Ow.error({err:p},"teams operation failed")}}})();i.done=u}async waitForNextPromptOrShutdown(e){for(;e.active;){await new Promise(o=>setTimeout(o,t.IDLE_POLL_INTERVAL_MS));let r=e.mailbox.receiveSync();if(r.length===0)continue;let s=r.find(o=>Hy(o));return s?{prompt:"",shutdown:s}:{prompt:`You have new messages from your team:
105
+ `:""}${A1}`:C||"[No output]";case"error":throw I.error}return C||"[No output]"}finally{await _?.stopAll()}}var O1=new Set(["Agent","SendMessage","TaskStop","SyntheticOutput","TeamDelete"]);function I1(t){return O1.has(t)}function K2(t=!1){return t?I1:()=>!0}function Z2(t=!1){return t}var pw=class{constructor(e,r){this.teamManager=e;this.taskManager=r}teamManager;taskManager;name="TaskStop";description="Stop a running teammate or background task (Agent, Bash, PowerShell). Pass exactly one of teammate or task_id.";category="command";schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{teammate:{type:"string",description:"Name of the teammate to stop, exactly as it appears in the from= field of a task-notification"},task_id:{type:"string",description:"ID of a background task (Agent, Bash, PowerShell)"}}}}}async execute(e,r){let s=$(r,"teammate",""),n=$(r,"task_id","");if(!s&&!n||s&&n)return{output:"Error: pass exactly one of teammate or task_id",isError:!0};if(n){let o=e.taskManager?.get(n)?e.taskManager:this.taskManager,i=o?.get(n);return i?i.status!=="running"?{output:`Background task '${n}' is ${i.status}, nothing to stop`,isError:!1}:(await o?.stopAndWait(n),{output:`Background task '${n}' stopped.`,isError:!1}):{output:`Error: background task '${n}' not found`,isError:!0}}for(let o of this.teamManager.list()){let i=o.members.get(s);if(i)return i.active?(await o.stopMember(s),{output:`Teammate '${s}' in team '${o.name}' stopped.`,isError:!1}):{output:`Teammate '${s}' in team '${o.name}' is not running, nothing to stop`,isError:!1}}return{output:`Error: teammate '${s}' not found. Known teammates: ${this.knownMembers()}`,isError:!0}}knownMembers(){let e=[];for(let r of this.teamManager.list())for(let s of r.members.keys())e.push(s);return e.length>0?e.join(", "):"(none)"}};import{mkdirSync as IR,readFileSync as zR,rmSync as NR}from"fs";import{join as vd}from"path";import{execSync as aa,spawn as j1}from"child_process";var fw=z({module:"teams"});function gw(){return process.platform==="win32"?"in-process":D1()}function D1(){return process.env.TMUX?"tmux":process.env.ITERM_SESSION_ID?"iterm":"in-process"}function yw(t){return/^[A-Za-z0-9_/.:=-]+$/.test(t)?t:`'${t.replace(/'/g,"'\\''")}'`}function mw(t){return[t.command,...t.args].map(yw).join(" ")}function ww(t){switch(t.mode){case"in-process":{let e=j1(t.command,t.args,{cwd:t.cwd,stdio:["pipe","pipe","pipe"],env:{...process.env,...t.env}});return{cancel:()=>e.kill("SIGTERM")}}case"tmux":{let e=`yukino-${Date.now().toString(36)}`,r=mw(t);try{aa(`tmux new-window -t "${e}" -n teammate "${r}"`,{cwd:t.cwd,encoding:"utf-8",stdio:["pipe","pipe","pipe"]})}catch(s){fw.error({err:s},"teams operation failed"),aa(`tmux new-session -d -s "${e}" -n teammate "${r}"`,{cwd:t.cwd,encoding:"utf-8",stdio:["pipe","pipe","pipe"]})}return{cancel:()=>{try{aa(`tmux kill-session -t "${e}"`,{stdio:["pipe","pipe","pipe"]})}catch(s){fw.error({err:s},"teams operation failed")}},paneId:e}}case"iterm":{let e=mw(t),o=['tell application "iTerm2"'," tell current window"," create tab with default profile",` tell current session to write text "${`cd ${yw(t.cwd)} && ${e}`.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`," end tell","end tell"].map(i=>`-e '${i.replace(/'/g,"'\\''")}'`).join(" ");return aa(`osascript ${o}`,{cwd:t.cwd,encoding:"utf-8",stdio:["pipe","pipe","pipe"]}),{cancel:()=>{}}}default:throw new Error(`Unknown team mode: ${String(t.mode)}`)}}import{readFileSync as L1,writeFileSync as F1,mkdirSync as U1,existsSync as B1,unlinkSync as vw,statSync as W1,openSync as H1,closeSync as G1}from"fs";import{join as V1}from"path";var Jn=z({module:"teams"}),K1=y.object({from:y.string(),text:y.string(),timestamp:y.string(),read:y.boolean().optional(),type:y.string().optional(),requestId:y.string().optional(),approve:y.boolean().optional()}),bw=5e3,Z1=1e4,Y1=5,J1=80,X1=y.looseObject({errno:y.number().optional(),code:y.string().optional(),path:y.string().optional(),syscall:y.string().optional()});function Q1(t){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,t)}function eR(t){let e=Date.now()+bw,r=Y1;for(;;)try{let s=H1(t,"wx");G1(s);return}catch(s){Jn.error({err:s},"teams operation failed");let{data:n,success:o}=Po(X1,s),i="";if(o&&n.code&&(i=n.code),i!=="EEXIST")throw s;try{let a=W1(t);if(Date.now()-a.mtimeMs>Z1)try{vw(t);continue}catch(c){Jn.error({err:c},"teams operation failed")}}catch(a){Jn.error({err:a},"teams operation failed")}if(Date.now()>=e)throw new Error(`mailbox lock ${t}: timed out after ${String(bw)}ms, message not written`);Q1(r+Math.floor(Math.random()*r)),r=Math.min(r*2,J1)}}function tR(t){try{vw(t)}catch(e){Jn.error({err:e},"teams operation failed")}}function yd(t,e){let r=t+".lock";eR(r);try{return e()}finally{tR(r)}}var Xn=class{filePath;constructor(e,r){U1(e,{recursive:!0}),this.filePath=V1(e,`${r}.json`)}readAll(){if(!B1(this.filePath))return[];try{let e=JSON.parse(L1(this.filePath,"utf-8")),r=[];if(Array.isArray(e))for(let s of e){let n=K1.safeParse(s);n.success&&r.push(n.data)}return r}catch(e){return Jn.error({err:e},"teams operation failed"),[]}}writeAll(e){F1(this.filePath,JSON.stringify(e,null,2),"utf-8")}async send(e,r,s){let n=s??{from:e,text:r,timestamp:new Date().toISOString()};return n.read=!1,yd(this.filePath,()=>{let o=this.readAll();o.push(n),this.writeAll(o)}),Promise.resolve()}receiveSync(){return yd(this.filePath,()=>{let e=this.readAll(),r=e.filter(s=>!s.read);if(r.length>0){for(let s of e)s.read=!0;this.writeAll(e)}return r})}async receive(){return Promise.resolve(this.receiveSync())}unreadCount(){return this.readAll().filter(e=>!e.read).length}markAllRead(){yd(this.filePath,()=>{let e=this.readAll(),r=!1;for(let s of e)s.read||(s.read=!0,r=!0);r&&this.writeAll(e)})}async*poll(e=1e3){for(;;){let r=await this.receive();for(let s of r)yield s;await new Promise(s=>setTimeout(s,e))}}};var _w=y.object({toolName:y.string(),input:y.record(y.string(),y.unknown()),activityDescription:y.string()}),sR=y.object({toolId:y.string(),toolName:y.string()}),nR=y.object({toolUseCount:y.number(),turnCount:y.number(),tokenCount:y.number(),activeTools:y.array(sR),lastActivity:_w.optional(),recentActivities:y.array(_w)}),oB=y.object({name:y.string(),teamName:y.string(),status:y.enum(["running","idle","completed","failed","stopped"]),progress:nR,originToolCallId:y.string().optional(),startTime:y.number(),spinnerVerb:y.string(),lastMessage:y.string().optional()});function wd(){return{toolUseCount:0,turnCount:0,tokenCount:0,activeTools:[],lastActivity:void 0,recentActivities:[]}}function oR(t,e,r){t.toolUseCount++;let s={toolName:e,input:r,activityDescription:iR(e,r)};t.lastActivity=s,t.recentActivities.push(s),t.recentActivities.length>5&&t.recentActivities.shift()}function Sw(t,e,r,s){oR(t,r,s),t.activeTools=[...t.activeTools.filter(n=>n.toolId!==e),{toolId:e,toolName:r}]}function kw(t,e){t.activeTools=t.activeTools.filter(r=>r.toolId!==e)}function xw(t){t.turnCount++,t.activeTools=[]}function ca(t){t.activeTools=[]}function Tw(t,e,r){t.tokenCount+=e+r}function iR(t,e){switch(t){case"ReadFile":return`Reading ${$(e,"file_path","file")}`;case"EditFile":return`Editing ${$(e,"file_path","file")}`;case"WriteFile":return`Writing ${$(e,"file_path","file")}`;case"Bash":case"PowerShell":{let r=$(e,"command","");return`Running ${r.length>40?r.slice(0,40)+"...":r}`}case"Glob":return`Searching ${$(e,"pattern","files")}`;case"Grep":return`Grepping ${$(e,"pattern","pattern")}`;case"WebFetch":return`Fetching ${$(e,"url","page")}`;default:return t}}function iB(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"k":String(t)}import{readFileSync as cR,writeFileSync as lR,mkdirSync as uR,existsSync as dR}from"fs";import{dirname as hR}from"path";var pR=y.object({id:y.string(),title:y.string(),description:y.string().default(""),status:y.string().default("pending"),assignee:y.string().default(""),blocks:y.array(y.string()).default([]),blocked_by:y.array(y.string()).default([]),created_by:y.string().default("")}),fR=y.object({next_id:y.number().int().positive().default(1),tasks:y.array(pR).default([])}),Qn=class{path;nextId=1;tasks=[];constructor(e){this.path=e,this.load()}load(){if(dR(this.path))try{let e=JSON.parse(cR(this.path,"utf-8")),r=tt(fR,e);this.nextId=r.next_id,this.tasks=r.tasks.map(s=>({id:s.id,title:s.title,description:s.description,status:s.status,assignee:s.assignee,blocks:s.blocks,blockedBy:s.blocked_by,createdBy:s.created_by}))}catch{}}save(){uR(hR(this.path),{recursive:!0});let e={next_id:this.nextId,tasks:this.tasks.map(r=>({id:r.id,title:r.title,description:r.description,status:r.status,assignee:r.assignee,blocks:r.blocks,blocked_by:r.blockedBy,created_by:r.createdBy}))};lR(this.path,JSON.stringify(e,null,2),"utf-8")}create(e,r="",s="",n=[],o=[],i=""){let a={id:String(this.nextId++),title:e,description:r,status:"pending",assignee:s,blocks:[...n],blockedBy:[...o],createdBy:i};return this.tasks.push(a),this.save(),a}get(e){return this.load(),this.tasks.find(r=>r.id===e)}listTasks(e,r){return this.load(),this.tasks.filter(s=>!(e&&s.status!==e||r&&s.assignee!==r))}update(e,r){this.load();let s=this.tasks.find(n=>n.id===e);if(s){r.status!==void 0&&(s.status=r.status),r.assignee!==void 0&&(s.assignee=r.assignee),r.description!==void 0&&(s.description=r.description);for(let n of r.addBlocks??[])s.blocks.includes(n)||s.blocks.push(n);for(let n of r.addBlockedBy??[])s.blockedBy.includes(n)||s.blockedBy.push(n);return this.save(),s}}initEmpty(){this.tasks=[],this.nextId=1,this.save()}};import{existsSync as gR,mkdirSync as yR,readdirSync as wR,readFileSync as bR,writeFileSync as vR}from"fs";import{homedir as _R}from"os";import{dirname as SR,join as bd}from"path";var kR=y.object({agentId:y.string(),name:y.string(),agentType:y.string().optional(),model:y.string().optional(),joinedAt:y.number(),worktreePath:y.string().optional(),backendType:y.string().optional(),isActive:y.boolean().optional()}),xR=y.object({name:y.string(),description:y.string().optional(),createdAt:y.number(),leadAgentId:y.string(),members:y.array(kR)});function Ew(){return bd(_R(),".yukino","teams")}function TR(t){return t.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()}function eo(t){return bd(Ew(),TR(t))}function $w(){try{return wR(Ew(),{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name)}catch{return[]}}function Pw(t){return bd(eo(t),"config.json")}function Cw(t){let e=Pw(t);if(!gR(e))return null;try{let r=JSON.parse(bR(e,"utf-8"));return xR.parse(r)}catch{return null}}function Rw(t,e){try{let r=Pw(t);yR(SR(r),{recursive:!0}),vR(r,JSON.stringify(e,null,2),"utf-8")}catch{}}import{mkdirSync as $R,readFileSync as mB,writeFileSync as PR,existsSync as gB}from"fs";import{join as Mw}from"path";var _B=z({module:"teams"}),CR=y.object({tool_use_id:y.string(),tool_name:y.string(),arguments:y.record(y.string(),y.unknown())}),RR=y.object({tool_use_id:y.string(),content:y.string(),is_error:y.boolean().optional()}),SB=y.object({role:y.string(),content:y.string().optional(),tool_uses:y.array(CR).optional(),tool_results:y.array(RR).optional()});function MR(t){let e=[];for(let r of t.getMessages()){let s={role:r.role,content:Sh(r.content)};r.toolUses&&r.toolUses.length>0&&(s.tool_uses=r.toolUses.map(n=>({tool_use_id:n.toolUseId,tool_name:n.toolName,arguments:n.arguments}))),r.toolResults&&r.toolResults.length>0&&(s.tool_results=r.toolResults.map(n=>({tool_use_id:n.toolUseId,content:n.content,is_error:n.isError||void 0}))),e.push(s)}return e}function AR(t,e){return Mw(t,".yukino","teams",e,"transcripts")}function Aw(t,e,r,s){let n=AR(t,e);$R(n,{recursive:!0});let o=Mw(n,`${r}.json`),i=MR(s);return PR(o,JSON.stringify(i,null,2),"utf-8"),o}var Ow=z({module:"teams"}),la=class t{name;mode;members=new Map;leadMailbox;mailboxDir;workDir;leadAgentId="";description;createdAt=Math.floor(Date.now()/1e3);constructor(e,r,s){this.name=e,this.mode=r,this.workDir=s,this.mailboxDir=vd(eo(e),"inboxes"),IR(this.mailboxDir,{recursive:!0}),this.leadMailbox=new Xn(this.mailboxDir,"lead")}addMember(e){let r=new Xn(this.mailboxDir,e),s={name:e,active:!1,mailbox:r,agentId:e,joinedAt:Math.floor(Date.now()/1e3)};return this.members.set(e,s),this.persist(),s}setMemberMeta(e,r){let s=this.members.get(e);s&&(s.agentType=r.agentType,s.model=r.model,s.worktreePath=r.worktreePath,this.persist())}snapshot(){return{name:this.name,description:this.description,createdAt:this.createdAt,leadAgentId:this.leadAgentId,members:[...this.members.values()].map(e=>({agentId:e.agentId??e.name,name:e.name,agentType:e.agentType,model:e.model,joinedAt:e.joinedAt??0,worktreePath:e.worktreePath,backendType:this.mode,isActive:e.active}))}}persist(){Rw(this.name,this.snapshot())}static IDLE_POLL_INTERVAL_MS=500;static SHUTDOWN_PREFIX="[shutdown]";spawnTeammate(e,r,s,n,o,i){if(this.mode==="in-process"){this.spawnInProcess(e,r,s,n,i);return}try{this.spawnExternal(e,r,o,i)}catch{this.spawnInProcess(e,r,s,n,i)}}spawnExternal(e,r,s,n){let o=this.addMember(e);o.active=!0,Cs().register(e,e),o.uiState={name:e,teamName:this.name,status:"running",progress:wd(),...n?{originToolCallId:n}:{},startTime:Date.now(),spinnerVerb:Qa()};let i=process.argv[1]??"src/main.tsx",a={mode:this.mode,command:"node",args:["run",i,"--teammate","--team-dir",this.mailboxDir,"--team-name",this.name,"--member-name",e,"--task",r,...s?["--provider-base-url",s]:[],"--input-type=module"],cwd:this.workDir},{cancel:c,paneId:l}=ww(a);o.cancel=c,o.paneId=l,o.external=!0}spawnInProcess(e,r,s,n,o){let i=this.addMember(e);i.active=!0,i.checker=n;let a=new AbortController;i.cancel=()=>{a.abort()},Cs().register(e,e);let c={name:e,teamName:this.name,status:"running",progress:wd(),...o?{originToolCallId:o}:{},startTime:Date.now(),spinnerVerb:Qa()};i.uiState=c;let l=d=>{switch(d.type){case"tool_use":Sw(c.progress,d.toolId,d.toolName,d.args);break;case"tool_result":kw(c.progress,d.toolId);break;case"usage":Tw(c.progress,d.usage.inputTokens,d.usage.outputTokens);break;case"turn_complete":xw(c.progress);break}},u=(async()=>{let d=r,h="available";try{for(;i.active;){c.status="running";let p=await s(hw(this.name,e,d),l,a.signal);if(ca(c.progress),c.lastMessage=p.length>200?p.slice(0,200)+"...":p,a.signal.aborted||!i.active){c.status="stopped",await this.leadMailbox.send(e,`[idle] ${e} (reason: stopped)`);break}if(i.checker?.mode==="plan"){c.status="idle";let f=await this.runPlanApproval(i,this.readPlanForReview());if(f===null)break;d=f;continue}c.status="idle",await this.leadMailbox.send(e,`[idle] ${e} (reason: ${h})`),h="available";let m=await this.waitForNextPromptOrShutdown(i);if(m.shutdown||!i.active){let f=m.shutdown;if(f?.type===Fr){let g=Qi(i.name,f.requestId??"",!0,"acknowledged, shutting down");await this.leadMailbox.send(i.name,g.text,g)}break}d=m.prompt}c.status!=="stopped"&&(c.status="completed")}catch(p){a.signal.aborted||!i.active?(c.status="stopped",c.lastMessage="Stopped",await this.leadMailbox.send(e,`[idle] ${e} (reason: stopped)`)):(Ow.error({err:p},"teams operation failed"),c.status="failed",c.lastMessage=A(p),await this.leadMailbox.send(e,`[idle] ${e} (reason: failed)`))}finally{if(i.active=!1,ca(c.progress),c.status==="running"&&(c.status="idle"),i.conversation)try{Aw(this.workDir,this.name,e,i.conversation)}catch(p){Ow.error({err:p},"teams operation failed")}}})();i.done=u}async waitForNextPromptOrShutdown(e){for(;e.active;){await new Promise(o=>setTimeout(o,t.IDLE_POLL_INTERVAL_MS));let r=e.mailbox.receiveSync();if(r.length===0)continue;let s=r.find(o=>Hy(o));return s?{prompt:"",shutdown:s}:{prompt:`You have new messages from your team:
106
106
 
107
107
  ${r.map(o=>`From ${o.from}: ${o.text}`).join(`
108
108
 
@@ -483,7 +483,7 @@ switch ($payload.action) {
483
483
  'type' { [YukinoComputer]::Text([string]$payload.text) }
484
484
  default { throw "Unsupported action: $($payload.action)" }
485
485
  }
486
- `;var lb=["key","hold_key","type","cursor_position","mouse_move","left_mouse_down","left_mouse_up","left_click","left_click_drag","right_click","middle_click","double_click","triple_click","scroll","wait","screenshot","zoom","click","drag","keypress","move"],ob=y.tuple([y.number().int().nonnegative(),y.number().int().nonnegative()]),ub=y.looseObject({x:y.number().int().nonnegative(),y:y.number().int().nonnegative()}),db=["click","double_click","drag","keypress","move","screenshot","scroll","type","wait"],hb=100,nM=y.looseObject({type:y.enum(db),button:y.enum(["left","right","wheel","back","forward"]).optional(),x:y.number().int().nonnegative().optional(),y:y.number().int().nonnegative().optional(),keys:y.array(y.string().min(1)).max(8).optional(),path:y.array(ub).min(2).max(200).optional(),scrollX:y.number().optional(),scrollY:y.number().optional(),text:y.string().max(1e4).optional()}),oM=y.looseObject({id:y.string().min(1),code:y.string().optional(),message:y.string().optional()}),iM=y.looseObject({action:y.enum(lb).optional(),actions:y.array(nM).min(1).max(hb).optional(),pendingSafetyChecks:y.array(oM).optional(),status:y.enum(["in_progress","completed","incomplete"]).optional(),coordinate:ob.optional(),duration:y.number().nonnegative().max(60).optional(),region:y.tuple([y.number().int().nonnegative(),y.number().int().nonnegative(),y.number().int().nonnegative(),y.number().int().nonnegative()]).optional(),scroll_amount:y.number().optional(),scroll_direction:y.enum(["up","down","left","right"]).optional(),start_coordinate:ob.optional(),text:y.string().max(1e4).optional(),x:y.number().int().nonnegative().optional(),y:y.number().int().nonnegative().optional(),button:y.enum(["left","right","wheel","middle","back","forward"]).optional(),keys:y.array(y.string().min(1)).max(8).optional(),path:y.array(ub).min(2).max(200).optional(),scroll_x:y.number().optional(),scroll_y:y.number().optional()}),js=15e3,aM=32*1024*1024,ib=1366,ab=900;function cM(t){return t==="darwin"?"mac":t==="win32"?"windows":"linux"}function lM(t,e,r={}){let s=r.timeoutMs??js,n=r.maxOutputBytes??aM;return new Promise((o,i)=>{let a=rM(t,[...e],{env:r.env??process.env,shell:!1,stdio:["ignore","pipe","pipe"],windowsHide:!0}),c=!1,l=0,u=[],d=[],h=w=>{c||(c=!0,clearTimeout(g),r.signal?.removeEventListener("abort",m),w())},p=w=>{a.kill(),h(()=>{i(new Error(w))})},m=()=>{p(`${t} was interrupted.`)},f=(w,v)=>{if(l+=w.length,l>n){p(`${t} exceeded the ${String(n)} byte output limit.`);return}v.push(w)},g=setTimeout(()=>{p(`${t} timed out after ${String(s)}ms.`)},s);g.unref(),a.stdout.on("data",w=>{f(w,u)}),a.stderr.on("data",w=>{f(w,d)}),a.on("error",w=>{h(()=>{i(w.code==="ENOENT"?new Error(`${t} is not installed or not on PATH.`):w)})}),a.on("close",w=>{h(()=>{o({code:w??1,stdout:Buffer.concat(u),stderr:Buffer.concat(d).toString("utf8").trim()})})}),r.signal?.addEventListener("abort",m,{once:!0}),r.signal?.aborted&&m()})}function Td(t){if(t.coordinate)return{x:t.coordinate[0],y:t.coordinate[1]};if(t.x!==void 0&&t.y!==void 0)return{x:t.x,y:t.y};throw new Error(`action=${String(t.action)} requires coordinate or x and y.`)}function ro(t){return t.keys?.length?t.keys:t.text?t.text.split("+").map(e=>e.trim()).filter(Boolean):[]}function uM(t){switch(t.action){case"screenshot":return"screenshot";case"zoom":{if(!t.region||t.region[2]<=t.region[0]||t.region[3]<=t.region[1])throw new Error("action=zoom requires region [x1, y1, x2, y2] with positive area.");return{region:t.region}}case"wait":return{action:"wait",duration:t.duration??1};case"cursor_position":return{action:"cursor_position"};case"type":if(t.text===void 0)throw new Error("action=type requires text.");return{action:"type",text:t.text};case"key":case"keypress":{let e=ro(t);if(e.length===0)throw new Error(`action=${t.action} requires text or keys.`);return{action:"key",keys:e}}case"hold_key":{let e=ro(t);if(e.length===0||t.duration===void 0)throw new Error("action=hold_key requires text or keys and duration.");return{action:"hold_key",keys:e,duration:t.duration}}case"mouse_move":case"move":return{action:"mouse_move",...Td(t),keys:t.keys};case"left_mouse_down":case"left_mouse_up":return{action:t.action,keys:t.keys};case"left_click_drag":{if(!t.start_coordinate)throw new Error("action=left_click_drag requires start_coordinate.");let e=Td(t);return{action:"left_click_drag",path:[{x:t.start_coordinate[0],y:t.start_coordinate[1]},e],keys:t.keys}}case"drag":{if(!t.path)throw new Error("action=drag requires a path with at least two points.");return{action:"left_click_drag",path:t.path,keys:t.keys}}case"left_click":case"right_click":case"middle_click":case"double_click":case"triple_click":case"click":{let e=Td(t),r=t.action==="right_click"?"right":t.action==="middle_click"?"middle":t.action==="click"?t.button==="wheel"?"middle":t.button??"left":"left",s=t.action==="double_click"?2:t.action==="triple_click"?3:1;return{action:"mouse_click",button:r,clicks:s,...e,keys:ro(t)}}case"scroll":{let e=t.coordinate?{x:t.coordinate[0],y:t.coordinate[1]}:t.x!==void 0&&t.y!==void 0?{x:t.x,y:t.y}:{};if(t.scroll_x!==void 0||t.scroll_y!==void 0){let s=n=>n===0?0:Math.sign(n)*Math.max(1,Math.round(Math.abs(n)/100));return{action:"scroll",...e,scrollX:s(t.scroll_x??0),scrollY:s(t.scroll_y??0),keys:ro(t)}}if(t.scroll_amount===void 0||!t.scroll_direction)throw new Error("action=scroll requires scroll_amount and scroll_direction, or scroll_x and scroll_y.");let r=Math.max(1,Math.round(Math.abs(t.scroll_amount)));return{action:"scroll",...e,scrollX:t.scroll_direction==="left"?-r:t.scroll_direction==="right"?r:0,scrollY:t.scroll_direction==="up"?-r:t.scroll_direction==="down"?r:0,keys:ro(t)}}default:throw new Error("action is required.")}}function dM(t){let e={...t.x!==void 0?{x:t.x}:{},...t.y!==void 0?{y:t.y}:{}};switch(t.type){case"click":return{action:"click",...t.button?{button:t.button}:{},...e,keys:t.keys};case"double_click":return{action:"double_click",...e,keys:t.keys};case"drag":return{action:"drag",path:t.path,keys:t.keys};case"keypress":return{action:"keypress",keys:t.keys};case"move":return{action:"move",...e,keys:t.keys};case"screenshot":return{action:"screenshot"};case"scroll":return{action:"scroll",...e,scroll_x:t.scrollX??0,scroll_y:t.scrollY??0,keys:t.keys};case"type":return{action:"type",text:t.text};case"wait":return{action:"wait"}}}function Br(t,e){return new Error(`${t} failed: ${e.stderr||e.stdout.toString("utf8").trim()||`exit ${String(e.code)}`}`)}var cb=class{name="ComputerUse";description;category="command";deferred=!1;displayHeightPx;displayNumber;displayWidthPx;enableZoom;environment;platform;run;coordinateScaleX=1;coordinateScaleY=1;macHelperPromise;constructor(e={}){this.displayHeightPx=e.displayHeightPx??ab,this.displayNumber=e.displayNumber,this.displayWidthPx=e.displayWidthPx??ib,this.enableZoom=e.enableZoom??!0,this.platform=e.platform??process.platform,this.environment=e.environment??cM(this.platform),this.run=e.runCommand??lM,this.description=`Control the current ${this.environment} computer with screenshots, mouse, keyboard, scrolling, waiting, and zoom. Use screenshot before choosing coordinates and verify consequential actions with another screenshot. Two call styles are supported: Anthropic-style single actions (action + coordinate/scroll_amount/scroll_direction/start_coordinate/region/text), and OpenAI-style batches (actions[] of typed actions with x/y/button/keys/path/scrollX/scrollY/text, plus pendingSafetyChecks and status; a screenshot is returned after the batch). Flat OpenAI aliases (action=click/drag/keypress/move) are also accepted.`}isConcurrencySafe(e){return!1}schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{action:{type:"string",enum:lb,description:"Anthropic-style single computer action. Send either action or actions, not both."},actions:{type:"array",items:{type:"object",properties:{type:{type:"string",enum:db,description:"OpenAI-style action type: click (button, x, y, keys), double_click (x, y, keys), drag (path, keys), keypress (keys), move (x, y, keys), screenshot, scroll (x, y, scrollX, scrollY, keys), type (text), wait."},button:{type:"string",enum:["left","right","wheel","back","forward"],description:"Button for type=click."},x:{type:"integer",minimum:0},y:{type:"integer",minimum:0},keys:{type:"array",items:{type:"string"},maxItems:8,description:"Keys held during the action, or pressed by keypress."},path:{type:"array",items:{type:"object",properties:{x:{type:"integer",minimum:0},y:{type:"integer",minimum:0}},required:["x","y"],additionalProperties:!1},minItems:2,maxItems:200,description:"Drag path for type=drag."},scrollX:{type:"number",description:"Horizontal scroll delta for type=scroll."},scrollY:{type:"number",description:"Vertical scroll delta for type=scroll."},text:{type:"string",description:"Text to type for type=type."}},required:["type"],additionalProperties:!1},minItems:1,maxItems:hb,description:"OpenAI-style ordered batch of computer actions, executed in sequence; a screenshot is returned after the batch."},pendingSafetyChecks:{type:"array",items:{type:"object",properties:{id:{type:"string"},code:{type:"string"},message:{type:"string"}},required:["id"],additionalProperties:!1},description:"OpenAI-style safety checks raised with the batch; acknowledged in the tool result."},status:{type:"string",enum:["in_progress","completed","incomplete"],description:"OpenAI-style status of the computer call; echoed in the tool result."},coordinate:{type:"array",items:{type:"integer",minimum:0},minItems:2,maxItems:2,description:"Anthropic-style [x, y] coordinate in the latest screenshot space."},duration:{type:"number",minimum:0,maximum:60,description:"Seconds for hold_key or wait."},region:{type:"array",items:{type:"integer",minimum:0},minItems:4,maxItems:4,description:"Zoom region [x1, y1, x2, y2] in the latest screenshot space."},scroll_amount:{type:"number",description:"Anthropic-style number of wheel clicks to scroll."},scroll_direction:{type:"string",enum:["up","down","left","right"]},start_coordinate:{type:"array",items:{type:"integer",minimum:0},minItems:2,maxItems:2,description:"Anthropic-style drag start coordinate."},text:{type:"string",description:"Text to type, or a '+'-separated key combination."},x:{type:"integer",minimum:0,description:"OpenAI-style x coordinate."},y:{type:"integer",minimum:0,description:"OpenAI-style y coordinate."},button:{type:"string",enum:["left","right","wheel","middle","back","forward"],description:"Button for action=click."},keys:{type:"array",items:{type:"string"},maxItems:8,description:"OpenAI-style keys held during an action or pressed by keypress."},path:{type:"array",items:{type:"object",properties:{x:{type:"integer",minimum:0},y:{type:"integer",minimum:0}},required:["x","y"],additionalProperties:!1},minItems:2,maxItems:200,description:"OpenAI-style drag path."},scroll_x:{type:"number",description:"OpenAI-style horizontal scroll delta."},scroll_y:{type:"number",description:"OpenAI-style vertical scroll delta."}},required:[],additionalProperties:!1}}}async execute(e,r){let s=Po(iM,r);if(!s.success)return{output:`Error: ${y.prettifyError(s.error)}`,isError:!0};let n=s.data,o=n.actions??[];if(o.length>0&&n.action!==void 0)return{output:"Error: send either action (Anthropic-style, one action per call) or actions (OpenAI-style batch), not both.",isError:!0};if(o.length===0&&n.action===void 0)return{output:"Error: action (Anthropic-style) or actions (OpenAI-style batch) is required.",isError:!0};try{return e.abortSignal?.throwIfAborted(),o.length>0?await this.executeBatch(e,n):await this.runSingle(e,n)}catch(i){return{output:`Error: ${A(i)}`,isError:!0}}}async runSingle(e,r){let s=uM(r);if(s==="screenshot")return await this.screenshot(e.abortSignal);if("region"in s)return await this.screenshot(e.abortSignal,s.region);if(s.action==="wait")return await nb((s.duration??1)*1e3,void 0,{signal:e.abortSignal}),{output:"Wait completed.",isError:!1};let n=this.toNativeCoordinates(s),o=await this.executeNative(n,e.abortSignal);if(n.action==="cursor_position"&&o){let[i,a]=o.split(",").map(Number);Number.isFinite(i)&&Number.isFinite(a)&&(o=`${String(Math.round(i/this.coordinateScaleX))},${String(Math.round(a/this.coordinateScaleY))}`)}return{output:o||`Computer action ${r.action??"batch"} completed.`,isError:!1}}async executeBatch(e,r){let s=r.actions??[],n=[],o;for(let[a,c]of s.entries()){e.abortSignal?.throwIfAborted();let l;try{l=await this.runSingle(e,dM(c))}catch(u){return{output:`Error at actions[${String(a)}] (${c.type}): ${A(u)}`,isError:!0}}if(l.isError)return{output:`Error at actions[${String(a)}] (${c.type}): ${l.output}`,contentBlocks:l.contentBlocks,isError:!0};n.push(c.type),c.type==="screenshot"&&(o=l)}o??=await this.screenshot(e.abortSignal).catch(a=>({output:`Actions completed, but the follow-up screenshot failed: ${A(a)}`,isError:!1}));let i=[r.status?`Status: ${r.status}.`:"",r.pendingSafetyChecks?.length?`Acknowledged safety checks: ${r.pendingSafetyChecks.map(a=>a.id).join(", ")}.`:""].filter(Boolean).join(" ");return{output:`${o.output} Executed ${String(n.length)} action(s): ${n.join(", ")}.${i?` ${i}`:""}`,contentBlocks:o.contentBlocks,isError:!1}}toNativeCoordinates(e){let r=s=>({x:Math.round(s.x*this.coordinateScaleX),y:Math.round(s.y*this.coordinateScaleY)});return{...e,...e.x!==void 0&&e.y!==void 0?r({x:e.x,y:e.y}):{},...e.path?{path:e.path.map(r)}:{}}}async executeNative(e,r){switch(this.platform){case"darwin":return this.executeMac(e,r);case"win32":return this.executeWindows(e,r);case"linux":return this.executeLinux(e,r);default:throw new Error(`ComputerUse is not supported on ${this.platform}.`)}}async executeMac(e,r){return this.runMacPayload(e,r,e.action==="hold_key"?Math.max(js,(e.duration??0)*1e3+5e3):js)}async runMacPayload(e,r,s=js){let n=await this.getMacHelper(r),o=await this.run(n,[],{env:{...process.env,YUKINO_COMPUTER_INPUT:Buffer.from(JSON.stringify(e)).toString("base64")},signal:r,timeoutMs:s});if(o.code!==0)throw Br("macOS computer helper",o);return o.stdout.toString("utf8").trim()}async getMacHelper(e){this.macHelperPromise??=this.compileMacHelper(e);try{return await this.macHelperPromise}catch(r){throw this.macHelperPromise=void 0,r}}async compileMacHelper(e){let r=await tb(to(sb(),"yukino-computer-helper-")),s=to(r,"main.swift"),n=to(r,"computer-helper");try{await sM(s,Xw,"utf8");let o=await this.run("/usr/bin/xcrun",["swiftc","-O",s,"-o",n],{signal:e,timeoutMs:12e4});if(o.code!==0)throw Br("swiftc",o);return n}catch(o){throw await rb(r,{recursive:!0,force:!0}),o}}async executeWindows(e,r){let s=await this.run("powershell.exe",["-NoProfile","-NonInteractive","-Sta","-Command",eb],{env:{...process.env,YUKINO_COMPUTER_INPUT:Buffer.from(JSON.stringify(e)).toString("base64")},signal:r,timeoutMs:e.action==="hold_key"?Math.max(js,(e.duration??0)*1e3+5e3):js});if(s.code!==0)throw Br("powershell.exe",s);return s.stdout.toString("utf8").trim()}async executeLinux(e,r){let s=async l=>{let u=await this.run("xdotool",l,{signal:r});if(u.code!==0)throw Br("xdotool",u);return u.stdout.toString("utf8").trim()},n=e.keys??[],o=async()=>{for(let l of n)await s(["keydown",l])},i=async()=>{for(let l of[...n].reverse())await s(["keyup",l])},a=async l=>{await o();try{await l()}finally{await i()}},c=async()=>{e.x!==void 0&&e.y!==void 0&&await s(["mousemove","--sync",String(e.x),String(e.y)])};switch(e.action){case"cursor_position":{let l=await s(["getmouselocation","--shell"]),u=/(?:^|\n)X=(\d+)/.exec(l)?.[1],d=/(?:^|\n)Y=(\d+)/.exec(l)?.[1];if(!u||!d)throw new Error(`Unable to parse cursor position: ${l}`);return`${u},${d}`}case"mouse_move":return await a(c),"";case"left_mouse_down":return await s(["mousedown","1"]),"";case"left_mouse_up":return await s(["mouseup","1"]),"";case"mouse_click":{await c();let l=e.button==="right"?3:e.button==="middle"?2:e.button==="back"?8:e.button==="forward"?9:1;return await a(async()=>{await s(["click","--repeat",String(e.clicks??1),"--delay","80",String(l)])}),""}case"left_click_drag":{let l=e.path??[];if(l.length<2)throw new Error("Drag path must contain at least two points.");return await a(async()=>{await s(["mousemove","--sync",String(l[0].x),String(l[0].y)]),await s(["mousedown","1"]);try{for(let u of l.slice(1))await s(["mousemove","--sync",String(u.x),String(u.y)])}finally{await s(["mouseup","1"])}}),""}case"scroll":return await c(),await a(async()=>{let l=[[e.scrollY??0,(e.scrollY??0)<0?4:5],[e.scrollX??0,(e.scrollX??0)<0?6:7]];for(let[u,d]of l)u!==0&&await s(["click","--repeat",String(Math.abs(u)),String(d)])}),"";case"key":return await s(["key",n.join("+")]),"";case"hold_key":await o();try{await nb((e.duration??0)*1e3,void 0,{signal:r})}finally{await i()}return"";case"type":return await s(["type","--delay","1","--",e.text??""]),""}}async screenshot(e,r){let s=await this.captureScreenshot(e),n=await Ns(s.bytes).metadata();if(!n.width||!n.height)throw new Error("Unable to determine screenshot dimensions.");if(r){let d=Math.round(r[0]*this.coordinateScaleX),h=Math.round(r[1]*this.coordinateScaleY),p=Math.round(r[2]*this.coordinateScaleX),m=Math.round(r[3]*this.coordinateScaleY),f=n.width/s.width,g=n.height/s.height,w=Math.max(0,Math.min(n.width-1,Math.round(d*f))),v=Math.max(0,Math.min(n.height-1,Math.round(h*g))),S=Math.max(w+1,Math.min(n.width,Math.round(p*f))),x=Math.max(v+1,Math.min(n.height,Math.round(m*g))),_=await Ns(s.bytes).extract({left:w,top:v,width:S-w,height:x-v}).png({compressionLevel:8}).toBuffer();return this.imageResult(_,`Zoomed screenshot of [${r.join(", ")}].`)}let o=Math.min(1,ib/s.width,ab/s.height),i=Math.max(1,Math.round(s.width*o)),a=Math.max(1,Math.round(s.height*o)),c=await Ns(s.bytes).resize(i,a,{fit:"fill"}).png({compressionLevel:8}).toBuffer(),l=await this.imageResult(c,`Screenshot ${String(i)}x${String(a)}. Use this coordinate space for subsequent actions.`),u=l.contentBlocks?.[0];if(u?.type==="image"&&u.source.type==="base64"){let d=await Ns(Buffer.from(u.source.data,"base64")).metadata();d.width&&d.height&&(this.coordinateScaleX=s.width/d.width,this.coordinateScaleY=s.height/d.height,l.output=`Screenshot ${String(d.width)}x${String(d.height)}. Use this coordinate space for subsequent actions.`)}return l}async imageResult(e,r){let s=await Oo(e,"image/png"),n={type:"image",source:{type:"base64",media_type:s.mediaType,data:s.data}};return{output:r,contentBlocks:[n],isError:!1}}async captureScreenshot(e){let r=await tb(to(sb(),"yukino-computer-")),s=to(r,"screenshot.png");try{switch(this.platform){case"darwin":{let n=await this.run("/usr/sbin/screencapture",["-x","-m","-t","png",s],{signal:e});if(n.code!==0)throw Br("screencapture",n);let o=await this.runMacPayload({action:"screen_size"},e).catch(()=>""),[i,a]=o.split(",").map(Number),c=await xd(s),l=await Ns(c).metadata();return{bytes:c,width:Number.isFinite(i)&&i>0?i:l.width??1,height:Number.isFinite(a)&&a>0?a:l.height??1}}case"win32":{let n=await this.run("powershell.exe",["-NoProfile","-NonInteractive","-Sta","-Command",Qw],{env:{...process.env,YUKINO_SCREENSHOT_PATH:s},signal:e});if(n.code!==0)throw Br("powershell.exe",n);let[o,i]=n.stdout.toString("utf8").trim().split(",").map(Number);return{bytes:await xd(s),width:o,height:i}}case"linux":{let n=[["gnome-screenshot",["-f",s]],["scrot",[s]],["import",["-window","root",s]]],o="No screenshot backend succeeded.";for(let[i,a]of n)try{let c=await this.run(i,a,{signal:e});if(c.code===0){let l=await xd(s),u=await Ns(l).metadata();return{bytes:l,width:u.width??1,height:u.height??1}}o=Br(i,c).message}catch(c){o=A(c)}throw new Error(`${o} Install gnome-screenshot, scrot, or ImageMagick; xdotool is required for input control.`)}default:throw new Error(`ComputerUse is not supported on ${this.platform}.`)}}finally{await rb(r,{recursive:!0,force:!0})}}};import{readFile as yM,writeFile as wM}from"fs/promises";import{resolve as bM}from"path";function pb(t,e){let r=t.split(`
486
+ `;var lb=["key","hold_key","type","cursor_position","mouse_move","left_mouse_down","left_mouse_up","left_click","left_click_drag","right_click","middle_click","double_click","triple_click","scroll","wait","screenshot","zoom","click","drag","keypress","move"],ob=y.tuple([y.number().int().nonnegative(),y.number().int().nonnegative()]),ub=y.object({x:y.number().int().nonnegative(),y:y.number().int().nonnegative()}),db=["click","double_click","drag","keypress","move","screenshot","scroll","type","wait"],hb=100,nM=y.object({type:y.enum(db),button:y.enum(["left","right","wheel","back","forward"]).optional(),x:y.number().int().nonnegative().optional(),y:y.number().int().nonnegative().optional(),keys:y.array(y.string().min(1)).max(8).optional(),path:y.array(ub).min(2).max(200).optional(),scrollX:y.number().optional(),scrollY:y.number().optional(),text:y.string().max(1e4).optional()}),oM=y.object({id:y.string().min(1),code:y.string().optional(),message:y.string().optional()}),iM=y.object({action:y.enum(lb).optional(),actions:y.array(nM).min(1).max(hb).optional(),pendingSafetyChecks:y.array(oM).optional(),status:y.enum(["in_progress","completed","incomplete"]).optional(),coordinate:ob.optional(),duration:y.number().nonnegative().max(60).optional(),region:y.tuple([y.number().int().nonnegative(),y.number().int().nonnegative(),y.number().int().nonnegative(),y.number().int().nonnegative()]).optional(),scroll_amount:y.number().optional(),scroll_direction:y.enum(["up","down","left","right"]).optional(),start_coordinate:ob.optional(),text:y.string().max(1e4).optional(),x:y.number().int().nonnegative().optional(),y:y.number().int().nonnegative().optional(),button:y.enum(["left","right","wheel","middle","back","forward"]).optional(),keys:y.array(y.string().min(1)).max(8).optional(),path:y.array(ub).min(2).max(200).optional(),scroll_x:y.number().optional(),scroll_y:y.number().optional()}),js=15e3,aM=32*1024*1024,ib=1366,ab=900;function cM(t){return t==="darwin"?"mac":t==="win32"?"windows":"linux"}function lM(t,e,r={}){let s=r.timeoutMs??js,n=r.maxOutputBytes??aM;return new Promise((o,i)=>{let a=rM(t,[...e],{env:r.env??process.env,shell:!1,stdio:["ignore","pipe","pipe"],windowsHide:!0}),c=!1,l=0,u=[],d=[],h=w=>{c||(c=!0,clearTimeout(g),r.signal?.removeEventListener("abort",m),w())},p=w=>{a.kill(),h(()=>{i(new Error(w))})},m=()=>{p(`${t} was interrupted.`)},f=(w,v)=>{if(l+=w.length,l>n){p(`${t} exceeded the ${String(n)} byte output limit.`);return}v.push(w)},g=setTimeout(()=>{p(`${t} timed out after ${String(s)}ms.`)},s);g.unref(),a.stdout.on("data",w=>{f(w,u)}),a.stderr.on("data",w=>{f(w,d)}),a.on("error",w=>{h(()=>{i(w.code==="ENOENT"?new Error(`${t} is not installed or not on PATH.`):w)})}),a.on("close",w=>{h(()=>{o({code:w??1,stdout:Buffer.concat(u),stderr:Buffer.concat(d).toString("utf8").trim()})})}),r.signal?.addEventListener("abort",m,{once:!0}),r.signal?.aborted&&m()})}function Td(t){if(t.coordinate)return{x:t.coordinate[0],y:t.coordinate[1]};if(t.x!==void 0&&t.y!==void 0)return{x:t.x,y:t.y};throw new Error(`action=${String(t.action)} requires coordinate or x and y.`)}function ro(t){return t.keys?.length?t.keys:t.text?t.text.split("+").map(e=>e.trim()).filter(Boolean):[]}function uM(t){switch(t.action){case"screenshot":return"screenshot";case"zoom":{if(!t.region||t.region[2]<=t.region[0]||t.region[3]<=t.region[1])throw new Error("action=zoom requires region [x1, y1, x2, y2] with positive area.");return{region:t.region}}case"wait":return{action:"wait",duration:t.duration??1};case"cursor_position":return{action:"cursor_position"};case"type":if(t.text===void 0)throw new Error("action=type requires text.");return{action:"type",text:t.text};case"key":case"keypress":{let e=ro(t);if(e.length===0)throw new Error(`action=${t.action} requires text or keys.`);return{action:"key",keys:e}}case"hold_key":{let e=ro(t);if(e.length===0||t.duration===void 0)throw new Error("action=hold_key requires text or keys and duration.");return{action:"hold_key",keys:e,duration:t.duration}}case"mouse_move":case"move":return{action:"mouse_move",...Td(t),keys:t.keys};case"left_mouse_down":case"left_mouse_up":return{action:t.action,keys:t.keys};case"left_click_drag":{if(!t.start_coordinate)throw new Error("action=left_click_drag requires start_coordinate.");let e=Td(t);return{action:"left_click_drag",path:[{x:t.start_coordinate[0],y:t.start_coordinate[1]},e],keys:t.keys}}case"drag":{if(!t.path)throw new Error("action=drag requires a path with at least two points.");return{action:"left_click_drag",path:t.path,keys:t.keys}}case"left_click":case"right_click":case"middle_click":case"double_click":case"triple_click":case"click":{let e=Td(t),r=t.action==="right_click"?"right":t.action==="middle_click"?"middle":t.action==="click"?t.button==="wheel"?"middle":t.button??"left":"left",s=t.action==="double_click"?2:t.action==="triple_click"?3:1;return{action:"mouse_click",button:r,clicks:s,...e,keys:ro(t)}}case"scroll":{let e=t.coordinate?{x:t.coordinate[0],y:t.coordinate[1]}:t.x!==void 0&&t.y!==void 0?{x:t.x,y:t.y}:{};if(t.scroll_x!==void 0||t.scroll_y!==void 0){let s=n=>n===0?0:Math.sign(n)*Math.max(1,Math.round(Math.abs(n)/100));return{action:"scroll",...e,scrollX:s(t.scroll_x??0),scrollY:s(t.scroll_y??0),keys:ro(t)}}if(t.scroll_amount===void 0||!t.scroll_direction)throw new Error("action=scroll requires scroll_amount and scroll_direction, or scroll_x and scroll_y.");let r=Math.max(1,Math.round(Math.abs(t.scroll_amount)));return{action:"scroll",...e,scrollX:t.scroll_direction==="left"?-r:t.scroll_direction==="right"?r:0,scrollY:t.scroll_direction==="up"?-r:t.scroll_direction==="down"?r:0,keys:ro(t)}}default:throw new Error("action is required.")}}function dM(t){let e={...t.x!==void 0?{x:t.x}:{},...t.y!==void 0?{y:t.y}:{}};switch(t.type){case"click":return{action:"click",...t.button?{button:t.button}:{},...e,keys:t.keys};case"double_click":return{action:"double_click",...e,keys:t.keys};case"drag":return{action:"drag",path:t.path,keys:t.keys};case"keypress":return{action:"keypress",keys:t.keys};case"move":return{action:"move",...e,keys:t.keys};case"screenshot":return{action:"screenshot"};case"scroll":return{action:"scroll",...e,scroll_x:t.scrollX??0,scroll_y:t.scrollY??0,keys:t.keys};case"type":return{action:"type",text:t.text};case"wait":return{action:"wait"}}}function Br(t,e){return new Error(`${t} failed: ${e.stderr||e.stdout.toString("utf8").trim()||`exit ${String(e.code)}`}`)}var cb=class{name="ComputerUse";description;category="command";deferred=!1;displayHeightPx;displayNumber;displayWidthPx;enableZoom;environment;platform;run;coordinateScaleX=1;coordinateScaleY=1;macHelperPromise;constructor(e={}){this.displayHeightPx=e.displayHeightPx??ab,this.displayNumber=e.displayNumber,this.displayWidthPx=e.displayWidthPx??ib,this.enableZoom=e.enableZoom??!0,this.platform=e.platform??process.platform,this.environment=e.environment??cM(this.platform),this.run=e.runCommand??lM,this.description=`Control the current ${this.environment} computer with screenshots, mouse, keyboard, scrolling, waiting, and zoom. Use screenshot before choosing coordinates and verify consequential actions with another screenshot. Two call styles are supported: Anthropic-style single actions (action + coordinate/scroll_amount/scroll_direction/start_coordinate/region/text), and OpenAI-style batches (actions[] of typed actions with x/y/button/keys/path/scrollX/scrollY/text, plus pendingSafetyChecks and status; a screenshot is returned after the batch). Flat OpenAI aliases (action=click/drag/keypress/move) are also accepted.`}isConcurrencySafe(e){return!1}schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{action:{type:"string",enum:lb,description:"Anthropic-style single computer action. Send either action or actions, not both."},actions:{type:"array",items:{type:"object",properties:{type:{type:"string",enum:db,description:"OpenAI-style action type: click (button, x, y, keys), double_click (x, y, keys), drag (path, keys), keypress (keys), move (x, y, keys), screenshot, scroll (x, y, scrollX, scrollY, keys), type (text), wait."},button:{type:"string",enum:["left","right","wheel","back","forward"],description:"Button for type=click."},x:{type:"integer",minimum:0},y:{type:"integer",minimum:0},keys:{type:"array",items:{type:"string"},maxItems:8,description:"Keys held during the action, or pressed by keypress."},path:{type:"array",items:{type:"object",properties:{x:{type:"integer",minimum:0},y:{type:"integer",minimum:0}},required:["x","y"],additionalProperties:!1},minItems:2,maxItems:200,description:"Drag path for type=drag."},scrollX:{type:"number",description:"Horizontal scroll delta for type=scroll."},scrollY:{type:"number",description:"Vertical scroll delta for type=scroll."},text:{type:"string",description:"Text to type for type=type."}},required:["type"],additionalProperties:!1},minItems:1,maxItems:hb,description:"OpenAI-style ordered batch of computer actions, executed in sequence; a screenshot is returned after the batch."},pendingSafetyChecks:{type:"array",items:{type:"object",properties:{id:{type:"string"},code:{type:"string"},message:{type:"string"}},required:["id"],additionalProperties:!1},description:"OpenAI-style safety checks raised with the batch; acknowledged in the tool result."},status:{type:"string",enum:["in_progress","completed","incomplete"],description:"OpenAI-style status of the computer call; echoed in the tool result."},coordinate:{type:"array",items:{type:"integer",minimum:0},minItems:2,maxItems:2,description:"Anthropic-style [x, y] coordinate in the latest screenshot space."},duration:{type:"number",minimum:0,maximum:60,description:"Seconds for hold_key or wait."},region:{type:"array",items:{type:"integer",minimum:0},minItems:4,maxItems:4,description:"Zoom region [x1, y1, x2, y2] in the latest screenshot space."},scroll_amount:{type:"number",description:"Anthropic-style number of wheel clicks to scroll."},scroll_direction:{type:"string",enum:["up","down","left","right"]},start_coordinate:{type:"array",items:{type:"integer",minimum:0},minItems:2,maxItems:2,description:"Anthropic-style drag start coordinate."},text:{type:"string",description:"Text to type, or a '+'-separated key combination."},x:{type:"integer",minimum:0,description:"OpenAI-style x coordinate."},y:{type:"integer",minimum:0,description:"OpenAI-style y coordinate."},button:{type:"string",enum:["left","right","wheel","middle","back","forward"],description:"Button for action=click."},keys:{type:"array",items:{type:"string"},maxItems:8,description:"OpenAI-style keys held during an action or pressed by keypress."},path:{type:"array",items:{type:"object",properties:{x:{type:"integer",minimum:0},y:{type:"integer",minimum:0}},required:["x","y"],additionalProperties:!1},minItems:2,maxItems:200,description:"OpenAI-style drag path."},scroll_x:{type:"number",description:"OpenAI-style horizontal scroll delta."},scroll_y:{type:"number",description:"OpenAI-style vertical scroll delta."}},required:[],additionalProperties:!1}}}async execute(e,r){let s=Po(iM,r);if(!s.success)return{output:`Error: ${y.prettifyError(s.error)}`,isError:!0};let n=s.data,o=n.actions??[];if(o.length>0&&n.action!==void 0)return{output:"Error: send either action (Anthropic-style, one action per call) or actions (OpenAI-style batch), not both.",isError:!0};if(o.length===0&&n.action===void 0)return{output:"Error: action (Anthropic-style) or actions (OpenAI-style batch) is required.",isError:!0};try{return e.abortSignal?.throwIfAborted(),o.length>0?await this.executeBatch(e,n):await this.runSingle(e,n)}catch(i){return{output:`Error: ${A(i)}`,isError:!0}}}async runSingle(e,r){let s=uM(r);if(s==="screenshot")return await this.screenshot(e.abortSignal);if("region"in s)return await this.screenshot(e.abortSignal,s.region);if(s.action==="wait")return await nb((s.duration??1)*1e3,void 0,{signal:e.abortSignal}),{output:"Wait completed.",isError:!1};let n=this.toNativeCoordinates(s),o=await this.executeNative(n,e.abortSignal);if(n.action==="cursor_position"&&o){let[i,a]=o.split(",").map(Number);Number.isFinite(i)&&Number.isFinite(a)&&(o=`${String(Math.round(i/this.coordinateScaleX))},${String(Math.round(a/this.coordinateScaleY))}`)}return{output:o||`Computer action ${r.action??"batch"} completed.`,isError:!1}}async executeBatch(e,r){let s=r.actions??[],n=[],o;for(let[a,c]of s.entries()){e.abortSignal?.throwIfAborted();let l;try{l=await this.runSingle(e,dM(c))}catch(u){return{output:`Error at actions[${String(a)}] (${c.type}): ${A(u)}`,isError:!0}}if(l.isError)return{output:`Error at actions[${String(a)}] (${c.type}): ${l.output}`,contentBlocks:l.contentBlocks,isError:!0};n.push(c.type),c.type==="screenshot"&&(o=l)}o??=await this.screenshot(e.abortSignal).catch(a=>({output:`Actions completed, but the follow-up screenshot failed: ${A(a)}`,isError:!1}));let i=[r.status?`Status: ${r.status}.`:"",r.pendingSafetyChecks?.length?`Acknowledged safety checks: ${r.pendingSafetyChecks.map(a=>a.id).join(", ")}.`:""].filter(Boolean).join(" ");return{output:`${o.output} Executed ${String(n.length)} action(s): ${n.join(", ")}.${i?` ${i}`:""}`,contentBlocks:o.contentBlocks,isError:!1}}toNativeCoordinates(e){let r=s=>({x:Math.round(s.x*this.coordinateScaleX),y:Math.round(s.y*this.coordinateScaleY)});return{...e,...e.x!==void 0&&e.y!==void 0?r({x:e.x,y:e.y}):{},...e.path?{path:e.path.map(r)}:{}}}async executeNative(e,r){switch(this.platform){case"darwin":return this.executeMac(e,r);case"win32":return this.executeWindows(e,r);case"linux":return this.executeLinux(e,r);default:throw new Error(`ComputerUse is not supported on ${this.platform}.`)}}async executeMac(e,r){return this.runMacPayload(e,r,e.action==="hold_key"?Math.max(js,(e.duration??0)*1e3+5e3):js)}async runMacPayload(e,r,s=js){let n=await this.getMacHelper(r),o=await this.run(n,[],{env:{...process.env,YUKINO_COMPUTER_INPUT:Buffer.from(JSON.stringify(e)).toString("base64")},signal:r,timeoutMs:s});if(o.code!==0)throw Br("macOS computer helper",o);return o.stdout.toString("utf8").trim()}async getMacHelper(e){this.macHelperPromise??=this.compileMacHelper(e);try{return await this.macHelperPromise}catch(r){throw this.macHelperPromise=void 0,r}}async compileMacHelper(e){let r=await tb(to(sb(),"yukino-computer-helper-")),s=to(r,"main.swift"),n=to(r,"computer-helper");try{await sM(s,Xw,"utf8");let o=await this.run("/usr/bin/xcrun",["swiftc","-O",s,"-o",n],{signal:e,timeoutMs:12e4});if(o.code!==0)throw Br("swiftc",o);return n}catch(o){throw await rb(r,{recursive:!0,force:!0}),o}}async executeWindows(e,r){let s=await this.run("powershell.exe",["-NoProfile","-NonInteractive","-Sta","-Command",eb],{env:{...process.env,YUKINO_COMPUTER_INPUT:Buffer.from(JSON.stringify(e)).toString("base64")},signal:r,timeoutMs:e.action==="hold_key"?Math.max(js,(e.duration??0)*1e3+5e3):js});if(s.code!==0)throw Br("powershell.exe",s);return s.stdout.toString("utf8").trim()}async executeLinux(e,r){let s=async l=>{let u=await this.run("xdotool",l,{signal:r});if(u.code!==0)throw Br("xdotool",u);return u.stdout.toString("utf8").trim()},n=e.keys??[],o=async()=>{for(let l of n)await s(["keydown",l])},i=async()=>{for(let l of[...n].reverse())await s(["keyup",l])},a=async l=>{await o();try{await l()}finally{await i()}},c=async()=>{e.x!==void 0&&e.y!==void 0&&await s(["mousemove","--sync",String(e.x),String(e.y)])};switch(e.action){case"cursor_position":{let l=await s(["getmouselocation","--shell"]),u=/(?:^|\n)X=(\d+)/.exec(l)?.[1],d=/(?:^|\n)Y=(\d+)/.exec(l)?.[1];if(!u||!d)throw new Error(`Unable to parse cursor position: ${l}`);return`${u},${d}`}case"mouse_move":return await a(c),"";case"left_mouse_down":return await s(["mousedown","1"]),"";case"left_mouse_up":return await s(["mouseup","1"]),"";case"mouse_click":{await c();let l=e.button==="right"?3:e.button==="middle"?2:e.button==="back"?8:e.button==="forward"?9:1;return await a(async()=>{await s(["click","--repeat",String(e.clicks??1),"--delay","80",String(l)])}),""}case"left_click_drag":{let l=e.path??[];if(l.length<2)throw new Error("Drag path must contain at least two points.");return await a(async()=>{await s(["mousemove","--sync",String(l[0].x),String(l[0].y)]),await s(["mousedown","1"]);try{for(let u of l.slice(1))await s(["mousemove","--sync",String(u.x),String(u.y)])}finally{await s(["mouseup","1"])}}),""}case"scroll":return await c(),await a(async()=>{let l=[[e.scrollY??0,(e.scrollY??0)<0?4:5],[e.scrollX??0,(e.scrollX??0)<0?6:7]];for(let[u,d]of l)u!==0&&await s(["click","--repeat",String(Math.abs(u)),String(d)])}),"";case"key":return await s(["key",n.join("+")]),"";case"hold_key":await o();try{await nb((e.duration??0)*1e3,void 0,{signal:r})}finally{await i()}return"";case"type":return await s(["type","--delay","1","--",e.text??""]),""}}async screenshot(e,r){let s=await this.captureScreenshot(e),n=await Ns(s.bytes).metadata();if(!n.width||!n.height)throw new Error("Unable to determine screenshot dimensions.");if(r){let d=Math.round(r[0]*this.coordinateScaleX),h=Math.round(r[1]*this.coordinateScaleY),p=Math.round(r[2]*this.coordinateScaleX),m=Math.round(r[3]*this.coordinateScaleY),f=n.width/s.width,g=n.height/s.height,w=Math.max(0,Math.min(n.width-1,Math.round(d*f))),v=Math.max(0,Math.min(n.height-1,Math.round(h*g))),S=Math.max(w+1,Math.min(n.width,Math.round(p*f))),x=Math.max(v+1,Math.min(n.height,Math.round(m*g))),_=await Ns(s.bytes).extract({left:w,top:v,width:S-w,height:x-v}).png({compressionLevel:8}).toBuffer();return this.imageResult(_,`Zoomed screenshot of [${r.join(", ")}].`)}let o=Math.min(1,ib/s.width,ab/s.height),i=Math.max(1,Math.round(s.width*o)),a=Math.max(1,Math.round(s.height*o)),c=await Ns(s.bytes).resize(i,a,{fit:"fill"}).png({compressionLevel:8}).toBuffer(),l=await this.imageResult(c,`Screenshot ${String(i)}x${String(a)}. Use this coordinate space for subsequent actions.`),u=l.contentBlocks?.[0];if(u?.type==="image"&&u.source.type==="base64"){let d=await Ns(Buffer.from(u.source.data,"base64")).metadata();d.width&&d.height&&(this.coordinateScaleX=s.width/d.width,this.coordinateScaleY=s.height/d.height,l.output=`Screenshot ${String(d.width)}x${String(d.height)}. Use this coordinate space for subsequent actions.`)}return l}async imageResult(e,r){let s=await Oo(e,"image/png"),n={type:"image",source:{type:"base64",media_type:s.mediaType,data:s.data}};return{output:r,contentBlocks:[n],isError:!1}}async captureScreenshot(e){let r=await tb(to(sb(),"yukino-computer-")),s=to(r,"screenshot.png");try{switch(this.platform){case"darwin":{let n=await this.run("/usr/sbin/screencapture",["-x","-m","-t","png",s],{signal:e});if(n.code!==0)throw Br("screencapture",n);let o=await this.runMacPayload({action:"screen_size"},e).catch(()=>""),[i,a]=o.split(",").map(Number),c=await xd(s),l=await Ns(c).metadata();return{bytes:c,width:Number.isFinite(i)&&i>0?i:l.width??1,height:Number.isFinite(a)&&a>0?a:l.height??1}}case"win32":{let n=await this.run("powershell.exe",["-NoProfile","-NonInteractive","-Sta","-Command",Qw],{env:{...process.env,YUKINO_SCREENSHOT_PATH:s},signal:e});if(n.code!==0)throw Br("powershell.exe",n);let[o,i]=n.stdout.toString("utf8").trim().split(",").map(Number);return{bytes:await xd(s),width:o,height:i}}case"linux":{let n=[["gnome-screenshot",["-f",s]],["scrot",[s]],["import",["-window","root",s]]],o="No screenshot backend succeeded.";for(let[i,a]of n)try{let c=await this.run(i,a,{signal:e});if(c.code===0){let l=await xd(s),u=await Ns(l).metadata();return{bytes:l,width:u.width??1,height:u.height??1}}o=Br(i,c).message}catch(c){o=A(c)}throw new Error(`${o} Install gnome-screenshot, scrot, or ImageMagick; xdotool is required for input control.`)}default:throw new Error(`ComputerUse is not supported on ${this.platform}.`)}}finally{await rb(r,{recursive:!0,force:!0})}}};import{readFile as yM,writeFile as wM}from"fs/promises";import{resolve as bM}from"path";function pb(t,e){let r=t.split(`
487
487
  `),s=e.split(`
488
488
  `),n=0,o=Math.min(r.length,s.length);for(;n<o&&r[n]===s[n];)n++;let i=0,a=o-n;for(;i<a&&r[r.length-1-i]===s[s.length-1-i];)i++;let c=r.slice(n,r.length-i),l=s.slice(n,s.length-i),u=Math.max(0,n-3),d=r.slice(u,n),h=Math.min(r.length,r.length-i+3),p=r.slice(r.length-i,h),m=[],f=u+1,g=u+1,w=!1,v=(S,x,_)=>{if(m.length>=200){w=!0;return}m.push(`${S} ${String(x).padStart(4)} ${_}`)};for(let S of d)v(" ",f,S),f++,g++;for(let S of c)v("-",f,S),f++;for(let S of l)v("+",g,S),g++;for(let S of p)v(" ",f,S),f++,g++;return w&&m.push(` ... (diff truncated at ${String(200)} lines)`),{text:m.join(`
489
489
  `),additions:l.length,removals:c.length}}import{realpath as fb}from"fs/promises";import{basename as hM,dirname as pM,join as fM,resolve as mM}from"path";var ya=new Map;async function gM(t){let e=mM(t);try{return await fb(e)}catch{try{return fM(await fb(pM(e)),hM(e))}catch{return e}}}async function wa(t,e){let r=await gM(t),s=ya.get(r)??Promise.resolve(),n=()=>{},o=new Promise(a=>{n=a}),i=s.then(()=>o);return ya.set(r,i),s.then(e).finally(()=>{n(),ya.get(r)===i&&ya.delete(r)})}var mb=z({module:"tools"}),ba=class{name="EditFile";description=Gw;category="write";schema(){let e={type:"object",properties:{file_path:{type:"string",description:"Path to the existing file, absolute or relative to the Agent's working directory. Read it first with ReadFile."},old_string:{type:"string",description:"Non-empty exact text to replace, including whitespace but excluding ReadFile line-number prefixes. Must match once unless replace_all is true."},new_string:{type:"string",description:"Replacement text. May be empty to delete the matched text; must differ from old_string."},replace_all:{type:"boolean",description:"Replace all occurrences of old_string (default false)",default:!1}},required:["file_path","old_string","new_string"]};return{name:this.name,description:this.description,input_schema:e}}async execute(e,r){let s=$(r,"file_path"),n=$(r,"old_string"),o=Yt(r,"replace_all");if(!s)return{output:"Error: file_path is required",isError:!0};let i=bM(e.workDir,s);if(!n)return{output:"Error: old_string is required",isError:!0};if(typeof r.new_string!="string")return{output:"Error: new_string is required",isError:!0};let a=r.new_string;return n===a?{output:"Error: old_string and new_string MUST be different",isError:!0}:wa(i,async()=>{if(e.abortSignal?.aborted)return{output:"Error: operation interrupted",isError:!0};if(e.fileStateCache){let h=e.fileStateCache.check(i);if(!h.ok)return{output:h.error,isError:!0}}e.fileHistory?.trackEdit(i);let c;try{c=await yM(i,"utf-8")}catch(h){return mb.error({err:h},"tool operation failed"),{output:`Error reading file: ${A(h)}`,isError:!0}}let l=c.split(n).length-1;if(l===0)return{output:"Error: old_string not found in file",isError:!0};if(!o&&l>1)return{output:`Error: old_string found ${String(l)} times in file. It must be unique. Add more surrounding context, or set replace_all to true`,isError:!0};let u=()=>a,d=o?c.replaceAll(n,u):c.replace(n,u);try{await wM(i,d,"utf-8"),e.fileStateCache?.update(i);let{text:h,additions:p,removals:m}=pb(c,d);return{output:`${o&&l>1?`Updated ${i} with ${String(p)} addition${p===1?"":"s"} and ${String(m)} removal${m===1?"":"s"} (${String(l)} replacements)`:`Updated ${i} with ${String(p)} addition${p===1?"":"s"} and ${String(m)} removal${m===1?"":"s"}`}
@@ -524,7 +524,7 @@ Branch: ${n.branch}
524
524
  Head: ${n.headCommit}`,isError:!1}}catch(n){return nz.error({err:n},"tool operation failed"),{output:`Error creating worktree: ${A(n)}`,isError:!0}}}};var oz=z({module:"tools"}),a0=class{name="ExitWorktree";description="Exit and optionally cleanup a git worktree";category="write";schema(){let e={type:"object",properties:{path:{type:"string",description:"Worktree path"},branch:{type:"string",description:"Worktree branch name"},git_root:{type:"string",description:"Git root directory"},head_commit:{type:"string",description:"Original HEAD commit for change detection"}},required:["path","branch","git_root"]};return{name:this.name,description:this.description,input_schema:e}}async execute(e,r){let s=$(r,"path"),n=$(r,"branch"),o=$(r,"git_root"),i=$(r,"head_commit");if(!s||!n||!o)return{output:"Error: path, branch and git_root are required",isError:!0};if(!i)return{output:`Original head_commit was not provided; worktree kept at: ${s}
525
525
  Branch: ${n}`,isError:!1};if(!await ow(s,i))try{return await nw(s,n,o),{output:`Worktree cleaned up (no changes): ${s}`,isError:!1}}catch(c){return oz.error({err:c},"tool operation failed"),{output:`Error cleaning up worktree: ${A(c)}`,isError:!0}}return{output:`Worktree has changes, kept at: ${s}
526
526
  Branch: ${n}`,isError:!1}}};import{randomUUID as iz}from"crypto";import{existsSync as l0,mkdirSync as az,readFileSync as cz,renameSync as lz,unlinkSync as uz,writeFileSync as dz}from"fs";import{dirname as hz,join as pz}from"path";var c0=(t,e,r)=>y.preprocess(s=>s===void 0||typeof s=="string"&&!s.trim()?t:s,y.union([y.number(),y.string().trim().regex(/^\d+$/,"Enter a whole number").transform(Number)]).pipe(y.number().int().min(e).max(r))),fz=Ja.extend({name:y.string().trim().min(1,"Name is required"),base_url:y.url("Enter a valid HTTP(S) URL").refine(t=>/^https?:\/\//i.test(t),"Use an HTTP(S) URL"),api_key:y.string().trim().min(1,"API key is required"),model:y.string().trim().min(1,"Model is required"),thinking:y.enum(Ro).optional(),context_window:c0(mh,1e3,1e7),max_output_tokens:c0(gh,1,1e6)}).refine(t=>t.max_output_tokens<=t.context_window,{path:["max_output_tokens"],message:"Max output tokens must not exceed the context window"}).transform(t=>({...t,thinking:wh(t)}));function Yd(t){if(!l0(t))return{};let e;try{e=Ye.load(cz(t,"utf-8"))}catch{throw new Error(`Unable to read existing ${t}; it has not been changed.`)}return y.record(y.string(),y.unknown()).parse(e??{})}function Jd(t,e){let r=hz(t);az(r,{recursive:!0});let s=pz(r,`.config-${iz()}.tmp`);try{dz(s,Ye.dump(e,{lineWidth:-1,noRefs:!0}),{encoding:"utf-8",mode:384,flag:"wx"}),lz(s,t)}finally{l0(s)&&uz(s)}}function d4(t,e){let r=fz.parse(t),s=Co(),n=Yd(s),i=[...y.array(y.record(y.string(),y.unknown())).parse(n.providers??[])];for(let u of e)i.some(d=>d.base_url===u.base_url)||i.push({...u});let a=[],c=!1;for(let u of i){if(u.base_url!==r.base_url){a.push(u);continue}c||(c=!0,a.push(r))}c||a.push(r);let l=a.map(u=>Ja.parse(u));return Jd(s,{...n,providers:a}),{provider:r,providers:l,replaced:c,path:s}}function h4(t,e){let r=Co(),s=Yd(r),n=y.array(y.record(y.string(),y.unknown())).parse(s.providers??[]),o=n.filter(a=>a.base_url===t);if(o.length===0)throw new Error(`Provider with base URL "${t}" not found in ${r}.`);let i=o.filter(a=>a.thinking!==e);if(i.length!==0){for(let a of i)a.thinking=e;Jd(r,{...s,providers:n})}}function p4(t){let e=Co(),r=Yd(e);r.default_provider!==t&&Jd(e,{...r,default_provider:t})}var u0=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=$(r,"subject"),n=$(r,"description"),o=$(r,"activeForm")||void 0;if(!s)return Promise.resolve({output:"Error: subject is required",isError:!0});let i=this.list.create(s,n,o);return Promise.resolve({output:`Task #${i.id} created successfully: ${i.subject}`,isError:!1})}},d0=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=$(r,"taskId"),n=this.list.get(s);return n?Promise.resolve({output:JSON.stringify(n,null,2),isError:!1}):Promise.resolve({output:"Task not found",isError:!0})}},h0=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(`
527
- `),isError:!1})}},p0=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 ih(mz,r);if(!s.success)return{output:A(s.error),isError:!0};let{taskId:n,status:o,subject:i,description:a,owner:c,addBlocks:l,addBlockedBy:u}=s.data;if(!n)return Promise.resolve({output:"Error: taskId is required",isError:!0});if(o==="deleted")return this.list.delete(n),Promise.resolve({output:`Task #${n} deleted`,isError:!1});let d={};return o&&(d.status=o),i&&(d.subject=i),a&&(d.description=a),c&&(d.owner=c),this.list.update(n,d)?(l&&this.list.addBlocks(n,l),u&&this.list.addBlockedBy(n,u),{output:`Updated task #${n} status`,isError:!1}):{output:"Task not found",isError:!0}}},mz=y.looseObject({taskId:y.string(),subject:y.string().optional(),description:y.string().optional(),status:y.enum(["pending","in_progress","completed","deleted"]).optional(),owner:y.string().optional(),addBlocks:y.array(y.string()).optional(),addBlockedBy:y.array(y.string()).optional()});var f0=class{name="ExitPlanMode";description=`
527
+ `),isError:!1})}},p0=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 ih(mz,r);if(!s.success)return{output:A(s.error),isError:!0};let{taskId:n,status:o,subject:i,description:a,owner:c,addBlocks:l,addBlockedBy:u}=s.data;if(!n)return Promise.resolve({output:"Error: taskId is required",isError:!0});if(o==="deleted")return this.list.delete(n),Promise.resolve({output:`Task #${n} deleted`,isError:!1});let d={};return o&&(d.status=o),i&&(d.subject=i),a&&(d.description=a),c&&(d.owner=c),this.list.update(n,d)?(l&&this.list.addBlocks(n,l),u&&this.list.addBlockedBy(n,u),{output:`Updated task #${n} status`,isError:!1}):{output:"Task not found",isError:!0}}},mz=y.object({taskId:y.string(),subject:y.string().optional(),description:y.string().optional(),status:y.enum(["pending","in_progress","completed","deleted"]).optional(),owner:y.string().optional(),addBlocks:y.array(y.string()).optional(),addBlockedBy:y.array(y.string()).optional()});var f0=class{name="ExitPlanMode";description=`
528
528
  Exit plan mode and present the plan for user approval.
529
529
  Call this when your plan is complete and written to the plan file.
530
530
  `;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()?this.planExists?.()?Promise.resolve({output:"You are not in plan mode. This tool is only for exiting plan mode after writing a plan. You can call AskUserQuestion tool to ask the user whether to execute the plan.",isError:!0}):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})}};var Xd=class{commands=new Map;aliasMap=new Map;register(e){if(this.commands.has(e.name))throw new Error(`Command '${e.name}' already registered`);if(this.aliasMap.has(e.name))throw new Error(`Command name '${e.name}' collides with alias of '${this.aliasMap.get(e.name)??""}'`);for(let r of e.aliases){if(this.commands.has(r))throw new Error(`Alias '${r}' for '${e.name}' collides with existing command name`);if(this.aliasMap.has(r))throw new Error(`Alias '${r}' for '${e.name}' already registered by '${this.aliasMap.get(r)??""}'`)}this.commands.set(e.name,e);for(let r of e.aliases)this.aliasMap.set(r,e.name)}hasConflict(e){if(this.find(e.name))return!0;for(let r of e.aliases)if(this.find(r))return!0;return!1}find(e){return this.commands.get(e)??this.commands.get(this.aliasMap.get(e)??"")}complete(e){let r=e.toLowerCase();return[...this.commands.values()].filter(s=>s.name.toLowerCase().startsWith(r)||s.aliases.some(n=>n.toLowerCase().startsWith(r)))}listCommands(){return[...this.commands.values()].sort((e,r)=>e.name.localeCompare(r.name))}};function v4(t){if(!t.startsWith("/"))return null;let e=t.slice(1).trim(),r=e.search(/\s/),s=r===-1?e:e.slice(0,r);return s.includes("/")?null:r===-1?{name:s,args:""}:{name:s,args:e.slice(r+1).trim()}}function _4(){let t=new Xd;return t.register({name:"login",aliases:[],type:"local_ui",description:"Configure, save, and activate an LLM provider",handler:()=>"login"}),t.register({name:"help",aliases:["h","?"],type:"local",description:"Show available commands",handler:e=>{if(e.args){let n=t.find(e.args);if(!n)return`Unknown command: ${e.args}`;let o=`/${n.name} \u2014 ${n.description}
@@ -540,7 +540,7 @@ Type /help <command> for details.`,s}}),t.register({name:"clear",aliases:[],type
540
540
  Commands: create, add <name>, remove <name>, list, status`}}),t.register({name:"review",aliases:[],type:"prompt",description:"Review the uncommitted code changes for bugs and improvements",handler:e=>"Review the current uncommitted changes. Run `git status` and `git diff` to see them, then report concrete findings (file:line) for correctness bugs, security issues, and obvious simplifications. Be specific and concise."+(e.args?`
541
541
 
542
542
  Focus on: ${e.args}`:"")}),t.register({name:"rewind",aliases:[],type:"local_ui",description:"Rewind conversation to a previous checkpoint",handler:()=>"rewind"}),t.register({name:"mcp",aliases:[],type:"local",description:"Show MCP server status; /mcp reload re-reads the config and reconnects",handler:()=>"mcp"}),t.register({name:"sandbox",aliases:["sb"],type:"local_ui",description:"Toggle OS sandbox mode for command execution",handler:()=>"sandbox"}),t.register({name:"thinking",aliases:["think"],type:"local",description:"Show or set the thinking level (off, minimal, low, medium, high, xhigh, max)",handler:e=>{let r=e.args.trim().toLowerCase(),s=e.availableThinkingLevels?.()??Ro;if(!r)return`Thinking level: ${e.thinkingLevel?e.thinkingLevel():"unknown"}
543
- Usage: /thinking <${s.join(" | ")}>`;if(!yh(r))return`Unknown thinking level "${r}". Available levels: ${s.join(", ")}`;if(!s.includes(r))return`Thinking level "${r}" is not supported. Available levels: ${s.join(", ")}`;if(!e.setThinkingLevel)return"Thinking level control is not available in this context.";let n;try{e.setThinkingLevel(r),n=e.thinkingLevel?.()??r}catch(i){return`Unable to set thinking level: ${i instanceof Error?i.message:String(i)}. Try /thinking <${s.join(" | ")}>. Nothing was saved.`}let o=n===r?"":` (requested ${r})`;if(e.persistThinkingLevel)try{return e.persistThinkingLevel(n),`Thinking level set to ${n}${o} and saved.`}catch(i){let a=i instanceof Error?i.message:String(i);return`Thinking level set to ${n}${o} for this session, but saving failed: ${a}`}return`Thinking level set to ${n}${o}.`}}),t}import{readdirSync as yz,readFileSync as wz,statSync as bz,existsSync as vz}from"fs";import{homedir as _z}from"os";import{join as Qd}from"path";function P4(t){let e=new Map,r=[Qd(_z(),".yukino","commands"),Qd(t,".yukino","commands")];for(let s of r)if(vz(s))for(let n of m0(s,s))e.set(n.name,n);return[...e.values()]}function m0(t,e){let r;try{r=yz(e)}catch{return[]}let s=[];for(let n of r){let o=Qd(e,n),i;try{i=bz(o)}catch{continue}if(i.isDirectory())s.push(...m0(t,o));else if(n.endsWith(".md")){let a=xz(t,o);a&&s.push(a)}}return s}function Sz(t,e){return e.slice(t.length+1).replace(/\.md$/,"").split(/[/\\]/).map(s=>s.toLowerCase().replace(/ /g,"-")).join(":")}var kz=y.looseObject({description:y.string().optional(),"argument-hint":y.string().optional(),aliases:y.array(y.string()).optional()});function xz(t,e){let r;try{r=wz(e,"utf-8")}catch{return null}let s="",n="",o=[],i=r;if(r.startsWith("---")){let c=r.indexOf("---",3);if(c!==-1){let l=r.slice(3,c).trim();i=r.slice(c+3).trim();try{let u=Ye.load(l),d=tt(kz,u);s=d.description??"",n=d["argument-hint"]??"",o=d.aliases??[]}catch{}}}let a=Sz(t,e);return a?{name:a,aliases:Array.isArray(o)?o:[],type:"prompt",description:s||(n?`custom command (args: ${n})`:"custom command"),handler:c=>Tz(i,c.args)}:null}function Tz(t,e){return t.includes("$ARGUMENTS")?t.replaceAll("$ARGUMENTS",()=>e):e?`${t}
543
+ Usage: /thinking <${s.join(" | ")}>`;if(!yh(r))return`Unknown thinking level "${r}". Available levels: ${s.join(", ")}`;if(!s.includes(r))return`Thinking level "${r}" is not supported. Available levels: ${s.join(", ")}`;if(!e.setThinkingLevel)return"Thinking level control is not available in this context.";let n;try{e.setThinkingLevel(r),n=e.thinkingLevel?.()??r}catch(i){return`Unable to set thinking level: ${i instanceof Error?i.message:String(i)}. Try /thinking <${s.join(" | ")}>. Nothing was saved.`}let o=n===r?"":` (requested ${r})`;if(e.persistThinkingLevel)try{return e.persistThinkingLevel(n),`Thinking level set to ${n}${o} and saved.`}catch(i){let a=i instanceof Error?i.message:String(i);return`Thinking level set to ${n}${o} for this session, but saving failed: ${a}`}return`Thinking level set to ${n}${o}.`}}),t}import{readdirSync as yz,readFileSync as wz,statSync as bz,existsSync as vz}from"fs";import{homedir as _z}from"os";import{join as Qd}from"path";function P4(t){let e=new Map,r=[Qd(_z(),".yukino","commands"),Qd(t,".yukino","commands")];for(let s of r)if(vz(s))for(let n of m0(s,s))e.set(n.name,n);return[...e.values()]}function m0(t,e){let r;try{r=yz(e)}catch{return[]}let s=[];for(let n of r){let o=Qd(e,n),i;try{i=bz(o)}catch{continue}if(i.isDirectory())s.push(...m0(t,o));else if(n.endsWith(".md")){let a=xz(t,o);a&&s.push(a)}}return s}function Sz(t,e){return e.slice(t.length+1).replace(/\.md$/,"").split(/[/\\]/).map(s=>s.toLowerCase().replace(/ /g,"-")).join(":")}var kz=y.object({description:y.string().optional(),"argument-hint":y.string().optional(),aliases:y.array(y.string()).optional()});function xz(t,e){let r;try{r=wz(e,"utf-8")}catch{return null}let s="",n="",o=[],i=r;if(r.startsWith("---")){let c=r.indexOf("---",3);if(c!==-1){let l=r.slice(3,c).trim();i=r.slice(c+3).trim();try{let u=Ye.load(l),d=tt(kz,u);s=d.description??"",n=d["argument-hint"]??"",o=d.aliases??[]}catch{}}}let a=Sz(t,e);return a?{name:a,aliases:Array.isArray(o)?o:[],type:"prompt",description:s||(n?`custom command (args: ${n})`:"custom command"),handler:c=>Tz(i,c.args)}:null}function Tz(t,e){return t.includes("$ARGUMENTS")?t.replaceAll("$ARGUMENTS",()=>e):e?`${t}
544
544
 
545
545
  ${e}`:t}import{exec as Ez}from"child_process";var Us=z({module:"hooks"});function $z(t,e){return new Promise((r,s)=>{Ez(t,{shell:"bash",encoding:"utf-8",timeout:3e4,env:e.env,cwd:e.cwd,signal:e.signal,maxBuffer:10*1024*1024},(n,o)=>{n?s(n):r(o)})})}var g0=class{hooks;firedOnce=new Set;notifications=[];agentRunner;constructor(e){this.hooks=e}recordNotification(e){e.trim()&&this.notifications.push(e)}drainNotifications(){let e=this.notifications;return this.notifications=[],e}async fire(e,r,s={}){let n=[];for(let[o,i]of this.hooks.entries()){if(s.abortSignal?.aborted)break;if(i.event===e&&!(i.condition&&!Pz(i.condition,r))){if(i.once){let a=i.id===void 0?`index:${String(o)}`:`id:${i.id}`;if(this.firedOnce.has(a))continue;this.firedOnce.add(a)}if(i.async){this.executeAction(i,r,s).then(a=>{this.recordNotification(a.output)}).catch(a=>{this.recordNotification(`Async hook error: ${A(a)}`)});continue}try{let a=await this.executeAction(i,r,s);if(n.push(a),a.reject&&e==="pre_tool_use")break}catch(a){Us.error({err:a},"hooks operation failed");let c=i.on_error??"ignore";if(c==="fail"){let l=`Hook error: ${A(a)}`;n.push({output:l,success:!1,reject:!1})}else if(c==="reject"){let l=`Hook error (rejecting): ${A(a)}`;if(n.push({output:l,success:!1,reject:!0}),e==="pre_tool_use")break}}}}return n}async firePreToolHooks(e,r,s={}){let n={event:"pre_tool_use",toolName:e,args:r,filePath:$(r,"file_path",$(r,"path",""))},o=await this.fire("pre_tool_use",n,s);for(let i of o){if(i.reject)return{rejected:!0,reason:i.output};this.recordNotification(i.output)}return{rejected:!1,reason:""}}async executeAction(e,r,s){switch(e.action.type){case"command":{let n=e.action.command??"";try{return{output:(await $z(n,{cwd:s.workDir,signal:s.abortSignal,env:{...process.env,YUKINO_EVENT:r.event,YUKINO_TOOL:r.toolName??"",YUKINO_FILE_PATH:r.filePath??""}})).trim(),success:!0,reject:e.reject??!1}}catch(o){throw Us.error({err:o},"hooks operation failed"),o}}case"prompt":return{output:e.action.prompt??"",success:!0,reject:e.reject??!1};case"http":{let n=e.action.url??"",o=(e.action.method??"POST").toUpperCase();try{let i=await fetch(n,{method:o,headers:{"Content-Type":"application/json"},...o==="GET"||o==="HEAD"?{}:{body:JSON.stringify(r)},signal:s.abortSignal?AbortSignal.any([s.abortSignal,AbortSignal.timeout(3e4)]):AbortSignal.timeout(3e4)});if(!i.ok)throw await i.body?.cancel(),new Error(`HTTP hook failed with status ${String(i.status)}`);return{output:await i.text(),success:i.ok,reject:e.reject??!1}}catch(i){throw Us.error({err:i},"hooks operation failed"),i}}case"agent":{if(!this.agentRunner)throw new Error("agent-type hook configured but no AgentRunner registered");let n=e.action.prompt??e.action.command??"";try{return{output:await this.agentRunner(n,r),success:!0,reject:e.reject??!1}}catch(o){throw Us.error({err:o},"hooks operation failed"),o}}default:return{output:"",success:!0,reject:!1}}}};function Pz(t,e){let r=[[]],s=0,n=!1;for(let o=0;o<t.length;o++){t[o]==='"'&&(n=!n);let i=t.slice(o,o+2);!n&&(i==="&&"||i==="||")&&(r[r.length-1].push(t.slice(s,o)),i==="||"&&r.push([]),s=o+2,o++)}return r[r.length-1].push(t.slice(s)),!n&&r.some(o=>o.every(i=>y0(i,e)))}function y0(t,e){let r=t.trim();if(r.startsWith("!"))return!y0(r.slice(1),e);let s=/^(\w+)\s*==\s*"([^"]*)"$/.exec(r);if(s)return Ba(s[1],e)===s[2];let n=/^(\w+)\s*!=\s*"([^"]*)"$/.exec(r);if(n)return Ba(n[1],e)!==n[2];let o=/^(\w+)\s*=~\s*"([^"]*)"$/.exec(r);if(o){let a=Ba(o[1],e);try{return new RegExp(o[2]).test(a)}catch(c){return Us.error({err:c},"hooks operation failed"),!1}}let i=/^(\w+)\s*=\*\s*"([^"]*)"$/.exec(r);if(i){let a=Ba(i[1],e),c=i[2].split(/(\*\*\/|\*\*|\*|\?)/).map(l=>{switch(l){case"**/":return"(?:.*/)?";case"**":return".*";case"*":return"[^/]*";case"?":return"[^/]";default:return l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}}).join("");try{return new RegExp(`^${c}$`).test(a)}catch(l){return Us.error({err:l},"hooks operation failed"),!1}}return/^\w+$/.test(r)&&r===e.toolName}function Ba(t,e){switch(t){case"tool":return e.toolName??"";case"event":return e.event;case"file_path":return e.filePath??"";case"message":return e.message??"";default:return $(e.args??{},t,"")}}function I4(t){let e=new Set(["session_start","session_end","turn_start","turn_end","pre_send","post_receive","pre_tool_use","post_tool_use","shutdown"]),r=new Set(["command","prompt","http","agent"]),s=[];for(let n=0;n<t.length;n++){let o=t[n],i=o.id?`hook[${String(n)}] (id="${o.id}")`:`hook[${String(n)}]`;if(o.event?e.has(o.event)||s.push(`${i}: invalid event '${o.event}'`):s.push(`${i}: event is required`),!o.action.type)s.push(`${i}: action.type is required`);else if(!r.has(o.action.type))s.push(`${i}: invalid action type '${o.action.type}'`);else switch(o.action.type){case"command":o.action.command?.trim()||s.push(`${i}: action.command must be non-empty for type "command"`);break;case"prompt":o.action.prompt?.trim()||s.push(`${i}: action.prompt must be non-empty for type "prompt"`);break;case"http":o.action.url?.trim()||s.push(`${i}: action.url must be non-empty for type "http"`);break;case"agent":!o.action.prompt?.trim()&&!o.action.command?.trim()&&s.push(`${i}: action.prompt (or action.command) must be non-empty for type "agent"`);break}o.reject&&o.async&&s.push(`${i}: reject and async are mutually exclusive`)}return s.length>0?new Error(s.join("; ")):null}var w0="# MCP Server Instructions";function N4(t,e,r){t.hasReminderContaining(w0)||e.clear();let s=new Set(r.connectedServers()),n=r.connectedInstructions().filter(({serverName:i})=>!e.has(i)).sort((i,a)=>i.serverName.localeCompare(a.serverName)),o=[...e].filter(i=>!s.has(i)).sort();if(n.length===0&&o.length===0)return!1;for(let{serverName:i}of n)e.add(i);for(let i of o)e.delete(i);return t.addSystemReminder(Cz(n,o)),!0}function Cz(t,e){let r=[];if(t.length>0){let s=t.map(({serverName:n,text:o})=>`## ${n}
546
546
  ${o}`).join(`
@@ -553,7 +553,7 @@ ${s}`)}return e.length>0&&r.push(`The following MCP servers have disconnected. T
553
553
  ${e.join(`
554
554
  `)}`),r.join(`
555
555
 
556
- `)}import{readFileSync as eh,readdirSync as th,unlinkSync as Rz,existsSync as Wa,mkdirSync as Mz,writeFileSync as Az,statSync as Oz}from"fs";import{homedir as Iz}from"os";import{join as Bs,relative as zz,basename as rh}from"path";function b0(t){return Math.max(0,Math.floor((Date.now()-t)/864e5))}function v0(t){let e=b0(t);return e===0?"today":e===1?"yesterday":`${String(e)} days ago`}function _0(t){let e=b0(t);return e<=1?"":`Saved ${String(e)} days ago; not live state. Code behavior and file:line citations may be stale. Verify against current code before asserting facts.`}var Ws=z({module:"memory"}),_o=200,So=25e3,Ha="MEMORY.md";function S0(t){let e=Buffer.from(t,"utf-8");if(e.length<=So)return t;let r=e.lastIndexOf(10,So-1);if(r>0)return e.subarray(0,r).toString("utf-8");let s=So;for(;s>0&&(e[s]&192)===128;)s--;return e.subarray(0,s).toString("utf-8")}function sh(t){return t<1024?`${String(t)}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Nz=y.looseObject({selected_memories:y.array(y.string())}),jz=`# Task
556
+ `)}import{readFileSync as eh,readdirSync as th,unlinkSync as Rz,existsSync as Wa,mkdirSync as Mz,writeFileSync as Az,statSync as Oz}from"fs";import{homedir as Iz}from"os";import{join as Bs,relative as zz,basename as rh}from"path";function b0(t){return Math.max(0,Math.floor((Date.now()-t)/864e5))}function v0(t){let e=b0(t);return e===0?"today":e===1?"yesterday":`${String(e)} days ago`}function _0(t){let e=b0(t);return e<=1?"":`Saved ${String(e)} days ago; not live state. Code behavior and file:line citations may be stale. Verify against current code before asserting facts.`}var Ws=z({module:"memory"}),_o=200,So=25e3,Ha="MEMORY.md";function S0(t){let e=Buffer.from(t,"utf-8");if(e.length<=So)return t;let r=e.lastIndexOf(10,So-1);if(r>0)return e.subarray(0,r).toString("utf-8");let s=So;for(;s>0&&(e[s]&192)===128;)s--;return e.subarray(0,s).toString("utf-8")}function sh(t){return t<1024?`${String(t)}B`:t<1024*1024?`${(t/1024).toFixed(1)}KB`:`${(t/1024/1024).toFixed(1)}MB`}var Nz=y.object({selected_memories:y.array(y.string())}),jz=`# Task
557
557
  Select up to 5 listed memories clearly useful for the query, based on their paths and descriptions. Omit uncertain matches; return an empty list when none qualify.
558
558
 
559
559
  # Constraints
@@ -592,10 +592,10 @@ ${a}${c}`,u="";try{let f=new Kr;f.addUserMessage(jz+`
592
592
  ${Ye.dump({name:e.name,description:e.description,type:e.type},{forceQuotes:!0,lineWidth:-1,noRefs:!0,quotingType:'"'})}---
593
593
 
594
594
  ${e.body}
595
- `}};import{readFileSync as Yz,writeFileSync as Jz,mkdirSync as Xz,existsSync as Qz}from"fs";import{join as eN,dirname as tN}from"path";var rN=z({module:"todo"}),sN=y.enum(["pending","in_progress","completed"]),nN=y.object({id:y.string(),subject:y.string(),description:y.string(),status:sN,owner:y.string().optional(),activeForm:y.string().optional(),blocks:y.array(y.string()),blockedBy:y.array(y.string()),metadata:y.record(y.string(),y.unknown())}),$0=class{filePath;constructor(e,r){this.filePath=eN(e,".yukino","tasks",`${r}.json`)}load(){if(!Qz(this.filePath))return[];try{let e=Yz(this.filePath,"utf-8"),r=JSON.parse(e);return tt(y.array(nN),r)}catch(e){return rN.error({err:e},"todo operation failed"),[]}}save(e){Xz(tN(this.filePath),{recursive:!0}),Jz(this.filePath,JSON.stringify(e,null,2),"utf-8")}};var P0=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 n=parseInt(s.id,10);!Number.isNaN(n)&&n>r&&(r=n)}this.nextId=r+1}persist(){this.store?.save([...this.tasks.values()])}create(e,r,s){let n={id:String(this.nextId++),subject:e,description:r,status:"pending",activeForm:s,blocks:[],blockedBy:[],metadata:{}};return this.tasks.set(n.id,n),this.persist(),n}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 n of r){s.blocks.includes(n)||s.blocks.push(n);let o=this.tasks.get(n);o&&!o.blockedBy.includes(e)&&o.blockedBy.push(e)}this.persist()}}addBlockedBy(e,r){let s=this.tasks.get(e);if(s){for(let n of r){s.blockedBy.includes(n)||s.blockedBy.push(n);let o=this.tasks.get(n);o&&!o.blocks.includes(e)&&o.blocks.push(e)}this.persist()}}};var iN=y.looseObject({label:y.string(),description:y.string().optional()}),aN=y.object({question:y.string(),header:y.string(),options:y.array(iN),multiSelect:y.boolean()}),C0=class{constructor(e){this.ask=e}ask;name="AskUserQuestion";description=`
595
+ `}};import{readFileSync as Yz,writeFileSync as Jz,mkdirSync as Xz,existsSync as Qz}from"fs";import{join as eN,dirname as tN}from"path";var rN=z({module:"todo"}),sN=y.enum(["pending","in_progress","completed"]),nN=y.object({id:y.string(),subject:y.string(),description:y.string(),status:sN,owner:y.string().optional(),activeForm:y.string().optional(),blocks:y.array(y.string()),blockedBy:y.array(y.string()),metadata:y.record(y.string(),y.unknown())}),$0=class{filePath;constructor(e,r){this.filePath=eN(e,".yukino","tasks",`${r}.json`)}load(){if(!Qz(this.filePath))return[];try{let e=Yz(this.filePath,"utf-8"),r=JSON.parse(e);return tt(y.array(nN),r)}catch(e){return rN.error({err:e},"todo operation failed"),[]}}save(e){Xz(tN(this.filePath),{recursive:!0}),Jz(this.filePath,JSON.stringify(e,null,2),"utf-8")}};var P0=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 n=parseInt(s.id,10);!Number.isNaN(n)&&n>r&&(r=n)}this.nextId=r+1}persist(){this.store?.save([...this.tasks.values()])}create(e,r,s){let n={id:String(this.nextId++),subject:e,description:r,status:"pending",activeForm:s,blocks:[],blockedBy:[],metadata:{}};return this.tasks.set(n.id,n),this.persist(),n}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 n of r){s.blocks.includes(n)||s.blocks.push(n);let o=this.tasks.get(n);o&&!o.blockedBy.includes(e)&&o.blockedBy.push(e)}this.persist()}}addBlockedBy(e,r){let s=this.tasks.get(e);if(s){for(let n of r){s.blockedBy.includes(n)||s.blockedBy.push(n);let o=this.tasks.get(n);o&&!o.blocks.includes(e)&&o.blocks.push(e)}this.persist()}}};var iN=y.object({label:y.string(),description:y.string().optional()}),aN=y.object({question:y.string(),header:y.string(),options:y.array(iN),multiSelect:y.boolean()}),C0=class{constructor(e){this.ask=e}ask;name="AskUserQuestion";description=`
596
596
  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.
597
597
  Set multiSelect=true when the user may choose multiple options, or false for one mutually exclusive choice. Ask only for missing information that changes the task; do not re-request authorization already given.
598
- `;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:n,error:o}=await ah(y.looseObject({questions:y.array(aN)}),r);if(!s)return{output:o.message,isError:!0};let i=n.questions;if(!Array.isArray(i)||i.length<1||i.length>4)return{output:"Error: must have 1-4 questions",isError:!0};for(let l of i)if(!Array.isArray(l.options)||l.options.length<2||l.options.length>4)return{output:`Error: question '${l.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(([l,u])=>`"${l}" = "${u}"`).join(", ")}. You can now continue with the user's answers`,isError:!1}}};export{tc as a,Xt as b,zi as c,wy as d,Sy as e,Ey as f,jy as g,Dy as h,qy as i,$s as j,Ly as k,ta as l,ra as m,sa as n,na as o,Vy as p,Ky as q,ea as r,Zy as s,Yy as t,iw as u,cw as v,hw as w,As as x,A1 as y,G2 as z,K2 as A,Z2 as B,Xn as C,iB as D,pw as E,Iw as F,XB as G,KB as H,ZB as I,YB as J,Jw as K,cb as L,ba as M,ja as N,qa as O,Gv as P,La as Q,Zv as R,Yv as S,Fa as T,Qv as U,e0 as V,q9 as W,U9 as X,s0 as Y,n0 as Z,o0 as _,i0 as $,a0 as aa,fz as ba,d4 as ca,h4 as da,p4 as ea,u0 as fa,d0 as ga,h0 as ha,p0 as ia,f0 as ja,v4 as ka,_4 as la,P4 as ma,g0 as na,I4 as oa,N4 as pa,Ga as qa,ko as ra,x0 as sa,E0 as ta,$0 as ua,P0 as va,C0 as wa};
598
+ `;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:n,error:o}=await ah(y.object({questions:y.array(aN)}),r);if(!s)return{output:o.message,isError:!0};let i=n.questions;if(!Array.isArray(i)||i.length<1||i.length>4)return{output:"Error: must have 1-4 questions",isError:!0};for(let l of i)if(!Array.isArray(l.options)||l.options.length<2||l.options.length>4)return{output:`Error: question '${l.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(([l,u])=>`"${l}" = "${u}"`).join(", ")}. You can now continue with the user's answers`,isError:!1}}};export{tc as a,Xt as b,zi as c,wy as d,Sy as e,Ey as f,jy as g,Dy as h,qy as i,$s as j,Ly as k,ta as l,ra as m,sa as n,na as o,Vy as p,Ky as q,ea as r,Zy as s,Yy as t,iw as u,cw as v,hw as w,As as x,A1 as y,G2 as z,K2 as A,Z2 as B,Xn as C,iB as D,pw as E,Iw as F,XB as G,KB as H,ZB as I,YB as J,Jw as K,cb as L,ba as M,ja as N,qa as O,Gv as P,La as Q,Zv as R,Yv as S,Fa as T,Qv as U,e0 as V,q9 as W,U9 as X,s0 as Y,n0 as Z,o0 as _,i0 as $,a0 as aa,fz as ba,d4 as ca,h4 as da,p4 as ea,u0 as fa,d0 as ga,h0 as ha,p0 as ia,f0 as ja,v4 as ka,_4 as la,P4 as ma,g0 as na,I4 as oa,N4 as pa,Ga as qa,ko as ra,x0 as sa,E0 as ta,$0 as ua,P0 as va,C0 as wa};
599
599
  /*! Bundled license information:
600
600
 
601
601
  content-type/index.js: