@mcp-b/global 1.0.13 → 1.0.14
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/README.md +555 -326
- package/dist/index.d.ts +206 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.iife.js +6 -0
- package/dist/index.js +429 -21
- package/dist/index.js.map +1 -0
- package/package.json +27 -15
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { CallToolResult, Server, ToolAnnotations } from "@mcp-b/webmcp-ts-sdk";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/global.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Initialize the Web Model Context API (window.navigator.modelContext)
|
|
7
|
+
*/
|
|
8
|
+
declare function initializeWebModelContext(): void;
|
|
9
|
+
/**
|
|
10
|
+
* Cleanup function (for testing/development)
|
|
11
|
+
*/
|
|
12
|
+
declare function cleanupWebModelContext(): void;
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/types.d.ts
|
|
15
|
+
/**
|
|
16
|
+
* JSON Schema definition for tool input parameters
|
|
17
|
+
*/
|
|
18
|
+
interface InputSchema {
|
|
19
|
+
type: string;
|
|
20
|
+
properties?: Record<string, {
|
|
21
|
+
type: string;
|
|
22
|
+
description?: string;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}>;
|
|
25
|
+
required?: string[];
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Zod schema object type (Record<string, ZodType>)
|
|
30
|
+
* Used for type-safe tool definitions
|
|
31
|
+
*/
|
|
32
|
+
type ZodSchemaObject = Record<string, z.ZodTypeAny>;
|
|
33
|
+
/**
|
|
34
|
+
* Tool response format (Web API version)
|
|
35
|
+
* This is compatible with MCP SDK's CallToolResult
|
|
36
|
+
*/
|
|
37
|
+
type ToolResponse = CallToolResult;
|
|
38
|
+
/**
|
|
39
|
+
* Tool descriptor for Web Model Context API
|
|
40
|
+
* Extended with full MCP protocol support
|
|
41
|
+
*
|
|
42
|
+
* Supports both JSON Schema (Web standard) and Zod schemas (type-safe)
|
|
43
|
+
*
|
|
44
|
+
* @template TInputSchema - If using Zod, the schema object type for type inference
|
|
45
|
+
* @template TOutputSchema - If using Zod, the output schema object type
|
|
46
|
+
*/
|
|
47
|
+
interface ToolDescriptor<TInputSchema extends ZodSchemaObject = Record<string, never>, TOutputSchema extends ZodSchemaObject = Record<string, never>> {
|
|
48
|
+
/**
|
|
49
|
+
* Unique identifier for the tool
|
|
50
|
+
*/
|
|
51
|
+
name: string;
|
|
52
|
+
/**
|
|
53
|
+
* Natural language description of what the tool does
|
|
54
|
+
*/
|
|
55
|
+
description: string;
|
|
56
|
+
/**
|
|
57
|
+
* Input schema - accepts EITHER:
|
|
58
|
+
* - JSON Schema object (Web standard): { type: "object", properties: {...}, required: [...] }
|
|
59
|
+
* - Zod schema object (type-safe): { text: z.string(), priority: z.enum(...) }
|
|
60
|
+
*
|
|
61
|
+
* When using Zod, TypeScript will infer the execute parameter types automatically
|
|
62
|
+
*/
|
|
63
|
+
inputSchema: InputSchema | TInputSchema;
|
|
64
|
+
/**
|
|
65
|
+
* Optional output schema - accepts EITHER:
|
|
66
|
+
* - JSON Schema object (Web standard): { type: "object", properties: {...} }
|
|
67
|
+
* - Zod schema object (type-safe): { result: z.string(), success: z.boolean() }
|
|
68
|
+
*/
|
|
69
|
+
outputSchema?: InputSchema | TOutputSchema;
|
|
70
|
+
/**
|
|
71
|
+
* Optional annotations providing hints about tool behavior
|
|
72
|
+
*/
|
|
73
|
+
annotations?: ToolAnnotations;
|
|
74
|
+
/**
|
|
75
|
+
* Function that executes the tool logic
|
|
76
|
+
*
|
|
77
|
+
* When using Zod schemas, the args parameter type is automatically inferred from TInputSchema
|
|
78
|
+
* When using JSON Schema, args is Record<string, unknown>
|
|
79
|
+
*/
|
|
80
|
+
execute: (args: TInputSchema extends Record<string, never> ? Record<string, unknown> : z.infer<z.ZodObject<TInputSchema>>) => Promise<ToolResponse>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Internal validated tool descriptor (used internally by the bridge)
|
|
84
|
+
* Always stores JSON Schema format for MCP protocol
|
|
85
|
+
* Plus Zod validators for runtime validation
|
|
86
|
+
*/
|
|
87
|
+
interface ValidatedToolDescriptor {
|
|
88
|
+
name: string;
|
|
89
|
+
description: string;
|
|
90
|
+
inputSchema: InputSchema;
|
|
91
|
+
outputSchema?: InputSchema;
|
|
92
|
+
annotations?: ToolAnnotations;
|
|
93
|
+
execute: (args: Record<string, unknown>) => Promise<ToolResponse>;
|
|
94
|
+
inputValidator: z.ZodType;
|
|
95
|
+
outputValidator?: z.ZodType;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Context provided to models via provideContext()
|
|
99
|
+
* Contains the base set of tools (Bucket A)
|
|
100
|
+
*/
|
|
101
|
+
interface ModelContextInput {
|
|
102
|
+
/**
|
|
103
|
+
* Array of tool descriptors
|
|
104
|
+
* Supports both JSON Schema and Zod schema formats
|
|
105
|
+
*/
|
|
106
|
+
tools: ToolDescriptor<any, any>[];
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Tool call event
|
|
110
|
+
*/
|
|
111
|
+
interface ToolCallEvent extends Event {
|
|
112
|
+
/**
|
|
113
|
+
* Name of the tool being called
|
|
114
|
+
*/
|
|
115
|
+
name: string;
|
|
116
|
+
/**
|
|
117
|
+
* Arguments passed to the tool
|
|
118
|
+
*/
|
|
119
|
+
arguments: Record<string, unknown>;
|
|
120
|
+
/**
|
|
121
|
+
* Respond with a result
|
|
122
|
+
*/
|
|
123
|
+
respondWith: (response: ToolResponse) => void;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* ModelContext interface on window.navigator
|
|
127
|
+
* Implements the W3C Web Model Context API proposal
|
|
128
|
+
*/
|
|
129
|
+
interface ModelContext {
|
|
130
|
+
/**
|
|
131
|
+
* Provide context (tools) to AI models
|
|
132
|
+
* Clears base tools (Bucket A) and replaces with the provided array.
|
|
133
|
+
* Dynamic tools (Bucket B) registered via registerTool() persist.
|
|
134
|
+
*/
|
|
135
|
+
provideContext(context: ModelContextInput): void;
|
|
136
|
+
/**
|
|
137
|
+
* Register a single tool dynamically
|
|
138
|
+
* Returns an object with an unregister function to remove the tool
|
|
139
|
+
* Supports both JSON Schema and Zod schema formats
|
|
140
|
+
*/
|
|
141
|
+
registerTool<TInputSchema extends ZodSchemaObject = Record<string, never>, TOutputSchema extends ZodSchemaObject = Record<string, never>>(tool: ToolDescriptor<TInputSchema, TOutputSchema>): {
|
|
142
|
+
unregister: () => void;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Add event listener for tool calls
|
|
146
|
+
*/
|
|
147
|
+
addEventListener(type: 'toolcall', listener: (event: ToolCallEvent) => void | Promise<void>, options?: boolean | AddEventListenerOptions): void;
|
|
148
|
+
/**
|
|
149
|
+
* Remove event listener
|
|
150
|
+
*/
|
|
151
|
+
removeEventListener(type: 'toolcall', listener: (event: ToolCallEvent) => void | Promise<void>, options?: boolean | EventListenerOptions): void;
|
|
152
|
+
/**
|
|
153
|
+
* Dispatch an event
|
|
154
|
+
*/
|
|
155
|
+
dispatchEvent(event: Event): boolean;
|
|
156
|
+
/**
|
|
157
|
+
* Get the list of all registered tools
|
|
158
|
+
* Returns tools from both buckets (provideContext and registerTool)
|
|
159
|
+
*/
|
|
160
|
+
listTools(): Array<{
|
|
161
|
+
name: string;
|
|
162
|
+
description: string;
|
|
163
|
+
inputSchema: InputSchema;
|
|
164
|
+
outputSchema?: InputSchema;
|
|
165
|
+
annotations?: ToolAnnotations;
|
|
166
|
+
}>;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Internal ModelContext interface with additional methods for MCP bridge
|
|
170
|
+
* Not exposed as part of the public Web Model Context API
|
|
171
|
+
*/
|
|
172
|
+
interface InternalModelContext extends ModelContext {
|
|
173
|
+
/**
|
|
174
|
+
* Execute a tool (internal use only by MCP bridge)
|
|
175
|
+
* @internal
|
|
176
|
+
*/
|
|
177
|
+
executeTool(toolName: string, args: Record<string, unknown>): Promise<ToolResponse>;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Internal MCP Bridge state
|
|
181
|
+
*/
|
|
182
|
+
interface MCPBridge {
|
|
183
|
+
server: Server;
|
|
184
|
+
tools: Map<string, ValidatedToolDescriptor>;
|
|
185
|
+
modelContext: InternalModelContext;
|
|
186
|
+
isInitialized: boolean;
|
|
187
|
+
}
|
|
188
|
+
declare global {
|
|
189
|
+
interface Navigator {
|
|
190
|
+
/**
|
|
191
|
+
* Web Model Context API
|
|
192
|
+
* Provides tools and context to AI agents
|
|
193
|
+
*/
|
|
194
|
+
modelContext: ModelContext;
|
|
195
|
+
}
|
|
196
|
+
interface Window {
|
|
197
|
+
/**
|
|
198
|
+
* Internal MCP server instance (for debugging/advanced use)
|
|
199
|
+
*/
|
|
200
|
+
__mcpBridge?: MCPBridge;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=types.d.ts.map
|
|
204
|
+
//#endregion
|
|
205
|
+
export { type CallToolResult, InputSchema, InternalModelContext, MCPBridge, ModelContext, ModelContextInput, type ToolAnnotations, ToolCallEvent, ToolDescriptor, ToolResponse, ValidatedToolDescriptor, ZodSchemaObject, cleanupWebModelContext, initializeWebModelContext };
|
|
206
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/global.ts","../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;;iBAifgB,yBAAA,CAAA;AAAhB;AAyCA;;iBAAgB,sBAAA,CAAA;;;;;AAzChB;AAyCgB,UCjhBC,WAAA,CDihBqB;;eC/gBvB;;IAFE,WAAW,CAAA,EAAA,MAAA;IAkBhB,CAAA,GAAA,EAAA,MAAA,CAAA,EAAe,OAAA;EAgBf,CAAA,CAAA;EAWK,QAAA,CAAA,EAAA,MAAc,EAAA;EACR,CAAA,GAAA,EAAA,MAAA,CAAA,EAAA,OAAA;;;;;;AA2BN,KAvDL,eAAA,GAAkB,MAuDb,CAAA,MAAA,EAvD4B,CAAA,CAAE,UAuD9B,CAAA;;;;AAyBjB;AAGe,KAnEH,YAAA,GAAe,cAmEZ;;;;;;;;;AAcf;AAWiB,UAjFA,cAiFc,CAAA,qBAhFR,eAgFQ,GAhFU,MAgFV,CAAA,MAAA,EAAA,KAAA,CAAA,EAAA,sBA/EP,eA+EO,GA/EW,MA+EX,CAAA,MAAA,EAAA,KAAA,CAAA,CAAA,CAAA;EASlB;;;EAT+B,IAAA,EAAA,MAAA;EAqB3B;;;EAc0B,WAAA,EAAA,MAAA;EACjB;;;;;;;EAaF,WAAA,EA7GT,WA6GS,GA7GK,YA6GL;EAQF;;;;;EAiBH,YAAA,CAAA,EA/HF,WA+HE,GA/HY,aA+HZ;EACD;;;EAQD,WAAA,CAAA,EAnID,eAmIsB;EAKA;;;;;AAMtC;EACU,OAAA,EAAA,CAAA,IAAA,EAtIA,YAsIA,SAtIqB,MAsIrB,CAAA,MAAA,EAAA,KAAA,CAAA,GArIF,MAqIE,CAAA,MAAA,EAAA,OAAA,CAAA,GApIF,CAAA,CAAE,KAoIA,CApIM,CAAA,CAAE,SAoIR,CApIkB,YAoIlB,CAAA,CAAA,EAAA,GAnIH,OAmIG,CAnIK,YAmIL,CAAA;;;;;AAIT;;AAAA,UA/HgB,uBAAA,CA8IU;EAAA,IAAA,EAAA,MAAA;EAAA,WAAA,EAAA,MAAA;eA3IZ;iBACE;gBACD;kBACE,4BAA4B,QAAQ;kBAGpC,CAAA,CAAE;oBACA,CAAA,CAAE;;;;;;UAOL,iBAAA;;;;;SAKR;;;;;UAMQ,aAAA,SAAsB;;;;;;;;aAS1B;;;;0BAKa;;;;;;UAOT,YAAA;;;;;;0BAMS;;;;;;oCAQD,kBAAkB,6CACjB,kBAAkB,6BAElC,eAAe,cAAc;;;;;;uDAUjB,yBAAyB,mCACvB;;;;0DAQF,yBAAyB,mCACvB;;;;uBAMD;;;;;eAMR;;;iBAGE;mBACE;kBACD;;;;;;;UAQD,oBAAA,SAA6B;;;;;sCAKR,0BAA0B,QAAQ;;;;;UAMvD,SAAA;UACP;SACD,YAAY;gBACL;;;;;;;;;kBAUE;;;;;;kBAOA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
var WebMCP=(function(e,t){var n=Object.create,r=Object.defineProperty,i=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,s=Object.prototype.hasOwnProperty,c=(e,t,n,o)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=a(t),l=0,ee=c.length,u;l<ee;l++)u=c[l],!s.call(e,u)&&u!==n&&r(e,u,{get:(e=>t[e]).bind(null,u),enumerable:!(o=i(t,u))||o.enumerable});return e};t=((e,t,i)=>(i=e==null?{}:n(o(e)),c(t||!e||!e.__esModule?r(i,`default`,{value:e,enumerable:!0}):i,e)))(t);var l;(function(e){e.assertEqual=e=>e;function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(l||={});var ee;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(ee||={});let u=l.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),d=e=>{switch(typeof e){case`undefined`:return u.undefined;case`string`:return u.string;case`number`:return isNaN(e)?u.nan:u.number;case`boolean`:return u.boolean;case`function`:return u.function;case`bigint`:return u.bigint;case`symbol`:return u.symbol;case`object`:return Array.isArray(e)?u.array:e===null?u.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?u.promise:typeof Map<`u`&&e instanceof Map?u.map:typeof Set<`u`&&e instanceof Set?u.set:typeof Date<`u`&&e instanceof Date?u.date:u.object;default:return u.unknown}},f=l.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),te=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,`$1:`);var p=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,l.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};p.create=e=>new p(e);let ne=(e,t)=>{let n;switch(e.code){case f.invalid_type:n=e.received===u.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case f.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,l.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:n=`Unrecognized key(s) in object: ${l.joinValues(e.keys,`, `)}`;break;case f.invalid_union:n=`Invalid input`;break;case f.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${l.joinValues(e.options)}`;break;case f.invalid_enum_value:n=`Invalid enum value. Expected ${l.joinValues(e.options)}, received '${e.received}'`;break;case f.invalid_arguments:n=`Invalid function arguments`;break;case f.invalid_return_type:n=`Invalid function return type`;break;case f.invalid_date:n=`Invalid date`;break;case f.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:l.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case f.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case f.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case f.custom:n=`Invalid input`;break;case f.invalid_intersection_types:n=`Intersection results could not be merged`;break;case f.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case f.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,l.assertNever(e)}return{message:n}},re=ne;function ie(e){re=e}function ae(){return re}let oe=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}},se=[];function m(e,t){let n=ae(),r=oe({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===ne?void 0:ne].filter(e=>!!e)});e.common.issues.push(r)}var h=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return g;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return g;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};let g=Object.freeze({status:`aborted`}),ce=e=>({status:`dirty`,value:e}),_=e=>({status:`valid`,value:e}),le=e=>e.status===`aborted`,ue=e=>e.status===`dirty`,de=e=>e.status===`valid`,fe=e=>typeof Promise<`u`&&e instanceof Promise;function pe(e,t,n,r){if(n===`a`&&!r)throw TypeError(`Private accessor was defined without a getter`);if(typeof t==`function`?e!==t||!r:!t.has(e))throw TypeError(`Cannot read private member from an object whose class did not declare it`);return n===`m`?r:n===`a`?r.call(e):r?r.value:t.get(e)}function me(e,t,n,r,i){if(r===`m`)throw TypeError(`Private method is not writable`);if(r===`a`&&!i)throw TypeError(`Private accessor was defined without a setter`);if(typeof t==`function`?e!==t||!i:!t.has(e))throw TypeError(`Cannot write private member to an object whose class did not declare it`);return r===`a`?i.call(e,n):i?i.value=n:t.set(e,n),n}var v;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(v||={});var he,ge,y=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};let _e=(e,t)=>{if(de(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){return this._error||=new p(e.common.issues),this._error}}};function b(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var x=class{get description(){return this._def.description}_getType(e){return d(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:d(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new h,ctx:{common:e.parent.common,data:e.data,parsedType:d(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(fe(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:d(e)};return _e(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:d(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return de(n)?{value:n.value}:{issues:t.common.issues}}catch(e){((e?.message)?.toLowerCase())?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>de(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:d(e)},r=this._parse({data:e,path:n.path,parent:n});return _e(n,await(fe(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:f.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new T({schema:this,typeName:D.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return E.create(this,this._def)}nullable(){return gt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $e.create(this)}promise(){return ht.create(this,this._def)}or(e){return tt.create([this,e],this._def)}and(e){return it.create(this,e,this._def)}transform(e){return new T({...b(this._def),schema:this,typeName:D.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new _t({...b(this._def),innerType:this,defaultValue:t,typeName:D.ZodDefault})}brand(){return new xt({typeName:D.ZodBranded,type:this,...b(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new vt({...b(this._def),innerType:this,catchValue:t,typeName:D.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return St.create(this,e)}readonly(){return Ct.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};let ve=/^c[^\s-]{8,}$/i,ye=/^[0-9a-z]+$/,be=/^[0-9A-HJKMNP-TV-Z]{26}$/i,xe=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Se=/^[a-z0-9_-]{21}$/i,Ce=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,we=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Te=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ee,De=/^(?:(?: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])$/,Oe=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,ke=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Ae=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,je=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Me=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ne=`((\\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])))`,Pe=RegExp(`^${Ne}$`);function Fe(e){let t=`([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;return e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`),t}function Ie(e){return RegExp(`^${Fe(e)}$`)}function Le(e){let t=`${Ne}T${Fe(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Re(e,t){return!!((t===`v4`||!t)&&De.test(e)||(t===`v6`||!t)&&ke.test(e))}function ze(e,t){if(!Ce.test(e))return!1;try{let[n]=e.split(`.`),r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||!i.typ||!i.alg||t&&i.alg!==t)}catch{return!1}}function Be(e,t){return!!((t===`v4`||!t)&&Oe.test(e)||(t===`v6`||!t)&&Ae.test(e))}var Ve=class e extends x{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==u.string){let t=this._getOrReturnCtx(e);return m(t,{code:f.invalid_type,expected:u.string,received:t.parsedType}),g}let t=new h,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),m(n,{code:f.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),m(n,{code:f.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?m(n,{code:f.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&m(n,{code:f.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)Te.test(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{validation:`email`,code:f.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)Ee||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),Ee.test(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{validation:`emoji`,code:f.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)xe.test(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{validation:`uuid`,code:f.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)Se.test(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{validation:`nanoid`,code:f.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)ve.test(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{validation:`cuid`,code:f.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)ye.test(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{validation:`cuid2`,code:f.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)be.test(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{validation:`ulid`,code:f.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),m(n,{validation:`url`,code:f.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{validation:`regex`,code:f.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),m(n,{code:f.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),m(n,{code:f.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),m(n,{code:f.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Le(r).test(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:f.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Pe.test(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:f.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Ie(r).test(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:f.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?we.test(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{validation:`duration`,code:f.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?Re(e.data,r.version)||(n=this._getOrReturnCtx(e,n),m(n,{validation:`ip`,code:f.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?ze(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),m(n,{validation:`jwt`,code:f.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?Be(e.data,r.version)||(n=this._getOrReturnCtx(e,n),m(n,{validation:`cidr`,code:f.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?je.test(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{validation:`base64`,code:f.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?Me.test(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{validation:`base64url`,code:f.invalid_string,message:r.message}),t.dirty()):l.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:f.invalid_string,...v.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...v.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...v.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...v.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...v.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...v.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...v.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...v.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...v.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...v.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...v.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...v.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...v.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...v.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...v.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...v.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...v.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...v.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...v.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...v.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...v.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...v.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...v.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...v.errToObj(t)})}nonempty(e){return this.min(1,v.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Ve.create=e=>new Ve({checks:[],typeName:D.ZodString,coerce:e?.coerce??!1,...b(e)});function He(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return parseInt(e.toFixed(i).replace(`.`,``))%parseInt(t.toFixed(i).replace(`.`,``))/10**i}var Ue=class e extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==u.number){let t=this._getOrReturnCtx(e);return m(t,{code:f.invalid_type,expected:u.number,received:t.parsedType}),g}let t,n=new h;for(let r of this._def.checks)r.kind===`int`?l.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),m(t,{code:f.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),m(t,{code:f.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),m(t,{code:f.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?He(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),m(t,{code:f.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),m(t,{code:f.not_finite,message:r.message}),n.dirty()):l.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,v.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,v.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,v.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,v.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:v.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:v.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:v.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:v.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:v.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:v.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&l.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};Ue.create=e=>new Ue({checks:[],typeName:D.ZodNumber,coerce:e?.coerce||!1,...b(e)});var We=class e extends x{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==u.bigint)return this._getInvalidInput(e);let t,n=new h;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),m(t,{code:f.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),m(t,{code:f.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),m(t,{code:f.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):l.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return m(t,{code:f.invalid_type,expected:u.bigint,received:t.parsedType}),g}gte(e,t){return this.setLimit(`min`,e,!0,v.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,v.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,v.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,v.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:v.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:v.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};We.create=e=>new We({checks:[],typeName:D.ZodBigInt,coerce:e?.coerce??!1,...b(e)});var Ge=class extends x{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==u.boolean){let t=this._getOrReturnCtx(e);return m(t,{code:f.invalid_type,expected:u.boolean,received:t.parsedType}),g}return _(e.data)}};Ge.create=e=>new Ge({typeName:D.ZodBoolean,coerce:e?.coerce||!1,...b(e)});var Ke=class e extends x{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==u.date){let t=this._getOrReturnCtx(e);return m(t,{code:f.invalid_type,expected:u.date,received:t.parsedType}),g}if(isNaN(e.data.getTime()))return m(this._getOrReturnCtx(e),{code:f.invalid_date}),g;let t=new h,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),m(n,{code:f.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),m(n,{code:f.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):l.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:v.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:v.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Ke.create=e=>new Ke({checks:[],coerce:e?.coerce||!1,typeName:D.ZodDate,...b(e)});var qe=class extends x{_parse(e){if(this._getType(e)!==u.symbol){let t=this._getOrReturnCtx(e);return m(t,{code:f.invalid_type,expected:u.symbol,received:t.parsedType}),g}return _(e.data)}};qe.create=e=>new qe({typeName:D.ZodSymbol,...b(e)});var Je=class extends x{_parse(e){if(this._getType(e)!==u.undefined){let t=this._getOrReturnCtx(e);return m(t,{code:f.invalid_type,expected:u.undefined,received:t.parsedType}),g}return _(e.data)}};Je.create=e=>new Je({typeName:D.ZodUndefined,...b(e)});var Ye=class extends x{_parse(e){if(this._getType(e)!==u.null){let t=this._getOrReturnCtx(e);return m(t,{code:f.invalid_type,expected:u.null,received:t.parsedType}),g}return _(e.data)}};Ye.create=e=>new Ye({typeName:D.ZodNull,...b(e)});var Xe=class extends x{constructor(){super(...arguments),this._any=!0}_parse(e){return _(e.data)}};Xe.create=e=>new Xe({typeName:D.ZodAny,...b(e)});var Ze=class extends x{constructor(){super(...arguments),this._unknown=!0}_parse(e){return _(e.data)}};Ze.create=e=>new Ze({typeName:D.ZodUnknown,...b(e)});var S=class extends x{_parse(e){let t=this._getOrReturnCtx(e);return m(t,{code:f.invalid_type,expected:u.never,received:t.parsedType}),g}};S.create=e=>new S({typeName:D.ZodNever,...b(e)});var Qe=class extends x{_parse(e){if(this._getType(e)!==u.undefined){let t=this._getOrReturnCtx(e);return m(t,{code:f.invalid_type,expected:u.void,received:t.parsedType}),g}return _(e.data)}};Qe.create=e=>new Qe({typeName:D.ZodVoid,...b(e)});var $e=class e extends x{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==u.array)return m(t,{code:f.invalid_type,expected:u.array,received:t.parsedType}),g;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(m(t,{code:e?f.too_big:f.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(m(t,{code:f.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(m(t,{code:f.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new y(t,e,t.path,n)))).then(e=>h.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new y(t,e,t.path,n)));return h.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:v.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:v.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:v.toString(n)}})}nonempty(e){return this.min(1,e)}};$e.create=(e,t)=>new $e({type:e,minLength:null,maxLength:null,exactLength:null,typeName:D.ZodArray,...b(t)});function et(e){if(e instanceof C){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=E.create(et(r))}return new C({...e._def,shape:()=>t})}else if(e instanceof $e)return new $e({...e._def,type:et(e.element)});else if(e instanceof E)return E.create(et(e.unwrap()));else if(e instanceof gt)return gt.create(et(e.unwrap()));else if(e instanceof at)return at.create(e.items.map(e=>et(e)));else return e}var C=class e extends x{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape();return this._cached={shape:e,keys:l.objectKeys(e)}}_parse(e){if(this._getType(e)!==u.object){let t=this._getOrReturnCtx(e);return m(t,{code:f.invalid_type,expected:u.object,received:t.parsedType}),g}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof S&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new y(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof S){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(m(n,{code:f.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new y(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>h.mergeObjectSync(t,e)):h.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return v.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{var r;let i=(r=this._def).errorMap?.call(r,e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:v.errToObj(t).message??i}:{message:i}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:D.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};return l.objectKeys(t).forEach(e=>{t[e]&&this.shape[e]&&(n[e]=this.shape[e])}),new e({...this._def,shape:()=>n})}omit(t){let n={};return l.objectKeys(this.shape).forEach(e=>{t[e]||(n[e]=this.shape[e])}),new e({...this._def,shape:()=>n})}deepPartial(){return et(this)}partial(t){let n={};return l.objectKeys(this.shape).forEach(e=>{let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}),new e({...this._def,shape:()=>n})}required(t){let n={};return l.objectKeys(this.shape).forEach(e=>{if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof E;)t=t._def.innerType;n[e]=t}}),new e({...this._def,shape:()=>n})}keyof(){return ft(l.objectKeys(this.shape))}};C.create=(e,t)=>new C({shape:()=>e,unknownKeys:`strip`,catchall:S.create(),typeName:D.ZodObject,...b(t)}),C.strictCreate=(e,t)=>new C({shape:()=>e,unknownKeys:`strict`,catchall:S.create(),typeName:D.ZodObject,...b(t)}),C.lazycreate=(e,t)=>new C({shape:e,unknownKeys:`strip`,catchall:S.create(),typeName:D.ZodObject,...b(t)});var tt=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new p(e.ctx.common.issues));return m(t,{code:f.invalid_union,unionErrors:n}),g}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new p(e));return m(t,{code:f.invalid_union,unionErrors:i}),g}}get options(){return this._def.options}};tt.create=(e,t)=>new tt({options:e,typeName:D.ZodUnion,...b(t)});let w=e=>e instanceof ut?w(e.schema):e instanceof T?w(e.innerType()):e instanceof dt?[e.value]:e instanceof pt?e.options:e instanceof mt?l.objectValues(e.enum):e instanceof _t?w(e._def.innerType):e instanceof Je?[void 0]:e instanceof Ye?[null]:e instanceof E?[void 0,...w(e.unwrap())]:e instanceof gt?[null,...w(e.unwrap())]:e instanceof xt||e instanceof Ct?w(e.unwrap()):e instanceof vt?w(e._def.innerType):[];var nt=class e extends x{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.object)return m(t,{code:f.invalid_type,expected:u.object,received:t.parsedType}),g;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(m(t,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=w(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:D.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...b(r)})}};function rt(e,t){let n=d(e),r=d(t);if(e===t)return{valid:!0,data:e};if(n===u.object&&r===u.object){let n=l.objectKeys(t),r=l.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=rt(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===u.array&&r===u.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=rt(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===u.date&&r===u.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var it=class extends x{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(le(e)||le(r))return g;let i=rt(e.value,r.value);return i.valid?((ue(e)||ue(r))&&t.dirty(),{status:t.value,value:i.data}):(m(n,{code:f.invalid_intersection_types}),g)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};it.create=(e,t,n)=>new it({left:e,right:t,typeName:D.ZodIntersection,...b(n)});var at=class e extends x{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==u.array)return m(n,{code:f.invalid_type,expected:u.array,received:n.parsedType}),g;if(n.data.length<this._def.items.length)return m(n,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),g;!this._def.rest&&n.data.length>this._def.items.length&&(m(n,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new y(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>h.mergeArray(t,e)):h.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};at.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new at({items:e,typeName:D.ZodTuple,rest:null,...b(t)})};var ot=class e extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==u.object)return m(n,{code:f.invalid_type,expected:u.object,received:n.parsedType}),g;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new y(n,e,n.path,e)),value:a._parse(new y(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?h.mergeObjectAsync(t,r):h.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof x?new e({keyType:t,valueType:n,typeName:D.ZodRecord,...b(r)}):new e({keyType:Ve.create(),valueType:t,typeName:D.ZodRecord,...b(n)})}},st=class extends x{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==u.map)return m(n,{code:f.invalid_type,expected:u.map,received:n.parsedType}),g;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new y(n,e,n.path,[a,`key`])),value:i._parse(new y(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return g;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return g;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};st.create=(e,t,n)=>new st({valueType:t,keyType:e,typeName:D.ZodMap,...b(n)});var ct=class e extends x{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==u.set)return m(n,{code:f.invalid_type,expected:u.set,received:n.parsedType}),g;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(m(n,{code:f.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(m(n,{code:f.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return g;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new y(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:v.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:v.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};ct.create=(e,t)=>new ct({valueType:e,minSize:null,maxSize:null,typeName:D.ZodSet,...b(t)});var lt=class e extends x{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==u.function)return m(t,{code:f.invalid_type,expected:u.function,received:t.parsedType}),g;function n(e,n){return oe({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ae(),ne].filter(e=>!!e),issueData:{code:f.invalid_arguments,argumentsError:n}})}function r(e,n){return oe({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ae(),ne].filter(e=>!!e),issueData:{code:f.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ht){let e=this;return _(async function(...t){let o=new p([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return _(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new p([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new p([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:at.create(t).rest(Ze.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||at.create([]).rest(Ze.create()),returns:n||Ze.create(),typeName:D.ZodFunction,...b(r)})}},ut=class extends x{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};ut.create=(e,t)=>new ut({getter:e,typeName:D.ZodLazy,...b(t)});var dt=class extends x{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return m(t,{received:t.data,code:f.invalid_literal,expected:this._def.value}),g}return{status:`valid`,value:e.data}}get value(){return this._def.value}};dt.create=(e,t)=>new dt({value:e,typeName:D.ZodLiteral,...b(t)});function ft(e,t){return new pt({values:e,typeName:D.ZodEnum,...b(t)})}var pt=class e extends x{constructor(){super(...arguments),he.set(this,void 0)}_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return m(t,{expected:l.joinValues(n),received:t.parsedType,code:f.invalid_type}),g}if(pe(this,he,`f`)||me(this,he,new Set(this._def.values),`f`),!pe(this,he,`f`).has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return m(t,{received:t.data,code:f.invalid_enum_value,options:n}),g}return _(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};he=new WeakMap,pt.create=ft;var mt=class extends x{constructor(){super(...arguments),ge.set(this,void 0)}_parse(e){let t=l.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==u.string&&n.parsedType!==u.number){let e=l.objectValues(t);return m(n,{expected:l.joinValues(e),received:n.parsedType,code:f.invalid_type}),g}if(pe(this,ge,`f`)||me(this,ge,new Set(l.getValidEnumValues(this._def.values)),`f`),!pe(this,ge,`f`).has(e.data)){let e=l.objectValues(t);return m(n,{received:n.data,code:f.invalid_enum_value,options:e}),g}return _(e.data)}get enum(){return this._def.values}};ge=new WeakMap,mt.create=(e,t)=>new mt({values:e,typeName:D.ZodNativeEnum,...b(t)});var ht=class extends x{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==u.promise&&t.common.async===!1?(m(t,{code:f.invalid_type,expected:u.promise,received:t.parsedType}),g):_((t.parsedType===u.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};ht.create=(e,t)=>new ht({type:e,typeName:D.ZodPromise,...b(t)});var T=class extends x{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===D.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{m(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return g;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?g:r.status===`dirty`||t.value===`dirty`?ce(r.value):r});{if(t.value===`aborted`)return g;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?g:r.status===`dirty`||t.value===`dirty`?ce(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?g:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?g:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!de(e))return e;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>de(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):e);l.assertNever(r)}};T.create=(e,t,n)=>new T({schema:e,typeName:D.ZodEffects,effect:t,...b(n)}),T.createWithPreprocess=(e,t,n)=>new T({schema:t,effect:{type:`preprocess`,transform:e},typeName:D.ZodEffects,...b(n)});var E=class extends x{_parse(e){return this._getType(e)===u.undefined?_(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};E.create=(e,t)=>new E({innerType:e,typeName:D.ZodOptional,...b(t)});var gt=class extends x{_parse(e){return this._getType(e)===u.null?_(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};gt.create=(e,t)=>new gt({innerType:e,typeName:D.ZodNullable,...b(t)});var _t=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===u.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};_t.create=(e,t)=>new _t({innerType:e,typeName:D.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...b(t)});var vt=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return fe(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new p(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new p(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};vt.create=(e,t)=>new vt({innerType:e,typeName:D.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...b(t)});var yt=class extends x{_parse(e){if(this._getType(e)!==u.nan){let t=this._getOrReturnCtx(e);return m(t,{code:f.invalid_type,expected:u.nan,received:t.parsedType}),g}return{status:`valid`,value:e.data}}};yt.create=e=>new yt({typeName:D.ZodNaN,...b(e)});let bt=Symbol(`zod_brand`);var xt=class extends x{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},St=class e extends x{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?g:e.status===`dirty`?(t.dirty(),ce(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?g:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:D.ZodPipeline})}},Ct=class extends x{_parse(e){let t=this._def.innerType._parse(e),n=e=>(de(e)&&(e.value=Object.freeze(e.value)),e);return fe(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Ct.create=(e,t)=>new Ct({innerType:e,typeName:D.ZodReadonly,...b(t)});function wt(e,t={},n){return e?Xe.create().superRefine((r,i)=>{if(!e(r)){let e=typeof t==`function`?t(r):typeof t==`string`?{message:t}:t,a=e.fatal??n??!0,o=typeof e==`string`?{message:e}:e;i.addIssue({code:`custom`,...o,fatal:a})}}):Xe.create()}let Tt={object:C.lazycreate};var D;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(D||={});let Et=(e,t={message:`Input not instance of ${e.name}`})=>wt(t=>t instanceof e,t),Dt=Ve.create,Ot=Ue.create,kt=yt.create,At=We.create,jt=Ge.create,Mt=Ke.create,Nt=qe.create,Pt=Je.create,Ft=Ye.create,It=Xe.create,Lt=Ze.create,Rt=S.create,zt=Qe.create,Bt=$e.create,Vt=C.create,Ht=C.strictCreate,Ut=tt.create,Wt=nt.create,Gt=it.create,Kt=at.create,qt=ot.create,Jt=st.create,Yt=ct.create,Xt=lt.create,Zt=ut.create,Qt=dt.create,$t=pt.create,en=mt.create,tn=ht.create,nn=T.create,rn=E.create,an=gt.create,on=T.createWithPreprocess,sn=St.create,cn=()=>Dt().optional(),ln=()=>Ot().optional(),un=()=>jt().optional(),dn={string:(e=>Ve.create({...e,coerce:!0})),number:(e=>Ue.create({...e,coerce:!0})),boolean:(e=>Ge.create({...e,coerce:!0})),bigint:(e=>We.create({...e,coerce:!0})),date:(e=>Ke.create({...e,coerce:!0}))},fn=g;var O=Object.freeze({__proto__:null,defaultErrorMap:ne,setErrorMap:ie,getErrorMap:ae,makeIssue:oe,EMPTY_PATH:se,addIssueToContext:m,ParseStatus:h,INVALID:g,DIRTY:ce,OK:_,isAborted:le,isDirty:ue,isValid:de,isAsync:fe,get util(){return l},get objectUtil(){return ee},ZodParsedType:u,getParsedType:d,ZodType:x,datetimeRegex:Le,ZodString:Ve,ZodNumber:Ue,ZodBigInt:We,ZodBoolean:Ge,ZodDate:Ke,ZodSymbol:qe,ZodUndefined:Je,ZodNull:Ye,ZodAny:Xe,ZodUnknown:Ze,ZodNever:S,ZodVoid:Qe,ZodArray:$e,ZodObject:C,ZodUnion:tt,ZodDiscriminatedUnion:nt,ZodIntersection:it,ZodTuple:at,ZodRecord:ot,ZodMap:st,ZodSet:ct,ZodFunction:lt,ZodLazy:ut,ZodLiteral:dt,ZodEnum:pt,ZodNativeEnum:mt,ZodPromise:ht,ZodEffects:T,ZodTransformer:T,ZodOptional:E,ZodNullable:gt,ZodDefault:_t,ZodCatch:vt,ZodNaN:yt,BRAND:bt,ZodBranded:xt,ZodPipeline:St,ZodReadonly:Ct,custom:wt,Schema:x,ZodSchema:x,late:Tt,get ZodFirstPartyTypeKind(){return D},coerce:dn,any:It,array:Bt,bigint:At,boolean:jt,date:Mt,discriminatedUnion:Wt,effect:nn,enum:$t,function:Xt,instanceof:Et,intersection:Gt,lazy:Zt,literal:Qt,map:Jt,nan:kt,nativeEnum:en,never:Rt,null:Ft,nullable:an,number:Ot,object:Vt,oboolean:un,onumber:ln,optional:rn,ostring:cn,pipeline:sn,preprocess:on,promise:tn,record:qt,set:Yt,strictObject:Ht,string:Dt,symbol:Nt,transformer:nn,tuple:Kt,undefined:Pt,union:Ut,unknown:Lt,void:zt,NEVER:fn,ZodIssueCode:f,quotelessJson:te,ZodError:p});let pn=O.union([O.string(),O.number().int()]),mn=O.string(),hn=O.object({progressToken:O.optional(pn)}).passthrough(),k=O.object({_meta:O.optional(hn)}).passthrough(),A=O.object({method:O.string(),params:O.optional(k)}),gn=O.object({_meta:O.optional(O.object({}).passthrough())}).passthrough(),j=O.object({method:O.string(),params:O.optional(gn)}),M=O.object({_meta:O.optional(O.object({}).passthrough())}).passthrough(),_n=O.union([O.string(),O.number().int()]),vn=O.object({jsonrpc:O.literal(`2.0`),id:_n}).merge(A).strict(),yn=O.object({jsonrpc:O.literal(`2.0`)}).merge(j).strict(),bn=O.object({jsonrpc:O.literal(`2.0`),id:_n,result:M}).strict();var xn;(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`})(xn||={});let Sn=O.object({jsonrpc:O.literal(`2.0`),id:_n,error:O.object({code:O.number().int(),message:O.string(),data:O.optional(O.unknown())})}).strict(),Cn=O.union([vn,yn,bn,Sn]),wn=M.strict(),Tn=j.extend({method:O.literal(`notifications/cancelled`),params:gn.extend({requestId:_n,reason:O.string().optional()})}),En=O.object({name:O.string(),title:O.optional(O.string())}).passthrough(),Dn=En.extend({version:O.string()}),On=O.object({experimental:O.optional(O.object({}).passthrough()),sampling:O.optional(O.object({}).passthrough()),elicitation:O.optional(O.object({}).passthrough()),roots:O.optional(O.object({listChanged:O.optional(O.boolean())}).passthrough())}).passthrough(),kn=A.extend({method:O.literal(`initialize`),params:k.extend({protocolVersion:O.string(),capabilities:On,clientInfo:Dn})}),An=O.object({experimental:O.optional(O.object({}).passthrough()),logging:O.optional(O.object({}).passthrough()),completions:O.optional(O.object({}).passthrough()),prompts:O.optional(O.object({listChanged:O.optional(O.boolean())}).passthrough()),resources:O.optional(O.object({subscribe:O.optional(O.boolean()),listChanged:O.optional(O.boolean())}).passthrough()),tools:O.optional(O.object({listChanged:O.optional(O.boolean())}).passthrough())}).passthrough(),jn=M.extend({protocolVersion:O.string(),capabilities:An,serverInfo:Dn,instructions:O.optional(O.string())}),Mn=j.extend({method:O.literal(`notifications/initialized`)}),Nn=A.extend({method:O.literal(`ping`)}),Pn=O.object({progress:O.number(),total:O.optional(O.number()),message:O.optional(O.string())}).passthrough(),Fn=j.extend({method:O.literal(`notifications/progress`),params:gn.merge(Pn).extend({progressToken:pn})}),In=A.extend({params:k.extend({cursor:O.optional(mn)}).optional()}),Ln=M.extend({nextCursor:O.optional(mn)}),Rn=O.object({uri:O.string(),mimeType:O.optional(O.string()),_meta:O.optional(O.object({}).passthrough())}).passthrough(),zn=Rn.extend({text:O.string()}),Bn=O.string().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),Vn=Rn.extend({blob:Bn}),Hn=En.extend({uri:O.string(),description:O.optional(O.string()),mimeType:O.optional(O.string()),_meta:O.optional(O.object({}).passthrough())}),Un=En.extend({uriTemplate:O.string(),description:O.optional(O.string()),mimeType:O.optional(O.string()),_meta:O.optional(O.object({}).passthrough())}),Wn=In.extend({method:O.literal(`resources/list`)}),Gn=Ln.extend({resources:O.array(Hn)}),Kn=In.extend({method:O.literal(`resources/templates/list`)}),qn=Ln.extend({resourceTemplates:O.array(Un)}),Jn=A.extend({method:O.literal(`resources/read`),params:k.extend({uri:O.string()})}),Yn=M.extend({contents:O.array(O.union([zn,Vn]))}),Xn=j.extend({method:O.literal(`notifications/resources/list_changed`)}),Zn=A.extend({method:O.literal(`resources/subscribe`),params:k.extend({uri:O.string()})}),Qn=A.extend({method:O.literal(`resources/unsubscribe`),params:k.extend({uri:O.string()})}),$n=j.extend({method:O.literal(`notifications/resources/updated`),params:gn.extend({uri:O.string()})}),er=O.object({name:O.string(),description:O.optional(O.string()),required:O.optional(O.boolean())}).passthrough(),tr=En.extend({description:O.optional(O.string()),arguments:O.optional(O.array(er)),_meta:O.optional(O.object({}).passthrough())}),nr=In.extend({method:O.literal(`prompts/list`)}),rr=Ln.extend({prompts:O.array(tr)}),ir=A.extend({method:O.literal(`prompts/get`),params:k.extend({name:O.string(),arguments:O.optional(O.record(O.string()))})}),ar=O.object({type:O.literal(`text`),text:O.string(),_meta:O.optional(O.object({}).passthrough())}).passthrough(),or=O.object({type:O.literal(`image`),data:Bn,mimeType:O.string(),_meta:O.optional(O.object({}).passthrough())}).passthrough(),sr=O.object({type:O.literal(`audio`),data:Bn,mimeType:O.string(),_meta:O.optional(O.object({}).passthrough())}).passthrough(),cr=O.object({type:O.literal(`resource`),resource:O.union([zn,Vn]),_meta:O.optional(O.object({}).passthrough())}).passthrough(),lr=Hn.extend({type:O.literal(`resource_link`)}),ur=O.union([ar,or,sr,lr,cr]),dr=O.object({role:O.enum([`user`,`assistant`]),content:ur}).passthrough(),fr=M.extend({description:O.optional(O.string()),messages:O.array(dr)}),pr=j.extend({method:O.literal(`notifications/prompts/list_changed`)}),mr=O.object({title:O.optional(O.string()),readOnlyHint:O.optional(O.boolean()),destructiveHint:O.optional(O.boolean()),idempotentHint:O.optional(O.boolean()),openWorldHint:O.optional(O.boolean())}).passthrough(),hr=En.extend({description:O.optional(O.string()),inputSchema:O.object({type:O.literal(`object`),properties:O.optional(O.object({}).passthrough()),required:O.optional(O.array(O.string()))}).passthrough(),outputSchema:O.optional(O.object({type:O.literal(`object`),properties:O.optional(O.object({}).passthrough()),required:O.optional(O.array(O.string()))}).passthrough()),annotations:O.optional(mr),_meta:O.optional(O.object({}).passthrough())}),gr=In.extend({method:O.literal(`tools/list`)}),_r=Ln.extend({tools:O.array(hr)}),vr=M.extend({content:O.array(ur).default([]),structuredContent:O.object({}).passthrough().optional(),isError:O.optional(O.boolean())});vr.or(M.extend({toolResult:O.unknown()}));let yr=A.extend({method:O.literal(`tools/call`),params:k.extend({name:O.string(),arguments:O.optional(O.record(O.unknown()))})}),br=j.extend({method:O.literal(`notifications/tools/list_changed`)}),xr=O.enum([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),Sr=A.extend({method:O.literal(`logging/setLevel`),params:k.extend({level:xr})}),Cr=j.extend({method:O.literal(`notifications/message`),params:gn.extend({level:xr,logger:O.optional(O.string()),data:O.unknown()})}),wr=O.object({name:O.string().optional()}).passthrough(),Tr=O.object({hints:O.optional(O.array(wr)),costPriority:O.optional(O.number().min(0).max(1)),speedPriority:O.optional(O.number().min(0).max(1)),intelligencePriority:O.optional(O.number().min(0).max(1))}).passthrough(),Er=O.object({role:O.enum([`user`,`assistant`]),content:O.union([ar,or,sr])}).passthrough(),Dr=A.extend({method:O.literal(`sampling/createMessage`),params:k.extend({messages:O.array(Er),systemPrompt:O.optional(O.string()),includeContext:O.optional(O.enum([`none`,`thisServer`,`allServers`])),temperature:O.optional(O.number()),maxTokens:O.number().int(),stopSequences:O.optional(O.array(O.string())),metadata:O.optional(O.object({}).passthrough()),modelPreferences:O.optional(Tr)})}),Or=M.extend({model:O.string(),stopReason:O.optional(O.enum([`endTurn`,`stopSequence`,`maxTokens`]).or(O.string())),role:O.enum([`user`,`assistant`]),content:O.discriminatedUnion(`type`,[ar,or,sr])}),kr=O.object({type:O.literal(`boolean`),title:O.optional(O.string()),description:O.optional(O.string()),default:O.optional(O.boolean())}).passthrough(),Ar=O.object({type:O.literal(`string`),title:O.optional(O.string()),description:O.optional(O.string()),minLength:O.optional(O.number()),maxLength:O.optional(O.number()),format:O.optional(O.enum([`email`,`uri`,`date`,`date-time`]))}).passthrough(),jr=O.object({type:O.enum([`number`,`integer`]),title:O.optional(O.string()),description:O.optional(O.string()),minimum:O.optional(O.number()),maximum:O.optional(O.number())}).passthrough(),Mr=O.object({type:O.literal(`string`),title:O.optional(O.string()),description:O.optional(O.string()),enum:O.array(O.string()),enumNames:O.optional(O.array(O.string()))}).passthrough(),Nr=O.union([kr,Ar,jr,Mr]),Pr=A.extend({method:O.literal(`elicitation/create`),params:k.extend({message:O.string(),requestedSchema:O.object({type:O.literal(`object`),properties:O.record(O.string(),Nr),required:O.optional(O.array(O.string()))}).passthrough()})}),Fr=M.extend({action:O.enum([`accept`,`decline`,`cancel`]),content:O.optional(O.record(O.string(),O.unknown()))}),Ir=O.object({type:O.literal(`ref/resource`),uri:O.string()}).passthrough(),Lr=O.object({type:O.literal(`ref/prompt`),name:O.string()}).passthrough(),Rr=A.extend({method:O.literal(`completion/complete`),params:k.extend({ref:O.union([Lr,Ir]),argument:O.object({name:O.string(),value:O.string()}).passthrough(),context:O.optional(O.object({arguments:O.optional(O.record(O.string(),O.string()))}))})}),zr=M.extend({completion:O.object({values:O.array(O.string()).max(100),total:O.optional(O.number().int()),hasMore:O.optional(O.boolean())}).passthrough()}),Br=O.object({uri:O.string().startsWith(`file://`),name:O.optional(O.string()),_meta:O.optional(O.object({}).passthrough())}).passthrough(),Vr=A.extend({method:O.literal(`roots/list`)}),Hr=M.extend({roots:O.array(Br)}),Ur=j.extend({method:O.literal(`notifications/roots/list_changed`)});O.union([Nn,kn,Rr,Sr,ir,nr,Wn,Kn,Jn,Zn,Qn,yr,gr]),O.union([Tn,Fn,Mn,Ur]),O.union([wn,Or,Fr,Hr]),O.union([Nn,Dr,Pr,Vr]),O.union([Tn,Fn,Cr,$n,Xn,br,pr]),O.union([wn,jn,zr,fr,rr,Gn,qn,Yn,vr,_r]),function(e){return e.START=`start`,e.STARTED=`started`,e.STOP=`stop`,e.STOPPED=`stopped`,e.PING=`ping`,e.PONG=`pong`,e.ERROR=`error`,e.LIST_TOOLS=`list_tools`,e.CALL_TOOL=`call_tool`,e.TOOL_LIST_UPDATED=`tool_list_updated`,e.TOOL_LIST_UPDATED_ACK=`tool_list_updated_ack`,e.PROCESS_DATA=`process_data`,e.SERVER_STARTED=`server_started`,e.SERVER_STOPPED=`server_stopped`,e.ERROR_FROM_NATIVE_HOST=`error_from_native_host`,e.CONNECT_NATIVE=`connectNative`,e.PING_NATIVE=`ping_native`,e.DISCONNECT_NATIVE=`disconnect_native`,e}({}),{NAME:`com.chromemcp.nativehost`,DEFAULT_PORT:12306}.NAME;var Wr=class{_started=!1;_allowedOrigins;_channelId;_messageHandler;_clientOrigin;onclose;onerror;onmessage;constructor(e){if(!e.allowedOrigins||e.allowedOrigins.length===0)throw Error(`At least one allowed origin must be specified`);this._allowedOrigins=e.allowedOrigins,this._channelId=e.channelId||`mcp-default`}async start(){if(this._started)throw Error(`Transport already started`);this._messageHandler=e=>{if(!this._allowedOrigins.includes(e.origin)&&!this._allowedOrigins.includes(`*`)||e.data?.channel!==this._channelId||e.data?.type!==`mcp`||e.data?.direction!==`client-to-server`)return;this._clientOrigin=e.origin;let t=e.data.payload;if(typeof t==`string`&&t===`mcp-check-ready`){window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-ready`},this._clientOrigin);return}try{let e=Cn.parse(t);this.onmessage?.(e)}catch(e){this.onerror?.(Error(`Invalid message: ${e instanceof Error?e.message:String(e)}`))}},window.addEventListener(`message`,this._messageHandler),this._started=!0,window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-ready`},`*`)}async send(e){if(!this._started)throw Error(`Transport not started`);if(!this._clientOrigin)throw Error(`No client connected`);window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:e},this._clientOrigin)}async close(){this._messageHandler&&window.removeEventListener(`message`,this._messageHandler),this._started=!1,window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-stopped`},`*`),this.onclose?.()}},N;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(N||={});var Gr;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Gr||={});let P=N.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Kr=e=>{switch(typeof e){case`undefined`:return P.undefined;case`string`:return P.string;case`number`:return Number.isNaN(e)?P.nan:P.number;case`boolean`:return P.boolean;case`function`:return P.function;case`bigint`:return P.bigint;case`symbol`:return P.symbol;case`object`:return Array.isArray(e)?P.array:e===null?P.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?P.promise:typeof Map<`u`&&e instanceof Map?P.map:typeof Set<`u`&&e instanceof Set?P.set:typeof Date<`u`&&e instanceof Date?P.date:P.object;default:return P.unknown}},F=N.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]);var I=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,N.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};I.create=e=>new I(e);var qr=(e,t)=>{let n;switch(e.code){case F.invalid_type:n=e.received===P.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case F.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,N.jsonStringifyReplacer)}`;break;case F.unrecognized_keys:n=`Unrecognized key(s) in object: ${N.joinValues(e.keys,`, `)}`;break;case F.invalid_union:n=`Invalid input`;break;case F.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${N.joinValues(e.options)}`;break;case F.invalid_enum_value:n=`Invalid enum value. Expected ${N.joinValues(e.options)}, received '${e.received}'`;break;case F.invalid_arguments:n=`Invalid function arguments`;break;case F.invalid_return_type:n=`Invalid function return type`;break;case F.invalid_date:n=`Invalid date`;break;case F.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:N.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case F.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case F.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case F.custom:n=`Invalid input`;break;case F.invalid_intersection_types:n=`Intersection results could not be merged`;break;case F.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case F.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,N.assertNever(e)}return{message:n}};let Jr=qr;function Yr(){return Jr}let Xr=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function L(e,t){let n=Yr(),r=Xr({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===qr?void 0:qr].filter(e=>!!e)});e.common.issues.push(r)}var R=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return z;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return z;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};let z=Object.freeze({status:`aborted`}),Zr=e=>({status:`dirty`,value:e}),B=e=>({status:`valid`,value:e}),Qr=e=>e.status===`aborted`,$r=e=>e.status===`dirty`,ei=e=>e.status===`valid`,ti=e=>typeof Promise<`u`&&e instanceof Promise;var V;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(V||={});var H=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};let ni=(e,t)=>{if(ei(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){return this._error||=new I(e.common.issues),this._error}}};function U(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var W=class{get description(){return this._def.description}_getType(e){return Kr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Kr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new R,ctx:{common:e.parent.common,data:e.data,parsedType:Kr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(ti(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Kr(e)};return ni(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Kr(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return ei(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>ei(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Kr(e)},r=this._parse({data:e,path:n.path,parent:n});return ni(n,await(ti(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:F.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new q({schema:this,typeName:Y.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return J.create(this,this._def)}nullable(){return na.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ri.create(this)}promise(){return ta.create(this,this._def)}or(e){return Bi.create([this,e],this._def)}and(e){return Wi.create(this,e,this._def)}transform(e){return new q({...U(this._def),schema:this,typeName:Y.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new ra({...U(this._def),innerType:this,defaultValue:t,typeName:Y.ZodDefault})}brand(){return new oa({typeName:Y.ZodBranded,type:this,...U(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new ia({...U(this._def),innerType:this,catchValue:t,typeName:Y.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return sa.create(this,e)}readonly(){return ca.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};let ri=/^c[^\s-]{8,}$/i,ii=/^[0-9a-z]+$/,ai=/^[0-9A-HJKMNP-TV-Z]{26}$/i,oi=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,si=/^[a-z0-9_-]{21}$/i,ci=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,li=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ui=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,di,fi=/^(?:(?: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])$/,pi=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,mi=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,hi=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,gi=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,_i=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,vi=`((\\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])))`,yi=RegExp(`^${vi}$`);function bi(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function xi(e){return RegExp(`^${bi(e)}$`)}function Si(e){let t=`${vi}T${bi(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Ci(e,t){return!!((t===`v4`||!t)&&fi.test(e)||(t===`v6`||!t)&&mi.test(e))}function wi(e,t){if(!ci.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function Ti(e,t){return!!((t===`v4`||!t)&&pi.test(e)||(t===`v6`||!t)&&hi.test(e))}var Ei=class e extends W{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==P.string){let t=this._getOrReturnCtx(e);return L(t,{code:F.invalid_type,expected:P.string,received:t.parsedType}),z}let t=new R,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),L(n,{code:F.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),L(n,{code:F.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?L(n,{code:F.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&L(n,{code:F.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)ui.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`email`,code:F.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)di||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),di.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`emoji`,code:F.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)oi.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`uuid`,code:F.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)si.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`nanoid`,code:F.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)ri.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`cuid`,code:F.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)ii.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`cuid2`,code:F.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)ai.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`ulid`,code:F.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),L(n,{validation:`url`,code:F.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`regex`,code:F.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),L(n,{code:F.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),L(n,{code:F.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),L(n,{code:F.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Si(r).test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{code:F.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?yi.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{code:F.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?xi(r).test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{code:F.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?li.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`duration`,code:F.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?Ci(e.data,r.version)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`ip`,code:F.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?wi(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`jwt`,code:F.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?Ti(e.data,r.version)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`cidr`,code:F.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?gi.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`base64`,code:F.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?_i.test(e.data)||(n=this._getOrReturnCtx(e,n),L(n,{validation:`base64url`,code:F.invalid_string,message:r.message}),t.dirty()):N.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:F.invalid_string,...V.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...V.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...V.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...V.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...V.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...V.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...V.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...V.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...V.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...V.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...V.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...V.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...V.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...V.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...V.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...V.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...V.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...V.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...V.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...V.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...V.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...V.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...V.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...V.errToObj(t)})}nonempty(e){return this.min(1,V.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Ei.create=e=>new Ei({checks:[],typeName:Y.ZodString,coerce:e?.coerce??!1,...U(e)});function Di(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var Oi=class e extends W{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==P.number){let t=this._getOrReturnCtx(e);return L(t,{code:F.invalid_type,expected:P.number,received:t.parsedType}),z}let t,n=new R;for(let r of this._def.checks)r.kind===`int`?N.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),L(t,{code:F.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),L(t,{code:F.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),L(t,{code:F.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?Di(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),L(t,{code:F.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),L(t,{code:F.not_finite,message:r.message}),n.dirty()):N.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,V.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,V.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,V.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,V.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:V.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:V.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:V.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:V.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:V.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:V.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:V.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:V.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:V.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:V.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&N.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};Oi.create=e=>new Oi({checks:[],typeName:Y.ZodNumber,coerce:e?.coerce||!1,...U(e)});var ki=class e extends W{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==P.bigint)return this._getInvalidInput(e);let t,n=new R;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),L(t,{code:F.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),L(t,{code:F.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),L(t,{code:F.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):N.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return L(t,{code:F.invalid_type,expected:P.bigint,received:t.parsedType}),z}gte(e,t){return this.setLimit(`min`,e,!0,V.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,V.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,V.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,V.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:V.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:V.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:V.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:V.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:V.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:V.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};ki.create=e=>new ki({checks:[],typeName:Y.ZodBigInt,coerce:e?.coerce??!1,...U(e)});var Ai=class extends W{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==P.boolean){let t=this._getOrReturnCtx(e);return L(t,{code:F.invalid_type,expected:P.boolean,received:t.parsedType}),z}return B(e.data)}};Ai.create=e=>new Ai({typeName:Y.ZodBoolean,coerce:e?.coerce||!1,...U(e)});var ji=class e extends W{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==P.date){let t=this._getOrReturnCtx(e);return L(t,{code:F.invalid_type,expected:P.date,received:t.parsedType}),z}if(Number.isNaN(e.data.getTime()))return L(this._getOrReturnCtx(e),{code:F.invalid_date}),z;let t=new R,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),L(n,{code:F.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),L(n,{code:F.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):N.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:V.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:V.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};ji.create=e=>new ji({checks:[],coerce:e?.coerce||!1,typeName:Y.ZodDate,...U(e)});var Mi=class extends W{_parse(e){if(this._getType(e)!==P.symbol){let t=this._getOrReturnCtx(e);return L(t,{code:F.invalid_type,expected:P.symbol,received:t.parsedType}),z}return B(e.data)}};Mi.create=e=>new Mi({typeName:Y.ZodSymbol,...U(e)});var Ni=class extends W{_parse(e){if(this._getType(e)!==P.undefined){let t=this._getOrReturnCtx(e);return L(t,{code:F.invalid_type,expected:P.undefined,received:t.parsedType}),z}return B(e.data)}};Ni.create=e=>new Ni({typeName:Y.ZodUndefined,...U(e)});var Pi=class extends W{_parse(e){if(this._getType(e)!==P.null){let t=this._getOrReturnCtx(e);return L(t,{code:F.invalid_type,expected:P.null,received:t.parsedType}),z}return B(e.data)}};Pi.create=e=>new Pi({typeName:Y.ZodNull,...U(e)});var Fi=class extends W{constructor(){super(...arguments),this._any=!0}_parse(e){return B(e.data)}};Fi.create=e=>new Fi({typeName:Y.ZodAny,...U(e)});var Ii=class extends W{constructor(){super(...arguments),this._unknown=!0}_parse(e){return B(e.data)}};Ii.create=e=>new Ii({typeName:Y.ZodUnknown,...U(e)});var G=class extends W{_parse(e){let t=this._getOrReturnCtx(e);return L(t,{code:F.invalid_type,expected:P.never,received:t.parsedType}),z}};G.create=e=>new G({typeName:Y.ZodNever,...U(e)});var Li=class extends W{_parse(e){if(this._getType(e)!==P.undefined){let t=this._getOrReturnCtx(e);return L(t,{code:F.invalid_type,expected:P.void,received:t.parsedType}),z}return B(e.data)}};Li.create=e=>new Li({typeName:Y.ZodVoid,...U(e)});var Ri=class e extends W{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==P.array)return L(t,{code:F.invalid_type,expected:P.array,received:t.parsedType}),z;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(L(t,{code:e?F.too_big:F.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(L(t,{code:F.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(L(t,{code:F.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new H(t,e,t.path,n)))).then(e=>R.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new H(t,e,t.path,n)));return R.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:V.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:V.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:V.toString(n)}})}nonempty(e){return this.min(1,e)}};Ri.create=(e,t)=>new Ri({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Y.ZodArray,...U(t)});function zi(e){if(e instanceof K){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=J.create(zi(r))}return new K({...e._def,shape:()=>t})}else if(e instanceof Ri)return new Ri({...e._def,type:zi(e.element)});else if(e instanceof J)return J.create(zi(e.unwrap()));else if(e instanceof na)return na.create(zi(e.unwrap()));else if(e instanceof Gi)return Gi.create(e.items.map(e=>zi(e)));else return e}var K=class e extends W{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape();return this._cached={shape:e,keys:N.objectKeys(e)},this._cached}_parse(e){if(this._getType(e)!==P.object){let t=this._getOrReturnCtx(e);return L(t,{code:F.invalid_type,expected:P.object,received:t.parsedType}),z}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof G&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new H(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof G){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(L(n,{code:F.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new H(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>R.mergeObjectSync(t,e)):R.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return V.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:V.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of N.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of N.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return zi(this)}partial(t){let n={};for(let e of N.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of N.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof J;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Qi(N.objectKeys(this.shape))}};K.create=(e,t)=>new K({shape:()=>e,unknownKeys:`strip`,catchall:G.create(),typeName:Y.ZodObject,...U(t)}),K.strictCreate=(e,t)=>new K({shape:()=>e,unknownKeys:`strict`,catchall:G.create(),typeName:Y.ZodObject,...U(t)}),K.lazycreate=(e,t)=>new K({shape:e,unknownKeys:`strip`,catchall:G.create(),typeName:Y.ZodObject,...U(t)});var Bi=class extends W{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new I(e.ctx.common.issues));return L(t,{code:F.invalid_union,unionErrors:n}),z}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new I(e));return L(t,{code:F.invalid_union,unionErrors:i}),z}}get options(){return this._def.options}};Bi.create=(e,t)=>new Bi({options:e,typeName:Y.ZodUnion,...U(t)});let Vi=e=>e instanceof Xi?Vi(e.schema):e instanceof q?Vi(e.innerType()):e instanceof Zi?[e.value]:e instanceof $i?e.options:e instanceof ea?N.objectValues(e.enum):e instanceof ra?Vi(e._def.innerType):e instanceof Ni?[void 0]:e instanceof Pi?[null]:e instanceof J?[void 0,...Vi(e.unwrap())]:e instanceof na?[null,...Vi(e.unwrap())]:e instanceof oa||e instanceof ca?Vi(e.unwrap()):e instanceof ia?Vi(e._def.innerType):[];var Hi=class e extends W{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==P.object)return L(t,{code:F.invalid_type,expected:P.object,received:t.parsedType}),z;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(L(t,{code:F.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),z)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=Vi(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:Y.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...U(r)})}};function Ui(e,t){let n=Kr(e),r=Kr(t);if(e===t)return{valid:!0,data:e};if(n===P.object&&r===P.object){let n=N.objectKeys(t),r=N.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Ui(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===P.array&&r===P.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Ui(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===P.date&&r===P.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Wi=class extends W{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Qr(e)||Qr(r))return z;let i=Ui(e.value,r.value);return i.valid?(($r(e)||$r(r))&&t.dirty(),{status:t.value,value:i.data}):(L(n,{code:F.invalid_intersection_types}),z)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Wi.create=(e,t,n)=>new Wi({left:e,right:t,typeName:Y.ZodIntersection,...U(n)});var Gi=class e extends W{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==P.array)return L(n,{code:F.invalid_type,expected:P.array,received:n.parsedType}),z;if(n.data.length<this._def.items.length)return L(n,{code:F.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),z;!this._def.rest&&n.data.length>this._def.items.length&&(L(n,{code:F.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new H(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>R.mergeArray(t,e)):R.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Gi.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Gi({items:e,typeName:Y.ZodTuple,rest:null,...U(t)})};var Ki=class e extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==P.object)return L(n,{code:F.invalid_type,expected:P.object,received:n.parsedType}),z;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new H(n,e,n.path,e)),value:a._parse(new H(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?R.mergeObjectAsync(t,r):R.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof W?new e({keyType:t,valueType:n,typeName:Y.ZodRecord,...U(r)}):new e({keyType:Ei.create(),valueType:t,typeName:Y.ZodRecord,...U(n)})}},qi=class extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==P.map)return L(n,{code:F.invalid_type,expected:P.map,received:n.parsedType}),z;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new H(n,e,n.path,[a,`key`])),value:i._parse(new H(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return z;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return z;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};qi.create=(e,t,n)=>new qi({valueType:t,keyType:e,typeName:Y.ZodMap,...U(n)});var Ji=class e extends W{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==P.set)return L(n,{code:F.invalid_type,expected:P.set,received:n.parsedType}),z;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(L(n,{code:F.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(L(n,{code:F.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return z;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new H(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:V.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:V.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ji.create=(e,t)=>new Ji({valueType:e,minSize:null,maxSize:null,typeName:Y.ZodSet,...U(t)});var Yi=class e extends W{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==P.function)return L(t,{code:F.invalid_type,expected:P.function,received:t.parsedType}),z;function n(e,n){return Xr({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Yr(),qr].filter(e=>!!e),issueData:{code:F.invalid_arguments,argumentsError:n}})}function r(e,n){return Xr({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Yr(),qr].filter(e=>!!e),issueData:{code:F.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof ta){let e=this;return B(async function(...t){let o=new I([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return B(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new I([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new I([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Gi.create(t).rest(Ii.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Gi.create([]).rest(Ii.create()),returns:n||Ii.create(),typeName:Y.ZodFunction,...U(r)})}},Xi=class extends W{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Xi.create=(e,t)=>new Xi({getter:e,typeName:Y.ZodLazy,...U(t)});var Zi=class extends W{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return L(t,{received:t.data,code:F.invalid_literal,expected:this._def.value}),z}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Zi.create=(e,t)=>new Zi({value:e,typeName:Y.ZodLiteral,...U(t)});function Qi(e,t){return new $i({values:e,typeName:Y.ZodEnum,...U(t)})}var $i=class e extends W{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return L(t,{expected:N.joinValues(n),received:t.parsedType,code:F.invalid_type}),z}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return L(t,{received:t.data,code:F.invalid_enum_value,options:n}),z}return B(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};$i.create=Qi;var ea=class extends W{_parse(e){let t=N.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==P.string&&n.parsedType!==P.number){let e=N.objectValues(t);return L(n,{expected:N.joinValues(e),received:n.parsedType,code:F.invalid_type}),z}if(this._cache||=new Set(N.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=N.objectValues(t);return L(n,{received:n.data,code:F.invalid_enum_value,options:e}),z}return B(e.data)}get enum(){return this._def.values}};ea.create=(e,t)=>new ea({values:e,typeName:Y.ZodNativeEnum,...U(t)});var ta=class extends W{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==P.promise&&t.common.async===!1?(L(t,{code:F.invalid_type,expected:P.promise,received:t.parsedType}),z):B((t.parsedType===P.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};ta.create=(e,t)=>new ta({type:e,typeName:Y.ZodPromise,...U(t)});var q=class extends W{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{L(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return z;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?z:r.status===`dirty`||t.value===`dirty`?Zr(r.value):r});{if(t.value===`aborted`)return z;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?z:r.status===`dirty`||t.value===`dirty`?Zr(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?z:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?z:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ei(e))return z;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>ei(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):z);N.assertNever(r)}};q.create=(e,t,n)=>new q({schema:e,typeName:Y.ZodEffects,effect:t,...U(n)}),q.createWithPreprocess=(e,t,n)=>new q({schema:t,effect:{type:`preprocess`,transform:e},typeName:Y.ZodEffects,...U(n)});var J=class extends W{_parse(e){return this._getType(e)===P.undefined?B(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};J.create=(e,t)=>new J({innerType:e,typeName:Y.ZodOptional,...U(t)});var na=class extends W{_parse(e){return this._getType(e)===P.null?B(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};na.create=(e,t)=>new na({innerType:e,typeName:Y.ZodNullable,...U(t)});var ra=class extends W{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===P.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ra.create=(e,t)=>new ra({innerType:e,typeName:Y.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...U(t)});var ia=class extends W{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ti(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new I(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new I(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ia.create=(e,t)=>new ia({innerType:e,typeName:Y.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...U(t)});var aa=class extends W{_parse(e){if(this._getType(e)!==P.nan){let t=this._getOrReturnCtx(e);return L(t,{code:F.invalid_type,expected:P.nan,received:t.parsedType}),z}return{status:`valid`,value:e.data}}};aa.create=e=>new aa({typeName:Y.ZodNaN,...U(e)});var oa=class extends W{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},sa=class e extends W{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?z:e.status===`dirty`?(t.dirty(),Zr(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?z:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:Y.ZodPipeline})}},ca=class extends W{_parse(e){let t=this._def.innerType._parse(e),n=e=>(ei(e)&&(e.value=Object.freeze(e.value)),e);return ti(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};ca.create=(e,t)=>new ca({innerType:e,typeName:Y.ZodReadonly,...U(t)}),K.lazycreate;var Y;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(Y||={});let la=Ei.create,ua=Oi.create;aa.create,ki.create;let da=Ai.create;ji.create,Mi.create,Ni.create;let fa=Pi.create,pa=Fi.create;Ii.create;let ma=G.create;Li.create;let ha=Ri.create,ga=K.create;K.strictCreate;let X=Bi.create;Hi.create;let _a=Wi.create,va=Gi.create,ya=Ki.create;qi.create,Ji.create,Yi.create,Xi.create;let ba=Zi.create,xa=$i.create;ea.create,ta.create,q.create,J.create,na.create,q.createWithPreprocess,sa.create;var Sa=e=>[e.slice(0,e.length/2),e.slice(e.length/2)],Ca=Symbol(`Original index`),wa=e=>{let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`boolean`)t.push(r?{[Ca]:n}:{[Ca]:n,not:{}});else if(Ca in r)return e;else t.push({...r,[Ca]:n})}return t};function Ta(e,t){if(e.allOf.length===0)return ma();if(e.allOf.length===1){let n=e.allOf[0];return $(n,{...t,path:[...t.path,`allOf`,n[Ca]]})}let[n,r]=Sa(wa(e.allOf));return _a(Ta({allOf:n},t),Ta({allOf:r},t))}var Ea=(e,t)=>e.anyOf.length?e.anyOf.length===1?$(e.anyOf[0],{...t,path:[...t.path,`anyOf`,0]}):X(e.anyOf.map((e,n)=>$(e,{...t,path:[...t.path,`anyOf`,n]}))):pa();function Z(e,t,n,r){let i=t[n];if(i!==void 0){let a=t.errorMessage?.[n];return r(e,i,a)}return e}var Q={an:{object:e=>e.type===`object`||!e.type&&(e.properties!==void 0||e.additionalProperties!==void 0||e.patternProperties!==void 0),array:e=>e.type===`array`,anyOf:e=>e.anyOf!==void 0,allOf:e=>e.allOf!==void 0,enum:e=>e.enum!==void 0},a:{nullable:e=>e.nullable===!0,multipleType:e=>Array.isArray(e.type),not:e=>e.not!==void 0,const:e=>e.const!==void 0,primitive:(e,t)=>e.type===t,conditional:e=>!!(`if`in e&&e.if&&`then`in e&&`else`in e&&e.then&&e.else),oneOf:e=>e.oneOf!==void 0}},Da=(e,t)=>{if(Q.an.anyOf(e)){let n=new Set,r=[];e.anyOf.forEach(e=>{if(typeof e==`object`&&e.type&&n.add(typeof e.type==`string`?e.type:e.type[0]),typeof e==`object`&&e.items){let t=e.items;!Array.isArray(t)&&typeof t==`object`&&r.push(t)}});let i;r.length===1?i=r[0]:r.length>1&&(i={anyOf:r});let a={...n.size>0?{type:Array.from(n)}:{type:`array`},...i&&{items:i}};return[`default`,`description`,`examples`,`title`].forEach(t=>{let n=e[t];n!==void 0&&(a[t]=n)}),$(a,t)}if(Array.isArray(e.items))return va(e.items.map((e,n)=>$(e,{...t,path:[...t.path,`items`,n]})));let n=e.items?ha($(e.items,{...t,path:[...t.path,`items`]})):ha(pa());return n=Z(n,e,`minItems`,(e,t,n)=>e.min(t,n)),n=Z(n,e,`maxItems`,(e,t,n)=>e.max(t,n)),typeof e.min==`number`&&typeof e.minItems!=`number`&&(n=Z(n,{...e,minItems:e.min},`minItems`,(e,t,n)=>e.min(t,n))),typeof e.max==`number`&&typeof e.maxItems!=`number`&&(n=Z(n,{...e,maxItems:e.max},`maxItems`,(e,t,n)=>e.max(t,n))),n},Oa=e=>da(),ka=e=>ba(e.const),Aa=e=>pa(),ja=e=>e.enum.length===0?ma():e.enum.length===1?ba(e.enum[0]):e.enum.every(e=>typeof e==`string`)?xa(e.enum):X(e.enum.map(e=>ba(e))),Ma=(e,t)=>{let n=$(e.if,{...t,path:[...t.path,`if`]}),r=$(e.then,{...t,path:[...t.path,`then`]}),i=$(e.else,{...t,path:[...t.path,`else`]});return X([r,i]).superRefine((e,t)=>{let a=n.safeParse(e).success?r.safeParse(e):i.safeParse(e);a.success||a.error.errors.forEach(e=>t.addIssue(e))})},Na=(e,t)=>X(e.type.map(n=>$({...e,type:n},t))),Pa=(e,t)=>pa().refine(n=>!$(e.not,{...t,path:[...t.path,`not`]}).safeParse(n).success,`Invalid input: Should NOT be valid against schema`),Fa=e=>fa(),Ia=(e,...t)=>Object.keys(e).reduce((n,r)=>(t.includes(r)||(n[r]=e[r]),n),{}),La=(e,t)=>{let n=e.default===null,r=$(n?Ia(Ia(e,`nullable`),`default`):Ia(e,`nullable`),t,!0).nullable();return n?r.default(null):r},Ra=e=>{let t=ua(),n=!1;return e.type===`integer`?(n=!0,t=Z(t,e,`type`,(e,t,n)=>e.int(n))):e.format===`int64`&&(n=!0,t=Z(t,e,`format`,(e,t,n)=>e.int(n))),t=Z(t,e,`multipleOf`,(e,t,r)=>t===1?n?e:e.int(r):e.multipleOf(t,r)),typeof e.minimum==`number`?t=e.exclusiveMinimum===!0?Z(t,e,`minimum`,(e,t,n)=>e.gt(t,n)):Z(t,e,`minimum`,(e,t,n)=>e.gte(t,n)):typeof e.exclusiveMinimum==`number`&&(t=Z(t,e,`exclusiveMinimum`,(e,t,n)=>e.gt(t,n))),typeof e.maximum==`number`?t=e.exclusiveMaximum===!0?Z(t,e,`maximum`,(e,t,n)=>e.lt(t,n)):Z(t,e,`maximum`,(e,t,n)=>e.lte(t,n)):typeof e.exclusiveMaximum==`number`&&(t=Z(t,e,`exclusiveMaximum`,(e,t,n)=>e.lt(t,n))),typeof e.min==`number`&&typeof e.minimum!=`number`&&(t=Z(t,{...e,minimum:e.min},`minimum`,(e,t,n)=>e.gte(t,n))),typeof e.max==`number`&&typeof e.maximum!=`number`&&(t=Z(t,{...e,maximum:e.max},`maximum`,(e,t,n)=>e.lte(t,n))),t},za=(e,t)=>e.oneOf.length?e.oneOf.length===1?$(e.oneOf[0],{...t,path:[...t.path,`oneOf`,0]}):pa().superRefine((n,r)=>{let i=e.oneOf.map((e,n)=>$(e,{...t,path:[...t.path,`oneOf`,n]})),a=i.reduce((e,t)=>(t=>t.error?[...e,t.error]:e)(t.safeParse(n)),[]);i.length-a.length!==1&&r.addIssue({path:r.path,code:`invalid_union`,unionErrors:a,message:`Invalid input: Should pass single schema`})}):pa();function Ba(e,t){if(!e.properties)return ga({});let n=Object.keys(e.properties);if(n.length===0)return ga({});let r={};for(let i of n){let n=e.properties[i],a=$(n,{...t,path:[...t.path,`properties`,i]}),o=Array.isArray(e.required)?e.required.includes(i):!1;if(!o&&n&&typeof n==`object`&&`default`in n)if(n.default===null){let e=n.anyOf&&Array.isArray(n.anyOf)&&n.anyOf.some(e=>typeof e==`object`&&!!e&&e.type===`null`),t=n.oneOf&&Array.isArray(n.oneOf)&&n.oneOf.some(e=>typeof e==`object`&&!!e&&e.type===`null`),o=`nullable`in n&&n.nullable===!0;e||t||o?r[i]=a.optional().default(null):r[i]=a.nullable().optional().default(null)}else r[i]=a.optional().default(n.default);else r[i]=o?a:a.optional()}return ga(r)}function Va(e,t){let n=Object.keys(e.patternProperties??{}).length>0,r=e.type===`object`?e:{...e,type:`object`},i=Ba(r,t),a=i,o=r.additionalProperties===void 0?void 0:$(r.additionalProperties,{...t,path:[...t.path,`additionalProperties`]}),s=r.additionalProperties===!0;if(r.patternProperties){let e=Object.fromEntries(Object.entries(r.patternProperties).map(([e,n])=>[e,$(n,{...t,path:[...t.path,`patternProperties`,e]})])),n=Object.values(e);a=i?o?i.catchall(X([...n,o])):Object.keys(e).length>1?i.catchall(X(n)):i.catchall(n[0]):o?ya(X([...n,o])):n.length>1?ya(X(n)):ya(n[0]);let s=new Set(Object.keys(r.properties??{}));a=a.superRefine((t,n)=>{for(let i in t){let a=s.has(i);for(let o in r.patternProperties){let r=new RegExp(o);if(i.match(r)){a=!0;let r=e[o].safeParse(t[i]);r.success||n.addIssue({path:[...n.path,i],code:`custom`,message:`Invalid input: Key matching regex /${i}/ must match schema`,params:{issues:r.error.issues}})}}if(!a&&o){let e=o.safeParse(t[i]);e.success||n.addIssue({path:[...n.path,i],code:`custom`,message:`Invalid input: must match catchall schema`,params:{issues:e.error.issues}})}}})}let c;return c=i?n?a:o?o instanceof G?i.strict():s?i.passthrough():i.catchall(o):i.strict():n?a:o?o instanceof G?ga({}).strict():s?ga({}).passthrough():ya(o):ga({}).passthrough(),Q.an.anyOf(e)&&(c=c.and(Ea({...e,anyOf:e.anyOf.map(e=>typeof e==`object`&&!e.type&&(e.properties??e.additionalProperties??e.patternProperties)?{...e,type:`object`}:e)},t))),Q.a.oneOf(e)&&(c=c.and(za({...e,oneOf:e.oneOf.map(e=>typeof e==`object`&&!e.type&&(e.properties??e.additionalProperties??e.patternProperties)?{...e,type:`object`}:e)},t))),Q.an.allOf(e)&&(c=c.and(Ta({...e,allOf:e.allOf.map(e=>typeof e==`object`&&!e.type&&(e.properties??e.additionalProperties??e.patternProperties)?{...e,type:`object`}:e)},t))),c}var Ha=e=>{let t=la();return t=Z(t,e,`format`,(e,t,n)=>{switch(t){case`email`:return e.email(n);case`ip`:return e.ip(n);case`ipv4`:return e.ip({version:`v4`,message:n});case`ipv6`:return e.ip({version:`v6`,message:n});case`uri`:return e.url(n);case`uuid`:return e.uuid(n);case`date-time`:return e.datetime({offset:!0,message:n});case`time`:return e.time(n);case`date`:return e.date(n);case`binary`:return e.base64(n);case`duration`:return e.duration(n);default:return e}}),t=Z(t,e,`contentEncoding`,(e,t,n)=>e.base64(n)),t=Z(t,e,`pattern`,(e,t,n)=>e.regex(new RegExp(t),n)),t=Z(t,e,`minLength`,(e,t,n)=>e.min(t,n)),t=Z(t,e,`maxLength`,(e,t,n)=>e.max(t,n)),typeof e.min==`number`&&typeof e.minLength!=`number`&&(t=Z(t,{...e,minLength:e.min},`minLength`,(e,t,n)=>e.min(t,n))),typeof e.max==`number`&&typeof e.maxLength!=`number`&&(t=Z(t,{...e,maxLength:e.max},`maxLength`,(e,t,n)=>e.max(t,n))),t},Ua=(e,t)=>{let n=``;if(e.description?n=e.description:e.title&&(n=e.title),e.example!==void 0){let t=`Example: ${JSON.stringify(e.example)}`;n=n?`${n}
|
|
2
|
+
${t}`:t}else if(e.examples!==void 0&&Array.isArray(e.examples)){let t=e.examples;if(t&&t.length&&t.length>0){let e=t.length===1?`Example: ${JSON.stringify(t[0])}`:`Examples:
|
|
3
|
+
${t.map(e=>` ${JSON.stringify(e)}`).join(`
|
|
4
|
+
`)}`;n=n?`${n}
|
|
5
|
+
${e}`:e}}return n&&(t=t.describe(n)),t},Wa=(e,t,n)=>{if(e.default!==void 0){if(e.default===null&&n?.path.some(e=>e===`anyOf`||e===`oneOf`)&&e.type&&e.type!==`null`&&!e.nullable)return t;t=t.default(e.default)}return t},Ga=(e,t)=>(e.readOnly&&(t=t.readonly()),t),Ka=(e,t)=>Q.a.nullable(e)?La(e,t):Q.an.object(e)?Va(e,t):Q.an.array(e)?Da(e,t):Q.an.anyOf(e)?Ea(e,t):Q.an.allOf(e)?Ta(e,t):Q.a.oneOf(e)?za(e,t):Q.a.not(e)?Pa(e,t):Q.an.enum(e)?ja(e):Q.a.const(e)?ka(e):Q.a.multipleType(e)?Na(e,t):Q.a.primitive(e,`string`)?Ha(e):Q.a.primitive(e,`number`)||Q.a.primitive(e,`integer`)?Ra(e):Q.a.primitive(e,`boolean`)?Oa(e):Q.a.primitive(e,`null`)?Fa(e):Q.a.conditional(e)?Ma(e,t):Aa(e),$=(e,t={seen:new Map,path:[]},n)=>{if(typeof e!=`object`)return e?pa():ma();if(t.parserOverride){let n=t.parserOverride(e,t);if(n instanceof W)return n}let r=t.seen.get(e);if(r){if(r.r!==void 0)return r.r;if(t.depth===void 0||r.n>=t.depth)return pa();r.n+=1}else r={r:void 0,n:0},t.seen.set(e,r);let i=Ka(e,t);return n||(t.withoutDescribes||(i=Ua(e,i)),t.withoutDefaults||(i=Wa(e,i,t)),i=Ga(e,i)),r.r=i,i},qa=(e,t={})=>$(e,{path:[],seen:new Map,...t});function Ja(e){if(typeof e!=`object`||!e||`type`in e&&typeof e.type==`string`)return!1;let t=Object.values(e);return t.length===0?!1:t.some(e=>e instanceof W)}function Ya(e){try{return qa(e)}catch(e){return console.warn(`[Web Model Context] Failed to convert JSON Schema to Zod:`,e),ga({}).passthrough()}}function Xa(e){let t={},n=[];for(let[r,i]of Object.entries(e)){let e=i.description||void 0,a=`string`,o,s;if(i instanceof Ei)a=`string`;else if(i instanceof Oi)a=`number`;else if(i instanceof Ai)a=`boolean`;else if(i instanceof Ri){a=`array`;let e=i.element;s=e instanceof Ei?{type:`string`}:e instanceof Oi?{type:`number`}:e instanceof Ai?{type:`boolean`}:{type:`string`}}else if(i instanceof K)a=`object`;else if(i instanceof $i){a=`string`;let e=i._def;e?.values&&(o=e.values)}let c={type:a};e&&(c.description=e),o&&(c.enum=o),s&&(c.items=s),t[r]=c,i.isOptional()||n.push(r)}return{type:`object`,properties:t,...n.length>0&&{required:n}}}function Za(e){if(Ja(e))return{jsonSchema:Xa(e),zodValidator:ga(e)};let t=e;return{jsonSchema:t,zodValidator:Ya(t)}}function Qa(e,t){let n=t.safeParse(e);return n.success?{success:!0,data:n.data}:{success:!1,error:`Validation failed:\n${n.error.errors.map(e=>` - ${e.path.join(`.`)||`root`}: ${e.message}`).join(`
|
|
6
|
+
`)}`}}var $a=class extends Event{name;arguments;_response=null;_responded=!1;constructor(e,t){super(`toolcall`,{cancelable:!0}),this.name=e,this.arguments=t}respondWith(e){if(this._responded)throw Error(`Response already provided for this tool call`);this._response=e,this._responded=!0}getResponse(){return this._response}hasResponse(){return this._responded}},eo=class{bridge;eventTarget;provideContextTools;dynamicTools;registrationTimestamps;unregisterFunctions;constructor(e){this.bridge=e,this.eventTarget=new EventTarget,this.provideContextTools=new Map,this.dynamicTools=new Map,this.registrationTimestamps=new Map,this.unregisterFunctions=new Map}addEventListener(e,t,n){this.eventTarget.addEventListener(e,t,n)}removeEventListener(e,t,n){this.eventTarget.removeEventListener(e,t,n)}dispatchEvent(e){return this.eventTarget.dispatchEvent(e)}provideContext(e){console.log(`[Web Model Context] Registering ${e.tools.length} tools via provideContext`),this.provideContextTools.clear();for(let t of e.tools){if(this.dynamicTools.has(t.name))throw Error(`[Web Model Context] Tool name collision: "${t.name}" is already registered via registerTool(). Please use a different name or unregister the dynamic tool first.`);let{jsonSchema:e,zodValidator:n}=Za(t.inputSchema),r=t.outputSchema?Za(t.outputSchema):null,i={name:t.name,description:t.description,inputSchema:e,...r&&{outputSchema:r.jsonSchema},...t.annotations&&{annotations:t.annotations},execute:t.execute,inputValidator:n,...r&&{outputValidator:r.zodValidator}};this.provideContextTools.set(t.name,i)}this.updateBridgeTools(),this.bridge.server.notification&&this.bridge.server.notification({method:`notifications/tools/list_changed`,params:{}})}registerTool(e){console.log(`[Web Model Context] Registering tool dynamically: ${e.name}`);let t=Date.now(),n=this.registrationTimestamps.get(e.name);if(n&&t-n<50){console.warn(`[Web Model Context] Tool "${e.name}" registered multiple times within 50ms. This is likely due to React Strict Mode double-mounting. Ignoring duplicate registration.`);let t=this.unregisterFunctions.get(e.name);if(t)return{unregister:t}}if(this.provideContextTools.has(e.name))throw Error(`[Web Model Context] Tool name collision: "${e.name}" is already registered via provideContext(). Please use a different name or update your provideContext() call.`);if(this.dynamicTools.has(e.name))throw Error(`[Web Model Context] Tool name collision: "${e.name}" is already registered via registerTool(). Please unregister it first or use a different name.`);let{jsonSchema:r,zodValidator:i}=Za(e.inputSchema),a=e.outputSchema?Za(e.outputSchema):null,o={name:e.name,description:e.description,inputSchema:r,...a&&{outputSchema:a.jsonSchema},...e.annotations&&{annotations:e.annotations},execute:e.execute,inputValidator:i,...a&&{outputValidator:a.zodValidator}};this.dynamicTools.set(e.name,o),this.registrationTimestamps.set(e.name,t),this.updateBridgeTools(),this.bridge.server.notification&&this.bridge.server.notification({method:`notifications/tools/list_changed`,params:{}});let s=()=>{if(console.log(`[Web Model Context] Unregistering tool: ${e.name}`),this.provideContextTools.has(e.name))throw Error(`[Web Model Context] Cannot unregister tool "${e.name}": This tool was registered via provideContext(). Use provideContext() to update the base tool set.`);if(!this.dynamicTools.has(e.name)){console.warn(`[Web Model Context] Tool "${e.name}" is not registered, ignoring unregister call`);return}this.dynamicTools.delete(e.name),this.registrationTimestamps.delete(e.name),this.unregisterFunctions.delete(e.name),this.updateBridgeTools(),this.bridge.server.notification&&this.bridge.server.notification({method:`notifications/tools/list_changed`,params:{}})};return this.unregisterFunctions.set(e.name,s),{unregister:s}}updateBridgeTools(){this.bridge.tools.clear();for(let[e,t]of this.provideContextTools)this.bridge.tools.set(e,t);for(let[e,t]of this.dynamicTools)this.bridge.tools.set(e,t);console.log(`[Web Model Context] Updated bridge with ${this.provideContextTools.size} base tools + ${this.dynamicTools.size} dynamic tools = ${this.bridge.tools.size} total`)}async executeTool(e,t){let n=this.bridge.tools.get(e);if(!n)throw Error(`Tool not found: ${e}`);console.log(`[Web Model Context] Validating input for tool: ${e}`);let r=Qa(t,n.inputValidator);if(!r.success)return console.error(`[Web Model Context] Input validation failed for ${e}:`,r.error),{content:[{type:`text`,text:`Input validation error for tool "${e}":\n${r.error}`}],isError:!0};let i=r.data,a=new $a(e,i);if(this.dispatchEvent(a),a.defaultPrevented&&a.hasResponse()){let t=a.getResponse();if(t)return console.log(`[Web Model Context] Tool ${e} handled by event listener`),t}console.log(`[Web Model Context] Executing tool: ${e}`);try{let t=await n.execute(i);if(n.outputValidator&&t.structuredContent){let r=Qa(t.structuredContent,n.outputValidator);r.success||console.warn(`[Web Model Context] Output validation failed for ${e}:`,r.error)}return t}catch(t){return console.error(`[Web Model Context] Error executing tool ${e}:`,t),{content:[{type:`text`,text:`Error: ${t instanceof Error?t.message:String(t)}`}],isError:!0}}}listTools(){return Array.from(this.bridge.tools.values()).map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema,...e.outputSchema&&{outputSchema:e.outputSchema},...e.annotations&&{annotations:e.annotations}}))}};function to(){console.log(`[Web Model Context] Initializing MCP bridge`);let e=new t.Server({name:window.location.hostname||`localhost`,version:`1.0.0`},{capabilities:{tools:{listChanged:!0}}}),n={server:e,tools:new Map,modelContext:void 0,isInitialized:!0};n.modelContext=new eo(n),e.setRequestHandler(t.ListToolsRequestSchema,async()=>(console.log(`[MCP Bridge] Handling list_tools request`),{tools:n.modelContext.listTools()})),e.setRequestHandler(t.CallToolRequestSchema,async e=>{console.log(`[MCP Bridge] Handling call_tool request: ${e.params.name}`);let t=e.params.name,r=e.params.arguments||{};try{let e=await n.modelContext.executeTool(t,r);return{content:e.content,isError:e.isError}}catch(e){throw console.error(`[MCP Bridge] Error calling tool ${t}:`,e),e}});let r=new Wr({allowedOrigins:[`*`]});return e.connect(r),console.log(`[Web Model Context] MCP server connected`),n}function no(){if(typeof window>`u`){console.warn(`[Web Model Context] Not in browser environment, skipping initialization`);return}if(window.navigator.modelContext){console.warn(`[Web Model Context] window.navigator.modelContext already exists, skipping initialization`);return}try{let e=to();Object.defineProperty(window.navigator,`modelContext`,{value:e.modelContext,writable:!1,configurable:!1}),Object.defineProperty(window,`__mcpBridge`,{value:e,writable:!1,configurable:!0}),console.log(`✅ [Web Model Context] window.navigator.modelContext initialized successfully`)}catch(e){throw console.error(`[Web Model Context] Failed to initialize:`,e),e}}function ro(){if(!(typeof window>`u`)){if(window.__mcpBridge)try{window.__mcpBridge.server.close()}catch(e){console.warn(`[Web Model Context] Error closing MCP server:`,e)}delete window.navigator.modelContext,delete window.__mcpBridge,console.log(`[Web Model Context] Cleaned up`)}}if(typeof window<`u`&&typeof document<`u`)try{no()}catch(e){console.error(`[Web Model Context] Auto-initialization failed:`,e)}return e.cleanupWebModelContext=ro,e.initializeWebModelContext=no,e})({},__mcp_b_webmcp_ts_sdk);
|