@ours.network/mcp 0.13.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1,60 +1,60 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
3
- var s_=Object.create;var Ms=Object.defineProperty;var i_=Object.getOwnPropertyDescriptor;var a_=Object.getOwnPropertyNames;var c_=Object.getPrototypeOf,u_=Object.prototype.hasOwnProperty;var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ds=(e,t)=>{for(var r in t)Ms(e,r,{get:t[r],enumerable:!0})},l_=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of a_(t))!u_.call(e,o)&&o!==r&&Ms(e,o,{get:()=>t[o],enumerable:!(n=i_(t,o))||n.enumerable});return e};var Pu=(e,t,r)=>(r=e!=null?s_(c_(e)):{},l_(t||!e||!e.__esModule?Ms(r,"default",{value:e,enumerable:!0}):r,e));var _n=P(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.regexpCode=B.getEsmExportName=B.getProperty=B.safeStringify=B.stringify=B.strConcat=B.addCodeArg=B.str=B._=B.nil=B._Code=B.Name=B.IDENTIFIER=B._CodeOrName=void 0;var hn=class{};B._CodeOrName=hn;B.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Vt=class extends hn{constructor(t){if(super(),!B.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};B.Name=Vt;var He=class extends hn{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof Vt&&(r[n.str]=(r[n.str]||0)+1),r),{})}};B._Code=He;B.nil=new He("");function mf(e,...t){let r=[e[0]],n=0;for(;n<t.length;)ca(r,t[n]),r.push(e[++n]);return new He(r)}B._=mf;var aa=new He("+");function hf(e,...t){let r=[gn(e[0])],n=0;for(;n<t.length;)r.push(aa),ca(r,t[n]),r.push(aa,gn(e[++n]));return gw(r),new He(r)}B.str=hf;function ca(e,t){t instanceof He?e.push(...t._items):t instanceof Vt?e.push(t):e.push(vw(t))}B.addCodeArg=ca;function gw(e){let t=1;for(;t<e.length-1;){if(e[t]===aa){let r=_w(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function _w(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Vt||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Vt))return`"${e}${t.slice(1)}`}function yw(e,t){return t.emptyStr()?e:e.emptyStr()?t:hf`${e}${t}`}B.strConcat=yw;function vw(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:gn(Array.isArray(e)?e.join(","):e)}function ww(e){return new He(gn(e))}B.stringify=ww;function gn(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}B.safeStringify=gn;function $w(e){return typeof e=="string"&&B.IDENTIFIER.test(e)?new He(`.${e}`):mf`[${e}]`}B.getProperty=$w;function bw(e){if(typeof e=="string"&&B.IDENTIFIER.test(e))return new He(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}B.getEsmExportName=bw;function xw(e){return new He(e.toString())}B.regexpCode=xw});var da=P(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.ValueScope=Ze.ValueScopeName=Ze.Scope=Ze.varKinds=Ze.UsedValueState=void 0;var je=_n(),ua=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Mo;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Mo||(Ze.UsedValueState=Mo={}));Ze.varKinds={const:new je.Name("const"),let:new je.Name("let"),var:new je.Name("var")};var Do=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof je.Name?t:this.name(t)}name(t){return new je.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Ze.Scope=Do;var qo=class extends je.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,je._)`.${new je.Name(r)}[${n}]`}};Ze.ValueScopeName=qo;var Sw=(0,je._)`\n`,la=class extends Do{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?Sw:je.nil}}get(){return this._scope}name(t){return new qo(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,je._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let s=je.nil;for(let i in t){let a=t[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Mo.Started);let l=r(u);if(l){let d=this.opts.es5?Ze.varKinds.var:Ze.varKinds.const;s=(0,je._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,je._)`${s}${l}${this.opts._n}`;else throw new ua(u);c.set(u,Mo.Completed)})}return s}};Ze.ValueScope=la});var M=P(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.or=D.and=D.not=D.CodeGen=D.operators=D.varKinds=D.ValueScopeName=D.ValueScope=D.Scope=D.Name=D.regexpCode=D.stringify=D.getProperty=D.nil=D.strConcat=D.str=D._=void 0;var L=_n(),et=da(),Pt=_n();Object.defineProperty(D,"_",{enumerable:!0,get:function(){return Pt._}});Object.defineProperty(D,"str",{enumerable:!0,get:function(){return Pt.str}});Object.defineProperty(D,"strConcat",{enumerable:!0,get:function(){return Pt.strConcat}});Object.defineProperty(D,"nil",{enumerable:!0,get:function(){return Pt.nil}});Object.defineProperty(D,"getProperty",{enumerable:!0,get:function(){return Pt.getProperty}});Object.defineProperty(D,"stringify",{enumerable:!0,get:function(){return Pt.stringify}});Object.defineProperty(D,"regexpCode",{enumerable:!0,get:function(){return Pt.regexpCode}});Object.defineProperty(D,"Name",{enumerable:!0,get:function(){return Pt.Name}});var Vo=da();Object.defineProperty(D,"Scope",{enumerable:!0,get:function(){return Vo.Scope}});Object.defineProperty(D,"ValueScope",{enumerable:!0,get:function(){return Vo.ValueScope}});Object.defineProperty(D,"ValueScopeName",{enumerable:!0,get:function(){return Vo.ValueScopeName}});Object.defineProperty(D,"varKinds",{enumerable:!0,get:function(){return Vo.varKinds}});D.operators={GT:new L._Code(">"),GTE:new L._Code(">="),LT:new L._Code("<"),LTE:new L._Code("<="),EQ:new L._Code("==="),NEQ:new L._Code("!=="),NOT:new L._Code("!"),OR:new L._Code("||"),AND:new L._Code("&&"),ADD:new L._Code("+")};var gt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},pa=class extends gt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?et.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=kr(this.rhs,t,r)),this}get names(){return this.rhs instanceof L._CodeOrName?this.rhs.names:{}}},Uo=class extends gt{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof L.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=kr(this.rhs,t,r),this}get names(){let t=this.lhs instanceof L.Name?{}:{...this.lhs.names};return Fo(t,this.rhs)}},fa=class extends Uo{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},ma=class extends gt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},ha=class extends gt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},ga=class extends gt{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},_a=class extends gt{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=kr(this.code,t,r),this}get names(){return this.code instanceof L._CodeOrName?this.code.names:{}}},yn=class extends gt{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(t,r)||(zw(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Bt(t,r.names),{})}},_t=class extends yn{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},ya=class extends yn{},zr=class extends _t{};zr.kind="else";var Ht=class e extends _t{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new zr(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(gf(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=kr(this.condition,t,r),this}get names(){let t=super.names;return Fo(t,this.condition),this.else&&Bt(t,this.else.names),t}};Ht.kind="if";var Kt=class extends _t{};Kt.kind="for";var va=class extends Kt{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=kr(this.iteration,t,r),this}get names(){return Bt(super.names,this.iteration.names)}},wa=class extends Kt{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?et.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=Fo(super.names,this.from);return Fo(t,this.to)}},Lo=class extends Kt{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=kr(this.iterable,t,r),this}get names(){return Bt(super.names,this.iterable.names)}},vn=class extends _t{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};vn.kind="func";var wn=class extends yn{render(t){return"return "+super.render(t)}};wn.kind="return";var $a=class extends _t{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&Bt(t,this.catch.names),this.finally&&Bt(t,this.finally.names),t}},$n=class extends _t{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};$n.kind="catch";var bn=class extends _t{render(t){return"finally"+super.render(t)}};bn.kind="finally";var ba=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
4
- `:""},this._extScope=t,this._scope=new et.Scope({parent:t}),this._nodes=[new ya]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new pa(t,s,n)),s}const(t,r,n){return this._def(et.varKinds.const,t,r,n)}let(t,r,n){return this._def(et.varKinds.let,t,r,n)}var(t,r,n){return this._def(et.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Uo(t,r,n))}add(t,r){return this._leafNode(new fa(t,D.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==L.nil&&this._leafNode(new _a(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,L.addCodeArg)(r,o));return r.push("}"),new L._Code(r)}if(t,r,n){if(this._blockNode(new Ht(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new Ht(t))}else(){return this._elseNode(new zr)}endIf(){return this._endBlockNode(Ht,zr)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new va(t),r)}forRange(t,r,n,o,s=this.opts.es5?et.varKinds.var:et.varKinds.let){let i=this._scope.toName(t);return this._for(new wa(s,i,r,n),()=>o(i))}forOf(t,r,n,o=et.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof L.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,L._)`${i}.length`,a=>{this.var(s,(0,L._)`${i}[${a}]`),n(s)})}return this._for(new Lo("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?et.varKinds.var:et.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,L._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new Lo("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Kt)}label(t){return this._leafNode(new ma(t))}break(t){return this._leafNode(new ha(t))}return(t){let r=new wn;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(wn)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new $a;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new $n(s),r(s)}return n&&(this._currNode=o.finally=new bn,this.code(n)),this._endBlockNode($n,bn)}throw(t){return this._leafNode(new ga(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=L.nil,n,o){return this._blockNode(new vn(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(vn)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof Ht))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};D.CodeGen=ba;function Bt(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Fo(e,t){return t instanceof L._CodeOrName?Bt(e,t.names):e}function kr(e,t,r){if(e instanceof L.Name)return n(e);if(!o(e))return e;return new L._Code(e._items.reduce((s,i)=>(i instanceof L.Name&&(i=n(i)),i instanceof L._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||t[s.str]!==1?s:(delete t[s.str],i)}function o(s){return s instanceof L._Code&&s._items.some(i=>i instanceof L.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function zw(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function gf(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,L._)`!${xa(e)}`}D.not=gf;var kw=_f(D.operators.AND);function Pw(...e){return e.reduce(kw)}D.and=Pw;var Tw=_f(D.operators.OR);function Rw(...e){return e.reduce(Tw)}D.or=Rw;function _f(e){return(t,r)=>t===L.nil?r:r===L.nil?t:(0,L._)`${xa(t)} ${e} ${xa(r)}`}function xa(e){return e instanceof L.Name?e:(0,L._)`(${e})`}});var V=P(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});q.checkStrictMode=q.getErrorPath=q.Type=q.useFunc=q.setEvaluated=q.evaluatedPropsToName=q.mergeEvaluated=q.eachItem=q.unescapeJsonPointer=q.escapeJsonPointer=q.escapeFragment=q.unescapeFragment=q.schemaRefOrVal=q.schemaHasRulesButRef=q.schemaHasRules=q.checkUnknownRules=q.alwaysValidSchema=q.toHash=void 0;var re=M(),Ew=_n();function Iw(e){let t={};for(let r of e)t[r]=!0;return t}q.toHash=Iw;function Ow(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(wf(e,t),!$f(t,e.self.RULES.all))}q.alwaysValidSchema=Ow;function wf(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||Sf(e,`unknown keyword: "${s}"`)}q.checkUnknownRules=wf;function $f(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}q.schemaHasRules=$f;function Cw(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}q.schemaHasRulesButRef=Cw;function Aw({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,re._)`${r}`}return(0,re._)`${e}${t}${(0,re.getProperty)(n)}`}q.schemaRefOrVal=Aw;function Nw(e){return bf(decodeURIComponent(e))}q.unescapeFragment=Nw;function jw(e){return encodeURIComponent(za(e))}q.escapeFragment=jw;function za(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}q.escapeJsonPointer=za;function bf(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}q.unescapeJsonPointer=bf;function Zw(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}q.eachItem=Zw;function yf({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof re.Name?(s instanceof re.Name?e(o,s,i):t(o,s,i),i):s instanceof re.Name?(t(o,i,s),s):r(s,i);return a===re.Name&&!(c instanceof re.Name)?n(o,c):c}}q.mergeEvaluated={props:yf({mergeNames:(e,t,r)=>e.if((0,re._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,re._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,re._)`${r} || {}`).code((0,re._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,re._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,re._)`${r} || {}`),ka(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:xf}),items:yf({mergeNames:(e,t,r)=>e.if((0,re._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,re._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,re._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,re._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function xf(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,re._)`{}`);return t!==void 0&&ka(e,r,t),r}q.evaluatedPropsToName=xf;function ka(e,t,r){Object.keys(r).forEach(n=>e.assign((0,re._)`${t}${(0,re.getProperty)(n)}`,!0))}q.setEvaluated=ka;var vf={};function Mw(e,t){return e.scopeValue("func",{ref:t,code:vf[t.code]||(vf[t.code]=new Ew._Code(t.code))})}q.useFunc=Mw;var Sa;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Sa||(q.Type=Sa={}));function Dw(e,t,r){if(e instanceof re.Name){let n=t===Sa.Num;return r?n?(0,re._)`"[" + ${e} + "]"`:(0,re._)`"['" + ${e} + "']"`:n?(0,re._)`"/" + ${e}`:(0,re._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,re.getProperty)(e).toString():"/"+za(e)}q.getErrorPath=Dw;function Sf(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}q.checkStrictMode=Sf});var yt=P(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});var Te=M(),qw={data:new Te.Name("data"),valCxt:new Te.Name("valCxt"),instancePath:new Te.Name("instancePath"),parentData:new Te.Name("parentData"),parentDataProperty:new Te.Name("parentDataProperty"),rootData:new Te.Name("rootData"),dynamicAnchors:new Te.Name("dynamicAnchors"),vErrors:new Te.Name("vErrors"),errors:new Te.Name("errors"),this:new Te.Name("this"),self:new Te.Name("self"),scope:new Te.Name("scope"),json:new Te.Name("json"),jsonPos:new Te.Name("jsonPos"),jsonLen:new Te.Name("jsonLen"),jsonPart:new Te.Name("jsonPart")};Pa.default=qw});var xn=P(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.extendErrors=Re.resetErrorsCount=Re.reportExtraError=Re.reportError=Re.keyword$DataError=Re.keywordError=void 0;var H=M(),Ho=V(),Oe=yt();Re.keywordError={message:({keyword:e})=>(0,H.str)`must pass "${e}" keyword validation`};Re.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,H.str)`"${e}" keyword must be ${t} ($data)`:(0,H.str)`"${e}" keyword is invalid ($data)`};function Uw(e,t=Re.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=Pf(e,t,r);n??(i||a)?zf(s,c):kf(o,(0,H._)`[${c}]`)}Re.reportError=Uw;function Lw(e,t=Re.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=Pf(e,t,r);zf(o,a),s||i||kf(n,Oe.default.vErrors)}Re.reportExtraError=Lw;function Fw(e,t){e.assign(Oe.default.errors,t),e.if((0,H._)`${Oe.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,H._)`${Oe.default.vErrors}.length`,t),()=>e.assign(Oe.default.vErrors,null)))}Re.resetErrorsCount=Fw;function Vw({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=e.name("err");e.forRange("i",o,Oe.default.errors,a=>{e.const(i,(0,H._)`${Oe.default.vErrors}[${a}]`),e.if((0,H._)`${i}.instancePath === undefined`,()=>e.assign((0,H._)`${i}.instancePath`,(0,H.strConcat)(Oe.default.instancePath,s.errorPath))),e.assign((0,H._)`${i}.schemaPath`,(0,H.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,H._)`${i}.schema`,r),e.assign((0,H._)`${i}.data`,n))})}Re.extendErrors=Vw;function zf(e,t){let r=e.const("err",t);e.if((0,H._)`${Oe.default.vErrors} === null`,()=>e.assign(Oe.default.vErrors,(0,H._)`[${r}]`),(0,H._)`${Oe.default.vErrors}.push(${r})`),e.code((0,H._)`${Oe.default.errors}++`)}function kf(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,H._)`new ${e.ValidationError}(${t})`):(r.assign((0,H._)`${n}.errors`,t),r.return(!1))}var Gt={keyword:new H.Name("keyword"),schemaPath:new H.Name("schemaPath"),params:new H.Name("params"),propertyName:new H.Name("propertyName"),message:new H.Name("message"),schema:new H.Name("schema"),parentSchema:new H.Name("parentSchema")};function Pf(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,H._)`{}`:Hw(e,t,r)}function Hw(e,t,r={}){let{gen:n,it:o}=e,s=[Kw(o,r),Bw(e,r)];return Gw(e,t,s),n.object(...s)}function Kw({errorPath:e},{instancePath:t}){let r=t?(0,H.str)`${e}${(0,Ho.getErrorPath)(t,Ho.Type.Str)}`:e;return[Oe.default.instancePath,(0,H.strConcat)(Oe.default.instancePath,r)]}function Bw({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,H.str)`${t}/${e}`;return r&&(o=(0,H.str)`${o}${(0,Ho.getErrorPath)(r,Ho.Type.Str)}`),[Gt.schemaPath,o]}function Gw(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([Gt.keyword,o],[Gt.params,typeof t=="function"?t(e):t||(0,H._)`{}`]),c.messages&&n.push([Gt.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([Gt.schema,i],[Gt.parentSchema,(0,H._)`${l}${d}`],[Oe.default.data,s]),u&&n.push([Gt.propertyName,u])}});var Rf=P(Pr=>{"use strict";Object.defineProperty(Pr,"__esModule",{value:!0});Pr.boolOrEmptySchema=Pr.topBoolOrEmptySchema=void 0;var Jw=xn(),Ww=M(),Yw=yt(),Qw={message:"boolean schema is false"};function Xw(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Tf(e,!1):typeof r=="object"&&r.$async===!0?t.return(Yw.default.data):(t.assign((0,Ww._)`${n}.errors`,null),t.return(!0))}Pr.topBoolOrEmptySchema=Xw;function e$(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Tf(e)):r.var(t,!0)}Pr.boolOrEmptySchema=e$;function Tf(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,Jw.reportError)(o,Qw,void 0,t)}});var Ta=P(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.getRules=Tr.isJSONType=void 0;var t$=["string","number","integer","boolean","null","object","array"],r$=new Set(t$);function n$(e){return typeof e=="string"&&r$.has(e)}Tr.isJSONType=n$;function o$(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Tr.getRules=o$});var Ra=P(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.shouldUseRule=Tt.shouldUseGroup=Tt.schemaHasRulesForType=void 0;function s$({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&Ef(e,n)}Tt.schemaHasRulesForType=s$;function Ef(e,t){return t.rules.some(r=>If(e,r))}Tt.shouldUseGroup=Ef;function If(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Tt.shouldUseRule=If});var Sn=P(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.reportTypeError=Ee.checkDataTypes=Ee.checkDataType=Ee.coerceAndCheckDataType=Ee.getJSONTypes=Ee.getSchemaTypes=Ee.DataType=void 0;var i$=Ta(),a$=Ra(),c$=xn(),Z=M(),Of=V(),Rr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Rr||(Ee.DataType=Rr={}));function u$(e){let t=Cf(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}Ee.getSchemaTypes=u$;function Cf(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(i$.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Ee.getJSONTypes=Cf;function l$(e,t){let{gen:r,data:n,opts:o}=e,s=d$(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,a$.schemaHasRulesForType)(e,t[0]));if(i){let a=Ia(t,n,o.strictNumbers,Rr.Wrong);r.if(a,()=>{s.length?p$(e,t,s):Oa(e)})}return i}Ee.coerceAndCheckDataType=l$;var Af=new Set(["string","number","integer","boolean","null"]);function d$(e,t){return t?e.filter(r=>Af.has(r)||t==="array"&&r==="array"):[]}function p$(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,Z._)`typeof ${o}`),a=n.let("coerced",(0,Z._)`undefined`);s.coerceTypes==="array"&&n.if((0,Z._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,Z._)`${o}[0]`).assign(i,(0,Z._)`typeof ${o}`).if(Ia(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,Z._)`${a} !== undefined`);for(let u of r)(Af.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Oa(e),n.endIf(),n.if((0,Z._)`${a} !== undefined`,()=>{n.assign(o,a),f$(e,a)});function c(u){switch(u){case"string":n.elseIf((0,Z._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,Z._)`"" + ${o}`).elseIf((0,Z._)`${o} === null`).assign(a,(0,Z._)`""`);return;case"number":n.elseIf((0,Z._)`${i} == "boolean" || ${o} === null
5
- || (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,Z._)`+${o}`);return;case"integer":n.elseIf((0,Z._)`${i} === "boolean" || ${o} === null
6
- || (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,Z._)`+${o}`);return;case"boolean":n.elseIf((0,Z._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,Z._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,Z._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,Z._)`${i} === "string" || ${i} === "number"
7
- || ${i} === "boolean" || ${o} === null`).assign(a,(0,Z._)`[${o}]`)}}}function f$({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,Z._)`${t} !== undefined`,()=>e.assign((0,Z._)`${t}[${r}]`,n))}function Ea(e,t,r,n=Rr.Correct){let o=n===Rr.Correct?Z.operators.EQ:Z.operators.NEQ,s;switch(e){case"null":return(0,Z._)`${t} ${o} null`;case"array":s=(0,Z._)`Array.isArray(${t})`;break;case"object":s=(0,Z._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,Z._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,Z._)`typeof ${t} ${o} ${e}`}return n===Rr.Correct?s:(0,Z.not)(s);function i(a=Z.nil){return(0,Z.and)((0,Z._)`typeof ${t} == "number"`,a,r?(0,Z._)`isFinite(${t})`:Z.nil)}}Ee.checkDataType=Ea;function Ia(e,t,r,n){if(e.length===1)return Ea(e[0],t,r,n);let o,s=(0,Of.toHash)(e);if(s.array&&s.object){let i=(0,Z._)`typeof ${t} != "object"`;o=s.null?i:(0,Z._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=Z.nil;s.number&&delete s.integer;for(let i in s)o=(0,Z.and)(o,Ea(i,t,r,n));return o}Ee.checkDataTypes=Ia;var m$={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,Z._)`{type: ${e}}`:(0,Z._)`{type: ${t}}`};function Oa(e){let t=h$(e);(0,c$.reportError)(t,m$)}Ee.reportTypeError=Oa;function h$(e){let{gen:t,data:r,schema:n}=e,o=(0,Of.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var jf=P(Ko=>{"use strict";Object.defineProperty(Ko,"__esModule",{value:!0});Ko.assignDefaults=void 0;var Er=M(),g$=V();function _$(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)Nf(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Nf(e,s,o.default))}Ko.assignDefaults=_$;function Nf(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,Er._)`${s}${(0,Er.getProperty)(t)}`;if(o){(0,g$.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,Er._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Er._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Er._)`${a} = ${(0,Er.stringify)(r)}`)}});var Ke=P(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.validateUnion=ee.validateArray=ee.usePattern=ee.callValidateCode=ee.schemaProperties=ee.allSchemaProperties=ee.noPropertyInData=ee.propertyInData=ee.isOwnProperty=ee.hasPropFunc=ee.reportMissingProp=ee.checkMissingProp=ee.checkReportMissingProp=void 0;var ue=M(),Ca=V(),Rt=yt(),y$=V();function v$(e,t){let{gen:r,data:n,it:o}=e;r.if(Na(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,ue._)`${t}`},!0),e.error()})}ee.checkReportMissingProp=v$;function w$({gen:e,data:t,it:{opts:r}},n,o){return(0,ue.or)(...n.map(s=>(0,ue.and)(Na(e,t,s,r.ownProperties),(0,ue._)`${o} = ${s}`)))}ee.checkMissingProp=w$;function $$(e,t){e.setParams({missingProperty:t},!0),e.error()}ee.reportMissingProp=$$;function Zf(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,ue._)`Object.prototype.hasOwnProperty`})}ee.hasPropFunc=Zf;function Aa(e,t,r){return(0,ue._)`${Zf(e)}.call(${t}, ${r})`}ee.isOwnProperty=Aa;function b$(e,t,r,n){let o=(0,ue._)`${t}${(0,ue.getProperty)(r)} !== undefined`;return n?(0,ue._)`${o} && ${Aa(e,t,r)}`:o}ee.propertyInData=b$;function Na(e,t,r,n){let o=(0,ue._)`${t}${(0,ue.getProperty)(r)} === undefined`;return n?(0,ue.or)(o,(0,ue.not)(Aa(e,t,r))):o}ee.noPropertyInData=Na;function Mf(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}ee.allSchemaProperties=Mf;function x$(e,t){return Mf(t).filter(r=>!(0,Ca.alwaysValidSchema)(e,t[r]))}ee.schemaProperties=x$;function S$({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,ue._)`${e}, ${t}, ${n}${o}`:t,d=[[Rt.default.instancePath,(0,ue.strConcat)(Rt.default.instancePath,s)],[Rt.default.parentData,i.parentData],[Rt.default.parentDataProperty,i.parentDataProperty],[Rt.default.rootData,Rt.default.rootData]];i.opts.dynamicRef&&d.push([Rt.default.dynamicAnchors,Rt.default.dynamicAnchors]);let m=(0,ue._)`${l}, ${r.object(...d)}`;return c!==ue.nil?(0,ue._)`${a}.call(${c}, ${m})`:(0,ue._)`${a}(${m})`}ee.callValidateCode=S$;var z$=(0,ue._)`new RegExp`;function k$({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,s=o(r,n);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,ue._)`${o.code==="new RegExp"?z$:(0,y$.useFunc)(e,o)}(${r}, ${n})`})}ee.usePattern=k$;function P$(e){let{gen:t,data:r,keyword:n,it:o}=e,s=t.name("valid");if(o.allErrors){let a=t.let("valid",!0);return i(()=>t.assign(a,!1)),a}return t.var(s,!0),i(()=>t.break()),s;function i(a){let c=t.const("len",(0,ue._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:Ca.Type.Num},s),t.if((0,ue.not)(s),a)})}}ee.validateArray=P$;function T$(e){let{gen:t,schema:r,keyword:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Ca.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((c,u)=>{let l=e.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);t.assign(i,(0,ue._)`${i} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,ue.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}ee.validateUnion=T$});var Uf=P(at=>{"use strict";Object.defineProperty(at,"__esModule",{value:!0});at.validateKeywordUsage=at.validSchemaType=at.funcKeywordCode=at.macroKeywordCode=void 0;var Ce=M(),Jt=yt(),R$=Ke(),E$=xn();function I$(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=qf(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");e.subschema({schema:a,schemaPath:Ce.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}at.macroKeywordCode=I$;function O$(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;A$(c,t);let u=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,l=qf(n,o,u),d=n.let("valid");e.block$data(d,m),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function m(){if(t.errors===!1)g(),t.modifying&&Df(e),v(()=>e.error());else{let w=t.async?f():h();t.modifying&&Df(e),v(()=>C$(e,w))}}function f(){let w=n.let("ruleErrs",null);return n.try(()=>g((0,Ce._)`await `),x=>n.assign(d,!1).if((0,Ce._)`${x} instanceof ${c.ValidationError}`,()=>n.assign(w,(0,Ce._)`${x}.errors`),()=>n.throw(x))),w}function h(){let w=(0,Ce._)`${l}.errors`;return n.assign(w,null),g(Ce.nil),w}function g(w=t.async?(0,Ce._)`await `:Ce.nil){let x=c.opts.passContext?Jt.default.this:Jt.default.self,$=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,Ce._)`${w}${(0,R$.callValidateCode)(e,l,x,$)}`,t.modifying)}function v(w){var x;n.if((0,Ce.not)((x=t.valid)!==null&&x!==void 0?x:d),w)}}at.funcKeywordCode=O$;function Df(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Ce._)`${n.parentData}[${n.parentDataProperty}]`))}function C$(e,t){let{gen:r}=e;r.if((0,Ce._)`Array.isArray(${t})`,()=>{r.assign(Jt.default.vErrors,(0,Ce._)`${Jt.default.vErrors} === null ? ${t} : ${Jt.default.vErrors}.concat(${t})`).assign(Jt.default.errors,(0,Ce._)`${Jt.default.vErrors}.length`),(0,E$.extendErrors)(e)},()=>e.error())}function A$({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function qf(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Ce.stringify)(r)})}function N$(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}at.validSchemaType=N$;function j$({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}at.validateKeywordUsage=j$});var Ff=P(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.extendSubschemaMode=Et.extendSubschemaData=Et.getSubschema=void 0;var ct=M(),Lf=V();function Z$(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,ct._)`${e.schemaPath}${(0,ct.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,ct._)`${e.schemaPath}${(0,ct.getProperty)(t)}${(0,ct.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,Lf.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Et.getSubschema=Z$;function M$(e,t,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=t,m=a.let("data",(0,ct._)`${t.data}${(0,ct.getProperty)(r)}`,!0);c(m),e.errorPath=(0,ct.str)`${u}${(0,Lf.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,ct._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(o!==void 0){let u=o instanceof ct.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(e.propertyName=i)}s&&(e.dataTypes=s);function c(u){e.data=u,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,u]}}Et.extendSubschemaData=M$;function D$(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),s!==void 0&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r}Et.extendSubschemaMode=D$});var ja=P((xO,Vf)=>{"use strict";Vf.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!e(t[i],r[i]))return!1}return!0}return t!==t&&r!==r}});var Kf=P((SO,Hf)=>{"use strict";var It=Hf.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Bo(t,n,o,e,"",e)};It.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};It.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};It.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};It.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 Bo(e,t,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in It.arrayKeywords)for(var m=0;m<d.length;m++)Bo(e,t,r,d[m],o+"/"+l+"/"+m,s,o,l,n,m)}else if(l in It.propsKeywords){if(d&&typeof d=="object")for(var f in d)Bo(e,t,r,d[f],o+"/"+l+"/"+q$(f),s,o,l,n,f)}else(l in It.keywords||e.allKeys&&!(l in It.skipKeywords))&&Bo(e,t,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function q$(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var zn=P(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Me.getSchemaRefs=Me.resolveUrl=Me.normalizeId=Me._getFullPath=Me.getFullPath=Me.inlineRef=void 0;var U$=V(),L$=ja(),F$=Kf(),V$=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function H$(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Za(e):t?Bf(e)<=t:!1}Me.inlineRef=H$;var K$=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Za(e){for(let t in e){if(K$.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(Za)||typeof r=="object"&&Za(r))return!0}return!1}function Bf(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!V$.has(r)&&(typeof e[r]=="object"&&(0,U$.eachItem)(e[r],n=>t+=Bf(n)),t===1/0))return 1/0}return t}function Gf(e,t="",r){r!==!1&&(t=Ir(t));let n=e.parse(t);return Jf(e,n)}Me.getFullPath=Gf;function Jf(e,t){return e.serialize(t).split("#")[0]+"#"}Me._getFullPath=Jf;var B$=/#\/?$/;function Ir(e){return e?e.replace(B$,""):""}Me.normalizeId=Ir;function G$(e,t,r){return r=Ir(r),e.resolve(t,r)}Me.resolveUrl=G$;var J$=/^[a-z_][-a-z0-9._]*$/i;function W$(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Ir(e[r]||t),s={"":o},i=Gf(n,o,!1),a={},c=new Set;return F$(e,{allKeys:!0},(d,m,f,h)=>{if(h===void 0)return;let g=i+m,v=s[h];typeof d[r]=="string"&&(v=w.call(this,d[r])),x.call(this,d.$anchor),x.call(this,d.$dynamicAnchor),s[m]=v;function w($){let T=this.opts.uriResolver.resolve;if($=Ir(v?T(v,$):$),c.has($))throw l($);c.add($);let y=this.refs[$];return typeof y=="string"&&(y=this.refs[y]),typeof y=="object"?u(d,y.schema,$):$!==Ir(g)&&($[0]==="#"?(u(d,a[$],$),a[$]=d):this.refs[$]=g),$}function x($){if(typeof $=="string"){if(!J$.test($))throw new Error(`invalid anchor "${$}"`);w.call(this,`#${$}`)}}}),a;function u(d,m,f){if(m!==void 0&&!L$(d,m))throw l(f)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Me.getSchemaRefs=W$});var Tn=P(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.getData=Ot.KeywordCxt=Ot.validateFunctionCode=void 0;var em=Rf(),Wf=Sn(),Da=Ra(),Go=Sn(),Y$=jf(),Pn=Uf(),Ma=Ff(),O=M(),j=yt(),Q$=zn(),vt=V(),kn=xn();function X$(e){if(nm(e)&&(om(e),rm(e))){rb(e);return}tm(e,()=>(0,em.topBoolOrEmptySchema)(e))}Ot.validateFunctionCode=X$;function tm({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,O._)`${j.default.data}, ${j.default.valCxt}`,n.$async,()=>{e.code((0,O._)`"use strict"; ${Yf(r,o)}`),tb(e,o),e.code(s)}):e.func(t,(0,O._)`${j.default.data}, ${eb(o)}`,n.$async,()=>e.code(Yf(r,o)).code(s))}function eb(e){return(0,O._)`{${j.default.instancePath}="", ${j.default.parentData}, ${j.default.parentDataProperty}, ${j.default.rootData}=${j.default.data}${e.dynamicRef?(0,O._)`, ${j.default.dynamicAnchors}={}`:O.nil}}={}`}function tb(e,t){e.if(j.default.valCxt,()=>{e.var(j.default.instancePath,(0,O._)`${j.default.valCxt}.${j.default.instancePath}`),e.var(j.default.parentData,(0,O._)`${j.default.valCxt}.${j.default.parentData}`),e.var(j.default.parentDataProperty,(0,O._)`${j.default.valCxt}.${j.default.parentDataProperty}`),e.var(j.default.rootData,(0,O._)`${j.default.valCxt}.${j.default.rootData}`),t.dynamicRef&&e.var(j.default.dynamicAnchors,(0,O._)`${j.default.valCxt}.${j.default.dynamicAnchors}`)},()=>{e.var(j.default.instancePath,(0,O._)`""`),e.var(j.default.parentData,(0,O._)`undefined`),e.var(j.default.parentDataProperty,(0,O._)`undefined`),e.var(j.default.rootData,j.default.data),t.dynamicRef&&e.var(j.default.dynamicAnchors,(0,O._)`{}`)})}function rb(e){let{schema:t,opts:r,gen:n}=e;tm(e,()=>{r.$comment&&t.$comment&&im(e),ab(e),n.let(j.default.vErrors,null),n.let(j.default.errors,0),r.unevaluated&&nb(e),sm(e),lb(e)})}function nb(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,O._)`${r}.evaluated`),t.if((0,O._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,O._)`${e.evaluated}.props`,(0,O._)`undefined`)),t.if((0,O._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,O._)`${e.evaluated}.items`,(0,O._)`undefined`))}function Yf(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,O._)`/*# sourceURL=${r} */`:O.nil}function ob(e,t){if(nm(e)&&(om(e),rm(e))){sb(e,t);return}(0,em.boolOrEmptySchema)(e,t)}function rm({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function nm(e){return typeof e.schema!="boolean"}function sb(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&im(e),cb(e),ub(e);let s=n.const("_errs",j.default.errors);sm(e,s),n.var(t,(0,O._)`${s} === ${j.default.errors}`)}function om(e){(0,vt.checkUnknownRules)(e),ib(e)}function sm(e,t){if(e.opts.jtd)return Qf(e,[],!1,t);let r=(0,Wf.getSchemaTypes)(e.schema),n=(0,Wf.coerceAndCheckDataType)(e,r);Qf(e,r,!n,t)}function ib(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,vt.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function ab(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,vt.checkStrictMode)(e,"default is ignored in the schema root")}function cb(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Q$.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function ub(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function im({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,O._)`${j.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,O.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,O._)`${j.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function lb(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,O._)`${j.default.errors} === 0`,()=>t.return(j.default.data),()=>t.throw((0,O._)`new ${o}(${j.default.vErrors})`)):(t.assign((0,O._)`${n}.errors`,j.default.vErrors),s.unevaluated&&db(e),t.return((0,O._)`${j.default.errors} === 0`))}function db({gen:e,evaluated:t,props:r,items:n}){r instanceof O.Name&&e.assign((0,O._)`${t}.props`,r),n instanceof O.Name&&e.assign((0,O._)`${t}.items`,n)}function Qf(e,t,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=e,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,vt.schemaHasRulesButRef)(s,l))){o.block(()=>cm(e,"$ref",l.all.$ref.definition));return}c.jtd||pb(e,t),o.block(()=>{for(let m of l.rules)d(m);d(l.post)});function d(m){(0,Da.shouldUseGroup)(s,m)&&(m.type?(o.if((0,Go.checkDataType)(m.type,i,c.strictNumbers)),Xf(e,m),t.length===1&&t[0]===m.type&&r&&(o.else(),(0,Go.reportTypeError)(e)),o.endIf()):Xf(e,m),a||o.if((0,O._)`${j.default.errors} === ${n||0}`))}}function Xf(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,Y$.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,Da.shouldUseRule)(n,s)&&cm(e,s.keyword,s.definition,t.type)})}function pb(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(fb(e,t),e.opts.allowUnionTypes||mb(e,t),hb(e,e.dataTypes))}function fb(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{am(e.dataTypes,r)||qa(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),_b(e,t)}}function mb(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&qa(e,"use allowUnionTypes to allow union type keyword")}function hb(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Da.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>gb(t,i))&&qa(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function gb(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function am(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function _b(e,t){let r=[];for(let n of e.dataTypes)am(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function qa(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,vt.checkStrictMode)(e,t,e.opts.strictTypes)}var Jo=class{constructor(t,r,n){if((0,Pn.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,vt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",um(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,Pn.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",j.default.errors))}result(t,r,n){this.failResult((0,O.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,O.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,O._)`${r} !== undefined && (${(0,O.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?kn.reportExtraError:kn.reportError)(this,this.def.error,r)}$dataError(){(0,kn.reportError)(this,this.def.$dataError||kn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,kn.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=O.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=O.nil,r=O.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,O.or)((0,O._)`${o} === undefined`,r)),t!==O.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==O.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,O.or)(i(),a());function i(){if(n.length){if(!(r instanceof O.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,O._)`${(0,Go.checkDataTypes)(c,r,s.opts.strictNumbers,Go.DataType.Wrong)}`}return O.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,O._)`!${c}(${r})`}return O.nil}}subschema(t,r){let n=(0,Ma.getSubschema)(this.it,t);(0,Ma.extendSubschemaData)(n,this.it,t),(0,Ma.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return ob(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=vt.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=vt.mergeEvaluated.items(o,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(t,O.Name)),!0}};Ot.KeywordCxt=Jo;function cm(e,t,r,n){let o=new Jo(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,Pn.funcKeywordCode)(o,r):"macro"in r?(0,Pn.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,Pn.funcKeywordCode)(o,r)}var yb=/^\/(?:[^~]|~0|~1)*$/,vb=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function um(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return j.default.rootData;if(e[0]==="/"){if(!yb.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=j.default.rootData}else{let u=vb.exec(e);if(!u)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=t)throw new Error(c("property/index",l));return n[t-l]}if(l>t)throw new Error(c("data",l));if(s=r[t-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,O._)`${s}${(0,O.getProperty)((0,vt.unescapeJsonPointer)(u))}`,i=(0,O._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}Ot.getData=um});var Wo=P(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});var Ua=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};La.default=Ua});var Rn=P(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});var Fa=zn(),Va=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Fa.resolveUrl)(t,r,n),this.missingSchema=(0,Fa.normalizeId)((0,Fa.getFullPath)(t,this.missingRef))}};Ha.default=Va});var Qo=P(Be=>{"use strict";Object.defineProperty(Be,"__esModule",{value:!0});Be.resolveSchema=Be.getCompilingSchema=Be.resolveRef=Be.compileSchema=Be.SchemaEnv=void 0;var tt=M(),wb=Wo(),Wt=yt(),rt=zn(),lm=V(),$b=Tn(),Or=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,rt.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};Be.SchemaEnv=Or;function Ba(e){let t=dm.call(this,e);if(t)return t;let r=(0,rt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new tt.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:wb.default,code:(0,tt._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:Wt.default.data,parentData:Wt.default.parentData,parentDataProperty:Wt.default.parentDataProperty,dataNames:[Wt.default.data],dataPathArr:[tt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,tt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:tt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,tt._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,$b.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(Wt.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let f=new Function(`${Wt.default.self}`,`${Wt.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:f}),f.errors=null,f.schema=e.schema,f.schemaEnv=e,e.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:h,items:g}=u;f.evaluated={props:h instanceof tt.Name?void 0:h,items:g instanceof tt.Name?void 0:g,dynamicProps:h instanceof tt.Name,dynamicItems:g instanceof tt.Name},f.source&&(f.source.evaluated=(0,tt.stringify)(f.evaluated))}return e.validate=f,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}Be.compileSchema=Ba;function bb(e,t,r){var n;r=(0,rt.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=zb.call(this,e,r);if(s===void 0){let i=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Or({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=xb.call(this,s)}Be.resolveRef=bb;function xb(e){return(0,rt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Ba.call(this,e)}function dm(e){for(let t of this._compilations)if(Sb(t,e))return t}Be.getCompilingSchema=dm;function Sb(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function zb(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Yo.call(this,e,t)}function Yo(e,t){let r=this.opts.uriResolver.parse(t),n=(0,rt._getFullPath)(this.opts.uriResolver,r),o=(0,rt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return Ka.call(this,r,e);let s=(0,rt.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Yo.call(this,e,i);return typeof a?.schema!="object"?void 0:Ka.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Ba.call(this,i),s===(0,rt.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,rt.resolveUrl)(this.opts.uriResolver,o,u)),new Or({schema:a,schemaId:c,root:e,baseId:o})}return Ka.call(this,r,i)}}Be.resolveSchema=Yo;var kb=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Ka(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,lm.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!kb.has(a)&&u&&(t=(0,rt.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,lm.schemaHasRulesButRef)(r,this.RULES)){let a=(0,rt.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=Yo.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Or({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var pm=P((EO,Pb)=>{Pb.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 Wa=P((IO,ym)=>{"use strict";var Tb=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),mm=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),Ga=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),hm=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Rb=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Ja(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var Eb=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function fm(e){return e.length=0,!0}function Ib(e,t,r){if(e.length){let n=Ja(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function Ob(e){let t=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=Ib;for(let c=0;c<e.length;c++){let u=e[c];if(!(u==="["||u==="]"))if(u===":"){if(s===!0&&(i=!0),!a(o,n,r))break;if(++t>7){r.error=!0;break}c>0&&e[c-1]===":"&&(s=!0),n.push(":");continue}else if(u==="%"){if(!a(o,n,r))break;a=fm}else{o.push(u);continue}}return o.length&&(a===fm?r.zone=o.join(""):i?n.push(o.join("")):n.push(Ja(o))),r.address=n.join(""),r}function gm(e){if(Cb(e,":")<2)return{host:e,isIPV6:!1};let t=Ob(e);if(t.error)return{host:e,isIPV6:!1};{let r=t.address,n=t.address;return t.zone&&(r+="%"+t.zone,n+="%25"+t.zone),{host:r,isIPV6:!0,escapedHost:n}}}function Cb(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function Ab(e){let t=e,r=[],n=-1,o=0;for(;o=t.length;){if(o===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(o===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(o===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}var Nb={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},jb=/[@/?#:]/g,Zb=/[@/?#]/g;function _m(e,t){let r=t?Zb:jb;return r.lastIndex=0,e.replace(r,n=>Nb[n])}function Mb(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(Ga(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&hm(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function Db(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(Ga(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));s!=="."&&hm(s)?t+=s:t+="%"+o,r+=2;continue}}Rb(e[r])?t+=e[r]:t+=escape(e[r])}return t}function qb(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(Ga(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function Ub(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!mm(r)){let n=gm(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=_m(r,!1)}t.push(r)}return(typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}ym.exports={nonSimpleDomain:Eb,recomposeAuthority:Ub,reescapeHostDelimiters:_m,normalizePercentEncoding:Mb,normalizePathEncoding:Db,escapePreservingEscapes:qb,removeDotSegments:Ab,isIPv4:mm,isUUID:Tb,normalizeIPv6:gm,stringArrayToHexStripped:Ja}});var xm=P((OO,bm)=>{"use strict";var{isUUID:Lb}=Wa(),Fb=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,Vb=["http","https","ws","wss","urn","urn:uuid"];function Hb(e){return Vb.indexOf(e)!==-1}function Ya(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function vm(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function wm(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function Kb(e){return e.secure=Ya(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function Bb(e){if((e.port===(Ya(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let[t,r]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=r,e.resourceName=void 0}return e.fragment=void 0,e}function Gb(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(Fb);if(r){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,s=Qa(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function Jb(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=`${r}:${t.nid||n}`,s=Qa(o);s&&(e=s.serialize(e,t));let i=e,a=e.nss;return i.path=`${n||t.nid}:${a}`,t.skipEscape=!0,i}function Wb(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!Lb(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Yb(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var $m={scheme:"http",domainHost:!0,parse:vm,serialize:wm},Qb={scheme:"https",domainHost:$m.domainHost,parse:vm,serialize:wm},Xo={scheme:"ws",domainHost:!0,parse:Kb,serialize:Bb},Xb={scheme:"wss",domainHost:Xo.domainHost,parse:Xo.parse,serialize:Xo.serialize},e0={scheme:"urn",parse:Gb,serialize:Jb,skipNormalize:!0},t0={scheme:"urn:uuid",parse:Wb,serialize:Yb,skipNormalize:!0},es={http:$m,https:Qb,ws:Xo,wss:Xb,urn:e0,"urn:uuid":t0};Object.setPrototypeOf(es,null);function Qa(e){return e&&(es[e]||es[e.toLowerCase()])||void 0}bm.exports={wsIsSecure:Ya,SCHEMES:es,isValidSchemeName:Hb,getSchemeHandler:Qa}});var Rm=P((CO,ts)=>{"use strict";var{normalizeIPv6:r0,removeDotSegments:En,recomposeAuthority:n0,normalizePercentEncoding:o0,normalizePathEncoding:s0,escapePreservingEscapes:i0,reescapeHostDelimiters:a0,isIPv4:c0,nonSimpleDomain:u0}=Wa(),{SCHEMES:l0,getSchemeHandler:zm}=xm();function d0(e,t){return typeof e=="string"?e=_0(e,t):typeof e=="object"&&(e=Cr(Yt(e,t),t)),e}function p0(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=km(Cr(e,n),Cr(t,n),n,!0);return n.skipEscape=!0,Yt(o,n)}function km(e,t,r,n){let o={};return n||(e=Cr(Yt(e,r),r),t=Cr(Yt(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=En(t.path||""),o.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=En(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=En(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?o.path="/"+t.path:e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path,o.path=En(o.path)),o.query=t.query):(o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function f0(e,t,r){let n=Sm(e,r),o=Sm(t,r);return n!==void 0&&o!==void 0&&n.toLowerCase()===o.toLowerCase()}function Yt(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),o=[],s=zm(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=o0(r.path):(r.path=i0(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=n0(r);if(i!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=En(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var m0=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,h0=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/;function g0(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function Pm(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let i=e.match(h0);i!==null&&i[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let a=e.match(m0);if(a){n.scheme=a[1],n.userinfo=a[3],n.host=a[4],n.port=parseInt(a[5],10),n.path=a[6]||"",n.query=a[7],n.fragment=a[8],isNaN(n.port)&&(n.port=a[5]);let c=g0(n,a);if(c!==void 0&&(n.error=n.error||c,o=!0),n.host)if(c0(n.host)===!1){let d=r0(n.host);n.host=d.host.toLowerCase(),s=d.isIPV6}else s=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let u=zm(r.scheme||n.scheme);if(!r.unicodeSupport&&(!u||!u.unicodeSupport)&&n.host&&(r.domainHost||u&&u.domainHost)&&s===!1&&u0(n.host))try{n.host=new URL("http://"+n.host).hostname}catch(l){n.error=n.error||"Host's domain name can not be converted to ASCII: "+l}if((!u||u&&!u.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=a0(unescape(n.host),s))),n.path&&(n.path=s0(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}u&&u.parse&&u.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o}}function Cr(e,t){return Pm(e,t).parsed}function _0(e,t){return Tm(e,t).normalized}function Tm(e,t){let{parsed:r,malformedAuthorityOrPort:n}=Pm(e,t);return{normalized:n?e:Yt(r,t),malformedAuthorityOrPort:n}}function Sm(e,t){if(typeof e=="string"){let{normalized:r,malformedAuthorityOrPort:n}=Tm(e,t);return n?void 0:r}if(typeof e=="object")return Yt(e,t)}var Xa={SCHEMES:l0,normalize:d0,resolve:p0,resolveComponent:km,equal:f0,serialize:Yt,parse:Cr};ts.exports=Xa;ts.exports.default=Xa;ts.exports.fastUri=Xa});var Im=P(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});var Em=Rm();Em.code='require("ajv/dist/runtime/uri").default';ec.default=Em});var Dm=P(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.CodeGen=Se.Name=Se.nil=Se.stringify=Se.str=Se._=Se.KeywordCxt=void 0;var y0=Tn();Object.defineProperty(Se,"KeywordCxt",{enumerable:!0,get:function(){return y0.KeywordCxt}});var Ar=M();Object.defineProperty(Se,"_",{enumerable:!0,get:function(){return Ar._}});Object.defineProperty(Se,"str",{enumerable:!0,get:function(){return Ar.str}});Object.defineProperty(Se,"stringify",{enumerable:!0,get:function(){return Ar.stringify}});Object.defineProperty(Se,"nil",{enumerable:!0,get:function(){return Ar.nil}});Object.defineProperty(Se,"Name",{enumerable:!0,get:function(){return Ar.Name}});Object.defineProperty(Se,"CodeGen",{enumerable:!0,get:function(){return Ar.CodeGen}});var v0=Wo(),jm=Rn(),w0=Ta(),In=Qo(),$0=M(),On=zn(),rs=Sn(),rc=V(),Om=pm(),b0=Im(),Zm=(e,t)=>new RegExp(e,t);Zm.code="new RegExp";var x0=["removeAdditional","useDefaults","coerceTypes"],S0=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),z0={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."},k0={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Cm=200;function P0(e){var t,r,n,o,s,i,a,c,u,l,d,m,f,h,g,v,w,x,$,T,y,S,R,J,W;let me=e.strict,st=(t=e.code)===null||t===void 0?void 0:t.optimize,lr=st===!0||st===void 0?1:st||0,xt=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Zm,Ae=(o=e.uriResolver)!==null&&o!==void 0?o:b0.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:me)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:me)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:me)!==null&&l!==void 0?l:"log",strictTuples:(m=(d=e.strictTuples)!==null&&d!==void 0?d:me)!==null&&m!==void 0?m:"log",strictRequired:(h=(f=e.strictRequired)!==null&&f!==void 0?f:me)!==null&&h!==void 0?h:!1,code:e.code?{...e.code,optimize:lr,regExp:xt}:{optimize:lr,regExp:xt},loopRequired:(g=e.loopRequired)!==null&&g!==void 0?g:Cm,loopEnum:(v=e.loopEnum)!==null&&v!==void 0?v:Cm,meta:(w=e.meta)!==null&&w!==void 0?w:!0,messages:(x=e.messages)!==null&&x!==void 0?x:!0,inlineRefs:($=e.inlineRefs)!==null&&$!==void 0?$:!0,schemaId:(T=e.schemaId)!==null&&T!==void 0?T:"$id",addUsedSchema:(y=e.addUsedSchema)!==null&&y!==void 0?y:!0,validateSchema:(S=e.validateSchema)!==null&&S!==void 0?S:!0,validateFormats:(R=e.validateFormats)!==null&&R!==void 0?R:!0,unicodeRegExp:(J=e.unicodeRegExp)!==null&&J!==void 0?J:!0,int32range:(W=e.int32range)!==null&&W!==void 0?W:!0,uriResolver:Ae}}var Cn=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...P0(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new $0.ValueScope({scope:{},prefixes:S0,es5:r,lines:n}),this.logger=C0(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,w0.getRules)(),Am.call(this,z0,t,"NOT SUPPORTED"),Am.call(this,k0,t,"DEPRECATED","warn"),this._metaOpts=I0.call(this),t.formats&&R0.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&E0.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),T0.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=Om;n==="id"&&(o={...Om},o.id=o.$id,delete o.$id),r&&t&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,t,r);async function o(l,d){await s.call(this,l.$schema);let m=this._addSchema(l,d);return m.validate||i.call(this,m)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof jm.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(t,r,n,o=this.opts.validateSchema){if(Array.isArray(t)){for(let i of t)this.addSchema(i,void 0,n,o);return this}let s;if(typeof t=="object"){let{schemaId:i}=this.opts;if(s=t[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,On.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,o,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,t);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(t){let r;for(;typeof(r=Nm.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new In.SchemaEnv({schema:{},schemaId:n});if(r=In.resolveSchema.call(this,o,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=Nm.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,On.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(N0.call(this,n,r),!r)return(0,rc.eachItem)(n,s=>tc.call(this,s)),this;Z0.call(this,r);let o={...r,type:(0,rs.getJSONTypes)(r.type),schemaType:(0,rs.getJSONTypes)(r.schemaType)};return(0,rc.eachItem)(n,o.type.length===0?s=>tc.call(this,s,o):s=>o.type.forEach(i=>tc.call(this,s,o,i))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===t);o>=0&&n.rules.splice(o,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let s=o.split("/").slice(1),i=t;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=Mm(l))}}return t}_removeAllSchemas(t,r){for(let n in t){let o=t[n];(!r||r.test(n))&&(typeof o=="string"?delete t[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete t[n]))}}_addSchema(t,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof t=="object")i=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(t);if(c!==void 0)return c;n=(0,On.normalizeId)(i||n);let u=On.getSchemaRefs.call(this,t,n);return c=new In.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(t,!0),c}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):In.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{In.compileSchema.call(this,t)}finally{this.opts=r}}};Cn.ValidationError=v0.default;Cn.MissingRefError=jm.default;Se.default=Cn;function Am(e,t,r,n="error"){for(let o in e){let s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function Nm(e){return e=(0,On.normalizeId)(e),this.schemas[e]||this.refs[e]}function T0(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function R0(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function E0(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function I0(){let e={...this.opts};for(let t of x0)delete e[t];return e}var O0={log(){},warn(){},error(){}};function C0(e){if(e===!1)return O0;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var A0=/^[a-z_$][a-z0-9_$:-]*$/i;function N0(e,t){let{RULES:r}=this;if((0,rc.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!A0.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function tc(e,t,r){var n;let o=t?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,rs.getJSONTypes)(t.type),schemaType:(0,rs.getJSONTypes)(t.schemaType)}};t.before?j0.call(this,i,a,t.before):i.rules.push(a),s.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function j0(e,t,r){let n=e.rules.findIndex(o=>o.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function Z0(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=Mm(t)),e.validateSchema=this.compile(t,!0))}var M0={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Mm(e){return{anyOf:[e,M0]}}});var qm=P(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});var D0={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};nc.default=D0});var Vm=P(Qt=>{"use strict";Object.defineProperty(Qt,"__esModule",{value:!0});Qt.callRef=Qt.getValidate=void 0;var q0=Rn(),Um=Ke(),De=M(),Nr=yt(),Lm=Qo(),ns=V(),U0={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=Lm.resolveRef.call(c,u,o,r);if(l===void 0)throw new q0.default(n.opts.uriResolver,o,r);if(l instanceof Lm.SchemaEnv)return m(l);return f(l);function d(){if(s===u)return os(e,i,s,s.$async);let h=t.scopeValue("root",{ref:u});return os(e,(0,De._)`${h}.validate`,u,u.$async)}function m(h){let g=Fm(e,h);os(e,g,h,h.$async)}function f(h){let g=t.scopeValue("schema",a.code.source===!0?{ref:h,code:(0,De.stringify)(h)}:{ref:h}),v=t.name("valid"),w=e.subschema({schema:h,dataTypes:[],schemaPath:De.nil,topSchemaRef:g,errSchemaPath:r},v);e.mergeEvaluated(w),e.ok(v)}}};function Fm(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,De._)`${r.scopeValue("wrapper",{ref:t})}.validate`}Qt.getValidate=Fm;function os(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Nr.default.this:De.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let h=o.let("valid");o.try(()=>{o.code((0,De._)`await ${(0,Um.callValidateCode)(e,t,u)}`),f(t),i||o.assign(h,!0)},g=>{o.if((0,De._)`!(${g} instanceof ${s.ValidationError})`,()=>o.throw(g)),m(g),i||o.assign(h,!1)}),e.ok(h)}function d(){e.result((0,Um.callValidateCode)(e,t,u),()=>f(t),()=>m(t))}function m(h){let g=(0,De._)`${h}.errors`;o.assign(Nr.default.vErrors,(0,De._)`${Nr.default.vErrors} === null ? ${g} : ${Nr.default.vErrors}.concat(${g})`),o.assign(Nr.default.errors,(0,De._)`${Nr.default.vErrors}.length`)}function f(h){var g;if(!s.opts.unevaluated)return;let v=(g=r?.validate)===null||g===void 0?void 0:g.evaluated;if(s.props!==!0)if(v&&!v.dynamicProps)v.props!==void 0&&(s.props=ns.mergeEvaluated.props(o,v.props,s.props));else{let w=o.var("props",(0,De._)`${h}.evaluated.props`);s.props=ns.mergeEvaluated.props(o,w,s.props,De.Name)}if(s.items!==!0)if(v&&!v.dynamicItems)v.items!==void 0&&(s.items=ns.mergeEvaluated.items(o,v.items,s.items));else{let w=o.var("items",(0,De._)`${h}.evaluated.items`);s.items=ns.mergeEvaluated.items(o,w,s.items,De.Name)}}}Qt.callRef=os;Qt.default=U0});var Hm=P(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});var L0=qm(),F0=Vm(),V0=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",L0.default,F0.default];oc.default=V0});var Km=P(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});var ss=M(),Ct=ss.operators,is={maximum:{okStr:"<=",ok:Ct.LTE,fail:Ct.GT},minimum:{okStr:">=",ok:Ct.GTE,fail:Ct.LT},exclusiveMaximum:{okStr:"<",ok:Ct.LT,fail:Ct.GTE},exclusiveMinimum:{okStr:">",ok:Ct.GT,fail:Ct.LTE}},H0={message:({keyword:e,schemaCode:t})=>(0,ss.str)`must be ${is[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ss._)`{comparison: ${is[e].okStr}, limit: ${t}}`},K0={keyword:Object.keys(is),type:"number",schemaType:"number",$data:!0,error:H0,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,ss._)`${r} ${is[t].fail} ${n} || isNaN(${r})`)}};sc.default=K0});var Bm=P(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});var An=M(),B0={message:({schemaCode:e})=>(0,An.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,An._)`{multipleOf: ${e}}`},G0={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:B0,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,An._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,An._)`${i} !== parseInt(${i})`;e.fail$data((0,An._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};ic.default=G0});var Jm=P(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});function Gm(e){let t=e.length,r=0,n=0,o;for(;n<t;)r++,o=e.charCodeAt(n++),o>=55296&&o<=56319&&n<t&&(o=e.charCodeAt(n),(o&64512)===56320&&n++);return r}ac.default=Gm;Gm.code='require("ajv/dist/runtime/ucs2length").default'});var Wm=P(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});var Xt=M(),J0=V(),W0=Jm(),Y0={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,Xt.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,Xt._)`{limit: ${e}}`},Q0={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:Y0,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?Xt.operators.GT:Xt.operators.LT,i=o.opts.unicode===!1?(0,Xt._)`${r}.length`:(0,Xt._)`${(0,J0.useFunc)(e.gen,W0.default)}(${r})`;e.fail$data((0,Xt._)`${i} ${s} ${n}`)}};cc.default=Q0});var Ym=P(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});var X0=Ke(),ex=V(),jr=M(),tx={message:({schemaCode:e})=>(0,jr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,jr._)`{pattern: ${e}}`},rx={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:tx,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,jr._)`new RegExp`:(0,ex.useFunc)(t,c),l=t.let("valid");t.try(()=>t.assign(l,(0,jr._)`${u}(${s}, ${a}).test(${r})`),()=>t.assign(l,!1)),e.fail$data((0,jr._)`!${l}`)}else{let c=(0,X0.usePattern)(e,o);e.fail$data((0,jr._)`!${c}.test(${r})`)}}};uc.default=rx});var Qm=P(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});var Nn=M(),nx={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,Nn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,Nn._)`{limit: ${e}}`},ox={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:nx,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?Nn.operators.GT:Nn.operators.LT;e.fail$data((0,Nn._)`Object.keys(${r}).length ${o} ${n}`)}};lc.default=ox});var Xm=P(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});var jn=Ke(),Zn=M(),sx=V(),ix={message:({params:{missingProperty:e}})=>(0,Zn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,Zn._)`{missingProperty: ${e}}`},ax={keyword:"required",type:"object",schemaType:"array",$data:!0,error:ix,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:i}=e,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let f=e.parentSchema.properties,{definedProperties:h}=e.it;for(let g of r)if(f?.[g]===void 0&&!h.has(g)){let v=i.schemaEnv.baseId+i.errSchemaPath,w=`required property "${g}" is not defined at "${v}" (strictRequired)`;(0,sx.checkStrictMode)(i,w,i.opts.strictRequired)}}function u(){if(c||s)e.block$data(Zn.nil,d);else for(let f of r)(0,jn.checkReportMissingProp)(e,f)}function l(){let f=t.let("missing");if(c||s){let h=t.let("valid",!0);e.block$data(h,()=>m(f,h)),e.ok(h)}else t.if((0,jn.checkMissingProp)(e,r,f)),(0,jn.reportMissingProp)(e,f),t.else()}function d(){t.forOf("prop",n,f=>{e.setParams({missingProperty:f}),t.if((0,jn.noPropertyInData)(t,o,f,a.ownProperties),()=>e.error())})}function m(f,h){e.setParams({missingProperty:f}),t.forOf(f,n,()=>{t.assign(h,(0,jn.propertyInData)(t,o,f,a.ownProperties)),t.if((0,Zn.not)(h),()=>{e.error(),t.break()})},Zn.nil)}}};dc.default=ax});var eh=P(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});var Mn=M(),cx={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,Mn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,Mn._)`{limit: ${e}}`},ux={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:cx,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?Mn.operators.GT:Mn.operators.LT;e.fail$data((0,Mn._)`${r}.length ${o} ${n}`)}};pc.default=ux});var as=P(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});var th=ja();th.code='require("ajv/dist/runtime/equal").default';fc.default=th});var rh=P(hc=>{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});var mc=Sn(),ze=M(),lx=V(),dx=as(),px={message:({params:{i:e,j:t}})=>(0,ze.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,ze._)`{i: ${e}, j: ${t}}`},fx={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:px,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=e;if(!n&&!o)return;let c=t.let("valid"),u=s.items?(0,mc.getSchemaTypes)(s.items):[];e.block$data(c,l,(0,ze._)`${i} === false`),e.ok(c);function l(){let h=t.let("i",(0,ze._)`${r}.length`),g=t.let("j");e.setParams({i:h,j:g}),t.assign(c,!0),t.if((0,ze._)`${h} > 1`,()=>(d()?m:f)(h,g))}function d(){return u.length>0&&!u.some(h=>h==="object"||h==="array")}function m(h,g){let v=t.name("item"),w=(0,mc.checkDataTypes)(u,v,a.opts.strictNumbers,mc.DataType.Wrong),x=t.const("indices",(0,ze._)`{}`);t.for((0,ze._)`;${h}--;`,()=>{t.let(v,(0,ze._)`${r}[${h}]`),t.if(w,(0,ze._)`continue`),u.length>1&&t.if((0,ze._)`typeof ${v} == "string"`,(0,ze._)`${v} += "_"`),t.if((0,ze._)`typeof ${x}[${v}] == "number"`,()=>{t.assign(g,(0,ze._)`${x}[${v}]`),e.error(),t.assign(c,!1).break()}).code((0,ze._)`${x}[${v}] = ${h}`)})}function f(h,g){let v=(0,lx.useFunc)(t,dx.default),w=t.name("outer");t.label(w).for((0,ze._)`;${h}--;`,()=>t.for((0,ze._)`${g} = ${h}; ${g}--;`,()=>t.if((0,ze._)`${v}(${r}[${h}], ${r}[${g}])`,()=>{e.error(),t.assign(c,!1).break(w)})))}}};hc.default=fx});var nh=P(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});var gc=M(),mx=V(),hx=as(),gx={message:"must be equal to constant",params:({schemaCode:e})=>(0,gc._)`{allowedValue: ${e}}`},_x={keyword:"const",$data:!0,error:gx,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,gc._)`!${(0,mx.useFunc)(t,hx.default)}(${r}, ${o})`):e.fail((0,gc._)`${s} !== ${r}`)}};_c.default=_x});var oh=P(yc=>{"use strict";Object.defineProperty(yc,"__esModule",{value:!0});var Dn=M(),yx=V(),vx=as(),wx={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Dn._)`{allowedValues: ${e}}`},$x={keyword:"enum",schemaType:"array",$data:!0,error:wx,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,yx.useFunc)(t,vx.default)),l;if(a||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let f=t.const("vSchema",s);l=(0,Dn.or)(...o.map((h,g)=>m(f,g)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",s,f=>t.if((0,Dn._)`${u()}(${r}, ${f})`,()=>t.assign(l,!0).break()))}function m(f,h){let g=o[h];return typeof g=="object"&&g!==null?(0,Dn._)`${u()}(${r}, ${f}[${h}])`:(0,Dn._)`${r} === ${g}`}}};yc.default=$x});var sh=P(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});var bx=Km(),xx=Bm(),Sx=Wm(),zx=Ym(),kx=Qm(),Px=Xm(),Tx=eh(),Rx=rh(),Ex=nh(),Ix=oh(),Ox=[bx.default,xx.default,Sx.default,zx.default,kx.default,Px.default,Tx.default,Rx.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Ex.default,Ix.default];vc.default=Ox});var $c=P(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.validateAdditionalItems=void 0;var er=M(),wc=V(),Cx={message:({params:{len:e}})=>(0,er.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,er._)`{limit: ${e}}`},Ax={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Cx,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,wc.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}ih(e,n)}};function ih(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,er._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,er._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,wc.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,er._)`${a} <= ${t.length}`);r.if((0,er.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,a,l=>{e.subschema({keyword:s,dataProp:l,dataPropType:wc.Type.Num},u),i.allErrors||r.if((0,er.not)(u),()=>r.break())})}}qn.validateAdditionalItems=ih;qn.default=Ax});var bc=P(Un=>{"use strict";Object.defineProperty(Un,"__esModule",{value:!0});Un.validateTuple=void 0;var ah=M(),cs=V(),Nx=Ke(),jx={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return ch(e,"additionalItems",t);r.items=!0,!(0,cs.alwaysValidSchema)(r,t)&&e.ok((0,Nx.validateArray)(e))}};function ch(e,t,r=e.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=e;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=cs.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,ah._)`${s}.length`);r.forEach((d,m)=>{(0,cs.alwaysValidSchema)(a,d)||(n.if((0,ah._)`${u} > ${m}`,()=>e.subschema({keyword:i,schemaProp:m,dataProp:m},c)),e.ok(c))});function l(d){let{opts:m,errSchemaPath:f}=a,h=r.length,g=h===d.minItems&&(h===d.maxItems||d[t]===!1);if(m.strictTuples&&!g){let v=`"${i}" is ${h}-tuple, but minItems or maxItems/${t} are not specified or different at path "${f}"`;(0,cs.checkStrictMode)(a,v,m.strictTuples)}}}Un.validateTuple=ch;Un.default=jx});var uh=P(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});var Zx=bc(),Mx={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,Zx.validateTuple)(e,"items")};xc.default=Mx});var dh=P(Sc=>{"use strict";Object.defineProperty(Sc,"__esModule",{value:!0});var lh=M(),Dx=V(),qx=Ke(),Ux=$c(),Lx={message:({params:{len:e}})=>(0,lh.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,lh._)`{limit: ${e}}`},Fx={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Lx,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,Dx.alwaysValidSchema)(n,t)&&(o?(0,Ux.validateAdditionalItems)(e,o):e.ok((0,qx.validateArray)(e)))}};Sc.default=Fx});var ph=P(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});var Ge=M(),us=V(),Vx={message:({params:{min:e,max:t}})=>t===void 0?(0,Ge.str)`must contain at least ${e} valid item(s)`:(0,Ge.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,Ge._)`{minContains: ${e}}`:(0,Ge._)`{minContains: ${e}, maxContains: ${t}}`},Hx={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Vx,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=t.const("len",(0,Ge._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,us.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,us.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,us.alwaysValidSchema)(s,r)){let g=(0,Ge._)`${l} >= ${i}`;a!==void 0&&(g=(0,Ge._)`${g} && ${l} <= ${a}`),e.pass(g);return}s.items=!0;let d=t.name("valid");a===void 0&&i===1?f(d,()=>t.if(d,()=>t.break())):i===0?(t.let(d,!0),a!==void 0&&t.if((0,Ge._)`${o}.length > 0`,m)):(t.let(d,!1),m()),e.result(d,()=>e.reset());function m(){let g=t.name("_valid"),v=t.let("count",0);f(g,()=>t.if(g,()=>h(v)))}function f(g,v){t.forRange("i",0,l,w=>{e.subschema({keyword:"contains",dataProp:w,dataPropType:us.Type.Num,compositeRule:!0},g),v()})}function h(g){t.code((0,Ge._)`${g}++`),a===void 0?t.if((0,Ge._)`${g} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,Ge._)`${g} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,Ge._)`${g} >= ${i}`,()=>t.assign(d,!0)))}}};zc.default=Hx});var hh=P(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.validateSchemaDeps=ut.validatePropertyDeps=ut.error=void 0;var kc=M(),Kx=V(),Ln=Ke();ut.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,kc.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,kc._)`{property: ${e},
3
+ var a_=Object.create;var Zs=Object.defineProperty;var c_=Object.getOwnPropertyDescriptor;var u_=Object.getOwnPropertyNames;var l_=Object.getPrototypeOf,d_=Object.prototype.hasOwnProperty;var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ds=(e,t)=>{for(var r in t)Zs(e,r,{get:t[r],enumerable:!0})},p_=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of u_(t))!d_.call(e,o)&&o!==r&&Zs(e,o,{get:()=>t[o],enumerable:!(n=c_(t,o))||n.enumerable});return e};var Tu=(e,t,r)=>(r=e!=null?a_(l_(e)):{},p_(t||!e||!e.__esModule?Zs(r,"default",{value:e,enumerable:!0}):r,e));var _n=P(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 hn=class{};K._CodeOrName=hn;K.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Ht=class extends hn{constructor(t){if(super(),!K.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};K.Name=Ht;var Be=class extends hn{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof Ht&&(r[n.str]=(r[n.str]||0)+1),r),{})}};K._Code=Be;K.nil=new Be("");function hf(e,...t){let r=[e[0]],n=0;for(;n<t.length;)ca(r,t[n]),r.push(e[++n]);return new Be(r)}K._=hf;var aa=new Be("+");function gf(e,...t){let r=[gn(e[0])],n=0;for(;n<t.length;)r.push(aa),ca(r,t[n]),r.push(aa,gn(e[++n]));return yw(r),new Be(r)}K.str=gf;function ca(e,t){t instanceof Be?e.push(...t._items):t instanceof Ht?e.push(t):e.push($w(t))}K.addCodeArg=ca;function yw(e){let t=1;for(;t<e.length-1;){if(e[t]===aa){let r=vw(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function vw(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Ht||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Ht))return`"${e}${t.slice(1)}`}function ww(e,t){return t.emptyStr()?e:e.emptyStr()?t:gf`${e}${t}`}K.strConcat=ww;function $w(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:gn(Array.isArray(e)?e.join(","):e)}function bw(e){return new Be(gn(e))}K.stringify=bw;function gn(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}K.safeStringify=gn;function Sw(e){return typeof e=="string"&&K.IDENTIFIER.test(e)?new Be(`.${e}`):hf`[${e}]`}K.getProperty=Sw;function xw(e){if(typeof e=="string"&&K.IDENTIFIER.test(e))return new Be(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}K.getEsmExportName=xw;function zw(e){return new Be(e.toString())}K.regexpCode=zw});var da=P(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Me.ValueScope=Me.ValueScopeName=Me.Scope=Me.varKinds=Me.UsedValueState=void 0;var je=_n(),ua=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Zo;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Zo||(Me.UsedValueState=Zo={}));Me.varKinds={const:new je.Name("const"),let:new je.Name("let"),var:new je.Name("var")};var Do=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof je.Name?t:this.name(t)}name(t){return new je.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Me.Scope=Do;var Uo=class extends je.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,je._)`.${new je.Name(r)}[${n}]`}};Me.ValueScopeName=Uo;var kw=(0,je._)`\n`,la=class extends Do{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?kw:je.nil}}get(){return this._scope}name(t){return new Uo(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let u=a.get(i);if(u)return u}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),l=c.length;return c[l]=r.ref,o.setValue(r,{property:s,itemIndex:l}),o}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,je._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let s=je.nil;for(let i in t){let a=t[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(l=>{if(c.has(l))return;c.set(l,Zo.Started);let u=r(l);if(u){let d=this.opts.es5?Me.varKinds.var:Me.varKinds.const;s=(0,je._)`${s}${d} ${l} = ${u};${this.opts._n}`}else if(u=o?.(l))s=(0,je._)`${s}${u}${this.opts._n}`;else throw new ua(l);c.set(l,Zo.Completed)})}return s}};Me.ValueScope=la});var Z=P(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.or=D.and=D.not=D.CodeGen=D.operators=D.varKinds=D.ValueScopeName=D.ValueScope=D.Scope=D.Name=D.regexpCode=D.stringify=D.getProperty=D.nil=D.strConcat=D.str=D._=void 0;var L=_n(),tt=da(),Tt=_n();Object.defineProperty(D,"_",{enumerable:!0,get:function(){return Tt._}});Object.defineProperty(D,"str",{enumerable:!0,get:function(){return Tt.str}});Object.defineProperty(D,"strConcat",{enumerable:!0,get:function(){return Tt.strConcat}});Object.defineProperty(D,"nil",{enumerable:!0,get:function(){return Tt.nil}});Object.defineProperty(D,"getProperty",{enumerable:!0,get:function(){return Tt.getProperty}});Object.defineProperty(D,"stringify",{enumerable:!0,get:function(){return Tt.stringify}});Object.defineProperty(D,"regexpCode",{enumerable:!0,get:function(){return Tt.regexpCode}});Object.defineProperty(D,"Name",{enumerable:!0,get:function(){return Tt.Name}});var Vo=da();Object.defineProperty(D,"Scope",{enumerable:!0,get:function(){return Vo.Scope}});Object.defineProperty(D,"ValueScope",{enumerable:!0,get:function(){return Vo.ValueScope}});Object.defineProperty(D,"ValueScopeName",{enumerable:!0,get:function(){return Vo.ValueScopeName}});Object.defineProperty(D,"varKinds",{enumerable:!0,get:function(){return Vo.varKinds}});D.operators={GT:new L._Code(">"),GTE:new L._Code(">="),LT:new L._Code("<"),LTE:new L._Code("<="),EQ:new L._Code("==="),NEQ:new L._Code("!=="),NOT:new L._Code("!"),OR:new L._Code("||"),AND:new L._Code("&&"),ADD:new L._Code("+")};var gt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},pa=class extends gt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?tt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=Pr(this.rhs,t,r)),this}get names(){return this.rhs instanceof L._CodeOrName?this.rhs.names:{}}},qo=class extends gt{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof L.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=Pr(this.rhs,t,r),this}get names(){let t=this.lhs instanceof L.Name?{}:{...this.lhs.names};return Fo(t,this.rhs)}},fa=class extends qo{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},ma=class extends gt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},ha=class extends gt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},ga=class extends gt{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},_a=class extends gt{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=Pr(this.code,t,r),this}get names(){return this.code instanceof L._CodeOrName?this.code.names:{}}},yn=class extends gt{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(t,r)||(Pw(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Gt(t,r.names),{})}},_t=class extends yn{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},ya=class extends yn{},kr=class extends _t{};kr.kind="else";var Bt=class e extends _t{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new kr(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(_f(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=Pr(this.condition,t,r),this}get names(){let t=super.names;return Fo(t,this.condition),this.else&&Gt(t,this.else.names),t}};Bt.kind="if";var Kt=class extends _t{};Kt.kind="for";var va=class extends Kt{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=Pr(this.iteration,t,r),this}get names(){return Gt(super.names,this.iteration.names)}},wa=class extends Kt{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?tt.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=Fo(super.names,this.from);return Fo(t,this.to)}},Lo=class extends Kt{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=Pr(this.iterable,t,r),this}get names(){return Gt(super.names,this.iterable.names)}},vn=class extends _t{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};vn.kind="func";var wn=class extends yn{render(t){return"return "+super.render(t)}};wn.kind="return";var $a=class extends _t{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&Gt(t,this.catch.names),this.finally&&Gt(t,this.finally.names),t}},$n=class extends _t{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};$n.kind="catch";var bn=class extends _t{render(t){return"finally"+super.render(t)}};bn.kind="finally";var ba=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
4
+ `:""},this._extScope=t,this._scope=new tt.Scope({parent:t}),this._nodes=[new ya]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new pa(t,s,n)),s}const(t,r,n){return this._def(tt.varKinds.const,t,r,n)}let(t,r,n){return this._def(tt.varKinds.let,t,r,n)}var(t,r,n){return this._def(tt.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new qo(t,r,n))}add(t,r){return this._leafNode(new fa(t,D.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==L.nil&&this._leafNode(new _a(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,L.addCodeArg)(r,o));return r.push("}"),new L._Code(r)}if(t,r,n){if(this._blockNode(new Bt(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new Bt(t))}else(){return this._elseNode(new kr)}endIf(){return this._endBlockNode(Bt,kr)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new va(t),r)}forRange(t,r,n,o,s=this.opts.es5?tt.varKinds.var:tt.varKinds.let){let i=this._scope.toName(t);return this._for(new wa(s,i,r,n),()=>o(i))}forOf(t,r,n,o=tt.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof L.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,L._)`${i}.length`,a=>{this.var(s,(0,L._)`${i}[${a}]`),n(s)})}return this._for(new Lo("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?tt.varKinds.var:tt.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,L._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new Lo("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Kt)}label(t){return this._leafNode(new ma(t))}break(t){return this._leafNode(new ha(t))}return(t){let r=new wn;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(wn)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new $a;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new $n(s),r(s)}return n&&(this._currNode=o.finally=new bn,this.code(n)),this._endBlockNode($n,bn)}throw(t){return this._leafNode(new ga(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=L.nil,n,o){return this._blockNode(new vn(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(vn)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof Bt))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};D.CodeGen=ba;function Gt(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Fo(e,t){return t instanceof L._CodeOrName?Gt(e,t.names):e}function Pr(e,t,r){if(e instanceof L.Name)return n(e);if(!o(e))return e;return new L._Code(e._items.reduce((s,i)=>(i instanceof L.Name&&(i=n(i)),i instanceof L._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||t[s.str]!==1?s:(delete t[s.str],i)}function o(s){return s instanceof L._Code&&s._items.some(i=>i instanceof L.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function Pw(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function _f(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,L._)`!${Sa(e)}`}D.not=_f;var Tw=yf(D.operators.AND);function Rw(...e){return e.reduce(Tw)}D.and=Rw;var Ew=yf(D.operators.OR);function Iw(...e){return e.reduce(Ew)}D.or=Iw;function yf(e){return(t,r)=>t===L.nil?r:r===L.nil?t:(0,L._)`${Sa(t)} ${e} ${Sa(r)}`}function Sa(e){return e instanceof L.Name?e:(0,L._)`(${e})`}});var V=P(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 re=Z(),Ow=_n();function Aw(e){let t={};for(let r of e)t[r]=!0;return t}U.toHash=Aw;function Cw(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:($f(e,t),!bf(t,e.self.RULES.all))}U.alwaysValidSchema=Cw;function $f(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||zf(e,`unknown keyword: "${s}"`)}U.checkUnknownRules=$f;function bf(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}U.schemaHasRules=bf;function Nw(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}U.schemaHasRulesButRef=Nw;function jw({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,re._)`${r}`}return(0,re._)`${e}${t}${(0,re.getProperty)(n)}`}U.schemaRefOrVal=jw;function Mw(e){return Sf(decodeURIComponent(e))}U.unescapeFragment=Mw;function Zw(e){return encodeURIComponent(za(e))}U.escapeFragment=Zw;function za(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}U.escapeJsonPointer=za;function Sf(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}U.unescapeJsonPointer=Sf;function Dw(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}U.eachItem=Dw;function vf({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof re.Name?(s instanceof re.Name?e(o,s,i):t(o,s,i),i):s instanceof re.Name?(t(o,i,s),s):r(s,i);return a===re.Name&&!(c instanceof re.Name)?n(o,c):c}}U.mergeEvaluated={props:vf({mergeNames:(e,t,r)=>e.if((0,re._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,re._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,re._)`${r} || {}`).code((0,re._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,re._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,re._)`${r} || {}`),ka(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:xf}),items:vf({mergeNames:(e,t,r)=>e.if((0,re._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,re._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,re._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,re._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function xf(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,re._)`{}`);return t!==void 0&&ka(e,r,t),r}U.evaluatedPropsToName=xf;function ka(e,t,r){Object.keys(r).forEach(n=>e.assign((0,re._)`${t}${(0,re.getProperty)(n)}`,!0))}U.setEvaluated=ka;var wf={};function Uw(e,t){return e.scopeValue("func",{ref:t,code:wf[t.code]||(wf[t.code]=new Ow._Code(t.code))})}U.useFunc=Uw;var xa;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(xa||(U.Type=xa={}));function qw(e,t,r){if(e instanceof re.Name){let n=t===xa.Num;return r?n?(0,re._)`"[" + ${e} + "]"`:(0,re._)`"['" + ${e} + "']"`:n?(0,re._)`"/" + ${e}`:(0,re._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,re.getProperty)(e).toString():"/"+za(e)}U.getErrorPath=qw;function zf(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}U.checkStrictMode=zf});var yt=P(Pa=>{"use strict";Object.defineProperty(Pa,"__esModule",{value:!0});var Te=Z(),Lw={data:new Te.Name("data"),valCxt:new Te.Name("valCxt"),instancePath:new Te.Name("instancePath"),parentData:new Te.Name("parentData"),parentDataProperty:new Te.Name("parentDataProperty"),rootData:new Te.Name("rootData"),dynamicAnchors:new Te.Name("dynamicAnchors"),vErrors:new Te.Name("vErrors"),errors:new Te.Name("errors"),this:new Te.Name("this"),self:new Te.Name("self"),scope:new Te.Name("scope"),json:new Te.Name("json"),jsonPos:new Te.Name("jsonPos"),jsonLen:new Te.Name("jsonLen"),jsonPart:new Te.Name("jsonPart")};Pa.default=Lw});var Sn=P(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.extendErrors=Re.resetErrorsCount=Re.reportExtraError=Re.reportError=Re.keyword$DataError=Re.keywordError=void 0;var H=Z(),Ho=V(),Oe=yt();Re.keywordError={message:({keyword:e})=>(0,H.str)`must pass "${e}" keyword validation`};Re.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,H.str)`"${e}" keyword must be ${t} ($data)`:(0,H.str)`"${e}" keyword is invalid ($data)`};function Fw(e,t=Re.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=Tf(e,t,r);n??(i||a)?kf(s,c):Pf(o,(0,H._)`[${c}]`)}Re.reportError=Fw;function Vw(e,t=Re.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=Tf(e,t,r);kf(o,a),s||i||Pf(n,Oe.default.vErrors)}Re.reportExtraError=Vw;function Hw(e,t){e.assign(Oe.default.errors,t),e.if((0,H._)`${Oe.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,H._)`${Oe.default.vErrors}.length`,t),()=>e.assign(Oe.default.vErrors,null)))}Re.resetErrorsCount=Hw;function Bw({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=e.name("err");e.forRange("i",o,Oe.default.errors,a=>{e.const(i,(0,H._)`${Oe.default.vErrors}[${a}]`),e.if((0,H._)`${i}.instancePath === undefined`,()=>e.assign((0,H._)`${i}.instancePath`,(0,H.strConcat)(Oe.default.instancePath,s.errorPath))),e.assign((0,H._)`${i}.schemaPath`,(0,H.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,H._)`${i}.schema`,r),e.assign((0,H._)`${i}.data`,n))})}Re.extendErrors=Bw;function kf(e,t){let r=e.const("err",t);e.if((0,H._)`${Oe.default.vErrors} === null`,()=>e.assign(Oe.default.vErrors,(0,H._)`[${r}]`),(0,H._)`${Oe.default.vErrors}.push(${r})`),e.code((0,H._)`${Oe.default.errors}++`)}function Pf(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,H._)`new ${e.ValidationError}(${t})`):(r.assign((0,H._)`${n}.errors`,t),r.return(!1))}var Jt={keyword:new H.Name("keyword"),schemaPath:new H.Name("schemaPath"),params:new H.Name("params"),propertyName:new H.Name("propertyName"),message:new H.Name("message"),schema:new H.Name("schema"),parentSchema:new H.Name("parentSchema")};function Tf(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,H._)`{}`:Kw(e,t,r)}function Kw(e,t,r={}){let{gen:n,it:o}=e,s=[Gw(o,r),Jw(e,r)];return Ww(e,t,s),n.object(...s)}function Gw({errorPath:e},{instancePath:t}){let r=t?(0,H.str)`${e}${(0,Ho.getErrorPath)(t,Ho.Type.Str)}`:e;return[Oe.default.instancePath,(0,H.strConcat)(Oe.default.instancePath,r)]}function Jw({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,H.str)`${t}/${e}`;return r&&(o=(0,H.str)`${o}${(0,Ho.getErrorPath)(r,Ho.Type.Str)}`),[Jt.schemaPath,o]}function Ww(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:l,topSchemaRef:u,schemaPath:d}=a;n.push([Jt.keyword,o],[Jt.params,typeof t=="function"?t(e):t||(0,H._)`{}`]),c.messages&&n.push([Jt.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([Jt.schema,i],[Jt.parentSchema,(0,H._)`${u}${d}`],[Oe.default.data,s]),l&&n.push([Jt.propertyName,l])}});var Ef=P(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.boolOrEmptySchema=Tr.topBoolOrEmptySchema=void 0;var Yw=Sn(),Qw=Z(),Xw=yt(),e$={message:"boolean schema is false"};function t$(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Rf(e,!1):typeof r=="object"&&r.$async===!0?t.return(Xw.default.data):(t.assign((0,Qw._)`${n}.errors`,null),t.return(!0))}Tr.topBoolOrEmptySchema=t$;function r$(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Rf(e)):r.var(t,!0)}Tr.boolOrEmptySchema=r$;function Rf(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,Yw.reportError)(o,e$,void 0,t)}});var Ta=P(Rr=>{"use strict";Object.defineProperty(Rr,"__esModule",{value:!0});Rr.getRules=Rr.isJSONType=void 0;var n$=["string","number","integer","boolean","null","object","array"],o$=new Set(n$);function s$(e){return typeof e=="string"&&o$.has(e)}Rr.isJSONType=s$;function i$(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Rr.getRules=i$});var Ra=P(Rt=>{"use strict";Object.defineProperty(Rt,"__esModule",{value:!0});Rt.shouldUseRule=Rt.shouldUseGroup=Rt.schemaHasRulesForType=void 0;function a$({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&If(e,n)}Rt.schemaHasRulesForType=a$;function If(e,t){return t.rules.some(r=>Of(e,r))}Rt.shouldUseGroup=If;function Of(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Rt.shouldUseRule=Of});var xn=P(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.reportTypeError=Ee.checkDataTypes=Ee.checkDataType=Ee.coerceAndCheckDataType=Ee.getJSONTypes=Ee.getSchemaTypes=Ee.DataType=void 0;var c$=Ta(),u$=Ra(),l$=Sn(),M=Z(),Af=V(),Er;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Er||(Ee.DataType=Er={}));function d$(e){let t=Cf(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}Ee.getSchemaTypes=d$;function Cf(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(c$.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Ee.getJSONTypes=Cf;function p$(e,t){let{gen:r,data:n,opts:o}=e,s=f$(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,u$.schemaHasRulesForType)(e,t[0]));if(i){let a=Ia(t,n,o.strictNumbers,Er.Wrong);r.if(a,()=>{s.length?m$(e,t,s):Oa(e)})}return i}Ee.coerceAndCheckDataType=p$;var Nf=new Set(["string","number","integer","boolean","null"]);function f$(e,t){return t?e.filter(r=>Nf.has(r)||t==="array"&&r==="array"):[]}function m$(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,M._)`typeof ${o}`),a=n.let("coerced",(0,M._)`undefined`);s.coerceTypes==="array"&&n.if((0,M._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,M._)`${o}[0]`).assign(i,(0,M._)`typeof ${o}`).if(Ia(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,M._)`${a} !== undefined`);for(let l of r)(Nf.has(l)||l==="array"&&s.coerceTypes==="array")&&c(l);n.else(),Oa(e),n.endIf(),n.if((0,M._)`${a} !== undefined`,()=>{n.assign(o,a),h$(e,a)});function c(l){switch(l){case"string":n.elseIf((0,M._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,M._)`"" + ${o}`).elseIf((0,M._)`${o} === null`).assign(a,(0,M._)`""`);return;case"number":n.elseIf((0,M._)`${i} == "boolean" || ${o} === null
5
+ || (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,M._)`+${o}`);return;case"integer":n.elseIf((0,M._)`${i} === "boolean" || ${o} === null
6
+ || (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,M._)`+${o}`);return;case"boolean":n.elseIf((0,M._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,M._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,M._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,M._)`${i} === "string" || ${i} === "number"
7
+ || ${i} === "boolean" || ${o} === null`).assign(a,(0,M._)`[${o}]`)}}}function h$({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,M._)`${t} !== undefined`,()=>e.assign((0,M._)`${t}[${r}]`,n))}function Ea(e,t,r,n=Er.Correct){let o=n===Er.Correct?M.operators.EQ:M.operators.NEQ,s;switch(e){case"null":return(0,M._)`${t} ${o} null`;case"array":s=(0,M._)`Array.isArray(${t})`;break;case"object":s=(0,M._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,M._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,M._)`typeof ${t} ${o} ${e}`}return n===Er.Correct?s:(0,M.not)(s);function i(a=M.nil){return(0,M.and)((0,M._)`typeof ${t} == "number"`,a,r?(0,M._)`isFinite(${t})`:M.nil)}}Ee.checkDataType=Ea;function Ia(e,t,r,n){if(e.length===1)return Ea(e[0],t,r,n);let o,s=(0,Af.toHash)(e);if(s.array&&s.object){let i=(0,M._)`typeof ${t} != "object"`;o=s.null?i:(0,M._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=M.nil;s.number&&delete s.integer;for(let i in s)o=(0,M.and)(o,Ea(i,t,r,n));return o}Ee.checkDataTypes=Ia;var g$={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,M._)`{type: ${e}}`:(0,M._)`{type: ${t}}`};function Oa(e){let t=_$(e);(0,l$.reportError)(t,g$)}Ee.reportTypeError=Oa;function _$(e){let{gen:t,data:r,schema:n}=e,o=(0,Af.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var Mf=P(Bo=>{"use strict";Object.defineProperty(Bo,"__esModule",{value:!0});Bo.assignDefaults=void 0;var Ir=Z(),y$=V();function v$(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)jf(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>jf(e,s,o.default))}Bo.assignDefaults=v$;function jf(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,Ir._)`${s}${(0,Ir.getProperty)(t)}`;if(o){(0,y$.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,Ir._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Ir._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Ir._)`${a} = ${(0,Ir.stringify)(r)}`)}});var Ke=P(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.validateUnion=ee.validateArray=ee.usePattern=ee.callValidateCode=ee.schemaProperties=ee.allSchemaProperties=ee.noPropertyInData=ee.propertyInData=ee.isOwnProperty=ee.hasPropFunc=ee.reportMissingProp=ee.checkMissingProp=ee.checkReportMissingProp=void 0;var ue=Z(),Aa=V(),Et=yt(),w$=V();function $$(e,t){let{gen:r,data:n,it:o}=e;r.if(Na(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,ue._)`${t}`},!0),e.error()})}ee.checkReportMissingProp=$$;function b$({gen:e,data:t,it:{opts:r}},n,o){return(0,ue.or)(...n.map(s=>(0,ue.and)(Na(e,t,s,r.ownProperties),(0,ue._)`${o} = ${s}`)))}ee.checkMissingProp=b$;function S$(e,t){e.setParams({missingProperty:t},!0),e.error()}ee.reportMissingProp=S$;function Zf(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,ue._)`Object.prototype.hasOwnProperty`})}ee.hasPropFunc=Zf;function Ca(e,t,r){return(0,ue._)`${Zf(e)}.call(${t}, ${r})`}ee.isOwnProperty=Ca;function x$(e,t,r,n){let o=(0,ue._)`${t}${(0,ue.getProperty)(r)} !== undefined`;return n?(0,ue._)`${o} && ${Ca(e,t,r)}`:o}ee.propertyInData=x$;function Na(e,t,r,n){let o=(0,ue._)`${t}${(0,ue.getProperty)(r)} === undefined`;return n?(0,ue.or)(o,(0,ue.not)(Ca(e,t,r))):o}ee.noPropertyInData=Na;function Df(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}ee.allSchemaProperties=Df;function z$(e,t){return Df(t).filter(r=>!(0,Aa.alwaysValidSchema)(e,t[r]))}ee.schemaProperties=z$;function k$({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,l){let u=l?(0,ue._)`${e}, ${t}, ${n}${o}`:t,d=[[Et.default.instancePath,(0,ue.strConcat)(Et.default.instancePath,s)],[Et.default.parentData,i.parentData],[Et.default.parentDataProperty,i.parentDataProperty],[Et.default.rootData,Et.default.rootData]];i.opts.dynamicRef&&d.push([Et.default.dynamicAnchors,Et.default.dynamicAnchors]);let f=(0,ue._)`${u}, ${r.object(...d)}`;return c!==ue.nil?(0,ue._)`${a}.call(${c}, ${f})`:(0,ue._)`${a}(${f})`}ee.callValidateCode=k$;var P$=(0,ue._)`new RegExp`;function T$({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,s=o(r,n);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,ue._)`${o.code==="new RegExp"?P$:(0,w$.useFunc)(e,o)}(${r}, ${n})`})}ee.usePattern=T$;function R$(e){let{gen:t,data:r,keyword:n,it:o}=e,s=t.name("valid");if(o.allErrors){let a=t.let("valid",!0);return i(()=>t.assign(a,!1)),a}return t.var(s,!0),i(()=>t.break()),s;function i(a){let c=t.const("len",(0,ue._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:Aa.Type.Num},s),t.if((0,ue.not)(s),a)})}}ee.validateArray=R$;function E$(e){let{gen:t,schema:r,keyword:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Aa.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((c,l)=>{let u=e.subschema({keyword:n,schemaProp:l,compositeRule:!0},a);t.assign(i,(0,ue._)`${i} || ${a}`),e.mergeValidEvaluated(u,a)||t.if((0,ue.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}ee.validateUnion=E$});var Lf=P(at=>{"use strict";Object.defineProperty(at,"__esModule",{value:!0});at.validateKeywordUsage=at.validSchemaType=at.funcKeywordCode=at.macroKeywordCode=void 0;var Ae=Z(),Wt=yt(),I$=Ke(),O$=Sn();function A$(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=qf(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let l=r.name("valid");e.subschema({schema:a,schemaPath:Ae.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}at.macroKeywordCode=A$;function C$(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;j$(c,t);let l=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,u=qf(n,o,l),d=n.let("valid");e.block$data(d,f),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function f(){if(t.errors===!1)g(),t.modifying&&Uf(e),v(()=>e.error());else{let $=t.async?m():h();t.modifying&&Uf(e),v(()=>N$(e,$))}}function m(){let $=n.let("ruleErrs",null);return n.try(()=>g((0,Ae._)`await `),S=>n.assign(d,!1).if((0,Ae._)`${S} instanceof ${c.ValidationError}`,()=>n.assign($,(0,Ae._)`${S}.errors`),()=>n.throw(S))),$}function h(){let $=(0,Ae._)`${u}.errors`;return n.assign($,null),g(Ae.nil),$}function g($=t.async?(0,Ae._)`await `:Ae.nil){let S=c.opts.passContext?Wt.default.this:Wt.default.self,b=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,Ae._)`${$}${(0,I$.callValidateCode)(e,u,S,b)}`,t.modifying)}function v($){var S;n.if((0,Ae.not)((S=t.valid)!==null&&S!==void 0?S:d),$)}}at.funcKeywordCode=C$;function Uf(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Ae._)`${n.parentData}[${n.parentDataProperty}]`))}function N$(e,t){let{gen:r}=e;r.if((0,Ae._)`Array.isArray(${t})`,()=>{r.assign(Wt.default.vErrors,(0,Ae._)`${Wt.default.vErrors} === null ? ${t} : ${Wt.default.vErrors}.concat(${t})`).assign(Wt.default.errors,(0,Ae._)`${Wt.default.vErrors}.length`),(0,O$.extendErrors)(e)},()=>e.error())}function j$({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function qf(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Ae.stringify)(r)})}function M$(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}at.validSchemaType=M$;function Z$({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}at.validateKeywordUsage=Z$});var Vf=P(It=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});It.extendSubschemaMode=It.extendSubschemaData=It.getSubschema=void 0;var ct=Z(),Ff=V();function D$(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,ct._)`${e.schemaPath}${(0,ct.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,ct._)`${e.schemaPath}${(0,ct.getProperty)(t)}${(0,ct.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,Ff.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}It.getSubschema=D$;function U$(e,t,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(r!==void 0){let{errorPath:l,dataPathArr:u,opts:d}=t,f=a.let("data",(0,ct._)`${t.data}${(0,ct.getProperty)(r)}`,!0);c(f),e.errorPath=(0,ct.str)`${l}${(0,Ff.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,ct._)`${r}`,e.dataPathArr=[...u,e.parentDataProperty]}if(o!==void 0){let l=o instanceof ct.Name?o:a.let("data",o,!0);c(l),i!==void 0&&(e.propertyName=i)}s&&(e.dataTypes=s);function c(l){e.data=l,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,l]}}It.extendSubschemaData=U$;function q$(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),s!==void 0&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r}It.extendSubschemaMode=q$});var ja=P((kO,Hf)=>{"use strict";Hf.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!e(t[i],r[i]))return!1}return!0}return t!==t&&r!==r}});var Kf=P((PO,Bf)=>{"use strict";var Ot=Bf.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Ko(t,n,o,e,"",e)};Ot.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Ot.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Ot.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Ot.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 Ko(e,t,r,n,o,s,i,a,c,l){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,s,i,a,c,l);for(var u in n){var d=n[u];if(Array.isArray(d)){if(u in Ot.arrayKeywords)for(var f=0;f<d.length;f++)Ko(e,t,r,d[f],o+"/"+u+"/"+f,s,o,u,n,f)}else if(u in Ot.propsKeywords){if(d&&typeof d=="object")for(var m in d)Ko(e,t,r,d[m],o+"/"+u+"/"+L$(m),s,o,u,n,m)}else(u in Ot.keywords||e.allKeys&&!(u in Ot.skipKeywords))&&Ko(e,t,r,d,o+"/"+u,s,o,u,n)}r(n,o,s,i,a,c,l)}}function L$(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var zn=P(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.getSchemaRefs=Ze.resolveUrl=Ze.normalizeId=Ze._getFullPath=Ze.getFullPath=Ze.inlineRef=void 0;var F$=V(),V$=ja(),H$=Kf(),B$=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function K$(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Ma(e):t?Gf(e)<=t:!1}Ze.inlineRef=K$;var G$=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Ma(e){for(let t in e){if(G$.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(Ma)||typeof r=="object"&&Ma(r))return!0}return!1}function Gf(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!B$.has(r)&&(typeof e[r]=="object"&&(0,F$.eachItem)(e[r],n=>t+=Gf(n)),t===1/0))return 1/0}return t}function Jf(e,t="",r){r!==!1&&(t=Or(t));let n=e.parse(t);return Wf(e,n)}Ze.getFullPath=Jf;function Wf(e,t){return e.serialize(t).split("#")[0]+"#"}Ze._getFullPath=Wf;var J$=/#\/?$/;function Or(e){return e?e.replace(J$,""):""}Ze.normalizeId=Or;function W$(e,t,r){return r=Or(r),e.resolve(t,r)}Ze.resolveUrl=W$;var Y$=/^[a-z_][-a-z0-9._]*$/i;function Q$(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Or(e[r]||t),s={"":o},i=Jf(n,o,!1),a={},c=new Set;return H$(e,{allKeys:!0},(d,f,m,h)=>{if(h===void 0)return;let g=i+f,v=s[h];typeof d[r]=="string"&&(v=$.call(this,d[r])),S.call(this,d.$anchor),S.call(this,d.$dynamicAnchor),s[f]=v;function $(b){let T=this.opts.uriResolver.resolve;if(b=Or(v?T(v,b):b),c.has(b))throw u(b);c.add(b);let y=this.refs[b];return typeof y=="string"&&(y=this.refs[y]),typeof y=="object"?l(d,y.schema,b):b!==Or(g)&&(b[0]==="#"?(l(d,a[b],b),a[b]=d):this.refs[b]=g),b}function S(b){if(typeof b=="string"){if(!Y$.test(b))throw new Error(`invalid anchor "${b}"`);$.call(this,`#${b}`)}}}),a;function l(d,f,m){if(f!==void 0&&!V$(d,f))throw u(m)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Ze.getSchemaRefs=Q$});var Tn=P(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.getData=At.KeywordCxt=At.validateFunctionCode=void 0;var tm=Ef(),Yf=xn(),Da=Ra(),Go=xn(),X$=Mf(),Pn=Lf(),Za=Vf(),O=Z(),j=yt(),eb=zn(),vt=V(),kn=Sn();function tb(e){if(om(e)&&(sm(e),nm(e))){ob(e);return}rm(e,()=>(0,tm.topBoolOrEmptySchema)(e))}At.validateFunctionCode=tb;function rm({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,O._)`${j.default.data}, ${j.default.valCxt}`,n.$async,()=>{e.code((0,O._)`"use strict"; ${Qf(r,o)}`),nb(e,o),e.code(s)}):e.func(t,(0,O._)`${j.default.data}, ${rb(o)}`,n.$async,()=>e.code(Qf(r,o)).code(s))}function rb(e){return(0,O._)`{${j.default.instancePath}="", ${j.default.parentData}, ${j.default.parentDataProperty}, ${j.default.rootData}=${j.default.data}${e.dynamicRef?(0,O._)`, ${j.default.dynamicAnchors}={}`:O.nil}}={}`}function nb(e,t){e.if(j.default.valCxt,()=>{e.var(j.default.instancePath,(0,O._)`${j.default.valCxt}.${j.default.instancePath}`),e.var(j.default.parentData,(0,O._)`${j.default.valCxt}.${j.default.parentData}`),e.var(j.default.parentDataProperty,(0,O._)`${j.default.valCxt}.${j.default.parentDataProperty}`),e.var(j.default.rootData,(0,O._)`${j.default.valCxt}.${j.default.rootData}`),t.dynamicRef&&e.var(j.default.dynamicAnchors,(0,O._)`${j.default.valCxt}.${j.default.dynamicAnchors}`)},()=>{e.var(j.default.instancePath,(0,O._)`""`),e.var(j.default.parentData,(0,O._)`undefined`),e.var(j.default.parentDataProperty,(0,O._)`undefined`),e.var(j.default.rootData,j.default.data),t.dynamicRef&&e.var(j.default.dynamicAnchors,(0,O._)`{}`)})}function ob(e){let{schema:t,opts:r,gen:n}=e;rm(e,()=>{r.$comment&&t.$comment&&am(e),ub(e),n.let(j.default.vErrors,null),n.let(j.default.errors,0),r.unevaluated&&sb(e),im(e),pb(e)})}function sb(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,O._)`${r}.evaluated`),t.if((0,O._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,O._)`${e.evaluated}.props`,(0,O._)`undefined`)),t.if((0,O._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,O._)`${e.evaluated}.items`,(0,O._)`undefined`))}function Qf(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,O._)`/*# sourceURL=${r} */`:O.nil}function ib(e,t){if(om(e)&&(sm(e),nm(e))){ab(e,t);return}(0,tm.boolOrEmptySchema)(e,t)}function nm({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function om(e){return typeof e.schema!="boolean"}function ab(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&am(e),lb(e),db(e);let s=n.const("_errs",j.default.errors);im(e,s),n.var(t,(0,O._)`${s} === ${j.default.errors}`)}function sm(e){(0,vt.checkUnknownRules)(e),cb(e)}function im(e,t){if(e.opts.jtd)return Xf(e,[],!1,t);let r=(0,Yf.getSchemaTypes)(e.schema),n=(0,Yf.coerceAndCheckDataType)(e,r);Xf(e,r,!n,t)}function cb(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,vt.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function ub(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,vt.checkStrictMode)(e,"default is ignored in the schema root")}function lb(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,eb.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function db(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function am({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,O._)`${j.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,O.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,O._)`${j.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function pb(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,O._)`${j.default.errors} === 0`,()=>t.return(j.default.data),()=>t.throw((0,O._)`new ${o}(${j.default.vErrors})`)):(t.assign((0,O._)`${n}.errors`,j.default.vErrors),s.unevaluated&&fb(e),t.return((0,O._)`${j.default.errors} === 0`))}function fb({gen:e,evaluated:t,props:r,items:n}){r instanceof O.Name&&e.assign((0,O._)`${t}.props`,r),n instanceof O.Name&&e.assign((0,O._)`${t}.items`,n)}function Xf(e,t,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:l}=e,{RULES:u}=l;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,vt.schemaHasRulesButRef)(s,u))){o.block(()=>um(e,"$ref",u.all.$ref.definition));return}c.jtd||mb(e,t),o.block(()=>{for(let f of u.rules)d(f);d(u.post)});function d(f){(0,Da.shouldUseGroup)(s,f)&&(f.type?(o.if((0,Go.checkDataType)(f.type,i,c.strictNumbers)),em(e,f),t.length===1&&t[0]===f.type&&r&&(o.else(),(0,Go.reportTypeError)(e)),o.endIf()):em(e,f),a||o.if((0,O._)`${j.default.errors} === ${n||0}`))}}function em(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,X$.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,Da.shouldUseRule)(n,s)&&um(e,s.keyword,s.definition,t.type)})}function mb(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(hb(e,t),e.opts.allowUnionTypes||gb(e,t),_b(e,e.dataTypes))}function hb(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{cm(e.dataTypes,r)||Ua(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),vb(e,t)}}function gb(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Ua(e,"use allowUnionTypes to allow union type keyword")}function _b(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Da.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>yb(t,i))&&Ua(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function yb(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function cm(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function vb(e,t){let r=[];for(let n of e.dataTypes)cm(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Ua(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,vt.checkStrictMode)(e,t,e.opts.strictTypes)}var Jo=class{constructor(t,r,n){if((0,Pn.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,vt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",lm(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,Pn.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",j.default.errors))}result(t,r,n){this.failResult((0,O.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,O.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,O._)`${r} !== undefined && (${(0,O.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?kn.reportExtraError:kn.reportError)(this,this.def.error,r)}$dataError(){(0,kn.reportError)(this,this.def.$dataError||kn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,kn.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=O.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=O.nil,r=O.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,O.or)((0,O._)`${o} === undefined`,r)),t!==O.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==O.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,O.or)(i(),a());function i(){if(n.length){if(!(r instanceof O.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,O._)`${(0,Go.checkDataTypes)(c,r,s.opts.strictNumbers,Go.DataType.Wrong)}`}return O.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,O._)`!${c}(${r})`}return O.nil}}subschema(t,r){let n=(0,Za.getSubschema)(this.it,t);(0,Za.extendSubschemaData)(n,this.it,t),(0,Za.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return ib(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=vt.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=vt.mergeEvaluated.items(o,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(t,O.Name)),!0}};At.KeywordCxt=Jo;function um(e,t,r,n){let o=new Jo(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,Pn.funcKeywordCode)(o,r):"macro"in r?(0,Pn.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,Pn.funcKeywordCode)(o,r)}var wb=/^\/(?:[^~]|~0|~1)*$/,$b=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function lm(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return j.default.rootData;if(e[0]==="/"){if(!wb.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=j.default.rootData}else{let l=$b.exec(e);if(!l)throw new Error(`Invalid JSON-pointer: ${e}`);let u=+l[1];if(o=l[2],o==="#"){if(u>=t)throw new Error(c("property/index",u));return n[t-u]}if(u>t)throw new Error(c("data",u));if(s=r[t-u],!o)return s}let i=s,a=o.split("/");for(let l of a)l&&(s=(0,O._)`${s}${(0,O.getProperty)((0,vt.unescapeJsonPointer)(l))}`,i=(0,O._)`${i} && ${s}`);return i;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${t}`}}At.getData=lm});var Wo=P(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});var qa=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};La.default=qa});var Rn=P(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});var Fa=zn(),Va=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Fa.resolveUrl)(t,r,n),this.missingSchema=(0,Fa.normalizeId)((0,Fa.getFullPath)(t,this.missingRef))}};Ha.default=Va});var Qo=P(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});Ge.resolveSchema=Ge.getCompilingSchema=Ge.resolveRef=Ge.compileSchema=Ge.SchemaEnv=void 0;var rt=Z(),bb=Wo(),Yt=yt(),nt=zn(),dm=V(),Sb=Tn(),Ar=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,nt.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};Ge.SchemaEnv=Ar;function Ka(e){let t=pm.call(this,e);if(t)return t;let r=(0,nt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new rt.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:bb.default,code:(0,rt._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let l={gen:i,allErrors:this.opts.allErrors,data:Yt.default.data,parentData:Yt.default.parentData,parentDataProperty:Yt.default.parentDataProperty,dataNames:[Yt.default.data],dataPathArr:[rt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,rt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:rt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,rt._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(e),(0,Sb.validateFunctionCode)(l),i.optimize(this.opts.code.optimize);let d=i.toString();u=`${i.scopeRefs(Yt.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,e));let m=new Function(`${Yt.default.self}`,`${Yt.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:m}),m.errors=null,m.schema=e.schema,m.schemaEnv=e,e.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:h,items:g}=l;m.evaluated={props:h instanceof rt.Name?void 0:h,items:g instanceof rt.Name?void 0:g,dynamicProps:h instanceof rt.Name,dynamicItems:g instanceof rt.Name},m.source&&(m.source.evaluated=(0,rt.stringify)(m.evaluated))}return e.validate=m,e}catch(d){throw delete e.validate,delete e.validateName,u&&this.logger.error("Error compiling schema, function code:",u),d}finally{this._compilations.delete(e)}}Ge.compileSchema=Ka;function xb(e,t,r){var n;r=(0,nt.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=Pb.call(this,e,r);if(s===void 0){let i=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Ar({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=zb.call(this,s)}Ge.resolveRef=xb;function zb(e){return(0,nt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Ka.call(this,e)}function pm(e){for(let t of this._compilations)if(kb(t,e))return t}Ge.getCompilingSchema=pm;function kb(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function Pb(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Yo.call(this,e,t)}function Yo(e,t){let r=this.opts.uriResolver.parse(t),n=(0,nt._getFullPath)(this.opts.uriResolver,r),o=(0,nt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return Ba.call(this,r,e);let s=(0,nt.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Yo.call(this,e,i);return typeof a?.schema!="object"?void 0:Ba.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Ka.call(this,i),s===(0,nt.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,l=a[c];return l&&(o=(0,nt.resolveUrl)(this.opts.uriResolver,o,l)),new Ar({schema:a,schemaId:c,root:e,baseId:o})}return Ba.call(this,r,i)}}Ge.resolveSchema=Yo;var Tb=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Ba(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,dm.unescapeFragment)(a)];if(c===void 0)return;r=c;let l=typeof r=="object"&&r[this.opts.schemaId];!Tb.has(a)&&l&&(t=(0,nt.resolveUrl)(this.opts.uriResolver,t,l))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,dm.schemaHasRulesButRef)(r,this.RULES)){let a=(0,nt.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=Yo.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Ar({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var fm=P((AO,Rb)=>{Rb.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 Wa=P((CO,vm)=>{"use strict";var Eb=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),hm=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),Ga=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),gm=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Ib=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Ja(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var Ob=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function mm(e){return e.length=0,!0}function Ab(e,t,r){if(e.length){let n=Ja(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function Cb(e){let t=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=Ab;for(let c=0;c<e.length;c++){let l=e[c];if(!(l==="["||l==="]"))if(l===":"){if(s===!0&&(i=!0),!a(o,n,r))break;if(++t>7){r.error=!0;break}c>0&&e[c-1]===":"&&(s=!0),n.push(":");continue}else if(l==="%"){if(!a(o,n,r))break;a=mm}else{o.push(l);continue}}return o.length&&(a===mm?r.zone=o.join(""):i?n.push(o.join("")):n.push(Ja(o))),r.address=n.join(""),r}function _m(e){if(Nb(e,":")<2)return{host:e,isIPV6:!1};let t=Cb(e);if(t.error)return{host:e,isIPV6:!1};{let r=t.address,n=t.address;return t.zone&&(r+="%"+t.zone,n+="%25"+t.zone),{host:r,isIPV6:!0,escapedHost:n}}}function Nb(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function jb(e){let t=e,r=[],n=-1,o=0;for(;o=t.length;){if(o===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(o===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(o===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}var Mb={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},Zb=/[@/?#:]/g,Db=/[@/?#]/g;function ym(e,t){let r=t?Db:Zb;return r.lastIndex=0,e.replace(r,n=>Mb[n])}function Ub(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(Ga(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&gm(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function qb(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(Ga(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));s!=="."&&gm(s)?t+=s:t+="%"+o,r+=2;continue}}Ib(e[r])?t+=e[r]:t+=escape(e[r])}return t}function Lb(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(Ga(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function Fb(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!hm(r)){let n=_m(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=ym(r,!1)}t.push(r)}return(typeof e.port=="number"||typeof e.port=="string")&&(t.push(":"),t.push(String(e.port))),t.length?t.join(""):void 0}vm.exports={nonSimpleDomain:Ob,recomposeAuthority:Fb,reescapeHostDelimiters:ym,normalizePercentEncoding:Ub,normalizePathEncoding:qb,escapePreservingEscapes:Lb,removeDotSegments:jb,isIPv4:hm,isUUID:Eb,normalizeIPv6:_m,stringArrayToHexStripped:Ja}});var xm=P((NO,Sm)=>{"use strict";var{isUUID:Vb}=Wa(),Hb=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,Bb=["http","https","ws","wss","urn","urn:uuid"];function Kb(e){return Bb.indexOf(e)!==-1}function Ya(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function wm(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function $m(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function Gb(e){return e.secure=Ya(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function Jb(e){if((e.port===(Ya(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let[t,r]=e.resourceName.split("?");e.path=t&&t!=="/"?t:void 0,e.query=r,e.resourceName=void 0}return e.fragment=void 0,e}function Wb(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(Hb);if(r){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,s=Qa(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function Yb(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=`${r}:${t.nid||n}`,s=Qa(o);s&&(e=s.serialize(e,t));let i=e,a=e.nss;return i.path=`${n||t.nid}:${a}`,t.skipEscape=!0,i}function Qb(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!Vb(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Xb(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var bm={scheme:"http",domainHost:!0,parse:wm,serialize:$m},e0={scheme:"https",domainHost:bm.domainHost,parse:wm,serialize:$m},Xo={scheme:"ws",domainHost:!0,parse:Gb,serialize:Jb},t0={scheme:"wss",domainHost:Xo.domainHost,parse:Xo.parse,serialize:Xo.serialize},r0={scheme:"urn",parse:Wb,serialize:Yb,skipNormalize:!0},n0={scheme:"urn:uuid",parse:Qb,serialize:Xb,skipNormalize:!0},es={http:bm,https:e0,ws:Xo,wss:t0,urn:r0,"urn:uuid":n0};Object.setPrototypeOf(es,null);function Qa(e){return e&&(es[e]||es[e.toLowerCase()])||void 0}Sm.exports={wsIsSecure:Ya,SCHEMES:es,isValidSchemeName:Kb,getSchemeHandler:Qa}});var Em=P((jO,ts)=>{"use strict";var{normalizeIPv6:o0,removeDotSegments:En,recomposeAuthority:s0,normalizePercentEncoding:i0,normalizePathEncoding:a0,escapePreservingEscapes:c0,reescapeHostDelimiters:u0,isIPv4:l0,nonSimpleDomain:d0}=Wa(),{SCHEMES:p0,getSchemeHandler:km}=xm();function f0(e,t){return typeof e=="string"?e=v0(e,t):typeof e=="object"&&(e=Cr(Qt(e,t),t)),e}function m0(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=Pm(Cr(e,n),Cr(t,n),n,!0);return n.skipEscape=!0,Qt(o,n)}function Pm(e,t,r,n){let o={};return n||(e=Cr(Qt(e,r),r),t=Cr(Qt(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=En(t.path||""),o.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=En(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=En(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?o.path="/"+t.path:e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path,o.path=En(o.path)),o.query=t.query):(o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function h0(e,t,r){let n=zm(e,r),o=zm(t,r);return n!==void 0&&o!==void 0&&n.toLowerCase()===o.toLowerCase()}function Qt(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),o=[],s=km(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=i0(r.path):(r.path=c0(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=s0(r);if(i!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=En(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var g0=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,_0=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/;function y0(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function Tm(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let i=e.match(_0);i!==null&&i[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let a=e.match(g0);if(a){n.scheme=a[1],n.userinfo=a[3],n.host=a[4],n.port=parseInt(a[5],10),n.path=a[6]||"",n.query=a[7],n.fragment=a[8],isNaN(n.port)&&(n.port=a[5]);let c=y0(n,a);if(c!==void 0&&(n.error=n.error||c,o=!0),n.host)if(l0(n.host)===!1){let d=o0(n.host);n.host=d.host.toLowerCase(),s=d.isIPV6}else s=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let l=km(r.scheme||n.scheme);if(!r.unicodeSupport&&(!l||!l.unicodeSupport)&&n.host&&(r.domainHost||l&&l.domainHost)&&s===!1&&d0(n.host))try{n.host=new URL("http://"+n.host).hostname}catch(u){n.error=n.error||"Host's domain name can not be converted to ASCII: "+u}if((!l||l&&!l.skipNormalize)&&(e.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=u0(unescape(n.host),s))),n.path&&(n.path=a0(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}l&&l.parse&&l.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o}}function Cr(e,t){return Tm(e,t).parsed}function v0(e,t){return Rm(e,t).normalized}function Rm(e,t){let{parsed:r,malformedAuthorityOrPort:n}=Tm(e,t);return{normalized:n?e:Qt(r,t),malformedAuthorityOrPort:n}}function zm(e,t){if(typeof e=="string"){let{normalized:r,malformedAuthorityOrPort:n}=Rm(e,t);return n?void 0:r}if(typeof e=="object")return Qt(e,t)}var Xa={SCHEMES:p0,normalize:f0,resolve:m0,resolveComponent:Pm,equal:h0,serialize:Qt,parse:Cr};ts.exports=Xa;ts.exports.default=Xa;ts.exports.fastUri=Xa});var Om=P(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});var Im=Em();Im.code='require("ajv/dist/runtime/uri").default';ec.default=Im});var Um=P(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.CodeGen=xe.Name=xe.nil=xe.stringify=xe.str=xe._=xe.KeywordCxt=void 0;var w0=Tn();Object.defineProperty(xe,"KeywordCxt",{enumerable:!0,get:function(){return w0.KeywordCxt}});var Nr=Z();Object.defineProperty(xe,"_",{enumerable:!0,get:function(){return Nr._}});Object.defineProperty(xe,"str",{enumerable:!0,get:function(){return Nr.str}});Object.defineProperty(xe,"stringify",{enumerable:!0,get:function(){return Nr.stringify}});Object.defineProperty(xe,"nil",{enumerable:!0,get:function(){return Nr.nil}});Object.defineProperty(xe,"Name",{enumerable:!0,get:function(){return Nr.Name}});Object.defineProperty(xe,"CodeGen",{enumerable:!0,get:function(){return Nr.CodeGen}});var $0=Wo(),Mm=Rn(),b0=Ta(),In=Qo(),S0=Z(),On=zn(),rs=xn(),rc=V(),Am=fm(),x0=Om(),Zm=(e,t)=>new RegExp(e,t);Zm.code="new RegExp";var z0=["removeAdditional","useDefaults","coerceTypes"],k0=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),P0={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."},T0={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Cm=200;function R0(e){var t,r,n,o,s,i,a,c,l,u,d,f,m,h,g,v,$,S,b,T,y,x,R,G,Q;let me=e.strict,qe=(t=e.code)===null||t===void 0?void 0:t.optimize,dr=qe===!0||qe===void 0?1:qe||0,xt=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Zm,Ce=(o=e.uriResolver)!==null&&o!==void 0?o:x0.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:me)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:me)!==null&&c!==void 0?c:!0,strictTypes:(u=(l=e.strictTypes)!==null&&l!==void 0?l:me)!==null&&u!==void 0?u:"log",strictTuples:(f=(d=e.strictTuples)!==null&&d!==void 0?d:me)!==null&&f!==void 0?f:"log",strictRequired:(h=(m=e.strictRequired)!==null&&m!==void 0?m:me)!==null&&h!==void 0?h:!1,code:e.code?{...e.code,optimize:dr,regExp:xt}:{optimize:dr,regExp:xt},loopRequired:(g=e.loopRequired)!==null&&g!==void 0?g:Cm,loopEnum:(v=e.loopEnum)!==null&&v!==void 0?v:Cm,meta:($=e.meta)!==null&&$!==void 0?$:!0,messages:(S=e.messages)!==null&&S!==void 0?S:!0,inlineRefs:(b=e.inlineRefs)!==null&&b!==void 0?b:!0,schemaId:(T=e.schemaId)!==null&&T!==void 0?T:"$id",addUsedSchema:(y=e.addUsedSchema)!==null&&y!==void 0?y:!0,validateSchema:(x=e.validateSchema)!==null&&x!==void 0?x:!0,validateFormats:(R=e.validateFormats)!==null&&R!==void 0?R:!0,unicodeRegExp:(G=e.unicodeRegExp)!==null&&G!==void 0?G:!0,int32range:(Q=e.int32range)!==null&&Q!==void 0?Q:!0,uriResolver:Ce}}var An=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...R0(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new S0.ValueScope({scope:{},prefixes:k0,es5:r,lines:n}),this.logger=N0(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,b0.getRules)(),Nm.call(this,P0,t,"NOT SUPPORTED"),Nm.call(this,T0,t,"DEPRECATED","warn"),this._metaOpts=A0.call(this),t.formats&&I0.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&O0.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),E0.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=Am;n==="id"&&(o={...Am},o.id=o.$id,delete o.$id),r&&t&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,t,r);async function o(u,d){await s.call(this,u.$schema);let f=this._addSchema(u,d);return f.validate||i.call(this,f)}async function s(u){u&&!this.getSchema(u)&&await o.call(this,{$ref:u},!0)}async function i(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof Mm.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 s.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]=n(u))}finally{delete this._loading[u]}}}addSchema(t,r,n,o=this.opts.validateSchema){if(Array.isArray(t)){for(let i of t)this.addSchema(i,void 0,n,o);return this}let s;if(typeof t=="object"){let{schemaId:i}=this.opts;if(s=t[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,On.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,o,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,t);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(t){let r;for(;typeof(r=jm.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new In.SchemaEnv({schema:{},schemaId:n});if(r=In.resolveSchema.call(this,o,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=jm.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,On.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(M0.call(this,n,r),!r)return(0,rc.eachItem)(n,s=>tc.call(this,s)),this;D0.call(this,r);let o={...r,type:(0,rs.getJSONTypes)(r.type),schemaType:(0,rs.getJSONTypes)(r.schemaType)};return(0,rc.eachItem)(n,o.type.length===0?s=>tc.call(this,s,o):s=>o.type.forEach(i=>tc.call(this,s,o,i))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===t);o>=0&&n.rules.splice(o,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let s=o.split("/").slice(1),i=t;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:l}=c.definition,u=i[a];l&&u&&(i[a]=Dm(u))}}return t}_removeAllSchemas(t,r){for(let n in t){let o=t[n];(!r||r.test(n))&&(typeof o=="string"?delete t[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete t[n]))}}_addSchema(t,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof t=="object")i=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(t);if(c!==void 0)return c;n=(0,On.normalizeId)(i||n);let l=On.getSchemaRefs.call(this,t,n);return c=new In.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:n,localRefs:l}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(t,!0),c}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):In.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{In.compileSchema.call(this,t)}finally{this.opts=r}}};An.ValidationError=$0.default;An.MissingRefError=Mm.default;xe.default=An;function Nm(e,t,r,n="error"){for(let o in e){let s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function jm(e){return e=(0,On.normalizeId)(e),this.schemas[e]||this.refs[e]}function E0(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function I0(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function O0(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function A0(){let e={...this.opts};for(let t of z0)delete e[t];return e}var C0={log(){},warn(){},error(){}};function N0(e){if(e===!1)return C0;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var j0=/^[a-z_$][a-z0-9_$:-]*$/i;function M0(e,t){let{RULES:r}=this;if((0,rc.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!j0.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function tc(e,t,r){var n;let o=t?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,rs.getJSONTypes)(t.type),schemaType:(0,rs.getJSONTypes)(t.schemaType)}};t.before?Z0.call(this,i,a,t.before):i.rules.push(a),s.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function Z0(e,t,r){let n=e.rules.findIndex(o=>o.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function D0(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=Dm(t)),e.validateSchema=this.compile(t,!0))}var U0={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Dm(e){return{anyOf:[e,U0]}}});var qm=P(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});var q0={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};nc.default=q0});var Hm=P(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.callRef=Xt.getValidate=void 0;var L0=Rn(),Lm=Ke(),De=Z(),jr=yt(),Fm=Qo(),ns=V(),F0={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:l}=s;if((r==="#"||r==="#/")&&o===l.baseId)return d();let u=Fm.resolveRef.call(c,l,o,r);if(u===void 0)throw new L0.default(n.opts.uriResolver,o,r);if(u instanceof Fm.SchemaEnv)return f(u);return m(u);function d(){if(s===l)return os(e,i,s,s.$async);let h=t.scopeValue("root",{ref:l});return os(e,(0,De._)`${h}.validate`,l,l.$async)}function f(h){let g=Vm(e,h);os(e,g,h,h.$async)}function m(h){let g=t.scopeValue("schema",a.code.source===!0?{ref:h,code:(0,De.stringify)(h)}:{ref:h}),v=t.name("valid"),$=e.subschema({schema:h,dataTypes:[],schemaPath:De.nil,topSchemaRef:g,errSchemaPath:r},v);e.mergeEvaluated($),e.ok(v)}}};function Vm(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,De._)`${r.scopeValue("wrapper",{ref:t})}.validate`}Xt.getValidate=Vm;function os(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,l=c.passContext?jr.default.this:De.nil;n?u():d();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");let h=o.let("valid");o.try(()=>{o.code((0,De._)`await ${(0,Lm.callValidateCode)(e,t,l)}`),m(t),i||o.assign(h,!0)},g=>{o.if((0,De._)`!(${g} instanceof ${s.ValidationError})`,()=>o.throw(g)),f(g),i||o.assign(h,!1)}),e.ok(h)}function d(){e.result((0,Lm.callValidateCode)(e,t,l),()=>m(t),()=>f(t))}function f(h){let g=(0,De._)`${h}.errors`;o.assign(jr.default.vErrors,(0,De._)`${jr.default.vErrors} === null ? ${g} : ${jr.default.vErrors}.concat(${g})`),o.assign(jr.default.errors,(0,De._)`${jr.default.vErrors}.length`)}function m(h){var g;if(!s.opts.unevaluated)return;let v=(g=r?.validate)===null||g===void 0?void 0:g.evaluated;if(s.props!==!0)if(v&&!v.dynamicProps)v.props!==void 0&&(s.props=ns.mergeEvaluated.props(o,v.props,s.props));else{let $=o.var("props",(0,De._)`${h}.evaluated.props`);s.props=ns.mergeEvaluated.props(o,$,s.props,De.Name)}if(s.items!==!0)if(v&&!v.dynamicItems)v.items!==void 0&&(s.items=ns.mergeEvaluated.items(o,v.items,s.items));else{let $=o.var("items",(0,De._)`${h}.evaluated.items`);s.items=ns.mergeEvaluated.items(o,$,s.items,De.Name)}}}Xt.callRef=os;Xt.default=F0});var Bm=P(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});var V0=qm(),H0=Hm(),B0=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",V0.default,H0.default];oc.default=B0});var Km=P(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});var ss=Z(),Ct=ss.operators,is={maximum:{okStr:"<=",ok:Ct.LTE,fail:Ct.GT},minimum:{okStr:">=",ok:Ct.GTE,fail:Ct.LT},exclusiveMaximum:{okStr:"<",ok:Ct.LT,fail:Ct.GTE},exclusiveMinimum:{okStr:">",ok:Ct.GT,fail:Ct.LTE}},K0={message:({keyword:e,schemaCode:t})=>(0,ss.str)`must be ${is[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ss._)`{comparison: ${is[e].okStr}, limit: ${t}}`},G0={keyword:Object.keys(is),type:"number",schemaType:"number",$data:!0,error:K0,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,ss._)`${r} ${is[t].fail} ${n} || isNaN(${r})`)}};sc.default=G0});var Gm=P(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});var Cn=Z(),J0={message:({schemaCode:e})=>(0,Cn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,Cn._)`{multipleOf: ${e}}`},W0={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:J0,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,Cn._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,Cn._)`${i} !== parseInt(${i})`;e.fail$data((0,Cn._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};ic.default=W0});var Wm=P(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});function Jm(e){let t=e.length,r=0,n=0,o;for(;n<t;)r++,o=e.charCodeAt(n++),o>=55296&&o<=56319&&n<t&&(o=e.charCodeAt(n),(o&64512)===56320&&n++);return r}ac.default=Jm;Jm.code='require("ajv/dist/runtime/ucs2length").default'});var Ym=P(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});var er=Z(),Y0=V(),Q0=Wm(),X0={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,er.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,er._)`{limit: ${e}}`},eS={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:X0,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?er.operators.GT:er.operators.LT,i=o.opts.unicode===!1?(0,er._)`${r}.length`:(0,er._)`${(0,Y0.useFunc)(e.gen,Q0.default)}(${r})`;e.fail$data((0,er._)`${i} ${s} ${n}`)}};cc.default=eS});var Qm=P(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});var tS=Ke(),rS=V(),Mr=Z(),nS={message:({schemaCode:e})=>(0,Mr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Mr._)`{pattern: ${e}}`},oS={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:nS,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,l=c.code==="new RegExp"?(0,Mr._)`new RegExp`:(0,rS.useFunc)(t,c),u=t.let("valid");t.try(()=>t.assign(u,(0,Mr._)`${l}(${s}, ${a}).test(${r})`),()=>t.assign(u,!1)),e.fail$data((0,Mr._)`!${u}`)}else{let c=(0,tS.usePattern)(e,o);e.fail$data((0,Mr._)`!${c}.test(${r})`)}}};uc.default=oS});var Xm=P(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});var Nn=Z(),sS={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,Nn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,Nn._)`{limit: ${e}}`},iS={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:sS,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?Nn.operators.GT:Nn.operators.LT;e.fail$data((0,Nn._)`Object.keys(${r}).length ${o} ${n}`)}};lc.default=iS});var eh=P(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});var jn=Ke(),Mn=Z(),aS=V(),cS={message:({params:{missingProperty:e}})=>(0,Mn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,Mn._)`{missingProperty: ${e}}`},uS={keyword:"required",type:"object",schemaType:"array",$data:!0,error:cS,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:i}=e,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?l():u(),a.strictRequired){let m=e.parentSchema.properties,{definedProperties:h}=e.it;for(let g of r)if(m?.[g]===void 0&&!h.has(g)){let v=i.schemaEnv.baseId+i.errSchemaPath,$=`required property "${g}" is not defined at "${v}" (strictRequired)`;(0,aS.checkStrictMode)(i,$,i.opts.strictRequired)}}function l(){if(c||s)e.block$data(Mn.nil,d);else for(let m of r)(0,jn.checkReportMissingProp)(e,m)}function u(){let m=t.let("missing");if(c||s){let h=t.let("valid",!0);e.block$data(h,()=>f(m,h)),e.ok(h)}else t.if((0,jn.checkMissingProp)(e,r,m)),(0,jn.reportMissingProp)(e,m),t.else()}function d(){t.forOf("prop",n,m=>{e.setParams({missingProperty:m}),t.if((0,jn.noPropertyInData)(t,o,m,a.ownProperties),()=>e.error())})}function f(m,h){e.setParams({missingProperty:m}),t.forOf(m,n,()=>{t.assign(h,(0,jn.propertyInData)(t,o,m,a.ownProperties)),t.if((0,Mn.not)(h),()=>{e.error(),t.break()})},Mn.nil)}}};dc.default=uS});var th=P(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});var Zn=Z(),lS={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,Zn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,Zn._)`{limit: ${e}}`},dS={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:lS,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?Zn.operators.GT:Zn.operators.LT;e.fail$data((0,Zn._)`${r}.length ${o} ${n}`)}};pc.default=dS});var as=P(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});var rh=ja();rh.code='require("ajv/dist/runtime/equal").default';fc.default=rh});var nh=P(hc=>{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});var mc=xn(),ze=Z(),pS=V(),fS=as(),mS={message:({params:{i:e,j:t}})=>(0,ze.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,ze._)`{i: ${e}, j: ${t}}`},hS={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:mS,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=e;if(!n&&!o)return;let c=t.let("valid"),l=s.items?(0,mc.getSchemaTypes)(s.items):[];e.block$data(c,u,(0,ze._)`${i} === false`),e.ok(c);function u(){let h=t.let("i",(0,ze._)`${r}.length`),g=t.let("j");e.setParams({i:h,j:g}),t.assign(c,!0),t.if((0,ze._)`${h} > 1`,()=>(d()?f:m)(h,g))}function d(){return l.length>0&&!l.some(h=>h==="object"||h==="array")}function f(h,g){let v=t.name("item"),$=(0,mc.checkDataTypes)(l,v,a.opts.strictNumbers,mc.DataType.Wrong),S=t.const("indices",(0,ze._)`{}`);t.for((0,ze._)`;${h}--;`,()=>{t.let(v,(0,ze._)`${r}[${h}]`),t.if($,(0,ze._)`continue`),l.length>1&&t.if((0,ze._)`typeof ${v} == "string"`,(0,ze._)`${v} += "_"`),t.if((0,ze._)`typeof ${S}[${v}] == "number"`,()=>{t.assign(g,(0,ze._)`${S}[${v}]`),e.error(),t.assign(c,!1).break()}).code((0,ze._)`${S}[${v}] = ${h}`)})}function m(h,g){let v=(0,pS.useFunc)(t,fS.default),$=t.name("outer");t.label($).for((0,ze._)`;${h}--;`,()=>t.for((0,ze._)`${g} = ${h}; ${g}--;`,()=>t.if((0,ze._)`${v}(${r}[${h}], ${r}[${g}])`,()=>{e.error(),t.assign(c,!1).break($)})))}}};hc.default=hS});var oh=P(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});var gc=Z(),gS=V(),_S=as(),yS={message:"must be equal to constant",params:({schemaCode:e})=>(0,gc._)`{allowedValue: ${e}}`},vS={keyword:"const",$data:!0,error:yS,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,gc._)`!${(0,gS.useFunc)(t,_S.default)}(${r}, ${o})`):e.fail((0,gc._)`${s} !== ${r}`)}};_c.default=vS});var sh=P(yc=>{"use strict";Object.defineProperty(yc,"__esModule",{value:!0});var Dn=Z(),wS=V(),$S=as(),bS={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Dn._)`{allowedValues: ${e}}`},SS={keyword:"enum",schemaType:"array",$data:!0,error:bS,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,l=()=>c??(c=(0,wS.useFunc)(t,$S.default)),u;if(a||n)u=t.let("valid"),e.block$data(u,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let m=t.const("vSchema",s);u=(0,Dn.or)(...o.map((h,g)=>f(m,g)))}e.pass(u);function d(){t.assign(u,!1),t.forOf("v",s,m=>t.if((0,Dn._)`${l()}(${r}, ${m})`,()=>t.assign(u,!0).break()))}function f(m,h){let g=o[h];return typeof g=="object"&&g!==null?(0,Dn._)`${l()}(${r}, ${m}[${h}])`:(0,Dn._)`${r} === ${g}`}}};yc.default=SS});var ih=P(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});var xS=Km(),zS=Gm(),kS=Ym(),PS=Qm(),TS=Xm(),RS=eh(),ES=th(),IS=nh(),OS=oh(),AS=sh(),CS=[xS.default,zS.default,kS.default,PS.default,TS.default,RS.default,ES.default,IS.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},OS.default,AS.default];vc.default=CS});var $c=P(Un=>{"use strict";Object.defineProperty(Un,"__esModule",{value:!0});Un.validateAdditionalItems=void 0;var tr=Z(),wc=V(),NS={message:({params:{len:e}})=>(0,tr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,tr._)`{limit: ${e}}`},jS={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:NS,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,wc.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}ah(e,n)}};function ah(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,tr._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,tr._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,wc.alwaysValidSchema)(i,n)){let l=r.var("valid",(0,tr._)`${a} <= ${t.length}`);r.if((0,tr.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,a,u=>{e.subschema({keyword:s,dataProp:u,dataPropType:wc.Type.Num},l),i.allErrors||r.if((0,tr.not)(l),()=>r.break())})}}Un.validateAdditionalItems=ah;Un.default=jS});var bc=P(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.validateTuple=void 0;var ch=Z(),cs=V(),MS=Ke(),ZS={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return uh(e,"additionalItems",t);r.items=!0,!(0,cs.alwaysValidSchema)(r,t)&&e.ok((0,MS.validateArray)(e))}};function uh(e,t,r=e.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=e;u(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=cs.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),l=n.const("len",(0,ch._)`${s}.length`);r.forEach((d,f)=>{(0,cs.alwaysValidSchema)(a,d)||(n.if((0,ch._)`${l} > ${f}`,()=>e.subschema({keyword:i,schemaProp:f,dataProp:f},c)),e.ok(c))});function u(d){let{opts:f,errSchemaPath:m}=a,h=r.length,g=h===d.minItems&&(h===d.maxItems||d[t]===!1);if(f.strictTuples&&!g){let v=`"${i}" is ${h}-tuple, but minItems or maxItems/${t} are not specified or different at path "${m}"`;(0,cs.checkStrictMode)(a,v,f.strictTuples)}}}qn.validateTuple=uh;qn.default=ZS});var lh=P(Sc=>{"use strict";Object.defineProperty(Sc,"__esModule",{value:!0});var DS=bc(),US={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,DS.validateTuple)(e,"items")};Sc.default=US});var ph=P(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});var dh=Z(),qS=V(),LS=Ke(),FS=$c(),VS={message:({params:{len:e}})=>(0,dh.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,dh._)`{limit: ${e}}`},HS={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:VS,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,qS.alwaysValidSchema)(n,t)&&(o?(0,FS.validateAdditionalItems)(e,o):e.ok((0,LS.validateArray)(e)))}};xc.default=HS});var fh=P(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});var Je=Z(),us=V(),BS={message:({params:{min:e,max:t}})=>t===void 0?(0,Je.str)`must contain at least ${e} valid item(s)`:(0,Je.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,Je._)`{minContains: ${e}}`:(0,Je._)`{minContains: ${e}, maxContains: ${t}}`},KS={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:BS,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e,i,a,{minContains:c,maxContains:l}=n;s.opts.next?(i=c===void 0?1:c,a=l):i=1;let u=t.const("len",(0,Je._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,us.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,us.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,us.alwaysValidSchema)(s,r)){let g=(0,Je._)`${u} >= ${i}`;a!==void 0&&(g=(0,Je._)`${g} && ${u} <= ${a}`),e.pass(g);return}s.items=!0;let d=t.name("valid");a===void 0&&i===1?m(d,()=>t.if(d,()=>t.break())):i===0?(t.let(d,!0),a!==void 0&&t.if((0,Je._)`${o}.length > 0`,f)):(t.let(d,!1),f()),e.result(d,()=>e.reset());function f(){let g=t.name("_valid"),v=t.let("count",0);m(g,()=>t.if(g,()=>h(v)))}function m(g,v){t.forRange("i",0,u,$=>{e.subschema({keyword:"contains",dataProp:$,dataPropType:us.Type.Num,compositeRule:!0},g),v()})}function h(g){t.code((0,Je._)`${g}++`),a===void 0?t.if((0,Je._)`${g} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,Je._)`${g} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,Je._)`${g} >= ${i}`,()=>t.assign(d,!0)))}}};zc.default=KS});var gh=P(ut=>{"use strict";Object.defineProperty(ut,"__esModule",{value:!0});ut.validateSchemaDeps=ut.validatePropertyDeps=ut.error=void 0;var kc=Z(),GS=V(),Ln=Ke();ut.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,kc.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,kc._)`{property: ${e},
8
8
  missingProperty: ${n},
9
9
  depsCount: ${t},
10
- deps: ${r}}`};var Bx={keyword:"dependencies",type:"object",schemaType:"object",error:ut.error,code(e){let[t,r]=Gx(e);fh(e,t),mh(e,r)}};function Gx({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let o=Array.isArray(e[n])?t:r;o[n]=e[n]}return[t,r]}function fh(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let i in t){let a=t[i];if(a.length===0)continue;let c=(0,Ln.propertyInData)(r,n,i,o.opts.ownProperties);e.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,Ln.checkReportMissingProp)(e,u)}):(r.if((0,kc._)`${c} && (${(0,Ln.checkMissingProp)(e,a,s)})`),(0,Ln.reportMissingProp)(e,s),r.else())}}ut.validatePropertyDeps=fh;function mh(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,i=r.name("valid");for(let a in t)(0,Kx.alwaysValidSchema)(s,t[a])||(r.if((0,Ln.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:a},i);e.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),e.ok(i))}ut.validateSchemaDeps=mh;ut.default=Bx});var _h=P(Pc=>{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});var gh=M(),Jx=V(),Wx={message:"property name must be valid",params:({params:e})=>(0,gh._)`{propertyName: ${e.propertyName}}`},Yx={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Wx,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,Jx.alwaysValidSchema)(o,r))return;let s=t.name("valid");t.forIn("key",n,i=>{e.setParams({propertyName:i}),e.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),t.if((0,gh.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};Pc.default=Yx});var Rc=P(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});var ls=Ke(),nt=M(),Qx=yt(),ds=V(),Xx={message:"must NOT have additional properties",params:({params:e})=>(0,nt._)`{additionalProperty: ${e.additionalProperty}}`},eS={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:Xx,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=e;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,ds.alwaysValidSchema)(i,r))return;let u=(0,ls.allSchemaProperties)(n.properties),l=(0,ls.allSchemaProperties)(n.patternProperties);d(),e.ok((0,nt._)`${s} === ${Qx.default.errors}`);function d(){t.forIn("key",o,v=>{!u.length&&!l.length?h(v):t.if(m(v),()=>h(v))})}function m(v){let w;if(u.length>8){let x=(0,ds.schemaRefOrVal)(i,n.properties,"properties");w=(0,ls.isOwnProperty)(t,x,v)}else u.length?w=(0,nt.or)(...u.map(x=>(0,nt._)`${v} === ${x}`)):w=nt.nil;return l.length&&(w=(0,nt.or)(w,...l.map(x=>(0,nt._)`${(0,ls.usePattern)(e,x)}.test(${v})`))),(0,nt.not)(w)}function f(v){t.code((0,nt._)`delete ${o}[${v}]`)}function h(v){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){f(v);return}if(r===!1){e.setParams({additionalProperty:v}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,ds.alwaysValidSchema)(i,r)){let w=t.name("valid");c.removeAdditional==="failing"?(g(v,w,!1),t.if((0,nt.not)(w),()=>{e.reset(),f(v)})):(g(v,w),a||t.if((0,nt.not)(w),()=>t.break()))}}function g(v,w,x){let $={keyword:"additionalProperties",dataProp:v,dataPropType:ds.Type.Str};x===!1&&Object.assign($,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema($,w)}}};Tc.default=eS});var wh=P(Ic=>{"use strict";Object.defineProperty(Ic,"__esModule",{value:!0});var tS=Tn(),yh=Ke(),Ec=V(),vh=Rc(),rS={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&vh.default.code(new tS.KeywordCxt(s,vh.default,"additionalProperties"));let i=(0,yh.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Ec.mergeEvaluated.props(t,(0,Ec.toHash)(i),s.props));let a=i.filter(d=>!(0,Ec.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=t.name("valid");for(let d of a)u(d)?l(d):(t.if((0,yh.propertyInData)(t,o,d,s.opts.ownProperties)),l(d),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Ic.default=rS});var Sh=P(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});var $h=Ke(),ps=M(),bh=V(),xh=V(),nS={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:i}=s,a=(0,$h.allSchemaProperties)(r),c=a.filter(g=>(0,bh.alwaysValidSchema)(s,r[g]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=t.name("valid");s.props!==!0&&!(s.props instanceof ps.Name)&&(s.props=(0,xh.evaluatedPropsToName)(t,s.props));let{props:d}=s;m();function m(){for(let g of a)u&&f(g),s.allErrors?h(g):(t.var(l,!0),h(g),t.if(l))}function f(g){for(let v in u)new RegExp(g).test(v)&&(0,bh.checkStrictMode)(s,`property ${v} matches pattern ${g} (use allowMatchingProperties)`)}function h(g){t.forIn("key",n,v=>{t.if((0,ps._)`${(0,$h.usePattern)(e,g)}.test(${v})`,()=>{let w=c.includes(g);w||e.subschema({keyword:"patternProperties",schemaProp:g,dataProp:v,dataPropType:xh.Type.Str},l),s.opts.unevaluated&&d!==!0?t.assign((0,ps._)`${d}[${v}]`,!0):!w&&!s.allErrors&&t.if((0,ps.not)(l),()=>t.break())})})}}};Oc.default=nS});var zh=P(Cc=>{"use strict";Object.defineProperty(Cc,"__esModule",{value:!0});var oS=V(),sS={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,oS.alwaysValidSchema)(n,r)){e.fail();return}let o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Cc.default=sS});var kh=P(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});var iS=Ke(),aS={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:iS.validateUnion,error:{message:"must match a schema in anyOf"}};Ac.default=aS});var Ph=P(Nc=>{"use strict";Object.defineProperty(Nc,"__esModule",{value:!0});var fs=M(),cS=V(),uS={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,fs._)`{passingSchemas: ${e.passing}}`},lS={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:uS,code(e){let{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=t.let("valid",!1),a=t.let("passing",null),c=t.name("_valid");e.setParams({passing:a}),t.block(u),e.result(i,()=>e.reset(),()=>e.error(!0));function u(){s.forEach((l,d)=>{let m;(0,cS.alwaysValidSchema)(o,l)?t.var(c,!0):m=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,fs._)`${c} && ${i}`).assign(i,!1).assign(a,(0,fs._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),m&&e.mergeEvaluated(m,fs.Name)})})}}};Nc.default=lS});var Th=P(jc=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});var dS=V(),pS={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=t.name("valid");r.forEach((s,i)=>{if((0,dS.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};jc.default=pS});var Ih=P(Zc=>{"use strict";Object.defineProperty(Zc,"__esModule",{value:!0});var ms=M(),Eh=V(),fS={message:({params:e})=>(0,ms.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,ms._)`{failingKeyword: ${e.ifClause}}`},mS={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:fS,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Eh.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=Rh(n,"then"),s=Rh(n,"else");if(!o&&!s)return;let i=t.let("valid",!0),a=t.name("_valid");if(c(),e.reset(),o&&s){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,u("then",l),u("else",l))}else o?t.if(a,u("then")):t.if((0,ms.not)(a),u("else"));e.pass(i,()=>e.error(!0));function c(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function u(l,d){return()=>{let m=e.subschema({keyword:l},a);t.assign(i,a),e.mergeValidEvaluated(m,i),d?t.assign(d,(0,ms._)`${l}`):e.setParams({ifClause:l})}}}};function Rh(e,t){let r=e.schema[t];return r!==void 0&&!(0,Eh.alwaysValidSchema)(e,r)}Zc.default=mS});var Oh=P(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});var hS=V(),gS={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,hS.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Mc.default=gS});var Ch=P(Dc=>{"use strict";Object.defineProperty(Dc,"__esModule",{value:!0});var _S=$c(),yS=uh(),vS=bc(),wS=dh(),$S=ph(),bS=hh(),xS=_h(),SS=Rc(),zS=wh(),kS=Sh(),PS=zh(),TS=kh(),RS=Ph(),ES=Th(),IS=Ih(),OS=Oh();function CS(e=!1){let t=[PS.default,TS.default,RS.default,ES.default,IS.default,OS.default,xS.default,SS.default,bS.default,zS.default,kS.default];return e?t.push(yS.default,wS.default):t.push(_S.default,vS.default),t.push($S.default),t}Dc.default=CS});var Ah=P(qc=>{"use strict";Object.defineProperty(qc,"__esModule",{value:!0});var he=M(),AS={message:({schemaCode:e})=>(0,he.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,he._)`{format: ${e}}`},NS={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:AS,code(e,t){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?m():f();function m(){let h=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),g=r.const("fDef",(0,he._)`${h}[${i}]`),v=r.let("fType"),w=r.let("format");r.if((0,he._)`typeof ${g} == "object" && !(${g} instanceof RegExp)`,()=>r.assign(v,(0,he._)`${g}.type || "string"`).assign(w,(0,he._)`${g}.validate`),()=>r.assign(v,(0,he._)`"string"`).assign(w,g)),e.fail$data((0,he.or)(x(),$()));function x(){return c.strictSchema===!1?he.nil:(0,he._)`${i} && !${w}`}function $(){let T=l.$async?(0,he._)`(${g}.async ? await ${w}(${n}) : ${w}(${n}))`:(0,he._)`${w}(${n})`,y=(0,he._)`(typeof ${w} == "function" ? ${T} : ${w}.test(${n}))`;return(0,he._)`${w} && ${w} !== true && ${v} === ${t} && !${y}`}}function f(){let h=d.formats[s];if(!h){x();return}if(h===!0)return;let[g,v,w]=$(h);g===t&&e.pass(T());function x(){if(c.strictSchema===!1){d.logger.warn(y());return}throw new Error(y());function y(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function $(y){let S=y instanceof RegExp?(0,he.regexpCode)(y):c.code.formats?(0,he._)`${c.code.formats}${(0,he.getProperty)(s)}`:void 0,R=r.scopeValue("formats",{key:s,ref:y,code:S});return typeof y=="object"&&!(y instanceof RegExp)?[y.type||"string",y.validate,(0,he._)`${R}.validate`]:["string",y,R]}function T(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!l.$async)throw new Error("async format in sync schema");return(0,he._)`await ${w}(${n})`}return typeof v=="function"?(0,he._)`${w}(${n})`:(0,he._)`${w}.test(${n})`}}}};qc.default=NS});var Nh=P(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});var jS=Ah(),ZS=[jS.default];Uc.default=ZS});var jh=P(Zr=>{"use strict";Object.defineProperty(Zr,"__esModule",{value:!0});Zr.contentVocabulary=Zr.metadataVocabulary=void 0;Zr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Zr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Mh=P(Lc=>{"use strict";Object.defineProperty(Lc,"__esModule",{value:!0});var MS=Hm(),DS=sh(),qS=Ch(),US=Nh(),Zh=jh(),LS=[MS.default,DS.default,(0,qS.default)(),US.default,Zh.metadataVocabulary,Zh.contentVocabulary];Lc.default=LS});var qh=P(hs=>{"use strict";Object.defineProperty(hs,"__esModule",{value:!0});hs.DiscrError=void 0;var Dh;(function(e){e.Tag="tag",e.Mapping="mapping"})(Dh||(hs.DiscrError=Dh={}))});var Lh=P(Vc=>{"use strict";Object.defineProperty(Vc,"__esModule",{value:!0});var Mr=M(),Fc=qh(),Uh=Qo(),FS=Rn(),VS=V(),HS={message:({params:{discrError:e,tagName:t}})=>e===Fc.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Mr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},KS={keyword:"discriminator",type:"object",schemaType:"object",error:HS,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),u=t.const("tag",(0,Mr._)`${r}${(0,Mr.getProperty)(a)}`);t.if((0,Mr._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:Fc.DiscrError.Tag,tag:u,tagName:a})),e.ok(c);function l(){let f=m();t.if(!1);for(let h in f)t.elseIf((0,Mr._)`${u} === ${h}`),t.assign(c,d(f[h]));t.else(),e.error(!1,{discrError:Fc.DiscrError.Mapping,tag:u,tagName:a}),t.endIf()}function d(f){let h=t.name("valid"),g=e.subschema({keyword:"oneOf",schemaProp:f},h);return e.mergeEvaluated(g,Mr.Name),h}function m(){var f;let h={},g=w(o),v=!0;for(let T=0;T<i.length;T++){let y=i[T];if(y?.$ref&&!(0,VS.schemaHasRulesButRef)(y,s.self.RULES)){let R=y.$ref;if(y=Uh.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,R),y instanceof Uh.SchemaEnv&&(y=y.schema),y===void 0)throw new FS.default(s.opts.uriResolver,s.baseId,R)}let S=(f=y?.properties)===null||f===void 0?void 0:f[a];if(typeof S!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);v=v&&(g||w(y)),x(S,T)}if(!v)throw new Error(`discriminator: "${a}" must be required`);return h;function w({required:T}){return Array.isArray(T)&&T.includes(a)}function x(T,y){if(T.const)$(T.const,y);else if(T.enum)for(let S of T.enum)$(S,y);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function $(T,y){if(typeof T!="string"||T in h)throw new Error(`discriminator: "${a}" values must be unique strings`);h[T]=y}}}};Vc.default=KS});var Fh=P(($1,BS)=>{BS.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 Kc=P((le,Hc)=>{"use strict";Object.defineProperty(le,"__esModule",{value:!0});le.MissingRefError=le.ValidationError=le.CodeGen=le.Name=le.nil=le.stringify=le.str=le._=le.KeywordCxt=le.Ajv=void 0;var GS=Dm(),JS=Mh(),WS=Lh(),Vh=Fh(),YS=["/properties"],gs="http://json-schema.org/draft-07/schema",Dr=class extends GS.default{_addVocabularies(){super._addVocabularies(),JS.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(WS.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(Vh,YS):Vh;this.addMetaSchema(t,gs,!1),this.refs["http://json-schema.org/schema"]=gs}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(gs)?gs:void 0)}};le.Ajv=Dr;Hc.exports=le=Dr;Hc.exports.Ajv=Dr;Object.defineProperty(le,"__esModule",{value:!0});le.default=Dr;var QS=Tn();Object.defineProperty(le,"KeywordCxt",{enumerable:!0,get:function(){return QS.KeywordCxt}});var qr=M();Object.defineProperty(le,"_",{enumerable:!0,get:function(){return qr._}});Object.defineProperty(le,"str",{enumerable:!0,get:function(){return qr.str}});Object.defineProperty(le,"stringify",{enumerable:!0,get:function(){return qr.stringify}});Object.defineProperty(le,"nil",{enumerable:!0,get:function(){return qr.nil}});Object.defineProperty(le,"Name",{enumerable:!0,get:function(){return qr.Name}});Object.defineProperty(le,"CodeGen",{enumerable:!0,get:function(){return qr.CodeGen}});var XS=Wo();Object.defineProperty(le,"ValidationError",{enumerable:!0,get:function(){return XS.default}});var ez=Rn();Object.defineProperty(le,"MissingRefError",{enumerable:!0,get:function(){return ez.default}})});var Qh=P(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.formatNames=dt.fastFormats=dt.fullFormats=void 0;function lt(e,t){return{validate:e,compare:t}}dt.fullFormats={date:lt(Gh,Wc),time:lt(Gc(!0),Yc),"date-time":lt(Hh(!0),Wh),"iso-time":lt(Gc(),Jh),"iso-date-time":lt(Hh(),Yh),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:iz,"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:fz,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:az,int32:{type:"number",validate:lz},int64:{type:"number",validate:dz},float:{type:"number",validate:Bh},double:{type:"number",validate:Bh},password:!0,binary:!0};dt.fastFormats={...dt.fullFormats,date:lt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Wc),time:lt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Yc),"date-time":lt(/^\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,Wh),"iso-time":lt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Jh),"iso-date-time":lt(/^\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,Yh),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};dt.formatNames=Object.keys(dt.fullFormats);function tz(e){return e%4===0&&(e%100!==0||e%400===0)}var rz=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,nz=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Gh(e){let t=rz.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&tz(r)?29:nz[n])}function Wc(e,t){if(e&&t)return e>t?1:e<t?-1:0}var Bc=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Gc(e){return function(r){let n=Bc.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||e&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,m=o-u*c-(d<0?1:0);return(m===23||m===-1)&&(d===59||d===-1)&&i<61}}function Yc(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function Jh(e,t){if(!(e&&t))return;let r=Bc.exec(e),n=Bc.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var Jc=/t|\s/i;function Hh(e){let t=Gc(e);return function(n){let o=n.split(Jc);return o.length===2&&Gh(o[0])&&t(o[1])}}function Wh(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function Yh(e,t){if(!(e&&t))return;let[r,n]=e.split(Jc),[o,s]=t.split(Jc),i=Wc(r,o);if(i!==void 0)return i||Yc(n,s)}var oz=/\/|:/,sz=/^(?:[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 iz(e){return oz.test(e)&&sz.test(e)}var Kh=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function az(e){return Kh.lastIndex=0,Kh.test(e)}var cz=-(2**31),uz=2**31-1;function lz(e){return Number.isInteger(e)&&e<=uz&&e>=cz}function dz(e){return Number.isInteger(e)}function Bh(){return!0}var pz=/[^\\]\\Z/;function fz(e){if(pz.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var Xh=P(Ur=>{"use strict";Object.defineProperty(Ur,"__esModule",{value:!0});Ur.formatLimitDefinition=void 0;var mz=Kc(),ot=M(),At=ot.operators,_s={formatMaximum:{okStr:"<=",ok:At.LTE,fail:At.GT},formatMinimum:{okStr:">=",ok:At.GTE,fail:At.LT},formatExclusiveMaximum:{okStr:"<",ok:At.LT,fail:At.GTE},formatExclusiveMinimum:{okStr:">",ok:At.GT,fail:At.LTE}},hz={message:({keyword:e,schemaCode:t})=>(0,ot.str)`should be ${_s[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ot._)`{comparison: ${_s[e].okStr}, limit: ${t}}`};Ur.formatLimitDefinition={keyword:Object.keys(_s),type:"string",schemaType:"string",$data:!0,error:hz,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:s}=e,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new mz.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let m=t.scopeValue("formats",{ref:a.formats,code:i.code.formats}),f=t.const("fmt",(0,ot._)`${m}[${c.schemaCode}]`);e.fail$data((0,ot.or)((0,ot._)`typeof ${f} != "object"`,(0,ot._)`${f} instanceof RegExp`,(0,ot._)`typeof ${f}.compare != "function"`,d(f)))}function l(){let m=c.schema,f=a.formats[m];if(!f||f===!0)return;if(typeof f!="object"||f instanceof RegExp||typeof f.compare!="function")throw new Error(`"${o}": format "${m}" does not define "compare" function`);let h=t.scopeValue("formats",{key:m,ref:f,code:i.code.formats?(0,ot._)`${i.code.formats}${(0,ot.getProperty)(m)}`:void 0});e.fail$data(d(h))}function d(m){return(0,ot._)`${m}.compare(${r}, ${n}) ${_s[o].fail} 0`}},dependencies:["format"]};var gz=e=>(e.addKeyword(Ur.formatLimitDefinition),e);Ur.default=gz});var ng=P((Fn,rg)=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});var Lr=Qh(),_z=Xh(),Qc=M(),eg=new Qc.Name("fullFormats"),yz=new Qc.Name("fastFormats"),Xc=(e,t={keywords:!0})=>{if(Array.isArray(t))return tg(e,t,Lr.fullFormats,eg),e;let[r,n]=t.mode==="fast"?[Lr.fastFormats,yz]:[Lr.fullFormats,eg],o=t.formats||Lr.formatNames;return tg(e,o,r,n),t.keywords&&(0,_z.default)(e),e};Xc.get=(e,t="full")=>{let n=(t==="fast"?Lr.fastFormats:Lr.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function tg(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,Qc._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}rg.exports=Fn=Xc;Object.defineProperty(Fn,"__esModule",{value:!0});Fn.default=Xc});import{spawn as Bg,spawnSync as Cs}from"node:child_process";import{connect as fk}from"node:net";import{homedir as Gg,userInfo as mu}from"node:os";import{resolve as Jg,join as bt,dirname as $u}from"node:path";import{fileURLToPath as mk,pathToFileURL as hk}from"node:url";import{createInterface as Is}from"node:readline/promises";import*as U from"node:fs";var qs=Object.freeze({status:"aborted"});function _(e,t,r){function n(a,c){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(e),t(a,c);for(let l in i.prototype)l in a||Object.defineProperty(a,l,{value:i.prototype[l].bind(a)});a._zod.constr=i,a._zod.def=c}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(a){var c;let u=r?.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}var d_=Symbol("zod_brand"),ft=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},ao={};function Ue(e){return e&&Object.assign(ao,e),ao}var G={};Ds(G,{BIGINT_FORMAT_RANGES:()=>Ru,Class:()=>Ls,NUMBER_FORMAT_RANGES:()=>Ws,aborted:()=>Dt,allowsEval:()=>Bs,assert:()=>g_,assertEqual:()=>p_,assertIs:()=>m_,assertNever:()=>h_,assertNotEqual:()=>f_,assignProp:()=>Ks,cached:()=>Wr,captureStackTrace:()=>uo,cleanEnum:()=>R_,cleanRegex:()=>Qr,clone:()=>We,createTransparentProxy:()=>b_,defineLazy:()=>oe,esc:()=>Mt,escapeRegex:()=>St,extend:()=>z_,finalizeIssue:()=>Ye,floatSafeRemainder:()=>Hs,getElementAtPath:()=>__,getEnumValues:()=>Fs,getLengthableOrigin:()=>Xr,getParsedType:()=>$_,getSizableOrigin:()=>Eu,isObject:()=>pr,isPlainObject:()=>fr,issue:()=>Ys,joinValues:()=>co,jsonStringifyReplacer:()=>Vs,merge:()=>k_,normalizeParams:()=>C,nullish:()=>Yr,numKeys:()=>w_,omit:()=>S_,optionalKeys:()=>Js,partial:()=>P_,pick:()=>x_,prefixIssues:()=>it,primitiveTypes:()=>Tu,promiseAllObject:()=>y_,propertyKeyTypes:()=>Gs,randomString:()=>v_,required:()=>T_,stringifyPrimitive:()=>lo,unwrapMessage:()=>Jr});function p_(e){return e}function f_(e){return e}function m_(e){}function h_(e){throw new Error}function g_(e){}function Fs(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function co(e,t="|"){return e.map(r=>lo(r)).join(t)}function Vs(e,t){return typeof t=="bigint"?t.toString():t}function Wr(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Yr(e){return e==null}function Qr(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Hs(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(e.toFixed(o).replace(".","")),i=Number.parseInt(t.toFixed(o).replace(".",""));return s%i/10**o}function oe(e,t,r){Object.defineProperty(e,t,{get(){{let o=r();return e[t]=o,o}throw new Error("cached value already set")},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Ks(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function __(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function y_(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function v_(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Mt(e){return JSON.stringify(e)}var uo=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function pr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Bs=Wr(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function fr(e){if(pr(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(pr(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function w_(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var $_=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Gs=new Set(["string","number","symbol"]),Tu=new Set(["string","number","bigint","boolean","symbol","undefined"]);function St(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function We(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function C(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function b_(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function lo(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Js(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Ws={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Ru={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function x_(e,t){let r={},n=e._zod.def;for(let o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(r[o]=n.shape[o])}return We(e,{...e._zod.def,shape:r,checks:[]})}function S_(e,t){let r={...e._zod.def.shape},n=e._zod.def;for(let o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&delete r[o]}return We(e,{...e._zod.def,shape:r,checks:[]})}function z_(e,t){if(!fr(t))throw new Error("Invalid input to extend: expected a plain object");let r={...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return Ks(this,"shape",n),n},checks:[]};return We(e,r)}function k_(e,t){return We(e,{...e._zod.def,get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return Ks(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function P_(e,t,r){let n=t._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in n))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=e?new e({type:"optional",innerType:n[s]}):n[s])}else for(let s in n)o[s]=e?new e({type:"optional",innerType:n[s]}):n[s];return We(t,{...t._zod.def,shape:o,checks:[]})}function T_(e,t,r){let n=t._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=new e({type:"nonoptional",innerType:n[s]}))}else for(let s in n)o[s]=new e({type:"nonoptional",innerType:n[s]});return We(t,{...t._zod.def,shape:o,checks:[]})}function Dt(e,t=0){for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function it(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Jr(e){return typeof e=="string"?e:e?.message}function Ye(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let o=Jr(e.inst?._zod.def?.error?.(e))??Jr(t?.error?.(e))??Jr(r.customError?.(e))??Jr(r.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function Eu(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Xr(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ys(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function R_(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var Ls=class{constructor(...t){}};var Iu=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,Vs,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},po=_("$ZodError",Iu),Qs=_("$ZodError",Iu,{Parent:Error});function Xs(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function ei(e,t){let r=t||function(s){return s.message},n={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(e),n}var Ou=e=>(t,r,n,o)=>{let s=n?Object.assign(n,{async:!1}):{async:!1},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new ft;if(i.issues.length){let a=new(o?.Err??e)(i.issues.map(c=>Ye(c,s,Ue())));throw uo(a,o?.callee),a}return i.value};var Cu=e=>async(t,r,n,o)=>{let s=n?Object.assign(n,{async:!0}):{async:!0},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(o?.Err??e)(i.issues.map(c=>Ye(c,s,Ue())));throw uo(a,o?.callee),a}return i.value};var ti=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ft;return s.issues.length?{success:!1,error:new(e??po)(s.issues.map(i=>Ye(i,o,Ue())))}:{success:!0,data:s.value}},en=ti(Qs),ri=e=>async(t,r,n)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>Ye(i,o,Ue())))}:{success:!0,data:s.value}},fo=ri(Qs);var Au=/^[cC][^\s-]{8,}$/,Nu=/^[0-9a-z]+$/,ju=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Zu=/^[0-9a-vA-V]{20}$/,Mu=/^[A-Za-z0-9]{27}$/,Du=/^[a-zA-Z0-9_-]{21}$/,qu=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Uu=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ni=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;var Lu=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var I_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Fu(){return new RegExp(I_,"u")}var Vu=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Hu=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,Ku=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Bu=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Gu=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,oi=/^[A-Za-z0-9_-]*$/,Ju=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var Wu=/^\+(?:[0-9]){6,14}[0-9]$/,Yu="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Qu=new RegExp(`^${Yu}$`);function Xu(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function el(e){return new RegExp(`^${Xu(e)}$`)}function tl(e){let t=Xu({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Yu}T(?:${n})$`)}var rl=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},nl=/^\d+n?$/,ol=/^\d+$/,sl=/^-?\d+(?:\.\d+)?/i,il=/true|false/i,al=/null/i;var cl=/^[^A-Z]*$/,ul=/^[^a-z]*$/;var Pe=_("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),ll={number:"number",bigint:"bigint",object:"date"},si=_("$ZodCheckLessThan",(e,t)=>{Pe.init(e,t);let r=ll[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ii=_("$ZodCheckGreaterThan",(e,t)=>{Pe.init(e,t);let r=ll[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),dl=_("$ZodCheckMultipleOf",(e,t)=>{Pe.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Hs(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),pl=_("$ZodCheckNumberFormat",(e,t)=>{Pe.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=Ws[t.format];e._zod.onattach.push(i=>{let a=i._zod.bag;a.format=t.format,a.minimum=o,a.maximum=s,r&&(a.pattern=ol)}),e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inst:e})}});var fl=_("$ZodCheckMaxLength",(e,t)=>{var r;Pe.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Yr(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;if(o.length<=t.maximum)return;let i=Xr(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),ml=_("$ZodCheckMinLength",(e,t)=>{var r;Pe.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Yr(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;if(o.length>=t.minimum)return;let i=Xr(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),hl=_("$ZodCheckLengthEquals",(e,t)=>{var r;Pe.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Yr(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{let o=n.value,s=o.length;if(s===t.length)return;let i=Xr(o),a=s>t.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),tn=_("$ZodCheckStringFormat",(e,t)=>{var r,n;Pe.init(e,t),e._zod.onattach.push(o=>{let s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),gl=_("$ZodCheckRegex",(e,t)=>{tn.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),_l=_("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=cl),tn.init(e,t)}),yl=_("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ul),tn.init(e,t)}),vl=_("$ZodCheckIncludes",(e,t)=>{Pe.init(e,t);let r=St(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),wl=_("$ZodCheckStartsWith",(e,t)=>{Pe.init(e,t);let r=new RegExp(`^${St(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),$l=_("$ZodCheckEndsWith",(e,t)=>{Pe.init(e,t);let r=new RegExp(`.*${St(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var bl=_("$ZodCheckOverwrite",(e,t)=>{Pe.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var ho=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
10
+ deps: ${r}}`};var JS={keyword:"dependencies",type:"object",schemaType:"object",error:ut.error,code(e){let[t,r]=WS(e);mh(e,t),hh(e,r)}};function WS({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let o=Array.isArray(e[n])?t:r;o[n]=e[n]}return[t,r]}function mh(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let i in t){let a=t[i];if(a.length===0)continue;let c=(0,Ln.propertyInData)(r,n,i,o.opts.ownProperties);e.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let l of a)(0,Ln.checkReportMissingProp)(e,l)}):(r.if((0,kc._)`${c} && (${(0,Ln.checkMissingProp)(e,a,s)})`),(0,Ln.reportMissingProp)(e,s),r.else())}}ut.validatePropertyDeps=mh;function hh(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,i=r.name("valid");for(let a in t)(0,GS.alwaysValidSchema)(s,t[a])||(r.if((0,Ln.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:a},i);e.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),e.ok(i))}ut.validateSchemaDeps=hh;ut.default=JS});var yh=P(Pc=>{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});var _h=Z(),YS=V(),QS={message:"property name must be valid",params:({params:e})=>(0,_h._)`{propertyName: ${e.propertyName}}`},XS={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:QS,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,YS.alwaysValidSchema)(o,r))return;let s=t.name("valid");t.forIn("key",n,i=>{e.setParams({propertyName:i}),e.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),t.if((0,_h.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};Pc.default=XS});var Rc=P(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});var ls=Ke(),ot=Z(),ex=yt(),ds=V(),tx={message:"must NOT have additional properties",params:({params:e})=>(0,ot._)`{additionalProperty: ${e.additionalProperty}}`},rx={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:tx,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=e;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,ds.alwaysValidSchema)(i,r))return;let l=(0,ls.allSchemaProperties)(n.properties),u=(0,ls.allSchemaProperties)(n.patternProperties);d(),e.ok((0,ot._)`${s} === ${ex.default.errors}`);function d(){t.forIn("key",o,v=>{!l.length&&!u.length?h(v):t.if(f(v),()=>h(v))})}function f(v){let $;if(l.length>8){let S=(0,ds.schemaRefOrVal)(i,n.properties,"properties");$=(0,ls.isOwnProperty)(t,S,v)}else l.length?$=(0,ot.or)(...l.map(S=>(0,ot._)`${v} === ${S}`)):$=ot.nil;return u.length&&($=(0,ot.or)($,...u.map(S=>(0,ot._)`${(0,ls.usePattern)(e,S)}.test(${v})`))),(0,ot.not)($)}function m(v){t.code((0,ot._)`delete ${o}[${v}]`)}function h(v){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){m(v);return}if(r===!1){e.setParams({additionalProperty:v}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,ds.alwaysValidSchema)(i,r)){let $=t.name("valid");c.removeAdditional==="failing"?(g(v,$,!1),t.if((0,ot.not)($),()=>{e.reset(),m(v)})):(g(v,$),a||t.if((0,ot.not)($),()=>t.break()))}}function g(v,$,S){let b={keyword:"additionalProperties",dataProp:v,dataPropType:ds.Type.Str};S===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(b,$)}}};Tc.default=rx});var $h=P(Ic=>{"use strict";Object.defineProperty(Ic,"__esModule",{value:!0});var nx=Tn(),vh=Ke(),Ec=V(),wh=Rc(),ox={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&wh.default.code(new nx.KeywordCxt(s,wh.default,"additionalProperties"));let i=(0,vh.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Ec.mergeEvaluated.props(t,(0,Ec.toHash)(i),s.props));let a=i.filter(d=>!(0,Ec.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=t.name("valid");for(let d of a)l(d)?u(d):(t.if((0,vh.propertyInData)(t,o,d,s.opts.ownProperties)),u(d),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(c);function l(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function u(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Ic.default=ox});var zh=P(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});var bh=Ke(),ps=Z(),Sh=V(),xh=V(),sx={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:i}=s,a=(0,bh.allSchemaProperties)(r),c=a.filter(g=>(0,Sh.alwaysValidSchema)(s,r[g]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let l=i.strictSchema&&!i.allowMatchingProperties&&o.properties,u=t.name("valid");s.props!==!0&&!(s.props instanceof ps.Name)&&(s.props=(0,xh.evaluatedPropsToName)(t,s.props));let{props:d}=s;f();function f(){for(let g of a)l&&m(g),s.allErrors?h(g):(t.var(u,!0),h(g),t.if(u))}function m(g){for(let v in l)new RegExp(g).test(v)&&(0,Sh.checkStrictMode)(s,`property ${v} matches pattern ${g} (use allowMatchingProperties)`)}function h(g){t.forIn("key",n,v=>{t.if((0,ps._)`${(0,bh.usePattern)(e,g)}.test(${v})`,()=>{let $=c.includes(g);$||e.subschema({keyword:"patternProperties",schemaProp:g,dataProp:v,dataPropType:xh.Type.Str},u),s.opts.unevaluated&&d!==!0?t.assign((0,ps._)`${d}[${v}]`,!0):!$&&!s.allErrors&&t.if((0,ps.not)(u),()=>t.break())})})}}};Oc.default=sx});var kh=P(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});var ix=V(),ax={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,ix.alwaysValidSchema)(n,r)){e.fail();return}let o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Ac.default=ax});var Ph=P(Cc=>{"use strict";Object.defineProperty(Cc,"__esModule",{value:!0});var cx=Ke(),ux={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:cx.validateUnion,error:{message:"must match a schema in anyOf"}};Cc.default=ux});var Th=P(Nc=>{"use strict";Object.defineProperty(Nc,"__esModule",{value:!0});var fs=Z(),lx=V(),dx={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,fs._)`{passingSchemas: ${e.passing}}`},px={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:dx,code(e){let{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=t.let("valid",!1),a=t.let("passing",null),c=t.name("_valid");e.setParams({passing:a}),t.block(l),e.result(i,()=>e.reset(),()=>e.error(!0));function l(){s.forEach((u,d)=>{let f;(0,lx.alwaysValidSchema)(o,u)?t.var(c,!0):f=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,fs._)`${c} && ${i}`).assign(i,!1).assign(a,(0,fs._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),f&&e.mergeEvaluated(f,fs.Name)})})}}};Nc.default=px});var Rh=P(jc=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});var fx=V(),mx={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=t.name("valid");r.forEach((s,i)=>{if((0,fx.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};jc.default=mx});var Oh=P(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});var ms=Z(),Ih=V(),hx={message:({params:e})=>(0,ms.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,ms._)`{failingKeyword: ${e.ifClause}}`},gx={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:hx,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Ih.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=Eh(n,"then"),s=Eh(n,"else");if(!o&&!s)return;let i=t.let("valid",!0),a=t.name("_valid");if(c(),e.reset(),o&&s){let u=t.let("ifClause");e.setParams({ifClause:u}),t.if(a,l("then",u),l("else",u))}else o?t.if(a,l("then")):t.if((0,ms.not)(a),l("else"));e.pass(i,()=>e.error(!0));function c(){let u=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(u)}function l(u,d){return()=>{let f=e.subschema({keyword:u},a);t.assign(i,a),e.mergeValidEvaluated(f,i),d?t.assign(d,(0,ms._)`${u}`):e.setParams({ifClause:u})}}}};function Eh(e,t){let r=e.schema[t];return r!==void 0&&!(0,Ih.alwaysValidSchema)(e,r)}Mc.default=gx});var Ah=P(Zc=>{"use strict";Object.defineProperty(Zc,"__esModule",{value:!0});var _x=V(),yx={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,_x.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Zc.default=yx});var Ch=P(Dc=>{"use strict";Object.defineProperty(Dc,"__esModule",{value:!0});var vx=$c(),wx=lh(),$x=bc(),bx=ph(),Sx=fh(),xx=gh(),zx=yh(),kx=Rc(),Px=$h(),Tx=zh(),Rx=kh(),Ex=Ph(),Ix=Th(),Ox=Rh(),Ax=Oh(),Cx=Ah();function Nx(e=!1){let t=[Rx.default,Ex.default,Ix.default,Ox.default,Ax.default,Cx.default,zx.default,kx.default,xx.default,Px.default,Tx.default];return e?t.push(wx.default,bx.default):t.push(vx.default,$x.default),t.push(Sx.default),t}Dc.default=Nx});var Nh=P(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});var he=Z(),jx={message:({schemaCode:e})=>(0,he.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,he._)`{format: ${e}}`},Mx={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:jx,code(e,t){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=e,{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=a;if(!c.validateFormats)return;o?f():m();function f(){let h=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),g=r.const("fDef",(0,he._)`${h}[${i}]`),v=r.let("fType"),$=r.let("format");r.if((0,he._)`typeof ${g} == "object" && !(${g} instanceof RegExp)`,()=>r.assign(v,(0,he._)`${g}.type || "string"`).assign($,(0,he._)`${g}.validate`),()=>r.assign(v,(0,he._)`"string"`).assign($,g)),e.fail$data((0,he.or)(S(),b()));function S(){return c.strictSchema===!1?he.nil:(0,he._)`${i} && !${$}`}function b(){let T=u.$async?(0,he._)`(${g}.async ? await ${$}(${n}) : ${$}(${n}))`:(0,he._)`${$}(${n})`,y=(0,he._)`(typeof ${$} == "function" ? ${T} : ${$}.test(${n}))`;return(0,he._)`${$} && ${$} !== true && ${v} === ${t} && !${y}`}}function m(){let h=d.formats[s];if(!h){S();return}if(h===!0)return;let[g,v,$]=b(h);g===t&&e.pass(T());function S(){if(c.strictSchema===!1){d.logger.warn(y());return}throw new Error(y());function y(){return`unknown format "${s}" ignored in schema at path "${l}"`}}function b(y){let x=y instanceof RegExp?(0,he.regexpCode)(y):c.code.formats?(0,he._)`${c.code.formats}${(0,he.getProperty)(s)}`:void 0,R=r.scopeValue("formats",{key:s,ref:y,code:x});return typeof y=="object"&&!(y instanceof RegExp)?[y.type||"string",y.validate,(0,he._)`${R}.validate`]:["string",y,R]}function T(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!u.$async)throw new Error("async format in sync schema");return(0,he._)`await ${$}(${n})`}return typeof v=="function"?(0,he._)`${$}(${n})`:(0,he._)`${$}.test(${n})`}}}};Uc.default=Mx});var jh=P(qc=>{"use strict";Object.defineProperty(qc,"__esModule",{value:!0});var Zx=Nh(),Dx=[Zx.default];qc.default=Dx});var Mh=P(Zr=>{"use strict";Object.defineProperty(Zr,"__esModule",{value:!0});Zr.contentVocabulary=Zr.metadataVocabulary=void 0;Zr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Zr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Dh=P(Lc=>{"use strict";Object.defineProperty(Lc,"__esModule",{value:!0});var Ux=Bm(),qx=ih(),Lx=Ch(),Fx=jh(),Zh=Mh(),Vx=[Ux.default,qx.default,(0,Lx.default)(),Fx.default,Zh.metadataVocabulary,Zh.contentVocabulary];Lc.default=Vx});var qh=P(hs=>{"use strict";Object.defineProperty(hs,"__esModule",{value:!0});hs.DiscrError=void 0;var Uh;(function(e){e.Tag="tag",e.Mapping="mapping"})(Uh||(hs.DiscrError=Uh={}))});var Fh=P(Vc=>{"use strict";Object.defineProperty(Vc,"__esModule",{value:!0});var Dr=Z(),Fc=qh(),Lh=Qo(),Hx=Rn(),Bx=V(),Kx={message:({params:{discrError:e,tagName:t}})=>e===Fc.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Dr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},Gx={keyword:"discriminator",type:"object",schemaType:"object",error:Kx,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),l=t.const("tag",(0,Dr._)`${r}${(0,Dr.getProperty)(a)}`);t.if((0,Dr._)`typeof ${l} == "string"`,()=>u(),()=>e.error(!1,{discrError:Fc.DiscrError.Tag,tag:l,tagName:a})),e.ok(c);function u(){let m=f();t.if(!1);for(let h in m)t.elseIf((0,Dr._)`${l} === ${h}`),t.assign(c,d(m[h]));t.else(),e.error(!1,{discrError:Fc.DiscrError.Mapping,tag:l,tagName:a}),t.endIf()}function d(m){let h=t.name("valid"),g=e.subschema({keyword:"oneOf",schemaProp:m},h);return e.mergeEvaluated(g,Dr.Name),h}function f(){var m;let h={},g=$(o),v=!0;for(let T=0;T<i.length;T++){let y=i[T];if(y?.$ref&&!(0,Bx.schemaHasRulesButRef)(y,s.self.RULES)){let R=y.$ref;if(y=Lh.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,R),y instanceof Lh.SchemaEnv&&(y=y.schema),y===void 0)throw new Hx.default(s.opts.uriResolver,s.baseId,R)}let x=(m=y?.properties)===null||m===void 0?void 0:m[a];if(typeof x!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);v=v&&(g||$(y)),S(x,T)}if(!v)throw new Error(`discriminator: "${a}" must be required`);return h;function $({required:T}){return Array.isArray(T)&&T.includes(a)}function S(T,y){if(T.const)b(T.const,y);else if(T.enum)for(let x of T.enum)b(x,y);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function b(T,y){if(typeof T!="string"||T in h)throw new Error(`discriminator: "${a}" values must be unique strings`);h[T]=y}}}};Vc.default=Gx});var Vh=P((xA,Jx)=>{Jx.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 Bc=P((le,Hc)=>{"use strict";Object.defineProperty(le,"__esModule",{value:!0});le.MissingRefError=le.ValidationError=le.CodeGen=le.Name=le.nil=le.stringify=le.str=le._=le.KeywordCxt=le.Ajv=void 0;var Wx=Um(),Yx=Dh(),Qx=Fh(),Hh=Vh(),Xx=["/properties"],gs="http://json-schema.org/draft-07/schema",Ur=class extends Wx.default{_addVocabularies(){super._addVocabularies(),Yx.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(Qx.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(Hh,Xx):Hh;this.addMetaSchema(t,gs,!1),this.refs["http://json-schema.org/schema"]=gs}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(gs)?gs:void 0)}};le.Ajv=Ur;Hc.exports=le=Ur;Hc.exports.Ajv=Ur;Object.defineProperty(le,"__esModule",{value:!0});le.default=Ur;var ez=Tn();Object.defineProperty(le,"KeywordCxt",{enumerable:!0,get:function(){return ez.KeywordCxt}});var qr=Z();Object.defineProperty(le,"_",{enumerable:!0,get:function(){return qr._}});Object.defineProperty(le,"str",{enumerable:!0,get:function(){return qr.str}});Object.defineProperty(le,"stringify",{enumerable:!0,get:function(){return qr.stringify}});Object.defineProperty(le,"nil",{enumerable:!0,get:function(){return qr.nil}});Object.defineProperty(le,"Name",{enumerable:!0,get:function(){return qr.Name}});Object.defineProperty(le,"CodeGen",{enumerable:!0,get:function(){return qr.CodeGen}});var tz=Wo();Object.defineProperty(le,"ValidationError",{enumerable:!0,get:function(){return tz.default}});var rz=Rn();Object.defineProperty(le,"MissingRefError",{enumerable:!0,get:function(){return rz.default}})});var Xh=P(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:!0});dt.formatNames=dt.fastFormats=dt.fullFormats=void 0;function lt(e,t){return{validate:e,compare:t}}dt.fullFormats={date:lt(Jh,Wc),time:lt(Gc(!0),Yc),"date-time":lt(Bh(!0),Yh),"iso-time":lt(Gc(),Wh),"iso-date-time":lt(Bh(),Qh),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:cz,"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:hz,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:uz,int32:{type:"number",validate:pz},int64:{type:"number",validate:fz},float:{type:"number",validate:Gh},double:{type:"number",validate:Gh},password:!0,binary:!0};dt.fastFormats={...dt.fullFormats,date:lt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Wc),time:lt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Yc),"date-time":lt(/^\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,Yh),"iso-time":lt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Wh),"iso-date-time":lt(/^\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,Qh),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};dt.formatNames=Object.keys(dt.fullFormats);function nz(e){return e%4===0&&(e%100!==0||e%400===0)}var oz=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,sz=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Jh(e){let t=oz.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&nz(r)?29:sz[n])}function Wc(e,t){if(e&&t)return e>t?1:e<t?-1:0}var Kc=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Gc(e){return function(r){let n=Kc.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,l=+(n[6]||0),u=+(n[7]||0);if(l>23||u>59||e&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-u*c,f=o-l*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&i<61}}function Yc(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function Wh(e,t){if(!(e&&t))return;let r=Kc.exec(e),n=Kc.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var Jc=/t|\s/i;function Bh(e){let t=Gc(e);return function(n){let o=n.split(Jc);return o.length===2&&Jh(o[0])&&t(o[1])}}function Yh(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function Qh(e,t){if(!(e&&t))return;let[r,n]=e.split(Jc),[o,s]=t.split(Jc),i=Wc(r,o);if(i!==void 0)return i||Yc(n,s)}var iz=/\/|:/,az=/^(?:[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 cz(e){return iz.test(e)&&az.test(e)}var Kh=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function uz(e){return Kh.lastIndex=0,Kh.test(e)}var lz=-(2**31),dz=2**31-1;function pz(e){return Number.isInteger(e)&&e<=dz&&e>=lz}function fz(e){return Number.isInteger(e)}function Gh(){return!0}var mz=/[^\\]\\Z/;function hz(e){if(mz.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var eg=P(Lr=>{"use strict";Object.defineProperty(Lr,"__esModule",{value:!0});Lr.formatLimitDefinition=void 0;var gz=Bc(),st=Z(),Nt=st.operators,_s={formatMaximum:{okStr:"<=",ok:Nt.LTE,fail:Nt.GT},formatMinimum:{okStr:">=",ok:Nt.GTE,fail:Nt.LT},formatExclusiveMaximum:{okStr:"<",ok:Nt.LT,fail:Nt.GTE},formatExclusiveMinimum:{okStr:">",ok:Nt.GT,fail:Nt.LTE}},_z={message:({keyword:e,schemaCode:t})=>(0,st.str)`should be ${_s[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,st._)`{comparison: ${_s[e].okStr}, limit: ${t}}`};Lr.formatLimitDefinition={keyword:Object.keys(_s),type:"string",schemaType:"string",$data:!0,error:_z,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:s}=e,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new gz.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?l():u();function l(){let f=t.scopeValue("formats",{ref:a.formats,code:i.code.formats}),m=t.const("fmt",(0,st._)`${f}[${c.schemaCode}]`);e.fail$data((0,st.or)((0,st._)`typeof ${m} != "object"`,(0,st._)`${m} instanceof RegExp`,(0,st._)`typeof ${m}.compare != "function"`,d(m)))}function u(){let f=c.schema,m=a.formats[f];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${o}": format "${f}" does not define "compare" function`);let h=t.scopeValue("formats",{key:f,ref:m,code:i.code.formats?(0,st._)`${i.code.formats}${(0,st.getProperty)(f)}`:void 0});e.fail$data(d(h))}function d(f){return(0,st._)`${f}.compare(${r}, ${n}) ${_s[o].fail} 0`}},dependencies:["format"]};var yz=e=>(e.addKeyword(Lr.formatLimitDefinition),e);Lr.default=yz});var og=P((Fn,ng)=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});var Fr=Xh(),vz=eg(),Qc=Z(),tg=new Qc.Name("fullFormats"),wz=new Qc.Name("fastFormats"),Xc=(e,t={keywords:!0})=>{if(Array.isArray(t))return rg(e,t,Fr.fullFormats,tg),e;let[r,n]=t.mode==="fast"?[Fr.fastFormats,wz]:[Fr.fullFormats,tg],o=t.formats||Fr.formatNames;return rg(e,o,r,n),t.keywords&&(0,vz.default)(e),e};Xc.get=(e,t="full")=>{let n=(t==="fast"?Fr.fastFormats:Fr.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function rg(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,Qc._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}ng.exports=Fn=Xc;Object.defineProperty(Fn,"__esModule",{value:!0});Fn.default=Xc});import{spawn as Jg,spawnSync as As}from"node:child_process";import{connect as hk}from"node:net";import{homedir as Wg,userInfo as hu}from"node:os";import{resolve as Yg,join as bt,dirname as bu}from"node:path";import{fileURLToPath as gk,pathToFileURL as _k}from"node:url";import{createInterface as Is}from"node:readline/promises";import*as q from"node:fs";var Us=Object.freeze({status:"aborted"});function _(e,t,r){function n(a,c){var l;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(l=a._zod).traits??(l.traits=new Set),a._zod.traits.add(e),t(a,c);for(let u in i.prototype)u in a||Object.defineProperty(a,u,{value:i.prototype[u].bind(a)});a._zod.constr=i,a._zod.def=c}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:e});function i(a){var c;let l=r?.Parent?new s:this;n(l,a),(c=l._zod).deferred??(c.deferred=[]);for(let u of l._zod.deferred)u();return l}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(i,"name",{value:e}),i}var f_=Symbol("zod_brand"),ft=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},ao={};function Le(e){return e&&Object.assign(ao,e),ao}var J={};Ds(J,{BIGINT_FORMAT_RANGES:()=>Eu,Class:()=>Ls,NUMBER_FORMAT_RANGES:()=>Ws,aborted:()=>Ut,allowsEval:()=>Ks,assert:()=>y_,assertEqual:()=>m_,assertIs:()=>g_,assertNever:()=>__,assertNotEqual:()=>h_,assignProp:()=>Bs,cached:()=>Wr,captureStackTrace:()=>uo,cleanEnum:()=>I_,cleanRegex:()=>Qr,clone:()=>Ye,createTransparentProxy:()=>x_,defineLazy:()=>oe,esc:()=>Dt,escapeRegex:()=>zt,extend:()=>P_,finalizeIssue:()=>Qe,floatSafeRemainder:()=>Hs,getElementAtPath:()=>v_,getEnumValues:()=>Fs,getLengthableOrigin:()=>Xr,getParsedType:()=>S_,getSizableOrigin:()=>Iu,isObject:()=>fr,isPlainObject:()=>mr,issue:()=>Ys,joinValues:()=>co,jsonStringifyReplacer:()=>Vs,merge:()=>T_,normalizeParams:()=>A,nullish:()=>Yr,numKeys:()=>b_,omit:()=>k_,optionalKeys:()=>Js,partial:()=>R_,pick:()=>z_,prefixIssues:()=>it,primitiveTypes:()=>Ru,promiseAllObject:()=>w_,propertyKeyTypes:()=>Gs,randomString:()=>$_,required:()=>E_,stringifyPrimitive:()=>lo,unwrapMessage:()=>Jr});function m_(e){return e}function h_(e){return e}function g_(e){}function __(e){throw new Error}function y_(e){}function Fs(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function co(e,t="|"){return e.map(r=>lo(r)).join(t)}function Vs(e,t){return typeof t=="bigint"?t.toString():t}function Wr(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Yr(e){return e==null}function Qr(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Hs(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(e.toFixed(o).replace(".","")),i=Number.parseInt(t.toFixed(o).replace(".",""));return s%i/10**o}function oe(e,t,r){Object.defineProperty(e,t,{get(){{let o=r();return e[t]=o,o}throw new Error("cached value already set")},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Bs(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function v_(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function w_(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function $_(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Dt(e){return JSON.stringify(e)}var uo=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function fr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Ks=Wr(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function mr(e){if(fr(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(fr(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function b_(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var S_=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Gs=new Set(["string","number","symbol"]),Ru=new Set(["string","number","bigint","boolean","symbol","undefined"]);function zt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ye(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function A(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function x_(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function lo(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Js(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Ws={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Eu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function z_(e,t){let r={},n=e._zod.def;for(let o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&(r[o]=n.shape[o])}return Ye(e,{...e._zod.def,shape:r,checks:[]})}function k_(e,t){let r={...e._zod.def.shape},n=e._zod.def;for(let o in t){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);t[o]&&delete r[o]}return Ye(e,{...e._zod.def,shape:r,checks:[]})}function P_(e,t){if(!mr(t))throw new Error("Invalid input to extend: expected a plain object");let r={...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return Bs(this,"shape",n),n},checks:[]};return Ye(e,r)}function T_(e,t){return Ye(e,{...e._zod.def,get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return Bs(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function R_(e,t,r){let n=t._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in n))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=e?new e({type:"optional",innerType:n[s]}):n[s])}else for(let s in n)o[s]=e?new e({type:"optional",innerType:n[s]}):n[s];return Ye(t,{...t._zod.def,shape:o,checks:[]})}function E_(e,t,r){let n=t._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=new e({type:"nonoptional",innerType:n[s]}))}else for(let s in n)o[s]=new e({type:"nonoptional",innerType:n[s]});return Ye(t,{...t._zod.def,shape:o,checks:[]})}function Ut(e,t=0){for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function it(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Jr(e){return typeof e=="string"?e:e?.message}function Qe(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let o=Jr(e.inst?._zod.def?.error?.(e))??Jr(t?.error?.(e))??Jr(r.customError?.(e))??Jr(r.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function Iu(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Xr(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ys(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function I_(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var Ls=class{constructor(...t){}};var Ou=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),Object.defineProperty(e,"message",{get(){return JSON.stringify(t,Vs,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},po=_("$ZodError",Ou),Qs=_("$ZodError",Ou,{Parent:Error});function Xs(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(t(o))):n.push(t(o));return{formErrors:n,fieldErrors:r}}function ei(e,t){let r=t||function(s){return s.message},n={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let l=i.path[c];c===i.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(r(i))):a[l]=a[l]||{_errors:[]},a=a[l],c++}}};return o(e),n}var Au=e=>(t,r,n,o)=>{let s=n?Object.assign(n,{async:!1}):{async:!1},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new ft;if(i.issues.length){let a=new(o?.Err??e)(i.issues.map(c=>Qe(c,s,Le())));throw uo(a,o?.callee),a}return i.value};var Cu=e=>async(t,r,n,o)=>{let s=n?Object.assign(n,{async:!0}):{async:!0},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(o?.Err??e)(i.issues.map(c=>Qe(c,s,Le())));throw uo(a,o?.callee),a}return i.value};var ti=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ft;return s.issues.length?{success:!1,error:new(e??po)(s.issues.map(i=>Qe(i,o,Le())))}:{success:!0,data:s.value}},en=ti(Qs),ri=e=>async(t,r,n)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new e(s.issues.map(i=>Qe(i,o,Le())))}:{success:!0,data:s.value}},fo=ri(Qs);var Nu=/^[cC][^\s-]{8,}$/,ju=/^[0-9a-z]+$/,Mu=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Zu=/^[0-9a-vA-V]{20}$/,Du=/^[A-Za-z0-9]{27}$/,Uu=/^[a-zA-Z0-9_-]{21}$/,qu=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Lu=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ni=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;var Fu=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var A_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Vu(){return new RegExp(A_,"u")}var Hu=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Bu=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,Ku=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Gu=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ju=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,oi=/^[A-Za-z0-9_-]*$/,Wu=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var Yu=/^\+(?:[0-9]){6,14}[0-9]$/,Qu="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Xu=new RegExp(`^${Qu}$`);function el(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function tl(e){return new RegExp(`^${el(e)}$`)}function rl(e){let t=el({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${t}(?:${r.join("|")})`;return new RegExp(`^${Qu}T(?:${n})$`)}var nl=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},ol=/^\d+n?$/,sl=/^\d+$/,il=/^-?\d+(?:\.\d+)?/i,al=/true|false/i,cl=/null/i;var ul=/^[^A-Z]*$/,ll=/^[^a-z]*$/;var Pe=_("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),dl={number:"number",bigint:"bigint",object:"date"},si=_("$ZodCheckLessThan",(e,t)=>{Pe.init(e,t);let r=dl[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,s=(t.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<s&&(t.inclusive?o.maximum=t.value:o.exclusiveMaximum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:r,code:"too_big",maximum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ii=_("$ZodCheckGreaterThan",(e,t)=>{Pe.init(e,t);let r=dl[typeof t.value];e._zod.onattach.push(n=>{let o=n._zod.bag,s=(t.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>s&&(t.inclusive?o.minimum=t.value:o.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),pl=_("$ZodCheckMultipleOf",(e,t)=>{Pe.init(e,t),e._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Hs(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),fl=_("$ZodCheckNumberFormat",(e,t)=>{Pe.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=Ws[t.format];e._zod.onattach.push(i=>{let a=i._zod.bag;a.format=t.format,a.minimum=o,a.maximum=s,r&&(a.pattern=sl)}),e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inst:e})}});var ml=_("$ZodCheckMaxLength",(e,t)=>{var r;Pe.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Yr(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<o&&(n._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let o=n.value;if(o.length<=t.maximum)return;let i=Xr(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),hl=_("$ZodCheckMinLength",(e,t)=>{var r;Pe.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Yr(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>o&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let o=n.value;if(o.length>=t.minimum)return;let i=Xr(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),gl=_("$ZodCheckLengthEquals",(e,t)=>{var r;Pe.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Yr(o)&&o.length!==void 0}),e._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=t.length,o.maximum=t.length,o.length=t.length}),e._zod.check=n=>{let o=n.value,s=o.length;if(s===t.length)return;let i=Xr(o),a=s>t.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),tn=_("$ZodCheckStringFormat",(e,t)=>{var r,n;Pe.init(e,t),e._zod.onattach.push(o=>{let s=o._zod.bag;s.format=t.format,t.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),_l=_("$ZodCheckRegex",(e,t)=>{tn.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),yl=_("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ul),tn.init(e,t)}),vl=_("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ll),tn.init(e,t)}),wl=_("$ZodCheckIncludes",(e,t)=>{Pe.init(e,t);let r=zt(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),$l=_("$ZodCheckStartsWith",(e,t)=>{Pe.init(e,t);let r=new RegExp(`^${zt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),bl=_("$ZodCheckEndsWith",(e,t)=>{Pe.init(e,t);let r=new RegExp(`.*${zt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var Sl=_("$ZodCheckOverwrite",(e,t)=>{Pe.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var ho=class{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
11
11
  `).filter(i=>i),o=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let t=Function,r=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new t(...r,o.join(`
12
- `))}};var Sl={major:4,minor:0,patch:0};var X=_("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Sl;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let s of o._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(s,i,a)=>{let c=Dt(s),u;for(let l of i){if(l._zod.def.when){if(!l._zod.def.when(s))continue}else if(c)continue;let d=s.issues.length,m=l._zod.check(s);if(m instanceof Promise&&a?.async===!1)throw new ft;if(u||m instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await m,s.issues.length!==d&&(c||(c=Dt(s,d)))});else{if(s.issues.length===d)continue;c||(c=Dt(s,d))}}return u?u.then(()=>s):s};e._zod.run=(s,i)=>{let a=e._zod.parse(s,i);if(a instanceof Promise){if(i.async===!1)throw new ft;return a.then(c=>o(c,n,i))}return o(a,n,i)}}e["~standard"]={validate:o=>{try{let s=en(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return fo(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),_o=_("$ZodString",(e,t)=>{X.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??rl(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ae=_("$ZodStringFormat",(e,t)=>{tn.init(e,t),_o.init(e,t)}),Al=_("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Uu),ae.init(e,t)}),Nl=_("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ni(n))}else t.pattern??(t.pattern=ni());ae.init(e,t)}),jl=_("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Lu),ae.init(e,t)}),Zl=_("$ZodURL",(e,t)=>{ae.init(e,t),e._zod.check=r=>{try{let n=r.value,o=new URL(n),s=o.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Ju.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),!n.endsWith("/")&&s.endsWith("/")?r.value=s.slice(0,-1):r.value=s;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Ml=_("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Fu()),ae.init(e,t)}),Dl=_("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Du),ae.init(e,t)}),ql=_("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Au),ae.init(e,t)}),Ul=_("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Nu),ae.init(e,t)}),Ll=_("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ju),ae.init(e,t)}),Fl=_("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Zu),ae.init(e,t)}),Vl=_("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Mu),ae.init(e,t)}),Hl=_("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=tl(t)),ae.init(e,t)}),Kl=_("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Qu),ae.init(e,t)}),Bl=_("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=el(t)),ae.init(e,t)}),Gl=_("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=qu),ae.init(e,t)}),Jl=_("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Vu),ae.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),Wl=_("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Hu),ae.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Yl=_("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ku),ae.init(e,t)}),Ql=_("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Bu),ae.init(e,t),e._zod.check=r=>{let[n,o]=r.value.split("/");try{if(!o)throw new Error;let s=Number(o);if(`${s}`!==o)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function Xl(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var ed=_("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Gu),ae.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{Xl(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function O_(e){if(!oi.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Xl(r)}var td=_("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=oi),ae.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{O_(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),rd=_("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Wu),ae.init(e,t)});function C_(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var nd=_("$ZodJWT",(e,t)=>{ae.init(e,t),e._zod.check=r=>{C_(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var ci=_("$ZodNumber",(e,t)=>{X.init(e,t),e._zod.pattern=e._zod.bag.pattern??sl,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),od=_("$ZodNumber",(e,t)=>{pl.init(e,t),ci.init(e,t)}),sd=_("$ZodBoolean",(e,t)=>{X.init(e,t),e._zod.pattern=il,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),id=_("$ZodBigInt",(e,t)=>{X.init(e,t),e._zod.pattern=nl,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}});var ad=_("$ZodNull",(e,t)=>{X.init(e,t),e._zod.pattern=al,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}}),cd=_("$ZodAny",(e,t)=>{X.init(e,t),e._zod.parse=r=>r}),ud=_("$ZodUnknown",(e,t)=>{X.init(e,t),e._zod.parse=r=>r}),ld=_("$ZodNever",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});var dd=_("$ZodDate",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let o=r.value,s=o instanceof Date;return s&&!Number.isNaN(o.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:o,...s?{received:"Invalid Date"}:{},inst:e}),r}});function zl(e,t,r){e.issues.length&&t.issues.push(...it(r,e.issues)),t.value[r]=e.value}var pd=_("$ZodArray",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let a=o[i],c=t.element._zod.run({value:a,issues:[]},n);c instanceof Promise?s.push(c.then(u=>zl(u,r,i))):zl(c,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function go(e,t,r){e.issues.length&&t.issues.push(...it(r,e.issues)),t.value[r]=e.value}function kl(e,t,r,n){e.issues.length?n[r]===void 0?r in n?t.value[r]=void 0:t.value[r]=e.value:t.issues.push(...it(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}var fd=_("$ZodObject",(e,t)=>{X.init(e,t);let r=Wr(()=>{let d=Object.keys(t.shape);for(let f of d)if(!(t.shape[f]instanceof X))throw new Error(`Invalid element at key "${f}": expected a Zod schema`);let m=Js(t.shape);return{shape:t.shape,keys:d,keySet:new Set(d),numKeys:d.length,optionalKeys:new Set(m)}});oe(e._zod,"propValues",()=>{let d=t.shape,m={};for(let f in d){let h=d[f]._zod;if(h.values){m[f]??(m[f]=new Set);for(let g of h.values)m[f].add(g)}}return m});let n=d=>{let m=new ho(["shape","payload","ctx"]),f=r.value,h=x=>{let $=Mt(x);return`shape[${$}]._zod.run({ value: input[${$}], issues: [] }, ctx)`};m.write("const input = payload.value;");let g=Object.create(null),v=0;for(let x of f.keys)g[x]=`key_${v++}`;m.write("const newResult = {}");for(let x of f.keys)if(f.optionalKeys.has(x)){let $=g[x];m.write(`const ${$} = ${h(x)};`);let T=Mt(x);m.write(`
13
- if (${$}.issues.length) {
12
+ `))}};var zl={major:4,minor:0,patch:0};var X=_("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=zl;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let o of n)for(let s of o._zod.onattach)s(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let o=(s,i,a)=>{let c=Ut(s),l;for(let u of i){if(u._zod.def.when){if(!u._zod.def.when(s))continue}else if(c)continue;let d=s.issues.length,f=u._zod.check(s);if(f instanceof Promise&&a?.async===!1)throw new ft;if(l||f instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await f,s.issues.length!==d&&(c||(c=Ut(s,d)))});else{if(s.issues.length===d)continue;c||(c=Ut(s,d))}}return l?l.then(()=>s):s};e._zod.run=(s,i)=>{let a=e._zod.parse(s,i);if(a instanceof Promise){if(i.async===!1)throw new ft;return a.then(c=>o(c,n,i))}return o(a,n,i)}}e["~standard"]={validate:o=>{try{let s=en(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return fo(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),_o=_("$ZodString",(e,t)=>{X.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??nl(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ae=_("$ZodStringFormat",(e,t)=>{tn.init(e,t),_o.init(e,t)}),Nl=_("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Lu),ae.init(e,t)}),jl=_("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ni(n))}else t.pattern??(t.pattern=ni());ae.init(e,t)}),Ml=_("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Fu),ae.init(e,t)}),Zl=_("$ZodURL",(e,t)=>{ae.init(e,t),e._zod.check=r=>{try{let n=r.value,o=new URL(n),s=o.href;t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Wu.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),!n.endsWith("/")&&s.endsWith("/")?r.value=s.slice(0,-1):r.value=s;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Dl=_("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Vu()),ae.init(e,t)}),Ul=_("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Uu),ae.init(e,t)}),ql=_("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Nu),ae.init(e,t)}),Ll=_("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=ju),ae.init(e,t)}),Fl=_("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Mu),ae.init(e,t)}),Vl=_("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Zu),ae.init(e,t)}),Hl=_("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Du),ae.init(e,t)}),Bl=_("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=rl(t)),ae.init(e,t)}),Kl=_("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Xu),ae.init(e,t)}),Gl=_("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=tl(t)),ae.init(e,t)}),Jl=_("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=qu),ae.init(e,t)}),Wl=_("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Hu),ae.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),Yl=_("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Bu),ae.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv6"}),e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),Ql=_("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ku),ae.init(e,t)}),Xl=_("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Gu),ae.init(e,t),e._zod.check=r=>{let[n,o]=r.value.split("/");try{if(!o)throw new Error;let s=Number(o);if(`${s}`!==o)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function ed(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var td=_("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ju),ae.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{ed(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function C_(e){if(!oi.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return ed(r)}var rd=_("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=oi),ae.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{C_(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),nd=_("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Yu),ae.init(e,t)});function N_(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var od=_("$ZodJWT",(e,t)=>{ae.init(e,t),e._zod.check=r=>{N_(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var ci=_("$ZodNumber",(e,t)=>{X.init(e,t),e._zod.pattern=e._zod.bag.pattern??il,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),sd=_("$ZodNumber",(e,t)=>{fl.init(e,t),ci.init(e,t)}),id=_("$ZodBoolean",(e,t)=>{X.init(e,t),e._zod.pattern=al,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}}),ad=_("$ZodBigInt",(e,t)=>{X.init(e,t),e._zod.pattern=ol,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}});var cd=_("$ZodNull",(e,t)=>{X.init(e,t),e._zod.pattern=cl,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}}),ud=_("$ZodAny",(e,t)=>{X.init(e,t),e._zod.parse=r=>r}),ld=_("$ZodUnknown",(e,t)=>{X.init(e,t),e._zod.parse=r=>r}),dd=_("$ZodNever",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});var pd=_("$ZodDate",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let o=r.value,s=o instanceof Date;return s&&!Number.isNaN(o.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:o,...s?{received:"Invalid Date"}:{},inst:e}),r}});function kl(e,t,r){e.issues.length&&t.issues.push(...it(r,e.issues)),t.value[r]=e.value}var fd=_("$ZodArray",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let a=o[i],c=t.element._zod.run({value:a,issues:[]},n);c instanceof Promise?s.push(c.then(l=>kl(l,r,i))):kl(c,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function go(e,t,r){e.issues.length&&t.issues.push(...it(r,e.issues)),t.value[r]=e.value}function Pl(e,t,r,n){e.issues.length?n[r]===void 0?r in n?t.value[r]=void 0:t.value[r]=e.value:t.issues.push(...it(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}var md=_("$ZodObject",(e,t)=>{X.init(e,t);let r=Wr(()=>{let d=Object.keys(t.shape);for(let m of d)if(!(t.shape[m]instanceof X))throw new Error(`Invalid element at key "${m}": expected a Zod schema`);let f=Js(t.shape);return{shape:t.shape,keys:d,keySet:new Set(d),numKeys:d.length,optionalKeys:new Set(f)}});oe(e._zod,"propValues",()=>{let d=t.shape,f={};for(let m in d){let h=d[m]._zod;if(h.values){f[m]??(f[m]=new Set);for(let g of h.values)f[m].add(g)}}return f});let n=d=>{let f=new ho(["shape","payload","ctx"]),m=r.value,h=S=>{let b=Dt(S);return`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`};f.write("const input = payload.value;");let g=Object.create(null),v=0;for(let S of m.keys)g[S]=`key_${v++}`;f.write("const newResult = {}");for(let S of m.keys)if(m.optionalKeys.has(S)){let b=g[S];f.write(`const ${b} = ${h(S)};`);let T=Dt(S);f.write(`
13
+ if (${b}.issues.length) {
14
14
  if (input[${T}] === undefined) {
15
15
  if (${T} in input) {
16
16
  newResult[${T}] = undefined;
17
17
  }
18
18
  } else {
19
19
  payload.issues = payload.issues.concat(
20
- ${$}.issues.map((iss) => ({
20
+ ${b}.issues.map((iss) => ({
21
21
  ...iss,
22
22
  path: iss.path ? [${T}, ...iss.path] : [${T}],
23
23
  }))
24
24
  );
25
25
  }
26
- } else if (${$}.value === undefined) {
26
+ } else if (${b}.value === undefined) {
27
27
  if (${T} in input) newResult[${T}] = undefined;
28
28
  } else {
29
- newResult[${T}] = ${$}.value;
29
+ newResult[${T}] = ${b}.value;
30
30
  }
31
- `)}else{let $=g[x];m.write(`const ${$} = ${h(x)};`),m.write(`
32
- if (${$}.issues.length) payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
31
+ `)}else{let b=g[S];f.write(`const ${b} = ${h(S)};`),f.write(`
32
+ if (${b}.issues.length) payload.issues = payload.issues.concat(${b}.issues.map(iss => ({
33
33
  ...iss,
34
- path: iss.path ? [${Mt(x)}, ...iss.path] : [${Mt(x)}]
35
- })));`),m.write(`newResult[${Mt(x)}] = ${$}.value`)}m.write("payload.value = newResult;"),m.write("return payload;");let w=m.compile();return(x,$)=>w(d,x,$)},o,s=pr,i=!ao.jitless,c=i&&Bs.value,u=t.catchall,l;e._zod.parse=(d,m)=>{l??(l=r.value);let f=d.value;if(!s(f))return d.issues.push({expected:"object",code:"invalid_type",input:f,inst:e}),d;let h=[];if(i&&c&&m?.async===!1&&m.jitless!==!0)o||(o=n(t.shape)),d=o(d,m);else{d.value={};let $=l.shape;for(let T of l.keys){let y=$[T],S=y._zod.run({value:f[T],issues:[]},m),R=y._zod.optin==="optional"&&y._zod.optout==="optional";S instanceof Promise?h.push(S.then(J=>R?kl(J,d,T,f):go(J,d,T))):R?kl(S,d,T,f):go(S,d,T)}}if(!u)return h.length?Promise.all(h).then(()=>d):d;let g=[],v=l.keySet,w=u._zod,x=w.def.type;for(let $ of Object.keys(f)){if(v.has($))continue;if(x==="never"){g.push($);continue}let T=w.run({value:f[$],issues:[]},m);T instanceof Promise?h.push(T.then(y=>go(y,d,$))):go(T,d,$)}return g.length&&d.issues.push({code:"unrecognized_keys",keys:g,input:f,inst:e}),h.length?Promise.all(h).then(()=>d):d}});function Pl(e,t,r,n){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(s=>Ye(s,n,Ue())))}),t}var ui=_("$ZodUnion",(e,t)=>{X.init(e,t),oe(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),oe(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),oe(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),oe(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){let r=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>Qr(n.source)).join("|")})$`)}}),e._zod.parse=(r,n)=>{let o=!1,s=[];for(let i of t.options){let a=i._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)s.push(a),o=!0;else{if(a.issues.length===0)return a;s.push(a)}}return o?Promise.all(s).then(i=>Pl(i,r,e,n)):Pl(s,r,e,n)}}),md=_("$ZodDiscriminatedUnion",(e,t)=>{ui.init(e,t);let r=e._zod.parse;oe(e._zod,"propValues",()=>{let o={};for(let s of t.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(let u of c)o[a].add(u)}}return o});let n=Wr(()=>{let o=t.options,s=new Map;for(let i of o){let a=i._zod.propValues[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});e._zod.parse=(o,s)=>{let i=o.value;if(!pr(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=n.value.get(i?.[t.discriminator]);return a?a._zod.run(o,s):t.unionFallback?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[t.discriminator],inst:e}),o)}}),hd=_("$ZodIntersection",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Tl(r,c,u)):Tl(r,s,i)}});function ai(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(fr(e)&&fr(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};for(let s of n){let i=ai(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=ai(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Tl(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),Dt(e))return e;let n=ai(t.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}var gd=_("$ZodRecord",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!fr(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;let s=[];if(t.keyType._zod.values){let i=t.keyType._zod.values;r.value={};for(let c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){let u=t.valueType._zod.run({value:o[c],issues:[]},n);u instanceof Promise?s.push(u.then(l=>{l.issues.length&&r.issues.push(...it(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...it(c,u.issues)),r.value[c]=u.value)}let a;for(let c in o)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{r.value={};for(let i of Reflect.ownKeys(o)){if(i==="__proto__")continue;let a=t.keyType._zod.run({value:i,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(u=>Ye(u,n,Ue())),input:i,path:[i],inst:e}),r.value[a.value]=a.value;continue}let c=t.valueType._zod.run({value:o[i],issues:[]},n);c instanceof Promise?s.push(c.then(u=>{u.issues.length&&r.issues.push(...it(i,u.issues)),r.value[a.value]=u.value})):(c.issues.length&&r.issues.push(...it(i,c.issues)),r.value[a.value]=c.value)}}return s.length?Promise.all(s).then(()=>r):r}});var _d=_("$ZodEnum",(e,t)=>{X.init(e,t);let r=Fs(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>Gs.has(typeof n)).map(n=>typeof n=="string"?St(n):n.toString()).join("|")})$`),e._zod.parse=(n,o)=>{let s=n.value;return e._zod.values.has(s)||n.issues.push({code:"invalid_value",values:r,input:s,inst:e}),n}}),yd=_("$ZodLiteral",(e,t)=>{X.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?St(r):r?r.toString():String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let o=r.value;return e._zod.values.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}});var vd=_("$ZodTransform",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new ft;return r.value=o,r}}),wd=_("$ZodOptional",(e,t)=>{X.init(e,t),e._zod.optin="optional",e._zod.optout="optional",oe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),oe(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Qr(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(r,n):r.value===void 0?r:t.innerType._zod.run(r,n)}),$d=_("$ZodNullable",(e,t)=>{X.init(e,t),oe(e._zod,"optin",()=>t.innerType._zod.optin),oe(e._zod,"optout",()=>t.innerType._zod.optout),oe(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Qr(r.source)}|null)$`):void 0}),oe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),bd=_("$ZodDefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Rl(s,t)):Rl(o,t)}});function Rl(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var xd=_("$ZodPrefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Sd=_("$ZodNonOptional",(e,t)=>{X.init(e,t),oe(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>El(s,e)):El(o,e)}});function El(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var zd=_("$ZodCatch",(e,t)=>{X.init(e,t),e._zod.optin="optional",oe(e._zod,"optout",()=>t.innerType._zod.optout),oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(i=>Ye(i,n,Ue()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(s=>Ye(s,n,Ue()))},input:r.value}),r.issues=[]),r)}});var kd=_("$ZodPipe",(e,t)=>{X.init(e,t),oe(e._zod,"values",()=>t.in._zod.values),oe(e._zod,"optin",()=>t.in._zod.optin),oe(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(r,n)=>{let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Il(s,t,n)):Il(o,t,n)}});function Il(e,t,r){return Dt(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}var Pd=_("$ZodReadonly",(e,t)=>{X.init(e,t),oe(e._zod,"propValues",()=>t.innerType._zod.propValues),oe(e._zod,"values",()=>t.innerType._zod.values),oe(e._zod,"optin",()=>t.innerType._zod.optin),oe(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Ol):Ol(o)}});function Ol(e){return e.value=Object.freeze(e.value),e}var Td=_("$ZodCustom",(e,t)=>{Pe.init(e,t),X.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Cl(s,r,n,e));Cl(o,r,n,e)}});function Cl(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Ys(o))}}var A_=e=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},N_=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${A_(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${lo(n.values[0])}`:`Invalid option: expected one of ${co(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",s=t(n.origin);return s?`Too big: expected ${n.origin??"value"} to have ${o}${n.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",s=t(n.origin);return s?`Too small: expected ${n.origin} to have ${o}${n.minimum.toString()} ${s.unit}`:`Too small: expected ${n.origin} to be ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${co(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function Rd(){return{localeError:N_()}}var j_=Symbol("ZodOutput"),Z_=Symbol("ZodInput"),li=class{constructor(){this._map=new Map,this._idmap=new Map}add(t,...r){let n=r[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}};function Ed(){return new li}var mr=Ed();function Id(e,t){return new e({type:"string",...C(t)})}function Od(e,t){return new e({type:"string",coerce:!0,...C(t)})}function Cd(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...C(t)})}function di(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...C(t)})}function Ad(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...C(t)})}function Nd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...C(t)})}function jd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...C(t)})}function Zd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...C(t)})}function pi(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...C(t)})}function Md(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...C(t)})}function Dd(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...C(t)})}function qd(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...C(t)})}function Ud(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...C(t)})}function Ld(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...C(t)})}function Fd(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...C(t)})}function Vd(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...C(t)})}function Hd(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...C(t)})}function Kd(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...C(t)})}function Bd(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...C(t)})}function Gd(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...C(t)})}function Jd(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...C(t)})}function Wd(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...C(t)})}function Yd(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...C(t)})}function Qd(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...C(t)})}function Xd(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...C(t)})}function ep(e,t){return new e({type:"string",format:"date",check:"string_format",...C(t)})}function tp(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...C(t)})}function rp(e,t){return new e({type:"string",format:"duration",check:"string_format",...C(t)})}function np(e,t){return new e({type:"number",checks:[],...C(t)})}function op(e,t){return new e({type:"number",coerce:!0,checks:[],...C(t)})}function sp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...C(t)})}function ip(e,t){return new e({type:"boolean",...C(t)})}function ap(e,t){return new e({type:"boolean",coerce:!0,...C(t)})}function cp(e,t){return new e({type:"bigint",coerce:!0,...C(t)})}function up(e,t){return new e({type:"null",...C(t)})}function lp(e){return new e({type:"any"})}function dp(e){return new e({type:"unknown"})}function pp(e,t){return new e({type:"never",...C(t)})}function fp(e,t){return new e({type:"date",coerce:!0,...C(t)})}function hr(e,t){return new si({check:"less_than",...C(t),value:e,inclusive:!1})}function mt(e,t){return new si({check:"less_than",...C(t),value:e,inclusive:!0})}function gr(e,t){return new ii({check:"greater_than",...C(t),value:e,inclusive:!1})}function Qe(e,t){return new ii({check:"greater_than",...C(t),value:e,inclusive:!0})}function rn(e,t){return new dl({check:"multiple_of",...C(t),value:e})}function yo(e,t){return new fl({check:"max_length",...C(t),maximum:e})}function _r(e,t){return new ml({check:"min_length",...C(t),minimum:e})}function vo(e,t){return new hl({check:"length_equals",...C(t),length:e})}function fi(e,t){return new gl({check:"string_format",format:"regex",...C(t),pattern:e})}function mi(e){return new _l({check:"string_format",format:"lowercase",...C(e)})}function hi(e){return new yl({check:"string_format",format:"uppercase",...C(e)})}function gi(e,t){return new vl({check:"string_format",format:"includes",...C(t),includes:e})}function _i(e,t){return new wl({check:"string_format",format:"starts_with",...C(t),prefix:e})}function yi(e,t){return new $l({check:"string_format",format:"ends_with",...C(t),suffix:e})}function qt(e){return new bl({check:"overwrite",tx:e})}function vi(e){return qt(t=>t.normalize(e))}function wi(){return qt(e=>e.trim())}function $i(){return qt(e=>e.toLowerCase())}function bi(){return qt(e=>e.toUpperCase())}function mp(e,t,r){return new e({type:"array",element:t,...C(r)})}function hp(e,t,r){let n=C(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function gp(e,t,r){return new e({type:"custom",check:"custom",fn:t,...C(r)})}function vr(e){return!!e._zod}function Xe(e,t){return vr(e)?en(e,t):e.safeParse(t)}function wo(e){if(!e)return;let t;if(vr(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function _p(e){if(vr(e)){let s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=e.value;if(n!==void 0)return n}var nn={};Ds(nn,{ZodISODate:()=>vp,ZodISODateTime:()=>yp,ZodISODuration:()=>$p,ZodISOTime:()=>wp,date:()=>Si,datetime:()=>xi,duration:()=>ki,time:()=>zi});var yp=_("ZodISODateTime",(e,t)=>{Hl.init(e,t),de.init(e,t)});function xi(e){return Xd(yp,e)}var vp=_("ZodISODate",(e,t)=>{Kl.init(e,t),de.init(e,t)});function Si(e){return ep(vp,e)}var wp=_("ZodISOTime",(e,t)=>{Bl.init(e,t),de.init(e,t)});function zi(e){return tp(wp,e)}var $p=_("ZodISODuration",(e,t)=>{Gl.init(e,t),de.init(e,t)});function ki(e){return rp($p,e)}var xp=(e,t)=>{po.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>ei(e,r)},flatten:{value:r=>Xs(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},RP=_("ZodError",xp),on=_("ZodError",xp,{Parent:Error});var Sp=Ou(on),zp=Cu(on),kp=ti(on),Pp=ri(on);var se=_("ZodType",(e,t)=>(X.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>We(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>Sp(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>kp(e,r,n),e.parseAsync=async(r,n)=>zp(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Pp(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(Iy(r,n)),e.superRefine=r=>e.check(Oy(r)),e.overwrite=r=>e.check(qt(r)),e.optional=()=>fe(e),e.nullable=()=>Ep(e),e.nullish=()=>fe(Ep(e)),e.nonoptional=r=>Sy(e,r),e.array=()=>z(e),e.or=r=>ce([e,r]),e.and=r=>xo(e,r),e.transform=r=>Ti(e,qp(r)),e.default=r=>$y(e,r),e.prefault=r=>xy(e,r),e.catch=r=>ky(e,r),e.pipe=r=>Ti(e,r),e.readonly=()=>Ry(e),e.describe=r=>{let n=e.clone();return mr.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return mr.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return mr.get(e);let n=e.clone();return mr.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Ip=_("_ZodString",(e,t)=>{_o.init(e,t),se.init(e,t);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(fi(...n)),e.includes=(...n)=>e.check(gi(...n)),e.startsWith=(...n)=>e.check(_i(...n)),e.endsWith=(...n)=>e.check(yi(...n)),e.min=(...n)=>e.check(_r(...n)),e.max=(...n)=>e.check(yo(...n)),e.length=(...n)=>e.check(vo(...n)),e.nonempty=(...n)=>e.check(_r(1,...n)),e.lowercase=n=>e.check(mi(n)),e.uppercase=n=>e.check(hi(n)),e.trim=()=>e.check(wi()),e.normalize=(...n)=>e.check(vi(...n)),e.toLowerCase=()=>e.check($i()),e.toUpperCase=()=>e.check(bi())}),Ri=_("ZodString",(e,t)=>{_o.init(e,t),Ip.init(e,t),e.email=r=>e.check(Cd(H_,r)),e.url=r=>e.check(pi(Op,r)),e.jwt=r=>e.check(Qd(iy,r)),e.emoji=r=>e.check(Md(K_,r)),e.guid=r=>e.check(di(Tp,r)),e.uuid=r=>e.check(Ad($o,r)),e.uuidv4=r=>e.check(Nd($o,r)),e.uuidv6=r=>e.check(jd($o,r)),e.uuidv7=r=>e.check(Zd($o,r)),e.nanoid=r=>e.check(Dd(B_,r)),e.guid=r=>e.check(di(Tp,r)),e.cuid=r=>e.check(qd(G_,r)),e.cuid2=r=>e.check(Ud(J_,r)),e.ulid=r=>e.check(Ld(W_,r)),e.base64=r=>e.check(Jd(ny,r)),e.base64url=r=>e.check(Wd(oy,r)),e.xid=r=>e.check(Fd(Y_,r)),e.ksuid=r=>e.check(Vd(Q_,r)),e.ipv4=r=>e.check(Hd(X_,r)),e.ipv6=r=>e.check(Kd(ey,r)),e.cidrv4=r=>e.check(Bd(ty,r)),e.cidrv6=r=>e.check(Gd(ry,r)),e.e164=r=>e.check(Yd(sy,r)),e.datetime=r=>e.check(xi(r)),e.date=r=>e.check(Si(r)),e.time=r=>e.check(zi(r)),e.duration=r=>e.check(ki(r))});function p(e){return Id(Ri,e)}var de=_("ZodStringFormat",(e,t)=>{ae.init(e,t),Ip.init(e,t)}),H_=_("ZodEmail",(e,t)=>{jl.init(e,t),de.init(e,t)});var Tp=_("ZodGUID",(e,t)=>{Al.init(e,t),de.init(e,t)});var $o=_("ZodUUID",(e,t)=>{Nl.init(e,t),de.init(e,t)});var Op=_("ZodURL",(e,t)=>{Zl.init(e,t),de.init(e,t)});function Cp(e){return pi(Op,e)}var K_=_("ZodEmoji",(e,t)=>{Ml.init(e,t),de.init(e,t)});var B_=_("ZodNanoID",(e,t)=>{Dl.init(e,t),de.init(e,t)});var G_=_("ZodCUID",(e,t)=>{ql.init(e,t),de.init(e,t)});var J_=_("ZodCUID2",(e,t)=>{Ul.init(e,t),de.init(e,t)});var W_=_("ZodULID",(e,t)=>{Ll.init(e,t),de.init(e,t)});var Y_=_("ZodXID",(e,t)=>{Fl.init(e,t),de.init(e,t)});var Q_=_("ZodKSUID",(e,t)=>{Vl.init(e,t),de.init(e,t)});var X_=_("ZodIPv4",(e,t)=>{Jl.init(e,t),de.init(e,t)});var ey=_("ZodIPv6",(e,t)=>{Wl.init(e,t),de.init(e,t)});var ty=_("ZodCIDRv4",(e,t)=>{Yl.init(e,t),de.init(e,t)});var ry=_("ZodCIDRv6",(e,t)=>{Ql.init(e,t),de.init(e,t)});var ny=_("ZodBase64",(e,t)=>{ed.init(e,t),de.init(e,t)});var oy=_("ZodBase64URL",(e,t)=>{td.init(e,t),de.init(e,t)});var sy=_("ZodE164",(e,t)=>{rd.init(e,t),de.init(e,t)});var iy=_("ZodJWT",(e,t)=>{nd.init(e,t),de.init(e,t)});var bo=_("ZodNumber",(e,t)=>{ci.init(e,t),se.init(e,t),e.gt=(n,o)=>e.check(gr(n,o)),e.gte=(n,o)=>e.check(Qe(n,o)),e.min=(n,o)=>e.check(Qe(n,o)),e.lt=(n,o)=>e.check(hr(n,o)),e.lte=(n,o)=>e.check(mt(n,o)),e.max=(n,o)=>e.check(mt(n,o)),e.int=n=>e.check(Rp(n)),e.safe=n=>e.check(Rp(n)),e.positive=n=>e.check(gr(0,n)),e.nonnegative=n=>e.check(Qe(0,n)),e.negative=n=>e.check(hr(0,n)),e.nonpositive=n=>e.check(mt(0,n)),e.multipleOf=(n,o)=>e.check(rn(n,o)),e.step=(n,o)=>e.check(rn(n,o)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function K(e){return np(bo,e)}var ay=_("ZodNumberFormat",(e,t)=>{od.init(e,t),bo.init(e,t)});function Rp(e){return sp(ay,e)}var Ei=_("ZodBoolean",(e,t)=>{sd.init(e,t),se.init(e,t)});function te(e){return ip(Ei,e)}var Ap=_("ZodBigInt",(e,t)=>{id.init(e,t),se.init(e,t),e.gte=(n,o)=>e.check(Qe(n,o)),e.min=(n,o)=>e.check(Qe(n,o)),e.gt=(n,o)=>e.check(gr(n,o)),e.gte=(n,o)=>e.check(Qe(n,o)),e.min=(n,o)=>e.check(Qe(n,o)),e.lt=(n,o)=>e.check(hr(n,o)),e.lte=(n,o)=>e.check(mt(n,o)),e.max=(n,o)=>e.check(mt(n,o)),e.positive=n=>e.check(gr(BigInt(0),n)),e.negative=n=>e.check(hr(BigInt(0),n)),e.nonpositive=n=>e.check(mt(BigInt(0),n)),e.nonnegative=n=>e.check(Qe(BigInt(0),n)),e.multipleOf=(n,o)=>e.check(rn(n,o));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});var cy=_("ZodNull",(e,t)=>{ad.init(e,t),se.init(e,t)});function Np(e){return up(cy,e)}var uy=_("ZodAny",(e,t)=>{cd.init(e,t),se.init(e,t)});function jp(){return lp(uy)}var ly=_("ZodUnknown",(e,t)=>{ud.init(e,t),se.init(e,t)});function pe(){return dp(ly)}var dy=_("ZodNever",(e,t)=>{ld.init(e,t),se.init(e,t)});function py(e){return pp(dy,e)}var Zp=_("ZodDate",(e,t)=>{dd.init(e,t),se.init(e,t),e.min=(n,o)=>e.check(Qe(n,o)),e.max=(n,o)=>e.check(mt(n,o));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});var fy=_("ZodArray",(e,t)=>{pd.init(e,t),se.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(_r(r,n)),e.nonempty=r=>e.check(_r(1,r)),e.max=(r,n)=>e.check(yo(r,n)),e.length=(r,n)=>e.check(vo(r,n)),e.unwrap=()=>e.element});function z(e,t){return mp(fy,e,t)}var Mp=_("ZodObject",(e,t)=>{fd.init(e,t),se.init(e,t),G.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>Ne(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:pe()}),e.loose=()=>e.clone({...e._zod.def,catchall:pe()}),e.strict=()=>e.clone({...e._zod.def,catchall:py()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>G.extend(e,r),e.merge=r=>G.merge(e,r),e.pick=r=>G.pick(e,r),e.omit=r=>G.omit(e,r),e.partial=(...r)=>G.partial(Up,e,r[0]),e.required=(...r)=>G.required(Lp,e,r[0])});function k(e,t){let r={type:"object",get shape(){return G.assignProp(this,"shape",{...e}),this.shape},...G.normalizeParams(t)};return new Mp(r)}function ye(e,t){return new Mp({type:"object",get shape(){return G.assignProp(this,"shape",{...e}),this.shape},catchall:pe(),...G.normalizeParams(t)})}var Dp=_("ZodUnion",(e,t)=>{ui.init(e,t),se.init(e,t),e.options=t.options});function ce(e,t){return new Dp({type:"union",options:e,...G.normalizeParams(t)})}var my=_("ZodDiscriminatedUnion",(e,t)=>{Dp.init(e,t),md.init(e,t)});function Ii(e,t,r){return new my({type:"union",options:t,discriminator:e,...G.normalizeParams(r)})}var hy=_("ZodIntersection",(e,t)=>{hd.init(e,t),se.init(e,t)});function xo(e,t){return new hy({type:"intersection",left:e,right:t})}var gy=_("ZodRecord",(e,t)=>{gd.init(e,t),se.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function ie(e,t,r){return new gy({type:"record",keyType:e,valueType:t,...G.normalizeParams(r)})}var Pi=_("ZodEnum",(e,t)=>{_d.init(e,t),se.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Pi({...t,checks:[],...G.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Pi({...t,checks:[],...G.normalizeParams(o),entries:s})}});function Ne(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Pi({type:"enum",entries:r,...G.normalizeParams(t)})}var _y=_("ZodLiteral",(e,t)=>{yd.init(e,t),se.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function E(e,t){return new _y({type:"literal",values:Array.isArray(e)?e:[e],...G.normalizeParams(t)})}var yy=_("ZodTransform",(e,t)=>{vd.init(e,t),se.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=s=>{if(typeof s=="string")r.issues.push(G.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=e),i.continue??(i.continue=!0),r.issues.push(G.issue(i))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function qp(e){return new yy({type:"transform",transform:e})}var Up=_("ZodOptional",(e,t)=>{wd.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType});function fe(e){return new Up({type:"optional",innerType:e})}var vy=_("ZodNullable",(e,t)=>{$d.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ep(e){return new vy({type:"nullable",innerType:e})}var wy=_("ZodDefault",(e,t)=>{bd.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function $y(e,t){return new wy({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var by=_("ZodPrefault",(e,t)=>{xd.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType});function xy(e,t){return new by({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var Lp=_("ZodNonOptional",(e,t)=>{Sd.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Sy(e,t){return new Lp({type:"nonoptional",innerType:e,...G.normalizeParams(t)})}var zy=_("ZodCatch",(e,t)=>{zd.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function ky(e,t){return new zy({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var Py=_("ZodPipe",(e,t)=>{kd.init(e,t),se.init(e,t),e.in=t.in,e.out=t.out});function Ti(e,t){return new Py({type:"pipe",in:e,out:t})}var Ty=_("ZodReadonly",(e,t)=>{Pd.init(e,t),se.init(e,t)});function Ry(e){return new Ty({type:"readonly",innerType:e})}var Fp=_("ZodCustom",(e,t)=>{Td.init(e,t),se.init(e,t)});function Ey(e){let t=new Pe({check:"custom"});return t._zod.check=e,t}function Vp(e,t){return hp(Fp,e??(()=>!0),t)}function Iy(e,t={}){return gp(Fp,e,t)}function Oy(e){let t=Ey(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(G.issue(n,r.value,t._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(G.issue(o))}},e(r.value,r)));return t}function Oi(e,t){return Ti(qp(e),t)}var Hp={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var So={};Ds(So,{bigint:()=>jy,boolean:()=>Ny,date:()=>Zy,number:()=>Ay,string:()=>Cy});function Cy(e){return Od(Ri,e)}function Ay(e){return op(bo,e)}function Ny(e){return ap(Ei,e)}function jy(e){return cp(Ap,e)}function Zy(e){return fp(Zp,e)}Ue(Rd());var $r="2025-11-25";var Kp=[$r,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],zt="io.modelcontextprotocol/related-task",ko="2.0",ve=Vp(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Bp=ce([p(),K().int()]),Gp=p(),xT=ye({ttl:K().optional(),pollInterval:K().optional()}),Dy=k({ttl:K().optional()}),qy=k({taskId:p()}),Ai=ye({progressToken:Bp.optional(),[zt]:qy.optional()}),Le=k({_meta:Ai.optional()}),sn=Le.extend({task:Dy.optional()}),Jp=e=>sn.safeParse(e).success,$e=k({method:p(),params:Le.loose().optional()}),Fe=k({_meta:Ai.optional()}),Ve=k({method:p(),params:Fe.loose().optional()}),be=ye({_meta:Ai.optional()}),Po=ce([p(),K().int()]),Wp=k({jsonrpc:E(ko),id:Po,...$e.shape}).strict(),an=e=>Wp.safeParse(e).success,Yp=k({jsonrpc:E(ko),...Ve.shape}).strict(),Qp=e=>Yp.safeParse(e).success,Ni=k({jsonrpc:E(ko),id:Po,result:be}).strict(),Ut=e=>Ni.safeParse(e).success;var N;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(N||(N={}));var ji=k({jsonrpc:E(ko),id:Po.optional(),error:k({code:K().int(),message:p(),data:pe().optional()})}).strict();var Xp=e=>ji.safeParse(e).success;var br=ce([Wp,Yp,Ni,ji]),ST=ce([Ni,ji]),Lt=be.strict(),Uy=Fe.extend({requestId:Po.optional(),reason:p().optional()}),To=Ve.extend({method:E("notifications/cancelled"),params:Uy}),Ly=k({src:p(),mimeType:p().optional(),sizes:z(p()).optional(),theme:Ne(["light","dark"]).optional()}),cn=k({icons:z(Ly).optional()}),wr=k({name:p(),title:p().optional()}),ef=wr.extend({...wr.shape,...cn.shape,version:p(),websiteUrl:p().optional(),description:p().optional()}),Fy=xo(k({applyDefaults:te().optional()}),ie(p(),pe())),Vy=Oi(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,xo(k({form:Fy.optional(),url:ve.optional()}),ie(p(),pe()).optional())),Hy=ye({list:ve.optional(),cancel:ve.optional(),requests:ye({sampling:ye({createMessage:ve.optional()}).optional(),elicitation:ye({create:ve.optional()}).optional()}).optional()}),Ky=ye({list:ve.optional(),cancel:ve.optional(),requests:ye({tools:ye({call:ve.optional()}).optional()}).optional()}),By=k({experimental:ie(p(),ve).optional(),sampling:k({context:ve.optional(),tools:ve.optional()}).optional(),elicitation:Vy.optional(),roots:k({listChanged:te().optional()}).optional(),tasks:Hy.optional(),extensions:ie(p(),ve).optional()}),Gy=Le.extend({protocolVersion:p(),capabilities:By,clientInfo:ef}),Jy=$e.extend({method:E("initialize"),params:Gy});var Wy=k({experimental:ie(p(),ve).optional(),logging:ve.optional(),completions:ve.optional(),prompts:k({listChanged:te().optional()}).optional(),resources:k({subscribe:te().optional(),listChanged:te().optional()}).optional(),tools:k({listChanged:te().optional()}).optional(),tasks:Ky.optional(),extensions:ie(p(),ve).optional()}),Zi=be.extend({protocolVersion:p(),capabilities:Wy,serverInfo:ef,instructions:p().optional()}),tf=Ve.extend({method:E("notifications/initialized"),params:Fe.optional()}),rf=e=>tf.safeParse(e).success,Ro=$e.extend({method:E("ping"),params:Le.optional()}),Yy=k({progress:K(),total:fe(K()),message:fe(p())}),Qy=k({...Fe.shape,...Yy.shape,progressToken:Bp}),Eo=Ve.extend({method:E("notifications/progress"),params:Qy}),Xy=Le.extend({cursor:Gp.optional()}),un=$e.extend({params:Xy.optional()}),ln=be.extend({nextCursor:Gp.optional()}),ev=Ne(["working","input_required","completed","failed","cancelled"]),dn=k({taskId:p(),status:ev,ttl:ce([K(),Np()]),createdAt:p(),lastUpdatedAt:p(),pollInterval:fe(K()),statusMessage:fe(p())}),Ft=be.extend({task:dn}),tv=Fe.merge(dn),pn=Ve.extend({method:E("notifications/tasks/status"),params:tv}),Io=$e.extend({method:E("tasks/get"),params:Le.extend({taskId:p()})}),Oo=be.merge(dn),Co=$e.extend({method:E("tasks/result"),params:Le.extend({taskId:p()})}),zT=be.loose(),Ao=un.extend({method:E("tasks/list")}),No=ln.extend({tasks:z(dn)}),jo=$e.extend({method:E("tasks/cancel"),params:Le.extend({taskId:p()})}),nf=be.merge(dn),of=k({uri:p(),mimeType:fe(p()),_meta:ie(p(),pe()).optional()}),sf=of.extend({text:p()}),Mi=p().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),af=of.extend({blob:Mi}),fn=Ne(["user","assistant"]),xr=k({audience:z(fn).optional(),priority:K().min(0).max(1).optional(),lastModified:nn.datetime({offset:!0}).optional()}),cf=k({...wr.shape,...cn.shape,uri:p(),description:fe(p()),mimeType:fe(p()),size:fe(K()),annotations:xr.optional(),_meta:fe(ye({}))}),rv=k({...wr.shape,...cn.shape,uriTemplate:p(),description:fe(p()),mimeType:fe(p()),annotations:xr.optional(),_meta:fe(ye({}))}),nv=un.extend({method:E("resources/list")}),Di=ln.extend({resources:z(cf)}),ov=un.extend({method:E("resources/templates/list")}),qi=ln.extend({resourceTemplates:z(rv)}),Ui=Le.extend({uri:p()}),sv=Ui,iv=$e.extend({method:E("resources/read"),params:sv}),Li=be.extend({contents:z(ce([sf,af]))}),Fi=Ve.extend({method:E("notifications/resources/list_changed"),params:Fe.optional()}),av=Ui,cv=$e.extend({method:E("resources/subscribe"),params:av}),uv=Ui,lv=$e.extend({method:E("resources/unsubscribe"),params:uv}),dv=Fe.extend({uri:p()}),pv=Ve.extend({method:E("notifications/resources/updated"),params:dv}),fv=k({name:p(),description:fe(p()),required:fe(te())}),mv=k({...wr.shape,...cn.shape,description:fe(p()),arguments:fe(z(fv)),_meta:fe(ye({}))}),hv=un.extend({method:E("prompts/list")}),Vi=ln.extend({prompts:z(mv)}),gv=Le.extend({name:p(),arguments:ie(p(),p()).optional()}),_v=$e.extend({method:E("prompts/get"),params:gv}),Hi=k({type:E("text"),text:p(),annotations:xr.optional(),_meta:ie(p(),pe()).optional()}),Ki=k({type:E("image"),data:Mi,mimeType:p(),annotations:xr.optional(),_meta:ie(p(),pe()).optional()}),Bi=k({type:E("audio"),data:Mi,mimeType:p(),annotations:xr.optional(),_meta:ie(p(),pe()).optional()}),yv=k({type:E("tool_use"),name:p(),id:p(),input:ie(p(),pe()),_meta:ie(p(),pe()).optional()}),vv=k({type:E("resource"),resource:ce([sf,af]),annotations:xr.optional(),_meta:ie(p(),pe()).optional()}),wv=cf.extend({type:E("resource_link")}),Gi=ce([Hi,Ki,Bi,wv,vv]),$v=k({role:fn,content:Gi}),Ji=be.extend({description:p().optional(),messages:z($v)}),Wi=Ve.extend({method:E("notifications/prompts/list_changed"),params:Fe.optional()}),bv=k({title:p().optional(),readOnlyHint:te().optional(),destructiveHint:te().optional(),idempotentHint:te().optional(),openWorldHint:te().optional()}),xv=k({taskSupport:Ne(["required","optional","forbidden"]).optional()}),uf=k({...wr.shape,...cn.shape,description:p().optional(),inputSchema:k({type:E("object"),properties:ie(p(),ve).optional(),required:z(p()).optional()}).catchall(pe()),outputSchema:k({type:E("object"),properties:ie(p(),ve).optional(),required:z(p()).optional()}).catchall(pe()).optional(),annotations:bv.optional(),execution:xv.optional(),_meta:ie(p(),pe()).optional()}),Sv=un.extend({method:E("tools/list")}),Yi=ln.extend({tools:z(uf)}),Sr=be.extend({content:z(Gi).default([]),structuredContent:ie(p(),pe()).optional(),isError:te().optional()}),kT=Sr.or(be.extend({toolResult:pe()})),zv=sn.extend({name:p(),arguments:ie(p(),pe()).optional()}),kv=$e.extend({method:E("tools/call"),params:zv}),Qi=Ve.extend({method:E("notifications/tools/list_changed"),params:Fe.optional()}),lf=k({autoRefresh:te().default(!0),debounceMs:K().int().nonnegative().default(300)}),df=Ne(["debug","info","notice","warning","error","critical","alert","emergency"]),Pv=Le.extend({level:df}),Tv=$e.extend({method:E("logging/setLevel"),params:Pv}),Rv=Fe.extend({level:df,logger:p().optional(),data:pe()}),Ev=Ve.extend({method:E("notifications/message"),params:Rv}),Iv=k({name:p().optional()}),Ov=k({hints:z(Iv).optional(),costPriority:K().min(0).max(1).optional(),speedPriority:K().min(0).max(1).optional(),intelligencePriority:K().min(0).max(1).optional()}),Cv=k({mode:Ne(["auto","required","none"]).optional()}),Av=k({type:E("tool_result"),toolUseId:p().describe("The unique identifier for the corresponding tool call."),content:z(Gi).default([]),structuredContent:k({}).loose().optional(),isError:te().optional(),_meta:ie(p(),pe()).optional()}),Nv=Ii("type",[Hi,Ki,Bi]),zo=Ii("type",[Hi,Ki,Bi,yv,Av]),jv=k({role:fn,content:ce([zo,z(zo)]),_meta:ie(p(),pe()).optional()}),Zv=sn.extend({messages:z(jv),modelPreferences:Ov.optional(),systemPrompt:p().optional(),includeContext:Ne(["none","thisServer","allServers"]).optional(),temperature:K().optional(),maxTokens:K().int(),stopSequences:z(p()).optional(),metadata:ve.optional(),tools:z(uf).optional(),toolChoice:Cv.optional()}),Xi=$e.extend({method:E("sampling/createMessage"),params:Zv}),ea=be.extend({model:p(),stopReason:fe(Ne(["endTurn","stopSequence","maxTokens"]).or(p())),role:fn,content:Nv}),ta=be.extend({model:p(),stopReason:fe(Ne(["endTurn","stopSequence","maxTokens","toolUse"]).or(p())),role:fn,content:ce([zo,z(zo)])}),Mv=k({type:E("boolean"),title:p().optional(),description:p().optional(),default:te().optional()}),Dv=k({type:E("string"),title:p().optional(),description:p().optional(),minLength:K().optional(),maxLength:K().optional(),format:Ne(["email","uri","date","date-time"]).optional(),default:p().optional()}),qv=k({type:Ne(["number","integer"]),title:p().optional(),description:p().optional(),minimum:K().optional(),maximum:K().optional(),default:K().optional()}),Uv=k({type:E("string"),title:p().optional(),description:p().optional(),enum:z(p()),default:p().optional()}),Lv=k({type:E("string"),title:p().optional(),description:p().optional(),oneOf:z(k({const:p(),title:p()})),default:p().optional()}),Fv=k({type:E("string"),title:p().optional(),description:p().optional(),enum:z(p()),enumNames:z(p()).optional(),default:p().optional()}),Vv=ce([Uv,Lv]),Hv=k({type:E("array"),title:p().optional(),description:p().optional(),minItems:K().optional(),maxItems:K().optional(),items:k({type:E("string"),enum:z(p())}),default:z(p()).optional()}),Kv=k({type:E("array"),title:p().optional(),description:p().optional(),minItems:K().optional(),maxItems:K().optional(),items:k({anyOf:z(k({const:p(),title:p()}))}),default:z(p()).optional()}),Bv=ce([Hv,Kv]),Gv=ce([Fv,Vv,Bv]),Jv=ce([Gv,Mv,Dv,qv]),Wv=sn.extend({mode:E("form").optional(),message:p(),requestedSchema:k({type:E("object"),properties:ie(p(),Jv),required:z(p()).optional()})}),Yv=sn.extend({mode:E("url"),message:p(),elicitationId:p(),url:p().url()}),Qv=ce([Wv,Yv]),ra=$e.extend({method:E("elicitation/create"),params:Qv}),Xv=Fe.extend({elicitationId:p()}),ew=Ve.extend({method:E("notifications/elicitation/complete"),params:Xv}),na=be.extend({action:Ne(["accept","decline","cancel"]),content:Oi(e=>e===null?void 0:e,ie(p(),ce([p(),K(),te(),z(p())])).optional())}),tw=k({type:E("ref/resource"),uri:p()});var rw=k({type:E("ref/prompt"),name:p()}),nw=Le.extend({ref:ce([rw,tw]),argument:k({name:p(),value:p()}),context:k({arguments:ie(p(),p()).optional()}).optional()}),ow=$e.extend({method:E("completion/complete"),params:nw});var oa=be.extend({completion:ye({values:z(p()).max(100),total:fe(K().int()),hasMore:fe(te())})}),sw=k({uri:p().startsWith("file://"),name:p().optional(),_meta:ie(p(),pe()).optional()}),iw=$e.extend({method:E("roots/list"),params:Le.optional()}),aw=be.extend({roots:z(sw)}),cw=Ve.extend({method:E("notifications/roots/list_changed"),params:Fe.optional()}),PT=ce([Ro,Jy,ow,Tv,_v,hv,nv,ov,iv,cv,lv,kv,Sv,Io,Co,Ao,jo]),TT=ce([To,Eo,tf,cw,pn]),RT=ce([Lt,ea,ta,na,aw,Oo,No,Ft]),ET=ce([Ro,Xi,ra,iw,Io,Co,Ao,jo]),IT=ce([To,Eo,Ev,pv,Fi,Qi,Wi,pn,ew]),OT=ce([Lt,Zi,oa,Ji,Vi,Di,qi,Li,Sr,Yi,Oo,No,Ft]),A=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===N.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Ci(o.elicitations,r)}return new e(t,r,n)}},Ci=class extends A{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(N.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function kt(e){return e==="completed"||e==="failed"||e==="cancelled"}var uw=Symbol("Let zodToJsonSchema decide on which parser to use");var dR=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function sa(e){let r=wo(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=_p(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function ia(e,t){let r=Xe(e,t);if(!r.success)throw r.error;return r.data}var hw=6e4,Zo=class{constructor(t){this._options=t,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(To,r=>{this._oncancel(r)}),this.setNotificationHandler(Eo,r=>{this._onprogress(r)}),this.setRequestHandler(Ro,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Io,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new A(N.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Co,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,m=new A(d.error.code,d.error.message,d.error.data);l(m)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new A(N.InvalidParams,`Task not found: ${s}`);if(!kt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(kt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[zt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Ao,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new A(N.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(jo,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new A(N.InvalidParams,`Task not found: ${r.params.taskId}`);if(kt(o.status))throw new A(N.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new A(N.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof A?o:new A(N.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),A.fromError(N.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){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=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),Ut(s)||Xp(s)?this._onresponse(s):an(s)?this._onrequest(s,i):Qp(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=A.fromError(N.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,s=t.params?._meta?.[zt]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:N.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(t.id,i);let a=Jp(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:t.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,m)=>{if(i.signal.aborted)throw new A(N.ConnectionClosed,"Request was cancelled");let f={...m,relatedRequestId:t.id};s&&!f.relatedTask&&(f.relatedTask={taskId:s});let h=f.relatedTask?.taskId??s;return h&&c&&await c.updateTaskStatus(h,"input_required"),await this.request(l,d,f)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:N.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===i&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Ut(t))n(t);else{let i=new A(t.error.code,t.error.message,t.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(Ut(t)&&t.result&&typeof t.result=="object"){let i=t.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),Ut(t))o(t);else{let i=A.fromError(t.error.code,t.error.message,t.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(i){yield{type:"error",error:i instanceof A?i:new A(N.InternalError,String(i))}}return}let s;try{let i=await this.request(t,Ft,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new A(N.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},kt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new A(N.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new A(N.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof A?i:new A(N.InternalError,String(i))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=x=>{l(x)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(x){d(x);return}n?.signal?.throwIfAborted();let m=this._requestMessageId++,f={...t,jsonrpc:"2.0",id:m};n?.onprogress&&(this._progressHandlers.set(m,n.onprogress),f.params={...t.params,_meta:{...t.params?._meta||{},progressToken:m}}),a&&(f.params={...f.params,task:a}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[zt]:c}});let h=x=>{this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(x)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(T=>this._onerror(new Error(`Failed to send cancellation: ${T}`)));let $=x instanceof A?x:new A(N.RequestTimeout,String(x));l($)};this._responseHandlers.set(m,x=>{if(!n?.signal?.aborted){if(x instanceof Error)return l(x);try{let $=Xe(r,x.result);$.success?u($.data):l($.error)}catch($){l($)}}}),n?.signal?.addEventListener("abort",()=>{h(n?.signal?.reason)});let g=n?.timeout??hw,v=()=>h(A.fromError(N.RequestTimeout,"Request timed out",{timeout:g}));this._setupTimeout(m,g,n?.maxTotalTimeout,v,n?.resetTimeoutOnProgress??!1);let w=c?.taskId;if(w){let x=$=>{let T=this._responseHandlers.get(m);T?T($):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`))};this._requestResolvers.set(m,x),this._enqueueTaskMessage(w,{type:"request",message:f,timestamp:Date.now()}).catch($=>{this._cleanupTimeout(m),l($)})}else this._transport.send(f,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(x=>{this._cleanupTimeout(m),l(x)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Oo,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},No,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},nf,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[zt]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[zt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[zt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=sa(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=ia(t,o);return Promise.resolve(r(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=sa(t);this._notificationHandlers.set(n,o=>{let s=ia(t,o);return Promise.resolve(r(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&an(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new A(N.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(t);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new A(N.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new A(N.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new A(N.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await n.storeTaskResult(o,s,i,r);let a=await n.getTask(o,r);if(a){let c=pn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),kt(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new A(N.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(kt(a.status))throw new A(N.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,i,r);let c=await n.getTask(o,r);if(c){let u=pn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),kt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function pf(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ff(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let i=r[o];pf(i)&&pf(s)?r[o]={...i,...s}:r[o]=s}return r}var og=Pu(Kc(),1),sg=Pu(ng(),1);function vz(){let e=new og.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,sg.default)(e),e}var ys=class{constructor(t){this._ajv=t??vz()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var vs=class{constructor(t){this._client=t}async*callToolStream(t,r=Sr,n){let o=this._client,s={...n,task:n?.task??(o.isToolTask(t.name)?{}:void 0)},i=o.requestStream({method:"tools/call",params:t},r,s),a=o.getToolOutputValidator(t.name);for await(let c of i){if(c.type==="result"&&a){let u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new A(N.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{let l=a(u.structuredContent);if(!l.valid){yield{type:"error",error:new A(N.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof A){yield{type:"error",error:l};return}yield{type:"error",error:new A(N.InvalidParams,`Failed to validate structured content: ${l instanceof Error?l.message:String(l)}`)};return}}yield c}}async getTask(t,r){return this._client.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._client.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._client.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._client.cancelTask({taskId:t},r)}requestStream(t,r,n){return this._client.requestStream(t,r,n)}};function ig(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function ag(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}function ws(e,t){if(!(!e||t===null||typeof t!="object")){if(e.type==="object"&&e.properties&&typeof e.properties=="object"){let r=t,n=e.properties;for(let o of Object.keys(n)){let s=n[o];r[o]===void 0&&Object.prototype.hasOwnProperty.call(s,"default")&&(r[o]=s.default),r[o]!==void 0&&ws(s,r[o])}}if(Array.isArray(e.anyOf))for(let r of e.anyOf)typeof r!="boolean"&&ws(r,t);if(Array.isArray(e.oneOf))for(let r of e.oneOf)typeof r!="boolean"&&ws(r,t)}}function wz(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,r=e.url!==void 0;return{supportsFormMode:t||!t&&!r,supportsUrlMode:r}}var $s=class extends Zo{constructor(t,r){super(r),this._clientInfo=t,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 ys,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(t){t.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",Qi,t.tools,async()=>(await this.listTools()).tools),t.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Wi,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",Fi,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new vs(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=ff(this._capabilities,t)}setRequestHandler(t,r){let o=wo(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(vr(o)){let a=o;s=a._zod?.def?.value??a.value}else{let a=o;s=a._def?.value??a.value}if(typeof s!="string")throw new Error("Schema method literal must be a string");let i=s;if(i==="elicitation/create"){let a=async(c,u)=>{let l=Xe(ra,c);if(!l.success){let x=l.error instanceof Error?l.error.message:String(l.error);throw new A(N.InvalidParams,`Invalid elicitation request: ${x}`)}let{params:d}=l.data;d.mode=d.mode??"form";let{supportsFormMode:m,supportsUrlMode:f}=wz(this._capabilities.elicitation);if(d.mode==="form"&&!m)throw new A(N.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!f)throw new A(N.InvalidParams,"Client does not support URL-mode elicitation requests");let h=await Promise.resolve(r(c,u));if(d.task){let x=Xe(Ft,h);if(!x.success){let $=x.error instanceof Error?x.error.message:String(x.error);throw new A(N.InvalidParams,`Invalid task creation result: ${$}`)}return x.data}let g=Xe(na,h);if(!g.success){let x=g.error instanceof Error?g.error.message:String(g.error);throw new A(N.InvalidParams,`Invalid elicitation result: ${x}`)}let v=g.data,w=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&v.action==="accept"&&v.content&&w&&this._capabilities.elicitation?.form?.applyDefaults)try{ws(w,v.content)}catch{}return v};return super.setRequestHandler(t,a)}if(i==="sampling/createMessage"){let a=async(c,u)=>{let l=Xe(Xi,c);if(!l.success){let v=l.error instanceof Error?l.error.message:String(l.error);throw new A(N.InvalidParams,`Invalid sampling request: ${v}`)}let{params:d}=l.data,m=await Promise.resolve(r(c,u));if(d.task){let v=Xe(Ft,m);if(!v.success){let w=v.error instanceof Error?v.error.message:String(v.error);throw new A(N.InvalidParams,`Invalid task creation result: ${w}`)}return v.data}let h=d.tools||d.toolChoice?ta:ea,g=Xe(h,m);if(!g.success){let v=g.error instanceof Error?g.error.message:String(g.error);throw new A(N.InvalidParams,`Invalid sampling result: ${v}`)}return g.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapability(t,r){if(!this._serverCapabilities?.[t])throw new Error(`Server does not support ${t} (required for ${r})`)}async connect(t,r){if(await super.connect(t),t.sessionId===void 0)try{let n=await this.request({method:"initialize",params:{protocolVersion:$r,capabilities:this._capabilities,clientInfo:this._clientInfo}},Zi,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!Kp.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,t.setProtocolVersion&&t.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(n){throw this.close(),n}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(t){switch(t){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${t})`);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 ${t})`);if(t==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${t})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${t})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${t})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${t})`);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 ${t})`);break;case"ping":break}}assertTaskCapability(t){ig(this._serverCapabilities?.tasks?.requests,t,"Server")}assertTaskHandlerCapability(t){this._capabilities&&ag(this._capabilities.tasks?.requests,t,"Client")}async ping(t){return this.request({method:"ping"},Lt,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},oa,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},Lt,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},Ji,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},Vi,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},Di,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},qi,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},Li,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},Lt,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},Lt,r)}async callTool(t,r=Sr,n){if(this.isToolTaskRequired(t.name))throw new A(N.InvalidRequest,`Tool "${t.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let o=await this.request({method:"tools/call",params:t},r,n),s=this.getToolOutputValidator(t.name);if(s){if(!o.structuredContent&&!o.isError)throw new A(N.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`);if(o.structuredContent)try{let i=s(o.structuredContent);if(!i.valid)throw new A(N.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof A?i:new A(N.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return o}isToolTask(t){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(t):!1}isToolTaskRequired(t){return this._cachedRequiredTaskTools.has(t)}cacheToolMetadata(t){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let r of t){if(r.outputSchema){let o=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,o)}let n=r.execution?.taskSupport;(n==="required"||n==="optional")&&this._cachedKnownTaskTools.add(r.name),n==="required"&&this._cachedRequiredTaskTools.add(r.name)}}getToolOutputValidator(t){return this._cachedToolOutputValidators.get(t)}async listTools(t,r){let n=await this.request({method:"tools/list",params:t},Yi,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,o){let s=lf.safeParse(n);if(!s.success)throw new Error(`Invalid ${t} listChanged options: ${s.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${t} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:a}=s.data,{onChanged:c}=n,u=async()=>{if(!i){c(null,null);return}try{let d=await o();c(null,d)}catch(d){let m=d instanceof Error?d:new Error(String(d));c(m,null)}},l=()=>{if(a){let d=this._listChangedDebounceTimers.get(t);d&&clearTimeout(d);let m=setTimeout(u,a);this._listChangedDebounceTimers.set(t,m)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};function bs(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function cg(e=fetch,t){return t?async(r,n)=>{let o={...t,...n,headers:n?.headers?{...bs(t.headers),...bs(n.headers)}:t.headers};return e(r,o)}:e}var eu;eu=globalThis.crypto?.webcrypto??globalThis.crypto??import("node:crypto").then(e=>e.webcrypto);async function $z(e){return(await eu).getRandomValues(new Uint8Array(e))}async function bz(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length,n="";for(;n.length<e;){let o=await $z(e-n.length);for(let s of o)s<r&&(n+=t[s%t.length])}return n}async function xz(e){return await bz(e)}async function Sz(e){let t=await(await eu).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function tu(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await xz(e),r=await Sz(t);return{code_verifier:t,code_challenge:r}}var ke=Cp().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Hp.custom,message:"URL must be parseable",fatal:!0}),qs}).refine(e=>{let t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),lg=ye({resource:p().url(),authorization_servers:z(ke).optional(),jwks_uri:p().url().optional(),scopes_supported:z(p()).optional(),bearer_methods_supported:z(p()).optional(),resource_signing_alg_values_supported:z(p()).optional(),resource_name:p().optional(),resource_documentation:p().optional(),resource_policy_uri:p().url().optional(),resource_tos_uri:p().url().optional(),tls_client_certificate_bound_access_tokens:te().optional(),authorization_details_types_supported:z(p()).optional(),dpop_signing_alg_values_supported:z(p()).optional(),dpop_bound_access_tokens_required:te().optional()}),ru=ye({issuer:p(),authorization_endpoint:ke,token_endpoint:ke,registration_endpoint:ke.optional(),scopes_supported:z(p()).optional(),response_types_supported:z(p()),response_modes_supported:z(p()).optional(),grant_types_supported:z(p()).optional(),token_endpoint_auth_methods_supported:z(p()).optional(),token_endpoint_auth_signing_alg_values_supported:z(p()).optional(),service_documentation:ke.optional(),revocation_endpoint:ke.optional(),revocation_endpoint_auth_methods_supported:z(p()).optional(),revocation_endpoint_auth_signing_alg_values_supported:z(p()).optional(),introspection_endpoint:p().optional(),introspection_endpoint_auth_methods_supported:z(p()).optional(),introspection_endpoint_auth_signing_alg_values_supported:z(p()).optional(),code_challenge_methods_supported:z(p()).optional(),client_id_metadata_document_supported:te().optional()}),zz=ye({issuer:p(),authorization_endpoint:ke,token_endpoint:ke,userinfo_endpoint:ke.optional(),jwks_uri:ke,registration_endpoint:ke.optional(),scopes_supported:z(p()).optional(),response_types_supported:z(p()),response_modes_supported:z(p()).optional(),grant_types_supported:z(p()).optional(),acr_values_supported:z(p()).optional(),subject_types_supported:z(p()),id_token_signing_alg_values_supported:z(p()),id_token_encryption_alg_values_supported:z(p()).optional(),id_token_encryption_enc_values_supported:z(p()).optional(),userinfo_signing_alg_values_supported:z(p()).optional(),userinfo_encryption_alg_values_supported:z(p()).optional(),userinfo_encryption_enc_values_supported:z(p()).optional(),request_object_signing_alg_values_supported:z(p()).optional(),request_object_encryption_alg_values_supported:z(p()).optional(),request_object_encryption_enc_values_supported:z(p()).optional(),token_endpoint_auth_methods_supported:z(p()).optional(),token_endpoint_auth_signing_alg_values_supported:z(p()).optional(),display_values_supported:z(p()).optional(),claim_types_supported:z(p()).optional(),claims_supported:z(p()).optional(),service_documentation:p().optional(),claims_locales_supported:z(p()).optional(),ui_locales_supported:z(p()).optional(),claims_parameter_supported:te().optional(),request_parameter_supported:te().optional(),request_uri_parameter_supported:te().optional(),require_request_uri_registration:te().optional(),op_policy_uri:ke.optional(),op_tos_uri:ke.optional(),client_id_metadata_document_supported:te().optional()}),dg=k({...zz.shape,...ru.pick({code_challenge_methods_supported:!0}).shape}),pg=k({access_token:p(),id_token:p().optional(),token_type:p(),expires_in:So.number().optional(),scope:p().optional(),refresh_token:p().optional()}).strip(),fg=k({error:p(),error_description:p().optional(),error_uri:p().optional()}),ug=ke.optional().or(E("").transform(()=>{})),kz=k({redirect_uris:z(ke),token_endpoint_auth_method:p().optional(),grant_types:z(p()).optional(),response_types:z(p()).optional(),client_name:p().optional(),client_uri:ke.optional(),logo_uri:ug,scope:p().optional(),contacts:z(p()).optional(),tos_uri:ug,policy_uri:p().optional(),jwks_uri:ke.optional(),jwks:jp().optional(),software_id:p().optional(),software_version:p().optional(),software_statement:p().optional()}).strip(),Pz=k({client_id:p(),client_secret:p().optional(),client_id_issued_at:K().optional(),client_secret_expires_at:K().optional()}).strip(),mg=kz.merge(Pz),Z1=k({error:p(),error_description:p().optional()}).strip(),M1=k({token:p(),token_type_hint:p().optional()}).strip();function hg(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function gg({requestedResource:e,configuredResource:t}){let r=typeof e=="string"?new URL(e):new URL(e.href),n=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==n.origin||r.pathname.length<n.pathname.length)return!1;let o=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return o.startsWith(s)}var ge=class extends Error{constructor(t,r){super(t),this.errorUri=r,this.name=this.constructor.name}toResponseObject(){let t={error:this.errorCode,error_description:this.message};return this.errorUri&&(t.error_uri=this.errorUri),t}get errorCode(){return this.constructor.errorCode}},Vn=class extends ge{};Vn.errorCode="invalid_request";var tr=class extends ge{};tr.errorCode="invalid_client";var rr=class extends ge{};rr.errorCode="invalid_grant";var nr=class extends ge{};nr.errorCode="unauthorized_client";var Hn=class extends ge{};Hn.errorCode="unsupported_grant_type";var Kn=class extends ge{};Kn.errorCode="invalid_scope";var Bn=class extends ge{};Bn.errorCode="access_denied";var wt=class extends ge{};wt.errorCode="server_error";var Gn=class extends ge{};Gn.errorCode="temporarily_unavailable";var Jn=class extends ge{};Jn.errorCode="unsupported_response_type";var Wn=class extends ge{};Wn.errorCode="unsupported_token_type";var Yn=class extends ge{};Yn.errorCode="invalid_token";var Qn=class extends ge{};Qn.errorCode="method_not_allowed";var Xn=class extends ge{};Xn.errorCode="too_many_requests";var or=class extends ge{};or.errorCode="invalid_client_metadata";var eo=class extends ge{};eo.errorCode="insufficient_scope";var to=class extends ge{};to.errorCode="invalid_target";var _g={[Vn.errorCode]:Vn,[tr.errorCode]:tr,[rr.errorCode]:rr,[nr.errorCode]:nr,[Hn.errorCode]:Hn,[Kn.errorCode]:Kn,[Bn.errorCode]:Bn,[wt.errorCode]:wt,[Gn.errorCode]:Gn,[Jn.errorCode]:Jn,[Wn.errorCode]:Wn,[Yn.errorCode]:Yn,[Qn.errorCode]:Qn,[Xn.errorCode]:Xn,[or.errorCode]:or,[eo.errorCode]:eo,[to.errorCode]:to};var $t=class extends Error{constructor(t){super(t??"Unauthorized")}};function Tz(e){return["client_secret_basic","client_secret_post","none"].includes(e)}var nu="code",ou="S256";function Rz(e,t){let r=e.client_secret!==void 0;return"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&Tz(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?r?"client_secret_basic":"none":r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none"}function Ez(e,t,r,n){let{client_id:o,client_secret:s}=t;switch(e){case"client_secret_basic":Iz(o,s,r);return;case"client_secret_post":Oz(o,s,n);return;case"none":Cz(o,n);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function Iz(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");let n=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${n}`)}function Oz(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}function Cz(e,t){t.set("client_id",e)}async function vg(e){let t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{let n=fg.parse(JSON.parse(r)),{error:o,error_description:s,error_uri:i}=n,a=_g[o]||wt;return new a(s||"",i)}catch(n){let o=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${n}. Raw body: ${r}`;return new wt(o)}}async function ro(e,t){try{return await su(e,t)}catch(r){if(r instanceof tr||r instanceof nr)return await e.invalidateCredentials?.("all"),await su(e,t);if(r instanceof rr)return await e.invalidateCredentials?.("tokens"),await su(e,t);throw r}}async function su(e,{serverUrl:t,authorizationCode:r,scope:n,resourceMetadataUrl:o,fetchFn:s}){let i=await e.discoveryState?.(),a,c,u,l=o;if(!l&&i?.resourceMetadataUrl&&(l=new URL(i.resourceMetadataUrl)),i?.authorizationServerUrl){if(c=i.authorizationServerUrl,a=i.resourceMetadata,u=i.authorizationServerMetadata??await $g(c,{fetchFn:s}),!a)try{a=await wg(t,{resourceMetadataUrl:l},s)}catch{}(u!==i.authorizationServerMetadata||a!==i.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}else{let $=await qz(t,{resourceMetadataUrl:l,fetchFn:s});c=$.authorizationServerUrl,u=$.authorizationServerMetadata,a=$.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}let d=await Nz(t,e,a),m=n||a?.scopes_supported?.join(" ")||e.clientMetadata.scope,f=await Promise.resolve(e.clientInformation());if(!f){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let $=u?.client_id_metadata_document_supported===!0,T=e.clientMetadataUrl;if(T&&!Az(T))throw new or(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${T}`);if($&&T)f={client_id:T},await e.saveClientInformation?.(f);else{if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");let S=await Hz(c,{metadata:u,clientMetadata:e.clientMetadata,scope:m,fetchFn:s});await e.saveClientInformation(S),f=S}}let h=!e.redirectUrl;if(r!==void 0||h){let $=await Vz(e,c,{metadata:u,resource:d,authorizationCode:r,fetchFn:s});return await e.saveTokens($),"AUTHORIZED"}let g=await e.tokens();if(g?.refresh_token)try{let $=await Fz(c,{metadata:u,clientInformation:f,refreshToken:g.refresh_token,resource:d,addClientAuthentication:e.addClientAuthentication,fetchFn:s});return await e.saveTokens($),"AUTHORIZED"}catch($){if(!(!($ instanceof ge)||$ instanceof wt))throw $}let v=e.state?await e.state():void 0,{authorizationUrl:w,codeVerifier:x}=await Uz(c,{metadata:u,clientInformation:f,state:v,redirectUrl:e.redirectUrl,scope:m,resource:d});return await e.saveCodeVerifier(x),await e.redirectToAuthorization(w),"REDIRECT"}function Az(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="https:"&&t.pathname!=="/"}catch{return!1}}async function Nz(e,t,r){let n=hg(e);if(t.validateResourceURL)return await t.validateResourceURL(n,r?.resource);if(r){if(!gg({requestedResource:n,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${n} (or origin)`);return new URL(r.resource)}}function au(e){let t=e.headers.get("WWW-Authenticate");if(!t)return{};let[r,n]=t.split(" ");if(r.toLowerCase()!=="bearer"||!n)return{};let o=iu(e,"resource_metadata")||void 0,s;if(o)try{s=new URL(o)}catch{}let i=iu(e,"scope")||void 0,a=iu(e,"error")||void 0;return{resourceMetadataUrl:s,scope:i,error:a}}function iu(e,t){let r=e.headers.get("WWW-Authenticate");if(!r)return null;let n=new RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),o=r.match(n);return o?o[1]||o[2]:null}async function wg(e,t,r=fetch){let n=await Mz(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!n||n.status===404)throw await n?.body?.cancel(),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!n.ok)throw await n.body?.cancel(),new Error(`HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`);return lg.parse(await n.json())}async function cu(e,t,r=fetch){try{return await r(e,{headers:t})}catch(n){if(n instanceof TypeError)return t?cu(e,void 0,r):void 0;throw n}}function jz(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function yg(e,t,r=fetch){return await cu(e,{"MCP-Protocol-Version":t},r)}function Zz(e,t){return!e||e.status>=400&&e.status<500&&t!=="/"}async function Mz(e,t,r,n){let o=new URL(e),s=n?.protocolVersion??$r,i;if(n?.metadataUrl)i=new URL(n.metadataUrl);else{let c=jz(t,o.pathname);i=new URL(c,n?.metadataServerUrl??o),i.search=o.search}let a=await yg(i,s,r);if(!n?.metadataUrl&&Zz(a,o.pathname)){let c=new URL(`/.well-known/${t}`,o);a=await yg(c,s,r)}return a}function Dz(e){let t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",n=[];if(!r)return n.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),n.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),n;let o=t.pathname;return o.endsWith("/")&&(o=o.slice(0,-1)),n.push({url:new URL(`/.well-known/oauth-authorization-server${o}`,t.origin),type:"oauth"}),n.push({url:new URL(`/.well-known/openid-configuration${o}`,t.origin),type:"oidc"}),n.push({url:new URL(`${o}/.well-known/openid-configuration`,t.origin),type:"oidc"}),n}async function $g(e,{fetchFn:t=fetch,protocolVersion:r=$r}={}){let n={"MCP-Protocol-Version":r,Accept:"application/json"},o=Dz(e);for(let{url:s,type:i}of o){let a=await cu(s,n,t);if(a){if(!a.ok){if(await a.body?.cancel(),a.status>=400&&a.status<500)continue;throw new Error(`HTTP ${a.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${s}`)}return i==="oauth"?ru.parse(await a.json()):dg.parse(await a.json())}}}async function qz(e,t){let r,n;try{r=await wg(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),r.authorization_servers&&r.authorization_servers.length>0&&(n=r.authorization_servers[0])}catch{}n||(n=String(new URL("/",e)));let o=await $g(n,{fetchFn:t?.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:o,resourceMetadata:r}}async function Uz(e,{metadata:t,clientInformation:r,redirectUrl:n,scope:o,state:s,resource:i}){let a;if(t){if(a=new URL(t.authorization_endpoint),!t.response_types_supported.includes(nu))throw new Error(`Incompatible auth server: does not support response type ${nu}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(ou))throw new Error(`Incompatible auth server: does not support code challenge method ${ou}`)}else a=new URL("/authorize",e);let c=await tu(),u=c.code_verifier,l=c.code_challenge;return a.searchParams.set("response_type",nu),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",l),a.searchParams.set("code_challenge_method",ou),a.searchParams.set("redirect_uri",String(n)),s&&a.searchParams.set("state",s),o&&a.searchParams.set("scope",o),o?.includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",i.href),{authorizationUrl:a,codeVerifier:u}}function Lz(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function bg(e,{metadata:t,tokenRequestParams:r,clientInformation:n,addClientAuthentication:o,resource:s,fetchFn:i}){let a=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(s&&r.set("resource",s.href),o)await o(c,r,a,t);else if(n){let l=t?.token_endpoint_auth_methods_supported??[],d=Rz(n,l);Ez(d,n,c,r)}let u=await(i??fetch)(a,{method:"POST",headers:c,body:r});if(!u.ok)throw await vg(u);return pg.parse(await u.json())}async function Fz(e,{metadata:t,clientInformation:r,refreshToken:n,resource:o,addClientAuthentication:s,fetchFn:i}){let a=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),c=await bg(e,{metadata:t,tokenRequestParams:a,clientInformation:r,addClientAuthentication:s,resource:o,fetchFn:i});return{refresh_token:n,...c}}async function Vz(e,t,{metadata:r,resource:n,authorizationCode:o,fetchFn:s}={}){let i=e.clientMetadata.scope,a;if(e.prepareTokenRequest&&(a=await e.prepareTokenRequest(i)),!a){if(!o)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");let u=await e.codeVerifier();a=Lz(o,u,e.redirectUrl)}let c=await e.clientInformation();return bg(t,{metadata:r,tokenRequestParams:a,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:s})}async function Hz(e,{metadata:t,clientMetadata:r,scope:n,fetchFn:o}){let s;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");s=new URL(t.registration_endpoint)}else s=new URL("/register",e);let i=await(o??fetch)(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...n!==void 0?{scope:n}:{}})});if(!i.ok)throw await vg(i);return mg.parse(await i.json())}var no=class extends Error{constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}},xg=10,Kz=13,sr=32;function uu(e){}function kg(e){if(typeof e=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=uu,onError:r=uu,onRetry:n=uu,onComment:o,maxBufferSize:s}=e,i=[],a=0,c=!0,u,l="",d=0,m,f=!1;function h(y){if(f)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,y.charCodeAt(0)===239&&y.charCodeAt(1)===187&&y.charCodeAt(2)===191&&(y=y.slice(3))),i.length===0){let J=v(y);J!==""&&(i.push(J),a=J.length),g();return}if(y.indexOf(`
36
- `)===-1&&y.indexOf("\r")===-1){i.push(y),a+=y.length,g();return}i.push(y);let S=i.join("");i.length=0,a=0;let R=v(S);R!==""&&(i.push(R),a=R.length),g()}function g(){s!==void 0&&(a+l.length<=s||(f=!0,i.length=0,a=0,u=void 0,l="",d=0,m=void 0,r(new no(`Buffered data exceeded max buffer size of ${s} characters`,{type:"max-buffer-size-exceeded"}))))}function v(y){let S=0;if(y.indexOf("\r")===-1){let R=y.indexOf(`
37
- `,S);for(;R!==-1;){if(S===R){d>0&&t({id:u,event:m,data:l}),u=void 0,l="",d=0,m=void 0,S=R+1,R=y.indexOf(`
38
- `,S);continue}let J=y.charCodeAt(S);if(Sg(y,S,J)){let W=y.charCodeAt(S+5)===sr?S+6:S+5,me=y.slice(W,R);if(d===0&&y.charCodeAt(R+1)===xg){t({id:u,event:m,data:me}),u=void 0,l="",m=void 0,S=R+2,R=y.indexOf(`
39
- `,S);continue}l=d===0?me:`${l}
40
- ${me}`,d++}else zg(y,S,J)?m=y.slice(y.charCodeAt(S+6)===sr?S+7:S+6,R)||void 0:w(y,S,R);S=R+1,R=y.indexOf(`
41
- `,S)}return y.slice(S)}for(;S<y.length;){let R=y.indexOf("\r",S),J=y.indexOf(`
42
- `,S),W=-1;if(R!==-1&&J!==-1?W=R<J?R:J:R!==-1?R===y.length-1?W=-1:W=R:J!==-1&&(W=J),W===-1)break;w(y,S,W),S=W+1,y.charCodeAt(S-1)===Kz&&y.charCodeAt(S)===xg&&S++}return y.slice(S)}function w(y,S,R){if(S===R){$();return}let J=y.charCodeAt(S);if(Sg(y,S,J)){let Ae=y.charCodeAt(S+5)===sr?S+6:S+5,dr=y.slice(Ae,R);l=d===0?dr:`${l}
43
- ${dr}`,d++;return}if(zg(y,S,J)){m=y.slice(y.charCodeAt(S+6)===sr?S+7:S+6,R)||void 0;return}if(J===105&&y.charCodeAt(S+1)===100&&y.charCodeAt(S+2)===58){let Ae=y.slice(y.charCodeAt(S+3)===sr?S+4:S+3,R);u=Ae.includes("\0")?void 0:Ae;return}if(J===58){if(o){let Ae=y.slice(S,R);o(Ae.slice(y.charCodeAt(S+1)===sr?2:1))}return}let W=y.slice(S,R),me=W.indexOf(":");if(me===-1){x(W,"",W);return}let st=W.slice(0,me),lr=W.charCodeAt(me+1)===sr?2:1,xt=W.slice(me+lr);x(st,xt,W)}function x(y,S,R){switch(y){case"event":m=S||void 0;break;case"data":l=d===0?S:`${l}
44
- ${S}`,d++;break;case"id":u=S.includes("\0")?void 0:S;break;case"retry":/^\d+$/.test(S)?n(parseInt(S,10)):r(new no(`Invalid \`retry\` value: "${S}"`,{type:"invalid-retry",value:S,line:R}));break;default:r(new no(`Unknown field "${y.length>20?`${y.slice(0,20)}\u2026`:y}"`,{type:"unknown-field",field:y,value:S,line:R}));break}}function $(){d>0&&t({id:u,event:m,data:l}),u=void 0,l="",d=0,m=void 0}function T(y={}){if(y.consume&&i.length>0){let S=i.join("");w(S,0,S.length)}c=!0,u=void 0,l="",d=0,m=void 0,i.length=0,a=0,f=!1}return{feed:h,reset:T}}function Sg(e,t,r){return r===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function zg(e,t,r){return r===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var xs=class extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:o}={}){let s;super({start(i){s=kg({onEvent:a=>{i.enqueue(a)},onError(a){typeof t=="function"&&t(a),(t==="terminate"||a.type==="max-buffer-size-exceeded")&&i.error(a)},onRetry:r,onComment:n,maxBufferSize:o})},transform(i){s.feed(i)}})}};var Bz={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},Nt=class extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}},Fr=class{constructor(t,r){this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=cg(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??Bz}async _authThenStart(){if(!this._authProvider)throw new $t("No auth provider");let t;try{t=await ro(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(t!=="AUTHORIZED")throw new $t;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let t={};if(this._authProvider){let n=await this._authProvider.tokens();n&&(t.Authorization=`Bearer ${n.access_token}`)}this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);let r=bs(this._requestInit?.headers);return new Headers({...t,...r})}async _startOrAuthSse(t){let{resumptionToken:r}=t;try{let n=await this._commonHeaders();n.set("Accept","text/event-stream"),r&&n.set("last-event-id",r);let o=await(this._fetch??fetch)(this._url,{method:"GET",headers:n,signal:this._abortController?.signal});if(!o.ok){if(await o.body?.cancel(),o.status===401&&this._authProvider)return await this._authThenStart();if(o.status===405)return;throw new Nt(o.status,`Failed to open SSE stream: ${o.statusText}`)}this._handleSseStream(o.body,t,!0)}catch(n){throw this.onerror?.(n),n}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,o=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,t),o)}_scheduleReconnection(t,r=0){let n=this._reconnectionOptions.maxRetries;if(r>=n){this.onerror?.(new Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let o=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(s=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(t,r+1)})},o)}_handleSseStream(t,r,n){if(!t)return;let{onresumptiontoken:o,replayMessageId:s}=r,i,a=!1,c=!1;(async()=>{try{let l=t.pipeThrough(new TextDecoderStream).pipeThrough(new xs({onRetry:f=>{this._serverRetryMs=f}})).getReader();for(;;){let{value:f,done:h}=await l.read();if(h)break;if(f.id&&(i=f.id,a=!0,o?.(f.id)),!!f.data&&(!f.event||f.event==="message"))try{let g=br.parse(JSON.parse(f.data));Ut(g)&&(c=!0,s!==void 0&&(g.id=s)),this.onmessage?.(g)}catch(g){this.onerror?.(g)}}(n||a)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:s},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(n||a)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:s},0)}catch(f){this.onerror?.(new Error(`Failed to reconnect: ${f instanceof Error?f.message:String(f)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new $t("No auth provider");if(await ro(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new $t("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(t,r){try{let{resumptionToken:n,onresumptiontoken:o}=r||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:an(t)?t.id:void 0}).catch(m=>this.onerror?.(m));return}let s=await this._commonHeaders();s.set("content-type","application/json"),s.set("accept","application/json, text/event-stream");let i={...this._requestInit,method:"POST",headers:s,body:JSON.stringify(t),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._url,i),c=a.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!a.ok){let m=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Nt(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:f,scope:h}=au(a);if(this._resourceMetadataUrl=f,this._scope=h,await ro(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new $t;return this._hasCompletedAuthFlow=!0,this.send(t)}if(a.status===403&&this._authProvider){let{resourceMetadataUrl:f,scope:h,error:g}=au(a);if(g==="insufficient_scope"){let v=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===v)throw new Nt(403,"Server returned 403 after trying upscoping");if(h&&(this._scope=h),f&&(this._resourceMetadataUrl=f),this._lastUpscopingHeader=v??void 0,await ro(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new $t;return this.send(t)}}throw new Nt(a.status,`Error POSTing to endpoint: ${m}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),rf(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(m=>this.onerror?.(m));return}let l=(Array.isArray(t)?t:[t]).filter(m=>"method"in m&&"id"in m&&m.id!==void 0).length>0,d=a.headers.get("content-type");if(l)if(d?.includes("text/event-stream"))this._handleSseStream(a.body,{onresumptiontoken:o},!1);else if(d?.includes("application/json")){let m=await a.json(),f=Array.isArray(m)?m.map(h=>br.parse(h)):[br.parse(m)];for(let h of f)this.onmessage?.(h)}else throw await a.body?.cancel(),new Nt(-1,`Unexpected content type: ${d}`);else await a.body?.cancel()}catch(n){throw this.onerror?.(n),n}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let t=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:t,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,r);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new Nt(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(t){throw this.onerror?.(t),t}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,r){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:r?.onresumptiontoken})}};import*as Ie from"node:fs";import{randomBytes as Gz}from"node:crypto";import{homedir as Tg}from"node:os";import{resolve as zs,join as lu,dirname as du,basename as Jz}from"node:path";var oo=["owner","shared","open"],Vr={brokerUrl:"wss://broker1.ours.network",port:3050,stateDir:zs(Tg(),".ours"),gcIntervalMs:36e5,autoStart:!1,apiVisibility:"owner"};function ks(){return process.env.OURS_CONFIG??lu(Tg(),".ours","config.json")}function Wz(){let e;try{e=Ie.readFileSync(ks(),"utf8")}catch{return{}}let t;try{t=JSON.parse(e)}catch{return{}}let r={};if(typeof t.brokerUrl=="string"&&(r.brokerUrl=t.brokerUrl),typeof t.port=="number"&&Number.isFinite(t.port)&&(r.port=t.port),typeof t.stateDir=="string"&&(r.stateDir=zs(t.stateDir)),typeof t.gcIntervalMs=="number"&&Number.isFinite(t.gcIntervalMs)&&(r.gcIntervalMs=t.gcIntervalMs),typeof t.autoStart=="boolean"&&(r.autoStart=t.autoStart),typeof t.apiVisibility=="string"&&oo.includes(t.apiVisibility)&&(r.apiVisibility=t.apiVisibility),typeof t.apiToken=="string"&&t.apiToken.trim()&&(r.apiToken=t.apiToken.trim()),t.stt&&typeof t.stt=="object"){let n=t.stt,o={};typeof n.provider=="string"&&(o.provider=n.provider),typeof n.apiKey=="string"&&(o.apiKey=n.apiKey),typeof n.model=="string"&&(o.model=n.model),typeof n.baseUrl=="string"&&(o.baseUrl=n.baseUrl),typeof n.language=="string"&&(o.language=n.language),typeof n.maxBytes=="number"&&Number.isFinite(n.maxBytes)&&(o.maxBytes=n.maxBytes),typeof n.timeoutMs=="number"&&Number.isFinite(n.timeoutMs)&&(o.timeoutMs=n.timeoutMs),n.custom&&typeof n.custom=="object"&&(o.custom=n.custom),r.stt=o}return r}function Yz(){let e=process.env.OURS_API_VISIBILITY?.trim().toLowerCase();return e&&oo.includes(e)?e:void 0}function Qz(e){let t=process.env[e];if(t!==void 0)return t==="1"||t.toLowerCase()==="true"}function Pg(e){let t=process.env[e];if(t===void 0)return;let r=parseInt(t,10);return Number.isNaN(r)?void 0:r}function pu(){let e=Wz();return{brokerUrl:process.env.OURS_BROKER_URL??e.brokerUrl??Vr.brokerUrl,port:Pg("OURS_PORT")??e.port??Vr.port,stateDir:zs(process.env.OURS_STATE_DIR??e.stateDir??Vr.stateDir),gcIntervalMs:Pg("OURS_GC_INTERVAL_MS")??e.gcIntervalMs??Vr.gcIntervalMs,autoStart:Qz("OURS_AUTOSTART")??e.autoStart??Vr.autoStart,apiVisibility:Yz()??e.apiVisibility??Vr.apiVisibility,apiToken:process.env.OURS_API_TOKEN?.trim()||e.apiToken,stt:Xz(e.stt)}}function Xz(e){let t={};process.env.OURS_STT_PROVIDER?.trim()&&(t.provider=process.env.OURS_STT_PROVIDER.trim()),process.env.OURS_STT_API_KEY?.trim()&&(t.apiKey=process.env.OURS_STT_API_KEY.trim()),process.env.OURS_STT_MODEL?.trim()&&(t.model=process.env.OURS_STT_MODEL.trim()),process.env.OURS_STT_BASE_URL?.trim()&&(t.baseUrl=process.env.OURS_STT_BASE_URL.trim()),process.env.OURS_STT_LANGUAGE?.trim()&&(t.language=process.env.OURS_STT_LANGUAGE.trim());let r={...e??{},...t};return Object.keys(r).length?r:void 0}var ek="daemon-token";function tk(e){return lu(e.stateDir,ek)}function Rg(e,t={}){let r=process.env.OURS_API_TOKEN?.trim();if(r)return{token:r,source:"env"};let n=e.apiToken?.trim();if(n)return{token:n,source:"config"};let o=tk(e);try{let i=Ie.readFileSync(o,"utf8").trim();if(i)return{token:i,source:"file"}}catch{}if(!t.generate)return null;let s=Gz(32).toString("hex");try{Ie.mkdirSync(du(o),{recursive:!0}),Ie.writeFileSync(o,s+`
45
- `,{mode:384}),Ie.chmodSync(o,384)}catch{}return{token:s,source:"generated"}}function Eg(e){let t=ks();Ie.mkdirSync(du(t),{recursive:!0}),Ie.writeFileSync(t,JSON.stringify(e,null,2)+`
46
- `,{mode:384});try{Ie.chmodSync(t,384)}catch{}return t}var Ss=".ours-identity";function Ps(e){if(!e.name.trim())throw new Error("identity name must not be empty");let t={identity:e.name.trim()};return e.force&&(t.force=!0),t.expose_local=e.exposeLocal??!0,t.local_auto_accept=e.localAutoAccept??!0,t}function fu(e){let t=zs(e);return Jz(t)===Ss?t:lu(t,Ss)}function Ig(e,t,r=!1){let n=Ps(t),o=fu(e);if(!r&&Ie.existsSync(o))throw new Error(`${o} already exists \u2014 pass overwrite to replace it`);return Ie.mkdirSync(du(o),{recursive:!0}),Ie.writeFileSync(o,JSON.stringify(n,null,2)+`
34
+ path: iss.path ? [${Dt(S)}, ...iss.path] : [${Dt(S)}]
35
+ })));`),f.write(`newResult[${Dt(S)}] = ${b}.value`)}f.write("payload.value = newResult;"),f.write("return payload;");let $=f.compile();return(S,b)=>$(d,S,b)},o,s=fr,i=!ao.jitless,c=i&&Ks.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??(u=r.value);let m=d.value;if(!s(m))return d.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),d;let h=[];if(i&&c&&f?.async===!1&&f.jitless!==!0)o||(o=n(t.shape)),d=o(d,f);else{d.value={};let b=u.shape;for(let T of u.keys){let y=b[T],x=y._zod.run({value:m[T],issues:[]},f),R=y._zod.optin==="optional"&&y._zod.optout==="optional";x instanceof Promise?h.push(x.then(G=>R?Pl(G,d,T,m):go(G,d,T))):R?Pl(x,d,T,m):go(x,d,T)}}if(!l)return h.length?Promise.all(h).then(()=>d):d;let g=[],v=u.keySet,$=l._zod,S=$.def.type;for(let b of Object.keys(m)){if(v.has(b))continue;if(S==="never"){g.push(b);continue}let T=$.run({value:m[b],issues:[]},f);T instanceof Promise?h.push(T.then(y=>go(y,d,b))):go(T,d,b)}return g.length&&d.issues.push({code:"unrecognized_keys",keys:g,input:m,inst:e}),h.length?Promise.all(h).then(()=>d):d}});function Tl(e,t,r,n){for(let o of e)if(o.issues.length===0)return t.value=o.value,t;return t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(o=>o.issues.map(s=>Qe(s,n,Le())))}),t}var ui=_("$ZodUnion",(e,t)=>{X.init(e,t),oe(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),oe(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),oe(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),oe(e._zod,"pattern",()=>{if(t.options.every(r=>r._zod.pattern)){let r=t.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>Qr(n.source)).join("|")})$`)}}),e._zod.parse=(r,n)=>{let o=!1,s=[];for(let i of t.options){let a=i._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)s.push(a),o=!0;else{if(a.issues.length===0)return a;s.push(a)}}return o?Promise.all(s).then(i=>Tl(i,r,e,n)):Tl(s,r,e,n)}}),hd=_("$ZodDiscriminatedUnion",(e,t)=>{ui.init(e,t);let r=e._zod.parse;oe(e._zod,"propValues",()=>{let o={};for(let s of t.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(let l of c)o[a].add(l)}}return o});let n=Wr(()=>{let o=t.options,s=new Map;for(let i of o){let a=i._zod.propValues[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});e._zod.parse=(o,s)=>{let i=o.value;if(!fr(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=n.value.get(i?.[t.discriminator]);return a?a._zod.run(o,s):t.unionFallback?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[t.discriminator],inst:e}),o)}}),gd=_("$ZodIntersection",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,l])=>Rl(r,c,l)):Rl(r,s,i)}});function ai(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(mr(e)&&mr(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};for(let s of n){let i=ai(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=ai(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Rl(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),Ut(e))return e;let n=ai(t.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return e.value=n.data,e}var _d=_("$ZodRecord",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!mr(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;let s=[];if(t.keyType._zod.values){let i=t.keyType._zod.values;r.value={};for(let c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){let l=t.valueType._zod.run({value:o[c],issues:[]},n);l instanceof Promise?s.push(l.then(u=>{u.issues.length&&r.issues.push(...it(c,u.issues)),r.value[c]=u.value})):(l.issues.length&&r.issues.push(...it(c,l.issues)),r.value[c]=l.value)}let a;for(let c in o)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:a})}else{r.value={};for(let i of Reflect.ownKeys(o)){if(i==="__proto__")continue;let a=t.keyType._zod.run({value:i,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(l=>Qe(l,n,Le())),input:i,path:[i],inst:e}),r.value[a.value]=a.value;continue}let c=t.valueType._zod.run({value:o[i],issues:[]},n);c instanceof Promise?s.push(c.then(l=>{l.issues.length&&r.issues.push(...it(i,l.issues)),r.value[a.value]=l.value})):(c.issues.length&&r.issues.push(...it(i,c.issues)),r.value[a.value]=c.value)}}return s.length?Promise.all(s).then(()=>r):r}});var yd=_("$ZodEnum",(e,t)=>{X.init(e,t);let r=Fs(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>Gs.has(typeof n)).map(n=>typeof n=="string"?zt(n):n.toString()).join("|")})$`),e._zod.parse=(n,o)=>{let s=n.value;return e._zod.values.has(s)||n.issues.push({code:"invalid_value",values:r,input:s,inst:e}),n}}),vd=_("$ZodLiteral",(e,t)=>{X.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?zt(r):r?r.toString():String(r)).join("|")})$`),e._zod.parse=(r,n)=>{let o=r.value;return e._zod.values.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}});var wd=_("$ZodTransform",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new ft;return r.value=o,r}}),$d=_("$ZodOptional",(e,t)=>{X.init(e,t),e._zod.optin="optional",e._zod.optout="optional",oe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),oe(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Qr(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>t.innerType._zod.optin==="optional"?t.innerType._zod.run(r,n):r.value===void 0?r:t.innerType._zod.run(r,n)}),bd=_("$ZodNullable",(e,t)=>{X.init(e,t),oe(e._zod,"optin",()=>t.innerType._zod.optin),oe(e._zod,"optout",()=>t.innerType._zod.optout),oe(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Qr(r.source)}|null)$`):void 0}),oe(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Sd=_("$ZodDefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>El(s,t)):El(o,t)}});function El(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var xd=_("$ZodPrefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>(r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),zd=_("$ZodNonOptional",(e,t)=>{X.init(e,t),oe(e._zod,"values",()=>{let r=t.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Il(s,e)):Il(o,e)}});function Il(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}var kd=_("$ZodCatch",(e,t)=>{X.init(e,t),e._zod.optin="optional",oe(e._zod,"optout",()=>t.innerType._zod.optout),oe(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=t.catchValue({...r,error:{issues:s.issues.map(i=>Qe(i,n,Le()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(s=>Qe(s,n,Le()))},input:r.value}),r.issues=[]),r)}});var Pd=_("$ZodPipe",(e,t)=>{X.init(e,t),oe(e._zod,"values",()=>t.in._zod.values),oe(e._zod,"optin",()=>t.in._zod.optin),oe(e._zod,"optout",()=>t.out._zod.optout),e._zod.parse=(r,n)=>{let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Ol(s,t,n)):Ol(o,t,n)}});function Ol(e,t,r){return Ut(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}var Td=_("$ZodReadonly",(e,t)=>{X.init(e,t),oe(e._zod,"propValues",()=>t.innerType._zod.propValues),oe(e._zod,"values",()=>t.innerType._zod.values),oe(e._zod,"optin",()=>t.innerType._zod.optin),oe(e._zod,"optout",()=>t.innerType._zod.optout),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Al):Al(o)}});function Al(e){return e.value=Object.freeze(e.value),e}var Rd=_("$ZodCustom",(e,t)=>{Pe.init(e,t),X.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Cl(s,r,n,e));Cl(o,r,n,e)}});function Cl(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Ys(o))}}var j_=e=>{let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},M_=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(n){return e[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${j_(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${lo(n.values[0])}`:`Invalid option: expected one of ${co(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",s=t(n.origin);return s?`Too big: expected ${n.origin??"value"} to have ${o}${n.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",s=t(n.origin);return s?`Too small: expected ${n.origin} to have ${o}${n.minimum.toString()} ${s.unit}`:`Too small: expected ${n.origin} to be ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${co(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function Ed(){return{localeError:M_()}}var Z_=Symbol("ZodOutput"),D_=Symbol("ZodInput"),li=class{constructor(){this._map=new Map,this._idmap=new Map}add(t,...r){let n=r[0];if(this._map.set(t,n),n&&typeof n=="object"&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,t)}return this}clear(){return this._map=new Map,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};return delete n.id,{...n,...this._map.get(t)}}return this._map.get(t)}has(t){return this._map.has(t)}};function Id(){return new li}var hr=Id();function Od(e,t){return new e({type:"string",...A(t)})}function Ad(e,t){return new e({type:"string",coerce:!0,...A(t)})}function Cd(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...A(t)})}function di(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...A(t)})}function Nd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...A(t)})}function jd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...A(t)})}function Md(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...A(t)})}function Zd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...A(t)})}function pi(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...A(t)})}function Dd(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...A(t)})}function Ud(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...A(t)})}function qd(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...A(t)})}function Ld(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...A(t)})}function Fd(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...A(t)})}function Vd(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...A(t)})}function Hd(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...A(t)})}function Bd(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...A(t)})}function Kd(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...A(t)})}function Gd(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...A(t)})}function Jd(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...A(t)})}function Wd(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...A(t)})}function Yd(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...A(t)})}function Qd(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...A(t)})}function Xd(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...A(t)})}function ep(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...A(t)})}function tp(e,t){return new e({type:"string",format:"date",check:"string_format",...A(t)})}function rp(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...A(t)})}function np(e,t){return new e({type:"string",format:"duration",check:"string_format",...A(t)})}function op(e,t){return new e({type:"number",checks:[],...A(t)})}function sp(e,t){return new e({type:"number",coerce:!0,checks:[],...A(t)})}function ip(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...A(t)})}function ap(e,t){return new e({type:"boolean",...A(t)})}function cp(e,t){return new e({type:"boolean",coerce:!0,...A(t)})}function up(e,t){return new e({type:"bigint",coerce:!0,...A(t)})}function lp(e,t){return new e({type:"null",...A(t)})}function dp(e){return new e({type:"any"})}function pp(e){return new e({type:"unknown"})}function fp(e,t){return new e({type:"never",...A(t)})}function mp(e,t){return new e({type:"date",coerce:!0,...A(t)})}function gr(e,t){return new si({check:"less_than",...A(t),value:e,inclusive:!1})}function mt(e,t){return new si({check:"less_than",...A(t),value:e,inclusive:!0})}function _r(e,t){return new ii({check:"greater_than",...A(t),value:e,inclusive:!1})}function Xe(e,t){return new ii({check:"greater_than",...A(t),value:e,inclusive:!0})}function rn(e,t){return new pl({check:"multiple_of",...A(t),value:e})}function yo(e,t){return new ml({check:"max_length",...A(t),maximum:e})}function yr(e,t){return new hl({check:"min_length",...A(t),minimum:e})}function vo(e,t){return new gl({check:"length_equals",...A(t),length:e})}function fi(e,t){return new _l({check:"string_format",format:"regex",...A(t),pattern:e})}function mi(e){return new yl({check:"string_format",format:"lowercase",...A(e)})}function hi(e){return new vl({check:"string_format",format:"uppercase",...A(e)})}function gi(e,t){return new wl({check:"string_format",format:"includes",...A(t),includes:e})}function _i(e,t){return new $l({check:"string_format",format:"starts_with",...A(t),prefix:e})}function yi(e,t){return new bl({check:"string_format",format:"ends_with",...A(t),suffix:e})}function qt(e){return new Sl({check:"overwrite",tx:e})}function vi(e){return qt(t=>t.normalize(e))}function wi(){return qt(e=>e.trim())}function $i(){return qt(e=>e.toLowerCase())}function bi(){return qt(e=>e.toUpperCase())}function hp(e,t,r){return new e({type:"array",element:t,...A(r)})}function gp(e,t,r){let n=A(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function _p(e,t,r){return new e({type:"custom",check:"custom",fn:t,...A(r)})}function wr(e){return!!e._zod}function et(e,t){return wr(e)?en(e,t):e.safeParse(t)}function wo(e){if(!e)return;let t;if(wr(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function yp(e){if(wr(e)){let s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=e.value;if(n!==void 0)return n}var nn={};Ds(nn,{ZodISODate:()=>wp,ZodISODateTime:()=>vp,ZodISODuration:()=>bp,ZodISOTime:()=>$p,date:()=>xi,datetime:()=>Si,duration:()=>ki,time:()=>zi});var vp=_("ZodISODateTime",(e,t)=>{Bl.init(e,t),de.init(e,t)});function Si(e){return ep(vp,e)}var wp=_("ZodISODate",(e,t)=>{Kl.init(e,t),de.init(e,t)});function xi(e){return tp(wp,e)}var $p=_("ZodISOTime",(e,t)=>{Gl.init(e,t),de.init(e,t)});function zi(e){return rp($p,e)}var bp=_("ZodISODuration",(e,t)=>{Jl.init(e,t),de.init(e,t)});function ki(e){return np(bp,e)}var xp=(e,t)=>{po.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>ei(e,r)},flatten:{value:r=>Xs(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},OP=_("ZodError",xp),on=_("ZodError",xp,{Parent:Error});var zp=Au(on),kp=Cu(on),Pp=ti(on),Tp=ri(on);var se=_("ZodType",(e,t)=>(X.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>Ye(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>zp(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Pp(e,r,n),e.parseAsync=async(r,n)=>kp(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Tp(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(Ay(r,n)),e.superRefine=r=>e.check(Cy(r)),e.overwrite=r=>e.check(qt(r)),e.optional=()=>fe(e),e.nullable=()=>Ip(e),e.nullish=()=>fe(Ip(e)),e.nonoptional=r=>ky(e,r),e.array=()=>z(e),e.or=r=>ce([e,r]),e.and=r=>So(e,r),e.transform=r=>Ti(e,qp(r)),e.default=r=>Sy(e,r),e.prefault=r=>zy(e,r),e.catch=r=>Ty(e,r),e.pipe=r=>Ti(e,r),e.readonly=()=>Iy(e),e.describe=r=>{let n=e.clone();return hr.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return hr.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return hr.get(e);let n=e.clone();return hr.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Op=_("_ZodString",(e,t)=>{_o.init(e,t),se.init(e,t);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...n)=>e.check(fi(...n)),e.includes=(...n)=>e.check(gi(...n)),e.startsWith=(...n)=>e.check(_i(...n)),e.endsWith=(...n)=>e.check(yi(...n)),e.min=(...n)=>e.check(yr(...n)),e.max=(...n)=>e.check(yo(...n)),e.length=(...n)=>e.check(vo(...n)),e.nonempty=(...n)=>e.check(yr(1,...n)),e.lowercase=n=>e.check(mi(n)),e.uppercase=n=>e.check(hi(n)),e.trim=()=>e.check(wi()),e.normalize=(...n)=>e.check(vi(...n)),e.toLowerCase=()=>e.check($i()),e.toUpperCase=()=>e.check(bi())}),Ri=_("ZodString",(e,t)=>{_o.init(e,t),Op.init(e,t),e.email=r=>e.check(Cd(K_,r)),e.url=r=>e.check(pi(Ap,r)),e.jwt=r=>e.check(Xd(cy,r)),e.emoji=r=>e.check(Dd(G_,r)),e.guid=r=>e.check(di(Rp,r)),e.uuid=r=>e.check(Nd($o,r)),e.uuidv4=r=>e.check(jd($o,r)),e.uuidv6=r=>e.check(Md($o,r)),e.uuidv7=r=>e.check(Zd($o,r)),e.nanoid=r=>e.check(Ud(J_,r)),e.guid=r=>e.check(di(Rp,r)),e.cuid=r=>e.check(qd(W_,r)),e.cuid2=r=>e.check(Ld(Y_,r)),e.ulid=r=>e.check(Fd(Q_,r)),e.base64=r=>e.check(Wd(sy,r)),e.base64url=r=>e.check(Yd(iy,r)),e.xid=r=>e.check(Vd(X_,r)),e.ksuid=r=>e.check(Hd(ey,r)),e.ipv4=r=>e.check(Bd(ty,r)),e.ipv6=r=>e.check(Kd(ry,r)),e.cidrv4=r=>e.check(Gd(ny,r)),e.cidrv6=r=>e.check(Jd(oy,r)),e.e164=r=>e.check(Qd(ay,r)),e.datetime=r=>e.check(Si(r)),e.date=r=>e.check(xi(r)),e.time=r=>e.check(zi(r)),e.duration=r=>e.check(ki(r))});function p(e){return Od(Ri,e)}var de=_("ZodStringFormat",(e,t)=>{ae.init(e,t),Op.init(e,t)}),K_=_("ZodEmail",(e,t)=>{Ml.init(e,t),de.init(e,t)});var Rp=_("ZodGUID",(e,t)=>{Nl.init(e,t),de.init(e,t)});var $o=_("ZodUUID",(e,t)=>{jl.init(e,t),de.init(e,t)});var Ap=_("ZodURL",(e,t)=>{Zl.init(e,t),de.init(e,t)});function Cp(e){return pi(Ap,e)}var G_=_("ZodEmoji",(e,t)=>{Dl.init(e,t),de.init(e,t)});var J_=_("ZodNanoID",(e,t)=>{Ul.init(e,t),de.init(e,t)});var W_=_("ZodCUID",(e,t)=>{ql.init(e,t),de.init(e,t)});var Y_=_("ZodCUID2",(e,t)=>{Ll.init(e,t),de.init(e,t)});var Q_=_("ZodULID",(e,t)=>{Fl.init(e,t),de.init(e,t)});var X_=_("ZodXID",(e,t)=>{Vl.init(e,t),de.init(e,t)});var ey=_("ZodKSUID",(e,t)=>{Hl.init(e,t),de.init(e,t)});var ty=_("ZodIPv4",(e,t)=>{Wl.init(e,t),de.init(e,t)});var ry=_("ZodIPv6",(e,t)=>{Yl.init(e,t),de.init(e,t)});var ny=_("ZodCIDRv4",(e,t)=>{Ql.init(e,t),de.init(e,t)});var oy=_("ZodCIDRv6",(e,t)=>{Xl.init(e,t),de.init(e,t)});var sy=_("ZodBase64",(e,t)=>{td.init(e,t),de.init(e,t)});var iy=_("ZodBase64URL",(e,t)=>{rd.init(e,t),de.init(e,t)});var ay=_("ZodE164",(e,t)=>{nd.init(e,t),de.init(e,t)});var cy=_("ZodJWT",(e,t)=>{od.init(e,t),de.init(e,t)});var bo=_("ZodNumber",(e,t)=>{ci.init(e,t),se.init(e,t),e.gt=(n,o)=>e.check(_r(n,o)),e.gte=(n,o)=>e.check(Xe(n,o)),e.min=(n,o)=>e.check(Xe(n,o)),e.lt=(n,o)=>e.check(gr(n,o)),e.lte=(n,o)=>e.check(mt(n,o)),e.max=(n,o)=>e.check(mt(n,o)),e.int=n=>e.check(Ep(n)),e.safe=n=>e.check(Ep(n)),e.positive=n=>e.check(_r(0,n)),e.nonnegative=n=>e.check(Xe(0,n)),e.negative=n=>e.check(gr(0,n)),e.nonpositive=n=>e.check(mt(0,n)),e.multipleOf=(n,o)=>e.check(rn(n,o)),e.step=(n,o)=>e.check(rn(n,o)),e.finite=()=>e;let r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function B(e){return op(bo,e)}var uy=_("ZodNumberFormat",(e,t)=>{sd.init(e,t),bo.init(e,t)});function Ep(e){return ip(uy,e)}var Ei=_("ZodBoolean",(e,t)=>{id.init(e,t),se.init(e,t)});function te(e){return ap(Ei,e)}var Np=_("ZodBigInt",(e,t)=>{ad.init(e,t),se.init(e,t),e.gte=(n,o)=>e.check(Xe(n,o)),e.min=(n,o)=>e.check(Xe(n,o)),e.gt=(n,o)=>e.check(_r(n,o)),e.gte=(n,o)=>e.check(Xe(n,o)),e.min=(n,o)=>e.check(Xe(n,o)),e.lt=(n,o)=>e.check(gr(n,o)),e.lte=(n,o)=>e.check(mt(n,o)),e.max=(n,o)=>e.check(mt(n,o)),e.positive=n=>e.check(_r(BigInt(0),n)),e.negative=n=>e.check(gr(BigInt(0),n)),e.nonpositive=n=>e.check(mt(BigInt(0),n)),e.nonnegative=n=>e.check(Xe(BigInt(0),n)),e.multipleOf=(n,o)=>e.check(rn(n,o));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});var ly=_("ZodNull",(e,t)=>{cd.init(e,t),se.init(e,t)});function jp(e){return lp(ly,e)}var dy=_("ZodAny",(e,t)=>{ud.init(e,t),se.init(e,t)});function Mp(){return dp(dy)}var py=_("ZodUnknown",(e,t)=>{ld.init(e,t),se.init(e,t)});function pe(){return pp(py)}var fy=_("ZodNever",(e,t)=>{dd.init(e,t),se.init(e,t)});function my(e){return fp(fy,e)}var Zp=_("ZodDate",(e,t)=>{pd.init(e,t),se.init(e,t),e.min=(n,o)=>e.check(Xe(n,o)),e.max=(n,o)=>e.check(mt(n,o));let r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});var hy=_("ZodArray",(e,t)=>{fd.init(e,t),se.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(yr(r,n)),e.nonempty=r=>e.check(yr(1,r)),e.max=(r,n)=>e.check(yo(r,n)),e.length=(r,n)=>e.check(vo(r,n)),e.unwrap=()=>e.element});function z(e,t){return hp(hy,e,t)}var Dp=_("ZodObject",(e,t)=>{md.init(e,t),se.init(e,t),J.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>Ne(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:pe()}),e.loose=()=>e.clone({...e._zod.def,catchall:pe()}),e.strict=()=>e.clone({...e._zod.def,catchall:my()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>J.extend(e,r),e.merge=r=>J.merge(e,r),e.pick=r=>J.pick(e,r),e.omit=r=>J.omit(e,r),e.partial=(...r)=>J.partial(Lp,e,r[0]),e.required=(...r)=>J.required(Fp,e,r[0])});function k(e,t){let r={type:"object",get shape(){return J.assignProp(this,"shape",{...e}),this.shape},...J.normalizeParams(t)};return new Dp(r)}function ye(e,t){return new Dp({type:"object",get shape(){return J.assignProp(this,"shape",{...e}),this.shape},catchall:pe(),...J.normalizeParams(t)})}var Up=_("ZodUnion",(e,t)=>{ui.init(e,t),se.init(e,t),e.options=t.options});function ce(e,t){return new Up({type:"union",options:e,...J.normalizeParams(t)})}var gy=_("ZodDiscriminatedUnion",(e,t)=>{Up.init(e,t),hd.init(e,t)});function Ii(e,t,r){return new gy({type:"union",options:t,discriminator:e,...J.normalizeParams(r)})}var _y=_("ZodIntersection",(e,t)=>{gd.init(e,t),se.init(e,t)});function So(e,t){return new _y({type:"intersection",left:e,right:t})}var yy=_("ZodRecord",(e,t)=>{_d.init(e,t),se.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function ie(e,t,r){return new yy({type:"record",keyType:e,valueType:t,...J.normalizeParams(r)})}var Pi=_("ZodEnum",(e,t)=>{yd.init(e,t),se.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Pi({...t,checks:[],...J.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Pi({...t,checks:[],...J.normalizeParams(o),entries:s})}});function Ne(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Pi({type:"enum",entries:r,...J.normalizeParams(t)})}var vy=_("ZodLiteral",(e,t)=>{vd.init(e,t),se.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function E(e,t){return new vy({type:"literal",values:Array.isArray(e)?e:[e],...J.normalizeParams(t)})}var wy=_("ZodTransform",(e,t)=>{wd.init(e,t),se.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=s=>{if(typeof s=="string")r.issues.push(J.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=e),i.continue??(i.continue=!0),r.issues.push(J.issue(i))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function qp(e){return new wy({type:"transform",transform:e})}var Lp=_("ZodOptional",(e,t)=>{$d.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType});function fe(e){return new Lp({type:"optional",innerType:e})}var $y=_("ZodNullable",(e,t)=>{bd.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ip(e){return new $y({type:"nullable",innerType:e})}var by=_("ZodDefault",(e,t)=>{Sd.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Sy(e,t){return new by({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var xy=_("ZodPrefault",(e,t)=>{xd.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType});function zy(e,t){return new xy({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var Fp=_("ZodNonOptional",(e,t)=>{zd.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ky(e,t){return new Fp({type:"nonoptional",innerType:e,...J.normalizeParams(t)})}var Py=_("ZodCatch",(e,t)=>{kd.init(e,t),se.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ty(e,t){return new Py({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var Ry=_("ZodPipe",(e,t)=>{Pd.init(e,t),se.init(e,t),e.in=t.in,e.out=t.out});function Ti(e,t){return new Ry({type:"pipe",in:e,out:t})}var Ey=_("ZodReadonly",(e,t)=>{Td.init(e,t),se.init(e,t)});function Iy(e){return new Ey({type:"readonly",innerType:e})}var Vp=_("ZodCustom",(e,t)=>{Rd.init(e,t),se.init(e,t)});function Oy(e){let t=new Pe({check:"custom"});return t._zod.check=e,t}function Hp(e,t){return gp(Vp,e??(()=>!0),t)}function Ay(e,t={}){return _p(Vp,e,t)}function Cy(e){let t=Oy(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(J.issue(n,r.value,t._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=t),o.continue??(o.continue=!t._zod.def.abort),r.issues.push(J.issue(o))}},e(r.value,r)));return t}function Oi(e,t){return Ti(qp(e),t)}var Bp={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};var xo={};Ds(xo,{bigint:()=>Zy,boolean:()=>My,date:()=>Dy,number:()=>jy,string:()=>Ny});function Ny(e){return Ad(Ri,e)}function jy(e){return sp(bo,e)}function My(e){return cp(Ei,e)}function Zy(e){return up(Np,e)}function Dy(e){return mp(Zp,e)}Le(Ed());var br="2025-11-25";var Kp=[br,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],kt="io.modelcontextprotocol/related-task",ko="2.0",ve=Hp(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Gp=ce([p(),B().int()]),Jp=p(),kT=ye({ttl:B().optional(),pollInterval:B().optional()}),qy=k({ttl:B().optional()}),Ly=k({taskId:p()}),Ci=ye({progressToken:Gp.optional(),[kt]:Ly.optional()}),Fe=k({_meta:Ci.optional()}),sn=Fe.extend({task:qy.optional()}),Wp=e=>sn.safeParse(e).success,$e=k({method:p(),params:Fe.loose().optional()}),Ve=k({_meta:Ci.optional()}),He=k({method:p(),params:Ve.loose().optional()}),be=ye({_meta:Ci.optional()}),Po=ce([p(),B().int()]),Yp=k({jsonrpc:E(ko),id:Po,...$e.shape}).strict(),an=e=>Yp.safeParse(e).success,Qp=k({jsonrpc:E(ko),...He.shape}).strict(),Xp=e=>Qp.safeParse(e).success,Ni=k({jsonrpc:E(ko),id:Po,result:be}).strict(),Lt=e=>Ni.safeParse(e).success;var N;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(N||(N={}));var ji=k({jsonrpc:E(ko),id:Po.optional(),error:k({code:B().int(),message:p(),data:pe().optional()})}).strict();var ef=e=>ji.safeParse(e).success;var Sr=ce([Yp,Qp,Ni,ji]),PT=ce([Ni,ji]),Ft=be.strict(),Fy=Ve.extend({requestId:Po.optional(),reason:p().optional()}),To=He.extend({method:E("notifications/cancelled"),params:Fy}),Vy=k({src:p(),mimeType:p().optional(),sizes:z(p()).optional(),theme:Ne(["light","dark"]).optional()}),cn=k({icons:z(Vy).optional()}),$r=k({name:p(),title:p().optional()}),tf=$r.extend({...$r.shape,...cn.shape,version:p(),websiteUrl:p().optional(),description:p().optional()}),Hy=So(k({applyDefaults:te().optional()}),ie(p(),pe())),By=Oi(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,So(k({form:Hy.optional(),url:ve.optional()}),ie(p(),pe()).optional())),Ky=ye({list:ve.optional(),cancel:ve.optional(),requests:ye({sampling:ye({createMessage:ve.optional()}).optional(),elicitation:ye({create:ve.optional()}).optional()}).optional()}),Gy=ye({list:ve.optional(),cancel:ve.optional(),requests:ye({tools:ye({call:ve.optional()}).optional()}).optional()}),Jy=k({experimental:ie(p(),ve).optional(),sampling:k({context:ve.optional(),tools:ve.optional()}).optional(),elicitation:By.optional(),roots:k({listChanged:te().optional()}).optional(),tasks:Ky.optional(),extensions:ie(p(),ve).optional()}),Wy=Fe.extend({protocolVersion:p(),capabilities:Jy,clientInfo:tf}),Yy=$e.extend({method:E("initialize"),params:Wy});var Qy=k({experimental:ie(p(),ve).optional(),logging:ve.optional(),completions:ve.optional(),prompts:k({listChanged:te().optional()}).optional(),resources:k({subscribe:te().optional(),listChanged:te().optional()}).optional(),tools:k({listChanged:te().optional()}).optional(),tasks:Gy.optional(),extensions:ie(p(),ve).optional()}),Mi=be.extend({protocolVersion:p(),capabilities:Qy,serverInfo:tf,instructions:p().optional()}),rf=He.extend({method:E("notifications/initialized"),params:Ve.optional()}),nf=e=>rf.safeParse(e).success,Ro=$e.extend({method:E("ping"),params:Fe.optional()}),Xy=k({progress:B(),total:fe(B()),message:fe(p())}),ev=k({...Ve.shape,...Xy.shape,progressToken:Gp}),Eo=He.extend({method:E("notifications/progress"),params:ev}),tv=Fe.extend({cursor:Jp.optional()}),un=$e.extend({params:tv.optional()}),ln=be.extend({nextCursor:Jp.optional()}),rv=Ne(["working","input_required","completed","failed","cancelled"]),dn=k({taskId:p(),status:rv,ttl:ce([B(),jp()]),createdAt:p(),lastUpdatedAt:p(),pollInterval:fe(B()),statusMessage:fe(p())}),Vt=be.extend({task:dn}),nv=Ve.merge(dn),pn=He.extend({method:E("notifications/tasks/status"),params:nv}),Io=$e.extend({method:E("tasks/get"),params:Fe.extend({taskId:p()})}),Oo=be.merge(dn),Ao=$e.extend({method:E("tasks/result"),params:Fe.extend({taskId:p()})}),TT=be.loose(),Co=un.extend({method:E("tasks/list")}),No=ln.extend({tasks:z(dn)}),jo=$e.extend({method:E("tasks/cancel"),params:Fe.extend({taskId:p()})}),of=be.merge(dn),sf=k({uri:p(),mimeType:fe(p()),_meta:ie(p(),pe()).optional()}),af=sf.extend({text:p()}),Zi=p().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),cf=sf.extend({blob:Zi}),fn=Ne(["user","assistant"]),xr=k({audience:z(fn).optional(),priority:B().min(0).max(1).optional(),lastModified:nn.datetime({offset:!0}).optional()}),uf=k({...$r.shape,...cn.shape,uri:p(),description:fe(p()),mimeType:fe(p()),size:fe(B()),annotations:xr.optional(),_meta:fe(ye({}))}),ov=k({...$r.shape,...cn.shape,uriTemplate:p(),description:fe(p()),mimeType:fe(p()),annotations:xr.optional(),_meta:fe(ye({}))}),sv=un.extend({method:E("resources/list")}),Di=ln.extend({resources:z(uf)}),iv=un.extend({method:E("resources/templates/list")}),Ui=ln.extend({resourceTemplates:z(ov)}),qi=Fe.extend({uri:p()}),av=qi,cv=$e.extend({method:E("resources/read"),params:av}),Li=be.extend({contents:z(ce([af,cf]))}),Fi=He.extend({method:E("notifications/resources/list_changed"),params:Ve.optional()}),uv=qi,lv=$e.extend({method:E("resources/subscribe"),params:uv}),dv=qi,pv=$e.extend({method:E("resources/unsubscribe"),params:dv}),fv=Ve.extend({uri:p()}),mv=He.extend({method:E("notifications/resources/updated"),params:fv}),hv=k({name:p(),description:fe(p()),required:fe(te())}),gv=k({...$r.shape,...cn.shape,description:fe(p()),arguments:fe(z(hv)),_meta:fe(ye({}))}),_v=un.extend({method:E("prompts/list")}),Vi=ln.extend({prompts:z(gv)}),yv=Fe.extend({name:p(),arguments:ie(p(),p()).optional()}),vv=$e.extend({method:E("prompts/get"),params:yv}),Hi=k({type:E("text"),text:p(),annotations:xr.optional(),_meta:ie(p(),pe()).optional()}),Bi=k({type:E("image"),data:Zi,mimeType:p(),annotations:xr.optional(),_meta:ie(p(),pe()).optional()}),Ki=k({type:E("audio"),data:Zi,mimeType:p(),annotations:xr.optional(),_meta:ie(p(),pe()).optional()}),wv=k({type:E("tool_use"),name:p(),id:p(),input:ie(p(),pe()),_meta:ie(p(),pe()).optional()}),$v=k({type:E("resource"),resource:ce([af,cf]),annotations:xr.optional(),_meta:ie(p(),pe()).optional()}),bv=uf.extend({type:E("resource_link")}),Gi=ce([Hi,Bi,Ki,bv,$v]),Sv=k({role:fn,content:Gi}),Ji=be.extend({description:p().optional(),messages:z(Sv)}),Wi=He.extend({method:E("notifications/prompts/list_changed"),params:Ve.optional()}),xv=k({title:p().optional(),readOnlyHint:te().optional(),destructiveHint:te().optional(),idempotentHint:te().optional(),openWorldHint:te().optional()}),zv=k({taskSupport:Ne(["required","optional","forbidden"]).optional()}),lf=k({...$r.shape,...cn.shape,description:p().optional(),inputSchema:k({type:E("object"),properties:ie(p(),ve).optional(),required:z(p()).optional()}).catchall(pe()),outputSchema:k({type:E("object"),properties:ie(p(),ve).optional(),required:z(p()).optional()}).catchall(pe()).optional(),annotations:xv.optional(),execution:zv.optional(),_meta:ie(p(),pe()).optional()}),kv=un.extend({method:E("tools/list")}),Yi=ln.extend({tools:z(lf)}),zr=be.extend({content:z(Gi).default([]),structuredContent:ie(p(),pe()).optional(),isError:te().optional()}),RT=zr.or(be.extend({toolResult:pe()})),Pv=sn.extend({name:p(),arguments:ie(p(),pe()).optional()}),Tv=$e.extend({method:E("tools/call"),params:Pv}),Qi=He.extend({method:E("notifications/tools/list_changed"),params:Ve.optional()}),df=k({autoRefresh:te().default(!0),debounceMs:B().int().nonnegative().default(300)}),pf=Ne(["debug","info","notice","warning","error","critical","alert","emergency"]),Rv=Fe.extend({level:pf}),Ev=$e.extend({method:E("logging/setLevel"),params:Rv}),Iv=Ve.extend({level:pf,logger:p().optional(),data:pe()}),Ov=He.extend({method:E("notifications/message"),params:Iv}),Av=k({name:p().optional()}),Cv=k({hints:z(Av).optional(),costPriority:B().min(0).max(1).optional(),speedPriority:B().min(0).max(1).optional(),intelligencePriority:B().min(0).max(1).optional()}),Nv=k({mode:Ne(["auto","required","none"]).optional()}),jv=k({type:E("tool_result"),toolUseId:p().describe("The unique identifier for the corresponding tool call."),content:z(Gi).default([]),structuredContent:k({}).loose().optional(),isError:te().optional(),_meta:ie(p(),pe()).optional()}),Mv=Ii("type",[Hi,Bi,Ki]),zo=Ii("type",[Hi,Bi,Ki,wv,jv]),Zv=k({role:fn,content:ce([zo,z(zo)]),_meta:ie(p(),pe()).optional()}),Dv=sn.extend({messages:z(Zv),modelPreferences:Cv.optional(),systemPrompt:p().optional(),includeContext:Ne(["none","thisServer","allServers"]).optional(),temperature:B().optional(),maxTokens:B().int(),stopSequences:z(p()).optional(),metadata:ve.optional(),tools:z(lf).optional(),toolChoice:Nv.optional()}),Xi=$e.extend({method:E("sampling/createMessage"),params:Dv}),ea=be.extend({model:p(),stopReason:fe(Ne(["endTurn","stopSequence","maxTokens"]).or(p())),role:fn,content:Mv}),ta=be.extend({model:p(),stopReason:fe(Ne(["endTurn","stopSequence","maxTokens","toolUse"]).or(p())),role:fn,content:ce([zo,z(zo)])}),Uv=k({type:E("boolean"),title:p().optional(),description:p().optional(),default:te().optional()}),qv=k({type:E("string"),title:p().optional(),description:p().optional(),minLength:B().optional(),maxLength:B().optional(),format:Ne(["email","uri","date","date-time"]).optional(),default:p().optional()}),Lv=k({type:Ne(["number","integer"]),title:p().optional(),description:p().optional(),minimum:B().optional(),maximum:B().optional(),default:B().optional()}),Fv=k({type:E("string"),title:p().optional(),description:p().optional(),enum:z(p()),default:p().optional()}),Vv=k({type:E("string"),title:p().optional(),description:p().optional(),oneOf:z(k({const:p(),title:p()})),default:p().optional()}),Hv=k({type:E("string"),title:p().optional(),description:p().optional(),enum:z(p()),enumNames:z(p()).optional(),default:p().optional()}),Bv=ce([Fv,Vv]),Kv=k({type:E("array"),title:p().optional(),description:p().optional(),minItems:B().optional(),maxItems:B().optional(),items:k({type:E("string"),enum:z(p())}),default:z(p()).optional()}),Gv=k({type:E("array"),title:p().optional(),description:p().optional(),minItems:B().optional(),maxItems:B().optional(),items:k({anyOf:z(k({const:p(),title:p()}))}),default:z(p()).optional()}),Jv=ce([Kv,Gv]),Wv=ce([Hv,Bv,Jv]),Yv=ce([Wv,Uv,qv,Lv]),Qv=sn.extend({mode:E("form").optional(),message:p(),requestedSchema:k({type:E("object"),properties:ie(p(),Yv),required:z(p()).optional()})}),Xv=sn.extend({mode:E("url"),message:p(),elicitationId:p(),url:p().url()}),ew=ce([Qv,Xv]),ra=$e.extend({method:E("elicitation/create"),params:ew}),tw=Ve.extend({elicitationId:p()}),rw=He.extend({method:E("notifications/elicitation/complete"),params:tw}),na=be.extend({action:Ne(["accept","decline","cancel"]),content:Oi(e=>e===null?void 0:e,ie(p(),ce([p(),B(),te(),z(p())])).optional())}),nw=k({type:E("ref/resource"),uri:p()});var ow=k({type:E("ref/prompt"),name:p()}),sw=Fe.extend({ref:ce([ow,nw]),argument:k({name:p(),value:p()}),context:k({arguments:ie(p(),p()).optional()}).optional()}),iw=$e.extend({method:E("completion/complete"),params:sw});var oa=be.extend({completion:ye({values:z(p()).max(100),total:fe(B().int()),hasMore:fe(te())})}),aw=k({uri:p().startsWith("file://"),name:p().optional(),_meta:ie(p(),pe()).optional()}),cw=$e.extend({method:E("roots/list"),params:Fe.optional()}),uw=be.extend({roots:z(aw)}),lw=He.extend({method:E("notifications/roots/list_changed"),params:Ve.optional()}),ET=ce([Ro,Yy,iw,Ev,vv,_v,sv,iv,cv,lv,pv,Tv,kv,Io,Ao,Co,jo]),IT=ce([To,Eo,rf,lw,pn]),OT=ce([Ft,ea,ta,na,uw,Oo,No,Vt]),AT=ce([Ro,Xi,ra,cw,Io,Ao,Co,jo]),CT=ce([To,Eo,Ov,mv,Fi,Qi,Wi,pn,rw]),NT=ce([Ft,Mi,oa,Ji,Vi,Di,Ui,Li,zr,Yi,Oo,No,Vt]),C=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===N.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Ai(o.elicitations,r)}return new e(t,r,n)}},Ai=class extends C{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(N.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function Pt(e){return e==="completed"||e==="failed"||e==="cancelled"}var dw=Symbol("Let zodToJsonSchema decide on which parser to use");var mR=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function sa(e){let r=wo(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=yp(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function ia(e,t){let r=et(e,t);if(!r.success)throw r.error;return r.data}var _w=6e4,Mo=class{constructor(t){this._options=t,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(To,r=>{this._oncancel(r)}),this.setNotificationHandler(Eo,r=>{this._onprogress(r)}),this.setRequestHandler(Ro,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Io,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new C(N.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Ao,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.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,f=new C(d.error.code,d.error.message,d.error.data);u(f)}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:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new C(N.InvalidParams,`Task not found: ${s}`);if(!Pt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Pt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[kt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Co,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new C(N.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(jo,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new C(N.InvalidParams,`Task not found: ${r.params.taskId}`);if(Pt(o.status))throw new C(N.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new C(N.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof C?o:new C(N.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),C.fromError(N.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){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=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),Lt(s)||ef(s)?this._onresponse(s):an(s)?this._onrequest(s,i):Xp(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=C.fromError(N.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,s=t.params?._meta?.[kt]?.taskId;if(n===void 0){let u={jsonrpc:"2.0",id:t.id,error:{code:N.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:u,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(u).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(t.id,i);let a=Wp(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,l={signal:i.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async u=>{if(i.signal.aborted)return;let d={relatedRequestId:t.id};s&&(d.relatedTask={taskId:s}),await this.notification(u,d)},sendRequest:async(u,d,f)=>{if(i.signal.aborted)throw new C(N.ConnectionClosed,"Request was cancelled");let m={...f,relatedRequestId:t.id};s&&!m.relatedTask&&(m.relatedTask={taskId:s});let h=m.relatedTask?.taskId??s;return h&&c&&await c.updateTaskStatus(h,"input_required"),await this.request(u,d,m)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,l)).then(async u=>{if(i.signal.aborted)return;let d={result:u,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async u=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(u.code)?u.code:N.InternalError,message:u.message??"Internal error",...u.data!==void 0&&{data:u.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(u=>this._onerror(new Error(`Failed to send response: ${u}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===i&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Lt(t))n(t);else{let i=new C(t.error.code,t.error.message,t.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(Lt(t)&&t.result&&typeof t.result=="object"){let i=t.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),Lt(t))o(t);else{let i=C.fromError(t.error.code,t.error.message,t.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(i){yield{type:"error",error:i instanceof C?i:new C(N.InternalError,String(i))}}return}let s;try{let i=await this.request(t,Vt,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new C(N.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Pt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new C(N.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new C(N.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(l=>setTimeout(l,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof C?i:new C(N.InternalError,String(i))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((l,u)=>{let d=S=>{u(S)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(S){d(S);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,m={...t,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),m.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),a&&(m.params={...m.params,task:a}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[kt]:c}});let h=S=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(S)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(T=>this._onerror(new Error(`Failed to send cancellation: ${T}`)));let b=S instanceof C?S:new C(N.RequestTimeout,String(S));u(b)};this._responseHandlers.set(f,S=>{if(!n?.signal?.aborted){if(S instanceof Error)return u(S);try{let b=et(r,S.result);b.success?l(b.data):u(b.error)}catch(b){u(b)}}}),n?.signal?.addEventListener("abort",()=>{h(n?.signal?.reason)});let g=n?.timeout??_w,v=()=>h(C.fromError(N.RequestTimeout,"Request timed out",{timeout:g}));this._setupTimeout(f,g,n?.maxTotalTimeout,v,n?.resetTimeoutOnProgress??!1);let $=c?.taskId;if($){let S=b=>{let T=this._responseHandlers.get(f);T?T(b):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,S),this._enqueueTaskMessage($,{type:"request",message:m,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(f),u(b)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(S=>{this._cleanupTimeout(f),u(S)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Oo,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},No,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},of,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[kt]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[kt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[kt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=sa(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=ia(t,o);return Promise.resolve(r(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=sa(t);this._notificationHandlers.set(n,o=>{let s=ia(t,o);return Promise.resolve(r(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&an(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new C(N.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(t);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new C(N.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new C(N.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new C(N.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await n.storeTaskResult(o,s,i,r);let a=await n.getTask(o,r);if(a){let c=pn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Pt(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new C(N.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Pt(a.status))throw new C(N.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,i,r);let c=await n.getTask(o,r);if(c){let l=pn.parse({method:"notifications/tasks/status",params:c});await this.notification(l),Pt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function ff(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function mf(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let i=r[o];ff(i)&&ff(s)?r[o]={...i,...s}:r[o]=s}return r}var sg=Tu(Bc(),1),ig=Tu(og(),1);function $z(){let e=new sg.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,ig.default)(e),e}var ys=class{constructor(t){this._ajv=t??$z()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var vs=class{constructor(t){this._client=t}async*callToolStream(t,r=zr,n){let o=this._client,s={...n,task:n?.task??(o.isToolTask(t.name)?{}:void 0)},i=o.requestStream({method:"tools/call",params:t},r,s),a=o.getToolOutputValidator(t.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 C(N.InvalidRequest,`Tool ${t.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 C(N.InvalidParams,`Structured content does not match the tool's output schema: ${u.errorMessage}`)};return}}catch(u){if(u instanceof C){yield{type:"error",error:u};return}yield{type:"error",error:new C(N.InvalidParams,`Failed to validate structured content: ${u instanceof Error?u.message:String(u)}`)};return}}yield c}}async getTask(t,r){return this._client.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._client.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._client.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._client.cancelTask({taskId:t},r)}requestStream(t,r,n){return this._client.requestStream(t,r,n)}};function ag(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function cg(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}function ws(e,t){if(!(!e||t===null||typeof t!="object")){if(e.type==="object"&&e.properties&&typeof e.properties=="object"){let r=t,n=e.properties;for(let o of Object.keys(n)){let s=n[o];r[o]===void 0&&Object.prototype.hasOwnProperty.call(s,"default")&&(r[o]=s.default),r[o]!==void 0&&ws(s,r[o])}}if(Array.isArray(e.anyOf))for(let r of e.anyOf)typeof r!="boolean"&&ws(r,t);if(Array.isArray(e.oneOf))for(let r of e.oneOf)typeof r!="boolean"&&ws(r,t)}}function bz(e){if(!e)return{supportsFormMode:!1,supportsUrlMode:!1};let t=e.form!==void 0,r=e.url!==void 0;return{supportsFormMode:t||!t&&!r,supportsUrlMode:r}}var $s=class extends Mo{constructor(t,r){super(r),this._clientInfo=t,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 ys,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(t){t.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",Qi,t.tools,async()=>(await this.listTools()).tools),t.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Wi,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",Fi,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new vs(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=mf(this._capabilities,t)}setRequestHandler(t,r){let o=wo(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(wr(o)){let a=o;s=a._zod?.def?.value??a.value}else{let a=o;s=a._def?.value??a.value}if(typeof s!="string")throw new Error("Schema method literal must be a string");let i=s;if(i==="elicitation/create"){let a=async(c,l)=>{let u=et(ra,c);if(!u.success){let S=u.error instanceof Error?u.error.message:String(u.error);throw new C(N.InvalidParams,`Invalid elicitation request: ${S}`)}let{params:d}=u.data;d.mode=d.mode??"form";let{supportsFormMode:f,supportsUrlMode:m}=bz(this._capabilities.elicitation);if(d.mode==="form"&&!f)throw new C(N.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!m)throw new C(N.InvalidParams,"Client does not support URL-mode elicitation requests");let h=await Promise.resolve(r(c,l));if(d.task){let S=et(Vt,h);if(!S.success){let b=S.error instanceof Error?S.error.message:String(S.error);throw new C(N.InvalidParams,`Invalid task creation result: ${b}`)}return S.data}let g=et(na,h);if(!g.success){let S=g.error instanceof Error?g.error.message:String(g.error);throw new C(N.InvalidParams,`Invalid elicitation result: ${S}`)}let v=g.data,$=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&v.action==="accept"&&v.content&&$&&this._capabilities.elicitation?.form?.applyDefaults)try{ws($,v.content)}catch{}return v};return super.setRequestHandler(t,a)}if(i==="sampling/createMessage"){let a=async(c,l)=>{let u=et(Xi,c);if(!u.success){let v=u.error instanceof Error?u.error.message:String(u.error);throw new C(N.InvalidParams,`Invalid sampling request: ${v}`)}let{params:d}=u.data,f=await Promise.resolve(r(c,l));if(d.task){let v=et(Vt,f);if(!v.success){let $=v.error instanceof Error?v.error.message:String(v.error);throw new C(N.InvalidParams,`Invalid task creation result: ${$}`)}return v.data}let h=d.tools||d.toolChoice?ta:ea,g=et(h,f);if(!g.success){let v=g.error instanceof Error?g.error.message:String(g.error);throw new C(N.InvalidParams,`Invalid sampling result: ${v}`)}return g.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapability(t,r){if(!this._serverCapabilities?.[t])throw new Error(`Server does not support ${t} (required for ${r})`)}async connect(t,r){if(await super.connect(t),t.sessionId===void 0)try{let n=await this.request({method:"initialize",params:{protocolVersion:br,capabilities:this._capabilities,clientInfo:this._clientInfo}},Mi,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!Kp.includes(n.protocolVersion))throw new Error(`Server's protocol version is not supported: ${n.protocolVersion}`);this._serverCapabilities=n.capabilities,this._serverVersion=n.serverInfo,t.setProtocolVersion&&t.setProtocolVersion(n.protocolVersion),this._instructions=n.instructions,await this.notification({method:"notifications/initialized"}),this._pendingListChangedConfig&&(this._setupListChangedHandlers(this._pendingListChangedConfig),this._pendingListChangedConfig=void 0)}catch(n){throw this.close(),n}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(t){switch(t){case"logging/setLevel":if(!this._serverCapabilities?.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._serverCapabilities?.prompts)throw new Error(`Server does not support prompts (required for ${t})`);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 ${t})`);if(t==="resources/subscribe"&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._serverCapabilities?.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"completion/complete":if(!this._serverCapabilities?.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"initialize":break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/roots/list_changed":if(!this._capabilities.roots?.listChanged)throw new Error(`Client does not support roots list changed notifications (required for ${t})`);break;case"notifications/initialized":break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${t})`);break;case"elicitation/create":if(!this._capabilities.elicitation)throw new Error(`Client does not support elicitation capability (required for ${t})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${t})`);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 ${t})`);break;case"ping":break}}assertTaskCapability(t){ag(this._serverCapabilities?.tasks?.requests,t,"Server")}assertTaskHandlerCapability(t){this._capabilities&&cg(this._capabilities.tasks?.requests,t,"Client")}async ping(t){return this.request({method:"ping"},Ft,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},oa,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},Ft,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},Ji,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},Vi,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},Di,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},Ui,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},Li,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},Ft,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},Ft,r)}async callTool(t,r=zr,n){if(this.isToolTaskRequired(t.name))throw new C(N.InvalidRequest,`Tool "${t.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);let o=await this.request({method:"tools/call",params:t},r,n),s=this.getToolOutputValidator(t.name);if(s){if(!o.structuredContent&&!o.isError)throw new C(N.InvalidRequest,`Tool ${t.name} has an output schema but did not return structured content`);if(o.structuredContent)try{let i=s(o.structuredContent);if(!i.valid)throw new C(N.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof C?i:new C(N.InvalidParams,`Failed to validate structured content: ${i instanceof Error?i.message:String(i)}`)}}return o}isToolTask(t){return this._serverCapabilities?.tasks?.requests?.tools?.call?this._cachedKnownTaskTools.has(t):!1}isToolTaskRequired(t){return this._cachedRequiredTaskTools.has(t)}cacheToolMetadata(t){this._cachedToolOutputValidators.clear(),this._cachedKnownTaskTools.clear(),this._cachedRequiredTaskTools.clear();for(let r of t){if(r.outputSchema){let o=this._jsonSchemaValidator.getValidator(r.outputSchema);this._cachedToolOutputValidators.set(r.name,o)}let n=r.execution?.taskSupport;(n==="required"||n==="optional")&&this._cachedKnownTaskTools.add(r.name),n==="required"&&this._cachedRequiredTaskTools.add(r.name)}}getToolOutputValidator(t){return this._cachedToolOutputValidators.get(t)}async listTools(t,r){let n=await this.request({method:"tools/list",params:t},Yi,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,o){let s=df.safeParse(n);if(!s.success)throw new Error(`Invalid ${t} listChanged options: ${s.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${t} listChanged options: onChanged must be a function`);let{autoRefresh:i,debounceMs:a}=s.data,{onChanged:c}=n,l=async()=>{if(!i){c(null,null);return}try{let d=await o();c(null,d)}catch(d){let f=d instanceof Error?d:new Error(String(d));c(f,null)}},u=()=>{if(a){let d=this._listChangedDebounceTimers.get(t);d&&clearTimeout(d);let f=setTimeout(l,a);this._listChangedDebounceTimers.set(t,f)}else l()};this.setNotificationHandler(r,u)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};function bs(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function ug(e=fetch,t){return t?async(r,n)=>{let o={...t,...n,headers:n?.headers?{...bs(t.headers),...bs(n.headers)}:t.headers};return e(r,o)}:e}var eu;eu=globalThis.crypto?.webcrypto??globalThis.crypto??import("node:crypto").then(e=>e.webcrypto);async function Sz(e){return(await eu).getRandomValues(new Uint8Array(e))}async function xz(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length,n="";for(;n.length<e;){let o=await Sz(e-n.length);for(let s of o)s<r&&(n+=t[s%t.length])}return n}async function zz(e){return await xz(e)}async function kz(e){let t=await(await eu).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function tu(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await zz(e),r=await kz(t);return{code_verifier:t,code_challenge:r}}var ke=Cp().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Bp.custom,message:"URL must be parseable",fatal:!0}),Us}).refine(e=>{let t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),dg=ye({resource:p().url(),authorization_servers:z(ke).optional(),jwks_uri:p().url().optional(),scopes_supported:z(p()).optional(),bearer_methods_supported:z(p()).optional(),resource_signing_alg_values_supported:z(p()).optional(),resource_name:p().optional(),resource_documentation:p().optional(),resource_policy_uri:p().url().optional(),resource_tos_uri:p().url().optional(),tls_client_certificate_bound_access_tokens:te().optional(),authorization_details_types_supported:z(p()).optional(),dpop_signing_alg_values_supported:z(p()).optional(),dpop_bound_access_tokens_required:te().optional()}),ru=ye({issuer:p(),authorization_endpoint:ke,token_endpoint:ke,registration_endpoint:ke.optional(),scopes_supported:z(p()).optional(),response_types_supported:z(p()),response_modes_supported:z(p()).optional(),grant_types_supported:z(p()).optional(),token_endpoint_auth_methods_supported:z(p()).optional(),token_endpoint_auth_signing_alg_values_supported:z(p()).optional(),service_documentation:ke.optional(),revocation_endpoint:ke.optional(),revocation_endpoint_auth_methods_supported:z(p()).optional(),revocation_endpoint_auth_signing_alg_values_supported:z(p()).optional(),introspection_endpoint:p().optional(),introspection_endpoint_auth_methods_supported:z(p()).optional(),introspection_endpoint_auth_signing_alg_values_supported:z(p()).optional(),code_challenge_methods_supported:z(p()).optional(),client_id_metadata_document_supported:te().optional()}),Pz=ye({issuer:p(),authorization_endpoint:ke,token_endpoint:ke,userinfo_endpoint:ke.optional(),jwks_uri:ke,registration_endpoint:ke.optional(),scopes_supported:z(p()).optional(),response_types_supported:z(p()),response_modes_supported:z(p()).optional(),grant_types_supported:z(p()).optional(),acr_values_supported:z(p()).optional(),subject_types_supported:z(p()),id_token_signing_alg_values_supported:z(p()),id_token_encryption_alg_values_supported:z(p()).optional(),id_token_encryption_enc_values_supported:z(p()).optional(),userinfo_signing_alg_values_supported:z(p()).optional(),userinfo_encryption_alg_values_supported:z(p()).optional(),userinfo_encryption_enc_values_supported:z(p()).optional(),request_object_signing_alg_values_supported:z(p()).optional(),request_object_encryption_alg_values_supported:z(p()).optional(),request_object_encryption_enc_values_supported:z(p()).optional(),token_endpoint_auth_methods_supported:z(p()).optional(),token_endpoint_auth_signing_alg_values_supported:z(p()).optional(),display_values_supported:z(p()).optional(),claim_types_supported:z(p()).optional(),claims_supported:z(p()).optional(),service_documentation:p().optional(),claims_locales_supported:z(p()).optional(),ui_locales_supported:z(p()).optional(),claims_parameter_supported:te().optional(),request_parameter_supported:te().optional(),request_uri_parameter_supported:te().optional(),require_request_uri_registration:te().optional(),op_policy_uri:ke.optional(),op_tos_uri:ke.optional(),client_id_metadata_document_supported:te().optional()}),pg=k({...Pz.shape,...ru.pick({code_challenge_methods_supported:!0}).shape}),fg=k({access_token:p(),id_token:p().optional(),token_type:p(),expires_in:xo.number().optional(),scope:p().optional(),refresh_token:p().optional()}).strip(),mg=k({error:p(),error_description:p().optional(),error_uri:p().optional()}),lg=ke.optional().or(E("").transform(()=>{})),Tz=k({redirect_uris:z(ke),token_endpoint_auth_method:p().optional(),grant_types:z(p()).optional(),response_types:z(p()).optional(),client_name:p().optional(),client_uri:ke.optional(),logo_uri:lg,scope:p().optional(),contacts:z(p()).optional(),tos_uri:lg,policy_uri:p().optional(),jwks_uri:ke.optional(),jwks:Mp().optional(),software_id:p().optional(),software_version:p().optional(),software_statement:p().optional()}).strip(),Rz=k({client_id:p(),client_secret:p().optional(),client_id_issued_at:B().optional(),client_secret_expires_at:B().optional()}).strip(),hg=Tz.merge(Rz),UA=k({error:p(),error_description:p().optional()}).strip(),qA=k({token:p(),token_type_hint:p().optional()}).strip();function gg(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function _g({requestedResource:e,configuredResource:t}){let r=typeof e=="string"?new URL(e):new URL(e.href),n=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==n.origin||r.pathname.length<n.pathname.length)return!1;let o=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",s=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";return o.startsWith(s)}var ge=class extends Error{constructor(t,r){super(t),this.errorUri=r,this.name=this.constructor.name}toResponseObject(){let t={error:this.errorCode,error_description:this.message};return this.errorUri&&(t.error_uri=this.errorUri),t}get errorCode(){return this.constructor.errorCode}},Vn=class extends ge{};Vn.errorCode="invalid_request";var rr=class extends ge{};rr.errorCode="invalid_client";var nr=class extends ge{};nr.errorCode="invalid_grant";var or=class extends ge{};or.errorCode="unauthorized_client";var Hn=class extends ge{};Hn.errorCode="unsupported_grant_type";var Bn=class extends ge{};Bn.errorCode="invalid_scope";var Kn=class extends ge{};Kn.errorCode="access_denied";var wt=class extends ge{};wt.errorCode="server_error";var Gn=class extends ge{};Gn.errorCode="temporarily_unavailable";var Jn=class extends ge{};Jn.errorCode="unsupported_response_type";var Wn=class extends ge{};Wn.errorCode="unsupported_token_type";var Yn=class extends ge{};Yn.errorCode="invalid_token";var Qn=class extends ge{};Qn.errorCode="method_not_allowed";var Xn=class extends ge{};Xn.errorCode="too_many_requests";var sr=class extends ge{};sr.errorCode="invalid_client_metadata";var eo=class extends ge{};eo.errorCode="insufficient_scope";var to=class extends ge{};to.errorCode="invalid_target";var yg={[Vn.errorCode]:Vn,[rr.errorCode]:rr,[nr.errorCode]:nr,[or.errorCode]:or,[Hn.errorCode]:Hn,[Bn.errorCode]:Bn,[Kn.errorCode]:Kn,[wt.errorCode]:wt,[Gn.errorCode]:Gn,[Jn.errorCode]:Jn,[Wn.errorCode]:Wn,[Yn.errorCode]:Yn,[Qn.errorCode]:Qn,[Xn.errorCode]:Xn,[sr.errorCode]:sr,[eo.errorCode]:eo,[to.errorCode]:to};var $t=class extends Error{constructor(t){super(t??"Unauthorized")}};function Ez(e){return["client_secret_basic","client_secret_post","none"].includes(e)}var nu="code",ou="S256";function Iz(e,t){let r=e.client_secret!==void 0;return"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&Ez(e.token_endpoint_auth_method)&&(t.length===0||t.includes(e.token_endpoint_auth_method))?e.token_endpoint_auth_method:t.length===0?r?"client_secret_basic":"none":r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none"}function Oz(e,t,r,n){let{client_id:o,client_secret:s}=t;switch(e){case"client_secret_basic":Az(o,s,r);return;case"client_secret_post":Cz(o,s,n);return;case"none":Nz(o,n);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function Az(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");let n=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${n}`)}function Cz(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}function Nz(e,t){t.set("client_id",e)}async function wg(e){let t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{let n=mg.parse(JSON.parse(r)),{error:o,error_description:s,error_uri:i}=n,a=yg[o]||wt;return new a(s||"",i)}catch(n){let o=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${n}. Raw body: ${r}`;return new wt(o)}}async function ro(e,t){try{return await su(e,t)}catch(r){if(r instanceof rr||r instanceof or)return await e.invalidateCredentials?.("all"),await su(e,t);if(r instanceof nr)return await e.invalidateCredentials?.("tokens"),await su(e,t);throw r}}async function su(e,{serverUrl:t,authorizationCode:r,scope:n,resourceMetadataUrl:o,fetchFn:s}){let i=await e.discoveryState?.(),a,c,l,u=o;if(!u&&i?.resourceMetadataUrl&&(u=new URL(i.resourceMetadataUrl)),i?.authorizationServerUrl){if(c=i.authorizationServerUrl,a=i.resourceMetadata,l=i.authorizationServerMetadata??await bg(c,{fetchFn:s}),!a)try{a=await $g(t,{resourceMetadataUrl:u},s)}catch{}(l!==i.authorizationServerMetadata||a!==i.resourceMetadata)&&await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:a,authorizationServerMetadata:l})}else{let b=await Lz(t,{resourceMetadataUrl:u,fetchFn:s});c=b.authorizationServerUrl,l=b.authorizationServerMetadata,a=b.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:a,authorizationServerMetadata:l})}let d=await Mz(t,e,a),f=n||a?.scopes_supported?.join(" ")||e.clientMetadata.scope,m=await Promise.resolve(e.clientInformation());if(!m){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");let b=l?.client_id_metadata_document_supported===!0,T=e.clientMetadataUrl;if(T&&!jz(T))throw new sr(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${T}`);if(b&&T)m={client_id:T},await e.saveClientInformation?.(m);else{if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");let x=await Kz(c,{metadata:l,clientMetadata:e.clientMetadata,scope:f,fetchFn:s});await e.saveClientInformation(x),m=x}}let h=!e.redirectUrl;if(r!==void 0||h){let b=await Bz(e,c,{metadata:l,resource:d,authorizationCode:r,fetchFn:s});return await e.saveTokens(b),"AUTHORIZED"}let g=await e.tokens();if(g?.refresh_token)try{let b=await Hz(c,{metadata:l,clientInformation:m,refreshToken:g.refresh_token,resource:d,addClientAuthentication:e.addClientAuthentication,fetchFn:s});return await e.saveTokens(b),"AUTHORIZED"}catch(b){if(!(!(b instanceof ge)||b instanceof wt))throw b}let v=e.state?await e.state():void 0,{authorizationUrl:$,codeVerifier:S}=await Fz(c,{metadata:l,clientInformation:m,state:v,redirectUrl:e.redirectUrl,scope:f,resource:d});return await e.saveCodeVerifier(S),await e.redirectToAuthorization($),"REDIRECT"}function jz(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="https:"&&t.pathname!=="/"}catch{return!1}}async function Mz(e,t,r){let n=gg(e);if(t.validateResourceURL)return await t.validateResourceURL(n,r?.resource);if(r){if(!_g({requestedResource:n,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${n} (or origin)`);return new URL(r.resource)}}function au(e){let t=e.headers.get("WWW-Authenticate");if(!t)return{};let[r,n]=t.split(" ");if(r.toLowerCase()!=="bearer"||!n)return{};let o=iu(e,"resource_metadata")||void 0,s;if(o)try{s=new URL(o)}catch{}let i=iu(e,"scope")||void 0,a=iu(e,"error")||void 0;return{resourceMetadataUrl:s,scope:i,error:a}}function iu(e,t){let r=e.headers.get("WWW-Authenticate");if(!r)return null;let n=new RegExp(`${t}=(?:"([^"]+)"|([^\\s,]+))`),o=r.match(n);return o?o[1]||o[2]:null}async function $g(e,t,r=fetch){let n=await Uz(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!n||n.status===404)throw await n?.body?.cancel(),new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!n.ok)throw await n.body?.cancel(),new Error(`HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`);return dg.parse(await n.json())}async function cu(e,t,r=fetch){try{return await r(e,{headers:t})}catch(n){if(n instanceof TypeError)return t?cu(e,void 0,r):void 0;throw n}}function Zz(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function vg(e,t,r=fetch){return await cu(e,{"MCP-Protocol-Version":t},r)}function Dz(e,t){return!e||e.status>=400&&e.status<500&&t!=="/"}async function Uz(e,t,r,n){let o=new URL(e),s=n?.protocolVersion??br,i;if(n?.metadataUrl)i=new URL(n.metadataUrl);else{let c=Zz(t,o.pathname);i=new URL(c,n?.metadataServerUrl??o),i.search=o.search}let a=await vg(i,s,r);if(!n?.metadataUrl&&Dz(a,o.pathname)){let c=new URL(`/.well-known/${t}`,o);a=await vg(c,s,r)}return a}function qz(e){let t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",n=[];if(!r)return n.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),n.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),n;let o=t.pathname;return o.endsWith("/")&&(o=o.slice(0,-1)),n.push({url:new URL(`/.well-known/oauth-authorization-server${o}`,t.origin),type:"oauth"}),n.push({url:new URL(`/.well-known/openid-configuration${o}`,t.origin),type:"oidc"}),n.push({url:new URL(`${o}/.well-known/openid-configuration`,t.origin),type:"oidc"}),n}async function bg(e,{fetchFn:t=fetch,protocolVersion:r=br}={}){let n={"MCP-Protocol-Version":r,Accept:"application/json"},o=qz(e);for(let{url:s,type:i}of o){let a=await cu(s,n,t);if(a){if(!a.ok){if(await a.body?.cancel(),a.status>=400&&a.status<500)continue;throw new Error(`HTTP ${a.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${s}`)}return i==="oauth"?ru.parse(await a.json()):pg.parse(await a.json())}}}async function Lz(e,t){let r,n;try{r=await $g(e,{resourceMetadataUrl:t?.resourceMetadataUrl},t?.fetchFn),r.authorization_servers&&r.authorization_servers.length>0&&(n=r.authorization_servers[0])}catch{}n||(n=String(new URL("/",e)));let o=await bg(n,{fetchFn:t?.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:o,resourceMetadata:r}}async function Fz(e,{metadata:t,clientInformation:r,redirectUrl:n,scope:o,state:s,resource:i}){let a;if(t){if(a=new URL(t.authorization_endpoint),!t.response_types_supported.includes(nu))throw new Error(`Incompatible auth server: does not support response type ${nu}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(ou))throw new Error(`Incompatible auth server: does not support code challenge method ${ou}`)}else a=new URL("/authorize",e);let c=await tu(),l=c.code_verifier,u=c.code_challenge;return a.searchParams.set("response_type",nu),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",u),a.searchParams.set("code_challenge_method",ou),a.searchParams.set("redirect_uri",String(n)),s&&a.searchParams.set("state",s),o&&a.searchParams.set("scope",o),o?.includes("offline_access")&&a.searchParams.append("prompt","consent"),i&&a.searchParams.set("resource",i.href),{authorizationUrl:a,codeVerifier:l}}function Vz(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function Sg(e,{metadata:t,tokenRequestParams:r,clientInformation:n,addClientAuthentication:o,resource:s,fetchFn:i}){let a=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e),c=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"});if(s&&r.set("resource",s.href),o)await o(c,r,a,t);else if(n){let u=t?.token_endpoint_auth_methods_supported??[],d=Iz(n,u);Oz(d,n,c,r)}let l=await(i??fetch)(a,{method:"POST",headers:c,body:r});if(!l.ok)throw await wg(l);return fg.parse(await l.json())}async function Hz(e,{metadata:t,clientInformation:r,refreshToken:n,resource:o,addClientAuthentication:s,fetchFn:i}){let a=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),c=await Sg(e,{metadata:t,tokenRequestParams:a,clientInformation:r,addClientAuthentication:s,resource:o,fetchFn:i});return{refresh_token:n,...c}}async function Bz(e,t,{metadata:r,resource:n,authorizationCode:o,fetchFn:s}={}){let i=e.clientMetadata.scope,a;if(e.prepareTokenRequest&&(a=await e.prepareTokenRequest(i)),!a){if(!o)throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");if(!e.redirectUrl)throw new Error("redirectUrl is required for authorization_code flow");let l=await e.codeVerifier();a=Vz(o,l,e.redirectUrl)}let c=await e.clientInformation();return Sg(t,{metadata:r,tokenRequestParams:a,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:s})}async function Kz(e,{metadata:t,clientMetadata:r,scope:n,fetchFn:o}){let s;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");s=new URL(t.registration_endpoint)}else s=new URL("/register",e);let i=await(o??fetch)(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...r,...n!==void 0?{scope:n}:{}})});if(!i.ok)throw await wg(i);return hg.parse(await i.json())}var no=class extends Error{constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}},xg=10,Gz=13,ir=32;function uu(e){}function Pg(e){if(typeof e=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=uu,onError:r=uu,onRetry:n=uu,onComment:o,maxBufferSize:s}=e,i=[],a=0,c=!0,l,u="",d=0,f,m=!1;function h(y){if(m)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,y.charCodeAt(0)===239&&y.charCodeAt(1)===187&&y.charCodeAt(2)===191&&(y=y.slice(3))),i.length===0){let G=v(y);G!==""&&(i.push(G),a=G.length),g();return}if(y.indexOf(`
36
+ `)===-1&&y.indexOf("\r")===-1){i.push(y),a+=y.length,g();return}i.push(y);let x=i.join("");i.length=0,a=0;let R=v(x);R!==""&&(i.push(R),a=R.length),g()}function g(){s!==void 0&&(a+u.length<=s||(m=!0,i.length=0,a=0,l=void 0,u="",d=0,f=void 0,r(new no(`Buffered data exceeded max buffer size of ${s} characters`,{type:"max-buffer-size-exceeded"}))))}function v(y){let x=0;if(y.indexOf("\r")===-1){let R=y.indexOf(`
37
+ `,x);for(;R!==-1;){if(x===R){d>0&&t({id:l,event:f,data:u}),l=void 0,u="",d=0,f=void 0,x=R+1,R=y.indexOf(`
38
+ `,x);continue}let G=y.charCodeAt(x);if(zg(y,x,G)){let Q=y.charCodeAt(x+5)===ir?x+6:x+5,me=y.slice(Q,R);if(d===0&&y.charCodeAt(R+1)===xg){t({id:l,event:f,data:me}),l=void 0,u="",f=void 0,x=R+2,R=y.indexOf(`
39
+ `,x);continue}u=d===0?me:`${u}
40
+ ${me}`,d++}else kg(y,x,G)?f=y.slice(y.charCodeAt(x+6)===ir?x+7:x+6,R)||void 0:$(y,x,R);x=R+1,R=y.indexOf(`
41
+ `,x)}return y.slice(x)}for(;x<y.length;){let R=y.indexOf("\r",x),G=y.indexOf(`
42
+ `,x),Q=-1;if(R!==-1&&G!==-1?Q=R<G?R:G:R!==-1?R===y.length-1?Q=-1:Q=R:G!==-1&&(Q=G),Q===-1)break;$(y,x,Q),x=Q+1,y.charCodeAt(x-1)===Gz&&y.charCodeAt(x)===xg&&x++}return y.slice(x)}function $(y,x,R){if(x===R){b();return}let G=y.charCodeAt(x);if(zg(y,x,G)){let Ce=y.charCodeAt(x+5)===ir?x+6:x+5,pr=y.slice(Ce,R);u=d===0?pr:`${u}
43
+ ${pr}`,d++;return}if(kg(y,x,G)){f=y.slice(y.charCodeAt(x+6)===ir?x+7:x+6,R)||void 0;return}if(G===105&&y.charCodeAt(x+1)===100&&y.charCodeAt(x+2)===58){let Ce=y.slice(y.charCodeAt(x+3)===ir?x+4:x+3,R);l=Ce.includes("\0")?void 0:Ce;return}if(G===58){if(o){let Ce=y.slice(x,R);o(Ce.slice(y.charCodeAt(x+1)===ir?2:1))}return}let Q=y.slice(x,R),me=Q.indexOf(":");if(me===-1){S(Q,"",Q);return}let qe=Q.slice(0,me),dr=Q.charCodeAt(me+1)===ir?2:1,xt=Q.slice(me+dr);S(qe,xt,Q)}function S(y,x,R){switch(y){case"event":f=x||void 0;break;case"data":u=d===0?x:`${u}
44
+ ${x}`,d++;break;case"id":l=x.includes("\0")?void 0:x;break;case"retry":/^\d+$/.test(x)?n(parseInt(x,10)):r(new no(`Invalid \`retry\` value: "${x}"`,{type:"invalid-retry",value:x,line:R}));break;default:r(new no(`Unknown field "${y.length>20?`${y.slice(0,20)}\u2026`:y}"`,{type:"unknown-field",field:y,value:x,line:R}));break}}function b(){d>0&&t({id:l,event:f,data:u}),l=void 0,u="",d=0,f=void 0}function T(y={}){if(y.consume&&i.length>0){let x=i.join("");$(x,0,x.length)}c=!0,l=void 0,u="",d=0,f=void 0,i.length=0,a=0,m=!1}return{feed:h,reset:T}}function zg(e,t,r){return r===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function kg(e,t,r){return r===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var Ss=class extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:o}={}){let s;super({start(i){s=Pg({onEvent:a=>{i.enqueue(a)},onError(a){typeof t=="function"&&t(a),(t==="terminate"||a.type==="max-buffer-size-exceeded")&&i.error(a)},onRetry:r,onComment:n,maxBufferSize:o})},transform(i){s.feed(i)}})}};var Jz={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},jt=class extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}},Vr=class{constructor(t,r){this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=r?.requestInit,this._authProvider=r?.authProvider,this._fetch=r?.fetch,this._fetchWithInit=ug(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??Jz}async _authThenStart(){if(!this._authProvider)throw new $t("No auth provider");let t;try{t=await ro(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})}catch(r){throw this.onerror?.(r),r}if(t!=="AUTHORIZED")throw new $t;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){let t={};if(this._authProvider){let n=await this._authProvider.tokens();n&&(t.Authorization=`Bearer ${n.access_token}`)}this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion);let r=bs(this._requestInit?.headers);return new Headers({...t,...r})}async _startOrAuthSse(t){let{resumptionToken:r}=t;try{let n=await this._commonHeaders();n.set("Accept","text/event-stream"),r&&n.set("last-event-id",r);let o=await(this._fetch??fetch)(this._url,{method:"GET",headers:n,signal:this._abortController?.signal});if(!o.ok){if(await o.body?.cancel(),o.status===401&&this._authProvider)return await this._authThenStart();if(o.status===405)return;throw new jt(o.status,`Failed to open SSE stream: ${o.statusText}`)}this._handleSseStream(o.body,t,!0)}catch(n){throw this.onerror?.(n),n}}_getNextReconnectionDelay(t){if(this._serverRetryMs!==void 0)return this._serverRetryMs;let r=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,o=this._reconnectionOptions.maxReconnectionDelay;return Math.min(r*Math.pow(n,t),o)}_scheduleReconnection(t,r=0){let n=this._reconnectionOptions.maxRetries;if(r>=n){this.onerror?.(new Error(`Maximum reconnection attempts (${n}) exceeded.`));return}let o=this._getNextReconnectionDelay(r);this._reconnectionTimeout=setTimeout(()=>{this._startOrAuthSse(t).catch(s=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(t,r+1)})},o)}_handleSseStream(t,r,n){if(!t)return;let{onresumptiontoken:o,replayMessageId:s}=r,i,a=!1,c=!1;(async()=>{try{let u=t.pipeThrough(new TextDecoderStream).pipeThrough(new Ss({onRetry:m=>{this._serverRetryMs=m}})).getReader();for(;;){let{value:m,done:h}=await u.read();if(h)break;if(m.id&&(i=m.id,a=!0,o?.(m.id)),!!m.data&&(!m.event||m.event==="message"))try{let g=Sr.parse(JSON.parse(m.data));Lt(g)&&(c=!0,s!==void 0&&(g.id=s)),this.onmessage?.(g)}catch(g){this.onerror?.(g)}}(n||a)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:s},0)}catch(u){if(this.onerror?.(new Error(`SSE stream disconnected: ${u}`)),(n||a)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:o,replayMessageId:s},0)}catch(m){this.onerror?.(new Error(`Failed to reconnect: ${m instanceof Error?m.message:String(m)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(t){if(!this._authProvider)throw new $t("No auth provider");if(await ro(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new $t("Failed to authorize")}async close(){this._reconnectionTimeout&&(clearTimeout(this._reconnectionTimeout),this._reconnectionTimeout=void 0),this._abortController?.abort(),this.onclose?.()}async send(t,r){try{let{resumptionToken:n,onresumptiontoken:o}=r||{};if(n){this._startOrAuthSse({resumptionToken:n,replayMessageId:an(t)?t.id:void 0}).catch(f=>this.onerror?.(f));return}let s=await this._commonHeaders();s.set("content-type","application/json"),s.set("accept","application/json, text/event-stream");let i={...this._requestInit,method:"POST",headers:s,body:JSON.stringify(t),signal:this._abortController?.signal},a=await(this._fetch??fetch)(this._url,i),c=a.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!a.ok){let f=await a.text().catch(()=>null);if(a.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new jt(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:m,scope:h}=au(a);if(this._resourceMetadataUrl=m,this._scope=h,await ro(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new $t;return this._hasCompletedAuthFlow=!0,this.send(t)}if(a.status===403&&this._authProvider){let{resourceMetadataUrl:m,scope:h,error:g}=au(a);if(g==="insufficient_scope"){let v=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===v)throw new jt(403,"Server returned 403 after trying upscoping");if(h&&(this._scope=h),m&&(this._resourceMetadataUrl=m),this._lastUpscopingHeader=v??void 0,await ro(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new $t;return this.send(t)}}throw new jt(a.status,`Error POSTing to endpoint: ${f}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),nf(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(f=>this.onerror?.(f));return}let u=(Array.isArray(t)?t:[t]).filter(f=>"method"in f&&"id"in f&&f.id!==void 0).length>0,d=a.headers.get("content-type");if(u)if(d?.includes("text/event-stream"))this._handleSseStream(a.body,{onresumptiontoken:o},!1);else if(d?.includes("application/json")){let f=await a.json(),m=Array.isArray(f)?f.map(h=>Sr.parse(h)):[Sr.parse(f)];for(let h of m)this.onmessage?.(h)}else throw await a.body?.cancel(),new jt(-1,`Unexpected content type: ${d}`);else await a.body?.cancel()}catch(n){throw this.onerror?.(n),n}}get sessionId(){return this._sessionId}async terminateSession(){if(this._sessionId)try{let t=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:t,signal:this._abortController?.signal},n=await(this._fetch??fetch)(this._url,r);if(await n.body?.cancel(),!n.ok&&n.status!==405)throw new jt(n.status,`Failed to terminate session: ${n.statusText}`);this._sessionId=void 0}catch(t){throw this.onerror?.(t),t}}setProtocolVersion(t){this._protocolVersion=t}get protocolVersion(){return this._protocolVersion}async resumeStream(t,r){await this._startOrAuthSse({resumptionToken:t,onresumptiontoken:r?.onresumptiontoken})}};import*as Ie from"node:fs";import{randomBytes as Wz}from"node:crypto";import{homedir as Rg}from"node:os";import{resolve as zs,join as lu,dirname as du,basename as Yz}from"node:path";var oo=["owner","shared","open"],Hr={brokerUrl:"wss://broker1.ours.network",port:3050,stateDir:zs(Rg(),".ours"),gcIntervalMs:36e5,autoStart:!1,apiVisibility:"owner"};function ks(){return process.env.OURS_CONFIG??lu(Rg(),".ours","config.json")}function Qz(){let e;try{e=Ie.readFileSync(ks(),"utf8")}catch{return{}}let t;try{t=JSON.parse(e)}catch{return{}}let r={};if(typeof t.brokerUrl=="string"&&(r.brokerUrl=t.brokerUrl),typeof t.port=="number"&&Number.isFinite(t.port)&&(r.port=t.port),typeof t.stateDir=="string"&&(r.stateDir=zs(t.stateDir)),typeof t.gcIntervalMs=="number"&&Number.isFinite(t.gcIntervalMs)&&(r.gcIntervalMs=t.gcIntervalMs),typeof t.autoStart=="boolean"&&(r.autoStart=t.autoStart),typeof t.apiVisibility=="string"&&oo.includes(t.apiVisibility)&&(r.apiVisibility=t.apiVisibility),typeof t.apiToken=="string"&&t.apiToken.trim()&&(r.apiToken=t.apiToken.trim()),t.stt&&typeof t.stt=="object"){let n=t.stt,o={};typeof n.provider=="string"&&(o.provider=n.provider),typeof n.apiKey=="string"&&(o.apiKey=n.apiKey),typeof n.model=="string"&&(o.model=n.model),typeof n.baseUrl=="string"&&(o.baseUrl=n.baseUrl),typeof n.language=="string"&&(o.language=n.language),typeof n.maxBytes=="number"&&Number.isFinite(n.maxBytes)&&(o.maxBytes=n.maxBytes),typeof n.timeoutMs=="number"&&Number.isFinite(n.timeoutMs)&&(o.timeoutMs=n.timeoutMs),n.custom&&typeof n.custom=="object"&&(o.custom=n.custom),r.stt=o}return r}function Xz(){let e=process.env.OURS_API_VISIBILITY?.trim().toLowerCase();return e&&oo.includes(e)?e:void 0}function ek(e){let t=process.env[e];if(t!==void 0)return t==="1"||t.toLowerCase()==="true"}function Tg(e){let t=process.env[e];if(t===void 0)return;let r=parseInt(t,10);return Number.isNaN(r)?void 0:r}function pu(){let e=Qz();return{brokerUrl:process.env.OURS_BROKER_URL??e.brokerUrl??Hr.brokerUrl,port:Tg("OURS_PORT")??e.port??Hr.port,stateDir:zs(process.env.OURS_STATE_DIR??e.stateDir??Hr.stateDir),gcIntervalMs:Tg("OURS_GC_INTERVAL_MS")??e.gcIntervalMs??Hr.gcIntervalMs,autoStart:ek("OURS_AUTOSTART")??e.autoStart??Hr.autoStart,apiVisibility:Xz()??e.apiVisibility??Hr.apiVisibility,apiToken:process.env.OURS_API_TOKEN?.trim()||e.apiToken,stt:tk(e.stt)}}function tk(e){let t={};process.env.OURS_STT_PROVIDER?.trim()&&(t.provider=process.env.OURS_STT_PROVIDER.trim()),process.env.OURS_STT_API_KEY?.trim()&&(t.apiKey=process.env.OURS_STT_API_KEY.trim()),process.env.OURS_STT_MODEL?.trim()&&(t.model=process.env.OURS_STT_MODEL.trim()),process.env.OURS_STT_BASE_URL?.trim()&&(t.baseUrl=process.env.OURS_STT_BASE_URL.trim()),process.env.OURS_STT_LANGUAGE?.trim()&&(t.language=process.env.OURS_STT_LANGUAGE.trim());let r={...e??{},...t};return Object.keys(r).length?r:void 0}var rk="daemon-token";function nk(e){return lu(e.stateDir,rk)}function Eg(e,t={}){let r=process.env.OURS_API_TOKEN?.trim();if(r)return{token:r,source:"env"};let n=e.apiToken?.trim();if(n)return{token:n,source:"config"};let o=nk(e);try{let i=Ie.readFileSync(o,"utf8").trim();if(i)return{token:i,source:"file"}}catch{}if(!t.generate)return null;let s=Wz(32).toString("hex");try{Ie.mkdirSync(du(o),{recursive:!0}),Ie.writeFileSync(o,s+`
45
+ `,{mode:384}),Ie.chmodSync(o,384)}catch{}return{token:s,source:"generated"}}function Ig(e){let t=ks();Ie.mkdirSync(du(t),{recursive:!0}),Ie.writeFileSync(t,JSON.stringify(e,null,2)+`
46
+ `,{mode:384});try{Ie.chmodSync(t,384)}catch{}return t}var xs=".ours-identity";function Ps(e){if(!e.name.trim())throw new Error("identity name must not be empty");let t={identity:e.name.trim()};return e.force&&(t.force=!0),t.expose_local=e.exposeLocal??!0,t.local_auto_accept=e.localAutoAccept??!0,t}function fu(e){let t=zs(e);return Yz(t)===xs?t:lu(t,xs)}function Og(e,t,r=!1){let n=Ps(t),o=fu(e);if(!r&&Ie.existsSync(o))throw new Error(`${o} already exists \u2014 pass overwrite to replace it`);return Ie.mkdirSync(du(o),{recursive:!0}),Ie.writeFileSync(o,JSON.stringify(n,null,2)+`
47
47
  `),o}import Cg from"node:process";var Ts=class{append(t){this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
48
- `);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),rk(r)}clear(){this._buffer=void 0}};function rk(e){return br.parse(JSON.parse(e))}function Og(e){return JSON.stringify(e)+`
49
- `}var Rs=class{constructor(t=Cg.stdin,r=Cg.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new Ts,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=Og(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};function Ag(e){let{selfVersion:t,daemonVersion:r}=e;return!r||r===t?null:`ours: version mismatch \u2014 this plugin/connector is v${t}, the running daemon is v${r}. Everything still works; for the best experience run matching versions. The daemon is a shared singleton and is never restarted automatically, so when no other session is mid-task run \`ours-mcp stop\` (the next session starts the daemon at the new version) \u2014 or update the lagging side to match. No action is required; this is advisory.`}import{mkdirSync as nk,writeFileSync as ok,readFileSync as sk,readdirSync as ik,statSync as Ng,unlinkSync as ak,chmodSync as jg}from"node:fs";import{join as Es}from"node:path";import{homedir as ck}from"node:os";var uk="0.13.0",lk=new Set(["choose_identity","create_identity","create_root_identity"]),Zg=e=>new Promise(t=>setTimeout(t,e)),dk=e=>typeof e?.method=="string"&&e.id!==void 0&&e.id!==null,pk=e=>e&&typeof e=="object"&&!("method"in e)&&e.id!==void 0&&e.id!==null,Mg=e=>{let t=e.result;return!!e.error||!!(t&&t.isError)},Dg=Number(process.env.OURS_RESTORE_TTL_MS)>0?Number(process.env.OURS_RESTORE_TTL_MS):7*24*60*60*1e3,qg=["1","true","yes","on"].includes((process.env.OURS_NO_AUTORESTORE??"").trim().toLowerCase());async function Lg(e){let t=new URL(e.url),r=(...I)=>process.stderr.write(`[ours-proxy] ${I.join(" ")}
50
- `),n=I=>Number.isInteger(I)&&I>1,o=Number(process.env.OURS_CLIENT_PID),s=n(o)?o:n(process.ppid)?process.ppid:process.pid,i=(process.env.CLAUDE_CODE_SESSION_ID??"").trim()||`client:${s}`,a=null,c=null,u,l=null,d=new Map,m=null,f=qg?null:(process.env.CLAUDE_CODE_SESSION_ID??"").trim()||null,h=e.stateDir??process.env.OURS_STATE_DIR??Es(ck(),".ours"),g=Es(h,"session-restore"),v=f&&/^[A-Za-z0-9._-]{1,200}$/.test(f)?f:null,w=v?Es(g,`${v}.json`):null,x=!1,$=null;function T(I){if(w)try{nk(g,{recursive:!0,mode:448}),ok(w,JSON.stringify({claudeSessionId:f,identity:I,boundAt:new Date().toISOString()}),{mode:384}),jg(g,448),jg(w,384)}catch(F){r("restore persist failed (non-fatal):",String(F))}}function y(){if(!w)return null;try{if(Date.now()-Ng(w).mtimeMs>Dg)return null;let I=JSON.parse(sk(w,"utf8"));return(typeof I.identity=="string"?I.identity.trim():"")||null}catch{return null}}function S(){try{let I=Date.now();for(let F of ik(g)){if(!F.endsWith(".json"))continue;let Y=Es(g,F);try{I-Ng(Y).mtimeMs>Dg&&(ak(Y),r("session-restore: pruned expired record",F))}catch{}}}catch{}}let R=null,J=!1,W=!1,me=!1,st=[],lr="__ours_proxy_init__",xt=0,Ae=new Set,dr=new Set,Zt=new Rs;Zt.onmessage=I=>{let F=[],Y=!1;for(let Je of Ug(I)){let _e=Je;if(_e.method==="notifications/initialized"&&(Y=!0),dk(_e)){if(_e.method==="initialize"&&(a=_e,c)){r("absorbed re-initialize locally \u2014 upstream session kept stable"),Zt.send({jsonrpc:"2.0",id:_e.id,result:c}).catch(we=>r("local initialize reply failed:",String(we)));continue}if(_e.method==="tools/call"){let we=_e.params;we&&lk.has(we.name??"")&&typeof we.arguments?.name=="string"&&d.set(_e.id,we.arguments.name)}}F.push(_e)}if(F.length){let Je=Array.isArray(I)?F:F[0];bu(Je)}Y&&t_()},Zt.onclose=()=>void js(0),Zt.onerror=I=>r("downstream error:",String(I));function t_(){if(x||!l)return;x=!0;let I=`__ours_proxy_restore_${++xt}__`;Ae.add(I),$=I,r("session-restore: self-recovering bound identity",`"${l}"`),bu({jsonrpc:"2.0",id:I,method:"tools/call",params:{name:"choose_identity",arguments:{name:l}}})}function bu(I){if(J&&R){let F=R;R.send(I).catch(Y=>{r("upstream send failed:",String(Y)),st.push(I),xu(F,"send failed")})}else st.push(I)}function xu(I,F){if(W||me||R!==null&&I!==R)return;r(`upstream dropped (${F}) \u2014 reconnecting`),J=!1;let Y=R;R=null;try{Y?.close?.()}catch{}n_()}function r_(I){I.onmessage=F=>{let Y=[];for(let Je of Ug(F)){let _e=Je;if(pk(_e)){let we=_e.id,Zs=_e.result?.protocolVersion;if(Zs&&(dr.has(we)||Su(we))){u=Zs;try{R?.setProtocolVersion?.(Zs)}catch{}if(c==null&&Su(we)&&!Ae.has(we)){let pt=_e.result??null;pt&&m&&(pt.instructions=`${pt.instructions?pt.instructions+`
48
+ `);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),ok(r)}clear(){this._buffer=void 0}};function ok(e){return Sr.parse(JSON.parse(e))}function Ag(e){return JSON.stringify(e)+`
49
+ `}var Rs=class{constructor(t=Cg.stdin,r=Cg.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new Ts,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=Ag(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};function Ng(e){let{selfVersion:t,daemonVersion:r}=e;return!r||r===t?null:`ours: version mismatch \u2014 this plugin/connector is v${t}, the running daemon is v${r}. Everything still works; for the best experience run matching versions. The daemon is a shared singleton and is never restarted automatically, so when no other session is mid-task run \`ours-mcp stop\` (the next session starts the daemon at the new version) \u2014 or update the lagging side to match. No action is required; this is advisory.`}import{mkdirSync as sk,writeFileSync as ik,readFileSync as ak,readdirSync as ck,statSync as jg,unlinkSync as uk,chmodSync as Mg}from"node:fs";import{join as Es}from"node:path";import{homedir as lk}from"node:os";var dk="0.14.1",pk=new Set(["choose_identity","create_identity","create_root_identity"]),Zg=e=>new Promise(t=>setTimeout(t,e)),fk=e=>typeof e?.method=="string"&&e.id!==void 0&&e.id!==null,mk=e=>e&&typeof e=="object"&&!("method"in e)&&e.id!==void 0&&e.id!==null,Dg=e=>{let t=e.result;return!!e.error||!!(t&&t.isError)},Ug=Number(process.env.OURS_RESTORE_TTL_MS)>0?Number(process.env.OURS_RESTORE_TTL_MS):7*24*60*60*1e3,qg=["1","true","yes","on"].includes((process.env.OURS_NO_AUTORESTORE??"").trim().toLowerCase());async function Fg(e){let t=new URL(e.url),r=(...I)=>process.stderr.write(`[ours-proxy] ${I.join(" ")}
50
+ `),n=I=>Number.isInteger(I)&&I>1,o=Number(process.env.OURS_CLIENT_PID),s=n(o)?o:n(process.ppid)?process.ppid:process.pid,i=(process.env.CLAUDE_CODE_SESSION_ID??"").trim()||`client:${s}`,a=null,c=null,l,u=null,d=new Map,f=null,m=qg?null:(process.env.CLAUDE_CODE_SESSION_ID??"").trim()||null,h=e.stateDir??process.env.OURS_STATE_DIR??Es(lk(),".ours"),g=Es(h,"session-restore"),v=m&&/^[A-Za-z0-9._-]{1,200}$/.test(m)?m:null,$=v?Es(g,`${v}.json`):null,S=!1,b=null;function T(I){if($)try{sk(g,{recursive:!0,mode:448}),ik($,JSON.stringify({claudeSessionId:m,identity:I,boundAt:new Date().toISOString()}),{mode:384}),Mg(g,448),Mg($,384)}catch(F){r("restore persist failed (non-fatal):",String(F))}}function y(){if(!$)return null;try{if(Date.now()-jg($).mtimeMs>Ug)return null;let I=JSON.parse(ak($,"utf8"));return(typeof I.identity=="string"?I.identity.trim():"")||null}catch{return null}}function x(){try{let I=Date.now();for(let F of ck(g)){if(!F.endsWith(".json"))continue;let W=Es(g,F);try{I-jg(W).mtimeMs>Ug&&(uk(W),r("session-restore: pruned expired record",F))}catch{}}}catch{}}let R=null,G=!1,Q=!1,me=!1,qe=[],dr="__ours_proxy_init__",xt=0,Ce=new Set,pr=new Set,Zt=new Rs;Zt.onmessage=I=>{let F=[],W=!1;for(let We of Lg(I)){let _e=We;if(_e.method==="notifications/initialized"&&(W=!0),fk(_e)){if(_e.method==="initialize"&&(a=_e,c)){r("absorbed re-initialize locally \u2014 upstream session kept stable"),Zt.send({jsonrpc:"2.0",id:_e.id,result:c}).catch(we=>r("local initialize reply failed:",String(we)));continue}if(_e.method==="tools/call"){let we=_e.params;we&&pk.has(we.name??"")&&typeof we.arguments?.name=="string"&&d.set(_e.id,we.arguments.name)}}F.push(_e)}if(F.length){let We=Array.isArray(I)?F:F[0];Su(We)}W&&n_()},Zt.onclose=()=>void js(0),Zt.onerror=I=>r("downstream error:",String(I));function n_(){if(S||!u)return;S=!0;let I=`__ours_proxy_restore_${++xt}__`;Ce.add(I),b=I,r("session-restore: self-recovering bound identity",`"${u}"`),Su({jsonrpc:"2.0",id:I,method:"tools/call",params:{name:"choose_identity",arguments:{name:u}}})}function Su(I){if(G&&R){let F=R;R.send(I).catch(W=>{r("upstream send failed:",String(W)),qe.push(I),xu(F,"send failed")})}else qe.push(I)}function xu(I,F){if(Q||me||R!==null&&I!==R)return;r(`upstream dropped (${F}) \u2014 reconnecting`),G=!1;let W=R;R=null;try{W?.close?.()}catch{}s_()}function o_(I){I.onmessage=F=>{let W=[];for(let We of Lg(F)){let _e=We;if(mk(_e)){let we=_e.id,Ms=_e.result?.protocolVersion;if(Ms&&(pr.has(we)||zu(we))){l=Ms;try{R?.setProtocolVersion?.(Ms)}catch{}if(c==null&&zu(we)&&!Ce.has(we)){let pt=_e.result??null;pt&&f&&(pt.instructions=`${pt.instructions?pt.instructions+`
51
51
 
52
- `:""}${m}`),c=pt}dr.delete(we)}if(Ae.has(we)){Ae.delete(we),we===$&&($=null,Mg(_e)&&(l=null,r("session-restore: re-bind refused (identity live elsewhere) \u2014 staying unbound")));continue}if(d.has(we)){let pt=d.get(we);d.delete(we),Mg(_e)||(l=pt,r("bound identity tracked:",pt),T(pt))}}Y.push(_e)}if(Y.length){let Je=Array.isArray(F)?Y:Y[0];Zt.send(Je).catch(_e=>r("downstream send failed:",String(_e)))}},I.onerror=F=>r("upstream error:",String(F)),I.onclose=()=>xu(I,"closed")}let Su=I=>a!=null&&a.id===I;async function zu(){e.ensureDaemon&&await e.ensureDaemon().catch(F=>r("ensureDaemon:",String(F)));let I=new Fr(t,{requestInit:{headers:{"x-ours-lease-token":i,"x-ours-client-pid":String(s),...e.apiToken?{"x-ours-api-token":e.apiToken}:{}}}});if(r_(I),await I.start(),u)try{I.setProtocolVersion?.(u)}catch{}R=I}async function ku(I,F){F&&I.id!==void 0&&Ae.add(I.id),await R.send(I)}async function n_(){if(me||W)return;me=!0;let I=500;for(;;){if(W){me=!1;return}try{if(await zu(),a){let Y=`${lr}${xt}`;dr.add(Y),await ku({...a,id:Y},!0),await R.send({jsonrpc:"2.0",method:"notifications/initialized"})}if(l){let Y=`__ours_proxy_rebind_${++xt}__`;await ku({jsonrpc:"2.0",id:Y,method:"tools/call",params:{name:"choose_identity",arguments:{name:l}}},!0)}J=!0;let F=st.splice(0);for(let Y of F)await R.send(Y).catch(Je=>r("flush failed:",String(Je)));r("upstream reconnected",l?`(re-bound "${l}")`:""),me=!1;return}catch(F){r("reconnect attempt failed:",String(F)),await Zg(I),I=Math.min(Math.floor(I*1.5),1e4)}}}async function js(I){if(!W){W=!0;try{await R?.close()}catch{}try{await Zt.close()}catch{}process.exit(I)}}process.on("SIGINT",()=>void js(0)),process.on("SIGTERM",()=>void js(0));async function o_(){let I=new URL(t.href);I.pathname="/state-dir";let F;try{F=await(await fetch(I,{signal:AbortSignal.timeout(3e3)})).json()}catch(Y){r("compat handshake: could not read daemon /state-dir, proceeding:",String(Y));return}m=Ag({selfVersion:uk,daemonVersion:typeof F?.version=="string"?F.version:null}),m&&r(m)}if((async()=>{e.ensureDaemon&&await e.ensureDaemon().catch(Y=>r("ensureDaemon:",String(Y))),await o_();let I=500;for(;;)try{await zu();break}catch(Y){r("initial upstream connect failed, retrying:",String(Y)),await Zg(I),I=Math.min(Math.floor(I*1.5),1e4)}J=!0;let F=st.splice(0);for(let Y of F)await R.send(Y).catch(Je=>r("flush failed:",String(Je)));r(`upstream ready \u2014 stdio \u21C4 ${t.href}`)})(),f){S();let I=y();I&&(l=I,r("session-restore: found prior binding for this session \u2014 will self-recover",`"${I}"`))}else qg&&r("session-restore: disabled via OURS_NO_AUTORESTORE \u2014 pure in-memory binding");await Zt.start(),r("proxy started (stdio transport up)")}function Ug(e){return Array.isArray(e)?e:[e]}if(!process.env.XDG_RUNTIME_DIR&&typeof process.getuid=="function"){let e=`/run/user/${process.getuid()}`;U.existsSync(e)&&(process.env.XDG_RUNTIME_DIR=e)}var Kr=pu(),qe=Kr.stateDir,ne=Kr.port,yu=Rg(Kr,{generate:!1})?.token??null,As=()=>yu?{"x-ours-api-token":yu}:{},Br=Kr.brokerUrl,cr=bt(qe,"daemon.pid"),ir=bt(qe,"daemon.log"),Gr=mk(import.meta.url),b=(...e)=>process.stdout.write(`${e.join(" ")}
53
- `),Q=(...e)=>process.stderr.write(`${e.join(" ")}
54
- `),ar="0.13.0";async function vu(){for(let e of["/version","/state-dir"])try{let t=new AbortController,r=setTimeout(()=>t.abort(),1500),n=await fetch(`http://127.0.0.1:${ne}${e}`,{signal:t.signal});if(clearTimeout(r),n.ok){let o=await n.json();if(o&&typeof o.version=="string")return o}}catch{}return null}function Fg(e){if(b(` cli: v${ar}`),e?.version){let t=e.version!==ar;b(` daemon: v${e.version}${e.compat?` (compat ${e.compat})`:""}`+(t?` \u26A0 differs from CLI \u2014 \`ours-mcp restart\` to load v${ar}`:""))}else b(" daemon: version unknown (running build predates /version \u2014 restart to update)")}var Ns=e=>new Promise(t=>setTimeout(t,e));function gk(){try{let e=parseInt(U.readFileSync(cr,"utf8").trim(),10);return Number.isFinite(e)?e:null}catch{return null}}function wu(e){try{return process.kill(e,0),!0}catch{return!1}}function io(){let e=gk();if(e&&wu(e))return e;if(e)try{U.rmSync(cr,{force:!0})}catch{}return null}function ur(e,t=1e3){return new Promise(r=>{let n=fk({host:"127.0.0.1",port:e}),o=s=>{n.destroy(),r(s)};n.setTimeout(t),n.once("connect",()=>o(!0)),n.once("timeout",()=>o(!1)),n.once("error",()=>o(!1))})}async function Wg(e,t=3e4){let r=Date.now()+t;for(;Date.now()<r;){if(await ur(e))return!0;await Ns(400)}return!1}async function Vg(){let e=io();if(e){b(`ours-mcp is already running (pid ${e}, port ${ne}).`);return}U.mkdirSync(qe,{recursive:!0});let t=U.openSync(ir,"a"),r=Bg(process.execPath,[Gr,"serve"],{detached:!0,stdio:["ignore",t,t],env:{...process.env,OURS_TRANSPORT:"http",OURS_PORT:String(ne),OURS_BROKER_URL:Br,OURS_STATE_DIR:qe}});r.unref(),r.pid||(Q("failed to spawn the daemon."),process.exit(1)),U.writeFileSync(cr,String(r.pid)),b(`starting ours-mcp (pid ${r.pid})\u2026`),await Wg(ne)?(b(`ours-mcp is up on http://localhost:${ne}/mcp`),b(` broker: ${Br}`),b(` state: ${qe}`),b(` logs: ${ir}`)):(Q(`daemon started (pid ${r.pid}) but port ${ne} did not open within 30s \u2014 check ${ir}.`),process.exit(1))}async function _k(){if(!await ur(ne)){if(!io()){U.mkdirSync(qe,{recursive:!0});let e=U.openSync(ir,"a"),t=Bg(process.execPath,[Gr,"serve"],{detached:!0,stdio:["ignore",e,e],env:{...process.env,OURS_TRANSPORT:"http",OURS_PORT:String(ne),OURS_BROKER_URL:Br,OURS_STATE_DIR:qe}});if(t.unref(),t.pid)try{U.writeFileSync(cr,String(t.pid))}catch{}}await Wg(ne)}}async function Os(){let e=io();if(!e){b("ours-mcp is not running.");return}b(`stopping ours-mcp (pid ${e})\u2026`);try{process.kill(e,"SIGTERM")}catch(t){Q(`failed to signal pid ${e}: ${String(t)}`)}for(let t=0;t<25&&wu(e);t++)await Ns(200);if(wu(e)){Q(`pid ${e} did not exit; sending SIGKILL.`);try{process.kill(e,"SIGKILL")}catch{}}try{U.rmSync(cr,{force:!0})}catch{}b("stopped.")}async function yk(){let e=io();if(!e){if(await ur(ne)){let n=await vu();b("ours-mcp: running (no pidfile \u2014 likely a stale process or external launcher)"),b(` url: http://localhost:${ne}/mcp (reachable)`),Fg(n);return}b("ours-mcp: stopped"),b(` cli: v${ar}`),process.exitCode=1;return}let t=await ur(ne),r=t?await vu():null;b("ours-mcp: running"),b(` pid: ${e}`),b(` url: http://localhost:${ne}/mcp ${t?"(reachable)":"(port not answering!)"}`),b(` broker: ${Br}`),b(` state: ${qe}`),b(` logs: ${ir}`),Fg(r)}async function vk(){if(b(`ours-mcp v${ar}`),await ur(ne)){let e=await vu();e?.version?b(`running daemon: v${e.version}`+(e.version!==ar?" (differs \u2014 restart to update)":"")):b("running daemon: version unknown (predates /version)")}else b("daemon: not running")}async function wk(){let e=pu(),t=ks();b(`ours-mcp setup \u2014 ${t}`),b("Enter a value, or press Enter to keep the current [bracketed] one."),b("");let r=Is({input:process.stdin,output:process.stdout}),n;try{let u=async(J,W)=>{let me=(await r.question(` ${J} [${W}]: `)).trim();return me===""?W:me},l=await u("broker URL",e.brokerUrl),d=await u("HTTP port",String(e.port)),m=await u("state dir",e.stateDir),f=await u("GC interval (ms)",String(e.gcIntervalMs)),h=await u("proxy auto-starts daemon (true/false)",String(e.autoStart)),g=await u("HTTP visibility (owner=same-user only / shared=cross-user w/ token / open=all local users)",e.apiVisibility);b(""),b(" Voice-message transcription (STT). Leave provider empty to keep it off \u2014"),b(" agents then deterministically tell users voice messages cannot be read."),b(" No provider or model is assumed; model strings pass to your provider verbatim.");let v=(await r.question(` STT provider (openai-compatible / elevenlabs / deepgram / custom, empty=off) [${e.stt?.provider??""}]: `)).trim()||(e.stt?.provider??""),w=e.stt?.model??"",x=e.stt?.baseUrl??"";v&&(w=await u("STT model (verbatim, e.g. whisper-large-v3-turbo / scribe_v1 / nova-2)",w),x=await u("STT base URL (required for openai-compatible; empty = provider default)",x),b(" (API key is not prompted to avoid echoing it \u2014 set OURS_STT_API_KEY or edit stt.apiKey in the config file.)"));let $=parseInt(d,10);(!Number.isFinite($)||$<=0)&&(Q(`invalid port: ${d}`),process.exit(1));let T=parseInt(f,10);(!Number.isFinite(T)||T<=0)&&(Q(`invalid GC interval: ${f}`),process.exit(1));let y=h.toLowerCase()==="true"||h==="1",S=g.trim().toLowerCase();oo.includes(S)||(Q(`invalid visibility: ${g} (expected one of ${oo.join(", ")})`),process.exit(1));let R=v?{...e.stt??{},provider:v,...w?{model:w}:{},...x?{baseUrl:x}:{}}:e.stt;n={brokerUrl:l,port:$,stateDir:Jg(m),gcIntervalMs:T,autoStart:y,apiVisibility:S,...e.apiToken?{apiToken:e.apiToken}:{},...R?{stt:R}:{}}}finally{r.close()}Eg(n),b(""),b(`wrote ${t} (mode 0600):`),b(JSON.stringify(n,null,2));let o=["OURS_BROKER_URL","OURS_PORT","OURS_STATE_DIR","OURS_GC_INTERVAL_MS","OURS_AUTOSTART","OURS_API_VISIBILITY","OURS_API_TOKEN"].filter(u=>process.env[u]!==void 0);o.length&&(b(""),b(`note: these env vars are set and OVERRIDE the file at runtime: ${o.join(", ")}`));let s=io();if(!s)return;let i=Is({input:process.stdin,output:process.stdout}),a=!1;try{let u=(await i.question(`
55
- daemon is running (pid ${s}); restart now to apply? [y/N]: `)).trim().toLowerCase();a=u==="y"||u==="yes"}finally{i.close()}if(!a){b("not restarting \u2014 changes apply on the next `ours-mcp restart`.");return}await Os();let c=Cs(process.execPath,[Gr,"start"],{stdio:"inherit"});c.status!==0&&process.exit(c.status??1)}function hu(e,t,r){return e.includes(r)?{value:!1,set:!0}:e.includes(t)?{value:!0,set:!0}:{value:void 0,set:!1}}function gu(e,t){let r=e.indexOf(t);return r>=0&&r+1<e.length?e[r+1]:void 0}async function $k(e){let t=gu(e,"--name"),r=hu(e,"--force-bind","--no-force-bind"),n=hu(e,"--local-book","--no-local-book"),o=hu(e,"--auto-accept-local","--no-auto-accept-local"),s=e.includes("--overwrite"),i=e.includes("--print"),a=gu(e,"--path")??gu(e,"--dir")??process.cwd(),c=t!==void 0||r.set||n.set||o.set||i,u;if(c?((!t||!t.trim())&&(Q("define-local-identity-file: --name is required in non-interactive mode."),process.exit(1)),u={name:t.trim(),force:r.value??!1,exposeLocal:n.value??!0,localAutoAccept:o.value??!0}):u=await bk(),i){b(JSON.stringify(Ps(u),null,2));return}let l=fu(a);if(!s&&U.existsSync(l)){c&&(Q(`define-local-identity-file: ${l} already exists \u2014 pass --overwrite to replace it.`),process.exit(1));let m=Is({input:process.stdin,output:process.stdout}),f=!1;try{let h=(await m.question(`
56
- ${l} already exists \u2014 overwrite? [y/N]: `)).trim().toLowerCase();f=h==="y"||h==="yes"}finally{m.close()}if(!f){b("aborted \u2014 nothing written.");return}}let d=Ig(a,u,!0);b(""),b(`wrote ${d}:`),b(JSON.stringify(Ps(u),null,2))}async function bk(){b("ours-mcp define-local-identity-file \u2014 interactive"),b(`Answer the prompts; the result is written to ${bt(process.cwd(),Ss)}.`),b("");let e=Is({input:process.stdin,output:process.stdout});try{let t=async(i,a)=>{let c=a?"Y/n":"y/N",u=(await e.question(` ${i} [${c}]: `)).trim().toLowerCase();return u===""?a:u==="y"||u==="yes"},r="";for(;!r;)r=(await e.question(" Identity name: ")).trim(),r||b(" (name is required)");let n=await t("Force-bind (pin pre-authorizes evicting another session)?",!1),o=await t("Add to the host-local contact book?",!0),s=await t("Auto-accept local invites/introductions?",!0);return{name:r,force:n,exposeLocal:o,localAutoAccept:s}}finally{e.close()}}async function xk(e){let t=(e[0]??"").trim();(!t||t.startsWith("--"))&&(Q('usage: ours-mcp create-root "<your name>"'),process.exit(1)),await ur(ne)||(Q(`create-root: the daemon is not running on port ${ne} \u2014 start it with \`ours-mcp start\`.`),process.exit(1));let r=new Fr(new URL(`http://127.0.0.1:${ne}/mcp`),{requestInit:{headers:As()}}),n=new $s({name:"ours-mcp-cli",version:ar});try{await n.connect(r);let o=await n.callTool({name:"create_root_identity",arguments:{name:t,skip_if_root_exists:!0}}),s=(Array.isArray(o.content)?o.content:[]).map(i=>typeof i.text=="string"?i.text:"").join(" ").split(/\n\nAsk the user\b/)[0].replace(/^create_root_identity failed: /,"").trim();if(o.isError){if(/a root identity already exists/i.test(s)){b(`create-root: ${s.split("\u2014")[0].trim()} \u2014 nothing to do.`);return}Q(`create-root failed: ${s}`),process.exit(1)}b(s)}finally{try{await r.terminateSession()}catch{}try{await n.close()}catch{}}}function Yg(e,t){t.event==="message_received"?b(`[${e}] new message from ${t.from??"?"}`+(t.msg_id!==void 0?` (#${t.msg_id})`:"")+(t.date?` (${t.date})`:"")):t.event==="file_received"?b(`[${e}] new file ${t.filename??"?"} from ${t.from??"?"}`+(t.bytes!==void 0?` (${t.bytes} B)`:"")+(t.file_id!==void 0?` (#${t.file_id})`:"")+(t.date?` (${t.date})`:"")):t.event==="local_contact_request"?b(`[${e}] pending local introduction from ${t.from??"?"} \u2014 respond_to_introduction to approve/reject`):t.event==="pending_message"&&b(`[${e}] ${t.from??"?"} queued a message awaiting introduction approval (${t.queued??"?"} queued)`)}function jt(e){Q(`ours-mcp watch: ${e}`),process.exit(1)}async function Sk(){try{let e=new AbortController,t=setTimeout(()=>e.abort(),1500),r=await fetch(`http://127.0.0.1:${ne}/state-dir`,{signal:e.signal});if(clearTimeout(t),r.ok){let n=await r.json();return typeof n.stateDir=="string"&&n.stateDir?Jg(n.stateDir):qe}}catch{}return null}var zk=e=>`http://127.0.0.1:${ne}/identities/${encodeURIComponent(e)}/notifications`;async function Hg(e){let t=async o=>{let s=new AbortController,i=setTimeout(()=>s.abort(),35e3),a;try{a=await fetch(`${zk(e)}?since=${o}`,{headers:As(),signal:s.signal})}finally{clearTimeout(i)}if(a.status===401&&jt(`daemon rejected the API token (401) for identity "${e}". Set OURS_API_TOKEN to the daemon's token (shared mode) or run watch as the daemon owner (owner mode).`),!a.ok)throw new Error(`daemon returned HTTP ${a.status}`);return await a.json()},r=(await t("tip")).cursor??0,n=0;for(;;)try{let o=await t(String(r));if(n=0,Array.isArray(o.events))for(let s of o.events)Yg(e,s);typeof o.cursor=="number"&&(r=o.cursor)}catch(o){n=Math.min(n+1e3,5e3),Q(`ours-mcp watch: notifications stream for "${e}" hiccupped (${String(o?.message??o)}), retrying\u2026`),await Ns(n)}}async function kk(e){if(e){await Hg(e);return}let t=new Set;for(;;){try{let r=await fetch(`http://127.0.0.1:${ne}/identities`,{headers:As()});if(r.status===401&&jt("daemon rejected the API token (401). Set OURS_API_TOKEN or run watch as the daemon owner."),r.ok){let n=await r.json();for(let o of n.identities??[]){let s=typeof o?.name=="string"?o.name:void 0;s&&!t.has(s)&&(t.add(s),Hg(s))}}}catch{}await Ns(3e3)}}var _u=e=>{let t=e?.code;return t==="EACCES"||t==="EPERM"};function Pk(e,t){try{U.readdirSync(e)}catch(i){jt(`cannot watch \u2014 the daemon API is unreachable AND ${e} is not readable (${i?.code??i}). On a multi-user host, run watch as the daemon owner, or enable the daemon API (start the daemon) so watch can stream over HTTP.`)}if(t)try{U.readdirSync(bt(e,t))}catch(i){jt(`cannot watch identity "${t}" \u2014 ${bt(e,t)} is not readable (${i?.code??i}). Is the daemon running and the name correct?`)}let r=new Map,n=i=>{let a;try{a=U.readdirSync(e,{withFileTypes:!0}).filter(c=>c.isDirectory()).map(c=>c.name)}catch(c){_u(c)&&jt(`lost read access to ${e} (${c.code}) \u2014 cannot watch.`);return}for(let c of a){if(t&&c!==t)continue;let u=bt(e,c,"notifications.log"),l;try{l=U.statSync(u).size}catch(f){_u(f)&&jt(`cannot read ${u} (${f.code}) \u2014 cannot watch identity "${c}".`);continue}let d=r.get(u);if(d===void 0&&(d=i?l:0,r.set(u,d),i))continue;if(l<=d){l<d&&r.set(u,l);continue}let m;try{let f=U.openSync(u,"r"),h=Buffer.alloc(l-d);U.readSync(f,h,0,h.length,d),U.closeSync(f),m=h.toString("utf8")}catch(f){_u(f)&&jt(`cannot read ${u} (${f.code}) \u2014 cannot watch identity "${c}".`);continue}r.set(u,l);for(let f of m.split(`
57
- `))if(f.trim())try{Yg(c,JSON.parse(f))}catch{}}};Q(`ours-mcp watch: daemon API unreachable \u2014 falling back to file poll of ${e} (Ctrl-C to stop)`),n(!0);let o=setInterval(()=>n(!1),1e3),s=()=>{clearInterval(o),process.exit(0)};process.on("SIGINT",s),process.on("SIGTERM",s)}async function Tk(){try{let e=await fetch(`http://127.0.0.1:${ne}/identities`,{headers:As()});return e.status===401&&jt("daemon rejected the API token (401). Set OURS_API_TOKEN to the daemon's token (shared mode) or run watch as the daemon owner (owner mode)."),e.status===404?"file":e.ok?"api":"file"}catch{return"file"}}async function Rk(e){let t=()=>process.exit(0);if(process.on("SIGINT",t),process.on("SIGTERM",t),await Sk()!==null&&await Tk()==="api"){Q(`ours-mcp watch: streaming ${e?`identity "${e}"`:"all identities"} from the daemon API on port ${ne} (Ctrl-C to stop)`),await kk(e);return}Pk(qe,e)}var so="ours.service",Qg="solutions.adaptframework.ours";function Xg(){return bt(Gg(),".config","systemd","user",so)}function e_(){return bt(Gg(),"Library","LaunchAgents",`${Qg}.plist`)}function Hr(e,t){return Cs(e,t,{stdio:"inherit"}).status===0}function Ek(){let e=Xg();U.mkdirSync($u(e),{recursive:!0});let t=`[Unit]
52
+ `:""}${f}`),c=pt}pr.delete(we)}if(Ce.has(we)){Ce.delete(we),we===b&&(b=null,Dg(_e)&&(u=null,r("session-restore: re-bind refused (identity live elsewhere) \u2014 staying unbound")));continue}if(d.has(we)){let pt=d.get(we);d.delete(we),Dg(_e)||(u=pt,r("bound identity tracked:",pt),T(pt))}}W.push(_e)}if(W.length){let We=Array.isArray(F)?W:W[0];Zt.send(We).catch(_e=>r("downstream send failed:",String(_e)))}},I.onerror=F=>r("upstream error:",String(F)),I.onclose=()=>xu(I,"closed")}let zu=I=>a!=null&&a.id===I;async function ku(){e.ensureDaemon&&await e.ensureDaemon().catch(F=>r("ensureDaemon:",String(F)));let I=new Vr(t,{requestInit:{headers:{"x-ours-lease-token":i,"x-ours-client-pid":String(s),...e.apiToken?{"x-ours-api-token":e.apiToken}:{}}}});if(o_(I),await I.start(),l)try{I.setProtocolVersion?.(l)}catch{}R=I}async function Pu(I,F){F&&I.id!==void 0&&Ce.add(I.id),await R.send(I)}async function s_(){if(me||Q)return;me=!0;let I=500;for(;;){if(Q){me=!1;return}try{if(await ku(),a){let W=`${dr}${xt}`;pr.add(W),await Pu({...a,id:W},!0),await R.send({jsonrpc:"2.0",method:"notifications/initialized"})}if(u){let W=`__ours_proxy_rebind_${++xt}__`;await Pu({jsonrpc:"2.0",id:W,method:"tools/call",params:{name:"choose_identity",arguments:{name:u}}},!0)}G=!0;let F=qe.splice(0);for(let W of F)await R.send(W).catch(We=>r("flush failed:",String(We)));r("upstream reconnected",u?`(re-bound "${u}")`:""),me=!1;return}catch(F){r("reconnect attempt failed:",String(F)),await Zg(I),I=Math.min(Math.floor(I*1.5),1e4)}}}async function js(I){if(!Q){Q=!0;try{await R?.close()}catch{}try{await Zt.close()}catch{}process.exit(I)}}process.on("SIGINT",()=>void js(0)),process.on("SIGTERM",()=>void js(0));async function i_(){let I=new URL(t.href);I.pathname="/state-dir";let F;try{F=await(await fetch(I,{signal:AbortSignal.timeout(3e3)})).json()}catch(W){r("compat handshake: could not read daemon /state-dir, proceeding:",String(W));return}f=Ng({selfVersion:dk,daemonVersion:typeof F?.version=="string"?F.version:null}),f&&r(f)}if((async()=>{e.ensureDaemon&&await e.ensureDaemon().catch(W=>r("ensureDaemon:",String(W))),await i_();let I=500;for(;;)try{await ku();break}catch(W){r("initial upstream connect failed, retrying:",String(W)),await Zg(I),I=Math.min(Math.floor(I*1.5),1e4)}G=!0;let F=qe.splice(0);for(let W of F)await R.send(W).catch(We=>r("flush failed:",String(We)));r(`upstream ready \u2014 stdio \u21C4 ${t.href}`)})(),m){x();let I=y();I&&(u=I,r("session-restore: found prior binding for this session \u2014 will self-recover",`"${I}"`))}else qg&&r("session-restore: disabled via OURS_NO_AUTORESTORE \u2014 pure in-memory binding");await Zt.start(),r("proxy started (stdio transport up)")}function Lg(e){return Array.isArray(e)?e:[e]}var mu=["openai-compatible","elevenlabs","deepgram","custom"],S1=5*1024*1024;function Vg(e){let t="configure it in config.json `stt: {}` or via OURS_STT_* env";if(!e?.provider)return{ready:!1,reason:`no STT provider configured (stt.provider: ${mu.join(" | ")}) \u2014 ${t}`};let r=e.provider.trim().toLowerCase();if(!mu.includes(r))return{ready:!1,reason:`unknown STT provider "${e.provider}" (expected: ${mu.join(" | ")})`};if(!e.apiKey?.trim())return{ready:!1,reason:`STT provider "${r}" is set but the API key is missing (stt.apiKey / OURS_STT_API_KEY)`};if(r==="openai-compatible"){if(!e.baseUrl?.trim())return{ready:!1,reason:"openai-compatible STT needs stt.baseUrl / OURS_STT_BASE_URL (e.g. your provider's /v1 root) \u2014 no endpoint is assumed"};if(!e.model?.trim())return{ready:!1,reason:"openai-compatible STT needs stt.model / OURS_STT_MODEL (passed to the provider verbatim) \u2014 no model is assumed"}}if(r==="elevenlabs"&&!e.model?.trim())return{ready:!1,reason:"elevenlabs STT needs stt.model / OURS_STT_MODEL (the model_id, e.g. from your ElevenLabs account) \u2014 no model is assumed"};if(r==="custom"){if(!e.custom?.url?.trim())return{ready:!1,reason:"custom STT needs stt.custom.url (the full endpoint URL of your provider)"};if((e.custom.url.includes("{model}")||e.custom.modelField!==void 0&&e.custom.modelField!=="")&&!e.model?.trim())return{ready:!1,reason:"the custom STT template references a model (url {model} or modelField) but stt.model / OURS_STT_MODEL is not set"}}return{ready:!0,provider:r}}if(!process.env.XDG_RUNTIME_DIR&&typeof process.getuid=="function"){let e=`/run/user/${process.getuid()}`;q.existsSync(e)&&(process.env.XDG_RUNTIME_DIR=e)}var St=pu(),Ue=St.stateDir,ne=St.port,vu=Eg(St,{generate:!1})?.token??null,Cs=()=>vu?{"x-ours-api-token":vu}:{},Kr=St.brokerUrl,ur=bt(Ue,"daemon.pid"),ar=bt(Ue,"daemon.log"),Gr=gk(import.meta.url),w=(...e)=>process.stdout.write(`${e.join(" ")}
53
+ `),Y=(...e)=>process.stderr.write(`${e.join(" ")}
54
+ `),cr="0.14.1";async function wu(){for(let e of["/version","/state-dir"])try{let t=new AbortController,r=setTimeout(()=>t.abort(),1500),n=await fetch(`http://127.0.0.1:${ne}${e}`,{signal:t.signal});if(clearTimeout(r),n.ok){let o=await n.json();if(o&&typeof o.version=="string")return o}}catch{}return null}function Hg(e){if(w(` cli: v${cr}`),e?.version){let t=e.version!==cr;w(` daemon: v${e.version}${e.compat?` (compat ${e.compat})`:""}`+(t?` \u26A0 differs from CLI \u2014 \`ours-mcp restart\` to load v${cr}`:""))}else w(" daemon: version unknown (running build predates /version \u2014 restart to update)")}var Ns=e=>new Promise(t=>setTimeout(t,e));function yk(){try{let e=parseInt(q.readFileSync(ur,"utf8").trim(),10);return Number.isFinite(e)?e:null}catch{return null}}function $u(e){try{return process.kill(e,0),!0}catch{return!1}}function io(){let e=yk();if(e&&$u(e))return e;if(e)try{q.rmSync(ur,{force:!0})}catch{}return null}function lr(e,t=1e3){return new Promise(r=>{let n=hk({host:"127.0.0.1",port:e}),o=s=>{n.destroy(),r(s)};n.setTimeout(t),n.once("connect",()=>o(!0)),n.once("timeout",()=>o(!1)),n.once("error",()=>o(!1))})}async function Qg(e,t=3e4){let r=Date.now()+t;for(;Date.now()<r;){if(await lr(e))return!0;await Ns(400)}return!1}async function Bg(){let e=io();if(e){w(`ours-mcp is already running (pid ${e}, port ${ne}).`);return}q.mkdirSync(Ue,{recursive:!0});let t=q.openSync(ar,"a"),r=Jg(process.execPath,[Gr,"serve"],{detached:!0,stdio:["ignore",t,t],env:{...process.env,OURS_TRANSPORT:"http",OURS_PORT:String(ne),OURS_BROKER_URL:Kr,OURS_STATE_DIR:Ue}});r.unref(),r.pid||(Y("failed to spawn the daemon."),process.exit(1)),q.writeFileSync(ur,String(r.pid)),w(`starting ours-mcp (pid ${r.pid})\u2026`),await Qg(ne)?(w(`ours-mcp is up on http://localhost:${ne}/mcp`),w(` broker: ${Kr}`),w(` state: ${Ue}`),w(` logs: ${ar}`)):(Y(`daemon started (pid ${r.pid}) but port ${ne} did not open within 30s \u2014 check ${ar}.`),process.exit(1))}async function vk(){if(!await lr(ne)){if(!io()){q.mkdirSync(Ue,{recursive:!0});let e=q.openSync(ar,"a"),t=Jg(process.execPath,[Gr,"serve"],{detached:!0,stdio:["ignore",e,e],env:{...process.env,OURS_TRANSPORT:"http",OURS_PORT:String(ne),OURS_BROKER_URL:Kr,OURS_STATE_DIR:Ue}});if(t.unref(),t.pid)try{q.writeFileSync(ur,String(t.pid))}catch{}}await Qg(ne)}}async function Os(){let e=io();if(!e){w("ours-mcp is not running.");return}w(`stopping ours-mcp (pid ${e})\u2026`);try{process.kill(e,"SIGTERM")}catch(t){Y(`failed to signal pid ${e}: ${String(t)}`)}for(let t=0;t<25&&$u(e);t++)await Ns(200);if($u(e)){Y(`pid ${e} did not exit; sending SIGKILL.`);try{process.kill(e,"SIGKILL")}catch{}}try{q.rmSync(ur,{force:!0})}catch{}w("stopped.")}async function wk(){let e=io();if(!e){if(await lr(ne)){let n=await wu();w("ours-mcp: running (no pidfile \u2014 likely a stale process or external launcher)"),w(` url: http://localhost:${ne}/mcp (reachable)`),Hg(n);return}w("ours-mcp: stopped"),w(` cli: v${cr}`),process.exitCode=1;return}let t=await lr(ne),r=t?await wu():null;w("ours-mcp: running"),w(` pid: ${e}`),w(` url: http://localhost:${ne}/mcp ${t?"(reachable)":"(port not answering!)"}`),w(` broker: ${Kr}`),w(` state: ${Ue}`),w(` logs: ${ar}`),Hg(r)}async function $k(){if(w(`ours-mcp v${cr}`),await lr(ne)){let e=await wu();e?.version?w(`running daemon: v${e.version}`+(e.version!==cr?" (differs \u2014 restart to update)":"")):w("running daemon: version unknown (predates /version)")}else w("daemon: not running")}async function bk(){let e=pu(),t=ks();w(`ours-mcp setup \u2014 ${t}`),w("Enter a value, or press Enter to keep the current [bracketed] one."),w("");let r=Is({input:process.stdin,output:process.stdout}),n;try{let u=async(Q,me)=>{let qe=(await r.question(` ${Q} [${me}]: `)).trim();return qe===""?me:qe},d=await u("broker URL",e.brokerUrl),f=await u("HTTP port",String(e.port)),m=await u("state dir",e.stateDir),h=await u("GC interval (ms)",String(e.gcIntervalMs)),g=await u("proxy auto-starts daemon (true/false)",String(e.autoStart)),v=await u("HTTP visibility (owner=same-user only / shared=cross-user w/ token / open=all local users)",e.apiVisibility);w(""),w(" Voice-message transcription (STT). Leave provider empty to keep it off \u2014"),w(" agents then deterministically tell users voice messages cannot be read."),w(" No provider or model is assumed; model strings pass to your provider verbatim.");let $=(await r.question(` STT provider (openai-compatible / elevenlabs / deepgram / custom, empty=off) [${e.stt?.provider??""}]: `)).trim()||(e.stt?.provider??""),S=e.stt?.model??"",b=e.stt?.baseUrl??"";$&&(S=await u("STT model (verbatim, e.g. whisper-large-v3-turbo / scribe_v1 / nova-2)",S),b=await u("STT base URL (required for openai-compatible; empty = provider default)",b),w(" (API key is not echoed here. Run `ours-install` for masked guided setup,"),w(" or set OURS_STT_API_KEY for environment-only secret injection.)"));let T=parseInt(f,10);(!Number.isFinite(T)||T<=0)&&(Y(`invalid port: ${f}`),process.exit(1));let y=parseInt(h,10);(!Number.isFinite(y)||y<=0)&&(Y(`invalid GC interval: ${h}`),process.exit(1));let x=g.toLowerCase()==="true"||g==="1",R=v.trim().toLowerCase();oo.includes(R)||(Y(`invalid visibility: ${v} (expected one of ${oo.join(", ")})`),process.exit(1));let G=$?{...e.stt??{},provider:$,...S?{model:S}:{},...b?{baseUrl:b}:{}}:e.stt;n={brokerUrl:d,port:T,stateDir:Yg(m),gcIntervalMs:y,autoStart:x,apiVisibility:R,...e.apiToken?{apiToken:e.apiToken}:{},...G?{stt:G}:{}}}finally{r.close()}Ig(n),w(""),w(`wrote ${t} (mode 0600):`);let o={...n,...n.apiToken?{apiToken:"[redacted]"}:{},...n.stt?{stt:{...n.stt,...n.stt.apiKey?{apiKey:"[redacted]"}:{}}}:{}};w(JSON.stringify(o,null,2));let s=["OURS_BROKER_URL","OURS_PORT","OURS_STATE_DIR","OURS_GC_INTERVAL_MS","OURS_AUTOSTART","OURS_API_VISIBILITY","OURS_API_TOKEN","OURS_STT_PROVIDER","OURS_STT_API_KEY","OURS_STT_MODEL","OURS_STT_BASE_URL","OURS_STT_LANGUAGE"].filter(u=>process.env[u]!==void 0);s.length&&(w(""),w(`note: these env vars are set and OVERRIDE the file at runtime: ${s.join(", ")}`));let i=io();if(!i)return;let a=Is({input:process.stdin,output:process.stdout}),c=!1;try{let u=(await a.question(`
55
+ daemon is running (pid ${i}); restart now to apply? [y/N]: `)).trim().toLowerCase();c=u==="y"||u==="yes"}finally{a.close()}if(!c){w("not restarting \u2014 changes apply on the next `ours-mcp restart`.");return}await Os();let l=As(process.execPath,[Gr,"start"],{stdio:"inherit"});l.status!==0&&process.exit(l.status??1)}function Sk(e){let t=Vg(St.stt),r=St.stt?.provider?.trim().toLowerCase()||null,n=process.env.OURS_STT_API_KEY?.trim()?"environment":St.stt?.apiKey?.trim()?"config":"missing",o=t.ready?{ready:!0,provider:t.provider,apiKey:"configured",keySource:n}:{ready:!1,provider:r,apiKey:n==="missing"?"missing":"configured",keySource:n,reason:t.reason};if(e.includes("--json")){w(JSON.stringify(o));return}o.ready?w(`voice transcription: ready (${o.provider}; API key from ${o.keySource})`):w(`voice transcription: not ready \u2014 ${o.reason}`)}function gu(e,t,r){return e.includes(r)?{value:!1,set:!0}:e.includes(t)?{value:!0,set:!0}:{value:void 0,set:!1}}function _u(e,t){let r=e.indexOf(t);return r>=0&&r+1<e.length?e[r+1]:void 0}async function xk(e){let t=_u(e,"--name"),r=gu(e,"--force-bind","--no-force-bind"),n=gu(e,"--local-book","--no-local-book"),o=gu(e,"--auto-accept-local","--no-auto-accept-local"),s=e.includes("--overwrite"),i=e.includes("--print"),a=_u(e,"--path")??_u(e,"--dir")??process.cwd(),c=t!==void 0||r.set||n.set||o.set||i,l;if(c?((!t||!t.trim())&&(Y("define-local-identity-file: --name is required in non-interactive mode."),process.exit(1)),l={name:t.trim(),force:r.value??!1,exposeLocal:n.value??!0,localAutoAccept:o.value??!0}):l=await zk(),i){w(JSON.stringify(Ps(l),null,2));return}let u=fu(a);if(!s&&q.existsSync(u)){c&&(Y(`define-local-identity-file: ${u} already exists \u2014 pass --overwrite to replace it.`),process.exit(1));let f=Is({input:process.stdin,output:process.stdout}),m=!1;try{let h=(await f.question(`
56
+ ${u} already exists \u2014 overwrite? [y/N]: `)).trim().toLowerCase();m=h==="y"||h==="yes"}finally{f.close()}if(!m){w("aborted \u2014 nothing written.");return}}let d=Og(a,l,!0);w(""),w(`wrote ${d}:`),w(JSON.stringify(Ps(l),null,2))}async function zk(){w("ours-mcp define-local-identity-file \u2014 interactive"),w(`Answer the prompts; the result is written to ${bt(process.cwd(),xs)}.`),w("");let e=Is({input:process.stdin,output:process.stdout});try{let t=async(i,a)=>{let c=a?"Y/n":"y/N",l=(await e.question(` ${i} [${c}]: `)).trim().toLowerCase();return l===""?a:l==="y"||l==="yes"},r="";for(;!r;)r=(await e.question(" Identity name: ")).trim(),r||w(" (name is required)");let n=await t("Force-bind (pin pre-authorizes evicting another session)?",!1),o=await t("Add to the host-local contact book?",!0),s=await t("Auto-accept local invites/introductions?",!0);return{name:r,force:n,exposeLocal:o,localAutoAccept:s}}finally{e.close()}}async function kk(e){let t=(e[0]??"").trim();(!t||t.startsWith("--"))&&(Y('usage: ours-mcp create-root "<your name>"'),process.exit(1)),await lr(ne)||(Y(`create-root: the daemon is not running on port ${ne} \u2014 start it with \`ours-mcp start\`.`),process.exit(1));let r=new Vr(new URL(`http://127.0.0.1:${ne}/mcp`),{requestInit:{headers:Cs()}}),n=new $s({name:"ours-mcp-cli",version:cr});try{await n.connect(r);let o=await n.callTool({name:"create_root_identity",arguments:{name:t,skip_if_root_exists:!0}}),s=(Array.isArray(o.content)?o.content:[]).map(i=>typeof i.text=="string"?i.text:"").join(" ").split(/\n\nAsk the user\b/)[0].replace(/^create_root_identity failed: /,"").trim();if(o.isError){if(/a root identity already exists/i.test(s)){w(`create-root: ${s.split("\u2014")[0].trim()} \u2014 nothing to do.`);return}Y(`create-root failed: ${s}`),process.exit(1)}w(s)}finally{try{await r.terminateSession()}catch{}try{await n.close()}catch{}}}function Xg(e,t){t.event==="message_received"?w(`[${e}] new message from ${t.from??"?"}`+(t.msg_id!==void 0?` (#${t.msg_id})`:"")+(t.date?` (${t.date})`:"")):t.event==="file_received"?w(`[${e}] new file ${t.filename??"?"} from ${t.from??"?"}`+(t.bytes!==void 0?` (${t.bytes} B)`:"")+(t.file_id!==void 0?` (#${t.file_id})`:"")+(t.date?` (${t.date})`:"")):t.event==="local_contact_request"?w(`[${e}] pending local introduction from ${t.from??"?"} \u2014 respond_to_introduction to approve/reject`):t.event==="pending_message"&&w(`[${e}] ${t.from??"?"} queued a message awaiting introduction approval (${t.queued??"?"} queued)`)}function Mt(e){Y(`ours-mcp watch: ${e}`),process.exit(1)}async function Pk(){try{let e=new AbortController,t=setTimeout(()=>e.abort(),1500),r=await fetch(`http://127.0.0.1:${ne}/state-dir`,{signal:e.signal});if(clearTimeout(t),r.ok){let n=await r.json();return typeof n.stateDir=="string"&&n.stateDir?Yg(n.stateDir):Ue}}catch{}return null}var Tk=e=>`http://127.0.0.1:${ne}/identities/${encodeURIComponent(e)}/notifications`;async function Kg(e){let t=async o=>{let s=new AbortController,i=setTimeout(()=>s.abort(),35e3),a;try{a=await fetch(`${Tk(e)}?since=${o}`,{headers:Cs(),signal:s.signal})}finally{clearTimeout(i)}if(a.status===401&&Mt(`daemon rejected the API token (401) for identity "${e}". Set OURS_API_TOKEN to the daemon's token (shared mode) or run watch as the daemon owner (owner mode).`),!a.ok)throw new Error(`daemon returned HTTP ${a.status}`);return await a.json()},r=(await t("tip")).cursor??0,n=0;for(;;)try{let o=await t(String(r));if(n=0,Array.isArray(o.events))for(let s of o.events)Xg(e,s);typeof o.cursor=="number"&&(r=o.cursor)}catch(o){n=Math.min(n+1e3,5e3),Y(`ours-mcp watch: notifications stream for "${e}" hiccupped (${String(o?.message??o)}), retrying\u2026`),await Ns(n)}}async function Rk(e){if(e){await Kg(e);return}let t=new Set;for(;;){try{let r=await fetch(`http://127.0.0.1:${ne}/identities`,{headers:Cs()});if(r.status===401&&Mt("daemon rejected the API token (401). Set OURS_API_TOKEN or run watch as the daemon owner."),r.ok){let n=await r.json();for(let o of n.identities??[]){let s=typeof o?.name=="string"?o.name:void 0;s&&!t.has(s)&&(t.add(s),Kg(s))}}}catch{}await Ns(3e3)}}var yu=e=>{let t=e?.code;return t==="EACCES"||t==="EPERM"};function Ek(e,t){try{q.readdirSync(e)}catch(i){Mt(`cannot watch \u2014 the daemon API is unreachable AND ${e} is not readable (${i?.code??i}). On a multi-user host, run watch as the daemon owner, or enable the daemon API (start the daemon) so watch can stream over HTTP.`)}if(t)try{q.readdirSync(bt(e,t))}catch(i){Mt(`cannot watch identity "${t}" \u2014 ${bt(e,t)} is not readable (${i?.code??i}). Is the daemon running and the name correct?`)}let r=new Map,n=i=>{let a;try{a=q.readdirSync(e,{withFileTypes:!0}).filter(c=>c.isDirectory()).map(c=>c.name)}catch(c){yu(c)&&Mt(`lost read access to ${e} (${c.code}) \u2014 cannot watch.`);return}for(let c of a){if(t&&c!==t)continue;let l=bt(e,c,"notifications.log"),u;try{u=q.statSync(l).size}catch(m){yu(m)&&Mt(`cannot read ${l} (${m.code}) \u2014 cannot watch identity "${c}".`);continue}let d=r.get(l);if(d===void 0&&(d=i?u:0,r.set(l,d),i))continue;if(u<=d){u<d&&r.set(l,u);continue}let f;try{let m=q.openSync(l,"r"),h=Buffer.alloc(u-d);q.readSync(m,h,0,h.length,d),q.closeSync(m),f=h.toString("utf8")}catch(m){yu(m)&&Mt(`cannot read ${l} (${m.code}) \u2014 cannot watch identity "${c}".`);continue}r.set(l,u);for(let m of f.split(`
57
+ `))if(m.trim())try{Xg(c,JSON.parse(m))}catch{}}};Y(`ours-mcp watch: daemon API unreachable \u2014 falling back to file poll of ${e} (Ctrl-C to stop)`),n(!0);let o=setInterval(()=>n(!1),1e3),s=()=>{clearInterval(o),process.exit(0)};process.on("SIGINT",s),process.on("SIGTERM",s)}async function Ik(){try{let e=await fetch(`http://127.0.0.1:${ne}/identities`,{headers:Cs()});return e.status===401&&Mt("daemon rejected the API token (401). Set OURS_API_TOKEN to the daemon's token (shared mode) or run watch as the daemon owner (owner mode)."),e.status===404?"file":e.ok?"api":"file"}catch{return"file"}}async function Ok(e){let t=()=>process.exit(0);if(process.on("SIGINT",t),process.on("SIGTERM",t),await Pk()!==null&&await Ik()==="api"){Y(`ours-mcp watch: streaming ${e?`identity "${e}"`:"all identities"} from the daemon API on port ${ne} (Ctrl-C to stop)`),await Rk(e);return}Ek(Ue,e)}var so="ours.service",e_="solutions.adaptframework.ours";function t_(){return bt(Wg(),".config","systemd","user",so)}function r_(){return bt(Wg(),"Library","LaunchAgents",`${e_}.plist`)}function Br(e,t){return As(e,t,{stdio:"inherit"}).status===0}function Ak(){let e=t_();q.mkdirSync(bu(e),{recursive:!0});let t=`[Unit]
58
58
  Description=ours MCP daemon (secure agent-to-agent messaging over ADAPT)
59
59
  After=network-online.target
60
60
  Wants=network-online.target
@@ -64,18 +64,18 @@ Type=simple
64
64
  ExecStart=${process.execPath} ${Gr} serve
65
65
  Environment=OURS_TRANSPORT=http
66
66
  Environment=OURS_PORT=${ne}
67
- Environment=OURS_BROKER_URL=${Br}
68
- Environment=OURS_STATE_DIR=${qe}
67
+ Environment=OURS_BROKER_URL=${Kr}
68
+ Environment=OURS_STATE_DIR=${Ue}
69
69
  Restart=on-failure
70
70
  RestartSec=2
71
71
 
72
72
  [Install]
73
73
  WantedBy=default.target
74
- `;U.writeFileSync(e,t),b(`wrote ${e}`),Hr("systemctl",["--user","daemon-reload"]),Hr("systemctl",["--user","enable","--now",so])||(Q("failed to enable/start the service via systemctl --user."),process.env.XDG_RUNTIME_DIR||(Q(`hint: no user runtime dir \u2014 enable linger: sudo loginctl enable-linger ${mu().username}`),Q(" (if linger is already on: export XDG_RUNTIME_DIR=/run/user/$(id -u))")),process.exit(1)),Hr("loginctl",["enable-linger",mu().username])||(Q("warning: could not enable linger \u2014 the daemon may not start until you log in."),Q(` run manually: loginctl enable-linger ${mu().username}`)),b(""),b("ours-mcp installed as a systemd user service and started."),b(` status: systemctl --user status ${so}`),b(` logs: journalctl --user -u ${so} -f`),b(" remove: ours-mcp uninstall-service")}function Ik(){Hr("systemctl",["--user","disable","--now",so]);let e=Xg();try{U.rmSync(e,{force:!0}),b(`removed ${e}`)}catch(t){Q(`failed to remove ${e}: ${String(t)}`)}Hr("systemctl",["--user","daemon-reload"]),b("ours-mcp service uninstalled.")}function Ok(){let e=e_();U.mkdirSync($u(e),{recursive:!0});let t=`<?xml version="1.0" encoding="UTF-8"?>
74
+ `;q.writeFileSync(e,t),w(`wrote ${e}`),Br("systemctl",["--user","daemon-reload"]),Br("systemctl",["--user","enable","--now",so])||(Y("failed to enable/start the service via systemctl --user."),process.env.XDG_RUNTIME_DIR||(Y(`hint: no user runtime dir \u2014 enable linger: sudo loginctl enable-linger ${hu().username}`),Y(" (if linger is already on: export XDG_RUNTIME_DIR=/run/user/$(id -u))")),process.exit(1)),Br("loginctl",["enable-linger",hu().username])||(Y("warning: could not enable linger \u2014 the daemon may not start until you log in."),Y(` run manually: loginctl enable-linger ${hu().username}`)),w(""),w("ours-mcp installed as a systemd user service and started."),w(` status: systemctl --user status ${so}`),w(` logs: journalctl --user -u ${so} -f`),w(" remove: ours-mcp uninstall-service")}function Ck(){Br("systemctl",["--user","disable","--now",so]);let e=t_();try{q.rmSync(e,{force:!0}),w(`removed ${e}`)}catch(t){Y(`failed to remove ${e}: ${String(t)}`)}Br("systemctl",["--user","daemon-reload"]),w("ours-mcp service uninstalled.")}function Nk(){let e=r_();q.mkdirSync(bu(e),{recursive:!0});let t=`<?xml version="1.0" encoding="UTF-8"?>
75
75
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
76
76
  <plist version="1.0">
77
77
  <dict>
78
- <key>Label</key><string>${Qg}</string>
78
+ <key>Label</key><string>${e_}</string>
79
79
  <key>ProgramArguments</key>
80
80
  <array>
81
81
  <string>${process.execPath}</string>
@@ -86,14 +86,14 @@ WantedBy=default.target
86
86
  <dict>
87
87
  <key>OURS_TRANSPORT</key><string>http</string>
88
88
  <key>OURS_PORT</key><string>${ne}</string>
89
- <key>OURS_BROKER_URL</key><string>${Br}</string>
90
- <key>OURS_STATE_DIR</key><string>${qe}</string>
89
+ <key>OURS_BROKER_URL</key><string>${Kr}</string>
90
+ <key>OURS_STATE_DIR</key><string>${Ue}</string>
91
91
  </dict>
92
92
  <key>RunAtLoad</key><true/>
93
93
  <key>KeepAlive</key><true/>
94
- <key>StandardOutPath</key><string>${ir}</string>
95
- <key>StandardErrorPath</key><string>${ir}</string>
94
+ <key>StandardOutPath</key><string>${ar}</string>
95
+ <key>StandardErrorPath</key><string>${ar}</string>
96
96
  </dict>
97
97
  </plist>
98
- `;U.writeFileSync(e,t),b(`wrote ${e}`);let r=`gui/${process.getuid()}`;Cs("launchctl",["bootout",r,e],{stdio:"ignore"}),Hr("launchctl",["bootstrap",r,e])||(Q("failed to load the launchd agent."),process.exit(1)),b(""),b("ours-mcp installed as a launchd agent and started."),b(" remove: ours-mcp uninstall-service")}function Ck(){let e=e_(),t=`gui/${process.getuid()}`;Cs("launchctl",["bootout",t,e],{stdio:"ignore"});try{U.rmSync(e,{force:!0}),b(`removed ${e}`)}catch(r){Q(`failed to remove ${e}: ${String(r)}`)}b("ours-mcp service uninstalled.")}async function Ak(){if(await Os(),process.platform==="linux")return Ek();if(process.platform==="darwin")return Ok();Q(`install-service: unsupported platform "${process.platform}" (only linux/systemd and macOS/launchd).`),process.exit(1)}function Nk(){if(process.platform==="linux")return Ik();if(process.platform==="darwin")return Ck();Q(`uninstall-service: unsupported platform "${process.platform}".`),process.exit(1)}function Kg(){b("ours-mcp \u2014 daemon for the ours MCP server"),b(""),b("Usage: ours-mcp <command>"),b(" start start the daemon in the background"),b(" stop stop the running daemon"),b(" restart stop then start"),b(" status show whether the daemon is running (incl. CLI + running-daemon version)"),b(" version print the CLI version and the running daemon version (GET /version)"),b(" setup interactively edit the config file (broker / port / state dir / gc)"),b(" serve run in the foreground (used by start; handy for debugging)"),b(" watch [identity] stream one line per new inbound message (wake source for a Monitor)"),b(" proxy per-session stdio shim \u2192 daemon (stable binding; for the MCP client config)"),b(""),b(' create-root "<name>" create THE root human identity (one per host) via the running'),b(" daemon \u2014 quiet no-op if a root already exists (installer seam)"),b(""),b(" define-local-identity-file write a .ours-identity workspace pin"),b(" interactive (default): 4-question survey, writes to CWD"),b(" scripted: --name <s> [--force-bind] [--local-book] [--auto-accept-local]"),b(" negate with --no-force-bind / --no-local-book / --no-auto-accept-local"),b(" --dir <path> | --path <file> (default CWD) \xB7 --overwrite \xB7 --print"),b(""),b(" install-service install + start a boot-persistent service (systemd/launchd)"),b(" uninstall-service stop + remove that service"),b(""),b("Config precedence (per field): env var > config.json > default."),b(" config.json: OURS_CONFIG, else ~/.ours/config.json \u2014 edit with `setup`."),b(" env: OURS_BROKER_URL, OURS_PORT (3050), OURS_STATE_DIR (~/.ours), OURS_GC_INTERVAL_MS (3600000), OURS_AUTOSTART (off)"),b("(install-service bakes the resolved config values into the service definition.)")}async function jk(){let e=process.argv[2]??"help";switch(e){case"serve":case"run":process.env.OURS_TRANSPORT||(process.env.OURS_TRANSPORT="http"),U.mkdirSync(qe,{recursive:!0}),U.writeFileSync(cr,String(process.pid));{let t=()=>{try{U.rmSync(cr,{force:!0})}catch{}};process.on("exit",t);for(let r of["SIGTERM","SIGINT"])process.on(r,()=>{t(),process.exit(0)})}await import(hk(bt($u(Gr),"index.js")).href);break;case"start":await Vg();break;case"stop":await Os();break;case"restart":await Os(),await Vg();break;case"status":await yk();break;case"version":case"--version":case"-v":await vk();break;case"setup":await wk();break;case"create-root":await xk(process.argv.slice(3));break;case"define-local-identity-file":await $k(process.argv.slice(3));break;case"watch":await Rk(process.argv[3]);break;case"proxy":!Kr.autoStart&&!await ur(ne)&&(Q(`ours-mcp daemon is not running on port ${ne} \u2014 start it with \`ours-mcp start\`.`),Q("(or enable auto-start: `ours-mcp setup` \u2192 autoStart, or OURS_AUTOSTART=1)"),process.exit(1)),await Lg({url:`http://127.0.0.1:${ne}/mcp`,ensureDaemon:Kr.autoStart?_k:void 0,stateDir:qe,apiToken:yu??void 0});break;case"install-service":await Ak();break;case"uninstall-service":Nk();break;case"help":case"--help":case"-h":Kg();break;default:Q(`unknown command: ${e}
99
- `),Kg(),process.exit(1)}}jk().catch(e=>{Q(`ours-mcp error: ${e?.stack??e}`),process.exit(1)});
98
+ `;q.writeFileSync(e,t),w(`wrote ${e}`);let r=`gui/${process.getuid()}`;As("launchctl",["bootout",r,e],{stdio:"ignore"}),Br("launchctl",["bootstrap",r,e])||(Y("failed to load the launchd agent."),process.exit(1)),w(""),w("ours-mcp installed as a launchd agent and started."),w(" remove: ours-mcp uninstall-service")}function jk(){let e=r_(),t=`gui/${process.getuid()}`;As("launchctl",["bootout",t,e],{stdio:"ignore"});try{q.rmSync(e,{force:!0}),w(`removed ${e}`)}catch(r){Y(`failed to remove ${e}: ${String(r)}`)}w("ours-mcp service uninstalled.")}async function Mk(){if(await Os(),process.platform==="linux")return Ak();if(process.platform==="darwin")return Nk();Y(`install-service: unsupported platform "${process.platform}" (only linux/systemd and macOS/launchd).`),process.exit(1)}function Zk(){if(process.platform==="linux")return Ck();if(process.platform==="darwin")return jk();Y(`uninstall-service: unsupported platform "${process.platform}".`),process.exit(1)}function Gg(){w("ours-mcp \u2014 daemon for the ours MCP server"),w(""),w("Usage: ours-mcp <command>"),w(" start start the daemon in the background"),w(" stop stop the running daemon"),w(" restart stop then start"),w(" status show whether the daemon is running (incl. CLI + running-daemon version)"),w(" version print the CLI version and the running daemon version (GET /version)"),w(" setup interactively edit the config file (broker / port / state dir / gc)"),w(" voice-status [--json] check voice-transcription readiness (never prints the API key)"),w(" serve run in the foreground (used by start; handy for debugging)"),w(" watch [identity] stream one line per new inbound message (wake source for a Monitor)"),w(" proxy per-session stdio shim \u2192 daemon (stable binding; for the MCP client config)"),w(""),w(' create-root "<name>" create THE root human identity (one per host) via the running'),w(" daemon \u2014 quiet no-op if a root already exists (installer seam)"),w(""),w(" define-local-identity-file write a .ours-identity workspace pin"),w(" interactive (default): 4-question survey, writes to CWD"),w(" scripted: --name <s> [--force-bind] [--local-book] [--auto-accept-local]"),w(" negate with --no-force-bind / --no-local-book / --no-auto-accept-local"),w(" --dir <path> | --path <file> (default CWD) \xB7 --overwrite \xB7 --print"),w(""),w(" install-service install + start a boot-persistent service (systemd/launchd)"),w(" uninstall-service stop + remove that service"),w(""),w("Config precedence (per field): env var > config.json > default."),w(" config.json: OURS_CONFIG, else ~/.ours/config.json \u2014 edit with `setup`."),w(" env: OURS_BROKER_URL, OURS_PORT (3050), OURS_STATE_DIR (~/.ours), OURS_GC_INTERVAL_MS (3600000), OURS_AUTOSTART (off)"),w("(install-service bakes the resolved config values into the service definition.)")}async function Dk(){let e=process.argv[2]??"help";switch(e){case"serve":case"run":process.env.OURS_TRANSPORT||(process.env.OURS_TRANSPORT="http"),q.mkdirSync(Ue,{recursive:!0}),q.writeFileSync(ur,String(process.pid));{let t=()=>{try{q.rmSync(ur,{force:!0})}catch{}};process.on("exit",t);for(let r of["SIGTERM","SIGINT"])process.on(r,()=>{t(),process.exit(0)})}await import(_k(bt(bu(Gr),"index.js")).href);break;case"start":await Bg();break;case"stop":await Os();break;case"restart":await Os(),await Bg();break;case"status":await wk();break;case"version":case"--version":case"-v":await $k();break;case"setup":await bk();break;case"voice-status":case"stt-status":Sk(process.argv.slice(3));break;case"create-root":await kk(process.argv.slice(3));break;case"define-local-identity-file":await xk(process.argv.slice(3));break;case"watch":await Ok(process.argv[3]);break;case"proxy":!St.autoStart&&!await lr(ne)&&(Y(`ours-mcp daemon is not running on port ${ne} \u2014 start it with \`ours-mcp start\`.`),Y("(or enable auto-start: `ours-mcp setup` \u2192 autoStart, or OURS_AUTOSTART=1)"),process.exit(1)),await Fg({url:`http://127.0.0.1:${ne}/mcp`,ensureDaemon:St.autoStart?vk:void 0,stateDir:Ue,apiToken:vu??void 0});break;case"install-service":await Mk();break;case"uninstall-service":Zk();break;case"help":case"--help":case"-h":Gg();break;default:Y(`unknown command: ${e}
99
+ `),Gg(),process.exit(1)}}Dk().catch(e=>{Y(`ours-mcp error: ${e?.stack??e}`),process.exit(1)});