@aibolabs/capability-runtime 0.0.0-stage → 0.1.8

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 chldu2000
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,52 @@
1
- # Temporary Holding Version
1
+ # @aibolabs/capability-runtime
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Node 22+ Capability Runtime 2.0/2.1 helper。声明 `hostSdk` 的插件由宿主提供此包,开发时用 `npm install -D @aibolabs/capability-runtime` 安装为 `devDependencies`,发布时不携带 SDK;包版本等于宿主 SDK 版本,即应声明的 `hostSdk.min`。版本、公开入口和迁移见[宿主 SDK](https://github.com/chldu2000/aibo/blob/main/docs/host-sdk.md)。`serveCapability` 使用标准输入/输出 JSON-RPC;日志请写入 stderr。每个实例注册一个 contribution 及明确的 capability/version/operationId 列表。
4
+
5
+ ```js
6
+ import { serveCapability } from '@aibolabs/capability-runtime/stdio';
7
+ serveCapability({
8
+ pluginId: 'dev.example.echo', pluginVersion: '1.0.0',
9
+ contributionId: 'dev.example.echo.worker',
10
+ operations: [{capability:'dev.example.echo.read',version:'1.0.0',operationId:'dev.example.echo.read'}],
11
+ invoke: async (request, tools) => request.input,
12
+ });
13
+ ```
14
+
15
+ `tools.initialization` 提供宿主传入的私有数据目录;`tools.signal` 表示本地 deadline、transport 关闭或调用结束。`tools.call({pluginId,contributionId,capability,version,input})` 经宿主 Broker 调用声明依赖,自动附带当前 invocation/generation,不允许传入 scope、权限或批准身份。子错误拒绝 Promise;没有自动重试。
16
+
17
+ 默认入口 `createCapabilityRuntime` 可接入自定义消息传输,通过 `receive` 接收消息、`send` 发出 JSON、`close` 关闭。公开类型只依赖纯数据协议包;取消接口使用结构类型,不需要 DOM/Node 类型库。
18
+
19
+ 宿主仍执行所有权限、schema、资源限制、原生批准、持久去重与最终结果判定。SDK 取消信号需要业务代码合作;它不能撤销文件修改或停止任意外部进程。宿主保留本机进程终止边界。此 helper 不包含 Agent Runtime v1,不装载前端代码。
20
+ ## Interactive protocol migration
21
+
22
+ The runtime helper accepts explicit `protocol: '2.1'` for invocation streams and
23
+ controls. The default remains `2.0`. During `invoke`, `tools.emit(json)` sends an
24
+ ordered invocation event. A `control(request, { invocation, signal })` handler can
25
+ answer a host-authorized control while the invocation is pending. Controls must
26
+ be declared in `operations`; they cannot change the original scope or permissions.
27
+ Only one control runs at a time. Handlers must cooperate with `signal`, including
28
+ after invocation completion; cancellation cannot undo side effects.
29
+
30
+ Stream emission ends with the invocation. It cannot be used for detached background
31
+ notifications. The host validates identity, sequence and size and owns durable
32
+ history. Built-in Codex and Pi sessions now use this capability protocol. See
33
+ `docs/capability-session-migration.md` in the host repository for current support
34
+ and validation limits, and `docs/plugin-development.md` for the development guide.
35
+
36
+ `serveCapabilities(options[])` lets one package declare multiple contribution configurations.
37
+ The first capability initialization selects one declared contribution for the process generation;
38
+ later initialization cannot switch it. Each configuration still uses the same runtime dispatcher
39
+ and its exact operation allowlist. Aibo supervises separate scoped instances, so a workspace
40
+ catalog does not open or borrow a conversation instance.
41
+
42
+ Handler exceptions can carry a supported `kind` (for example `unsupported`,
43
+ `permission_denied`, or `invalid_input`). The dispatcher preserves that category
44
+ in JSON-RPC `error.data.kind`, bounds the error message, and maps unknown native
45
+ categories to `provider_unavailable`. This applies to invocation and control
46
+ handlers; it does not grant authority or turn failures into successful outputs.
47
+
48
+ Host SDK 0.1.1 exposes `@aibolabs/capability-runtime/host-tools` for generic native-tool and MCP adapters.
49
+ Declare `hostTools: ["aibo.host-tools/v1"]` and the standard tool response operation; consume the
50
+ trusted invocation catalog and bind calls to the invocation using `createHostToolChannel`.
51
+ MCP uses `createHostToolMcpBridge`; its generated stdio module is included in the host SDK.
52
+ See [the complete integration contract](https://github.com/chldu2000/aibo/blob/main/docs/session-history-tool-design.md).
@@ -0,0 +1 @@
1
+ export function serveHostToolMcp(): Promise<void>;
@@ -0,0 +1,66 @@
1
+ var qg=Object.create;var xs=Object.defineProperty;var Fg=Object.getOwnPropertyDescriptor;var Lg=Object.getOwnPropertyNames;var Ug=Object.getPrototypeOf,Vg=Object.prototype.hasOwnProperty;var $=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},Uc=(e,t)=>{for(var r in t)xs(e,r,{get:t[r],enumerable:!0})},Hg=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Lg(t))!Vg.call(e,o)&&o!==r&&xs(e,o,{get:()=>t[o],enumerable:!(n=Fg(t,o))||n.enumerable});return e};var Vc=(e,t,r)=>(r=e!=null?qg(Ug(e)):{},Hg(t||!e||!e.__esModule?xs(r,"default",{value:e,enumerable:!0}):r,e));var en=$(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.regexpCode=U.getEsmExportName=U.getProperty=U.safeStringify=U.stringify=U.strConcat=U.addCodeArg=U.str=U._=U.nil=U._Code=U.Name=U.IDENTIFIER=U._CodeOrName=void 0;var Yr=class{};U._CodeOrName=Yr;U.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Tt=class extends Yr{constructor(t){if(super(),!U.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}}};U.Name=Tt;var Ze=class extends Yr{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 Tt&&(r[n.str]=(r[n.str]||0)+1),r),{})}};U._Code=Ze;U.nil=new Ze("");function Ap(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Ji(r,t[n]),r.push(e[++n]);return new Ze(r)}U._=Ap;var Hi=new Ze("+");function Cp(e,...t){let r=[Qr(e[0])],n=0;for(;n<t.length;)r.push(Hi),Ji(r,t[n]),r.push(Hi,Qr(e[++n]));return X0(r),new Ze(r)}U.str=Cp;function Ji(e,t){t instanceof Ze?e.push(...t._items):t instanceof Tt?e.push(t):e.push(eb(t))}U.addCodeArg=Ji;function X0(e){let t=1;for(;t<e.length-1;){if(e[t]===Hi){let r=Y0(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function Y0(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Tt||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 Tt))return`"${e}${t.slice(1)}`}function Q0(e,t){return t.emptyStr()?e:e.emptyStr()?t:Cp`${e}${t}`}U.strConcat=Q0;function eb(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Qr(Array.isArray(e)?e.join(","):e)}function tb(e){return new Ze(Qr(e))}U.stringify=tb;function Qr(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}U.safeStringify=Qr;function rb(e){return typeof e=="string"&&U.IDENTIFIER.test(e)?new Ze(`.${e}`):Ap`[${e}]`}U.getProperty=rb;function nb(e){if(typeof e=="string"&&U.IDENTIFIER.test(e))return new Ze(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}U.getEsmExportName=nb;function ob(e){return new Ze(e.toString())}U.regexpCode=ob});var Gi=$(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.ValueScope=Se.ValueScopeName=Se.Scope=Se.varKinds=Se.UsedValueState=void 0;var ze=en(),Ki=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Co;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Co||(Se.UsedValueState=Co={}));Se.varKinds={const:new ze.Name("const"),let:new ze.Name("let"),var:new ze.Name("var")};var Zo=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof ze.Name?t:this.name(t)}name(t){return new ze.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}}};Se.Scope=Zo;var jo=class extends ze.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,ze._)`.${new ze.Name(r)}[${n}]`}};Se.ValueScopeName=jo;var sb=(0,ze._)`\n`,Bi=class extends Zo{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?sb:ze.nil}}get(){return this._scope}name(t){return new jo(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,ze._)`${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=ze.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,Co.Started);let u=r(l);if(u){let d=this.opts.es5?Se.varKinds.var:Se.varKinds.const;s=(0,ze._)`${s}${d} ${l} = ${u};${this.opts._n}`}else if(u=o?.(l))s=(0,ze._)`${s}${u}${this.opts._n}`;else throw new Ki(l);c.set(l,Co.Completed)})}return s}};Se.ValueScope=Bi});var R=$(A=>{"use strict";Object.defineProperty(A,"__esModule",{value:!0});A.or=A.and=A.not=A.CodeGen=A.operators=A.varKinds=A.ValueScopeName=A.ValueScope=A.Scope=A.Name=A.regexpCode=A.stringify=A.getProperty=A.nil=A.strConcat=A.str=A._=void 0;var M=en(),Ve=Gi(),yt=en();Object.defineProperty(A,"_",{enumerable:!0,get:function(){return yt._}});Object.defineProperty(A,"str",{enumerable:!0,get:function(){return yt.str}});Object.defineProperty(A,"strConcat",{enumerable:!0,get:function(){return yt.strConcat}});Object.defineProperty(A,"nil",{enumerable:!0,get:function(){return yt.nil}});Object.defineProperty(A,"getProperty",{enumerable:!0,get:function(){return yt.getProperty}});Object.defineProperty(A,"stringify",{enumerable:!0,get:function(){return yt.stringify}});Object.defineProperty(A,"regexpCode",{enumerable:!0,get:function(){return yt.regexpCode}});Object.defineProperty(A,"Name",{enumerable:!0,get:function(){return yt.Name}});var Fo=Gi();Object.defineProperty(A,"Scope",{enumerable:!0,get:function(){return Fo.Scope}});Object.defineProperty(A,"ValueScope",{enumerable:!0,get:function(){return Fo.ValueScope}});Object.defineProperty(A,"ValueScopeName",{enumerable:!0,get:function(){return Fo.ValueScopeName}});Object.defineProperty(A,"varKinds",{enumerable:!0,get:function(){return Fo.varKinds}});A.operators={GT:new M._Code(">"),GTE:new M._Code(">="),LT:new M._Code("<"),LTE:new M._Code("<="),EQ:new M._Code("==="),NEQ:new M._Code("!=="),NOT:new M._Code("!"),OR:new M._Code("||"),AND:new M._Code("&&"),ADD:new M._Code("+")};var at=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},Wi=class extends at{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?Ve.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=sr(this.rhs,t,r)),this}get names(){return this.rhs instanceof M._CodeOrName?this.rhs.names:{}}},Do=class extends at{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 M.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=sr(this.rhs,t,r),this}get names(){let t=this.lhs instanceof M.Name?{}:{...this.lhs.names};return qo(t,this.rhs)}},Xi=class extends Do{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},Yi=class extends at{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},Qi=class extends at{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},ea=class extends at{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},ta=class extends at{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=sr(this.code,t,r),this}get names(){return this.code instanceof M._CodeOrName?this.code.names:{}}},tn=class extends at{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)||(ib(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Nt(t,r.names),{})}},ct=class extends tn{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},ra=class extends tn{},or=class extends ct{};or.kind="else";var It=class e extends ct{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 or(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Zp(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=sr(this.condition,t,r),this}get names(){let t=super.names;return qo(t,this.condition),this.else&&Nt(t,this.else.names),t}};It.kind="if";var Rt=class extends ct{};Rt.kind="for";var na=class extends Rt{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=sr(this.iteration,t,r),this}get names(){return Nt(super.names,this.iteration.names)}},oa=class extends Rt{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?Ve.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=qo(super.names,this.from);return qo(t,this.to)}},Mo=class extends Rt{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=sr(this.iterable,t,r),this}get names(){return Nt(super.names,this.iterable.names)}},rn=class extends ct{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)}};rn.kind="func";var nn=class extends tn{render(t){return"return "+super.render(t)}};nn.kind="return";var sa=class extends ct{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&&Nt(t,this.catch.names),this.finally&&Nt(t,this.finally.names),t}},on=class extends ct{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};on.kind="catch";var sn=class extends ct{render(t){return"finally"+super.render(t)}};sn.kind="finally";var ia=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
2
+ `:""},this._extScope=t,this._scope=new Ve.Scope({parent:t}),this._nodes=[new ra]}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 Wi(t,s,n)),s}const(t,r,n){return this._def(Ve.varKinds.const,t,r,n)}let(t,r,n){return this._def(Ve.varKinds.let,t,r,n)}var(t,r,n){return this._def(Ve.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Do(t,r,n))}add(t,r){return this._leafNode(new Xi(t,A.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==M.nil&&this._leafNode(new ta(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,M.addCodeArg)(r,o));return r.push("}"),new M._Code(r)}if(t,r,n){if(this._blockNode(new It(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 It(t))}else(){return this._elseNode(new or)}endIf(){return this._endBlockNode(It,or)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new na(t),r)}forRange(t,r,n,o,s=this.opts.es5?Ve.varKinds.var:Ve.varKinds.let){let i=this._scope.toName(t);return this._for(new oa(s,i,r,n),()=>o(i))}forOf(t,r,n,o=Ve.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof M.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,M._)`${i}.length`,a=>{this.var(s,(0,M._)`${i}[${a}]`),n(s)})}return this._for(new Mo("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?Ve.varKinds.var:Ve.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,M._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new Mo("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Rt)}label(t){return this._leafNode(new Yi(t))}break(t){return this._leafNode(new Qi(t))}return(t){let r=new nn;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(nn)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new sa;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new on(s),r(s)}return n&&(this._currNode=o.finally=new sn,this.code(n)),this._endBlockNode(on,sn)}throw(t){return this._leafNode(new ea(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=M.nil,n,o){return this._blockNode(new rn(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(rn)}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 It))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}};A.CodeGen=ia;function Nt(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function qo(e,t){return t instanceof M._CodeOrName?Nt(e,t.names):e}function sr(e,t,r){if(e instanceof M.Name)return n(e);if(!o(e))return e;return new M._Code(e._items.reduce((s,i)=>(i instanceof M.Name&&(i=n(i)),i instanceof M._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 M._Code&&s._items.some(i=>i instanceof M.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function ib(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function Zp(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,M._)`!${aa(e)}`}A.not=Zp;var ab=jp(A.operators.AND);function cb(...e){return e.reduce(ab)}A.and=cb;var ub=jp(A.operators.OR);function lb(...e){return e.reduce(ub)}A.or=lb;function jp(e){return(t,r)=>t===M.nil?r:r===M.nil?t:(0,M._)`${aa(t)} ${e} ${aa(r)}`}function aa(e){return e instanceof M.Name?e:(0,M._)`(${e})`}});var q=$(C=>{"use strict";Object.defineProperty(C,"__esModule",{value:!0});C.checkStrictMode=C.getErrorPath=C.Type=C.useFunc=C.setEvaluated=C.evaluatedPropsToName=C.mergeEvaluated=C.eachItem=C.unescapeJsonPointer=C.escapeJsonPointer=C.escapeFragment=C.unescapeFragment=C.schemaRefOrVal=C.schemaHasRulesButRef=C.schemaHasRules=C.checkUnknownRules=C.alwaysValidSchema=C.toHash=void 0;var J=R(),db=en();function fb(e){let t={};for(let r of e)t[r]=!0;return t}C.toHash=fb;function pb(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(qp(e,t),!Fp(t,e.self.RULES.all))}C.alwaysValidSchema=pb;function qp(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]||Vp(e,`unknown keyword: "${s}"`)}C.checkUnknownRules=qp;function Fp(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}C.schemaHasRules=Fp;function mb(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}C.schemaHasRulesButRef=mb;function hb({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,J._)`${r}`}return(0,J._)`${e}${t}${(0,J.getProperty)(n)}`}C.schemaRefOrVal=hb;function gb(e){return Lp(decodeURIComponent(e))}C.unescapeFragment=gb;function _b(e){return encodeURIComponent(ua(e))}C.escapeFragment=_b;function ua(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}C.escapeJsonPointer=ua;function Lp(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}C.unescapeJsonPointer=Lp;function yb(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}C.eachItem=yb;function Dp({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof J.Name?(s instanceof J.Name?e(o,s,i):t(o,s,i),i):s instanceof J.Name?(t(o,i,s),s):r(s,i);return a===J.Name&&!(c instanceof J.Name)?n(o,c):c}}C.mergeEvaluated={props:Dp({mergeNames:(e,t,r)=>e.if((0,J._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,J._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,J._)`${r} || {}`).code((0,J._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,J._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,J._)`${r} || {}`),la(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Up}),items:Dp({mergeNames:(e,t,r)=>e.if((0,J._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,J._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,J._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,J._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Up(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,J._)`{}`);return t!==void 0&&la(e,r,t),r}C.evaluatedPropsToName=Up;function la(e,t,r){Object.keys(r).forEach(n=>e.assign((0,J._)`${t}${(0,J.getProperty)(n)}`,!0))}C.setEvaluated=la;var Mp={};function vb(e,t){return e.scopeValue("func",{ref:t,code:Mp[t.code]||(Mp[t.code]=new db._Code(t.code))})}C.useFunc=vb;var ca;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(ca||(C.Type=ca={}));function bb(e,t,r){if(e instanceof J.Name){let n=t===ca.Num;return r?n?(0,J._)`"[" + ${e} + "]"`:(0,J._)`"['" + ${e} + "']"`:n?(0,J._)`"/" + ${e}`:(0,J._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,J.getProperty)(e).toString():"/"+ua(e)}C.getErrorPath=bb;function Vp(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}C.checkStrictMode=Vp});var ut=$(da=>{"use strict";Object.defineProperty(da,"__esModule",{value:!0});var me=R(),$b={data:new me.Name("data"),valCxt:new me.Name("valCxt"),instancePath:new me.Name("instancePath"),parentData:new me.Name("parentData"),parentDataProperty:new me.Name("parentDataProperty"),rootData:new me.Name("rootData"),dynamicAnchors:new me.Name("dynamicAnchors"),vErrors:new me.Name("vErrors"),errors:new me.Name("errors"),this:new me.Name("this"),self:new me.Name("self"),scope:new me.Name("scope"),json:new me.Name("json"),jsonPos:new me.Name("jsonPos"),jsonLen:new me.Name("jsonLen"),jsonPart:new me.Name("jsonPart")};da.default=$b});var an=$(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.extendErrors=he.resetErrorsCount=he.reportExtraError=he.reportError=he.keyword$DataError=he.keywordError=void 0;var F=R(),Lo=q(),be=ut();he.keywordError={message:({keyword:e})=>(0,F.str)`must pass "${e}" keyword validation`};he.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 xb(e,t=he.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=Kp(e,t,r);n??(i||a)?Hp(s,c):Jp(o,(0,F._)`[${c}]`)}he.reportError=xb;function wb(e,t=he.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=Kp(e,t,r);Hp(o,a),s||i||Jp(n,be.default.vErrors)}he.reportExtraError=wb;function zb(e,t){e.assign(be.default.errors,t),e.if((0,F._)`${be.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,F._)`${be.default.vErrors}.length`,t),()=>e.assign(be.default.vErrors,null)))}he.resetErrorsCount=zb;function Sb({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,be.default.errors,a=>{e.const(i,(0,F._)`${be.default.vErrors}[${a}]`),e.if((0,F._)`${i}.instancePath === undefined`,()=>e.assign((0,F._)`${i}.instancePath`,(0,F.strConcat)(be.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))})}he.extendErrors=Sb;function Hp(e,t){let r=e.const("err",t);e.if((0,F._)`${be.default.vErrors} === null`,()=>e.assign(be.default.vErrors,(0,F._)`[${r}]`),(0,F._)`${be.default.vErrors}.push(${r})`),e.code((0,F._)`${be.default.errors}++`)}function Jp(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 At={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 Kp(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,F._)`{}`:kb(e,t,r)}function kb(e,t,r={}){let{gen:n,it:o}=e,s=[Pb(o,r),Eb(e,r)];return Ob(e,t,s),n.object(...s)}function Pb({errorPath:e},{instancePath:t}){let r=t?(0,F.str)`${e}${(0,Lo.getErrorPath)(t,Lo.Type.Str)}`:e;return[be.default.instancePath,(0,F.strConcat)(be.default.instancePath,r)]}function Eb({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,Lo.getErrorPath)(r,Lo.Type.Str)}`),[At.schemaPath,o]}function Ob(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([At.keyword,o],[At.params,typeof t=="function"?t(e):t||(0,F._)`{}`]),c.messages&&n.push([At.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([At.schema,i],[At.parentSchema,(0,F._)`${u}${d}`],[be.default.data,s]),l&&n.push([At.propertyName,l])}});var Gp=$(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});ir.boolOrEmptySchema=ir.topBoolOrEmptySchema=void 0;var Tb=an(),Ib=R(),Rb=ut(),Nb={message:"boolean schema is false"};function Ab(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Bp(e,!1):typeof r=="object"&&r.$async===!0?t.return(Rb.default.data):(t.assign((0,Ib._)`${n}.errors`,null),t.return(!0))}ir.topBoolOrEmptySchema=Ab;function Cb(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Bp(e)):r.var(t,!0)}ir.boolOrEmptySchema=Cb;function Bp(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,Tb.reportError)(o,Nb,void 0,t)}});var fa=$(ar=>{"use strict";Object.defineProperty(ar,"__esModule",{value:!0});ar.getRules=ar.isJSONType=void 0;var Zb=["string","number","integer","boolean","null","object","array"],jb=new Set(Zb);function Db(e){return typeof e=="string"&&jb.has(e)}ar.isJSONType=Db;function Mb(){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:{}}}ar.getRules=Mb});var pa=$(vt=>{"use strict";Object.defineProperty(vt,"__esModule",{value:!0});vt.shouldUseRule=vt.shouldUseGroup=vt.schemaHasRulesForType=void 0;function qb({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&Wp(e,n)}vt.schemaHasRulesForType=qb;function Wp(e,t){return t.rules.some(r=>Xp(e,r))}vt.shouldUseGroup=Wp;function Xp(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))}vt.shouldUseRule=Xp});var cn=$(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.reportTypeError=ge.checkDataTypes=ge.checkDataType=ge.coerceAndCheckDataType=ge.getJSONTypes=ge.getSchemaTypes=ge.DataType=void 0;var Fb=fa(),Lb=pa(),Ub=an(),I=R(),Yp=q(),cr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(cr||(ge.DataType=cr={}));function Vb(e){let t=Qp(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}ge.getSchemaTypes=Vb;function Qp(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(Fb.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}ge.getJSONTypes=Qp;function Hb(e,t){let{gen:r,data:n,opts:o}=e,s=Jb(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,Lb.schemaHasRulesForType)(e,t[0]));if(i){let a=ha(t,n,o.strictNumbers,cr.Wrong);r.if(a,()=>{s.length?Kb(e,t,s):ga(e)})}return i}ge.coerceAndCheckDataType=Hb;var em=new Set(["string","number","integer","boolean","null"]);function Jb(e,t){return t?e.filter(r=>em.has(r)||t==="array"&&r==="array"):[]}function Kb(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,I._)`typeof ${o}`),a=n.let("coerced",(0,I._)`undefined`);s.coerceTypes==="array"&&n.if((0,I._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,I._)`${o}[0]`).assign(i,(0,I._)`typeof ${o}`).if(ha(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,I._)`${a} !== undefined`);for(let l of r)(em.has(l)||l==="array"&&s.coerceTypes==="array")&&c(l);n.else(),ga(e),n.endIf(),n.if((0,I._)`${a} !== undefined`,()=>{n.assign(o,a),Bb(e,a)});function c(l){switch(l){case"string":n.elseIf((0,I._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,I._)`"" + ${o}`).elseIf((0,I._)`${o} === null`).assign(a,(0,I._)`""`);return;case"number":n.elseIf((0,I._)`${i} == "boolean" || ${o} === null
3
+ || (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,I._)`+${o}`);return;case"integer":n.elseIf((0,I._)`${i} === "boolean" || ${o} === null
4
+ || (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,I._)`+${o}`);return;case"boolean":n.elseIf((0,I._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,I._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,I._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,I._)`${i} === "string" || ${i} === "number"
5
+ || ${i} === "boolean" || ${o} === null`).assign(a,(0,I._)`[${o}]`)}}}function Bb({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,I._)`${t} !== undefined`,()=>e.assign((0,I._)`${t}[${r}]`,n))}function ma(e,t,r,n=cr.Correct){let o=n===cr.Correct?I.operators.EQ:I.operators.NEQ,s;switch(e){case"null":return(0,I._)`${t} ${o} null`;case"array":s=(0,I._)`Array.isArray(${t})`;break;case"object":s=(0,I._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,I._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,I._)`typeof ${t} ${o} ${e}`}return n===cr.Correct?s:(0,I.not)(s);function i(a=I.nil){return(0,I.and)((0,I._)`typeof ${t} == "number"`,a,r?(0,I._)`isFinite(${t})`:I.nil)}}ge.checkDataType=ma;function ha(e,t,r,n){if(e.length===1)return ma(e[0],t,r,n);let o,s=(0,Yp.toHash)(e);if(s.array&&s.object){let i=(0,I._)`typeof ${t} != "object"`;o=s.null?i:(0,I._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=I.nil;s.number&&delete s.integer;for(let i in s)o=(0,I.and)(o,ma(i,t,r,n));return o}ge.checkDataTypes=ha;var Gb={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,I._)`{type: ${e}}`:(0,I._)`{type: ${t}}`};function ga(e){let t=Wb(e);(0,Ub.reportError)(t,Gb)}ge.reportTypeError=ga;function Wb(e){let{gen:t,data:r,schema:n}=e,o=(0,Yp.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var rm=$(Uo=>{"use strict";Object.defineProperty(Uo,"__esModule",{value:!0});Uo.assignDefaults=void 0;var ur=R(),Xb=q();function Yb(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)tm(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>tm(e,s,o.default))}Uo.assignDefaults=Yb;function tm(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,ur._)`${s}${(0,ur.getProperty)(t)}`;if(o){(0,Xb.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,ur._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,ur._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,ur._)`${a} = ${(0,ur.stringify)(r)}`)}});var je=$(H=>{"use strict";Object.defineProperty(H,"__esModule",{value:!0});H.validateUnion=H.validateArray=H.usePattern=H.callValidateCode=H.schemaProperties=H.allSchemaProperties=H.noPropertyInData=H.propertyInData=H.isOwnProperty=H.hasPropFunc=H.reportMissingProp=H.checkMissingProp=H.checkReportMissingProp=void 0;var X=R(),_a=q(),bt=ut(),Qb=q();function e$(e,t){let{gen:r,data:n,it:o}=e;r.if(va(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,X._)`${t}`},!0),e.error()})}H.checkReportMissingProp=e$;function t$({gen:e,data:t,it:{opts:r}},n,o){return(0,X.or)(...n.map(s=>(0,X.and)(va(e,t,s,r.ownProperties),(0,X._)`${o} = ${s}`)))}H.checkMissingProp=t$;function r$(e,t){e.setParams({missingProperty:t},!0),e.error()}H.reportMissingProp=r$;function nm(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,X._)`Object.prototype.hasOwnProperty`})}H.hasPropFunc=nm;function ya(e,t,r){return(0,X._)`${nm(e)}.call(${t}, ${r})`}H.isOwnProperty=ya;function n$(e,t,r,n){let o=(0,X._)`${t}${(0,X.getProperty)(r)} !== undefined`;return n?(0,X._)`${o} && ${ya(e,t,r)}`:o}H.propertyInData=n$;function va(e,t,r,n){let o=(0,X._)`${t}${(0,X.getProperty)(r)} === undefined`;return n?(0,X.or)(o,(0,X.not)(ya(e,t,r))):o}H.noPropertyInData=va;function om(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}H.allSchemaProperties=om;function o$(e,t){return om(t).filter(r=>!(0,_a.alwaysValidSchema)(e,t[r]))}H.schemaProperties=o$;function s$({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,l){let u=l?(0,X._)`${e}, ${t}, ${n}${o}`:t,d=[[bt.default.instancePath,(0,X.strConcat)(bt.default.instancePath,s)],[bt.default.parentData,i.parentData],[bt.default.parentDataProperty,i.parentDataProperty],[bt.default.rootData,bt.default.rootData]];i.opts.dynamicRef&&d.push([bt.default.dynamicAnchors,bt.default.dynamicAnchors]);let p=(0,X._)`${u}, ${r.object(...d)}`;return c!==X.nil?(0,X._)`${a}.call(${c}, ${p})`:(0,X._)`${a}(${p})`}H.callValidateCode=s$;var i$=(0,X._)`new RegExp`;function a$({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,X._)`${o.code==="new RegExp"?i$:(0,Qb.useFunc)(e,o)}(${r}, ${n})`})}H.usePattern=a$;function c$(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,X._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:n,dataProp:l,dataPropType:_a.Type.Num},s),t.if((0,X.not)(s),a)})}}H.validateArray=c$;function u$(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,_a.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,X._)`${i} || ${a}`),e.mergeValidEvaluated(u,a)||t.if((0,X.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}H.validateUnion=u$});var am=$(Ge=>{"use strict";Object.defineProperty(Ge,"__esModule",{value:!0});Ge.validateKeywordUsage=Ge.validSchemaType=Ge.funcKeywordCode=Ge.macroKeywordCode=void 0;var $e=R(),Ct=ut(),l$=je(),d$=an();function f$(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=im(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let l=r.name("valid");e.subschema({schema:a,schemaPath:$e.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},l),e.pass(l,()=>e.error(!0))}Ge.macroKeywordCode=f$;function p$(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;h$(c,t);let l=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,u=im(n,o,l),d=n.let("valid");e.block$data(d,p),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function p(){if(t.errors===!1)h(),t.modifying&&sm(e),g(()=>e.error());else{let v=t.async?f():m();t.modifying&&sm(e),g(()=>m$(e,v))}}function f(){let v=n.let("ruleErrs",null);return n.try(()=>h((0,$e._)`await `),b=>n.assign(d,!1).if((0,$e._)`${b} instanceof ${c.ValidationError}`,()=>n.assign(v,(0,$e._)`${b}.errors`),()=>n.throw(b))),v}function m(){let v=(0,$e._)`${u}.errors`;return n.assign(v,null),h($e.nil),v}function h(v=t.async?(0,$e._)`await `:$e.nil){let b=c.opts.passContext?Ct.default.this:Ct.default.self,z=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,$e._)`${v}${(0,l$.callValidateCode)(e,u,b,z)}`,t.modifying)}function g(v){var b;n.if((0,$e.not)((b=t.valid)!==null&&b!==void 0?b:d),v)}}Ge.funcKeywordCode=p$;function sm(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,$e._)`${n.parentData}[${n.parentDataProperty}]`))}function m$(e,t){let{gen:r}=e;r.if((0,$e._)`Array.isArray(${t})`,()=>{r.assign(Ct.default.vErrors,(0,$e._)`${Ct.default.vErrors} === null ? ${t} : ${Ct.default.vErrors}.concat(${t})`).assign(Ct.default.errors,(0,$e._)`${Ct.default.vErrors}.length`),(0,d$.extendErrors)(e)},()=>e.error())}function h$({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function im(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,$e.stringify)(r)})}function g$(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")}Ge.validSchemaType=g$;function _$({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");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)}}Ge.validateKeywordUsage=_$});var um=$($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});$t.extendSubschemaMode=$t.extendSubschemaData=$t.getSubschema=void 0;var We=R(),cm=q();function y$(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,We._)`${e.schemaPath}${(0,We.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,We._)`${e.schemaPath}${(0,We.getProperty)(t)}${(0,We.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,cm.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')}$t.getSubschema=y$;function v$(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,p=a.let("data",(0,We._)`${t.data}${(0,We.getProperty)(r)}`,!0);c(p),e.errorPath=(0,We.str)`${l}${(0,cm.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,We._)`${r}`,e.dataPathArr=[...u,e.parentDataProperty]}if(o!==void 0){let l=o instanceof We.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]}}$t.extendSubschemaData=v$;function b$(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}$t.extendSubschemaMode=b$});var ba=$((W1,lm)=>{"use strict";lm.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 fm=$((X1,dm)=>{"use strict";var xt=dm.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(){};Vo(t,n,o,e,"",e)};xt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};xt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};xt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};xt.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 Vo(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 xt.arrayKeywords)for(var p=0;p<d.length;p++)Vo(e,t,r,d[p],o+"/"+u+"/"+p,s,o,u,n,p)}else if(u in xt.propsKeywords){if(d&&typeof d=="object")for(var f in d)Vo(e,t,r,d[f],o+"/"+u+"/"+$$(f),s,o,u,n,f)}else(u in xt.keywords||e.allKeys&&!(u in xt.skipKeywords))&&Vo(e,t,r,d,o+"/"+u,s,o,u,n)}r(n,o,s,i,a,c,l)}}function $$(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var un=$(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});ke.getSchemaRefs=ke.resolveUrl=ke.normalizeId=ke._getFullPath=ke.getFullPath=ke.inlineRef=void 0;var x$=q(),w$=ba(),z$=fm(),S$=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function k$(e,t=!0){return typeof e=="boolean"?!0:t===!0?!$a(e):t?pm(e)<=t:!1}ke.inlineRef=k$;var P$=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function $a(e){for(let t in e){if(P$.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some($a)||typeof r=="object"&&$a(r))return!0}return!1}function pm(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!S$.has(r)&&(typeof e[r]=="object"&&(0,x$.eachItem)(e[r],n=>t+=pm(n)),t===1/0))return 1/0}return t}function mm(e,t="",r){r!==!1&&(t=lr(t));let n=e.parse(t);return hm(e,n)}ke.getFullPath=mm;function hm(e,t){return e.serialize(t).split("#")[0]+"#"}ke._getFullPath=hm;var E$=/#\/?$/;function lr(e){return e?e.replace(E$,""):""}ke.normalizeId=lr;function O$(e,t,r){return r=lr(r),e.resolve(t,r)}ke.resolveUrl=O$;var T$=/^[a-z_][-a-z0-9._]*$/i;function I$(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=lr(e[r]||t),s={"":o},i=mm(n,o,!1),a={},c=new Set;return z$(e,{allKeys:!0},(d,p,f,m)=>{if(m===void 0)return;let h=i+p,g=s[m];typeof d[r]=="string"&&(g=v.call(this,d[r])),b.call(this,d.$anchor),b.call(this,d.$dynamicAnchor),s[p]=g;function v(z){let N=this.opts.uriResolver.resolve;if(z=lr(g?N(g,z):z),c.has(z))throw u(z);c.add(z);let w=this.refs[z];return typeof w=="string"&&(w=this.refs[w]),typeof w=="object"?l(d,w.schema,z):z!==lr(h)&&(z[0]==="#"?(l(d,a[z],z),a[z]=d):this.refs[z]=h),z}function b(z){if(typeof z=="string"){if(!T$.test(z))throw new Error(`invalid anchor "${z}"`);v.call(this,`#${z}`)}}}),a;function l(d,p,f){if(p!==void 0&&!w$(d,p))throw u(f)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}ke.getSchemaRefs=I$});var fn=$(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.getData=wt.KeywordCxt=wt.validateFunctionCode=void 0;var bm=Gp(),gm=cn(),wa=pa(),Ho=cn(),R$=rm(),dn=am(),xa=um(),k=R(),O=ut(),N$=un(),lt=q(),ln=an();function A$(e){if(wm(e)&&(zm(e),xm(e))){j$(e);return}$m(e,()=>(0,bm.topBoolOrEmptySchema)(e))}wt.validateFunctionCode=A$;function $m({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,k._)`${O.default.data}, ${O.default.valCxt}`,n.$async,()=>{e.code((0,k._)`"use strict"; ${_m(r,o)}`),Z$(e,o),e.code(s)}):e.func(t,(0,k._)`${O.default.data}, ${C$(o)}`,n.$async,()=>e.code(_m(r,o)).code(s))}function C$(e){return(0,k._)`{${O.default.instancePath}="", ${O.default.parentData}, ${O.default.parentDataProperty}, ${O.default.rootData}=${O.default.data}${e.dynamicRef?(0,k._)`, ${O.default.dynamicAnchors}={}`:k.nil}}={}`}function Z$(e,t){e.if(O.default.valCxt,()=>{e.var(O.default.instancePath,(0,k._)`${O.default.valCxt}.${O.default.instancePath}`),e.var(O.default.parentData,(0,k._)`${O.default.valCxt}.${O.default.parentData}`),e.var(O.default.parentDataProperty,(0,k._)`${O.default.valCxt}.${O.default.parentDataProperty}`),e.var(O.default.rootData,(0,k._)`${O.default.valCxt}.${O.default.rootData}`),t.dynamicRef&&e.var(O.default.dynamicAnchors,(0,k._)`${O.default.valCxt}.${O.default.dynamicAnchors}`)},()=>{e.var(O.default.instancePath,(0,k._)`""`),e.var(O.default.parentData,(0,k._)`undefined`),e.var(O.default.parentDataProperty,(0,k._)`undefined`),e.var(O.default.rootData,O.default.data),t.dynamicRef&&e.var(O.default.dynamicAnchors,(0,k._)`{}`)})}function j$(e){let{schema:t,opts:r,gen:n}=e;$m(e,()=>{r.$comment&&t.$comment&&km(e),L$(e),n.let(O.default.vErrors,null),n.let(O.default.errors,0),r.unevaluated&&D$(e),Sm(e),H$(e)})}function D$(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,k._)`${r}.evaluated`),t.if((0,k._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,k._)`${e.evaluated}.props`,(0,k._)`undefined`)),t.if((0,k._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,k._)`${e.evaluated}.items`,(0,k._)`undefined`))}function _m(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,k._)`/*# sourceURL=${r} */`:k.nil}function M$(e,t){if(wm(e)&&(zm(e),xm(e))){q$(e,t);return}(0,bm.boolOrEmptySchema)(e,t)}function xm({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 wm(e){return typeof e.schema!="boolean"}function q$(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&km(e),U$(e),V$(e);let s=n.const("_errs",O.default.errors);Sm(e,s),n.var(t,(0,k._)`${s} === ${O.default.errors}`)}function zm(e){(0,lt.checkUnknownRules)(e),F$(e)}function Sm(e,t){if(e.opts.jtd)return ym(e,[],!1,t);let r=(0,gm.getSchemaTypes)(e.schema),n=(0,gm.coerceAndCheckDataType)(e,r);ym(e,r,!n,t)}function F$(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,lt.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function L$(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,lt.checkStrictMode)(e,"default is ignored in the schema root")}function U$(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,N$.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function V$(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function km({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,k._)`${O.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,k.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,k._)`${O.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function H$(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,k._)`${O.default.errors} === 0`,()=>t.return(O.default.data),()=>t.throw((0,k._)`new ${o}(${O.default.vErrors})`)):(t.assign((0,k._)`${n}.errors`,O.default.vErrors),s.unevaluated&&J$(e),t.return((0,k._)`${O.default.errors} === 0`))}function J$({gen:e,evaluated:t,props:r,items:n}){r instanceof k.Name&&e.assign((0,k._)`${t}.props`,r),n instanceof k.Name&&e.assign((0,k._)`${t}.items`,n)}function ym(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,lt.schemaHasRulesButRef)(s,u))){o.block(()=>Em(e,"$ref",u.all.$ref.definition));return}c.jtd||K$(e,t),o.block(()=>{for(let p of u.rules)d(p);d(u.post)});function d(p){(0,wa.shouldUseGroup)(s,p)&&(p.type?(o.if((0,Ho.checkDataType)(p.type,i,c.strictNumbers)),vm(e,p),t.length===1&&t[0]===p.type&&r&&(o.else(),(0,Ho.reportTypeError)(e)),o.endIf()):vm(e,p),a||o.if((0,k._)`${O.default.errors} === ${n||0}`))}}function vm(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,R$.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,wa.shouldUseRule)(n,s)&&Em(e,s.keyword,s.definition,t.type)})}function K$(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(B$(e,t),e.opts.allowUnionTypes||G$(e,t),W$(e,e.dataTypes))}function B$(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Pm(e.dataTypes,r)||za(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),Y$(e,t)}}function G$(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&za(e,"use allowUnionTypes to allow union type keyword")}function W$(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,wa.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>X$(t,i))&&za(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function X$(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Pm(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Y$(e,t){let r=[];for(let n of e.dataTypes)Pm(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function za(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,lt.checkStrictMode)(e,t,e.opts.strictTypes)}var Jo=class{constructor(t,r,n){if((0,dn.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,lt.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",Om(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,dn.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",O.default.errors))}result(t,r,n){this.failResult((0,k.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,k.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,k._)`${r} !== undefined && (${(0,k.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?ln.reportExtraError:ln.reportError)(this,this.def.error,r)}$dataError(){(0,ln.reportError)(this,this.def.$dataError||ln.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,ln.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=k.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=k.nil,r=k.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,k.or)((0,k._)`${o} === undefined`,r)),t!==k.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==k.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,k.or)(i(),a());function i(){if(n.length){if(!(r instanceof k.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,k._)`${(0,Ho.checkDataTypes)(c,r,s.opts.strictNumbers,Ho.DataType.Wrong)}`}return k.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,k._)`!${c}(${r})`}return k.nil}}subschema(t,r){let n=(0,xa.getSubschema)(this.it,t);(0,xa.extendSubschemaData)(n,this.it,t),(0,xa.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return M$(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=lt.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=lt.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,k.Name)),!0}};wt.KeywordCxt=Jo;function Em(e,t,r,n){let o=new Jo(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,dn.funcKeywordCode)(o,r):"macro"in r?(0,dn.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,dn.funcKeywordCode)(o,r)}var Q$=/^\/(?:[^~]|~0|~1)*$/,ex=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Om(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return O.default.rootData;if(e[0]==="/"){if(!Q$.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=O.default.rootData}else{let l=ex.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,k._)`${s}${(0,k.getProperty)((0,lt.unescapeJsonPointer)(l))}`,i=(0,k._)`${i} && ${s}`);return i;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${t}`}}wt.getData=Om});var Ko=$(ka=>{"use strict";Object.defineProperty(ka,"__esModule",{value:!0});var Sa=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};ka.default=Sa});var pn=$(Oa=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});var Pa=un(),Ea=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Pa.resolveUrl)(t,r,n),this.missingSchema=(0,Pa.normalizeId)((0,Pa.getFullPath)(t,this.missingRef))}};Oa.default=Ea});var Go=$(De=>{"use strict";Object.defineProperty(De,"__esModule",{value:!0});De.resolveSchema=De.getCompilingSchema=De.resolveRef=De.compileSchema=De.SchemaEnv=void 0;var He=R(),tx=Ko(),Zt=ut(),Je=un(),Tm=q(),rx=fn(),dr=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,Je.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};De.SchemaEnv=dr;function Ia(e){let t=Im.call(this,e);if(t)return t;let r=(0,Je.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new He.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:tx.default,code:(0,He._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let l={gen:i,allErrors:this.opts.allErrors,data:Zt.default.data,parentData:Zt.default.parentData,parentDataProperty:Zt.default.parentDataProperty,dataNames:[Zt.default.data],dataPathArr:[He.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,He.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:He.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,He._)`""`,opts:this.opts,self:this},u;try{this._compilations.add(e),(0,rx.validateFunctionCode)(l),i.optimize(this.opts.code.optimize);let d=i.toString();u=`${i.scopeRefs(Zt.default.scope)}return ${d}`,this.opts.code.process&&(u=this.opts.code.process(u,e));let f=new Function(`${Zt.default.self}`,`${Zt.default.scope}`,u)(this,this.scope.get());if(this.scope.value(c,{ref:f}),f.errors=null,f.schema=e.schema,f.schemaEnv=e,e.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:m,items:h}=l;f.evaluated={props:m instanceof He.Name?void 0:m,items:h instanceof He.Name?void 0:h,dynamicProps:m instanceof He.Name,dynamicItems:h instanceof He.Name},f.source&&(f.source.evaluated=(0,He.stringify)(f.evaluated))}return e.validate=f,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)}}De.compileSchema=Ia;function nx(e,t,r){var n;r=(0,Je.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=ix.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 dr({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=ox.call(this,s)}De.resolveRef=nx;function ox(e){return(0,Je.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Ia.call(this,e)}function Im(e){for(let t of this._compilations)if(sx(t,e))return t}De.getCompilingSchema=Im;function sx(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function ix(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Bo.call(this,e,t)}function Bo(e,t){let r=this.opts.uriResolver.parse(t),n=(0,Je._getFullPath)(this.opts.uriResolver,r),o=(0,Je.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return Ta.call(this,r,e);let s=(0,Je.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Bo.call(this,e,i);return typeof a?.schema!="object"?void 0:Ta.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Ia.call(this,i),s===(0,Je.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,l=a[c];return l&&(o=(0,Je.resolveUrl)(this.opts.uriResolver,o,l)),new dr({schema:a,schemaId:c,root:e,baseId:o})}return Ta.call(this,r,i)}}De.resolveSchema=Bo;var ax=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Ta(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,Tm.unescapeFragment)(a)];if(c===void 0)return;r=c;let l=typeof r=="object"&&r[this.opts.schemaId];!ax.has(a)&&l&&(t=(0,Je.resolveUrl)(this.opts.uriResolver,t,l))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,Tm.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Je.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=Bo.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new dr({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var Rm=$((nR,cx)=>{cx.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 ja=$((oR,Mm)=>{"use strict";var ux=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Na=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),lx=RegExp.prototype.test.bind(/^\d*$/u),jt=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Aa=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Am=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),Ca=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),dx=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),Pe=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)Pe[t]="%"+e[t>>4]+e[t&15]}function _e(e){return e<2048?Pe[192|e>>6]+Pe[128|e&63]:e<65536?Pe[224|e>>12]+Pe[128|e>>6&63]+Pe[128|e&63]:Pe[240|e>>18]+Pe[128|e>>12&63]+Pe[128|e>>6&63]+Pe[128|e&63]}function fx(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 px=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),mx=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),hx=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),gx=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function _x(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!hx(e[t])){if(e[t]==="%"&&t+2<e.length&&jt(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function Nm(e){let t=-1,r=0,n=-1,o=0;for(let a=0;a<e.length;a++)e[a]==="0"?(n===-1&&(n=a),o++,o>r&&(r=o,t=n)):(n=-1,o=0);if(r<2)return e.join(":");let s=e.slice(0,t).join(":"),i=e.slice(t+r).join(":");return s+"::"+i}function yx(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let r=t===-1?e.split(":"):e.slice(0,t).split(":"),n=t===-1?[]:e.slice(t+2).split(":");t!==-1&&(r.length===1&&r[0]===""&&(r.length=0),n.length===1&&n[0]===""&&(n.length=0));let o=r.concat(n),s=0;for(let a=0;a<o.length;a++){let c=o[a];if(c==="")return;if(c.indexOf(".")!==-1){if(a!==o.length-1||t!==-1&&n.length===0||!Na(c))return;s+=2;continue}if(!px(c))return;o[a]=parseInt(c,16).toString(16),s++}if(t===-1)return s!==8?void 0:Nm(o);if(s>=8)return;let i=o.slice(0,r.length);for(let a=s;a<8;a++)i.push("0");for(let a=r.length;a<o.length;a++)i.push(o[a]);return Nm(i)}function Ra(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&mx(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(vx(n,":")<2)return{host:e,isIPV6:!1,error:t};let o="",s=n.indexOf("%");if(s!==-1){let a=n.slice(s,s+3).toLowerCase()==="%25"?3:1;if(o=n.slice(s+a),!_x(o))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,s)}let i=yx(n);return i===void 0?{host:e,isIPV6:!1,error:!0}:{host:i+(o?"%"+o:""),escapedHost:i+(o?"%25"+o:""),isIPV6:!0}}function vx(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function bx(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 $x={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},xx=/[@/?#:]/g,wx=/[@/?#]/g;function Cm(e,t){let r=t?wx:xx;return r.lastIndex=0,e.replace(r,n=>$x[n])}function Zm(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(jt(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&Aa(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function zx(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(jt(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&Aa(i)?t+=i:t+="%"+s,r+=2;continue}}if(Am(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=Dm(o)?n:Pe[o];else if(o<55296||o>57343)t+=_e(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=_e(65536+(o-55296<<10)+(s-56320)),r++):t+=_e(65533)}else t+=_e(65533)}}return t}function Sx(e,t=!1){let r="",n=t&&e[0]!=="/";for(let o=0;o<e.length;o++){let s=e[o];if(s==="%"&&o+2<e.length){let i=e.slice(o+1,o+3);if(jt(i)){r+="%"+i.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),Am(s)&&(s!==":"||!n))r+=s;else{let i=e.charCodeAt(o);if(i<128)r+=Pe[i];else if(i<55296||i>57343)r+=_e(i);else if(i<=56319&&o+1<e.length){let a=e.charCodeAt(o+1);a>=56320&&a<=57343?(r+=_e(65536+(i-55296<<10)+(a-56320)),o++):r+=_e(65533)}else r+=_e(65533)}}return r}function Za(e,t){let r="";for(let n=0;n<e.length;n++){let o=e[n];if(o==="%"&&n+2<e.length){let s=e.slice(n+1,n+3);if(jt(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(t(o))r+=o;else{let s=e.charCodeAt(n);if(s<128)r+=Pe[s];else if(s<55296||s>57343)r+=_e(s);else if(s<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);i>=56320&&i<=57343?(r+=_e(65536+(s-55296<<10)+(i-56320)),n++):r+=_e(65533)}else r+=_e(65533)}}return r}function jm(e){return Za(e,dx)}function kx(e){return Za(e,Ca)}function Px(e){return Za(e,Ca)}function Dm(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function Ex(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(jt(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));Aa(i)?t+=i:t+="%"+s,r+=2;continue}}if(Ca(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=Dm(o)?n:Pe[o];else if(o<55296||o>57343)t+=_e(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=_e(65536+(o-55296<<10)+(s-56320)),r++):t+=_e(65533)}else t+=_e(65533)}}return t}function Ox(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(jt(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function Tx(e){let t=[];if(e.userinfo!==void 0&&(t.push(jm(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!Na(r)){let n=Ra(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=Zm(r,!0),n=Ra(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=Cm(r,!1)}t.push(r)}if(typeof e.port=="number"||typeof e.port=="string"){let r=String(e.port);if(!lx(r))throw new TypeError("URI port is malformed.");t.push(":"),t.push(r)}return t.length?t.join(""):void 0}Mm.exports={nonSimpleDomain:gx,recomposeAuthority:Tx,reescapeHostDelimiters:Cm,normalizePercentEncoding:Zm,normalizePathEncoding:zx,serializePathEncoding:Sx,normalizeQueryFragmentEncoding:Ex,encodeUserinfo:jm,encodeQuery:kx,encodeFragment:Px,escapePreservingEscapes:Ox,removeDotSegments:bx,isIPv4:Na,isUUID:ux,normalizeIPv6:Ra,stringArrayToHexStripped:fx}});var Vm=$((sR,Um)=>{"use strict";var{isUUID:Ix}=ja(),Rx=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,Nx=["http","https","ws","wss","urn","urn:uuid"];function Ax(e){return Nx.indexOf(e)!==-1}function Da(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 qm(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Fm(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 Cx(e){return e.secure=Da(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function Zx(e){if((e.port===(Da(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=e.resourceName.indexOf("?"),r=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=r&&r!=="/"?r:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function jx(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(Rx);if(r&&r[0]===e.path){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,s=Ma(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function Dx(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=Ma(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 Mx(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!Ix(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function qx(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Lm={scheme:"http",domainHost:!0,parse:qm,serialize:Fm},Fx={scheme:"https",domainHost:Lm.domainHost,parse:qm,serialize:Fm},Wo={scheme:"ws",domainHost:!0,parse:Cx,serialize:Zx},Lx={scheme:"wss",domainHost:Wo.domainHost,parse:Wo.parse,serialize:Wo.serialize},Ux={scheme:"urn",parse:jx,serialize:Dx,skipNormalize:!0},Vx={scheme:"urn:uuid",parse:Mx,serialize:qx,skipNormalize:!0},Xo={http:Lm,https:Fx,ws:Wo,wss:Lx,urn:Ux,"urn:uuid":Vx};Object.setPrototypeOf(Xo,null);function Ma(e){return e&&(Xo[e]||Xo[e.toLowerCase()])||void 0}Um.exports={wsIsSecure:Da,SCHEMES:Xo,isValidSchemeName:Ax,getSchemeHandler:Ma}});var oh=$((iR,es)=>{"use strict";var{normalizeIPv6:Gm,removeDotSegments:hn,recomposeAuthority:Hx,normalizePercentEncoding:Wm,normalizePathEncoding:Jx,serializePathEncoding:Hm,normalizeQueryFragmentEncoding:Jm,encodeQuery:Kx,encodeFragment:Bx,reescapeHostDelimiters:Gx,isIPv4:Xm,nonSimpleDomain:Wx}=ja(),{SCHEMES:Ym,getSchemeHandler:qa}=Vm(),Qm=/^[A-Za-z][A-Za-z0-9+.-]*$/u,eh="URI scheme is malformed.";function Km(e){let t=unescape(String(e));if(!Qm.test(t))throw new TypeError(eh);return t}function Xx(e,t){return typeof e=="string"?e=sw(e,t):typeof e=="object"&&(e=Qo(Dt(e,t),t)),e}function Yx(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:l}=Yo(e,n),{parsed:u,malformedAuthorityOrPort:d,malformedPercentEncoding:p,malformedSchemeSpecific:f,malformedHost:m,malformedScheme:h}=Yo(t,n);if(s||d||i||p||a||f||c||m||l||h)throw new Error(o.error||u.error||"URI is malformed.");let g=th(o,u,n,!0),v=qa(r&&r.scheme||g.scheme),b=g.host,z=b!==void 0&&b!==""&&(Xm(b)||Gm(b).isIPV6);rh(g,r||{},v,z);let N=b&&b.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(b);if(g.error&&!N)throw new Error(g.error);return n.skipEscape=!0,Dt(g,n)}function th(e,t,r,n){let o={};return n||(e=Qo(Dt(e,r),r),t=Qo(Dt(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=hn(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=hn(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=hn(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=hn(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 Qx(e,t,r){let n=Bm(e,r),o=Bm(t,r);return n!==void 0&&o!==void 0&&n===o}function Dt(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=[];r.scheme&&(r.scheme=Km(r.scheme));let s=qa(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n);let i=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,a=!n.skipEscape&&r.scheme===void 0&&!i;r.path!==void 0&&(n.skipEscape?r.path=Wm(r.path):r.path=Hm(r.path,a)),n.reference!=="suffix"&&r.scheme&&(r.scheme=Km(r.scheme),o.push(r.scheme,":"));let c=Hx(r);if(c!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(c),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let l=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(l=hn(l)),a&&(l=Hm(l,!0)),c===void 0&&l[0]==="/"&&l[1]==="/"&&(l="/%2F"+l.slice(2)),o.push(l)}return r.query!==void 0&&o.push("?",Kx(r.query)),r.fragment!==void 0&&o.push("#",Bx(r.fragment)),o.join("")}var ew=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,tw=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,rw=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function nw(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 mn(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}function Fa(e){return e[0]==="["&&e[e.length-1]==="]"}function ow(e){let t=e[4];return mn(e[3])||t!==void 0&&!Fa(t)&&mn(t)||mn(e[6])||mn(e[7])||mn(e[8])}function rh(e,t,r,n){if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&!Fa(e.host)&&(t.domainHost||r&&r.domainHost)&&n===!1&&Wx(e.host))try{e.host=new URL("http://"+e.host).hostname}catch(o){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+o,!0}return!1}function Yo(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,i=!1,a=!1,c=!1,l=!1,u=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let d=e.match(tw);d!==null&&d[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let p=e.match(rw);if(p!==null){let m=p[1],h=m.replace(/[\t\n\r]/g,"");h.length>=2&&(h.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",o=!0):m.length!==h.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}let f=e.match(ew);if(f){if(n.scheme=f[1],n.userinfo=f[3],n.host=f[4],n.port=parseInt(f[5],10),n.path=f[6]||"",n.query=f[7],n.fragment=f[8],n.scheme!==void 0){let g=unescape(n.scheme);Qm.test(g)?n.scheme=g.toLowerCase():(n.error=n.error||eh,l=!0)}s=ow(f),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=f[5]);let m=nw(n,f);if(m!==void 0&&(n.error=n.error||m,o=!0),n.host)if(Xm(n.host)===!1){let v=Fa(n.host),b=n.host.indexOf("[")!==-1||n.host.indexOf("]")!==-1,z=Gm(n.host);u=z.isIPV6||z.isIPVFuture===!0,c=b&&(!v||z.error===!0),n.host=u?z.host:z.host.toLowerCase(),c&&(n.error=n.error||"URI host is malformed.",o=!0)}else u=!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 h=qa(r.scheme||n.scheme);if(c||(a=rh(n,r,h,u)),!h||h&&!h.skipNormalize){if(e.indexOf("%")!==-1&&n.host!==void 0&&!c){let g=u?n.host:Wm(n.host,!0);n.host=Gx(g,u)}n.path&&(n.path=Jx(n.path)),n.query&&(n.query=Jm(n.query)),n.fragment&&(n.fragment=Jm(n.fragment))}h&&h.parse&&(h.parse(n,r),h===Ym.urn&&n.nid===void 0&&(i=!0))}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:l}}function Qo(e,t){return Yo(e,t).parsed}function sw(e,t){return nh(e,t).normalized}function nh(e,t){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}=Yo(e,t);return{normalized:n||o||s||i||a?e:Dt(r,t),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}}function Bm(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:Dt(e,t)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:c}=nh(r,t);return o||s||i||a||c?void 0:n}var La={SCHEMES:Ym,normalize:Xx,resolve:Yx,resolveComponent:th,equal:Qx,serialize:Dt,parse:Qo};es.exports=La;es.exports.default=La;es.exports.fastUri=La});var ih=$(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:!0});var sh=oh();sh.code='require("ajv/dist/runtime/uri").default';Ua.default=sh});var mh=$(fe=>{"use strict";Object.defineProperty(fe,"__esModule",{value:!0});fe.CodeGen=fe.Name=fe.nil=fe.stringify=fe.str=fe._=fe.KeywordCxt=void 0;var iw=fn();Object.defineProperty(fe,"KeywordCxt",{enumerable:!0,get:function(){return iw.KeywordCxt}});var fr=R();Object.defineProperty(fe,"_",{enumerable:!0,get:function(){return fr._}});Object.defineProperty(fe,"str",{enumerable:!0,get:function(){return fr.str}});Object.defineProperty(fe,"stringify",{enumerable:!0,get:function(){return fr.stringify}});Object.defineProperty(fe,"nil",{enumerable:!0,get:function(){return fr.nil}});Object.defineProperty(fe,"Name",{enumerable:!0,get:function(){return fr.Name}});Object.defineProperty(fe,"CodeGen",{enumerable:!0,get:function(){return fr.CodeGen}});var aw=Ko(),dh=pn(),cw=fa(),gn=Go(),uw=R(),_n=un(),ts=cn(),Ha=q(),ah=Rm(),lw=ih(),fh=(e,t)=>new RegExp(e,t);fh.code="new RegExp";var dw=["removeAdditional","useDefaults","coerceTypes"],fw=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),pw={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."},mw={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},ch=200;function hw(e){var t,r,n,o,s,i,a,c,l,u,d,p,f,m,h,g,v,b,z,N,w,Z,se,kt,Lt;let et=e.strict,Ut=(t=e.code)===null||t===void 0?void 0:t.optimize,On=Ut===!0||Ut===void 0?1:Ut||0,Tn=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:fh,Mg=(o=e.uriResolver)!==null&&o!==void 0?o:lw.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:et)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:et)!==null&&c!==void 0?c:!0,strictTypes:(u=(l=e.strictTypes)!==null&&l!==void 0?l:et)!==null&&u!==void 0?u:"log",strictTuples:(p=(d=e.strictTuples)!==null&&d!==void 0?d:et)!==null&&p!==void 0?p:"log",strictRequired:(m=(f=e.strictRequired)!==null&&f!==void 0?f:et)!==null&&m!==void 0?m:!1,code:e.code?{...e.code,optimize:On,regExp:Tn}:{optimize:On,regExp:Tn},loopRequired:(h=e.loopRequired)!==null&&h!==void 0?h:ch,loopEnum:(g=e.loopEnum)!==null&&g!==void 0?g:ch,meta:(v=e.meta)!==null&&v!==void 0?v:!0,messages:(b=e.messages)!==null&&b!==void 0?b:!0,inlineRefs:(z=e.inlineRefs)!==null&&z!==void 0?z:!0,schemaId:(N=e.schemaId)!==null&&N!==void 0?N:"$id",addUsedSchema:(w=e.addUsedSchema)!==null&&w!==void 0?w:!0,validateSchema:(Z=e.validateSchema)!==null&&Z!==void 0?Z:!0,validateFormats:(se=e.validateFormats)!==null&&se!==void 0?se:!0,unicodeRegExp:(kt=e.unicodeRegExp)!==null&&kt!==void 0?kt:!0,int32range:(Lt=e.int32range)!==null&&Lt!==void 0?Lt:!0,uriResolver:Mg}}var yn=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,...hw(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new uw.ValueScope({scope:{},prefixes:fw,es5:r,lines:n}),this.logger=$w(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,cw.getRules)(),uh.call(this,pw,t,"NOT SUPPORTED"),uh.call(this,mw,t,"DEPRECATED","warn"),this._metaOpts=vw.call(this),t.formats&&_w.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&yw.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),gw.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=ah;n==="id"&&(o={...ah},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 p=this._addSchema(u,d);return p.validate||i.call(this,p)}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 dh.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,_n.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=lh.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new gn.SchemaEnv({schema:{},schemaId:n});if(r=gn.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=lh.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,_n.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(ww.call(this,n,r),!r)return(0,Ha.eachItem)(n,s=>Va.call(this,s)),this;Sw.call(this,r);let o={...r,type:(0,ts.getJSONTypes)(r.type),schemaType:(0,ts.getJSONTypes)(r.schemaType)};return(0,Ha.eachItem)(n,o.type.length===0?s=>Va.call(this,s,o):s=>o.type.forEach(i=>Va.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]=ph(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,_n.normalizeId)(i||n);let l=_n.getSchemaRefs.call(this,t,n);return c=new gn.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):gn.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{gn.compileSchema.call(this,t)}finally{this.opts=r}}};yn.ValidationError=aw.default;yn.MissingRefError=dh.default;fe.default=yn;function uh(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 lh(e){return e=(0,_n.normalizeId)(e),this.schemas[e]||this.refs[e]}function gw(){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 _w(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function yw(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 vw(){let e={...this.opts};for(let t of dw)delete e[t];return e}var bw={log(){},warn(){},error(){}};function $w(e){if(e===!1)return bw;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 xw=/^[a-z_$][a-z0-9_$:-]*$/i;function ww(e,t){let{RULES:r}=this;if((0,Ha.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!xw.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 Va(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,ts.getJSONTypes)(t.type),schemaType:(0,ts.getJSONTypes)(t.schemaType)}};t.before?zw.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 zw(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 Sw(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=ph(t)),e.validateSchema=this.compile(t,!0))}var kw={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ph(e){return{anyOf:[e,kw]}}});var hh=$(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});var Pw={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Ja.default=Pw});var vh=$(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.callRef=Mt.getValidate=void 0;var Ew=pn(),gh=je(),Ee=R(),pr=ut(),_h=Go(),rs=q(),Ow={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=_h.resolveRef.call(c,l,o,r);if(u===void 0)throw new Ew.default(n.opts.uriResolver,o,r);if(u instanceof _h.SchemaEnv)return p(u);return f(u);function d(){if(s===l)return ns(e,i,s,s.$async);let m=t.scopeValue("root",{ref:l});return ns(e,(0,Ee._)`${m}.validate`,l,l.$async)}function p(m){let h=yh(e,m);ns(e,h,m,m.$async)}function f(m){let h=t.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Ee.stringify)(m)}:{ref:m}),g=t.name("valid"),v=e.subschema({schema:m,dataTypes:[],schemaPath:Ee.nil,topSchemaRef:h,errSchemaPath:r},g);e.mergeEvaluated(v),e.ok(g)}}};function yh(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Ee._)`${r.scopeValue("wrapper",{ref:t})}.validate`}Mt.getValidate=yh;function ns(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,l=c.passContext?pr.default.this:Ee.nil;n?u():d();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=o.let("valid");o.try(()=>{o.code((0,Ee._)`await ${(0,gh.callValidateCode)(e,t,l)}`),f(t),i||o.assign(m,!0)},h=>{o.if((0,Ee._)`!(${h} instanceof ${s.ValidationError})`,()=>o.throw(h)),p(h),i||o.assign(m,!1)}),e.ok(m)}function d(){e.result((0,gh.callValidateCode)(e,t,l),()=>f(t),()=>p(t))}function p(m){let h=(0,Ee._)`${m}.errors`;o.assign(pr.default.vErrors,(0,Ee._)`${pr.default.vErrors} === null ? ${h} : ${pr.default.vErrors}.concat(${h})`),o.assign(pr.default.errors,(0,Ee._)`${pr.default.vErrors}.length`)}function f(m){var h;if(!s.opts.unevaluated)return;let g=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=rs.mergeEvaluated.props(o,g.props,s.props));else{let v=o.var("props",(0,Ee._)`${m}.evaluated.props`);s.props=rs.mergeEvaluated.props(o,v,s.props,Ee.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=rs.mergeEvaluated.items(o,g.items,s.items));else{let v=o.var("items",(0,Ee._)`${m}.evaluated.items`);s.items=rs.mergeEvaluated.items(o,v,s.items,Ee.Name)}}}Mt.callRef=ns;Mt.default=Ow});var bh=$(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});var Tw=hh(),Iw=vh(),Rw=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Tw.default,Iw.default];Ka.default=Rw});var $h=$(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});var os=R(),zt=os.operators,ss={maximum:{okStr:"<=",ok:zt.LTE,fail:zt.GT},minimum:{okStr:">=",ok:zt.GTE,fail:zt.LT},exclusiveMaximum:{okStr:"<",ok:zt.LT,fail:zt.GTE},exclusiveMinimum:{okStr:">",ok:zt.GT,fail:zt.LTE}},Nw={message:({keyword:e,schemaCode:t})=>(0,os.str)`must be ${ss[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,os._)`{comparison: ${ss[e].okStr}, limit: ${t}}`},Aw={keyword:Object.keys(ss),type:"number",schemaType:"number",$data:!0,error:Nw,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,os._)`${r} ${ss[t].fail} ${n} || isNaN(${r})`)}};Ba.default=Aw});var xh=$(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});var vn=R(),Cw={message:({schemaCode:e})=>(0,vn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,vn._)`{multipleOf: ${e}}`},Zw={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Cw,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,vn._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,vn._)`${i} !== parseInt(${i})`;e.fail$data((0,vn._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Ga.default=Zw});var zh=$(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});function wh(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}Wa.default=wh;wh.code='require("ajv/dist/runtime/ucs2length").default'});var Sh=$(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});var qt=R(),jw=q(),Dw=zh(),Mw={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,qt.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,qt._)`{limit: ${e}}`},qw={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:Mw,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?qt.operators.GT:qt.operators.LT,i=o.opts.unicode===!1?(0,qt._)`${r}.length`:(0,qt._)`${(0,jw.useFunc)(e.gen,Dw.default)}(${r})`;e.fail$data((0,qt._)`${i} ${s} ${n}`)}};Xa.default=qw});var kh=$(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});var Fw=je(),Lw=q(),mr=R(),Uw={message:({schemaCode:e})=>(0,mr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,mr._)`{pattern: ${e}}`},Vw={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:Uw,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,l=c.code==="new RegExp"?(0,mr._)`new RegExp`:(0,Lw.useFunc)(t,c),u=t.let("valid");t.try(()=>t.assign(u,(0,mr._)`${l}(${s}, ${a}).test(${r})`),()=>t.assign(u,!1)),e.fail$data((0,mr._)`!${u}`)}else{let c=(0,Fw.usePattern)(e,o);e.fail$data((0,mr._)`!${c}.test(${r})`)}}};Ya.default=Vw});var Ph=$(Qa=>{"use strict";Object.defineProperty(Qa,"__esModule",{value:!0});var bn=R(),Hw={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,bn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,bn._)`{limit: ${e}}`},Jw={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Hw,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?bn.operators.GT:bn.operators.LT;e.fail$data((0,bn._)`Object.keys(${r}).length ${o} ${n}`)}};Qa.default=Jw});var Eh=$(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});var $n=je(),xn=R(),Kw=q(),Bw={message:({params:{missingProperty:e}})=>(0,xn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,xn._)`{missingProperty: ${e}}`},Gw={keyword:"required",type:"object",schemaType:"array",$data:!0,error:Bw,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 f=e.parentSchema.properties,{definedProperties:m}=e.it;for(let h of r)if(f?.[h]===void 0&&!m.has(h)){let g=i.schemaEnv.baseId+i.errSchemaPath,v=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,Kw.checkStrictMode)(i,v,i.opts.strictRequired)}}function l(){if(c||s)e.block$data(xn.nil,d);else for(let f of r)(0,$n.checkReportMissingProp)(e,f)}function u(){let f=t.let("missing");if(c||s){let m=t.let("valid",!0);e.block$data(m,()=>p(f,m)),e.ok(m)}else t.if((0,$n.checkMissingProp)(e,r,f)),(0,$n.reportMissingProp)(e,f),t.else()}function d(){t.forOf("prop",n,f=>{e.setParams({missingProperty:f}),t.if((0,$n.noPropertyInData)(t,o,f,a.ownProperties),()=>e.error())})}function p(f,m){e.setParams({missingProperty:f}),t.forOf(f,n,()=>{t.assign(m,(0,$n.propertyInData)(t,o,f,a.ownProperties)),t.if((0,xn.not)(m),()=>{e.error(),t.break()})},xn.nil)}}};ec.default=Gw});var Oh=$(tc=>{"use strict";Object.defineProperty(tc,"__esModule",{value:!0});var wn=R(),Ww={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,wn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,wn._)`{limit: ${e}}`},Xw={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Ww,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?wn.operators.GT:wn.operators.LT;e.fail$data((0,wn._)`${r}.length ${o} ${n}`)}};tc.default=Xw});var is=$(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});var Th=ba();Th.code='require("ajv/dist/runtime/equal").default';rc.default=Th});var Ih=$(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});var nc=cn(),pe=R(),Yw=q(),Qw=is(),ez={message:({params:{i:e,j:t}})=>(0,pe.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,pe._)`{i: ${e}, j: ${t}}`},tz={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:ez,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,nc.getSchemaTypes)(s.items):[];e.block$data(c,u,(0,pe._)`${i} === false`),e.ok(c);function u(){let m=t.let("i",(0,pe._)`${r}.length`),h=t.let("j");e.setParams({i:m,j:h}),t.assign(c,!0),t.if((0,pe._)`${m} > 1`,()=>(d()?p:f)(m,h))}function d(){return l.length>0&&!l.some(m=>m==="object"||m==="array")}function p(m,h){let g=t.name("item"),v=(0,nc.checkDataTypes)(l,g,a.opts.strictNumbers,nc.DataType.Wrong),b=t.const("indices",(0,pe._)`{}`);t.for((0,pe._)`;${m}--;`,()=>{t.let(g,(0,pe._)`${r}[${m}]`),t.if(v,(0,pe._)`continue`),l.length>1&&t.if((0,pe._)`typeof ${g} == "string"`,(0,pe._)`${g} += "_"`),t.if((0,pe._)`typeof ${b}[${g}] == "number"`,()=>{t.assign(h,(0,pe._)`${b}[${g}]`),e.error(),t.assign(c,!1).break()}).code((0,pe._)`${b}[${g}] = ${m}`)})}function f(m,h){let g=(0,Yw.useFunc)(t,Qw.default),v=t.name("outer");t.label(v).for((0,pe._)`;${m}--;`,()=>t.for((0,pe._)`${h} = ${m}; ${h}--;`,()=>t.if((0,pe._)`${g}(${r}[${m}], ${r}[${h}])`,()=>{e.error(),t.assign(c,!1).break(v)})))}}};oc.default=tz});var Rh=$(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});var sc=R(),rz=q(),nz=is(),oz={message:"must be equal to constant",params:({schemaCode:e})=>(0,sc._)`{allowedValue: ${e}}`},sz={keyword:"const",$data:!0,error:oz,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,sc._)`!${(0,rz.useFunc)(t,nz.default)}(${r}, ${o})`):e.fail((0,sc._)`${s} !== ${r}`)}};ic.default=sz});var Nh=$(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});var zn=R(),iz=q(),az=is(),cz={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,zn._)`{allowedValues: ${e}}`},uz={keyword:"enum",schemaType:"array",$data:!0,error:cz,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,iz.useFunc)(t,az.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 f=t.const("vSchema",s);u=(0,zn.or)(...o.map((m,h)=>p(f,h)))}e.pass(u);function d(){t.assign(u,!1),t.forOf("v",s,f=>t.if((0,zn._)`${l()}(${r}, ${f})`,()=>t.assign(u,!0).break()))}function p(f,m){let h=o[m];return typeof h=="object"&&h!==null?(0,zn._)`${l()}(${r}, ${f}[${m}])`:(0,zn._)`${r} === ${h}`}}};ac.default=uz});var Ah=$(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});var lz=$h(),dz=xh(),fz=Sh(),pz=kh(),mz=Ph(),hz=Eh(),gz=Oh(),_z=Ih(),yz=Rh(),vz=Nh(),bz=[lz.default,dz.default,fz.default,pz.default,mz.default,hz.default,gz.default,_z.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},yz.default,vz.default];cc.default=bz});var lc=$(Sn=>{"use strict";Object.defineProperty(Sn,"__esModule",{value:!0});Sn.validateAdditionalItems=void 0;var Ft=R(),uc=q(),$z={message:({params:{len:e}})=>(0,Ft.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Ft._)`{limit: ${e}}`},xz={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:$z,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,uc.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Ch(e,n)}};function Ch(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,Ft._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,Ft._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,uc.alwaysValidSchema)(i,n)){let l=r.var("valid",(0,Ft._)`${a} <= ${t.length}`);r.if((0,Ft.not)(l),()=>c(l)),e.ok(l)}function c(l){r.forRange("i",t.length,a,u=>{e.subschema({keyword:s,dataProp:u,dataPropType:uc.Type.Num},l),i.allErrors||r.if((0,Ft.not)(l),()=>r.break())})}}Sn.validateAdditionalItems=Ch;Sn.default=xz});var dc=$(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.validateTuple=void 0;var Zh=R(),as=q(),wz=je(),zz={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return jh(e,"additionalItems",t);r.items=!0,!(0,as.alwaysValidSchema)(r,t)&&e.ok((0,wz.validateArray)(e))}};function jh(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=as.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),l=n.const("len",(0,Zh._)`${s}.length`);r.forEach((d,p)=>{(0,as.alwaysValidSchema)(a,d)||(n.if((0,Zh._)`${l} > ${p}`,()=>e.subschema({keyword:i,schemaProp:p,dataProp:p},c)),e.ok(c))});function u(d){let{opts:p,errSchemaPath:f}=a,m=r.length,h=m===d.minItems&&(m===d.maxItems||d[t]===!1);if(p.strictTuples&&!h){let g=`"${i}" is ${m}-tuple, but minItems or maxItems/${t} are not specified or different at path "${f}"`;(0,as.checkStrictMode)(a,g,p.strictTuples)}}}kn.validateTuple=jh;kn.default=zz});var Dh=$(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});var Sz=dc(),kz={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,Sz.validateTuple)(e,"items")};fc.default=kz});var qh=$(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});var Mh=R(),Pz=q(),Ez=je(),Oz=lc(),Tz={message:({params:{len:e}})=>(0,Mh.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Mh._)`{limit: ${e}}`},Iz={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Tz,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,Pz.alwaysValidSchema)(n,t)&&(o?(0,Oz.validateAdditionalItems)(e,o):e.ok((0,Ez.validateArray)(e)))}};pc.default=Iz});var Fh=$(mc=>{"use strict";Object.defineProperty(mc,"__esModule",{value:!0});var Me=R(),cs=q(),Rz={message:({params:{min:e,max:t}})=>t===void 0?(0,Me.str)`must contain at least ${e} valid item(s)`:(0,Me.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,Me._)`{minContains: ${e}}`:(0,Me._)`{minContains: ${e}, maxContains: ${t}}`},Nz={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Rz,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,Me._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,cs.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,cs.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,cs.alwaysValidSchema)(s,r)){let h=(0,Me._)`${u} >= ${i}`;a!==void 0&&(h=(0,Me._)`${h} && ${u} <= ${a}`),e.pass(h);return}s.items=!0;let d=t.name("valid");a===void 0&&i===1?f(d,()=>t.if(d,()=>t.break())):i===0?(t.let(d,!0),a!==void 0&&t.if((0,Me._)`${o}.length > 0`,p)):(t.let(d,!1),p()),e.result(d,()=>e.reset());function p(){let h=t.name("_valid"),g=t.let("count",0);f(h,()=>t.if(h,()=>m(g)))}function f(h,g){t.forRange("i",0,u,v=>{e.subschema({keyword:"contains",dataProp:v,dataPropType:cs.Type.Num,compositeRule:!0},h),g()})}function m(h){t.code((0,Me._)`${h}++`),a===void 0?t.if((0,Me._)`${h} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,Me._)`${h} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,Me._)`${h} >= ${i}`,()=>t.assign(d,!0)))}}};mc.default=Nz});var Vh=$(Xe=>{"use strict";Object.defineProperty(Xe,"__esModule",{value:!0});Xe.validateSchemaDeps=Xe.validatePropertyDeps=Xe.error=void 0;var hc=R(),Az=q(),Pn=je();Xe.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,hc.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,hc._)`{property: ${e},
6
+ missingProperty: ${n},
7
+ depsCount: ${t},
8
+ deps: ${r}}`};var Cz={keyword:"dependencies",type:"object",schemaType:"object",error:Xe.error,code(e){let[t,r]=Zz(e);Lh(e,t),Uh(e,r)}};function Zz({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 Lh(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,Pn.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,Pn.checkReportMissingProp)(e,l)}):(r.if((0,hc._)`${c} && (${(0,Pn.checkMissingProp)(e,a,s)})`),(0,Pn.reportMissingProp)(e,s),r.else())}}Xe.validatePropertyDeps=Lh;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,Az.alwaysValidSchema)(s,t[a])||(r.if((0,Pn.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))}Xe.validateSchemaDeps=Uh;Xe.default=Cz});var Jh=$(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});var Hh=R(),jz=q(),Dz={message:"property name must be valid",params:({params:e})=>(0,Hh._)`{propertyName: ${e.propertyName}}`},Mz={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Dz,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,jz.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,Hh.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};gc.default=Mz});var yc=$(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});var us=je(),Ke=R(),qz=ut(),ls=q(),Fz={message:"must NOT have additional properties",params:({params:e})=>(0,Ke._)`{additionalProperty: ${e.additionalProperty}}`},Lz={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:Fz,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,ls.alwaysValidSchema)(i,r))return;let l=(0,us.allSchemaProperties)(n.properties),u=(0,us.allSchemaProperties)(n.patternProperties);d(),e.ok((0,Ke._)`${s} === ${qz.default.errors}`);function d(){t.forIn("key",o,g=>{!l.length&&!u.length?m(g):t.if(p(g),()=>m(g))})}function p(g){let v;if(l.length>8){let b=(0,ls.schemaRefOrVal)(i,n.properties,"properties");v=(0,us.isOwnProperty)(t,b,g)}else l.length?v=(0,Ke.or)(...l.map(b=>(0,Ke._)`${g} === ${b}`)):v=Ke.nil;return u.length&&(v=(0,Ke.or)(v,...u.map(b=>(0,Ke._)`${(0,us.usePattern)(e,b)}.test(${g})`))),(0,Ke.not)(v)}function f(g){t.code((0,Ke._)`delete ${o}[${g}]`)}function m(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){f(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,ls.alwaysValidSchema)(i,r)){let v=t.name("valid");c.removeAdditional==="failing"?(h(g,v,!1),t.if((0,Ke.not)(v),()=>{e.reset(),f(g)})):(h(g,v),a||t.if((0,Ke.not)(v),()=>t.break()))}}function h(g,v,b){let z={keyword:"additionalProperties",dataProp:g,dataPropType:ls.Type.Str};b===!1&&Object.assign(z,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(z,v)}}};_c.default=Lz});var Gh=$(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});var Uz=fn(),Kh=je(),vc=q(),Bh=yc(),Vz={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&&Bh.default.code(new Uz.KeywordCxt(s,Bh.default,"additionalProperties"));let i=(0,Kh.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=vc.mergeEvaluated.props(t,(0,vc.toHash)(i),s.props));let a=i.filter(d=>!(0,vc.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,Kh.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)}}};bc.default=Vz});var Qh=$($c=>{"use strict";Object.defineProperty($c,"__esModule",{value:!0});var Wh=je(),ds=R(),Xh=q(),Yh=q(),Hz={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,Wh.allSchemaProperties)(r),c=a.filter(h=>(0,Xh.alwaysValidSchema)(s,r[h]));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 ds.Name)&&(s.props=(0,Yh.evaluatedPropsToName)(t,s.props));let{props:d}=s;p();function p(){for(let h of a)l&&f(h),s.allErrors?m(h):(t.var(u,!0),m(h),t.if(u))}function f(h){for(let g in l)new RegExp(h).test(g)&&(0,Xh.checkStrictMode)(s,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){t.forIn("key",n,g=>{t.if((0,ds._)`${(0,Wh.usePattern)(e,h)}.test(${g})`,()=>{let v=c.includes(h);v||e.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:Yh.Type.Str},u),s.opts.unevaluated&&d!==!0?t.assign((0,ds._)`${d}[${g}]`,!0):!v&&!s.allErrors&&t.if((0,ds.not)(u),()=>t.break())})})}}};$c.default=Hz});var eg=$(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});var Jz=q(),Kz={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,Jz.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=Kz});var tg=$(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});var Bz=je(),Gz={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:Bz.validateUnion,error:{message:"must match a schema in anyOf"}};wc.default=Gz});var rg=$(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});var fs=R(),Wz=q(),Xz={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,fs._)`{passingSchemas: ${e.passing}}`},Yz={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:Xz,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 p;(0,Wz.alwaysValidSchema)(o,u)?t.var(c,!0):p=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,fs._)`${c} && ${i}`).assign(i,!1).assign(a,(0,fs._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),p&&e.mergeEvaluated(p,fs.Name)})})}}};zc.default=Yz});var ng=$(Sc=>{"use strict";Object.defineProperty(Sc,"__esModule",{value:!0});var Qz=q(),eS={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,Qz.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};Sc.default=eS});var ig=$(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});var ps=R(),sg=q(),tS={message:({params:e})=>(0,ps.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,ps._)`{failingKeyword: ${e.ifClause}}`},rS={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:tS,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,sg.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=og(n,"then"),s=og(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,ps.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 p=e.subschema({keyword:u},a);t.assign(i,a),e.mergeValidEvaluated(p,i),d?t.assign(d,(0,ps._)`${u}`):e.setParams({ifClause:u})}}}};function og(e,t){let r=e.schema[t];return r!==void 0&&!(0,sg.alwaysValidSchema)(e,r)}kc.default=rS});var ag=$(Pc=>{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});var nS=q(),oS={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,nS.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Pc.default=oS});var cg=$(Ec=>{"use strict";Object.defineProperty(Ec,"__esModule",{value:!0});var sS=lc(),iS=Dh(),aS=dc(),cS=qh(),uS=Fh(),lS=Vh(),dS=Jh(),fS=yc(),pS=Gh(),mS=Qh(),hS=eg(),gS=tg(),_S=rg(),yS=ng(),vS=ig(),bS=ag();function $S(e=!1){let t=[hS.default,gS.default,_S.default,yS.default,vS.default,bS.default,dS.default,fS.default,lS.default,pS.default,mS.default];return e?t.push(iS.default,cS.default):t.push(sS.default,aS.default),t.push(uS.default),t}Ec.default=$S});var ug=$(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});var oe=R(),xS={message:({schemaCode:e})=>(0,oe.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,oe._)`{format: ${e}}`},wS={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:xS,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?p():f();function p(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,oe._)`${m}[${i}]`),g=r.let("fType"),v=r.let("format");r.if((0,oe._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,oe._)`${h}.type || "string"`).assign(v,(0,oe._)`${h}.validate`),()=>r.assign(g,(0,oe._)`"string"`).assign(v,h)),e.fail$data((0,oe.or)(b(),z()));function b(){return c.strictSchema===!1?oe.nil:(0,oe._)`${i} && !${v}`}function z(){let N=u.$async?(0,oe._)`(${h}.async ? await ${v}(${n}) : ${v}(${n}))`:(0,oe._)`${v}(${n})`,w=(0,oe._)`(typeof ${v} == "function" ? ${N} : ${v}.test(${n}))`;return(0,oe._)`${v} && ${v} !== true && ${g} === ${t} && !${w}`}}function f(){let m=d.formats[s];if(!m){b();return}if(m===!0)return;let[h,g,v]=z(m);h===t&&e.pass(N());function b(){if(c.strictSchema===!1){d.logger.warn(w());return}throw new Error(w());function w(){return`unknown format "${s}" ignored in schema at path "${l}"`}}function z(w){let Z=w instanceof RegExp?(0,oe.regexpCode)(w):c.code.formats?(0,oe._)`${c.code.formats}${(0,oe.getProperty)(s)}`:void 0,se=r.scopeValue("formats",{key:s,ref:w,code:Z});return typeof w=="object"&&!(w instanceof RegExp)?[w.type||"string",w.validate,(0,oe._)`${se}.validate`]:["string",w,se]}function N(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!u.$async)throw new Error("async format in sync schema");return(0,oe._)`await ${v}(${n})`}return typeof g=="function"?(0,oe._)`${v}(${n})`:(0,oe._)`${v}.test(${n})`}}}};Oc.default=wS});var lg=$(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});var zS=ug(),SS=[zS.default];Tc.default=SS});var dg=$(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.contentVocabulary=hr.metadataVocabulary=void 0;hr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];hr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var pg=$(Ic=>{"use strict";Object.defineProperty(Ic,"__esModule",{value:!0});var kS=bh(),PS=Ah(),ES=cg(),OS=lg(),fg=dg(),TS=[kS.default,PS.default,(0,ES.default)(),OS.default,fg.metadataVocabulary,fg.contentVocabulary];Ic.default=TS});var hg=$(ms=>{"use strict";Object.defineProperty(ms,"__esModule",{value:!0});ms.DiscrError=void 0;var mg;(function(e){e.Tag="tag",e.Mapping="mapping"})(mg||(ms.DiscrError=mg={}))});var _g=$(Nc=>{"use strict";Object.defineProperty(Nc,"__esModule",{value:!0});var gr=R(),Rc=hg(),gg=Go(),IS=pn(),RS=q(),NS={message:({params:{discrError:e,tagName:t}})=>e===Rc.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,gr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},AS={keyword:"discriminator",type:"object",schemaType:"object",error:NS,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,gr._)`${r}${(0,gr.getProperty)(a)}`);t.if((0,gr._)`typeof ${l} == "string"`,()=>u(),()=>e.error(!1,{discrError:Rc.DiscrError.Tag,tag:l,tagName:a})),e.ok(c);function u(){let f=p();t.if(!1);for(let m in f)t.elseIf((0,gr._)`${l} === ${m}`),t.assign(c,d(f[m]));t.else(),e.error(!1,{discrError:Rc.DiscrError.Mapping,tag:l,tagName:a}),t.endIf()}function d(f){let m=t.name("valid"),h=e.subschema({keyword:"oneOf",schemaProp:f},m);return e.mergeEvaluated(h,gr.Name),m}function p(){var f;let m={},h=v(o),g=!0;for(let N=0;N<i.length;N++){let w=i[N];if(w?.$ref&&!(0,RS.schemaHasRulesButRef)(w,s.self.RULES)){let se=w.$ref;if(w=gg.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,se),w instanceof gg.SchemaEnv&&(w=w.schema),w===void 0)throw new IS.default(s.opts.uriResolver,s.baseId,se)}let Z=(f=w?.properties)===null||f===void 0?void 0:f[a];if(typeof Z!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||v(w)),b(Z,N)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return m;function v({required:N}){return Array.isArray(N)&&N.includes(a)}function b(N,w){if(N.const)z(N.const,w);else if(N.enum)for(let Z of N.enum)z(Z,w);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function z(N,w){if(typeof N!="string"||N in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[N]=w}}}};Nc.default=AS});var yg=$((BR,CS)=>{CS.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 Cc=$((Y,Ac)=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.MissingRefError=Y.ValidationError=Y.CodeGen=Y.Name=Y.nil=Y.stringify=Y.str=Y._=Y.KeywordCxt=Y.Ajv=void 0;var ZS=mh(),jS=pg(),DS=_g(),vg=yg(),MS=["/properties"],hs="http://json-schema.org/draft-07/schema",_r=class extends ZS.default{_addVocabularies(){super._addVocabularies(),jS.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(DS.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(vg,MS):vg;this.addMetaSchema(t,hs,!1),this.refs["http://json-schema.org/schema"]=hs}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(hs)?hs:void 0)}};Y.Ajv=_r;Ac.exports=Y=_r;Ac.exports.Ajv=_r;Object.defineProperty(Y,"__esModule",{value:!0});Y.default=_r;var qS=fn();Object.defineProperty(Y,"KeywordCxt",{enumerable:!0,get:function(){return qS.KeywordCxt}});var yr=R();Object.defineProperty(Y,"_",{enumerable:!0,get:function(){return yr._}});Object.defineProperty(Y,"str",{enumerable:!0,get:function(){return yr.str}});Object.defineProperty(Y,"stringify",{enumerable:!0,get:function(){return yr.stringify}});Object.defineProperty(Y,"nil",{enumerable:!0,get:function(){return yr.nil}});Object.defineProperty(Y,"Name",{enumerable:!0,get:function(){return yr.Name}});Object.defineProperty(Y,"CodeGen",{enumerable:!0,get:function(){return yr.CodeGen}});var FS=Ko();Object.defineProperty(Y,"ValidationError",{enumerable:!0,get:function(){return FS.default}});var LS=pn();Object.defineProperty(Y,"MissingRefError",{enumerable:!0,get:function(){return LS.default}})});var Pg=$(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.formatNames=Qe.fastFormats=Qe.fullFormats=void 0;function Ye(e,t){return{validate:e,compare:t}}Qe.fullFormats={date:Ye(wg,Mc),time:Ye(jc(!0),qc),"date-time":Ye(bg(!0),Sg),"iso-time":Ye(jc(),zg),"iso-date-time":Ye(bg(),kg),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:BS,"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:tk,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:GS,int32:{type:"number",validate:YS},int64:{type:"number",validate:QS},float:{type:"number",validate:xg},double:{type:"number",validate:xg},password:!0,binary:!0};Qe.fastFormats={...Qe.fullFormats,date:Ye(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Mc),time:Ye(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,qc),"date-time":Ye(/^\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,Sg),"iso-time":Ye(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,zg),"iso-date-time":Ye(/^\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,kg),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};Qe.formatNames=Object.keys(Qe.fullFormats);function US(e){return e%4===0&&(e%100!==0||e%400===0)}var VS=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,HS=[0,31,28,31,30,31,30,31,31,30,31,30,31];function wg(e){let t=VS.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&&US(r)?29:HS[n])}function Mc(e,t){if(e&&t)return e>t?1:e<t?-1:0}var Zc=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function jc(e){return function(r){let n=Zc.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,p=o-l*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&i<61}}function qc(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 zg(e,t){if(!(e&&t))return;let r=Zc.exec(e),n=Zc.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 Dc=/t|\s/i;function bg(e){let t=jc(e);return function(n){let o=n.split(Dc);return o.length===2&&wg(o[0])&&t(o[1])}}function Sg(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function kg(e,t){if(!(e&&t))return;let[r,n]=e.split(Dc),[o,s]=t.split(Dc),i=Mc(r,o);if(i!==void 0)return i||qc(n,s)}var JS=/\/|:/,KS=/^(?:[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 BS(e){return JS.test(e)&&KS.test(e)}var $g=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function GS(e){return $g.lastIndex=0,$g.test(e)}var WS=-(2**31),XS=2**31-1;function YS(e){return Number.isInteger(e)&&e<=XS&&e>=WS}function QS(e){return Number.isInteger(e)}function xg(){return!0}var ek=/[^\\]\\Z/;function tk(e){if(ek.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var Eg=$(vr=>{"use strict";Object.defineProperty(vr,"__esModule",{value:!0});vr.formatLimitDefinition=void 0;var rk=Cc(),Be=R(),St=Be.operators,gs={formatMaximum:{okStr:"<=",ok:St.LTE,fail:St.GT},formatMinimum:{okStr:">=",ok:St.GTE,fail:St.LT},formatExclusiveMaximum:{okStr:"<",ok:St.LT,fail:St.GTE},formatExclusiveMinimum:{okStr:">",ok:St.GT,fail:St.LTE}},nk={message:({keyword:e,schemaCode:t})=>(0,Be.str)`should be ${gs[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Be._)`{comparison: ${gs[e].okStr}, limit: ${t}}`};vr.formatLimitDefinition={keyword:Object.keys(gs),type:"string",schemaType:"string",$data:!0,error:nk,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 rk.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?l():u();function l(){let p=t.scopeValue("formats",{ref:a.formats,code:i.code.formats}),f=t.const("fmt",(0,Be._)`${p}[${c.schemaCode}]`);e.fail$data((0,Be.or)((0,Be._)`typeof ${f} != "object"`,(0,Be._)`${f} instanceof RegExp`,(0,Be._)`typeof ${f}.compare != "function"`,d(f)))}function u(){let p=c.schema,f=a.formats[p];if(!f||f===!0)return;if(typeof f!="object"||f instanceof RegExp||typeof f.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let m=t.scopeValue("formats",{key:p,ref:f,code:i.code.formats?(0,Be._)`${i.code.formats}${(0,Be.getProperty)(p)}`:void 0});e.fail$data(d(m))}function d(p){return(0,Be._)`${p}.compare(${r}, ${n}) ${gs[o].fail} 0`}},dependencies:["format"]};var ok=e=>(e.addKeyword(vr.formatLimitDefinition),e);vr.default=ok});var Rg=$((En,Ig)=>{"use strict";Object.defineProperty(En,"__esModule",{value:!0});var br=Pg(),sk=Eg(),Fc=R(),Og=new Fc.Name("fullFormats"),ik=new Fc.Name("fastFormats"),Lc=(e,t={keywords:!0})=>{if(Array.isArray(t))return Tg(e,t,br.fullFormats,Og),e;let[r,n]=t.mode==="fast"?[br.fastFormats,ik]:[br.fullFormats,Og],o=t.formats||br.formatNames;return Tg(e,o,r,n),t.keywords&&(0,sk.default)(e),e};Lc.get=(e,t="full")=>{let n=(t==="fast"?br.fastFormats:br.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function Tg(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,Fc._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}Ig.exports=En=Lc;Object.defineProperty(En,"__esModule",{value:!0});En.default=Lc});var E={};Uc(E,{BIGINT_FORMAT_RANGES:()=>An,CONSTANT_CATCH:()=>tu,Class:()=>Ss,NUMBER_FORMAT_RANGES:()=>xr,aborted:()=>Fe,allowsEval:()=>Ts,assert:()=>Xg,assertEqual:()=>Jg,assertIs:()=>Gg,assertNever:()=>Wg,assertNotEqual:()=>Kg,assignProp:()=>Oe,attachSchema:()=>Zn,base64ToUint8Array:()=>Qc,base64urlToUint8Array:()=>g_,cached:()=>Kt,captureStackTrace:()=>Rn,cleanEnum:()=>h_,cleanRegex:()=>$r,clone:()=>qe,cloneDef:()=>e_,codePointLength:()=>wr,constantCatch:()=>ru,createTransparentProxy:()=>i_,defineLazy:()=>Jc,defineLazyInternal:()=>L,derived:()=>b_,esc:()=>Es,escapeRegex:()=>nt,explicitlyAborted:()=>Ns,extend:()=>u_,finalizeIssue:()=>Le,floatSafeRemainder:()=>Ps,getElementAtPath:()=>t_,getEnumValues:()=>Ht,getLengthableOrigin:()=>zr,getParsedType:()=>s_,getSizableOrigin:()=>Yc,hexToUint8Array:()=>y_,hide:()=>jn,installLazyProp:()=>z_,isObject:()=>Et,isPlainObject:()=>pt,issue:()=>Gt,joinValues:()=>In,jsonStringifyReplacer:()=>Jt,members:()=>Cs,merge:()=>d_,mergeDefs:()=>rt,normalizeParams:()=>P,nullish:()=>ks,numKeys:()=>o_,objectClone:()=>Yg,omit:()=>c_,optionalKeys:()=>Rs,own:()=>ft,parsedType:()=>As,partial:()=>f_,pick:()=>a_,prefixIssues:()=>ot,primitiveTypes:()=>Wc,promiseAllObject:()=>r_,propertyKeyTypes:()=>Is,randomString:()=>n_,rawShape:()=>Bt,required:()=>p_,safeExtend:()=>l_,shallowClone:()=>Gc,slugify:()=>Os,stringifyPrimitive:()=>Nn,toZod:()=>Bg,uint8ArrayToBase64:()=>eu,uint8ArrayToBase64url:()=>__,uint8ArrayToHex:()=>v_,unwrapMessage:()=>Vt});function Jg(e){return e}function Kg(e){return e}function Bg(){return e=>e}function Gg(e){}function Wg(e){throw new Error("Unexpected value in exhaustive check")}function Xg(e){}function Ht(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 In(e,t="|"){return e.map(r=>Nn(r)).join(t)}function Jt(e,t){return typeof t=="bigint"?t.toString():t}var zs=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function Kt(e){return new zs(e)}function ks(e){return e==null}function $r(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Ps(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var Hc=Symbol("evaluating");function Jc(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Hc)return n===void 0&&(n=Hc,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Yg(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Oe(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Bt(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function tt(e){return Bt(e._zod.def)??e._zod.def.shape}function Kc(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return Oe(this,t,n),n},enumerable:!0,configurable:!0})}function Bc(e,t,r){t in e?Oe(e,t,r):e[t]=r}function Pt(e,t,r,n){let o=tt(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);i.enumerable&&(i.get?Kc(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a}):Bc(e,s,n?n(i.value,s):i.value))}}function Qg(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?Kc(e,r,()=>t[r]):Bc(e,r,n.value))}}function rt(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function e_(e){return rt(e._zod.def)}function t_(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function r_(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 n_(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Es(e){return JSON.stringify(e)}function Os(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Rn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Et(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Ts=Kt(()=>{if(xe.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function pt(e){if(Et(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Et(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Gc(e){return pt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function o_(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var s_=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Is=new Set(["string","number","symbol"]),Wc=new Set(["string","number","bigint","boolean","symbol","undefined"]);function nt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function qe(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function P(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 i_(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 Nn(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Rs(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var xr={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]},An={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function a_(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s={};return Pt(s,e,Cn(e,t)),qe(e,rt(r,{shape:s,checks:[]}))}function Cn(e,t){let r=tt(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&n.push(o)}return n}function c_(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Cn(e,t)),i={};return Pt(i,e,Reflect.ownKeys(tt(e)).filter(a=>!s.has(a))),qe(e,rt(r,{shape:i,checks:[]}))}function u_(e,t){if(!pt(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=tt(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return qe(e,rt(e._zod.def,{shape:Xc(e,t)}))}function Xc(e,t){let r={};return Pt(r,e,Reflect.ownKeys(tt(e))),Qg(r,t),r}function l_(e,t){if(!pt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return qe(e,rt(e._zod.def,{shape:Xc(e,t)}))}function d_(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Pt(r,e,Reflect.ownKeys(tt(e))),Pt(r,t,Reflect.ownKeys(tt(t)));let n=rt(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return qe(e,n)}function f_(e,t,r,n="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(Cn(t,r)):void 0,c={};return Pt(c,t,Reflect.ownKeys(tt(t)),e&&((l,u)=>a&&!a.has(u)?l:new e({type:"optional",innerType:l}))),qe(t,rt(t._zod.def,{shape:c,checks:[]}))}function p_(e,t,r){let n=r?new Set(Cn(t,r)):void 0,o={};return Pt(o,t,Reflect.ownKeys(tt(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),qe(t,rt(t._zod.def,{shape:o}))}function Fe(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Ns(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function ot(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function Vt(e){return typeof e=="string"?e:e?.message}function Zn(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function Le(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:Vt(e.inst?._zod.def?.error?.(e))??Vt(s?.(e))??Vt(t?.error?.(e))??Vt(r.customError?.(e))??Vt(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=i,t?.reportInput&&(a.input=e.input),a}function Yc(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var m_=/[\uD800-\uDBFF]/;function wr(e){let t=e.length;if(!m_.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function zr(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function As(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function Gt(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function h_(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Qc(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function eu(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function g_(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Qc(t+r)}function __(e){return eu(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function y_(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function v_(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Ss=class{constructor(...t){}};function Cs(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):$_(e,r,n.value)}}function ft(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function jn(e,t,r){return ft(e,t,r,!1)}function b_(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return ft(this,r,n(this))},set(o){ft(this,r,o)}})}return t}function $_(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:ft(this,t,r.bind(this))},set(n){ft(this,t,n)}})}function x_(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var ws,dt=!1,w_={configurable:!0,get(){dt=!0}};function L(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&ws!==e._zod){ws=void 0;return}ws=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,w_);let o=dt;dt=!1;try{let s=r(this);return dt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),dt=dt||o,s}catch(s){throw delete this[t],dt=dt||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function z_(e,t,r,n){let o=x_(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var tu="~constantCatch";function ru(e){let t=()=>e;return t[tu]=!0,t}var nu;var Zs={value:void 0,enumerable:!1},ou="captureStackTrace"in Error?Error:null;function S_(e){let t=ou;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return ou=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function y(e,t,r,n){let o={};function s(p){this.def=p,this.constr=d,this.traits=new Set}s.prototype=o;let i=r,a=i&&new WeakSet;function c(p,f){if(p._zod){if(p._zod.traits.has(e))return}else{Zs.value=new s(f);try{Object.defineProperty(p,"_zod",Zs)}finally{Zs.value=void 0}}if(p._zod.traits.add(e),t(p,f),a){let h=Object.getPrototypeOf(p),g=p._zod.constr.prototype,v=h;for(;v&&v!==g;)v=Object.getPrototypeOf(v);let b=v??h;a.has(b)||(a.add(b),Cs(b,i))}let m=d.prototype;for(let h in m)Object.prototype.hasOwnProperty.call(m,h)&&(h in p||(p[h]=m[h].bind(p)))}let l=n?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(p){let f=n?.Parent?S_(u):this;c(f,p);let m=f._zod.deferred;if(m){for(let g of m)g();f._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(f),f}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:p=>n?.Parent&&p instanceof n.Parent?!0:p?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Ue=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Wt=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(nu=globalThis).__zod_globalConfig??(nu.__zod_globalConfig={});var xe=globalThis.__zod_globalConfig;function Te(e){return e&&Object.assign(xe,e),xe}function k_(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Jt,2)),e.message}function P_(e){this._zod.message=e}var E_={get:k_,set:P_,enumerable:!0,configurable:!0},Ds={value:void 0,enumerable:!1},su=new WeakSet([Object.prototype,Error.prototype]),iu=(e,t)=>{e.name="$ZodError",Ds.value=t,Object.defineProperty(e,"issues",Ds),Ds.value=void 0,Object.defineProperty(e,"message",E_);let r=Object.getPrototypeOf(e);su.has(r)||(su.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},au=y("$ZodError",iu),cu=y("$ZodError",iu,void 0,{Parent:Error});function O_(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function uu(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?O_(r,o.path[0],()=>[]).push(t(o)):n.push(t(o));return{formErrors:n,fieldErrors:r}}function lu(e,t=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,l=0;for(;l<a.length;){let u=a[l],d=l===a.length-1;if(u==="_errors"){d&&c._errors.push(t(i)),l++;continue}Object.prototype.hasOwnProperty.call(c,u)||Object.defineProperty(c,u,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let p=c[u];d&&p._errors.push(t(i)),c=p,l++}}}};return n(e),r}function Dn(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Mn=e=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Ue;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map(l=>Le(l,i,Te())));throw Rn(c,s?.callee??t),c}return a.value};return t};var qn=e=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(s?.Err??e)(a.issues.map(l=>Le(l,i,Te())));throw Rn(c,s?.callee??t),c}return a.value};return t};var Sr=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 Ue;return s.issues.length?du(e,s.issues,o):{success:!0,data:s.value}},Ms=Sr(cu);function du(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>Le(o,r,Te()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var Fn=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?du(e,s.issues,o):{success:!0,data:s.value}};var I_=Symbol.for("zod.compile.invalid"),R_=Symbol.for("zod.compile.fallback"),Ln=((e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==I_)return!0;if(n.definite===!0&&r===void 0)return!1}return N_(e,t,r)});function N_(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o?(n[R_]=!0,s=o({value:t,issues:[]},n)):s=e._zod.run({value:t,issues:[]},n),s instanceof Promise)throw new Ue;return s.issues.length===0}var Un=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length===0},fu=e=>{let t=Mn(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,Dn(r,i))};return r};var pu=e=>{let t=Mn(e),r=(n,o,s,i)=>t(n,o,s,Dn(r,i));return r};var mu=e=>{let t=qn(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,Dn(r,i))};return r};var hu=e=>{let t=qn(e),r=async(n,o,s,i)=>await t(n,o,s,Dn(r,i));return r};var gu=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Sr(e)(t,r,o)};var _u=e=>(t,r,n)=>Sr(e)(t,r,n);var yu=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Fn(e)(t,r,o)};var vu=e=>async(t,r,n)=>Fn(e)(t,r,n);var bu=/^[cC][0-9a-z]{6,}$/,$u=/^[0-9a-z]+$/,xu=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,wu=/^[0-9a-vA-V]{20}$/,zu=/^[A-Za-z0-9]{27}$/,Su=/^[a-zA-Z0-9_-]{21}$/;function ku(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Pu=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Eu=/^([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})$/,Fs=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|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var Ou=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var A_="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Tu(){return new RegExp(A_,"u")}var Iu=/^(?:(?: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])$/,Ru=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Nu=/^((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])$/,Au=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Cu=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Zu=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var ju=/^https?$/,Du=/^\+[1-9]\d{6,14}$/;var Mu="(?:(?:\\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])))";function C_(e){return new RegExp(`^${e}$`)}var qu=C_(Mu);function qs(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}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Fu(e){return new RegExp(`^${qs(e)}$`)}function Lu(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${qs({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${qs({precision:e.precision})}`:r;return new RegExp(`^${Mu}T(?:${n})$`)}var Uu=/^[\s\S]{0,}$/;var Ls=/^-?\d+$/,kr=/^-?\d+(?:\.\d+)?$/,Vu=/^(?:true|false)$/i,Hu=/^null$/i;var Ju=/^[^A-Z]*$/,Ku=/^[^a-z]*$/;var ce=y("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Us=e=>{let t=e.value;return!ks(t)&&t.length!==void 0},Vn={number:"number",bigint:"bigint",object:"date"},Vs=y("$ZodCheckLessThan",(e,t)=>{ce.init(e,t);let r=Vn[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:Vn[typeof n.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Hs=y("$ZodCheckGreaterThan",(e,t)=>{ce.init(e,t);let r=Vn[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:Vn[typeof n.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Bu=y("$ZodCheckMultipleOf",(e,t)=>{ce.init(e,t),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"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):Ps(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})}}),Gu=y("$ZodCheckNumberFormat",(e,t)=>{ce.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=xr[t.format];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",continue:!1,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,inclusive:!0,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,inclusive:!0,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,inclusive:!0,inst:e,continue:!t.abort})}});var Wu=y("$ZodCheckMaxLength",(e,t)=>{var r;ce.init(e,t),(r=e._zod.def).when??(r.when=Us),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>t.maximum?wr(o):s)<=t.maximum)return;let a=zr(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Xu=y("$ZodCheckMinLength",(e,t)=>{var r;ce.init(e,t),(r=e._zod.def).when??(r.when=Us),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?wr(o):s)>=t.minimum)return;let a=zr(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Yu=y("$ZodCheckLengthEquals",(e,t)=>{var r;ce.init(e,t),(r=e._zod.def).when??(r.when=Us),e._zod.check=n=>{let o=n.value,s=o.length,i=typeof o=="string"&&s>=t.length&&s<=t.length*2?wr(o):s;if(i===t.length)return;let a=zr(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Er=y("$ZodCheckStringFormat",(e,t)=>{var r,n;ce.init(e,t),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=()=>{})}),Qu=y("$ZodCheckRegex",(e,t)=>{Er.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})}}),el=y("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ju),Er.init(e,t)}),tl=y("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ku),Er.init(e,t)}),rl=y("$ZodCheckIncludes",(e,t)=>{ce.init(e,t);let r=nt(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=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})}}),nl=y("$ZodCheckStartsWith",(e,t)=>{ce.init(e,t);let r=new RegExp(`^${nt(t.prefix)}.*`);t.pattern??(t.pattern=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})}}),ol=y("$ZodCheckEndsWith",(e,t)=>{ce.init(e,t);let r=new RegExp(`.*${nt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var sl=y("$ZodCheckOverwrite",(e,t)=>{ce.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Hn=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
9
+ `).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?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
10
+ ${r.join(`
11
+ `)}
12
+ };`)(...Object.values(this.closed))}};var al={major:4,minor:6,patch:5};var B=y("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=al;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,l)=>{if(a.memo)return a;let u=Fe(a),d;for(let p of c){if(p._zod.def.when){if(Ns(a)||!p._zod.def.when(a))continue}else if(u)continue;let f=a.issues.length,m=p._zod.check(a);if(m instanceof Promise&&l?.async===!1)throw new Ue;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,a.issues.length!==f&&(Zn(a.issues,f,e),u||(u=Fe(a,f)))});else{if(a.issues.length===f)continue;Zn(a.issues,f,e),u||(u=Fe(a,f))}}return d?d.then(()=>a):a},i=(a,c,l)=>{if(Fe(a))return a.aborted=!0,a;let u=s(c,o,l);if(u instanceof Promise){if(l.async===!1)throw new Ue;return u.then(d=>e._zod.parse(d,l))}return e._zod.parse(u,l)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let u=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return u instanceof Promise?u.then(d=>i(d,a,c)):i(u,a,c)}let l=e._zod.parse(a,c);if(l instanceof Promise){if(c.async===!1)throw new Ue;return l.then(u=>s(u,o,c))}return s(l,o,c)}}},{get"~standard"(){return jn(this,"~standard",Ks(this))},set"~standard"(e){ft(this,"~standard",e)}}),yl=(e,t)=>e.issues.length?{issues:e.issues.map(r=>Le(r,t,Te()))}:{value:e.value};async function Z_(e,t){let r={async:!0};return yl(await e._zod.run({value:t,issues:[]},r),r)}function Ks(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return yl(n,r)}catch{}return Z_(e,t)},vendor:"zod",version:1}}var Gn=y("$ZodString",(e,t)=>{B.init(e,t),e._zod.pattern=t.pattern??Uu,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}}),G=y("$ZodStringFormat",(e,t)=>{Er.init(e,t),Gn.init(e,t)}),vl=y("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Eu),G.init(e,t)}),bl=y("$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=Fs(n))}else t.pattern??(t.pattern=Fs());G.init(e,t)}),$l=y("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Ou),G.init(e,t)}),xl=1,Kn=2;function wl(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function j_(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?wl(e)||Kn:D_(e,t)}function D_(e,t){if(!t.normalize&&t.protocol?.source===ju.source&&!/^https?:\/\//i.test(e))return xl;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??Kn}return new URL(e)}catch{return Kn}}var M_=/[\t\n\r]/g;function cl(e){return e.replace(M_,"")}function q_(e,t){return t.lastIndex=0,t.test(e.hostname)}function F_(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var zl=y("$ZodURL",(e,t)=>{G.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=j_(n,t);if(o===xl){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Kn){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=cl(n);return}t.hostname&&!q_(o,t.hostname)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&!F_(o,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?o.href:cl(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Sl=y("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Tu()),G.init(e,t)}),kl=y("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?Su:ku(t.length)),G.init(e,t)}),Pl=y("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=bu),G.init(e,t)}),El=y("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=$u),G.init(e,t)}),Ol=y("$ZodULID",(e,t)=>{t.pattern??(t.pattern=xu),G.init(e,t)}),Tl=y("$ZodXID",(e,t)=>{t.pattern??(t.pattern=wu),G.init(e,t)}),Il=y("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=zu),G.init(e,t)}),Rl=y("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Lu(t)),G.init(e,t)}),Nl=y("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=qu),G.init(e,t)}),Al=y("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Fu(t)),G.init(e,t)}),Cl=y("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Pu),G.init(e,t)}),Zl=y("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Iu),G.init(e,t)}),L_=/^[0-9a-fA-F:.]+$/;function jl(e){return L_.test(e)?wl(`http://[${e}]`):!1}var Dl=y("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Ru),G.init(e,t),e._zod.check=r=>{jl(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var Ml=y("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Nu),G.init(e,t)});function U_(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);return`${o}`!==n||o<0||o>128?!1:jl(r)}var ql=y("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Au),G.init(e,t),e._zod.check=r=>{U_(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function Fl(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Bs=/^[0-9a-zA-Z+/]*={0,2}$/,Ll=y("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Bs),G.init(e,t),e._zod.check=r=>{Fl(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),Wn=/^[A-Za-z0-9_-]*$/;function V_(e){if(!Wn.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return Fl(r)}var Ul=y("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Wn),G.init(e,t),e._zod.check=r=>{V_(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Vl=y("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Du),G.init(e,t)});function H_(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 Hl=y("$ZodJWT",(e,t)=>{G.init(e,t),e._zod.check=r=>{H_(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Gs=y("$ZodNumber",(e,t)=>{B.init(e,t),e._zod.pattern=kr,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:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),Jl=y("$ZodNumberFormat",(e,t)=>{Gu.init(e,t),Gs.init(e,t)}),Kl=y("$ZodBoolean",(e,t)=>{B.init(e,t),e._zod.pattern=Vu,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}});var Bl=y("$ZodNull",(e,t)=>{B.init(e,t),e._zod.pattern=Hu,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}});var Gl=y("$ZodUnknown",(e,t)=>{B.init(e,t),e._zod.parse=r=>r}),Wl=y("$ZodNever",(e,t)=>{B.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function ul(e,t,r){e.issues.length&&t.issues.push(...ot(r,e.issues)),t.value[r]=e.value}var Xl=y("$ZodArray",(e,t)=>{B.init(e,t);let r=xe.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){let l=s[c],u=t.element._zod.run({value:l,issues:[]},o);if(u instanceof Promise)i.push(u.then(d=>ul(d,n,c)));else if(ul(u,n,c),a&&u.issues.length!==0&&Fe(u))break}return i.length?Promise.all(i).then(()=>n):n}});function Bn(e,t,r,n,o,s){let i=r in n,a=s==="optional";if(!(!i&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(...ot(r,e.issues))}if(!i&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(i||o==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var J_=[];function Yl(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:J_,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=Rs(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Ql(e,t,r,n,o,s,i){let a=[],c=o.keySet,l=o.catchall._zod,u=l.def.type,d=l.optin,p=l.optout,f=0;for(let m in t){if(i&&r.issues.length!==f){if(Fe(r,f))break;f=r.issues.length}if(c.has(m))continue;if(m==="__proto__"){u==="never"&&a.push(m);continue}if(u==="never"){a.push(m);continue}let h=l.run({value:t[m],issues:[]},n);h instanceof Promise?e.push(h.then(g=>Bn(g,r,m,t,d,p))):Bn(h,r,m,t,d,p)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var K_=y("$ZodObject",(e,t)=>{B.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let l=()=>{let u={...n};return Object.defineProperty(t,"shape",{value:u}),l.raw=u,u};l.raw=n,Object.defineProperty(t,"shape",{get:l})}let o=Kt(()=>Yl(t));L(e,"propValues",l=>{let u=l.def.shape,d={};for(let p in u){let f=u[p]._zod;if(f.values){Object.prototype.hasOwnProperty.call(d,p)||Oe(d,p,new Set);for(let m of f.values)d[p].add(m);f.optin!==void 0&&d[p].add(void 0)}}return d});let s=Et,i=t.catchall,a,c=xe.memoizer;c?.attach(e),e._zod.parse=(l,u)=>{a??(a=o.value);let d=l.value;if(!s(d))return l.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),l;l.value=c?c.alloc(e,l,{},u):{};let p=[],f=a.shape,m=u?.abortEarly,h=l.issues.length;for(let g of a.allKeys){if(m&&l.issues.length!==h){if(Fe(l,h))break;h=l.issues.length}if(g==="__proto__")continue;let v=f[g],b=v._zod.optin,z=v._zod.optout,N=v._zod.run({value:d[g],issues:[]},u);N instanceof Promise?p.push(N.then(w=>Bn(w,l,g,d,b,z))):Bn(N,l,g,d,b,z)}return i?Ql(p,d,l,u,o.value,e,m===!0):p.length?Promise.all(p).then(()=>l):l}}),ed=y("$ZodObjectJIT",(e,t)=>{K_.init(e,t);let r=e._zod.parse,n=Kt(()=>Yl(t)),o=xe.memoizer,s=f=>{let m=n.value,h=m.symbolKeys,g=new Hn(["payload","ctx"],{shape:f,inst:e,memo:o,syms:h}),v=w=>`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`,b=(w,Z)=>`
13
+ let ${w}_ab = false;
14
+ for (let i = 0; i < ${w}.issues.length; i++) {
15
+ const iss = ${w}.issues[i];
16
+ iss.path = iss.path ? [${Z}, ...iss.path] : [${Z}];
17
+ payload.issues.push(iss);
18
+ if (iss.continue !== true) ${w}_ab = true;
19
+ }
20
+ if (${w}_ab && ctx && ctx.abortEarly) {
21
+ payload.value = newResult;
22
+ return payload;
23
+ }`;g.write("const input = payload.value;");let z=Object.create(null),N=0;for(let w of m.allKeys)z[w]=`key_${N++}`;g.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let w of m.allKeys){if(w==="__proto__")continue;let Z=z[w],se=typeof w=="symbol"?`syms[${h.indexOf(w)}]`:Es(w),kt=`${se} in input`,Lt=f[w],et=Lt?._zod?.optin,Ut=et!==void 0,On=Lt?._zod?.optout==="optional";if(g.write(`const ${Z} = ${v(se)};`),Ut&&On){let Tn=et==="optional"?`${Z}_present`:`${Z}.value !== undefined || ${Z}_present`;g.write(`
24
+ const ${Z}_present = ${kt};
25
+ if (!${Z}.issues.length || ${Z}_present) {
26
+ if (${Z}.issues.length) {${b(Z,se)}
27
+ }
28
+
29
+ if (${Tn}) {
30
+ newResult[${se}] = ${Z}.value;
31
+ }
32
+ }
33
+
34
+ `)}else Ut?(g.write(`
35
+ if (${Z}.issues.length) {${b(Z,se)}
36
+ }
37
+ `),et==="defaulted"?g.write(`newResult[${se}] = ${Z}.value;`):g.write(`
38
+ if (${Z}.value !== undefined || ${kt}) {
39
+ newResult[${se}] = ${Z}.value;
40
+ }
41
+ `)):g.write(`
42
+ const ${Z}_present = ${kt};
43
+ if (${Z}.issues.length) {${b(Z,se)}
44
+ }
45
+ if (!${Z}_present && !${Z}.issues.length) {
46
+ payload.issues.push({
47
+ code: "invalid_type",
48
+ expected: "nonoptional",
49
+ input: undefined,
50
+ path: [${se}]
51
+ });
52
+ if (ctx && ctx.abortEarly) {
53
+ payload.value = newResult;
54
+ return payload;
55
+ }
56
+ }
57
+
58
+ if (${Z}_present) {
59
+ newResult[${se}] = ${Z}.value;
60
+ }
61
+
62
+ `)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},i,a=Et,c=!xe.jitless,u=c&&Ts.value,d=t.catchall,p;e._zod.parse=(f,m)=>{p??(p=n.value);let h=f.value;return a(h)?c&&u&&m?.async===!1&&m.jitless!==!0?(i||(i=s(t.shape)),f=i(f,m),d?Ql([],h,f,m,p,e,m?.abortEarly===!0):f):r(f,m):(f.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),f)}});function ll(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!Fe(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>Le(i,n,Te())))}),t)}var Ws=y("$ZodUnion",(e,t)=>{B.init(e,t),L(e,"optin",n=>n.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),L(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),L(e,"values",n=>{if(n.def.options.every(o=>o._zod.values))return new Set(n.def.options.flatMap(o=>Array.from(o._zod.values)))}),L(e,"pattern",n=>{if(n.def.options.every(o=>o._zod.pattern)){let o=n.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>$r(s.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>ll(a,n,e,o)):ll(i,n,e,o)}});function B_(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var td=y("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ws.init(e,t);let r=e._zod.parse;L(e,"propValues",o=>{let s={},i=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&i++;for(let[l,u]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,l)||Oe(s,l,new Set);for(let d of u)s[l].add(d)}}return!o.def.unionFallback&&i>1&&s[o.def.discriminator]?.delete(void 0),s}),t.options.forEach((o,s)=>{let i=Bt(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});let n=Kt(()=>B_(t));e._zod.parse=(o,s)=>{let i=o.value;if(!Et(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=i?.[t.discriminator],c=n.value.get(a);return c&&(a!==void 0||s.direction!=="backward")?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter(l=>n.value.get(l)!==null),input:i,path:[t.discriminator],inst:e}),o)}}),rd=y("$ZodIntersection",(e,t)=>{B.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])=>dl(r,c,l)):dl(r,s,i)}});function Js(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(pt(e)&&pt(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=Js(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=Js(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 dl(e,t,r){let n=new Map,o,s=new Map,i=(l,u)=>{let d;if(l.code==="unrecognized_keys"&&!l.path?.length)o??(o=l),d=l.keys;else if(l.code==="invalid_key"&&l.origin==="record"&&l.path?.length===1){let p=String(l.path[0]);s.has(p)||s.set(p,l),d=[p]}else return!1;for(let p of d)n.has(p)||n.set(p,{}),n.get(p)[u]=!0;return!0};for(let l of t.issues)i(l,"l")||e.issues.push(l);for(let l of r.issues)i(l,"r")||e.issues.push(l);let a=[...n].filter(([,l])=>l.l&&l.r).map(([l])=>l);if(a.length){let l=o?a.filter(u=>o.keys.includes(u)):[];l.length&&e.issues.push({...o,keys:l});for(let u of a)!l.includes(u)&&s.has(u)&&e.issues.push(s.get(u))}let c=Js(t.value,r.value);if(!c.valid){if(Fe(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var nd=y("$ZodRecord",(e,t)=>{B.init(e,t);let r=xe.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!pt(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){if(c.add(typeof u=="number"?u.toString():u),u==="__proto__")continue;let d=t.keyType._zod.run({value:u,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(m=>Le(m,o,Te())),input:u,path:[u],inst:e});continue}let p=d.value;if(p==="__proto__")continue;let f=t.valueType._zod.run({value:s[u],issues:[]},o);f instanceof Promise?i.push(f.then(m=>{m.issues.length&&n.issues.push(...ot(u,m.issues)),n.value[p]=m.value})):(f.issues.length&&n.issues.push(...ot(u,f.issues)),n.value[p]=f.value)}let l;for(let u in s)if(!c.has(u))if(t.mode==="loose"){if(u==="__proto__")continue;n.value[u]=s[u]}else l=l??[],l.push(u);l&&l.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:l,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let l of Reflect.ownKeys(s)){if(l==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,l))continue;let u=t.keyType._zod.run({value:l,issues:[]},o);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof l=="string"&&kr.test(l)&&u.issues.length){let m=t.keyType._zod.run({value:Number(l),issues:[]},o);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(u=m)}if(u.issues.length){t.mode==="loose"?n.value[l]=s[l]:a?(c=c??[],c.push(l)):n.issues.push({code:"invalid_key",origin:"record",issues:u.issues.map(m=>Le(m,o,Te())),input:l,path:[l],inst:e});continue}let p=u.value;if(p==="__proto__")continue;let f=t.valueType._zod.run({value:s[l],issues:[]},o);f instanceof Promise?i.push(f.then(m=>{m.issues.length&&n.issues.push(...ot(l,m.issues)),n.value[p]=m.value})):(f.issues.length&&n.issues.push(...ot(l,f.issues)),n.value[p]=f.value)}c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>n):n}});var od=y("$ZodEnum",(e,t)=>{B.init(e,t);let r=Ht(t.entries),n=new Set(r);e._zod.values=n,L(e,"pattern",o=>{let s=Ht(o.def.entries).filter(i=>Is.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>nt(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),sd=y("$ZodLiteral",(e,t)=>{B.init(e,t);let r=new Set(t.values);e._zod.values=r,L(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(s=>typeof s=="string"?nt(s):s?nt(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var id=y("$ZodTransform",(e,t)=>{B.init(e,t),e._zod.optin="optional",xe.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Wt(e.constructor.name);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 Ue;return r.value=o,r}});function fl(e,t){return e.value=t.issues.length?void 0:t.value,e}var Xs=y("$ZodOptional",(e,t)=>{B.init(e,t),L(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",L(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),L(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${$r(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>fl(r,s)):fl(r,o)}return t.innerType._zod.run(r,n)}}),ad=y("$ZodExactOptional",(e,t)=>{Xs.init(e,t),L(e,"values",r=>r.def.innerType._zod.values),L(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),cd=y("$ZodNullable",(e,t)=>{B.init(e,t),L(e,"optin",r=>r.def.innerType._zod.optin),L(e,"optout",r=>r.def.innerType._zod.optout),L(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${$r(n.source)}|null)$`):void 0}),L(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),ud=y("$ZodDefault",(e,t)=>{B.init(e,t),e._zod.optin="defaulted",L(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(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=>pl(s,t)):pl(o,t)}});function pl(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var ld=y("$ZodPrefault",(e,t)=>{B.init(e,t),e._zod.optin="defaulted",L(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),dd=y("$ZodNonOptional",(e,t)=>{B.init(e,t),L(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>ml(s,e)):ml(o,e)}});function ml(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function hl(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Le(o,n,Te()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var fd=y("$ZodCatch",(e,t)=>{B.init(e,t),L(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),L(e,"optout",r=>r.def.innerType._zod.optout),L(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>hl(r,s,t,n)):hl(r,o,t,n)}});var Ys=y("$ZodPipe",(e,t)=>{B.init(e,t),L(e,"values",r=>r.def.in._zod.values),L(e,"optin",r=>r.def.in._zod.optin),L(e,"optout",r=>r.def.out._zod.optout),L(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>Jn(i,t.in,n)):Jn(s,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Jn(s,t.out,n)):Jn(o,t.out,n)}});function Jn(e,t,r){return e.issues.some(n=>n.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var pd=y("$ZodPreprocess",(e,t)=>{Ys.init(e,t)}),md=y("$ZodReadonly",(e,t)=>{B.init(e,t),L(e,"propValues",r=>r.def.innerType._zod.propValues),L(e,"values",r=>r.def.innerType._zod.values),L(e,"optin",r=>r.def.innerType?._zod?.optin),L(e,"optout",r=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(gl):gl(o)}});function gl(e){return e.memo||(e.value=Object.freeze(e.value)),e}var hd=y("$ZodCustom",(e,t)=>{ce.init(e,t),B.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=>_l(s,r,n,e));_l(o,r,n,e)}});function _l(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(Gt(o))}}var ei=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},ti="~memo",gd=[];function _d(e){return e!==null&&typeof e=="object"}function Qs(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var yd=new WeakMap,Or=0,Qn=1,Tr=2;function eo(e,t,r){let n=yd.get(e);if(n!==void 0)return n?Tr:Or;if(t.has(e))return Tr;t.add(e);let o=Or,s=u=>{if(o!==Tr&&u?._zod){let d=eo(u,t,r);d>o&&(o=d)}},i=(u,d)=>{let p=Or;for(let f of Reflect.ownKeys(u)){let m=Object.getOwnPropertyDescriptor(u,f);if(d&&!m.enumerable)continue;let h=m.get?Qn:m.value?._zod?eo(m.value,t,r):Or;h>p&&(p=h)}return p},a=u=>{u>o&&(o=u)},c=e._zod.def,l=c.type;switch(l){case"object":{let u=Bt(c);a(u?i(u,!0):Qn),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let u of c.items)s(u);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let u of c.options)s(u);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let u=c._cachedInner??(r?e._zod.innerType:void 0);a(u?eo(u,t,!1):Qn);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let u in c){let d=Object.getOwnPropertyDescriptor(c,u);if(!d||d.get)continue;let p=d.value;if(!(!p||typeof p!="object")){if(p._zod)s(p);else if(Array.isArray(p))for(let f of p)s(f)}}}return t.delete(e),G_(e,o)}function G_(e,t){return t!==Qn&&yd.set(e,t===Tr),t}function W_(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var Xn,Yn=[],X_={alloc(e,t,r){let n=Xn;if(!n)return r;Xn=void 0;let o={value:r,issues:null};return n.set(t.value,o),Yn.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&Y_(s,o.value))throw new ei;return r(o,s)};e._zod.parse=n,e._zod.run===r&&(e._zod.run=n)})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,l)=>{if(r===void 0){let v=eo(e,new Set,!1);if(v===Or)return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,l);v===Tr||n?r=!0:n=!0}let u=c.value;if(!_d(u))return i(c,l);let d=l[ti];d||(d={buckets:new WeakMap,backEdges:void 0},l[ti]=d);let p;o===l?p=s:(p=W_(d,e),o=l,s=p);let f=p.get(u);if(f)return c.value=f.value,f.issues?f.issues.length&&c.issues.push(...Qs(f.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(f.value)),c;Xn=p;let m=Yn.length,h=i(c,l);Xn=void 0;let g=Yn.length>m?Yn.pop():void 0;return h instanceof Promise?h.then(v=>(g&&(g.issues=v.issues.length?Qs(v.issues):gd),v)):(g&&(g.issues=h.issues.length?Qs(h.issues):gd),h)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function vd(){return X_}function Y_(e,t){let r=e[ti]?.backEdges;return r!==void 0&&_d(t)&&r.has(t)}var Q_=()=>{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"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??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",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(s,i){return s==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):n[s]??s}return s=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=As(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${Nn(s.values[0])}`:`Invalid option: expected one of ${In(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);return a?`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);return a?`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`:`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${In(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(a=>`'${a}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function bd(){return{localeError:Q_()}}var $d;var ri=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,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)??{}};delete n.id;let o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function ey(){return new ri}($d=globalThis).__zod_globalRegistry??($d.__zod_globalRegistry=ey());var Ot=globalThis.__zod_globalRegistry;function xd(e){return e.checks&&(e.checks=[...e.checks]),e}function wd(e,t){return new e(xd({type:"string",...P(t)}))}function zd(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...P(t)})}function Sd(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...P(t)})}function kd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...P(t)})}function Pd(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...P(t)})}function Ed(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...P(t)})}function Od(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...P(t)})}function Td(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...P(t)})}function Id(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...P(t)})}function Rd(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...P(t)})}function Nd(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...P(t)})}function Ad(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...P(t)})}function Cd(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...P(t)})}function Zd(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...P(t)})}function jd(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...P(t)})}function Dd(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...P(t)})}function Md(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...P(t)})}function qd(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...P(t)})}function Fd(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...P(t)})}function Ld(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...P(t)})}function Ud(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...P(t)})}function Vd(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...P(t)})}function Hd(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...P(t)})}function to(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...P(t)})}function ro(e,t){return new e({type:"string",format:"date",check:"string_format",...P(t)})}function no(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...P(t)})}function oo(e,t){return new e({type:"string",format:"duration",check:"string_format",...P(t)})}function Jd(e,t){return new e(xd({type:"number",checks:[],...P(t)}))}function Kd(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...P(t)})}function Bd(e,t){return new e({type:"boolean",...P(t)})}function Gd(e,t){return new e({type:"null",...P(t)})}function Wd(e){return new e({type:"unknown"})}function Xd(e,t){return new e({type:"never",...P(t)})}function so(e,t){return new Vs({check:"less_than",...P(t),value:e,inclusive:!1})}function Ir(e,t){return new Vs({check:"less_than",...P(t),value:e,inclusive:!0})}function io(e,t){return new Hs({check:"greater_than",...P(t),value:e,inclusive:!1})}function Rr(e,t){return new Hs({check:"greater_than",...P(t),value:e,inclusive:!0})}function ao(e,t){return new Bu({check:"multiple_of",...P(t),value:e})}function co(e,t){return new Wu({check:"max_length",...P(t),maximum:e})}function Xt(e,t){return new Xu({check:"min_length",...P(t),minimum:e})}function uo(e,t){return new Yu({check:"length_equals",...P(t),length:e})}function ni(e,t){return new Qu({check:"string_format",format:"regex",...P(t),pattern:e})}function oi(e){return new el({check:"string_format",format:"lowercase",...P(e)})}function si(e){return new tl({check:"string_format",format:"uppercase",...P(e)})}function ii(e,t){return new rl({check:"string_format",format:"includes",...P(t),includes:e})}function ai(e,t){return new nl({check:"string_format",format:"starts_with",...P(t),prefix:e})}function ci(e,t){return new ol({check:"string_format",format:"ends_with",...P(t),suffix:e})}function mt(e){return new sl({check:"overwrite",tx:e})}function ui(e){return mt(t=>t.normalize(e))}function li(){return mt(e=>e.trim())}function di(){return mt(e=>e.toLowerCase())}function fi(){return mt(e=>e.toUpperCase())}function pi(){return mt(e=>Os(e))}function Yd(e,t,r){return new e({type:"array",element:t,...P(r)})}function Qd(e,t,r){let n=P(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function ef(e,t,r){return new e({type:"custom",check:"custom",fn:t,...P(r)})}function tf(e,t){let r=ty(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Gt(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(Gt(s))}},e(n.value,n)),t);return r}function ty(e,t){let r=new ce({check:"custom",...P(t)});return r._zod.check=e,r}function Nr(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&Oe(e,n,r[n]);return e}function hi(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Ot,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function st(e,t,r,n,o){let s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(r,s),!0}function ne(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let u={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,u);else{let p=i.schema,f=t.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(e,t,p,u)}let d=e._zod.parent;d&&(i.ref||(i.ref=d),ne(d,t,u),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Nr(i.schema,c),t.io==="input"&&ye(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function rf(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function gi(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,p=e.external.uri??(m=>m);if(d)return{ref:p(d)};let f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${p("__shared")}#/${a}/${rf(f)}`}}let c="#",l=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let u=i[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+rf(u)}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:l}=o(i);a.def={...a.schema},l&&(a.defId=l);let u=a.schema;for(let d in u)delete u[d];u.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
63
+
64
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}a.count>1&&e.reused==="ref"&&s(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function sf(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!="object")return;sf(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var af=new Set(["type","properties","required","additionalProperties"]),nf=["oneOf","anyOf"];function of(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function mi(e){let t=[];for(let s of e){if(typeof s!="object"||s.type!=="object")return null;for(let i in s)if(!af.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let l of t){let u=l.properties?.[i]??of(l);u!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(u))||a.push(u))}let c=a.length===1?a[0]:mi(a)??{allOf:a};Oe(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size&&(o.required=[...n]),t.every(s=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=of(i);a&&!s.some(c=>JSON.stringify(c)===JSON.stringify(a))&&s.push(a)}s.length===1?o.additionalProperties=s[0]:s.length>1&&(o.additionalProperties={allOf:s})}return o}function ry(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of af)if(o in e)return;let r=t.filter(o=>nf.some(s=>Array.isArray(o[s]))),n=null;if(!r.length)n=mi(t);else{let o=r[0],s=nf.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter(c=>c!==o),a=o[s].map(c=>mi([...i,c]));if(a.some(c=>!c))return;n={[s]:a}}n&&(delete e.allOf,Nr(e,n))}function _i(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=e.seen.get(a);if(c.ref===null)return;let l=c.def??c.schema,u={...l},d=c.ref;if(c.ref=null,d){n(d);let f=e.seen.get(d),m=f.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(m)):Nr(l,m),Nr(l,u),a._zod.parent===d)for(let g in l)g==="$ref"||g==="allOf"||g in u||delete l[g];if(m.$ref&&f.def)for(let g in l)g==="$ref"||g==="allOf"||g in f.def&&JSON.stringify(l[g])===JSON.stringify(f.def[g])&&delete l[g]}let p=a._zod.parent;if(p&&p!==d){n(p);let f=e.seen.get(p);if(f?.schema.$ref&&(l.$ref=f.schema.$ref,f.def))for(let m in l)m==="$ref"||m==="allOf"||m in f.def&&JSON.stringify(l[m])===JSON.stringify(f.def[m])&&delete l[m]}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())sf(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let l of[c.schema,c.def]){let u=l?.allOf;if(!Array.isArray(u))continue;let d=a.get(u);d?d.push(l):a.set(u,[l])}for(let c of e.intersections)for(let l of a.get(c)??[])ry(l)}}let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}Nr(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,Oe(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Ar(t,"input",e.processors),output:Ar(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function ye(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return ye(n.element,r);if(n.type==="set")return ye(n.valueType,r);if(n.type==="lazy")return ye(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return ye(n.innerType,r);if(n.type==="intersection")return ye(n.left,r)||ye(n.right,r);if(n.type==="record"||n.type==="map")return ye(n.keyType,r)||ye(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ye(n.in,r)||ye(n.out,r);if(n.type==="object"){for(let o in n.shape)if(ye(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(ye(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(ye(o,r))return!0;return!!(n.rest&&ye(n.rest,r))}return!1}var cf=(e,t={})=>r=>{let n=hi({...r,processors:t});return ne(e,n),gi(n,e),_i(n,e)},Ar=(e,t,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=hi({...o??{},target:s,io:t,processors:r});return ne(e,i),gi(i,e),_i(i,e)};var Yt=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},Qt=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},uf=(e,t)=>{Yt(e,"minimum",t),Qt(e,"maximum",t)},pf=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},mf=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},hf=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},gf=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},lf=(e,t)=>Yt(e,"minimum",t.minimum),df=(e,t)=>Qt(e,"maximum",t.maximum),ff=e=>(t,r)=>{gf(t,r.format);let[n,o]=e[r.format];Yt(t,"minimum",n),Qt(t,"maximum",o)},ny={greater_than:(e,t)=>Yt(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Qt(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>pf(e,t.value),number_format:ff(xr),bigint_format:ff(An),min_length:lf,max_length:df,length_equals:(e,t)=>uf(e,t.length),min_size:lf,max_size:df,size_equals:(e,t)=>uf(e,t.size),string_format:(e,t)=>{gf(e,t.format),t.pattern&&mf(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>hf(e,t.mime)};function Ne(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)ny[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;o.minimum!==void 0&&Yt(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&Yt(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&Qt(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&Qt(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&pf(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&hf(t,o.mime);for(let s of o.patterns??[])mf(t,s);return t}var oy={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},sy=new Map([[Bs,Cu],[Wn,Zu]]),_f=e=>sy.get(e)??e,yf=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:l,laxFormat:u}=Ne(e);if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=oy[a]??a,o.format===""&&delete o.format,(a==="time"||u)&&delete o.format),l&&(o.contentEncoding=l),c&&c.size>0){let d=[...c].map(_f);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(p=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:p.source}))])}},vf=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Ne(e);o.type=u?"integer":"number";let d=typeof l=="number"&&l>=(s??Number.NEGATIVE_INFINITY),p=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),f=t.target==="draft-04"||t.target==="openapi-3.0";if(d?f?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l:typeof s=="number"&&(o.minimum=s),p?f?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof i=="number"&&(o.maximum=i),a){let m=new Set;for(let v of a)Number.isFinite(v)&&v!==0?m.add(Math.abs(v)):st(e,t,o,n,`A multipleOf divisor of ${v} cannot be represented in JSON Schema`);let[h,...g]=m;h!==void 0&&(o.multipleOf=h),g.length&&(o.allOf=[...o.allOf??[],...g.map(v=>({multipleOf:v}))])}},bf=(e,t,r,n)=>{r.type="boolean"};var $f=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var xf=(e,t,r,n)=>{r.not={}};var wf=(e,t,r,n)=>{};var zf=(e,t,r,n)=>{let o=e._zod.def,s=Ht(o.entries);if(s.length===0){r.not={};return}s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},Sf=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(st(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(st(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var kf=(e,t,r,n)=>{st(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var Pf=(e,t,r,n)=>{st(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var Ef=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=Ne(e);typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ne(s.element,t,{...n,path:[...n.path,"items"]})};function lo(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?lo(t.out):t.type==="catch"?lo(t.innerType):e._zod.optin}var Of=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&st(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let l in i)Oe(o.properties,l,ne(i[l],t,{...n,path:[...n.path,"properties",l]}));let c=[];for(let l of Object.keys(i)){let u=s.shape[l];(t.io==="input"?lo(u)===void 0:u._zod.optout===void 0)&&c.push(l)}c.length>0&&(o.required=c),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=ne(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Tf=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>ne(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},If=(e,t,r,n)=>{let o=e._zod.def,s=ne(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=ne(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)};function yi(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let m=e.get(t)?.def;if(!m)return t;let h=yi(e,m,r);return h===m?t:h}for(let m of["anyOf","oneOf"]){let h=t[m];if(!Array.isArray(h))continue;let g=h.map(v=>yi(e,v,r));g.some((v,b)=>v!==h[b])&&(t={...t,[m]:g})}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some(m=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some(m=>typeof m=="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:p,...f}=t;return f.enum?f.enum=f.enum.map(m=>typeof m=="number"?String(m):m):typeof f.const=="number"&&(f.const=String(f.const)),o&&(f.type="string",s||(f.pattern=(n.includes("number")?kr:Ls).source)),f}var vi=new WeakMap;function iy(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let r=new Map;for(let n of vi.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=yi(t,s,new Set);i!==s&&r.set(s,i)}if(r.size)for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);s&&(o.propertyNames=s)}}var Rf=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=Ne(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let u=ne(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)Oe(o.patternProperties,_f(d).source,u)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=ne(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let u=vi.get(t);u||(u=[],vi.set(t,u),t.deferred.push(()=>iy(t))),u.push(e)}o.additionalProperties=ne(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,l=t.io==="input"&&lo(s.valueType)!==void 0;if(c&&!s.partial&&!l){let u=[...c].filter(d=>typeof d=="string"||typeof d=="number");u.length>0&&(o.required=u.map(String))}},Nf=(e,t,r,n)=>{let o=e._zod.def,s=ne(o.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},Af=(e,t,r,n)=>{let o=e._zod.def;ne(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},bi=Symbol();function Cf(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(st(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),bi):JSON.parse(i)}var Zf=(e,t,r,n)=>{let o=e._zod.def;ne(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=Cf(o.defaultValue,e,t,r,n);i!==bi&&(r.default=i)},jf=(e,t,r,n)=>{let o=e._zod.def;ne(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=Cf(o.defaultValue,e,t,r,n);i!==bi&&(r._prefault=i)},Df=(e,t,r,n)=>{let o=e._zod.def;ne(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{st(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},Mf=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;ne(i,t,n);let a=t.seen.get(e);a.ref=i},qf=(e,t,r,n)=>{let o=e._zod.def;ne(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var $i=(e,t,r,n)=>{let o=e._zod.def;ne(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};function fo(e){return!!e._zod}function ht(e,t){return fo(e)?Ms(e,t):e.safeParse(t)}function po(e){if(!e)return;let t;if(fo(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function mo(e){if(fo(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 Ff=new WeakSet([Object.prototype,Error.prototype]);function ho(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var gy=(e,t)=>{au.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);Ff.has(r)||(Ff.add(r),ho(r,"format",n=>o=>lu(n,o)),ho(r,"flatten",n=>o=>uu(n,o)),ho(r,"addIssue",n=>o=>{n.issues.push(o),n.message=JSON.stringify(n.issues,Jt,2)}),ho(r,"addIssues",n=>o=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,Jt,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))};var Ie=y("ZodError",gy,void 0,{Parent:Error});var Lf=Mn(Ie),Uf=qn(Ie),Vf=Sr(Ie),Hf=Fn(Ie),Jf=fu(Ie),Kf=pu(Ie),Bf=mu(Ie),Gf=hu(Ie),Wf=gu(Ie),Xf=_u(Ie),Yf=yu(Ie),Qf=vu(Ie);function yy(){xe.localeError||Te(bd())}function _o(){xe.memoizer||Te({memoizer:vd()})}var te=y("ZodType",(e,t)=>(yy(),B.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(E.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return qe(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(av(e,t))},superRefine(e,t){return this.check(cv(e,t))},overwrite(e){return this.check(mt(e))},optional(){return ee(this)},exactOptional(){return Gy(this)},nullable(){return rp(this)},nullish(){return ee(rp(this))},nonoptional(e){return tv(this,e)},array(){return D(this)},or(e){return W([this,e])},and(e){return yo(this,e)},transform(e){return np(this,up(e))},default(e){return Yy(this,e)},prefault(e){return ev(this,e)},catch(e){return nv(this,e)},pipe(e){return np(this,e)},readonly(){return iv(this)},describe(e){let t=this.clone();return Ot.add(t,{description:e}),t},meta(...e){if(e.length===0)return Ot.get(this);let t=this.clone();return Ot.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return E.hide(this,"~standard",{...Ks(this),jsonSchema:{input:Ar(this,"input"),output:Ar(this,"output")}})},set"~standard"(e){E.own(this,"~standard",e)},parse:function e(t,r){return Lf(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Uf(this,t,r,{callee:e})},safeParse(e,t){return Vf(this,e,t)},async safeParseAsync(e,t){return Hf(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){E.own(this,"spa",e)},validate(e,t){return Ln(this,e,t)},validateAsync(e,t){return Un(this,e,t)},encode:function e(t,r){return Jf(this,t,r,{callee:e})},decode:function e(t,r){return Kf(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Bf(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Gf(this,t,r,{callee:e})},safeEncode(e,t){return Wf(this,e,t)},safeDecode(e,t){return Xf(this,e,t)},async safeEncodeAsync(e,t){return Yf(this,e,t)},async safeDecodeAsync(e,t){return Qf(this,e,t)},toJSONSchema(e){return cf(this,{})(e)},get description(){return Ot.get(this)?.description},get _def(){return this._zod.def}}),op=y("_ZodString",(e,t)=>{Gn.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>yf(e,r,n,o)},E.derived({format:e=>Ne(e).format??null,minLength:e=>Ne(e).minimum??null,maxLength:e=>Ne(e).maximum??null},{regex(...e){return this.check(ni(...e))},includes(...e){return this.check(ii(...e))},startsWith(...e){return this.check(ai(...e))},endsWith(...e){return this.check(ci(...e))},min(...e){return this.check(Xt(...e))},max(...e){return this.check(co(...e))},length(...e){return this.check(uo(...e))},nonempty(...e){return this.check(Xt(1,...e))},lowercase(e){return this.check(oi(e))},uppercase(e){return this.check(si(e))},trim(){return this.check(li())},normalize(...e){return this.check(ui(...e))},toLowerCase(){return this.check(di())},toUpperCase(){return this.check(fi())},slugify(){return this.check(pi())}})),vy=y("ZodString",(e,t)=>{Gn.init(e,t),op.init(e,t)},{email(e){return this.check(zd(by,e))},url(e){return this.check(Td(xy,e))},jwt(e){return this.check(Hd(jy,e))},emoji(e){return this.check(Id(wy,e))},guid(e){return this.check(Sd($y,e))},uuid(e){return this.check(kd(go,e))},uuidv4(e){return this.check(Pd(go,e))},uuidv6(e){return this.check(Ed(go,e))},uuidv7(e){return this.check(Od(go,e))},nanoid(e){return this.check(Rd(zy,e))},cuid(e){return this.check(Nd(Sy,e))},cuid2(e){return this.check(Ad(ky,e))},ulid(e){return this.check(Cd(Py,e))},base64(e){return this.check(Ld(Ay,e))},base64url(e){return this.check(Ud(Cy,e))},xid(e){return this.check(Zd(Ey,e))},ksuid(e){return this.check(jd(Oy,e))},ipv4(e){return this.check(Dd(Ty,e))},ipv6(e){return this.check(Md(Iy,e))},cidrv4(e){return this.check(qd(Ry,e))},cidrv6(e){return this.check(Fd(Ny,e))},e164(e){return this.check(Vd(Zy,e))},datetime(e){return this.check(to(Zr,e))},date(e){return this.check(ro(jr,e))},time(e){return this.check(no(Dr,e))},duration(e){return this.check(oo(Mr,e))}});function _(e){return wd(vy,e)}var re=y("ZodStringFormat",(e,t)=>{G.init(e,t),op.init(e,t)}),Zr=y("ZodISODateTime",(e,t)=>{Rl.init(e,t),re.init(e,t)}),jr=y("ZodISODate",(e,t)=>{Nl.init(e,t),re.init(e,t)}),Dr=y("ZodISOTime",(e,t)=>{Al.init(e,t),re.init(e,t)}),Mr=y("ZodISODuration",(e,t)=>{Cl.init(e,t),re.init(e,t)}),by=y("ZodEmail",(e,t)=>{$l.init(e,t),re.init(e,t)});var $y=y("ZodGUID",(e,t)=>{vl.init(e,t),re.init(e,t)});var go=y("ZodUUID",(e,t)=>{bl.init(e,t),re.init(e,t)});var xy=y("ZodURL",(e,t)=>{zl.init(e,t),re.init(e,t)});var wy=y("ZodEmoji",(e,t)=>{Sl.init(e,t),re.init(e,t)});var zy=y("ZodNanoID",(e,t)=>{kl.init(e,t),re.init(e,t)});var Sy=y("ZodCUID",(e,t)=>{Pl.init(e,t),re.init(e,t)});var ky=y("ZodCUID2",(e,t)=>{El.init(e,t),re.init(e,t)});var Py=y("ZodULID",(e,t)=>{Ol.init(e,t),re.init(e,t)});var Ey=y("ZodXID",(e,t)=>{Tl.init(e,t),re.init(e,t)});var Oy=y("ZodKSUID",(e,t)=>{Il.init(e,t),re.init(e,t)});var Ty=y("ZodIPv4",(e,t)=>{Zl.init(e,t),re.init(e,t)});var Iy=y("ZodIPv6",(e,t)=>{Dl.init(e,t),re.init(e,t)});var Ry=y("ZodCIDRv4",(e,t)=>{Ml.init(e,t),re.init(e,t)});var Ny=y("ZodCIDRv6",(e,t)=>{ql.init(e,t),re.init(e,t)});var Ay=y("ZodBase64",(e,t)=>{Ll.init(e,t),re.init(e,t)});var Cy=y("ZodBase64URL",(e,t)=>{Ul.init(e,t),re.init(e,t)});var Zy=y("ZodE164",(e,t)=>{Vl.init(e,t),re.init(e,t)});var jy=y("ZodJWT",(e,t)=>{Hl.init(e,t),re.init(e,t)});var sp=y("ZodNumber",(e,t)=>{Gs.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>vf(e,r,n,o),e.isFinite=!0},E.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=Ne(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=Ne(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=Ne(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>Ne(e).format??null},{gt(e,t){return this.check(io(e,t))},gte(e,t){return this.check(Rr(e,t))},min(e,t){return this.check(Rr(e,t))},lt(e,t){return this.check(so(e,t))},lte(e,t){return this.check(Ir(e,t))},max(e,t){return this.check(Ir(e,t))},int(e){return this.check(ep(e))},safe(e){return this.check(ep(e))},positive(e){return this.check(io(0,e))},nonnegative(e){return this.check(Rr(0,e))},negative(e){return this.check(so(0,e))},nonpositive(e){return this.check(Ir(0,e))},multipleOf(e,t){return this.check(ao(e,t))},step(e,t){return this.check(ao(e,t))},finite(){return this}}));function V(e){return Jd(sp,e)}var Dy=y("ZodNumberFormat",(e,t)=>{Jl.init(e,t),sp.init(e,t)});function ep(e){return Kd(Dy,e)}var My=y("ZodBoolean",(e,t)=>{Kl.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>bf(e,r,n,o)});function ae(e){return Bd(My,e)}var qy=y("ZodNull",(e,t)=>{Bl.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$f(e,r,n,o)});function ip(e){return Gd(qy,e)}var Fy=y("ZodUnknown",(e,t)=>{Gl.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wf(e,r,n,o)});function Q(){return Wd(Fy)}var Ly=y("ZodNever",(e,t)=>{Wl.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>xf(e,r,n,o)});function Uy(e){return Xd(Ly,e)}var Vy=y("ZodArray",(e,t)=>{_o(),Xl.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ef(e,r,n,o),e.element=t.element},{min(e,t){return this.check(Xt(e,t))},nonempty(e){return this.check(Xt(1,e))},max(e,t){return this.check(co(e,t))},length(e,t){return this.check(uo(e,t))},unwrap(){return this.element}});function D(e,t){return Yd(Vy,e,t)}var ap=y("ZodObject",(e,t)=>{_o(),ed.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Of(e,r,n,o),E.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return we(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(E.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(E.mergeDefs(this._zod.def,{catchall:Q()}))},loose(){return this.clone(E.mergeDefs(this._zod.def,{catchall:Q()}))},strict(){return this.clone(E.mergeDefs(this._zod.def,{catchall:Uy()}))},strip(){return this.clone(E.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return E.extend(this,e)},safeExtend(e){return E.safeExtend(this,e)},merge(e){return E.merge(this,e)},pick(e){return E.pick(this,e)},omit(e){return E.omit(this,e)},partial(...e){return E.partial(lp,this,e[0])},exactPartial(...e){return E.partial(dp,this,e[0],"exactPartial")},required(...e){return E.required(fp,this,e[0])}});function x(e,t){let r={type:"object",shape:e??{},...E.normalizeParams(t)};return new ap(r)}function ve(e,t){return new ap({type:"object",shape:e,catchall:Q(),...E.normalizeParams(t)})}var cp=y("ZodUnion",(e,t)=>{Ws.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Tf(e,r,n,o),e.options=t.options});function W(e,t){return new cp({type:"union",options:e,...E.normalizeParams(t)})}var Hy=y("ZodDiscriminatedUnion",(e,t)=>{cp.init(e,t),td.init(e,t)});function wi(e,t,r){return new Hy({type:"union",options:t,discriminator:e,...E.normalizeParams(r)})}var Jy=y("ZodIntersection",(e,t)=>{rd.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>If(e,r,n,o)});function yo(e,t){return new Jy({type:"intersection",left:e,right:t})}var tp=y("ZodRecord",(e,t)=>{_o(),nd.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Rf(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function K(e,t,r){return!t||!t._zod?new tp({type:"record",keyType:_(),valueType:e,...E.normalizeParams(t)}):new tp({type:"record",keyType:e,valueType:t,...E.normalizeParams(r)})}var xi=y("ZodEnum",(e,t)=>{od.init(e,t),te.init(e,t),e._zod.processJSONSchema=(n,o,s)=>zf(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];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 xi({...t,checks:[],...E.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 xi({...t,checks:[],...E.normalizeParams(o),entries:s})}});function we(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new xi({type:"enum",entries:r,...E.normalizeParams(t)})}var Ky=y("ZodLiteral",(e,t)=>{sd.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Sf(e,r,n,o),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 S(e,t){return new Ky({type:"literal",values:Array.isArray(e)?e:[e],...E.normalizeParams(t)})}var By=y("ZodTransform",(e,t)=>{_o(),id.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Pf(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Wt(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(E.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(E.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 up(e){return new By({type:"transform",transform:e})}var lp=y("ZodOptional",(e,t)=>{Xs.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$i(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ee(e){return new lp({type:"optional",innerType:e})}var dp=y("ZodExactOptional",(e,t)=>{ad.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$i(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Gy(e){return new dp({type:"optional",innerType:e})}var Wy=y("ZodNullable",(e,t)=>{cd.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Nf(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function rp(e){return new Wy({type:"nullable",innerType:e})}var Xy=y("ZodDefault",(e,t)=>{ud.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zf(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Yy(e,t){return new Xy({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():E.shallowClone(t)}})}var Qy=y("ZodPrefault",(e,t)=>{ld.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>jf(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ev(e,t){return new Qy({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():E.shallowClone(t)}})}var fp=y("ZodNonOptional",(e,t)=>{dd.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Af(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function tv(e,t){return new fp({type:"nonoptional",innerType:e,...E.normalizeParams(t)})}var rv=y("ZodCatch",(e,t)=>{fd.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Df(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function nv(e,t){return new rv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:E.constantCatch(t)})}var pp=y("ZodPipe",(e,t)=>{Ys.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Mf(e,r,n,o),e.in=t.in,e.out=t.out});function np(e,t){return new pp({type:"pipe",in:e,out:t})}var ov=y("ZodPreprocess",(e,t)=>{pp.init(e,t),pd.init(e,t)}),sv=y("ZodReadonly",(e,t)=>{md.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qf(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function iv(e){return new sv({type:"readonly",innerType:e})}var mp=y("ZodCustom",(e,t)=>{hd.init(e,t),te.init(e,t),e._zod.processJSONSchema=(r,n,o)=>kf(e,r,n,o)});function hp(e,t){return Qd(mp,e??(()=>!0),t)}function av(e,t={}){return ef(mp,e,t)}function cv(e,t){return tf(e,t)}function zi(e,t){return new ov({type:"pipe",in:up(e),out:t})}var vo={};Uc(vo,{ZodISODate:()=>jr,ZodISODateTime:()=>Zr,ZodISODuration:()=>Mr,ZodISOTime:()=>Dr,date:()=>lv,datetime:()=>uv,duration:()=>fv,time:()=>dv});function uv(e){return to(Zr,e)}function lv(e){return ro(jr,e)}function dv(e){return no(Dr,e)}function fv(e){return oo(Mr,e)}var ki="2025-11-25";var gp=[ki,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],gt="io.modelcontextprotocol/related-task",$o="2.0",ie=hp(e=>e!==null&&(typeof e=="object"||typeof e=="function")),_p=W([_(),V().int()]),yp=_(),BE=ve({ttl:V().optional(),pollInterval:V().optional()}),pv=x({ttl:V().optional()}),mv=x({taskId:_()}),Pi=ve({progressToken:_p.optional(),[gt]:mv.optional()}),Re=x({_meta:Pi.optional()}),qr=Re.extend({task:pv.optional()}),vp=e=>qr.safeParse(e).success,ue=x({method:_(),params:Re.loose().optional()}),Ae=x({_meta:Pi.optional()}),Ce=x({method:_(),params:Ae.loose().optional()}),le=ve({_meta:Pi.optional()}),xo=W([_(),V().int()]),bp=x({jsonrpc:S($o),id:xo,...ue.shape}).strict(),Ei=e=>bp.safeParse(e).success,$p=x({jsonrpc:S($o),...Ce.shape}).strict(),xp=e=>$p.safeParse(e).success,Oi=x({jsonrpc:S($o),id:xo,result:le}).strict(),Fr=e=>Oi.safeParse(e).success;var j;(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"})(j||(j={}));var Ti=x({jsonrpc:S($o),id:xo.optional(),error:x({code:V().int(),message:_(),data:Q().optional()})}).strict();var wp=e=>Ti.safeParse(e).success;var zp=W([bp,$p,Oi,Ti]),GE=W([Oi,Ti]),wo=le.strict(),hv=Ae.extend({requestId:xo.optional(),reason:_().optional()}),zo=Ce.extend({method:S("notifications/cancelled"),params:hv}),gv=x({src:_(),mimeType:_().optional(),sizes:D(_()).optional(),theme:we(["light","dark"]).optional()}),Lr=x({icons:D(gv).optional()}),er=x({name:_(),title:_().optional()}),Sp=er.extend({...er.shape,...Lr.shape,version:_(),websiteUrl:_().optional(),description:_().optional()}),_v=yo(x({applyDefaults:ae().optional()}),K(_(),Q())),yv=zi(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,yo(x({form:_v.optional(),url:ie.optional()}),K(_(),Q()).optional())),vv=ve({list:ie.optional(),cancel:ie.optional(),requests:ve({sampling:ve({createMessage:ie.optional()}).optional(),elicitation:ve({create:ie.optional()}).optional()}).optional()}),bv=ve({list:ie.optional(),cancel:ie.optional(),requests:ve({tools:ve({call:ie.optional()}).optional()}).optional()}),$v=x({experimental:K(_(),ie).optional(),sampling:x({context:ie.optional(),tools:ie.optional()}).optional(),elicitation:yv.optional(),roots:x({listChanged:ae().optional()}).optional(),tasks:vv.optional(),extensions:K(_(),ie).optional()}),xv=Re.extend({protocolVersion:_(),capabilities:$v,clientInfo:Sp}),Ii=ue.extend({method:S("initialize"),params:xv});var wv=x({experimental:K(_(),ie).optional(),logging:ie.optional(),completions:ie.optional(),prompts:x({listChanged:ae().optional()}).optional(),resources:x({subscribe:ae().optional(),listChanged:ae().optional()}).optional(),tools:x({listChanged:ae().optional()}).optional(),tasks:bv.optional(),extensions:K(_(),ie).optional()}),zv=le.extend({protocolVersion:_(),capabilities:wv,serverInfo:Sp,instructions:_().optional()}),Ri=Ce.extend({method:S("notifications/initialized"),params:Ae.optional()});var So=ue.extend({method:S("ping"),params:Re.optional()}),Sv=x({progress:V(),total:ee(V()),message:ee(_())}),kv=x({...Ae.shape,...Sv.shape,progressToken:_p}),ko=Ce.extend({method:S("notifications/progress"),params:kv}),Pv=Re.extend({cursor:yp.optional()}),Ur=ue.extend({params:Pv.optional()}),Vr=le.extend({nextCursor:yp.optional()}),Ev=we(["working","input_required","completed","failed","cancelled"]),Hr=x({taskId:_(),status:Ev,ttl:W([V(),ip()]),createdAt:_(),lastUpdatedAt:_(),pollInterval:ee(V()),statusMessage:ee(_())}),tr=le.extend({task:Hr}),Ov=Ae.merge(Hr),Jr=Ce.extend({method:S("notifications/tasks/status"),params:Ov}),Po=ue.extend({method:S("tasks/get"),params:Re.extend({taskId:_()})}),Eo=le.merge(Hr),Oo=ue.extend({method:S("tasks/result"),params:Re.extend({taskId:_()})}),WE=le.loose(),To=Ur.extend({method:S("tasks/list")}),Io=Vr.extend({tasks:D(Hr)}),Ro=ue.extend({method:S("tasks/cancel"),params:Re.extend({taskId:_()})}),kp=le.merge(Hr),Pp=x({uri:_(),mimeType:ee(_()),_meta:K(_(),Q()).optional()}),Ep=Pp.extend({text:_()}),Ni=_().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Op=Pp.extend({blob:Ni}),Kr=we(["user","assistant"]),rr=x({audience:D(Kr).optional(),priority:V().min(0).max(1).optional(),lastModified:vo.datetime({offset:!0}).optional()}),Tp=x({...er.shape,...Lr.shape,uri:_(),description:ee(_()),mimeType:ee(_()),size:ee(V()),annotations:rr.optional(),_meta:ee(ve({}))}),Tv=x({...er.shape,...Lr.shape,uriTemplate:_(),description:ee(_()),mimeType:ee(_()),annotations:rr.optional(),_meta:ee(ve({}))}),Iv=Ur.extend({method:S("resources/list")}),Rv=Vr.extend({resources:D(Tp)}),Nv=Ur.extend({method:S("resources/templates/list")}),Av=Vr.extend({resourceTemplates:D(Tv)}),Ai=Re.extend({uri:_()}),Cv=Ai,Zv=ue.extend({method:S("resources/read"),params:Cv}),jv=le.extend({contents:D(W([Ep,Op]))}),Dv=Ce.extend({method:S("notifications/resources/list_changed"),params:Ae.optional()}),Mv=Ai,qv=ue.extend({method:S("resources/subscribe"),params:Mv}),Fv=Ai,Lv=ue.extend({method:S("resources/unsubscribe"),params:Fv}),Uv=Ae.extend({uri:_()}),Vv=Ce.extend({method:S("notifications/resources/updated"),params:Uv}),Hv=x({name:_(),description:ee(_()),required:ee(ae())}),Jv=x({...er.shape,...Lr.shape,description:ee(_()),arguments:ee(D(Hv)),_meta:ee(ve({}))}),Kv=Ur.extend({method:S("prompts/list")}),Bv=Vr.extend({prompts:D(Jv)}),Gv=Re.extend({name:_(),arguments:K(_(),_()).optional()}),Wv=ue.extend({method:S("prompts/get"),params:Gv}),Ci=x({type:S("text"),text:_(),annotations:rr.optional(),_meta:K(_(),Q()).optional()}),Zi=x({type:S("image"),data:Ni,mimeType:_(),annotations:rr.optional(),_meta:K(_(),Q()).optional()}),ji=x({type:S("audio"),data:Ni,mimeType:_(),annotations:rr.optional(),_meta:K(_(),Q()).optional()}),Xv=x({type:S("tool_use"),name:_(),id:_(),input:K(_(),Q()),_meta:K(_(),Q()).optional()}),Yv=x({type:S("resource"),resource:W([Ep,Op]),annotations:rr.optional(),_meta:K(_(),Q()).optional()}),Qv=Tp.extend({type:S("resource_link")}),Di=W([Ci,Zi,ji,Qv,Yv]),e0=x({role:Kr,content:Di}),t0=le.extend({description:_().optional(),messages:D(e0)}),r0=Ce.extend({method:S("notifications/prompts/list_changed"),params:Ae.optional()}),n0=x({title:_().optional(),readOnlyHint:ae().optional(),destructiveHint:ae().optional(),idempotentHint:ae().optional(),openWorldHint:ae().optional()}),o0=x({taskSupport:we(["required","optional","forbidden"]).optional()}),Ip=x({...er.shape,...Lr.shape,description:_().optional(),inputSchema:x({type:S("object"),properties:K(_(),ie).optional(),required:D(_()).optional()}).catchall(Q()),outputSchema:x({type:S("object"),properties:K(_(),ie).optional(),required:D(_()).optional()}).catchall(Q()).optional(),annotations:n0.optional(),execution:o0.optional(),_meta:K(_(),Q()).optional()}),Mi=Ur.extend({method:S("tools/list")}),s0=Vr.extend({tools:D(Ip)}),No=le.extend({content:D(Di).default([]),structuredContent:K(_(),Q()).optional(),isError:ae().optional()}),XE=No.or(le.extend({toolResult:Q()})),i0=qr.extend({name:_(),arguments:K(_(),Q()).optional()}),Br=ue.extend({method:S("tools/call"),params:i0}),a0=Ce.extend({method:S("notifications/tools/list_changed"),params:Ae.optional()}),YE=x({autoRefresh:ae().default(!0),debounceMs:V().int().nonnegative().default(300)}),Gr=we(["debug","info","notice","warning","error","critical","alert","emergency"]),c0=Re.extend({level:Gr}),qi=ue.extend({method:S("logging/setLevel"),params:c0}),u0=Ae.extend({level:Gr,logger:_().optional(),data:Q()}),l0=Ce.extend({method:S("notifications/message"),params:u0}),d0=x({name:_().optional()}),f0=x({hints:D(d0).optional(),costPriority:V().min(0).max(1).optional(),speedPriority:V().min(0).max(1).optional(),intelligencePriority:V().min(0).max(1).optional()}),p0=x({mode:we(["auto","required","none"]).optional()}),m0=x({type:S("tool_result"),toolUseId:_().describe("The unique identifier for the corresponding tool call."),content:D(Di).default([]),structuredContent:x({}).loose().optional(),isError:ae().optional(),_meta:K(_(),Q()).optional()}),h0=wi("type",[Ci,Zi,ji]),bo=wi("type",[Ci,Zi,ji,Xv,m0]),g0=x({role:Kr,content:W([bo,D(bo)]),_meta:K(_(),Q()).optional()}),_0=qr.extend({messages:D(g0),modelPreferences:f0.optional(),systemPrompt:_().optional(),includeContext:we(["none","thisServer","allServers"]).optional(),temperature:V().optional(),maxTokens:V().int(),stopSequences:D(_()).optional(),metadata:ie.optional(),tools:D(Ip).optional(),toolChoice:p0.optional()}),y0=ue.extend({method:S("sampling/createMessage"),params:_0}),Wr=le.extend({model:_(),stopReason:ee(we(["endTurn","stopSequence","maxTokens"]).or(_())),role:Kr,content:h0}),Fi=le.extend({model:_(),stopReason:ee(we(["endTurn","stopSequence","maxTokens","toolUse"]).or(_())),role:Kr,content:W([bo,D(bo)])}),v0=x({type:S("boolean"),title:_().optional(),description:_().optional(),default:ae().optional()}),b0=x({type:S("string"),title:_().optional(),description:_().optional(),minLength:V().optional(),maxLength:V().optional(),format:we(["email","uri","date","date-time"]).optional(),default:_().optional()}),$0=x({type:we(["number","integer"]),title:_().optional(),description:_().optional(),minimum:V().optional(),maximum:V().optional(),default:V().optional()}),x0=x({type:S("string"),title:_().optional(),description:_().optional(),enum:D(_()),default:_().optional()}),w0=x({type:S("string"),title:_().optional(),description:_().optional(),oneOf:D(x({const:_(),title:_()})),default:_().optional()}),z0=x({type:S("string"),title:_().optional(),description:_().optional(),enum:D(_()),enumNames:D(_()).optional(),default:_().optional()}),S0=W([x0,w0]),k0=x({type:S("array"),title:_().optional(),description:_().optional(),minItems:V().optional(),maxItems:V().optional(),items:x({type:S("string"),enum:D(_())}),default:D(_()).optional()}),P0=x({type:S("array"),title:_().optional(),description:_().optional(),minItems:V().optional(),maxItems:V().optional(),items:x({anyOf:D(x({const:_(),title:_()}))}),default:D(_()).optional()}),E0=W([k0,P0]),O0=W([z0,S0,E0]),T0=W([O0,v0,b0,$0]),I0=qr.extend({mode:S("form").optional(),message:_(),requestedSchema:x({type:S("object"),properties:K(_(),T0),required:D(_()).optional()})}),R0=qr.extend({mode:S("url"),message:_(),elicitationId:_(),url:_().url()}),N0=W([I0,R0]),A0=ue.extend({method:S("elicitation/create"),params:N0}),C0=Ae.extend({elicitationId:_()}),Z0=Ce.extend({method:S("notifications/elicitation/complete"),params:C0}),nr=le.extend({action:we(["accept","decline","cancel"]),content:zi(e=>e===null?void 0:e,K(_(),W([_(),V(),ae(),D(_())])).optional())}),j0=x({type:S("ref/resource"),uri:_()});var D0=x({type:S("ref/prompt"),name:_()}),M0=Re.extend({ref:W([D0,j0]),argument:x({name:_(),value:_()}),context:x({arguments:K(_(),_()).optional()}).optional()}),q0=ue.extend({method:S("completion/complete"),params:M0});var F0=le.extend({completion:ve({values:D(_()).max(100),total:ee(V().int()),hasMore:ee(ae())})}),L0=x({uri:_().startsWith("file://"),name:_().optional(),_meta:K(_(),Q()).optional()}),U0=ue.extend({method:S("roots/list"),params:Re.optional()}),Li=le.extend({roots:D(L0)}),V0=Ce.extend({method:S("notifications/roots/list_changed"),params:Ae.optional()}),QE=W([So,Ii,q0,qi,Wv,Kv,Iv,Nv,Zv,qv,Lv,Br,Mi,Po,Oo,To,Ro]),eO=W([zo,ko,Ri,V0,Jr]),tO=W([wo,Wr,Fi,nr,Li,Eo,Io,tr]),rO=W([So,y0,A0,U0,Po,Oo,To,Ro]),nO=W([zo,ko,l0,Vv,Dv,a0,r0,Jr,Z0]),oO=W([wo,zv,F0,t0,Bv,Rv,Av,jv,No,s0,Eo,Io,tr]),T=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===j.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Si(o.elicitations,r)}return new e(t,r,n)}},Si=class extends T{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(j.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function _t(e){return e==="completed"||e==="failed"||e==="cancelled"}var jO=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Ui(e){let r=po(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=mo(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Vi(e,t){let r=ht(e,t);if(!r.success)throw r.error;return r.data}var W0=6e4,Ao=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(zo,r=>{this._oncancel(r)}),this.setNotificationHandler(ko,r=>{this._onprogress(r)}),this.setRequestHandler(So,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Po,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new T(j.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Oo,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,p=new T(d.error.code,d.error.message,d.error.data);u(p)}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 T(j.InvalidParams,`Task not found: ${s}`);if(!_t(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(_t(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[gt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(To,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 T(j.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Ro,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new T(j.InvalidParams,`Task not found: ${r.params.taskId}`);if(_t(o.status))throw new T(j.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 T(j.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof T?o:new T(j.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),T.fromError(j.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),Fr(s)||wp(s)?this._onresponse(s):Ei(s)?this._onrequest(s,i):xp(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=T.fromError(j.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?.[gt]?.taskId;if(n===void 0){let u={jsonrpc:"2.0",id:t.id,error:{code:j.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=vp(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,p)=>{if(i.signal.aborted)throw new T(j.ConnectionClosed,"Request was cancelled");let f={...p,relatedRequestId:t.id};s&&!f.relatedTask&&(f.relatedTask={taskId:s});let m=f.relatedTask?.taskId??s;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(u,d,f)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,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:j.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),Fr(t))n(t);else{let i=new T(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(Fr(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),Fr(t))o(t);else{let i=T.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 T?i:new T(j.InternalError,String(i))}}return}let s;try{let i=await this.request(t,tr,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new T(j.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},_t(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new T(j.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new T(j.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 T?i:new T(j.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=b=>{u(b)};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(b){d(b);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,f={...t,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),f.params={...t.params,_meta:{...t.params?._meta||{},progressToken:p}}),a&&(f.params={...f.params,task:a}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[gt]:c}});let m=b=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(b)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(N=>this._onerror(new Error(`Failed to send cancellation: ${N}`)));let z=b instanceof T?b:new T(j.RequestTimeout,String(b));u(z)};this._responseHandlers.set(p,b=>{if(!n?.signal?.aborted){if(b instanceof Error)return u(b);try{let z=ht(r,b.result);z.success?l(z.data):u(z.error)}catch(z){u(z)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let h=n?.timeout??W0,g=()=>m(T.fromError(j.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(p,h,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let v=c?.taskId;if(v){let b=z=>{let N=this._responseHandlers.get(p);N?N(z):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,b),this._enqueueTaskMessage(v,{type:"request",message:f,timestamp:Date.now()}).catch(z=>{this._cleanupTimeout(p),u(z)})}else this._transport.send(f,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(b=>{this._cleanupTimeout(p),u(b)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Eo,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},Io,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},kp,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||{},[gt]: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||{},[gt]: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||{},[gt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=Ui(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=Vi(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=Ui(t);this._notificationHandlers.set(n,o=>{let s=Vi(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"&&Ei(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new T(j.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 T(j.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new T(j.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 T(j.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=Jr.parse({method:"notifications/tasks/status",params:a});await this.notification(c),_t(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 T(j.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(_t(a.status))throw new T(j.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=Jr.parse({method:"notifications/tasks/status",params:c});await this.notification(l),_t(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function Rp(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Np(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];Rp(i)&&Rp(s)?r[o]={...i,...s}:r[o]=s}return r}var Ng=Vc(Cc(),1),Ag=Vc(Rg(),1);function ak(){let e=new Ng.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Ag.default)(e),e}var _s=class{constructor(t){this._ajv=t??ak()}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 ys=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(u=>u.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],l=c.some(u=>u.type==="tool_use");if(i){if(s.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!l)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(l){let u=new Set(c.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(s.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(u.size!==d.size||![...u].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},Wr,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:s},nr,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function Cg(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 Zg(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}}var vs=class extends Ao{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Gr.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let s=this._loggingLevels.get(o);return s?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(s):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new _s,this.setRequestHandler(Ii,n=>this._oninitialize(n)),this.setNotificationHandler(Ri,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(qi,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=Gr.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new ys(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Np(this._capabilities,t)}setRequestHandler(t,r){let o=po(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=mo(o);if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,l)=>{let u=ht(Br,c);if(!u.success){let m=u.error instanceof Error?u.error.message:String(u.error);throw new T(j.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=u.data,p=await Promise.resolve(r(c,l));if(d.task){let m=ht(tr,p);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new T(j.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}let f=ht(No,p);if(!f.success){let m=f.error instanceof Error?f.error.message:String(f.error);throw new T(j.InvalidParams,`Invalid tools/call result: ${m}`)}return f.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){Zg(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&Cg(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:gp.includes(r)?r:ki,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},wo)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(l=>l.type==="tool_result"),i=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(l=>l.type==="tool_use");if(s){if(o.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let l=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),u=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(l.size!==u.size||![...l].every(d=>u.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},Fi,r):this.request({method:"sampling/createMessage",params:t},Wr,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=t;return this.request({method:"elicitation/create",params:o},nr,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},s=await this.request({method:"elicitation/create",params:o},nr,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new T(j.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof T?i:new T(j.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},Li,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};import Dg from"node:process";var ck=10*1024*1024,bs=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??ck}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
65
+ `);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),uk(r)}clear(){this._buffer=void 0}};function uk(e){return zp.parse(JSON.parse(e))}function jg(e){return JSON.stringify(e)+`
66
+ `}var $s=class{constructor(t=Dg.stdin,r=Dg.stdout,n){this._stdin=t,this._stdout=r,this._started=!1,this._ondata=o=>{try{this._readBuffer.append(o),this.processReadBuffer()}catch(s){this.onerror?.(s),this.close().catch(()=>{})}},this._onerror=o=>{this.onerror?.(o)},this._readBuffer=new bs({maxBufferSize:n?.maxBufferSize})}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=jg(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};async function gN(){let e=process.env.AIBO_HOST_TOOL_ENDPOINT,t=process.env.AIBO_HOST_TOOL_TOKEN;if(!/^http:\/\/127\.0\.0\.1:[1-9][0-9]*$/.test(e??"")||!/^[a-f0-9]{64}$/.test(t??""))throw Error("Invalid host tool bridge configuration");let r=async(o,s)=>{let i=await fetch(e+o,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"},body:JSON.stringify(s),signal:AbortSignal.timeout(3e4)}),a=await i.text();if(Buffer.byteLength(a)>262144)throw Error("Host tool result exceeds transport limit");let c=JSON.parse(a);if(!i.ok)throw Error(c.error??"Host tool unavailable");return c},n=new vs({name:"aibo-host-tools",version:"1.0.0"},{capabilities:{tools:{}}});n.setRequestHandler(Mi,()=>r("/list",{})),n.setRequestHandler(Br,async({params:o})=>{try{let{result:s}=await r("/call",o);return{content:[{type:"text",text:JSON.stringify(s)}],structuredContent:s}}catch(s){return{content:[{type:"text",text:String(s.message??s)}],isError:!0}}}),await n.connect(new $s),process.stdin.once("end",()=>{n.close()})}export{gN as serveHostToolMcp};
@@ -0,0 +1,12 @@
1
+ import type { InvocationTools } from './runtime.js';
2
+ import type { CapabilityInvocation } from '@aibolabs/plugin-protocol';
3
+ export type HostToolDefinition = {name:string;description:string;inputSchema:Record<string,unknown>;outputSchema?:Record<string,unknown>;annotations?:Record<string,unknown>};
4
+ export function hostToolDefinitions(context: unknown): HostToolDefinition[];
5
+ export function createHostToolChannel(): {
6
+ begin(request:CapabilityInvocation, tools:Pick<InvocationTools,'signal'|'emit'>, nativeSessionId:()=>string|null):()=>void;
7
+ call(name:string,input:unknown):Promise<unknown>;
8
+ respond(input:{requestId:string;result?:unknown;error?:string}):{resolved:true};
9
+ };
10
+ export function createHostToolMcpBridge(options:{definitions:HostToolDefinition[];call(name:string,input:unknown):Promise<unknown>}):Promise<{
11
+ ready:Promise<void>;configuration:{name:string;command:string;args:string[];env:Record<string,string>};close():Promise<void>;
12
+ }>;
package/host-tools.mjs ADDED
@@ -0,0 +1,85 @@
1
+ /** Generic host tool transport. No provider names, database access, or tool-specific behavior. */
2
+ import { createServer } from 'node:http';
3
+ import { randomBytes } from 'node:crypto';
4
+
5
+ export function hostToolDefinitions(context) {
6
+ const catalog=context?.hostTools;
7
+ if (catalog == null) return [];
8
+ if (catalog.schema!=='aibo.host-tools/v1' || !Array.isArray(catalog.tools) || catalog.tools.length>32
9
+ || catalog.tools.some(tool=>!tool || typeof tool.name!=='string' || typeof tool.description!=='string' || tool.inputSchema?.type!=='object')) throw Error('Invalid host tool catalog');
10
+ return structuredClone(catalog.tools);
11
+ }
12
+ export function createHostToolChannel() {
13
+ let active, next=0;
14
+ const pending=new Map();
15
+ const fail=(message)=>Object.assign(new Error(message),{kind:'permission_denied'});
16
+ function clear(owner, reason) {
17
+ for (const [id, item] of pending) if(item.owner===owner){pending.delete(id);clearTimeout(item.timer);item.reject(fail(reason));}
18
+ }
19
+ return {
20
+ begin(request,tools,nativeSessionId) {
21
+ if(active) throw Error('Host tool invocation already active');
22
+ const owner={request,tools,nativeSessionId,names:new Set(hostToolDefinitions(request.context).map(tool=>tool.name))};
23
+ active=owner;
24
+ const abort=()=>clear(owner,'cancelled: host tool invocation cancelled');
25
+ tools.signal.addEventListener('abort',abort,{once:true});
26
+ return ()=>{tools.signal.removeEventListener('abort',abort);clear(owner,'cancelled: host tool invocation ended');if(active===owner)active=undefined;};
27
+ },
28
+ call(name,input) {
29
+ const owner=active;
30
+ if(!owner || !owner.request.context.turnId || owner.tools.signal.aborted || !owner.names.has(name)) return Promise.reject(fail('Host tool is not available in this active turn'));
31
+ if(pending.size>=8) return Promise.reject(Error('Host tool concurrency limit'));
32
+ if(Buffer.byteLength(JSON.stringify(input))>131072) return Promise.reject(Error('Host tool input exceeds limit'));
33
+ const requestId=`host-history-${++next}`;
34
+ return new Promise((resolve,reject)=>{
35
+ const timer=setTimeout(()=>{pending.delete(requestId);reject(Error('Host tool request timed out'));},Math.max(1,Math.min(30000,owner.request.deadlineUnixMs-Date.now())));
36
+ pending.set(requestId,{owner,resolve,reject,timer});
37
+ try {owner.tools.emit({type:'workspace.requested',nativeSessionId:owner.nativeSessionId(),turnId:owner.request.context.turnId,
38
+ correlation:{requestId},payload:{requestId,tool:name,input}});}
39
+ catch(error){clearTimeout(timer);pending.delete(requestId);reject(error);}
40
+ });
41
+ },
42
+ respond(input) {
43
+ const item=pending.get(input.requestId);
44
+ if(!item || item.owner!==active || active.tools.signal.aborted) throw fail('Host tool request is no longer pending');
45
+ pending.delete(input.requestId);clearTimeout(item.timer);
46
+ if(typeof input.error==='string')item.reject(Error(input.error));else item.resolve(input.result);
47
+ return {resolved:true};
48
+ },
49
+ };
50
+ }
51
+
52
+ /** Private loopback relay for SDK-backed MCP stdio children. Never expose credentials to the model. */
53
+ export async function createHostToolMcpBridge({definitions,call}) {
54
+ const token=randomBytes(32).toString('hex');
55
+ let confirm;const ready=new Promise(resolve=>{confirm=resolve;});
56
+ let inflight=0;
57
+ const sockets=new Set();
58
+ const server=createServer(async(req,res)=>{
59
+ const reply=(status,value)=>{if(!res.destroyed){res.writeHead(status,{'Content-Type':'application/json'});res.end(JSON.stringify(value));}};
60
+ if(req.method!=='POST' || req.headers.authorization!==`Bearer ${token}`){reply(403,{error:'Unauthorized'});return;}
61
+ if(inflight>=8){reply(429,{error:'Tool concurrency limit'});return;}
62
+ inflight++;
63
+ try {
64
+ let size=0;const parts=[];
65
+ for await(const part of req){size+=part.length;if(size>131072){reply(413,{error:'Input exceeds limit'});req.destroy();return;}parts.push(part);}
66
+ const input=JSON.parse(Buffer.concat(parts).toString('utf8'));
67
+ if(req.url==='/list'){reply(200,{tools:definitions});confirm();return;}
68
+ if(req.url!=='/call' || !definitions.some(tool=>tool.name===input.name)) throw Error('Unknown host tool');
69
+ reply(200,{result:await call(input.name,input.arguments??{})});
70
+ }catch(error){reply(400,{error:String(error.message??error).slice(0,4096)});}
71
+ finally{inflight--;}
72
+ });
73
+ server.requestTimeout=35000;server.headersTimeout=5000;server.timeout=35000;server.maxConnections=12;
74
+ server.on('connection',socket=>{sockets.add(socket);socket.on('close',()=>sockets.delete(socket));});
75
+ await new Promise((resolve,reject)=>{server.once('error',reject);server.listen(0,'127.0.0.1',resolve);});
76
+ const moduleUrl=new URL('./host-tools-mcp.mjs',import.meta.url).href;
77
+ // In an installed plugin use the public host SDK export; local source tests use a file URL.
78
+ const specifier=moduleUrl.startsWith('aibo-sdk:')?'@aibolabs/capability-runtime/host-tools-mcp':moduleUrl;
79
+ return {
80
+ ready,
81
+ configuration:{name:`aibo-${randomBytes(8).toString('hex')}`,command:process.execPath,args:[...process.execArgv,'--input-type=module','-e',`import { serveHostToolMcp } from ${JSON.stringify(specifier)}; await serveHostToolMcp();`],
82
+ env:{AIBO_HOST_TOOL_ENDPOINT:`http://127.0.0.1:${server.address().port}`,AIBO_HOST_TOOL_TOKEN:token}},
83
+ async close(){for(const socket of sockets)socket.destroy();await new Promise(resolve=>server.close(resolve));},
84
+ };
85
+ }
package/package.json CHANGED
@@ -1,6 +1,50 @@
1
1
  {
2
2
  "name": "@aibolabs/capability-runtime",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.8",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/chldu2000/aibo.git",
8
+ "directory": "packages/capability-runtime"
9
+ },
10
+ "type": "module",
11
+ "files": [
12
+ "runtime.mjs",
13
+ "stdio.mjs",
14
+ "runtime.d.ts",
15
+ "stdio.d.ts",
16
+ "README.md",
17
+ "host-tools.mjs",
18
+ "host-tools.d.ts",
19
+ "host-tools-mcp.mjs",
20
+ "host-tools-mcp.d.ts"
21
+ ],
22
+ "exports": {
23
+ ".": {
24
+ "types": "./runtime.d.ts",
25
+ "import": "./runtime.mjs"
26
+ },
27
+ "./stdio": {
28
+ "types": "./stdio.d.ts",
29
+ "import": "./stdio.mjs"
30
+ },
31
+ "./host-tools": {
32
+ "types": "./host-tools.d.ts",
33
+ "import": "./host-tools.mjs"
34
+ },
35
+ "./host-tools-mcp": {
36
+ "types": "./host-tools-mcp.d.ts",
37
+ "import": "./host-tools-mcp.mjs"
38
+ }
39
+ },
40
+ "dependencies": {
41
+ "@aibolabs/plugin-protocol": "0.1.8"
42
+ },
43
+ "engines": {
44
+ "node": ">=22"
45
+ },
46
+ "publishConfig": {
47
+ "access": "public",
48
+ "registry": "https://registry.npmjs.org/"
49
+ }
50
+ }
package/runtime.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import type { JsonValue, CapabilityInitialization, CapabilityInvocation, CapabilityOperation, CapabilityCallTarget, CapabilityResult, CapabilityControl } from '@aibolabs/plugin-protocol';
2
+ /** Structural cancellation port; no DOM or Node type library is required. */
3
+ export interface CancellationSignal {
4
+ readonly aborted:boolean;
5
+ readonly reason:unknown;
6
+ addEventListener(type:'abort',listener:()=>void,options?:{once?:boolean}):void;
7
+ removeEventListener(type:'abort',listener:()=>void):void;
8
+ }
9
+ export type InvocationTools = {initialization:CapabilityInitialization;signal:CancellationSignal;call(target:CapabilityCallTarget):Promise<CapabilityResult>;emit(event:JsonValue):void};
10
+ export type CapabilityOptions = {pluginId:string;pluginVersion:string;contributionId:string;protocol?:'2.0'|'2.1';operations:CapabilityOperation[];invoke(request:CapabilityInvocation,tools:InvocationTools):JsonValue|Promise<JsonValue>;control?(request:CapabilityControl,tools:{invocation:CapabilityInvocation;signal:CancellationSignal}):JsonValue|Promise<JsonValue>};
11
+ export function createCapabilityRuntime(options:CapabilityOptions & {send(message:JsonValue):void}):{receive(message:unknown):Promise<void>;close(reason?:string):void};
package/runtime.mjs ADDED
@@ -0,0 +1,108 @@
1
+ /** Runtime 2.0 dispatcher. Host authority and process cancellation remain in Aibo. */
2
+ export function createCapabilityRuntime({ pluginId, pluginVersion, contributionId, protocol = '2.0', operations, invoke, control, send }) {
3
+ if (!['2.0','2.1'].includes(protocol)) throw Error('Unsupported capability protocol');
4
+ let initialized, active, closed = false, nextId = 0;
5
+ const pending = new Map();
6
+ const copy = value => JSON.parse(JSON.stringify(value));
7
+ const offered = copy(operations);
8
+ const reply = (id, result) => send({jsonrpc:'2.0',id,result});
9
+ const reject = (id, message) => send({jsonrpc:'2.0',id,error:{code:-32602,message}});
10
+ function handlerError(id, error, fallback) {
11
+ const kinds = new Set(['unsupported','incompatible_version','permission_denied','provider_unavailable','busy','cancelled','timeout','invalid_output','invalid_input','approval_rejected','outcome_unknown']);
12
+ const aliases = {capability_unsupported:'unsupported',invalid_request:'invalid_input',invalid_session:'invalid_input',invalid_recovery_data:'invalid_input'};
13
+ const raw = error?.kind ?? error?.code;
14
+ const kind = kinds.has(raw) ? raw : aliases[raw] ?? 'provider_unavailable';
15
+ send({jsonrpc:'2.0',id,error:{code:-32000,message:(error instanceof Error ? error.message : fallback).slice(0,4096),data:{kind}}});
16
+ }
17
+
18
+ function close(reason = 'Capability transport closed') {
19
+ closed = true;
20
+ active?.abort.abort(new Error(reason));
21
+ for (const request of pending.values()) request.reject(new Error(reason));
22
+ pending.clear();
23
+ }
24
+ async function receive(message) {
25
+ if (closed) return;
26
+ const {id,method,params:p} = message ?? {};
27
+ if (message?.jsonrpc !== '2.0' || (typeof id !== 'string' && typeof id !== 'number')) throw Error('Invalid JSON-RPC envelope');
28
+ if (method === undefined) {
29
+ const request = pending.get(id);
30
+ if (!request) throw Error('Unknown capability response');
31
+ pending.delete(id);
32
+ if (message.result?.ok === true && message.result.response) request.resolve(copy(message.result.response));
33
+ else request.reject(Object.assign(new Error(message.result?.error?.message ?? message.error?.message ?? 'Invalid capability response'), {code:message.result?.error?.code ?? 'invalid_output'}));
34
+ return;
35
+ }
36
+ if (method === 'capability.initialize') {
37
+ if (active || p?.protocol !== protocol || p.pluginId !== pluginId || p.pluginVersion !== pluginVersion || p.contributionId !== contributionId || typeof p.generationId !== 'string' || typeof p.instanceId !== 'string') return reject(id,'Incompatible initialization');
38
+ if (initialized && JSON.stringify(initialized) !== JSON.stringify(p)) return reject(id,'Runtime identity cannot change');
39
+ initialized = copy(p);
40
+ return reply(id,{protocol,pluginId,pluginVersion,generationId:p.generationId,operations:copy(offered)});
41
+ }
42
+ if (method === 'capability.control') {
43
+ const owner = active;
44
+ const keys = ['instanceId','generationId','contributionId','invocationId','capability','contractVersion','operationId','input'];
45
+ if (protocol !== '2.1' || !control || !initialized || !owner || owner.controlling || owner.abort.signal.aborted || Date.now() >= owner.request.deadlineUnixMs || !p || Object.keys(p).some(key=>!keys.includes(key)) || p.invocationId !== owner.id || p.instanceId !== initialized.instanceId || p.generationId !== initialized.generationId || p.contributionId !== contributionId || !offered.some(op=>op.capability===p.capability && op.version===p.contractVersion && op.operationId===p.operationId)) return reject(id,'Invalid control identity or operation');
46
+ owner.controlling = true;
47
+ let listener;
48
+ const aborted = new Promise((_,reject) => {
49
+ listener = () => reject(owner.abort.signal.reason);
50
+ owner.abort.signal.addEventListener('abort',listener,{once:true});
51
+ });
52
+ try {
53
+ const output = await Promise.race([Promise.resolve().then(()=>control(copy(p),{invocation:copy(owner.request),signal:owner.abort.signal})),aborted]);
54
+ if (!closed) reply(id,{invocationId:owner.id,generationId:initialized.generationId,output:copy(output)});
55
+ } catch(error) {
56
+ if (!closed) handlerError(id,error,'Capability control failed');
57
+ } finally {
58
+ owner.abort.signal.removeEventListener('abort',listener);
59
+ owner.controlling = false;
60
+ }
61
+ return;
62
+ }
63
+ if (method !== 'capability.invoke') return reject(id,'Unsupported capability method');
64
+ if (!initialized || active || p?.generationId !== initialized.generationId || p.instanceId !== initialized.instanceId || p.contributionId !== contributionId || typeof p.invocationId !== 'string' || !Number.isSafeInteger(p.deadlineUnixMs) || !offered.some(op=>op.capability===p.capability && op.version===p.contractVersion && op.operationId===p.operationId)) return reject(id,'Invalid invocation identity or operation');
65
+ if (p.deadlineUnixMs <= Date.now()) return reject(id,'Capability deadline expired');
66
+ const owner = {id:p.invocationId,request:copy(p),abort:new AbortController(),calls:0,sequence:0,streamBytes:0,controlling:false};
67
+ active = owner;
68
+ const emit = event => {
69
+ if (protocol !== '2.1') throw Error('Streaming requires capability protocol 2.1');
70
+ if (closed || active !== owner || owner.abort.signal.aborted || Date.now() >= owner.request.deadlineUnixMs) throw Error('Invocation is no longer active');
71
+ const value = copy(event);
72
+ const bytes = new TextEncoder().encode(JSON.stringify(value)).length;
73
+ if (bytes > 262144 || owner.sequence >= 100000 || owner.streamBytes+bytes > 64*1024*1024) throw Error('Capability stream limit');
74
+ owner.streamBytes += bytes;
75
+ send({jsonrpc:'2.0',method:'capability.event',params:{instanceId:initialized.instanceId,generationId:initialized.generationId,contributionId,invocationId:owner.id,sequence:++owner.sequence,event:value}});
76
+ };
77
+ const timer = setTimeout(()=>owner.abort.abort(new Error('Capability deadline expired')),Math.max(0,Math.min(p.deadlineUnixMs-Date.now(),2147483647)));
78
+ const call = target => {
79
+ if (closed || active !== owner || owner.abort.signal.aborted) return Promise.reject(new Error('Invocation is no longer active'));
80
+ if (++owner.calls > 32) return Promise.reject(new Error('Capability child call limit'));
81
+ if (!target || Object.keys(target).some(key=>!['pluginId','contributionId','capability','version','input'].includes(key))) return Promise.reject(new Error('Child calls cannot supply host authority'));
82
+ const childId = `sdk-child-${++nextId}`;
83
+ return new Promise((resolve,reject) => {
84
+ pending.set(childId,{resolve,reject,owner});
85
+ try { send({jsonrpc:'2.0',id:childId,method:'capability.call',params:{...copy(target),invocationId:owner.id,generationId:initialized.generationId}}); }
86
+ catch(error) {pending.delete(childId);reject(error);}
87
+ });
88
+ };
89
+ let abortListener;
90
+ const aborted = new Promise((_,reject) => {
91
+ abortListener = () => reject(owner.abort.signal.reason);
92
+ owner.abort.signal.addEventListener('abort',abortListener,{once:true});
93
+ });
94
+ try {
95
+ const result = await Promise.race([Promise.resolve().then(()=>invoke(copy(p),{initialization:copy(initialized),signal:owner.abort.signal,call,emit})),aborted]);
96
+ if (!closed) reply(id,{invocationId:owner.id,generationId:initialized.generationId,output:copy(result)});
97
+ } catch(error) {
98
+ if (!closed) handlerError(id,error,'Capability handler failed');
99
+ } finally {
100
+ clearTimeout(timer);
101
+ owner.abort.signal.removeEventListener('abort',abortListener);
102
+ owner.abort.abort(new Error('Invocation completed'));
103
+ for (const [key,request] of pending) if (request.owner===owner) {pending.delete(key);request.reject(new Error('Parent invocation completed'));}
104
+ if (active===owner) active=undefined;
105
+ }
106
+ }
107
+ return {receive,close};
108
+ }
package/stdio.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ import type { CapabilityOptions } from './runtime.js';
2
+ export function serveCapability(options:CapabilityOptions):{close():void};
3
+
4
+ /** A generation binds one declared contribution; later initialization cannot switch it. */
5
+ export function serveCapabilities(contributions:CapabilityOptions[]):{close():void};
package/stdio.mjs ADDED
@@ -0,0 +1,31 @@
1
+ import { createInterface } from 'node:readline';
2
+ import { createCapabilityRuntime } from './runtime.mjs';
3
+ /** stdout is reserved for protocol frames; plugin diagnostics belong on stderr. */
4
+ function serve(select) {
5
+ let runtime;
6
+ const send = message=>process.stdout.write(JSON.stringify(message)+'\n');
7
+ const lines = createInterface({input:process.stdin});
8
+ const fail = error=>{runtime?.close(String(error));lines.close();process.exitCode=1;};
9
+ lines.on('line', line => {
10
+ try {
11
+ const message = JSON.parse(line);
12
+ if (!runtime) {
13
+ const options = select(message);
14
+ if (!options) throw Error('Unknown capability contribution initialization');
15
+ runtime = createCapabilityRuntime({...options,send});
16
+ }
17
+ void runtime.receive(message).catch(fail);
18
+ } catch(error) {fail(error);}
19
+ });
20
+ lines.on('close',()=>runtime?.close());
21
+ return {close(){runtime?.close();lines.close();}};
22
+ }
23
+ export function serveCapability(options) { return serve(()=>options); }
24
+ /** One process binds exactly one declared contribution for its entire generation. */
25
+ export function serveCapabilities(contributions) {
26
+ const ids = new Set(contributions.map(options=>options.contributionId));
27
+ if (!contributions.length || ids.size!==contributions.length) throw Error('Duplicate or empty contribution configuration');
28
+ return serve(message=>message?.method==='capability.initialize'
29
+ ? contributions.find(options=>options.contributionId===message.params?.contributionId)
30
+ : undefined);
31
+ }