@ours.network/mcp 0.16.0 → 0.17.0-nightly.2
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,67 +1,64 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from 'node:module'; const require = createRequire(import.meta.url);
|
|
3
|
-
var X_=Object.create;var oi=Object.defineProperty;var ey=Object.getOwnPropertyDescriptor;var ty=Object.getOwnPropertyNames;var ry=Object.getPrototypeOf,ny=Object.prototype.hasOwnProperty;var R=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),si=(e,t)=>{for(var r in t)oi(e,r,{get:t[r],enumerable:!0})},oy=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ty(t))!ny.call(e,o)&&o!==r&&oi(e,o,{get:()=>t[o],enumerable:!(n=ey(t,o))||n.enumerable});return e};var Yu=(e,t,r)=>(r=e!=null?X_(ry(e)):{},oy(t||!e||!e.__esModule?oi(r,"default",{value:e,enumerable:!0}):r,e));var In=R(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.regexpCode=X.getEsmExportName=X.getProperty=X.safeStringify=X.stringify=X.strConcat=X.addCodeArg=X.str=X._=X.nil=X._Code=X.Name=X.IDENTIFIER=X._CodeOrName=void 0;var Rn=class{};X._CodeOrName=Rn;X.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var tr=class extends Rn{constructor(t){if(super(),!X.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}}};X.Name=tr;var et=class extends Rn{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 tr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};X._Code=et;X.nil=new et("");function Uf(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Ta(r,t[n]),r.push(e[++n]);return new et(r)}X._=Uf;var Pa=new et("+");function Df(e,...t){let r=[En(e[0])],n=0;for(;n<t.length;)r.push(Pa),Ta(r,t[n]),r.push(Pa,En(e[++n]));return lw(r),new et(r)}X.str=Df;function Ta(e,t){t instanceof et?e.push(...t._items):t instanceof tr?e.push(t):e.push(fw(t))}X.addCodeArg=Ta;function lw(e){let t=1;for(;t<e.length-1;){if(e[t]===Pa){let r=dw(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function dw(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof tr||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 tr))return`"${e}${t.slice(1)}`}function pw(e,t){return t.emptyStr()?e:e.emptyStr()?t:Df`${e}${t}`}X.strConcat=pw;function fw(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:En(Array.isArray(e)?e.join(","):e)}function mw(e){return new et(En(e))}X.stringify=mw;function En(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}X.safeStringify=En;function hw(e){return typeof e=="string"&&X.IDENTIFIER.test(e)?new et(`.${e}`):Uf`[${e}]`}X.getProperty=hw;function gw(e){if(typeof e=="string"&&X.IDENTIFIER.test(e))return new et(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}X.getEsmExportName=gw;function _w(e){return new et(e.toString())}X.regexpCode=_w});var Ia=R(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.ValueScope=Fe.ValueScopeName=Fe.Scope=Fe.varKinds=Fe.UsedValueState=void 0;var Le=In(),Ra=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},ts;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(ts||(Fe.UsedValueState=ts={}));Fe.varKinds={const:new Le.Name("const"),let:new Le.Name("let"),var:new Le.Name("var")};var rs=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Le.Name?t:this.name(t)}name(t){return new Le.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}}};Fe.Scope=rs;var ns=class extends Le.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Le._)`.${new Le.Name(r)}[${n}]`}};Fe.ValueScopeName=ns;var yw=(0,Le._)`\n`,Ea=class extends rs{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?yw:Le.nil}}get(){return this._scope}name(t){return new ns(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,Le._)`${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=Le.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,ts.Started);let u=r(l);if(u){let d=this.opts.es5?Fe.varKinds.var:Fe.varKinds.const;s=(0,Le._)`${s}${d} ${l} = ${u};${this.opts._n}`}else if(u=o?.(l))s=(0,Le._)`${s}${u}${this.opts._n}`;else throw new Ra(l);c.set(l,ts.Completed)})}return s}};Fe.ValueScope=Ea});var L=R(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.or=F.and=F.not=F.CodeGen=F.operators=F.varKinds=F.ValueScopeName=F.ValueScope=F.Scope=F.Name=F.regexpCode=F.stringify=F.getProperty=F.nil=F.strConcat=F.str=F._=void 0;var G=In(),ct=Ia(),jt=In();Object.defineProperty(F,"_",{enumerable:!0,get:function(){return jt._}});Object.defineProperty(F,"str",{enumerable:!0,get:function(){return jt.str}});Object.defineProperty(F,"strConcat",{enumerable:!0,get:function(){return jt.strConcat}});Object.defineProperty(F,"nil",{enumerable:!0,get:function(){return jt.nil}});Object.defineProperty(F,"getProperty",{enumerable:!0,get:function(){return jt.getProperty}});Object.defineProperty(F,"stringify",{enumerable:!0,get:function(){return jt.stringify}});Object.defineProperty(F,"regexpCode",{enumerable:!0,get:function(){return jt.regexpCode}});Object.defineProperty(F,"Name",{enumerable:!0,get:function(){return jt.Name}});var as=Ia();Object.defineProperty(F,"Scope",{enumerable:!0,get:function(){return as.Scope}});Object.defineProperty(F,"ValueScope",{enumerable:!0,get:function(){return as.ValueScope}});Object.defineProperty(F,"ValueScopeName",{enumerable:!0,get:function(){return as.ValueScopeName}});Object.defineProperty(F,"varKinds",{enumerable:!0,get:function(){return as.varKinds}});F.operators={GT:new G._Code(">"),GTE:new G._Code(">="),LT:new G._Code("<"),LTE:new G._Code("<="),EQ:new G._Code("==="),NEQ:new G._Code("!=="),NOT:new G._Code("!"),OR:new G._Code("||"),AND:new G._Code("&&"),ADD:new G._Code("+")};var zt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},Oa=class extends zt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?ct.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=jr(this.rhs,t,r)),this}get names(){return this.rhs instanceof G._CodeOrName?this.rhs.names:{}}},os=class extends zt{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 G.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=jr(this.rhs,t,r),this}get names(){let t=this.lhs instanceof G.Name?{}:{...this.lhs.names};return is(t,this.rhs)}},Aa=class extends os{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},Ca=class extends zt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},Na=class extends zt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},ja=class extends zt{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},Ma=class extends zt{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=jr(this.code,t,r),this}get names(){return this.code instanceof G._CodeOrName?this.code.names:{}}},On=class extends zt{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)||(vw(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>or(t,r.names),{})}},Pt=class extends On{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},Ua=class extends On{},Nr=class extends Pt{};Nr.kind="else";var rr=class e extends Pt{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 Nr(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Zf(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=jr(this.condition,t,r),this}get names(){let t=super.names;return is(t,this.condition),this.else&&or(t,this.else.names),t}};rr.kind="if";var nr=class extends Pt{};nr.kind="for";var Da=class extends nr{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=jr(this.iteration,t,r),this}get names(){return or(super.names,this.iteration.names)}},Za=class extends nr{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?ct.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=is(super.names,this.from);return is(t,this.to)}},ss=class extends nr{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=jr(this.iterable,t,r),this}get names(){return or(super.names,this.iterable.names)}},An=class extends Pt{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)}};An.kind="func";var Cn=class extends On{render(t){return"return "+super.render(t)}};Cn.kind="return";var qa=class extends Pt{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&&or(t,this.catch.names),this.finally&&or(t,this.finally.names),t}},Nn=class extends Pt{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};Nn.kind="catch";var jn=class extends Pt{render(t){return"finally"+super.render(t)}};jn.kind="finally";var La=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
4
|
-
`:""},this._extScope=t,this._scope=new ct.Scope({parent:t}),this._nodes=[new Ua]}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 Oa(t,s,n)),s}const(t,r,n){return this._def(ct.varKinds.const,t,r,n)}let(t,r,n){return this._def(ct.varKinds.let,t,r,n)}var(t,r,n){return this._def(ct.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new os(t,r,n))}add(t,r){return this._leafNode(new Aa(t,F.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==G.nil&&this._leafNode(new Ma(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,G.addCodeArg)(r,o));return r.push("}"),new G._Code(r)}if(t,r,n){if(this._blockNode(new rr(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 rr(t))}else(){return this._elseNode(new Nr)}endIf(){return this._endBlockNode(rr,Nr)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Da(t),r)}forRange(t,r,n,o,s=this.opts.es5?ct.varKinds.var:ct.varKinds.let){let i=this._scope.toName(t);return this._for(new Za(s,i,r,n),()=>o(i))}forOf(t,r,n,o=ct.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof G.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,G._)`${i}.length`,a=>{this.var(s,(0,G._)`${i}[${a}]`),n(s)})}return this._for(new ss("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?ct.varKinds.var:ct.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,G._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new ss("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(nr)}label(t){return this._leafNode(new Ca(t))}break(t){return this._leafNode(new Na(t))}return(t){let r=new Cn;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Cn)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new qa;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new Nn(s),r(s)}return n&&(this._currNode=o.finally=new jn,this.code(n)),this._endBlockNode(Nn,jn)}throw(t){return this._leafNode(new ja(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=G.nil,n,o){return this._blockNode(new An(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(An)}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 rr))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}};F.CodeGen=La;function or(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function is(e,t){return t instanceof G._CodeOrName?or(e,t.names):e}function jr(e,t,r){if(e instanceof G.Name)return n(e);if(!o(e))return e;return new G._Code(e._items.reduce((s,i)=>(i instanceof G.Name&&(i=n(i)),i instanceof G._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 G._Code&&s._items.some(i=>i instanceof G.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function vw(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function Zf(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,G._)`!${Fa(e)}`}F.not=Zf;var bw=qf(F.operators.AND);function ww(...e){return e.reduce(bw)}F.and=ww;var $w=qf(F.operators.OR);function Sw(...e){return e.reduce($w)}F.or=Sw;function qf(e){return(t,r)=>t===G.nil?r:r===G.nil?t:(0,G._)`${Fa(t)} ${e} ${Fa(r)}`}function Fa(e){return e instanceof G.Name?e:(0,G._)`(${e})`}});var W=R(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.checkStrictMode=V.getErrorPath=V.Type=V.useFunc=V.setEvaluated=V.evaluatedPropsToName=V.mergeEvaluated=V.eachItem=V.unescapeJsonPointer=V.escapeJsonPointer=V.escapeFragment=V.unescapeFragment=V.schemaRefOrVal=V.schemaHasRulesButRef=V.schemaHasRules=V.checkUnknownRules=V.alwaysValidSchema=V.toHash=void 0;var se=L(),xw=In();function kw(e){let t={};for(let r of e)t[r]=!0;return t}V.toHash=kw;function zw(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Vf(e,t),!Hf(t,e.self.RULES.all))}V.alwaysValidSchema=zw;function Vf(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]||Jf(e,`unknown keyword: "${s}"`)}V.checkUnknownRules=Vf;function Hf(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}V.schemaHasRules=Hf;function Pw(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}V.schemaHasRulesButRef=Pw;function Tw({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,se._)`${r}`}return(0,se._)`${e}${t}${(0,se.getProperty)(n)}`}V.schemaRefOrVal=Tw;function Rw(e){return Bf(decodeURIComponent(e))}V.unescapeFragment=Rw;function Ew(e){return encodeURIComponent(Ha(e))}V.escapeFragment=Ew;function Ha(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}V.escapeJsonPointer=Ha;function Bf(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}V.unescapeJsonPointer=Bf;function Iw(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}V.eachItem=Iw;function Lf({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof se.Name?(s instanceof se.Name?e(o,s,i):t(o,s,i),i):s instanceof se.Name?(t(o,i,s),s):r(s,i);return a===se.Name&&!(c instanceof se.Name)?n(o,c):c}}V.mergeEvaluated={props:Lf({mergeNames:(e,t,r)=>e.if((0,se._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,se._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,se._)`${r} || {}`).code((0,se._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,se._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,se._)`${r} || {}`),Ba(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Kf}),items:Lf({mergeNames:(e,t,r)=>e.if((0,se._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,se._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,se._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,se._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Kf(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,se._)`{}`);return t!==void 0&&Ba(e,r,t),r}V.evaluatedPropsToName=Kf;function Ba(e,t,r){Object.keys(r).forEach(n=>e.assign((0,se._)`${t}${(0,se.getProperty)(n)}`,!0))}V.setEvaluated=Ba;var Ff={};function Ow(e,t){return e.scopeValue("func",{ref:t,code:Ff[t.code]||(Ff[t.code]=new xw._Code(t.code))})}V.useFunc=Ow;var Va;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Va||(V.Type=Va={}));function Aw(e,t,r){if(e instanceof se.Name){let n=t===Va.Num;return r?n?(0,se._)`"[" + ${e} + "]"`:(0,se._)`"['" + ${e} + "']"`:n?(0,se._)`"/" + ${e}`:(0,se._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,se.getProperty)(e).toString():"/"+Ha(e)}V.getErrorPath=Aw;function Jf(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}V.checkStrictMode=Jf});var Tt=R(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});var Oe=L(),Cw={data:new Oe.Name("data"),valCxt:new Oe.Name("valCxt"),instancePath:new Oe.Name("instancePath"),parentData:new Oe.Name("parentData"),parentDataProperty:new Oe.Name("parentDataProperty"),rootData:new Oe.Name("rootData"),dynamicAnchors:new Oe.Name("dynamicAnchors"),vErrors:new Oe.Name("vErrors"),errors:new Oe.Name("errors"),this:new Oe.Name("this"),self:new Oe.Name("self"),scope:new Oe.Name("scope"),json:new Oe.Name("json"),jsonPos:new Oe.Name("jsonPos"),jsonLen:new Oe.Name("jsonLen"),jsonPart:new Oe.Name("jsonPart")};Ka.default=Cw});var Mn=R(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});Ae.extendErrors=Ae.resetErrorsCount=Ae.reportExtraError=Ae.reportError=Ae.keyword$DataError=Ae.keywordError=void 0;var Y=L(),cs=W(),Me=Tt();Ae.keywordError={message:({keyword:e})=>(0,Y.str)`must pass "${e}" keyword validation`};Ae.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,Y.str)`"${e}" keyword must be ${t} ($data)`:(0,Y.str)`"${e}" keyword is invalid ($data)`};function Nw(e,t=Ae.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=Yf(e,t,r);n??(i||a)?Gf(s,c):Wf(o,(0,Y._)`[${c}]`)}Ae.reportError=Nw;function jw(e,t=Ae.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=Yf(e,t,r);Gf(o,a),s||i||Wf(n,Me.default.vErrors)}Ae.reportExtraError=jw;function Mw(e,t){e.assign(Me.default.errors,t),e.if((0,Y._)`${Me.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,Y._)`${Me.default.vErrors}.length`,t),()=>e.assign(Me.default.vErrors,null)))}Ae.resetErrorsCount=Mw;function Uw({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,Me.default.errors,a=>{e.const(i,(0,Y._)`${Me.default.vErrors}[${a}]`),e.if((0,Y._)`${i}.instancePath === undefined`,()=>e.assign((0,Y._)`${i}.instancePath`,(0,Y.strConcat)(Me.default.instancePath,s.errorPath))),e.assign((0,Y._)`${i}.schemaPath`,(0,Y.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,Y._)`${i}.schema`,r),e.assign((0,Y._)`${i}.data`,n))})}Ae.extendErrors=Uw;function Gf(e,t){let r=e.const("err",t);e.if((0,Y._)`${Me.default.vErrors} === null`,()=>e.assign(Me.default.vErrors,(0,Y._)`[${r}]`),(0,Y._)`${Me.default.vErrors}.push(${r})`),e.code((0,Y._)`${Me.default.errors}++`)}function Wf(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,Y._)`new ${e.ValidationError}(${t})`):(r.assign((0,Y._)`${n}.errors`,t),r.return(!1))}var sr={keyword:new Y.Name("keyword"),schemaPath:new Y.Name("schemaPath"),params:new Y.Name("params"),propertyName:new Y.Name("propertyName"),message:new Y.Name("message"),schema:new Y.Name("schema"),parentSchema:new Y.Name("parentSchema")};function Yf(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,Y._)`{}`:Dw(e,t,r)}function Dw(e,t,r={}){let{gen:n,it:o}=e,s=[Zw(o,r),qw(e,r)];return Lw(e,t,s),n.object(...s)}function Zw({errorPath:e},{instancePath:t}){let r=t?(0,Y.str)`${e}${(0,cs.getErrorPath)(t,cs.Type.Str)}`:e;return[Me.default.instancePath,(0,Y.strConcat)(Me.default.instancePath,r)]}function qw({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,Y.str)`${t}/${e}`;return r&&(o=(0,Y.str)`${o}${(0,cs.getErrorPath)(r,cs.Type.Str)}`),[sr.schemaPath,o]}function Lw(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([sr.keyword,o],[sr.params,typeof t=="function"?t(e):t||(0,Y._)`{}`]),c.messages&&n.push([sr.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([sr.schema,i],[sr.parentSchema,(0,Y._)`${u}${d}`],[Me.default.data,s]),l&&n.push([sr.propertyName,l])}});var Xf=R(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Mr.boolOrEmptySchema=Mr.topBoolOrEmptySchema=void 0;var Fw=Mn(),Vw=L(),Hw=Tt(),Bw={message:"boolean schema is false"};function Kw(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Qf(e,!1):typeof r=="object"&&r.$async===!0?t.return(Hw.default.data):(t.assign((0,Vw._)`${n}.errors`,null),t.return(!0))}Mr.topBoolOrEmptySchema=Kw;function Jw(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Qf(e)):r.var(t,!0)}Mr.boolOrEmptySchema=Jw;function Qf(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,Fw.reportError)(o,Bw,void 0,t)}});var Ja=R(Ur=>{"use strict";Object.defineProperty(Ur,"__esModule",{value:!0});Ur.getRules=Ur.isJSONType=void 0;var Gw=["string","number","integer","boolean","null","object","array"],Ww=new Set(Gw);function Yw(e){return typeof e=="string"&&Ww.has(e)}Ur.isJSONType=Yw;function Qw(){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:{}}}Ur.getRules=Qw});var Ga=R(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.shouldUseRule=Mt.shouldUseGroup=Mt.schemaHasRulesForType=void 0;function Xw({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&em(e,n)}Mt.schemaHasRulesForType=Xw;function em(e,t){return t.rules.some(r=>tm(e,r))}Mt.shouldUseGroup=em;function tm(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))}Mt.shouldUseRule=tm});var Un=R(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.reportTypeError=Ce.checkDataTypes=Ce.checkDataType=Ce.coerceAndCheckDataType=Ce.getJSONTypes=Ce.getSchemaTypes=Ce.DataType=void 0;var e0=Ja(),t0=Ga(),r0=Mn(),q=L(),rm=W(),Dr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Dr||(Ce.DataType=Dr={}));function n0(e){let t=nm(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}Ce.getSchemaTypes=n0;function nm(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(e0.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Ce.getJSONTypes=nm;function o0(e,t){let{gen:r,data:n,opts:o}=e,s=s0(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,t0.schemaHasRulesForType)(e,t[0]));if(i){let a=Ya(t,n,o.strictNumbers,Dr.Wrong);r.if(a,()=>{s.length?i0(e,t,s):Qa(e)})}return i}Ce.coerceAndCheckDataType=o0;var om=new Set(["string","number","integer","boolean","null"]);function s0(e,t){return t?e.filter(r=>om.has(r)||t==="array"&&r==="array"):[]}function i0(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,q._)`typeof ${o}`),a=n.let("coerced",(0,q._)`undefined`);s.coerceTypes==="array"&&n.if((0,q._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,q._)`${o}[0]`).assign(i,(0,q._)`typeof ${o}`).if(Ya(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,q._)`${a} !== undefined`);for(let l of r)(om.has(l)||l==="array"&&s.coerceTypes==="array")&&c(l);n.else(),Qa(e),n.endIf(),n.if((0,q._)`${a} !== undefined`,()=>{n.assign(o,a),a0(e,a)});function c(l){switch(l){case"string":n.elseIf((0,q._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,q._)`"" + ${o}`).elseIf((0,q._)`${o} === null`).assign(a,(0,q._)`""`);return;case"number":n.elseIf((0,q._)`${i} == "boolean" || ${o} === null
|
|
5
|
-
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,
|
|
6
|
-
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,
|
|
7
|
-
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,q._)`[${o}]`)}}}function a0({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,q._)`${t} !== undefined`,()=>e.assign((0,q._)`${t}[${r}]`,n))}function Wa(e,t,r,n=Dr.Correct){let o=n===Dr.Correct?q.operators.EQ:q.operators.NEQ,s;switch(e){case"null":return(0,q._)`${t} ${o} null`;case"array":s=(0,q._)`Array.isArray(${t})`;break;case"object":s=(0,q._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,q._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,q._)`typeof ${t} ${o} ${e}`}return n===Dr.Correct?s:(0,q.not)(s);function i(a=q.nil){return(0,q.and)((0,q._)`typeof ${t} == "number"`,a,r?(0,q._)`isFinite(${t})`:q.nil)}}Ce.checkDataType=Wa;function Ya(e,t,r,n){if(e.length===1)return Wa(e[0],t,r,n);let o,s=(0,rm.toHash)(e);if(s.array&&s.object){let i=(0,q._)`typeof ${t} != "object"`;o=s.null?i:(0,q._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=q.nil;s.number&&delete s.integer;for(let i in s)o=(0,q.and)(o,Wa(i,t,r,n));return o}Ce.checkDataTypes=Ya;var c0={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,q._)`{type: ${e}}`:(0,q._)`{type: ${t}}`};function Qa(e){let t=u0(e);(0,r0.reportError)(t,c0)}Ce.reportTypeError=Qa;function u0(e){let{gen:t,data:r,schema:n}=e,o=(0,rm.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var im=R(us=>{"use strict";Object.defineProperty(us,"__esModule",{value:!0});us.assignDefaults=void 0;var Zr=L(),l0=W();function d0(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)sm(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>sm(e,s,o.default))}us.assignDefaults=d0;function sm(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,Zr._)`${s}${(0,Zr.getProperty)(t)}`;if(o){(0,l0.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,Zr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Zr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Zr._)`${a} = ${(0,Zr.stringify)(r)}`)}});var tt=R(ne=>{"use strict";Object.defineProperty(ne,"__esModule",{value:!0});ne.validateUnion=ne.validateArray=ne.usePattern=ne.callValidateCode=ne.schemaProperties=ne.allSchemaProperties=ne.noPropertyInData=ne.propertyInData=ne.isOwnProperty=ne.hasPropFunc=ne.reportMissingProp=ne.checkMissingProp=ne.checkReportMissingProp=void 0;var pe=L(),Xa=W(),Ut=Tt(),p0=W();function f0(e,t){let{gen:r,data:n,it:o}=e;r.if(tc(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,pe._)`${t}`},!0),e.error()})}ne.checkReportMissingProp=f0;function m0({gen:e,data:t,it:{opts:r}},n,o){return(0,pe.or)(...n.map(s=>(0,pe.and)(tc(e,t,s,r.ownProperties),(0,pe._)`${o} = ${s}`)))}ne.checkMissingProp=m0;function h0(e,t){e.setParams({missingProperty:t},!0),e.error()}ne.reportMissingProp=h0;function am(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,pe._)`Object.prototype.hasOwnProperty`})}ne.hasPropFunc=am;function ec(e,t,r){return(0,pe._)`${am(e)}.call(${t}, ${r})`}ne.isOwnProperty=ec;function g0(e,t,r,n){let o=(0,pe._)`${t}${(0,pe.getProperty)(r)} !== undefined`;return n?(0,pe._)`${o} && ${ec(e,t,r)}`:o}ne.propertyInData=g0;function tc(e,t,r,n){let o=(0,pe._)`${t}${(0,pe.getProperty)(r)} === undefined`;return n?(0,pe.or)(o,(0,pe.not)(ec(e,t,r))):o}ne.noPropertyInData=tc;function cm(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}ne.allSchemaProperties=cm;function _0(e,t){return cm(t).filter(r=>!(0,Xa.alwaysValidSchema)(e,t[r]))}ne.schemaProperties=_0;function y0({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,l){let u=l?(0,pe._)`${e}, ${t}, ${n}${o}`:t,d=[[Ut.default.instancePath,(0,pe.strConcat)(Ut.default.instancePath,s)],[Ut.default.parentData,i.parentData],[Ut.default.parentDataProperty,i.parentDataProperty],[Ut.default.rootData,Ut.default.rootData]];i.opts.dynamicRef&&d.push([Ut.default.dynamicAnchors,Ut.default.dynamicAnchors]);let f=(0,pe._)`${u}, ${r.object(...d)}`;return c!==pe.nil?(0,pe._)`${a}.call(${c}, ${f})`:(0,pe._)`${a}(${f})`}ne.callValidateCode=y0;var v0=(0,pe._)`new RegExp`;function b0({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,pe._)`${o.code==="new RegExp"?v0:(0,p0.useFunc)(e,o)}(${r}, ${n})`})}ne.usePattern=b0;function w0(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,pe._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:Xa.Type.Num},s),t.if((0,pe.not)(s),a)})}}ne.validateArray=w0;function $0(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,Xa.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,pe._)`${i} || ${a}`),e.mergeValidEvaluated(u,a)||t.if((0,pe.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}ne.validateUnion=$0});var dm=R(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.validateKeywordUsage=ht.validSchemaType=ht.funcKeywordCode=ht.macroKeywordCode=void 0;var Ue=L(),ir=Tt(),S0=tt(),x0=Mn();function k0(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=lm(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let l=r.name("valid");e.subschema({schema:a,schemaPath:Ue.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}ht.macroKeywordCode=k0;function z0(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;T0(c,t);let l=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,u=lm(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&&um(e),y(()=>e.error());else{let S=t.async?m():h();t.modifying&&um(e),y(()=>P0(e,S))}}function m(){let S=n.let("ruleErrs",null);return n.try(()=>g((0,Ue._)`await `),$=>n.assign(d,!1).if((0,Ue._)`${$} instanceof ${c.ValidationError}`,()=>n.assign(S,(0,Ue._)`${$}.errors`),()=>n.throw($))),S}function h(){let S=(0,Ue._)`${u}.errors`;return n.assign(S,null),g(Ue.nil),S}function g(S=t.async?(0,Ue._)`await `:Ue.nil){let $=c.opts.passContext?ir.default.this:ir.default.self,w=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,Ue._)`${S}${(0,S0.callValidateCode)(e,u,$,w)}`,t.modifying)}function y(S){var $;n.if((0,Ue.not)(($=t.valid)!==null&&$!==void 0?$:d),S)}}ht.funcKeywordCode=z0;function um(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Ue._)`${n.parentData}[${n.parentDataProperty}]`))}function P0(e,t){let{gen:r}=e;r.if((0,Ue._)`Array.isArray(${t})`,()=>{r.assign(ir.default.vErrors,(0,Ue._)`${ir.default.vErrors} === null ? ${t} : ${ir.default.vErrors}.concat(${t})`).assign(ir.default.errors,(0,Ue._)`${ir.default.vErrors}.length`),(0,x0.extendErrors)(e)},()=>e.error())}function T0({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function lm(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,Ue.stringify)(r)})}function R0(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")}ht.validSchemaType=R0;function E0({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)}}ht.validateKeywordUsage=E0});var fm=R(Dt=>{"use strict";Object.defineProperty(Dt,"__esModule",{value:!0});Dt.extendSubschemaMode=Dt.extendSubschemaData=Dt.getSubschema=void 0;var gt=L(),pm=W();function I0(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,gt._)`${e.schemaPath}${(0,gt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,gt._)`${e.schemaPath}${(0,gt.getProperty)(t)}${(0,gt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,pm.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')}Dt.getSubschema=I0;function O0(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,gt._)`${t.data}${(0,gt.getProperty)(r)}`,!0);c(f),e.errorPath=(0,gt.str)`${l}${(0,pm.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,gt._)`${r}`,e.dataPathArr=[...u,e.parentDataProperty]}if(o!==void 0){let l=o instanceof gt.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]}}Dt.extendSubschemaData=O0;function A0(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}Dt.extendSubschemaMode=A0});var rc=R((nC,mm)=>{"use strict";mm.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 gm=R((oC,hm)=>{"use strict";var Zt=hm.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(){};ls(t,n,o,e,"",e)};Zt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Zt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Zt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Zt.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 ls(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 Zt.arrayKeywords)for(var f=0;f<d.length;f++)ls(e,t,r,d[f],o+"/"+u+"/"+f,s,o,u,n,f)}else if(u in Zt.propsKeywords){if(d&&typeof d=="object")for(var m in d)ls(e,t,r,d[m],o+"/"+u+"/"+C0(m),s,o,u,n,m)}else(u in Zt.keywords||e.allKeys&&!(u in Zt.skipKeywords))&&ls(e,t,r,d,o+"/"+u,s,o,u,n)}r(n,o,s,i,a,c,l)}}function C0(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var Dn=R(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});Ve.getSchemaRefs=Ve.resolveUrl=Ve.normalizeId=Ve._getFullPath=Ve.getFullPath=Ve.inlineRef=void 0;var N0=W(),j0=rc(),M0=gm(),U0=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function D0(e,t=!0){return typeof e=="boolean"?!0:t===!0?!nc(e):t?_m(e)<=t:!1}Ve.inlineRef=D0;var Z0=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function nc(e){for(let t in e){if(Z0.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(nc)||typeof r=="object"&&nc(r))return!0}return!1}function _m(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!U0.has(r)&&(typeof e[r]=="object"&&(0,N0.eachItem)(e[r],n=>t+=_m(n)),t===1/0))return 1/0}return t}function ym(e,t="",r){r!==!1&&(t=qr(t));let n=e.parse(t);return vm(e,n)}Ve.getFullPath=ym;function vm(e,t){return e.serialize(t).split("#")[0]+"#"}Ve._getFullPath=vm;var q0=/#\/?$/;function qr(e){return e?e.replace(q0,""):""}Ve.normalizeId=qr;function L0(e,t,r){return r=qr(r),e.resolve(t,r)}Ve.resolveUrl=L0;var F0=/^[a-z_][-a-z0-9._]*$/i;function V0(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=qr(e[r]||t),s={"":o},i=ym(n,o,!1),a={},c=new Set;return M0(e,{allKeys:!0},(d,f,m,h)=>{if(h===void 0)return;let g=i+f,y=s[h];typeof d[r]=="string"&&(y=S.call(this,d[r])),$.call(this,d.$anchor),$.call(this,d.$dynamicAnchor),s[f]=y;function S(w){let T=this.opts.uriResolver.resolve;if(w=qr(y?T(y,w):w),c.has(w))throw u(w);c.add(w);let v=this.refs[w];return typeof v=="string"&&(v=this.refs[v]),typeof v=="object"?l(d,v.schema,w):w!==qr(g)&&(w[0]==="#"?(l(d,a[w],w),a[w]=d):this.refs[w]=g),w}function $(w){if(typeof w=="string"){if(!F0.test(w))throw new Error(`invalid anchor "${w}"`);S.call(this,`#${w}`)}}}),a;function l(d,f,m){if(f!==void 0&&!j0(d,f))throw u(m)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Ve.getSchemaRefs=V0});var Ln=R(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.getData=qt.KeywordCxt=qt.validateFunctionCode=void 0;var xm=Xf(),bm=Un(),sc=Ga(),ds=Un(),H0=im(),qn=dm(),oc=fm(),I=L(),D=Tt(),B0=Dn(),Rt=W(),Zn=Mn();function K0(e){if(Pm(e)&&(Tm(e),zm(e))){W0(e);return}km(e,()=>(0,xm.topBoolOrEmptySchema)(e))}qt.validateFunctionCode=K0;function km({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,I._)`${D.default.data}, ${D.default.valCxt}`,n.$async,()=>{e.code((0,I._)`"use strict"; ${wm(r,o)}`),G0(e,o),e.code(s)}):e.func(t,(0,I._)`${D.default.data}, ${J0(o)}`,n.$async,()=>e.code(wm(r,o)).code(s))}function J0(e){return(0,I._)`{${D.default.instancePath}="", ${D.default.parentData}, ${D.default.parentDataProperty}, ${D.default.rootData}=${D.default.data}${e.dynamicRef?(0,I._)`, ${D.default.dynamicAnchors}={}`:I.nil}}={}`}function G0(e,t){e.if(D.default.valCxt,()=>{e.var(D.default.instancePath,(0,I._)`${D.default.valCxt}.${D.default.instancePath}`),e.var(D.default.parentData,(0,I._)`${D.default.valCxt}.${D.default.parentData}`),e.var(D.default.parentDataProperty,(0,I._)`${D.default.valCxt}.${D.default.parentDataProperty}`),e.var(D.default.rootData,(0,I._)`${D.default.valCxt}.${D.default.rootData}`),t.dynamicRef&&e.var(D.default.dynamicAnchors,(0,I._)`${D.default.valCxt}.${D.default.dynamicAnchors}`)},()=>{e.var(D.default.instancePath,(0,I._)`""`),e.var(D.default.parentData,(0,I._)`undefined`),e.var(D.default.parentDataProperty,(0,I._)`undefined`),e.var(D.default.rootData,D.default.data),t.dynamicRef&&e.var(D.default.dynamicAnchors,(0,I._)`{}`)})}function W0(e){let{schema:t,opts:r,gen:n}=e;km(e,()=>{r.$comment&&t.$comment&&Em(e),t$(e),n.let(D.default.vErrors,null),n.let(D.default.errors,0),r.unevaluated&&Y0(e),Rm(e),o$(e)})}function Y0(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,I._)`${r}.evaluated`),t.if((0,I._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,I._)`${e.evaluated}.props`,(0,I._)`undefined`)),t.if((0,I._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,I._)`${e.evaluated}.items`,(0,I._)`undefined`))}function wm(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,I._)`/*# sourceURL=${r} */`:I.nil}function Q0(e,t){if(Pm(e)&&(Tm(e),zm(e))){X0(e,t);return}(0,xm.boolOrEmptySchema)(e,t)}function zm({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 Pm(e){return typeof e.schema!="boolean"}function X0(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&Em(e),r$(e),n$(e);let s=n.const("_errs",D.default.errors);Rm(e,s),n.var(t,(0,I._)`${s} === ${D.default.errors}`)}function Tm(e){(0,Rt.checkUnknownRules)(e),e$(e)}function Rm(e,t){if(e.opts.jtd)return $m(e,[],!1,t);let r=(0,bm.getSchemaTypes)(e.schema),n=(0,bm.coerceAndCheckDataType)(e,r);$m(e,r,!n,t)}function e$(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Rt.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function t$(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Rt.checkStrictMode)(e,"default is ignored in the schema root")}function r$(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,B0.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function n$(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Em({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,I._)`${D.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,I.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,I._)`${D.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function o$(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,I._)`${D.default.errors} === 0`,()=>t.return(D.default.data),()=>t.throw((0,I._)`new ${o}(${D.default.vErrors})`)):(t.assign((0,I._)`${n}.errors`,D.default.vErrors),s.unevaluated&&s$(e),t.return((0,I._)`${D.default.errors} === 0`))}function s$({gen:e,evaluated:t,props:r,items:n}){r instanceof I.Name&&e.assign((0,I._)`${t}.props`,r),n instanceof I.Name&&e.assign((0,I._)`${t}.items`,n)}function $m(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,Rt.schemaHasRulesButRef)(s,u))){o.block(()=>Om(e,"$ref",u.all.$ref.definition));return}c.jtd||i$(e,t),o.block(()=>{for(let f of u.rules)d(f);d(u.post)});function d(f){(0,sc.shouldUseGroup)(s,f)&&(f.type?(o.if((0,ds.checkDataType)(f.type,i,c.strictNumbers)),Sm(e,f),t.length===1&&t[0]===f.type&&r&&(o.else(),(0,ds.reportTypeError)(e)),o.endIf()):Sm(e,f),a||o.if((0,I._)`${D.default.errors} === ${n||0}`))}}function Sm(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,H0.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,sc.shouldUseRule)(n,s)&&Om(e,s.keyword,s.definition,t.type)})}function i$(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(a$(e,t),e.opts.allowUnionTypes||c$(e,t),u$(e,e.dataTypes))}function a$(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Im(e.dataTypes,r)||ic(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),d$(e,t)}}function c$(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&ic(e,"use allowUnionTypes to allow union type keyword")}function u$(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,sc.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>l$(t,i))&&ic(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function l$(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Im(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function d$(e,t){let r=[];for(let n of e.dataTypes)Im(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function ic(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Rt.checkStrictMode)(e,t,e.opts.strictTypes)}var ps=class{constructor(t,r,n){if((0,qn.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,Rt.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",Am(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,qn.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",D.default.errors))}result(t,r,n){this.failResult((0,I.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,I.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,I._)`${r} !== undefined && (${(0,I.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?Zn.reportExtraError:Zn.reportError)(this,this.def.error,r)}$dataError(){(0,Zn.reportError)(this,this.def.$dataError||Zn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Zn.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=I.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=I.nil,r=I.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,I.or)((0,I._)`${o} === undefined`,r)),t!==I.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==I.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,I.or)(i(),a());function i(){if(n.length){if(!(r instanceof I.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,I._)`${(0,ds.checkDataTypes)(c,r,s.opts.strictNumbers,ds.DataType.Wrong)}`}return I.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,I._)`!${c}(${r})`}return I.nil}}subschema(t,r){let n=(0,oc.getSubschema)(this.it,t);(0,oc.extendSubschemaData)(n,this.it,t),(0,oc.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return Q0(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Rt.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Rt.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,I.Name)),!0}};qt.KeywordCxt=ps;function Om(e,t,r,n){let o=new ps(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,qn.funcKeywordCode)(o,r):"macro"in r?(0,qn.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,qn.funcKeywordCode)(o,r)}var p$=/^\/(?:[^~]|~0|~1)*$/,f$=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Am(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return D.default.rootData;if(e[0]==="/"){if(!p$.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=D.default.rootData}else{let l=f$.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,I._)`${s}${(0,I.getProperty)((0,Rt.unescapeJsonPointer)(l))}`,i=(0,I._)`${i} && ${s}`);return i;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${t}`}}qt.getData=Am});var fs=R(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});var ac=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};cc.default=ac});var Fn=R(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});var uc=Dn(),lc=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,uc.resolveUrl)(t,r,n),this.missingSchema=(0,uc.normalizeId)((0,uc.getFullPath)(t,this.missingRef))}};dc.default=lc});var hs=R(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});rt.resolveSchema=rt.getCompilingSchema=rt.resolveRef=rt.compileSchema=rt.SchemaEnv=void 0;var ut=L(),m$=fs(),ar=Tt(),lt=Dn(),Cm=W(),h$=Ln(),Lr=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,lt.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};rt.SchemaEnv=Lr;function fc(e){let t=Nm.call(this,e);if(t)return t;let r=(0,lt.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new ut.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:m$.default,code:(0,ut._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let l={gen:i,allErrors:this.opts.allErrors,data:ar.default.data,parentData:ar.default.parentData,parentDataProperty:ar.default.parentDataProperty,dataNames:[ar.default.data],dataPathArr:[ut.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,ut.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:ut.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,ut._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(e),(0,h$.validateFunctionCode)(l),i.optimize(this.opts.code.optimize);let d=i.toString();u=`${i.scopeRefs(ar.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,e));let m=new Function(`${ar.default.self}`,`${ar.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 ut.Name?void 0:h,items:g instanceof ut.Name?void 0:g,dynamicProps:h instanceof ut.Name,dynamicItems:g instanceof ut.Name},m.source&&(m.source.evaluated=(0,ut.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)}}rt.compileSchema=fc;function g$(e,t,r){var n;r=(0,lt.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=v$.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 Lr({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=_$.call(this,s)}rt.resolveRef=g$;function _$(e){return(0,lt.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:fc.call(this,e)}function Nm(e){for(let t of this._compilations)if(y$(t,e))return t}rt.getCompilingSchema=Nm;function y$(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function v$(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||ms.call(this,e,t)}function ms(e,t){let r=this.opts.uriResolver.parse(t),n=(0,lt._getFullPath)(this.opts.uriResolver,r),o=(0,lt.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return pc.call(this,r,e);let s=(0,lt.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=ms.call(this,e,i);return typeof a?.schema!="object"?void 0:pc.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||fc.call(this,i),s===(0,lt.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,l=a[c];return l&&(o=(0,lt.resolveUrl)(this.opts.uriResolver,o,l)),new Lr({schema:a,schemaId:c,root:e,baseId:o})}return pc.call(this,r,i)}}rt.resolveSchema=ms;var b$=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function pc(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,Cm.unescapeFragment)(a)];if(c===void 0)return;r=c;let l=typeof r=="object"&&r[this.opts.schemaId];!b$.has(a)&&l&&(t=(0,lt.resolveUrl)(this.opts.uriResolver,t,l))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,Cm.schemaHasRulesButRef)(r,this.RULES)){let a=(0,lt.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=ms.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Lr({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var jm=R((lC,w$)=>{w$.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 gc=R((dC,Lm)=>{"use strict";var $$=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Um=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),mc=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Dm=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),S$=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function hc(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 x$=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Mm(e){return e.length=0,!0}function k$(e,t,r){if(e.length){let n=hc(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function z$(e){let t=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=k$;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(hc(o))),r.address=n.join(""),r}function Zm(e){if(P$(e,":")<2)return{host:e,isIPV6:!1};let t=z$(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 P$(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function T$(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 R$={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},E$=/[@/?#:]/g,I$=/[@/?#]/g;function qm(e,t){let r=t?I$:E$;return r.lastIndex=0,e.replace(r,n=>R$[n])}function O$(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(mc(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&Dm(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function A$(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(mc(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));s!=="."&&Dm(s)?t+=s:t+="%"+o,r+=2;continue}}S$(e[r])?t+=e[r]:t+=escape(e[r])}return t}function C$(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(mc(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function N$(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!Um(r)){let n=Zm(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=qm(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}Lm.exports={nonSimpleDomain:x$,recomposeAuthority:N$,reescapeHostDelimiters:qm,normalizePercentEncoding:O$,normalizePathEncoding:A$,escapePreservingEscapes:C$,removeDotSegments:T$,isIPv4:Um,isUUID:$$,normalizeIPv6:Zm,stringArrayToHexStripped:hc}});var Km=R((pC,Bm)=>{"use strict";var{isUUID:j$}=gc(),M$=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,U$=["http","https","ws","wss","urn","urn:uuid"];function D$(e){return U$.indexOf(e)!==-1}function _c(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 Fm(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Vm(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 Z$(e){return e.secure=_c(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function q$(e){if((e.port===(_c(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 L$(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(M$);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=yc(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function F$(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=yc(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 V$(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!j$(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function H$(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Hm={scheme:"http",domainHost:!0,parse:Fm,serialize:Vm},B$={scheme:"https",domainHost:Hm.domainHost,parse:Fm,serialize:Vm},gs={scheme:"ws",domainHost:!0,parse:Z$,serialize:q$},K$={scheme:"wss",domainHost:gs.domainHost,parse:gs.parse,serialize:gs.serialize},J$={scheme:"urn",parse:L$,serialize:F$,skipNormalize:!0},G$={scheme:"urn:uuid",parse:V$,serialize:H$,skipNormalize:!0},_s={http:Hm,https:B$,ws:gs,wss:K$,urn:J$,"urn:uuid":G$};Object.setPrototypeOf(_s,null);function yc(e){return e&&(_s[e]||_s[e.toLowerCase()])||void 0}Bm.exports={wsIsSecure:_c,SCHEMES:_s,isValidSchemeName:D$,getSchemeHandler:yc}});var Xm=R((fC,ys)=>{"use strict";var{normalizeIPv6:W$,removeDotSegments:Vn,recomposeAuthority:Y$,normalizePercentEncoding:Q$,normalizePathEncoding:X$,escapePreservingEscapes:eS,reescapeHostDelimiters:tS,isIPv4:rS,nonSimpleDomain:nS}=gc(),{SCHEMES:oS,getSchemeHandler:Gm}=Km();function sS(e,t){return typeof e=="string"?e=dS(e,t):typeof e=="object"&&(e=Fr(cr(e,t),t)),e}function iS(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=Wm(Fr(e,n),Fr(t,n),n,!0);return n.skipEscape=!0,cr(o,n)}function Wm(e,t,r,n){let o={};return n||(e=Fr(cr(e,r),r),t=Fr(cr(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=Vn(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=Vn(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=Vn(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=Vn(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 aS(e,t,r){let n=Jm(e,r),o=Jm(t,r);return n!==void 0&&o!==void 0&&n.toLowerCase()===o.toLowerCase()}function cr(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=Gm(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=Q$(r.path):(r.path=eS(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=Y$(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=Vn(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 cS=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,uS=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/;function lS(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 Ym(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(uS);i!==null&&i[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let a=e.match(cS);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=lS(n,a);if(c!==void 0&&(n.error=n.error||c,o=!0),n.host)if(rS(n.host)===!1){let d=W$(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=Gm(r.scheme||n.scheme);if(!r.unicodeSupport&&(!l||!l.unicodeSupport)&&n.host&&(r.domainHost||l&&l.domainHost)&&s===!1&&nS(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=tS(unescape(n.host),s))),n.path&&(n.path=X$(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 Fr(e,t){return Ym(e,t).parsed}function dS(e,t){return Qm(e,t).normalized}function Qm(e,t){let{parsed:r,malformedAuthorityOrPort:n}=Ym(e,t);return{normalized:n?e:cr(r,t),malformedAuthorityOrPort:n}}function Jm(e,t){if(typeof e=="string"){let{normalized:r,malformedAuthorityOrPort:n}=Qm(e,t);return n?void 0:r}if(typeof e=="object")return cr(e,t)}var vc={SCHEMES:oS,normalize:sS,resolve:iS,resolveComponent:Wm,equal:aS,serialize:cr,parse:Fr};ys.exports=vc;ys.exports.default=vc;ys.exports.fastUri=vc});var th=R(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});var eh=Xm();eh.code='require("ajv/dist/runtime/uri").default';bc.default=eh});var uh=R(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.CodeGen=Pe.Name=Pe.nil=Pe.stringify=Pe.str=Pe._=Pe.KeywordCxt=void 0;var pS=Ln();Object.defineProperty(Pe,"KeywordCxt",{enumerable:!0,get:function(){return pS.KeywordCxt}});var Vr=L();Object.defineProperty(Pe,"_",{enumerable:!0,get:function(){return Vr._}});Object.defineProperty(Pe,"str",{enumerable:!0,get:function(){return Vr.str}});Object.defineProperty(Pe,"stringify",{enumerable:!0,get:function(){return Vr.stringify}});Object.defineProperty(Pe,"nil",{enumerable:!0,get:function(){return Vr.nil}});Object.defineProperty(Pe,"Name",{enumerable:!0,get:function(){return Vr.Name}});Object.defineProperty(Pe,"CodeGen",{enumerable:!0,get:function(){return Vr.CodeGen}});var fS=fs(),ih=Fn(),mS=Ja(),Hn=hs(),hS=L(),Bn=Dn(),vs=Un(),$c=W(),rh=jm(),gS=th(),ah=(e,t)=>new RegExp(e,t);ah.code="new RegExp";var _S=["removeAdditional","useDefaults","coerceTypes"],yS=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),vS={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."},bS={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},nh=200;function wS(e){var t,r,n,o,s,i,a,c,l,u,d,f,m,h,g,y,S,$,w,T,v,x,A,B,J;let _e=e.strict,We=(t=e.code)===null||t===void 0?void 0:t.optimize,wr=We===!0||We===void 0?1:We||0,Jt=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:ah,Ye=(o=e.uriResolver)!==null&&o!==void 0?o:gS.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:_e)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:_e)!==null&&c!==void 0?c:!0,strictTypes:(u=(l=e.strictTypes)!==null&&l!==void 0?l:_e)!==null&&u!==void 0?u:"log",strictTuples:(f=(d=e.strictTuples)!==null&&d!==void 0?d:_e)!==null&&f!==void 0?f:"log",strictRequired:(h=(m=e.strictRequired)!==null&&m!==void 0?m:_e)!==null&&h!==void 0?h:!1,code:e.code?{...e.code,optimize:wr,regExp:Jt}:{optimize:wr,regExp:Jt},loopRequired:(g=e.loopRequired)!==null&&g!==void 0?g:nh,loopEnum:(y=e.loopEnum)!==null&&y!==void 0?y:nh,meta:(S=e.meta)!==null&&S!==void 0?S:!0,messages:($=e.messages)!==null&&$!==void 0?$:!0,inlineRefs:(w=e.inlineRefs)!==null&&w!==void 0?w:!0,schemaId:(T=e.schemaId)!==null&&T!==void 0?T:"$id",addUsedSchema:(v=e.addUsedSchema)!==null&&v!==void 0?v:!0,validateSchema:(x=e.validateSchema)!==null&&x!==void 0?x:!0,validateFormats:(A=e.validateFormats)!==null&&A!==void 0?A:!0,unicodeRegExp:(B=e.unicodeRegExp)!==null&&B!==void 0?B:!0,int32range:(J=e.int32range)!==null&&J!==void 0?J:!0,uriResolver:Ye}}var Kn=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,...wS(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new hS.ValueScope({scope:{},prefixes:yS,es5:r,lines:n}),this.logger=PS(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,mS.getRules)(),oh.call(this,vS,t,"NOT SUPPORTED"),oh.call(this,bS,t,"DEPRECATED","warn"),this._metaOpts=kS.call(this),t.formats&&SS.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&xS.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),$S.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=rh;n==="id"&&(o={...rh},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 ih.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,Bn.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=sh.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new Hn.SchemaEnv({schema:{},schemaId:n});if(r=Hn.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=sh.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,Bn.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(RS.call(this,n,r),!r)return(0,$c.eachItem)(n,s=>wc.call(this,s)),this;IS.call(this,r);let o={...r,type:(0,vs.getJSONTypes)(r.type),schemaType:(0,vs.getJSONTypes)(r.schemaType)};return(0,$c.eachItem)(n,o.type.length===0?s=>wc.call(this,s,o):s=>o.type.forEach(i=>wc.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]=ch(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,Bn.normalizeId)(i||n);let l=Bn.getSchemaRefs.call(this,t,n);return c=new Hn.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):Hn.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{Hn.compileSchema.call(this,t)}finally{this.opts=r}}};Kn.ValidationError=fS.default;Kn.MissingRefError=ih.default;Pe.default=Kn;function oh(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 sh(e){return e=(0,Bn.normalizeId)(e),this.schemas[e]||this.refs[e]}function $S(){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 SS(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function xS(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 kS(){let e={...this.opts};for(let t of _S)delete e[t];return e}var zS={log(){},warn(){},error(){}};function PS(e){if(e===!1)return zS;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 TS=/^[a-z_$][a-z0-9_$:-]*$/i;function RS(e,t){let{RULES:r}=this;if((0,$c.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!TS.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 wc(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,vs.getJSONTypes)(t.type),schemaType:(0,vs.getJSONTypes)(t.schemaType)}};t.before?ES.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 ES(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 IS(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=ch(t)),e.validateSchema=this.compile(t,!0))}var OS={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ch(e){return{anyOf:[e,OS]}}});var lh=R(Sc=>{"use strict";Object.defineProperty(Sc,"__esModule",{value:!0});var AS={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Sc.default=AS});var mh=R(ur=>{"use strict";Object.defineProperty(ur,"__esModule",{value:!0});ur.callRef=ur.getValidate=void 0;var CS=Fn(),dh=tt(),He=L(),Hr=Tt(),ph=hs(),bs=W(),NS={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=ph.resolveRef.call(c,l,o,r);if(u===void 0)throw new CS.default(n.opts.uriResolver,o,r);if(u instanceof ph.SchemaEnv)return f(u);return m(u);function d(){if(s===l)return ws(e,i,s,s.$async);let h=t.scopeValue("root",{ref:l});return ws(e,(0,He._)`${h}.validate`,l,l.$async)}function f(h){let g=fh(e,h);ws(e,g,h,h.$async)}function m(h){let g=t.scopeValue("schema",a.code.source===!0?{ref:h,code:(0,He.stringify)(h)}:{ref:h}),y=t.name("valid"),S=e.subschema({schema:h,dataTypes:[],schemaPath:He.nil,topSchemaRef:g,errSchemaPath:r},y);e.mergeEvaluated(S),e.ok(y)}}};function fh(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,He._)`${r.scopeValue("wrapper",{ref:t})}.validate`}ur.getValidate=fh;function ws(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,l=c.passContext?Hr.default.this:He.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,He._)`await ${(0,dh.callValidateCode)(e,t,l)}`),m(t),i||o.assign(h,!0)},g=>{o.if((0,He._)`!(${g} instanceof ${s.ValidationError})`,()=>o.throw(g)),f(g),i||o.assign(h,!1)}),e.ok(h)}function d(){e.result((0,dh.callValidateCode)(e,t,l),()=>m(t),()=>f(t))}function f(h){let g=(0,He._)`${h}.errors`;o.assign(Hr.default.vErrors,(0,He._)`${Hr.default.vErrors} === null ? ${g} : ${Hr.default.vErrors}.concat(${g})`),o.assign(Hr.default.errors,(0,He._)`${Hr.default.vErrors}.length`)}function m(h){var g;if(!s.opts.unevaluated)return;let y=(g=r?.validate)===null||g===void 0?void 0:g.evaluated;if(s.props!==!0)if(y&&!y.dynamicProps)y.props!==void 0&&(s.props=bs.mergeEvaluated.props(o,y.props,s.props));else{let S=o.var("props",(0,He._)`${h}.evaluated.props`);s.props=bs.mergeEvaluated.props(o,S,s.props,He.Name)}if(s.items!==!0)if(y&&!y.dynamicItems)y.items!==void 0&&(s.items=bs.mergeEvaluated.items(o,y.items,s.items));else{let S=o.var("items",(0,He._)`${h}.evaluated.items`);s.items=bs.mergeEvaluated.items(o,S,s.items,He.Name)}}}ur.callRef=ws;ur.default=NS});var hh=R(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});var jS=lh(),MS=mh(),US=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",jS.default,MS.default];xc.default=US});var gh=R(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});var $s=L(),Lt=$s.operators,Ss={maximum:{okStr:"<=",ok:Lt.LTE,fail:Lt.GT},minimum:{okStr:">=",ok:Lt.GTE,fail:Lt.LT},exclusiveMaximum:{okStr:"<",ok:Lt.LT,fail:Lt.GTE},exclusiveMinimum:{okStr:">",ok:Lt.GT,fail:Lt.LTE}},DS={message:({keyword:e,schemaCode:t})=>(0,$s.str)`must be ${Ss[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,$s._)`{comparison: ${Ss[e].okStr}, limit: ${t}}`},ZS={keyword:Object.keys(Ss),type:"number",schemaType:"number",$data:!0,error:DS,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,$s._)`${r} ${Ss[t].fail} ${n} || isNaN(${r})`)}};kc.default=ZS});var _h=R(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});var Jn=L(),qS={message:({schemaCode:e})=>(0,Jn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,Jn._)`{multipleOf: ${e}}`},LS={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:qS,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,Jn._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,Jn._)`${i} !== parseInt(${i})`;e.fail$data((0,Jn._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};zc.default=LS});var vh=R(Pc=>{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});function yh(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}Pc.default=yh;yh.code='require("ajv/dist/runtime/ucs2length").default'});var bh=R(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});var lr=L(),FS=W(),VS=vh(),HS={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,lr.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,lr._)`{limit: ${e}}`},BS={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:HS,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?lr.operators.GT:lr.operators.LT,i=o.opts.unicode===!1?(0,lr._)`${r}.length`:(0,lr._)`${(0,FS.useFunc)(e.gen,VS.default)}(${r})`;e.fail$data((0,lr._)`${i} ${s} ${n}`)}};Tc.default=BS});var wh=R(Rc=>{"use strict";Object.defineProperty(Rc,"__esModule",{value:!0});var KS=tt(),JS=W(),Br=L(),GS={message:({schemaCode:e})=>(0,Br.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Br._)`{pattern: ${e}}`},WS={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:GS,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,Br._)`new RegExp`:(0,JS.useFunc)(t,c),u=t.let("valid");t.try(()=>t.assign(u,(0,Br._)`${l}(${s}, ${a}).test(${r})`),()=>t.assign(u,!1)),e.fail$data((0,Br._)`!${u}`)}else{let c=(0,KS.usePattern)(e,o);e.fail$data((0,Br._)`!${c}.test(${r})`)}}};Rc.default=WS});var $h=R(Ec=>{"use strict";Object.defineProperty(Ec,"__esModule",{value:!0});var Gn=L(),YS={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,Gn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,Gn._)`{limit: ${e}}`},QS={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:YS,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?Gn.operators.GT:Gn.operators.LT;e.fail$data((0,Gn._)`Object.keys(${r}).length ${o} ${n}`)}};Ec.default=QS});var Sh=R(Ic=>{"use strict";Object.defineProperty(Ic,"__esModule",{value:!0});var Wn=tt(),Yn=L(),XS=W(),ex={message:({params:{missingProperty:e}})=>(0,Yn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,Yn._)`{missingProperty: ${e}}`},tx={keyword:"required",type:"object",schemaType:"array",$data:!0,error:ex,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 y=i.schemaEnv.baseId+i.errSchemaPath,S=`required property "${g}" is not defined at "${y}" (strictRequired)`;(0,XS.checkStrictMode)(i,S,i.opts.strictRequired)}}function l(){if(c||s)e.block$data(Yn.nil,d);else for(let m of r)(0,Wn.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,Wn.checkMissingProp)(e,r,m)),(0,Wn.reportMissingProp)(e,m),t.else()}function d(){t.forOf("prop",n,m=>{e.setParams({missingProperty:m}),t.if((0,Wn.noPropertyInData)(t,o,m,a.ownProperties),()=>e.error())})}function f(m,h){e.setParams({missingProperty:m}),t.forOf(m,n,()=>{t.assign(h,(0,Wn.propertyInData)(t,o,m,a.ownProperties)),t.if((0,Yn.not)(h),()=>{e.error(),t.break()})},Yn.nil)}}};Ic.default=tx});var xh=R(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});var Qn=L(),rx={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,Qn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,Qn._)`{limit: ${e}}`},nx={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:rx,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?Qn.operators.GT:Qn.operators.LT;e.fail$data((0,Qn._)`${r}.length ${o} ${n}`)}};Oc.default=nx});var xs=R(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});var kh=rc();kh.code='require("ajv/dist/runtime/equal").default';Ac.default=kh});var zh=R(Nc=>{"use strict";Object.defineProperty(Nc,"__esModule",{value:!0});var Cc=Un(),Te=L(),ox=W(),sx=xs(),ix={message:({params:{i:e,j:t}})=>(0,Te.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,Te._)`{i: ${e}, j: ${t}}`},ax={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:ix,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,Cc.getSchemaTypes)(s.items):[];e.block$data(c,u,(0,Te._)`${i} === false`),e.ok(c);function u(){let h=t.let("i",(0,Te._)`${r}.length`),g=t.let("j");e.setParams({i:h,j:g}),t.assign(c,!0),t.if((0,Te._)`${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 y=t.name("item"),S=(0,Cc.checkDataTypes)(l,y,a.opts.strictNumbers,Cc.DataType.Wrong),$=t.const("indices",(0,Te._)`{}`);t.for((0,Te._)`;${h}--;`,()=>{t.let(y,(0,Te._)`${r}[${h}]`),t.if(S,(0,Te._)`continue`),l.length>1&&t.if((0,Te._)`typeof ${y} == "string"`,(0,Te._)`${y} += "_"`),t.if((0,Te._)`typeof ${$}[${y}] == "number"`,()=>{t.assign(g,(0,Te._)`${$}[${y}]`),e.error(),t.assign(c,!1).break()}).code((0,Te._)`${$}[${y}] = ${h}`)})}function m(h,g){let y=(0,ox.useFunc)(t,sx.default),S=t.name("outer");t.label(S).for((0,Te._)`;${h}--;`,()=>t.for((0,Te._)`${g} = ${h}; ${g}--;`,()=>t.if((0,Te._)`${y}(${r}[${h}], ${r}[${g}])`,()=>{e.error(),t.assign(c,!1).break(S)})))}}};Nc.default=ax});var Ph=R(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});var jc=L(),cx=W(),ux=xs(),lx={message:"must be equal to constant",params:({schemaCode:e})=>(0,jc._)`{allowedValue: ${e}}`},dx={keyword:"const",$data:!0,error:lx,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,jc._)`!${(0,cx.useFunc)(t,ux.default)}(${r}, ${o})`):e.fail((0,jc._)`${s} !== ${r}`)}};Mc.default=dx});var Th=R(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});var Xn=L(),px=W(),fx=xs(),mx={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Xn._)`{allowedValues: ${e}}`},hx={keyword:"enum",schemaType:"array",$data:!0,error:mx,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,px.useFunc)(t,fx.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,Xn.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,Xn._)`${l()}(${r}, ${m})`,()=>t.assign(u,!0).break()))}function f(m,h){let g=o[h];return typeof g=="object"&&g!==null?(0,Xn._)`${l()}(${r}, ${m}[${h}])`:(0,Xn._)`${r} === ${g}`}}};Uc.default=hx});var Rh=R(Dc=>{"use strict";Object.defineProperty(Dc,"__esModule",{value:!0});var gx=gh(),_x=_h(),yx=bh(),vx=wh(),bx=$h(),wx=Sh(),$x=xh(),Sx=zh(),xx=Ph(),kx=Th(),zx=[gx.default,_x.default,yx.default,vx.default,bx.default,wx.default,$x.default,Sx.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},xx.default,kx.default];Dc.default=zx});var qc=R(eo=>{"use strict";Object.defineProperty(eo,"__esModule",{value:!0});eo.validateAdditionalItems=void 0;var dr=L(),Zc=W(),Px={message:({params:{len:e}})=>(0,dr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,dr._)`{limit: ${e}}`},Tx={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Px,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Zc.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Eh(e,n)}};function Eh(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,dr._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,dr._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,Zc.alwaysValidSchema)(i,n)){let l=r.var("valid",(0,dr._)`${a} <= ${t.length}`);r.if((0,dr.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,a,u=>{e.subschema({keyword:s,dataProp:u,dataPropType:Zc.Type.Num},l),i.allErrors||r.if((0,dr.not)(l),()=>r.break())})}}eo.validateAdditionalItems=Eh;eo.default=Tx});var Lc=R(to=>{"use strict";Object.defineProperty(to,"__esModule",{value:!0});to.validateTuple=void 0;var Ih=L(),ks=W(),Rx=tt(),Ex={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return Oh(e,"additionalItems",t);r.items=!0,!(0,ks.alwaysValidSchema)(r,t)&&e.ok((0,Rx.validateArray)(e))}};function Oh(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=ks.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),l=n.const("len",(0,Ih._)`${s}.length`);r.forEach((d,f)=>{(0,ks.alwaysValidSchema)(a,d)||(n.if((0,Ih._)`${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 y=`"${i}" is ${h}-tuple, but minItems or maxItems/${t} are not specified or different at path "${m}"`;(0,ks.checkStrictMode)(a,y,f.strictTuples)}}}to.validateTuple=Oh;to.default=Ex});var Ah=R(Fc=>{"use strict";Object.defineProperty(Fc,"__esModule",{value:!0});var Ix=Lc(),Ox={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,Ix.validateTuple)(e,"items")};Fc.default=Ox});var Nh=R(Vc=>{"use strict";Object.defineProperty(Vc,"__esModule",{value:!0});var Ch=L(),Ax=W(),Cx=tt(),Nx=qc(),jx={message:({params:{len:e}})=>(0,Ch.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Ch._)`{limit: ${e}}`},Mx={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:jx,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,Ax.alwaysValidSchema)(n,t)&&(o?(0,Nx.validateAdditionalItems)(e,o):e.ok((0,Cx.validateArray)(e)))}};Vc.default=Mx});var jh=R(Hc=>{"use strict";Object.defineProperty(Hc,"__esModule",{value:!0});var nt=L(),zs=W(),Ux={message:({params:{min:e,max:t}})=>t===void 0?(0,nt.str)`must contain at least ${e} valid item(s)`:(0,nt.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,nt._)`{minContains: ${e}}`:(0,nt._)`{minContains: ${e}, maxContains: ${t}}`},Dx={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Ux,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,nt._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,zs.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,zs.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,zs.alwaysValidSchema)(s,r)){let g=(0,nt._)`${u} >= ${i}`;a!==void 0&&(g=(0,nt._)`${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,nt._)`${o}.length > 0`,f)):(t.let(d,!1),f()),e.result(d,()=>e.reset());function f(){let g=t.name("_valid"),y=t.let("count",0);m(g,()=>t.if(g,()=>h(y)))}function m(g,y){t.forRange("i",0,u,S=>{e.subschema({keyword:"contains",dataProp:S,dataPropType:zs.Type.Num,compositeRule:!0},g),y()})}function h(g){t.code((0,nt._)`${g}++`),a===void 0?t.if((0,nt._)`${g} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,nt._)`${g} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,nt._)`${g} >= ${i}`,()=>t.assign(d,!0)))}}};Hc.default=Dx});var Dh=R(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:!0});_t.validateSchemaDeps=_t.validatePropertyDeps=_t.error=void 0;var Bc=L(),Zx=W(),ro=tt();_t.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,Bc.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,Bc._)`{property: ${e},
|
|
3
|
+
var x_=Object.create;var Ds=Object.defineProperty;var k_=Object.getOwnPropertyDescriptor;var z_=Object.getOwnPropertyNames;var P_=Object.getPrototypeOf,T_=Object.prototype.hasOwnProperty;var P=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Zs=(e,t)=>{for(var r in t)Ds(e,r,{get:t[r],enumerable:!0})},R_=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of z_(t))!T_.call(e,o)&&o!==r&&Ds(e,o,{get:()=>t[o],enumerable:!(n=k_(t,o))||n.enumerable});return e};var Nu=(e,t,r)=>(r=e!=null?x_(P_(e)):{},R_(t||!e||!e.__esModule?Ds(r,"default",{value:e,enumerable:!0}):r,e));var hn=P(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.regexpCode=H.getEsmExportName=H.getProperty=H.safeStringify=H.stringify=H.strConcat=H.addCodeArg=H.str=H._=H.nil=H._Code=H.Name=H.IDENTIFIER=H._CodeOrName=void 0;var fn=class{};H._CodeOrName=fn;H.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Ft=class extends fn{constructor(t){if(super(),!H.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}}};H.Name=Ft;var Le=class extends fn{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 Ft&&(r[n.str]=(r[n.str]||0)+1),r),{})}};H._Code=Le;H.nil=new Le("");function wf(e,...t){let r=[e[0]],n=0;for(;n<t.length;)pa(r,t[n]),r.push(e[++n]);return new Le(r)}H._=wf;var da=new Le("+");function bf(e,...t){let r=[mn(e[0])],n=0;for(;n<t.length;)r.push(da),pa(r,t[n]),r.push(da,mn(e[++n]));return Nw(r),new Le(r)}H.str=bf;function pa(e,t){t instanceof Le?e.push(...t._items):t instanceof Ft?e.push(t):e.push(qw(t))}H.addCodeArg=pa;function Nw(e){let t=1;for(;t<e.length-1;){if(e[t]===da){let r=jw(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function jw(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Ft||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 Ft))return`"${e}${t.slice(1)}`}function Mw(e,t){return t.emptyStr()?e:e.emptyStr()?t:bf`${e}${t}`}H.strConcat=Mw;function qw(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:mn(Array.isArray(e)?e.join(","):e)}function Uw(e){return new Le(mn(e))}H.stringify=Uw;function mn(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}H.safeStringify=mn;function Dw(e){return typeof e=="string"&&H.IDENTIFIER.test(e)?new Le(`.${e}`):wf`[${e}]`}H.getProperty=Dw;function Zw(e){if(typeof e=="string"&&H.IDENTIFIER.test(e))return new Le(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}H.getEsmExportName=Zw;function Lw(e){return new Le(e.toString())}H.regexpCode=Lw});var ha=P(Ce=>{"use strict";Object.defineProperty(Ce,"__esModule",{value:!0});Ce.ValueScope=Ce.ValueScopeName=Ce.Scope=Ce.varKinds=Ce.UsedValueState=void 0;var Oe=hn(),fa=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||(Ce.UsedValueState=Zo={}));Ce.varKinds={const:new Oe.Name("const"),let:new Oe.Name("let"),var:new Oe.Name("var")};var Lo=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Oe.Name?t:this.name(t)}name(t){return new Oe.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}}};Ce.Scope=Lo;var Fo=class extends Oe.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Oe._)`.${new Oe.Name(r)}[${n}]`}};Ce.ValueScopeName=Fo;var Fw=(0,Oe._)`\n`,ma=class extends Lo{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?Fw:Oe.nil}}get(){return this._scope}name(t){return new Fo(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,Oe._)`${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=Oe.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,Zo.Started);let l=r(u);if(l){let d=this.opts.es5?Ce.varKinds.var:Ce.varKinds.const;s=(0,Oe._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Oe._)`${s}${l}${this.opts._n}`;else throw new fa(u);c.set(u,Zo.Completed)})}return s}};Ce.ValueScope=ma});var M=P(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});q.or=q.and=q.not=q.CodeGen=q.operators=q.varKinds=q.ValueScopeName=q.ValueScope=q.Scope=q.Name=q.regexpCode=q.stringify=q.getProperty=q.nil=q.strConcat=q.str=q._=void 0;var Z=hn(),We=ha(),kt=hn();Object.defineProperty(q,"_",{enumerable:!0,get:function(){return kt._}});Object.defineProperty(q,"str",{enumerable:!0,get:function(){return kt.str}});Object.defineProperty(q,"strConcat",{enumerable:!0,get:function(){return kt.strConcat}});Object.defineProperty(q,"nil",{enumerable:!0,get:function(){return kt.nil}});Object.defineProperty(q,"getProperty",{enumerable:!0,get:function(){return kt.getProperty}});Object.defineProperty(q,"stringify",{enumerable:!0,get:function(){return kt.stringify}});Object.defineProperty(q,"regexpCode",{enumerable:!0,get:function(){return kt.regexpCode}});Object.defineProperty(q,"Name",{enumerable:!0,get:function(){return kt.Name}});var Ko=ha();Object.defineProperty(q,"Scope",{enumerable:!0,get:function(){return Ko.Scope}});Object.defineProperty(q,"ValueScope",{enumerable:!0,get:function(){return Ko.ValueScope}});Object.defineProperty(q,"ValueScopeName",{enumerable:!0,get:function(){return Ko.ValueScopeName}});Object.defineProperty(q,"varKinds",{enumerable:!0,get:function(){return Ko.varKinds}});q.operators={GT:new Z._Code(">"),GTE:new Z._Code(">="),LT:new Z._Code("<"),LTE:new Z._Code("<="),EQ:new Z._Code("==="),NEQ:new Z._Code("!=="),NOT:new Z._Code("!"),OR:new Z._Code("||"),AND:new Z._Code("&&"),ADD:new Z._Code("+")};var pt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},ga=class extends pt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?We.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=$r(this.rhs,t,r)),this}get names(){return this.rhs instanceof Z._CodeOrName?this.rhs.names:{}}},Vo=class extends pt{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 Z.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=$r(this.rhs,t,r),this}get names(){let t=this.lhs instanceof Z.Name?{}:{...this.lhs.names};return Bo(t,this.rhs)}},_a=class extends Vo{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},ya=class extends pt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},va=class extends pt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},wa=class extends pt{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},ba=class extends pt{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=$r(this.code,t,r),this}get names(){return this.code instanceof Z._CodeOrName?this.code.names:{}}},gn=class extends pt{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)||(Vw(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),{})}},ft=class extends gn{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},Sa=class extends gn{},Sr=class extends ft{};Sr.kind="else";var Vt=class e extends ft{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 Sr(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Sf(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=$r(this.condition,t,r),this}get names(){let t=super.names;return Bo(t,this.condition),this.else&&Bt(t,this.else.names),t}};Vt.kind="if";var Ht=class extends ft{};Ht.kind="for";var $a=class extends Ht{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=$r(this.iteration,t,r),this}get names(){return Bt(super.names,this.iteration.names)}},xa=class extends Ht{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?We.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=Bo(super.names,this.from);return Bo(t,this.to)}},Ho=class extends Ht{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=$r(this.iterable,t,r),this}get names(){return Bt(super.names,this.iterable.names)}},_n=class extends ft{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)}};_n.kind="func";var yn=class extends gn{render(t){return"return "+super.render(t)}};yn.kind="return";var ka=class extends ft{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}},vn=class extends ft{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};vn.kind="catch";var wn=class extends ft{render(t){return"finally"+super.render(t)}};wn.kind="finally";var za=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
4
|
+
`:""},this._extScope=t,this._scope=new We.Scope({parent:t}),this._nodes=[new Sa]}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 ga(t,s,n)),s}const(t,r,n){return this._def(We.varKinds.const,t,r,n)}let(t,r,n){return this._def(We.varKinds.let,t,r,n)}var(t,r,n){return this._def(We.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Vo(t,r,n))}add(t,r){return this._leafNode(new _a(t,q.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==Z.nil&&this._leafNode(new ba(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,Z.addCodeArg)(r,o));return r.push("}"),new Z._Code(r)}if(t,r,n){if(this._blockNode(new Vt(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 Vt(t))}else(){return this._elseNode(new Sr)}endIf(){return this._endBlockNode(Vt,Sr)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new $a(t),r)}forRange(t,r,n,o,s=this.opts.es5?We.varKinds.var:We.varKinds.let){let i=this._scope.toName(t);return this._for(new xa(s,i,r,n),()=>o(i))}forOf(t,r,n,o=We.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof Z.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,Z._)`${i}.length`,a=>{this.var(s,(0,Z._)`${i}[${a}]`),n(s)})}return this._for(new Ho("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?We.varKinds.var:We.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,Z._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new Ho("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Ht)}label(t){return this._leafNode(new ya(t))}break(t){return this._leafNode(new va(t))}return(t){let r=new yn;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(yn)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new ka;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new vn(s),r(s)}return n&&(this._currNode=o.finally=new wn,this.code(n)),this._endBlockNode(vn,wn)}throw(t){return this._leafNode(new wa(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=Z.nil,n,o){return this._blockNode(new _n(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(_n)}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 Vt))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}};q.CodeGen=za;function Bt(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Bo(e,t){return t instanceof Z._CodeOrName?Bt(e,t.names):e}function $r(e,t,r){if(e instanceof Z.Name)return n(e);if(!o(e))return e;return new Z._Code(e._items.reduce((s,i)=>(i instanceof Z.Name&&(i=n(i)),i instanceof Z._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 Z._Code&&s._items.some(i=>i instanceof Z.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function Vw(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function Sf(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,Z._)`!${Pa(e)}`}q.not=Sf;var Hw=$f(q.operators.AND);function Bw(...e){return e.reduce(Hw)}q.and=Bw;var Kw=$f(q.operators.OR);function Jw(...e){return e.reduce(Kw)}q.or=Jw;function $f(e){return(t,r)=>t===Z.nil?r:r===Z.nil?t:(0,Z._)`${Pa(t)} ${e} ${Pa(r)}`}function Pa(e){return e instanceof Z.Name?e:(0,Z._)`(${e})`}});var L=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 X=M(),Gw=hn();function Ww(e){let t={};for(let r of e)t[r]=!0;return t}U.toHash=Ww;function Yw(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(zf(e,t),!Pf(t,e.self.RULES.all))}U.alwaysValidSchema=Yw;function zf(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]||Ef(e,`unknown keyword: "${s}"`)}U.checkUnknownRules=zf;function Pf(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}U.schemaHasRules=Pf;function Xw(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=Xw;function Qw({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,X._)`${r}`}return(0,X._)`${e}${t}${(0,X.getProperty)(n)}`}U.schemaRefOrVal=Qw;function eb(e){return Tf(decodeURIComponent(e))}U.unescapeFragment=eb;function tb(e){return encodeURIComponent(Ra(e))}U.escapeFragment=tb;function Ra(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}U.escapeJsonPointer=Ra;function Tf(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}U.unescapeJsonPointer=Tf;function rb(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}U.eachItem=rb;function xf({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof X.Name?(s instanceof X.Name?e(o,s,i):t(o,s,i),i):s instanceof X.Name?(t(o,i,s),s):r(s,i);return a===X.Name&&!(c instanceof X.Name)?n(o,c):c}}U.mergeEvaluated={props:xf({mergeNames:(e,t,r)=>e.if((0,X._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,X._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,X._)`${r} || {}`).code((0,X._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,X._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,X._)`${r} || {}`),Ea(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Rf}),items:xf({mergeNames:(e,t,r)=>e.if((0,X._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,X._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,X._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,X._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Rf(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,X._)`{}`);return t!==void 0&&Ea(e,r,t),r}U.evaluatedPropsToName=Rf;function Ea(e,t,r){Object.keys(r).forEach(n=>e.assign((0,X._)`${t}${(0,X.getProperty)(n)}`,!0))}U.setEvaluated=Ea;var kf={};function nb(e,t){return e.scopeValue("func",{ref:t,code:kf[t.code]||(kf[t.code]=new Gw._Code(t.code))})}U.useFunc=nb;var Ta;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Ta||(U.Type=Ta={}));function ob(e,t,r){if(e instanceof X.Name){let n=t===Ta.Num;return r?n?(0,X._)`"[" + ${e} + "]"`:(0,X._)`"['" + ${e} + "']"`:n?(0,X._)`"/" + ${e}`:(0,X._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,X.getProperty)(e).toString():"/"+Ra(e)}U.getErrorPath=ob;function Ef(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=Ef});var mt=P(Ia=>{"use strict";Object.defineProperty(Ia,"__esModule",{value:!0});var xe=M(),sb={data:new xe.Name("data"),valCxt:new xe.Name("valCxt"),instancePath:new xe.Name("instancePath"),parentData:new xe.Name("parentData"),parentDataProperty:new xe.Name("parentDataProperty"),rootData:new xe.Name("rootData"),dynamicAnchors:new xe.Name("dynamicAnchors"),vErrors:new xe.Name("vErrors"),errors:new xe.Name("errors"),this:new xe.Name("this"),self:new xe.Name("self"),scope:new xe.Name("scope"),json:new xe.Name("json"),jsonPos:new xe.Name("jsonPos"),jsonLen:new xe.Name("jsonLen"),jsonPart:new xe.Name("jsonPart")};Ia.default=sb});var bn=P(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});ke.extendErrors=ke.resetErrorsCount=ke.reportExtraError=ke.reportError=ke.keyword$DataError=ke.keywordError=void 0;var F=M(),Jo=L(),Te=mt();ke.keywordError={message:({keyword:e})=>(0,F.str)`must pass "${e}" keyword validation`};ke.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,F.str)`"${e}" keyword must be ${t} ($data)`:(0,F.str)`"${e}" keyword is invalid ($data)`};function ib(e,t=ke.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=Cf(e,t,r);n??(i||a)?If(s,c):Of(o,(0,F._)`[${c}]`)}ke.reportError=ib;function ab(e,t=ke.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=Cf(e,t,r);If(o,a),s||i||Of(n,Te.default.vErrors)}ke.reportExtraError=ab;function cb(e,t){e.assign(Te.default.errors,t),e.if((0,F._)`${Te.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,F._)`${Te.default.vErrors}.length`,t),()=>e.assign(Te.default.vErrors,null)))}ke.resetErrorsCount=cb;function ub({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,Te.default.errors,a=>{e.const(i,(0,F._)`${Te.default.vErrors}[${a}]`),e.if((0,F._)`${i}.instancePath === undefined`,()=>e.assign((0,F._)`${i}.instancePath`,(0,F.strConcat)(Te.default.instancePath,s.errorPath))),e.assign((0,F._)`${i}.schemaPath`,(0,F.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,F._)`${i}.schema`,r),e.assign((0,F._)`${i}.data`,n))})}ke.extendErrors=ub;function If(e,t){let r=e.const("err",t);e.if((0,F._)`${Te.default.vErrors} === null`,()=>e.assign(Te.default.vErrors,(0,F._)`[${r}]`),(0,F._)`${Te.default.vErrors}.push(${r})`),e.code((0,F._)`${Te.default.errors}++`)}function Of(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,F._)`new ${e.ValidationError}(${t})`):(r.assign((0,F._)`${n}.errors`,t),r.return(!1))}var Kt={keyword:new F.Name("keyword"),schemaPath:new F.Name("schemaPath"),params:new F.Name("params"),propertyName:new F.Name("propertyName"),message:new F.Name("message"),schema:new F.Name("schema"),parentSchema:new F.Name("parentSchema")};function Cf(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,F._)`{}`:lb(e,t,r)}function lb(e,t,r={}){let{gen:n,it:o}=e,s=[db(o,r),pb(e,r)];return fb(e,t,s),n.object(...s)}function db({errorPath:e},{instancePath:t}){let r=t?(0,F.str)`${e}${(0,Jo.getErrorPath)(t,Jo.Type.Str)}`:e;return[Te.default.instancePath,(0,F.strConcat)(Te.default.instancePath,r)]}function pb({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,F.str)`${t}/${e}`;return r&&(o=(0,F.str)`${o}${(0,Jo.getErrorPath)(r,Jo.Type.Str)}`),[Kt.schemaPath,o]}function fb(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([Kt.keyword,o],[Kt.params,typeof t=="function"?t(e):t||(0,F._)`{}`]),c.messages&&n.push([Kt.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([Kt.schema,i],[Kt.parentSchema,(0,F._)`${l}${d}`],[Te.default.data,s]),u&&n.push([Kt.propertyName,u])}});var Nf=P(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});xr.boolOrEmptySchema=xr.topBoolOrEmptySchema=void 0;var mb=bn(),hb=M(),gb=mt(),_b={message:"boolean schema is false"};function yb(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Af(e,!1):typeof r=="object"&&r.$async===!0?t.return(gb.default.data):(t.assign((0,hb._)`${n}.errors`,null),t.return(!0))}xr.topBoolOrEmptySchema=yb;function vb(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Af(e)):r.var(t,!0)}xr.boolOrEmptySchema=vb;function Af(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,mb.reportError)(o,_b,void 0,t)}});var Oa=P(kr=>{"use strict";Object.defineProperty(kr,"__esModule",{value:!0});kr.getRules=kr.isJSONType=void 0;var wb=["string","number","integer","boolean","null","object","array"],bb=new Set(wb);function Sb(e){return typeof e=="string"&&bb.has(e)}kr.isJSONType=Sb;function $b(){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:{}}}kr.getRules=$b});var Ca=P(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});zt.shouldUseRule=zt.shouldUseGroup=zt.schemaHasRulesForType=void 0;function xb({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&jf(e,n)}zt.schemaHasRulesForType=xb;function jf(e,t){return t.rules.some(r=>Mf(e,r))}zt.shouldUseGroup=jf;function Mf(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))}zt.shouldUseRule=Mf});var Sn=P(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.reportTypeError=ze.checkDataTypes=ze.checkDataType=ze.coerceAndCheckDataType=ze.getJSONTypes=ze.getSchemaTypes=ze.DataType=void 0;var kb=Oa(),zb=Ca(),Pb=bn(),j=M(),qf=L(),zr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(zr||(ze.DataType=zr={}));function Tb(e){let t=Uf(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}ze.getSchemaTypes=Tb;function Uf(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(kb.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}ze.getJSONTypes=Uf;function Rb(e,t){let{gen:r,data:n,opts:o}=e,s=Eb(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,zb.schemaHasRulesForType)(e,t[0]));if(i){let a=Na(t,n,o.strictNumbers,zr.Wrong);r.if(a,()=>{s.length?Ib(e,t,s):ja(e)})}return i}ze.coerceAndCheckDataType=Rb;var Df=new Set(["string","number","integer","boolean","null"]);function Eb(e,t){return t?e.filter(r=>Df.has(r)||t==="array"&&r==="array"):[]}function Ib(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,j._)`typeof ${o}`),a=n.let("coerced",(0,j._)`undefined`);s.coerceTypes==="array"&&n.if((0,j._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,j._)`${o}[0]`).assign(i,(0,j._)`typeof ${o}`).if(Na(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,j._)`${a} !== undefined`);for(let u of r)(Df.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),ja(e),n.endIf(),n.if((0,j._)`${a} !== undefined`,()=>{n.assign(o,a),Ob(e,a)});function c(u){switch(u){case"string":n.elseIf((0,j._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,j._)`"" + ${o}`).elseIf((0,j._)`${o} === null`).assign(a,(0,j._)`""`);return;case"number":n.elseIf((0,j._)`${i} == "boolean" || ${o} === null
|
|
5
|
+
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,j._)`+${o}`);return;case"integer":n.elseIf((0,j._)`${i} === "boolean" || ${o} === null
|
|
6
|
+
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,j._)`+${o}`);return;case"boolean":n.elseIf((0,j._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,j._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,j._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,j._)`${i} === "string" || ${i} === "number"
|
|
7
|
+
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,j._)`[${o}]`)}}}function Ob({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,j._)`${t} !== undefined`,()=>e.assign((0,j._)`${t}[${r}]`,n))}function Aa(e,t,r,n=zr.Correct){let o=n===zr.Correct?j.operators.EQ:j.operators.NEQ,s;switch(e){case"null":return(0,j._)`${t} ${o} null`;case"array":s=(0,j._)`Array.isArray(${t})`;break;case"object":s=(0,j._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,j._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,j._)`typeof ${t} ${o} ${e}`}return n===zr.Correct?s:(0,j.not)(s);function i(a=j.nil){return(0,j.and)((0,j._)`typeof ${t} == "number"`,a,r?(0,j._)`isFinite(${t})`:j.nil)}}ze.checkDataType=Aa;function Na(e,t,r,n){if(e.length===1)return Aa(e[0],t,r,n);let o,s=(0,qf.toHash)(e);if(s.array&&s.object){let i=(0,j._)`typeof ${t} != "object"`;o=s.null?i:(0,j._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=j.nil;s.number&&delete s.integer;for(let i in s)o=(0,j.and)(o,Aa(i,t,r,n));return o}ze.checkDataTypes=Na;var Cb={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,j._)`{type: ${e}}`:(0,j._)`{type: ${t}}`};function ja(e){let t=Ab(e);(0,Pb.reportError)(t,Cb)}ze.reportTypeError=ja;function Ab(e){let{gen:t,data:r,schema:n}=e,o=(0,qf.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var Lf=P(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});Go.assignDefaults=void 0;var Pr=M(),Nb=L();function jb(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)Zf(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Zf(e,s,o.default))}Go.assignDefaults=jb;function Zf(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,Pr._)`${s}${(0,Pr.getProperty)(t)}`;if(o){(0,Nb.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,Pr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Pr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Pr._)`${a} = ${(0,Pr.stringify)(r)}`)}});var Fe=P(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.validateUnion=W.validateArray=W.usePattern=W.callValidateCode=W.schemaProperties=W.allSchemaProperties=W.noPropertyInData=W.propertyInData=W.isOwnProperty=W.hasPropFunc=W.reportMissingProp=W.checkMissingProp=W.checkReportMissingProp=void 0;var se=M(),Ma=L(),Pt=mt(),Mb=L();function qb(e,t){let{gen:r,data:n,it:o}=e;r.if(Ua(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,se._)`${t}`},!0),e.error()})}W.checkReportMissingProp=qb;function Ub({gen:e,data:t,it:{opts:r}},n,o){return(0,se.or)(...n.map(s=>(0,se.and)(Ua(e,t,s,r.ownProperties),(0,se._)`${o} = ${s}`)))}W.checkMissingProp=Ub;function Db(e,t){e.setParams({missingProperty:t},!0),e.error()}W.reportMissingProp=Db;function Ff(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,se._)`Object.prototype.hasOwnProperty`})}W.hasPropFunc=Ff;function qa(e,t,r){return(0,se._)`${Ff(e)}.call(${t}, ${r})`}W.isOwnProperty=qa;function Zb(e,t,r,n){let o=(0,se._)`${t}${(0,se.getProperty)(r)} !== undefined`;return n?(0,se._)`${o} && ${qa(e,t,r)}`:o}W.propertyInData=Zb;function Ua(e,t,r,n){let o=(0,se._)`${t}${(0,se.getProperty)(r)} === undefined`;return n?(0,se.or)(o,(0,se.not)(qa(e,t,r))):o}W.noPropertyInData=Ua;function Vf(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}W.allSchemaProperties=Vf;function Lb(e,t){return Vf(t).filter(r=>!(0,Ma.alwaysValidSchema)(e,t[r]))}W.schemaProperties=Lb;function Fb({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,se._)`${e}, ${t}, ${n}${o}`:t,d=[[Pt.default.instancePath,(0,se.strConcat)(Pt.default.instancePath,s)],[Pt.default.parentData,i.parentData],[Pt.default.parentDataProperty,i.parentDataProperty],[Pt.default.rootData,Pt.default.rootData]];i.opts.dynamicRef&&d.push([Pt.default.dynamicAnchors,Pt.default.dynamicAnchors]);let f=(0,se._)`${l}, ${r.object(...d)}`;return c!==se.nil?(0,se._)`${a}.call(${c}, ${f})`:(0,se._)`${a}(${f})`}W.callValidateCode=Fb;var Vb=(0,se._)`new RegExp`;function Hb({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,se._)`${o.code==="new RegExp"?Vb:(0,Mb.useFunc)(e,o)}(${r}, ${n})`})}W.usePattern=Hb;function Bb(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,se._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:Ma.Type.Num},s),t.if((0,se.not)(s),a)})}}W.validateArray=Bb;function Kb(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,Ma.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,se._)`${i} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,se.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}W.validateUnion=Kb});var Kf=P(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});rt.validateKeywordUsage=rt.validSchemaType=rt.funcKeywordCode=rt.macroKeywordCode=void 0;var Re=M(),Jt=mt(),Jb=Fe(),Gb=bn();function Wb(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=Bf(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");e.subschema({schema:a,schemaPath:Re.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}rt.macroKeywordCode=Wb;function Yb(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;Qb(c,t);let u=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,l=Bf(n,o,u),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&&Hf(e),y(()=>e.error());else{let S=t.async?m():h();t.modifying&&Hf(e),y(()=>Xb(e,S))}}function m(){let S=n.let("ruleErrs",null);return n.try(()=>g((0,Re._)`await `),$=>n.assign(d,!1).if((0,Re._)`${$} instanceof ${c.ValidationError}`,()=>n.assign(S,(0,Re._)`${$}.errors`),()=>n.throw($))),S}function h(){let S=(0,Re._)`${l}.errors`;return n.assign(S,null),g(Re.nil),S}function g(S=t.async?(0,Re._)`await `:Re.nil){let $=c.opts.passContext?Jt.default.this:Jt.default.self,b=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,Re._)`${S}${(0,Jb.callValidateCode)(e,l,$,b)}`,t.modifying)}function y(S){var $;n.if((0,Re.not)(($=t.valid)!==null&&$!==void 0?$:d),S)}}rt.funcKeywordCode=Yb;function Hf(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Re._)`${n.parentData}[${n.parentDataProperty}]`))}function Xb(e,t){let{gen:r}=e;r.if((0,Re._)`Array.isArray(${t})`,()=>{r.assign(Jt.default.vErrors,(0,Re._)`${Jt.default.vErrors} === null ? ${t} : ${Jt.default.vErrors}.concat(${t})`).assign(Jt.default.errors,(0,Re._)`${Jt.default.vErrors}.length`),(0,Gb.extendErrors)(e)},()=>e.error())}function Qb({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Bf(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,Re.stringify)(r)})}function e0(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")}rt.validSchemaType=e0;function t0({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)}}rt.validateKeywordUsage=t0});var Gf=P(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.extendSubschemaMode=Tt.extendSubschemaData=Tt.getSubschema=void 0;var nt=M(),Jf=L();function r0(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,nt._)`${e.schemaPath}${(0,nt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,nt._)`${e.schemaPath}${(0,nt.getProperty)(t)}${(0,nt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,Jf.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')}Tt.getSubschema=r0;function n0(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,f=a.let("data",(0,nt._)`${t.data}${(0,nt.getProperty)(r)}`,!0);c(f),e.errorPath=(0,nt.str)`${u}${(0,Jf.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,nt._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(o!==void 0){let u=o instanceof nt.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]}}Tt.extendSubschemaData=n0;function o0(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}Tt.extendSubschemaMode=o0});var Da=P((bC,Wf)=>{"use strict";Wf.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 Xf=P((SC,Yf)=>{"use strict";var Rt=Yf.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(){};Wo(t,n,o,e,"",e)};Rt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Rt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Rt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Rt.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 Wo(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 Rt.arrayKeywords)for(var f=0;f<d.length;f++)Wo(e,t,r,d[f],o+"/"+l+"/"+f,s,o,l,n,f)}else if(l in Rt.propsKeywords){if(d&&typeof d=="object")for(var m in d)Wo(e,t,r,d[m],o+"/"+l+"/"+s0(m),s,o,l,n,m)}else(l in Rt.keywords||e.allKeys&&!(l in Rt.skipKeywords))&&Wo(e,t,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function s0(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var $n=P(Ae=>{"use strict";Object.defineProperty(Ae,"__esModule",{value:!0});Ae.getSchemaRefs=Ae.resolveUrl=Ae.normalizeId=Ae._getFullPath=Ae.getFullPath=Ae.inlineRef=void 0;var i0=L(),a0=Da(),c0=Xf(),u0=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function l0(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Za(e):t?Qf(e)<=t:!1}Ae.inlineRef=l0;var d0=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Za(e){for(let t in e){if(d0.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 Qf(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!u0.has(r)&&(typeof e[r]=="object"&&(0,i0.eachItem)(e[r],n=>t+=Qf(n)),t===1/0))return 1/0}return t}function em(e,t="",r){r!==!1&&(t=Tr(t));let n=e.parse(t);return tm(e,n)}Ae.getFullPath=em;function tm(e,t){return e.serialize(t).split("#")[0]+"#"}Ae._getFullPath=tm;var p0=/#\/?$/;function Tr(e){return e?e.replace(p0,""):""}Ae.normalizeId=Tr;function f0(e,t,r){return r=Tr(r),e.resolve(t,r)}Ae.resolveUrl=f0;var m0=/^[a-z_][-a-z0-9._]*$/i;function h0(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Tr(e[r]||t),s={"":o},i=em(n,o,!1),a={},c=new Set;return c0(e,{allKeys:!0},(d,f,m,h)=>{if(h===void 0)return;let g=i+f,y=s[h];typeof d[r]=="string"&&(y=S.call(this,d[r])),$.call(this,d.$anchor),$.call(this,d.$dynamicAnchor),s[f]=y;function S(b){let T=this.opts.uriResolver.resolve;if(b=Tr(y?T(y,b):b),c.has(b))throw l(b);c.add(b);let v=this.refs[b];return typeof v=="string"&&(v=this.refs[v]),typeof v=="object"?u(d,v.schema,b):b!==Tr(g)&&(b[0]==="#"?(u(d,a[b],b),a[b]=d):this.refs[b]=g),b}function $(b){if(typeof b=="string"){if(!m0.test(b))throw new Error(`invalid anchor "${b}"`);S.call(this,`#${b}`)}}}),a;function u(d,f,m){if(f!==void 0&&!a0(d,f))throw l(m)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Ae.getSchemaRefs=h0});var zn=P(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.getData=Et.KeywordCxt=Et.validateFunctionCode=void 0;var im=Nf(),rm=Sn(),Fa=Ca(),Yo=Sn(),g0=Lf(),kn=Kf(),La=Gf(),E=M(),N=mt(),_0=$n(),ht=L(),xn=bn();function y0(e){if(um(e)&&(lm(e),cm(e))){b0(e);return}am(e,()=>(0,im.topBoolOrEmptySchema)(e))}Et.validateFunctionCode=y0;function am({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,E._)`${N.default.data}, ${N.default.valCxt}`,n.$async,()=>{e.code((0,E._)`"use strict"; ${nm(r,o)}`),w0(e,o),e.code(s)}):e.func(t,(0,E._)`${N.default.data}, ${v0(o)}`,n.$async,()=>e.code(nm(r,o)).code(s))}function v0(e){return(0,E._)`{${N.default.instancePath}="", ${N.default.parentData}, ${N.default.parentDataProperty}, ${N.default.rootData}=${N.default.data}${e.dynamicRef?(0,E._)`, ${N.default.dynamicAnchors}={}`:E.nil}}={}`}function w0(e,t){e.if(N.default.valCxt,()=>{e.var(N.default.instancePath,(0,E._)`${N.default.valCxt}.${N.default.instancePath}`),e.var(N.default.parentData,(0,E._)`${N.default.valCxt}.${N.default.parentData}`),e.var(N.default.parentDataProperty,(0,E._)`${N.default.valCxt}.${N.default.parentDataProperty}`),e.var(N.default.rootData,(0,E._)`${N.default.valCxt}.${N.default.rootData}`),t.dynamicRef&&e.var(N.default.dynamicAnchors,(0,E._)`${N.default.valCxt}.${N.default.dynamicAnchors}`)},()=>{e.var(N.default.instancePath,(0,E._)`""`),e.var(N.default.parentData,(0,E._)`undefined`),e.var(N.default.parentDataProperty,(0,E._)`undefined`),e.var(N.default.rootData,N.default.data),t.dynamicRef&&e.var(N.default.dynamicAnchors,(0,E._)`{}`)})}function b0(e){let{schema:t,opts:r,gen:n}=e;am(e,()=>{r.$comment&&t.$comment&&pm(e),z0(e),n.let(N.default.vErrors,null),n.let(N.default.errors,0),r.unevaluated&&S0(e),dm(e),R0(e)})}function S0(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,E._)`${r}.evaluated`),t.if((0,E._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,E._)`${e.evaluated}.props`,(0,E._)`undefined`)),t.if((0,E._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,E._)`${e.evaluated}.items`,(0,E._)`undefined`))}function nm(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,E._)`/*# sourceURL=${r} */`:E.nil}function $0(e,t){if(um(e)&&(lm(e),cm(e))){x0(e,t);return}(0,im.boolOrEmptySchema)(e,t)}function cm({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 um(e){return typeof e.schema!="boolean"}function x0(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&pm(e),P0(e),T0(e);let s=n.const("_errs",N.default.errors);dm(e,s),n.var(t,(0,E._)`${s} === ${N.default.errors}`)}function lm(e){(0,ht.checkUnknownRules)(e),k0(e)}function dm(e,t){if(e.opts.jtd)return om(e,[],!1,t);let r=(0,rm.getSchemaTypes)(e.schema),n=(0,rm.coerceAndCheckDataType)(e,r);om(e,r,!n,t)}function k0(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,ht.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function z0(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,ht.checkStrictMode)(e,"default is ignored in the schema root")}function P0(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,_0.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function T0(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function pm({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,E._)`${N.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,E.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,E._)`${N.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function R0(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,E._)`${N.default.errors} === 0`,()=>t.return(N.default.data),()=>t.throw((0,E._)`new ${o}(${N.default.vErrors})`)):(t.assign((0,E._)`${n}.errors`,N.default.vErrors),s.unevaluated&&E0(e),t.return((0,E._)`${N.default.errors} === 0`))}function E0({gen:e,evaluated:t,props:r,items:n}){r instanceof E.Name&&e.assign((0,E._)`${t}.props`,r),n instanceof E.Name&&e.assign((0,E._)`${t}.items`,n)}function om(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,ht.schemaHasRulesButRef)(s,l))){o.block(()=>mm(e,"$ref",l.all.$ref.definition));return}c.jtd||I0(e,t),o.block(()=>{for(let f of l.rules)d(f);d(l.post)});function d(f){(0,Fa.shouldUseGroup)(s,f)&&(f.type?(o.if((0,Yo.checkDataType)(f.type,i,c.strictNumbers)),sm(e,f),t.length===1&&t[0]===f.type&&r&&(o.else(),(0,Yo.reportTypeError)(e)),o.endIf()):sm(e,f),a||o.if((0,E._)`${N.default.errors} === ${n||0}`))}}function sm(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,g0.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,Fa.shouldUseRule)(n,s)&&mm(e,s.keyword,s.definition,t.type)})}function I0(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(O0(e,t),e.opts.allowUnionTypes||C0(e,t),A0(e,e.dataTypes))}function O0(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{fm(e.dataTypes,r)||Va(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),j0(e,t)}}function C0(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Va(e,"use allowUnionTypes to allow union type keyword")}function A0(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Fa.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>N0(t,i))&&Va(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function N0(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function fm(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function j0(e,t){let r=[];for(let n of e.dataTypes)fm(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Va(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,ht.checkStrictMode)(e,t,e.opts.strictTypes)}var Xo=class{constructor(t,r,n){if((0,kn.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,ht.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",hm(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,kn.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",N.default.errors))}result(t,r,n){this.failResult((0,E.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,E.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,E._)`${r} !== undefined && (${(0,E.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?xn.reportExtraError:xn.reportError)(this,this.def.error,r)}$dataError(){(0,xn.reportError)(this,this.def.$dataError||xn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,xn.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=E.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=E.nil,r=E.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,E.or)((0,E._)`${o} === undefined`,r)),t!==E.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==E.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,E.or)(i(),a());function i(){if(n.length){if(!(r instanceof E.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,E._)`${(0,Yo.checkDataTypes)(c,r,s.opts.strictNumbers,Yo.DataType.Wrong)}`}return E.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,E._)`!${c}(${r})`}return E.nil}}subschema(t,r){let n=(0,La.getSubschema)(this.it,t);(0,La.extendSubschemaData)(n,this.it,t),(0,La.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return $0(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=ht.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=ht.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,E.Name)),!0}};Et.KeywordCxt=Xo;function mm(e,t,r,n){let o=new Xo(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,kn.funcKeywordCode)(o,r):"macro"in r?(0,kn.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,kn.funcKeywordCode)(o,r)}var M0=/^\/(?:[^~]|~0|~1)*$/,q0=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function hm(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return N.default.rootData;if(e[0]==="/"){if(!M0.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=N.default.rootData}else{let u=q0.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,E._)`${s}${(0,E.getProperty)((0,ht.unescapeJsonPointer)(u))}`,i=(0,E._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}Et.getData=hm});var Qo=P(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});var Ha=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};Ba.default=Ha});var Pn=P(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});var Ka=$n(),Ja=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Ka.resolveUrl)(t,r,n),this.missingSchema=(0,Ka.normalizeId)((0,Ka.getFullPath)(t,this.missingRef))}};Ga.default=Ja});var ts=P(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});Ve.resolveSchema=Ve.getCompilingSchema=Ve.resolveRef=Ve.compileSchema=Ve.SchemaEnv=void 0;var Ye=M(),U0=Qo(),Gt=mt(),Xe=$n(),gm=L(),D0=zn(),Rr=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,Xe.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};Ve.SchemaEnv=Rr;function Ya(e){let t=_m.call(this,e);if(t)return t;let r=(0,Xe.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new Ye.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:U0.default,code:(0,Ye._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:Gt.default.data,parentData:Gt.default.parentData,parentDataProperty:Gt.default.parentDataProperty,dataNames:[Gt.default.data],dataPathArr:[Ye.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,Ye.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:Ye.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Ye._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,D0.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(Gt.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let m=new Function(`${Gt.default.self}`,`${Gt.default.scope}`,l)(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}=u;m.evaluated={props:h instanceof Ye.Name?void 0:h,items:g instanceof Ye.Name?void 0:g,dynamicProps:h instanceof Ye.Name,dynamicItems:g instanceof Ye.Name},m.source&&(m.source.evaluated=(0,Ye.stringify)(m.evaluated))}return e.validate=m,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)}}Ve.compileSchema=Ya;function Z0(e,t,r){var n;r=(0,Xe.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=V0.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 Rr({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=L0.call(this,s)}Ve.resolveRef=Z0;function L0(e){return(0,Xe.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Ya.call(this,e)}function _m(e){for(let t of this._compilations)if(F0(t,e))return t}Ve.getCompilingSchema=_m;function F0(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function V0(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||es.call(this,e,t)}function es(e,t){let r=this.opts.uriResolver.parse(t),n=(0,Xe._getFullPath)(this.opts.uriResolver,r),o=(0,Xe.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return Wa.call(this,r,e);let s=(0,Xe.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=es.call(this,e,i);return typeof a?.schema!="object"?void 0:Wa.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Ya.call(this,i),s===(0,Xe.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,Xe.resolveUrl)(this.opts.uriResolver,o,u)),new Rr({schema:a,schemaId:c,root:e,baseId:o})}return Wa.call(this,r,i)}}Ve.resolveSchema=es;var H0=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Wa(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,gm.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!H0.has(a)&&u&&(t=(0,Xe.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,gm.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Xe.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=es.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Rr({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var ym=P((TC,B0)=>{B0.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 ec=P((RC,xm)=>{"use strict";var K0=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),wm=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),Xa=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),bm=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),J0=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Qa(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 G0=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function vm(e){return e.length=0,!0}function W0(e,t,r){if(e.length){let n=Qa(e);if(n!=="")t.push(n);else return r.error=!0,!1;e.length=0}return!0}function Y0(e){let t=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=W0;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=vm}else{o.push(u);continue}}return o.length&&(a===vm?r.zone=o.join(""):i?n.push(o.join("")):n.push(Qa(o))),r.address=n.join(""),r}function Sm(e){if(X0(e,":")<2)return{host:e,isIPV6:!1};let t=Y0(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 X0(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function Q0(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 eS={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},tS=/[@/?#:]/g,rS=/[@/?#]/g;function $m(e,t){let r=t?rS:tS;return r.lastIndex=0,e.replace(r,n=>eS[n])}function nS(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(Xa(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&bm(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function oS(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(Xa(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));s!=="."&&bm(s)?t+=s:t+="%"+o,r+=2;continue}}J0(e[r])?t+=e[r]:t+=escape(e[r])}return t}function sS(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(Xa(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function iS(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push("@")),e.host!==void 0){let r=unescape(e.host);if(!wm(r)){let n=Sm(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}xm.exports={nonSimpleDomain:G0,recomposeAuthority:iS,reescapeHostDelimiters:$m,normalizePercentEncoding:nS,normalizePathEncoding:oS,escapePreservingEscapes:sS,removeDotSegments:Q0,isIPv4:wm,isUUID:K0,normalizeIPv6:Sm,stringArrayToHexStripped:Qa}});var Rm=P((EC,Tm)=>{"use strict";var{isUUID:aS}=ec(),cS=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,uS=["http","https","ws","wss","urn","urn:uuid"];function lS(e){return uS.indexOf(e)!==-1}function tc(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 km(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function zm(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 dS(e){return e.secure=tc(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function pS(e){if((e.port===(tc(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 fS(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(cS);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=rc(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function mS(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=rc(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 hS(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!aS(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function gS(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Pm={scheme:"http",domainHost:!0,parse:km,serialize:zm},_S={scheme:"https",domainHost:Pm.domainHost,parse:km,serialize:zm},rs={scheme:"ws",domainHost:!0,parse:dS,serialize:pS},yS={scheme:"wss",domainHost:rs.domainHost,parse:rs.parse,serialize:rs.serialize},vS={scheme:"urn",parse:fS,serialize:mS,skipNormalize:!0},wS={scheme:"urn:uuid",parse:hS,serialize:gS,skipNormalize:!0},ns={http:Pm,https:_S,ws:rs,wss:yS,urn:vS,"urn:uuid":wS};Object.setPrototypeOf(ns,null);function rc(e){return e&&(ns[e]||ns[e.toLowerCase()])||void 0}Tm.exports={wsIsSecure:tc,SCHEMES:ns,isValidSchemeName:lS,getSchemeHandler:rc}});var Nm=P((IC,os)=>{"use strict";var{normalizeIPv6:bS,removeDotSegments:Tn,recomposeAuthority:SS,normalizePercentEncoding:$S,normalizePathEncoding:xS,escapePreservingEscapes:kS,reescapeHostDelimiters:zS,isIPv4:PS,nonSimpleDomain:TS}=ec(),{SCHEMES:RS,getSchemeHandler:Im}=Rm();function ES(e,t){return typeof e=="string"?e=jS(e,t):typeof e=="object"&&(e=Er(Wt(e,t),t)),e}function IS(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=Om(Er(e,n),Er(t,n),n,!0);return n.skipEscape=!0,Wt(o,n)}function Om(e,t,r,n){let o={};return n||(e=Er(Wt(e,r),r),t=Er(Wt(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=Tn(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=Tn(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=Tn(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=Tn(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 OS(e,t,r){let n=Em(e,r),o=Em(t,r);return n!==void 0&&o!==void 0&&n.toLowerCase()===o.toLowerCase()}function Wt(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=Im(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=$S(r.path):(r.path=kS(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=SS(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=Tn(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 CS=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,AS=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/;function NS(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 Cm(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(AS);i!==null&&i[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let a=e.match(CS);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=NS(n,a);if(c!==void 0&&(n.error=n.error||c,o=!0),n.host)if(PS(n.host)===!1){let d=bS(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=Im(r.scheme||n.scheme);if(!r.unicodeSupport&&(!u||!u.unicodeSupport)&&n.host&&(r.domainHost||u&&u.domainHost)&&s===!1&&TS(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=zS(unescape(n.host),s))),n.path&&(n.path=xS(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 Er(e,t){return Cm(e,t).parsed}function jS(e,t){return Am(e,t).normalized}function Am(e,t){let{parsed:r,malformedAuthorityOrPort:n}=Cm(e,t);return{normalized:n?e:Wt(r,t),malformedAuthorityOrPort:n}}function Em(e,t){if(typeof e=="string"){let{normalized:r,malformedAuthorityOrPort:n}=Am(e,t);return n?void 0:r}if(typeof e=="object")return Wt(e,t)}var nc={SCHEMES:RS,normalize:ES,resolve:IS,resolveComponent:Om,equal:OS,serialize:Wt,parse:Er};os.exports=nc;os.exports.default=nc;os.exports.fastUri=nc});var Mm=P(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});var jm=Nm();jm.code='require("ajv/dist/runtime/uri").default';oc.default=jm});var Hm=P(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.CodeGen=ve.Name=ve.nil=ve.stringify=ve.str=ve._=ve.KeywordCxt=void 0;var MS=zn();Object.defineProperty(ve,"KeywordCxt",{enumerable:!0,get:function(){return MS.KeywordCxt}});var Ir=M();Object.defineProperty(ve,"_",{enumerable:!0,get:function(){return Ir._}});Object.defineProperty(ve,"str",{enumerable:!0,get:function(){return Ir.str}});Object.defineProperty(ve,"stringify",{enumerable:!0,get:function(){return Ir.stringify}});Object.defineProperty(ve,"nil",{enumerable:!0,get:function(){return Ir.nil}});Object.defineProperty(ve,"Name",{enumerable:!0,get:function(){return Ir.Name}});Object.defineProperty(ve,"CodeGen",{enumerable:!0,get:function(){return Ir.CodeGen}});var qS=Qo(),Lm=Pn(),US=Oa(),Rn=ts(),DS=M(),En=$n(),ss=Sn(),ic=L(),qm=ym(),ZS=Mm(),Fm=(e,t)=>new RegExp(e,t);Fm.code="new RegExp";var LS=["removeAdditional","useDefaults","coerceTypes"],FS=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),VS={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."},HS={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Um=200;function BS(e){var t,r,n,o,s,i,a,c,u,l,d,f,m,h,g,y,S,$,b,T,v,x,O,J,ae;let he=e.strict,vt=(t=e.code)===null||t===void 0?void 0:t.optimize,co=vt===!0||vt===void 0?1:vt||0,uo=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Fm,wt=(o=e.uriResolver)!==null&&o!==void 0?o:ZS.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:he)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:he)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:he)!==null&&l!==void 0?l:"log",strictTuples:(f=(d=e.strictTuples)!==null&&d!==void 0?d:he)!==null&&f!==void 0?f:"log",strictRequired:(h=(m=e.strictRequired)!==null&&m!==void 0?m:he)!==null&&h!==void 0?h:!1,code:e.code?{...e.code,optimize:co,regExp:uo}:{optimize:co,regExp:uo},loopRequired:(g=e.loopRequired)!==null&&g!==void 0?g:Um,loopEnum:(y=e.loopEnum)!==null&&y!==void 0?y:Um,meta:(S=e.meta)!==null&&S!==void 0?S:!0,messages:($=e.messages)!==null&&$!==void 0?$:!0,inlineRefs:(b=e.inlineRefs)!==null&&b!==void 0?b:!0,schemaId:(T=e.schemaId)!==null&&T!==void 0?T:"$id",addUsedSchema:(v=e.addUsedSchema)!==null&&v!==void 0?v:!0,validateSchema:(x=e.validateSchema)!==null&&x!==void 0?x:!0,validateFormats:(O=e.validateFormats)!==null&&O!==void 0?O:!0,unicodeRegExp:(J=e.unicodeRegExp)!==null&&J!==void 0?J:!0,int32range:(ae=e.int32range)!==null&&ae!==void 0?ae:!0,uriResolver:wt}}var In=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,...BS(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new DS.ValueScope({scope:{},prefixes:FS,es5:r,lines:n}),this.logger=XS(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,US.getRules)(),Dm.call(this,VS,t,"NOT SUPPORTED"),Dm.call(this,HS,t,"DEPRECATED","warn"),this._metaOpts=WS.call(this),t.formats&&JS.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&GS.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),KS.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=qm;n==="id"&&(o={...qm},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 f=this._addSchema(l,d);return f.validate||i.call(this,f)}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 Lm.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,En.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=Zm.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new Rn.SchemaEnv({schema:{},schemaId:n});if(r=Rn.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=Zm.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,En.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(e$.call(this,n,r),!r)return(0,ic.eachItem)(n,s=>sc.call(this,s)),this;r$.call(this,r);let o={...r,type:(0,ss.getJSONTypes)(r.type),schemaType:(0,ss.getJSONTypes)(r.schemaType)};return(0,ic.eachItem)(n,o.type.length===0?s=>sc.call(this,s,o):s=>o.type.forEach(i=>sc.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]=Vm(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,En.normalizeId)(i||n);let u=En.getSchemaRefs.call(this,t,n);return c=new Rn.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):Rn.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{Rn.compileSchema.call(this,t)}finally{this.opts=r}}};In.ValidationError=qS.default;In.MissingRefError=Lm.default;ve.default=In;function Dm(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 Zm(e){return e=(0,En.normalizeId)(e),this.schemas[e]||this.refs[e]}function KS(){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 JS(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function GS(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 WS(){let e={...this.opts};for(let t of LS)delete e[t];return e}var YS={log(){},warn(){},error(){}};function XS(e){if(e===!1)return YS;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 QS=/^[a-z_$][a-z0-9_$:-]*$/i;function e$(e,t){let{RULES:r}=this;if((0,ic.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!QS.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 sc(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,ss.getJSONTypes)(t.type),schemaType:(0,ss.getJSONTypes)(t.schemaType)}};t.before?t$.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 t$(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 r$(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=Vm(t)),e.validateSchema=this.compile(t,!0))}var n$={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Vm(e){return{anyOf:[e,n$]}}});var Bm=P(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});var o$={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};ac.default=o$});var Wm=P(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.callRef=Yt.getValidate=void 0;var s$=Pn(),Km=Fe(),Ne=M(),Or=mt(),Jm=ts(),is=L(),i$={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=Jm.resolveRef.call(c,u,o,r);if(l===void 0)throw new s$.default(n.opts.uriResolver,o,r);if(l instanceof Jm.SchemaEnv)return f(l);return m(l);function d(){if(s===u)return as(e,i,s,s.$async);let h=t.scopeValue("root",{ref:u});return as(e,(0,Ne._)`${h}.validate`,u,u.$async)}function f(h){let g=Gm(e,h);as(e,g,h,h.$async)}function m(h){let g=t.scopeValue("schema",a.code.source===!0?{ref:h,code:(0,Ne.stringify)(h)}:{ref:h}),y=t.name("valid"),S=e.subschema({schema:h,dataTypes:[],schemaPath:Ne.nil,topSchemaRef:g,errSchemaPath:r},y);e.mergeEvaluated(S),e.ok(y)}}};function Gm(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Ne._)`${r.scopeValue("wrapper",{ref:t})}.validate`}Yt.getValidate=Gm;function as(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Or.default.this:Ne.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,Ne._)`await ${(0,Km.callValidateCode)(e,t,u)}`),m(t),i||o.assign(h,!0)},g=>{o.if((0,Ne._)`!(${g} instanceof ${s.ValidationError})`,()=>o.throw(g)),f(g),i||o.assign(h,!1)}),e.ok(h)}function d(){e.result((0,Km.callValidateCode)(e,t,u),()=>m(t),()=>f(t))}function f(h){let g=(0,Ne._)`${h}.errors`;o.assign(Or.default.vErrors,(0,Ne._)`${Or.default.vErrors} === null ? ${g} : ${Or.default.vErrors}.concat(${g})`),o.assign(Or.default.errors,(0,Ne._)`${Or.default.vErrors}.length`)}function m(h){var g;if(!s.opts.unevaluated)return;let y=(g=r?.validate)===null||g===void 0?void 0:g.evaluated;if(s.props!==!0)if(y&&!y.dynamicProps)y.props!==void 0&&(s.props=is.mergeEvaluated.props(o,y.props,s.props));else{let S=o.var("props",(0,Ne._)`${h}.evaluated.props`);s.props=is.mergeEvaluated.props(o,S,s.props,Ne.Name)}if(s.items!==!0)if(y&&!y.dynamicItems)y.items!==void 0&&(s.items=is.mergeEvaluated.items(o,y.items,s.items));else{let S=o.var("items",(0,Ne._)`${h}.evaluated.items`);s.items=is.mergeEvaluated.items(o,S,s.items,Ne.Name)}}}Yt.callRef=as;Yt.default=i$});var Ym=P(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});var a$=Bm(),c$=Wm(),u$=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",a$.default,c$.default];cc.default=u$});var Xm=P(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});var cs=M(),It=cs.operators,us={maximum:{okStr:"<=",ok:It.LTE,fail:It.GT},minimum:{okStr:">=",ok:It.GTE,fail:It.LT},exclusiveMaximum:{okStr:"<",ok:It.LT,fail:It.GTE},exclusiveMinimum:{okStr:">",ok:It.GT,fail:It.LTE}},l$={message:({keyword:e,schemaCode:t})=>(0,cs.str)`must be ${us[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,cs._)`{comparison: ${us[e].okStr}, limit: ${t}}`},d$={keyword:Object.keys(us),type:"number",schemaType:"number",$data:!0,error:l$,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,cs._)`${r} ${us[t].fail} ${n} || isNaN(${r})`)}};uc.default=d$});var Qm=P(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});var On=M(),p$={message:({schemaCode:e})=>(0,On.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,On._)`{multipleOf: ${e}}`},f$={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:p$,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,On._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,On._)`${i} !== parseInt(${i})`;e.fail$data((0,On._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};lc.default=f$});var th=P(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});function eh(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}dc.default=eh;eh.code='require("ajv/dist/runtime/ucs2length").default'});var rh=P(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});var Xt=M(),m$=L(),h$=th(),g$={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}}`},_$={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:g$,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,m$.useFunc)(e.gen,h$.default)}(${r})`;e.fail$data((0,Xt._)`${i} ${s} ${n}`)}};pc.default=_$});var nh=P(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});var y$=Fe(),v$=L(),Cr=M(),w$={message:({schemaCode:e})=>(0,Cr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Cr._)`{pattern: ${e}}`},b$={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:w$,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,Cr._)`new RegExp`:(0,v$.useFunc)(t,c),l=t.let("valid");t.try(()=>t.assign(l,(0,Cr._)`${u}(${s}, ${a}).test(${r})`),()=>t.assign(l,!1)),e.fail$data((0,Cr._)`!${l}`)}else{let c=(0,y$.usePattern)(e,o);e.fail$data((0,Cr._)`!${c}.test(${r})`)}}};fc.default=b$});var oh=P(mc=>{"use strict";Object.defineProperty(mc,"__esModule",{value:!0});var Cn=M(),S$={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,Cn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,Cn._)`{limit: ${e}}`},$$={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:S$,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?Cn.operators.GT:Cn.operators.LT;e.fail$data((0,Cn._)`Object.keys(${r}).length ${o} ${n}`)}};mc.default=$$});var sh=P(hc=>{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});var An=Fe(),Nn=M(),x$=L(),k$={message:({params:{missingProperty:e}})=>(0,Nn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,Nn._)`{missingProperty: ${e}}`},z$={keyword:"required",type:"object",schemaType:"array",$data:!0,error:k$,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 m=e.parentSchema.properties,{definedProperties:h}=e.it;for(let g of r)if(m?.[g]===void 0&&!h.has(g)){let y=i.schemaEnv.baseId+i.errSchemaPath,S=`required property "${g}" is not defined at "${y}" (strictRequired)`;(0,x$.checkStrictMode)(i,S,i.opts.strictRequired)}}function u(){if(c||s)e.block$data(Nn.nil,d);else for(let m of r)(0,An.checkReportMissingProp)(e,m)}function l(){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,An.checkMissingProp)(e,r,m)),(0,An.reportMissingProp)(e,m),t.else()}function d(){t.forOf("prop",n,m=>{e.setParams({missingProperty:m}),t.if((0,An.noPropertyInData)(t,o,m,a.ownProperties),()=>e.error())})}function f(m,h){e.setParams({missingProperty:m}),t.forOf(m,n,()=>{t.assign(h,(0,An.propertyInData)(t,o,m,a.ownProperties)),t.if((0,Nn.not)(h),()=>{e.error(),t.break()})},Nn.nil)}}};hc.default=z$});var ih=P(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});var jn=M(),P$={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,jn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,jn._)`{limit: ${e}}`},T$={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:P$,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?jn.operators.GT:jn.operators.LT;e.fail$data((0,jn._)`${r}.length ${o} ${n}`)}};gc.default=T$});var ls=P(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});var ah=Da();ah.code='require("ajv/dist/runtime/equal").default';_c.default=ah});var ch=P(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});var yc=Sn(),we=M(),R$=L(),E$=ls(),I$={message:({params:{i:e,j:t}})=>(0,we.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,we._)`{i: ${e}, j: ${t}}`},O$={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:I$,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,yc.getSchemaTypes)(s.items):[];e.block$data(c,l,(0,we._)`${i} === false`),e.ok(c);function l(){let h=t.let("i",(0,we._)`${r}.length`),g=t.let("j");e.setParams({i:h,j:g}),t.assign(c,!0),t.if((0,we._)`${h} > 1`,()=>(d()?f:m)(h,g))}function d(){return u.length>0&&!u.some(h=>h==="object"||h==="array")}function f(h,g){let y=t.name("item"),S=(0,yc.checkDataTypes)(u,y,a.opts.strictNumbers,yc.DataType.Wrong),$=t.const("indices",(0,we._)`{}`);t.for((0,we._)`;${h}--;`,()=>{t.let(y,(0,we._)`${r}[${h}]`),t.if(S,(0,we._)`continue`),u.length>1&&t.if((0,we._)`typeof ${y} == "string"`,(0,we._)`${y} += "_"`),t.if((0,we._)`typeof ${$}[${y}] == "number"`,()=>{t.assign(g,(0,we._)`${$}[${y}]`),e.error(),t.assign(c,!1).break()}).code((0,we._)`${$}[${y}] = ${h}`)})}function m(h,g){let y=(0,R$.useFunc)(t,E$.default),S=t.name("outer");t.label(S).for((0,we._)`;${h}--;`,()=>t.for((0,we._)`${g} = ${h}; ${g}--;`,()=>t.if((0,we._)`${y}(${r}[${h}], ${r}[${g}])`,()=>{e.error(),t.assign(c,!1).break(S)})))}}};vc.default=O$});var uh=P(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});var wc=M(),C$=L(),A$=ls(),N$={message:"must be equal to constant",params:({schemaCode:e})=>(0,wc._)`{allowedValue: ${e}}`},j$={keyword:"const",$data:!0,error:N$,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,wc._)`!${(0,C$.useFunc)(t,A$.default)}(${r}, ${o})`):e.fail((0,wc._)`${s} !== ${r}`)}};bc.default=j$});var lh=P(Sc=>{"use strict";Object.defineProperty(Sc,"__esModule",{value:!0});var Mn=M(),M$=L(),q$=ls(),U$={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Mn._)`{allowedValues: ${e}}`},D$={keyword:"enum",schemaType:"array",$data:!0,error:U$,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,M$.useFunc)(t,q$.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 m=t.const("vSchema",s);l=(0,Mn.or)(...o.map((h,g)=>f(m,g)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",s,m=>t.if((0,Mn._)`${u()}(${r}, ${m})`,()=>t.assign(l,!0).break()))}function f(m,h){let g=o[h];return typeof g=="object"&&g!==null?(0,Mn._)`${u()}(${r}, ${m}[${h}])`:(0,Mn._)`${r} === ${g}`}}};Sc.default=D$});var dh=P($c=>{"use strict";Object.defineProperty($c,"__esModule",{value:!0});var Z$=Xm(),L$=Qm(),F$=rh(),V$=nh(),H$=oh(),B$=sh(),K$=ih(),J$=ch(),G$=uh(),W$=lh(),Y$=[Z$.default,L$.default,F$.default,V$.default,H$.default,B$.default,K$.default,J$.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},G$.default,W$.default];$c.default=Y$});var kc=P(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.validateAdditionalItems=void 0;var Qt=M(),xc=L(),X$={message:({params:{len:e}})=>(0,Qt.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Qt._)`{limit: ${e}}`},Q$={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:X$,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,xc.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}ph(e,n)}};function ph(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,Qt._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,Qt._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,xc.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,Qt._)`${a} <= ${t.length}`);r.if((0,Qt.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,a,l=>{e.subschema({keyword:s,dataProp:l,dataPropType:xc.Type.Num},u),i.allErrors||r.if((0,Qt.not)(u),()=>r.break())})}}qn.validateAdditionalItems=ph;qn.default=Q$});var zc=P(Un=>{"use strict";Object.defineProperty(Un,"__esModule",{value:!0});Un.validateTuple=void 0;var fh=M(),ds=L(),ex=Fe(),tx={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return mh(e,"additionalItems",t);r.items=!0,!(0,ds.alwaysValidSchema)(r,t)&&e.ok((0,ex.validateArray)(e))}};function mh(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=ds.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,fh._)`${s}.length`);r.forEach((d,f)=>{(0,ds.alwaysValidSchema)(a,d)||(n.if((0,fh._)`${u} > ${f}`,()=>e.subschema({keyword:i,schemaProp:f,dataProp:f},c)),e.ok(c))});function l(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 y=`"${i}" is ${h}-tuple, but minItems or maxItems/${t} are not specified or different at path "${m}"`;(0,ds.checkStrictMode)(a,y,f.strictTuples)}}}Un.validateTuple=mh;Un.default=tx});var hh=P(Pc=>{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});var rx=zc(),nx={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,rx.validateTuple)(e,"items")};Pc.default=nx});var _h=P(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});var gh=M(),ox=L(),sx=Fe(),ix=kc(),ax={message:({params:{len:e}})=>(0,gh.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,gh._)`{limit: ${e}}`},cx={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:ax,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,ox.alwaysValidSchema)(n,t)&&(o?(0,ix.validateAdditionalItems)(e,o):e.ok((0,sx.validateArray)(e)))}};Tc.default=cx});var yh=P(Rc=>{"use strict";Object.defineProperty(Rc,"__esModule",{value:!0});var He=M(),ps=L(),ux={message:({params:{min:e,max:t}})=>t===void 0?(0,He.str)`must contain at least ${e} valid item(s)`:(0,He.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,He._)`{minContains: ${e}}`:(0,He._)`{minContains: ${e}, maxContains: ${t}}`},lx={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:ux,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,He._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,ps.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,ps.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,ps.alwaysValidSchema)(s,r)){let g=(0,He._)`${l} >= ${i}`;a!==void 0&&(g=(0,He._)`${g} && ${l} <= ${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,He._)`${o}.length > 0`,f)):(t.let(d,!1),f()),e.result(d,()=>e.reset());function f(){let g=t.name("_valid"),y=t.let("count",0);m(g,()=>t.if(g,()=>h(y)))}function m(g,y){t.forRange("i",0,l,S=>{e.subschema({keyword:"contains",dataProp:S,dataPropType:ps.Type.Num,compositeRule:!0},g),y()})}function h(g){t.code((0,He._)`${g}++`),a===void 0?t.if((0,He._)`${g} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,He._)`${g} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,He._)`${g} >= ${i}`,()=>t.assign(d,!0)))}}};Rc.default=lx});var bh=P(ot=>{"use strict";Object.defineProperty(ot,"__esModule",{value:!0});ot.validateSchemaDeps=ot.validatePropertyDeps=ot.error=void 0;var Ec=M(),dx=L(),Dn=Fe();ot.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,Ec.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,Ec._)`{property: ${e},
|
|
8
8
|
missingProperty: ${n},
|
|
9
9
|
depsCount: ${t},
|
|
10
|
-
deps: ${r}}`};var qx={keyword:"dependencies",type:"object",schemaType:"object",error:_t.error,code(e){let[t,r]=Lx(e);Mh(e,t),Uh(e,r)}};function Lx({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,ro.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,ro.checkReportMissingProp)(e,l)}):(r.if((0,Bc._)`${c} && (${(0,ro.checkMissingProp)(e,a,s)})`),(0,ro.reportMissingProp)(e,s),r.else())}}_t.validatePropertyDeps=Mh;function Uh(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,i=r.name("valid");for(let a in t)(0,Zx.alwaysValidSchema)(s,t[a])||(r.if((0,ro.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))}_t.validateSchemaDeps=Uh;_t.default=qx});var qh=R(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});var Zh=L(),Fx=W(),Vx={message:"property name must be valid",params:({params:e})=>(0,Zh._)`{propertyName: ${e.propertyName}}`},Hx={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Vx,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,Fx.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,Zh.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};Kc.default=Hx});var Gc=R(Jc=>{"use strict";Object.defineProperty(Jc,"__esModule",{value:!0});var Ps=tt(),dt=L(),Bx=Tt(),Ts=W(),Kx={message:"must NOT have additional properties",params:({params:e})=>(0,dt._)`{additionalProperty: ${e.additionalProperty}}`},Jx={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:Kx,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,Ts.alwaysValidSchema)(i,r))return;let l=(0,Ps.allSchemaProperties)(n.properties),u=(0,Ps.allSchemaProperties)(n.patternProperties);d(),e.ok((0,dt._)`${s} === ${Bx.default.errors}`);function d(){t.forIn("key",o,y=>{!l.length&&!u.length?h(y):t.if(f(y),()=>h(y))})}function f(y){let S;if(l.length>8){let $=(0,Ts.schemaRefOrVal)(i,n.properties,"properties");S=(0,Ps.isOwnProperty)(t,$,y)}else l.length?S=(0,dt.or)(...l.map($=>(0,dt._)`${y} === ${$}`)):S=dt.nil;return u.length&&(S=(0,dt.or)(S,...u.map($=>(0,dt._)`${(0,Ps.usePattern)(e,$)}.test(${y})`))),(0,dt.not)(S)}function m(y){t.code((0,dt._)`delete ${o}[${y}]`)}function h(y){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){m(y);return}if(r===!1){e.setParams({additionalProperty:y}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,Ts.alwaysValidSchema)(i,r)){let S=t.name("valid");c.removeAdditional==="failing"?(g(y,S,!1),t.if((0,dt.not)(S),()=>{e.reset(),m(y)})):(g(y,S),a||t.if((0,dt.not)(S),()=>t.break()))}}function g(y,S,$){let w={keyword:"additionalProperties",dataProp:y,dataPropType:Ts.Type.Str};$===!1&&Object.assign(w,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(w,S)}}};Jc.default=Jx});var Vh=R(Yc=>{"use strict";Object.defineProperty(Yc,"__esModule",{value:!0});var Gx=Ln(),Lh=tt(),Wc=W(),Fh=Gc(),Wx={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&&Fh.default.code(new Gx.KeywordCxt(s,Fh.default,"additionalProperties"));let i=(0,Lh.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Wc.mergeEvaluated.props(t,(0,Wc.toHash)(i),s.props));let a=i.filter(d=>!(0,Wc.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,Lh.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)}}};Yc.default=Wx});var Jh=R(Qc=>{"use strict";Object.defineProperty(Qc,"__esModule",{value:!0});var Hh=tt(),Rs=L(),Bh=W(),Kh=W(),Yx={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,Hh.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 l=i.strictSchema&&!i.allowMatchingProperties&&o.properties,u=t.name("valid");s.props!==!0&&!(s.props instanceof Rs.Name)&&(s.props=(0,Kh.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 y in l)new RegExp(g).test(y)&&(0,Bh.checkStrictMode)(s,`property ${y} matches pattern ${g} (use allowMatchingProperties)`)}function h(g){t.forIn("key",n,y=>{t.if((0,Rs._)`${(0,Hh.usePattern)(e,g)}.test(${y})`,()=>{let S=c.includes(g);S||e.subschema({keyword:"patternProperties",schemaProp:g,dataProp:y,dataPropType:Kh.Type.Str},u),s.opts.unevaluated&&d!==!0?t.assign((0,Rs._)`${d}[${y}]`,!0):!S&&!s.allErrors&&t.if((0,Rs.not)(u),()=>t.break())})})}}};Qc.default=Yx});var Gh=R(Xc=>{"use strict";Object.defineProperty(Xc,"__esModule",{value:!0});var Qx=W(),Xx={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,Qx.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"}};Xc.default=Xx});var Wh=R(eu=>{"use strict";Object.defineProperty(eu,"__esModule",{value:!0});var ek=tt(),tk={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:ek.validateUnion,error:{message:"must match a schema in anyOf"}};eu.default=tk});var Yh=R(tu=>{"use strict";Object.defineProperty(tu,"__esModule",{value:!0});var Es=L(),rk=W(),nk={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,Es._)`{passingSchemas: ${e.passing}}`},ok={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:nk,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,rk.alwaysValidSchema)(o,u)?t.var(c,!0):f=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,Es._)`${c} && ${i}`).assign(i,!1).assign(a,(0,Es._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),f&&e.mergeEvaluated(f,Es.Name)})})}}};tu.default=ok});var Qh=R(ru=>{"use strict";Object.defineProperty(ru,"__esModule",{value:!0});var sk=W(),ik={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,sk.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};ru.default=ik});var tg=R(nu=>{"use strict";Object.defineProperty(nu,"__esModule",{value:!0});var Is=L(),eg=W(),ak={message:({params:e})=>(0,Is.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,Is._)`{failingKeyword: ${e.ifClause}}`},ck={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:ak,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,eg.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=Xh(n,"then"),s=Xh(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,Is.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,Is._)`${u}`):e.setParams({ifClause:u})}}}};function Xh(e,t){let r=e.schema[t];return r!==void 0&&!(0,eg.alwaysValidSchema)(e,r)}nu.default=ck});var rg=R(ou=>{"use strict";Object.defineProperty(ou,"__esModule",{value:!0});var uk=W(),lk={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,uk.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};ou.default=lk});var ng=R(su=>{"use strict";Object.defineProperty(su,"__esModule",{value:!0});var dk=qc(),pk=Ah(),fk=Lc(),mk=Nh(),hk=jh(),gk=Dh(),_k=qh(),yk=Gc(),vk=Vh(),bk=Jh(),wk=Gh(),$k=Wh(),Sk=Yh(),xk=Qh(),kk=tg(),zk=rg();function Pk(e=!1){let t=[wk.default,$k.default,Sk.default,xk.default,kk.default,zk.default,_k.default,yk.default,gk.default,vk.default,bk.default];return e?t.push(pk.default,mk.default):t.push(dk.default,fk.default),t.push(hk.default),t}su.default=Pk});var og=R(iu=>{"use strict";Object.defineProperty(iu,"__esModule",{value:!0});var ve=L(),Tk={message:({schemaCode:e})=>(0,ve.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,ve._)`{format: ${e}}`},Rk={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:Tk,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,ve._)`${h}[${i}]`),y=r.let("fType"),S=r.let("format");r.if((0,ve._)`typeof ${g} == "object" && !(${g} instanceof RegExp)`,()=>r.assign(y,(0,ve._)`${g}.type || "string"`).assign(S,(0,ve._)`${g}.validate`),()=>r.assign(y,(0,ve._)`"string"`).assign(S,g)),e.fail$data((0,ve.or)($(),w()));function $(){return c.strictSchema===!1?ve.nil:(0,ve._)`${i} && !${S}`}function w(){let T=u.$async?(0,ve._)`(${g}.async ? await ${S}(${n}) : ${S}(${n}))`:(0,ve._)`${S}(${n})`,v=(0,ve._)`(typeof ${S} == "function" ? ${T} : ${S}.test(${n}))`;return(0,ve._)`${S} && ${S} !== true && ${y} === ${t} && !${v}`}}function m(){let h=d.formats[s];if(!h){$();return}if(h===!0)return;let[g,y,S]=w(h);g===t&&e.pass(T());function $(){if(c.strictSchema===!1){d.logger.warn(v());return}throw new Error(v());function v(){return`unknown format "${s}" ignored in schema at path "${l}"`}}function w(v){let x=v instanceof RegExp?(0,ve.regexpCode)(v):c.code.formats?(0,ve._)`${c.code.formats}${(0,ve.getProperty)(s)}`:void 0,A=r.scopeValue("formats",{key:s,ref:v,code:x});return typeof v=="object"&&!(v instanceof RegExp)?[v.type||"string",v.validate,(0,ve._)`${A}.validate`]:["string",v,A]}function T(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!u.$async)throw new Error("async format in sync schema");return(0,ve._)`await ${S}(${n})`}return typeof y=="function"?(0,ve._)`${S}(${n})`:(0,ve._)`${S}.test(${n})`}}}};iu.default=Rk});var sg=R(au=>{"use strict";Object.defineProperty(au,"__esModule",{value:!0});var Ek=og(),Ik=[Ek.default];au.default=Ik});var ig=R(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.contentVocabulary=Kr.metadataVocabulary=void 0;Kr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Kr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var cg=R(cu=>{"use strict";Object.defineProperty(cu,"__esModule",{value:!0});var Ok=hh(),Ak=Rh(),Ck=ng(),Nk=sg(),ag=ig(),jk=[Ok.default,Ak.default,(0,Ck.default)(),Nk.default,ag.metadataVocabulary,ag.contentVocabulary];cu.default=jk});var lg=R(Os=>{"use strict";Object.defineProperty(Os,"__esModule",{value:!0});Os.DiscrError=void 0;var ug;(function(e){e.Tag="tag",e.Mapping="mapping"})(ug||(Os.DiscrError=ug={}))});var pg=R(lu=>{"use strict";Object.defineProperty(lu,"__esModule",{value:!0});var Jr=L(),uu=lg(),dg=hs(),Mk=Fn(),Uk=W(),Dk={message:({params:{discrError:e,tagName:t}})=>e===uu.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Jr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},Zk={keyword:"discriminator",type:"object",schemaType:"object",error:Dk,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,Jr._)`${r}${(0,Jr.getProperty)(a)}`);t.if((0,Jr._)`typeof ${l} == "string"`,()=>u(),()=>e.error(!1,{discrError:uu.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,Jr._)`${l} === ${h}`),t.assign(c,d(m[h]));t.else(),e.error(!1,{discrError:uu.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,Jr.Name),h}function f(){var m;let h={},g=S(o),y=!0;for(let T=0;T<i.length;T++){let v=i[T];if(v?.$ref&&!(0,Uk.schemaHasRulesButRef)(v,s.self.RULES)){let A=v.$ref;if(v=dg.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,A),v instanceof dg.SchemaEnv&&(v=v.schema),v===void 0)throw new Mk.default(s.opts.uriResolver,s.baseId,A)}let x=(m=v?.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}"`);y=y&&(g||S(v)),$(x,T)}if(!y)throw new Error(`discriminator: "${a}" must be required`);return h;function S({required:T}){return Array.isArray(T)&&T.includes(a)}function $(T,v){if(T.const)w(T.const,v);else if(T.enum)for(let x of T.enum)w(x,v);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function w(T,v){if(typeof T!="string"||T in h)throw new Error(`discriminator: "${a}" values must be unique strings`);h[T]=v}}}};lu.default=Zk});var fg=R((t1,qk)=>{qk.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 pu=R((fe,du)=>{"use strict";Object.defineProperty(fe,"__esModule",{value:!0});fe.MissingRefError=fe.ValidationError=fe.CodeGen=fe.Name=fe.nil=fe.stringify=fe.str=fe._=fe.KeywordCxt=fe.Ajv=void 0;var Lk=uh(),Fk=cg(),Vk=pg(),mg=fg(),Hk=["/properties"],As="http://json-schema.org/draft-07/schema",Gr=class extends Lk.default{_addVocabularies(){super._addVocabularies(),Fk.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(Vk.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(mg,Hk):mg;this.addMetaSchema(t,As,!1),this.refs["http://json-schema.org/schema"]=As}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(As)?As:void 0)}};fe.Ajv=Gr;du.exports=fe=Gr;du.exports.Ajv=Gr;Object.defineProperty(fe,"__esModule",{value:!0});fe.default=Gr;var Bk=Ln();Object.defineProperty(fe,"KeywordCxt",{enumerable:!0,get:function(){return Bk.KeywordCxt}});var Wr=L();Object.defineProperty(fe,"_",{enumerable:!0,get:function(){return Wr._}});Object.defineProperty(fe,"str",{enumerable:!0,get:function(){return Wr.str}});Object.defineProperty(fe,"stringify",{enumerable:!0,get:function(){return Wr.stringify}});Object.defineProperty(fe,"nil",{enumerable:!0,get:function(){return Wr.nil}});Object.defineProperty(fe,"Name",{enumerable:!0,get:function(){return Wr.Name}});Object.defineProperty(fe,"CodeGen",{enumerable:!0,get:function(){return Wr.CodeGen}});var Kk=fs();Object.defineProperty(fe,"ValidationError",{enumerable:!0,get:function(){return Kk.default}});var Jk=Fn();Object.defineProperty(fe,"MissingRefError",{enumerable:!0,get:function(){return Jk.default}})});var $g=R(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.formatNames=vt.fastFormats=vt.fullFormats=void 0;function yt(e,t){return{validate:e,compare:t}}vt.fullFormats={date:yt(yg,gu),time:yt(mu(!0),_u),"date-time":yt(hg(!0),bg),"iso-time":yt(mu(),vg),"iso-date-time":yt(hg(),wg),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:ez,"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:az,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:tz,int32:{type:"number",validate:oz},int64:{type:"number",validate:sz},float:{type:"number",validate:_g},double:{type:"number",validate:_g},password:!0,binary:!0};vt.fastFormats={...vt.fullFormats,date:yt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,gu),time:yt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,_u),"date-time":yt(/^\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,bg),"iso-time":yt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,vg),"iso-date-time":yt(/^\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,wg),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};vt.formatNames=Object.keys(vt.fullFormats);function Gk(e){return e%4===0&&(e%100!==0||e%400===0)}var Wk=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Yk=[0,31,28,31,30,31,30,31,31,30,31,30,31];function yg(e){let t=Wk.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&&Gk(r)?29:Yk[n])}function gu(e,t){if(e&&t)return e>t?1:e<t?-1:0}var fu=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function mu(e){return function(r){let n=fu.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 _u(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 vg(e,t){if(!(e&&t))return;let r=fu.exec(e),n=fu.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 hu=/t|\s/i;function hg(e){let t=mu(e);return function(n){let o=n.split(hu);return o.length===2&&yg(o[0])&&t(o[1])}}function bg(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function wg(e,t){if(!(e&&t))return;let[r,n]=e.split(hu),[o,s]=t.split(hu),i=gu(r,o);if(i!==void 0)return i||_u(n,s)}var Qk=/\/|:/,Xk=/^(?:[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 ez(e){return Qk.test(e)&&Xk.test(e)}var gg=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function tz(e){return gg.lastIndex=0,gg.test(e)}var rz=-(2**31),nz=2**31-1;function oz(e){return Number.isInteger(e)&&e<=nz&&e>=rz}function sz(e){return Number.isInteger(e)}function _g(){return!0}var iz=/[^\\]\\Z/;function az(e){if(iz.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var Sg=R(Yr=>{"use strict";Object.defineProperty(Yr,"__esModule",{value:!0});Yr.formatLimitDefinition=void 0;var cz=pu(),pt=L(),Ft=pt.operators,Cs={formatMaximum:{okStr:"<=",ok:Ft.LTE,fail:Ft.GT},formatMinimum:{okStr:">=",ok:Ft.GTE,fail:Ft.LT},formatExclusiveMaximum:{okStr:"<",ok:Ft.LT,fail:Ft.GTE},formatExclusiveMinimum:{okStr:">",ok:Ft.GT,fail:Ft.LTE}},uz={message:({keyword:e,schemaCode:t})=>(0,pt.str)`should be ${Cs[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,pt._)`{comparison: ${Cs[e].okStr}, limit: ${t}}`};Yr.formatLimitDefinition={keyword:Object.keys(Cs),type:"string",schemaType:"string",$data:!0,error:uz,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 cz.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,pt._)`${f}[${c.schemaCode}]`);e.fail$data((0,pt.or)((0,pt._)`typeof ${m} != "object"`,(0,pt._)`${m} instanceof RegExp`,(0,pt._)`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,pt._)`${i.code.formats}${(0,pt.getProperty)(f)}`:void 0});e.fail$data(d(h))}function d(f){return(0,pt._)`${f}.compare(${r}, ${n}) ${Cs[o].fail} 0`}},dependencies:["format"]};var lz=e=>(e.addKeyword(Yr.formatLimitDefinition),e);Yr.default=lz});var Pg=R((no,zg)=>{"use strict";Object.defineProperty(no,"__esModule",{value:!0});var Qr=$g(),dz=Sg(),yu=L(),xg=new yu.Name("fullFormats"),pz=new yu.Name("fastFormats"),vu=(e,t={keywords:!0})=>{if(Array.isArray(t))return kg(e,t,Qr.fullFormats,xg),e;let[r,n]=t.mode==="fast"?[Qr.fastFormats,pz]:[Qr.fullFormats,xg],o=t.formats||Qr.formatNames;return kg(e,o,r,n),t.keywords&&(0,dz.default)(e),e};vu.get=(e,t="full")=>{let n=(t==="fast"?Qr.fastFormats:Qr.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function kg(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,yu._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}zg.exports=no=vu;Object.defineProperty(no,"__esModule",{value:!0});no.default=vu});import{spawn as A_,spawnSync as rn}from"node:child_process";import{connect as LP}from"node:net";import{homedir as C_,userInfo as Zu}from"node:os";import{resolve as N_,join as Ot,dirname as Hu}from"node:path";import{fileURLToPath as FP,pathToFileURL as VP}from"node:url";import{createInterface as Ws}from"node:readline/promises";import*as H from"node:fs";var ii=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 sy=Symbol("zod_brand"),St=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},ko={};function Be(e){return e&&Object.assign(ko,e),ko}var ee={};si(ee,{BIGINT_FORMAT_RANGES:()=>Xu,Class:()=>ci,NUMBER_FORMAT_RANGES:()=>gi,aborted:()=>Wt,allowsEval:()=>fi,assert:()=>ly,assertEqual:()=>iy,assertIs:()=>cy,assertNever:()=>uy,assertNotEqual:()=>ay,assignProp:()=>pi,cached:()=>dn,captureStackTrace:()=>Po,cleanEnum:()=>Sy,cleanRegex:()=>fn,clone:()=>ot,createTransparentProxy:()=>gy,defineLazy:()=>ae,esc:()=>Gt,escapeRegex:()=>At,extend:()=>vy,finalizeIssue:()=>st,floatSafeRemainder:()=>di,getElementAtPath:()=>dy,getEnumValues:()=>ui,getLengthableOrigin:()=>mn,getParsedType:()=>hy,getSizableOrigin:()=>el,isObject:()=>$r,isPlainObject:()=>Sr,issue:()=>_i,joinValues:()=>zo,jsonStringifyReplacer:()=>li,merge:()=>by,normalizeParams:()=>O,nullish:()=>pn,numKeys:()=>my,omit:()=>yy,optionalKeys:()=>hi,partial:()=>wy,pick:()=>_y,prefixIssues:()=>mt,primitiveTypes:()=>Qu,promiseAllObject:()=>py,propertyKeyTypes:()=>mi,randomString:()=>fy,required:()=>$y,stringifyPrimitive:()=>To,unwrapMessage:()=>ln});function iy(e){return e}function ay(e){return e}function cy(e){}function uy(e){throw new Error}function ly(e){}function ui(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 zo(e,t="|"){return e.map(r=>To(r)).join(t)}function li(e,t){return typeof t=="bigint"?t.toString():t}function dn(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function pn(e){return e==null}function fn(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function di(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 ae(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 pi(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function dy(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function py(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 fy(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Gt(e){return JSON.stringify(e)}var Po=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function $r(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var fi=dn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Sr(e){if($r(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!($r(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function my(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var hy=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}`)}},mi=new Set(["string","number","symbol"]),Qu=new Set(["string","number","bigint","boolean","symbol","undefined"]);function At(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ot(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function O(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 gy(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 To(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function hi(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var gi={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]},Xu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function _y(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 ot(e,{...e._zod.def,shape:r,checks:[]})}function yy(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 ot(e,{...e._zod.def,shape:r,checks:[]})}function vy(e,t){if(!Sr(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 pi(this,"shape",n),n},checks:[]};return ot(e,r)}function by(e,t){return ot(e,{...e._zod.def,get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return pi(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function wy(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 ot(t,{...t._zod.def,shape:o,checks:[]})}function $y(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 ot(t,{...t._zod.def,shape:o,checks:[]})}function Wt(e,t=0){for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function mt(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function ln(e){return typeof e=="string"?e:e?.message}function st(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let o=ln(e.inst?._zod.def?.error?.(e))??ln(t?.error?.(e))??ln(r.customError?.(e))??ln(r.localeError?.(e))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}function el(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function mn(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function _i(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function Sy(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var ci=class{constructor(...t){}};var tl=(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,li,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Ro=_("$ZodError",tl),yi=_("$ZodError",tl,{Parent:Error});function vi(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 bi(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 rl=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 St;if(i.issues.length){let a=new(o?.Err??e)(i.issues.map(c=>st(c,s,Be())));throw Po(a,o?.callee),a}return i.value};var nl=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=>st(c,s,Be())));throw Po(a,o?.callee),a}return i.value};var wi=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 St;return s.issues.length?{success:!1,error:new(e??Ro)(s.issues.map(i=>st(i,o,Be())))}:{success:!0,data:s.value}},hn=wi(yi),$i=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=>st(i,o,Be())))}:{success:!0,data:s.value}},Eo=$i(yi);var ol=/^[cC][^\s-]{8,}$/,sl=/^[0-9a-z]+$/,il=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,al=/^[0-9a-vA-V]{20}$/,cl=/^[A-Za-z0-9]{27}$/,ul=/^[a-zA-Z0-9_-]{21}$/,ll=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var dl=/^([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})$/,Si=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 pl=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var ky="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function fl(){return new RegExp(ky,"u")}var ml=/^(?:(?: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])$/,hl=/^(([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})$/,gl=/^((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])$/,_l=/^(([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])$/,yl=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,xi=/^[A-Za-z0-9_-]*$/,vl=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var bl=/^\+(?:[0-9]){6,14}[0-9]$/,wl="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",$l=new RegExp(`^${wl}$`);function Sl(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 xl(e){return new RegExp(`^${Sl(e)}$`)}function kl(e){let t=Sl({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(`^${wl}T(?:${n})$`)}var zl=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Pl=/^\d+n?$/,Tl=/^\d+$/,Rl=/^-?\d+(?:\.\d+)?/i,El=/true|false/i,Il=/null/i;var Ol=/^[^A-Z]*$/,Al=/^[^a-z]*$/;var Ie=_("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Cl={number:"number",bigint:"bigint",object:"date"},ki=_("$ZodCheckLessThan",(e,t)=>{Ie.init(e,t);let r=Cl[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})}}),zi=_("$ZodCheckGreaterThan",(e,t)=>{Ie.init(e,t);let r=Cl[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})}}),Nl=_("$ZodCheckMultipleOf",(e,t)=>{Ie.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):di(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})}}),jl=_("$ZodCheckNumberFormat",(e,t)=>{Ie.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=gi[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=Tl)}),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;Ie.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!pn(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=mn(o);n.issues.push({origin:i,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ul=_("$ZodCheckMinLength",(e,t)=>{var r;Ie.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!pn(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=mn(o);n.issues.push({origin:i,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Dl=_("$ZodCheckLengthEquals",(e,t)=>{var r;Ie.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!pn(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=mn(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})}}),gn=_("$ZodCheckStringFormat",(e,t)=>{var r,n;Ie.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=()=>{})}),Zl=_("$ZodCheckRegex",(e,t)=>{gn.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})}}),ql=_("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ol),gn.init(e,t)}),Ll=_("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Al),gn.init(e,t)}),Fl=_("$ZodCheckIncludes",(e,t)=>{Ie.init(e,t);let r=At(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})}}),Vl=_("$ZodCheckStartsWith",(e,t)=>{Ie.init(e,t);let r=new RegExp(`^${At(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})}}),Hl=_("$ZodCheckEndsWith",(e,t)=>{Ie.init(e,t);let r=new RegExp(`.*${At(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)=>{Ie.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Oo=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 px={keyword:"dependencies",type:"object",schemaType:"object",error:ot.error,code(e){let[t,r]=fx(e);vh(e,t),wh(e,r)}};function fx({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 vh(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,Dn.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,Dn.checkReportMissingProp)(e,u)}):(r.if((0,Ec._)`${c} && (${(0,Dn.checkMissingProp)(e,a,s)})`),(0,Dn.reportMissingProp)(e,s),r.else())}}ot.validatePropertyDeps=vh;function wh(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,i=r.name("valid");for(let a in t)(0,dx.alwaysValidSchema)(s,t[a])||(r.if((0,Dn.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))}ot.validateSchemaDeps=wh;ot.default=px});var $h=P(Ic=>{"use strict";Object.defineProperty(Ic,"__esModule",{value:!0});var Sh=M(),mx=L(),hx={message:"property name must be valid",params:({params:e})=>(0,Sh._)`{propertyName: ${e.propertyName}}`},gx={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:hx,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,mx.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,Sh.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};Ic.default=gx});var Cc=P(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});var fs=Fe(),Qe=M(),_x=mt(),ms=L(),yx={message:"must NOT have additional properties",params:({params:e})=>(0,Qe._)`{additionalProperty: ${e.additionalProperty}}`},vx={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:yx,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,ms.alwaysValidSchema)(i,r))return;let u=(0,fs.allSchemaProperties)(n.properties),l=(0,fs.allSchemaProperties)(n.patternProperties);d(),e.ok((0,Qe._)`${s} === ${_x.default.errors}`);function d(){t.forIn("key",o,y=>{!u.length&&!l.length?h(y):t.if(f(y),()=>h(y))})}function f(y){let S;if(u.length>8){let $=(0,ms.schemaRefOrVal)(i,n.properties,"properties");S=(0,fs.isOwnProperty)(t,$,y)}else u.length?S=(0,Qe.or)(...u.map($=>(0,Qe._)`${y} === ${$}`)):S=Qe.nil;return l.length&&(S=(0,Qe.or)(S,...l.map($=>(0,Qe._)`${(0,fs.usePattern)(e,$)}.test(${y})`))),(0,Qe.not)(S)}function m(y){t.code((0,Qe._)`delete ${o}[${y}]`)}function h(y){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){m(y);return}if(r===!1){e.setParams({additionalProperty:y}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,ms.alwaysValidSchema)(i,r)){let S=t.name("valid");c.removeAdditional==="failing"?(g(y,S,!1),t.if((0,Qe.not)(S),()=>{e.reset(),m(y)})):(g(y,S),a||t.if((0,Qe.not)(S),()=>t.break()))}}function g(y,S,$){let b={keyword:"additionalProperties",dataProp:y,dataPropType:ms.Type.Str};$===!1&&Object.assign(b,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(b,S)}}};Oc.default=vx});var zh=P(Nc=>{"use strict";Object.defineProperty(Nc,"__esModule",{value:!0});var wx=zn(),xh=Fe(),Ac=L(),kh=Cc(),bx={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&&kh.default.code(new wx.KeywordCxt(s,kh.default,"additionalProperties"));let i=(0,xh.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Ac.mergeEvaluated.props(t,(0,Ac.toHash)(i),s.props));let a=i.filter(d=>!(0,Ac.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,xh.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)}}};Nc.default=bx});var Eh=P(jc=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});var Ph=Fe(),hs=M(),Th=L(),Rh=L(),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,Ph.allSchemaProperties)(r),c=a.filter(g=>(0,Th.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 hs.Name)&&(s.props=(0,Rh.evaluatedPropsToName)(t,s.props));let{props:d}=s;f();function f(){for(let g of a)u&&m(g),s.allErrors?h(g):(t.var(l,!0),h(g),t.if(l))}function m(g){for(let y in u)new RegExp(g).test(y)&&(0,Th.checkStrictMode)(s,`property ${y} matches pattern ${g} (use allowMatchingProperties)`)}function h(g){t.forIn("key",n,y=>{t.if((0,hs._)`${(0,Ph.usePattern)(e,g)}.test(${y})`,()=>{let S=c.includes(g);S||e.subschema({keyword:"patternProperties",schemaProp:g,dataProp:y,dataPropType:Rh.Type.Str},l),s.opts.unevaluated&&d!==!0?t.assign((0,hs._)`${d}[${y}]`,!0):!S&&!s.allErrors&&t.if((0,hs.not)(l),()=>t.break())})})}}};jc.default=Sx});var Ih=P(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});var $x=L(),xx={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,$x.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"}};Mc.default=xx});var Oh=P(qc=>{"use strict";Object.defineProperty(qc,"__esModule",{value:!0});var kx=Fe(),zx={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:kx.validateUnion,error:{message:"must match a schema in anyOf"}};qc.default=zx});var Ch=P(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});var gs=M(),Px=L(),Tx={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,gs._)`{passingSchemas: ${e.passing}}`},Rx={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Tx,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 f;(0,Px.alwaysValidSchema)(o,l)?t.var(c,!0):f=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,gs._)`${c} && ${i}`).assign(i,!1).assign(a,(0,gs._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),f&&e.mergeEvaluated(f,gs.Name)})})}}};Uc.default=Rx});var Ah=P(Dc=>{"use strict";Object.defineProperty(Dc,"__esModule",{value:!0});var Ex=L(),Ix={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,Ex.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};Dc.default=Ix});var Mh=P(Zc=>{"use strict";Object.defineProperty(Zc,"__esModule",{value:!0});var _s=M(),jh=L(),Ox={message:({params:e})=>(0,_s.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,_s._)`{failingKeyword: ${e.ifClause}}`},Cx={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:Ox,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,jh.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=Nh(n,"then"),s=Nh(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,_s.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 f=e.subschema({keyword:l},a);t.assign(i,a),e.mergeValidEvaluated(f,i),d?t.assign(d,(0,_s._)`${l}`):e.setParams({ifClause:l})}}}};function Nh(e,t){let r=e.schema[t];return r!==void 0&&!(0,jh.alwaysValidSchema)(e,r)}Zc.default=Cx});var qh=P(Lc=>{"use strict";Object.defineProperty(Lc,"__esModule",{value:!0});var Ax=L(),Nx={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,Ax.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Lc.default=Nx});var Uh=P(Fc=>{"use strict";Object.defineProperty(Fc,"__esModule",{value:!0});var jx=kc(),Mx=hh(),qx=zc(),Ux=_h(),Dx=yh(),Zx=bh(),Lx=$h(),Fx=Cc(),Vx=zh(),Hx=Eh(),Bx=Ih(),Kx=Oh(),Jx=Ch(),Gx=Ah(),Wx=Mh(),Yx=qh();function Xx(e=!1){let t=[Bx.default,Kx.default,Jx.default,Gx.default,Wx.default,Yx.default,Lx.default,Fx.default,Zx.default,Vx.default,Hx.default];return e?t.push(Mx.default,Ux.default):t.push(jx.default,qx.default),t.push(Dx.default),t}Fc.default=Xx});var Dh=P(Vc=>{"use strict";Object.defineProperty(Vc,"__esModule",{value:!0});var de=M(),Qx={message:({schemaCode:e})=>(0,de.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,de._)`{format: ${e}}`},ek={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:Qx,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?f():m();function f(){let h=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),g=r.const("fDef",(0,de._)`${h}[${i}]`),y=r.let("fType"),S=r.let("format");r.if((0,de._)`typeof ${g} == "object" && !(${g} instanceof RegExp)`,()=>r.assign(y,(0,de._)`${g}.type || "string"`).assign(S,(0,de._)`${g}.validate`),()=>r.assign(y,(0,de._)`"string"`).assign(S,g)),e.fail$data((0,de.or)($(),b()));function $(){return c.strictSchema===!1?de.nil:(0,de._)`${i} && !${S}`}function b(){let T=l.$async?(0,de._)`(${g}.async ? await ${S}(${n}) : ${S}(${n}))`:(0,de._)`${S}(${n})`,v=(0,de._)`(typeof ${S} == "function" ? ${T} : ${S}.test(${n}))`;return(0,de._)`${S} && ${S} !== true && ${y} === ${t} && !${v}`}}function m(){let h=d.formats[s];if(!h){$();return}if(h===!0)return;let[g,y,S]=b(h);g===t&&e.pass(T());function $(){if(c.strictSchema===!1){d.logger.warn(v());return}throw new Error(v());function v(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function b(v){let x=v instanceof RegExp?(0,de.regexpCode)(v):c.code.formats?(0,de._)`${c.code.formats}${(0,de.getProperty)(s)}`:void 0,O=r.scopeValue("formats",{key:s,ref:v,code:x});return typeof v=="object"&&!(v instanceof RegExp)?[v.type||"string",v.validate,(0,de._)`${O}.validate`]:["string",v,O]}function T(){if(typeof h=="object"&&!(h instanceof RegExp)&&h.async){if(!l.$async)throw new Error("async format in sync schema");return(0,de._)`await ${S}(${n})`}return typeof y=="function"?(0,de._)`${S}(${n})`:(0,de._)`${S}.test(${n})`}}}};Vc.default=ek});var Zh=P(Hc=>{"use strict";Object.defineProperty(Hc,"__esModule",{value:!0});var tk=Dh(),rk=[tk.default];Hc.default=rk});var Lh=P(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.contentVocabulary=Ar.metadataVocabulary=void 0;Ar.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Ar.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Vh=P(Bc=>{"use strict";Object.defineProperty(Bc,"__esModule",{value:!0});var nk=Ym(),ok=dh(),sk=Uh(),ik=Zh(),Fh=Lh(),ak=[nk.default,ok.default,(0,sk.default)(),ik.default,Fh.metadataVocabulary,Fh.contentVocabulary];Bc.default=ak});var Bh=P(ys=>{"use strict";Object.defineProperty(ys,"__esModule",{value:!0});ys.DiscrError=void 0;var Hh;(function(e){e.Tag="tag",e.Mapping="mapping"})(Hh||(ys.DiscrError=Hh={}))});var Jh=P(Jc=>{"use strict";Object.defineProperty(Jc,"__esModule",{value:!0});var Nr=M(),Kc=Bh(),Kh=ts(),ck=Pn(),uk=L(),lk={message:({params:{discrError:e,tagName:t}})=>e===Kc.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Nr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},dk={keyword:"discriminator",type:"object",schemaType:"object",error:lk,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,Nr._)`${r}${(0,Nr.getProperty)(a)}`);t.if((0,Nr._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:Kc.DiscrError.Tag,tag:u,tagName:a})),e.ok(c);function l(){let m=f();t.if(!1);for(let h in m)t.elseIf((0,Nr._)`${u} === ${h}`),t.assign(c,d(m[h]));t.else(),e.error(!1,{discrError:Kc.DiscrError.Mapping,tag:u,tagName:a}),t.endIf()}function d(m){let h=t.name("valid"),g=e.subschema({keyword:"oneOf",schemaProp:m},h);return e.mergeEvaluated(g,Nr.Name),h}function f(){var m;let h={},g=S(o),y=!0;for(let T=0;T<i.length;T++){let v=i[T];if(v?.$ref&&!(0,uk.schemaHasRulesButRef)(v,s.self.RULES)){let O=v.$ref;if(v=Kh.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,O),v instanceof Kh.SchemaEnv&&(v=v.schema),v===void 0)throw new ck.default(s.opts.uriResolver,s.baseId,O)}let x=(m=v?.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}"`);y=y&&(g||S(v)),$(x,T)}if(!y)throw new Error(`discriminator: "${a}" must be required`);return h;function S({required:T}){return Array.isArray(T)&&T.includes(a)}function $(T,v){if(T.const)b(T.const,v);else if(T.enum)for(let x of T.enum)b(x,v);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function b(T,v){if(typeof T!="string"||T in h)throw new Error(`discriminator: "${a}" values must be unique strings`);h[T]=v}}}};Jc.default=dk});var Gh=P((vA,pk)=>{pk.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 Wc=P((ie,Gc)=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.MissingRefError=ie.ValidationError=ie.CodeGen=ie.Name=ie.nil=ie.stringify=ie.str=ie._=ie.KeywordCxt=ie.Ajv=void 0;var fk=Hm(),mk=Vh(),hk=Jh(),Wh=Gh(),gk=["/properties"],vs="http://json-schema.org/draft-07/schema",jr=class extends fk.default{_addVocabularies(){super._addVocabularies(),mk.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(hk.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(Wh,gk):Wh;this.addMetaSchema(t,vs,!1),this.refs["http://json-schema.org/schema"]=vs}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(vs)?vs:void 0)}};ie.Ajv=jr;Gc.exports=ie=jr;Gc.exports.Ajv=jr;Object.defineProperty(ie,"__esModule",{value:!0});ie.default=jr;var _k=zn();Object.defineProperty(ie,"KeywordCxt",{enumerable:!0,get:function(){return _k.KeywordCxt}});var Mr=M();Object.defineProperty(ie,"_",{enumerable:!0,get:function(){return Mr._}});Object.defineProperty(ie,"str",{enumerable:!0,get:function(){return Mr.str}});Object.defineProperty(ie,"stringify",{enumerable:!0,get:function(){return Mr.stringify}});Object.defineProperty(ie,"nil",{enumerable:!0,get:function(){return Mr.nil}});Object.defineProperty(ie,"Name",{enumerable:!0,get:function(){return Mr.Name}});Object.defineProperty(ie,"CodeGen",{enumerable:!0,get:function(){return Mr.CodeGen}});var yk=Qo();Object.defineProperty(ie,"ValidationError",{enumerable:!0,get:function(){return yk.default}});var vk=Pn();Object.defineProperty(ie,"MissingRefError",{enumerable:!0,get:function(){return vk.default}})});var og=P(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.formatNames=it.fastFormats=it.fullFormats=void 0;function st(e,t){return{validate:e,compare:t}}it.fullFormats={date:st(eg,eu),time:st(Xc(!0),tu),"date-time":st(Yh(!0),rg),"iso-time":st(Xc(),tg),"iso-date-time":st(Yh(),ng),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:kk,"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:Ok,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:zk,int32:{type:"number",validate:Rk},int64:{type:"number",validate:Ek},float:{type:"number",validate:Qh},double:{type:"number",validate:Qh},password:!0,binary:!0};it.fastFormats={...it.fullFormats,date:st(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,eu),time:st(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,tu),"date-time":st(/^\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,rg),"iso-time":st(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,tg),"iso-date-time":st(/^\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,ng),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};it.formatNames=Object.keys(it.fullFormats);function wk(e){return e%4===0&&(e%100!==0||e%400===0)}var bk=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Sk=[0,31,28,31,30,31,30,31,31,30,31,30,31];function eg(e){let t=bk.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&&wk(r)?29:Sk[n])}function eu(e,t){if(e&&t)return e>t?1:e<t?-1:0}var Yc=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Xc(e){return function(r){let n=Yc.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,f=o-u*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&i<61}}function tu(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 tg(e,t){if(!(e&&t))return;let r=Yc.exec(e),n=Yc.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 Qc=/t|\s/i;function Yh(e){let t=Xc(e);return function(n){let o=n.split(Qc);return o.length===2&&eg(o[0])&&t(o[1])}}function rg(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function ng(e,t){if(!(e&&t))return;let[r,n]=e.split(Qc),[o,s]=t.split(Qc),i=eu(r,o);if(i!==void 0)return i||tu(n,s)}var $k=/\/|:/,xk=/^(?:[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 kk(e){return $k.test(e)&&xk.test(e)}var Xh=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function zk(e){return Xh.lastIndex=0,Xh.test(e)}var Pk=-(2**31),Tk=2**31-1;function Rk(e){return Number.isInteger(e)&&e<=Tk&&e>=Pk}function Ek(e){return Number.isInteger(e)}function Qh(){return!0}var Ik=/[^\\]\\Z/;function Ok(e){if(Ik.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var sg=P(qr=>{"use strict";Object.defineProperty(qr,"__esModule",{value:!0});qr.formatLimitDefinition=void 0;var Ck=Wc(),et=M(),Ot=et.operators,ws={formatMaximum:{okStr:"<=",ok:Ot.LTE,fail:Ot.GT},formatMinimum:{okStr:">=",ok:Ot.GTE,fail:Ot.LT},formatExclusiveMaximum:{okStr:"<",ok:Ot.LT,fail:Ot.GTE},formatExclusiveMinimum:{okStr:">",ok:Ot.GT,fail:Ot.LTE}},Ak={message:({keyword:e,schemaCode:t})=>(0,et.str)`should be ${ws[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,et._)`{comparison: ${ws[e].okStr}, limit: ${t}}`};qr.formatLimitDefinition={keyword:Object.keys(ws),type:"string",schemaType:"string",$data:!0,error:Ak,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 Ck.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let f=t.scopeValue("formats",{ref:a.formats,code:i.code.formats}),m=t.const("fmt",(0,et._)`${f}[${c.schemaCode}]`);e.fail$data((0,et.or)((0,et._)`typeof ${m} != "object"`,(0,et._)`${m} instanceof RegExp`,(0,et._)`typeof ${m}.compare != "function"`,d(m)))}function l(){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,et._)`${i.code.formats}${(0,et.getProperty)(f)}`:void 0});e.fail$data(d(h))}function d(f){return(0,et._)`${f}.compare(${r}, ${n}) ${ws[o].fail} 0`}},dependencies:["format"]};var Nk=e=>(e.addKeyword(qr.formatLimitDefinition),e);qr.default=Nk});var ug=P((Zn,cg)=>{"use strict";Object.defineProperty(Zn,"__esModule",{value:!0});var Ur=og(),jk=sg(),ru=M(),ig=new ru.Name("fullFormats"),Mk=new ru.Name("fastFormats"),nu=(e,t={keywords:!0})=>{if(Array.isArray(t))return ag(e,t,Ur.fullFormats,ig),e;let[r,n]=t.mode==="fast"?[Ur.fastFormats,Mk]:[Ur.fullFormats,ig],o=t.formats||Ur.formatNames;return ag(e,o,r,n),t.keywords&&(0,jk.default)(e),e};nu.get=(e,t="full")=>{let n=(t==="fast"?Ur.fastFormats:Ur.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function ag(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,ru._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}cg.exports=Zn=nu;Object.defineProperty(Zn,"__esModule",{value:!0});Zn.default=nu});import{spawn as m_,spawnSync as Hr}from"node:child_process";import{connect as oP}from"node:net";import{homedir as h_,userInfo as Pu}from"node:os";import{resolve as g_,join as yt,dirname as Ou}from"node:path";import{fileURLToPath as sP,pathToFileURL as iP}from"node:url";import{createInterface as js}from"node:readline/promises";import*as D from"node:fs";var Ls=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 E_=Symbol("zod_brand"),ut=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},lo={};function je(e){return e&&Object.assign(lo,e),lo}var B={};Zs(B,{BIGINT_FORMAT_RANGES:()=>Mu,Class:()=>Vs,NUMBER_FORMAT_RANGES:()=>Xs,aborted:()=>qt,allowsEval:()=>Gs,assert:()=>N_,assertEqual:()=>I_,assertIs:()=>C_,assertNever:()=>A_,assertNotEqual:()=>O_,assignProp:()=>Js,cached:()=>Gr,captureStackTrace:()=>fo,cleanEnum:()=>J_,cleanRegex:()=>Yr,clone:()=>Be,createTransparentProxy:()=>Z_,defineLazy:()=>ee,esc:()=>Mt,escapeRegex:()=>bt,extend:()=>V_,finalizeIssue:()=>Ke,floatSafeRemainder:()=>Ks,getElementAtPath:()=>j_,getEnumValues:()=>Hs,getLengthableOrigin:()=>Xr,getParsedType:()=>D_,getSizableOrigin:()=>qu,isObject:()=>ur,isPlainObject:()=>lr,issue:()=>Qs,joinValues:()=>po,jsonStringifyReplacer:()=>Bs,merge:()=>H_,normalizeParams:()=>I,nullish:()=>Wr,numKeys:()=>U_,omit:()=>F_,optionalKeys:()=>Ys,partial:()=>B_,pick:()=>L_,prefixIssues:()=>tt,primitiveTypes:()=>ju,promiseAllObject:()=>M_,propertyKeyTypes:()=>Ws,randomString:()=>q_,required:()=>K_,stringifyPrimitive:()=>mo,unwrapMessage:()=>Jr});function I_(e){return e}function O_(e){return e}function C_(e){}function A_(e){throw new Error}function N_(e){}function Hs(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 po(e,t="|"){return e.map(r=>mo(r)).join(t)}function Bs(e,t){return typeof t=="bigint"?t.toString():t}function Gr(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Wr(e){return e==null}function Yr(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Ks(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 ee(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 Js(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function j_(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function M_(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 q_(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 fo=Error.captureStackTrace?Error.captureStackTrace:(...e)=>{};function ur(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Gs=Gr(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function lr(e){if(ur(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let r=t.prototype;return!(ur(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function U_(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var D_=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}`)}},Ws=new Set(["string","number","symbol"]),ju=new Set(["string","number","bigint","boolean","symbol","undefined"]);function bt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Be(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function I(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 Z_(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 mo(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Ys(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}var Xs={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]},Mu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function L_(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 Be(e,{...e._zod.def,shape:r,checks:[]})}function F_(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 Be(e,{...e._zod.def,shape:r,checks:[]})}function V_(e,t){if(!lr(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 Js(this,"shape",n),n},checks:[]};return Be(e,r)}function H_(e,t){return Be(e,{...e._zod.def,get shape(){let r={...e._zod.def.shape,...t._zod.def.shape};return Js(this,"shape",r),r},catchall:t._zod.def.catchall,checks:[]})}function B_(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 Be(t,{...t._zod.def,shape:o,checks:[]})}function K_(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 Be(t,{...t._zod.def,shape:o,checks:[]})}function qt(e,t=0){for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function tt(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 Ke(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 qu(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 Qs(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function J_(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}var Vs=class{constructor(...t){}};var Uu=(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,Bs,2)},enumerable:!0}),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ho=_("$ZodError",Uu),ei=_("$ZodError",Uu,{Parent:Error});function ti(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 ri(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 Du=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 ut;if(i.issues.length){let a=new(o?.Err??e)(i.issues.map(c=>Ke(c,s,je())));throw fo(a,o?.callee),a}return i.value};var Zu=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=>Ke(c,s,je())));throw fo(a,o?.callee),a}return i.value};var ni=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 ut;return s.issues.length?{success:!1,error:new(e??ho)(s.issues.map(i=>Ke(i,o,je())))}:{success:!0,data:s.value}},Qr=ni(ei),oi=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=>Ke(i,o,je())))}:{success:!0,data:s.value}},go=oi(ei);var Lu=/^[cC][^\s-]{8,}$/,Fu=/^[0-9a-z]+$/,Vu=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Hu=/^[0-9a-vA-V]{20}$/,Bu=/^[A-Za-z0-9]{27}$/,Ku=/^[a-zA-Z0-9_-]{21}$/,Ju=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Gu=/^([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})$/,si=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 Wu=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var W_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Yu(){return new RegExp(W_,"u")}var Xu=/^(?:(?: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])$/,Qu=/^(([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})$/,el=/^((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])$/,tl=/^(([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])$/,rl=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ii=/^[A-Za-z0-9_-]*$/,nl=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var ol=/^\+(?:[0-9]){6,14}[0-9]$/,sl="(?:(?:\\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])))",il=new RegExp(`^${sl}$`);function al(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 cl(e){return new RegExp(`^${al(e)}$`)}function ul(e){let t=al({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(`^${sl}T(?:${n})$`)}var ll=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},dl=/^\d+n?$/,pl=/^\d+$/,fl=/^-?\d+(?:\.\d+)?/i,ml=/true|false/i,hl=/null/i;var gl=/^[^A-Z]*$/,_l=/^[^a-z]*$/;var $e=_("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),yl={number:"number",bigint:"bigint",object:"date"},ai=_("$ZodCheckLessThan",(e,t)=>{$e.init(e,t);let r=yl[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})}}),ci=_("$ZodCheckGreaterThan",(e,t)=>{$e.init(e,t);let r=yl[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})}}),vl=_("$ZodCheckMultipleOf",(e,t)=>{$e.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):Ks(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})}}),wl=_("$ZodCheckNumberFormat",(e,t)=>{$e.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=Xs[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=pl)}),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 bl=_("$ZodCheckMaxLength",(e,t)=>{var r;$e.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Wr(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})}}),Sl=_("$ZodCheckMinLength",(e,t)=>{var r;$e.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Wr(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})}}),$l=_("$ZodCheckLengthEquals",(e,t)=>{var r;$e.init(e,t),(r=e._zod.def).when??(r.when=n=>{let o=n.value;return!Wr(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})}}),en=_("$ZodCheckStringFormat",(e,t)=>{var r,n;$e.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=()=>{})}),xl=_("$ZodCheckRegex",(e,t)=>{en.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})}}),kl=_("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=gl),en.init(e,t)}),zl=_("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=_l),en.init(e,t)}),Pl=_("$ZodCheckIncludes",(e,t)=>{$e.init(e,t);let r=bt(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})}}),Tl=_("$ZodCheckStartsWith",(e,t)=>{$e.init(e,t);let r=new RegExp(`^${bt(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})}}),Rl=_("$ZodCheckEndsWith",(e,t)=>{$e.init(e,t);let r=new RegExp(`.*${bt(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 El=_("$ZodCheckOverwrite",(e,t)=>{$e.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var yo=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
|
|
13
|
-
if (${
|
|
12
|
+
`))}};var Ol={major:4,minor:0,patch:0};var G=_("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ol;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=qt(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,f=l._zod.check(s);if(f instanceof Promise&&a?.async===!1)throw new ut;if(u||f instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await f,s.issues.length!==d&&(c||(c=qt(s,d)))});else{if(s.issues.length===d)continue;c||(c=qt(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 ut;return a.then(c=>o(c,n,i))}return o(a,n,i)}}e["~standard"]={validate:o=>{try{let s=Qr(e,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return go(e,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),wo=_("$ZodString",(e,t)=>{G.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ll(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}}),ne=_("$ZodStringFormat",(e,t)=>{en.init(e,t),wo.init(e,t)}),Ll=_("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Gu),ne.init(e,t)}),Fl=_("$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=si(n))}else t.pattern??(t.pattern=si());ne.init(e,t)}),Vl=_("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Wu),ne.init(e,t)}),Hl=_("$ZodURL",(e,t)=>{ne.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:nl.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})}}}),Bl=_("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Yu()),ne.init(e,t)}),Kl=_("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Ku),ne.init(e,t)}),Jl=_("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Lu),ne.init(e,t)}),Gl=_("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Fu),ne.init(e,t)}),Wl=_("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Vu),ne.init(e,t)}),Yl=_("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Hu),ne.init(e,t)}),Xl=_("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Bu),ne.init(e,t)}),Ql=_("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ul(t)),ne.init(e,t)}),ed=_("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=il),ne.init(e,t)}),td=_("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=cl(t)),ne.init(e,t)}),rd=_("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ju),ne.init(e,t)}),nd=_("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Xu),ne.init(e,t),e._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),od=_("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Qu),ne.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})}}}),sd=_("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=el),ne.init(e,t)}),id=_("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=tl),ne.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 ad(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var cd=_("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=rl),ne.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),e._zod.check=r=>{ad(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function Y_(e){if(!ii.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return ad(r)}var ud=_("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ii),ne.init(e,t),e._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),e._zod.check=r=>{Y_(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),ld=_("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ol),ne.init(e,t)});function X_(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 dd=_("$ZodJWT",(e,t)=>{ne.init(e,t),e._zod.check=r=>{X_(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var li=_("$ZodNumber",(e,t)=>{G.init(e,t),e._zod.pattern=e._zod.bag.pattern??fl,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}}),pd=_("$ZodNumber",(e,t)=>{wl.init(e,t),li.init(e,t)}),fd=_("$ZodBoolean",(e,t)=>{G.init(e,t),e._zod.pattern=ml,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}}),md=_("$ZodBigInt",(e,t)=>{G.init(e,t),e._zod.pattern=dl,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 hd=_("$ZodNull",(e,t)=>{G.init(e,t),e._zod.pattern=hl,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}}),gd=_("$ZodAny",(e,t)=>{G.init(e,t),e._zod.parse=r=>r}),_d=_("$ZodUnknown",(e,t)=>{G.init(e,t),e._zod.parse=r=>r}),yd=_("$ZodNever",(e,t)=>{G.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});var vd=_("$ZodDate",(e,t)=>{G.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 Cl(e,t,r){e.issues.length&&t.issues.push(...tt(r,e.issues)),t.value[r]=e.value}var wd=_("$ZodArray",(e,t)=>{G.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=>Cl(u,r,i))):Cl(c,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function vo(e,t,r){e.issues.length&&t.issues.push(...tt(r,e.issues)),t.value[r]=e.value}function Al(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(...tt(r,e.issues)):e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}var bd=_("$ZodObject",(e,t)=>{G.init(e,t);let r=Gr(()=>{let d=Object.keys(t.shape);for(let m of d)if(!(t.shape[m]instanceof G))throw new Error(`Invalid element at key "${m}": expected a Zod schema`);let f=Ys(t.shape);return{shape:t.shape,keys:d,keySet:new Set(d),numKeys:d.length,optionalKeys:new Set(f)}});ee(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 yo(["shape","payload","ctx"]),m=r.value,h=$=>{let b=Mt($);return`shape[${b}]._zod.run({ value: input[${b}], issues: [] }, ctx)`};f.write("const input = payload.value;");let g=Object.create(null),y=0;for(let $ of m.keys)g[$]=`key_${y++}`;f.write("const newResult = {}");for(let $ of m.keys)if(m.optionalKeys.has($)){let b=g[$];f.write(`const ${b} = ${h($)};`);let T=Mt($);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
|
-
${
|
|
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 (${
|
|
26
|
+
} else if (${b}.value === undefined) {
|
|
27
27
|
if (${T} in input) newResult[${T}] = undefined;
|
|
28
28
|
} else {
|
|
29
|
-
newResult[${T}] = ${
|
|
29
|
+
newResult[${T}] = ${b}.value;
|
|
30
30
|
}
|
|
31
|
-
`)}else{let
|
|
32
|
-
if (${
|
|
31
|
+
`)}else{let b=g[$];f.write(`const ${b} = ${h($)};`),f.write(`
|
|
32
|
+
if (${b}.issues.length) payload.issues = payload.issues.concat(${b}.issues.map(iss => ({
|
|
33
33
|
...iss,
|
|
34
|
-
path: iss.path ? [${
|
|
35
|
-
})));`),f.write(`newResult[${Gt($)}] = ${w}.value`)}f.write("payload.value = newResult;"),f.write("return payload;");let S=f.compile();return($,w)=>S(d,$,w)},o,s=$r,i=!ko.jitless,c=i&&fi.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 w=u.shape;for(let T of u.keys){let v=w[T],x=v._zod.run({value:m[T],issues:[]},f),A=v._zod.optin==="optional"&&v._zod.optout==="optional";x instanceof Promise?h.push(x.then(B=>A?Wl(B,d,T,m):Ao(B,d,T))):A?Wl(x,d,T,m):Ao(x,d,T)}}if(!l)return h.length?Promise.all(h).then(()=>d):d;let g=[],y=u.keySet,S=l._zod,$=S.def.type;for(let w of Object.keys(m)){if(y.has(w))continue;if($==="never"){g.push(w);continue}let T=S.run({value:m[w],issues:[]},f);T instanceof Promise?h.push(T.then(v=>Ao(v,d,w))):Ao(T,d,w)}return g.length&&d.issues.push({code:"unrecognized_keys",keys:g,input:m,inst:e}),h.length?Promise.all(h).then(()=>d):d}});function Yl(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=>st(s,n,Be())))}),t}var Ri=_("$ZodUnion",(e,t)=>{re.init(e,t),ae(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),ae(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),ae(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),ae(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=>fn(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=>Yl(i,r,e,n)):Yl(s,r,e,n)}}),Ud=_("$ZodDiscriminatedUnion",(e,t)=>{Ri.init(e,t);let r=e._zod.parse;ae(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=dn(()=>{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(!$r(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)}}),Dd=_("$ZodIntersection",(e,t)=>{re.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])=>Ql(r,c,l)):Ql(r,s,i)}});function Pi(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(Sr(e)&&Sr(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=Pi(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=Pi(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 Ql(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),Wt(e))return e;let n=Pi(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 Zd=_("$ZodRecord",(e,t)=>{re.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!Sr(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(...mt(c,u.issues)),r.value[c]=u.value})):(l.issues.length&&r.issues.push(...mt(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=>st(l,n,Be())),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(...mt(i,l.issues)),r.value[a.value]=l.value})):(c.issues.length&&r.issues.push(...mt(i,c.issues)),r.value[a.value]=c.value)}}return s.length?Promise.all(s).then(()=>r):r}});var qd=_("$ZodEnum",(e,t)=>{re.init(e,t);let r=ui(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>mi.has(typeof n)).map(n=>typeof n=="string"?At(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}}),Ld=_("$ZodLiteral",(e,t)=>{re.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?At(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 Fd=_("$ZodTransform",(e,t)=>{re.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 St;return r.value=o,r}}),Vd=_("$ZodOptional",(e,t)=>{re.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ae(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ae(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${fn(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)}),Hd=_("$ZodNullable",(e,t)=>{re.init(e,t),ae(e._zod,"optin",()=>t.innerType._zod.optin),ae(e._zod,"optout",()=>t.innerType._zod.optout),ae(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${fn(r.source)}|null)$`):void 0}),ae(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)=>{re.init(e,t),e._zod.optin="optional",ae(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=>Xl(s,t)):Xl(o,t)}});function Xl(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Kd=_("$ZodPrefault",(e,t)=>{re.init(e,t),e._zod.optin="optional",ae(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))}),Jd=_("$ZodNonOptional",(e,t)=>{re.init(e,t),ae(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=>ed(s,e)):ed(o,e)}});function ed(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 Gd=_("$ZodCatch",(e,t)=>{re.init(e,t),e._zod.optin="optional",ae(e._zod,"optout",()=>t.innerType._zod.optout),ae(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=>st(i,n,Be()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(s=>st(s,n,Be()))},input:r.value}),r.issues=[]),r)}});var Wd=_("$ZodPipe",(e,t)=>{re.init(e,t),ae(e._zod,"values",()=>t.in._zod.values),ae(e._zod,"optin",()=>t.in._zod.optin),ae(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=>td(s,t,n)):td(o,t,n)}});function td(e,t,r){return Wt(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}var Yd=_("$ZodReadonly",(e,t)=>{re.init(e,t),ae(e._zod,"propValues",()=>t.innerType._zod.propValues),ae(e._zod,"values",()=>t.innerType._zod.values),ae(e._zod,"optin",()=>t.innerType._zod.optin),ae(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(rd):rd(o)}});function rd(e){return e.value=Object.freeze(e.value),e}var Qd=_("$ZodCustom",(e,t)=>{Ie.init(e,t),re.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=>nd(s,r,n,e));nd(o,r,n,e)}});function nd(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(_i(o))}}var Ty=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},Ry=()=>{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 ${Ty(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${To(n.values[0])}`:`Invalid option: expected one of ${zo(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":""}: ${zo(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 Xd(){return{localeError:Ry()}}var Ey=Symbol("ZodOutput"),Iy=Symbol("ZodInput"),Ei=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 ep(){return new Ei}var xr=ep();function tp(e,t){return new e({type:"string",...O(t)})}function rp(e,t){return new e({type:"string",coerce:!0,...O(t)})}function np(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...O(t)})}function Ii(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...O(t)})}function op(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...O(t)})}function sp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(t)})}function ip(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(t)})}function ap(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(t)})}function Oi(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...O(t)})}function cp(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...O(t)})}function up(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(t)})}function lp(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...O(t)})}function dp(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(t)})}function pp(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...O(t)})}function fp(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...O(t)})}function mp(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(t)})}function hp(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(t)})}function gp(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(t)})}function _p(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(t)})}function yp(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(t)})}function vp(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...O(t)})}function bp(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...O(t)})}function wp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...O(t)})}function $p(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...O(t)})}function Sp(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(t)})}function xp(e,t){return new e({type:"string",format:"date",check:"string_format",...O(t)})}function kp(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...O(t)})}function zp(e,t){return new e({type:"string",format:"duration",check:"string_format",...O(t)})}function Pp(e,t){return new e({type:"number",checks:[],...O(t)})}function Tp(e,t){return new e({type:"number",coerce:!0,checks:[],...O(t)})}function Rp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...O(t)})}function Ep(e,t){return new e({type:"boolean",...O(t)})}function Ip(e,t){return new e({type:"boolean",coerce:!0,...O(t)})}function Op(e,t){return new e({type:"bigint",coerce:!0,...O(t)})}function Ap(e,t){return new e({type:"null",...O(t)})}function Cp(e){return new e({type:"any"})}function Np(e){return new e({type:"unknown"})}function jp(e,t){return new e({type:"never",...O(t)})}function Mp(e,t){return new e({type:"date",coerce:!0,...O(t)})}function kr(e,t){return new ki({check:"less_than",...O(t),value:e,inclusive:!1})}function xt(e,t){return new ki({check:"less_than",...O(t),value:e,inclusive:!0})}function zr(e,t){return new zi({check:"greater_than",...O(t),value:e,inclusive:!1})}function it(e,t){return new zi({check:"greater_than",...O(t),value:e,inclusive:!0})}function _n(e,t){return new Nl({check:"multiple_of",...O(t),value:e})}function No(e,t){return new Ml({check:"max_length",...O(t),maximum:e})}function Pr(e,t){return new Ul({check:"min_length",...O(t),minimum:e})}function jo(e,t){return new Dl({check:"length_equals",...O(t),length:e})}function Ai(e,t){return new Zl({check:"string_format",format:"regex",...O(t),pattern:e})}function Ci(e){return new ql({check:"string_format",format:"lowercase",...O(e)})}function Ni(e){return new Ll({check:"string_format",format:"uppercase",...O(e)})}function ji(e,t){return new Fl({check:"string_format",format:"includes",...O(t),includes:e})}function Mi(e,t){return new Vl({check:"string_format",format:"starts_with",...O(t),prefix:e})}function Ui(e,t){return new Hl({check:"string_format",format:"ends_with",...O(t),suffix:e})}function Yt(e){return new Bl({check:"overwrite",tx:e})}function Di(e){return Yt(t=>t.normalize(e))}function Zi(){return Yt(e=>e.trim())}function qi(){return Yt(e=>e.toLowerCase())}function Li(){return Yt(e=>e.toUpperCase())}function Up(e,t,r){return new e({type:"array",element:t,...O(r)})}function Dp(e,t,r){let n=O(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Zp(e,t,r){return new e({type:"custom",check:"custom",fn:t,...O(r)})}function Rr(e){return!!e._zod}function at(e,t){return Rr(e)?hn(e,t):e.safeParse(t)}function Mo(e){if(!e)return;let t;if(Rr(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function qp(e){if(Rr(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 yn={};si(yn,{ZodISODate:()=>Fp,ZodISODateTime:()=>Lp,ZodISODuration:()=>Hp,ZodISOTime:()=>Vp,date:()=>Vi,datetime:()=>Fi,duration:()=>Bi,time:()=>Hi});var Lp=_("ZodISODateTime",(e,t)=>{hd.init(e,t),me.init(e,t)});function Fi(e){return Sp(Lp,e)}var Fp=_("ZodISODate",(e,t)=>{gd.init(e,t),me.init(e,t)});function Vi(e){return xp(Fp,e)}var Vp=_("ZodISOTime",(e,t)=>{_d.init(e,t),me.init(e,t)});function Hi(e){return kp(Vp,e)}var Hp=_("ZodISODuration",(e,t)=>{yd.init(e,t),me.init(e,t)});function Bi(e){return zp(Hp,e)}var Kp=(e,t)=>{Ro.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>bi(e,r)},flatten:{value:r=>vi(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},uR=_("ZodError",Kp),vn=_("ZodError",Kp,{Parent:Error});var Jp=rl(vn),Gp=nl(vn),Wp=wi(vn),Yp=$i(vn);var ce=_("ZodType",(e,t)=>(re.init(e,t),e.def=t,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),e.clone=(r,n)=>ot(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>Jp(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Wp(e,r,n),e.parseAsync=async(r,n)=>Gp(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Yp(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(kv(r,n)),e.superRefine=r=>e.check(zv(r)),e.overwrite=r=>e.check(Yt(r)),e.optional=()=>ge(e),e.nullable=()=>ef(e),e.nullish=()=>ge(ef(e)),e.nonoptional=r=>yv(e,r),e.array=()=>z(e),e.or=r=>de([e,r]),e.and=r=>Zo(e,r),e.transform=r=>Ji(e,df(r)),e.default=r=>hv(e,r),e.prefault=r=>_v(e,r),e.catch=r=>bv(e,r),e.pipe=r=>Ji(e,r),e.readonly=()=>Sv(e),e.describe=r=>{let n=e.clone();return xr.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return xr.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return xr.get(e);let n=e.clone();return xr.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),tf=_("_ZodString",(e,t)=>{Co.init(e,t),ce.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(Ai(...n)),e.includes=(...n)=>e.check(ji(...n)),e.startsWith=(...n)=>e.check(Mi(...n)),e.endsWith=(...n)=>e.check(Ui(...n)),e.min=(...n)=>e.check(Pr(...n)),e.max=(...n)=>e.check(No(...n)),e.length=(...n)=>e.check(jo(...n)),e.nonempty=(...n)=>e.check(Pr(1,...n)),e.lowercase=n=>e.check(Ci(n)),e.uppercase=n=>e.check(Ni(n)),e.trim=()=>e.check(Zi()),e.normalize=(...n)=>e.check(Di(...n)),e.toLowerCase=()=>e.check(qi()),e.toUpperCase=()=>e.check(Li())}),Gi=_("ZodString",(e,t)=>{Co.init(e,t),tf.init(e,t),e.email=r=>e.check(np(Dy,r)),e.url=r=>e.check(Oi(rf,r)),e.jwt=r=>e.check($p(ev,r)),e.emoji=r=>e.check(cp(Zy,r)),e.guid=r=>e.check(Ii(Qp,r)),e.uuid=r=>e.check(op(Uo,r)),e.uuidv4=r=>e.check(sp(Uo,r)),e.uuidv6=r=>e.check(ip(Uo,r)),e.uuidv7=r=>e.check(ap(Uo,r)),e.nanoid=r=>e.check(up(qy,r)),e.guid=r=>e.check(Ii(Qp,r)),e.cuid=r=>e.check(lp(Ly,r)),e.cuid2=r=>e.check(dp(Fy,r)),e.ulid=r=>e.check(pp(Vy,r)),e.base64=r=>e.check(vp(Yy,r)),e.base64url=r=>e.check(bp(Qy,r)),e.xid=r=>e.check(fp(Hy,r)),e.ksuid=r=>e.check(mp(By,r)),e.ipv4=r=>e.check(hp(Ky,r)),e.ipv6=r=>e.check(gp(Jy,r)),e.cidrv4=r=>e.check(_p(Gy,r)),e.cidrv6=r=>e.check(yp(Wy,r)),e.e164=r=>e.check(wp(Xy,r)),e.datetime=r=>e.check(Fi(r)),e.date=r=>e.check(Vi(r)),e.time=r=>e.check(Hi(r)),e.duration=r=>e.check(Bi(r))});function p(e){return tp(Gi,e)}var me=_("ZodStringFormat",(e,t)=>{le.init(e,t),tf.init(e,t)}),Dy=_("ZodEmail",(e,t)=>{id.init(e,t),me.init(e,t)});var Qp=_("ZodGUID",(e,t)=>{od.init(e,t),me.init(e,t)});var Uo=_("ZodUUID",(e,t)=>{sd.init(e,t),me.init(e,t)});var rf=_("ZodURL",(e,t)=>{ad.init(e,t),me.init(e,t)});function nf(e){return Oi(rf,e)}var Zy=_("ZodEmoji",(e,t)=>{cd.init(e,t),me.init(e,t)});var qy=_("ZodNanoID",(e,t)=>{ud.init(e,t),me.init(e,t)});var Ly=_("ZodCUID",(e,t)=>{ld.init(e,t),me.init(e,t)});var Fy=_("ZodCUID2",(e,t)=>{dd.init(e,t),me.init(e,t)});var Vy=_("ZodULID",(e,t)=>{pd.init(e,t),me.init(e,t)});var Hy=_("ZodXID",(e,t)=>{fd.init(e,t),me.init(e,t)});var By=_("ZodKSUID",(e,t)=>{md.init(e,t),me.init(e,t)});var Ky=_("ZodIPv4",(e,t)=>{vd.init(e,t),me.init(e,t)});var Jy=_("ZodIPv6",(e,t)=>{bd.init(e,t),me.init(e,t)});var Gy=_("ZodCIDRv4",(e,t)=>{wd.init(e,t),me.init(e,t)});var Wy=_("ZodCIDRv6",(e,t)=>{$d.init(e,t),me.init(e,t)});var Yy=_("ZodBase64",(e,t)=>{xd.init(e,t),me.init(e,t)});var Qy=_("ZodBase64URL",(e,t)=>{kd.init(e,t),me.init(e,t)});var Xy=_("ZodE164",(e,t)=>{zd.init(e,t),me.init(e,t)});var ev=_("ZodJWT",(e,t)=>{Pd.init(e,t),me.init(e,t)});var Do=_("ZodNumber",(e,t)=>{Ti.init(e,t),ce.init(e,t),e.gt=(n,o)=>e.check(zr(n,o)),e.gte=(n,o)=>e.check(it(n,o)),e.min=(n,o)=>e.check(it(n,o)),e.lt=(n,o)=>e.check(kr(n,o)),e.lte=(n,o)=>e.check(xt(n,o)),e.max=(n,o)=>e.check(xt(n,o)),e.int=n=>e.check(Xp(n)),e.safe=n=>e.check(Xp(n)),e.positive=n=>e.check(zr(0,n)),e.nonnegative=n=>e.check(it(0,n)),e.negative=n=>e.check(kr(0,n)),e.nonpositive=n=>e.check(xt(0,n)),e.multipleOf=(n,o)=>e.check(_n(n,o)),e.step=(n,o)=>e.check(_n(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 Q(e){return Pp(Do,e)}var tv=_("ZodNumberFormat",(e,t)=>{Td.init(e,t),Do.init(e,t)});function Xp(e){return Rp(tv,e)}var Wi=_("ZodBoolean",(e,t)=>{Rd.init(e,t),ce.init(e,t)});function oe(e){return Ep(Wi,e)}var of=_("ZodBigInt",(e,t)=>{Ed.init(e,t),ce.init(e,t),e.gte=(n,o)=>e.check(it(n,o)),e.min=(n,o)=>e.check(it(n,o)),e.gt=(n,o)=>e.check(zr(n,o)),e.gte=(n,o)=>e.check(it(n,o)),e.min=(n,o)=>e.check(it(n,o)),e.lt=(n,o)=>e.check(kr(n,o)),e.lte=(n,o)=>e.check(xt(n,o)),e.max=(n,o)=>e.check(xt(n,o)),e.positive=n=>e.check(zr(BigInt(0),n)),e.negative=n=>e.check(kr(BigInt(0),n)),e.nonpositive=n=>e.check(xt(BigInt(0),n)),e.nonnegative=n=>e.check(it(BigInt(0),n)),e.multipleOf=(n,o)=>e.check(_n(n,o));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});var rv=_("ZodNull",(e,t)=>{Id.init(e,t),ce.init(e,t)});function sf(e){return Ap(rv,e)}var nv=_("ZodAny",(e,t)=>{Od.init(e,t),ce.init(e,t)});function af(){return Cp(nv)}var ov=_("ZodUnknown",(e,t)=>{Ad.init(e,t),ce.init(e,t)});function he(){return Np(ov)}var sv=_("ZodNever",(e,t)=>{Cd.init(e,t),ce.init(e,t)});function iv(e){return jp(sv,e)}var cf=_("ZodDate",(e,t)=>{Nd.init(e,t),ce.init(e,t),e.min=(n,o)=>e.check(it(n,o)),e.max=(n,o)=>e.check(xt(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 av=_("ZodArray",(e,t)=>{jd.init(e,t),ce.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(Pr(r,n)),e.nonempty=r=>e.check(Pr(1,r)),e.max=(r,n)=>e.check(No(r,n)),e.length=(r,n)=>e.check(jo(r,n)),e.unwrap=()=>e.element});function z(e,t){return Up(av,e,t)}var uf=_("ZodObject",(e,t)=>{Md.init(e,t),ce.init(e,t),ee.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>qe(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:he()}),e.loose=()=>e.clone({...e._zod.def,catchall:he()}),e.strict=()=>e.clone({...e._zod.def,catchall:iv()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>ee.extend(e,r),e.merge=r=>ee.merge(e,r),e.pick=r=>ee.pick(e,r),e.omit=r=>ee.omit(e,r),e.partial=(...r)=>ee.partial(pf,e,r[0]),e.required=(...r)=>ee.required(ff,e,r[0])});function P(e,t){let r={type:"object",get shape(){return ee.assignProp(this,"shape",{...e}),this.shape},...ee.normalizeParams(t)};return new uf(r)}function $e(e,t){return new uf({type:"object",get shape(){return ee.assignProp(this,"shape",{...e}),this.shape},catchall:he(),...ee.normalizeParams(t)})}var lf=_("ZodUnion",(e,t)=>{Ri.init(e,t),ce.init(e,t),e.options=t.options});function de(e,t){return new lf({type:"union",options:e,...ee.normalizeParams(t)})}var cv=_("ZodDiscriminatedUnion",(e,t)=>{lf.init(e,t),Ud.init(e,t)});function Yi(e,t,r){return new cv({type:"union",options:t,discriminator:e,...ee.normalizeParams(r)})}var uv=_("ZodIntersection",(e,t)=>{Dd.init(e,t),ce.init(e,t)});function Zo(e,t){return new uv({type:"intersection",left:e,right:t})}var lv=_("ZodRecord",(e,t)=>{Zd.init(e,t),ce.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function ue(e,t,r){return new lv({type:"record",keyType:e,valueType:t,...ee.normalizeParams(r)})}var Ki=_("ZodEnum",(e,t)=>{qd.init(e,t),ce.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 Ki({...t,checks:[],...ee.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 Ki({...t,checks:[],...ee.normalizeParams(o),entries:s})}});function qe(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Ki({type:"enum",entries:r,...ee.normalizeParams(t)})}var dv=_("ZodLiteral",(e,t)=>{Ld.init(e,t),ce.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 dv({type:"literal",values:Array.isArray(e)?e:[e],...ee.normalizeParams(t)})}var pv=_("ZodTransform",(e,t)=>{Fd.init(e,t),ce.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=s=>{if(typeof s=="string")r.issues.push(ee.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(ee.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 df(e){return new pv({type:"transform",transform:e})}var pf=_("ZodOptional",(e,t)=>{Vd.init(e,t),ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ge(e){return new pf({type:"optional",innerType:e})}var fv=_("ZodNullable",(e,t)=>{Hd.init(e,t),ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ef(e){return new fv({type:"nullable",innerType:e})}var mv=_("ZodDefault",(e,t)=>{Bd.init(e,t),ce.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function hv(e,t){return new mv({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var gv=_("ZodPrefault",(e,t)=>{Kd.init(e,t),ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function _v(e,t){return new gv({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var ff=_("ZodNonOptional",(e,t)=>{Jd.init(e,t),ce.init(e,t),e.unwrap=()=>e._zod.def.innerType});function yv(e,t){return new ff({type:"nonoptional",innerType:e,...ee.normalizeParams(t)})}var vv=_("ZodCatch",(e,t)=>{Gd.init(e,t),ce.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function bv(e,t){return new vv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var wv=_("ZodPipe",(e,t)=>{Wd.init(e,t),ce.init(e,t),e.in=t.in,e.out=t.out});function Ji(e,t){return new wv({type:"pipe",in:e,out:t})}var $v=_("ZodReadonly",(e,t)=>{Yd.init(e,t),ce.init(e,t)});function Sv(e){return new $v({type:"readonly",innerType:e})}var mf=_("ZodCustom",(e,t)=>{Qd.init(e,t),ce.init(e,t)});function xv(e){let t=new Ie({check:"custom"});return t._zod.check=e,t}function hf(e,t){return Dp(mf,e??(()=>!0),t)}function kv(e,t={}){return Zp(mf,e,t)}function zv(e){let t=xv(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ee.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(ee.issue(o))}},e(r.value,r)));return t}function Qi(e,t){return Ji(df(e),t)}var gf={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 qo={};si(qo,{bigint:()=>Ev,boolean:()=>Rv,date:()=>Iv,number:()=>Tv,string:()=>Pv});function Pv(e){return rp(Gi,e)}function Tv(e){return Tp(Do,e)}function Rv(e){return Ip(Wi,e)}function Ev(e){return Op(of,e)}function Iv(e){return Mp(cf,e)}Be(Xd());var Ir="2025-11-25";var _f=[Ir,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Ct="io.modelcontextprotocol/related-task",Fo="2.0",Se=hf(e=>e!==null&&(typeof e=="object"||typeof e=="function")),yf=de([p(),Q().int()]),vf=p(),nE=$e({ttl:Q().optional(),pollInterval:Q().optional()}),Av=P({ttl:Q().optional()}),Cv=P({taskId:p()}),ea=$e({progressToken:yf.optional(),[Ct]:Cv.optional()}),Ke=P({_meta:ea.optional()}),bn=Ke.extend({task:Av.optional()}),bf=e=>bn.safeParse(e).success,xe=P({method:p(),params:Ke.loose().optional()}),Qe=P({_meta:ea.optional()}),Xe=P({method:p(),params:Qe.loose().optional()}),ke=$e({_meta:ea.optional()}),Vo=de([p(),Q().int()]),wf=P({jsonrpc:E(Fo),id:Vo,...xe.shape}).strict(),wn=e=>wf.safeParse(e).success,$f=P({jsonrpc:E(Fo),...Xe.shape}).strict(),Sf=e=>$f.safeParse(e).success,ta=P({jsonrpc:E(Fo),id:Vo,result:ke}).strict(),Qt=e=>ta.safeParse(e).success;var U;(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"})(U||(U={}));var ra=P({jsonrpc:E(Fo),id:Vo.optional(),error:P({code:Q().int(),message:p(),data:he().optional()})}).strict();var xf=e=>ra.safeParse(e).success;var Or=de([wf,$f,ta,ra]),oE=de([ta,ra]),Xt=ke.strict(),Nv=Qe.extend({requestId:Vo.optional(),reason:p().optional()}),Ho=Xe.extend({method:E("notifications/cancelled"),params:Nv}),jv=P({src:p(),mimeType:p().optional(),sizes:z(p()).optional(),theme:qe(["light","dark"]).optional()}),$n=P({icons:z(jv).optional()}),Er=P({name:p(),title:p().optional()}),kf=Er.extend({...Er.shape,...$n.shape,version:p(),websiteUrl:p().optional(),description:p().optional()}),Mv=Zo(P({applyDefaults:oe().optional()}),ue(p(),he())),Uv=Qi(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Zo(P({form:Mv.optional(),url:Se.optional()}),ue(p(),he()).optional())),Dv=$e({list:Se.optional(),cancel:Se.optional(),requests:$e({sampling:$e({createMessage:Se.optional()}).optional(),elicitation:$e({create:Se.optional()}).optional()}).optional()}),Zv=$e({list:Se.optional(),cancel:Se.optional(),requests:$e({tools:$e({call:Se.optional()}).optional()}).optional()}),qv=P({experimental:ue(p(),Se).optional(),sampling:P({context:Se.optional(),tools:Se.optional()}).optional(),elicitation:Uv.optional(),roots:P({listChanged:oe().optional()}).optional(),tasks:Dv.optional(),extensions:ue(p(),Se).optional()}),Lv=Ke.extend({protocolVersion:p(),capabilities:qv,clientInfo:kf}),Fv=xe.extend({method:E("initialize"),params:Lv});var Vv=P({experimental:ue(p(),Se).optional(),logging:Se.optional(),completions:Se.optional(),prompts:P({listChanged:oe().optional()}).optional(),resources:P({subscribe:oe().optional(),listChanged:oe().optional()}).optional(),tools:P({listChanged:oe().optional()}).optional(),tasks:Zv.optional(),extensions:ue(p(),Se).optional()}),na=ke.extend({protocolVersion:p(),capabilities:Vv,serverInfo:kf,instructions:p().optional()}),zf=Xe.extend({method:E("notifications/initialized"),params:Qe.optional()}),Pf=e=>zf.safeParse(e).success,Bo=xe.extend({method:E("ping"),params:Ke.optional()}),Hv=P({progress:Q(),total:ge(Q()),message:ge(p())}),Bv=P({...Qe.shape,...Hv.shape,progressToken:yf}),Ko=Xe.extend({method:E("notifications/progress"),params:Bv}),Kv=Ke.extend({cursor:vf.optional()}),Sn=xe.extend({params:Kv.optional()}),xn=ke.extend({nextCursor:vf.optional()}),Jv=qe(["working","input_required","completed","failed","cancelled"]),kn=P({taskId:p(),status:Jv,ttl:de([Q(),sf()]),createdAt:p(),lastUpdatedAt:p(),pollInterval:ge(Q()),statusMessage:ge(p())}),er=ke.extend({task:kn}),Gv=Qe.merge(kn),zn=Xe.extend({method:E("notifications/tasks/status"),params:Gv}),Jo=xe.extend({method:E("tasks/get"),params:Ke.extend({taskId:p()})}),Go=ke.merge(kn),Wo=xe.extend({method:E("tasks/result"),params:Ke.extend({taskId:p()})}),sE=ke.loose(),Yo=Sn.extend({method:E("tasks/list")}),Qo=xn.extend({tasks:z(kn)}),Xo=xe.extend({method:E("tasks/cancel"),params:Ke.extend({taskId:p()})}),Tf=ke.merge(kn),Rf=P({uri:p(),mimeType:ge(p()),_meta:ue(p(),he()).optional()}),Ef=Rf.extend({text:p()}),oa=p().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),If=Rf.extend({blob:oa}),Pn=qe(["user","assistant"]),Ar=P({audience:z(Pn).optional(),priority:Q().min(0).max(1).optional(),lastModified:yn.datetime({offset:!0}).optional()}),Of=P({...Er.shape,...$n.shape,uri:p(),description:ge(p()),mimeType:ge(p()),size:ge(Q()),annotations:Ar.optional(),_meta:ge($e({}))}),Wv=P({...Er.shape,...$n.shape,uriTemplate:p(),description:ge(p()),mimeType:ge(p()),annotations:Ar.optional(),_meta:ge($e({}))}),Yv=Sn.extend({method:E("resources/list")}),sa=xn.extend({resources:z(Of)}),Qv=Sn.extend({method:E("resources/templates/list")}),ia=xn.extend({resourceTemplates:z(Wv)}),aa=Ke.extend({uri:p()}),Xv=aa,eb=xe.extend({method:E("resources/read"),params:Xv}),ca=ke.extend({contents:z(de([Ef,If]))}),ua=Xe.extend({method:E("notifications/resources/list_changed"),params:Qe.optional()}),tb=aa,rb=xe.extend({method:E("resources/subscribe"),params:tb}),nb=aa,ob=xe.extend({method:E("resources/unsubscribe"),params:nb}),sb=Qe.extend({uri:p()}),ib=Xe.extend({method:E("notifications/resources/updated"),params:sb}),ab=P({name:p(),description:ge(p()),required:ge(oe())}),cb=P({...Er.shape,...$n.shape,description:ge(p()),arguments:ge(z(ab)),_meta:ge($e({}))}),ub=Sn.extend({method:E("prompts/list")}),la=xn.extend({prompts:z(cb)}),lb=Ke.extend({name:p(),arguments:ue(p(),p()).optional()}),db=xe.extend({method:E("prompts/get"),params:lb}),da=P({type:E("text"),text:p(),annotations:Ar.optional(),_meta:ue(p(),he()).optional()}),pa=P({type:E("image"),data:oa,mimeType:p(),annotations:Ar.optional(),_meta:ue(p(),he()).optional()}),fa=P({type:E("audio"),data:oa,mimeType:p(),annotations:Ar.optional(),_meta:ue(p(),he()).optional()}),pb=P({type:E("tool_use"),name:p(),id:p(),input:ue(p(),he()),_meta:ue(p(),he()).optional()}),fb=P({type:E("resource"),resource:de([Ef,If]),annotations:Ar.optional(),_meta:ue(p(),he()).optional()}),mb=Of.extend({type:E("resource_link")}),ma=de([da,pa,fa,mb,fb]),hb=P({role:Pn,content:ma}),ha=ke.extend({description:p().optional(),messages:z(hb)}),ga=Xe.extend({method:E("notifications/prompts/list_changed"),params:Qe.optional()}),gb=P({title:p().optional(),readOnlyHint:oe().optional(),destructiveHint:oe().optional(),idempotentHint:oe().optional(),openWorldHint:oe().optional()}),_b=P({taskSupport:qe(["required","optional","forbidden"]).optional()}),Af=P({...Er.shape,...$n.shape,description:p().optional(),inputSchema:P({type:E("object"),properties:ue(p(),Se).optional(),required:z(p()).optional()}).catchall(he()),outputSchema:P({type:E("object"),properties:ue(p(),Se).optional(),required:z(p()).optional()}).catchall(he()).optional(),annotations:gb.optional(),execution:_b.optional(),_meta:ue(p(),he()).optional()}),yb=Sn.extend({method:E("tools/list")}),_a=xn.extend({tools:z(Af)}),Cr=ke.extend({content:z(ma).default([]),structuredContent:ue(p(),he()).optional(),isError:oe().optional()}),iE=Cr.or(ke.extend({toolResult:he()})),vb=bn.extend({name:p(),arguments:ue(p(),he()).optional()}),bb=xe.extend({method:E("tools/call"),params:vb}),ya=Xe.extend({method:E("notifications/tools/list_changed"),params:Qe.optional()}),Cf=P({autoRefresh:oe().default(!0),debounceMs:Q().int().nonnegative().default(300)}),Nf=qe(["debug","info","notice","warning","error","critical","alert","emergency"]),wb=Ke.extend({level:Nf}),$b=xe.extend({method:E("logging/setLevel"),params:wb}),Sb=Qe.extend({level:Nf,logger:p().optional(),data:he()}),xb=Xe.extend({method:E("notifications/message"),params:Sb}),kb=P({name:p().optional()}),zb=P({hints:z(kb).optional(),costPriority:Q().min(0).max(1).optional(),speedPriority:Q().min(0).max(1).optional(),intelligencePriority:Q().min(0).max(1).optional()}),Pb=P({mode:qe(["auto","required","none"]).optional()}),Tb=P({type:E("tool_result"),toolUseId:p().describe("The unique identifier for the corresponding tool call."),content:z(ma).default([]),structuredContent:P({}).loose().optional(),isError:oe().optional(),_meta:ue(p(),he()).optional()}),Rb=Yi("type",[da,pa,fa]),Lo=Yi("type",[da,pa,fa,pb,Tb]),Eb=P({role:Pn,content:de([Lo,z(Lo)]),_meta:ue(p(),he()).optional()}),Ib=bn.extend({messages:z(Eb),modelPreferences:zb.optional(),systemPrompt:p().optional(),includeContext:qe(["none","thisServer","allServers"]).optional(),temperature:Q().optional(),maxTokens:Q().int(),stopSequences:z(p()).optional(),metadata:Se.optional(),tools:z(Af).optional(),toolChoice:Pb.optional()}),va=xe.extend({method:E("sampling/createMessage"),params:Ib}),ba=ke.extend({model:p(),stopReason:ge(qe(["endTurn","stopSequence","maxTokens"]).or(p())),role:Pn,content:Rb}),wa=ke.extend({model:p(),stopReason:ge(qe(["endTurn","stopSequence","maxTokens","toolUse"]).or(p())),role:Pn,content:de([Lo,z(Lo)])}),Ob=P({type:E("boolean"),title:p().optional(),description:p().optional(),default:oe().optional()}),Ab=P({type:E("string"),title:p().optional(),description:p().optional(),minLength:Q().optional(),maxLength:Q().optional(),format:qe(["email","uri","date","date-time"]).optional(),default:p().optional()}),Cb=P({type:qe(["number","integer"]),title:p().optional(),description:p().optional(),minimum:Q().optional(),maximum:Q().optional(),default:Q().optional()}),Nb=P({type:E("string"),title:p().optional(),description:p().optional(),enum:z(p()),default:p().optional()}),jb=P({type:E("string"),title:p().optional(),description:p().optional(),oneOf:z(P({const:p(),title:p()})),default:p().optional()}),Mb=P({type:E("string"),title:p().optional(),description:p().optional(),enum:z(p()),enumNames:z(p()).optional(),default:p().optional()}),Ub=de([Nb,jb]),Db=P({type:E("array"),title:p().optional(),description:p().optional(),minItems:Q().optional(),maxItems:Q().optional(),items:P({type:E("string"),enum:z(p())}),default:z(p()).optional()}),Zb=P({type:E("array"),title:p().optional(),description:p().optional(),minItems:Q().optional(),maxItems:Q().optional(),items:P({anyOf:z(P({const:p(),title:p()}))}),default:z(p()).optional()}),qb=de([Db,Zb]),Lb=de([Mb,Ub,qb]),Fb=de([Lb,Ob,Ab,Cb]),Vb=bn.extend({mode:E("form").optional(),message:p(),requestedSchema:P({type:E("object"),properties:ue(p(),Fb),required:z(p()).optional()})}),Hb=bn.extend({mode:E("url"),message:p(),elicitationId:p(),url:p().url()}),Bb=de([Vb,Hb]),$a=xe.extend({method:E("elicitation/create"),params:Bb}),Kb=Qe.extend({elicitationId:p()}),Jb=Xe.extend({method:E("notifications/elicitation/complete"),params:Kb}),Sa=ke.extend({action:qe(["accept","decline","cancel"]),content:Qi(e=>e===null?void 0:e,ue(p(),de([p(),Q(),oe(),z(p())])).optional())}),Gb=P({type:E("ref/resource"),uri:p()});var Wb=P({type:E("ref/prompt"),name:p()}),Yb=Ke.extend({ref:de([Wb,Gb]),argument:P({name:p(),value:p()}),context:P({arguments:ue(p(),p()).optional()}).optional()}),Qb=xe.extend({method:E("completion/complete"),params:Yb});var xa=ke.extend({completion:$e({values:z(p()).max(100),total:ge(Q().int()),hasMore:ge(oe())})}),Xb=P({uri:p().startsWith("file://"),name:p().optional(),_meta:ue(p(),he()).optional()}),ew=xe.extend({method:E("roots/list"),params:Ke.optional()}),tw=ke.extend({roots:z(Xb)}),rw=Xe.extend({method:E("notifications/roots/list_changed"),params:Qe.optional()}),aE=de([Bo,Fv,Qb,$b,db,ub,Yv,Qv,eb,rb,ob,bb,yb,Jo,Wo,Yo,Xo]),cE=de([Ho,Ko,zf,rw,zn]),uE=de([Xt,ba,wa,Sa,tw,Go,Qo,er]),lE=de([Bo,va,$a,ew,Jo,Wo,Yo,Xo]),dE=de([Ho,Ko,xb,ib,ua,ya,ga,zn,Jb]),pE=de([Xt,na,xa,ha,la,sa,ia,ca,Cr,_a,Go,Qo,er]),j=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===U.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Xi(o.elicitations,r)}return new e(t,r,n)}},Xi=class extends j{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(U.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function Nt(e){return e==="completed"||e==="failed"||e==="cancelled"}var nw=Symbol("Let zodToJsonSchema decide on which parser to use");var HE=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function ka(e){let r=Mo(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=qp(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function za(e,t){let r=at(e,t);if(!r.success)throw r.error;return r.data}var uw=6e4,es=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(Ho,r=>{this._oncancel(r)}),this.setNotificationHandler(Ko,r=>{this._onprogress(r)}),this.setRequestHandler(Bo,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Jo,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new j(U.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Wo,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 j(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 j(U.InvalidParams,`Task not found: ${s}`);if(!Nt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Nt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[Ct]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Yo,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 j(U.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Xo,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new j(U.InvalidParams,`Task not found: ${r.params.taskId}`);if(Nt(o.status))throw new j(U.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 j(U.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof j?o:new j(U.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),j.fromError(U.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),Qt(s)||xf(s)?this._onresponse(s):wn(s)?this._onrequest(s,i):Sf(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=j.fromError(U.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?.[Ct]?.taskId;if(n===void 0){let u={jsonrpc:"2.0",id:t.id,error:{code:U.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=bf(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 j(U.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:U.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),Qt(t))n(t);else{let i=new j(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(Qt(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),Qt(t))o(t);else{let i=j.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 j?i:new j(U.InternalError,String(i))}}return}let s;try{let i=await this.request(t,er,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new j(U.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Nt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new j(U.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new j(U.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 j?i:new j(U.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=$=>{u($)};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($){d($);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||{},[Ct]:c}});let h=$=>{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($)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(T=>this._onerror(new Error(`Failed to send cancellation: ${T}`)));let w=$ instanceof j?$:new j(U.RequestTimeout,String($));u(w)};this._responseHandlers.set(f,$=>{if(!n?.signal?.aborted){if($ instanceof Error)return u($);try{let w=at(r,$.result);w.success?l(w.data):u(w.error)}catch(w){u(w)}}}),n?.signal?.addEventListener("abort",()=>{h(n?.signal?.reason)});let g=n?.timeout??uw,y=()=>h(j.fromError(U.RequestTimeout,"Request timed out",{timeout:g}));this._setupTimeout(f,g,n?.maxTotalTimeout,y,n?.resetTimeoutOnProgress??!1);let S=c?.taskId;if(S){let $=w=>{let T=this._responseHandlers.get(f);T?T(w):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,$),this._enqueueTaskMessage(S,{type:"request",message:m,timestamp:Date.now()}).catch(w=>{this._cleanupTimeout(f),u(w)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch($=>{this._cleanupTimeout(f),u($)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Go,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},Qo,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Tf,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||{},[Ct]: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||{},[Ct]: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||{},[Ct]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=ka(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=za(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=ka(t);this._notificationHandlers.set(n,o=>{let s=za(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"&&wn(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new j(U.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 j(U.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new j(U.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 j(U.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=zn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Nt(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 j(U.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Nt(a.status))throw new j(U.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=zn.parse({method:"notifications/tasks/status",params:c});await this.notification(l),Nt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function jf(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];jf(i)&&jf(s)?r[o]={...i,...s}:r[o]=s}return r}var Tg=Yu(pu(),1),Rg=Yu(Pg(),1);function fz(){let e=new Tg.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Rg.default)(e),e}var Ns=class{constructor(t){this._ajv=t??fz()}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 js=class{constructor(t){this._client=t}async*callToolStream(t,r=Cr,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 j(U.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 j(U.InvalidParams,`Structured content does not match the tool's output schema: ${u.errorMessage}`)};return}}catch(u){if(u instanceof j){yield{type:"error",error:u};return}yield{type:"error",error:new j(U.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 Eg(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 Ig(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 Ms(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&&Ms(s,r[o])}}if(Array.isArray(e.anyOf))for(let r of e.anyOf)typeof r!="boolean"&&Ms(r,t);if(Array.isArray(e.oneOf))for(let r of e.oneOf)typeof r!="boolean"&&Ms(r,t)}}function mz(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 Us=class extends es{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 Ns,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(t){t.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",ya,t.tools,async()=>(await this.listTools()).tools),t.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",ga,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",ua,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new js(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=Mo(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(Rr(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=at($a,c);if(!u.success){let $=u.error instanceof Error?u.error.message:String(u.error);throw new j(U.InvalidParams,`Invalid elicitation request: ${$}`)}let{params:d}=u.data;d.mode=d.mode??"form";let{supportsFormMode:f,supportsUrlMode:m}=mz(this._capabilities.elicitation);if(d.mode==="form"&&!f)throw new j(U.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!m)throw new j(U.InvalidParams,"Client does not support URL-mode elicitation requests");let h=await Promise.resolve(r(c,l));if(d.task){let $=at(er,h);if(!$.success){let w=$.error instanceof Error?$.error.message:String($.error);throw new j(U.InvalidParams,`Invalid task creation result: ${w}`)}return $.data}let g=at(Sa,h);if(!g.success){let $=g.error instanceof Error?g.error.message:String(g.error);throw new j(U.InvalidParams,`Invalid elicitation result: ${$}`)}let y=g.data,S=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&y.action==="accept"&&y.content&&S&&this._capabilities.elicitation?.form?.applyDefaults)try{Ms(S,y.content)}catch{}return y};return super.setRequestHandler(t,a)}if(i==="sampling/createMessage"){let a=async(c,l)=>{let u=at(va,c);if(!u.success){let y=u.error instanceof Error?u.error.message:String(u.error);throw new j(U.InvalidParams,`Invalid sampling request: ${y}`)}let{params:d}=u.data,f=await Promise.resolve(r(c,l));if(d.task){let y=at(er,f);if(!y.success){let S=y.error instanceof Error?y.error.message:String(y.error);throw new j(U.InvalidParams,`Invalid task creation result: ${S}`)}return y.data}let h=d.tools||d.toolChoice?wa:ba,g=at(h,f);if(!g.success){let y=g.error instanceof Error?g.error.message:String(g.error);throw new j(U.InvalidParams,`Invalid sampling result: ${y}`)}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:Ir,capabilities:this._capabilities,clientInfo:this._clientInfo}},na,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!_f.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){Eg(this._serverCapabilities?.tasks?.requests,t,"Server")}assertTaskHandlerCapability(t){this._capabilities&&Ig(this._capabilities.tasks?.requests,t,"Client")}async ping(t){return this.request({method:"ping"},Xt,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},xa,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},Xt,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},ha,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},la,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},sa,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},ia,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},ca,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},Xt,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},Xt,r)}async callTool(t,r=Cr,n){if(this.isToolTaskRequired(t.name))throw new j(U.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 j(U.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 j(U.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof j?i:new j(U.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},_a,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,o){let s=Cf.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 Ds(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function Og(e=fetch,t){return t?async(r,n)=>{let o={...t,...n,headers:n?.headers?{...Ds(t.headers),...Ds(n.headers)}:t.headers};return e(r,o)}:e}var bu;bu=globalThis.crypto?.webcrypto??globalThis.crypto??import("node:crypto").then(e=>e.webcrypto);async function hz(e){return(await bu).getRandomValues(new Uint8Array(e))}async function gz(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length,n="";for(;n.length<e;){let o=await hz(e-n.length);for(let s of o)s<r&&(n+=t[s%t.length])}return n}async function _z(e){return await gz(e)}async function yz(e){let t=await(await bu).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function wu(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await _z(e),r=await yz(t);return{code_verifier:t,code_challenge:r}}var Re=nf().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:gf.custom,message:"URL must be parseable",fatal:!0}),ii}).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"}),Cg=$e({resource:p().url(),authorization_servers:z(Re).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:oe().optional(),authorization_details_types_supported:z(p()).optional(),dpop_signing_alg_values_supported:z(p()).optional(),dpop_bound_access_tokens_required:oe().optional()}),$u=$e({issuer:p(),authorization_endpoint:Re,token_endpoint:Re,registration_endpoint:Re.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:Re.optional(),revocation_endpoint:Re.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:oe().optional()}),vz=$e({issuer:p(),authorization_endpoint:Re,token_endpoint:Re,userinfo_endpoint:Re.optional(),jwks_uri:Re,registration_endpoint:Re.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:oe().optional(),request_parameter_supported:oe().optional(),request_uri_parameter_supported:oe().optional(),require_request_uri_registration:oe().optional(),op_policy_uri:Re.optional(),op_tos_uri:Re.optional(),client_id_metadata_document_supported:oe().optional()}),Ng=P({...vz.shape,...$u.pick({code_challenge_methods_supported:!0}).shape}),jg=P({access_token:p(),id_token:p().optional(),token_type:p(),expires_in:qo.number().optional(),scope:p().optional(),refresh_token:p().optional()}).strip(),Mg=P({error:p(),error_description:p().optional(),error_uri:p().optional()}),Ag=Re.optional().or(E("").transform(()=>{})),bz=P({redirect_uris:z(Re),token_endpoint_auth_method:p().optional(),grant_types:z(p()).optional(),response_types:z(p()).optional(),client_name:p().optional(),client_uri:Re.optional(),logo_uri:Ag,scope:p().optional(),contacts:z(p()).optional(),tos_uri:Ag,policy_uri:p().optional(),jwks_uri:Re.optional(),jwks:af().optional(),software_id:p().optional(),software_version:p().optional(),software_statement:p().optional()}).strip(),wz=P({client_id:p(),client_secret:p().optional(),client_id_issued_at:Q().optional(),client_secret_expires_at:Q().optional()}).strip(),Ug=bz.merge(wz),_1=P({error:p(),error_description:p().optional()}).strip(),y1=P({token:p(),token_type_hint:p().optional()}).strip();function Dg(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function Zg({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 be=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}},oo=class extends be{};oo.errorCode="invalid_request";var pr=class extends be{};pr.errorCode="invalid_client";var fr=class extends be{};fr.errorCode="invalid_grant";var mr=class extends be{};mr.errorCode="unauthorized_client";var so=class extends be{};so.errorCode="unsupported_grant_type";var io=class extends be{};io.errorCode="invalid_scope";var ao=class extends be{};ao.errorCode="access_denied";var Et=class extends be{};Et.errorCode="server_error";var co=class extends be{};co.errorCode="temporarily_unavailable";var uo=class extends be{};uo.errorCode="unsupported_response_type";var lo=class extends be{};lo.errorCode="unsupported_token_type";var po=class extends be{};po.errorCode="invalid_token";var fo=class extends be{};fo.errorCode="method_not_allowed";var mo=class extends be{};mo.errorCode="too_many_requests";var hr=class extends be{};hr.errorCode="invalid_client_metadata";var ho=class extends be{};ho.errorCode="insufficient_scope";var go=class extends be{};go.errorCode="invalid_target";var qg={[oo.errorCode]:oo,[pr.errorCode]:pr,[fr.errorCode]:fr,[mr.errorCode]:mr,[so.errorCode]:so,[io.errorCode]:io,[ao.errorCode]:ao,[Et.errorCode]:Et,[co.errorCode]:co,[uo.errorCode]:uo,[lo.errorCode]:lo,[po.errorCode]:po,[fo.errorCode]:fo,[mo.errorCode]:mo,[hr.errorCode]:hr,[ho.errorCode]:ho,[go.errorCode]:go};var It=class extends Error{constructor(t){super(t??"Unauthorized")}};function $z(e){return["client_secret_basic","client_secret_post","none"].includes(e)}var Su="code",xu="S256";function Sz(e,t){let r=e.client_secret!==void 0;return"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&$z(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 xz(e,t,r,n){let{client_id:o,client_secret:s}=t;switch(e){case"client_secret_basic":kz(o,s,r);return;case"client_secret_post":zz(o,s,n);return;case"none":Pz(o,n);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function kz(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 zz(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}function Pz(e,t){t.set("client_id",e)}async function Fg(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=qg[o]||Et;return new a(s||"",i)}catch(n){let o=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${n}. Raw body: ${r}`;return new Et(o)}}async function _o(e,t){try{return await ku(e,t)}catch(r){if(r instanceof pr||r instanceof mr)return await e.invalidateCredentials?.("all"),await ku(e,t);if(r instanceof fr)return await e.invalidateCredentials?.("tokens"),await ku(e,t);throw r}}async function ku(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 Hg(c,{fetchFn:s}),!a)try{a=await Vg(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 w=await Cz(t,{resourceMetadataUrl:u,fetchFn:s});c=w.authorizationServerUrl,l=w.authorizationServerMetadata,a=w.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:u?.toString(),resourceMetadata:a,authorizationServerMetadata:l})}let d=await Rz(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 w=l?.client_id_metadata_document_supported===!0,T=e.clientMetadataUrl;if(T&&!Tz(T))throw new hr(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${T}`);if(w&&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 Dz(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 w=await Uz(e,c,{metadata:l,resource:d,authorizationCode:r,fetchFn:s});return await e.saveTokens(w),"AUTHORIZED"}let g=await e.tokens();if(g?.refresh_token)try{let w=await Mz(c,{metadata:l,clientInformation:m,refreshToken:g.refresh_token,resource:d,addClientAuthentication:e.addClientAuthentication,fetchFn:s});return await e.saveTokens(w),"AUTHORIZED"}catch(w){if(!(!(w instanceof be)||w instanceof Et))throw w}let y=e.state?await e.state():void 0,{authorizationUrl:S,codeVerifier:$}=await Nz(c,{metadata:l,clientInformation:m,state:y,redirectUrl:e.redirectUrl,scope:f,resource:d});return await e.saveCodeVerifier($),await e.redirectToAuthorization(S),"REDIRECT"}function Tz(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="https:"&&t.pathname!=="/"}catch{return!1}}async function Rz(e,t,r){let n=Dg(e);if(t.validateResourceURL)return await t.validateResourceURL(n,r?.resource);if(r){if(!Zg({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 Pu(e){let t=e.headers.get("WWW-Authenticate");if(!t)return{};let[r,n]=t.split(" ");if(r.toLowerCase()!=="bearer"||!n)return{};let o=zu(e,"resource_metadata")||void 0,s;if(o)try{s=new URL(o)}catch{}let i=zu(e,"scope")||void 0,a=zu(e,"error")||void 0;return{resourceMetadataUrl:s,scope:i,error:a}}function zu(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 Vg(e,t,r=fetch){let n=await Oz(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 Cg.parse(await n.json())}async function Tu(e,t,r=fetch){try{return await r(e,{headers:t})}catch(n){if(n instanceof TypeError)return t?Tu(e,void 0,r):void 0;throw n}}function Ez(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function Lg(e,t,r=fetch){return await Tu(e,{"MCP-Protocol-Version":t},r)}function Iz(e,t){return!e||e.status>=400&&e.status<500&&t!=="/"}async function Oz(e,t,r,n){let o=new URL(e),s=n?.protocolVersion??Ir,i;if(n?.metadataUrl)i=new URL(n.metadataUrl);else{let c=Ez(t,o.pathname);i=new URL(c,n?.metadataServerUrl??o),i.search=o.search}let a=await Lg(i,s,r);if(!n?.metadataUrl&&Iz(a,o.pathname)){let c=new URL(`/.well-known/${t}`,o);a=await Lg(c,s,r)}return a}function Az(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 Hg(e,{fetchFn:t=fetch,protocolVersion:r=Ir}={}){let n={"MCP-Protocol-Version":r,Accept:"application/json"},o=Az(e);for(let{url:s,type:i}of o){let a=await Tu(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"?$u.parse(await a.json()):Ng.parse(await a.json())}}}async function Cz(e,t){let r,n;try{r=await Vg(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 Hg(n,{fetchFn:t?.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:o,resourceMetadata:r}}async function Nz(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(Su))throw new Error(`Incompatible auth server: does not support response type ${Su}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(xu))throw new Error(`Incompatible auth server: does not support code challenge method ${xu}`)}else a=new URL("/authorize",e);let c=await wu(),l=c.code_verifier,u=c.code_challenge;return a.searchParams.set("response_type",Su),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",u),a.searchParams.set("code_challenge_method",xu),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 jz(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 u=t?.token_endpoint_auth_methods_supported??[],d=Sz(n,u);xz(d,n,c,r)}let l=await(i??fetch)(a,{method:"POST",headers:c,body:r});if(!l.ok)throw await Fg(l);return jg.parse(await l.json())}async function Mz(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 Uz(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=jz(o,l,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 Dz(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 Fg(i);return Ug.parse(await i.json())}var yo=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}},Kg=10,Zz=13,gr=32;function Ru(e){}function Wg(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=Ru,onError:r=Ru,onRetry:n=Ru,onComment:o,maxBufferSize:s}=e,i=[],a=0,c=!0,l,u="",d=0,f,m=!1;function h(v){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,v.charCodeAt(0)===239&&v.charCodeAt(1)===187&&v.charCodeAt(2)===191&&(v=v.slice(3))),i.length===0){let B=y(v);B!==""&&(i.push(B),a=B.length),g();return}if(v.indexOf(`
|
|
36
|
-
`)===-1&&v.indexOf("\r")===-1){i.push(v),a+=v.length,g();return}i.push(v);let x=i.join("");i.length=0,a=0;let
|
|
37
|
-
`,x);for(;
|
|
38
|
-
`,x);continue}let
|
|
39
|
-
`,x);continue}
|
|
40
|
-
${
|
|
41
|
-
`,x)}return v.slice(x)}for(;x<v.length;){let
|
|
42
|
-
`,x),
|
|
43
|
-
${
|
|
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 yo(`Invalid \`retry\` value: "${x}"`,{type:"invalid-retry",value:x,line:A}));break;default:r(new yo(`Unknown field "${v.length>20?`${v.slice(0,20)}\u2026`:v}"`,{type:"unknown-field",field:v,value:x,line:A}));break}}function w(){d>0&&t({id:l,event:f,data:u}),l=void 0,u="",d=0,f=void 0}function T(v={}){if(v.consume&&i.length>0){let x=i.join("");S(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 Jg(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 Gg(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 Zs=class extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:o}={}){let s;super({start(i){s=Wg({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 qz={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},Vt=class extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}},Xr=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=Og(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??qz}async _authThenStart(){if(!this._authProvider)throw new It("No auth provider");let t;try{t=await _o(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 It;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=Ds(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 Vt(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 Zs({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=Or.parse(JSON.parse(m.data));Qt(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 It("No auth provider");if(await _o(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new It("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:wn(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 Vt(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:m,scope:h}=Pu(a);if(this._resourceMetadataUrl=m,this._scope=h,await _o(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new It;return this._hasCompletedAuthFlow=!0,this.send(t)}if(a.status===403&&this._authProvider){let{resourceMetadataUrl:m,scope:h,error:g}=Pu(a);if(g==="insufficient_scope"){let y=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===y)throw new Vt(403,"Server returned 403 after trying upscoping");if(h&&(this._scope=h),m&&(this._resourceMetadataUrl=m),this._lastUpscopingHeader=y??void 0,await _o(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new It;return this.send(t)}}throw new Vt(a.status,`Error POSTing to endpoint: ${f}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),Pf(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=>Or.parse(h)):[Or.parse(f)];for(let h of m)this.onmessage?.(h)}else throw await a.body?.cancel(),new Vt(-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 Vt(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 Ne from"node:fs";import{randomBytes as Lz}from"node:crypto";import{homedir as Qg}from"node:os";import{resolve as Ls,join as Eu,dirname as Iu,basename as Fz}from"node:path";var vo=["owner","shared","open"],en={brokerUrl:"wss://broker1.ours.network",port:3050,stateDir:Ls(Qg(),".ours"),gcIntervalMs:36e5,autoStart:!1,apiVisibility:"owner"};function bo(){return process.env.OURS_CONFIG??Eu(Qg(),".ours","config.json")}function Vz(){let e;try{e=Ne.readFileSync(bo(),"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=Ls(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"&&vo.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 Hz(){let e=process.env.OURS_API_VISIBILITY?.trim().toLowerCase();return e&&vo.includes(e)?e:void 0}function Bz(e){let t=process.env[e];if(t!==void 0)return t==="1"||t.toLowerCase()==="true"}function Yg(e){let t=process.env[e];if(t===void 0)return;let r=parseInt(t,10);return Number.isNaN(r)?void 0:r}function Ou(){let e=Vz();return{brokerUrl:process.env.OURS_BROKER_URL??e.brokerUrl??en.brokerUrl,port:Yg("OURS_PORT")??e.port??en.port,stateDir:Ls(process.env.OURS_STATE_DIR??e.stateDir??en.stateDir),gcIntervalMs:Yg("OURS_GC_INTERVAL_MS")??e.gcIntervalMs??en.gcIntervalMs,autoStart:Bz("OURS_AUTOSTART")??e.autoStart??en.autoStart,apiVisibility:Hz()??e.apiVisibility??en.apiVisibility,apiToken:process.env.OURS_API_TOKEN?.trim()||e.apiToken,stt:Kz(e.stt)}}function Kz(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 Jz="daemon-token";function Gz(e){return Eu(e.stateDir,Jz)}function Au(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=Gz(e);try{let i=Ne.readFileSync(o,"utf8").trim();if(i)return{token:i,source:"file"}}catch{}if(!t.generate)return null;let s=Lz(32).toString("hex");try{Ne.mkdirSync(Iu(o),{recursive:!0}),Ne.writeFileSync(o,s+`
|
|
45
|
-
`,{mode:384}),
|
|
46
|
-
`,{mode:384});try{
|
|
47
|
-
`),o}import
|
|
48
|
-
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),
|
|
49
|
-
`}var
|
|
50
|
-
`)},...r.content??[]],!0}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
`);
|
|
56
|
-
`)
|
|
57
|
-
`)})
|
|
58
|
-
`),
|
|
59
|
-
`),Je.forEach((s,i)=>{Ge(e,` ${i+1}. ${s.label} \u2014 ${s.detail}
|
|
60
|
-
`)});let o=Gs(e,`Select 1-${Je.length}: `);if(!/^[1-4]$/.test(o))throw new Ee("cancel");return Je[Number(o)-1].value}}function jP(e){let t=e.stt;return t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}async function $_(e){let t=e.env??process.env,r=e.stdout??(i=>process.stdout.write(i)),n=(i="")=>r(`${i}
|
|
61
|
-
`),o=e.daemonState??"stopped",s=null;try{let i;try{i=zP(e.configFile)}catch{return n(`voice setup: ${e.configFile} is not valid JSON; no changes made.`),1}let a=jP(i),c=wo(m_(a,t)),l=t.OURS_STT_API_KEY?.trim()?"environment":a.apiKey?.trim()?"config":"missing";if(s=t.OURS_ASSUME_YES?null:OP(),n(`ours-mcp voice-setup \u2014 ${e.configFile}`),c.ready){if(n(`voice transcription is already ready (${c.provider}; API key from ${l}).`),s===null)return 0;if(!CP(s,"Change the current voice settings?",!1))return n("kept the current voice settings; no changes made."),0}else if(n("Voice transcription is not ready. This command keeps the provider key hidden."),s===null)return n("No interactive terminal is available; no changes made."),n("Run `ours-mcp voice-setup` in a terminal, or configure OURS_STT_* environment values."),0;n("");let u=String(t.OURS_STT_PROVIDER||a.provider||"").trim().toLowerCase(),d=NP(s,u),f=String(t.OURS_STT_MODEL||a.model||"").trim(),m=String(t.OURS_STT_BASE_URL||a.baseUrl||"").trim(),h=String(a.custom?.url||"").trim();d==="openai-compatible"?(m=bt(s,`Provider /v1 base URL${m?` [${m}]`:""}: `,m),f=bt(s,`Model name (sent verbatim)${f?` [${f}]`:""}: `,f)):d==="elevenlabs"?(f=bt(s,`ElevenLabs model id${f?` [${f}]`:""}: `,f),m=bt(s,`Custom base URL (Enter for provider default)${m?` [${m}]`:""}: `,m)):d==="deepgram"?(f=bt(s,`Model (optional; Enter for provider default)${f?` [${f}]`:""}: `,f),m=bt(s,`Custom base URL (optional)${m?` [${m}]`:""}: `,m)):(h=bt(s,`Full transcription endpoint URL${h?` [${h}]`:""}: `,h),f=bt(s,`Model (optional unless URL contains {model})${f?` [${f}]`:""}: `,f));let g=t.OURS_STT_API_KEY?.trim(),y=String(a.apiKey||"").trim();if(g)n("API key: using OURS_STT_API_KEY from the environment; it will not be copied to config.");else{let v=y?"Provider API key [configured; Enter keeps it]: ":"Provider API key (input hidden): ",x;try{x=bt(s,v,y,!0)}catch(B){if(!(B instanceof Ee)||B.reason!=="unavailable")throw B;if(Ge(s,`
|
|
34
|
+
path: iss.path ? [${Mt($)}, ...iss.path] : [${Mt($)}]
|
|
35
|
+
})));`),f.write(`newResult[${Mt($)}] = ${b}.value`)}f.write("payload.value = newResult;"),f.write("return payload;");let S=f.compile();return($,b)=>S(d,$,b)},o,s=ur,i=!lo.jitless,c=i&&Gs.value,u=t.catchall,l;e._zod.parse=(d,f)=>{l??(l=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=l.shape;for(let T of l.keys){let v=b[T],x=v._zod.run({value:m[T],issues:[]},f),O=v._zod.optin==="optional"&&v._zod.optout==="optional";x instanceof Promise?h.push(x.then(J=>O?Al(J,d,T,m):vo(J,d,T))):O?Al(x,d,T,m):vo(x,d,T)}}if(!u)return h.length?Promise.all(h).then(()=>d):d;let g=[],y=l.keySet,S=u._zod,$=S.def.type;for(let b of Object.keys(m)){if(y.has(b))continue;if($==="never"){g.push(b);continue}let T=S.run({value:m[b],issues:[]},f);T instanceof Promise?h.push(T.then(v=>vo(v,d,b))):vo(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 Nl(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=>Ke(s,n,je())))}),t}var di=_("$ZodUnion",(e,t)=>{G.init(e,t),ee(e._zod,"optin",()=>t.options.some(r=>r._zod.optin==="optional")?"optional":void 0),ee(e._zod,"optout",()=>t.options.some(r=>r._zod.optout==="optional")?"optional":void 0),ee(e._zod,"values",()=>{if(t.options.every(r=>r._zod.values))return new Set(t.options.flatMap(r=>Array.from(r._zod.values)))}),ee(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=>Yr(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=>Nl(i,r,e,n)):Nl(s,r,e,n)}}),Sd=_("$ZodDiscriminatedUnion",(e,t)=>{di.init(e,t);let r=e._zod.parse;ee(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=Gr(()=>{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(!ur(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)}}),$d=_("$ZodIntersection",(e,t)=>{G.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])=>jl(r,c,u)):jl(r,s,i)}});function ui(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(lr(e)&&lr(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=ui(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=ui(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 jl(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),qt(e))return e;let n=ui(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 xd=_("$ZodRecord",(e,t)=>{G.init(e,t),e._zod.parse=(r,n)=>{let o=r.value;if(!lr(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(...tt(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...tt(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=>Ke(u,n,je())),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(...tt(i,u.issues)),r.value[a.value]=u.value})):(c.issues.length&&r.issues.push(...tt(i,c.issues)),r.value[a.value]=c.value)}}return s.length?Promise.all(s).then(()=>r):r}});var kd=_("$ZodEnum",(e,t)=>{G.init(e,t);let r=Hs(t.entries);e._zod.values=new Set(r),e._zod.pattern=new RegExp(`^(${r.filter(n=>Ws.has(typeof n)).map(n=>typeof n=="string"?bt(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}}),zd=_("$ZodLiteral",(e,t)=>{G.init(e,t),e._zod.values=new Set(t.values),e._zod.pattern=new RegExp(`^(${t.values.map(r=>typeof r=="string"?bt(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 Pd=_("$ZodTransform",(e,t)=>{G.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 ut;return r.value=o,r}}),Td=_("$ZodOptional",(e,t)=>{G.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ee(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ee(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Yr(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)}),Rd=_("$ZodNullable",(e,t)=>{G.init(e,t),ee(e._zod,"optin",()=>t.innerType._zod.optin),ee(e._zod,"optout",()=>t.innerType._zod.optout),ee(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${Yr(r.source)}|null)$`):void 0}),ee(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)}),Ed=_("$ZodDefault",(e,t)=>{G.init(e,t),e._zod.optin="optional",ee(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=>Ml(s,t)):Ml(o,t)}});function Ml(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Id=_("$ZodPrefault",(e,t)=>{G.init(e,t),e._zod.optin="optional",ee(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))}),Od=_("$ZodNonOptional",(e,t)=>{G.init(e,t),ee(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=>ql(s,e)):ql(o,e)}});function ql(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 Cd=_("$ZodCatch",(e,t)=>{G.init(e,t),e._zod.optin="optional",ee(e._zod,"optout",()=>t.innerType._zod.optout),ee(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=>Ke(i,n,je()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=t.catchValue({...r,error:{issues:o.issues.map(s=>Ke(s,n,je()))},input:r.value}),r.issues=[]),r)}});var Ad=_("$ZodPipe",(e,t)=>{G.init(e,t),ee(e._zod,"values",()=>t.in._zod.values),ee(e._zod,"optin",()=>t.in._zod.optin),ee(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=>Ul(s,t,n)):Ul(o,t,n)}});function Ul(e,t,r){return qt(e)?e:t.out._zod.run({value:e.value,issues:e.issues},r)}var Nd=_("$ZodReadonly",(e,t)=>{G.init(e,t),ee(e._zod,"propValues",()=>t.innerType._zod.propValues),ee(e._zod,"values",()=>t.innerType._zod.values),ee(e._zod,"optin",()=>t.innerType._zod.optin),ee(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(Dl):Dl(o)}});function Dl(e){return e.value=Object.freeze(e.value),e}var jd=_("$ZodCustom",(e,t)=>{$e.init(e,t),G.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=>Zl(s,r,n,e));Zl(o,r,n,e)}});function Zl(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(Qs(o))}}var Q_=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},ey=()=>{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 ${Q_(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${mo(n.values[0])}`:`Invalid option: expected one of ${po(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":""}: ${po(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 Md(){return{localeError:ey()}}var ty=Symbol("ZodOutput"),ry=Symbol("ZodInput"),pi=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 qd(){return new pi}var dr=qd();function Ud(e,t){return new e({type:"string",...I(t)})}function Dd(e,t){return new e({type:"string",coerce:!0,...I(t)})}function Zd(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...I(t)})}function fi(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...I(t)})}function Ld(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...I(t)})}function Fd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...I(t)})}function Vd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...I(t)})}function Hd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...I(t)})}function mi(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...I(t)})}function Bd(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...I(t)})}function Kd(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...I(t)})}function Jd(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...I(t)})}function Gd(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...I(t)})}function Wd(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...I(t)})}function Yd(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...I(t)})}function Xd(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...I(t)})}function Qd(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...I(t)})}function ep(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...I(t)})}function tp(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...I(t)})}function rp(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...I(t)})}function np(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...I(t)})}function op(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...I(t)})}function sp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...I(t)})}function ip(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...I(t)})}function ap(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...I(t)})}function cp(e,t){return new e({type:"string",format:"date",check:"string_format",...I(t)})}function up(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...I(t)})}function lp(e,t){return new e({type:"string",format:"duration",check:"string_format",...I(t)})}function dp(e,t){return new e({type:"number",checks:[],...I(t)})}function pp(e,t){return new e({type:"number",coerce:!0,checks:[],...I(t)})}function fp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...I(t)})}function mp(e,t){return new e({type:"boolean",...I(t)})}function hp(e,t){return new e({type:"boolean",coerce:!0,...I(t)})}function gp(e,t){return new e({type:"bigint",coerce:!0,...I(t)})}function _p(e,t){return new e({type:"null",...I(t)})}function yp(e){return new e({type:"any"})}function vp(e){return new e({type:"unknown"})}function wp(e,t){return new e({type:"never",...I(t)})}function bp(e,t){return new e({type:"date",coerce:!0,...I(t)})}function pr(e,t){return new ai({check:"less_than",...I(t),value:e,inclusive:!1})}function lt(e,t){return new ai({check:"less_than",...I(t),value:e,inclusive:!0})}function fr(e,t){return new ci({check:"greater_than",...I(t),value:e,inclusive:!1})}function Je(e,t){return new ci({check:"greater_than",...I(t),value:e,inclusive:!0})}function tn(e,t){return new vl({check:"multiple_of",...I(t),value:e})}function bo(e,t){return new bl({check:"max_length",...I(t),maximum:e})}function mr(e,t){return new Sl({check:"min_length",...I(t),minimum:e})}function So(e,t){return new $l({check:"length_equals",...I(t),length:e})}function hi(e,t){return new xl({check:"string_format",format:"regex",...I(t),pattern:e})}function gi(e){return new kl({check:"string_format",format:"lowercase",...I(e)})}function _i(e){return new zl({check:"string_format",format:"uppercase",...I(e)})}function yi(e,t){return new Pl({check:"string_format",format:"includes",...I(t),includes:e})}function vi(e,t){return new Tl({check:"string_format",format:"starts_with",...I(t),prefix:e})}function wi(e,t){return new Rl({check:"string_format",format:"ends_with",...I(t),suffix:e})}function Ut(e){return new El({check:"overwrite",tx:e})}function bi(e){return Ut(t=>t.normalize(e))}function Si(){return Ut(e=>e.trim())}function $i(){return Ut(e=>e.toLowerCase())}function xi(){return Ut(e=>e.toUpperCase())}function Sp(e,t,r){return new e({type:"array",element:t,...I(r)})}function $p(e,t,r){let n=I(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function xp(e,t,r){return new e({type:"custom",check:"custom",fn:t,...I(r)})}function gr(e){return!!e._zod}function Ge(e,t){return gr(e)?Qr(e,t):e.safeParse(t)}function $o(e){if(!e)return;let t;if(gr(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function kp(e){if(gr(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 rn={};Zs(rn,{ZodISODate:()=>Pp,ZodISODateTime:()=>zp,ZodISODuration:()=>Rp,ZodISOTime:()=>Tp,date:()=>zi,datetime:()=>ki,duration:()=>Ti,time:()=>Pi});var zp=_("ZodISODateTime",(e,t)=>{Ql.init(e,t),ce.init(e,t)});function ki(e){return ap(zp,e)}var Pp=_("ZodISODate",(e,t)=>{ed.init(e,t),ce.init(e,t)});function zi(e){return cp(Pp,e)}var Tp=_("ZodISOTime",(e,t)=>{td.init(e,t),ce.init(e,t)});function Pi(e){return up(Tp,e)}var Rp=_("ZodISODuration",(e,t)=>{rd.init(e,t),ce.init(e,t)});function Ti(e){return lp(Rp,e)}var Ip=(e,t)=>{ho.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>ri(e,r)},flatten:{value:r=>ti(e,r)},addIssue:{value:r=>e.issues.push(r)},addIssues:{value:r=>e.issues.push(...r)},isEmpty:{get(){return e.issues.length===0}}})},PT=_("ZodError",Ip),nn=_("ZodError",Ip,{Parent:Error});var Op=Du(nn),Cp=Zu(nn),Ap=ni(nn),Np=oi(nn);var te=_("ZodType",(e,t)=>(G.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)=>Be(e,r,n),e.brand=()=>e,e.register=(r,n)=>(r.add(e,n),e),e.parse=(r,n)=>Op(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Ap(e,r,n),e.parseAsync=async(r,n)=>Cp(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>Np(e,r,n),e.spa=e.safeParseAsync,e.refine=(r,n)=>e.check(Wy(r,n)),e.superRefine=r=>e.check(Yy(r)),e.overwrite=r=>e.check(Ut(r)),e.optional=()=>le(e),e.nullable=()=>qp(e),e.nullish=()=>le(qp(e)),e.nonoptional=r=>Fy(e,r),e.array=()=>k(e),e.or=r=>oe([e,r]),e.and=r=>zo(e,r),e.transform=r=>Ei(e,Jp(r)),e.default=r=>Dy(e,r),e.prefault=r=>Ly(e,r),e.catch=r=>Hy(e,r),e.pipe=r=>Ei(e,r),e.readonly=()=>Jy(e),e.describe=r=>{let n=e.clone();return dr.add(n,{description:r}),n},Object.defineProperty(e,"description",{get(){return dr.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return dr.get(e);let n=e.clone();return dr.add(n,r[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Up=_("_ZodString",(e,t)=>{wo.init(e,t),te.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(hi(...n)),e.includes=(...n)=>e.check(yi(...n)),e.startsWith=(...n)=>e.check(vi(...n)),e.endsWith=(...n)=>e.check(wi(...n)),e.min=(...n)=>e.check(mr(...n)),e.max=(...n)=>e.check(bo(...n)),e.length=(...n)=>e.check(So(...n)),e.nonempty=(...n)=>e.check(mr(1,...n)),e.lowercase=n=>e.check(gi(n)),e.uppercase=n=>e.check(_i(n)),e.trim=()=>e.check(Si()),e.normalize=(...n)=>e.check(bi(...n)),e.toLowerCase=()=>e.check($i()),e.toUpperCase=()=>e.check(xi())}),Ii=_("ZodString",(e,t)=>{wo.init(e,t),Up.init(e,t),e.email=r=>e.check(Zd(ly,r)),e.url=r=>e.check(mi(Dp,r)),e.jwt=r=>e.check(ip(ky,r)),e.emoji=r=>e.check(Bd(dy,r)),e.guid=r=>e.check(fi(jp,r)),e.uuid=r=>e.check(Ld(xo,r)),e.uuidv4=r=>e.check(Fd(xo,r)),e.uuidv6=r=>e.check(Vd(xo,r)),e.uuidv7=r=>e.check(Hd(xo,r)),e.nanoid=r=>e.check(Kd(py,r)),e.guid=r=>e.check(fi(jp,r)),e.cuid=r=>e.check(Jd(fy,r)),e.cuid2=r=>e.check(Gd(my,r)),e.ulid=r=>e.check(Wd(hy,r)),e.base64=r=>e.check(np(Sy,r)),e.base64url=r=>e.check(op($y,r)),e.xid=r=>e.check(Yd(gy,r)),e.ksuid=r=>e.check(Xd(_y,r)),e.ipv4=r=>e.check(Qd(yy,r)),e.ipv6=r=>e.check(ep(vy,r)),e.cidrv4=r=>e.check(tp(wy,r)),e.cidrv6=r=>e.check(rp(by,r)),e.e164=r=>e.check(sp(xy,r)),e.datetime=r=>e.check(ki(r)),e.date=r=>e.check(zi(r)),e.time=r=>e.check(Pi(r)),e.duration=r=>e.check(Ti(r))});function p(e){return Ud(Ii,e)}var ce=_("ZodStringFormat",(e,t)=>{ne.init(e,t),Up.init(e,t)}),ly=_("ZodEmail",(e,t)=>{Vl.init(e,t),ce.init(e,t)});var jp=_("ZodGUID",(e,t)=>{Ll.init(e,t),ce.init(e,t)});var xo=_("ZodUUID",(e,t)=>{Fl.init(e,t),ce.init(e,t)});var Dp=_("ZodURL",(e,t)=>{Hl.init(e,t),ce.init(e,t)});function Zp(e){return mi(Dp,e)}var dy=_("ZodEmoji",(e,t)=>{Bl.init(e,t),ce.init(e,t)});var py=_("ZodNanoID",(e,t)=>{Kl.init(e,t),ce.init(e,t)});var fy=_("ZodCUID",(e,t)=>{Jl.init(e,t),ce.init(e,t)});var my=_("ZodCUID2",(e,t)=>{Gl.init(e,t),ce.init(e,t)});var hy=_("ZodULID",(e,t)=>{Wl.init(e,t),ce.init(e,t)});var gy=_("ZodXID",(e,t)=>{Yl.init(e,t),ce.init(e,t)});var _y=_("ZodKSUID",(e,t)=>{Xl.init(e,t),ce.init(e,t)});var yy=_("ZodIPv4",(e,t)=>{nd.init(e,t),ce.init(e,t)});var vy=_("ZodIPv6",(e,t)=>{od.init(e,t),ce.init(e,t)});var wy=_("ZodCIDRv4",(e,t)=>{sd.init(e,t),ce.init(e,t)});var by=_("ZodCIDRv6",(e,t)=>{id.init(e,t),ce.init(e,t)});var Sy=_("ZodBase64",(e,t)=>{cd.init(e,t),ce.init(e,t)});var $y=_("ZodBase64URL",(e,t)=>{ud.init(e,t),ce.init(e,t)});var xy=_("ZodE164",(e,t)=>{ld.init(e,t),ce.init(e,t)});var ky=_("ZodJWT",(e,t)=>{dd.init(e,t),ce.init(e,t)});var ko=_("ZodNumber",(e,t)=>{li.init(e,t),te.init(e,t),e.gt=(n,o)=>e.check(fr(n,o)),e.gte=(n,o)=>e.check(Je(n,o)),e.min=(n,o)=>e.check(Je(n,o)),e.lt=(n,o)=>e.check(pr(n,o)),e.lte=(n,o)=>e.check(lt(n,o)),e.max=(n,o)=>e.check(lt(n,o)),e.int=n=>e.check(Mp(n)),e.safe=n=>e.check(Mp(n)),e.positive=n=>e.check(fr(0,n)),e.nonnegative=n=>e.check(Je(0,n)),e.negative=n=>e.check(pr(0,n)),e.nonpositive=n=>e.check(lt(0,n)),e.multipleOf=(n,o)=>e.check(tn(n,o)),e.step=(n,o)=>e.check(tn(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 V(e){return dp(ko,e)}var zy=_("ZodNumberFormat",(e,t)=>{pd.init(e,t),ko.init(e,t)});function Mp(e){return fp(zy,e)}var Oi=_("ZodBoolean",(e,t)=>{fd.init(e,t),te.init(e,t)});function Y(e){return mp(Oi,e)}var Lp=_("ZodBigInt",(e,t)=>{md.init(e,t),te.init(e,t),e.gte=(n,o)=>e.check(Je(n,o)),e.min=(n,o)=>e.check(Je(n,o)),e.gt=(n,o)=>e.check(fr(n,o)),e.gte=(n,o)=>e.check(Je(n,o)),e.min=(n,o)=>e.check(Je(n,o)),e.lt=(n,o)=>e.check(pr(n,o)),e.lte=(n,o)=>e.check(lt(n,o)),e.max=(n,o)=>e.check(lt(n,o)),e.positive=n=>e.check(fr(BigInt(0),n)),e.negative=n=>e.check(pr(BigInt(0),n)),e.nonpositive=n=>e.check(lt(BigInt(0),n)),e.nonnegative=n=>e.check(Je(BigInt(0),n)),e.multipleOf=(n,o)=>e.check(tn(n,o));let r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});var Py=_("ZodNull",(e,t)=>{hd.init(e,t),te.init(e,t)});function Fp(e){return _p(Py,e)}var Ty=_("ZodAny",(e,t)=>{gd.init(e,t),te.init(e,t)});function Vp(){return yp(Ty)}var Ry=_("ZodUnknown",(e,t)=>{_d.init(e,t),te.init(e,t)});function ue(){return vp(Ry)}var Ey=_("ZodNever",(e,t)=>{yd.init(e,t),te.init(e,t)});function Iy(e){return wp(Ey,e)}var Hp=_("ZodDate",(e,t)=>{vd.init(e,t),te.init(e,t),e.min=(n,o)=>e.check(Je(n,o)),e.max=(n,o)=>e.check(lt(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 Oy=_("ZodArray",(e,t)=>{wd.init(e,t),te.init(e,t),e.element=t.element,e.min=(r,n)=>e.check(mr(r,n)),e.nonempty=r=>e.check(mr(1,r)),e.max=(r,n)=>e.check(bo(r,n)),e.length=(r,n)=>e.check(So(r,n)),e.unwrap=()=>e.element});function k(e,t){return Sp(Oy,e,t)}var Bp=_("ZodObject",(e,t)=>{bd.init(e,t),te.init(e,t),B.defineLazy(e,"shape",()=>t.shape),e.keyof=()=>Ie(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:ue()}),e.loose=()=>e.clone({...e._zod.def,catchall:ue()}),e.strict=()=>e.clone({...e._zod.def,catchall:Iy()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>B.extend(e,r),e.merge=r=>B.merge(e,r),e.pick=r=>B.pick(e,r),e.omit=r=>B.omit(e,r),e.partial=(...r)=>B.partial(Gp,e,r[0]),e.required=(...r)=>B.required(Wp,e,r[0])});function z(e,t){let r={type:"object",get shape(){return B.assignProp(this,"shape",{...e}),this.shape},...B.normalizeParams(t)};return new Bp(r)}function fe(e,t){return new Bp({type:"object",get shape(){return B.assignProp(this,"shape",{...e}),this.shape},catchall:ue(),...B.normalizeParams(t)})}var Kp=_("ZodUnion",(e,t)=>{di.init(e,t),te.init(e,t),e.options=t.options});function oe(e,t){return new Kp({type:"union",options:e,...B.normalizeParams(t)})}var Cy=_("ZodDiscriminatedUnion",(e,t)=>{Kp.init(e,t),Sd.init(e,t)});function Ci(e,t,r){return new Cy({type:"union",options:t,discriminator:e,...B.normalizeParams(r)})}var Ay=_("ZodIntersection",(e,t)=>{$d.init(e,t),te.init(e,t)});function zo(e,t){return new Ay({type:"intersection",left:e,right:t})}var Ny=_("ZodRecord",(e,t)=>{xd.init(e,t),te.init(e,t),e.keyType=t.keyType,e.valueType=t.valueType});function re(e,t,r){return new Ny({type:"record",keyType:e,valueType:t,...B.normalizeParams(r)})}var Ri=_("ZodEnum",(e,t)=>{kd.init(e,t),te.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 Ri({...t,checks:[],...B.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 Ri({...t,checks:[],...B.normalizeParams(o),entries:s})}});function Ie(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Ri({type:"enum",entries:r,...B.normalizeParams(t)})}var jy=_("ZodLiteral",(e,t)=>{zd.init(e,t),te.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 R(e,t){return new jy({type:"literal",values:Array.isArray(e)?e:[e],...B.normalizeParams(t)})}var My=_("ZodTransform",(e,t)=>{Pd.init(e,t),te.init(e,t),e._zod.parse=(r,n)=>{r.addIssue=s=>{if(typeof s=="string")r.issues.push(B.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(B.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 Jp(e){return new My({type:"transform",transform:e})}var Gp=_("ZodOptional",(e,t)=>{Td.init(e,t),te.init(e,t),e.unwrap=()=>e._zod.def.innerType});function le(e){return new Gp({type:"optional",innerType:e})}var qy=_("ZodNullable",(e,t)=>{Rd.init(e,t),te.init(e,t),e.unwrap=()=>e._zod.def.innerType});function qp(e){return new qy({type:"nullable",innerType:e})}var Uy=_("ZodDefault",(e,t)=>{Ed.init(e,t),te.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Dy(e,t){return new Uy({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var Zy=_("ZodPrefault",(e,t)=>{Id.init(e,t),te.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ly(e,t){return new Zy({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():t}})}var Wp=_("ZodNonOptional",(e,t)=>{Od.init(e,t),te.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Fy(e,t){return new Wp({type:"nonoptional",innerType:e,...B.normalizeParams(t)})}var Vy=_("ZodCatch",(e,t)=>{Cd.init(e,t),te.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Hy(e,t){return new Vy({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}var By=_("ZodPipe",(e,t)=>{Ad.init(e,t),te.init(e,t),e.in=t.in,e.out=t.out});function Ei(e,t){return new By({type:"pipe",in:e,out:t})}var Ky=_("ZodReadonly",(e,t)=>{Nd.init(e,t),te.init(e,t)});function Jy(e){return new Ky({type:"readonly",innerType:e})}var Yp=_("ZodCustom",(e,t)=>{jd.init(e,t),te.init(e,t)});function Gy(e){let t=new $e({check:"custom"});return t._zod.check=e,t}function Xp(e,t){return $p(Yp,e??(()=>!0),t)}function Wy(e,t={}){return xp(Yp,e,t)}function Yy(e){let t=Gy(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(B.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(B.issue(o))}},e(r.value,r)));return t}function Ai(e,t){return Ei(Jp(e),t)}var Qp={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 Po={};Zs(Po,{bigint:()=>tv,boolean:()=>ev,date:()=>rv,number:()=>Qy,string:()=>Xy});function Xy(e){return Dd(Ii,e)}function Qy(e){return pp(ko,e)}function ev(e){return hp(Oi,e)}function tv(e){return gp(Lp,e)}function rv(e){return bp(Hp,e)}je(Md());var yr="2025-11-25";var ji=[yr,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],St="io.modelcontextprotocol/related-task",Ro="2.0",me=Xp(e=>e!==null&&(typeof e=="object"||typeof e=="function")),ef=oe([p(),V().int()]),tf=p(),bR=fe({ttl:V().optional(),pollInterval:V().optional()}),ov=z({ttl:V().optional()}),sv=z({taskId:p()}),Mi=fe({progressToken:ef.optional(),[St]:sv.optional()}),Me=z({_meta:Mi.optional()}),on=Me.extend({task:ov.optional()}),rf=e=>on.safeParse(e).success,ge=z({method:p(),params:Me.loose().optional()}),De=z({_meta:Mi.optional()}),Ze=z({method:p(),params:De.loose().optional()}),_e=fe({_meta:Mi.optional()}),Eo=oe([p(),V().int()]),nf=z({jsonrpc:R(Ro),id:Eo,...ge.shape}).strict(),vr=e=>nf.safeParse(e).success,of=z({jsonrpc:R(Ro),...Ze.shape}).strict(),sf=e=>of.safeParse(e).success,qi=z({jsonrpc:R(Ro),id:Eo,result:_e}).strict(),$t=e=>qi.safeParse(e).success;var A;(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"})(A||(A={}));var Ui=z({jsonrpc:R(Ro),id:Eo.optional(),error:z({code:V().int(),message:p(),data:ue().optional()})}).strict();var Di=e=>Ui.safeParse(e).success;var Dt=oe([nf,of,qi,Ui]),SR=oe([qi,Ui]),Zt=_e.strict(),iv=De.extend({requestId:Eo.optional(),reason:p().optional()}),Io=Ze.extend({method:R("notifications/cancelled"),params:iv}),av=z({src:p(),mimeType:p().optional(),sizes:k(p()).optional(),theme:Ie(["light","dark"]).optional()}),sn=z({icons:k(av).optional()}),_r=z({name:p(),title:p().optional()}),af=_r.extend({..._r.shape,...sn.shape,version:p(),websiteUrl:p().optional(),description:p().optional()}),cv=zo(z({applyDefaults:Y().optional()}),re(p(),ue())),uv=Ai(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,zo(z({form:cv.optional(),url:me.optional()}),re(p(),ue()).optional())),lv=fe({list:me.optional(),cancel:me.optional(),requests:fe({sampling:fe({createMessage:me.optional()}).optional(),elicitation:fe({create:me.optional()}).optional()}).optional()}),dv=fe({list:me.optional(),cancel:me.optional(),requests:fe({tools:fe({call:me.optional()}).optional()}).optional()}),pv=z({experimental:re(p(),me).optional(),sampling:z({context:me.optional(),tools:me.optional()}).optional(),elicitation:uv.optional(),roots:z({listChanged:Y().optional()}).optional(),tasks:lv.optional(),extensions:re(p(),me).optional()}),fv=Me.extend({protocolVersion:p(),capabilities:pv,clientInfo:af}),mv=ge.extend({method:R("initialize"),params:fv});var hv=z({experimental:re(p(),me).optional(),logging:me.optional(),completions:me.optional(),prompts:z({listChanged:Y().optional()}).optional(),resources:z({subscribe:Y().optional(),listChanged:Y().optional()}).optional(),tools:z({listChanged:Y().optional()}).optional(),tasks:dv.optional(),extensions:re(p(),me).optional()}),Zi=_e.extend({protocolVersion:p(),capabilities:hv,serverInfo:af,instructions:p().optional()}),cf=Ze.extend({method:R("notifications/initialized"),params:De.optional()}),uf=e=>cf.safeParse(e).success,Oo=ge.extend({method:R("ping"),params:Me.optional()}),gv=z({progress:V(),total:le(V()),message:le(p())}),_v=z({...De.shape,...gv.shape,progressToken:ef}),Co=Ze.extend({method:R("notifications/progress"),params:_v}),yv=Me.extend({cursor:tf.optional()}),an=ge.extend({params:yv.optional()}),cn=_e.extend({nextCursor:tf.optional()}),vv=Ie(["working","input_required","completed","failed","cancelled"]),un=z({taskId:p(),status:vv,ttl:oe([V(),Fp()]),createdAt:p(),lastUpdatedAt:p(),pollInterval:le(V()),statusMessage:le(p())}),Lt=_e.extend({task:un}),wv=De.merge(un),ln=Ze.extend({method:R("notifications/tasks/status"),params:wv}),Ao=ge.extend({method:R("tasks/get"),params:Me.extend({taskId:p()})}),No=_e.merge(un),jo=ge.extend({method:R("tasks/result"),params:Me.extend({taskId:p()})}),$R=_e.loose(),Mo=an.extend({method:R("tasks/list")}),qo=cn.extend({tasks:k(un)}),Uo=ge.extend({method:R("tasks/cancel"),params:Me.extend({taskId:p()})}),lf=_e.merge(un),df=z({uri:p(),mimeType:le(p()),_meta:re(p(),ue()).optional()}),pf=df.extend({text:p()}),Li=p().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),ff=df.extend({blob:Li}),dn=Ie(["user","assistant"]),wr=z({audience:k(dn).optional(),priority:V().min(0).max(1).optional(),lastModified:rn.datetime({offset:!0}).optional()}),mf=z({..._r.shape,...sn.shape,uri:p(),description:le(p()),mimeType:le(p()),size:le(V()),annotations:wr.optional(),_meta:le(fe({}))}),bv=z({..._r.shape,...sn.shape,uriTemplate:p(),description:le(p()),mimeType:le(p()),annotations:wr.optional(),_meta:le(fe({}))}),Sv=an.extend({method:R("resources/list")}),Fi=cn.extend({resources:k(mf)}),$v=an.extend({method:R("resources/templates/list")}),Vi=cn.extend({resourceTemplates:k(bv)}),Hi=Me.extend({uri:p()}),xv=Hi,kv=ge.extend({method:R("resources/read"),params:xv}),Bi=_e.extend({contents:k(oe([pf,ff]))}),Ki=Ze.extend({method:R("notifications/resources/list_changed"),params:De.optional()}),zv=Hi,Pv=ge.extend({method:R("resources/subscribe"),params:zv}),Tv=Hi,Rv=ge.extend({method:R("resources/unsubscribe"),params:Tv}),Ev=De.extend({uri:p()}),Iv=Ze.extend({method:R("notifications/resources/updated"),params:Ev}),Ov=z({name:p(),description:le(p()),required:le(Y())}),Cv=z({..._r.shape,...sn.shape,description:le(p()),arguments:le(k(Ov)),_meta:le(fe({}))}),Av=an.extend({method:R("prompts/list")}),Ji=cn.extend({prompts:k(Cv)}),Nv=Me.extend({name:p(),arguments:re(p(),p()).optional()}),jv=ge.extend({method:R("prompts/get"),params:Nv}),Gi=z({type:R("text"),text:p(),annotations:wr.optional(),_meta:re(p(),ue()).optional()}),Wi=z({type:R("image"),data:Li,mimeType:p(),annotations:wr.optional(),_meta:re(p(),ue()).optional()}),Yi=z({type:R("audio"),data:Li,mimeType:p(),annotations:wr.optional(),_meta:re(p(),ue()).optional()}),Mv=z({type:R("tool_use"),name:p(),id:p(),input:re(p(),ue()),_meta:re(p(),ue()).optional()}),qv=z({type:R("resource"),resource:oe([pf,ff]),annotations:wr.optional(),_meta:re(p(),ue()).optional()}),Uv=mf.extend({type:R("resource_link")}),Xi=oe([Gi,Wi,Yi,Uv,qv]),Dv=z({role:dn,content:Xi}),Qi=_e.extend({description:p().optional(),messages:k(Dv)}),ea=Ze.extend({method:R("notifications/prompts/list_changed"),params:De.optional()}),Zv=z({title:p().optional(),readOnlyHint:Y().optional(),destructiveHint:Y().optional(),idempotentHint:Y().optional(),openWorldHint:Y().optional()}),Lv=z({taskSupport:Ie(["required","optional","forbidden"]).optional()}),hf=z({..._r.shape,...sn.shape,description:p().optional(),inputSchema:z({type:R("object"),properties:re(p(),me).optional(),required:k(p()).optional()}).catchall(ue()),outputSchema:z({type:R("object"),properties:re(p(),me).optional(),required:k(p()).optional()}).catchall(ue()).optional(),annotations:Zv.optional(),execution:Lv.optional(),_meta:re(p(),ue()).optional()}),Fv=an.extend({method:R("tools/list")}),ta=cn.extend({tools:k(hf)}),br=_e.extend({content:k(Xi).default([]),structuredContent:re(p(),ue()).optional(),isError:Y().optional()}),xR=br.or(_e.extend({toolResult:ue()})),Vv=on.extend({name:p(),arguments:re(p(),ue()).optional()}),Hv=ge.extend({method:R("tools/call"),params:Vv}),ra=Ze.extend({method:R("notifications/tools/list_changed"),params:De.optional()}),gf=z({autoRefresh:Y().default(!0),debounceMs:V().int().nonnegative().default(300)}),_f=Ie(["debug","info","notice","warning","error","critical","alert","emergency"]),Bv=Me.extend({level:_f}),Kv=ge.extend({method:R("logging/setLevel"),params:Bv}),Jv=De.extend({level:_f,logger:p().optional(),data:ue()}),Gv=Ze.extend({method:R("notifications/message"),params:Jv}),Wv=z({name:p().optional()}),Yv=z({hints:k(Wv).optional(),costPriority:V().min(0).max(1).optional(),speedPriority:V().min(0).max(1).optional(),intelligencePriority:V().min(0).max(1).optional()}),Xv=z({mode:Ie(["auto","required","none"]).optional()}),Qv=z({type:R("tool_result"),toolUseId:p().describe("The unique identifier for the corresponding tool call."),content:k(Xi).default([]),structuredContent:z({}).loose().optional(),isError:Y().optional(),_meta:re(p(),ue()).optional()}),ew=Ci("type",[Gi,Wi,Yi]),To=Ci("type",[Gi,Wi,Yi,Mv,Qv]),tw=z({role:dn,content:oe([To,k(To)]),_meta:re(p(),ue()).optional()}),rw=on.extend({messages:k(tw),modelPreferences:Yv.optional(),systemPrompt:p().optional(),includeContext:Ie(["none","thisServer","allServers"]).optional(),temperature:V().optional(),maxTokens:V().int(),stopSequences:k(p()).optional(),metadata:me.optional(),tools:k(hf).optional(),toolChoice:Xv.optional()}),na=ge.extend({method:R("sampling/createMessage"),params:rw}),oa=_e.extend({model:p(),stopReason:le(Ie(["endTurn","stopSequence","maxTokens"]).or(p())),role:dn,content:ew}),sa=_e.extend({model:p(),stopReason:le(Ie(["endTurn","stopSequence","maxTokens","toolUse"]).or(p())),role:dn,content:oe([To,k(To)])}),nw=z({type:R("boolean"),title:p().optional(),description:p().optional(),default:Y().optional()}),ow=z({type:R("string"),title:p().optional(),description:p().optional(),minLength:V().optional(),maxLength:V().optional(),format:Ie(["email","uri","date","date-time"]).optional(),default:p().optional()}),sw=z({type:Ie(["number","integer"]),title:p().optional(),description:p().optional(),minimum:V().optional(),maximum:V().optional(),default:V().optional()}),iw=z({type:R("string"),title:p().optional(),description:p().optional(),enum:k(p()),default:p().optional()}),aw=z({type:R("string"),title:p().optional(),description:p().optional(),oneOf:k(z({const:p(),title:p()})),default:p().optional()}),cw=z({type:R("string"),title:p().optional(),description:p().optional(),enum:k(p()),enumNames:k(p()).optional(),default:p().optional()}),uw=oe([iw,aw]),lw=z({type:R("array"),title:p().optional(),description:p().optional(),minItems:V().optional(),maxItems:V().optional(),items:z({type:R("string"),enum:k(p())}),default:k(p()).optional()}),dw=z({type:R("array"),title:p().optional(),description:p().optional(),minItems:V().optional(),maxItems:V().optional(),items:z({anyOf:k(z({const:p(),title:p()}))}),default:k(p()).optional()}),pw=oe([lw,dw]),fw=oe([cw,uw,pw]),mw=oe([fw,nw,ow,sw]),hw=on.extend({mode:R("form").optional(),message:p(),requestedSchema:z({type:R("object"),properties:re(p(),mw),required:k(p()).optional()})}),gw=on.extend({mode:R("url"),message:p(),elicitationId:p(),url:p().url()}),_w=oe([hw,gw]),ia=ge.extend({method:R("elicitation/create"),params:_w}),yw=De.extend({elicitationId:p()}),vw=Ze.extend({method:R("notifications/elicitation/complete"),params:yw}),aa=_e.extend({action:Ie(["accept","decline","cancel"]),content:Ai(e=>e===null?void 0:e,re(p(),oe([p(),V(),Y(),k(p())])).optional())}),ww=z({type:R("ref/resource"),uri:p()});var bw=z({type:R("ref/prompt"),name:p()}),Sw=Me.extend({ref:oe([bw,ww]),argument:z({name:p(),value:p()}),context:z({arguments:re(p(),p()).optional()}).optional()}),$w=ge.extend({method:R("completion/complete"),params:Sw});var ca=_e.extend({completion:fe({values:k(p()).max(100),total:le(V().int()),hasMore:le(Y())})}),xw=z({uri:p().startsWith("file://"),name:p().optional(),_meta:re(p(),ue()).optional()}),kw=ge.extend({method:R("roots/list"),params:Me.optional()}),zw=_e.extend({roots:k(xw)}),Pw=Ze.extend({method:R("notifications/roots/list_changed"),params:De.optional()}),kR=oe([Oo,mv,$w,Kv,jv,Av,Sv,$v,kv,Pv,Rv,Hv,Fv,Ao,jo,Mo,Uo]),zR=oe([Io,Co,cf,Pw,ln]),PR=oe([Zt,oa,sa,aa,zw,No,qo,Lt]),TR=oe([Oo,na,ia,kw,Ao,jo,Mo,Uo]),RR=oe([Io,Co,Gv,Iv,Ki,ra,ea,ln,vw]),ER=oe([Zt,Zi,ca,Qi,Ji,Fi,Vi,Bi,br,ta,No,qo,Lt]),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===A.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Ni(o.elicitations,r)}return new e(t,r,n)}},Ni=class extends C{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(A.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function xt(e){return e==="completed"||e==="failed"||e==="cancelled"}var Tw=Symbol("Let zodToJsonSchema decide on which parser to use");var uE=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function ua(e){let r=$o(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=kp(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function la(e,t){let r=Ge(e,t);if(!r.success)throw r.error;return r.data}var Aw=6e4,Do=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(Io,r=>{this._oncancel(r)}),this.setNotificationHandler(Co,r=>{this._onprogress(r)}),this.setRequestHandler(Oo,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Ao,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new C(A.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(jo,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,f=new C(d.error.code,d.error.message,d.error.data);l(f)}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 C(A.InvalidParams,`Task not found: ${s}`);if(!xt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(xt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[St]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Mo,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(A.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Uo,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new C(A.InvalidParams,`Task not found: ${r.params.taskId}`);if(xt(o.status))throw new C(A.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(A.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof C?o:new C(A.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(A.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),$t(s)||Di(s)?this._onresponse(s):vr(s)?this._onrequest(s,i):sf(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(A.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?.[St]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:A.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=rf(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,f)=>{if(i.signal.aborted)throw new C(A.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(l,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,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:A.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),$t(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($t(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),$t(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(A.InternalError,String(i))}}return}let s;try{let i=await this.request(t,Lt,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new C(A.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},xt(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(A.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new C(A.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 C?i:new C(A.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=$=>{l($)};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($){d($);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||{},[St]:c}});let h=$=>{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($)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(T=>this._onerror(new Error(`Failed to send cancellation: ${T}`)));let b=$ instanceof C?$:new C(A.RequestTimeout,String($));l(b)};this._responseHandlers.set(f,$=>{if(!n?.signal?.aborted){if($ instanceof Error)return l($);try{let b=Ge(r,$.result);b.success?u(b.data):l(b.error)}catch(b){l(b)}}}),n?.signal?.addEventListener("abort",()=>{h(n?.signal?.reason)});let g=n?.timeout??Aw,y=()=>h(C.fromError(A.RequestTimeout,"Request timed out",{timeout:g}));this._setupTimeout(f,g,n?.maxTotalTimeout,y,n?.resetTimeoutOnProgress??!1);let S=c?.taskId;if(S){let $=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,$),this._enqueueTaskMessage(S,{type:"request",message:m,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(f),l(b)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch($=>{this._cleanupTimeout(f),l($)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},No,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},qo,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},lf,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||{},[St]: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||{},[St]: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||{},[St]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=ua(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=la(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=ua(t);this._notificationHandlers.set(n,o=>{let s=la(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"&&vr(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new C(A.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(A.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new C(A.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(A.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=ln.parse({method:"notifications/tasks/status",params:a});await this.notification(c),xt(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(A.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(xt(a.status))throw new C(A.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=ln.parse({method:"notifications/tasks/status",params:c});await this.notification(u),xt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function yf(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function vf(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];yf(i)&&yf(s)?r[o]={...i,...s}:r[o]=s}return r}var lg=Nu(Wc(),1),dg=Nu(ug(),1);function qk(){let e=new lg.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,dg.default)(e),e}var bs=class{constructor(t){this._ajv=t??qk()}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 Ss=class{constructor(t){this._client=t}async*callToolStream(t,r=br,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 C(A.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 C(A.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof C){yield{type:"error",error:l};return}yield{type:"error",error:new C(A.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 pg(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 fg(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 $s(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&&$s(s,r[o])}}if(Array.isArray(e.anyOf))for(let r of e.anyOf)typeof r!="boolean"&&$s(r,t);if(Array.isArray(e.oneOf))for(let r of e.oneOf)typeof r!="boolean"&&$s(r,t)}}function Uk(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 xs=class extends Do{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 bs,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(t){t.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",ra,t.tools,async()=>(await this.listTools()).tools),t.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",ea,t.prompts,async()=>(await this.listPrompts()).prompts),t.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",Ki,t.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new Ss(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=vf(this._capabilities,t)}setRequestHandler(t,r){let o=$o(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(gr(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=Ge(ia,c);if(!l.success){let $=l.error instanceof Error?l.error.message:String(l.error);throw new C(A.InvalidParams,`Invalid elicitation request: ${$}`)}let{params:d}=l.data;d.mode=d.mode??"form";let{supportsFormMode:f,supportsUrlMode:m}=Uk(this._capabilities.elicitation);if(d.mode==="form"&&!f)throw new C(A.InvalidParams,"Client does not support form-mode elicitation requests");if(d.mode==="url"&&!m)throw new C(A.InvalidParams,"Client does not support URL-mode elicitation requests");let h=await Promise.resolve(r(c,u));if(d.task){let $=Ge(Lt,h);if(!$.success){let b=$.error instanceof Error?$.error.message:String($.error);throw new C(A.InvalidParams,`Invalid task creation result: ${b}`)}return $.data}let g=Ge(aa,h);if(!g.success){let $=g.error instanceof Error?g.error.message:String(g.error);throw new C(A.InvalidParams,`Invalid elicitation result: ${$}`)}let y=g.data,S=d.mode==="form"?d.requestedSchema:void 0;if(d.mode==="form"&&y.action==="accept"&&y.content&&S&&this._capabilities.elicitation?.form?.applyDefaults)try{$s(S,y.content)}catch{}return y};return super.setRequestHandler(t,a)}if(i==="sampling/createMessage"){let a=async(c,u)=>{let l=Ge(na,c);if(!l.success){let y=l.error instanceof Error?l.error.message:String(l.error);throw new C(A.InvalidParams,`Invalid sampling request: ${y}`)}let{params:d}=l.data,f=await Promise.resolve(r(c,u));if(d.task){let y=Ge(Lt,f);if(!y.success){let S=y.error instanceof Error?y.error.message:String(y.error);throw new C(A.InvalidParams,`Invalid task creation result: ${S}`)}return y.data}let h=d.tools||d.toolChoice?sa:oa,g=Ge(h,f);if(!g.success){let y=g.error instanceof Error?g.error.message:String(g.error);throw new C(A.InvalidParams,`Invalid sampling result: ${y}`)}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:yr,capabilities:this._capabilities,clientInfo:this._clientInfo}},Zi,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!ji.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){pg(this._serverCapabilities?.tasks?.requests,t,"Server")}assertTaskHandlerCapability(t){this._capabilities&&fg(this._capabilities.tasks?.requests,t,"Client")}async ping(t){return this.request({method:"ping"},Zt,t)}async complete(t,r){return this.request({method:"completion/complete",params:t},ca,r)}async setLoggingLevel(t,r){return this.request({method:"logging/setLevel",params:{level:t}},Zt,r)}async getPrompt(t,r){return this.request({method:"prompts/get",params:t},Qi,r)}async listPrompts(t,r){return this.request({method:"prompts/list",params:t},Ji,r)}async listResources(t,r){return this.request({method:"resources/list",params:t},Fi,r)}async listResourceTemplates(t,r){return this.request({method:"resources/templates/list",params:t},Vi,r)}async readResource(t,r){return this.request({method:"resources/read",params:t},Bi,r)}async subscribeResource(t,r){return this.request({method:"resources/subscribe",params:t},Zt,r)}async unsubscribeResource(t,r){return this.request({method:"resources/unsubscribe",params:t},Zt,r)}async callTool(t,r=br,n){if(this.isToolTaskRequired(t.name))throw new C(A.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(A.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(A.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof C?i:new C(A.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},ta,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(t,r,n,o){let s=gf.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 f=d instanceof Error?d:new Error(String(d));c(f,null)}},l=()=>{if(a){let d=this._listChangedDebounceTimers.get(t);d&&clearTimeout(d);let f=setTimeout(u,a);this._listChangedDebounceTimers.set(t,f)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}};function ks(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):{...e}:{}}function mg(e=fetch,t){return t?async(r,n)=>{let o={...t,...n,headers:n?.headers?{...ks(t.headers),...ks(n.headers)}:t.headers};return e(r,o)}:e}var ou;ou=globalThis.crypto?.webcrypto??globalThis.crypto??import("node:crypto").then(e=>e.webcrypto);async function Dk(e){return(await ou).getRandomValues(new Uint8Array(e))}async function Zk(e){let t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%t.length,n="";for(;n.length<e;){let o=await Dk(e-n.length);for(let s of o)s<r&&(n+=t[s%t.length])}return n}async function Lk(e){return await Zk(e)}async function Fk(e){let t=await(await ou).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function su(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;let t=await Lk(e),r=await Fk(t);return{code_verifier:t,code_challenge:r}}var be=Zp().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:Qp.custom,message:"URL must be parseable",fatal:!0}),Ls}).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"}),gg=fe({resource:p().url(),authorization_servers:k(be).optional(),jwks_uri:p().url().optional(),scopes_supported:k(p()).optional(),bearer_methods_supported:k(p()).optional(),resource_signing_alg_values_supported:k(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:Y().optional(),authorization_details_types_supported:k(p()).optional(),dpop_signing_alg_values_supported:k(p()).optional(),dpop_bound_access_tokens_required:Y().optional()}),iu=fe({issuer:p(),authorization_endpoint:be,token_endpoint:be,registration_endpoint:be.optional(),scopes_supported:k(p()).optional(),response_types_supported:k(p()),response_modes_supported:k(p()).optional(),grant_types_supported:k(p()).optional(),token_endpoint_auth_methods_supported:k(p()).optional(),token_endpoint_auth_signing_alg_values_supported:k(p()).optional(),service_documentation:be.optional(),revocation_endpoint:be.optional(),revocation_endpoint_auth_methods_supported:k(p()).optional(),revocation_endpoint_auth_signing_alg_values_supported:k(p()).optional(),introspection_endpoint:p().optional(),introspection_endpoint_auth_methods_supported:k(p()).optional(),introspection_endpoint_auth_signing_alg_values_supported:k(p()).optional(),code_challenge_methods_supported:k(p()).optional(),client_id_metadata_document_supported:Y().optional()}),Vk=fe({issuer:p(),authorization_endpoint:be,token_endpoint:be,userinfo_endpoint:be.optional(),jwks_uri:be,registration_endpoint:be.optional(),scopes_supported:k(p()).optional(),response_types_supported:k(p()),response_modes_supported:k(p()).optional(),grant_types_supported:k(p()).optional(),acr_values_supported:k(p()).optional(),subject_types_supported:k(p()),id_token_signing_alg_values_supported:k(p()),id_token_encryption_alg_values_supported:k(p()).optional(),id_token_encryption_enc_values_supported:k(p()).optional(),userinfo_signing_alg_values_supported:k(p()).optional(),userinfo_encryption_alg_values_supported:k(p()).optional(),userinfo_encryption_enc_values_supported:k(p()).optional(),request_object_signing_alg_values_supported:k(p()).optional(),request_object_encryption_alg_values_supported:k(p()).optional(),request_object_encryption_enc_values_supported:k(p()).optional(),token_endpoint_auth_methods_supported:k(p()).optional(),token_endpoint_auth_signing_alg_values_supported:k(p()).optional(),display_values_supported:k(p()).optional(),claim_types_supported:k(p()).optional(),claims_supported:k(p()).optional(),service_documentation:p().optional(),claims_locales_supported:k(p()).optional(),ui_locales_supported:k(p()).optional(),claims_parameter_supported:Y().optional(),request_parameter_supported:Y().optional(),request_uri_parameter_supported:Y().optional(),require_request_uri_registration:Y().optional(),op_policy_uri:be.optional(),op_tos_uri:be.optional(),client_id_metadata_document_supported:Y().optional()}),_g=z({...Vk.shape,...iu.pick({code_challenge_methods_supported:!0}).shape}),yg=z({access_token:p(),id_token:p().optional(),token_type:p(),expires_in:Po.number().optional(),scope:p().optional(),refresh_token:p().optional()}).strip(),vg=z({error:p(),error_description:p().optional(),error_uri:p().optional()}),hg=be.optional().or(R("").transform(()=>{})),Hk=z({redirect_uris:k(be),token_endpoint_auth_method:p().optional(),grant_types:k(p()).optional(),response_types:k(p()).optional(),client_name:p().optional(),client_uri:be.optional(),logo_uri:hg,scope:p().optional(),contacts:k(p()).optional(),tos_uri:hg,policy_uri:p().optional(),jwks_uri:be.optional(),jwks:Vp().optional(),software_id:p().optional(),software_version:p().optional(),software_statement:p().optional()}).strip(),Bk=z({client_id:p(),client_secret:p().optional(),client_id_issued_at:V().optional(),client_secret_expires_at:V().optional()}).strip(),wg=Hk.merge(Bk),NA=z({error:p(),error_description:p().optional()}).strip(),jA=z({token:p(),token_type_hint:p().optional()}).strip();function bg(e){let t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function Sg({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 pe=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}},Ln=class extends pe{};Ln.errorCode="invalid_request";var er=class extends pe{};er.errorCode="invalid_client";var tr=class extends pe{};tr.errorCode="invalid_grant";var rr=class extends pe{};rr.errorCode="unauthorized_client";var Fn=class extends pe{};Fn.errorCode="unsupported_grant_type";var Vn=class extends pe{};Vn.errorCode="invalid_scope";var Hn=class extends pe{};Hn.errorCode="access_denied";var gt=class extends pe{};gt.errorCode="server_error";var Bn=class extends pe{};Bn.errorCode="temporarily_unavailable";var Kn=class extends pe{};Kn.errorCode="unsupported_response_type";var Jn=class extends pe{};Jn.errorCode="unsupported_token_type";var Gn=class extends pe{};Gn.errorCode="invalid_token";var Wn=class extends pe{};Wn.errorCode="method_not_allowed";var Yn=class extends pe{};Yn.errorCode="too_many_requests";var nr=class extends pe{};nr.errorCode="invalid_client_metadata";var Xn=class extends pe{};Xn.errorCode="insufficient_scope";var Qn=class extends pe{};Qn.errorCode="invalid_target";var $g={[Ln.errorCode]:Ln,[er.errorCode]:er,[tr.errorCode]:tr,[rr.errorCode]:rr,[Fn.errorCode]:Fn,[Vn.errorCode]:Vn,[Hn.errorCode]:Hn,[gt.errorCode]:gt,[Bn.errorCode]:Bn,[Kn.errorCode]:Kn,[Jn.errorCode]:Jn,[Gn.errorCode]:Gn,[Wn.errorCode]:Wn,[Yn.errorCode]:Yn,[nr.errorCode]:nr,[Xn.errorCode]:Xn,[Qn.errorCode]:Qn};var _t=class extends Error{constructor(t){super(t??"Unauthorized")}};function Kk(e){return["client_secret_basic","client_secret_post","none"].includes(e)}var au="code",cu="S256";function Jk(e,t){let r=e.client_secret!==void 0;return"token_endpoint_auth_method"in e&&e.token_endpoint_auth_method&&Kk(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 Gk(e,t,r,n){let{client_id:o,client_secret:s}=t;switch(e){case"client_secret_basic":Wk(o,s,r);return;case"client_secret_post":Yk(o,s,n);return;case"none":Xk(o,n);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function Wk(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 Yk(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}function Xk(e,t){t.set("client_id",e)}async function kg(e){let t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{let n=vg.parse(JSON.parse(r)),{error:o,error_description:s,error_uri:i}=n,a=$g[o]||gt;return new a(s||"",i)}catch(n){let o=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${n}. Raw body: ${r}`;return new gt(o)}}async function eo(e,t){try{return await uu(e,t)}catch(r){if(r instanceof er||r instanceof rr)return await e.invalidateCredentials?.("all"),await uu(e,t);if(r instanceof tr)return await e.invalidateCredentials?.("tokens"),await uu(e,t);throw r}}async function uu(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 Pg(c,{fetchFn:s}),!a)try{a=await zg(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 b=await sz(t,{resourceMetadataUrl:l,fetchFn:s});c=b.authorizationServerUrl,u=b.authorizationServerMetadata,a=b.resourceMetadata,await e.saveDiscoveryState?.({authorizationServerUrl:String(c),resourceMetadataUrl:l?.toString(),resourceMetadata:a,authorizationServerMetadata:u})}let d=await ez(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=u?.client_id_metadata_document_supported===!0,T=e.clientMetadataUrl;if(T&&!Qk(T))throw new nr(`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 lz(c,{metadata:u,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 uz(e,c,{metadata:u,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 cz(c,{metadata:u,clientInformation:m,refreshToken:g.refresh_token,resource:d,addClientAuthentication:e.addClientAuthentication,fetchFn:s});return await e.saveTokens(b),"AUTHORIZED"}catch(b){if(!(!(b instanceof pe)||b instanceof gt))throw b}let y=e.state?await e.state():void 0,{authorizationUrl:S,codeVerifier:$}=await iz(c,{metadata:u,clientInformation:m,state:y,redirectUrl:e.redirectUrl,scope:f,resource:d});return await e.saveCodeVerifier($),await e.redirectToAuthorization(S),"REDIRECT"}function Qk(e){if(!e)return!1;try{let t=new URL(e);return t.protocol==="https:"&&t.pathname!=="/"}catch{return!1}}async function ez(e,t,r){let n=bg(e);if(t.validateResourceURL)return await t.validateResourceURL(n,r?.resource);if(r){if(!Sg({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 du(e){let t=e.headers.get("WWW-Authenticate");if(!t)return{};let[r,n]=t.split(" ");if(r.toLowerCase()!=="bearer"||!n)return{};let o=lu(e,"resource_metadata")||void 0,s;if(o)try{s=new URL(o)}catch{}let i=lu(e,"scope")||void 0,a=lu(e,"error")||void 0;return{resourceMetadataUrl:s,scope:i,error:a}}function lu(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 zg(e,t,r=fetch){let n=await nz(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 gg.parse(await n.json())}async function pu(e,t,r=fetch){try{return await r(e,{headers:t})}catch(n){if(n instanceof TypeError)return t?pu(e,void 0,r):void 0;throw n}}function tz(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function xg(e,t,r=fetch){return await pu(e,{"MCP-Protocol-Version":t},r)}function rz(e,t){return!e||e.status>=400&&e.status<500&&t!=="/"}async function nz(e,t,r,n){let o=new URL(e),s=n?.protocolVersion??yr,i;if(n?.metadataUrl)i=new URL(n.metadataUrl);else{let c=tz(t,o.pathname);i=new URL(c,n?.metadataServerUrl??o),i.search=o.search}let a=await xg(i,s,r);if(!n?.metadataUrl&&rz(a,o.pathname)){let c=new URL(`/.well-known/${t}`,o);a=await xg(c,s,r)}return a}function oz(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 Pg(e,{fetchFn:t=fetch,protocolVersion:r=yr}={}){let n={"MCP-Protocol-Version":r,Accept:"application/json"},o=oz(e);for(let{url:s,type:i}of o){let a=await pu(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"?iu.parse(await a.json()):_g.parse(await a.json())}}}async function sz(e,t){let r,n;try{r=await zg(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 Pg(n,{fetchFn:t?.fetchFn});return{authorizationServerUrl:n,authorizationServerMetadata:o,resourceMetadata:r}}async function iz(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(au))throw new Error(`Incompatible auth server: does not support response type ${au}`);if(t.code_challenge_methods_supported&&!t.code_challenge_methods_supported.includes(cu))throw new Error(`Incompatible auth server: does not support code challenge method ${cu}`)}else a=new URL("/authorize",e);let c=await su(),u=c.code_verifier,l=c.code_challenge;return a.searchParams.set("response_type",au),a.searchParams.set("client_id",r.client_id),a.searchParams.set("code_challenge",l),a.searchParams.set("code_challenge_method",cu),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 az(e,t,r){return new URLSearchParams({grant_type:"authorization_code",code:e,code_verifier:t,redirect_uri:String(r)})}async function Tg(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=Jk(n,l);Gk(d,n,c,r)}let u=await(i??fetch)(a,{method:"POST",headers:c,body:r});if(!u.ok)throw await kg(u);return yg.parse(await u.json())}async function cz(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 Tg(e,{metadata:t,tokenRequestParams:a,clientInformation:r,addClientAuthentication:s,resource:o,fetchFn:i});return{refresh_token:n,...c}}async function uz(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=az(o,u,e.redirectUrl)}let c=await e.clientInformation();return Tg(t,{metadata:r,tokenRequestParams:a,clientInformation:c??void 0,addClientAuthentication:e.addClientAuthentication,resource:n,fetchFn:s})}async function lz(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 kg(i);return wg.parse(await i.json())}var to=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}},Rg=10,dz=13,or=32;function fu(e){}function Og(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=fu,onError:r=fu,onRetry:n=fu,onComment:o,maxBufferSize:s}=e,i=[],a=0,c=!0,u,l="",d=0,f,m=!1;function h(v){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,v.charCodeAt(0)===239&&v.charCodeAt(1)===187&&v.charCodeAt(2)===191&&(v=v.slice(3))),i.length===0){let J=y(v);J!==""&&(i.push(J),a=J.length),g();return}if(v.indexOf(`
|
|
36
|
+
`)===-1&&v.indexOf("\r")===-1){i.push(v),a+=v.length,g();return}i.push(v);let x=i.join("");i.length=0,a=0;let O=y(x);O!==""&&(i.push(O),a=O.length),g()}function g(){s!==void 0&&(a+l.length<=s||(m=!0,i.length=0,a=0,u=void 0,l="",d=0,f=void 0,r(new to(`Buffered data exceeded max buffer size of ${s} characters`,{type:"max-buffer-size-exceeded"}))))}function y(v){let x=0;if(v.indexOf("\r")===-1){let O=v.indexOf(`
|
|
37
|
+
`,x);for(;O!==-1;){if(x===O){d>0&&t({id:u,event:f,data:l}),u=void 0,l="",d=0,f=void 0,x=O+1,O=v.indexOf(`
|
|
38
|
+
`,x);continue}let J=v.charCodeAt(x);if(Eg(v,x,J)){let ae=v.charCodeAt(x+5)===or?x+6:x+5,he=v.slice(ae,O);if(d===0&&v.charCodeAt(O+1)===Rg){t({id:u,event:f,data:he}),u=void 0,l="",f=void 0,x=O+2,O=v.indexOf(`
|
|
39
|
+
`,x);continue}l=d===0?he:`${l}
|
|
40
|
+
${he}`,d++}else Ig(v,x,J)?f=v.slice(v.charCodeAt(x+6)===or?x+7:x+6,O)||void 0:S(v,x,O);x=O+1,O=v.indexOf(`
|
|
41
|
+
`,x)}return v.slice(x)}for(;x<v.length;){let O=v.indexOf("\r",x),J=v.indexOf(`
|
|
42
|
+
`,x),ae=-1;if(O!==-1&&J!==-1?ae=O<J?O:J:O!==-1?O===v.length-1?ae=-1:ae=O:J!==-1&&(ae=J),ae===-1)break;S(v,x,ae),x=ae+1,v.charCodeAt(x-1)===dz&&v.charCodeAt(x)===Rg&&x++}return v.slice(x)}function S(v,x,O){if(x===O){b();return}let J=v.charCodeAt(x);if(Eg(v,x,J)){let wt=v.charCodeAt(x+5)===or?x+6:x+5,Au=v.slice(wt,O);l=d===0?Au:`${l}
|
|
43
|
+
${Au}`,d++;return}if(Ig(v,x,J)){f=v.slice(v.charCodeAt(x+6)===or?x+7:x+6,O)||void 0;return}if(J===105&&v.charCodeAt(x+1)===100&&v.charCodeAt(x+2)===58){let wt=v.slice(v.charCodeAt(x+3)===or?x+4:x+3,O);u=wt.includes("\0")?void 0:wt;return}if(J===58){if(o){let wt=v.slice(x,O);o(wt.slice(v.charCodeAt(x+1)===or?2:1))}return}let ae=v.slice(x,O),he=ae.indexOf(":");if(he===-1){$(ae,"",ae);return}let vt=ae.slice(0,he),co=ae.charCodeAt(he+1)===or?2:1,uo=ae.slice(he+co);$(vt,uo,ae)}function $(v,x,O){switch(v){case"event":f=x||void 0;break;case"data":l=d===0?x:`${l}
|
|
44
|
+
${x}`,d++;break;case"id":u=x.includes("\0")?void 0:x;break;case"retry":/^\d+$/.test(x)?n(parseInt(x,10)):r(new to(`Invalid \`retry\` value: "${x}"`,{type:"invalid-retry",value:x,line:O}));break;default:r(new to(`Unknown field "${v.length>20?`${v.slice(0,20)}\u2026`:v}"`,{type:"unknown-field",field:v,value:x,line:O}));break}}function b(){d>0&&t({id:u,event:f,data:l}),u=void 0,l="",d=0,f=void 0}function T(v={}){if(v.consume&&i.length>0){let x=i.join("");S(x,0,x.length)}c=!0,u=void 0,l="",d=0,f=void 0,i.length=0,a=0,m=!1}return{feed:h,reset:T}}function Eg(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 Ig(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 zs=class extends TransformStream{constructor({onError:t,onRetry:r,onComment:n,maxBufferSize:o}={}){let s;super({start(i){s=Og({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 pz={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},Ct=class extends Error{constructor(t,r){super(`Streamable HTTP error: ${r}`),this.code=t}},Dr=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=mg(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??pz}async _authThenStart(){if(!this._authProvider)throw new _t("No auth provider");let t;try{t=await eo(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=ks(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 Ct(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 zs({onRetry:m=>{this._serverRetryMs=m}})).getReader();for(;;){let{value:m,done:h}=await l.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=Dt.parse(JSON.parse(m.data));$t(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(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 eo(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:vr(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 Ct(401,"Server returned 401 after successful authentication");let{resourceMetadataUrl:m,scope:h}=du(a);if(this._resourceMetadataUrl=m,this._scope=h,await eo(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}=du(a);if(g==="insufficient_scope"){let y=a.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===y)throw new Ct(403,"Server returned 403 after trying upscoping");if(h&&(this._scope=h),m&&(this._resourceMetadataUrl=m),this._lastUpscopingHeader=y??void 0,await eo(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new _t;return this.send(t)}}throw new Ct(a.status,`Error POSTing to endpoint: ${f}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,a.status===202){await a.body?.cancel(),uf(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(f=>this.onerror?.(f));return}let l=(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(l)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=>Dt.parse(h)):[Dt.parse(f)];for(let h of m)this.onmessage?.(h)}else throw await a.body?.cancel(),new Ct(-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 Ct(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 Pe from"node:fs";import{randomBytes as fz}from"node:crypto";import{homedir as Ag}from"node:os";import{resolve as Ts,join as mu,dirname as hu,basename as mz}from"node:path";var ro=["owner","shared","open"],Zr={brokerUrl:"wss://broker1.ours.network",port:3050,stateDir:Ts(Ag(),".ours"),gcIntervalMs:36e5,autoStart:!1,apiVisibility:"owner"};function no(){return process.env.OURS_CONFIG??mu(Ag(),".ours","config.json")}function hz(){let e;try{e=Pe.readFileSync(no(),"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=Ts(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"&&ro.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 gz(){let e=process.env.OURS_API_VISIBILITY?.trim().toLowerCase();return e&&ro.includes(e)?e:void 0}function _z(e){let t=process.env[e];if(t!==void 0)return t==="1"||t.toLowerCase()==="true"}function Cg(e){let t=process.env[e];if(t===void 0)return;let r=parseInt(t,10);return Number.isNaN(r)?void 0:r}function gu(){let e=hz();return{brokerUrl:process.env.OURS_BROKER_URL??e.brokerUrl??Zr.brokerUrl,port:Cg("OURS_PORT")??e.port??Zr.port,stateDir:Ts(process.env.OURS_STATE_DIR??e.stateDir??Zr.stateDir),gcIntervalMs:Cg("OURS_GC_INTERVAL_MS")??e.gcIntervalMs??Zr.gcIntervalMs,autoStart:_z("OURS_AUTOSTART")??e.autoStart??Zr.autoStart,apiVisibility:gz()??e.apiVisibility??Zr.apiVisibility,apiToken:process.env.OURS_API_TOKEN?.trim()||e.apiToken,stt:yz(e.stt)}}function yz(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 vz="daemon-token";function wz(e){return mu(e.stateDir,vz)}function _u(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=wz(e);try{let i=Pe.readFileSync(o,"utf8").trim();if(i)return{token:i,source:"file"}}catch{}if(!t.generate)return null;let s=fz(32).toString("hex");try{Pe.mkdirSync(hu(o),{recursive:!0}),Pe.writeFileSync(o,s+`
|
|
45
|
+
`,{mode:384}),Pe.chmodSync(o,384)}catch{}return{token:s,source:"generated"}}function Ng(e){let t=no();Pe.mkdirSync(hu(t),{recursive:!0}),Pe.writeFileSync(t,JSON.stringify(e,null,2)+`
|
|
46
|
+
`,{mode:384});try{Pe.chmodSync(t,384)}catch{}return t}var Ps=".ours-identity";function Rs(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 yu(e){let t=Ts(e);return mz(t)===Ps?t:mu(t,Ps)}function jg(e,t,r=!1){let n=Rs(t),o=yu(e);if(!r&&Pe.existsSync(o))throw new Error(`${o} already exists \u2014 pass overwrite to replace it`);return Pe.mkdirSync(hu(o),{recursive:!0}),Pe.writeFileSync(o,JSON.stringify(n,null,2)+`
|
|
47
|
+
`),o}import{runProxy as aP}from"@ours.network/sdk/connector";import qg from"node:process";var Es=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),bz(r)}clear(){this._buffer=void 0}};function bz(e){return Dt.parse(JSON.parse(e))}function Mg(e){return JSON.stringify(e)+`
|
|
49
|
+
`}var Is=class{constructor(t=qg.stdin,r=qg.stdout){this._stdin=t,this._stdout=r,this._readBuffer=new Es,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=Mg(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};import{Readable as Ug}from"stream";import Tz from"crypto";var Sz=global.Request,bu=class extends Sz{constructor(e,t){typeof e=="object"&&Fr in e&&(e=e[Fr]()),typeof t?.body?.getReader<"u"&&(t.duplex??="half"),super(e,t)}},$z=e=>{let t=[],r=e.rawHeaders;for(let n=0;n<r.length;n+=2){let{[n]:o,[n+1]:s}=r;o.charCodeAt(0)!==58&&t.push([o,s])}return new Headers(t)},xz=Symbol("wrapBodyStream"),kz=(e,t,r,n,o)=>{let s={method:e,headers:r,signal:o.signal};if(e==="TRACE"){s.method="GET";let i=new bu(t,s);return Object.defineProperty(i,"method",{get(){return"TRACE"}}),i}if(!(e==="GET"||e==="HEAD"))if("rawBody"in n&&n.rawBody instanceof Buffer)s.body=new ReadableStream({start(i){i.enqueue(n.rawBody),i.close()}});else if(n[xz]){let i;s.body=new ReadableStream({async pull(a){try{i||=Ug.toWeb(n).getReader();let{done:c,value:u}=await i.read();c?a.close():a.enqueue(u)}catch(c){a.error(c)}}})}else s.body=Ug.toWeb(n);return new bu(t,s)},Fr=Symbol("getRequestCache"),Zg=Symbol("requestCache"),vu=Symbol("incomingKey"),Dg=Symbol("urlKey"),zz=Symbol("headersKey"),wu=Symbol("abortControllerKey"),Pz=Symbol("getAbortController"),Cs={get method(){return this[vu].method||"GET"},get url(){return this[Dg]},get headers(){return this[zz]||=$z(this[vu])},[Pz](){return this[Fr](),this[wu]},[Fr](){return this[wu]||=new AbortController,this[Zg]||=kz(this.method,this[Dg],this.headers,this[vu],this[wu])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach(e=>{Object.defineProperty(Cs,e,{get(){return this[Fr]()[e]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(Cs,e,{value:function(){return this[Fr]()[e]()}})});Object.defineProperty(Cs,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,r){let n={method:this.method,url:this.url,headers:this.headers,nativeRequest:this[Zg]};return`Request (lightweight) ${r(n,{...t,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(Cs,bu.prototype);var Su=Symbol("responseCache"),Lr=Symbol("getResponseCache"),Os=Symbol("cache"),$u=global.Response,oo=class Lg{#t;#e;[Lr](){return delete this[Os],this[Su]||=new $u(this.#t,this.#e)}constructor(t,r){let n;if(this.#t=t,r instanceof Lg){let o=r[Su];if(o){this.#e=o,this[Lr]();return}else this.#e=r.#e,n=new Headers(r.#e.headers)}else this.#e=r;(typeof t=="string"||typeof t?.getReader<"u"||t instanceof Blob||t instanceof Uint8Array)&&(this[Os]=[r?.status||200,t,n||r?.headers])}get headers(){let t=this[Os];return t?(t[2]instanceof Headers||(t[2]=new Headers(t[2]||{"content-type":"text/plain; charset=UTF-8"})),t[2]):this[Lr]().headers}get status(){return this[Os]?.[0]??this[Lr]().status}get ok(){let t=this.status;return t>=200&&t<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(e=>{Object.defineProperty(oo.prototype,e,{get(){return this[Lr]()[e]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(e=>{Object.defineProperty(oo.prototype,e,{value:function(){return this[Lr]()[e]()}})});Object.defineProperty(oo.prototype,Symbol.for("nodejs.util.inspect.custom"),{value:function(e,t,r){let n={status:this.status,headers:this.headers,ok:this.ok,nativeResponse:this[Su]};return`Response (lightweight) ${r(n,{...t,depth:e==null?null:e-1})}`}});Object.setPrototypeOf(oo,$u);Object.setPrototypeOf(oo.prototype,$u.prototype);typeof global.crypto>"u"&&(global.crypto=Tz);var p1=Symbol("outgoingEnded"),f1=Symbol("incomingDraining");var m1=64*1024*1024;var Fg={createStdioServer:()=>new Is,createHttpClient:(e,t)=>new Dr(e,t)};import{accessSync as Ez,constants as Iz}from"node:fs";var Vg=e=>{try{return Ez(e,Iz.R_OK),!0}catch{return!1}};var Oz=e=>` \u2022 ${e.filename} \u2014 ${e.mime||"application/octet-stream"}, ${e.size} B, sha256 ${e.sha256} \u2014 from ${e.sender} \u2014 wire_id ${e.wire_id}`;function Cz(e,t){let r=e;if(!r||r.isError)return!1;let n=r.structuredContent?.files;if(!Array.isArray(n))return!1;let o=n.filter(a=>!!a&&typeof a=="object"&&typeof a.path=="string"&&typeof a.wire_id=="string");if(o.length===0)return!1;let s=o.filter(a=>a.kind!=="voice_message"&&!t(a.path));for(let a of o)a.readable=t(a.path);if(s.length===0)return!1;let i=[`${s.length} of ${o.length} received file(s) are NOT readable by your OS user: the ours daemon runs as a different OS user and keeps its files dir private. Nothing was lost \u2014 the bytes are safely on disk. IGNORE the on-disk paths reported below for these files; you cannot open them.`,"","TELL THE USER what arrived (details below) and ASK WHERE TO SAVE each file on this filesystem. Then call save_file({ wire_id, dest_path }) with the path they choose: the ours connector streams the bytes daemon\u2192proxy\u2192disk and writes them as YOUR OS user. The bytes never enter this conversation.","","Awaiting a destination:",...s.map(Oz)];return r.content=[{type:"text",text:i.join(`
|
|
50
|
+
`)},...r.content??[]],!0}function Hg(e,t){let r=e;return!r||typeof r!="object"||!("result"in r)?!1:Cz(r.result,t)}var xu=["openai-compatible","elevenlabs","deepgram","custom"],C1=5*1024*1024;function so(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: ${xu.join(" | ")}) \u2014 ${t}`};let r=e.provider.trim().toLowerCase();if(!xu.includes(r))return{ready:!1,reason:`unknown STT provider "${e.provider}" (expected: ${xu.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}}function Az(e){let t=e.lastIndexOf(")");if(t<0)return null;let r=e.slice(t+1).trimStart();return/^[A-Za-z](?:\s|$)/.test(r)?r[0]:null}function Bg(e){let t=Az(e);return t==="Z"||t==="X"||t==="x"}import{chmodSync as Kg,closeSync as Nz,existsSync as Wg,mkdirSync as jz,openSync as Jg,readFileSync as Yg,readSync as Xg,renameSync as Mz,statSync as qz,unlinkSync as Qg,writeFileSync as Uz,writeSync as Dz}from"node:fs";import{spawnSync as As}from"node:child_process";import{dirname as Zz}from"node:path";var qe=[{value:"openai-compatible",label:"OpenAI-compatible",detail:"an OpenAI-style /v1 transcription endpoint"},{value:"elevenlabs",label:"ElevenLabs",detail:"ElevenLabs speech-to-text"},{value:"deepgram",label:"Deepgram",detail:"Deepgram speech-to-text"},{value:"custom",label:"Custom HTTP endpoint",detail:"a fully specified transcription URL"}],Se=class extends Error{constructor(r){super(r);this.reason=r}};function Lz(e){if(!Wg(e))return{};let t=JSON.parse(Yg(e,"utf8"));if(!t||typeof t!="object"||Array.isArray(t))throw new Error("config root must be a JSON object");return t}function Fz(e){return Wg(e)?{exists:!0,text:Yg(e,"utf8"),mode:qz(e).mode&511}:{exists:!1}}function Vz(e,t){e_(e,`${JSON.stringify(t,null,2)}
|
|
51
|
+
`,384)}function e_(e,t,r){jz(Zz(e),{recursive:!0,mode:448});let n=`${e}.tmp-${process.pid}-${Date.now()}`;try{Uz(n,t,{encoding:"utf8",mode:r,flag:"wx"}),Kg(n,r),Mz(n,e),Kg(e,r)}catch(o){try{Qg(n)}catch{}throw o}}function Hz(e,t){if(!t.exists){try{Qg(e)}catch{}return}e_(e,t.text,t.mode)}async function Bz(e,t,r,n){let o=Fz(e);try{Vz(e,t)}catch{return{ok:!1,stage:"write",rolledBack:!0,daemonRestored:!0}}if(r!=="managed")return{ok:!0,stage:"write"};let s;try{s=n?await n():{ok:!1}}catch{s={ok:!1}}if(s.ok)return{ok:!0,stage:"apply"};try{Hz(e,o)}catch{return{ok:!1,stage:"rollback",rolledBack:!1,daemonRestored:!1}}let i;try{i=n?await n():{ok:!1}}catch{i={ok:!1}}return{ok:!1,stage:i.ok?"apply":"rollback",rolledBack:!0,daemonRestored:i.ok}}function Gg(e,t){let r={...e},n=[["provider",t.OURS_STT_PROVIDER],["apiKey",t.OURS_STT_API_KEY],["model",t.OURS_STT_MODEL],["baseUrl",t.OURS_STT_BASE_URL],["language",t.OURS_STT_LANGUAGE]];for(let[o,s]of n)s?.trim()&&(r[o]=s.trim());return r}function Kz(e){let t=e.trim();return t.length<8?{ok:!1,reason:"API key must contain at least 8 characters"}:/[\s\x00-\x1f\x7f]/.test(t)?{ok:!1,reason:"API key must not contain whitespace or control characters"}:{ok:!0,value:t}}function Jz(){try{return Jg("/dev/tty","r+")}catch{if(process.stdin.isTTY&&process.stdout.isTTY)try{return Jg("/dev/stdin","r+")}catch{}return null}}function Ue(e,t){Dz(e,t)}function ku(e){let t=Buffer.alloc(1);try{return Xg(e,t,0,1,null)===1?t[0]:null}catch(r){throw r.code==="EINTR"?new Se("cancel"):r}}function t_(e){let t="";for(let r=0;r<12;r++){let n=ku(e);if(n===null)break;let o=String.fromCharCode(n);if(t+=o,/[A-Za-z~]$/.test(t))break}return t}function r_(e,t){let r=As("stty",["-g"],{stdio:[e,"pipe","ignore"],encoding:"utf8"}),n=(r.stdout||"").trim();if(r.status!==0||!n)throw new Se("unavailable");if(As("stty",["-icanon","-echo","-isig","min","1","time","0"],{stdio:[e,"ignore","ignore"]}).status!==0)throw new Se("unavailable");let s=!1,i=()=>{if(s)return;s=!0,As("stty",[n],{stdio:[e,"ignore","ignore"]}).status!==0&&As("stty",["sane"],{stdio:[e,"ignore","ignore"]})};process.once("exit",i);try{return t()}finally{process.removeListener("exit",i),i()}}function Gz(e,t,r,n){return r_(e,()=>{Ue(e,t);let o="";for(;;){let i=ku(e);if(i===null||i===4)throw new Se("eof");if(i===3)throw new Se("cancel");if(i===10||i===13){Ue(e,`
|
|
52
|
+
`);break}if(i===127||i===8){o.length&&(o=o.slice(0,-1),n||Ue(e,"\b \b"));continue}if(i===27){t_(e);continue}if(i<32||o.length>=16384)continue;let a=String.fromCharCode(i);o+=a,n||Ue(e,a)}let s=o.trim();return s===""?r:s})}function Ns(e,t,r=""){Ue(e,t);let n=[],o=0;for(;;){let i=Buffer.alloc(1024),a;try{a=Xg(e,i,0,i.length,null)}catch(l){throw l.code==="EINTR"?new Se("cancel"):l}if(a===0)throw new Se("eof");let c=i.subarray(0,a).indexOf(10),u=c>=0?i.subarray(0,c):i.subarray(0,a);if(n.push(u),o+=u.length,o>16384)throw new Error("prompt input too long");if(c>=0)break}let s=Buffer.concat(n).toString("utf8").replace(/\r$/,"").trim();return s===""?r:s}function at(e,t,r="",n=!1){try{return Gz(e,t,r,n)}catch(o){if(o instanceof Se&&o.reason==="unavailable"&&!n)return Ns(e,t,r);throw o}}function Wz(e,t,r){let n=at(e,`${t} ${r?"[Y/n]":"[y/N]"} `,r?"y":"n");return/^y(?:es)?$/i.test(n)}function Yz(e,t){let r=qe.findIndex(n=>n.value===t);r<0&&(r=0);try{return r_(e,()=>{Ue(e,`Choose one transcription provider (\u2191/\u2193 or j/k, then Enter; q cancels):
|
|
53
|
+
`);let n=!1,o=()=>{n&&Ue(e,`\x1B[${qe.length}A`),n=!0,qe.forEach((s,i)=>{Ue(e,`\r\x1B[K ${i===r?">":" "} ${i===r?"(*)":"( )"} ${s.label} \u2014 ${s.detail}
|
|
54
|
+
`)})};for(o();;){let s=ku(e);if(s===null||s===4)throw new Se("eof");if(s===3||s===113||s===81)throw new Se("cancel");if(s===10||s===13)return Ue(e,`
|
|
55
|
+
`),qe[r].value;if(s>=49&&s<=52)r=s-49;else if(s===107||s===75)r=(r-1+qe.length)%qe.length;else if(s===106||s===74)r=(r+1)%qe.length;else if(s===27){let i=t_(e);i==="[A"||i==="OA"?r=(r-1+qe.length)%qe.length:(i==="[B"||i==="OB")&&(r=(r+1)%qe.length)}else continue;o()}})}catch(n){if(!(n instanceof Se)||n.reason!=="unavailable")throw n;Ue(e,`Choose one transcription provider:
|
|
56
|
+
`),qe.forEach((s,i)=>{Ue(e,` ${i+1}. ${s.label} \u2014 ${s.detail}
|
|
57
|
+
`)});let o=Ns(e,`Select 1-${qe.length}: `);if(!/^[1-4]$/.test(o))throw new Se("cancel");return qe[Number(o)-1].value}}function Xz(e){let t=e.stt;return t&&typeof t=="object"&&!Array.isArray(t)?{...t}:{}}async function n_(e){let t=e.env??process.env,r=e.stdout??(i=>process.stdout.write(i)),n=(i="")=>r(`${i}
|
|
58
|
+
`),o=e.daemonState??"stopped",s=null;try{let i;try{i=Lz(e.configFile)}catch{return n(`voice setup: ${e.configFile} is not valid JSON; no changes made.`),1}let a=Xz(i),c=so(Gg(a,t)),u=t.OURS_STT_API_KEY?.trim()?"environment":a.apiKey?.trim()?"config":"missing";if(s=t.OURS_ASSUME_YES?null:Jz(),n(`ours-mcp voice-setup \u2014 ${e.configFile}`),c.ready){if(n(`voice transcription is already ready (${c.provider}; API key from ${u}).`),s===null)return 0;if(!Wz(s,"Change the current voice settings?",!1))return n("kept the current voice settings; no changes made."),0}else if(n("Voice transcription is not ready. This command keeps the provider key hidden."),s===null)return n("No interactive terminal is available; no changes made."),n("Run `ours-mcp voice-setup` in a terminal, or configure OURS_STT_* environment values."),0;n("");let l=String(t.OURS_STT_PROVIDER||a.provider||"").trim().toLowerCase(),d=Yz(s,l),f=String(t.OURS_STT_MODEL||a.model||"").trim(),m=String(t.OURS_STT_BASE_URL||a.baseUrl||"").trim(),h=String(a.custom?.url||"").trim();d==="openai-compatible"?(m=at(s,`Provider /v1 base URL${m?` [${m}]`:""}: `,m),f=at(s,`Model name (sent verbatim)${f?` [${f}]`:""}: `,f)):d==="elevenlabs"?(f=at(s,`ElevenLabs model id${f?` [${f}]`:""}: `,f),m=at(s,`Custom base URL (Enter for provider default)${m?` [${m}]`:""}: `,m)):d==="deepgram"?(f=at(s,`Model (optional; Enter for provider default)${f?` [${f}]`:""}: `,f),m=at(s,`Custom base URL (optional)${m?` [${m}]`:""}: `,m)):(h=at(s,`Full transcription endpoint URL${h?` [${h}]`:""}: `,h),f=at(s,`Model (optional unless URL contains {model})${f?` [${f}]`:""}: `,f));let g=t.OURS_STT_API_KEY?.trim(),y=String(a.apiKey||"").trim();if(g)n("API key: using OURS_STT_API_KEY from the environment; it will not be copied to config.");else{let v=y?"Provider API key [configured; Enter keeps it]: ":"Provider API key (input hidden): ",x;try{x=at(s,v,y,!0)}catch(J){if(!(J instanceof Se)||J.reason!=="unavailable")throw J;if(Ue(s,`
|
|
62
59
|
Secure hidden input is unavailable on this terminal.
|
|
63
|
-
`),
|
|
64
|
-
`),
|
|
60
|
+
`),Ue(s,`Visible fallback will echo the token on screen and may leave it in scrollback.
|
|
61
|
+
`),Ns(s,"Type SHOW to enter the token visibly, or press Enter to cancel: ")!=="SHOW")throw new Se("cancel");x=Ns(s,"Provider API key (VISIBLE): ",y)}let O=Kz(x);if(!O.ok)return n(`Voice setup was not saved: ${O.reason}.`),1;y=O.value}let S={...a,provider:d,...y?{apiKey:y}:{},...f?{model:f}:{},...m?{baseUrl:m}:{},...d==="custom"&&h?{custom:{...a.custom??{},url:h}}:{}},$=so(Gg(S,t));if(!$.ready)return n(`Voice setup was not saved: ${$.reason}.`),1;if(e.dryRun)return n(`voice transcription would be configured (${d}); API key stays hidden.`),n("dry-run: config, daemon, and existing settings were not changed."),0;let b={...i,stt:S};o==="managed"&&n("Restarting ours-mcp to apply and verify voice transcription\u2026");let T=await Bz(e.configFile,b,o,e.apply);return!T.ok&&T.stage==="write"?(n(`Could not write ${e.configFile}; the prior config is intact.`),1):o==="stopped"?(n(`voice transcription configured (${d}); API key saved in mode-0600 config.`),n("The daemon is stopped; run `ours-mcp start` to apply it."),0):o==="external"?(n(`voice transcription configured (${d}); API key saved in mode-0600 config.`),n("The daemon has no managed PID; restart its external launcher to apply the new settings."),0):T.ok?(n(`voice transcription: ready (${d}).`),n("API key saved in mode-0600 config and never displayed."),0):T.rolledBack?(n("Voice readiness check failed; restored the exact prior config."),T.daemonRestored?(n("The prior config and daemon state were restored; voice setup was not changed."),2):(n("The prior config is restored, but the daemon did not restart; run `ours-mcp status`."),2)):(n("Voice setup failed and automatic config rollback also failed; inspect the config before restarting."),2)}catch(i){return i instanceof Se?i.reason==="cancel"?(n(""),n("voice setup cancelled; no configuration changes were made."),130):i.reason==="eof"?(n(""),n("voice setup ended at EOF; no configuration changes were made."),1):(n("Secure interactive input is unavailable on this terminal; no changes made."),1):(n("voice setup failed unexpectedly; no credential was displayed."),1)}finally{if(s!==null)try{Nz(s)}catch{}}}var o_=`ours-mcp voice-setup \u2014 configure voice transcription securely
|
|
65
62
|
|
|
66
63
|
Usage: ours-mcp voice-setup [--dry-run]
|
|
67
64
|
|
|
@@ -76,53 +73,53 @@ exact prior config.
|
|
|
76
73
|
|
|
77
74
|
Headless automation remains environment-driven through OURS_STT_PROVIDER,
|
|
78
75
|
OURS_STT_API_KEY, OURS_STT_MODEL, OURS_STT_BASE_URL, and OURS_STT_LANGUAGE.
|
|
79
|
-
Exit 2 means restart/readiness failed after a write and rollback was attempted.`;import*as
|
|
80
|
-
`}async function
|
|
81
|
-
`),
|
|
82
|
-
`),
|
|
83
|
-
`),s.ok?(
|
|
84
|
-
daemon is running (pid ${i}); restart now to apply? [y/N]: `)).trim().toLowerCase();c=
|
|
85
|
-
${
|
|
86
|
-
`))if(m.trim())try{
|
|
76
|
+
Exit 2 means restart/readiness failed after a write and rollback was attempted.`;import*as sr from"node:fs";import{join as Qz}from"node:path";var eP="startup-progress.json",tP=1,s_={initializing:"Initializing daemon",wrapper:"Starting protocol runtime",registrar:"Starting local contact book",identities:"Restoring identities",reconciliation:"Reconciling restored identities",server:"Opening local API",ready:"Daemon ready",failed:"Daemon startup failed"};function rP(e){return Qz(e,eP)}function nP(e){return typeof e=="string"&&Object.hasOwn(s_,e)}function i_(e){try{let t=JSON.parse(sr.readFileSync(rP(e),"utf8"));return t.version!==tP||!Number.isInteger(t.pid)||(t.pid??0)<=0||typeof t.bootId!="string"||!t.bootId||!nP(t.phase)||!Number.isFinite(t.startedAt)||!Number.isFinite(t.updatedAt)||(t.completed!==void 0||t.total!==void 0)&&(!Number.isInteger(t.completed)||!Number.isInteger(t.total)||(t.completed??-1)<0||(t.total??-1)<0||(t.completed??0)>(t.total??0))?null:t}catch{return null}}function zu(e){let t=s_[e.phase];return e.phase==="identities"&&e.completed!==void 0&&e.total!==void 0?`${t} ${e.completed}/${e.total}`:t}function a_(e,t){let r=`startup: ${zu(e)}`;return t?`\r${r}\x1B[K`:`${r}
|
|
77
|
+
`}async function c_(e){let t=e.now??Date.now,r=e.sleep??(c=>new Promise(u=>setTimeout(u,c))),n=t(),o=n,s=-1,i="",a=null;for(;;){if(await e.isReady())return{ok:!0,elapsedMs:t()-n,lastProgress:a};let c=e.readProgress();if(c?.pid===e.pid){a=c,c.updatedAt>s&&(s=c.updatedAt,o=t());let f=`${c.phase}:${c.completed??""}:${c.total??""}`;if(f!==i&&(i=f,e.onProgress?.(c)),c.phase==="failed")return{ok:!1,reason:"daemon-reported-failure",elapsedMs:t()-n,lastProgress:a}}if(!e.isProcessAlive())return{ok:!1,reason:"process-exited",elapsedMs:t()-n,lastProgress:a};let u=t()-n;if(u>=e.absoluteMs)return{ok:!1,reason:"absolute-timeout",elapsedMs:u,lastProgress:a};if(t()-o>=e.inactivityMs)return{ok:!1,reason:"inactivity-timeout",elapsedMs:u,lastProgress:a};let l=e.absoluteMs-u,d=e.inactivityMs-(t()-o);await r(Math.max(1,Math.min(e.pollMs,l,d)))}}var cP=["1","true","yes","on"].includes((process.env.OURS_FILES_ALWAYS_PROMPT??"").trim().toLowerCase());if(!process.env.XDG_RUNTIME_DIR&&typeof process.getuid=="function"){let e=`/run/user/${process.getuid()}`;D.existsSync(e)&&(process.env.XDG_RUNTIME_DIR=e)}var ct=gu(),Ee=ct.stateDir,Q=ct.port,ao=()=>{let e=_u(ct,{generate:!1})?.token??null;return e?{"x-ours-api-token":e}:{}},Br=ct.brokerUrl,cr=yt(Ee,"daemon.pid"),ir=yt(Ee,"daemon.log"),Nt=sP(import.meta.url),w=(...e)=>process.stdout.write(`${e.join(" ")}
|
|
78
|
+
`),K=(...e)=>process.stderr.write(`${e.join(" ")}
|
|
79
|
+
`),ar="0.17.0-nightly.2";async function Iu(){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:${Q}${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 u_(e){if(w(` cli: v${ar}`),e?.version){let t=e.version!==ar;w(` daemon: v${e.version}${e.compat?` (compat ${e.compat})`:""}`+(t?` \u26A0 differs from CLI \u2014 \`ours-mcp restart\` to load v${ar}`:""))}else w(" daemon: version unknown (running build predates /version \u2014 restart to update)")}var Us=e=>new Promise(t=>setTimeout(t,e));function uP(){try{let e=parseInt(D.readFileSync(cr,"utf8").trim(),10);return Number.isFinite(e)?e:null}catch{return null}}function Ms(e){try{if(process.kill(e,0),process.platform==="linux")try{if(Bg(D.readFileSync(`/proc/${e}/stat`,"utf8")))return!1}catch{try{process.kill(e,0)}catch{return!1}}return!0}catch{return!1}}function Kr(){let e=uP();if(e&&Ms(e))return e;if(e)try{D.rmSync(cr,{force:!0})}catch{}return null}function jt(e,t=1e3){return new Promise(r=>{let n=oP({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 lP(e,t=3e4){let r=Date.now()+t;for(;Date.now()<r;){if(await jt(e))return!0;await Us(400)}return!1}function Cu(e,t){let r=Number(process.env[e]||"");return Number.isFinite(r)&&r>0?r:t}var __=Cu("OURS_TEST_STARTUP_ABSOLUTE_MS",18e4),y_=Cu("OURS_TEST_STARTUP_INACTIVITY_MS",3e4),v_=Cu("OURS_TEST_STARTUP_POLL_MS",400);async function dP(e){let t=new AbortController,r=setTimeout(()=>t.abort(),Math.min(1e3,v_));try{let n=await fetch(`http://127.0.0.1:${e}/identities`,{signal:t.signal,headers:ao()}),o=n.ok;try{await n.body?.cancel()}catch{}return o}catch{return!1}finally{clearTimeout(r)}}function l_(e){return e<1e3?`${Math.round(e)}ms`:e%6e4===0?`${e/6e4}m`:`${Math.round(e/1e3)}s`}function pP(e,t){let r=t?` Last phase: ${zu(t)}.`:"";return e==="process-exited"||e==="daemon-reported-failure"?`daemon exited before becoming ready.${r}`:e==="inactivity-timeout"?`daemon startup made no observable progress for ${l_(y_)}.${r} The process is still running, but startup is stalled.`:`daemon startup did not finish within ${l_(__)}.${r} The bounded wait expired.`}async function d_(){let e=Kr();if(e){w(`ours-mcp is already running (pid ${e}, port ${Q}).`);return}D.mkdirSync(Ee,{recursive:!0});let t=D.openSync(ir,"a"),r=m_(process.execPath,[Nt,"serve"],{detached:!0,stdio:["ignore",t,t],env:{...process.env,OURS_TRANSPORT:"http",OURS_PORT:String(Q),OURS_BROKER_URL:Br,OURS_STATE_DIR:Ee}});r.unref(),r.pid||(K("failed to spawn the daemon."),process.exit(1)),D.writeFileSync(cr,String(r.pid)),w(`starting ours-mcp (pid ${r.pid})\u2026`);let n=!!process.stderr.isTTY,o=!1,s=await c_({pid:r.pid,absoluteMs:__,inactivityMs:y_,pollMs:v_,isProcessAlive:()=>Ms(r.pid),isReady:()=>dP(Q),readProgress:()=>i_(Ee),onProgress:i=>{o=!0,process.stderr.write(a_(i,n))}});o&&n&&process.stderr.write(`
|
|
80
|
+
`),s.ok?(w(`ours-mcp is up on http://localhost:${Q}/mcp`),w(` broker: ${Br}`),w(` state: ${Ee}`),w(` logs: ${ir}`)):(K(`${pP(s.reason,s.lastProgress)} Check ${ir}.`),process.exit(1))}async function fP(){if(!await jt(Q)){if(!Kr()){D.mkdirSync(Ee,{recursive:!0});let e=D.openSync(ir,"a"),t=m_(process.execPath,[Nt,"serve"],{detached:!0,stdio:["ignore",e,e],env:{...process.env,OURS_TRANSPORT:"http",OURS_PORT:String(Q),OURS_BROKER_URL:Br,OURS_STATE_DIR:Ee}});if(t.unref(),t.pid)try{D.writeFileSync(cr,String(t.pid))}catch{}}await lP(Q)}}async function qs(){let e=Kr();if(!e){w("ours-mcp is not running.");return}w(`stopping ours-mcp (pid ${e})\u2026`);try{process.kill(e,"SIGTERM")}catch(t){K(`failed to signal pid ${e}: ${String(t)}`)}for(let t=0;t<25&&Ms(e);t++)await Us(200);if(Ms(e)){K(`pid ${e} did not exit; sending SIGKILL.`);try{process.kill(e,"SIGKILL")}catch{}}try{D.rmSync(cr,{force:!0})}catch{}w("stopped.")}async function mP(){let e=Kr();if(!e){if(await jt(Q)){let n=await Iu();w("ours-mcp: running (no pidfile \u2014 likely a stale process or external launcher)"),w(` url: http://localhost:${Q}/mcp (reachable)`),u_(n);return}w("ours-mcp: stopped"),w(` cli: v${ar}`),process.exitCode=1;return}let t=await jt(Q),r=t?await Iu():null;w("ours-mcp: running"),w(` pid: ${e}`),w(` url: http://localhost:${Q}/mcp ${t?"(reachable)":"(port not answering!)"}`),w(` broker: ${Br}`),w(` state: ${Ee}`),w(` logs: ${ir}`),u_(r)}async function hP(){if(w(`ours-mcp v${ar}`),await jt(Q)){let e=await Iu();e?.version?w(`running daemon: v${e.version}`+(e.version!==ar?" (differs \u2014 restart to update)":"")):w("running daemon: version unknown (predates /version)")}else w("daemon: not running")}async function gP(){let e=gu(),t=no();w(`ours-mcp setup \u2014 ${t}`),w("Enter a value, or press Enter to keep the current [bracketed] one."),w("");let r=js({input:process.stdin,output:process.stdout}),n;try{let l=async(ae,he)=>{let vt=(await r.question(` ${ae} [${he}]: `)).trim();return vt===""?he:vt},d=await l("broker URL",e.brokerUrl),f=await l("HTTP port",String(e.port)),m=await l("state dir",e.stateDir),h=await l("GC interval (ms)",String(e.gcIntervalMs)),g=await l("proxy auto-starts daemon (true/false)",String(e.autoStart)),y=await l("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 S=(await r.question(` STT provider (openai-compatible / elevenlabs / deepgram / custom, empty=off) [${e.stt?.provider??""}]: `)).trim()||(e.stt?.provider??""),$=e.stt?.model??"",b=e.stt?.baseUrl??"";S&&($=await l("STT model (verbatim, e.g. whisper-large-v3-turbo / scribe_v1 / nova-2)",$),b=await l("STT base URL (required for openai-compatible; empty = provider default)",b),w(" (API key is not echoed here. Run `ours-mcp voice-setup` for guided hidden input,"),w(" or set OURS_STT_API_KEY for environment-only secret injection.)"));let T=parseInt(f,10);(!Number.isFinite(T)||T<=0)&&(K(`invalid port: ${f}`),process.exit(1));let v=parseInt(h,10);(!Number.isFinite(v)||v<=0)&&(K(`invalid GC interval: ${h}`),process.exit(1));let x=g.toLowerCase()==="true"||g==="1",O=y.trim().toLowerCase();ro.includes(O)||(K(`invalid visibility: ${y} (expected one of ${ro.join(", ")})`),process.exit(1));let J=S?{...e.stt??{},provider:S,...$?{model:$}:{},...b?{baseUrl:b}:{}}:e.stt;n={brokerUrl:d,port:T,stateDir:g_(m),gcIntervalMs:v,autoStart:x,apiVisibility:O,...e.apiToken?{apiToken:e.apiToken}:{},...J?{stt:J}:{}}}finally{r.close()}Ng(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(l=>process.env[l]!==void 0);s.length&&(w(""),w(`note: these env vars are set and OVERRIDE the file at runtime: ${s.join(", ")}`));let i=Kr();if(!i)return;let a=js({input:process.stdin,output:process.stdout}),c=!1;try{let l=(await a.question(`
|
|
81
|
+
daemon is running (pid ${i}); restart now to apply? [y/N]: `)).trim().toLowerCase();c=l==="y"||l==="yes"}finally{a.close()}if(!c){w("not restarting \u2014 changes apply on the next `ours-mcp restart`.");return}await qs();let u=Hr(process.execPath,[Nt,"start"],{stdio:"inherit"});u.status!==0&&process.exit(u.status??1)}function _P(e){let t=so(ct.stt),r=ct.stt?.provider?.trim().toLowerCase()||null,n=process.env.OURS_STT_API_KEY?.trim()?"environment":ct.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}`)}async function yP(e){if(e.includes("--help")||e.includes("-h")){w(o_);return}let t=new Set(["--dry-run"]);if(e.filter(i=>!t.has(i)).length){K("voice-setup: unsupported command-line option or argument"),K("The provider key is never accepted as a CLI argument. Run `ours-mcp voice-setup --help`."),process.exitCode=1;return}let n=Kr()!==null,o=await jt(Q),s=await n_({configFile:no(),env:process.env,dryRun:e.includes("--dry-run"),daemonState:n?"managed":o?"external":"stopped",apply:async()=>{let i=Hr(process.execPath,[Nt,"restart"],{stdio:"inherit"});if(i.error||i.status!==0)return{ok:!1};let a=Hr(process.execPath,[Nt,"voice-status","--json"],{encoding:"utf8",stdio:["ignore","pipe","ignore"]});if(a.error||a.status!==0)return{ok:!1};try{return{ok:JSON.parse(a.stdout||"{}").ready===!0}}catch{return{ok:!1}}}});s!==0&&(process.exitCode=s)}function Tu(e,t,r){return e.includes(r)?{value:!1,set:!0}:e.includes(t)?{value:!0,set:!0}:{value:void 0,set:!1}}function Ru(e,t){let r=e.indexOf(t);return r>=0&&r+1<e.length?e[r+1]:void 0}async function vP(e){let t=Ru(e,"--name"),r=Tu(e,"--force-bind","--no-force-bind"),n=Tu(e,"--local-book","--no-local-book"),o=Tu(e,"--auto-accept-local","--no-auto-accept-local"),s=e.includes("--overwrite"),i=e.includes("--print"),a=Ru(e,"--path")??Ru(e,"--dir")??process.cwd(),c=t!==void 0||r.set||n.set||o.set||i,u;if(c?((!t||!t.trim())&&(K("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 wP(),i){w(JSON.stringify(Rs(u),null,2));return}let l=yu(a);if(!s&&D.existsSync(l)){c&&(K(`define-local-identity-file: ${l} already exists \u2014 pass --overwrite to replace it.`),process.exit(1));let f=js({input:process.stdin,output:process.stdout}),m=!1;try{let h=(await f.question(`
|
|
82
|
+
${l} 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=jg(a,u,!0);w(""),w(`wrote ${d}:`),w(JSON.stringify(Rs(u),null,2))}async function wP(){w("ours-mcp define-local-identity-file \u2014 interactive"),w(`Answer the prompts; the result is written to ${yt(process.cwd(),Ps)}.`),w("");let e=js({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||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 bP(e){let t=(e[0]??"").trim();(!t||t.startsWith("--"))&&(K('usage: ours-mcp create-root "<your name>"'),process.exit(1)),await jt(Q)||(K(`create-root: the daemon is not running on port ${Q} \u2014 start it with \`ours-mcp start\`.`),process.exit(1));let r=new Dr(new URL(`http://127.0.0.1:${Q}/mcp`),{requestInit:{headers:ao()}}),n=new xs({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)){w(`create-root: ${s.split("\u2014")[0].trim()} \u2014 nothing to do.`);return}K(`create-root failed: ${s}`),process.exit(1)}w(s)}finally{try{await r.terminateSession()}catch{}try{await n.close()}catch{}}}function w_(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 At(e){K(`ours-mcp watch: ${e}`),process.exit(1)}async function SP(){try{let e=new AbortController,t=setTimeout(()=>e.abort(),1500),r=await fetch(`http://127.0.0.1:${Q}/state-dir`,{signal:e.signal});if(clearTimeout(t),r.ok){let n=await r.json();return typeof n.stateDir=="string"&&n.stateDir?g_(n.stateDir):Ee}}catch{}return null}var $P=e=>`http://127.0.0.1:${Q}/identities/${encodeURIComponent(e)}/notifications`;async function p_(e){let t=async o=>{let s=new AbortController,i=setTimeout(()=>s.abort(),35e3),a;try{a=await fetch(`${$P(e)}?since=${o}`,{headers:ao(),signal:s.signal})}finally{clearTimeout(i)}if(a.status===401&&At(`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)w_(e,s);typeof o.cursor=="number"&&(r=o.cursor)}catch(o){n=Math.min(n+1e3,5e3),K(`ours-mcp watch: notifications stream for "${e}" hiccupped (${String(o?.message??o)}), retrying\u2026`),await Us(n)}}async function xP(e){if(e){await p_(e);return}let t=new Set;for(;;){try{let r=await fetch(`http://127.0.0.1:${Q}/identities`,{headers:ao()});if(r.status===401&&At("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),p_(s))}}}catch{}await Us(3e3)}}var Eu=e=>{let t=e?.code;return t==="EACCES"||t==="EPERM"};function kP(e,t){try{D.readdirSync(e)}catch(i){At(`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{D.readdirSync(yt(e,t))}catch(i){At(`cannot watch identity "${t}" \u2014 ${yt(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=D.readdirSync(e,{withFileTypes:!0}).filter(c=>c.isDirectory()).map(c=>c.name)}catch(c){Eu(c)&&At(`lost read access to ${e} (${c.code}) \u2014 cannot watch.`);return}for(let c of a){if(t&&c!==t)continue;let u=yt(e,c,"notifications.log"),l;try{l=D.statSync(u).size}catch(m){Eu(m)&&At(`cannot read ${u} (${m.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 f;try{let m=D.openSync(u,"r"),h=Buffer.alloc(l-d);D.readSync(m,h,0,h.length,d),D.closeSync(m),f=h.toString("utf8")}catch(m){Eu(m)&&At(`cannot read ${u} (${m.code}) \u2014 cannot watch identity "${c}".`);continue}r.set(u,l);for(let m of f.split(`
|
|
83
|
+
`))if(m.trim())try{w_(c,JSON.parse(m))}catch{}}};K(`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 zP(){try{let e=await fetch(`http://127.0.0.1:${Q}/identities`,{headers:ao()});return e.status===401&&At("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 PP(e){let t=()=>process.exit(0);if(process.on("SIGINT",t),process.on("SIGTERM",t),await SP()!==null&&await zP()==="api"){K(`ours-mcp watch: streaming ${e?`identity "${e}"`:"all identities"} from the daemon API on port ${Q} (Ctrl-C to stop)`),await xP(e);return}kP(Ee,e)}var io="ours.service",b_="solutions.adaptframework.ours";function S_(){return yt(h_(),".config","systemd","user",io)}function $_(){return yt(h_(),"Library","LaunchAgents",`${b_}.plist`)}function Vr(e,t){return Hr(e,t,{stdio:"inherit"}).status===0}function TP(){let e=S_();D.mkdirSync(Ou(e),{recursive:!0});let t=`[Unit]
|
|
87
84
|
Description=ours MCP daemon (secure agent-to-agent messaging over ADAPT)
|
|
88
85
|
After=network-online.target
|
|
89
86
|
Wants=network-online.target
|
|
90
87
|
|
|
91
88
|
[Service]
|
|
92
89
|
Type=simple
|
|
93
|
-
ExecStart=${process.execPath} ${
|
|
90
|
+
ExecStart=${process.execPath} ${Nt} serve
|
|
94
91
|
Environment=OURS_TRANSPORT=http
|
|
95
|
-
Environment=OURS_PORT=${
|
|
96
|
-
Environment=OURS_BROKER_URL=${
|
|
97
|
-
Environment=OURS_STATE_DIR=${
|
|
92
|
+
Environment=OURS_PORT=${Q}
|
|
93
|
+
Environment=OURS_BROKER_URL=${Br}
|
|
94
|
+
Environment=OURS_STATE_DIR=${Ee}
|
|
98
95
|
Restart=on-failure
|
|
99
96
|
RestartSec=2
|
|
100
97
|
|
|
101
98
|
[Install]
|
|
102
99
|
WantedBy=default.target
|
|
103
|
-
`;
|
|
100
|
+
`;D.writeFileSync(e,t),w(`wrote ${e}`),Vr("systemctl",["--user","daemon-reload"]),Vr("systemctl",["--user","enable","--now",io])||(K("failed to enable/start the service via systemctl --user."),process.env.XDG_RUNTIME_DIR||(K(`hint: no user runtime dir \u2014 enable linger: sudo loginctl enable-linger ${Pu().username}`),K(" (if linger is already on: export XDG_RUNTIME_DIR=/run/user/$(id -u))")),process.exit(1)),Vr("loginctl",["enable-linger",Pu().username])||(K("warning: could not enable linger \u2014 the daemon may not start until you log in."),K(` run manually: loginctl enable-linger ${Pu().username}`)),w(""),w("ours-mcp installed as a systemd user service and started."),w(` status: systemctl --user status ${io}`),w(` logs: journalctl --user -u ${io} -f`),w(" remove: ours-mcp uninstall-service")}function RP(){Vr("systemctl",["--user","disable","--now",io]);let e=S_();try{D.rmSync(e,{force:!0}),w(`removed ${e}`)}catch(t){K(`failed to remove ${e}: ${String(t)}`)}Vr("systemctl",["--user","daemon-reload"]),w("ours-mcp service uninstalled.")}function EP(){let e=$_();D.mkdirSync(Ou(e),{recursive:!0});let t=`<?xml version="1.0" encoding="UTF-8"?>
|
|
104
101
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
105
102
|
<plist version="1.0">
|
|
106
103
|
<dict>
|
|
107
|
-
<key>Label</key><string>${
|
|
104
|
+
<key>Label</key><string>${b_}</string>
|
|
108
105
|
<key>ProgramArguments</key>
|
|
109
106
|
<array>
|
|
110
107
|
<string>${process.execPath}</string>
|
|
111
|
-
<string>${
|
|
108
|
+
<string>${Nt}</string>
|
|
112
109
|
<string>serve</string>
|
|
113
110
|
</array>
|
|
114
111
|
<key>EnvironmentVariables</key>
|
|
115
112
|
<dict>
|
|
116
113
|
<key>OURS_TRANSPORT</key><string>http</string>
|
|
117
|
-
<key>OURS_PORT</key><string>${
|
|
118
|
-
<key>OURS_BROKER_URL</key><string>${
|
|
119
|
-
<key>OURS_STATE_DIR</key><string>${
|
|
114
|
+
<key>OURS_PORT</key><string>${Q}</string>
|
|
115
|
+
<key>OURS_BROKER_URL</key><string>${Br}</string>
|
|
116
|
+
<key>OURS_STATE_DIR</key><string>${Ee}</string>
|
|
120
117
|
</dict>
|
|
121
118
|
<key>RunAtLoad</key><true/>
|
|
122
119
|
<key>KeepAlive</key><true/>
|
|
123
|
-
<key>StandardOutPath</key><string>${
|
|
124
|
-
<key>StandardErrorPath</key><string>${
|
|
120
|
+
<key>StandardOutPath</key><string>${ir}</string>
|
|
121
|
+
<key>StandardErrorPath</key><string>${ir}</string>
|
|
125
122
|
</dict>
|
|
126
123
|
</plist>
|
|
127
|
-
`;
|
|
128
|
-
`),
|
|
124
|
+
`;D.writeFileSync(e,t),w(`wrote ${e}`);let r=`gui/${process.getuid()}`;Hr("launchctl",["bootout",r,e],{stdio:"ignore"}),Vr("launchctl",["bootstrap",r,e])||(K("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 IP(){let e=$_(),t=`gui/${process.getuid()}`;Hr("launchctl",["bootout",t,e],{stdio:"ignore"});try{D.rmSync(e,{force:!0}),w(`removed ${e}`)}catch(r){K(`failed to remove ${e}: ${String(r)}`)}w("ours-mcp service uninstalled.")}async function OP(){if(await qs(),process.platform==="linux")return TP();if(process.platform==="darwin")return EP();K(`install-service: unsupported platform "${process.platform}" (only linux/systemd and macOS/launchd).`),process.exit(1)}function CP(){if(process.platform==="linux")return RP();if(process.platform==="darwin")return IP();K(`uninstall-service: unsupported platform "${process.platform}".`),process.exit(1)}function f_(){w("ours-mcp \u2014 daemon for the ours MCP server"),w(""),w("Usage: ours-mcp <command>"),w(" start start in the background; show structured progress until ready"),w(" stop stop the running daemon"),w(" restart stop then start; healthy slow restores may take up to 3 minutes"),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-setup [--dry-run] securely choose a provider and configure its hidden API key"),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 AP(){let e=process.argv[2]??"help";switch(e){case"serve":case"run":process.env.OURS_TRANSPORT||(process.env.OURS_TRANSPORT="http"),D.mkdirSync(Ee,{recursive:!0}),D.writeFileSync(cr,String(process.pid));{let t=()=>{try{D.rmSync(cr,{force:!0})}catch{}};process.on("exit",t);for(let r of["SIGTERM","SIGINT"])process.on(r,()=>{t(),process.exit(0)})}await import(iP(yt(Ou(Nt),"index.js")).href);break;case"start":await d_();break;case"stop":await qs();break;case"restart":await qs(),await d_();break;case"status":await mP();break;case"version":case"--version":case"-v":await hP();break;case"setup":await gP();break;case"voice-status":case"stt-status":_P(process.argv.slice(3));break;case"voice-setup":case"stt-setup":await yP(process.argv.slice(3));break;case"create-root":await bP(process.argv.slice(3));break;case"define-local-identity-file":await vP(process.argv.slice(3));break;case"watch":await PP(process.argv[3]);break;case"proxy":!ct.autoStart&&!await jt(Q)&&(K(`ours-mcp daemon is not running on port ${Q} \u2014 start it with \`ours-mcp start\`.`),K("(or enable auto-start: `ours-mcp setup` \u2192 autoStart, or OURS_AUTOSTART=1)"),process.exit(1)),await aP({url:`http://127.0.0.1:${Q}/mcp`,ensureDaemon:ct.autoStart?fP:void 0,stateDir:Ee,apiToken:_u(ct,{generate:!1})?.token,transports:Fg,annotateResult:t=>Hg(t,cP?()=>!1:Vg)});break;case"install-service":await OP();break;case"uninstall-service":CP();break;case"help":case"--help":case"-h":f_();break;default:K(`unknown command: ${e}
|
|
125
|
+
`),f_(),process.exit(1)}}AP().catch(e=>{K(`ours-mcp error: ${e?.stack??e}`),process.exit(1)});
|