@typescape-ai/mcp 0.1.2 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -9
- package/dist/mcp.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,11 +9,7 @@ Typescape MCP Server - Model Context Protocol integration for AI agents like Cla
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
# Using bun
|
|
13
12
|
bun add -D @typescape-ai/mcp
|
|
14
|
-
|
|
15
|
-
# Using npm/pnpm/yarn (still requires Bun runtime)
|
|
16
|
-
npm install -D @typescape-ai/mcp
|
|
17
13
|
```
|
|
18
14
|
|
|
19
15
|
## Usage with Claude Code
|
|
@@ -28,19 +24,57 @@ Add to your Claude Code MCP settings (`~/.claude/mcp.json`):
|
|
|
28
24
|
"args": ["@typescape-ai/mcp"],
|
|
29
25
|
"env": {
|
|
30
26
|
"TYPESCAPE_API_TOKEN": "your-token-here",
|
|
31
|
-
"TYPESCAPE_BASE_URL": "https://your-typescape-instance.
|
|
27
|
+
"TYPESCAPE_BASE_URL": "https://your-typescape-instance.vercel.app"
|
|
32
28
|
}
|
|
33
29
|
}
|
|
34
30
|
}
|
|
35
31
|
}
|
|
36
32
|
```
|
|
37
33
|
|
|
34
|
+
## Usage with Cursor
|
|
35
|
+
|
|
36
|
+
Add to `.cursor/mcp.json` in your project:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"mcpServers": {
|
|
41
|
+
"typescape": {
|
|
42
|
+
"command": "bunx",
|
|
43
|
+
"args": ["@typescape-ai/mcp"],
|
|
44
|
+
"env": {
|
|
45
|
+
"TYPESCAPE_API_TOKEN": "your-token-here",
|
|
46
|
+
"TYPESCAPE_BASE_URL": "https://your-typescape-instance.vercel.app"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Then reload MCP servers in Cursor (Cmd+Shift+P > "MCP: Reload").
|
|
54
|
+
|
|
38
55
|
## Available Tools
|
|
39
56
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
57
|
+
### `typescape_create_session`
|
|
58
|
+
|
|
59
|
+
Create a review session for a Markdown file.
|
|
60
|
+
|
|
61
|
+
| Parameter | Required | Description |
|
|
62
|
+
| ----------------- | -------- | ------------------------------------- |
|
|
63
|
+
| `repo_id` | Yes | Repository identifier |
|
|
64
|
+
| `git_sha` | Yes | Concrete 40-hex Git commit SHA |
|
|
65
|
+
| `file_path` | Yes | Path to Markdown file within the repo |
|
|
66
|
+
| `participants` | Yes | Array of `{ email, roles }` (min 1) |
|
|
67
|
+
| `title` | No | Session title |
|
|
68
|
+
| `idempotency_key` | No | Key for safe retries |
|
|
69
|
+
|
|
70
|
+
### `typescape_export_feedback`
|
|
71
|
+
|
|
72
|
+
Export all feedback from a session as structured JSON (schema v1).
|
|
73
|
+
|
|
74
|
+
| Parameter | Required | Description |
|
|
75
|
+
| ------------ | -------- | ----------------------------------- |
|
|
76
|
+
| `session_id` | Yes | Session ID (e.g., `sess_01HX...`) |
|
|
77
|
+
| `schema` | No | Export schema version (default: v1) |
|
|
44
78
|
|
|
45
79
|
## Environment Variables
|
|
46
80
|
|
package/dist/mcp.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var m1=Object.create;var{getPrototypeOf:Z1,defineProperty:J1,getOwnPropertyNames:c1}=Object;var u1=Object.prototype.hasOwnProperty;var p1=($,W,X)=>{X=$!=null?m1(Z1($)):{};let G=W||!$||!$.__esModule?J1(X,"default",{value:$,enumerable:!0}):X;for(let Q of c1($))if(!u1.call(G,Q))J1(G,Q,{get:()=>$[Q],enumerable:!0});return G};var n1=($,W)=>()=>(W||$((W={exports:{}}).exports,W),W.exports);var g1=n1((R8,i6)=>{i6.exports={name:"@typescape-ai/mcp",version:"0.0.1",description:"Typescape MCP Server - Model Context Protocol integration for AI agents",type:"module",bin:{"typescape-mcp":"./dist/mcp.js"},files:["dist","README.md"],exports:{".":"./dist/mcp.js"},publishConfig:{access:"public"},scripts:{build:"bun build src/index.ts --outfile=dist/mcp.js --target=bun --bundle --minify",dev:"bun run --watch src/index.ts",test:"bun test",typecheck:"tsc --noEmit",lint:"eslint src",prepublishOnly:"bun run build"},dependencies:{},devDependencies:{"@modelcontextprotocol/sdk":"1.0.4","@types/bun":"1.1.14","@typescape/schemas":"workspace:*",zod:"4.3.0"},engines:{bun:">=1.0.0"},keywords:["typescape","mcp","model-context-protocol","ai","claude","review","bun"],repository:{type:"git",url:"https://github.com/voidserf/typescape-docs.git",directory:"apps/mcp"},license:"MIT"}});function Y1(){let $=new Map;return{register(W,X){$.set(W.name,{definition:W,handler:X})},getTools(){return Array.from($.values()).map((W)=>W.definition)},getHandler(W){return $.get(W)?.handler}}}class T extends Error{status;code;requestId;constructor($,W,X,G){super(X);this.status=$;this.code=W;this.requestId=G;this.name="ApiError"}}function w1($,W){let G=$.replace(/\/$/,"");async function Q(J,Y,w={}){let z=`${G}/v1${Y}`;if(w.query&&Object.keys(w.query).length>0){let K=new URLSearchParams(w.query);z+=`?${K.toString()}`}let V={Authorization:`Bearer ${W}`,Accept:"application/json",...w.headers};if(w.body!==void 0)V["Content-Type"]="application/json";let U;try{U=await fetch(z,{method:J,headers:V,body:w.body!==void 0?JSON.stringify(w.body):void 0})}catch(K){let f=K instanceof Error?K.message:String(K);throw new T(0,"network_error",`Network error: ${f}`,"unknown")}let S;if((U.headers.get("Content-Type")||"").includes("application/json"))try{S=await U.json()}catch{S={}}else S={};let A0=S?.request_id||U.headers.get("X-Request-Id")||"unknown";if(!U.ok){let K=S,f=K.error?.code||"api_error",r=K.error?.message||`API request failed with status ${U.status}`;throw new T(U.status,f,r,A0)}return{status:U.status,body:S,requestId:A0}}return{async get(J,Y){return Q("GET",J,Y)},async post(J,Y){return Q("POST",J,Y)},request:Q}}var F;(function($){$.assertEqual=(Q)=>Q;function W(Q){}$.assertIs=W;function X(Q){throw Error()}$.assertNever=X,$.arrayToEnum=(Q)=>{let J={};for(let Y of Q)J[Y]=Y;return J},$.getValidEnumValues=(Q)=>{let J=$.objectKeys(Q).filter((w)=>typeof Q[Q[w]]!=="number"),Y={};for(let w of J)Y[w]=Q[w];return $.objectValues(Y)},$.objectValues=(Q)=>{return $.objectKeys(Q).map(function(J){return Q[J]})},$.objectKeys=typeof Object.keys==="function"?(Q)=>Object.keys(Q):(Q)=>{let J=[];for(let Y in Q)if(Object.prototype.hasOwnProperty.call(Q,Y))J.push(Y);return J},$.find=(Q,J)=>{for(let Y of Q)if(J(Y))return Y;return},$.isInteger=typeof Number.isInteger==="function"?(Q)=>Number.isInteger(Q):(Q)=>typeof Q==="number"&&isFinite(Q)&&Math.floor(Q)===Q;function G(Q,J=" | "){return Q.map((Y)=>typeof Y==="string"?`'${Y}'`:Y).join(J)}$.joinValues=G,$.jsonStringifyReplacer=(Q,J)=>{if(typeof J==="bigint")return J.toString();return J}})(F||(F={}));var n0;(function($){$.mergeShapes=(W,X)=>{return{...W,...X}}})(n0||(n0={}));var q=F.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Z=($)=>{switch(typeof $){case"undefined":return q.undefined;case"string":return q.string;case"number":return isNaN($)?q.nan:q.number;case"boolean":return q.boolean;case"function":return q.function;case"bigint":return q.bigint;case"symbol":return q.symbol;case"object":if(Array.isArray($))return q.array;if($===null)return q.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return q.promise;if(typeof Map<"u"&&$ instanceof Map)return q.map;if(typeof Set<"u"&&$ instanceof Set)return q.set;if(typeof Date<"u"&&$ instanceof Date)return q.date;return q.object;default:return q.unknown}},B=F.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"]),i1=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class E extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(X)=>{this.issues=[...this.issues,X]},this.addIssues=(X=[])=>{this.issues=[...this.issues,...X]};let W=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,W);else this.__proto__=W;this.name="ZodError",this.issues=$}format($){let W=$||function(Q){return Q.message},X={_errors:[]},G=(Q)=>{for(let J of Q.issues)if(J.code==="invalid_union")J.unionErrors.map(G);else if(J.code==="invalid_return_type")G(J.returnTypeError);else if(J.code==="invalid_arguments")G(J.argumentsError);else if(J.path.length===0)X._errors.push(W(J));else{let Y=X,w=0;while(w<J.path.length){let z=J.path[w];if(w!==J.path.length-1)Y[z]=Y[z]||{_errors:[]};else Y[z]=Y[z]||{_errors:[]},Y[z]._errors.push(W(J));Y=Y[z],w++}}};return G(this),X}static assert($){if(!($ instanceof E))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,F.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(W)=>W.message){let W={},X=[];for(let G of this.issues)if(G.path.length>0)W[G.path[0]]=W[G.path[0]]||[],W[G.path[0]].push($(G));else X.push($(G));return{formErrors:X,fieldErrors:W}}get formErrors(){return this.flatten()}}E.create=($)=>{return new E($)};var G0=($,W)=>{let X;switch($.code){case B.invalid_type:if($.received===q.undefined)X="Required";else X=`Expected ${$.expected}, received ${$.received}`;break;case B.invalid_literal:X=`Invalid literal value, expected ${JSON.stringify($.expected,F.jsonStringifyReplacer)}`;break;case B.unrecognized_keys:X=`Unrecognized key(s) in object: ${F.joinValues($.keys,", ")}`;break;case B.invalid_union:X="Invalid input";break;case B.invalid_union_discriminator:X=`Invalid discriminator value. Expected ${F.joinValues($.options)}`;break;case B.invalid_enum_value:X=`Invalid enum value. Expected ${F.joinValues($.options)}, received '${$.received}'`;break;case B.invalid_arguments:X="Invalid function arguments";break;case B.invalid_return_type:X="Invalid function return type";break;case B.invalid_date:X="Invalid date";break;case B.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(X=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")X=`${X} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)X=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)X=`Invalid input: must end with "${$.validation.endsWith}"`;else F.assertNever($.validation);else if($.validation!=="regex")X=`Invalid ${$.validation}`;else X="Invalid";break;case B.too_small:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else X="Invalid input";break;case B.too_big:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")X=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else X="Invalid input";break;case B.custom:X="Invalid input";break;case B.invalid_intersection_types:X="Intersection results could not be merged";break;case B.not_multiple_of:X=`Number must be a multiple of ${$.multipleOf}`;break;case B.not_finite:X="Number must be finite";break;default:X=W.defaultError,F.assertNever($)}return{message:X}},M1=G0;function d1($){M1=$}function f0(){return M1}var C0=($)=>{let{data:W,path:X,errorMaps:G,issueData:Q}=$,J=[...X,...Q.path||[]],Y={...Q,path:J};if(Q.message!==void 0)return{...Q,path:J,message:Q.message};let w="",z=G.filter((V)=>!!V).slice().reverse();for(let V of z)w=V(Y,{data:W,defaultError:w}).message;return{...Q,path:J,message:w}},r1=[];function M($,W){let X=f0(),G=C0({issueData:W,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,X,X===G0?void 0:G0].filter((Q)=>!!Q)});$.common.issues.push(G)}class N{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,W){let X=[];for(let G of W){if(G.status==="aborted")return L;if(G.status==="dirty")$.dirty();X.push(G.value)}return{status:$.value,value:X}}static async mergeObjectAsync($,W){let X=[];for(let G of W){let Q=await G.key,J=await G.value;X.push({key:Q,value:J})}return N.mergeObjectSync($,X)}static mergeObjectSync($,W){let X={};for(let G of W){let{key:Q,value:J}=G;if(Q.status==="aborted")return L;if(J.status==="aborted")return L;if(Q.status==="dirty")$.dirty();if(J.status==="dirty")$.dirty();if(Q.value!=="__proto__"&&(typeof J.value<"u"||G.alwaysSet))X[Q.value]=J.value}return{status:$.value,value:X}}}var L=Object.freeze({status:"aborted"}),X0=($)=>({status:"dirty",value:$}),_=($)=>({status:"valid",value:$}),i0=($)=>$.status==="aborted",d0=($)=>$.status==="dirty",o=($)=>$.status==="valid",F0=($)=>typeof Promise<"u"&&$ instanceof Promise;function k0($,W,X,G){if(X==="a"&&!G)throw TypeError("Private accessor was defined without a getter");if(typeof W==="function"?$!==W||!G:!W.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?G:X==="a"?G.call($):G?G.value:W.get($)}function q1($,W,X,G,Q){if(G==="m")throw TypeError("Private method is not writable");if(G==="a"&&!Q)throw TypeError("Private accessor was defined without a setter");if(typeof W==="function"?$!==W||!Q:!W.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return G==="a"?Q.call($,X):Q?Q.value=X:W.set($,X),X}var O;(function($){$.errToObj=(W)=>typeof W==="string"?{message:W}:W||{},$.toString=(W)=>typeof W==="string"?W:W===null||W===void 0?void 0:W.message})(O||(O={}));var D0,U0;class P{constructor($,W,X,G){this._cachedPath=[],this.parent=$,this.data=W,this._path=X,this._key=G}get path(){if(!this._cachedPath.length)if(this._key instanceof Array)this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var z1=($,W)=>{if(o(W))return{success:!0,data:W.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let X=new E($.common.issues);return this._error=X,this._error}}}};function A($){if(!$)return{};let{errorMap:W,invalid_type_error:X,required_error:G,description:Q}=$;if(W&&(X||G))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(W)return{errorMap:W,description:Q};return{errorMap:(Y,w)=>{var z,V;let{message:U}=$;if(Y.code==="invalid_enum_value")return{message:U!==null&&U!==void 0?U:w.defaultError};if(typeof w.data>"u")return{message:(z=U!==null&&U!==void 0?U:G)!==null&&z!==void 0?z:w.defaultError};if(Y.code!=="invalid_type")return{message:w.defaultError};return{message:(V=U!==null&&U!==void 0?U:X)!==null&&V!==void 0?V:w.defaultError}},description:Q}}class D{get description(){return this._def.description}_getType($){return Z($.data)}_getOrReturnCtx($,W){return W||{common:$.parent.common,data:$.data,parsedType:Z($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new N,ctx:{common:$.parent.common,data:$.data,parsedType:Z($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let W=this._parse($);if(F0(W))throw Error("Synchronous parse encountered promise.");return W}_parseAsync($){let W=this._parse($);return Promise.resolve(W)}parse($,W){let X=this.safeParse($,W);if(X.success)return X.data;throw X.error}safeParse($,W){var X;let G={common:{issues:[],async:(X=W===null||W===void 0?void 0:W.async)!==null&&X!==void 0?X:!1,contextualErrorMap:W===null||W===void 0?void 0:W.errorMap},path:(W===null||W===void 0?void 0:W.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:Z($)},Q=this._parseSync({data:$,path:G.path,parent:G});return z1(G,Q)}"~validate"($){var W,X;let G={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:Z($)};if(!this["~standard"].async)try{let Q=this._parseSync({data:$,path:[],parent:G});return o(Q)?{value:Q.value}:{issues:G.common.issues}}catch(Q){if((X=(W=Q===null||Q===void 0?void 0:Q.message)===null||W===void 0?void 0:W.toLowerCase())===null||X===void 0?void 0:X.includes("encountered"))this["~standard"].async=!0;G.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:G}).then((Q)=>o(Q)?{value:Q.value}:{issues:G.common.issues})}async parseAsync($,W){let X=await this.safeParseAsync($,W);if(X.success)return X.data;throw X.error}async safeParseAsync($,W){let X={common:{issues:[],contextualErrorMap:W===null||W===void 0?void 0:W.errorMap,async:!0},path:(W===null||W===void 0?void 0:W.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:Z($)},G=this._parse({data:$,path:X.path,parent:X}),Q=await(F0(G)?G:Promise.resolve(G));return z1(X,Q)}refine($,W){let X=(G)=>{if(typeof W==="string"||typeof W>"u")return{message:W};else if(typeof W==="function")return W(G);else return W};return this._refinement((G,Q)=>{let J=$(G),Y=()=>Q.addIssue({code:B.custom,...X(G)});if(typeof Promise<"u"&&J instanceof Promise)return J.then((w)=>{if(!w)return Y(),!1;else return!0});if(!J)return Y(),!1;else return!0})}refinement($,W){return this._refinement((X,G)=>{if(!$(X))return G.addIssue(typeof W==="function"?W(X,G):W),!1;else return!0})}_refinement($){return new v({schema:this,typeName:j.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,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:(W)=>this["~validate"](W)}}optional(){return I.create(this,this._def)}nullable(){return c.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return k.create(this)}promise(){return e.create(this,this._def)}or($){return w0.create([this,$],this._def)}and($){return z0.create(this,$,this._def)}transform($){return new v({...A(this._def),schema:this,typeName:j.ZodEffects,effect:{type:"transform",transform:$}})}default($){let W=typeof $==="function"?$:()=>$;return new O0({...A(this._def),innerType:this,defaultValue:W,typeName:j.ZodDefault})}brand(){return new P0({typeName:j.ZodBranded,type:this,...A(this._def)})}catch($){let W=typeof $==="function"?$:()=>$;return new V0({...A(this._def),innerType:this,catchValue:W,typeName:j.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return E0.create(this,$)}readonly(){return j0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var o1=/^c[^\s-]{8,}$/i,a1=/^[0-9a-z]+$/,t1=/^[0-9A-HJKMNP-TV-Z]{26}$/i,s1=/^[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,e1=/^[a-z0-9_-]{21}$/i,$4=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,W4=/^[-+]?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)?)??$/,X4=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Q4="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",p0,G4=/^(?:(?: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])$/,H4=/^(?:(?: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])$/,J4=/^(([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]))$/,Y4=/^(([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])$/,w4=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,z4=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,O1="((\\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])))",B4=new RegExp(`^${O1}$`);function V1($){let W="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";if($.precision)W=`${W}\\.\\d{${$.precision}}`;else if($.precision==null)W=`${W}(\\.\\d+)?`;return W}function M4($){return new RegExp(`^${V1($)}$`)}function j1($){let W=`${O1}T${V1($)}`,X=[];if(X.push($.local?"Z?":"Z"),$.offset)X.push("([+-]\\d{2}:?\\d{2})");return W=`${W}(${X.join("|")})`,new RegExp(`^${W}$`)}function q4($,W){if((W==="v4"||!W)&&G4.test($))return!0;if((W==="v6"||!W)&&J4.test($))return!0;return!1}function O4($,W){if(!$4.test($))return!1;try{let[X]=$.split("."),G=X.replace(/-/g,"+").replace(/_/g,"/").padEnd(X.length+(4-X.length%4)%4,"="),Q=JSON.parse(atob(G));if(typeof Q!=="object"||Q===null)return!1;if(!Q.typ||!Q.alg)return!1;if(W&&Q.alg!==W)return!1;return!0}catch(X){return!1}}function V4($,W){if((W==="v4"||!W)&&H4.test($))return!0;if((W==="v6"||!W)&&Y4.test($))return!0;return!1}class C extends D{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==q.string){let Q=this._getOrReturnCtx($);return M(Q,{code:B.invalid_type,expected:q.string,received:Q.parsedType}),L}let X=new N,G=void 0;for(let Q of this._def.checks)if(Q.kind==="min"){if($.data.length<Q.value)G=this._getOrReturnCtx($,G),M(G,{code:B.too_small,minimum:Q.value,type:"string",inclusive:!0,exact:!1,message:Q.message}),X.dirty()}else if(Q.kind==="max"){if($.data.length>Q.value)G=this._getOrReturnCtx($,G),M(G,{code:B.too_big,maximum:Q.value,type:"string",inclusive:!0,exact:!1,message:Q.message}),X.dirty()}else if(Q.kind==="length"){let J=$.data.length>Q.value,Y=$.data.length<Q.value;if(J||Y){if(G=this._getOrReturnCtx($,G),J)M(G,{code:B.too_big,maximum:Q.value,type:"string",inclusive:!0,exact:!0,message:Q.message});else if(Y)M(G,{code:B.too_small,minimum:Q.value,type:"string",inclusive:!0,exact:!0,message:Q.message});X.dirty()}}else if(Q.kind==="email"){if(!X4.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"email",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="emoji"){if(!p0)p0=new RegExp(Q4,"u");if(!p0.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"emoji",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="uuid"){if(!s1.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"uuid",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="nanoid"){if(!e1.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"nanoid",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="cuid"){if(!o1.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"cuid",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="cuid2"){if(!a1.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"cuid2",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="ulid"){if(!t1.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"ulid",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="url")try{new URL($.data)}catch(J){G=this._getOrReturnCtx($,G),M(G,{validation:"url",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="regex"){if(Q.regex.lastIndex=0,!Q.regex.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"regex",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="trim")$.data=$.data.trim();else if(Q.kind==="includes"){if(!$.data.includes(Q.value,Q.position))G=this._getOrReturnCtx($,G),M(G,{code:B.invalid_string,validation:{includes:Q.value,position:Q.position},message:Q.message}),X.dirty()}else if(Q.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(Q.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(Q.kind==="startsWith"){if(!$.data.startsWith(Q.value))G=this._getOrReturnCtx($,G),M(G,{code:B.invalid_string,validation:{startsWith:Q.value},message:Q.message}),X.dirty()}else if(Q.kind==="endsWith"){if(!$.data.endsWith(Q.value))G=this._getOrReturnCtx($,G),M(G,{code:B.invalid_string,validation:{endsWith:Q.value},message:Q.message}),X.dirty()}else if(Q.kind==="datetime"){if(!j1(Q).test($.data))G=this._getOrReturnCtx($,G),M(G,{code:B.invalid_string,validation:"datetime",message:Q.message}),X.dirty()}else if(Q.kind==="date"){if(!B4.test($.data))G=this._getOrReturnCtx($,G),M(G,{code:B.invalid_string,validation:"date",message:Q.message}),X.dirty()}else if(Q.kind==="time"){if(!M4(Q).test($.data))G=this._getOrReturnCtx($,G),M(G,{code:B.invalid_string,validation:"time",message:Q.message}),X.dirty()}else if(Q.kind==="duration"){if(!W4.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"duration",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="ip"){if(!q4($.data,Q.version))G=this._getOrReturnCtx($,G),M(G,{validation:"ip",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="jwt"){if(!O4($.data,Q.alg))G=this._getOrReturnCtx($,G),M(G,{validation:"jwt",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="cidr"){if(!V4($.data,Q.version))G=this._getOrReturnCtx($,G),M(G,{validation:"cidr",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="base64"){if(!w4.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"base64",code:B.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="base64url"){if(!z4.test($.data))G=this._getOrReturnCtx($,G),M(G,{validation:"base64url",code:B.invalid_string,message:Q.message}),X.dirty()}else F.assertNever(Q);return{status:X.value,value:$.data}}_regex($,W,X){return this.refinement((G)=>$.test(G),{validation:W,code:B.invalid_string,...O.errToObj(X)})}_addCheck($){return new C({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...O.errToObj($)})}url($){return this._addCheck({kind:"url",...O.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...O.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...O.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...O.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...O.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...O.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...O.errToObj($)})}base64($){return this._addCheck({kind:"base64",...O.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...O.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...O.errToObj($)})}ip($){return this._addCheck({kind:"ip",...O.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...O.errToObj($)})}datetime($){var W,X;if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof($===null||$===void 0?void 0:$.precision)>"u"?null:$===null||$===void 0?void 0:$.precision,offset:(W=$===null||$===void 0?void 0:$.offset)!==null&&W!==void 0?W:!1,local:(X=$===null||$===void 0?void 0:$.local)!==null&&X!==void 0?X:!1,...O.errToObj($===null||$===void 0?void 0:$.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof($===null||$===void 0?void 0:$.precision)>"u"?null:$===null||$===void 0?void 0:$.precision,...O.errToObj($===null||$===void 0?void 0:$.message)})}duration($){return this._addCheck({kind:"duration",...O.errToObj($)})}regex($,W){return this._addCheck({kind:"regex",regex:$,...O.errToObj(W)})}includes($,W){return this._addCheck({kind:"includes",value:$,position:W===null||W===void 0?void 0:W.position,...O.errToObj(W===null||W===void 0?void 0:W.message)})}startsWith($,W){return this._addCheck({kind:"startsWith",value:$,...O.errToObj(W)})}endsWith($,W){return this._addCheck({kind:"endsWith",value:$,...O.errToObj(W)})}min($,W){return this._addCheck({kind:"min",value:$,...O.errToObj(W)})}max($,W){return this._addCheck({kind:"max",value:$,...O.errToObj(W)})}length($,W){return this._addCheck({kind:"length",value:$,...O.errToObj(W)})}nonempty($){return this.min(1,O.errToObj($))}trim(){return new C({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new C({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new C({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let W of this._def.checks)if(W.kind==="min"){if($===null||W.value>$)$=W.value}return $}get maxLength(){let $=null;for(let W of this._def.checks)if(W.kind==="max"){if($===null||W.value<$)$=W.value}return $}}C.create=($)=>{var W;return new C({checks:[],typeName:j.ZodString,coerce:(W=$===null||$===void 0?void 0:$.coerce)!==null&&W!==void 0?W:!1,...A($)})};function j4($,W){let X=($.toString().split(".")[1]||"").length,G=(W.toString().split(".")[1]||"").length,Q=X>G?X:G,J=parseInt($.toFixed(Q).replace(".","")),Y=parseInt(W.toFixed(Q).replace(".",""));return J%Y/Math.pow(10,Q)}class p extends D{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==q.number){let Q=this._getOrReturnCtx($);return M(Q,{code:B.invalid_type,expected:q.number,received:Q.parsedType}),L}let X=void 0,G=new N;for(let Q of this._def.checks)if(Q.kind==="int"){if(!F.isInteger($.data))X=this._getOrReturnCtx($,X),M(X,{code:B.invalid_type,expected:"integer",received:"float",message:Q.message}),G.dirty()}else if(Q.kind==="min"){if(Q.inclusive?$.data<Q.value:$.data<=Q.value)X=this._getOrReturnCtx($,X),M(X,{code:B.too_small,minimum:Q.value,type:"number",inclusive:Q.inclusive,exact:!1,message:Q.message}),G.dirty()}else if(Q.kind==="max"){if(Q.inclusive?$.data>Q.value:$.data>=Q.value)X=this._getOrReturnCtx($,X),M(X,{code:B.too_big,maximum:Q.value,type:"number",inclusive:Q.inclusive,exact:!1,message:Q.message}),G.dirty()}else if(Q.kind==="multipleOf"){if(j4($.data,Q.value)!==0)X=this._getOrReturnCtx($,X),M(X,{code:B.not_multiple_of,multipleOf:Q.value,message:Q.message}),G.dirty()}else if(Q.kind==="finite"){if(!Number.isFinite($.data))X=this._getOrReturnCtx($,X),M(X,{code:B.not_finite,message:Q.message}),G.dirty()}else F.assertNever(Q);return{status:G.value,value:$.data}}gte($,W){return this.setLimit("min",$,!0,O.toString(W))}gt($,W){return this.setLimit("min",$,!1,O.toString(W))}lte($,W){return this.setLimit("max",$,!0,O.toString(W))}lt($,W){return this.setLimit("max",$,!1,O.toString(W))}setLimit($,W,X,G){return new p({...this._def,checks:[...this._def.checks,{kind:$,value:W,inclusive:X,message:O.toString(G)}]})}_addCheck($){return new p({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:O.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:O.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:O.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:O.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:O.toString($)})}multipleOf($,W){return this._addCheck({kind:"multipleOf",value:$,message:O.toString(W)})}finite($){return this._addCheck({kind:"finite",message:O.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:O.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:O.toString($)})}get minValue(){let $=null;for(let W of this._def.checks)if(W.kind==="min"){if($===null||W.value>$)$=W.value}return $}get maxValue(){let $=null;for(let W of this._def.checks)if(W.kind==="max"){if($===null||W.value<$)$=W.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&F.isInteger($.value))}get isFinite(){let $=null,W=null;for(let X of this._def.checks)if(X.kind==="finite"||X.kind==="int"||X.kind==="multipleOf")return!0;else if(X.kind==="min"){if(W===null||X.value>W)W=X.value}else if(X.kind==="max"){if($===null||X.value<$)$=X.value}return Number.isFinite(W)&&Number.isFinite($)}}p.create=($)=>{return new p({checks:[],typeName:j.ZodNumber,coerce:($===null||$===void 0?void 0:$.coerce)||!1,...A($)})};class n extends D{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch(Q){return this._getInvalidInput($)}if(this._getType($)!==q.bigint)return this._getInvalidInput($);let X=void 0,G=new N;for(let Q of this._def.checks)if(Q.kind==="min"){if(Q.inclusive?$.data<Q.value:$.data<=Q.value)X=this._getOrReturnCtx($,X),M(X,{code:B.too_small,type:"bigint",minimum:Q.value,inclusive:Q.inclusive,message:Q.message}),G.dirty()}else if(Q.kind==="max"){if(Q.inclusive?$.data>Q.value:$.data>=Q.value)X=this._getOrReturnCtx($,X),M(X,{code:B.too_big,type:"bigint",maximum:Q.value,inclusive:Q.inclusive,message:Q.message}),G.dirty()}else if(Q.kind==="multipleOf"){if($.data%Q.value!==BigInt(0))X=this._getOrReturnCtx($,X),M(X,{code:B.not_multiple_of,multipleOf:Q.value,message:Q.message}),G.dirty()}else F.assertNever(Q);return{status:G.value,value:$.data}}_getInvalidInput($){let W=this._getOrReturnCtx($);return M(W,{code:B.invalid_type,expected:q.bigint,received:W.parsedType}),L}gte($,W){return this.setLimit("min",$,!0,O.toString(W))}gt($,W){return this.setLimit("min",$,!1,O.toString(W))}lte($,W){return this.setLimit("max",$,!0,O.toString(W))}lt($,W){return this.setLimit("max",$,!1,O.toString(W))}setLimit($,W,X,G){return new n({...this._def,checks:[...this._def.checks,{kind:$,value:W,inclusive:X,message:O.toString(G)}]})}_addCheck($){return new n({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:O.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:O.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:O.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:O.toString($)})}multipleOf($,W){return this._addCheck({kind:"multipleOf",value:$,message:O.toString(W)})}get minValue(){let $=null;for(let W of this._def.checks)if(W.kind==="min"){if($===null||W.value>$)$=W.value}return $}get maxValue(){let $=null;for(let W of this._def.checks)if(W.kind==="max"){if($===null||W.value<$)$=W.value}return $}}n.create=($)=>{var W;return new n({checks:[],typeName:j.ZodBigInt,coerce:(W=$===null||$===void 0?void 0:$.coerce)!==null&&W!==void 0?W:!1,...A($)})};class H0 extends D{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==q.boolean){let X=this._getOrReturnCtx($);return M(X,{code:B.invalid_type,expected:q.boolean,received:X.parsedType}),L}return _($.data)}}H0.create=($)=>{return new H0({typeName:j.ZodBoolean,coerce:($===null||$===void 0?void 0:$.coerce)||!1,...A($)})};class a extends D{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==q.date){let Q=this._getOrReturnCtx($);return M(Q,{code:B.invalid_type,expected:q.date,received:Q.parsedType}),L}if(isNaN($.data.getTime())){let Q=this._getOrReturnCtx($);return M(Q,{code:B.invalid_date}),L}let X=new N,G=void 0;for(let Q of this._def.checks)if(Q.kind==="min"){if($.data.getTime()<Q.value)G=this._getOrReturnCtx($,G),M(G,{code:B.too_small,message:Q.message,inclusive:!0,exact:!1,minimum:Q.value,type:"date"}),X.dirty()}else if(Q.kind==="max"){if($.data.getTime()>Q.value)G=this._getOrReturnCtx($,G),M(G,{code:B.too_big,message:Q.message,inclusive:!0,exact:!1,maximum:Q.value,type:"date"}),X.dirty()}else F.assertNever(Q);return{status:X.value,value:new Date($.data.getTime())}}_addCheck($){return new a({...this._def,checks:[...this._def.checks,$]})}min($,W){return this._addCheck({kind:"min",value:$.getTime(),message:O.toString(W)})}max($,W){return this._addCheck({kind:"max",value:$.getTime(),message:O.toString(W)})}get minDate(){let $=null;for(let W of this._def.checks)if(W.kind==="min"){if($===null||W.value>$)$=W.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let W of this._def.checks)if(W.kind==="max"){if($===null||W.value<$)$=W.value}return $!=null?new Date($):null}}a.create=($)=>{return new a({checks:[],coerce:($===null||$===void 0?void 0:$.coerce)||!1,typeName:j.ZodDate,...A($)})};class R0 extends D{_parse($){if(this._getType($)!==q.symbol){let X=this._getOrReturnCtx($);return M(X,{code:B.invalid_type,expected:q.symbol,received:X.parsedType}),L}return _($.data)}}R0.create=($)=>{return new R0({typeName:j.ZodSymbol,...A($)})};class J0 extends D{_parse($){if(this._getType($)!==q.undefined){let X=this._getOrReturnCtx($);return M(X,{code:B.invalid_type,expected:q.undefined,received:X.parsedType}),L}return _($.data)}}J0.create=($)=>{return new J0({typeName:j.ZodUndefined,...A($)})};class Y0 extends D{_parse($){if(this._getType($)!==q.null){let X=this._getOrReturnCtx($);return M(X,{code:B.invalid_type,expected:q.null,received:X.parsedType}),L}return _($.data)}}Y0.create=($)=>{return new Y0({typeName:j.ZodNull,...A($)})};class t extends D{constructor(){super(...arguments);this._any=!0}_parse($){return _($.data)}}t.create=($)=>{return new t({typeName:j.ZodAny,...A($)})};class u extends D{constructor(){super(...arguments);this._unknown=!0}_parse($){return _($.data)}}u.create=($)=>{return new u({typeName:j.ZodUnknown,...A($)})};class x extends D{_parse($){let W=this._getOrReturnCtx($);return M(W,{code:B.invalid_type,expected:q.never,received:W.parsedType}),L}}x.create=($)=>{return new x({typeName:j.ZodNever,...A($)})};class K0 extends D{_parse($){if(this._getType($)!==q.undefined){let X=this._getOrReturnCtx($);return M(X,{code:B.invalid_type,expected:q.void,received:X.parsedType}),L}return _($.data)}}K0.create=($)=>{return new K0({typeName:j.ZodVoid,...A($)})};class k extends D{_parse($){let{ctx:W,status:X}=this._processInputParams($),G=this._def;if(W.parsedType!==q.array)return M(W,{code:B.invalid_type,expected:q.array,received:W.parsedType}),L;if(G.exactLength!==null){let J=W.data.length>G.exactLength.value,Y=W.data.length<G.exactLength.value;if(J||Y)M(W,{code:J?B.too_big:B.too_small,minimum:Y?G.exactLength.value:void 0,maximum:J?G.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:G.exactLength.message}),X.dirty()}if(G.minLength!==null){if(W.data.length<G.minLength.value)M(W,{code:B.too_small,minimum:G.minLength.value,type:"array",inclusive:!0,exact:!1,message:G.minLength.message}),X.dirty()}if(G.maxLength!==null){if(W.data.length>G.maxLength.value)M(W,{code:B.too_big,maximum:G.maxLength.value,type:"array",inclusive:!0,exact:!1,message:G.maxLength.message}),X.dirty()}if(W.common.async)return Promise.all([...W.data].map((J,Y)=>{return G.type._parseAsync(new P(W,J,W.path,Y))})).then((J)=>{return N.mergeArray(X,J)});let Q=[...W.data].map((J,Y)=>{return G.type._parseSync(new P(W,J,W.path,Y))});return N.mergeArray(X,Q)}get element(){return this._def.type}min($,W){return new k({...this._def,minLength:{value:$,message:O.toString(W)}})}max($,W){return new k({...this._def,maxLength:{value:$,message:O.toString(W)}})}length($,W){return new k({...this._def,exactLength:{value:$,message:O.toString(W)}})}nonempty($){return this.min(1,$)}}k.create=($,W)=>{return new k({type:$,minLength:null,maxLength:null,exactLength:null,typeName:j.ZodArray,...A(W)})};function W0($){if($ instanceof R){let W={};for(let X in $.shape){let G=$.shape[X];W[X]=I.create(W0(G))}return new R({...$._def,shape:()=>W})}else if($ instanceof k)return new k({...$._def,type:W0($.element)});else if($ instanceof I)return I.create(W0($.unwrap()));else if($ instanceof c)return c.create(W0($.unwrap()));else if($ instanceof y)return y.create($.items.map((W)=>W0(W)));else return $}class R extends D{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),W=F.objectKeys($);return this._cached={shape:$,keys:W}}_parse($){if(this._getType($)!==q.object){let z=this._getOrReturnCtx($);return M(z,{code:B.invalid_type,expected:q.object,received:z.parsedType}),L}let{status:X,ctx:G}=this._processInputParams($),{shape:Q,keys:J}=this._getCached(),Y=[];if(!(this._def.catchall instanceof x&&this._def.unknownKeys==="strip")){for(let z in G.data)if(!J.includes(z))Y.push(z)}let w=[];for(let z of J){let V=Q[z],U=G.data[z];w.push({key:{status:"valid",value:z},value:V._parse(new P(G,U,G.path,z)),alwaysSet:z in G.data})}if(this._def.catchall instanceof x){let z=this._def.unknownKeys;if(z==="passthrough")for(let V of Y)w.push({key:{status:"valid",value:V},value:{status:"valid",value:G.data[V]}});else if(z==="strict"){if(Y.length>0)M(G,{code:B.unrecognized_keys,keys:Y}),X.dirty()}else if(z==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let z=this._def.catchall;for(let V of Y){let U=G.data[V];w.push({key:{status:"valid",value:V},value:z._parse(new P(G,U,G.path,V)),alwaysSet:V in G.data})}}if(G.common.async)return Promise.resolve().then(async()=>{let z=[];for(let V of w){let U=await V.key,S=await V.value;z.push({key:U,value:S,alwaysSet:V.alwaysSet})}return z}).then((z)=>{return N.mergeObjectSync(X,z)});else return N.mergeObjectSync(X,w)}get shape(){return this._def.shape()}strict($){return O.errToObj,new R({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(W,X)=>{var G,Q,J,Y;let w=(J=(Q=(G=this._def).errorMap)===null||Q===void 0?void 0:Q.call(G,W,X).message)!==null&&J!==void 0?J:X.defaultError;if(W.code==="unrecognized_keys")return{message:(Y=O.errToObj($).message)!==null&&Y!==void 0?Y:w};return{message:w}}}:{}})}strip(){return new R({...this._def,unknownKeys:"strip"})}passthrough(){return new R({...this._def,unknownKeys:"passthrough"})}extend($){return new R({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new R({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:j.ZodObject})}setKey($,W){return this.augment({[$]:W})}catchall($){return new R({...this._def,catchall:$})}pick($){let W={};return F.objectKeys($).forEach((X)=>{if($[X]&&this.shape[X])W[X]=this.shape[X]}),new R({...this._def,shape:()=>W})}omit($){let W={};return F.objectKeys(this.shape).forEach((X)=>{if(!$[X])W[X]=this.shape[X]}),new R({...this._def,shape:()=>W})}deepPartial(){return W0(this)}partial($){let W={};return F.objectKeys(this.shape).forEach((X)=>{let G=this.shape[X];if($&&!$[X])W[X]=G;else W[X]=G.optional()}),new R({...this._def,shape:()=>W})}required($){let W={};return F.objectKeys(this.shape).forEach((X)=>{if($&&!$[X])W[X]=this.shape[X];else{let Q=this.shape[X];while(Q instanceof I)Q=Q._def.innerType;W[X]=Q}}),new R({...this._def,shape:()=>W})}keyof(){return L1(F.objectKeys(this.shape))}}R.create=($,W)=>{return new R({shape:()=>$,unknownKeys:"strip",catchall:x.create(),typeName:j.ZodObject,...A(W)})};R.strictCreate=($,W)=>{return new R({shape:()=>$,unknownKeys:"strict",catchall:x.create(),typeName:j.ZodObject,...A(W)})};R.lazycreate=($,W)=>{return new R({shape:$,unknownKeys:"strip",catchall:x.create(),typeName:j.ZodObject,...A(W)})};class w0 extends D{_parse($){let{ctx:W}=this._processInputParams($),X=this._def.options;function G(Q){for(let Y of Q)if(Y.result.status==="valid")return Y.result;for(let Y of Q)if(Y.result.status==="dirty")return W.common.issues.push(...Y.ctx.common.issues),Y.result;let J=Q.map((Y)=>new E(Y.ctx.common.issues));return M(W,{code:B.invalid_union,unionErrors:J}),L}if(W.common.async)return Promise.all(X.map(async(Q)=>{let J={...W,common:{...W.common,issues:[]},parent:null};return{result:await Q._parseAsync({data:W.data,path:W.path,parent:J}),ctx:J}})).then(G);else{let Q=void 0,J=[];for(let w of X){let z={...W,common:{...W.common,issues:[]},parent:null},V=w._parseSync({data:W.data,path:W.path,parent:z});if(V.status==="valid")return V;else if(V.status==="dirty"&&!Q)Q={result:V,ctx:z};if(z.common.issues.length)J.push(z.common.issues)}if(Q)return W.common.issues.push(...Q.ctx.common.issues),Q.result;let Y=J.map((w)=>new E(w));return M(W,{code:B.invalid_union,unionErrors:Y}),L}}get options(){return this._def.options}}w0.create=($,W)=>{return new w0({options:$,typeName:j.ZodUnion,...A(W)})};var m=($)=>{if($ instanceof B0)return m($.schema);else if($ instanceof v)return m($.innerType());else if($ instanceof M0)return[$.value];else if($ instanceof i)return $.options;else if($ instanceof q0)return F.objectValues($.enum);else if($ instanceof O0)return m($._def.innerType);else if($ instanceof J0)return[void 0];else if($ instanceof Y0)return[null];else if($ instanceof I)return[void 0,...m($.unwrap())];else if($ instanceof c)return[null,...m($.unwrap())];else if($ instanceof P0)return m($.unwrap());else if($ instanceof j0)return m($.unwrap());else if($ instanceof V0)return m($._def.innerType);else return[]};class I0 extends D{_parse($){let{ctx:W}=this._processInputParams($);if(W.parsedType!==q.object)return M(W,{code:B.invalid_type,expected:q.object,received:W.parsedType}),L;let X=this.discriminator,G=W.data[X],Q=this.optionsMap.get(G);if(!Q)return M(W,{code:B.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[X]}),L;if(W.common.async)return Q._parseAsync({data:W.data,path:W.path,parent:W});else return Q._parseSync({data:W.data,path:W.path,parent:W})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,W,X){let G=new Map;for(let Q of W){let J=m(Q.shape[$]);if(!J.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let Y of J){if(G.has(Y))throw Error(`Discriminator property ${String($)} has duplicate value ${String(Y)}`);G.set(Y,Q)}}return new I0({typeName:j.ZodDiscriminatedUnion,discriminator:$,options:W,optionsMap:G,...A(X)})}}function r0($,W){let X=Z($),G=Z(W);if($===W)return{valid:!0,data:$};else if(X===q.object&&G===q.object){let Q=F.objectKeys(W),J=F.objectKeys($).filter((w)=>Q.indexOf(w)!==-1),Y={...$,...W};for(let w of J){let z=r0($[w],W[w]);if(!z.valid)return{valid:!1};Y[w]=z.data}return{valid:!0,data:Y}}else if(X===q.array&&G===q.array){if($.length!==W.length)return{valid:!1};let Q=[];for(let J=0;J<$.length;J++){let Y=$[J],w=W[J],z=r0(Y,w);if(!z.valid)return{valid:!1};Q.push(z.data)}return{valid:!0,data:Q}}else if(X===q.date&&G===q.date&&+$===+W)return{valid:!0,data:$};else return{valid:!1}}class z0 extends D{_parse($){let{status:W,ctx:X}=this._processInputParams($),G=(Q,J)=>{if(i0(Q)||i0(J))return L;let Y=r0(Q.value,J.value);if(!Y.valid)return M(X,{code:B.invalid_intersection_types}),L;if(d0(Q)||d0(J))W.dirty();return{status:W.value,value:Y.data}};if(X.common.async)return Promise.all([this._def.left._parseAsync({data:X.data,path:X.path,parent:X}),this._def.right._parseAsync({data:X.data,path:X.path,parent:X})]).then(([Q,J])=>G(Q,J));else return G(this._def.left._parseSync({data:X.data,path:X.path,parent:X}),this._def.right._parseSync({data:X.data,path:X.path,parent:X}))}}z0.create=($,W,X)=>{return new z0({left:$,right:W,typeName:j.ZodIntersection,...A(X)})};class y extends D{_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==q.array)return M(X,{code:B.invalid_type,expected:q.array,received:X.parsedType}),L;if(X.data.length<this._def.items.length)return M(X,{code:B.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),L;if(!this._def.rest&&X.data.length>this._def.items.length)M(X,{code:B.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),W.dirty();let Q=[...X.data].map((J,Y)=>{let w=this._def.items[Y]||this._def.rest;if(!w)return null;return w._parse(new P(X,J,X.path,Y))}).filter((J)=>!!J);if(X.common.async)return Promise.all(Q).then((J)=>{return N.mergeArray(W,J)});else return N.mergeArray(W,Q)}get items(){return this._def.items}rest($){return new y({...this._def,rest:$})}}y.create=($,W)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new y({items:$,typeName:j.ZodTuple,rest:null,...A(W)})};class S0 extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==q.object)return M(X,{code:B.invalid_type,expected:q.object,received:X.parsedType}),L;let G=[],Q=this._def.keyType,J=this._def.valueType;for(let Y in X.data)G.push({key:Q._parse(new P(X,Y,X.path,Y)),value:J._parse(new P(X,X.data[Y],X.path,Y)),alwaysSet:Y in X.data});if(X.common.async)return N.mergeObjectAsync(W,G);else return N.mergeObjectSync(W,G)}get element(){return this._def.valueType}static create($,W,X){if(W instanceof D)return new S0({keyType:$,valueType:W,typeName:j.ZodRecord,...A(X)});return new S0({keyType:C.create(),valueType:$,typeName:j.ZodRecord,...A(W)})}}class N0 extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==q.map)return M(X,{code:B.invalid_type,expected:q.map,received:X.parsedType}),L;let G=this._def.keyType,Q=this._def.valueType,J=[...X.data.entries()].map(([Y,w],z)=>{return{key:G._parse(new P(X,Y,X.path,[z,"key"])),value:Q._parse(new P(X,w,X.path,[z,"value"]))}});if(X.common.async){let Y=new Map;return Promise.resolve().then(async()=>{for(let w of J){let z=await w.key,V=await w.value;if(z.status==="aborted"||V.status==="aborted")return L;if(z.status==="dirty"||V.status==="dirty")W.dirty();Y.set(z.value,V.value)}return{status:W.value,value:Y}})}else{let Y=new Map;for(let w of J){let{key:z,value:V}=w;if(z.status==="aborted"||V.status==="aborted")return L;if(z.status==="dirty"||V.status==="dirty")W.dirty();Y.set(z.value,V.value)}return{status:W.value,value:Y}}}}N0.create=($,W,X)=>{return new N0({valueType:W,keyType:$,typeName:j.ZodMap,...A(X)})};class s extends D{_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==q.set)return M(X,{code:B.invalid_type,expected:q.set,received:X.parsedType}),L;let G=this._def;if(G.minSize!==null){if(X.data.size<G.minSize.value)M(X,{code:B.too_small,minimum:G.minSize.value,type:"set",inclusive:!0,exact:!1,message:G.minSize.message}),W.dirty()}if(G.maxSize!==null){if(X.data.size>G.maxSize.value)M(X,{code:B.too_big,maximum:G.maxSize.value,type:"set",inclusive:!0,exact:!1,message:G.maxSize.message}),W.dirty()}let Q=this._def.valueType;function J(w){let z=new Set;for(let V of w){if(V.status==="aborted")return L;if(V.status==="dirty")W.dirty();z.add(V.value)}return{status:W.value,value:z}}let Y=[...X.data.values()].map((w,z)=>Q._parse(new P(X,w,X.path,z)));if(X.common.async)return Promise.all(Y).then((w)=>J(w));else return J(Y)}min($,W){return new s({...this._def,minSize:{value:$,message:O.toString(W)}})}max($,W){return new s({...this._def,maxSize:{value:$,message:O.toString(W)}})}size($,W){return this.min($,W).max($,W)}nonempty($){return this.min(1,$)}}s.create=($,W)=>{return new s({valueType:$,minSize:null,maxSize:null,typeName:j.ZodSet,...A(W)})};class Q0 extends D{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:W}=this._processInputParams($);if(W.parsedType!==q.function)return M(W,{code:B.invalid_type,expected:q.function,received:W.parsedType}),L;function X(Y,w){return C0({data:Y,path:W.path,errorMaps:[W.common.contextualErrorMap,W.schemaErrorMap,f0(),G0].filter((z)=>!!z),issueData:{code:B.invalid_arguments,argumentsError:w}})}function G(Y,w){return C0({data:Y,path:W.path,errorMaps:[W.common.contextualErrorMap,W.schemaErrorMap,f0(),G0].filter((z)=>!!z),issueData:{code:B.invalid_return_type,returnTypeError:w}})}let Q={errorMap:W.common.contextualErrorMap},J=W.data;if(this._def.returns instanceof e){let Y=this;return _(async function(...w){let z=new E([]),V=await Y._def.args.parseAsync(w,Q).catch((d)=>{throw z.addIssue(X(w,d)),z}),U=await Reflect.apply(J,this,V);return await Y._def.returns._def.type.parseAsync(U,Q).catch((d)=>{throw z.addIssue(G(U,d)),z})})}else{let Y=this;return _(function(...w){let z=Y._def.args.safeParse(w,Q);if(!z.success)throw new E([X(w,z.error)]);let V=Reflect.apply(J,this,z.data),U=Y._def.returns.safeParse(V,Q);if(!U.success)throw new E([G(V,U.error)]);return U.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new Q0({...this._def,args:y.create($).rest(u.create())})}returns($){return new Q0({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,W,X){return new Q0({args:$?$:y.create([]).rest(u.create()),returns:W||u.create(),typeName:j.ZodFunction,...A(X)})}}class B0 extends D{get schema(){return this._def.getter()}_parse($){let{ctx:W}=this._processInputParams($);return this._def.getter()._parse({data:W.data,path:W.path,parent:W})}}B0.create=($,W)=>{return new B0({getter:$,typeName:j.ZodLazy,...A(W)})};class M0 extends D{_parse($){if($.data!==this._def.value){let W=this._getOrReturnCtx($);return M(W,{received:W.data,code:B.invalid_literal,expected:this._def.value}),L}return{status:"valid",value:$.data}}get value(){return this._def.value}}M0.create=($,W)=>{return new M0({value:$,typeName:j.ZodLiteral,...A(W)})};function L1($,W){return new i({values:$,typeName:j.ZodEnum,...A(W)})}class i extends D{constructor(){super(...arguments);D0.set(this,void 0)}_parse($){if(typeof $.data!=="string"){let W=this._getOrReturnCtx($),X=this._def.values;return M(W,{expected:F.joinValues(X),received:W.parsedType,code:B.invalid_type}),L}if(!k0(this,D0,"f"))q1(this,D0,new Set(this._def.values),"f");if(!k0(this,D0,"f").has($.data)){let W=this._getOrReturnCtx($),X=this._def.values;return M(W,{received:W.data,code:B.invalid_enum_value,options:X}),L}return _($.data)}get options(){return this._def.values}get enum(){let $={};for(let W of this._def.values)$[W]=W;return $}get Values(){let $={};for(let W of this._def.values)$[W]=W;return $}get Enum(){let $={};for(let W of this._def.values)$[W]=W;return $}extract($,W=this._def){return i.create($,{...this._def,...W})}exclude($,W=this._def){return i.create(this.options.filter((X)=>!$.includes(X)),{...this._def,...W})}}D0=new WeakMap;i.create=L1;class q0 extends D{constructor(){super(...arguments);U0.set(this,void 0)}_parse($){let W=F.getValidEnumValues(this._def.values),X=this._getOrReturnCtx($);if(X.parsedType!==q.string&&X.parsedType!==q.number){let G=F.objectValues(W);return M(X,{expected:F.joinValues(G),received:X.parsedType,code:B.invalid_type}),L}if(!k0(this,U0,"f"))q1(this,U0,new Set(F.getValidEnumValues(this._def.values)),"f");if(!k0(this,U0,"f").has($.data)){let G=F.objectValues(W);return M(X,{received:X.data,code:B.invalid_enum_value,options:G}),L}return _($.data)}get enum(){return this._def.values}}U0=new WeakMap;q0.create=($,W)=>{return new q0({values:$,typeName:j.ZodNativeEnum,...A(W)})};class e extends D{unwrap(){return this._def.type}_parse($){let{ctx:W}=this._processInputParams($);if(W.parsedType!==q.promise&&W.common.async===!1)return M(W,{code:B.invalid_type,expected:q.promise,received:W.parsedType}),L;let X=W.parsedType===q.promise?W.data:Promise.resolve(W.data);return _(X.then((G)=>{return this._def.type.parseAsync(G,{path:W.path,errorMap:W.common.contextualErrorMap})}))}}e.create=($,W)=>{return new e({type:$,typeName:j.ZodPromise,...A(W)})};class v extends D{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===j.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:W,ctx:X}=this._processInputParams($),G=this._def.effect||null,Q={addIssue:(J)=>{if(M(X,J),J.fatal)W.abort();else W.dirty()},get path(){return X.path}};if(Q.addIssue=Q.addIssue.bind(Q),G.type==="preprocess"){let J=G.transform(X.data,Q);if(X.common.async)return Promise.resolve(J).then(async(Y)=>{if(W.value==="aborted")return L;let w=await this._def.schema._parseAsync({data:Y,path:X.path,parent:X});if(w.status==="aborted")return L;if(w.status==="dirty")return X0(w.value);if(W.value==="dirty")return X0(w.value);return w});else{if(W.value==="aborted")return L;let Y=this._def.schema._parseSync({data:J,path:X.path,parent:X});if(Y.status==="aborted")return L;if(Y.status==="dirty")return X0(Y.value);if(W.value==="dirty")return X0(Y.value);return Y}}if(G.type==="refinement"){let J=(Y)=>{let w=G.refinement(Y,Q);if(X.common.async)return Promise.resolve(w);if(w instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return Y};if(X.common.async===!1){let Y=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(Y.status==="aborted")return L;if(Y.status==="dirty")W.dirty();return J(Y.value),{status:W.value,value:Y.value}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((Y)=>{if(Y.status==="aborted")return L;if(Y.status==="dirty")W.dirty();return J(Y.value).then(()=>{return{status:W.value,value:Y.value}})})}if(G.type==="transform")if(X.common.async===!1){let J=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(!o(J))return J;let Y=G.transform(J.value,Q);if(Y instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:W.value,value:Y}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((J)=>{if(!o(J))return J;return Promise.resolve(G.transform(J.value,Q)).then((Y)=>({status:W.value,value:Y}))});F.assertNever(G)}}v.create=($,W,X)=>{return new v({schema:$,typeName:j.ZodEffects,effect:W,...A(X)})};v.createWithPreprocess=($,W,X)=>{return new v({schema:W,effect:{type:"preprocess",transform:$},typeName:j.ZodEffects,...A(X)})};class I extends D{_parse($){if(this._getType($)===q.undefined)return _(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}I.create=($,W)=>{return new I({innerType:$,typeName:j.ZodOptional,...A(W)})};class c extends D{_parse($){if(this._getType($)===q.null)return _(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}c.create=($,W)=>{return new c({innerType:$,typeName:j.ZodNullable,...A(W)})};class O0 extends D{_parse($){let{ctx:W}=this._processInputParams($),X=W.data;if(W.parsedType===q.undefined)X=this._def.defaultValue();return this._def.innerType._parse({data:X,path:W.path,parent:W})}removeDefault(){return this._def.innerType}}O0.create=($,W)=>{return new O0({innerType:$,typeName:j.ZodDefault,defaultValue:typeof W.default==="function"?W.default:()=>W.default,...A(W)})};class V0 extends D{_parse($){let{ctx:W}=this._processInputParams($),X={...W,common:{...W.common,issues:[]}},G=this._def.innerType._parse({data:X.data,path:X.path,parent:{...X}});if(F0(G))return G.then((Q)=>{return{status:"valid",value:Q.status==="valid"?Q.value:this._def.catchValue({get error(){return new E(X.common.issues)},input:X.data})}});else return{status:"valid",value:G.status==="valid"?G.value:this._def.catchValue({get error(){return new E(X.common.issues)},input:X.data})}}removeCatch(){return this._def.innerType}}V0.create=($,W)=>{return new V0({innerType:$,typeName:j.ZodCatch,catchValue:typeof W.catch==="function"?W.catch:()=>W.catch,...A(W)})};class _0 extends D{_parse($){if(this._getType($)!==q.nan){let X=this._getOrReturnCtx($);return M(X,{code:B.invalid_type,expected:q.nan,received:X.parsedType}),L}return{status:"valid",value:$.data}}}_0.create=($)=>{return new _0({typeName:j.ZodNaN,...A($)})};var L4=Symbol("zod_brand");class P0 extends D{_parse($){let{ctx:W}=this._processInputParams($),X=W.data;return this._def.type._parse({data:X,path:W.path,parent:W})}unwrap(){return this._def.type}}class E0 extends D{_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.common.async)return(async()=>{let Q=await this._def.in._parseAsync({data:X.data,path:X.path,parent:X});if(Q.status==="aborted")return L;if(Q.status==="dirty")return W.dirty(),X0(Q.value);else return this._def.out._parseAsync({data:Q.value,path:X.path,parent:X})})();else{let G=this._def.in._parseSync({data:X.data,path:X.path,parent:X});if(G.status==="aborted")return L;if(G.status==="dirty")return W.dirty(),{status:"dirty",value:G.value};else return this._def.out._parseSync({data:G.value,path:X.path,parent:X})}}static create($,W){return new E0({in:$,out:W,typeName:j.ZodPipeline})}}class j0 extends D{_parse($){let W=this._def.innerType._parse($),X=(G)=>{if(o(G))G.value=Object.freeze(G.value);return G};return F0(W)?W.then((G)=>X(G)):X(W)}unwrap(){return this._def.innerType}}j0.create=($,W)=>{return new j0({innerType:$,typeName:j.ZodReadonly,...A(W)})};function A1($,W={},X){if($)return t.create().superRefine((G,Q)=>{var J,Y;if(!$(G)){let w=typeof W==="function"?W(G):typeof W==="string"?{message:W}:W,z=(Y=(J=w.fatal)!==null&&J!==void 0?J:X)!==null&&Y!==void 0?Y:!0,V=typeof w==="string"?{message:w}:w;Q.addIssue({code:"custom",...V,fatal:z})}});return t.create()}var A4={object:R.lazycreate},j;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(j||(j={}));var D4=($,W={message:`Input not instance of ${$.name}`})=>A1((X)=>X instanceof $,W),D1=C.create,U1=p.create,U4=_0.create,F4=n.create,F1=H0.create,R4=a.create,K4=R0.create,S4=J0.create,N4=Y0.create,_4=t.create,E4=u.create,b4=x.create,v4=K0.create,f4=k.create,C4=R.create,k4=R.strictCreate,I4=w0.create,P4=I0.create,g4=z0.create,h4=y.create,T4=S0.create,x4=N0.create,y4=s.create,l4=Q0.create,m4=B0.create,Z4=M0.create,c4=i.create,u4=q0.create,p4=e.create,B1=v.create,n4=I.create,i4=c.create,d4=v.createWithPreprocess,r4=E0.create,o4=()=>D1().optional(),a4=()=>U1().optional(),t4=()=>F1().optional(),s4={string:($)=>C.create({...$,coerce:!0}),number:($)=>p.create({...$,coerce:!0}),boolean:($)=>H0.create({...$,coerce:!0}),bigint:($)=>n.create({...$,coerce:!0}),date:($)=>a.create({...$,coerce:!0})},e4=L,H=Object.freeze({__proto__:null,defaultErrorMap:G0,setErrorMap:d1,getErrorMap:f0,makeIssue:C0,EMPTY_PATH:r1,addIssueToContext:M,ParseStatus:N,INVALID:L,DIRTY:X0,OK:_,isAborted:i0,isDirty:d0,isValid:o,isAsync:F0,get util(){return F},get objectUtil(){return n0},ZodParsedType:q,getParsedType:Z,ZodType:D,datetimeRegex:j1,ZodString:C,ZodNumber:p,ZodBigInt:n,ZodBoolean:H0,ZodDate:a,ZodSymbol:R0,ZodUndefined:J0,ZodNull:Y0,ZodAny:t,ZodUnknown:u,ZodNever:x,ZodVoid:K0,ZodArray:k,ZodObject:R,ZodUnion:w0,ZodDiscriminatedUnion:I0,ZodIntersection:z0,ZodTuple:y,ZodRecord:S0,ZodMap:N0,ZodSet:s,ZodFunction:Q0,ZodLazy:B0,ZodLiteral:M0,ZodEnum:i,ZodNativeEnum:q0,ZodPromise:e,ZodEffects:v,ZodTransformer:v,ZodOptional:I,ZodNullable:c,ZodDefault:O0,ZodCatch:V0,ZodNaN:_0,BRAND:L4,ZodBranded:P0,ZodPipeline:E0,ZodReadonly:j0,custom:A1,Schema:D,ZodSchema:D,late:A4,get ZodFirstPartyTypeKind(){return j},coerce:s4,any:_4,array:f4,bigint:F4,boolean:F1,date:R4,discriminatedUnion:P4,effect:B1,enum:c4,function:l4,instanceof:D4,intersection:g4,lazy:m4,literal:Z4,map:x4,nan:U4,nativeEnum:u4,never:b4,null:N4,nullable:i4,number:U1,object:C4,oboolean:t4,onumber:a4,optional:n4,ostring:o4,pipeline:r4,preprocess:d4,promise:p4,record:T4,set:y4,strictObject:k4,string:D1,symbol:K4,transformer:B1,tuple:h4,undefined:S4,union:I4,unknown:E4,void:v4,NEVER:e4,ZodIssueCode:B,quotelessJson:i1,ZodError:E});var o0="2024-11-05",R1=[o0,"2024-10-07"],g0="2.0",K1=H.union([H.string(),H.number().int()]),S1=H.string(),g=H.object({_meta:H.optional(H.object({progressToken:H.optional(K1)}).passthrough())}).passthrough(),b=H.object({method:H.string(),params:H.optional(g)}),b0=H.object({_meta:H.optional(H.object({}).passthrough())}).passthrough(),l=H.object({method:H.string(),params:H.optional(b0)}),h=H.object({_meta:H.optional(H.object({}).passthrough())}).passthrough(),h0=H.union([H.string(),H.number().int()]),$6=H.object({jsonrpc:H.literal(g0),id:h0}).merge(b).strict(),W6=H.object({jsonrpc:H.literal(g0)}).merge(l).strict(),X6=H.object({jsonrpc:H.literal(g0),id:h0,result:h}).strict(),$0;(function($){$[$.ConnectionClosed=-1]="ConnectionClosed",$[$.RequestTimeout=-2]="RequestTimeout",$[$.ParseError=-32700]="ParseError",$[$.InvalidRequest=-32600]="InvalidRequest",$[$.MethodNotFound=-32601]="MethodNotFound",$[$.InvalidParams=-32602]="InvalidParams",$[$.InternalError=-32603]="InternalError"})($0||($0={}));var Q6=H.object({jsonrpc:H.literal(g0),id:h0,error:H.object({code:H.number().int(),message:H.string(),data:H.optional(H.unknown())})}).strict(),N1=H.union([$6,W6,X6,Q6]),T0=h.strict(),x0=l.extend({method:H.literal("notifications/cancelled"),params:b0.extend({requestId:h0,reason:H.string().optional()})}),_1=H.object({name:H.string(),version:H.string()}).passthrough(),G6=H.object({experimental:H.optional(H.object({}).passthrough()),sampling:H.optional(H.object({}).passthrough()),roots:H.optional(H.object({listChanged:H.optional(H.boolean())}).passthrough())}).passthrough(),a0=b.extend({method:H.literal("initialize"),params:g.extend({protocolVersion:H.string(),capabilities:G6,clientInfo:_1})}),H6=H.object({experimental:H.optional(H.object({}).passthrough()),logging:H.optional(H.object({}).passthrough()),prompts:H.optional(H.object({listChanged:H.optional(H.boolean())}).passthrough()),resources:H.optional(H.object({subscribe:H.optional(H.boolean()),listChanged:H.optional(H.boolean())}).passthrough()),tools:H.optional(H.object({listChanged:H.optional(H.boolean())}).passthrough())}).passthrough(),J6=h.extend({protocolVersion:H.string(),capabilities:H6,serverInfo:_1}),t0=l.extend({method:H.literal("notifications/initialized")}),y0=b.extend({method:H.literal("ping")}),Y6=H.object({progress:H.number(),total:H.optional(H.number())}).passthrough(),l0=l.extend({method:H.literal("notifications/progress"),params:b0.merge(Y6).extend({progressToken:K1})}),m0=b.extend({params:g.extend({cursor:H.optional(S1)}).optional()}),Z0=h.extend({nextCursor:H.optional(S1)}),E1=H.object({uri:H.string(),mimeType:H.optional(H.string())}).passthrough(),b1=E1.extend({text:H.string()}),v1=E1.extend({blob:H.string().base64()}),w6=H.object({uri:H.string(),name:H.string(),description:H.optional(H.string()),mimeType:H.optional(H.string())}).passthrough(),z6=H.object({uriTemplate:H.string(),name:H.string(),description:H.optional(H.string()),mimeType:H.optional(H.string())}).passthrough(),B6=m0.extend({method:H.literal("resources/list")}),M6=Z0.extend({resources:H.array(w6)}),q6=m0.extend({method:H.literal("resources/templates/list")}),O6=Z0.extend({resourceTemplates:H.array(z6)}),V6=b.extend({method:H.literal("resources/read"),params:g.extend({uri:H.string()})}),j6=h.extend({contents:H.array(H.union([b1,v1]))}),L6=l.extend({method:H.literal("notifications/resources/list_changed")}),A6=b.extend({method:H.literal("resources/subscribe"),params:g.extend({uri:H.string()})}),D6=b.extend({method:H.literal("resources/unsubscribe"),params:g.extend({uri:H.string()})}),U6=l.extend({method:H.literal("notifications/resources/updated"),params:b0.extend({uri:H.string()})}),F6=H.object({name:H.string(),description:H.optional(H.string()),required:H.optional(H.boolean())}).passthrough(),R6=H.object({name:H.string(),description:H.optional(H.string()),arguments:H.optional(H.array(F6))}).passthrough(),K6=m0.extend({method:H.literal("prompts/list")}),S6=Z0.extend({prompts:H.array(R6)}),N6=b.extend({method:H.literal("prompts/get"),params:g.extend({name:H.string(),arguments:H.optional(H.record(H.string()))})}),c0=H.object({type:H.literal("text"),text:H.string()}).passthrough(),u0=H.object({type:H.literal("image"),data:H.string().base64(),mimeType:H.string()}).passthrough(),f1=H.object({type:H.literal("resource"),resource:H.union([b1,v1])}).passthrough(),_6=H.object({role:H.enum(["user","assistant"]),content:H.union([c0,u0,f1])}).passthrough(),E6=h.extend({description:H.optional(H.string()),messages:H.array(_6)}),b6=l.extend({method:H.literal("notifications/prompts/list_changed")}),v6=H.object({name:H.string(),description:H.optional(H.string()),inputSchema:H.object({type:H.literal("object"),properties:H.optional(H.object({}).passthrough())}).passthrough()}).passthrough(),s0=m0.extend({method:H.literal("tools/list")}),f6=Z0.extend({tools:H.array(v6)}),C1=h.extend({content:H.array(H.union([c0,u0,f1])),isError:H.boolean().default(!1).optional()}),Q8=C1.or(h.extend({toolResult:H.unknown()})),e0=b.extend({method:H.literal("tools/call"),params:g.extend({name:H.string(),arguments:H.optional(H.record(H.unknown()))})}),C6=l.extend({method:H.literal("notifications/tools/list_changed")}),k1=H.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),k6=b.extend({method:H.literal("logging/setLevel"),params:g.extend({level:k1})}),I6=l.extend({method:H.literal("notifications/message"),params:b0.extend({level:k1,logger:H.optional(H.string()),data:H.unknown()})}),P6=H.object({name:H.string().optional()}).passthrough(),g6=H.object({hints:H.optional(H.array(P6)),costPriority:H.optional(H.number().min(0).max(1)),speedPriority:H.optional(H.number().min(0).max(1)),intelligencePriority:H.optional(H.number().min(0).max(1))}).passthrough(),h6=H.object({role:H.enum(["user","assistant"]),content:H.union([c0,u0])}).passthrough(),T6=b.extend({method:H.literal("sampling/createMessage"),params:g.extend({messages:H.array(h6),systemPrompt:H.optional(H.string()),includeContext:H.optional(H.enum(["none","thisServer","allServers"])),temperature:H.optional(H.number()),maxTokens:H.number().int(),stopSequences:H.optional(H.array(H.string())),metadata:H.optional(H.object({}).passthrough()),modelPreferences:H.optional(g6)})}),$1=h.extend({model:H.string(),stopReason:H.optional(H.enum(["endTurn","stopSequence","maxTokens"]).or(H.string())),role:H.enum(["user","assistant"]),content:H.discriminatedUnion("type",[c0,u0])}),x6=H.object({type:H.literal("ref/resource"),uri:H.string()}).passthrough(),y6=H.object({type:H.literal("ref/prompt"),name:H.string()}).passthrough(),l6=b.extend({method:H.literal("completion/complete"),params:g.extend({ref:H.union([y6,x6]),argument:H.object({name:H.string(),value:H.string()}).passthrough()})}),m6=h.extend({completion:H.object({values:H.array(H.string()).max(100),total:H.optional(H.number().int()),hasMore:H.optional(H.boolean())}).passthrough()}),Z6=H.object({uri:H.string().startsWith("file://"),name:H.optional(H.string())}).passthrough(),c6=b.extend({method:H.literal("roots/list")}),W1=h.extend({roots:H.array(Z6)}),u6=l.extend({method:H.literal("notifications/roots/list_changed")}),G8=H.union([y0,a0,l6,k6,N6,K6,B6,q6,V6,A6,D6,e0,s0]),H8=H.union([x0,l0,t0,u6]),J8=H.union([T0,$1,W1]),Y8=H.union([y0,T6,c6]),w8=H.union([x0,l0,I6,U6,L6,C6,b6]),z8=H.union([T0,J6,m6,E6,S6,M6,O6,j6,C1,f6]);class v0 extends Error{constructor($,W,X){super(`MCP error ${$}: ${W}`);this.code=$,this.data=X}}var p6=60000;class X1{constructor($){this._options=$,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this.setNotificationHandler(x0,(W)=>{let X=this._requestHandlerAbortControllers.get(W.params.requestId);X===null||X===void 0||X.abort(W.params.reason)}),this.setNotificationHandler(l0,(W)=>{this._onprogress(W)}),this.setRequestHandler(y0,(W)=>({}))}async connect($){this._transport=$,this._transport.onclose=()=>{this._onclose()},this._transport.onerror=(W)=>{this._onerror(W)},this._transport.onmessage=(W)=>{if(!("method"in W))this._onresponse(W);else if("id"in W)this._onrequest(W);else this._onnotification(W)},await this._transport.start()}_onclose(){var $;let W=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,($=this.onclose)===null||$===void 0||$.call(this);let X=new v0($0.ConnectionClosed,"Connection closed");for(let G of W.values())G(X)}_onerror($){var W;(W=this.onerror)===null||W===void 0||W.call(this,$)}_onnotification($){var W;let X=(W=this._notificationHandlers.get($.method))!==null&&W!==void 0?W:this.fallbackNotificationHandler;if(X===void 0)return;Promise.resolve().then(()=>X($)).catch((G)=>this._onerror(Error(`Uncaught error in notification handler: ${G}`)))}_onrequest($){var W,X;let G=(W=this._requestHandlers.get($.method))!==null&&W!==void 0?W:this.fallbackRequestHandler;if(G===void 0){(X=this._transport)===null||X===void 0||X.send({jsonrpc:"2.0",id:$.id,error:{code:$0.MethodNotFound,message:"Method not found"}}).catch((J)=>this._onerror(Error(`Failed to send an error response: ${J}`)));return}let Q=new AbortController;this._requestHandlerAbortControllers.set($.id,Q),Promise.resolve().then(()=>G($,{signal:Q.signal})).then((J)=>{var Y;if(Q.signal.aborted)return;return(Y=this._transport)===null||Y===void 0?void 0:Y.send({result:J,jsonrpc:"2.0",id:$.id})},(J)=>{var Y,w;if(Q.signal.aborted)return;return(Y=this._transport)===null||Y===void 0?void 0:Y.send({jsonrpc:"2.0",id:$.id,error:{code:Number.isSafeInteger(J.code)?J.code:$0.InternalError,message:(w=J.message)!==null&&w!==void 0?w:"Internal error"}})}).catch((J)=>this._onerror(Error(`Failed to send response: ${J}`))).finally(()=>{this._requestHandlerAbortControllers.delete($.id)})}_onprogress($){let{progressToken:W,...X}=$.params,G=this._progressHandlers.get(Number(W));if(G===void 0){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify($)}`));return}G(X)}_onresponse($){let W=$.id,X=this._responseHandlers.get(Number(W));if(X===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify($)}`));return}if(this._responseHandlers.delete(Number(W)),this._progressHandlers.delete(Number(W)),"result"in $)X($);else{let G=new v0($.error.code,$.error.message,$.error.data);X(G)}}get transport(){return this._transport}async close(){var $;await(($=this._transport)===null||$===void 0?void 0:$.close())}request($,W,X){return new Promise((G,Q)=>{var J,Y,w,z;if(!this._transport){Q(Error("Not connected"));return}if(((J=this._options)===null||J===void 0?void 0:J.enforceStrictCapabilities)===!0)this.assertCapabilityForMethod($.method);(Y=X===null||X===void 0?void 0:X.signal)===null||Y===void 0||Y.throwIfAborted();let V=this._requestMessageId++,U={...$,jsonrpc:"2.0",id:V};if(X===null||X===void 0?void 0:X.onprogress)this._progressHandlers.set(V,X.onprogress),U.params={...$.params,_meta:{progressToken:V}};let S=void 0;this._responseHandlers.set(V,(K)=>{var f;if(S!==void 0)clearTimeout(S);if((f=X===null||X===void 0?void 0:X.signal)===null||f===void 0?void 0:f.aborted)return;if(K instanceof Error)return Q(K);try{let r=W.parse(K.result);G(r)}catch(r){Q(r)}});let d=(K)=>{var f;this._responseHandlers.delete(V),this._progressHandlers.delete(V),(f=this._transport)===null||f===void 0||f.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:V,reason:String(K)}}).catch((r)=>this._onerror(Error(`Failed to send cancellation: ${r}`))),Q(K)};(w=X===null||X===void 0?void 0:X.signal)===null||w===void 0||w.addEventListener("abort",()=>{var K;if(S!==void 0)clearTimeout(S);d((K=X===null||X===void 0?void 0:X.signal)===null||K===void 0?void 0:K.reason)});let A0=(z=X===null||X===void 0?void 0:X.timeout)!==null&&z!==void 0?z:p6;S=setTimeout(()=>d(new v0($0.RequestTimeout,"Request timed out",{timeout:A0})),A0),this._transport.send(U).catch((K)=>{if(S!==void 0)clearTimeout(S);Q(K)})})}async notification($){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability($.method);let W={...$,jsonrpc:"2.0"};await this._transport.send(W)}setRequestHandler($,W){let X=$.shape.method.value;this.assertRequestHandlerCapability(X),this._requestHandlers.set(X,(G,Q)=>Promise.resolve(W($.parse(G),Q)))}removeRequestHandler($){this._requestHandlers.delete($)}setNotificationHandler($,W){this._notificationHandlers.set($.shape.method.value,(X)=>Promise.resolve(W($.parse(X))))}removeNotificationHandler($){this._notificationHandlers.delete($)}}class Q1 extends X1{constructor($,W){super(W);this._serverInfo=$,this._capabilities=W.capabilities,this.setRequestHandler(a0,(X)=>this._oninitialize(X)),this.setNotificationHandler(t0,()=>{var X;return(X=this.oninitialized)===null||X===void 0?void 0:X.call(this)})}assertCapabilityForMethod($){var W,X;switch($){case"sampling/createMessage":if(!((W=this._clientCapabilities)===null||W===void 0?void 0:W.sampling))throw Error(`Client does not support sampling (required for ${$})`);break;case"roots/list":if(!((X=this._clientCapabilities)===null||X===void 0?void 0:X.roots))throw Error(`Client does not support listing roots (required for ${$})`);break;case"ping":break}}assertNotificationCapability($){switch($){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${$})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${$})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${$})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${$})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability($){switch($){case"sampling/createMessage":if(!this._capabilities.sampling)throw Error(`Server does not support sampling (required for ${$})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${$})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${$})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${$})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${$})`);break;case"ping":case"initialize":break}}async _oninitialize($){let W=$.params.protocolVersion;return this._clientCapabilities=$.params.capabilities,this._clientVersion=$.params.clientInfo,{protocolVersion:R1.includes(W)?W:o0,capabilities:this.getCapabilities(),serverInfo:this._serverInfo}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},T0)}async createMessage($,W){return this.request({method:"sampling/createMessage",params:$},$1,W)}async listRoots($,W){return this.request({method:"roots/list",params:$},W1,W)}async sendLoggingMessage($){return this.notification({method:"notifications/message",params:$})}async sendResourceUpdated($){return this.notification({method:"notifications/resources/updated",params:$})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}import P1 from"process";class G1{append($){this._buffer=this._buffer?Buffer.concat([this._buffer,$]):$}readMessage(){if(!this._buffer)return null;let $=this._buffer.indexOf(`
|
|
3
|
-
`);if($===-1)return null;let
|
|
4
|
-
`}class H1{constructor($=P1.stdin,W=P1.stdout){this._stdin=$,this._stdout=W,this._readBuffer=new G1,this._started=!1,this._ondata=(X)=>{this._readBuffer.append(X),this.processReadBuffer()},this._onerror=(X)=>{var G;(G=this.onerror)===null||G===void 0||G.call(this,X)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){var $,W;while(!0)try{let X=this._readBuffer.readMessage();if(X===null)break;($=this.onmessage)===null||$===void 0||$.call(this,X)}catch(X){(W=this.onerror)===null||W===void 0||W.call(this,X)}}async close(){var $;this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._readBuffer.clear(),($=this.onclose)===null||$===void 0||$.call(this)}send($){return new Promise((W)=>{let X=I1($);if(this._stdout.write(X))W();else this._stdout.once("drain",W)})}}var d6=await Promise.resolve().then(() => p1(g1(),1)),h1=d6.version;async function T1($){let W=new Q1({name:"typescape",version:h1},{capabilities:{tools:{}}});W.setRequestHandler(s0,async()=>{return{tools:$.getTools().map((Q)=>({name:Q.name,description:Q.description,inputSchema:Q.inputSchema}))}}),W.setRequestHandler(e0,async(G)=>{let{name:Q,arguments:J}=G.params,Y=$.getHandler(Q);if(!Y)return{content:[{type:"text",text:`Unknown tool: ${Q}`}],isError:!0};try{let w=await Y(J||{});return{content:w.content.map((z)=>({type:z.type,text:z.text})),isError:w.isError}}catch(w){return{content:[{type:"text",text:`Error: ${w instanceof Error?w.message:String(w)}`}],isError:!0}}});let X=new H1;await W.connect(X),console.error(`Typescape MCP server v${h1} started`)}var r6={type:"object",properties:{repo_id:{type:"string",description:"Repository identifier"},git_sha:{type:"string",description:"Concrete 40-hex Git commit SHA (agent must resolve; no symbolic refs)"},file_path:{type:"string",description:"Path to Markdown file within the repo"},title:{type:"string",description:"Session title (optional)"},participants:{type:"array",items:{type:"object",properties:{email:{type:"string"},roles:{type:"array",items:{type:"string",enum:["reviewer","approver"]}}},required:["email","roles"]},description:"Participants to invite (optional)"},idempotency_key:{type:"string",description:"Idempotency key for safe retries (optional)"},expected_version:{type:"string",description:"Expected version for optimistic concurrency (If-Match header, optional)"}},required:["repo_id","git_sha","file_path"]},o6={type:"object",properties:{session_id:{type:"string",description:"Session ID to export (e.g., sess_01HXYZ...)"},schema:{type:"string",default:"v1",description:"Export schema version (default: v1)"},expected_version:{type:"string",description:"Expected version for optimistic concurrency (If-Match header, optional)"}},required:["session_id"]};function x1($,W){return{content:[{type:"text",text:JSON.stringify({...$,request_id:W},null,2)}]}}function L0($){let W=$.status===0||$.status>=500||$.status===429;return{content:[{type:"text",text:JSON.stringify({error:{code:$.code,message:$.message,retryable:W,request_id:$.requestId}},null,2)}],isError:!0}}function y1($,W){let X={name:"typescape_create_session",description:"Create a new Typescape review session for a Markdown file. Returns the session ID and any invitations sent. The agent must provide a concrete 40-hex Git SHA; no symbolic ref resolution is performed.",inputSchema:r6};$.register(X,async(Q)=>{let J=Q;if(!J.repo_id)return L0(new T(400,"missing_param","Missing required parameter: repo_id","local"));if(!J.git_sha)return L0(new T(400,"missing_param","Missing required parameter: git_sha","local"));if(!J.file_path)return L0(new T(400,"missing_param","Missing required parameter: file_path","local"));let Y={source:{source_type:"git",repo_id:J.repo_id,git_sha:J.git_sha,file_path:J.file_path}};if(J.title!==void 0)Y.title=J.title;if(J.participants!==void 0&&J.participants.length>0)Y.participants=J.participants;let w={};if(J.idempotency_key)w["Idempotency-Key"]=J.idempotency_key;if(J.expected_version)w["If-Match"]=J.expected_version;try{let z=await W.post("/sessions",{body:Y,headers:w});return x1({session:z.body.session,invitations:z.body.invitations??[]},z.requestId)}catch(z){if(z instanceof T)return L0(z);throw z}});let G={name:"typescape_export_feedback",description:"Export all feedback from a Typescape review session as structured JSON. Returns the full export document including threads, comments, and anchors.",inputSchema:o6};$.register(G,async(Q)=>{let J=Q;if(!J.session_id)return L0(new T(400,"missing_param","Missing required parameter: session_id","local"));let Y={schema:J.schema||"v1"},w={};if(J.expected_version)w["If-Match"]=J.expected_version;try{let z=await W.get(`/sessions/${J.session_id}/export`,{query:Y,headers:w});return x1(z.body,z.requestId)}catch(z){if(z instanceof T)return L0(z);throw z}})}var l1={TYPESCAPE_API_TOKEN:"Operator API token for authenticating with the Typescape API",TYPESCAPE_BASE_URL:"Base URL of the Typescape API server (e.g., https://review.example.com)"};function a6(){let $=process.env.TYPESCAPE_API_TOKEN,W=process.env.TYPESCAPE_BASE_URL,X=[];if(!$)X.push(`TYPESCAPE_API_TOKEN: ${l1.TYPESCAPE_API_TOKEN}`);if(!W)X.push(`TYPESCAPE_BASE_URL: ${l1.TYPESCAPE_BASE_URL}`);if(X.length>0){console.error("Error: Missing required environment variables:");for(let G of X)console.error(` - ${G}`);process.exit(1)}return{apiToken:$,baseUrl:W}}async function t6(){let{apiToken:$,baseUrl:W}=a6(),X=w1(W,$),G=Y1();y1(G,X),await T1(G)}t6().catch(($)=>{console.error("Fatal error:",$ instanceof Error?$.message:String($)),process.exit(1)});
|
|
2
|
+
var i1=Object.create;var{getPrototypeOf:a1,defineProperty:j1,getOwnPropertyNames:o1}=Object;var t1=Object.prototype.hasOwnProperty;var s1=($,Q,X)=>{X=$!=null?i1(a1($)):{};let W=Q||!$||!$.__esModule?j1(X,"default",{value:$,enumerable:!0}):X;for(let J of o1($))if(!t1.call(W,J))j1(W,J,{get:()=>$[J],enumerable:!0});return W};var r1=($,Q)=>()=>(Q||$((Q={exports:{}}).exports,Q),Q.exports);var l1=r1((o6,e2)=>{e2.exports={name:"@typescape-ai/mcp",version:"1.0.0",description:"Typescape MCP Server - Model Context Protocol integration for AI agents",type:"module",bin:{"typescape-mcp":"./dist/mcp.js"},files:["dist","README.md"],exports:{".":"./dist/mcp.js"},publishConfig:{access:"public"},scripts:{build:"bun build src/index.ts --outfile=dist/mcp.js --target=bun --bundle --minify",dev:"bun run --watch src/index.ts",test:"bun test",typecheck:"tsc --noEmit",lint:"eslint src",prepublishOnly:"bun run build"},dependencies:{},devDependencies:{"@modelcontextprotocol/sdk":"1.0.4","@types/bun":"1.1.14","@typescape/schemas":"workspace:*",zod:"4.3.0"},engines:{bun:">=1.0.0"},keywords:["typescape","mcp","model-context-protocol","ai","claude","review","bun"],repository:{type:"git",url:"https://github.com/voidserf/typescape-docs.git",directory:"apps/mcp"},license:"MIT"}});function V1(){let $=new Map;return{register(Q,X){$.set(Q.name,{definition:Q,handler:X})},getTools(){return Array.from($.values()).map((Q)=>Q.definition)},getHandler(Q){return $.get(Q)?.handler}}}class V extends Error{status;code;requestId;constructor($,Q,X,W){super(X);this.status=$;this.code=Q;this.requestId=W;this.name="ApiError"}}function O1($,Q){let W=$.replace(/\/$/,"");async function J(H,z,q={}){let j=`${W}/v1${z}`;if(q.query&&Object.keys(q.query).length>0){let k=new URLSearchParams(q.query);j+=`?${k.toString()}`}let D={Authorization:`Bearer ${Q}`,Accept:"application/json",...q.headers};if(q.body!==void 0)D["Content-Type"]="application/json";let b;try{b=await fetch(j,{method:H,headers:D,body:q.body!==void 0?JSON.stringify(q.body):void 0})}catch(k){let T=k instanceof Error?k.message:String(k);throw new V(0,"network_error",`Network error: ${T}`,"unknown")}let E;if((b.headers.get("Content-Type")||"").includes("application/json"))try{E=await b.json()}catch{E={}}else E={};let g=E?.request_id||b.headers.get("X-Request-Id")||"unknown";if(!b.ok){let k=E,T=k.error?.code||"api_error",o=k.error?.message||`API request failed with status ${b.status}`;throw new V(b.status,T,o,g)}return{status:b.status,body:E,requestId:g}}return{async get(H,z){return J("GET",H,z)},async post(H,z){return J("POST",H,z)},request:J}}var R;(function($){$.assertEqual=(J)=>J;function Q(J){}$.assertIs=Q;function X(J){throw Error()}$.assertNever=X,$.arrayToEnum=(J)=>{let H={};for(let z of J)H[z]=z;return H},$.getValidEnumValues=(J)=>{let H=$.objectKeys(J).filter((q)=>typeof J[J[q]]!=="number"),z={};for(let q of H)z[q]=J[q];return $.objectValues(z)},$.objectValues=(J)=>{return $.objectKeys(J).map(function(H){return J[H]})},$.objectKeys=typeof Object.keys==="function"?(J)=>Object.keys(J):(J)=>{let H=[];for(let z in J)if(Object.prototype.hasOwnProperty.call(J,z))H.push(z);return H},$.find=(J,H)=>{for(let z of J)if(H(z))return z;return},$.isInteger=typeof Number.isInteger==="function"?(J)=>Number.isInteger(J):(J)=>typeof J==="number"&&isFinite(J)&&Math.floor(J)===J;function W(J,H=" | "){return J.map((z)=>typeof z==="string"?`'${z}'`:z).join(H)}$.joinValues=W,$.jsonStringifyReplacer=(J,H)=>{if(typeof H==="bigint")return H.toString();return H}})(R||(R={}));var r0;(function($){$.mergeShapes=(Q,X)=>{return{...Q,...X}}})(r0||(r0={}));var F=R.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),s=($)=>{switch(typeof $){case"undefined":return F.undefined;case"string":return F.string;case"number":return isNaN($)?F.nan:F.number;case"boolean":return F.boolean;case"function":return F.function;case"bigint":return F.bigint;case"symbol":return F.symbol;case"object":if(Array.isArray($))return F.array;if($===null)return F.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return F.promise;if(typeof Map<"u"&&$ instanceof Map)return F.map;if(typeof Set<"u"&&$ instanceof Set)return F.set;if(typeof Date<"u"&&$ instanceof Date)return F.date;return F.object;default:return F.unknown}},M=R.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"]),e1=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class x extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(X)=>{this.issues=[...this.issues,X]},this.addIssues=(X=[])=>{this.issues=[...this.issues,...X]};let Q=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,Q);else this.__proto__=Q;this.name="ZodError",this.issues=$}format($){let Q=$||function(J){return J.message},X={_errors:[]},W=(J)=>{for(let H of J.issues)if(H.code==="invalid_union")H.unionErrors.map(W);else if(H.code==="invalid_return_type")W(H.returnTypeError);else if(H.code==="invalid_arguments")W(H.argumentsError);else if(H.path.length===0)X._errors.push(Q(H));else{let z=X,q=0;while(q<H.path.length){let j=H.path[q];if(q!==H.path.length-1)z[j]=z[j]||{_errors:[]};else z[j]=z[j]||{_errors:[]},z[j]._errors.push(Q(H));z=z[j],q++}}};return W(this),X}static assert($){if(!($ instanceof x))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,R.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(Q)=>Q.message){let Q={},X=[];for(let W of this.issues)if(W.path.length>0)Q[W.path[0]]=Q[W.path[0]]||[],Q[W.path[0]].push($(W));else X.push($(W));return{formErrors:X,fieldErrors:Q}}get formErrors(){return this.flatten()}}x.create=($)=>{return new x($)};var M0=($,Q)=>{let X;switch($.code){case M.invalid_type:if($.received===F.undefined)X="Required";else X=`Expected ${$.expected}, received ${$.received}`;break;case M.invalid_literal:X=`Invalid literal value, expected ${JSON.stringify($.expected,R.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:X=`Unrecognized key(s) in object: ${R.joinValues($.keys,", ")}`;break;case M.invalid_union:X="Invalid input";break;case M.invalid_union_discriminator:X=`Invalid discriminator value. Expected ${R.joinValues($.options)}`;break;case M.invalid_enum_value:X=`Invalid enum value. Expected ${R.joinValues($.options)}, received '${$.received}'`;break;case M.invalid_arguments:X="Invalid function arguments";break;case M.invalid_return_type:X="Invalid function return type";break;case M.invalid_date:X="Invalid date";break;case M.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(X=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")X=`${X} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)X=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)X=`Invalid input: must end with "${$.validation.endsWith}"`;else R.assertNever($.validation);else if($.validation!=="regex")X=`Invalid ${$.validation}`;else X="Invalid";break;case M.too_small:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else X="Invalid input";break;case M.too_big:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")X=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else X="Invalid input";break;case M.custom:X="Invalid input";break;case M.invalid_intersection_types:X="Intersection results could not be merged";break;case M.not_multiple_of:X=`Number must be a multiple of ${$.multipleOf}`;break;case M.not_finite:X="Number must be finite";break;default:X=Q.defaultError,R.assertNever($)}return{message:X}},F1=M0;function $4($){F1=$}function g0(){return F1}var T0=($)=>{let{data:Q,path:X,errorMaps:W,issueData:J}=$,H=[...X,...J.path||[]],z={...J,path:H};if(J.message!==void 0)return{...J,path:H,message:J.message};let q="",j=W.filter((D)=>!!D).slice().reverse();for(let D of j)q=D(z,{data:Q,defaultError:q}).message;return{...J,path:H,message:q}},Q4=[];function U($,Q){let X=g0(),W=T0({issueData:Q,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,X,X===M0?void 0:M0].filter((J)=>!!J)});$.common.issues.push(W)}class I{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,Q){let X=[];for(let W of Q){if(W.status==="aborted")return _;if(W.status==="dirty")$.dirty();X.push(W.value)}return{status:$.value,value:X}}static async mergeObjectAsync($,Q){let X=[];for(let W of Q){let J=await W.key,H=await W.value;X.push({key:J,value:H})}return I.mergeObjectSync($,X)}static mergeObjectSync($,Q){let X={};for(let W of Q){let{key:J,value:H}=W;if(J.status==="aborted")return _;if(H.status==="aborted")return _;if(J.status==="dirty")$.dirty();if(H.status==="dirty")$.dirty();if(J.value!=="__proto__"&&(typeof H.value<"u"||W.alwaysSet))X[J.value]=H.value}return{status:$.value,value:X}}}var _=Object.freeze({status:"aborted"}),w0=($)=>({status:"dirty",value:$}),h=($)=>({status:"valid",value:$}),e0=($)=>$.status==="aborted",$1=($)=>$.status==="dirty",J0=($)=>$.status==="valid",b0=($)=>typeof Promise<"u"&&$ instanceof Promise;function x0($,Q,X,W){if(X==="a"&&!W)throw TypeError("Private accessor was defined without a getter");if(typeof Q==="function"?$!==Q||!W:!Q.has($))throw TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?W:X==="a"?W.call($):W?W.value:Q.get($)}function K1($,Q,X,W,J){if(W==="m")throw TypeError("Private method is not writable");if(W==="a"&&!J)throw TypeError("Private accessor was defined without a setter");if(typeof Q==="function"?$!==Q||!J:!Q.has($))throw TypeError("Cannot write private member to an object whose class did not declare it");return W==="a"?J.call($,X):J?J.value=X:Q.set($,X),X}var K;(function($){$.errToObj=(Q)=>typeof Q==="string"?{message:Q}:Q||{},$.toString=(Q)=>typeof Q==="string"?Q:Q===null||Q===void 0?void 0:Q.message})(K||(K={}));var v0,A0;class u{constructor($,Q,X,W){this._cachedPath=[],this.parent=$,this.data=Q,this._path=X,this._key=W}get path(){if(!this._cachedPath.length)if(this._key instanceof Array)this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var L1=($,Q)=>{if(J0(Q))return{success:!0,data:Q.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let X=new x($.common.issues);return this._error=X,this._error}}}};function v($){if(!$)return{};let{errorMap:Q,invalid_type_error:X,required_error:W,description:J}=$;if(Q&&(X||W))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(Q)return{errorMap:Q,description:J};return{errorMap:(z,q)=>{var j,D;let{message:b}=$;if(z.code==="invalid_enum_value")return{message:b!==null&&b!==void 0?b:q.defaultError};if(typeof q.data>"u")return{message:(j=b!==null&&b!==void 0?b:W)!==null&&j!==void 0?j:q.defaultError};if(z.code!=="invalid_type")return{message:q.defaultError};return{message:(D=b!==null&&b!==void 0?b:X)!==null&&D!==void 0?D:q.defaultError}},description:J}}class A{get description(){return this._def.description}_getType($){return s($.data)}_getOrReturnCtx($,Q){return Q||{common:$.parent.common,data:$.data,parsedType:s($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new I,ctx:{common:$.parent.common,data:$.data,parsedType:s($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let Q=this._parse($);if(b0(Q))throw Error("Synchronous parse encountered promise.");return Q}_parseAsync($){let Q=this._parse($);return Promise.resolve(Q)}parse($,Q){let X=this.safeParse($,Q);if(X.success)return X.data;throw X.error}safeParse($,Q){var X;let W={common:{issues:[],async:(X=Q===null||Q===void 0?void 0:Q.async)!==null&&X!==void 0?X:!1,contextualErrorMap:Q===null||Q===void 0?void 0:Q.errorMap},path:(Q===null||Q===void 0?void 0:Q.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:s($)},J=this._parseSync({data:$,path:W.path,parent:W});return L1(W,J)}"~validate"($){var Q,X;let W={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:s($)};if(!this["~standard"].async)try{let J=this._parseSync({data:$,path:[],parent:W});return J0(J)?{value:J.value}:{issues:W.common.issues}}catch(J){if((X=(Q=J===null||J===void 0?void 0:J.message)===null||Q===void 0?void 0:Q.toLowerCase())===null||X===void 0?void 0:X.includes("encountered"))this["~standard"].async=!0;W.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:W}).then((J)=>J0(J)?{value:J.value}:{issues:W.common.issues})}async parseAsync($,Q){let X=await this.safeParseAsync($,Q);if(X.success)return X.data;throw X.error}async safeParseAsync($,Q){let X={common:{issues:[],contextualErrorMap:Q===null||Q===void 0?void 0:Q.errorMap,async:!0},path:(Q===null||Q===void 0?void 0:Q.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:s($)},W=this._parse({data:$,path:X.path,parent:X}),J=await(b0(W)?W:Promise.resolve(W));return L1(X,J)}refine($,Q){let X=(W)=>{if(typeof Q==="string"||typeof Q>"u")return{message:Q};else if(typeof Q==="function")return Q(W);else return Q};return this._refinement((W,J)=>{let H=$(W),z=()=>J.addIssue({code:M.custom,...X(W)});if(typeof Promise<"u"&&H instanceof Promise)return H.then((q)=>{if(!q)return z(),!1;else return!0});if(!H)return z(),!1;else return!0})}refinement($,Q){return this._refinement((X,W)=>{if(!$(X))return W.addIssue(typeof Q==="function"?Q(X,W):Q),!1;else return!0})}_refinement($){return new Z({schema:this,typeName:S.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,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:(Q)=>this["~validate"](Q)}}optional(){return c.create(this,this._def)}nullable(){return r.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return l.create(this)}promise(){return H0.create(this,this._def)}or($){return L0.create([this,$],this._def)}and($){return U0.create(this,$,this._def)}transform($){return new Z({...v(this._def),schema:this,typeName:S.ZodEffects,effect:{type:"transform",transform:$}})}default($){let Q=typeof $==="function"?$:()=>$;return new N0({...v(this._def),innerType:this,defaultValue:Q,typeName:S.ZodDefault})}brand(){return new Z0({typeName:S.ZodBranded,type:this,...v(this._def)})}catch($){let Q=typeof $==="function"?$:()=>$;return new S0({...v(this._def),innerType:this,catchValue:Q,typeName:S.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return P0.create(this,$)}readonly(){return _0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var X4=/^c[^\s-]{8,}$/i,J4=/^[0-9a-z]+$/,W4=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Y4=/^[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,G4=/^[a-z0-9_-]{21}$/i,H4=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,z4=/^[-+]?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)?)??$/,B4=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,w4="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",s0,q4=/^(?:(?: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])$/,M4=/^(?:(?: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])$/,j4=/^(([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]))$/,V4=/^(([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])$/,O4=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,L4=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,D1="((\\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])))",U4=new RegExp(`^${D1}$`);function N1($){let Q="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";if($.precision)Q=`${Q}\\.\\d{${$.precision}}`;else if($.precision==null)Q=`${Q}(\\.\\d+)?`;return Q}function F4($){return new RegExp(`^${N1($)}$`)}function S1($){let Q=`${D1}T${N1($)}`,X=[];if(X.push($.local?"Z?":"Z"),$.offset)X.push("([+-]\\d{2}:?\\d{2})");return Q=`${Q}(${X.join("|")})`,new RegExp(`^${Q}$`)}function K4($,Q){if((Q==="v4"||!Q)&&q4.test($))return!0;if((Q==="v6"||!Q)&&j4.test($))return!0;return!1}function D4($,Q){if(!H4.test($))return!1;try{let[X]=$.split("."),W=X.replace(/-/g,"+").replace(/_/g,"/").padEnd(X.length+(4-X.length%4)%4,"="),J=JSON.parse(atob(W));if(typeof J!=="object"||J===null)return!1;if(!J.typ||!J.alg)return!1;if(Q&&J.alg!==Q)return!1;return!0}catch(X){return!1}}function N4($,Q){if((Q==="v4"||!Q)&&M4.test($))return!0;if((Q==="v6"||!Q)&&V4.test($))return!0;return!1}class m extends A{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==F.string){let J=this._getOrReturnCtx($);return U(J,{code:M.invalid_type,expected:F.string,received:J.parsedType}),_}let X=new I,W=void 0;for(let J of this._def.checks)if(J.kind==="min"){if($.data.length<J.value)W=this._getOrReturnCtx($,W),U(W,{code:M.too_small,minimum:J.value,type:"string",inclusive:!0,exact:!1,message:J.message}),X.dirty()}else if(J.kind==="max"){if($.data.length>J.value)W=this._getOrReturnCtx($,W),U(W,{code:M.too_big,maximum:J.value,type:"string",inclusive:!0,exact:!1,message:J.message}),X.dirty()}else if(J.kind==="length"){let H=$.data.length>J.value,z=$.data.length<J.value;if(H||z){if(W=this._getOrReturnCtx($,W),H)U(W,{code:M.too_big,maximum:J.value,type:"string",inclusive:!0,exact:!0,message:J.message});else if(z)U(W,{code:M.too_small,minimum:J.value,type:"string",inclusive:!0,exact:!0,message:J.message});X.dirty()}}else if(J.kind==="email"){if(!B4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"email",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="emoji"){if(!s0)s0=new RegExp(w4,"u");if(!s0.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"emoji",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="uuid"){if(!Y4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"uuid",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="nanoid"){if(!G4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"nanoid",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="cuid"){if(!X4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"cuid",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="cuid2"){if(!J4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"cuid2",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="ulid"){if(!W4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"ulid",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="url")try{new URL($.data)}catch(H){W=this._getOrReturnCtx($,W),U(W,{validation:"url",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="regex"){if(J.regex.lastIndex=0,!J.regex.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"regex",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="trim")$.data=$.data.trim();else if(J.kind==="includes"){if(!$.data.includes(J.value,J.position))W=this._getOrReturnCtx($,W),U(W,{code:M.invalid_string,validation:{includes:J.value,position:J.position},message:J.message}),X.dirty()}else if(J.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(J.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(J.kind==="startsWith"){if(!$.data.startsWith(J.value))W=this._getOrReturnCtx($,W),U(W,{code:M.invalid_string,validation:{startsWith:J.value},message:J.message}),X.dirty()}else if(J.kind==="endsWith"){if(!$.data.endsWith(J.value))W=this._getOrReturnCtx($,W),U(W,{code:M.invalid_string,validation:{endsWith:J.value},message:J.message}),X.dirty()}else if(J.kind==="datetime"){if(!S1(J).test($.data))W=this._getOrReturnCtx($,W),U(W,{code:M.invalid_string,validation:"datetime",message:J.message}),X.dirty()}else if(J.kind==="date"){if(!U4.test($.data))W=this._getOrReturnCtx($,W),U(W,{code:M.invalid_string,validation:"date",message:J.message}),X.dirty()}else if(J.kind==="time"){if(!F4(J).test($.data))W=this._getOrReturnCtx($,W),U(W,{code:M.invalid_string,validation:"time",message:J.message}),X.dirty()}else if(J.kind==="duration"){if(!z4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"duration",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="ip"){if(!K4($.data,J.version))W=this._getOrReturnCtx($,W),U(W,{validation:"ip",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="jwt"){if(!D4($.data,J.alg))W=this._getOrReturnCtx($,W),U(W,{validation:"jwt",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="cidr"){if(!N4($.data,J.version))W=this._getOrReturnCtx($,W),U(W,{validation:"cidr",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="base64"){if(!O4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"base64",code:M.invalid_string,message:J.message}),X.dirty()}else if(J.kind==="base64url"){if(!L4.test($.data))W=this._getOrReturnCtx($,W),U(W,{validation:"base64url",code:M.invalid_string,message:J.message}),X.dirty()}else R.assertNever(J);return{status:X.value,value:$.data}}_regex($,Q,X){return this.refinement((W)=>$.test(W),{validation:Q,code:M.invalid_string,...K.errToObj(X)})}_addCheck($){return new m({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...K.errToObj($)})}url($){return this._addCheck({kind:"url",...K.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...K.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...K.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...K.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...K.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...K.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...K.errToObj($)})}base64($){return this._addCheck({kind:"base64",...K.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...K.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...K.errToObj($)})}ip($){return this._addCheck({kind:"ip",...K.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...K.errToObj($)})}datetime($){var Q,X;if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof($===null||$===void 0?void 0:$.precision)>"u"?null:$===null||$===void 0?void 0:$.precision,offset:(Q=$===null||$===void 0?void 0:$.offset)!==null&&Q!==void 0?Q:!1,local:(X=$===null||$===void 0?void 0:$.local)!==null&&X!==void 0?X:!1,...K.errToObj($===null||$===void 0?void 0:$.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof($===null||$===void 0?void 0:$.precision)>"u"?null:$===null||$===void 0?void 0:$.precision,...K.errToObj($===null||$===void 0?void 0:$.message)})}duration($){return this._addCheck({kind:"duration",...K.errToObj($)})}regex($,Q){return this._addCheck({kind:"regex",regex:$,...K.errToObj(Q)})}includes($,Q){return this._addCheck({kind:"includes",value:$,position:Q===null||Q===void 0?void 0:Q.position,...K.errToObj(Q===null||Q===void 0?void 0:Q.message)})}startsWith($,Q){return this._addCheck({kind:"startsWith",value:$,...K.errToObj(Q)})}endsWith($,Q){return this._addCheck({kind:"endsWith",value:$,...K.errToObj(Q)})}min($,Q){return this._addCheck({kind:"min",value:$,...K.errToObj(Q)})}max($,Q){return this._addCheck({kind:"max",value:$,...K.errToObj(Q)})}length($,Q){return this._addCheck({kind:"length",value:$,...K.errToObj(Q)})}nonempty($){return this.min(1,K.errToObj($))}trim(){return new m({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new m({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new m({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let Q of this._def.checks)if(Q.kind==="min"){if($===null||Q.value>$)$=Q.value}return $}get maxLength(){let $=null;for(let Q of this._def.checks)if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return $}}m.create=($)=>{var Q;return new m({checks:[],typeName:S.ZodString,coerce:(Q=$===null||$===void 0?void 0:$.coerce)!==null&&Q!==void 0?Q:!1,...v($)})};function S4($,Q){let X=($.toString().split(".")[1]||"").length,W=(Q.toString().split(".")[1]||"").length,J=X>W?X:W,H=parseInt($.toFixed(J).replace(".","")),z=parseInt(Q.toFixed(J).replace(".",""));return H%z/Math.pow(10,J)}class $0 extends A{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==F.number){let J=this._getOrReturnCtx($);return U(J,{code:M.invalid_type,expected:F.number,received:J.parsedType}),_}let X=void 0,W=new I;for(let J of this._def.checks)if(J.kind==="int"){if(!R.isInteger($.data))X=this._getOrReturnCtx($,X),U(X,{code:M.invalid_type,expected:"integer",received:"float",message:J.message}),W.dirty()}else if(J.kind==="min"){if(J.inclusive?$.data<J.value:$.data<=J.value)X=this._getOrReturnCtx($,X),U(X,{code:M.too_small,minimum:J.value,type:"number",inclusive:J.inclusive,exact:!1,message:J.message}),W.dirty()}else if(J.kind==="max"){if(J.inclusive?$.data>J.value:$.data>=J.value)X=this._getOrReturnCtx($,X),U(X,{code:M.too_big,maximum:J.value,type:"number",inclusive:J.inclusive,exact:!1,message:J.message}),W.dirty()}else if(J.kind==="multipleOf"){if(S4($.data,J.value)!==0)X=this._getOrReturnCtx($,X),U(X,{code:M.not_multiple_of,multipleOf:J.value,message:J.message}),W.dirty()}else if(J.kind==="finite"){if(!Number.isFinite($.data))X=this._getOrReturnCtx($,X),U(X,{code:M.not_finite,message:J.message}),W.dirty()}else R.assertNever(J);return{status:W.value,value:$.data}}gte($,Q){return this.setLimit("min",$,!0,K.toString(Q))}gt($,Q){return this.setLimit("min",$,!1,K.toString(Q))}lte($,Q){return this.setLimit("max",$,!0,K.toString(Q))}lt($,Q){return this.setLimit("max",$,!1,K.toString(Q))}setLimit($,Q,X,W){return new $0({...this._def,checks:[...this._def.checks,{kind:$,value:Q,inclusive:X,message:K.toString(W)}]})}_addCheck($){return new $0({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:K.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:K.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:K.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:K.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:K.toString($)})}multipleOf($,Q){return this._addCheck({kind:"multipleOf",value:$,message:K.toString(Q)})}finite($){return this._addCheck({kind:"finite",message:K.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:K.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:K.toString($)})}get minValue(){let $=null;for(let Q of this._def.checks)if(Q.kind==="min"){if($===null||Q.value>$)$=Q.value}return $}get maxValue(){let $=null;for(let Q of this._def.checks)if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&R.isInteger($.value))}get isFinite(){let $=null,Q=null;for(let X of this._def.checks)if(X.kind==="finite"||X.kind==="int"||X.kind==="multipleOf")return!0;else if(X.kind==="min"){if(Q===null||X.value>Q)Q=X.value}else if(X.kind==="max"){if($===null||X.value<$)$=X.value}return Number.isFinite(Q)&&Number.isFinite($)}}$0.create=($)=>{return new $0({checks:[],typeName:S.ZodNumber,coerce:($===null||$===void 0?void 0:$.coerce)||!1,...v($)})};class Q0 extends A{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch(J){return this._getInvalidInput($)}if(this._getType($)!==F.bigint)return this._getInvalidInput($);let X=void 0,W=new I;for(let J of this._def.checks)if(J.kind==="min"){if(J.inclusive?$.data<J.value:$.data<=J.value)X=this._getOrReturnCtx($,X),U(X,{code:M.too_small,type:"bigint",minimum:J.value,inclusive:J.inclusive,message:J.message}),W.dirty()}else if(J.kind==="max"){if(J.inclusive?$.data>J.value:$.data>=J.value)X=this._getOrReturnCtx($,X),U(X,{code:M.too_big,type:"bigint",maximum:J.value,inclusive:J.inclusive,message:J.message}),W.dirty()}else if(J.kind==="multipleOf"){if($.data%J.value!==BigInt(0))X=this._getOrReturnCtx($,X),U(X,{code:M.not_multiple_of,multipleOf:J.value,message:J.message}),W.dirty()}else R.assertNever(J);return{status:W.value,value:$.data}}_getInvalidInput($){let Q=this._getOrReturnCtx($);return U(Q,{code:M.invalid_type,expected:F.bigint,received:Q.parsedType}),_}gte($,Q){return this.setLimit("min",$,!0,K.toString(Q))}gt($,Q){return this.setLimit("min",$,!1,K.toString(Q))}lte($,Q){return this.setLimit("max",$,!0,K.toString(Q))}lt($,Q){return this.setLimit("max",$,!1,K.toString(Q))}setLimit($,Q,X,W){return new Q0({...this._def,checks:[...this._def.checks,{kind:$,value:Q,inclusive:X,message:K.toString(W)}]})}_addCheck($){return new Q0({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:K.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:K.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:K.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:K.toString($)})}multipleOf($,Q){return this._addCheck({kind:"multipleOf",value:$,message:K.toString(Q)})}get minValue(){let $=null;for(let Q of this._def.checks)if(Q.kind==="min"){if($===null||Q.value>$)$=Q.value}return $}get maxValue(){let $=null;for(let Q of this._def.checks)if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return $}}Q0.create=($)=>{var Q;return new Q0({checks:[],typeName:S.ZodBigInt,coerce:(Q=$===null||$===void 0?void 0:$.coerce)!==null&&Q!==void 0?Q:!1,...v($)})};class j0 extends A{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==F.boolean){let X=this._getOrReturnCtx($);return U(X,{code:M.invalid_type,expected:F.boolean,received:X.parsedType}),_}return h($.data)}}j0.create=($)=>{return new j0({typeName:S.ZodBoolean,coerce:($===null||$===void 0?void 0:$.coerce)||!1,...v($)})};class W0 extends A{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==F.date){let J=this._getOrReturnCtx($);return U(J,{code:M.invalid_type,expected:F.date,received:J.parsedType}),_}if(isNaN($.data.getTime())){let J=this._getOrReturnCtx($);return U(J,{code:M.invalid_date}),_}let X=new I,W=void 0;for(let J of this._def.checks)if(J.kind==="min"){if($.data.getTime()<J.value)W=this._getOrReturnCtx($,W),U(W,{code:M.too_small,message:J.message,inclusive:!0,exact:!1,minimum:J.value,type:"date"}),X.dirty()}else if(J.kind==="max"){if($.data.getTime()>J.value)W=this._getOrReturnCtx($,W),U(W,{code:M.too_big,message:J.message,inclusive:!0,exact:!1,maximum:J.value,type:"date"}),X.dirty()}else R.assertNever(J);return{status:X.value,value:new Date($.data.getTime())}}_addCheck($){return new W0({...this._def,checks:[...this._def.checks,$]})}min($,Q){return this._addCheck({kind:"min",value:$.getTime(),message:K.toString(Q)})}max($,Q){return this._addCheck({kind:"max",value:$.getTime(),message:K.toString(Q)})}get minDate(){let $=null;for(let Q of this._def.checks)if(Q.kind==="min"){if($===null||Q.value>$)$=Q.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let Q of this._def.checks)if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return $!=null?new Date($):null}}W0.create=($)=>{return new W0({checks:[],coerce:($===null||$===void 0?void 0:$.coerce)||!1,typeName:S.ZodDate,...v($)})};class R0 extends A{_parse($){if(this._getType($)!==F.symbol){let X=this._getOrReturnCtx($);return U(X,{code:M.invalid_type,expected:F.symbol,received:X.parsedType}),_}return h($.data)}}R0.create=($)=>{return new R0({typeName:S.ZodSymbol,...v($)})};class V0 extends A{_parse($){if(this._getType($)!==F.undefined){let X=this._getOrReturnCtx($);return U(X,{code:M.invalid_type,expected:F.undefined,received:X.parsedType}),_}return h($.data)}}V0.create=($)=>{return new V0({typeName:S.ZodUndefined,...v($)})};class O0 extends A{_parse($){if(this._getType($)!==F.null){let X=this._getOrReturnCtx($);return U(X,{code:M.invalid_type,expected:F.null,received:X.parsedType}),_}return h($.data)}}O0.create=($)=>{return new O0({typeName:S.ZodNull,...v($)})};class Y0 extends A{constructor(){super(...arguments);this._any=!0}_parse($){return h($.data)}}Y0.create=($)=>{return new Y0({typeName:S.ZodAny,...v($)})};class e extends A{constructor(){super(...arguments);this._unknown=!0}_parse($){return h($.data)}}e.create=($)=>{return new e({typeName:S.ZodUnknown,...v($)})};class d extends A{_parse($){let Q=this._getOrReturnCtx($);return U(Q,{code:M.invalid_type,expected:F.never,received:Q.parsedType}),_}}d.create=($)=>{return new d({typeName:S.ZodNever,...v($)})};class f0 extends A{_parse($){if(this._getType($)!==F.undefined){let X=this._getOrReturnCtx($);return U(X,{code:M.invalid_type,expected:F.void,received:X.parsedType}),_}return h($.data)}}f0.create=($)=>{return new f0({typeName:S.ZodVoid,...v($)})};class l extends A{_parse($){let{ctx:Q,status:X}=this._processInputParams($),W=this._def;if(Q.parsedType!==F.array)return U(Q,{code:M.invalid_type,expected:F.array,received:Q.parsedType}),_;if(W.exactLength!==null){let H=Q.data.length>W.exactLength.value,z=Q.data.length<W.exactLength.value;if(H||z)U(Q,{code:H?M.too_big:M.too_small,minimum:z?W.exactLength.value:void 0,maximum:H?W.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:W.exactLength.message}),X.dirty()}if(W.minLength!==null){if(Q.data.length<W.minLength.value)U(Q,{code:M.too_small,minimum:W.minLength.value,type:"array",inclusive:!0,exact:!1,message:W.minLength.message}),X.dirty()}if(W.maxLength!==null){if(Q.data.length>W.maxLength.value)U(Q,{code:M.too_big,maximum:W.maxLength.value,type:"array",inclusive:!0,exact:!1,message:W.maxLength.message}),X.dirty()}if(Q.common.async)return Promise.all([...Q.data].map((H,z)=>{return W.type._parseAsync(new u(Q,H,Q.path,z))})).then((H)=>{return I.mergeArray(X,H)});let J=[...Q.data].map((H,z)=>{return W.type._parseSync(new u(Q,H,Q.path,z))});return I.mergeArray(X,J)}get element(){return this._def.type}min($,Q){return new l({...this._def,minLength:{value:$,message:K.toString(Q)}})}max($,Q){return new l({...this._def,maxLength:{value:$,message:K.toString(Q)}})}length($,Q){return new l({...this._def,exactLength:{value:$,message:K.toString(Q)}})}nonempty($){return this.min(1,$)}}l.create=($,Q)=>{return new l({type:$,minLength:null,maxLength:null,exactLength:null,typeName:S.ZodArray,...v(Q)})};function B0($){if($ instanceof C){let Q={};for(let X in $.shape){let W=$.shape[X];Q[X]=c.create(B0(W))}return new C({...$._def,shape:()=>Q})}else if($ instanceof l)return new l({...$._def,type:B0($.element)});else if($ instanceof c)return c.create(B0($.unwrap()));else if($ instanceof r)return r.create(B0($.unwrap()));else if($ instanceof i)return i.create($.items.map((Q)=>B0(Q)));else return $}class C extends A{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),Q=R.objectKeys($);return this._cached={shape:$,keys:Q}}_parse($){if(this._getType($)!==F.object){let j=this._getOrReturnCtx($);return U(j,{code:M.invalid_type,expected:F.object,received:j.parsedType}),_}let{status:X,ctx:W}=this._processInputParams($),{shape:J,keys:H}=this._getCached(),z=[];if(!(this._def.catchall instanceof d&&this._def.unknownKeys==="strip")){for(let j in W.data)if(!H.includes(j))z.push(j)}let q=[];for(let j of H){let D=J[j],b=W.data[j];q.push({key:{status:"valid",value:j},value:D._parse(new u(W,b,W.path,j)),alwaysSet:j in W.data})}if(this._def.catchall instanceof d){let j=this._def.unknownKeys;if(j==="passthrough")for(let D of z)q.push({key:{status:"valid",value:D},value:{status:"valid",value:W.data[D]}});else if(j==="strict"){if(z.length>0)U(W,{code:M.unrecognized_keys,keys:z}),X.dirty()}else if(j==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let j=this._def.catchall;for(let D of z){let b=W.data[D];q.push({key:{status:"valid",value:D},value:j._parse(new u(W,b,W.path,D)),alwaysSet:D in W.data})}}if(W.common.async)return Promise.resolve().then(async()=>{let j=[];for(let D of q){let b=await D.key,E=await D.value;j.push({key:b,value:E,alwaysSet:D.alwaysSet})}return j}).then((j)=>{return I.mergeObjectSync(X,j)});else return I.mergeObjectSync(X,q)}get shape(){return this._def.shape()}strict($){return K.errToObj,new C({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(Q,X)=>{var W,J,H,z;let q=(H=(J=(W=this._def).errorMap)===null||J===void 0?void 0:J.call(W,Q,X).message)!==null&&H!==void 0?H:X.defaultError;if(Q.code==="unrecognized_keys")return{message:(z=K.errToObj($).message)!==null&&z!==void 0?z:q};return{message:q}}}:{}})}strip(){return new C({...this._def,unknownKeys:"strip"})}passthrough(){return new C({...this._def,unknownKeys:"passthrough"})}extend($){return new C({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new C({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:S.ZodObject})}setKey($,Q){return this.augment({[$]:Q})}catchall($){return new C({...this._def,catchall:$})}pick($){let Q={};return R.objectKeys($).forEach((X)=>{if($[X]&&this.shape[X])Q[X]=this.shape[X]}),new C({...this._def,shape:()=>Q})}omit($){let Q={};return R.objectKeys(this.shape).forEach((X)=>{if(!$[X])Q[X]=this.shape[X]}),new C({...this._def,shape:()=>Q})}deepPartial(){return B0(this)}partial($){let Q={};return R.objectKeys(this.shape).forEach((X)=>{let W=this.shape[X];if($&&!$[X])Q[X]=W;else Q[X]=W.optional()}),new C({...this._def,shape:()=>Q})}required($){let Q={};return R.objectKeys(this.shape).forEach((X)=>{if($&&!$[X])Q[X]=this.shape[X];else{let J=this.shape[X];while(J instanceof c)J=J._def.innerType;Q[X]=J}}),new C({...this._def,shape:()=>Q})}keyof(){return _1(R.objectKeys(this.shape))}}C.create=($,Q)=>{return new C({shape:()=>$,unknownKeys:"strip",catchall:d.create(),typeName:S.ZodObject,...v(Q)})};C.strictCreate=($,Q)=>{return new C({shape:()=>$,unknownKeys:"strict",catchall:d.create(),typeName:S.ZodObject,...v(Q)})};C.lazycreate=($,Q)=>{return new C({shape:$,unknownKeys:"strip",catchall:d.create(),typeName:S.ZodObject,...v(Q)})};class L0 extends A{_parse($){let{ctx:Q}=this._processInputParams($),X=this._def.options;function W(J){for(let z of J)if(z.result.status==="valid")return z.result;for(let z of J)if(z.result.status==="dirty")return Q.common.issues.push(...z.ctx.common.issues),z.result;let H=J.map((z)=>new x(z.ctx.common.issues));return U(Q,{code:M.invalid_union,unionErrors:H}),_}if(Q.common.async)return Promise.all(X.map(async(J)=>{let H={...Q,common:{...Q.common,issues:[]},parent:null};return{result:await J._parseAsync({data:Q.data,path:Q.path,parent:H}),ctx:H}})).then(W);else{let J=void 0,H=[];for(let q of X){let j={...Q,common:{...Q.common,issues:[]},parent:null},D=q._parseSync({data:Q.data,path:Q.path,parent:j});if(D.status==="valid")return D;else if(D.status==="dirty"&&!J)J={result:D,ctx:j};if(j.common.issues.length)H.push(j.common.issues)}if(J)return Q.common.issues.push(...J.ctx.common.issues),J.result;let z=H.map((q)=>new x(q));return U(Q,{code:M.invalid_union,unionErrors:z}),_}}get options(){return this._def.options}}L0.create=($,Q)=>{return new L0({options:$,typeName:S.ZodUnion,...v(Q)})};var t=($)=>{if($ instanceof F0)return t($.schema);else if($ instanceof Z)return t($.innerType());else if($ instanceof K0)return[$.value];else if($ instanceof X0)return $.options;else if($ instanceof D0)return R.objectValues($.enum);else if($ instanceof N0)return t($._def.innerType);else if($ instanceof V0)return[void 0];else if($ instanceof O0)return[null];else if($ instanceof c)return[void 0,...t($.unwrap())];else if($ instanceof r)return[null,...t($.unwrap())];else if($ instanceof Z0)return t($.unwrap());else if($ instanceof _0)return t($.unwrap());else if($ instanceof S0)return t($._def.innerType);else return[]};class y0 extends A{_parse($){let{ctx:Q}=this._processInputParams($);if(Q.parsedType!==F.object)return U(Q,{code:M.invalid_type,expected:F.object,received:Q.parsedType}),_;let X=this.discriminator,W=Q.data[X],J=this.optionsMap.get(W);if(!J)return U(Q,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[X]}),_;if(Q.common.async)return J._parseAsync({data:Q.data,path:Q.path,parent:Q});else return J._parseSync({data:Q.data,path:Q.path,parent:Q})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,Q,X){let W=new Map;for(let J of Q){let H=t(J.shape[$]);if(!H.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let z of H){if(W.has(z))throw Error(`Discriminator property ${String($)} has duplicate value ${String(z)}`);W.set(z,J)}}return new y0({typeName:S.ZodDiscriminatedUnion,discriminator:$,options:Q,optionsMap:W,...v(X)})}}function Q1($,Q){let X=s($),W=s(Q);if($===Q)return{valid:!0,data:$};else if(X===F.object&&W===F.object){let J=R.objectKeys(Q),H=R.objectKeys($).filter((q)=>J.indexOf(q)!==-1),z={...$,...Q};for(let q of H){let j=Q1($[q],Q[q]);if(!j.valid)return{valid:!1};z[q]=j.data}return{valid:!0,data:z}}else if(X===F.array&&W===F.array){if($.length!==Q.length)return{valid:!1};let J=[];for(let H=0;H<$.length;H++){let z=$[H],q=Q[H],j=Q1(z,q);if(!j.valid)return{valid:!1};J.push(j.data)}return{valid:!0,data:J}}else if(X===F.date&&W===F.date&&+$===+Q)return{valid:!0,data:$};else return{valid:!1}}class U0 extends A{_parse($){let{status:Q,ctx:X}=this._processInputParams($),W=(J,H)=>{if(e0(J)||e0(H))return _;let z=Q1(J.value,H.value);if(!z.valid)return U(X,{code:M.invalid_intersection_types}),_;if($1(J)||$1(H))Q.dirty();return{status:Q.value,value:z.data}};if(X.common.async)return Promise.all([this._def.left._parseAsync({data:X.data,path:X.path,parent:X}),this._def.right._parseAsync({data:X.data,path:X.path,parent:X})]).then(([J,H])=>W(J,H));else return W(this._def.left._parseSync({data:X.data,path:X.path,parent:X}),this._def.right._parseSync({data:X.data,path:X.path,parent:X}))}}U0.create=($,Q,X)=>{return new U0({left:$,right:Q,typeName:S.ZodIntersection,...v(X)})};class i extends A{_parse($){let{status:Q,ctx:X}=this._processInputParams($);if(X.parsedType!==F.array)return U(X,{code:M.invalid_type,expected:F.array,received:X.parsedType}),_;if(X.data.length<this._def.items.length)return U(X,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),_;if(!this._def.rest&&X.data.length>this._def.items.length)U(X,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Q.dirty();let J=[...X.data].map((H,z)=>{let q=this._def.items[z]||this._def.rest;if(!q)return null;return q._parse(new u(X,H,X.path,z))}).filter((H)=>!!H);if(X.common.async)return Promise.all(J).then((H)=>{return I.mergeArray(Q,H)});else return I.mergeArray(Q,J)}get items(){return this._def.items}rest($){return new i({...this._def,rest:$})}}i.create=($,Q)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new i({items:$,typeName:S.ZodTuple,rest:null,...v(Q)})};class k0 extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:Q,ctx:X}=this._processInputParams($);if(X.parsedType!==F.object)return U(X,{code:M.invalid_type,expected:F.object,received:X.parsedType}),_;let W=[],J=this._def.keyType,H=this._def.valueType;for(let z in X.data)W.push({key:J._parse(new u(X,z,X.path,z)),value:H._parse(new u(X,X.data[z],X.path,z)),alwaysSet:z in X.data});if(X.common.async)return I.mergeObjectAsync(Q,W);else return I.mergeObjectSync(Q,W)}get element(){return this._def.valueType}static create($,Q,X){if(Q instanceof A)return new k0({keyType:$,valueType:Q,typeName:S.ZodRecord,...v(X)});return new k0({keyType:m.create(),valueType:$,typeName:S.ZodRecord,...v(Q)})}}class C0 extends A{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:Q,ctx:X}=this._processInputParams($);if(X.parsedType!==F.map)return U(X,{code:M.invalid_type,expected:F.map,received:X.parsedType}),_;let W=this._def.keyType,J=this._def.valueType,H=[...X.data.entries()].map(([z,q],j)=>{return{key:W._parse(new u(X,z,X.path,[j,"key"])),value:J._parse(new u(X,q,X.path,[j,"value"]))}});if(X.common.async){let z=new Map;return Promise.resolve().then(async()=>{for(let q of H){let j=await q.key,D=await q.value;if(j.status==="aborted"||D.status==="aborted")return _;if(j.status==="dirty"||D.status==="dirty")Q.dirty();z.set(j.value,D.value)}return{status:Q.value,value:z}})}else{let z=new Map;for(let q of H){let{key:j,value:D}=q;if(j.status==="aborted"||D.status==="aborted")return _;if(j.status==="dirty"||D.status==="dirty")Q.dirty();z.set(j.value,D.value)}return{status:Q.value,value:z}}}}C0.create=($,Q,X)=>{return new C0({valueType:Q,keyType:$,typeName:S.ZodMap,...v(X)})};class G0 extends A{_parse($){let{status:Q,ctx:X}=this._processInputParams($);if(X.parsedType!==F.set)return U(X,{code:M.invalid_type,expected:F.set,received:X.parsedType}),_;let W=this._def;if(W.minSize!==null){if(X.data.size<W.minSize.value)U(X,{code:M.too_small,minimum:W.minSize.value,type:"set",inclusive:!0,exact:!1,message:W.minSize.message}),Q.dirty()}if(W.maxSize!==null){if(X.data.size>W.maxSize.value)U(X,{code:M.too_big,maximum:W.maxSize.value,type:"set",inclusive:!0,exact:!1,message:W.maxSize.message}),Q.dirty()}let J=this._def.valueType;function H(q){let j=new Set;for(let D of q){if(D.status==="aborted")return _;if(D.status==="dirty")Q.dirty();j.add(D.value)}return{status:Q.value,value:j}}let z=[...X.data.values()].map((q,j)=>J._parse(new u(X,q,X.path,j)));if(X.common.async)return Promise.all(z).then((q)=>H(q));else return H(z)}min($,Q){return new G0({...this._def,minSize:{value:$,message:K.toString(Q)}})}max($,Q){return new G0({...this._def,maxSize:{value:$,message:K.toString(Q)}})}size($,Q){return this.min($,Q).max($,Q)}nonempty($){return this.min(1,$)}}G0.create=($,Q)=>{return new G0({valueType:$,minSize:null,maxSize:null,typeName:S.ZodSet,...v(Q)})};class q0 extends A{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:Q}=this._processInputParams($);if(Q.parsedType!==F.function)return U(Q,{code:M.invalid_type,expected:F.function,received:Q.parsedType}),_;function X(z,q){return T0({data:z,path:Q.path,errorMaps:[Q.common.contextualErrorMap,Q.schemaErrorMap,g0(),M0].filter((j)=>!!j),issueData:{code:M.invalid_arguments,argumentsError:q}})}function W(z,q){return T0({data:z,path:Q.path,errorMaps:[Q.common.contextualErrorMap,Q.schemaErrorMap,g0(),M0].filter((j)=>!!j),issueData:{code:M.invalid_return_type,returnTypeError:q}})}let J={errorMap:Q.common.contextualErrorMap},H=Q.data;if(this._def.returns instanceof H0){let z=this;return h(async function(...q){let j=new x([]),D=await z._def.args.parseAsync(q,J).catch((P)=>{throw j.addIssue(X(q,P)),j}),b=await Reflect.apply(H,this,D);return await z._def.returns._def.type.parseAsync(b,J).catch((P)=>{throw j.addIssue(W(b,P)),j})})}else{let z=this;return h(function(...q){let j=z._def.args.safeParse(q,J);if(!j.success)throw new x([X(q,j.error)]);let D=Reflect.apply(H,this,j.data),b=z._def.returns.safeParse(D,J);if(!b.success)throw new x([W(D,b.error)]);return b.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new q0({...this._def,args:i.create($).rest(e.create())})}returns($){return new q0({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,Q,X){return new q0({args:$?$:i.create([]).rest(e.create()),returns:Q||e.create(),typeName:S.ZodFunction,...v(X)})}}class F0 extends A{get schema(){return this._def.getter()}_parse($){let{ctx:Q}=this._processInputParams($);return this._def.getter()._parse({data:Q.data,path:Q.path,parent:Q})}}F0.create=($,Q)=>{return new F0({getter:$,typeName:S.ZodLazy,...v(Q)})};class K0 extends A{_parse($){if($.data!==this._def.value){let Q=this._getOrReturnCtx($);return U(Q,{received:Q.data,code:M.invalid_literal,expected:this._def.value}),_}return{status:"valid",value:$.data}}get value(){return this._def.value}}K0.create=($,Q)=>{return new K0({value:$,typeName:S.ZodLiteral,...v(Q)})};function _1($,Q){return new X0({values:$,typeName:S.ZodEnum,...v(Q)})}class X0 extends A{constructor(){super(...arguments);v0.set(this,void 0)}_parse($){if(typeof $.data!=="string"){let Q=this._getOrReturnCtx($),X=this._def.values;return U(Q,{expected:R.joinValues(X),received:Q.parsedType,code:M.invalid_type}),_}if(!x0(this,v0,"f"))K1(this,v0,new Set(this._def.values),"f");if(!x0(this,v0,"f").has($.data)){let Q=this._getOrReturnCtx($),X=this._def.values;return U(Q,{received:Q.data,code:M.invalid_enum_value,options:X}),_}return h($.data)}get options(){return this._def.values}get enum(){let $={};for(let Q of this._def.values)$[Q]=Q;return $}get Values(){let $={};for(let Q of this._def.values)$[Q]=Q;return $}get Enum(){let $={};for(let Q of this._def.values)$[Q]=Q;return $}extract($,Q=this._def){return X0.create($,{...this._def,...Q})}exclude($,Q=this._def){return X0.create(this.options.filter((X)=>!$.includes(X)),{...this._def,...Q})}}v0=new WeakMap;X0.create=_1;class D0 extends A{constructor(){super(...arguments);A0.set(this,void 0)}_parse($){let Q=R.getValidEnumValues(this._def.values),X=this._getOrReturnCtx($);if(X.parsedType!==F.string&&X.parsedType!==F.number){let W=R.objectValues(Q);return U(X,{expected:R.joinValues(W),received:X.parsedType,code:M.invalid_type}),_}if(!x0(this,A0,"f"))K1(this,A0,new Set(R.getValidEnumValues(this._def.values)),"f");if(!x0(this,A0,"f").has($.data)){let W=R.objectValues(Q);return U(X,{received:X.data,code:M.invalid_enum_value,options:W}),_}return h($.data)}get enum(){return this._def.values}}A0=new WeakMap;D0.create=($,Q)=>{return new D0({values:$,typeName:S.ZodNativeEnum,...v(Q)})};class H0 extends A{unwrap(){return this._def.type}_parse($){let{ctx:Q}=this._processInputParams($);if(Q.parsedType!==F.promise&&Q.common.async===!1)return U(Q,{code:M.invalid_type,expected:F.promise,received:Q.parsedType}),_;let X=Q.parsedType===F.promise?Q.data:Promise.resolve(Q.data);return h(X.then((W)=>{return this._def.type.parseAsync(W,{path:Q.path,errorMap:Q.common.contextualErrorMap})}))}}H0.create=($,Q)=>{return new H0({type:$,typeName:S.ZodPromise,...v(Q)})};class Z extends A{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===S.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:Q,ctx:X}=this._processInputParams($),W=this._def.effect||null,J={addIssue:(H)=>{if(U(X,H),H.fatal)Q.abort();else Q.dirty()},get path(){return X.path}};if(J.addIssue=J.addIssue.bind(J),W.type==="preprocess"){let H=W.transform(X.data,J);if(X.common.async)return Promise.resolve(H).then(async(z)=>{if(Q.value==="aborted")return _;let q=await this._def.schema._parseAsync({data:z,path:X.path,parent:X});if(q.status==="aborted")return _;if(q.status==="dirty")return w0(q.value);if(Q.value==="dirty")return w0(q.value);return q});else{if(Q.value==="aborted")return _;let z=this._def.schema._parseSync({data:H,path:X.path,parent:X});if(z.status==="aborted")return _;if(z.status==="dirty")return w0(z.value);if(Q.value==="dirty")return w0(z.value);return z}}if(W.type==="refinement"){let H=(z)=>{let q=W.refinement(z,J);if(X.common.async)return Promise.resolve(q);if(q instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return z};if(X.common.async===!1){let z=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(z.status==="aborted")return _;if(z.status==="dirty")Q.dirty();return H(z.value),{status:Q.value,value:z.value}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((z)=>{if(z.status==="aborted")return _;if(z.status==="dirty")Q.dirty();return H(z.value).then(()=>{return{status:Q.value,value:z.value}})})}if(W.type==="transform")if(X.common.async===!1){let H=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(!J0(H))return H;let z=W.transform(H.value,J);if(z instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:Q.value,value:z}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((H)=>{if(!J0(H))return H;return Promise.resolve(W.transform(H.value,J)).then((z)=>({status:Q.value,value:z}))});R.assertNever(W)}}Z.create=($,Q,X)=>{return new Z({schema:$,typeName:S.ZodEffects,effect:Q,...v(X)})};Z.createWithPreprocess=($,Q,X)=>{return new Z({schema:Q,effect:{type:"preprocess",transform:$},typeName:S.ZodEffects,...v(X)})};class c extends A{_parse($){if(this._getType($)===F.undefined)return h(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}c.create=($,Q)=>{return new c({innerType:$,typeName:S.ZodOptional,...v(Q)})};class r extends A{_parse($){if(this._getType($)===F.null)return h(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}r.create=($,Q)=>{return new r({innerType:$,typeName:S.ZodNullable,...v(Q)})};class N0 extends A{_parse($){let{ctx:Q}=this._processInputParams($),X=Q.data;if(Q.parsedType===F.undefined)X=this._def.defaultValue();return this._def.innerType._parse({data:X,path:Q.path,parent:Q})}removeDefault(){return this._def.innerType}}N0.create=($,Q)=>{return new N0({innerType:$,typeName:S.ZodDefault,defaultValue:typeof Q.default==="function"?Q.default:()=>Q.default,...v(Q)})};class S0 extends A{_parse($){let{ctx:Q}=this._processInputParams($),X={...Q,common:{...Q.common,issues:[]}},W=this._def.innerType._parse({data:X.data,path:X.path,parent:{...X}});if(b0(W))return W.then((J)=>{return{status:"valid",value:J.status==="valid"?J.value:this._def.catchValue({get error(){return new x(X.common.issues)},input:X.data})}});else return{status:"valid",value:W.status==="valid"?W.value:this._def.catchValue({get error(){return new x(X.common.issues)},input:X.data})}}removeCatch(){return this._def.innerType}}S0.create=($,Q)=>{return new S0({innerType:$,typeName:S.ZodCatch,catchValue:typeof Q.catch==="function"?Q.catch:()=>Q.catch,...v(Q)})};class E0 extends A{_parse($){if(this._getType($)!==F.nan){let X=this._getOrReturnCtx($);return U(X,{code:M.invalid_type,expected:F.nan,received:X.parsedType}),_}return{status:"valid",value:$.data}}}E0.create=($)=>{return new E0({typeName:S.ZodNaN,...v($)})};var _4=Symbol("zod_brand");class Z0 extends A{_parse($){let{ctx:Q}=this._processInputParams($),X=Q.data;return this._def.type._parse({data:X,path:Q.path,parent:Q})}unwrap(){return this._def.type}}class P0 extends A{_parse($){let{status:Q,ctx:X}=this._processInputParams($);if(X.common.async)return(async()=>{let J=await this._def.in._parseAsync({data:X.data,path:X.path,parent:X});if(J.status==="aborted")return _;if(J.status==="dirty")return Q.dirty(),w0(J.value);else return this._def.out._parseAsync({data:J.value,path:X.path,parent:X})})();else{let W=this._def.in._parseSync({data:X.data,path:X.path,parent:X});if(W.status==="aborted")return _;if(W.status==="dirty")return Q.dirty(),{status:"dirty",value:W.value};else return this._def.out._parseSync({data:W.value,path:X.path,parent:X})}}static create($,Q){return new P0({in:$,out:Q,typeName:S.ZodPipeline})}}class _0 extends A{_parse($){let Q=this._def.innerType._parse($),X=(W)=>{if(J0(W))W.value=Object.freeze(W.value);return W};return b0(Q)?Q.then((W)=>X(W)):X(Q)}unwrap(){return this._def.innerType}}_0.create=($,Q)=>{return new _0({innerType:$,typeName:S.ZodReadonly,...v(Q)})};function v1($,Q={},X){if($)return Y0.create().superRefine((W,J)=>{var H,z;if(!$(W)){let q=typeof Q==="function"?Q(W):typeof Q==="string"?{message:Q}:Q,j=(z=(H=q.fatal)!==null&&H!==void 0?H:X)!==null&&z!==void 0?z:!0,D=typeof q==="string"?{message:q}:q;J.addIssue({code:"custom",...D,fatal:j})}});return Y0.create()}var v4={object:C.lazycreate},S;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(S||(S={}));var A4=($,Q={message:`Input not instance of ${$.name}`})=>v1((X)=>X instanceof $,Q),A1=m.create,b1=$0.create,b4=E0.create,R4=Q0.create,R1=j0.create,f4=W0.create,k4=R0.create,C4=V0.create,E4=O0.create,P4=Y0.create,I4=e.create,h4=d.create,g4=f0.create,T4=l.create,x4=C.create,y4=C.strictCreate,Z4=L0.create,m4=y0.create,l4=U0.create,c4=i.create,u4=k0.create,n4=C0.create,p4=G0.create,d4=q0.create,i4=F0.create,a4=K0.create,o4=X0.create,t4=D0.create,s4=H0.create,U1=Z.create,r4=c.create,e4=r.create,$2=Z.createWithPreprocess,Q2=P0.create,X2=()=>A1().optional(),J2=()=>b1().optional(),W2=()=>R1().optional(),Y2={string:($)=>m.create({...$,coerce:!0}),number:($)=>$0.create({...$,coerce:!0}),boolean:($)=>j0.create({...$,coerce:!0}),bigint:($)=>Q0.create({...$,coerce:!0}),date:($)=>W0.create({...$,coerce:!0})},G2=_,Y=Object.freeze({__proto__:null,defaultErrorMap:M0,setErrorMap:$4,getErrorMap:g0,makeIssue:T0,EMPTY_PATH:Q4,addIssueToContext:U,ParseStatus:I,INVALID:_,DIRTY:w0,OK:h,isAborted:e0,isDirty:$1,isValid:J0,isAsync:b0,get util(){return R},get objectUtil(){return r0},ZodParsedType:F,getParsedType:s,ZodType:A,datetimeRegex:S1,ZodString:m,ZodNumber:$0,ZodBigInt:Q0,ZodBoolean:j0,ZodDate:W0,ZodSymbol:R0,ZodUndefined:V0,ZodNull:O0,ZodAny:Y0,ZodUnknown:e,ZodNever:d,ZodVoid:f0,ZodArray:l,ZodObject:C,ZodUnion:L0,ZodDiscriminatedUnion:y0,ZodIntersection:U0,ZodTuple:i,ZodRecord:k0,ZodMap:C0,ZodSet:G0,ZodFunction:q0,ZodLazy:F0,ZodLiteral:K0,ZodEnum:X0,ZodNativeEnum:D0,ZodPromise:H0,ZodEffects:Z,ZodTransformer:Z,ZodOptional:c,ZodNullable:r,ZodDefault:N0,ZodCatch:S0,ZodNaN:E0,BRAND:_4,ZodBranded:Z0,ZodPipeline:P0,ZodReadonly:_0,custom:v1,Schema:A,ZodSchema:A,late:v4,get ZodFirstPartyTypeKind(){return S},coerce:Y2,any:P4,array:T4,bigint:R4,boolean:R1,date:f4,discriminatedUnion:m4,effect:U1,enum:o4,function:d4,instanceof:A4,intersection:l4,lazy:i4,literal:a4,map:n4,nan:b4,nativeEnum:t4,never:h4,null:E4,nullable:e4,number:b1,object:x4,oboolean:W2,onumber:J2,optional:r4,ostring:X2,pipeline:Q2,preprocess:$2,promise:s4,record:u4,set:p4,strictObject:y4,string:A1,symbol:k4,transformer:U1,tuple:c4,undefined:C4,union:Z4,unknown:I4,void:g4,NEVER:G2,ZodIssueCode:M,quotelessJson:e1,ZodError:x});var X1="2024-11-05",f1=[X1,"2024-10-07"],m0="2.0",k1=Y.union([Y.string(),Y.number().int()]),C1=Y.string(),n=Y.object({_meta:Y.optional(Y.object({progressToken:Y.optional(k1)}).passthrough())}).passthrough(),y=Y.object({method:Y.string(),params:Y.optional(n)}),I0=Y.object({_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),a=Y.object({method:Y.string(),params:Y.optional(I0)}),p=Y.object({_meta:Y.optional(Y.object({}).passthrough())}).passthrough(),l0=Y.union([Y.string(),Y.number().int()]),H2=Y.object({jsonrpc:Y.literal(m0),id:l0}).merge(y).strict(),z2=Y.object({jsonrpc:Y.literal(m0)}).merge(a).strict(),B2=Y.object({jsonrpc:Y.literal(m0),id:l0,result:p}).strict(),z0;(function($){$[$.ConnectionClosed=-1]="ConnectionClosed",$[$.RequestTimeout=-2]="RequestTimeout",$[$.ParseError=-32700]="ParseError",$[$.InvalidRequest=-32600]="InvalidRequest",$[$.MethodNotFound=-32601]="MethodNotFound",$[$.InvalidParams=-32602]="InvalidParams",$[$.InternalError=-32603]="InternalError"})(z0||(z0={}));var w2=Y.object({jsonrpc:Y.literal(m0),id:l0,error:Y.object({code:Y.number().int(),message:Y.string(),data:Y.optional(Y.unknown())})}).strict(),E1=Y.union([H2,z2,B2,w2]),c0=p.strict(),u0=a.extend({method:Y.literal("notifications/cancelled"),params:I0.extend({requestId:l0,reason:Y.string().optional()})}),P1=Y.object({name:Y.string(),version:Y.string()}).passthrough(),q2=Y.object({experimental:Y.optional(Y.object({}).passthrough()),sampling:Y.optional(Y.object({}).passthrough()),roots:Y.optional(Y.object({listChanged:Y.optional(Y.boolean())}).passthrough())}).passthrough(),J1=y.extend({method:Y.literal("initialize"),params:n.extend({protocolVersion:Y.string(),capabilities:q2,clientInfo:P1})}),M2=Y.object({experimental:Y.optional(Y.object({}).passthrough()),logging:Y.optional(Y.object({}).passthrough()),prompts:Y.optional(Y.object({listChanged:Y.optional(Y.boolean())}).passthrough()),resources:Y.optional(Y.object({subscribe:Y.optional(Y.boolean()),listChanged:Y.optional(Y.boolean())}).passthrough()),tools:Y.optional(Y.object({listChanged:Y.optional(Y.boolean())}).passthrough())}).passthrough(),j2=p.extend({protocolVersion:Y.string(),capabilities:M2,serverInfo:P1}),W1=a.extend({method:Y.literal("notifications/initialized")}),n0=y.extend({method:Y.literal("ping")}),V2=Y.object({progress:Y.number(),total:Y.optional(Y.number())}).passthrough(),p0=a.extend({method:Y.literal("notifications/progress"),params:I0.merge(V2).extend({progressToken:k1})}),d0=y.extend({params:n.extend({cursor:Y.optional(C1)}).optional()}),i0=p.extend({nextCursor:Y.optional(C1)}),I1=Y.object({uri:Y.string(),mimeType:Y.optional(Y.string())}).passthrough(),h1=I1.extend({text:Y.string()}),g1=I1.extend({blob:Y.string().base64()}),O2=Y.object({uri:Y.string(),name:Y.string(),description:Y.optional(Y.string()),mimeType:Y.optional(Y.string())}).passthrough(),L2=Y.object({uriTemplate:Y.string(),name:Y.string(),description:Y.optional(Y.string()),mimeType:Y.optional(Y.string())}).passthrough(),U2=d0.extend({method:Y.literal("resources/list")}),F2=i0.extend({resources:Y.array(O2)}),K2=d0.extend({method:Y.literal("resources/templates/list")}),D2=i0.extend({resourceTemplates:Y.array(L2)}),N2=y.extend({method:Y.literal("resources/read"),params:n.extend({uri:Y.string()})}),S2=p.extend({contents:Y.array(Y.union([h1,g1]))}),_2=a.extend({method:Y.literal("notifications/resources/list_changed")}),v2=y.extend({method:Y.literal("resources/subscribe"),params:n.extend({uri:Y.string()})}),A2=y.extend({method:Y.literal("resources/unsubscribe"),params:n.extend({uri:Y.string()})}),b2=a.extend({method:Y.literal("notifications/resources/updated"),params:I0.extend({uri:Y.string()})}),R2=Y.object({name:Y.string(),description:Y.optional(Y.string()),required:Y.optional(Y.boolean())}).passthrough(),f2=Y.object({name:Y.string(),description:Y.optional(Y.string()),arguments:Y.optional(Y.array(R2))}).passthrough(),k2=d0.extend({method:Y.literal("prompts/list")}),C2=i0.extend({prompts:Y.array(f2)}),E2=y.extend({method:Y.literal("prompts/get"),params:n.extend({name:Y.string(),arguments:Y.optional(Y.record(Y.string()))})}),a0=Y.object({type:Y.literal("text"),text:Y.string()}).passthrough(),o0=Y.object({type:Y.literal("image"),data:Y.string().base64(),mimeType:Y.string()}).passthrough(),T1=Y.object({type:Y.literal("resource"),resource:Y.union([h1,g1])}).passthrough(),P2=Y.object({role:Y.enum(["user","assistant"]),content:Y.union([a0,o0,T1])}).passthrough(),I2=p.extend({description:Y.optional(Y.string()),messages:Y.array(P2)}),h2=a.extend({method:Y.literal("notifications/prompts/list_changed")}),g2=Y.object({name:Y.string(),description:Y.optional(Y.string()),inputSchema:Y.object({type:Y.literal("object"),properties:Y.optional(Y.object({}).passthrough())}).passthrough()}).passthrough(),Y1=d0.extend({method:Y.literal("tools/list")}),T2=i0.extend({tools:Y.array(g2)}),x1=p.extend({content:Y.array(Y.union([a0,o0,T1])),isError:Y.boolean().default(!1).optional()}),E6=x1.or(p.extend({toolResult:Y.unknown()})),G1=y.extend({method:Y.literal("tools/call"),params:n.extend({name:Y.string(),arguments:Y.optional(Y.record(Y.unknown()))})}),x2=a.extend({method:Y.literal("notifications/tools/list_changed")}),y1=Y.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),y2=y.extend({method:Y.literal("logging/setLevel"),params:n.extend({level:y1})}),Z2=a.extend({method:Y.literal("notifications/message"),params:I0.extend({level:y1,logger:Y.optional(Y.string()),data:Y.unknown()})}),m2=Y.object({name:Y.string().optional()}).passthrough(),l2=Y.object({hints:Y.optional(Y.array(m2)),costPriority:Y.optional(Y.number().min(0).max(1)),speedPriority:Y.optional(Y.number().min(0).max(1)),intelligencePriority:Y.optional(Y.number().min(0).max(1))}).passthrough(),c2=Y.object({role:Y.enum(["user","assistant"]),content:Y.union([a0,o0])}).passthrough(),u2=y.extend({method:Y.literal("sampling/createMessage"),params:n.extend({messages:Y.array(c2),systemPrompt:Y.optional(Y.string()),includeContext:Y.optional(Y.enum(["none","thisServer","allServers"])),temperature:Y.optional(Y.number()),maxTokens:Y.number().int(),stopSequences:Y.optional(Y.array(Y.string())),metadata:Y.optional(Y.object({}).passthrough()),modelPreferences:Y.optional(l2)})}),H1=p.extend({model:Y.string(),stopReason:Y.optional(Y.enum(["endTurn","stopSequence","maxTokens"]).or(Y.string())),role:Y.enum(["user","assistant"]),content:Y.discriminatedUnion("type",[a0,o0])}),n2=Y.object({type:Y.literal("ref/resource"),uri:Y.string()}).passthrough(),p2=Y.object({type:Y.literal("ref/prompt"),name:Y.string()}).passthrough(),d2=y.extend({method:Y.literal("completion/complete"),params:n.extend({ref:Y.union([p2,n2]),argument:Y.object({name:Y.string(),value:Y.string()}).passthrough()})}),i2=p.extend({completion:Y.object({values:Y.array(Y.string()).max(100),total:Y.optional(Y.number().int()),hasMore:Y.optional(Y.boolean())}).passthrough()}),a2=Y.object({uri:Y.string().startsWith("file://"),name:Y.optional(Y.string())}).passthrough(),o2=y.extend({method:Y.literal("roots/list")}),z1=p.extend({roots:Y.array(a2)}),t2=a.extend({method:Y.literal("notifications/roots/list_changed")}),P6=Y.union([n0,J1,d2,y2,E2,k2,U2,K2,N2,v2,A2,G1,Y1]),I6=Y.union([u0,p0,W1,t2]),h6=Y.union([c0,H1,z1]),g6=Y.union([n0,u2,o2]),T6=Y.union([u0,p0,Z2,b2,_2,x2,h2]),x6=Y.union([c0,j2,i2,I2,C2,F2,D2,S2,x1,T2]);class h0 extends Error{constructor($,Q,X){super(`MCP error ${$}: ${Q}`);this.code=$,this.data=X}}var s2=60000;class B1{constructor($){this._options=$,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this.setNotificationHandler(u0,(Q)=>{let X=this._requestHandlerAbortControllers.get(Q.params.requestId);X===null||X===void 0||X.abort(Q.params.reason)}),this.setNotificationHandler(p0,(Q)=>{this._onprogress(Q)}),this.setRequestHandler(n0,(Q)=>({}))}async connect($){this._transport=$,this._transport.onclose=()=>{this._onclose()},this._transport.onerror=(Q)=>{this._onerror(Q)},this._transport.onmessage=(Q)=>{if(!("method"in Q))this._onresponse(Q);else if("id"in Q)this._onrequest(Q);else this._onnotification(Q)},await this._transport.start()}_onclose(){var $;let Q=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,($=this.onclose)===null||$===void 0||$.call(this);let X=new h0(z0.ConnectionClosed,"Connection closed");for(let W of Q.values())W(X)}_onerror($){var Q;(Q=this.onerror)===null||Q===void 0||Q.call(this,$)}_onnotification($){var Q;let X=(Q=this._notificationHandlers.get($.method))!==null&&Q!==void 0?Q:this.fallbackNotificationHandler;if(X===void 0)return;Promise.resolve().then(()=>X($)).catch((W)=>this._onerror(Error(`Uncaught error in notification handler: ${W}`)))}_onrequest($){var Q,X;let W=(Q=this._requestHandlers.get($.method))!==null&&Q!==void 0?Q:this.fallbackRequestHandler;if(W===void 0){(X=this._transport)===null||X===void 0||X.send({jsonrpc:"2.0",id:$.id,error:{code:z0.MethodNotFound,message:"Method not found"}}).catch((H)=>this._onerror(Error(`Failed to send an error response: ${H}`)));return}let J=new AbortController;this._requestHandlerAbortControllers.set($.id,J),Promise.resolve().then(()=>W($,{signal:J.signal})).then((H)=>{var z;if(J.signal.aborted)return;return(z=this._transport)===null||z===void 0?void 0:z.send({result:H,jsonrpc:"2.0",id:$.id})},(H)=>{var z,q;if(J.signal.aborted)return;return(z=this._transport)===null||z===void 0?void 0:z.send({jsonrpc:"2.0",id:$.id,error:{code:Number.isSafeInteger(H.code)?H.code:z0.InternalError,message:(q=H.message)!==null&&q!==void 0?q:"Internal error"}})}).catch((H)=>this._onerror(Error(`Failed to send response: ${H}`))).finally(()=>{this._requestHandlerAbortControllers.delete($.id)})}_onprogress($){let{progressToken:Q,...X}=$.params,W=this._progressHandlers.get(Number(Q));if(W===void 0){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify($)}`));return}W(X)}_onresponse($){let Q=$.id,X=this._responseHandlers.get(Number(Q));if(X===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify($)}`));return}if(this._responseHandlers.delete(Number(Q)),this._progressHandlers.delete(Number(Q)),"result"in $)X($);else{let W=new h0($.error.code,$.error.message,$.error.data);X(W)}}get transport(){return this._transport}async close(){var $;await(($=this._transport)===null||$===void 0?void 0:$.close())}request($,Q,X){return new Promise((W,J)=>{var H,z,q,j;if(!this._transport){J(Error("Not connected"));return}if(((H=this._options)===null||H===void 0?void 0:H.enforceStrictCapabilities)===!0)this.assertCapabilityForMethod($.method);(z=X===null||X===void 0?void 0:X.signal)===null||z===void 0||z.throwIfAborted();let D=this._requestMessageId++,b={...$,jsonrpc:"2.0",id:D};if(X===null||X===void 0?void 0:X.onprogress)this._progressHandlers.set(D,X.onprogress),b.params={...$.params,_meta:{progressToken:D}};let E=void 0;this._responseHandlers.set(D,(k)=>{var T;if(E!==void 0)clearTimeout(E);if((T=X===null||X===void 0?void 0:X.signal)===null||T===void 0?void 0:T.aborted)return;if(k instanceof Error)return J(k);try{let o=Q.parse(k.result);W(o)}catch(o){J(o)}});let P=(k)=>{var T;this._responseHandlers.delete(D),this._progressHandlers.delete(D),(T=this._transport)===null||T===void 0||T.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:D,reason:String(k)}}).catch((o)=>this._onerror(Error(`Failed to send cancellation: ${o}`))),J(k)};(q=X===null||X===void 0?void 0:X.signal)===null||q===void 0||q.addEventListener("abort",()=>{var k;if(E!==void 0)clearTimeout(E);P((k=X===null||X===void 0?void 0:X.signal)===null||k===void 0?void 0:k.reason)});let g=(j=X===null||X===void 0?void 0:X.timeout)!==null&&j!==void 0?j:s2;E=setTimeout(()=>P(new h0(z0.RequestTimeout,"Request timed out",{timeout:g})),g),this._transport.send(b).catch((k)=>{if(E!==void 0)clearTimeout(E);J(k)})})}async notification($){if(!this._transport)throw Error("Not connected");this.assertNotificationCapability($.method);let Q={...$,jsonrpc:"2.0"};await this._transport.send(Q)}setRequestHandler($,Q){let X=$.shape.method.value;this.assertRequestHandlerCapability(X),this._requestHandlers.set(X,(W,J)=>Promise.resolve(Q($.parse(W),J)))}removeRequestHandler($){this._requestHandlers.delete($)}setNotificationHandler($,Q){this._notificationHandlers.set($.shape.method.value,(X)=>Promise.resolve(Q($.parse(X))))}removeNotificationHandler($){this._notificationHandlers.delete($)}}class w1 extends B1{constructor($,Q){super(Q);this._serverInfo=$,this._capabilities=Q.capabilities,this.setRequestHandler(J1,(X)=>this._oninitialize(X)),this.setNotificationHandler(W1,()=>{var X;return(X=this.oninitialized)===null||X===void 0?void 0:X.call(this)})}assertCapabilityForMethod($){var Q,X;switch($){case"sampling/createMessage":if(!((Q=this._clientCapabilities)===null||Q===void 0?void 0:Q.sampling))throw Error(`Client does not support sampling (required for ${$})`);break;case"roots/list":if(!((X=this._clientCapabilities)===null||X===void 0?void 0:X.roots))throw Error(`Client does not support listing roots (required for ${$})`);break;case"ping":break}}assertNotificationCapability($){switch($){case"notifications/message":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${$})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${$})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${$})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${$})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability($){switch($){case"sampling/createMessage":if(!this._capabilities.sampling)throw Error(`Server does not support sampling (required for ${$})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${$})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${$})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${$})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${$})`);break;case"ping":case"initialize":break}}async _oninitialize($){let Q=$.params.protocolVersion;return this._clientCapabilities=$.params.capabilities,this._clientVersion=$.params.clientInfo,{protocolVersion:f1.includes(Q)?Q:X1,capabilities:this.getCapabilities(),serverInfo:this._serverInfo}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},c0)}async createMessage($,Q){return this.request({method:"sampling/createMessage",params:$},H1,Q)}async listRoots($,Q){return this.request({method:"roots/list",params:$},z1,Q)}async sendLoggingMessage($){return this.notification({method:"notifications/message",params:$})}async sendResourceUpdated($){return this.notification({method:"notifications/resources/updated",params:$})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}import m1 from"process";class q1{append($){this._buffer=this._buffer?Buffer.concat([this._buffer,$]):$}readMessage(){if(!this._buffer)return null;let $=this._buffer.indexOf(`
|
|
3
|
+
`);if($===-1)return null;let Q=this._buffer.toString("utf8",0,$);return this._buffer=this._buffer.subarray($+1),r2(Q)}clear(){this._buffer=void 0}}function r2($){return E1.parse(JSON.parse($))}function Z1($){return JSON.stringify($)+`
|
|
4
|
+
`}class M1{constructor($=m1.stdin,Q=m1.stdout){this._stdin=$,this._stdout=Q,this._readBuffer=new q1,this._started=!1,this._ondata=(X)=>{this._readBuffer.append(X),this.processReadBuffer()},this._onerror=(X)=>{var W;(W=this.onerror)===null||W===void 0||W.call(this,X)}}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){var $,Q;while(!0)try{let X=this._readBuffer.readMessage();if(X===null)break;($=this.onmessage)===null||$===void 0||$.call(this,X)}catch(X){(Q=this.onerror)===null||Q===void 0||Q.call(this,X)}}async close(){var $;this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._readBuffer.clear(),($=this.onclose)===null||$===void 0||$.call(this)}send($){return new Promise((Q)=>{let X=Z1($);if(this._stdout.write(X))Q();else this._stdout.once("drain",Q)})}}var $6=await Promise.resolve().then(() => s1(l1(),1)),c1=$6.version;async function u1($){let Q=new w1({name:"typescape",version:c1},{capabilities:{tools:{}}});Q.setRequestHandler(Y1,async()=>{return{tools:$.getTools().map((J)=>({name:J.name,description:J.description,inputSchema:J.inputSchema}))}}),Q.setRequestHandler(G1,async(W)=>{let{name:J,arguments:H}=W.params,z=$.getHandler(J);if(!z)return{content:[{type:"text",text:`Unknown tool: ${J}`}],isError:!0};try{let q=await z(H||{});return{content:q.content.map((j)=>({type:j.type,text:j.text})),isError:q.isError}}catch(q){return{content:[{type:"text",text:`Error: ${q instanceof Error?q.message:String(q)}`}],isError:!0}}});let X=new M1;await Q.connect(X),console.error(`Typescape MCP server v${c1} started`)}var Q6={type:"object",properties:{repo_id:{type:"string",description:"Repository identifier"},git_sha:{type:"string",description:"Concrete 40-hex Git commit SHA (agent must resolve; no symbolic refs)"},file_path:{type:"string",description:"Path to Markdown file within the repo"},title:{type:"string",description:"Session title (optional)"},participants:{type:"array",minItems:1,items:{type:"object",properties:{email:{type:"string"},name:{type:"string"},role:{type:"string",enum:["reviewer","approver","observer","owner"]},scopes:{type:"array",minItems:1,items:{type:"string",enum:["read","comment","approve","admin"]}}},required:["email","role","scopes"]},description:"Participants to invite (at least one required). Each must include email, role, and scopes."},idempotency_key:{type:"string",description:"Idempotency key for safe retries (optional)"},expected_version:{type:"string",description:"Expected version for optimistic concurrency (If-Match header, optional)"}},required:["repo_id","git_sha","file_path","participants"]},X6={type:"object",properties:{session_id:{type:"string",description:"ID of the session to supersede (the predecessor, e.g., sess_01HXYZ...)"},git_sha:{type:"string",description:"Concrete 40-hex Git commit SHA for the new revision (agent must resolve; no symbolic refs)"},file_path:{type:"string",description:"Path to Markdown file within the repo (optional; defaults to predecessor's file_path)"},title:{type:"string",description:"Title for the new session (optional; defaults to predecessor's title)"},idempotency_key:{type:"string",description:"Idempotency key for safe retries (optional)"}},required:["session_id","git_sha"]},J6={type:"object",properties:{session_id:{type:"string",description:"Session ID to export (e.g., sess_01HXYZ...)"},schema:{type:"string",default:"v1",description:"Export schema version (default: v1)"},view:{type:"string",description:"Export view variant (optional). Values: redacted, response_matrix.v1, delta_review.v1"},expected_version:{type:"string",description:"Expected version for optimistic concurrency (If-Match header, optional)"}},required:["session_id"]},W6={type:"object",properties:{repo_id:{type:"string",description:"Filter sessions by repository identifier (optional)"},state:{type:"string",description:"Filter by session state: active, closed, archived (optional)"},file_paths:{type:"string",description:"Comma-separated list of file paths to filter by (optional)"},cursor:{type:"string",description:"Pagination cursor from previous response (optional)"},limit:{type:"number",description:"Maximum number of sessions to return (optional, default: 20)"}},required:[]},Y6={type:"object",properties:{session_id:{type:"string",description:"Session ID to retrieve (e.g., sess_01HXYZ...)"}},required:["session_id"]},G6={type:"object",properties:{session_id:{type:"string",description:"Session ID to render (e.g., sess_01HXYZ...)"},include_plaintext:{type:"boolean",description:"Include plaintext representation alongside HTML (optional, default: false)"}},required:["session_id"]},H6={type:"object",properties:{session_id:{type:"string",description:"Session ID to list threads for (e.g., sess_01HXYZ...)"},block_id:{type:"string",description:"Filter threads by block_id anchor (optional)"},status:{type:"string",description:"Filter threads by status: open, resolved, all (optional, default: all)"},cursor:{type:"string",description:"Pagination cursor from previous response (optional)"},limit:{type:"number",description:"Maximum number of threads to return (optional, default: 50)"}},required:["session_id"]},z6={type:"object",properties:{session_id:{type:"string",description:"Session ID to export response matrix for (e.g., sess_01HXYZ...)"}},required:["session_id"]};function f($,Q){return{content:[{type:"text",text:JSON.stringify({...$,request_id:Q},null,2)}]}}function O($){let Q=$.status===0||$.status>=500||$.status===429;return{content:[{type:"text",text:JSON.stringify({error:{code:$.code,message:$.message,retryable:Q,request_id:$.requestId}},null,2)}],isError:!0}}var B6={type:"object",properties:{source_type:{type:"string",enum:["git","upload"],description:"Source type for the review set"},title:{type:"string",description:"Review set title (optional)"},kind:{type:"string",enum:["review_set","release_bundle","packet"],description:"Kind of review set (optional, default: review_set)"},participants:{type:"array",items:{type:"object",properties:{email:{type:"string"},role:{type:"string"}},required:["email","role"]},description:"Participants to invite (optional)"},idempotency_key:{type:"string",description:"Idempotency key for safe retries (optional)"}},required:["source_type"]},w6={type:"object",properties:{review_set_id:{type:"string",description:"Review set ID to export"},schema:{type:"string",description:"Export schema version (optional, default: v1)"},view:{type:"string",description:"Export view variant (optional). Values: full, redacted, response_matrix.v1, etc."}},required:["review_set_id"]},q6={type:"object",properties:{source_type:{type:"string",enum:["git","upload"],description:"Source type for the review ref"},repo_id:{type:"string",description:"Repository identifier (for git source_type)"},project_id:{type:"string",description:"Project identifier (for upload source_type)"},kind:{type:"string",description:"Review ref kind (e.g., 'branch', 'pr')"},key:{type:"string",description:"Review ref key (e.g., branch name, PR number)"},file_path:{type:"string",description:"File path within the repository"},git_sha:{type:"string",description:"Git SHA for initial head (for git source_type)"},upload_batch_id:{type:"string",description:"Upload batch ID for initial head (for upload source_type)"}},required:["source_type","kind","key"]},M6={type:"object",properties:{review_ref_id:{type:"string",description:"Review ref ID to resolve"}},required:["review_ref_id"]},j6={type:"object",properties:{review_ref_id:{type:"string",description:"Review ref ID to advance"},head_session_id:{type:"string",description:"New head session ID to advance to"},expected_head_session_id:{type:"string",description:"Expected current head for optimistic concurrency (optional)"}},required:["review_ref_id","head_session_id"]},V6={type:"object",properties:{session_id:{type:"string",description:"Session ID to request approval for"},approver_emails:{type:"array",items:{type:"string"},description:"Email addresses of approvers"},message:{type:"string",description:"Message to include with the approval request (optional)"},notify:{type:"object",properties:{email:{type:"boolean"},slack:{type:"boolean"}},description:"Notification channels (optional)"},idempotency_key:{type:"string",description:"Idempotency key for safe retries (optional)"}},required:["session_id","approver_emails"]},O6={type:"object",properties:{session_id:{type:"string",description:"Session ID to record decision for"},decision:{type:"string",enum:["approve","deny","abstain"],description:"Approval decision"},comment_md:{type:"string",description:"Comment in Markdown (optional)"},conditions:{type:"array",items:{type:"object",properties:{type:{type:"string"},description:{type:"string"}},required:["type"]},description:"Conditions for the approval (optional)"},idempotency_key:{type:"string",description:"Idempotency key for safe retries (optional)"}},required:["session_id","decision"]},L6={type:"object",properties:{session_id:{type:"string",description:"Session ID to get status for"},simulate:{type:"boolean",description:"Run policy evaluation without side effects (optional)"},wait:{type:"number",description:"Long-poll timeout in seconds (optional)"}},required:["session_id"]},U6={type:"object",properties:{session_id:{type:"string",description:"Session ID to run checks against"}},required:["session_id"]},F6={type:"object",properties:{session_id:{type:"string",description:"Session ID to create thread in (e.g., sess_01HXYZ...)"},body_md:{type:"string",description:"Thread body in Markdown"},block_id:{type:"string",description:"Block ID to anchor thread to (optional; omit for session-level)"},anchor:{type:"object",properties:{type:{type:"string",enum:["session","block","range"],description:"Anchor type (default: session if no block_id, block if block_id provided)"},start_offset:{type:"number",description:"Start offset for range anchor"},end_offset:{type:"number",description:"End offset for range anchor"}},description:"Anchor details (optional)"},severity:{type:"string",enum:["suggestion","needs_changes","blocking"],description:"Thread severity. Note: 'blocking' from automation is coerced to 'needs_changes' per Ch 11 L6250"},tags:{type:"array",items:{type:"string"},description:"Tags for categorization (optional)"},suggestion:{type:"object",properties:{type:{type:"string",enum:["replace","insert","delete"]}},description:"Suggested change (optional)"},idempotency_key:{type:"string",description:"Idempotency key for safe retries (optional)"}},required:["session_id","body_md"]},K6={type:"object",properties:{session_id:{type:"string",description:"Session ID containing the thread"},thread_id:{type:"string",description:"Thread ID to post comment to"},body_md:{type:"string",description:"Comment body in Markdown"},idempotency_key:{type:"string",description:"Idempotency key for safe retries (optional)"}},required:["session_id","thread_id","body_md"]},D6={type:"object",properties:{session_id:{type:"string",description:"Session ID containing the thread"},thread_id:{type:"string",description:"Thread ID to resolve"},disposition:{type:"object",properties:{state:{type:"string",enum:["accepted_change","rejected_wont_fix","deferred","duplicate","needs_more_info","answered_no_change"],description:"Disposition state"},rationale_md:{type:"string",description:"Rationale in Markdown (optional)"}},required:["state"],description:"Disposition to record with resolution (optional)"},expected_version:{type:"string",description:"Expected version for optimistic concurrency (If-Match header, optional)"}},required:["session_id","thread_id"]},N6={type:"object",properties:{session_id:{type:"string",description:"Session ID containing the thread"},thread_id:{type:"string",description:"Thread ID to reopen"},expected_version:{type:"string",description:"Expected version for optimistic concurrency (If-Match header, optional)"}},required:["session_id","thread_id"]},S6={type:"object",properties:{session_id:{type:"string",description:"Session ID containing the thread"},thread_id:{type:"string",description:"Thread ID to record disposition for"},state:{type:"string",enum:["undecided","accepted_change","rejected_wont_fix","deferred","duplicate","needs_more_info","answered_no_change"],description:"Disposition state"},rationale_md:{type:"string",description:"Rationale in Markdown (optional)"}},required:["session_id","thread_id","state"]},_6={type:"object",properties:{session_id:{type:"string",description:"Session ID containing the thread"},thread_id:{type:"string",description:"Thread ID to attach evidence to"},evidence:{type:"object",properties:{type:{type:"string",enum:["commit","proposed_change","pr_url","attestation"],description:"Evidence type"},commit_sha:{type:"string",description:"Git commit SHA (for commit type)"},proposed_change_id:{type:"string",description:"Proposed change ID (for proposed_change type)"},patch_sha256:{type:"string",description:"Patch SHA256 (for proposed_change type)"},url:{type:"string",description:"PR URL (for pr_url type)"},attestation_id:{type:"string",description:"Attestation ID (for attestation type)"}},required:["type"],description:"Evidence to attach"}},required:["session_id","thread_id","evidence"]};function n1($,Q){let X={name:"typescape_create_session",description:"Create a new Typescape review session for a Markdown file. Returns the session ID and any invitations sent. The agent must provide a concrete 40-hex Git SHA; no symbolic ref resolution is performed.",inputSchema:Q6};$.register(X,async(N)=>{let G=N;if(!G.repo_id)return O(new V(400,"missing_param","Missing required parameter: repo_id","local"));if(!G.git_sha)return O(new V(400,"missing_param","Missing required parameter: git_sha","local"));if(!G.file_path)return O(new V(400,"missing_param","Missing required parameter: file_path","local"));if(!G.participants)return O(new V(400,"missing_param","Missing required parameter: participants","local"));if(G.participants.length===0)return O(new V(422,"invalid_argument","participants must have at least 1 item","local"));let B={repo_id:G.repo_id,git_sha:G.git_sha,file_path:G.file_path,participants:G.participants};if(G.title!==void 0)B.title=G.title;let w={};if(G.idempotency_key)w["Idempotency-Key"]=G.idempotency_key;if(G.expected_version)w["If-Match"]=G.expected_version;try{let L=await Q.post("/sessions",{body:B,headers:w});return f({session:L.body.session,invitations:L.body.invitations??[]},L.requestId)}catch(L){if(L instanceof V)return O(L);throw L}});let W={name:"typescape_supersede_session",description:"Create a new Typescape review session pinned to a newer revision, superseding an existing session. The predecessor becomes read-only and unresolved threads are carried forward to the new session. The agent must provide a concrete 40-hex Git SHA.",inputSchema:X6};$.register(W,async(N)=>{let G=N;if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));if(!G.git_sha)return O(new V(400,"missing_param","Missing required parameter: git_sha","local"));if(!/^[a-f0-9]{40}$/i.test(G.git_sha))return O(new V(400,"invalid_param",`Invalid git_sha format: must be a 40-character hex string, got "${G.git_sha}"`,"local"));let B={git_sha:G.git_sha.toLowerCase()};if(G.file_path!==void 0)B.file_path=G.file_path;if(G.title!==void 0)B.title=G.title;let w={};if(G.idempotency_key)w["Idempotency-Key"]=G.idempotency_key;try{let L=await Q.post(`/sessions/${encodeURIComponent(G.session_id)}/supersede`,{body:B,headers:w});return f(L.body,L.requestId)}catch(L){if(L instanceof V)return O(L);throw L}});let J={name:"typescape_export_feedback",description:"Export all feedback from a Typescape review session as structured JSON. Returns the full export document including threads, comments, and anchors.",inputSchema:J6};$.register(J,async(N)=>{let G=N;if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));let B={schema:G.schema||"v1"};if(G.view)B.view=G.view;let w={};if(G.expected_version)w["If-Match"]=G.expected_version;try{let L=await Q.get(`/sessions/${G.session_id}/export`,{query:B,headers:w});return f(L.body,L.requestId)}catch(L){if(L instanceof V)return O(L);throw L}});let H={name:"typescape_list_sessions",description:"List Typescape review sessions with optional filters. Returns paginated session summaries. Use cursor from previous response for pagination.",inputSchema:W6};$.register(H,async(N)=>{let G=N,B={};if(G.repo_id)B.repo_id=G.repo_id;if(G.state)B.state=G.state;if(G.file_paths)B.file_paths=G.file_paths;if(G.cursor)B.cursor=G.cursor;if(G.limit!==void 0)B.limit=String(G.limit);try{let w=await Q.get("/sessions",{query:B});return f(w.body,w.requestId)}catch(w){if(w instanceof V)return O(w);throw w}});let z={name:"typescape_get_session",description:"Get details of a specific Typescape review session. Returns full session metadata including participants, stats, and provenance.",inputSchema:Y6};$.register(z,async(N)=>{let G=N;if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));try{let B=await Q.get(`/sessions/${G.session_id}`);return f(B.body,B.requestId)}catch(B){if(B instanceof V)return O(B);throw B}});let q={name:"typescape_get_render",description:"Get the rendered content of a review session. Returns immutable block-level HTML structure with block_ids for anchoring.",inputSchema:G6};$.register(q,async(N)=>{let G=N;if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));let B={};if(G.include_plaintext)B.include_plaintext="true";try{let w=await Q.get(`/sessions/${G.session_id}/render`,{query:B});return f(w.body,w.requestId)}catch(w){if(w instanceof V)return O(w);throw w}});let j={name:"typescape_get_threads",description:"List threads (comments) for a review session. Optionally filter by block_id anchor or thread status. Returns paginated thread list with comments.",inputSchema:H6};$.register(j,async(N)=>{let G=N;if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));let B={};if(G.block_id)B.block_id=G.block_id;if(G.status)B.status=G.status;if(G.cursor)B.cursor=G.cursor;if(G.limit!==void 0)B.limit=String(G.limit);try{let w=await Q.get(`/sessions/${G.session_id}/threads`,{query:B});return f(w.body,w.requestId)}catch(w){if(w instanceof V)return O(w);throw w}});let D={name:"typescape_export_response_matrix",description:"Export the response matrix for a review session. Returns per-thread disposition and evidence summary.",inputSchema:z6};$.register(D,async(N)=>{let G=N;if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));try{let B=await Q.get(`/sessions/${G.session_id}/export`,{query:{schema:"v1",view:"response_matrix.v1"}});return f(B.body,B.requestId)}catch(B){if(B instanceof V)return O(B);throw B}}),$.register({name:"typescape_create_thread",description:"Create a new thread (comment) on a review session. Optionally anchor to a specific block_id. Agent-created threads are tagged source='automation'. Severity 'blocking' is coerced to 'needs_changes' for automation sources.",inputSchema:F6},async(N)=>{let G=N;if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));if(!G.body_md)return O(new V(400,"missing_param","Missing required parameter: body_md","local"));let B={body_md:G.body_md,source:"automation"};if(G.block_id!==void 0)B.block_id=G.block_id;if(G.anchor!==void 0)B.anchor=G.anchor;if(G.severity!==void 0)B.severity=G.severity;if(G.tags!==void 0)B.tags=G.tags;if(G.suggestion!==void 0)B.suggestion=G.suggestion;let w={};if(G.idempotency_key)w["Idempotency-Key"]=G.idempotency_key;try{let L=await Q.post(`/sessions/${G.session_id}/threads`,{body:B,headers:w});return f(L.body,L.requestId)}catch(L){if(L instanceof V)return O(L);throw L}}),$.register({name:"typescape_post_comment",description:"Post a comment (reply) to an existing thread. Returns the created comment with its ID.",inputSchema:K6},async(N)=>{let G=N;if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));if(!G.thread_id)return O(new V(400,"missing_param","Missing required parameter: thread_id","local"));if(!G.body_md)return O(new V(400,"missing_param","Missing required parameter: body_md","local"));let B={body_md:G.body_md,source:"automation"},w={};if(G.idempotency_key)w["Idempotency-Key"]=G.idempotency_key;try{let L=await Q.post(`/sessions/${G.session_id}/threads/${G.thread_id}/comments`,{body:B,headers:w});return f(L.body,L.requestId)}catch(L){if(L instanceof V)return O(L);throw L}}),$.register({name:"typescape_resolve_thread",description:"Resolve (close) a thread. Optionally include a disposition. Use expected_version for optimistic concurrency.",inputSchema:D6},async(N)=>{let G=N;if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));if(!G.thread_id)return O(new V(400,"missing_param","Missing required parameter: thread_id","local"));let B={};if(G.disposition!==void 0)B.disposition=G.disposition;let w={};if(G.expected_version)w["If-Match"]=G.expected_version;try{let L=await Q.post(`/sessions/${G.session_id}/threads/${G.thread_id}/resolve`,{body:B,headers:w});return f(L.body,L.requestId)}catch(L){if(L instanceof V)return O(L);throw L}}),$.register({name:"typescape_reopen_thread",description:"Reopen a previously resolved thread. Use expected_version for optimistic concurrency.",inputSchema:N6},async(N)=>{let G=N;if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));if(!G.thread_id)return O(new V(400,"missing_param","Missing required parameter: thread_id","local"));let B={},w={};if(G.expected_version)w["If-Match"]=G.expected_version;try{let L=await Q.post(`/sessions/${G.session_id}/threads/${G.thread_id}/reopen`,{body:B,headers:w});return f(L.body,L.requestId)}catch(L){if(L instanceof V)return O(L);throw L}}),$.register({name:"typescape_record_disposition",description:"Record a disposition (decision) on a thread. Dispositions track how feedback was addressed.",inputSchema:S6},async(N)=>{let G=N;if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));if(!G.thread_id)return O(new V(400,"missing_param","Missing required parameter: thread_id","local"));if(!G.state)return O(new V(400,"missing_param","Missing required parameter: state","local"));let B={state:G.state};if(G.rationale_md!==void 0)B.rationale_md=G.rationale_md;try{let w=await Q.post(`/sessions/${G.session_id}/threads/${G.thread_id}/dispositions`,{body:B});return f(w.body,w.requestId)}catch(w){if(w instanceof V)return O(w);throw w}}),$.register({name:"typescape_attach_evidence",description:"Attach evidence to a thread. Evidence proves that feedback was addressed (e.g., commit SHA, proposed change, PR URL, or attestation).",inputSchema:_6},async(N)=>{let G=N;if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));if(!G.thread_id)return O(new V(400,"missing_param","Missing required parameter: thread_id","local"));if(!G.evidence)return O(new V(400,"missing_param","Missing required parameter: evidence","local"));let B={evidence:G.evidence};try{let w=await Q.post(`/sessions/${G.session_id}/threads/${G.thread_id}/evidence`,{body:B});return f(w.body,w.requestId)}catch(w){if(w instanceof V)return O(w);throw w}});let b=null,E=300000;async function P(){let N=Date.now();if(b&&N-b.fetchedAt<E)return b.features;try{return b={features:(await Q.get("/me/capabilities")).body.features??{},fetchedAt:N},b.features}catch(G){if(G instanceof V)throw G;throw G}}function g(N){return{content:[{type:"text",text:JSON.stringify({error:{code:"feature_disabled",feature:N,message:`Feature '${N}' is not enabled on this server`,request_id:"local"}},null,2)}],isError:!0}}$.register({name:"typescape_create_review_set",description:"Create a new review set (multi-file review pack). Requires features.review_sets to be enabled.",inputSchema:B6},async(N)=>{let G=N;try{if(!(await P()).review_sets)return g("review_sets")}catch(L){if(L instanceof V)return O(L);throw L}if(!G.source_type)return O(new V(400,"missing_param","Missing required parameter: source_type","local"));let B={source_type:G.source_type};if(G.title!==void 0)B.title=G.title;if(G.kind!==void 0)B.kind=G.kind;if(G.participants!==void 0)B.participants=G.participants;let w={};if(G.idempotency_key)w["Idempotency-Key"]=G.idempotency_key;try{let L=await Q.post("/review-sets",{body:B,headers:w});return f(L.body,L.requestId)}catch(L){if(L instanceof V)return O(L);throw L}}),$.register({name:"typescape_export_review_set",description:"Export feedback from a review set. Requires features.review_sets to be enabled.",inputSchema:w6},async(N)=>{let G=N;try{if(!(await P()).review_sets)return g("review_sets")}catch(w){if(w instanceof V)return O(w);throw w}if(!G.review_set_id)return O(new V(400,"missing_param","Missing required parameter: review_set_id","local"));let B={schema:G.schema||"v1"};if(G.view)B.view=G.view;try{let w=await Q.get(`/review-sets/${encodeURIComponent(G.review_set_id)}/export`,{query:B});return f(w.body,w.requestId)}catch(w){if(w instanceof V)return O(w);throw w}}),$.register({name:"typescape_create_review_ref",description:"Create a stable review reference that tracks HEAD session for a branch/PR. Always available (core primitive).",inputSchema:q6},async(N)=>{let G=N;if(!G.source_type)return O(new V(400,"missing_param","Missing required parameter: source_type","local"));if(!G.kind)return O(new V(400,"missing_param","Missing required parameter: kind","local"));if(!G.key)return O(new V(400,"missing_param","Missing required parameter: key","local"));let B={source_type:G.source_type,kind:G.kind,key:G.key};if(G.repo_id!==void 0)B.repo_id=G.repo_id;if(G.project_id!==void 0)B.project_id=G.project_id;if(G.file_path!==void 0)B.file_path=G.file_path;if(G.git_sha!==void 0)B.git_sha=G.git_sha;if(G.upload_batch_id!==void 0)B.upload_batch_id=G.upload_batch_id;try{let w=await Q.post("/review-refs",{body:B});return f(w.body,w.requestId)}catch(w){if(w instanceof V)return O(w);throw w}}),$.register({name:"typescape_resolve_review_ref",description:"Resolve a review ref to its current head session. Returns the head session ID and pinned content details.",inputSchema:M6},async(N)=>{let G=N;if(!G.review_ref_id)return O(new V(400,"missing_param","Missing required parameter: review_ref_id","local"));try{let B=await Q.get(`/review-refs/${encodeURIComponent(G.review_ref_id)}/resolve`);return f(B.body,B.requestId)}catch(B){if(B instanceof V)return O(B);throw B}}),$.register({name:"typescape_advance_review_ref",description:"Advance a review ref to a new head session. Use expected_head_session_id for optimistic concurrency.",inputSchema:j6},async(N)=>{let G=N;if(!G.review_ref_id)return O(new V(400,"missing_param","Missing required parameter: review_ref_id","local"));if(!G.head_session_id)return O(new V(400,"missing_param","Missing required parameter: head_session_id","local"));let B={head_session_id:G.head_session_id};if(G.expected_head_session_id!==void 0)B.expected_head_session_id=G.expected_head_session_id;try{let w=await Q.post(`/review-refs/${encodeURIComponent(G.review_ref_id)}/advance`,{body:B});return f(w.body,w.requestId)}catch(w){if(w instanceof V)return O(w);throw w}}),$.register({name:"typescape_request_approval",description:"Request approval for a review session from specified approvers. Sends notifications via configured channels.",inputSchema:V6},async(N)=>{let G=N;if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));if(!G.approver_emails||G.approver_emails.length===0)return O(new V(400,"missing_param","Missing required parameter: approver_emails","local"));let B={approver_emails:G.approver_emails};if(G.message!==void 0)B.message=G.message;if(G.notify!==void 0)B.notify=G.notify;let w={};if(G.idempotency_key)w["Idempotency-Key"]=G.idempotency_key;try{let L=await Q.post(`/sessions/${encodeURIComponent(G.session_id)}/request-approval`,{body:B,headers:w});return f(L.body,L.requestId)}catch(L){if(L instanceof V)return O(L);throw L}}),$.register({name:"typescape_decide_approval",description:"Record an approval decision (approve/deny/abstain) for a session. Requires a reviewer token with approve scope.",inputSchema:O6},async(N)=>{let G=N;if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));if(!G.decision)return O(new V(400,"missing_param","Missing required parameter: decision","local"));let B={decision:G.decision};if(G.comment_md!==void 0)B.comment_md=G.comment_md;if(G.conditions!==void 0)B.conditions=G.conditions;let w={};if(G.idempotency_key)w["Idempotency-Key"]=G.idempotency_key;try{let L=await Q.post(`/sessions/${encodeURIComponent(G.session_id)}/approval`,{body:B,headers:w});return f(L.body,L.requestId)}catch(L){if(L instanceof V)return O(L);throw L}}),$.register({name:"typescape_get_status",description:"Get the policy verdict for a session. Returns pass/fail/needs_review with reasons. Requires features.policy to be enabled.",inputSchema:L6},async(N)=>{let G=N;try{if(!(await P()).policy)return g("policy")}catch(w){if(w instanceof V)return O(w);throw w}if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));let B={};if(G.simulate)B.simulate="true";if(G.wait!==void 0)B.wait=String(G.wait);try{let w=await Q.get(`/sessions/${encodeURIComponent(G.session_id)}/status`,{query:B});return f(w.body,w.requestId)}catch(w){if(w instanceof V)return O(w);throw w}}),$.register({name:"typescape_run_checks",description:"Trigger quality checks (DocLint-as-Threads) for a session. Returns the check run ID. Requires features.checks to be enabled.",inputSchema:U6},async(N)=>{let G=N;try{if(!(await P()).checks)return g("checks")}catch(B){if(B instanceof V)return O(B);throw B}if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));try{let B=await Q.post(`/sessions/${encodeURIComponent(G.session_id)}/run-checks`,{body:{}});return f(B.body,B.requestId)}catch(B){if(B instanceof V)return O(B);throw B}});let k={type:"object",properties:{repo_id:{type:"string",description:"Repository identifier"},git_sha:{type:"string",description:"Git commit SHA for the snapshot"}},required:["repo_id","git_sha"]};$.register({name:"typescape_get_snapshot",description:"Get corpus snapshot metadata for a Git repo at a specific commit. Returns snapshot status, config hash, and source type. Requires features.corpus_snapshots to be enabled.",inputSchema:k},async(N)=>{let G=N;try{if(!(await P()).corpus_snapshots)return g("corpus_snapshots")}catch(B){if(B instanceof V)return O(B);throw B}if(!G.repo_id)return O(new V(400,"missing_param","Missing required parameter: repo_id","local"));if(!G.git_sha)return O(new V(400,"missing_param","Missing required parameter: git_sha","local"));try{let B=await Q.get(`/repos/${encodeURIComponent(G.repo_id)}/snapshots/${encodeURIComponent(G.git_sha)}`);return f(B.body,B.requestId)}catch(B){if(B instanceof V)return O(B);throw B}});let T={type:"object",properties:{repo_id:{type:"string",description:"Repository identifier"},git_sha:{type:"string",description:"Git commit SHA for the snapshot"},path:{type:"string",description:"Target file path to query backlinks for"},anchor:{type:"string",description:"Optional anchor within the file to narrow backlinks"}},required:["repo_id","git_sha","path"]};$.register({name:"typescape_list_backlinks",description:"List inbound backlinks for a target file (and optional anchor) within a corpus snapshot. Returns deterministic, authoritative data. Requires features.corpus_snapshots to be enabled.",inputSchema:T},async(N)=>{let G=N;try{if(!(await P()).corpus_snapshots)return g("corpus_snapshots")}catch(B){if(B instanceof V)return O(B);throw B}if(!G.repo_id)return O(new V(400,"missing_param","Missing required parameter: repo_id","local"));if(!G.git_sha)return O(new V(400,"missing_param","Missing required parameter: git_sha","local"));if(!G.path)return O(new V(400,"missing_param","Missing required parameter: path","local"));try{let B=new URLSearchParams({path:G.path});if(G.anchor)B.set("anchor",G.anchor);let w=await Q.get(`/repos/${encodeURIComponent(G.repo_id)}/snapshots/${encodeURIComponent(G.git_sha)}/backlinks?${B}`);return f(w.body,w.requestId)}catch(B){if(B instanceof V)return O(B);throw B}});let o={type:"object",properties:{session_id:{type:"string",description:"Session identifier to compute impact radius for"}},required:["session_id"]};$.register({name:"typescape_get_impact",description:"Compute the impact radius for a session: which other files are affected by changes to the session's target file (via backlinks). Returns deterministic, authoritative data. Requires features.corpus_snapshots to be enabled.",inputSchema:o},async(N)=>{let G=N;try{if(!(await P()).corpus_snapshots)return g("corpus_snapshots")}catch(B){if(B instanceof V)return O(B);throw B}if(!G.session_id)return O(new V(400,"missing_param","Missing required parameter: session_id","local"));try{let B=await Q.get(`/sessions/${encodeURIComponent(G.session_id)}/impact`);return f(B.body,B.requestId)}catch(B){if(B instanceof V)return O(B);throw B}});let d1={type:"object",properties:{repo_id:{type:"string",description:"Repository identifier"},file_path:{type:"string",description:"Optional file path to scope steering rules (returns only rules matching this path)"},format:{type:"string",enum:["structured","prompt_fragment"],description:'Output format: "structured" returns governed JSON rules (authoritative), "prompt_fragment" returns pre-computed Markdown text within token budget (may include non-authoritative assistive fields). Default: prompt_fragment.'},token_budget:{type:"number",description:"Maximum token count for prompt_fragment format (100-10000, default 2000)",minimum:100,maximum:1e4}},required:["repo_id"]};$.register({name:"typescape_get_steering",description:'Get active steering rules for a repository. format="structured" returns governed, human-approved rules (authoritative). format="prompt_fragment" returns pre-computed text within configured token budget. Requires steering to be enabled.',inputSchema:d1},async(N)=>{let G=N;try{if(!(await P()).steering)return g("steering")}catch(w){if(w instanceof V)return O(w);throw w}if(!G.repo_id)return O(new V(400,"missing_param","Missing required parameter: repo_id","local"));let B=G.format??"prompt_fragment";try{let w=new URLSearchParams({format:B==="structured"?"structured.v1":"prompt_fragment.v1"});if(G.file_path)w.set("file_path",G.file_path);if(G.token_budget!=null)w.set("token_budget",String(G.token_budget));let L=await Q.get(`/repos/${encodeURIComponent(G.repo_id)}/steering-pack?${w}`),t0=L.body;if(B==="prompt_fragment"&&t0.prompt_fragment)t0.non_authoritative=!0;return f(t0,L.requestId)}catch(w){if(w instanceof V)return O(w);throw w}})}var p1={TYPESCAPE_API_TOKEN:"Operator API token for authenticating with the Typescape API",TYPESCAPE_BASE_URL:"Base URL of the Typescape API server (e.g., https://review.example.com)"};function v6(){let $=process.env.TYPESCAPE_API_TOKEN,Q=process.env.TYPESCAPE_BASE_URL,X=[];if(!$)X.push(`TYPESCAPE_API_TOKEN: ${p1.TYPESCAPE_API_TOKEN}`);if(!Q)X.push(`TYPESCAPE_BASE_URL: ${p1.TYPESCAPE_BASE_URL}`);if(X.length>0){console.error("Error: Missing required environment variables:");for(let W of X)console.error(` - ${W}`);process.exit(1)}return{apiToken:$,baseUrl:Q}}async function A6(){let{apiToken:$,baseUrl:Q}=v6(),X=O1(Q,$),W=V1();n1(W,X),await u1(W)}A6().catch(($)=>{console.error("Fatal error:",$ instanceof Error?$.message:String($)),process.exit(1)});
|