PluginProbe
Elementor Website Builder – more than just a page builder / trunk
Elementor Website Builder – more than just a page builder vtrunk
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 All 457 releases
← All changes | assets/js/packages/elementor-mcp-common/elementor-mcp-common.js +19790 -2 4.1.0-dev3 → trunk View file →
@@ -1,3 +1,19791 @@
1 -/*! For license information please see elementor-mcp-common.js.LICENSE.txt */
2 -!function(){"use strict";var e={"./packages/packages/libs/elementor-mcp-common/src/editor-detection.ts":function(e,t,n){n.r(t),n.d(t,{ensureElementorFrontend:function(){return ensureElementorFrontend},hasGutenbergUI:function(){return hasGutenbergUI},isElementorAIActive:function(){return isElementorAIActive},isElementorEditor:function(){return isElementorEditor},isElementorEditorReady:function(){return isElementorEditorReady},isGutenbergEditor:function(){return isGutenbergEditor},waitForElementor:function(){return waitForElementor},waitForElementorEditor:function(){return waitForElementorEditor},whenElementorReady:function(){return whenElementorReady}});var r=n("./packages/packages/libs/elementor-mcp-common/src/utils.ts");const o={maxRetries:50,retryInterval:100,checkFn:()=>!(!(0,r.getElementor)()||!(0,r.get$e)())};function isGutenbergEditor(){return void 0!==(0,r.getWp)()?.data?.select("core/editor")}function isElementorEditor(){const e=new URLSearchParams(window.location.search);for(const[,t]of e.entries())if(t.includes("elementor"))return!0;return!1}function isElementorAIActive(){return!!(0,r.getElementorAiConfig)()}function hasGutenbergUI(){return!!document.querySelector(".edit-post-header-toolbar")}function ensureElementorFrontend(){const e=(0,r.getElementorFrontend)();if(!e?.elements?.$body)throw new Error("elementorFrontend or its required components not available")}function isElementorEditorReady(){return!!(0,r.get$e)()?.components.get("panel")}function waitForElementorEditor(){return new Promise(e=>{if(isElementorEditorReady())return void e();const checkReady=()=>{isElementorEditorReady()?e():setTimeout(checkReady,100)};window.addEventListener("DOMContentLoaded",()=>{checkReady()},{once:!0})})}function waitForElementor(e=o){const{maxRetries:t,retryInterval:n,checkFn:r}=e;return new Promise((e,o)=>{let i=0;const check=()=>{r()?e():(i++,i>=t?o(new Error(`Elementor not loaded after ${t} attempts`)):setTimeout(check,n))};check()})}async function whenElementorReady(e,t=o){return await waitForElementor(t),await waitForElementorEditor(),await e()}},"./packages/packages/libs/elementor-mcp-common/src/elements.ts":function(e,t,n){n.r(t),n.d(t,{extractElementImageData:function(){return extractElementImageData},getElementSettings:function(){return getElementSettings},getGutenbergBlockEditorApis:function(){return getGutenbergBlockEditorApis},injectElementCSS:function(){return injectElementCSS},isSelectAllCheckbox:function(){return isSelectAllCheckbox},removeElementCSS:function(){return removeElementCSS},updateElementSettings:function(){return updateElementSettings},updateGutenbergBlockAttributes:function(){return updateGutenbergBlockAttributes},validateAndGetGutenbergBlock:function(){return validateAndGetGutenbergBlock}});var r=n("./packages/packages/libs/elementor-mcp-common/src/editor-detection.ts"),o=n("./packages/packages/libs/elementor-mcp-common/src/utils.ts");function injectElementCSS(e,t){const n=document.createElement("style");n.id=e,n.appendChild(document.createTextNode(t)),(0,r.ensureElementorFrontend)();const i=(0,o.getElementorFrontend)();i&&i.elements.$body[0].appendChild(n)}function removeElementCSS(e){(0,r.ensureElementorFrontend)();const t=(0,o.getElementorFrontend)();if(!t)return;const n=t.elements.$body[0],i=n.querySelectorAll(`#${CSS.escape(e)}`);i?.length>0&&i.forEach(e=>{n.removeChild(e)})}async function updateElementSettings({id:e,settings:t}){const n=(0,o.getElementor)()?.getContainer(e);if(!n)throw new Error(`Element with ID "${e}" not found.`);const r=await((0,o.get$e)()?.run("document/elements/settings",{container:n,settings:t,options:{external:!0,render:!0}})),i=(0,o.getElementorFrontend)();return i?.elements.$body.resize(),r}function getElementSettings(e){const t=(0,o.getElementor)()?.getContainer(e);if(!t)throw new Error(`Element with ID "${e}" not found.`);return t.settings}function getGutenbergBlockEditorApis(){const e=(0,o.getWp)();if(!(0,r.isGutenbergEditor)()||!e)throw new Error("WordPress editor API is not available");const t=e.data.dispatch("core/block-editor"),n=e.data.select("core/block-editor");if(!t||!n)throw new Error("Block editor API is not available");return{blockEditorDispatch:t,blockEditorSelect:n}}function validateAndGetGutenbergBlock(e,t){const n=e.getBlock(t);if(!n)throw new Error(`Block with ID "${t}" not found`);return n}function updateGutenbergBlockAttributes(e,t){const{blockEditorDispatch:n,blockEditorSelect:r}=getGutenbergBlockEditorApis(),o=validateAndGetGutenbergBlock(r,e);return n.updateBlockAttributes(e,t),{blockId:e,blockName:o.name,updatedAttributes:Object.keys(t)}}function extractElementImageData(e,t="",n=""){let r=t,i=n;if(e&&(!r||!i)){const t=(0,o.getElementor)()?.getContainer?.(e);if(t){const e=t.settings.get("image");if(e&&"object"==typeof e){const t=e;r=r||t.id?.toString()||"",i=i||t.url||""}}}return{imageId:r,imageUrl:i}}function isSelectAllCheckbox(e){return!!(e.id&&e.id.includes("select-all")||e.name&&e.name.includes("select-all"))}},"./packages/packages/libs/elementor-mcp-common/src/nonce-refresh.ts":function(e,t,n){n.r(t),n.d(t,{initNonceRefresh:function(){return initNonceRefresh},isNonceError:function(){return isNonceError},refreshNonce:function(){return refreshNonce}});var r=n("./packages/packages/libs/elementor-mcp-common/src/utils.ts");let o=!1,i=null;function initNonceRefresh(){const e=(0,r.getJQuery)(),t=(0,r.getWpApiSettings)();!o&&void 0!==e&&t&&(o=!0,e?.(document).on("heartbeat-tick.angieNonceRefresh",(e,t)=>{try{const e=t,n=(0,r.getWpApiSettings)();e.angie_nonce&&n&&n.nonce!==e.angie_nonce&&(n.nonce=e.angie_nonce)}catch(e){console.error("Failed to refresh nonce:",e)}}))}async function refreshNonce(){if(i)return i;i=async function fetchFreshNonce(){const e=new URL((0,r.getAjaxUrl)()||"/wp-admin/admin-ajax.php",window.location.origin);e.searchParams.set("action","rest-nonce");const t=await fetch(e.toString(),{credentials:"same-origin"});if(!t.ok)throw new Error(`Failed to refresh nonce: HTTP ${t.status}`);const n=await t.text();if(!n||"0"===n)throw new Error("Session expired — received invalid nonce");const o=(0,r.getWpApiSettings)();if(!o)throw new Error("wpApiSettings not available — cannot refresh nonce");return o.nonce=n,n}();try{return await i}finally{i=null}}function isNonceError(e,t){return 403===e&&t.includes("rest_cookie_invalid_nonce")}},"./packages/packages/libs/elementor-mcp-common/src/rest-client.ts":function(e,t,n){n.r(t),n.d(t,{callWpApi:function(){return callWpApi},extractJSONFromResponse:function(){return extractJSONFromResponse}});var r=n("./packages/packages/libs/elementor-mcp-common/src/nonce-refresh.ts"),o=n("./packages/packages/libs/elementor-mcp-common/src/utils.ts");async function callWpApi(e,t,n,r){return executeWpApiCall(e,t,n,r,!0)}async function executeWpApiCall(e,t,n,i,c=!1){const s=(0,o.getWpApiSettings)();if(!s?.nonce||!s.root)throw new Error("wpApiSettings not available");const a=s.root,u=new URL(a),l=new URL(e,a);u.searchParams.set("rest_route",l.pathname);for(const[e,t]of l.searchParams.entries())u.searchParams.append(e,t);const m=u.toString(),d={"X-WP-Nonce":s.nonce,...i?.customHeaders||{}};i?.binaryData||i?.customHeaders?.["Content-Type"]||(d["Content-Type"]="application/json");const g={method:t,headers:d,credentials:"same-origin"};i?.binaryData?g.body=i.binaryData:!n||"POST"!==t&&"PUT"!==t&&"PATCH"!==t||(g.body=JSON.stringify(n));const f=await fetch(m,g);if(!f.ok){const o=await f.text();if(c&&(0,r.isNonceError)(f.status,o))return await(0,r.refreshNonce)(),executeWpApiCall(e,t,n,i,!1);throw new Error(`HTTP error ${f.status}: ${o}`)}const p=await f.text(),E=extractJSONFromResponse(p);if(null===E)throw new Error(`Invalid response: no JSON found in: ${p.substring(0,200)}`);const w=E;if(void 0!==w?.success&&!w.success)throw new Error(`API errors: ${JSON.stringify(E)}`);const b=f.headers.get("X-WP-Total"),k=f.headers.get("X-WP-TotalPages");return{data:E,totalItems:b?parseInt(b,10):void 0,totalPages:k?parseInt(k,10):void 0}}function extractJSONFromResponse(e){const t=e.indexOf("{"),n=e.indexOf("[");let r=-1,o=!1;if(-1===t&&-1===n)return null;-1===t?(r=n,o=!0):-1===n?(r=t,o=!1):n<t?(r=n,o=!0):(r=t,o=!1);let i=0,c=-1;const s=o?"[":"{",a=o?"]":"}";for(let t=r;t<e.length;t++)if(e[t]===s)i++;else if(e[t]===a&&(i--,0===i)){c=t;break}if(-1===c)return null;const u=e.substring(r,c+1);try{return JSON.parse(u)}catch{return null}}},"./packages/packages/libs/elementor-mcp-common/src/utils.ts":function(e,t,n){n.r(t),n.d(t,{get$e:function(){return get$e},getAjaxUrl:function(){return getAjaxUrl},getElementor:function(){return getElementor},getElementorAiConfig:function(){return getElementorAiConfig},getElementorCommon:function(){return getElementorCommon},getElementorFrontend:function(){return getElementorFrontend},getJQuery:function(){return getJQuery},getWp:function(){return getWp},getWpApiSettings:function(){return getWpApiSettings}});const getElementor=()=>window.elementor,getElementorFrontend=()=>window.elementorFrontend,get$e=()=>window.$e,getElementorCommon=()=>window.elementorCommon,getWpApiSettings=()=>window.wpApiSettings,getAjaxUrl=()=>window.ajaxurl,getWp=()=>window.wp,getJQuery=()=>window.jQuery,getElementorAiConfig=()=>window.ElementorAiConfig},"./packages/packages/libs/elementor-mcp-common/src/validation-utils.ts":function(e,t,n){function requireConfirmationMessage(e,t){if(!e||""===e.trim())throw new Error(`LLM Instructions: ${t} changes require user confirmation. You MUST provide a confirmationMessage parameter explaining what will be changed and its impact.`)}n.r(t),n.d(t,{requireConfirmationMessage:function(){return requireConfirmationMessage}})}},t={};function __webpack_require__(n){var r=t[n];if(void 0!==r)return r.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,__webpack_require__),o.exports}__webpack_require__.d=function(e,t){for(var n in t)__webpack_require__.o(t,n)&&!__webpack_require__.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},__webpack_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};!function(){__webpack_require__.r(n),__webpack_require__.d(n,{callWpApi:function(){return r.callWpApi},ensureElementorFrontend:function(){return e.ensureElementorFrontend},extractElementImageData:function(){return t.extractElementImageData},extractJSONFromResponse:function(){return r.extractJSONFromResponse},get$e:function(){return c.get$e},getAjaxUrl:function(){return c.getAjaxUrl},getElementSettings:function(){return t.getElementSettings},getElementor:function(){return c.getElementor},getElementorAiConfig:function(){return c.getElementorAiConfig},getElementorCommon:function(){return c.getElementorCommon},getElementorFrontend:function(){return c.getElementorFrontend},getGutenbergBlockEditorApis:function(){return t.getGutenbergBlockEditorApis},getJQuery:function(){return c.getJQuery},getWp:function(){return c.getWp},getWpApiSettings:function(){return c.getWpApiSettings},hasGutenbergUI:function(){return e.hasGutenbergUI},initNonceRefresh:function(){return o.initNonceRefresh},injectElementCSS:function(){return t.injectElementCSS},isElementorAIActive:function(){return e.isElementorAIActive},isElementorEditor:function(){return e.isElementorEditor},isElementorEditorReady:function(){return e.isElementorEditorReady},isGutenbergEditor:function(){return e.isGutenbergEditor},isNonceError:function(){return o.isNonceError},isSelectAllCheckbox:function(){return t.isSelectAllCheckbox},refreshNonce:function(){return o.refreshNonce},removeElementCSS:function(){return t.removeElementCSS},requireConfirmationMessage:function(){return i.requireConfirmationMessage},updateElementSettings:function(){return t.updateElementSettings},updateGutenbergBlockAttributes:function(){return t.updateGutenbergBlockAttributes},validateAndGetGutenbergBlock:function(){return t.validateAndGetGutenbergBlock},waitForElementor:function(){return e.waitForElementor},waitForElementorEditor:function(){return e.waitForElementorEditor},whenElementorReady:function(){return e.whenElementorReady}});var e=__webpack_require__("./packages/packages/libs/elementor-mcp-common/src/editor-detection.ts"),t=__webpack_require__("./packages/packages/libs/elementor-mcp-common/src/elements.ts"),r=__webpack_require__("./packages/packages/libs/elementor-mcp-common/src/rest-client.ts"),o=__webpack_require__("./packages/packages/libs/elementor-mcp-common/src/nonce-refresh.ts"),i=__webpack_require__("./packages/packages/libs/elementor-mcp-common/src/validation-utils.ts"),c=__webpack_require__("./packages/packages/libs/elementor-mcp-common/src/utils.ts")}(),(window.elementorV2=window.elementorV2||{}).elementorMcpCommon=n}(),window.elementorV2.elementorMcpCommon?.init?.();
1 +(function() {
2 +
3 +//#region \0rolldown/runtime.js
4 + var __create = Object.create;
5 + var __defProp = Object.defineProperty;
6 + var __name = (target, value) => __defProp(target, "name", {
7 + value,
8 + configurable: true
9 + });
10 + var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
11 + var __getOwnPropNames = Object.getOwnPropertyNames;
12 + var __getProtoOf = Object.getPrototypeOf;
13 + var __hasOwnProp = Object.prototype.hasOwnProperty;
14 + var __esmMin = (fn, res, err) => () => {
15 + if (err) throw err[0];
16 + try {
17 + return fn && (res = fn(fn = 0)), res;
18 + } catch (e) {
19 + throw err = [e], e;
20 + }
21 + };
22 + var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
23 + var __exportAll = (all, no_symbols) => {
24 + let target = {};
25 + for (var name in all) {
26 + __defProp(target, name, {
27 + get: all[name],
28 + enumerable: true
29 + });
30 + }
31 + if (!no_symbols) {
32 + __defProp(target, Symbol.toStringTag, { value: "Module" });
33 + }
34 + return target;
35 + };
36 + var __copyProps = (to, from, except, desc) => {
37 + if (from && typeof from === "object" || typeof from === "function") {
38 + for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
39 + key = keys[i];
40 + if (!__hasOwnProp.call(to, key) && key !== except) {
41 + __defProp(to, key, {
42 + get: ((k) => from[k]).bind(null, key),
43 + enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
44 + });
45 + }
46 + }
47 + }
48 + return to;
49 + };
50 + var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
51 + value: mod,
52 + enumerable: true
53 + }) : target, mod));
54 + var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
55 +
56 +//#endregion
57 +
58 +//#region node_modules/zod/v3/helpers/util.js
59 + var util;
60 + (function(util) {
61 + util.assertEqual = (_) => {};
62 + function assertIs(_arg) {}
63 + util.assertIs = assertIs;
64 + function assertNever(_x) {
65 + throw new Error();
66 + }
67 + util.assertNever = assertNever;
68 + util.arrayToEnum = (items) => {
69 + const obj = {};
70 + for (const item of items) obj[item] = item;
71 + return obj;
72 + };
73 + util.getValidEnumValues = (obj) => {
74 + const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
75 + const filtered = {};
76 + for (const k of validKeys) filtered[k] = obj[k];
77 + return util.objectValues(filtered);
78 + };
79 + util.objectValues = (obj) => {
80 + return util.objectKeys(obj).map(function(e) {
81 + return obj[e];
82 + });
83 + };
84 + util.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
85 + const keys = [];
86 + for (const key in object) if (Object.prototype.hasOwnProperty.call(object, key)) keys.push(key);
87 + return keys;
88 + };
89 + util.find = (arr, checker) => {
90 + for (const item of arr) if (checker(item)) return item;
91 + };
92 + util.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
93 + function joinValues(array, separator = " | ") {
94 + return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
95 + }
96 + util.joinValues = joinValues;
97 + util.jsonStringifyReplacer = (_, value) => {
98 + if (typeof value === "bigint") return value.toString();
99 + return value;
100 + };
101 + })(util || (util = {}));
102 + var objectUtil;
103 + (function(objectUtil) {
104 + objectUtil.mergeShapes = (first, second) => {
105 + return {
106 + ...first,
107 + ...second
108 + };
109 + };
110 + })(objectUtil || (objectUtil = {}));
111 + var ZodParsedType = util.arrayToEnum([
112 + "string",
113 + "nan",
114 + "number",
115 + "integer",
116 + "float",
117 + "boolean",
118 + "date",
119 + "bigint",
120 + "symbol",
121 + "function",
122 + "undefined",
123 + "null",
124 + "array",
125 + "object",
126 + "unknown",
127 + "promise",
128 + "void",
129 + "never",
130 + "map",
131 + "set"
132 + ]);
133 + var getParsedType = (data) => {
134 + switch (typeof data) {
135 + case "undefined": return ZodParsedType.undefined;
136 + case "string": return ZodParsedType.string;
137 + case "number": return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
138 + case "boolean": return ZodParsedType.boolean;
139 + case "function": return ZodParsedType.function;
140 + case "bigint": return ZodParsedType.bigint;
141 + case "symbol": return ZodParsedType.symbol;
142 + case "object":
143 + if (Array.isArray(data)) return ZodParsedType.array;
144 + if (data === null) return ZodParsedType.null;
145 + if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") return ZodParsedType.promise;
146 + if (typeof Map !== "undefined" && data instanceof Map) return ZodParsedType.map;
147 + if (typeof Set !== "undefined" && data instanceof Set) return ZodParsedType.set;
148 + if (typeof Date !== "undefined" && data instanceof Date) return ZodParsedType.date;
149 + return ZodParsedType.object;
150 + default: return ZodParsedType.unknown;
151 + }
152 + };
153 +
154 +//#endregion
155 +//#region node_modules/zod/v3/ZodError.js
156 + var ZodIssueCode = util.arrayToEnum([
157 + "invalid_type",
158 + "invalid_literal",
159 + "custom",
160 + "invalid_union",
161 + "invalid_union_discriminator",
162 + "invalid_enum_value",
163 + "unrecognized_keys",
164 + "invalid_arguments",
165 + "invalid_return_type",
166 + "invalid_date",
167 + "invalid_string",
168 + "too_small",
169 + "too_big",
170 + "invalid_intersection_types",
171 + "not_multiple_of",
172 + "not_finite"
173 + ]);
174 + var ZodError$1 = class ZodError$1 extends Error {
175 + static {
176 + __name(this, "ZodError");
177 + }
178 + get errors() {
179 + return this.issues;
180 + }
181 + constructor(issues) {
182 + super();
183 + this.issues = [];
184 + this.addIssue = (sub) => {
185 + this.issues = [...this.issues, sub];
186 + };
187 + this.addIssues = (subs = []) => {
188 + this.issues = [...this.issues, ...subs];
189 + };
190 + const actualProto = new.target.prototype;
191 + if (Object.setPrototypeOf) Object.setPrototypeOf(this, actualProto);
192 + else this.__proto__ = actualProto;
193 + this.name = "ZodError";
194 + this.issues = issues;
195 + }
196 + format(_mapper) {
197 + const mapper = _mapper || function(issue) {
198 + return issue.message;
199 + };
200 + const fieldErrors = { _errors: [] };
201 + const processError = (error) => {
202 + for (const issue of error.issues) if (issue.code === "invalid_union") issue.unionErrors.map(processError);
203 + else if (issue.code === "invalid_return_type") processError(issue.returnTypeError);
204 + else if (issue.code === "invalid_arguments") processError(issue.argumentsError);
205 + else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));
206 + else {
207 + let curr = fieldErrors;
208 + let i = 0;
209 + while (i < issue.path.length) {
210 + const el = issue.path[i];
211 + if (!(i === issue.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
212 + else {
213 + curr[el] = curr[el] || { _errors: [] };
214 + curr[el]._errors.push(mapper(issue));
215 + }
216 + curr = curr[el];
217 + i++;
218 + }
219 + }
220 + };
221 + processError(this);
222 + return fieldErrors;
223 + }
224 + static assert(value) {
225 + if (!(value instanceof ZodError$1)) throw new Error(`Not a ZodError: ${value}`);
226 + }
227 + toString() {
228 + return this.message;
229 + }
230 + get message() {
231 + return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
232 + }
233 + get isEmpty() {
234 + return this.issues.length === 0;
235 + }
236 + flatten(mapper = (issue) => issue.message) {
237 + const fieldErrors = {};
238 + const formErrors = [];
239 + for (const sub of this.issues) if (sub.path.length > 0) {
240 + const firstEl = sub.path[0];
241 + fieldErrors[firstEl] = fieldErrors[firstEl] || [];
242 + fieldErrors[firstEl].push(mapper(sub));
243 + } else formErrors.push(mapper(sub));
244 + return {
245 + formErrors,
246 + fieldErrors
247 + };
248 + }
249 + get formErrors() {
250 + return this.flatten();
251 + }
252 + };
253 + ZodError$1.create = (issues) => {
254 + return new ZodError$1(issues);
255 + };
256 +
257 +//#endregion
258 +//#region node_modules/zod/v3/locales/en.js
259 + var errorMap = (issue, _ctx) => {
260 + let message;
261 + switch (issue.code) {
262 + case ZodIssueCode.invalid_type:
263 + if (issue.received === ZodParsedType.undefined) message = "Required";
264 + else message = `Expected ${issue.expected}, received ${issue.received}`;
265 + break;
266 + case ZodIssueCode.invalid_literal:
267 + message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util.jsonStringifyReplacer)}`;
268 + break;
269 + case ZodIssueCode.unrecognized_keys:
270 + message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
271 + break;
272 + case ZodIssueCode.invalid_union:
273 + message = `Invalid input`;
274 + break;
275 + case ZodIssueCode.invalid_union_discriminator:
276 + message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
277 + break;
278 + case ZodIssueCode.invalid_enum_value:
279 + message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
280 + break;
281 + case ZodIssueCode.invalid_arguments:
282 + message = `Invalid function arguments`;
283 + break;
284 + case ZodIssueCode.invalid_return_type:
285 + message = `Invalid function return type`;
286 + break;
287 + case ZodIssueCode.invalid_date:
288 + message = `Invalid date`;
289 + break;
290 + case ZodIssueCode.invalid_string:
291 + if (typeof issue.validation === "object") if ("includes" in issue.validation) {
292 + message = `Invalid input: must include "${issue.validation.includes}"`;
293 + if (typeof issue.validation.position === "number") message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
294 + } else if ("startsWith" in issue.validation) message = `Invalid input: must start with "${issue.validation.startsWith}"`;
295 + else if ("endsWith" in issue.validation) message = `Invalid input: must end with "${issue.validation.endsWith}"`;
296 + else util.assertNever(issue.validation);
297 + else if (issue.validation !== "regex") message = `Invalid ${issue.validation}`;
298 + else message = "Invalid";
299 + break;
300 + case ZodIssueCode.too_small:
301 + if (issue.type === "array") message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
302 + else if (issue.type === "string") message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
303 + else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
304 + else if (issue.type === "bigint") message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
305 + else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
306 + else message = "Invalid input";
307 + break;
308 + case ZodIssueCode.too_big:
309 + if (issue.type === "array") message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
310 + else if (issue.type === "string") message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
311 + else if (issue.type === "number") message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
312 + else if (issue.type === "bigint") message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
313 + else if (issue.type === "date") message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
314 + else message = "Invalid input";
315 + break;
316 + case ZodIssueCode.custom:
317 + message = `Invalid input`;
318 + break;
319 + case ZodIssueCode.invalid_intersection_types:
320 + message = `Intersection results could not be merged`;
321 + break;
322 + case ZodIssueCode.not_multiple_of:
323 + message = `Number must be a multiple of ${issue.multipleOf}`;
324 + break;
325 + case ZodIssueCode.not_finite:
326 + message = "Number must be finite";
327 + break;
328 + default:
329 + message = _ctx.defaultError;
330 + util.assertNever(issue);
331 + }
332 + return { message };
333 + };
334 +
335 +//#endregion
336 +//#region node_modules/zod/v3/errors.js
337 + var overrideErrorMap = errorMap;
338 + function getErrorMap() {
339 + return overrideErrorMap;
340 + }
341 +
342 +//#endregion
343 +//#region node_modules/zod/v3/helpers/parseUtil.js
344 + var makeIssue = (params) => {
345 + const { data, path, errorMaps, issueData } = params;
346 + const fullPath = [...path, ...issueData.path || []];
347 + const fullIssue = {
348 + ...issueData,
349 + path: fullPath
350 + };
351 + if (issueData.message !== void 0) return {
352 + ...issueData,
353 + path: fullPath,
354 + message: issueData.message
355 + };
356 + let errorMessage = "";
357 + const maps = errorMaps.filter((m) => !!m).slice().reverse();
358 + for (const map of maps) errorMessage = map(fullIssue, {
359 + data,
360 + defaultError: errorMessage
361 + }).message;
362 + return {
363 + ...issueData,
364 + path: fullPath,
365 + message: errorMessage
366 + };
367 + };
368 + function addIssueToContext(ctx, issueData) {
369 + const overrideMap = getErrorMap();
370 + const issue = makeIssue({
371 + issueData,
372 + data: ctx.data,
373 + path: ctx.path,
374 + errorMaps: [
375 + ctx.common.contextualErrorMap,
376 + ctx.schemaErrorMap,
377 + overrideMap,
378 + overrideMap === errorMap ? void 0 : errorMap
379 + ].filter((x) => !!x)
380 + });
381 + ctx.common.issues.push(issue);
382 + }
383 + var ParseStatus = class ParseStatus {
384 + constructor() {
385 + this.value = "valid";
386 + }
387 + dirty() {
388 + if (this.value === "valid") this.value = "dirty";
389 + }
390 + abort() {
391 + if (this.value !== "aborted") this.value = "aborted";
392 + }
393 + static mergeArray(status, results) {
394 + const arrayValue = [];
395 + for (const s of results) {
396 + if (s.status === "aborted") return INVALID;
397 + if (s.status === "dirty") status.dirty();
398 + arrayValue.push(s.value);
399 + }
400 + return {
401 + status: status.value,
402 + value: arrayValue
403 + };
404 + }
405 + static async mergeObjectAsync(status, pairs) {
406 + const syncPairs = [];
407 + for (const pair of pairs) {
408 + const key = await pair.key;
409 + const value = await pair.value;
410 + syncPairs.push({
411 + key,
412 + value
413 + });
414 + }
415 + return ParseStatus.mergeObjectSync(status, syncPairs);
416 + }
417 + static mergeObjectSync(status, pairs) {
418 + const finalObject = {};
419 + for (const pair of pairs) {
420 + const { key, value } = pair;
421 + if (key.status === "aborted") return INVALID;
422 + if (value.status === "aborted") return INVALID;
423 + if (key.status === "dirty") status.dirty();
424 + if (value.status === "dirty") status.dirty();
425 + if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) finalObject[key.value] = value.value;
426 + }
427 + return {
428 + status: status.value,
429 + value: finalObject
430 + };
431 + }
432 + };
433 + var INVALID = Object.freeze({ status: "aborted" });
434 + var DIRTY = (value) => ({
435 + status: "dirty",
436 + value
437 + });
438 + var OK = (value) => ({
439 + status: "valid",
440 + value
441 + });
442 + var isAborted = (x) => x.status === "aborted";
443 + var isDirty = (x) => x.status === "dirty";
444 + var isValid = (x) => x.status === "valid";
445 + var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
446 +
447 +//#endregion
448 +//#region node_modules/zod/v3/helpers/errorUtil.js
449 + var errorUtil;
450 + (function(errorUtil) {
451 + errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
452 + errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
453 + })(errorUtil || (errorUtil = {}));
454 +
455 +//#endregion
456 +//#region node_modules/zod/v3/types.js
457 + var ParseInputLazyPath = class {
458 + constructor(parent, value, path, key) {
459 + this._cachedPath = [];
460 + this.parent = parent;
461 + this.data = value;
462 + this._path = path;
463 + this._key = key;
464 + }
465 + get path() {
466 + if (!this._cachedPath.length) if (Array.isArray(this._key)) this._cachedPath.push(...this._path, ...this._key);
467 + else this._cachedPath.push(...this._path, this._key);
468 + return this._cachedPath;
469 + }
470 + };
471 + var handleResult = (ctx, result) => {
472 + if (isValid(result)) return {
473 + success: true,
474 + data: result.value
475 + };
476 + else {
477 + if (!ctx.common.issues.length) throw new Error("Validation failed but no issues detected.");
478 + return {
479 + success: false,
480 + get error() {
481 + if (this._error) return this._error;
482 + const error = new ZodError$1(ctx.common.issues);
483 + this._error = error;
484 + return this._error;
485 + }
486 + };
487 + }
488 + };
489 + function processCreateParams(params) {
490 + if (!params) return {};
491 + const { errorMap, invalid_type_error, required_error, description } = params;
492 + if (errorMap && (invalid_type_error || required_error)) throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
493 + if (errorMap) return {
494 + errorMap,
495 + description
496 + };
497 + const customMap = (iss, ctx) => {
498 + const { message } = params;
499 + if (iss.code === "invalid_enum_value") return { message: message ?? ctx.defaultError };
500 + if (typeof ctx.data === "undefined") return { message: message ?? required_error ?? ctx.defaultError };
501 + if (iss.code !== "invalid_type") return { message: ctx.defaultError };
502 + return { message: message ?? invalid_type_error ?? ctx.defaultError };
503 + };
504 + return {
505 + errorMap: customMap,
506 + description
507 + };
508 + }
509 + var ZodType$1 = class {
510 + static {
511 + __name(this, "ZodType");
512 + }
513 + get description() {
514 + return this._def.description;
515 + }
516 + _getType(input) {
517 + return getParsedType(input.data);
518 + }
519 + _getOrReturnCtx(input, ctx) {
520 + return ctx || {
521 + common: input.parent.common,
522 + data: input.data,
523 + parsedType: getParsedType(input.data),
524 + schemaErrorMap: this._def.errorMap,
525 + path: input.path,
526 + parent: input.parent
527 + };
528 + }
529 + _processInputParams(input) {
530 + return {
531 + status: new ParseStatus(),
532 + ctx: {
533 + common: input.parent.common,
534 + data: input.data,
535 + parsedType: getParsedType(input.data),
536 + schemaErrorMap: this._def.errorMap,
537 + path: input.path,
538 + parent: input.parent
539 + }
540 + };
541 + }
542 + _parseSync(input) {
543 + const result = this._parse(input);
544 + if (isAsync(result)) throw new Error("Synchronous parse encountered promise.");
545 + return result;
546 + }
547 + _parseAsync(input) {
548 + const result = this._parse(input);
549 + return Promise.resolve(result);
550 + }
551 + parse(data, params) {
552 + const result = this.safeParse(data, params);
553 + if (result.success) return result.data;
554 + throw result.error;
555 + }
556 + safeParse(data, params) {
557 + const ctx = {
558 + common: {
559 + issues: [],
560 + async: params?.async ?? false,
561 + contextualErrorMap: params?.errorMap
562 + },
563 + path: params?.path || [],
564 + schemaErrorMap: this._def.errorMap,
565 + parent: null,
566 + data,
567 + parsedType: getParsedType(data)
568 + };
569 + const result = this._parseSync({
570 + data,
571 + path: ctx.path,
572 + parent: ctx
573 + });
574 + return handleResult(ctx, result);
575 + }
576 + "~validate"(data) {
577 + const ctx = {
578 + common: {
579 + issues: [],
580 + async: !!this["~standard"].async
581 + },
582 + path: [],
583 + schemaErrorMap: this._def.errorMap,
584 + parent: null,
585 + data,
586 + parsedType: getParsedType(data)
587 + };
588 + if (!this["~standard"].async) try {
589 + const result = this._parseSync({
590 + data,
591 + path: [],
592 + parent: ctx
593 + });
594 + return isValid(result) ? { value: result.value } : { issues: ctx.common.issues };
595 + } catch (err) {
596 + if (err?.message?.toLowerCase()?.includes("encountered")) this["~standard"].async = true;
597 + ctx.common = {
598 + issues: [],
599 + async: true
600 + };
601 + }
602 + return this._parseAsync({
603 + data,
604 + path: [],
605 + parent: ctx
606 + }).then((result) => isValid(result) ? { value: result.value } : { issues: ctx.common.issues });
607 + }
608 + async parseAsync(data, params) {
609 + const result = await this.safeParseAsync(data, params);
610 + if (result.success) return result.data;
611 + throw result.error;
612 + }
613 + async safeParseAsync(data, params) {
614 + const ctx = {
615 + common: {
616 + issues: [],
617 + contextualErrorMap: params?.errorMap,
618 + async: true
619 + },
620 + path: params?.path || [],
621 + schemaErrorMap: this._def.errorMap,
622 + parent: null,
623 + data,
624 + parsedType: getParsedType(data)
625 + };
626 + const maybeAsyncResult = this._parse({
627 + data,
628 + path: ctx.path,
629 + parent: ctx
630 + });
631 + const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
632 + return handleResult(ctx, result);
633 + }
634 + refine(check, message) {
635 + const getIssueProperties = (val) => {
636 + if (typeof message === "string" || typeof message === "undefined") return { message };
637 + else if (typeof message === "function") return message(val);
638 + else return message;
639 + };
640 + return this._refinement((val, ctx) => {
641 + const result = check(val);
642 + const setError = () => ctx.addIssue({
643 + code: ZodIssueCode.custom,
644 + ...getIssueProperties(val)
645 + });
646 + if (typeof Promise !== "undefined" && result instanceof Promise) return result.then((data) => {
647 + if (!data) {
648 + setError();
649 + return false;
650 + } else return true;
651 + });
652 + if (!result) {
653 + setError();
654 + return false;
655 + } else return true;
656 + });
657 + }
658 + refinement(check, refinementData) {
659 + return this._refinement((val, ctx) => {
660 + if (!check(val)) {
661 + ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
662 + return false;
663 + } else return true;
664 + });
665 + }
666 + _refinement(refinement) {
667 + return new ZodEffects({
668 + schema: this,
669 + typeName: ZodFirstPartyTypeKind.ZodEffects,
670 + effect: {
671 + type: "refinement",
672 + refinement
673 + }
674 + });
675 + }
676 + superRefine(refinement) {
677 + return this._refinement(refinement);
678 + }
679 + constructor(def) {
680 + /** Alias of safeParseAsync */
681 + this.spa = this.safeParseAsync;
682 + this._def = def;
683 + this.parse = this.parse.bind(this);
684 + this.safeParse = this.safeParse.bind(this);
685 + this.parseAsync = this.parseAsync.bind(this);
686 + this.safeParseAsync = this.safeParseAsync.bind(this);
687 + this.spa = this.spa.bind(this);
688 + this.refine = this.refine.bind(this);
689 + this.refinement = this.refinement.bind(this);
690 + this.superRefine = this.superRefine.bind(this);
691 + this.optional = this.optional.bind(this);
692 + this.nullable = this.nullable.bind(this);
693 + this.nullish = this.nullish.bind(this);
694 + this.array = this.array.bind(this);
695 + this.promise = this.promise.bind(this);
696 + this.or = this.or.bind(this);
697 + this.and = this.and.bind(this);
698 + this.transform = this.transform.bind(this);
699 + this.brand = this.brand.bind(this);
700 + this.default = this.default.bind(this);
701 + this.catch = this.catch.bind(this);
702 + this.describe = this.describe.bind(this);
703 + this.pipe = this.pipe.bind(this);
704 + this.readonly = this.readonly.bind(this);
705 + this.isNullable = this.isNullable.bind(this);
706 + this.isOptional = this.isOptional.bind(this);
707 + this["~standard"] = {
708 + version: 1,
709 + vendor: "zod",
710 + validate: (data) => this["~validate"](data)
711 + };
712 + }
713 + optional() {
714 + return ZodOptional$1.create(this, this._def);
715 + }
716 + nullable() {
717 + return ZodNullable$1.create(this, this._def);
718 + }
719 + nullish() {
720 + return this.nullable().optional();
721 + }
722 + array() {
723 + return ZodArray$1.create(this);
724 + }
725 + promise() {
726 + return ZodPromise.create(this, this._def);
727 + }
728 + or(option) {
729 + return ZodUnion$1.create([this, option], this._def);
730 + }
731 + and(incoming) {
732 + return ZodIntersection$1.create(this, incoming, this._def);
733 + }
734 + transform(transform) {
735 + return new ZodEffects({
736 + ...processCreateParams(this._def),
737 + schema: this,
738 + typeName: ZodFirstPartyTypeKind.ZodEffects,
739 + effect: {
740 + type: "transform",
741 + transform
742 + }
743 + });
744 + }
745 + default(def) {
746 + const defaultValueFunc = typeof def === "function" ? def : () => def;
747 + return new ZodDefault$1({
748 + ...processCreateParams(this._def),
749 + innerType: this,
750 + defaultValue: defaultValueFunc,
751 + typeName: ZodFirstPartyTypeKind.ZodDefault
752 + });
753 + }
754 + brand() {
755 + return new ZodBranded({
756 + typeName: ZodFirstPartyTypeKind.ZodBranded,
757 + type: this,
758 + ...processCreateParams(this._def)
759 + });
760 + }
761 + catch(def) {
762 + const catchValueFunc = typeof def === "function" ? def : () => def;
763 + return new ZodCatch$1({
764 + ...processCreateParams(this._def),
765 + innerType: this,
766 + catchValue: catchValueFunc,
767 + typeName: ZodFirstPartyTypeKind.ZodCatch
768 + });
769 + }
770 + describe(description) {
771 + const This = this.constructor;
772 + return new This({
773 + ...this._def,
774 + description
775 + });
776 + }
777 + pipe(target) {
778 + return ZodPipeline.create(this, target);
779 + }
780 + readonly() {
781 + return ZodReadonly$1.create(this);
782 + }
783 + isOptional() {
784 + return this.safeParse(void 0).success;
785 + }
786 + isNullable() {
787 + return this.safeParse(null).success;
788 + }
789 + };
790 + var cuidRegex = /^c[^\s-]{8,}$/i;
791 + var cuid2Regex = /^[0-9a-z]+$/;
792 + var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
793 + var uuidRegex = /^[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;
794 + var nanoidRegex = /^[a-z0-9_-]{21}$/i;
795 + var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
796 + var durationRegex = /^[-+]?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)?)??$/;
797 + var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
798 + var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
799 + var emojiRegex$1;
800 + var ipv4Regex = /^(?:(?: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])$/;
801 + var ipv4CidrRegex = /^(?:(?: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])$/;
802 + var ipv6Regex = /^(([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]))$/;
803 + var ipv6CidrRegex = /^(([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])$/;
804 + var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
805 + var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
806 + var dateRegexSource = `((\\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])))`;
807 + var dateRegex = new RegExp(`^${dateRegexSource}$`);
808 + function timeRegexSource(args) {
809 + let secondsRegexSource = `[0-5]\\d`;
810 + if (args.precision) secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
811 + else if (args.precision == null) secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
812 + const secondsQuantifier = args.precision ? "+" : "?";
813 + return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
814 + }
815 + function timeRegex(args) {
816 + return new RegExp(`^${timeRegexSource(args)}$`);
817 + }
818 + function datetimeRegex(args) {
819 + let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
820 + const opts = [];
821 + opts.push(args.local ? `Z?` : `Z`);
822 + if (args.offset) opts.push(`([+-]\\d{2}:?\\d{2})`);
823 + regex = `${regex}(${opts.join("|")})`;
824 + return new RegExp(`^${regex}$`);
825 + }
826 + function isValidIP(ip, version) {
827 + if ((version === "v4" || !version) && ipv4Regex.test(ip)) return true;
828 + if ((version === "v6" || !version) && ipv6Regex.test(ip)) return true;
829 + return false;
830 + }
831 + function isValidJWT$1(jwt, alg) {
832 + if (!jwtRegex.test(jwt)) return false;
833 + try {
834 + const [header] = jwt.split(".");
835 + if (!header) return false;
836 + const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
837 + const decoded = JSON.parse(atob(base64));
838 + if (typeof decoded !== "object" || decoded === null) return false;
839 + if ("typ" in decoded && decoded?.typ !== "JWT") return false;
840 + if (!decoded.alg) return false;
841 + if (alg && decoded.alg !== alg) return false;
842 + return true;
843 + } catch {
844 + return false;
845 + }
846 + }
847 + __name(isValidJWT$1, "isValidJWT");
848 + function isValidCidr(ip, version) {
849 + if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) return true;
850 + if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) return true;
851 + return false;
852 + }
853 + var ZodString$1 = class ZodString$1 extends ZodType$1 {
854 + static {
855 + __name(this, "ZodString");
856 + }
857 + _parse(input) {
858 + if (this._def.coerce) input.data = String(input.data);
859 + if (this._getType(input) !== ZodParsedType.string) {
860 + const ctx = this._getOrReturnCtx(input);
861 + addIssueToContext(ctx, {
862 + code: ZodIssueCode.invalid_type,
863 + expected: ZodParsedType.string,
864 + received: ctx.parsedType
865 + });
866 + return INVALID;
867 + }
868 + const status = new ParseStatus();
869 + let ctx = void 0;
870 + for (const check of this._def.checks) if (check.kind === "min") {
871 + if (input.data.length < check.value) {
872 + ctx = this._getOrReturnCtx(input, ctx);
873 + addIssueToContext(ctx, {
874 + code: ZodIssueCode.too_small,
875 + minimum: check.value,
876 + type: "string",
877 + inclusive: true,
878 + exact: false,
879 + message: check.message
880 + });
881 + status.dirty();
882 + }
883 + } else if (check.kind === "max") {
884 + if (input.data.length > check.value) {
885 + ctx = this._getOrReturnCtx(input, ctx);
886 + addIssueToContext(ctx, {
887 + code: ZodIssueCode.too_big,
888 + maximum: check.value,
889 + type: "string",
890 + inclusive: true,
891 + exact: false,
892 + message: check.message
893 + });
894 + status.dirty();
895 + }
896 + } else if (check.kind === "length") {
897 + const tooBig = input.data.length > check.value;
898 + const tooSmall = input.data.length < check.value;
899 + if (tooBig || tooSmall) {
900 + ctx = this._getOrReturnCtx(input, ctx);
901 + if (tooBig) addIssueToContext(ctx, {
902 + code: ZodIssueCode.too_big,
903 + maximum: check.value,
904 + type: "string",
905 + inclusive: true,
906 + exact: true,
907 + message: check.message
908 + });
909 + else if (tooSmall) addIssueToContext(ctx, {
910 + code: ZodIssueCode.too_small,
911 + minimum: check.value,
912 + type: "string",
913 + inclusive: true,
914 + exact: true,
915 + message: check.message
916 + });
917 + status.dirty();
918 + }
919 + } else if (check.kind === "email") {
920 + if (!emailRegex.test(input.data)) {
921 + ctx = this._getOrReturnCtx(input, ctx);
922 + addIssueToContext(ctx, {
923 + validation: "email",
924 + code: ZodIssueCode.invalid_string,
925 + message: check.message
926 + });
927 + status.dirty();
928 + }
929 + } else if (check.kind === "emoji") {
930 + if (!emojiRegex$1) emojiRegex$1 = new RegExp(_emojiRegex, "u");
931 + if (!emojiRegex$1.test(input.data)) {
932 + ctx = this._getOrReturnCtx(input, ctx);
933 + addIssueToContext(ctx, {
934 + validation: "emoji",
935 + code: ZodIssueCode.invalid_string,
936 + message: check.message
937 + });
938 + status.dirty();
939 + }
940 + } else if (check.kind === "uuid") {
941 + if (!uuidRegex.test(input.data)) {
942 + ctx = this._getOrReturnCtx(input, ctx);
943 + addIssueToContext(ctx, {
944 + validation: "uuid",
945 + code: ZodIssueCode.invalid_string,
946 + message: check.message
947 + });
948 + status.dirty();
949 + }
950 + } else if (check.kind === "nanoid") {
951 + if (!nanoidRegex.test(input.data)) {
952 + ctx = this._getOrReturnCtx(input, ctx);
953 + addIssueToContext(ctx, {
954 + validation: "nanoid",
955 + code: ZodIssueCode.invalid_string,
956 + message: check.message
957 + });
958 + status.dirty();
959 + }
960 + } else if (check.kind === "cuid") {
961 + if (!cuidRegex.test(input.data)) {
962 + ctx = this._getOrReturnCtx(input, ctx);
963 + addIssueToContext(ctx, {
964 + validation: "cuid",
965 + code: ZodIssueCode.invalid_string,
966 + message: check.message
967 + });
968 + status.dirty();
969 + }
970 + } else if (check.kind === "cuid2") {
971 + if (!cuid2Regex.test(input.data)) {
972 + ctx = this._getOrReturnCtx(input, ctx);
973 + addIssueToContext(ctx, {
974 + validation: "cuid2",
975 + code: ZodIssueCode.invalid_string,
976 + message: check.message
977 + });
978 + status.dirty();
979 + }
980 + } else if (check.kind === "ulid") {
981 + if (!ulidRegex.test(input.data)) {
982 + ctx = this._getOrReturnCtx(input, ctx);
983 + addIssueToContext(ctx, {
984 + validation: "ulid",
985 + code: ZodIssueCode.invalid_string,
986 + message: check.message
987 + });
988 + status.dirty();
989 + }
990 + } else if (check.kind === "url") try {
991 + new URL(input.data);
992 + } catch {
993 + ctx = this._getOrReturnCtx(input, ctx);
994 + addIssueToContext(ctx, {
995 + validation: "url",
996 + code: ZodIssueCode.invalid_string,
997 + message: check.message
998 + });
999 + status.dirty();
1000 + }
1001 + else if (check.kind === "regex") {
1002 + check.regex.lastIndex = 0;
1003 + if (!check.regex.test(input.data)) {
1004 + ctx = this._getOrReturnCtx(input, ctx);
1005 + addIssueToContext(ctx, {
1006 + validation: "regex",
1007 + code: ZodIssueCode.invalid_string,
1008 + message: check.message
1009 + });
1010 + status.dirty();
1011 + }
1012 + } else if (check.kind === "trim") input.data = input.data.trim();
1013 + else if (check.kind === "includes") {
1014 + if (!input.data.includes(check.value, check.position)) {
1015 + ctx = this._getOrReturnCtx(input, ctx);
1016 + addIssueToContext(ctx, {
1017 + code: ZodIssueCode.invalid_string,
1018 + validation: {
1019 + includes: check.value,
1020 + position: check.position
1021 + },
1022 + message: check.message
1023 + });
1024 + status.dirty();
1025 + }
1026 + } else if (check.kind === "toLowerCase") input.data = input.data.toLowerCase();
1027 + else if (check.kind === "toUpperCase") input.data = input.data.toUpperCase();
1028 + else if (check.kind === "startsWith") {
1029 + if (!input.data.startsWith(check.value)) {
1030 + ctx = this._getOrReturnCtx(input, ctx);
1031 + addIssueToContext(ctx, {
1032 + code: ZodIssueCode.invalid_string,
1033 + validation: { startsWith: check.value },
1034 + message: check.message
1035 + });
1036 + status.dirty();
1037 + }
1038 + } else if (check.kind === "endsWith") {
1039 + if (!input.data.endsWith(check.value)) {
1040 + ctx = this._getOrReturnCtx(input, ctx);
1041 + addIssueToContext(ctx, {
1042 + code: ZodIssueCode.invalid_string,
1043 + validation: { endsWith: check.value },
1044 + message: check.message
1045 + });
1046 + status.dirty();
1047 + }
1048 + } else if (check.kind === "datetime") {
1049 + if (!datetimeRegex(check).test(input.data)) {
1050 + ctx = this._getOrReturnCtx(input, ctx);
1051 + addIssueToContext(ctx, {
1052 + code: ZodIssueCode.invalid_string,
1053 + validation: "datetime",
1054 + message: check.message
1055 + });
1056 + status.dirty();
1057 + }
1058 + } else if (check.kind === "date") {
1059 + if (!dateRegex.test(input.data)) {
1060 + ctx = this._getOrReturnCtx(input, ctx);
1061 + addIssueToContext(ctx, {
1062 + code: ZodIssueCode.invalid_string,
1063 + validation: "date",
1064 + message: check.message
1065 + });
1066 + status.dirty();
1067 + }
1068 + } else if (check.kind === "time") {
1069 + if (!timeRegex(check).test(input.data)) {
1070 + ctx = this._getOrReturnCtx(input, ctx);
1071 + addIssueToContext(ctx, {
1072 + code: ZodIssueCode.invalid_string,
1073 + validation: "time",
1074 + message: check.message
1075 + });
1076 + status.dirty();
1077 + }
1078 + } else if (check.kind === "duration") {
1079 + if (!durationRegex.test(input.data)) {
1080 + ctx = this._getOrReturnCtx(input, ctx);
1081 + addIssueToContext(ctx, {
1082 + validation: "duration",
1083 + code: ZodIssueCode.invalid_string,
1084 + message: check.message
1085 + });
1086 + status.dirty();
1087 + }
1088 + } else if (check.kind === "ip") {
1089 + if (!isValidIP(input.data, check.version)) {
1090 + ctx = this._getOrReturnCtx(input, ctx);
1091 + addIssueToContext(ctx, {
1092 + validation: "ip",
1093 + code: ZodIssueCode.invalid_string,
1094 + message: check.message
1095 + });
1096 + status.dirty();
1097 + }
1098 + } else if (check.kind === "jwt") {
1099 + if (!isValidJWT$1(input.data, check.alg)) {
1100 + ctx = this._getOrReturnCtx(input, ctx);
1101 + addIssueToContext(ctx, {
1102 + validation: "jwt",
1103 + code: ZodIssueCode.invalid_string,
1104 + message: check.message
1105 + });
1106 + status.dirty();
1107 + }
1108 + } else if (check.kind === "cidr") {
1109 + if (!isValidCidr(input.data, check.version)) {
1110 + ctx = this._getOrReturnCtx(input, ctx);
1111 + addIssueToContext(ctx, {
1112 + validation: "cidr",
1113 + code: ZodIssueCode.invalid_string,
1114 + message: check.message
1115 + });
1116 + status.dirty();
1117 + }
1118 + } else if (check.kind === "base64") {
1119 + if (!base64Regex.test(input.data)) {
1120 + ctx = this._getOrReturnCtx(input, ctx);
1121 + addIssueToContext(ctx, {
1122 + validation: "base64",
1123 + code: ZodIssueCode.invalid_string,
1124 + message: check.message
1125 + });
1126 + status.dirty();
1127 + }
1128 + } else if (check.kind === "base64url") {
1129 + if (!base64urlRegex.test(input.data)) {
1130 + ctx = this._getOrReturnCtx(input, ctx);
1131 + addIssueToContext(ctx, {
1132 + validation: "base64url",
1133 + code: ZodIssueCode.invalid_string,
1134 + message: check.message
1135 + });
1136 + status.dirty();
1137 + }
1138 + } else util.assertNever(check);
1139 + return {
1140 + status: status.value,
1141 + value: input.data
1142 + };
1143 + }
1144 + _regex(regex, validation, message) {
1145 + return this.refinement((data) => regex.test(data), {
1146 + validation,
1147 + code: ZodIssueCode.invalid_string,
1148 + ...errorUtil.errToObj(message)
1149 + });
1150 + }
1151 + _addCheck(check) {
1152 + return new ZodString$1({
1153 + ...this._def,
1154 + checks: [...this._def.checks, check]
1155 + });
1156 + }
1157 + email(message) {
1158 + return this._addCheck({
1159 + kind: "email",
1160 + ...errorUtil.errToObj(message)
1161 + });
1162 + }
1163 + url(message) {
1164 + return this._addCheck({
1165 + kind: "url",
1166 + ...errorUtil.errToObj(message)
1167 + });
1168 + }
1169 + emoji(message) {
1170 + return this._addCheck({
1171 + kind: "emoji",
1172 + ...errorUtil.errToObj(message)
1173 + });
1174 + }
1175 + uuid(message) {
1176 + return this._addCheck({
1177 + kind: "uuid",
1178 + ...errorUtil.errToObj(message)
1179 + });
1180 + }
1181 + nanoid(message) {
1182 + return this._addCheck({
1183 + kind: "nanoid",
1184 + ...errorUtil.errToObj(message)
1185 + });
1186 + }
1187 + cuid(message) {
1188 + return this._addCheck({
1189 + kind: "cuid",
1190 + ...errorUtil.errToObj(message)
1191 + });
1192 + }
1193 + cuid2(message) {
1194 + return this._addCheck({
1195 + kind: "cuid2",
1196 + ...errorUtil.errToObj(message)
1197 + });
1198 + }
1199 + ulid(message) {
1200 + return this._addCheck({
1201 + kind: "ulid",
1202 + ...errorUtil.errToObj(message)
1203 + });
1204 + }
1205 + base64(message) {
1206 + return this._addCheck({
1207 + kind: "base64",
1208 + ...errorUtil.errToObj(message)
1209 + });
1210 + }
1211 + base64url(message) {
1212 + return this._addCheck({
1213 + kind: "base64url",
1214 + ...errorUtil.errToObj(message)
1215 + });
1216 + }
1217 + jwt(options) {
1218 + return this._addCheck({
1219 + kind: "jwt",
1220 + ...errorUtil.errToObj(options)
1221 + });
1222 + }
1223 + ip(options) {
1224 + return this._addCheck({
1225 + kind: "ip",
1226 + ...errorUtil.errToObj(options)
1227 + });
1228 + }
1229 + cidr(options) {
1230 + return this._addCheck({
1231 + kind: "cidr",
1232 + ...errorUtil.errToObj(options)
1233 + });
1234 + }
1235 + datetime(options) {
1236 + if (typeof options === "string") return this._addCheck({
1237 + kind: "datetime",
1238 + precision: null,
1239 + offset: false,
1240 + local: false,
1241 + message: options
1242 + });
1243 + return this._addCheck({
1244 + kind: "datetime",
1245 + precision: typeof options?.precision === "undefined" ? null : options?.precision,
1246 + offset: options?.offset ?? false,
1247 + local: options?.local ?? false,
1248 + ...errorUtil.errToObj(options?.message)
1249 + });
1250 + }
1251 + date(message) {
1252 + return this._addCheck({
1253 + kind: "date",
1254 + message
1255 + });
1256 + }
1257 + time(options) {
1258 + if (typeof options === "string") return this._addCheck({
1259 + kind: "time",
1260 + precision: null,
1261 + message: options
1262 + });
1263 + return this._addCheck({
1264 + kind: "time",
1265 + precision: typeof options?.precision === "undefined" ? null : options?.precision,
1266 + ...errorUtil.errToObj(options?.message)
1267 + });
1268 + }
1269 + duration(message) {
1270 + return this._addCheck({
1271 + kind: "duration",
1272 + ...errorUtil.errToObj(message)
1273 + });
1274 + }
1275 + regex(regex, message) {
1276 + return this._addCheck({
1277 + kind: "regex",
1278 + regex,
1279 + ...errorUtil.errToObj(message)
1280 + });
1281 + }
1282 + includes(value, options) {
1283 + return this._addCheck({
1284 + kind: "includes",
1285 + value,
1286 + position: options?.position,
1287 + ...errorUtil.errToObj(options?.message)
1288 + });
1289 + }
1290 + startsWith(value, message) {
1291 + return this._addCheck({
1292 + kind: "startsWith",
1293 + value,
1294 + ...errorUtil.errToObj(message)
1295 + });
1296 + }
1297 + endsWith(value, message) {
1298 + return this._addCheck({
1299 + kind: "endsWith",
1300 + value,
1301 + ...errorUtil.errToObj(message)
1302 + });
1303 + }
1304 + min(minLength, message) {
1305 + return this._addCheck({
1306 + kind: "min",
1307 + value: minLength,
1308 + ...errorUtil.errToObj(message)
1309 + });
1310 + }
1311 + max(maxLength, message) {
1312 + return this._addCheck({
1313 + kind: "max",
1314 + value: maxLength,
1315 + ...errorUtil.errToObj(message)
1316 + });
1317 + }
1318 + length(len, message) {
1319 + return this._addCheck({
1320 + kind: "length",
1321 + value: len,
1322 + ...errorUtil.errToObj(message)
1323 + });
1324 + }
1325 + /**
1326 + * Equivalent to `.min(1)`
1327 + */
1328 + nonempty(message) {
1329 + return this.min(1, errorUtil.errToObj(message));
1330 + }
1331 + trim() {
1332 + return new ZodString$1({
1333 + ...this._def,
1334 + checks: [...this._def.checks, { kind: "trim" }]
1335 + });
1336 + }
1337 + toLowerCase() {
1338 + return new ZodString$1({
1339 + ...this._def,
1340 + checks: [...this._def.checks, { kind: "toLowerCase" }]
1341 + });
1342 + }
1343 + toUpperCase() {
1344 + return new ZodString$1({
1345 + ...this._def,
1346 + checks: [...this._def.checks, { kind: "toUpperCase" }]
1347 + });
1348 + }
1349 + get isDatetime() {
1350 + return !!this._def.checks.find((ch) => ch.kind === "datetime");
1351 + }
1352 + get isDate() {
1353 + return !!this._def.checks.find((ch) => ch.kind === "date");
1354 + }
1355 + get isTime() {
1356 + return !!this._def.checks.find((ch) => ch.kind === "time");
1357 + }
1358 + get isDuration() {
1359 + return !!this._def.checks.find((ch) => ch.kind === "duration");
1360 + }
1361 + get isEmail() {
1362 + return !!this._def.checks.find((ch) => ch.kind === "email");
1363 + }
1364 + get isURL() {
1365 + return !!this._def.checks.find((ch) => ch.kind === "url");
1366 + }
1367 + get isEmoji() {
1368 + return !!this._def.checks.find((ch) => ch.kind === "emoji");
1369 + }
1370 + get isUUID() {
1371 + return !!this._def.checks.find((ch) => ch.kind === "uuid");
1372 + }
1373 + get isNANOID() {
1374 + return !!this._def.checks.find((ch) => ch.kind === "nanoid");
1375 + }
1376 + get isCUID() {
1377 + return !!this._def.checks.find((ch) => ch.kind === "cuid");
1378 + }
1379 + get isCUID2() {
1380 + return !!this._def.checks.find((ch) => ch.kind === "cuid2");
1381 + }
1382 + get isULID() {
1383 + return !!this._def.checks.find((ch) => ch.kind === "ulid");
1384 + }
1385 + get isIP() {
1386 + return !!this._def.checks.find((ch) => ch.kind === "ip");
1387 + }
1388 + get isCIDR() {
1389 + return !!this._def.checks.find((ch) => ch.kind === "cidr");
1390 + }
1391 + get isBase64() {
1392 + return !!this._def.checks.find((ch) => ch.kind === "base64");
1393 + }
1394 + get isBase64url() {
1395 + return !!this._def.checks.find((ch) => ch.kind === "base64url");
1396 + }
1397 + get minLength() {
1398 + let min = null;
1399 + for (const ch of this._def.checks) if (ch.kind === "min") {
1400 + if (min === null || ch.value > min) min = ch.value;
1401 + }
1402 + return min;
1403 + }
1404 + get maxLength() {
1405 + let max = null;
1406 + for (const ch of this._def.checks) if (ch.kind === "max") {
1407 + if (max === null || ch.value < max) max = ch.value;
1408 + }
1409 + return max;
1410 + }
1411 + };
1412 + ZodString$1.create = (params) => {
1413 + return new ZodString$1({
1414 + checks: [],
1415 + typeName: ZodFirstPartyTypeKind.ZodString,
1416 + coerce: params?.coerce ?? false,
1417 + ...processCreateParams(params)
1418 + });
1419 + };
1420 + function floatSafeRemainder$1(val, step) {
1421 + const valDecCount = (val.toString().split(".")[1] || "").length;
1422 + const stepDecCount = (step.toString().split(".")[1] || "").length;
1423 + const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
1424 + return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
1425 + }
1426 + __name(floatSafeRemainder$1, "floatSafeRemainder");
1427 + var ZodNumber$1 = class ZodNumber$1 extends ZodType$1 {
1428 + static {
1429 + __name(this, "ZodNumber");
1430 + }
1431 + constructor() {
1432 + super(...arguments);
1433 + this.min = this.gte;
1434 + this.max = this.lte;
1435 + this.step = this.multipleOf;
1436 + }
1437 + _parse(input) {
1438 + if (this._def.coerce) input.data = Number(input.data);
1439 + if (this._getType(input) !== ZodParsedType.number) {
1440 + const ctx = this._getOrReturnCtx(input);
1441 + addIssueToContext(ctx, {
1442 + code: ZodIssueCode.invalid_type,
1443 + expected: ZodParsedType.number,
1444 + received: ctx.parsedType
1445 + });
1446 + return INVALID;
1447 + }
1448 + let ctx = void 0;
1449 + const status = new ParseStatus();
1450 + for (const check of this._def.checks) if (check.kind === "int") {
1451 + if (!util.isInteger(input.data)) {
1452 + ctx = this._getOrReturnCtx(input, ctx);
1453 + addIssueToContext(ctx, {
1454 + code: ZodIssueCode.invalid_type,
1455 + expected: "integer",
1456 + received: "float",
1457 + message: check.message
1458 + });
1459 + status.dirty();
1460 + }
1461 + } else if (check.kind === "min") {
1462 + if (check.inclusive ? input.data < check.value : input.data <= check.value) {
1463 + ctx = this._getOrReturnCtx(input, ctx);
1464 + addIssueToContext(ctx, {
1465 + code: ZodIssueCode.too_small,
1466 + minimum: check.value,
1467 + type: "number",
1468 + inclusive: check.inclusive,
1469 + exact: false,
1470 + message: check.message
1471 + });
1472 + status.dirty();
1473 + }
1474 + } else if (check.kind === "max") {
1475 + if (check.inclusive ? input.data > check.value : input.data >= check.value) {
1476 + ctx = this._getOrReturnCtx(input, ctx);
1477 + addIssueToContext(ctx, {
1478 + code: ZodIssueCode.too_big,
1479 + maximum: check.value,
1480 + type: "number",
1481 + inclusive: check.inclusive,
1482 + exact: false,
1483 + message: check.message
1484 + });
1485 + status.dirty();
1486 + }
1487 + } else if (check.kind === "multipleOf") {
1488 + if (floatSafeRemainder$1(input.data, check.value) !== 0) {
1489 + ctx = this._getOrReturnCtx(input, ctx);
1490 + addIssueToContext(ctx, {
1491 + code: ZodIssueCode.not_multiple_of,
1492 + multipleOf: check.value,
1493 + message: check.message
1494 + });
1495 + status.dirty();
1496 + }
1497 + } else if (check.kind === "finite") {
1498 + if (!Number.isFinite(input.data)) {
1499 + ctx = this._getOrReturnCtx(input, ctx);
1500 + addIssueToContext(ctx, {
1501 + code: ZodIssueCode.not_finite,
1502 + message: check.message
1503 + });
1504 + status.dirty();
1505 + }
1506 + } else util.assertNever(check);
1507 + return {
1508 + status: status.value,
1509 + value: input.data
1510 + };
1511 + }
1512 + gte(value, message) {
1513 + return this.setLimit("min", value, true, errorUtil.toString(message));
1514 + }
1515 + gt(value, message) {
1516 + return this.setLimit("min", value, false, errorUtil.toString(message));
1517 + }
1518 + lte(value, message) {
1519 + return this.setLimit("max", value, true, errorUtil.toString(message));
1520 + }
1521 + lt(value, message) {
1522 + return this.setLimit("max", value, false, errorUtil.toString(message));
1523 + }
1524 + setLimit(kind, value, inclusive, message) {
1525 + return new ZodNumber$1({
1526 + ...this._def,
1527 + checks: [...this._def.checks, {
1528 + kind,
1529 + value,
1530 + inclusive,
1531 + message: errorUtil.toString(message)
1532 + }]
1533 + });
1534 + }
1535 + _addCheck(check) {
1536 + return new ZodNumber$1({
1537 + ...this._def,
1538 + checks: [...this._def.checks, check]
1539 + });
1540 + }
1541 + int(message) {
1542 + return this._addCheck({
1543 + kind: "int",
1544 + message: errorUtil.toString(message)
1545 + });
1546 + }
1547 + positive(message) {
1548 + return this._addCheck({
1549 + kind: "min",
1550 + value: 0,
1551 + inclusive: false,
1552 + message: errorUtil.toString(message)
1553 + });
1554 + }
1555 + negative(message) {
1556 + return this._addCheck({
1557 + kind: "max",
1558 + value: 0,
1559 + inclusive: false,
1560 + message: errorUtil.toString(message)
1561 + });
1562 + }
1563 + nonpositive(message) {
1564 + return this._addCheck({
1565 + kind: "max",
1566 + value: 0,
1567 + inclusive: true,
1568 + message: errorUtil.toString(message)
1569 + });
1570 + }
1571 + nonnegative(message) {
1572 + return this._addCheck({
1573 + kind: "min",
1574 + value: 0,
1575 + inclusive: true,
1576 + message: errorUtil.toString(message)
1577 + });
1578 + }
1579 + multipleOf(value, message) {
1580 + return this._addCheck({
1581 + kind: "multipleOf",
1582 + value,
1583 + message: errorUtil.toString(message)
1584 + });
1585 + }
1586 + finite(message) {
1587 + return this._addCheck({
1588 + kind: "finite",
1589 + message: errorUtil.toString(message)
1590 + });
1591 + }
1592 + safe(message) {
1593 + return this._addCheck({
1594 + kind: "min",
1595 + inclusive: true,
1596 + value: Number.MIN_SAFE_INTEGER,
1597 + message: errorUtil.toString(message)
1598 + })._addCheck({
1599 + kind: "max",
1600 + inclusive: true,
1601 + value: Number.MAX_SAFE_INTEGER,
1602 + message: errorUtil.toString(message)
1603 + });
1604 + }
1605 + get minValue() {
1606 + let min = null;
1607 + for (const ch of this._def.checks) if (ch.kind === "min") {
1608 + if (min === null || ch.value > min) min = ch.value;
1609 + }
1610 + return min;
1611 + }
1612 + get maxValue() {
1613 + let max = null;
1614 + for (const ch of this._def.checks) if (ch.kind === "max") {
1615 + if (max === null || ch.value < max) max = ch.value;
1616 + }
1617 + return max;
1618 + }
1619 + get isInt() {
1620 + return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
1621 + }
1622 + get isFinite() {
1623 + let max = null;
1624 + let min = null;
1625 + for (const ch of this._def.checks) if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") return true;
1626 + else if (ch.kind === "min") {
1627 + if (min === null || ch.value > min) min = ch.value;
1628 + } else if (ch.kind === "max") {
1629 + if (max === null || ch.value < max) max = ch.value;
1630 + }
1631 + return Number.isFinite(min) && Number.isFinite(max);
1632 + }
1633 + };
1634 + ZodNumber$1.create = (params) => {
1635 + return new ZodNumber$1({
1636 + checks: [],
1637 + typeName: ZodFirstPartyTypeKind.ZodNumber,
1638 + coerce: params?.coerce || false,
1639 + ...processCreateParams(params)
1640 + });
1641 + };
1642 + var ZodBigInt = class ZodBigInt extends ZodType$1 {
1643 + constructor() {
1644 + super(...arguments);
1645 + this.min = this.gte;
1646 + this.max = this.lte;
1647 + }
1648 + _parse(input) {
1649 + if (this._def.coerce) try {
1650 + input.data = BigInt(input.data);
1651 + } catch {
1652 + return this._getInvalidInput(input);
1653 + }
1654 + if (this._getType(input) !== ZodParsedType.bigint) return this._getInvalidInput(input);
1655 + let ctx = void 0;
1656 + const status = new ParseStatus();
1657 + for (const check of this._def.checks) if (check.kind === "min") {
1658 + if (check.inclusive ? input.data < check.value : input.data <= check.value) {
1659 + ctx = this._getOrReturnCtx(input, ctx);
1660 + addIssueToContext(ctx, {
1661 + code: ZodIssueCode.too_small,
1662 + type: "bigint",
1663 + minimum: check.value,
1664 + inclusive: check.inclusive,
1665 + message: check.message
1666 + });
1667 + status.dirty();
1668 + }
1669 + } else if (check.kind === "max") {
1670 + if (check.inclusive ? input.data > check.value : input.data >= check.value) {
1671 + ctx = this._getOrReturnCtx(input, ctx);
1672 + addIssueToContext(ctx, {
1673 + code: ZodIssueCode.too_big,
1674 + type: "bigint",
1675 + maximum: check.value,
1676 + inclusive: check.inclusive,
1677 + message: check.message
1678 + });
1679 + status.dirty();
1680 + }
1681 + } else if (check.kind === "multipleOf") {
1682 + if (input.data % check.value !== BigInt(0)) {
1683 + ctx = this._getOrReturnCtx(input, ctx);
1684 + addIssueToContext(ctx, {
1685 + code: ZodIssueCode.not_multiple_of,
1686 + multipleOf: check.value,
1687 + message: check.message
1688 + });
1689 + status.dirty();
1690 + }
1691 + } else util.assertNever(check);
1692 + return {
1693 + status: status.value,
1694 + value: input.data
1695 + };
1696 + }
1697 + _getInvalidInput(input) {
1698 + const ctx = this._getOrReturnCtx(input);
1699 + addIssueToContext(ctx, {
1700 + code: ZodIssueCode.invalid_type,
1701 + expected: ZodParsedType.bigint,
1702 + received: ctx.parsedType
1703 + });
1704 + return INVALID;
1705 + }
1706 + gte(value, message) {
1707 + return this.setLimit("min", value, true, errorUtil.toString(message));
1708 + }
1709 + gt(value, message) {
1710 + return this.setLimit("min", value, false, errorUtil.toString(message));
1711 + }
1712 + lte(value, message) {
1713 + return this.setLimit("max", value, true, errorUtil.toString(message));
1714 + }
1715 + lt(value, message) {
1716 + return this.setLimit("max", value, false, errorUtil.toString(message));
1717 + }
1718 + setLimit(kind, value, inclusive, message) {
1719 + return new ZodBigInt({
1720 + ...this._def,
1721 + checks: [...this._def.checks, {
1722 + kind,
1723 + value,
1724 + inclusive,
1725 + message: errorUtil.toString(message)
1726 + }]
1727 + });
1728 + }
1729 + _addCheck(check) {
1730 + return new ZodBigInt({
1731 + ...this._def,
1732 + checks: [...this._def.checks, check]
1733 + });
1734 + }
1735 + positive(message) {
1736 + return this._addCheck({
1737 + kind: "min",
1738 + value: BigInt(0),
1739 + inclusive: false,
1740 + message: errorUtil.toString(message)
1741 + });
1742 + }
1743 + negative(message) {
1744 + return this._addCheck({
1745 + kind: "max",
1746 + value: BigInt(0),
1747 + inclusive: false,
1748 + message: errorUtil.toString(message)
1749 + });
1750 + }
1751 + nonpositive(message) {
1752 + return this._addCheck({
1753 + kind: "max",
1754 + value: BigInt(0),
1755 + inclusive: true,
1756 + message: errorUtil.toString(message)
1757 + });
1758 + }
1759 + nonnegative(message) {
1760 + return this._addCheck({
1761 + kind: "min",
1762 + value: BigInt(0),
1763 + inclusive: true,
1764 + message: errorUtil.toString(message)
1765 + });
1766 + }
1767 + multipleOf(value, message) {
1768 + return this._addCheck({
1769 + kind: "multipleOf",
1770 + value,
1771 + message: errorUtil.toString(message)
1772 + });
1773 + }
1774 + get minValue() {
1775 + let min = null;
1776 + for (const ch of this._def.checks) if (ch.kind === "min") {
1777 + if (min === null || ch.value > min) min = ch.value;
1778 + }
1779 + return min;
1780 + }
1781 + get maxValue() {
1782 + let max = null;
1783 + for (const ch of this._def.checks) if (ch.kind === "max") {
1784 + if (max === null || ch.value < max) max = ch.value;
1785 + }
1786 + return max;
1787 + }
1788 + };
1789 + ZodBigInt.create = (params) => {
1790 + return new ZodBigInt({
1791 + checks: [],
1792 + typeName: ZodFirstPartyTypeKind.ZodBigInt,
1793 + coerce: params?.coerce ?? false,
1794 + ...processCreateParams(params)
1795 + });
1796 + };
1797 + var ZodBoolean$1 = class extends ZodType$1 {
1798 + static {
1799 + __name(this, "ZodBoolean");
1800 + }
1801 + _parse(input) {
1802 + if (this._def.coerce) input.data = Boolean(input.data);
1803 + if (this._getType(input) !== ZodParsedType.boolean) {
1804 + const ctx = this._getOrReturnCtx(input);
1805 + addIssueToContext(ctx, {
1806 + code: ZodIssueCode.invalid_type,
1807 + expected: ZodParsedType.boolean,
1808 + received: ctx.parsedType
1809 + });
1810 + return INVALID;
1811 + }
1812 + return OK(input.data);
1813 + }
1814 + };
1815 + ZodBoolean$1.create = (params) => {
1816 + return new ZodBoolean$1({
1817 + typeName: ZodFirstPartyTypeKind.ZodBoolean,
1818 + coerce: params?.coerce || false,
1819 + ...processCreateParams(params)
1820 + });
1821 + };
1822 + var ZodDate = class ZodDate extends ZodType$1 {
1823 + _parse(input) {
1824 + if (this._def.coerce) input.data = new Date(input.data);
1825 + if (this._getType(input) !== ZodParsedType.date) {
1826 + const ctx = this._getOrReturnCtx(input);
1827 + addIssueToContext(ctx, {
1828 + code: ZodIssueCode.invalid_type,
1829 + expected: ZodParsedType.date,
1830 + received: ctx.parsedType
1831 + });
1832 + return INVALID;
1833 + }
1834 + if (Number.isNaN(input.data.getTime())) {
1835 + addIssueToContext(this._getOrReturnCtx(input), { code: ZodIssueCode.invalid_date });
1836 + return INVALID;
1837 + }
1838 + const status = new ParseStatus();
1839 + let ctx = void 0;
1840 + for (const check of this._def.checks) if (check.kind === "min") {
1841 + if (input.data.getTime() < check.value) {
1842 + ctx = this._getOrReturnCtx(input, ctx);
1843 + addIssueToContext(ctx, {
1844 + code: ZodIssueCode.too_small,
1845 + message: check.message,
1846 + inclusive: true,
1847 + exact: false,
1848 + minimum: check.value,
1849 + type: "date"
1850 + });
1851 + status.dirty();
1852 + }
1853 + } else if (check.kind === "max") {
1854 + if (input.data.getTime() > check.value) {
1855 + ctx = this._getOrReturnCtx(input, ctx);
1856 + addIssueToContext(ctx, {
1857 + code: ZodIssueCode.too_big,
1858 + message: check.message,
1859 + inclusive: true,
1860 + exact: false,
1861 + maximum: check.value,
1862 + type: "date"
1863 + });
1864 + status.dirty();
1865 + }
1866 + } else util.assertNever(check);
1867 + return {
1868 + status: status.value,
1869 + value: new Date(input.data.getTime())
1870 + };
1871 + }
1872 + _addCheck(check) {
1873 + return new ZodDate({
1874 + ...this._def,
1875 + checks: [...this._def.checks, check]
1876 + });
1877 + }
1878 + min(minDate, message) {
1879 + return this._addCheck({
1880 + kind: "min",
1881 + value: minDate.getTime(),
1882 + message: errorUtil.toString(message)
1883 + });
1884 + }
1885 + max(maxDate, message) {
1886 + return this._addCheck({
1887 + kind: "max",
1888 + value: maxDate.getTime(),
1889 + message: errorUtil.toString(message)
1890 + });
1891 + }
1892 + get minDate() {
1893 + let min = null;
1894 + for (const ch of this._def.checks) if (ch.kind === "min") {
1895 + if (min === null || ch.value > min) min = ch.value;
1896 + }
1897 + return min != null ? new Date(min) : null;
1898 + }
1899 + get maxDate() {
1900 + let max = null;
1901 + for (const ch of this._def.checks) if (ch.kind === "max") {
1902 + if (max === null || ch.value < max) max = ch.value;
1903 + }
1904 + return max != null ? new Date(max) : null;
1905 + }
1906 + };
1907 + ZodDate.create = (params) => {
1908 + return new ZodDate({
1909 + checks: [],
1910 + coerce: params?.coerce || false,
1911 + typeName: ZodFirstPartyTypeKind.ZodDate,
1912 + ...processCreateParams(params)
1913 + });
1914 + };
1915 + var ZodSymbol = class extends ZodType$1 {
1916 + _parse(input) {
1917 + if (this._getType(input) !== ZodParsedType.symbol) {
1918 + const ctx = this._getOrReturnCtx(input);
1919 + addIssueToContext(ctx, {
1920 + code: ZodIssueCode.invalid_type,
1921 + expected: ZodParsedType.symbol,
1922 + received: ctx.parsedType
1923 + });
1924 + return INVALID;
1925 + }
1926 + return OK(input.data);
1927 + }
1928 + };
1929 + ZodSymbol.create = (params) => {
1930 + return new ZodSymbol({
1931 + typeName: ZodFirstPartyTypeKind.ZodSymbol,
1932 + ...processCreateParams(params)
1933 + });
1934 + };
1935 + var ZodUndefined = class extends ZodType$1 {
1936 + _parse(input) {
1937 + if (this._getType(input) !== ZodParsedType.undefined) {
1938 + const ctx = this._getOrReturnCtx(input);
1939 + addIssueToContext(ctx, {
1940 + code: ZodIssueCode.invalid_type,
1941 + expected: ZodParsedType.undefined,
1942 + received: ctx.parsedType
1943 + });
1944 + return INVALID;
1945 + }
1946 + return OK(input.data);
1947 + }
1948 + };
1949 + ZodUndefined.create = (params) => {
1950 + return new ZodUndefined({
1951 + typeName: ZodFirstPartyTypeKind.ZodUndefined,
1952 + ...processCreateParams(params)
1953 + });
1954 + };
1955 + var ZodNull$1 = class extends ZodType$1 {
1956 + static {
1957 + __name(this, "ZodNull");
1958 + }
1959 + _parse(input) {
1960 + if (this._getType(input) !== ZodParsedType.null) {
1961 + const ctx = this._getOrReturnCtx(input);
1962 + addIssueToContext(ctx, {
1963 + code: ZodIssueCode.invalid_type,
1964 + expected: ZodParsedType.null,
1965 + received: ctx.parsedType
1966 + });
1967 + return INVALID;
1968 + }
1969 + return OK(input.data);
1970 + }
1971 + };
1972 + ZodNull$1.create = (params) => {
1973 + return new ZodNull$1({
1974 + typeName: ZodFirstPartyTypeKind.ZodNull,
1975 + ...processCreateParams(params)
1976 + });
1977 + };
1978 + var ZodAny = class extends ZodType$1 {
1979 + constructor() {
1980 + super(...arguments);
1981 + this._any = true;
1982 + }
1983 + _parse(input) {
1984 + return OK(input.data);
1985 + }
1986 + };
1987 + ZodAny.create = (params) => {
1988 + return new ZodAny({
1989 + typeName: ZodFirstPartyTypeKind.ZodAny,
1990 + ...processCreateParams(params)
1991 + });
1992 + };
1993 + var ZodUnknown$1 = class extends ZodType$1 {
1994 + static {
1995 + __name(this, "ZodUnknown");
1996 + }
1997 + constructor() {
1998 + super(...arguments);
1999 + this._unknown = true;
2000 + }
2001 + _parse(input) {
2002 + return OK(input.data);
2003 + }
2004 + };
2005 + ZodUnknown$1.create = (params) => {
2006 + return new ZodUnknown$1({
2007 + typeName: ZodFirstPartyTypeKind.ZodUnknown,
2008 + ...processCreateParams(params)
2009 + });
2010 + };
2011 + var ZodNever$1 = class extends ZodType$1 {
2012 + static {
2013 + __name(this, "ZodNever");
2014 + }
2015 + _parse(input) {
2016 + const ctx = this._getOrReturnCtx(input);
2017 + addIssueToContext(ctx, {
2018 + code: ZodIssueCode.invalid_type,
2019 + expected: ZodParsedType.never,
2020 + received: ctx.parsedType
2021 + });
2022 + return INVALID;
2023 + }
2024 + };
2025 + ZodNever$1.create = (params) => {
2026 + return new ZodNever$1({
2027 + typeName: ZodFirstPartyTypeKind.ZodNever,
2028 + ...processCreateParams(params)
2029 + });
2030 + };
2031 + var ZodVoid = class extends ZodType$1 {
2032 + _parse(input) {
2033 + if (this._getType(input) !== ZodParsedType.undefined) {
2034 + const ctx = this._getOrReturnCtx(input);
2035 + addIssueToContext(ctx, {
2036 + code: ZodIssueCode.invalid_type,
2037 + expected: ZodParsedType.void,
2038 + received: ctx.parsedType
2039 + });
2040 + return INVALID;
2041 + }
2042 + return OK(input.data);
2043 + }
2044 + };
2045 + ZodVoid.create = (params) => {
2046 + return new ZodVoid({
2047 + typeName: ZodFirstPartyTypeKind.ZodVoid,
2048 + ...processCreateParams(params)
2049 + });
2050 + };
2051 + var ZodArray$1 = class ZodArray$1 extends ZodType$1 {
2052 + static {
2053 + __name(this, "ZodArray");
2054 + }
2055 + _parse(input) {
2056 + const { ctx, status } = this._processInputParams(input);
2057 + const def = this._def;
2058 + if (ctx.parsedType !== ZodParsedType.array) {
2059 + addIssueToContext(ctx, {
2060 + code: ZodIssueCode.invalid_type,
2061 + expected: ZodParsedType.array,
2062 + received: ctx.parsedType
2063 + });
2064 + return INVALID;
2065 + }
2066 + if (def.exactLength !== null) {
2067 + const tooBig = ctx.data.length > def.exactLength.value;
2068 + const tooSmall = ctx.data.length < def.exactLength.value;
2069 + if (tooBig || tooSmall) {
2070 + addIssueToContext(ctx, {
2071 + code: tooBig ? ZodIssueCode.too_big : ZodIssueCode.too_small,
2072 + minimum: tooSmall ? def.exactLength.value : void 0,
2073 + maximum: tooBig ? def.exactLength.value : void 0,
2074 + type: "array",
2075 + inclusive: true,
2076 + exact: true,
2077 + message: def.exactLength.message
2078 + });
2079 + status.dirty();
2080 + }
2081 + }
2082 + if (def.minLength !== null) {
2083 + if (ctx.data.length < def.minLength.value) {
2084 + addIssueToContext(ctx, {
2085 + code: ZodIssueCode.too_small,
2086 + minimum: def.minLength.value,
2087 + type: "array",
2088 + inclusive: true,
2089 + exact: false,
2090 + message: def.minLength.message
2091 + });
2092 + status.dirty();
2093 + }
2094 + }
2095 + if (def.maxLength !== null) {
2096 + if (ctx.data.length > def.maxLength.value) {
2097 + addIssueToContext(ctx, {
2098 + code: ZodIssueCode.too_big,
2099 + maximum: def.maxLength.value,
2100 + type: "array",
2101 + inclusive: true,
2102 + exact: false,
2103 + message: def.maxLength.message
2104 + });
2105 + status.dirty();
2106 + }
2107 + }
2108 + if (ctx.common.async) return Promise.all([...ctx.data].map((item, i) => {
2109 + return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2110 + })).then((result) => {
2111 + return ParseStatus.mergeArray(status, result);
2112 + });
2113 + const result = [...ctx.data].map((item, i) => {
2114 + return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
2115 + });
2116 + return ParseStatus.mergeArray(status, result);
2117 + }
2118 + get element() {
2119 + return this._def.type;
2120 + }
2121 + min(minLength, message) {
2122 + return new ZodArray$1({
2123 + ...this._def,
2124 + minLength: {
2125 + value: minLength,
2126 + message: errorUtil.toString(message)
2127 + }
2128 + });
2129 + }
2130 + max(maxLength, message) {
2131 + return new ZodArray$1({
2132 + ...this._def,
2133 + maxLength: {
2134 + value: maxLength,
2135 + message: errorUtil.toString(message)
2136 + }
2137 + });
2138 + }
2139 + length(len, message) {
2140 + return new ZodArray$1({
2141 + ...this._def,
2142 + exactLength: {
2143 + value: len,
2144 + message: errorUtil.toString(message)
2145 + }
2146 + });
2147 + }
2148 + nonempty(message) {
2149 + return this.min(1, message);
2150 + }
2151 + };
2152 + ZodArray$1.create = (schema, params) => {
2153 + return new ZodArray$1({
2154 + type: schema,
2155 + minLength: null,
2156 + maxLength: null,
2157 + exactLength: null,
2158 + typeName: ZodFirstPartyTypeKind.ZodArray,
2159 + ...processCreateParams(params)
2160 + });
2161 + };
2162 + function deepPartialify(schema) {
2163 + if (schema instanceof ZodObject$1) {
2164 + const newShape = {};
2165 + for (const key in schema.shape) {
2166 + const fieldSchema = schema.shape[key];
2167 + newShape[key] = ZodOptional$1.create(deepPartialify(fieldSchema));
2168 + }
2169 + return new ZodObject$1({
2170 + ...schema._def,
2171 + shape: () => newShape
2172 + });
2173 + } else if (schema instanceof ZodArray$1) return new ZodArray$1({
2174 + ...schema._def,
2175 + type: deepPartialify(schema.element)
2176 + });
2177 + else if (schema instanceof ZodOptional$1) return ZodOptional$1.create(deepPartialify(schema.unwrap()));
2178 + else if (schema instanceof ZodNullable$1) return ZodNullable$1.create(deepPartialify(schema.unwrap()));
2179 + else if (schema instanceof ZodTuple) return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
2180 + else return schema;
2181 + }
2182 + var ZodObject$1 = class ZodObject$1 extends ZodType$1 {
2183 + static {
2184 + __name(this, "ZodObject");
2185 + }
2186 + constructor() {
2187 + super(...arguments);
2188 + this._cached = null;
2189 + /**
2190 + * @deprecated In most cases, this is no longer needed - unknown properties are now silently stripped.
2191 + * If you want to pass through unknown properties, use `.passthrough()` instead.
2192 + */
2193 + this.nonstrict = this.passthrough;
2194 + /**
2195 + * @deprecated Use `.extend` instead
2196 + * */
2197 + this.augment = this.extend;
2198 + }
2199 + _getCached() {
2200 + if (this._cached !== null) return this._cached;
2201 + const shape = this._def.shape();
2202 + const keys = util.objectKeys(shape);
2203 + this._cached = {
2204 + shape,
2205 + keys
2206 + };
2207 + return this._cached;
2208 + }
2209 + _parse(input) {
2210 + if (this._getType(input) !== ZodParsedType.object) {
2211 + const ctx = this._getOrReturnCtx(input);
2212 + addIssueToContext(ctx, {
2213 + code: ZodIssueCode.invalid_type,
2214 + expected: ZodParsedType.object,
2215 + received: ctx.parsedType
2216 + });
2217 + return INVALID;
2218 + }
2219 + const { status, ctx } = this._processInputParams(input);
2220 + const { shape, keys: shapeKeys } = this._getCached();
2221 + const extraKeys = [];
2222 + if (!(this._def.catchall instanceof ZodNever$1 && this._def.unknownKeys === "strip")) {
2223 + for (const key in ctx.data) if (!shapeKeys.includes(key)) extraKeys.push(key);
2224 + }
2225 + const pairs = [];
2226 + for (const key of shapeKeys) {
2227 + const keyValidator = shape[key];
2228 + const value = ctx.data[key];
2229 + pairs.push({
2230 + key: {
2231 + status: "valid",
2232 + value: key
2233 + },
2234 + value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2235 + alwaysSet: key in ctx.data
2236 + });
2237 + }
2238 + if (this._def.catchall instanceof ZodNever$1) {
2239 + const unknownKeys = this._def.unknownKeys;
2240 + if (unknownKeys === "passthrough") for (const key of extraKeys) pairs.push({
2241 + key: {
2242 + status: "valid",
2243 + value: key
2244 + },
2245 + value: {
2246 + status: "valid",
2247 + value: ctx.data[key]
2248 + }
2249 + });
2250 + else if (unknownKeys === "strict") {
2251 + if (extraKeys.length > 0) {
2252 + addIssueToContext(ctx, {
2253 + code: ZodIssueCode.unrecognized_keys,
2254 + keys: extraKeys
2255 + });
2256 + status.dirty();
2257 + }
2258 + } else if (unknownKeys === "strip") {} else throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
2259 + } else {
2260 + const catchall = this._def.catchall;
2261 + for (const key of extraKeys) {
2262 + const value = ctx.data[key];
2263 + pairs.push({
2264 + key: {
2265 + status: "valid",
2266 + value: key
2267 + },
2268 + value: catchall._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
2269 + alwaysSet: key in ctx.data
2270 + });
2271 + }
2272 + }
2273 + if (ctx.common.async) return Promise.resolve().then(async () => {
2274 + const syncPairs = [];
2275 + for (const pair of pairs) {
2276 + const key = await pair.key;
2277 + const value = await pair.value;
2278 + syncPairs.push({
2279 + key,
2280 + value,
2281 + alwaysSet: pair.alwaysSet
2282 + });
2283 + }
2284 + return syncPairs;
2285 + }).then((syncPairs) => {
2286 + return ParseStatus.mergeObjectSync(status, syncPairs);
2287 + });
2288 + else return ParseStatus.mergeObjectSync(status, pairs);
2289 + }
2290 + get shape() {
2291 + return this._def.shape();
2292 + }
2293 + strict(message) {
2294 + errorUtil.errToObj;
2295 + return new ZodObject$1({
2296 + ...this._def,
2297 + unknownKeys: "strict",
2298 + ...message !== void 0 ? { errorMap: (issue, ctx) => {
2299 + const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
2300 + if (issue.code === "unrecognized_keys") return { message: errorUtil.errToObj(message).message ?? defaultError };
2301 + return { message: defaultError };
2302 + } } : {}
2303 + });
2304 + }
2305 + strip() {
2306 + return new ZodObject$1({
2307 + ...this._def,
2308 + unknownKeys: "strip"
2309 + });
2310 + }
2311 + passthrough() {
2312 + return new ZodObject$1({
2313 + ...this._def,
2314 + unknownKeys: "passthrough"
2315 + });
2316 + }
2317 + extend(augmentation) {
2318 + return new ZodObject$1({
2319 + ...this._def,
2320 + shape: () => ({
2321 + ...this._def.shape(),
2322 + ...augmentation
2323 + })
2324 + });
2325 + }
2326 + /**
2327 + * Prior to [email protected] there was a bug in the
2328 + * inferred type of merged objects. Please
2329 + * upgrade if you are experiencing issues.
2330 + */
2331 + merge(merging) {
2332 + return new ZodObject$1({
2333 + unknownKeys: merging._def.unknownKeys,
2334 + catchall: merging._def.catchall,
2335 + shape: () => ({
2336 + ...this._def.shape(),
2337 + ...merging._def.shape()
2338 + }),
2339 + typeName: ZodFirstPartyTypeKind.ZodObject
2340 + });
2341 + }
2342 + setKey(key, schema) {
2343 + return this.augment({ [key]: schema });
2344 + }
2345 + catchall(index) {
2346 + return new ZodObject$1({
2347 + ...this._def,
2348 + catchall: index
2349 + });
2350 + }
2351 + pick(mask) {
2352 + const shape = {};
2353 + for (const key of util.objectKeys(mask)) if (mask[key] && this.shape[key]) shape[key] = this.shape[key];
2354 + return new ZodObject$1({
2355 + ...this._def,
2356 + shape: () => shape
2357 + });
2358 + }
2359 + omit(mask) {
2360 + const shape = {};
2361 + for (const key of util.objectKeys(this.shape)) if (!mask[key]) shape[key] = this.shape[key];
2362 + return new ZodObject$1({
2363 + ...this._def,
2364 + shape: () => shape
2365 + });
2366 + }
2367 + /**
2368 + * @deprecated
2369 + */
2370 + deepPartial() {
2371 + return deepPartialify(this);
2372 + }
2373 + partial(mask) {
2374 + const newShape = {};
2375 + for (const key of util.objectKeys(this.shape)) {
2376 + const fieldSchema = this.shape[key];
2377 + if (mask && !mask[key]) newShape[key] = fieldSchema;
2378 + else newShape[key] = fieldSchema.optional();
2379 + }
2380 + return new ZodObject$1({
2381 + ...this._def,
2382 + shape: () => newShape
2383 + });
2384 + }
2385 + required(mask) {
2386 + const newShape = {};
2387 + for (const key of util.objectKeys(this.shape)) if (mask && !mask[key]) newShape[key] = this.shape[key];
2388 + else {
2389 + let newField = this.shape[key];
2390 + while (newField instanceof ZodOptional$1) newField = newField._def.innerType;
2391 + newShape[key] = newField;
2392 + }
2393 + return new ZodObject$1({
2394 + ...this._def,
2395 + shape: () => newShape
2396 + });
2397 + }
2398 + keyof() {
2399 + return createZodEnum(util.objectKeys(this.shape));
2400 + }
2401 + };
2402 + ZodObject$1.create = (shape, params) => {
2403 + return new ZodObject$1({
2404 + shape: () => shape,
2405 + unknownKeys: "strip",
2406 + catchall: ZodNever$1.create(),
2407 + typeName: ZodFirstPartyTypeKind.ZodObject,
2408 + ...processCreateParams(params)
2409 + });
2410 + };
2411 + ZodObject$1.strictCreate = (shape, params) => {
2412 + return new ZodObject$1({
2413 + shape: () => shape,
2414 + unknownKeys: "strict",
2415 + catchall: ZodNever$1.create(),
2416 + typeName: ZodFirstPartyTypeKind.ZodObject,
2417 + ...processCreateParams(params)
2418 + });
2419 + };
2420 + ZodObject$1.lazycreate = (shape, params) => {
2421 + return new ZodObject$1({
2422 + shape,
2423 + unknownKeys: "strip",
2424 + catchall: ZodNever$1.create(),
2425 + typeName: ZodFirstPartyTypeKind.ZodObject,
2426 + ...processCreateParams(params)
2427 + });
2428 + };
2429 + var ZodUnion$1 = class extends ZodType$1 {
2430 + static {
2431 + __name(this, "ZodUnion");
2432 + }
2433 + _parse(input) {
2434 + const { ctx } = this._processInputParams(input);
2435 + const options = this._def.options;
2436 + function handleResults(results) {
2437 + for (const result of results) if (result.result.status === "valid") return result.result;
2438 + for (const result of results) if (result.result.status === "dirty") {
2439 + ctx.common.issues.push(...result.ctx.common.issues);
2440 + return result.result;
2441 + }
2442 + const unionErrors = results.map((result) => new ZodError$1(result.ctx.common.issues));
2443 + addIssueToContext(ctx, {
2444 + code: ZodIssueCode.invalid_union,
2445 + unionErrors
2446 + });
2447 + return INVALID;
2448 + }
2449 + if (ctx.common.async) return Promise.all(options.map(async (option) => {
2450 + const childCtx = {
2451 + ...ctx,
2452 + common: {
2453 + ...ctx.common,
2454 + issues: []
2455 + },
2456 + parent: null
2457 + };
2458 + return {
2459 + result: await option._parseAsync({
2460 + data: ctx.data,
2461 + path: ctx.path,
2462 + parent: childCtx
2463 + }),
2464 + ctx: childCtx
2465 + };
2466 + })).then(handleResults);
2467 + else {
2468 + let dirty = void 0;
2469 + const issues = [];
2470 + for (const option of options) {
2471 + const childCtx = {
2472 + ...ctx,
2473 + common: {
2474 + ...ctx.common,
2475 + issues: []
2476 + },
2477 + parent: null
2478 + };
2479 + const result = option._parseSync({
2480 + data: ctx.data,
2481 + path: ctx.path,
2482 + parent: childCtx
2483 + });
2484 + if (result.status === "valid") return result;
2485 + else if (result.status === "dirty" && !dirty) dirty = {
2486 + result,
2487 + ctx: childCtx
2488 + };
2489 + if (childCtx.common.issues.length) issues.push(childCtx.common.issues);
2490 + }
2491 + if (dirty) {
2492 + ctx.common.issues.push(...dirty.ctx.common.issues);
2493 + return dirty.result;
2494 + }
2495 + const unionErrors = issues.map((issues) => new ZodError$1(issues));
2496 + addIssueToContext(ctx, {
2497 + code: ZodIssueCode.invalid_union,
2498 + unionErrors
2499 + });
2500 + return INVALID;
2501 + }
2502 + }
2503 + get options() {
2504 + return this._def.options;
2505 + }
2506 + };
2507 + ZodUnion$1.create = (types, params) => {
2508 + return new ZodUnion$1({
2509 + options: types,
2510 + typeName: ZodFirstPartyTypeKind.ZodUnion,
2511 + ...processCreateParams(params)
2512 + });
2513 + };
2514 + var getDiscriminator = (type) => {
2515 + if (type instanceof ZodLazy) return getDiscriminator(type.schema);
2516 + else if (type instanceof ZodEffects) return getDiscriminator(type.innerType());
2517 + else if (type instanceof ZodLiteral$1) return [type.value];
2518 + else if (type instanceof ZodEnum$1) return type.options;
2519 + else if (type instanceof ZodNativeEnum) return util.objectValues(type.enum);
2520 + else if (type instanceof ZodDefault$1) return getDiscriminator(type._def.innerType);
2521 + else if (type instanceof ZodUndefined) return [void 0];
2522 + else if (type instanceof ZodNull$1) return [null];
2523 + else if (type instanceof ZodOptional$1) return [void 0, ...getDiscriminator(type.unwrap())];
2524 + else if (type instanceof ZodNullable$1) return [null, ...getDiscriminator(type.unwrap())];
2525 + else if (type instanceof ZodBranded) return getDiscriminator(type.unwrap());
2526 + else if (type instanceof ZodReadonly$1) return getDiscriminator(type.unwrap());
2527 + else if (type instanceof ZodCatch$1) return getDiscriminator(type._def.innerType);
2528 + else return [];
2529 + };
2530 + var ZodDiscriminatedUnion$1 = class ZodDiscriminatedUnion$1 extends ZodType$1 {
2531 + static {
2532 + __name(this, "ZodDiscriminatedUnion");
2533 + }
2534 + _parse(input) {
2535 + const { ctx } = this._processInputParams(input);
2536 + if (ctx.parsedType !== ZodParsedType.object) {
2537 + addIssueToContext(ctx, {
2538 + code: ZodIssueCode.invalid_type,
2539 + expected: ZodParsedType.object,
2540 + received: ctx.parsedType
2541 + });
2542 + return INVALID;
2543 + }
2544 + const discriminator = this.discriminator;
2545 + const discriminatorValue = ctx.data[discriminator];
2546 + const option = this.optionsMap.get(discriminatorValue);
2547 + if (!option) {
2548 + addIssueToContext(ctx, {
2549 + code: ZodIssueCode.invalid_union_discriminator,
2550 + options: Array.from(this.optionsMap.keys()),
2551 + path: [discriminator]
2552 + });
2553 + return INVALID;
2554 + }
2555 + if (ctx.common.async) return option._parseAsync({
2556 + data: ctx.data,
2557 + path: ctx.path,
2558 + parent: ctx
2559 + });
2560 + else return option._parseSync({
2561 + data: ctx.data,
2562 + path: ctx.path,
2563 + parent: ctx
2564 + });
2565 + }
2566 + get discriminator() {
2567 + return this._def.discriminator;
2568 + }
2569 + get options() {
2570 + return this._def.options;
2571 + }
2572 + get optionsMap() {
2573 + return this._def.optionsMap;
2574 + }
2575 + /**
2576 + * The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
2577 + * However, it only allows a union of objects, all of which need to share a discriminator property. This property must
2578 + * have a different value for each object in the union.
2579 + * @param discriminator the name of the discriminator property
2580 + * @param types an array of object schemas
2581 + * @param params
2582 + */
2583 + static create(discriminator, options, params) {
2584 + const optionsMap = /* @__PURE__ */ new Map();
2585 + for (const type of options) {
2586 + const discriminatorValues = getDiscriminator(type.shape[discriminator]);
2587 + if (!discriminatorValues.length) throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
2588 + for (const value of discriminatorValues) {
2589 + if (optionsMap.has(value)) throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
2590 + optionsMap.set(value, type);
2591 + }
2592 + }
2593 + return new ZodDiscriminatedUnion$1({
2594 + typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
2595 + discriminator,
2596 + options,
2597 + optionsMap,
2598 + ...processCreateParams(params)
2599 + });
2600 + }
2601 + };
2602 + function mergeValues$1(a, b) {
2603 + const aType = getParsedType(a);
2604 + const bType = getParsedType(b);
2605 + if (a === b) return {
2606 + valid: true,
2607 + data: a
2608 + };
2609 + else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
2610 + const bKeys = util.objectKeys(b);
2611 + const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
2612 + const newObj = {
2613 + ...a,
2614 + ...b
2615 + };
2616 + for (const key of sharedKeys) {
2617 + const sharedValue = mergeValues$1(a[key], b[key]);
2618 + if (!sharedValue.valid) return { valid: false };
2619 + newObj[key] = sharedValue.data;
2620 + }
2621 + return {
2622 + valid: true,
2623 + data: newObj
2624 + };
2625 + } else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
2626 + if (a.length !== b.length) return { valid: false };
2627 + const newArray = [];
2628 + for (let index = 0; index < a.length; index++) {
2629 + const itemA = a[index];
2630 + const itemB = b[index];
2631 + const sharedValue = mergeValues$1(itemA, itemB);
2632 + if (!sharedValue.valid) return { valid: false };
2633 + newArray.push(sharedValue.data);
2634 + }
2635 + return {
2636 + valid: true,
2637 + data: newArray
2638 + };
2639 + } else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) return {
2640 + valid: true,
2641 + data: a
2642 + };
2643 + else return { valid: false };
2644 + }
2645 + __name(mergeValues$1, "mergeValues");
2646 + var ZodIntersection$1 = class extends ZodType$1 {
2647 + static {
2648 + __name(this, "ZodIntersection");
2649 + }
2650 + _parse(input) {
2651 + const { status, ctx } = this._processInputParams(input);
2652 + const handleParsed = (parsedLeft, parsedRight) => {
2653 + if (isAborted(parsedLeft) || isAborted(parsedRight)) return INVALID;
2654 + const merged = mergeValues$1(parsedLeft.value, parsedRight.value);
2655 + if (!merged.valid) {
2656 + addIssueToContext(ctx, { code: ZodIssueCode.invalid_intersection_types });
2657 + return INVALID;
2658 + }
2659 + if (isDirty(parsedLeft) || isDirty(parsedRight)) status.dirty();
2660 + return {
2661 + status: status.value,
2662 + value: merged.data
2663 + };
2664 + };
2665 + if (ctx.common.async) return Promise.all([this._def.left._parseAsync({
2666 + data: ctx.data,
2667 + path: ctx.path,
2668 + parent: ctx
2669 + }), this._def.right._parseAsync({
2670 + data: ctx.data,
2671 + path: ctx.path,
2672 + parent: ctx
2673 + })]).then(([left, right]) => handleParsed(left, right));
2674 + else return handleParsed(this._def.left._parseSync({
2675 + data: ctx.data,
2676 + path: ctx.path,
2677 + parent: ctx
2678 + }), this._def.right._parseSync({
2679 + data: ctx.data,
2680 + path: ctx.path,
2681 + parent: ctx
2682 + }));
2683 + }
2684 + };
2685 + ZodIntersection$1.create = (left, right, params) => {
2686 + return new ZodIntersection$1({
2687 + left,
2688 + right,
2689 + typeName: ZodFirstPartyTypeKind.ZodIntersection,
2690 + ...processCreateParams(params)
2691 + });
2692 + };
2693 + var ZodTuple = class ZodTuple extends ZodType$1 {
2694 + _parse(input) {
2695 + const { status, ctx } = this._processInputParams(input);
2696 + if (ctx.parsedType !== ZodParsedType.array) {
2697 + addIssueToContext(ctx, {
2698 + code: ZodIssueCode.invalid_type,
2699 + expected: ZodParsedType.array,
2700 + received: ctx.parsedType
2701 + });
2702 + return INVALID;
2703 + }
2704 + if (ctx.data.length < this._def.items.length) {
2705 + addIssueToContext(ctx, {
2706 + code: ZodIssueCode.too_small,
2707 + minimum: this._def.items.length,
2708 + inclusive: true,
2709 + exact: false,
2710 + type: "array"
2711 + });
2712 + return INVALID;
2713 + }
2714 + if (!this._def.rest && ctx.data.length > this._def.items.length) {
2715 + addIssueToContext(ctx, {
2716 + code: ZodIssueCode.too_big,
2717 + maximum: this._def.items.length,
2718 + inclusive: true,
2719 + exact: false,
2720 + type: "array"
2721 + });
2722 + status.dirty();
2723 + }
2724 + const items = [...ctx.data].map((item, itemIndex) => {
2725 + const schema = this._def.items[itemIndex] || this._def.rest;
2726 + if (!schema) return null;
2727 + return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
2728 + }).filter((x) => !!x);
2729 + if (ctx.common.async) return Promise.all(items).then((results) => {
2730 + return ParseStatus.mergeArray(status, results);
2731 + });
2732 + else return ParseStatus.mergeArray(status, items);
2733 + }
2734 + get items() {
2735 + return this._def.items;
2736 + }
2737 + rest(rest) {
2738 + return new ZodTuple({
2739 + ...this._def,
2740 + rest
2741 + });
2742 + }
2743 + };
2744 + ZodTuple.create = (schemas, params) => {
2745 + if (!Array.isArray(schemas)) throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
2746 + return new ZodTuple({
2747 + items: schemas,
2748 + typeName: ZodFirstPartyTypeKind.ZodTuple,
2749 + rest: null,
2750 + ...processCreateParams(params)
2751 + });
2752 + };
2753 + var ZodRecord$1 = class ZodRecord$1 extends ZodType$1 {
2754 + static {
2755 + __name(this, "ZodRecord");
2756 + }
2757 + get keySchema() {
2758 + return this._def.keyType;
2759 + }
2760 + get valueSchema() {
2761 + return this._def.valueType;
2762 + }
2763 + _parse(input) {
2764 + const { status, ctx } = this._processInputParams(input);
2765 + if (ctx.parsedType !== ZodParsedType.object) {
2766 + addIssueToContext(ctx, {
2767 + code: ZodIssueCode.invalid_type,
2768 + expected: ZodParsedType.object,
2769 + received: ctx.parsedType
2770 + });
2771 + return INVALID;
2772 + }
2773 + const pairs = [];
2774 + const keyType = this._def.keyType;
2775 + const valueType = this._def.valueType;
2776 + for (const key in ctx.data) pairs.push({
2777 + key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
2778 + value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
2779 + alwaysSet: key in ctx.data
2780 + });
2781 + if (ctx.common.async) return ParseStatus.mergeObjectAsync(status, pairs);
2782 + else return ParseStatus.mergeObjectSync(status, pairs);
2783 + }
2784 + get element() {
2785 + return this._def.valueType;
2786 + }
2787 + static create(first, second, third) {
2788 + if (second instanceof ZodType$1) return new ZodRecord$1({
2789 + keyType: first,
2790 + valueType: second,
2791 + typeName: ZodFirstPartyTypeKind.ZodRecord,
2792 + ...processCreateParams(third)
2793 + });
2794 + return new ZodRecord$1({
2795 + keyType: ZodString$1.create(),
2796 + valueType: first,
2797 + typeName: ZodFirstPartyTypeKind.ZodRecord,
2798 + ...processCreateParams(second)
2799 + });
2800 + }
2801 + };
2802 + var ZodMap = class extends ZodType$1 {
2803 + get keySchema() {
2804 + return this._def.keyType;
2805 + }
2806 + get valueSchema() {
2807 + return this._def.valueType;
2808 + }
2809 + _parse(input) {
2810 + const { status, ctx } = this._processInputParams(input);
2811 + if (ctx.parsedType !== ZodParsedType.map) {
2812 + addIssueToContext(ctx, {
2813 + code: ZodIssueCode.invalid_type,
2814 + expected: ZodParsedType.map,
2815 + received: ctx.parsedType
2816 + });
2817 + return INVALID;
2818 + }
2819 + const keyType = this._def.keyType;
2820 + const valueType = this._def.valueType;
2821 + const pairs = [...ctx.data.entries()].map(([key, value], index) => {
2822 + return {
2823 + key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [index, "key"])),
2824 + value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
2825 + };
2826 + });
2827 + if (ctx.common.async) {
2828 + const finalMap = /* @__PURE__ */ new Map();
2829 + return Promise.resolve().then(async () => {
2830 + for (const pair of pairs) {
2831 + const key = await pair.key;
2832 + const value = await pair.value;
2833 + if (key.status === "aborted" || value.status === "aborted") return INVALID;
2834 + if (key.status === "dirty" || value.status === "dirty") status.dirty();
2835 + finalMap.set(key.value, value.value);
2836 + }
2837 + return {
2838 + status: status.value,
2839 + value: finalMap
2840 + };
2841 + });
2842 + } else {
2843 + const finalMap = /* @__PURE__ */ new Map();
2844 + for (const pair of pairs) {
2845 + const key = pair.key;
2846 + const value = pair.value;
2847 + if (key.status === "aborted" || value.status === "aborted") return INVALID;
2848 + if (key.status === "dirty" || value.status === "dirty") status.dirty();
2849 + finalMap.set(key.value, value.value);
2850 + }
2851 + return {
2852 + status: status.value,
2853 + value: finalMap
2854 + };
2855 + }
2856 + }
2857 + };
2858 + ZodMap.create = (keyType, valueType, params) => {
2859 + return new ZodMap({
2860 + valueType,
2861 + keyType,
2862 + typeName: ZodFirstPartyTypeKind.ZodMap,
2863 + ...processCreateParams(params)
2864 + });
2865 + };
2866 + var ZodSet = class ZodSet extends ZodType$1 {
2867 + _parse(input) {
2868 + const { status, ctx } = this._processInputParams(input);
2869 + if (ctx.parsedType !== ZodParsedType.set) {
2870 + addIssueToContext(ctx, {
2871 + code: ZodIssueCode.invalid_type,
2872 + expected: ZodParsedType.set,
2873 + received: ctx.parsedType
2874 + });
2875 + return INVALID;
2876 + }
2877 + const def = this._def;
2878 + if (def.minSize !== null) {
2879 + if (ctx.data.size < def.minSize.value) {
2880 + addIssueToContext(ctx, {
2881 + code: ZodIssueCode.too_small,
2882 + minimum: def.minSize.value,
2883 + type: "set",
2884 + inclusive: true,
2885 + exact: false,
2886 + message: def.minSize.message
2887 + });
2888 + status.dirty();
2889 + }
2890 + }
2891 + if (def.maxSize !== null) {
2892 + if (ctx.data.size > def.maxSize.value) {
2893 + addIssueToContext(ctx, {
2894 + code: ZodIssueCode.too_big,
2895 + maximum: def.maxSize.value,
2896 + type: "set",
2897 + inclusive: true,
2898 + exact: false,
2899 + message: def.maxSize.message
2900 + });
2901 + status.dirty();
2902 + }
2903 + }
2904 + const valueType = this._def.valueType;
2905 + function finalizeSet(elements) {
2906 + const parsedSet = /* @__PURE__ */ new Set();
2907 + for (const element of elements) {
2908 + if (element.status === "aborted") return INVALID;
2909 + if (element.status === "dirty") status.dirty();
2910 + parsedSet.add(element.value);
2911 + }
2912 + return {
2913 + status: status.value,
2914 + value: parsedSet
2915 + };
2916 + }
2917 + const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
2918 + if (ctx.common.async) return Promise.all(elements).then((elements) => finalizeSet(elements));
2919 + else return finalizeSet(elements);
2920 + }
2921 + min(minSize, message) {
2922 + return new ZodSet({
2923 + ...this._def,
2924 + minSize: {
2925 + value: minSize,
2926 + message: errorUtil.toString(message)
2927 + }
2928 + });
2929 + }
2930 + max(maxSize, message) {
2931 + return new ZodSet({
2932 + ...this._def,
2933 + maxSize: {
2934 + value: maxSize,
2935 + message: errorUtil.toString(message)
2936 + }
2937 + });
2938 + }
2939 + size(size, message) {
2940 + return this.min(size, message).max(size, message);
2941 + }
2942 + nonempty(message) {
2943 + return this.min(1, message);
2944 + }
2945 + };
2946 + ZodSet.create = (valueType, params) => {
2947 + return new ZodSet({
2948 + valueType,
2949 + minSize: null,
2950 + maxSize: null,
2951 + typeName: ZodFirstPartyTypeKind.ZodSet,
2952 + ...processCreateParams(params)
2953 + });
2954 + };
2955 + var ZodFunction = class ZodFunction extends ZodType$1 {
2956 + constructor() {
2957 + super(...arguments);
2958 + this.validate = this.implement;
2959 + }
2960 + _parse(input) {
2961 + const { ctx } = this._processInputParams(input);
2962 + if (ctx.parsedType !== ZodParsedType.function) {
2963 + addIssueToContext(ctx, {
2964 + code: ZodIssueCode.invalid_type,
2965 + expected: ZodParsedType.function,
2966 + received: ctx.parsedType
2967 + });
2968 + return INVALID;
2969 + }
2970 + function makeArgsIssue(args, error) {
2971 + return makeIssue({
2972 + data: args,
2973 + path: ctx.path,
2974 + errorMaps: [
2975 + ctx.common.contextualErrorMap,
2976 + ctx.schemaErrorMap,
2977 + getErrorMap(),
2978 + errorMap
2979 + ].filter((x) => !!x),
2980 + issueData: {
2981 + code: ZodIssueCode.invalid_arguments,
2982 + argumentsError: error
2983 + }
2984 + });
2985 + }
2986 + function makeReturnsIssue(returns, error) {
2987 + return makeIssue({
2988 + data: returns,
2989 + path: ctx.path,
2990 + errorMaps: [
2991 + ctx.common.contextualErrorMap,
2992 + ctx.schemaErrorMap,
2993 + getErrorMap(),
2994 + errorMap
2995 + ].filter((x) => !!x),
2996 + issueData: {
2997 + code: ZodIssueCode.invalid_return_type,
2998 + returnTypeError: error
2999 + }
3000 + });
3001 + }
3002 + const params = { errorMap: ctx.common.contextualErrorMap };
3003 + const fn = ctx.data;
3004 + if (this._def.returns instanceof ZodPromise) {
3005 + const me = this;
3006 + return OK(async function(...args) {
3007 + const error = new ZodError$1([]);
3008 + const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
3009 + error.addIssue(makeArgsIssue(args, e));
3010 + throw error;
3011 + });
3012 + const result = await Reflect.apply(fn, this, parsedArgs);
3013 + return await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
3014 + error.addIssue(makeReturnsIssue(result, e));
3015 + throw error;
3016 + });
3017 + });
3018 + } else {
3019 + const me = this;
3020 + return OK(function(...args) {
3021 + const parsedArgs = me._def.args.safeParse(args, params);
3022 + if (!parsedArgs.success) throw new ZodError$1([makeArgsIssue(args, parsedArgs.error)]);
3023 + const result = Reflect.apply(fn, this, parsedArgs.data);
3024 + const parsedReturns = me._def.returns.safeParse(result, params);
3025 + if (!parsedReturns.success) throw new ZodError$1([makeReturnsIssue(result, parsedReturns.error)]);
3026 + return parsedReturns.data;
3027 + });
3028 + }
3029 + }
3030 + parameters() {
3031 + return this._def.args;
3032 + }
3033 + returnType() {
3034 + return this._def.returns;
3035 + }
3036 + args(...items) {
3037 + return new ZodFunction({
3038 + ...this._def,
3039 + args: ZodTuple.create(items).rest(ZodUnknown$1.create())
3040 + });
3041 + }
3042 + returns(returnType) {
3043 + return new ZodFunction({
3044 + ...this._def,
3045 + returns: returnType
3046 + });
3047 + }
3048 + implement(func) {
3049 + return this.parse(func);
3050 + }
3051 + strictImplement(func) {
3052 + return this.parse(func);
3053 + }
3054 + static create(args, returns, params) {
3055 + return new ZodFunction({
3056 + args: args ? args : ZodTuple.create([]).rest(ZodUnknown$1.create()),
3057 + returns: returns || ZodUnknown$1.create(),
3058 + typeName: ZodFirstPartyTypeKind.ZodFunction,
3059 + ...processCreateParams(params)
3060 + });
3061 + }
3062 + };
3063 + var ZodLazy = class extends ZodType$1 {
3064 + get schema() {
3065 + return this._def.getter();
3066 + }
3067 + _parse(input) {
3068 + const { ctx } = this._processInputParams(input);
3069 + return this._def.getter()._parse({
3070 + data: ctx.data,
3071 + path: ctx.path,
3072 + parent: ctx
3073 + });
3074 + }
3075 + };
3076 + ZodLazy.create = (getter, params) => {
3077 + return new ZodLazy({
3078 + getter,
3079 + typeName: ZodFirstPartyTypeKind.ZodLazy,
3080 + ...processCreateParams(params)
3081 + });
3082 + };
3083 + var ZodLiteral$1 = class extends ZodType$1 {
3084 + static {
3085 + __name(this, "ZodLiteral");
3086 + }
3087 + _parse(input) {
3088 + if (input.data !== this._def.value) {
3089 + const ctx = this._getOrReturnCtx(input);
3090 + addIssueToContext(ctx, {
3091 + received: ctx.data,
3092 + code: ZodIssueCode.invalid_literal,
3093 + expected: this._def.value
3094 + });
3095 + return INVALID;
3096 + }
3097 + return {
3098 + status: "valid",
3099 + value: input.data
3100 + };
3101 + }
3102 + get value() {
3103 + return this._def.value;
3104 + }
3105 + };
3106 + ZodLiteral$1.create = (value, params) => {
3107 + return new ZodLiteral$1({
3108 + value,
3109 + typeName: ZodFirstPartyTypeKind.ZodLiteral,
3110 + ...processCreateParams(params)
3111 + });
3112 + };
3113 + function createZodEnum(values, params) {
3114 + return new ZodEnum$1({
3115 + values,
3116 + typeName: ZodFirstPartyTypeKind.ZodEnum,
3117 + ...processCreateParams(params)
3118 + });
3119 + }
3120 + var ZodEnum$1 = class ZodEnum$1 extends ZodType$1 {
3121 + static {
3122 + __name(this, "ZodEnum");
3123 + }
3124 + _parse(input) {
3125 + if (typeof input.data !== "string") {
3126 + const ctx = this._getOrReturnCtx(input);
3127 + const expectedValues = this._def.values;
3128 + addIssueToContext(ctx, {
3129 + expected: util.joinValues(expectedValues),
3130 + received: ctx.parsedType,
3131 + code: ZodIssueCode.invalid_type
3132 + });
3133 + return INVALID;
3134 + }
3135 + if (!this._cache) this._cache = new Set(this._def.values);
3136 + if (!this._cache.has(input.data)) {
3137 + const ctx = this._getOrReturnCtx(input);
3138 + const expectedValues = this._def.values;
3139 + addIssueToContext(ctx, {
3140 + received: ctx.data,
3141 + code: ZodIssueCode.invalid_enum_value,
3142 + options: expectedValues
3143 + });
3144 + return INVALID;
3145 + }
3146 + return OK(input.data);
3147 + }
3148 + get options() {
3149 + return this._def.values;
3150 + }
3151 + get enum() {
3152 + const enumValues = {};
3153 + for (const val of this._def.values) enumValues[val] = val;
3154 + return enumValues;
3155 + }
3156 + get Values() {
3157 + const enumValues = {};
3158 + for (const val of this._def.values) enumValues[val] = val;
3159 + return enumValues;
3160 + }
3161 + get Enum() {
3162 + const enumValues = {};
3163 + for (const val of this._def.values) enumValues[val] = val;
3164 + return enumValues;
3165 + }
3166 + extract(values, newDef = this._def) {
3167 + return ZodEnum$1.create(values, {
3168 + ...this._def,
3169 + ...newDef
3170 + });
3171 + }
3172 + exclude(values, newDef = this._def) {
3173 + return ZodEnum$1.create(this.options.filter((opt) => !values.includes(opt)), {
3174 + ...this._def,
3175 + ...newDef
3176 + });
3177 + }
3178 + };
3179 + ZodEnum$1.create = createZodEnum;
3180 + var ZodNativeEnum = class extends ZodType$1 {
3181 + _parse(input) {
3182 + const nativeEnumValues = util.getValidEnumValues(this._def.values);
3183 + const ctx = this._getOrReturnCtx(input);
3184 + if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
3185 + const expectedValues = util.objectValues(nativeEnumValues);
3186 + addIssueToContext(ctx, {
3187 + expected: util.joinValues(expectedValues),
3188 + received: ctx.parsedType,
3189 + code: ZodIssueCode.invalid_type
3190 + });
3191 + return INVALID;
3192 + }
3193 + if (!this._cache) this._cache = new Set(util.getValidEnumValues(this._def.values));
3194 + if (!this._cache.has(input.data)) {
3195 + const expectedValues = util.objectValues(nativeEnumValues);
3196 + addIssueToContext(ctx, {
3197 + received: ctx.data,
3198 + code: ZodIssueCode.invalid_enum_value,
3199 + options: expectedValues
3200 + });
3201 + return INVALID;
3202 + }
3203 + return OK(input.data);
3204 + }
3205 + get enum() {
3206 + return this._def.values;
3207 + }
3208 + };
3209 + ZodNativeEnum.create = (values, params) => {
3210 + return new ZodNativeEnum({
3211 + values,
3212 + typeName: ZodFirstPartyTypeKind.ZodNativeEnum,
3213 + ...processCreateParams(params)
3214 + });
3215 + };
3216 + var ZodPromise = class extends ZodType$1 {
3217 + unwrap() {
3218 + return this._def.type;
3219 + }
3220 + _parse(input) {
3221 + const { ctx } = this._processInputParams(input);
3222 + if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
3223 + addIssueToContext(ctx, {
3224 + code: ZodIssueCode.invalid_type,
3225 + expected: ZodParsedType.promise,
3226 + received: ctx.parsedType
3227 + });
3228 + return INVALID;
3229 + }
3230 + return OK((ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data)).then((data) => {
3231 + return this._def.type.parseAsync(data, {
3232 + path: ctx.path,
3233 + errorMap: ctx.common.contextualErrorMap
3234 + });
3235 + }));
3236 + }
3237 + };
3238 + ZodPromise.create = (schema, params) => {
3239 + return new ZodPromise({
3240 + type: schema,
3241 + typeName: ZodFirstPartyTypeKind.ZodPromise,
3242 + ...processCreateParams(params)
3243 + });
3244 + };
3245 + var ZodEffects = class extends ZodType$1 {
3246 + innerType() {
3247 + return this._def.schema;
3248 + }
3249 + sourceType() {
3250 + return this._def.schema._def.typeName === ZodFirstPartyTypeKind.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
3251 + }
3252 + _parse(input) {
3253 + const { status, ctx } = this._processInputParams(input);
3254 + const effect = this._def.effect || null;
3255 + const checkCtx = {
3256 + addIssue: (arg) => {
3257 + addIssueToContext(ctx, arg);
3258 + if (arg.fatal) status.abort();
3259 + else status.dirty();
3260 + },
3261 + get path() {
3262 + return ctx.path;
3263 + }
3264 + };
3265 + checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
3266 + if (effect.type === "preprocess") {
3267 + const processed = effect.transform(ctx.data, checkCtx);
3268 + if (ctx.common.async) return Promise.resolve(processed).then(async (processed) => {
3269 + if (status.value === "aborted") return INVALID;
3270 + const result = await this._def.schema._parseAsync({
3271 + data: processed,
3272 + path: ctx.path,
3273 + parent: ctx
3274 + });
3275 + if (result.status === "aborted") return INVALID;
3276 + if (result.status === "dirty") return DIRTY(result.value);
3277 + if (status.value === "dirty") return DIRTY(result.value);
3278 + return result;
3279 + });
3280 + else {
3281 + if (status.value === "aborted") return INVALID;
3282 + const result = this._def.schema._parseSync({
3283 + data: processed,
3284 + path: ctx.path,
3285 + parent: ctx
3286 + });
3287 + if (result.status === "aborted") return INVALID;
3288 + if (result.status === "dirty") return DIRTY(result.value);
3289 + if (status.value === "dirty") return DIRTY(result.value);
3290 + return result;
3291 + }
3292 + }
3293 + if (effect.type === "refinement") {
3294 + const executeRefinement = (acc) => {
3295 + const result = effect.refinement(acc, checkCtx);
3296 + if (ctx.common.async) return Promise.resolve(result);
3297 + if (result instanceof Promise) throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
3298 + return acc;
3299 + };
3300 + if (ctx.common.async === false) {
3301 + const inner = this._def.schema._parseSync({
3302 + data: ctx.data,
3303 + path: ctx.path,
3304 + parent: ctx
3305 + });
3306 + if (inner.status === "aborted") return INVALID;
3307 + if (inner.status === "dirty") status.dirty();
3308 + executeRefinement(inner.value);
3309 + return {
3310 + status: status.value,
3311 + value: inner.value
3312 + };
3313 + } else return this._def.schema._parseAsync({
3314 + data: ctx.data,
3315 + path: ctx.path,
3316 + parent: ctx
3317 + }).then((inner) => {
3318 + if (inner.status === "aborted") return INVALID;
3319 + if (inner.status === "dirty") status.dirty();
3320 + return executeRefinement(inner.value).then(() => {
3321 + return {
3322 + status: status.value,
3323 + value: inner.value
3324 + };
3325 + });
3326 + });
3327 + }
3328 + if (effect.type === "transform") if (ctx.common.async === false) {
3329 + const base = this._def.schema._parseSync({
3330 + data: ctx.data,
3331 + path: ctx.path,
3332 + parent: ctx
3333 + });
3334 + if (!isValid(base)) return INVALID;
3335 + const result = effect.transform(base.value, checkCtx);
3336 + if (result instanceof Promise) throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
3337 + return {
3338 + status: status.value,
3339 + value: result
3340 + };
3341 + } else return this._def.schema._parseAsync({
3342 + data: ctx.data,
3343 + path: ctx.path,
3344 + parent: ctx
3345 + }).then((base) => {
3346 + if (!isValid(base)) return INVALID;
3347 + return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
3348 + status: status.value,
3349 + value: result
3350 + }));
3351 + });
3352 + util.assertNever(effect);
3353 + }
3354 + };
3355 + ZodEffects.create = (schema, effect, params) => {
3356 + return new ZodEffects({
3357 + schema,
3358 + typeName: ZodFirstPartyTypeKind.ZodEffects,
3359 + effect,
3360 + ...processCreateParams(params)
3361 + });
3362 + };
3363 + ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
3364 + return new ZodEffects({
3365 + schema,
3366 + effect: {
3367 + type: "preprocess",
3368 + transform: preprocess
3369 + },
3370 + typeName: ZodFirstPartyTypeKind.ZodEffects,
3371 + ...processCreateParams(params)
3372 + });
3373 + };
3374 + var ZodOptional$1 = class extends ZodType$1 {
3375 + static {
3376 + __name(this, "ZodOptional");
3377 + }
3378 + _parse(input) {
3379 + if (this._getType(input) === ZodParsedType.undefined) return OK(void 0);
3380 + return this._def.innerType._parse(input);
3381 + }
3382 + unwrap() {
3383 + return this._def.innerType;
3384 + }
3385 + };
3386 + ZodOptional$1.create = (type, params) => {
3387 + return new ZodOptional$1({
3388 + innerType: type,
3389 + typeName: ZodFirstPartyTypeKind.ZodOptional,
3390 + ...processCreateParams(params)
3391 + });
3392 + };
3393 + var ZodNullable$1 = class extends ZodType$1 {
3394 + static {
3395 + __name(this, "ZodNullable");
3396 + }
3397 + _parse(input) {
3398 + if (this._getType(input) === ZodParsedType.null) return OK(null);
3399 + return this._def.innerType._parse(input);
3400 + }
3401 + unwrap() {
3402 + return this._def.innerType;
3403 + }
3404 + };
3405 + ZodNullable$1.create = (type, params) => {
3406 + return new ZodNullable$1({
3407 + innerType: type,
3408 + typeName: ZodFirstPartyTypeKind.ZodNullable,
3409 + ...processCreateParams(params)
3410 + });
3411 + };
3412 + var ZodDefault$1 = class extends ZodType$1 {
3413 + static {
3414 + __name(this, "ZodDefault");
3415 + }
3416 + _parse(input) {
3417 + const { ctx } = this._processInputParams(input);
3418 + let data = ctx.data;
3419 + if (ctx.parsedType === ZodParsedType.undefined) data = this._def.defaultValue();
3420 + return this._def.innerType._parse({
3421 + data,
3422 + path: ctx.path,
3423 + parent: ctx
3424 + });
3425 + }
3426 + removeDefault() {
3427 + return this._def.innerType;
3428 + }
3429 + };
3430 + ZodDefault$1.create = (type, params) => {
3431 + return new ZodDefault$1({
3432 + innerType: type,
3433 + typeName: ZodFirstPartyTypeKind.ZodDefault,
3434 + defaultValue: typeof params.default === "function" ? params.default : () => params.default,
3435 + ...processCreateParams(params)
3436 + });
3437 + };
3438 + var ZodCatch$1 = class extends ZodType$1 {
3439 + static {
3440 + __name(this, "ZodCatch");
3441 + }
3442 + _parse(input) {
3443 + const { ctx } = this._processInputParams(input);
3444 + const newCtx = {
3445 + ...ctx,
3446 + common: {
3447 + ...ctx.common,
3448 + issues: []
3449 + }
3450 + };
3451 + const result = this._def.innerType._parse({
3452 + data: newCtx.data,
3453 + path: newCtx.path,
3454 + parent: { ...newCtx }
3455 + });
3456 + if (isAsync(result)) return result.then((result) => {
3457 + return {
3458 + status: "valid",
3459 + value: result.status === "valid" ? result.value : this._def.catchValue({
3460 + get error() {
3461 + return new ZodError$1(newCtx.common.issues);
3462 + },
3463 + input: newCtx.data
3464 + })
3465 + };
3466 + });
3467 + else return {
3468 + status: "valid",
3469 + value: result.status === "valid" ? result.value : this._def.catchValue({
3470 + get error() {
3471 + return new ZodError$1(newCtx.common.issues);
3472 + },
3473 + input: newCtx.data
3474 + })
3475 + };
3476 + }
3477 + removeCatch() {
3478 + return this._def.innerType;
3479 + }
3480 + };
3481 + ZodCatch$1.create = (type, params) => {
3482 + return new ZodCatch$1({
3483 + innerType: type,
3484 + typeName: ZodFirstPartyTypeKind.ZodCatch,
3485 + catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
3486 + ...processCreateParams(params)
3487 + });
3488 + };
3489 + var ZodNaN = class extends ZodType$1 {
3490 + _parse(input) {
3491 + if (this._getType(input) !== ZodParsedType.nan) {
3492 + const ctx = this._getOrReturnCtx(input);
3493 + addIssueToContext(ctx, {
3494 + code: ZodIssueCode.invalid_type,
3495 + expected: ZodParsedType.nan,
3496 + received: ctx.parsedType
3497 + });
3498 + return INVALID;
3499 + }
3500 + return {
3501 + status: "valid",
3502 + value: input.data
3503 + };
3504 + }
3505 + };
3506 + ZodNaN.create = (params) => {
3507 + return new ZodNaN({
3508 + typeName: ZodFirstPartyTypeKind.ZodNaN,
3509 + ...processCreateParams(params)
3510 + });
3511 + };
3512 + var ZodBranded = class extends ZodType$1 {
3513 + _parse(input) {
3514 + const { ctx } = this._processInputParams(input);
3515 + const data = ctx.data;
3516 + return this._def.type._parse({
3517 + data,
3518 + path: ctx.path,
3519 + parent: ctx
3520 + });
3521 + }
3522 + unwrap() {
3523 + return this._def.type;
3524 + }
3525 + };
3526 + var ZodPipeline = class ZodPipeline extends ZodType$1 {
3527 + _parse(input) {
3528 + const { status, ctx } = this._processInputParams(input);
3529 + if (ctx.common.async) {
3530 + const handleAsync = async () => {
3531 + const inResult = await this._def.in._parseAsync({
3532 + data: ctx.data,
3533 + path: ctx.path,
3534 + parent: ctx
3535 + });
3536 + if (inResult.status === "aborted") return INVALID;
3537 + if (inResult.status === "dirty") {
3538 + status.dirty();
3539 + return DIRTY(inResult.value);
3540 + } else return this._def.out._parseAsync({
3541 + data: inResult.value,
3542 + path: ctx.path,
3543 + parent: ctx
3544 + });
3545 + };
3546 + return handleAsync();
3547 + } else {
3548 + const inResult = this._def.in._parseSync({
3549 + data: ctx.data,
3550 + path: ctx.path,
3551 + parent: ctx
3552 + });
3553 + if (inResult.status === "aborted") return INVALID;
3554 + if (inResult.status === "dirty") {
3555 + status.dirty();
3556 + return {
3557 + status: "dirty",
3558 + value: inResult.value
3559 + };
3560 + } else return this._def.out._parseSync({
3561 + data: inResult.value,
3562 + path: ctx.path,
3563 + parent: ctx
3564 + });
3565 + }
3566 + }
3567 + static create(a, b) {
3568 + return new ZodPipeline({
3569 + in: a,
3570 + out: b,
3571 + typeName: ZodFirstPartyTypeKind.ZodPipeline
3572 + });
3573 + }
3574 + };
3575 + var ZodReadonly$1 = class extends ZodType$1 {
3576 + static {
3577 + __name(this, "ZodReadonly");
3578 + }
3579 + _parse(input) {
3580 + const result = this._def.innerType._parse(input);
3581 + const freeze = (data) => {
3582 + if (isValid(data)) data.value = Object.freeze(data.value);
3583 + return data;
3584 + };
3585 + return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
3586 + }
3587 + unwrap() {
3588 + return this._def.innerType;
3589 + }
3590 + };
3591 + ZodReadonly$1.create = (type, params) => {
3592 + return new ZodReadonly$1({
3593 + innerType: type,
3594 + typeName: ZodFirstPartyTypeKind.ZodReadonly,
3595 + ...processCreateParams(params)
3596 + });
3597 + };
3598 + var late = { object: ZodObject$1.lazycreate };
3599 + var ZodFirstPartyTypeKind;
3600 + (function(ZodFirstPartyTypeKind) {
3601 + ZodFirstPartyTypeKind["ZodString"] = "ZodString";
3602 + ZodFirstPartyTypeKind["ZodNumber"] = "ZodNumber";
3603 + ZodFirstPartyTypeKind["ZodNaN"] = "ZodNaN";
3604 + ZodFirstPartyTypeKind["ZodBigInt"] = "ZodBigInt";
3605 + ZodFirstPartyTypeKind["ZodBoolean"] = "ZodBoolean";
3606 + ZodFirstPartyTypeKind["ZodDate"] = "ZodDate";
3607 + ZodFirstPartyTypeKind["ZodSymbol"] = "ZodSymbol";
3608 + ZodFirstPartyTypeKind["ZodUndefined"] = "ZodUndefined";
3609 + ZodFirstPartyTypeKind["ZodNull"] = "ZodNull";
3610 + ZodFirstPartyTypeKind["ZodAny"] = "ZodAny";
3611 + ZodFirstPartyTypeKind["ZodUnknown"] = "ZodUnknown";
3612 + ZodFirstPartyTypeKind["ZodNever"] = "ZodNever";
3613 + ZodFirstPartyTypeKind["ZodVoid"] = "ZodVoid";
3614 + ZodFirstPartyTypeKind["ZodArray"] = "ZodArray";
3615 + ZodFirstPartyTypeKind["ZodObject"] = "ZodObject";
3616 + ZodFirstPartyTypeKind["ZodUnion"] = "ZodUnion";
3617 + ZodFirstPartyTypeKind["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
3618 + ZodFirstPartyTypeKind["ZodIntersection"] = "ZodIntersection";
3619 + ZodFirstPartyTypeKind["ZodTuple"] = "ZodTuple";
3620 + ZodFirstPartyTypeKind["ZodRecord"] = "ZodRecord";
3621 + ZodFirstPartyTypeKind["ZodMap"] = "ZodMap";
3622 + ZodFirstPartyTypeKind["ZodSet"] = "ZodSet";
3623 + ZodFirstPartyTypeKind["ZodFunction"] = "ZodFunction";
3624 + ZodFirstPartyTypeKind["ZodLazy"] = "ZodLazy";
3625 + ZodFirstPartyTypeKind["ZodLiteral"] = "ZodLiteral";
3626 + ZodFirstPartyTypeKind["ZodEnum"] = "ZodEnum";
3627 + ZodFirstPartyTypeKind["ZodEffects"] = "ZodEffects";
3628 + ZodFirstPartyTypeKind["ZodNativeEnum"] = "ZodNativeEnum";
3629 + ZodFirstPartyTypeKind["ZodOptional"] = "ZodOptional";
3630 + ZodFirstPartyTypeKind["ZodNullable"] = "ZodNullable";
3631 + ZodFirstPartyTypeKind["ZodDefault"] = "ZodDefault";
3632 + ZodFirstPartyTypeKind["ZodCatch"] = "ZodCatch";
3633 + ZodFirstPartyTypeKind["ZodPromise"] = "ZodPromise";
3634 + ZodFirstPartyTypeKind["ZodBranded"] = "ZodBranded";
3635 + ZodFirstPartyTypeKind["ZodPipeline"] = "ZodPipeline";
3636 + ZodFirstPartyTypeKind["ZodReadonly"] = "ZodReadonly";
3637 + })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
3638 + var stringType = ZodString$1.create;
3639 + var numberType = ZodNumber$1.create;
3640 + var nanType = ZodNaN.create;
3641 + var bigIntType = ZodBigInt.create;
3642 + var booleanType = ZodBoolean$1.create;
3643 + var dateType = ZodDate.create;
3644 + var symbolType = ZodSymbol.create;
3645 + var undefinedType = ZodUndefined.create;
3646 + var nullType = ZodNull$1.create;
3647 + var anyType = ZodAny.create;
3648 + var unknownType = ZodUnknown$1.create;
3649 + var neverType = ZodNever$1.create;
3650 + var voidType = ZodVoid.create;
3651 + var arrayType = ZodArray$1.create;
3652 + var objectType = ZodObject$1.create;
3653 + var strictObjectType = ZodObject$1.strictCreate;
3654 + var unionType = ZodUnion$1.create;
3655 + var discriminatedUnionType = ZodDiscriminatedUnion$1.create;
3656 + var intersectionType = ZodIntersection$1.create;
3657 + var tupleType = ZodTuple.create;
3658 + var recordType = ZodRecord$1.create;
3659 + var mapType = ZodMap.create;
3660 + var setType = ZodSet.create;
3661 + var functionType = ZodFunction.create;
3662 + var lazyType = ZodLazy.create;
3663 + var literalType = ZodLiteral$1.create;
3664 + var enumType = ZodEnum$1.create;
3665 + var nativeEnumType = ZodNativeEnum.create;
3666 + var promiseType = ZodPromise.create;
3667 + var effectsType = ZodEffects.create;
3668 + var optionalType = ZodOptional$1.create;
3669 + var nullableType = ZodNullable$1.create;
3670 + var preprocessType = ZodEffects.createWithPreprocess;
3671 + var pipelineType = ZodPipeline.create;
3672 +
3673 +//#endregion
3674 +//#region node_modules/zod/v4/core/core.js
3675 +/** A special constant with type `never` */
3676 + var NEVER = Object.freeze({ status: "aborted" });
3677 + function $constructor(name, initializer, params) {
3678 + function init(inst, def) {
3679 + var _a;
3680 + Object.defineProperty(inst, "_zod", {
3681 + value: inst._zod ?? {},
3682 + enumerable: false
3683 + });
3684 + (_a = inst._zod).traits ?? (_a.traits = /* @__PURE__ */ new Set());
3685 + inst._zod.traits.add(name);
3686 + initializer(inst, def);
3687 + for (const k in _.prototype) if (!(k in inst)) Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
3688 + inst._zod.constr = _;
3689 + inst._zod.def = def;
3690 + }
3691 + const Parent = params?.Parent ?? Object;
3692 + class Definition extends Parent {}
3693 + Object.defineProperty(Definition, "name", { value: name });
3694 + function _(def) {
3695 + var _a;
3696 + const inst = params?.Parent ? new Definition() : this;
3697 + init(inst, def);
3698 + (_a = inst._zod).deferred ?? (_a.deferred = []);
3699 + for (const fn of inst._zod.deferred) fn();
3700 + return inst;
3701 + }
3702 + Object.defineProperty(_, "init", { value: init });
3703 + Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
3704 + if (params?.Parent && inst instanceof params.Parent) return true;
3705 + return inst?._zod?.traits?.has(name);
3706 + } });
3707 + Object.defineProperty(_, "name", { value: name });
3708 + return _;
3709 + }
3710 + var $ZodAsyncError = class extends Error {
3711 + constructor() {
3712 + super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
3713 + }
3714 + };
3715 + var globalConfig = {};
3716 + function config(newConfig) {
3717 + if (newConfig) Object.assign(globalConfig, newConfig);
3718 + return globalConfig;
3719 + }
3720 +
3721 +//#endregion
3722 +//#region node_modules/zod/v4/core/util.js
3723 + function getEnumValues(entries) {
3724 + const numericValues = Object.values(entries).filter((v) => typeof v === "number");
3725 + return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
3726 + }
3727 + function jsonStringifyReplacer(_, value) {
3728 + if (typeof value === "bigint") return value.toString();
3729 + return value;
3730 + }
3731 + function cached(getter) {
3732 + return { get value() {
3733 + {
3734 + const value = getter();
3735 + Object.defineProperty(this, "value", { value });
3736 + return value;
3737 + }
3738 + } };
3739 + }
3740 + function nullish(input) {
3741 + return input === null || input === void 0;
3742 + }
3743 + function cleanRegex(source) {
3744 + const start = source.startsWith("^") ? 1 : 0;
3745 + const end = source.endsWith("$") ? source.length - 1 : source.length;
3746 + return source.slice(start, end);
3747 + }
3748 + function floatSafeRemainder(val, step) {
3749 + const valDecCount = (val.toString().split(".")[1] || "").length;
3750 + const stepDecCount = (step.toString().split(".")[1] || "").length;
3751 + const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
3752 + return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
3753 + }
3754 + function defineLazy(object, key, getter) {
3755 + Object.defineProperty(object, key, {
3756 + get() {
3757 + {
3758 + const value = getter();
3759 + object[key] = value;
3760 + return value;
3761 + }
3762 + },
3763 + set(v) {
3764 + Object.defineProperty(object, key, { value: v });
3765 + },
3766 + configurable: true
3767 + });
3768 + }
3769 + function assignProp(target, prop, value) {
3770 + Object.defineProperty(target, prop, {
3771 + value,
3772 + writable: true,
3773 + enumerable: true,
3774 + configurable: true
3775 + });
3776 + }
3777 + function esc(str) {
3778 + return JSON.stringify(str);
3779 + }
3780 + var captureStackTrace = Error.captureStackTrace ? Error.captureStackTrace : (..._args) => {};
3781 + function isObject(data) {
3782 + return typeof data === "object" && data !== null && !Array.isArray(data);
3783 + }
3784 + var allowsEval = cached(() => {
3785 + if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
3786 + try {
3787 + new Function("");
3788 + return true;
3789 + } catch (_) {
3790 + return false;
3791 + }
3792 + });
3793 + function isPlainObject$1(o) {
3794 + if (isObject(o) === false) return false;
3795 + const ctor = o.constructor;
3796 + if (ctor === void 0) return true;
3797 + const prot = ctor.prototype;
3798 + if (isObject(prot) === false) return false;
3799 + if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
3800 + return true;
3801 + }
3802 + __name(isPlainObject$1, "isPlainObject");
3803 + var propertyKeyTypes = /* @__PURE__ */ new Set([
3804 + "string",
3805 + "number",
3806 + "symbol"
3807 + ]);
3808 + function escapeRegex(str) {
3809 + return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
3810 + }
3811 + function clone(inst, def, params) {
3812 + const cl = new inst._zod.constr(def ?? inst._zod.def);
3813 + if (!def || params?.parent) cl._zod.parent = inst;
3814 + return cl;
3815 + }
3816 + function normalizeParams(_params) {
3817 + const params = _params;
3818 + if (!params) return {};
3819 + if (typeof params === "string") return { error: () => params };
3820 + if (params?.message !== void 0) {
3821 + if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
3822 + params.error = params.message;
3823 + }
3824 + delete params.message;
3825 + if (typeof params.error === "string") return {
3826 + ...params,
3827 + error: () => params.error
3828 + };
3829 + return params;
3830 + }
3831 + function optionalKeys(shape) {
3832 + return Object.keys(shape).filter((k) => {
3833 + return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
3834 + });
3835 + }
3836 + var NUMBER_FORMAT_RANGES = {
3837 + safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
3838 + int32: [-2147483648, 2147483647],
3839 + uint32: [0, 4294967295],
3840 + float32: [-34028234663852886e22, 34028234663852886e22],
3841 + float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
3842 + };
3843 + function pick(schema, mask) {
3844 + const newShape = {};
3845 + const currDef = schema._zod.def;
3846 + for (const key in mask) {
3847 + if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
3848 + if (!mask[key]) continue;
3849 + newShape[key] = currDef.shape[key];
3850 + }
3851 + return clone(schema, {
3852 + ...schema._zod.def,
3853 + shape: newShape,
3854 + checks: []
3855 + });
3856 + }
3857 + function omit(schema, mask) {
3858 + const newShape = { ...schema._zod.def.shape };
3859 + const currDef = schema._zod.def;
3860 + for (const key in mask) {
3861 + if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
3862 + if (!mask[key]) continue;
3863 + delete newShape[key];
3864 + }
3865 + return clone(schema, {
3866 + ...schema._zod.def,
3867 + shape: newShape,
3868 + checks: []
3869 + });
3870 + }
3871 + function extend(schema, shape) {
3872 + if (!isPlainObject$1(shape)) throw new Error("Invalid input to extend: expected a plain object");
3873 + return clone(schema, {
3874 + ...schema._zod.def,
3875 + get shape() {
3876 + const _shape = {
3877 + ...schema._zod.def.shape,
3878 + ...shape
3879 + };
3880 + assignProp(this, "shape", _shape);
3881 + return _shape;
3882 + },
3883 + checks: []
3884 + });
3885 + }
3886 + function merge(a, b) {
3887 + return clone(a, {
3888 + ...a._zod.def,
3889 + get shape() {
3890 + const _shape = {
3891 + ...a._zod.def.shape,
3892 + ...b._zod.def.shape
3893 + };
3894 + assignProp(this, "shape", _shape);
3895 + return _shape;
3896 + },
3897 + catchall: b._zod.def.catchall,
3898 + checks: []
3899 + });
3900 + }
3901 + function partial(Class, schema, mask) {
3902 + const oldShape = schema._zod.def.shape;
3903 + const shape = { ...oldShape };
3904 + if (mask) for (const key in mask) {
3905 + if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
3906 + if (!mask[key]) continue;
3907 + shape[key] = Class ? new Class({
3908 + type: "optional",
3909 + innerType: oldShape[key]
3910 + }) : oldShape[key];
3911 + }
3912 + else for (const key in oldShape) shape[key] = Class ? new Class({
3913 + type: "optional",
3914 + innerType: oldShape[key]
3915 + }) : oldShape[key];
3916 + return clone(schema, {
3917 + ...schema._zod.def,
3918 + shape,
3919 + checks: []
3920 + });
3921 + }
3922 + function required$1(Class, schema, mask) {
3923 + const oldShape = schema._zod.def.shape;
3924 + const shape = { ...oldShape };
3925 + if (mask) for (const key in mask) {
3926 + if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
3927 + if (!mask[key]) continue;
3928 + shape[key] = new Class({
3929 + type: "nonoptional",
3930 + innerType: oldShape[key]
3931 + });
3932 + }
3933 + else for (const key in oldShape) shape[key] = new Class({
3934 + type: "nonoptional",
3935 + innerType: oldShape[key]
3936 + });
3937 + return clone(schema, {
3938 + ...schema._zod.def,
3939 + shape,
3940 + checks: []
3941 + });
3942 + }
3943 + __name(required$1, "required");
3944 + function aborted(x, startIndex = 0) {
3945 + for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
3946 + return false;
3947 + }
3948 + function prefixIssues(path, issues) {
3949 + return issues.map((iss) => {
3950 + var _a;
3951 + (_a = iss).path ?? (_a.path = []);
3952 + iss.path.unshift(path);
3953 + return iss;
3954 + });
3955 + }
3956 + function unwrapMessage(message) {
3957 + return typeof message === "string" ? message : message?.message;
3958 + }
3959 + function finalizeIssue(iss, ctx, config) {
3960 + const full = {
3961 + ...iss,
3962 + path: iss.path ?? []
3963 + };
3964 + if (!iss.message) full.message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
3965 + delete full.inst;
3966 + delete full.continue;
3967 + if (!ctx?.reportInput) delete full.input;
3968 + return full;
3969 + }
3970 + function getLengthableOrigin(input) {
3971 + if (Array.isArray(input)) return "array";
3972 + if (typeof input === "string") return "string";
3973 + return "unknown";
3974 + }
3975 + function issue(...args) {
3976 + const [iss, input, inst] = args;
3977 + if (typeof iss === "string") return {
3978 + message: iss,
3979 + code: "custom",
3980 + input,
3981 + inst
3982 + };
3983 + return { ...iss };
3984 + }
3985 +
3986 +//#endregion
3987 +//#region node_modules/zod/v4/core/errors.js
3988 + var initializer$1 = /* @__PURE__ */ __name((inst, def) => {
3989 + inst.name = "$ZodError";
3990 + Object.defineProperty(inst, "_zod", {
3991 + value: inst._zod,
3992 + enumerable: false
3993 + });
3994 + Object.defineProperty(inst, "issues", {
3995 + value: def,
3996 + enumerable: false
3997 + });
3998 + Object.defineProperty(inst, "message", {
3999 + get() {
4000 + return JSON.stringify(def, jsonStringifyReplacer, 2);
4001 + },
4002 + enumerable: true
4003 + });
4004 + Object.defineProperty(inst, "toString", {
4005 + value: () => inst.message,
4006 + enumerable: false
4007 + });
4008 + }, "initializer");
4009 + var $ZodError = $constructor("$ZodError", initializer$1);
4010 + var $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
4011 + function flattenError(error, mapper = (issue) => issue.message) {
4012 + const fieldErrors = {};
4013 + const formErrors = [];
4014 + for (const sub of error.issues) if (sub.path.length > 0) {
4015 + fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
4016 + fieldErrors[sub.path[0]].push(mapper(sub));
4017 + } else formErrors.push(mapper(sub));
4018 + return {
4019 + formErrors,
4020 + fieldErrors
4021 + };
4022 + }
4023 + function formatError(error, _mapper) {
4024 + const mapper = _mapper || function(issue) {
4025 + return issue.message;
4026 + };
4027 + const fieldErrors = { _errors: [] };
4028 + const processError = (error) => {
4029 + for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }));
4030 + else if (issue.code === "invalid_key") processError({ issues: issue.issues });
4031 + else if (issue.code === "invalid_element") processError({ issues: issue.issues });
4032 + else if (issue.path.length === 0) fieldErrors._errors.push(mapper(issue));
4033 + else {
4034 + let curr = fieldErrors;
4035 + let i = 0;
4036 + while (i < issue.path.length) {
4037 + const el = issue.path[i];
4038 + if (!(i === issue.path.length - 1)) curr[el] = curr[el] || { _errors: [] };
4039 + else {
4040 + curr[el] = curr[el] || { _errors: [] };
4041 + curr[el]._errors.push(mapper(issue));
4042 + }
4043 + curr = curr[el];
4044 + i++;
4045 + }
4046 + }
4047 + };
4048 + processError(error);
4049 + return fieldErrors;
4050 + }
4051 +
4052 +//#endregion
4053 +//#region node_modules/zod/v4/core/parse.js
4054 + var _parse = (_Err) => (schema, value, _ctx, _params) => {
4055 + const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
4056 + const result = schema._zod.run({
4057 + value,
4058 + issues: []
4059 + }, ctx);
4060 + if (result instanceof Promise) throw new $ZodAsyncError();
4061 + if (result.issues.length) {
4062 + const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
4063 + captureStackTrace(e, _params?.callee);
4064 + throw e;
4065 + }
4066 + return result.value;
4067 + };
4068 + var parse$1 = /* @__PURE__*/ _parse($ZodRealError);
4069 + var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
4070 + const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
4071 + let result = schema._zod.run({
4072 + value,
4073 + issues: []
4074 + }, ctx);
4075 + if (result instanceof Promise) result = await result;
4076 + if (result.issues.length) {
4077 + const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
4078 + captureStackTrace(e, params?.callee);
4079 + throw e;
4080 + }
4081 + return result.value;
4082 + };
4083 + var parseAsync$1 = /* @__PURE__*/ _parseAsync($ZodRealError);
4084 + var _safeParse = (_Err) => (schema, value, _ctx) => {
4085 + const ctx = _ctx ? {
4086 + ..._ctx,
4087 + async: false
4088 + } : { async: false };
4089 + const result = schema._zod.run({
4090 + value,
4091 + issues: []
4092 + }, ctx);
4093 + if (result instanceof Promise) throw new $ZodAsyncError();
4094 + return result.issues.length ? {
4095 + success: false,
4096 + error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
4097 + } : {
4098 + success: true,
4099 + data: result.value
4100 + };
4101 + };
4102 + var safeParse$2 = /* @__PURE__*/ _safeParse($ZodRealError);
4103 + var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
4104 + const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
4105 + let result = schema._zod.run({
4106 + value,
4107 + issues: []
4108 + }, ctx);
4109 + if (result instanceof Promise) result = await result;
4110 + return result.issues.length ? {
4111 + success: false,
4112 + error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
4113 + } : {
4114 + success: true,
4115 + data: result.value
4116 + };
4117 + };
4118 + var safeParseAsync$2 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
4119 +
4120 +//#endregion
4121 +//#region node_modules/zod/v4/core/regexes.js
4122 + var cuid = /^[cC][^\s-]{8,}$/;
4123 + var cuid2 = /^[0-9a-z]+$/;
4124 + var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
4125 + var xid = /^[0-9a-vA-V]{20}$/;
4126 + var ksuid = /^[A-Za-z0-9]{27}$/;
4127 + var nanoid = /^[a-zA-Z0-9_-]{21}$/;
4128 + /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
4129 + var duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
4130 + /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
4131 + var guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
4132 + /** Returns a regex for validating an RFC 4122 UUID.
4133 + *
4134 + * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
4135 + var uuid = (version) => {
4136 + if (!version) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;
4137 + return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
4138 + };
4139 + /** Practical email validation */
4140 + var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
4141 + var _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
4142 + function emoji() {
4143 + return new RegExp(_emoji$1, "u");
4144 + }
4145 + var ipv4 = /^(?:(?: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])$/;
4146 + var ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/;
4147 + var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
4148 + var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
4149 + var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
4150 + var base64url = /^[A-Za-z0-9_-]*$/;
4151 + var hostname = /^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;
4152 + var e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
4153 + var dateSource = `(?:(?:\\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])))`;
4154 + var date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
4155 + function timeSource(args) {
4156 + const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
4157 + return typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
4158 + }
4159 + function time$1(args) {
4160 + return new RegExp(`^${timeSource(args)}$`);
4161 + }
4162 + __name(time$1, "time");
4163 + function datetime$1(args) {
4164 + const time = timeSource({ precision: args.precision });
4165 + const opts = ["Z"];
4166 + if (args.local) opts.push("");
4167 + if (args.offset) opts.push(`([+-]\\d{2}:\\d{2})`);
4168 + const timeRegex = `${time}(?:${opts.join("|")})`;
4169 + return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
4170 + }
4171 + __name(datetime$1, "datetime");
4172 + var string$1 = /* @__PURE__ */ __name((params) => {
4173 + const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
4174 + return new RegExp(`^${regex}$`);
4175 + }, "string");
4176 + var integer = /^\d+$/;
4177 + var number$1 = /^-?\d+(?:\.\d+)?/i;
4178 + var boolean$1 = /true|false/i;
4179 + var _null$2 = /null/i;
4180 + var lowercase = /^[^A-Z]*$/;
4181 + var uppercase = /^[^a-z]*$/;
4182 +
4183 +//#endregion
4184 +//#region node_modules/zod/v4/core/checks.js
4185 + var $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
4186 + var _a;
4187 + inst._zod ?? (inst._zod = {});
4188 + inst._zod.def = def;
4189 + (_a = inst._zod).onattach ?? (_a.onattach = []);
4190 + });
4191 + var numericOriginMap = {
4192 + number: "number",
4193 + bigint: "bigint",
4194 + object: "date"
4195 + };
4196 + var $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
4197 + $ZodCheck.init(inst, def);
4198 + const origin = numericOriginMap[typeof def.value];
4199 + inst._zod.onattach.push((inst) => {
4200 + const bag = inst._zod.bag;
4201 + const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
4202 + if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
4203 + else bag.exclusiveMaximum = def.value;
4204 + });
4205 + inst._zod.check = (payload) => {
4206 + if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
4207 + payload.issues.push({
4208 + origin,
4209 + code: "too_big",
4210 + maximum: def.value,
4211 + input: payload.value,
4212 + inclusive: def.inclusive,
4213 + inst,
4214 + continue: !def.abort
4215 + });
4216 + };
4217 + });
4218 + var $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
4219 + $ZodCheck.init(inst, def);
4220 + const origin = numericOriginMap[typeof def.value];
4221 + inst._zod.onattach.push((inst) => {
4222 + const bag = inst._zod.bag;
4223 + const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
4224 + if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
4225 + else bag.exclusiveMinimum = def.value;
4226 + });
4227 + inst._zod.check = (payload) => {
4228 + if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
4229 + payload.issues.push({
4230 + origin,
4231 + code: "too_small",
4232 + minimum: def.value,
4233 + input: payload.value,
4234 + inclusive: def.inclusive,
4235 + inst,
4236 + continue: !def.abort
4237 + });
4238 + };
4239 + });
4240 + var $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
4241 + $ZodCheck.init(inst, def);
4242 + inst._zod.onattach.push((inst) => {
4243 + var _a;
4244 + (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
4245 + });
4246 + inst._zod.check = (payload) => {
4247 + if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
4248 + if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
4249 + payload.issues.push({
4250 + origin: typeof payload.value,
4251 + code: "not_multiple_of",
4252 + divisor: def.value,
4253 + input: payload.value,
4254 + inst,
4255 + continue: !def.abort
4256 + });
4257 + };
4258 + });
4259 + var $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat", (inst, def) => {
4260 + $ZodCheck.init(inst, def);
4261 + def.format = def.format || "float64";
4262 + const isInt = def.format?.includes("int");
4263 + const origin = isInt ? "int" : "number";
4264 + const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
4265 + inst._zod.onattach.push((inst) => {
4266 + const bag = inst._zod.bag;
4267 + bag.format = def.format;
4268 + bag.minimum = minimum;
4269 + bag.maximum = maximum;
4270 + if (isInt) bag.pattern = integer;
4271 + });
4272 + inst._zod.check = (payload) => {
4273 + const input = payload.value;
4274 + if (isInt) {
4275 + if (!Number.isInteger(input)) {
4276 + payload.issues.push({
4277 + expected: origin,
4278 + format: def.format,
4279 + code: "invalid_type",
4280 + input,
4281 + inst
4282 + });
4283 + return;
4284 + }
4285 + if (!Number.isSafeInteger(input)) {
4286 + if (input > 0) payload.issues.push({
4287 + input,
4288 + code: "too_big",
4289 + maximum: Number.MAX_SAFE_INTEGER,
4290 + note: "Integers must be within the safe integer range.",
4291 + inst,
4292 + origin,
4293 + continue: !def.abort
4294 + });
4295 + else payload.issues.push({
4296 + input,
4297 + code: "too_small",
4298 + minimum: Number.MIN_SAFE_INTEGER,
4299 + note: "Integers must be within the safe integer range.",
4300 + inst,
4301 + origin,
4302 + continue: !def.abort
4303 + });
4304 + return;
4305 + }
4306 + }
4307 + if (input < minimum) payload.issues.push({
4308 + origin: "number",
4309 + input,
4310 + code: "too_small",
4311 + minimum,
4312 + inclusive: true,
4313 + inst,
4314 + continue: !def.abort
4315 + });
4316 + if (input > maximum) payload.issues.push({
4317 + origin: "number",
4318 + input,
4319 + code: "too_big",
4320 + maximum,
4321 + inst
4322 + });
4323 + };
4324 + });
4325 + var $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
4326 + var _a;
4327 + $ZodCheck.init(inst, def);
4328 + (_a = inst._zod.def).when ?? (_a.when = (payload) => {
4329 + const val = payload.value;
4330 + return !nullish(val) && val.length !== void 0;
4331 + });
4332 + inst._zod.onattach.push((inst) => {
4333 + const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
4334 + if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
4335 + });
4336 + inst._zod.check = (payload) => {
4337 + const input = payload.value;
4338 + if (input.length <= def.maximum) return;
4339 + const origin = getLengthableOrigin(input);
4340 + payload.issues.push({
4341 + origin,
4342 + code: "too_big",
4343 + maximum: def.maximum,
4344 + inclusive: true,
4345 + input,
4346 + inst,
4347 + continue: !def.abort
4348 + });
4349 + };
4350 + });
4351 + var $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
4352 + var _a;
4353 + $ZodCheck.init(inst, def);
4354 + (_a = inst._zod.def).when ?? (_a.when = (payload) => {
4355 + const val = payload.value;
4356 + return !nullish(val) && val.length !== void 0;
4357 + });
4358 + inst._zod.onattach.push((inst) => {
4359 + const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
4360 + if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
4361 + });
4362 + inst._zod.check = (payload) => {
4363 + const input = payload.value;
4364 + if (input.length >= def.minimum) return;
4365 + const origin = getLengthableOrigin(input);
4366 + payload.issues.push({
4367 + origin,
4368 + code: "too_small",
4369 + minimum: def.minimum,
4370 + inclusive: true,
4371 + input,
4372 + inst,
4373 + continue: !def.abort
4374 + });
4375 + };
4376 + });
4377 + var $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
4378 + var _a;
4379 + $ZodCheck.init(inst, def);
4380 + (_a = inst._zod.def).when ?? (_a.when = (payload) => {
4381 + const val = payload.value;
4382 + return !nullish(val) && val.length !== void 0;
4383 + });
4384 + inst._zod.onattach.push((inst) => {
4385 + const bag = inst._zod.bag;
4386 + bag.minimum = def.length;
4387 + bag.maximum = def.length;
4388 + bag.length = def.length;
4389 + });
4390 + inst._zod.check = (payload) => {
4391 + const input = payload.value;
4392 + const length = input.length;
4393 + if (length === def.length) return;
4394 + const origin = getLengthableOrigin(input);
4395 + const tooBig = length > def.length;
4396 + payload.issues.push({
4397 + origin,
4398 + ...tooBig ? {
4399 + code: "too_big",
4400 + maximum: def.length
4401 + } : {
4402 + code: "too_small",
4403 + minimum: def.length
4404 + },
4405 + inclusive: true,
4406 + exact: true,
4407 + input: payload.value,
4408 + inst,
4409 + continue: !def.abort
4410 + });
4411 + };
4412 + });
4413 + var $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
4414 + var _a;
4415 + var _b;
4416 + $ZodCheck.init(inst, def);
4417 + inst._zod.onattach.push((inst) => {
4418 + const bag = inst._zod.bag;
4419 + bag.format = def.format;
4420 + if (def.pattern) {
4421 + bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
4422 + bag.patterns.add(def.pattern);
4423 + }
4424 + });
4425 + if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
4426 + def.pattern.lastIndex = 0;
4427 + if (def.pattern.test(payload.value)) return;
4428 + payload.issues.push({
4429 + origin: "string",
4430 + code: "invalid_format",
4431 + format: def.format,
4432 + input: payload.value,
4433 + ...def.pattern ? { pattern: def.pattern.toString() } : {},
4434 + inst,
4435 + continue: !def.abort
4436 + });
4437 + });
4438 + else (_b = inst._zod).check ?? (_b.check = () => {});
4439 + });
4440 + var $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (inst, def) => {
4441 + $ZodCheckStringFormat.init(inst, def);
4442 + inst._zod.check = (payload) => {
4443 + def.pattern.lastIndex = 0;
4444 + if (def.pattern.test(payload.value)) return;
4445 + payload.issues.push({
4446 + origin: "string",
4447 + code: "invalid_format",
4448 + format: "regex",
4449 + input: payload.value,
4450 + pattern: def.pattern.toString(),
4451 + inst,
4452 + continue: !def.abort
4453 + });
4454 + };
4455 + });
4456 + var $ZodCheckLowerCase = /*@__PURE__*/ $constructor("$ZodCheckLowerCase", (inst, def) => {
4457 + def.pattern ?? (def.pattern = lowercase);
4458 + $ZodCheckStringFormat.init(inst, def);
4459 + });
4460 + var $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst, def) => {
4461 + def.pattern ?? (def.pattern = uppercase);
4462 + $ZodCheckStringFormat.init(inst, def);
4463 + });
4464 + var $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
4465 + $ZodCheck.init(inst, def);
4466 + const escapedRegex = escapeRegex(def.includes);
4467 + const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
4468 + def.pattern = pattern;
4469 + inst._zod.onattach.push((inst) => {
4470 + const bag = inst._zod.bag;
4471 + bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
4472 + bag.patterns.add(pattern);
4473 + });
4474 + inst._zod.check = (payload) => {
4475 + if (payload.value.includes(def.includes, def.position)) return;
4476 + payload.issues.push({
4477 + origin: "string",
4478 + code: "invalid_format",
4479 + format: "includes",
4480 + includes: def.includes,
4481 + input: payload.value,
4482 + inst,
4483 + continue: !def.abort
4484 + });
4485 + };
4486 + });
4487 + var $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (inst, def) => {
4488 + $ZodCheck.init(inst, def);
4489 + const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
4490 + def.pattern ?? (def.pattern = pattern);
4491 + inst._zod.onattach.push((inst) => {
4492 + const bag = inst._zod.bag;
4493 + bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
4494 + bag.patterns.add(pattern);
4495 + });
4496 + inst._zod.check = (payload) => {
4497 + if (payload.value.startsWith(def.prefix)) return;
4498 + payload.issues.push({
4499 + origin: "string",
4500 + code: "invalid_format",
4501 + format: "starts_with",
4502 + prefix: def.prefix,
4503 + input: payload.value,
4504 + inst,
4505 + continue: !def.abort
4506 + });
4507 + };
4508 + });
4509 + var $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, def) => {
4510 + $ZodCheck.init(inst, def);
4511 + const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
4512 + def.pattern ?? (def.pattern = pattern);
4513 + inst._zod.onattach.push((inst) => {
4514 + const bag = inst._zod.bag;
4515 + bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
4516 + bag.patterns.add(pattern);
4517 + });
4518 + inst._zod.check = (payload) => {
4519 + if (payload.value.endsWith(def.suffix)) return;
4520 + payload.issues.push({
4521 + origin: "string",
4522 + code: "invalid_format",
4523 + format: "ends_with",
4524 + suffix: def.suffix,
4525 + input: payload.value,
4526 + inst,
4527 + continue: !def.abort
4528 + });
4529 + };
4530 + });
4531 + var $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst, def) => {
4532 + $ZodCheck.init(inst, def);
4533 + inst._zod.check = (payload) => {
4534 + payload.value = def.tx(payload.value);
4535 + };
4536 + });
4537 +
4538 +//#endregion
4539 +//#region node_modules/zod/v4/core/doc.js
4540 + var Doc = class {
4541 + constructor(args = []) {
4542 + this.content = [];
4543 + this.indent = 0;
4544 + if (this) this.args = args;
4545 + }
4546 + indented(fn) {
4547 + this.indent += 1;
4548 + fn(this);
4549 + this.indent -= 1;
4550 + }
4551 + write(arg) {
4552 + if (typeof arg === "function") {
4553 + arg(this, { execution: "sync" });
4554 + arg(this, { execution: "async" });
4555 + return;
4556 + }
4557 + const lines = arg.split("\n").filter((x) => x);
4558 + const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
4559 + const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
4560 + for (const line of dedented) this.content.push(line);
4561 + }
4562 + compile() {
4563 + const F = Function;
4564 + const args = this?.args;
4565 + const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
4566 + return new F(...args, lines.join("\n"));
4567 + }
4568 + };
4569 +
4570 +//#endregion
4571 +//#region node_modules/zod/v4/core/versions.js
4572 + var version = {
4573 + major: 4,
4574 + minor: 0,
4575 + patch: 0
4576 + };
4577 +
4578 +//#endregion
4579 +//#region node_modules/zod/v4/core/schemas.js
4580 + var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
4581 + var _a;
4582 + inst ?? (inst = {});
4583 + inst._zod.def = def;
4584 + inst._zod.bag = inst._zod.bag || {};
4585 + inst._zod.version = version;
4586 + const checks = [...inst._zod.def.checks ?? []];
4587 + if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
4588 + for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
4589 + if (checks.length === 0) {
4590 + (_a = inst._zod).deferred ?? (_a.deferred = []);
4591 + inst._zod.deferred?.push(() => {
4592 + inst._zod.run = inst._zod.parse;
4593 + });
4594 + } else {
4595 + const runChecks = (payload, checks, ctx) => {
4596 + let isAborted = aborted(payload);
4597 + let asyncResult;
4598 + for (const ch of checks) {
4599 + if (ch._zod.def.when) {
4600 + if (!ch._zod.def.when(payload)) continue;
4601 + } else if (isAborted) continue;
4602 + const currLen = payload.issues.length;
4603 + const _ = ch._zod.check(payload);
4604 + if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
4605 + if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
4606 + await _;
4607 + if (payload.issues.length === currLen) return;
4608 + if (!isAborted) isAborted = aborted(payload, currLen);
4609 + });
4610 + else {
4611 + if (payload.issues.length === currLen) continue;
4612 + if (!isAborted) isAborted = aborted(payload, currLen);
4613 + }
4614 + }
4615 + if (asyncResult) return asyncResult.then(() => {
4616 + return payload;
4617 + });
4618 + return payload;
4619 + };
4620 + inst._zod.run = (payload, ctx) => {
4621 + const result = inst._zod.parse(payload, ctx);
4622 + if (result instanceof Promise) {
4623 + if (ctx.async === false) throw new $ZodAsyncError();
4624 + return result.then((result) => runChecks(result, checks, ctx));
4625 + }
4626 + return runChecks(result, checks, ctx);
4627 + };
4628 + }
4629 + inst["~standard"] = {
4630 + validate: (value) => {
4631 + try {
4632 + const r = safeParse$2(inst, value);
4633 + return r.success ? { value: r.data } : { issues: r.error?.issues };
4634 + } catch (_) {
4635 + return safeParseAsync$2(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
4636 + }
4637 + },
4638 + vendor: "zod",
4639 + version: 1
4640 + };
4641 + });
4642 + var $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
4643 + $ZodType.init(inst, def);
4644 + inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
4645 + inst._zod.parse = (payload, _) => {
4646 + if (def.coerce) try {
4647 + payload.value = String(payload.value);
4648 + } catch (_) {}
4649 + if (typeof payload.value === "string") return payload;
4650 + payload.issues.push({
4651 + expected: "string",
4652 + code: "invalid_type",
4653 + input: payload.value,
4654 + inst
4655 + });
4656 + return payload;
4657 + };
4658 + });
4659 + var $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (inst, def) => {
4660 + $ZodCheckStringFormat.init(inst, def);
4661 + $ZodString.init(inst, def);
4662 + });
4663 + var $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (inst, def) => {
4664 + def.pattern ?? (def.pattern = guid);
4665 + $ZodStringFormat.init(inst, def);
4666 + });
4667 + var $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def) => {
4668 + if (def.version) {
4669 + const v = {
4670 + v1: 1,
4671 + v2: 2,
4672 + v3: 3,
4673 + v4: 4,
4674 + v5: 5,
4675 + v6: 6,
4676 + v7: 7,
4677 + v8: 8
4678 + }[def.version];
4679 + if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
4680 + def.pattern ?? (def.pattern = uuid(v));
4681 + } else def.pattern ?? (def.pattern = uuid());
4682 + $ZodStringFormat.init(inst, def);
4683 + });
4684 + var $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
4685 + def.pattern ?? (def.pattern = email);
4686 + $ZodStringFormat.init(inst, def);
4687 + });
4688 + var $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
4689 + $ZodStringFormat.init(inst, def);
4690 + inst._zod.check = (payload) => {
4691 + try {
4692 + const orig = payload.value;
4693 + const url = new URL(orig);
4694 + const href = url.href;
4695 + if (def.hostname) {
4696 + def.hostname.lastIndex = 0;
4697 + if (!def.hostname.test(url.hostname)) payload.issues.push({
4698 + code: "invalid_format",
4699 + format: "url",
4700 + note: "Invalid hostname",
4701 + pattern: hostname.source,
4702 + input: payload.value,
4703 + inst,
4704 + continue: !def.abort
4705 + });
4706 + }
4707 + if (def.protocol) {
4708 + def.protocol.lastIndex = 0;
4709 + if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
4710 + code: "invalid_format",
4711 + format: "url",
4712 + note: "Invalid protocol",
4713 + pattern: def.protocol.source,
4714 + input: payload.value,
4715 + inst,
4716 + continue: !def.abort
4717 + });
4718 + }
4719 + if (!orig.endsWith("/") && href.endsWith("/")) payload.value = href.slice(0, -1);
4720 + else payload.value = href;
4721 + return;
4722 + } catch (_) {
4723 + payload.issues.push({
4724 + code: "invalid_format",
4725 + format: "url",
4726 + input: payload.value,
4727 + inst,
4728 + continue: !def.abort
4729 + });
4730 + }
4731 + };
4732 + });
4733 + var $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
4734 + def.pattern ?? (def.pattern = emoji());
4735 + $ZodStringFormat.init(inst, def);
4736 + });
4737 + var $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
4738 + def.pattern ?? (def.pattern = nanoid);
4739 + $ZodStringFormat.init(inst, def);
4740 + });
4741 + var $ZodCUID = /*@__PURE__*/ $constructor("$ZodCUID", (inst, def) => {
4742 + def.pattern ?? (def.pattern = cuid);
4743 + $ZodStringFormat.init(inst, def);
4744 + });
4745 + var $ZodCUID2 = /*@__PURE__*/ $constructor("$ZodCUID2", (inst, def) => {
4746 + def.pattern ?? (def.pattern = cuid2);
4747 + $ZodStringFormat.init(inst, def);
4748 + });
4749 + var $ZodULID = /*@__PURE__*/ $constructor("$ZodULID", (inst, def) => {
4750 + def.pattern ?? (def.pattern = ulid);
4751 + $ZodStringFormat.init(inst, def);
4752 + });
4753 + var $ZodXID = /*@__PURE__*/ $constructor("$ZodXID", (inst, def) => {
4754 + def.pattern ?? (def.pattern = xid);
4755 + $ZodStringFormat.init(inst, def);
4756 + });
4757 + var $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
4758 + def.pattern ?? (def.pattern = ksuid);
4759 + $ZodStringFormat.init(inst, def);
4760 + });
4761 + var $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
4762 + def.pattern ?? (def.pattern = datetime$1(def));
4763 + $ZodStringFormat.init(inst, def);
4764 + });
4765 + var $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
4766 + def.pattern ?? (def.pattern = date$1);
4767 + $ZodStringFormat.init(inst, def);
4768 + });
4769 + var $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
4770 + def.pattern ?? (def.pattern = time$1(def));
4771 + $ZodStringFormat.init(inst, def);
4772 + });
4773 + var $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
4774 + def.pattern ?? (def.pattern = duration$1);
4775 + $ZodStringFormat.init(inst, def);
4776 + });
4777 + var $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
4778 + def.pattern ?? (def.pattern = ipv4);
4779 + $ZodStringFormat.init(inst, def);
4780 + inst._zod.onattach.push((inst) => {
4781 + const bag = inst._zod.bag;
4782 + bag.format = `ipv4`;
4783 + });
4784 + });
4785 + var $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
4786 + def.pattern ?? (def.pattern = ipv6);
4787 + $ZodStringFormat.init(inst, def);
4788 + inst._zod.onattach.push((inst) => {
4789 + const bag = inst._zod.bag;
4790 + bag.format = `ipv6`;
4791 + });
4792 + inst._zod.check = (payload) => {
4793 + try {
4794 + new URL(`http://[${payload.value}]`);
4795 + } catch {
4796 + payload.issues.push({
4797 + code: "invalid_format",
4798 + format: "ipv6",
4799 + input: payload.value,
4800 + inst,
4801 + continue: !def.abort
4802 + });
4803 + }
4804 + };
4805 + });
4806 + var $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
4807 + def.pattern ?? (def.pattern = cidrv4);
4808 + $ZodStringFormat.init(inst, def);
4809 + });
4810 + var $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
4811 + def.pattern ?? (def.pattern = cidrv6);
4812 + $ZodStringFormat.init(inst, def);
4813 + inst._zod.check = (payload) => {
4814 + const [address, prefix] = payload.value.split("/");
4815 + try {
4816 + if (!prefix) throw new Error();
4817 + const prefixNum = Number(prefix);
4818 + if (`${prefixNum}` !== prefix) throw new Error();
4819 + if (prefixNum < 0 || prefixNum > 128) throw new Error();
4820 + new URL(`http://[${address}]`);
4821 + } catch {
4822 + payload.issues.push({
4823 + code: "invalid_format",
4824 + format: "cidrv6",
4825 + input: payload.value,
4826 + inst,
4827 + continue: !def.abort
4828 + });
4829 + }
4830 + };
4831 + });
4832 + function isValidBase64(data) {
4833 + if (data === "") return true;
4834 + if (data.length % 4 !== 0) return false;
4835 + try {
4836 + atob(data);
4837 + return true;
4838 + } catch {
4839 + return false;
4840 + }
4841 + }
4842 + var $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
4843 + def.pattern ?? (def.pattern = base64);
4844 + $ZodStringFormat.init(inst, def);
4845 + inst._zod.onattach.push((inst) => {
4846 + inst._zod.bag.contentEncoding = "base64";
4847 + });
4848 + inst._zod.check = (payload) => {
4849 + if (isValidBase64(payload.value)) return;
4850 + payload.issues.push({
4851 + code: "invalid_format",
4852 + format: "base64",
4853 + input: payload.value,
4854 + inst,
4855 + continue: !def.abort
4856 + });
4857 + };
4858 + });
4859 + function isValidBase64URL(data) {
4860 + if (!base64url.test(data)) return false;
4861 + const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
4862 + return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
4863 + }
4864 + var $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
4865 + def.pattern ?? (def.pattern = base64url);
4866 + $ZodStringFormat.init(inst, def);
4867 + inst._zod.onattach.push((inst) => {
4868 + inst._zod.bag.contentEncoding = "base64url";
4869 + });
4870 + inst._zod.check = (payload) => {
4871 + if (isValidBase64URL(payload.value)) return;
4872 + payload.issues.push({
4873 + code: "invalid_format",
4874 + format: "base64url",
4875 + input: payload.value,
4876 + inst,
4877 + continue: !def.abort
4878 + });
4879 + };
4880 + });
4881 + var $ZodE164 = /*@__PURE__*/ $constructor("$ZodE164", (inst, def) => {
4882 + def.pattern ?? (def.pattern = e164);
4883 + $ZodStringFormat.init(inst, def);
4884 + });
4885 + function isValidJWT(token, algorithm = null) {
4886 + try {
4887 + const tokensParts = token.split(".");
4888 + if (tokensParts.length !== 3) return false;
4889 + const [header] = tokensParts;
4890 + if (!header) return false;
4891 + const parsedHeader = JSON.parse(atob(header));
4892 + if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
4893 + if (!parsedHeader.alg) return false;
4894 + if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
4895 + return true;
4896 + } catch {
4897 + return false;
4898 + }
4899 + }
4900 + var $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
4901 + $ZodStringFormat.init(inst, def);
4902 + inst._zod.check = (payload) => {
4903 + if (isValidJWT(payload.value, def.alg)) return;
4904 + payload.issues.push({
4905 + code: "invalid_format",
4906 + format: "jwt",
4907 + input: payload.value,
4908 + inst,
4909 + continue: !def.abort
4910 + });
4911 + };
4912 + });
4913 + var $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
4914 + $ZodType.init(inst, def);
4915 + inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
4916 + inst._zod.parse = (payload, _ctx) => {
4917 + if (def.coerce) try {
4918 + payload.value = Number(payload.value);
4919 + } catch (_) {}
4920 + const input = payload.value;
4921 + if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
4922 + const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
4923 + payload.issues.push({
4924 + expected: "number",
4925 + code: "invalid_type",
4926 + input,
4927 + inst,
4928 + ...received ? { received } : {}
4929 + });
4930 + return payload;
4931 + };
4932 + });
4933 + var $ZodNumberFormat = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
4934 + $ZodCheckNumberFormat.init(inst, def);
4935 + $ZodNumber.init(inst, def);
4936 + });
4937 + var $ZodBoolean = /*@__PURE__*/ $constructor("$ZodBoolean", (inst, def) => {
4938 + $ZodType.init(inst, def);
4939 + inst._zod.pattern = boolean$1;
4940 + inst._zod.parse = (payload, _ctx) => {
4941 + if (def.coerce) try {
4942 + payload.value = Boolean(payload.value);
4943 + } catch (_) {}
4944 + const input = payload.value;
4945 + if (typeof input === "boolean") return payload;
4946 + payload.issues.push({
4947 + expected: "boolean",
4948 + code: "invalid_type",
4949 + input,
4950 + inst
4951 + });
4952 + return payload;
4953 + };
4954 + });
4955 + var $ZodNull = /*@__PURE__*/ $constructor("$ZodNull", (inst, def) => {
4956 + $ZodType.init(inst, def);
4957 + inst._zod.pattern = _null$2;
4958 + inst._zod.values = /* @__PURE__ */ new Set([null]);
4959 + inst._zod.parse = (payload, _ctx) => {
4960 + const input = payload.value;
4961 + if (input === null) return payload;
4962 + payload.issues.push({
4963 + expected: "null",
4964 + code: "invalid_type",
4965 + input,
4966 + inst
4967 + });
4968 + return payload;
4969 + };
4970 + });
4971 + var $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (inst, def) => {
4972 + $ZodType.init(inst, def);
4973 + inst._zod.parse = (payload) => payload;
4974 + });
4975 + var $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (inst, def) => {
4976 + $ZodType.init(inst, def);
4977 + inst._zod.parse = (payload, _ctx) => {
4978 + payload.issues.push({
4979 + expected: "never",
4980 + code: "invalid_type",
4981 + input: payload.value,
4982 + inst
4983 + });
4984 + return payload;
4985 + };
4986 + });
4987 + function handleArrayResult(result, final, index) {
4988 + if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
4989 + final.value[index] = result.value;
4990 + }
4991 + var $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
4992 + $ZodType.init(inst, def);
4993 + inst._zod.parse = (payload, ctx) => {
4994 + const input = payload.value;
4995 + if (!Array.isArray(input)) {
4996 + payload.issues.push({
4997 + expected: "array",
4998 + code: "invalid_type",
4999 + input,
5000 + inst
5001 + });
5002 + return payload;
5003 + }
5004 + payload.value = Array(input.length);
5005 + const proms = [];
5006 + for (let i = 0; i < input.length; i++) {
5007 + const item = input[i];
5008 + const result = def.element._zod.run({
5009 + value: item,
5010 + issues: []
5011 + }, ctx);
5012 + if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
5013 + else handleArrayResult(result, payload, i);
5014 + }
5015 + if (proms.length) return Promise.all(proms).then(() => payload);
5016 + return payload;
5017 + };
5018 + });
5019 + function handleObjectResult(result, final, key) {
5020 + if (result.issues.length) final.issues.push(...prefixIssues(key, result.issues));
5021 + final.value[key] = result.value;
5022 + }
5023 + function handleOptionalObjectResult(result, final, key, input) {
5024 + if (result.issues.length) if (input[key] === void 0) if (key in input) final.value[key] = void 0;
5025 + else final.value[key] = result.value;
5026 + else final.issues.push(...prefixIssues(key, result.issues));
5027 + else if (result.value === void 0) {
5028 + if (key in input) final.value[key] = void 0;
5029 + } else final.value[key] = result.value;
5030 + }
5031 + var $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
5032 + $ZodType.init(inst, def);
5033 + const _normalized = cached(() => {
5034 + const keys = Object.keys(def.shape);
5035 + for (const k of keys) if (!(def.shape[k] instanceof $ZodType)) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
5036 + const okeys = optionalKeys(def.shape);
5037 + return {
5038 + shape: def.shape,
5039 + keys,
5040 + keySet: new Set(keys),
5041 + numKeys: keys.length,
5042 + optionalKeys: new Set(okeys)
5043 + };
5044 + });
5045 + defineLazy(inst._zod, "propValues", () => {
5046 + const shape = def.shape;
5047 + const propValues = {};
5048 + for (const key in shape) {
5049 + const field = shape[key]._zod;
5050 + if (field.values) {
5051 + propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
5052 + for (const v of field.values) propValues[key].add(v);
5053 + }
5054 + }
5055 + return propValues;
5056 + });
5057 + const generateFastpass = (shape) => {
5058 + const doc = new Doc([
5059 + "shape",
5060 + "payload",
5061 + "ctx"
5062 + ]);
5063 + const normalized = _normalized.value;
5064 + const parseStr = (key) => {
5065 + const k = esc(key);
5066 + return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
5067 + };
5068 + doc.write(`const input = payload.value;`);
5069 + const ids = Object.create(null);
5070 + let counter = 0;
5071 + for (const key of normalized.keys) ids[key] = `key_${counter++}`;
5072 + doc.write(`const newResult = {}`);
5073 + for (const key of normalized.keys) if (normalized.optionalKeys.has(key)) {
5074 + const id = ids[key];
5075 + doc.write(`const ${id} = ${parseStr(key)};`);
5076 + const k = esc(key);
5077 + doc.write(`
5078 + if (${id}.issues.length) {
5079 + if (input[${k}] === undefined) {
5080 + if (${k} in input) {
5081 + newResult[${k}] = undefined;
5082 + }
5083 + } else {
5084 + payload.issues = payload.issues.concat(
5085 + ${id}.issues.map((iss) => ({
5086 + ...iss,
5087 + path: iss.path ? [${k}, ...iss.path] : [${k}],
5088 + }))
5089 + );
5090 + }
5091 + } else if (${id}.value === undefined) {
5092 + if (${k} in input) newResult[${k}] = undefined;
5093 + } else {
5094 + newResult[${k}] = ${id}.value;
5095 + }
5096 + `);
5097 + } else {
5098 + const id = ids[key];
5099 + doc.write(`const ${id} = ${parseStr(key)};`);
5100 + doc.write(`
5101 + if (${id}.issues.length) payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
5102 + ...iss,
5103 + path: iss.path ? [${esc(key)}, ...iss.path] : [${esc(key)}]
5104 + })));`);
5105 + doc.write(`newResult[${esc(key)}] = ${id}.value`);
5106 + }
5107 + doc.write(`payload.value = newResult;`);
5108 + doc.write(`return payload;`);
5109 + const fn = doc.compile();
5110 + return (payload, ctx) => fn(shape, payload, ctx);
5111 + };
5112 + let fastpass;
5113 + const isObject$1 = isObject;
5114 + const jit = !globalConfig.jitless;
5115 + const allowsEval$1 = allowsEval;
5116 + const fastEnabled = jit && allowsEval$1.value;
5117 + const catchall = def.catchall;
5118 + let value;
5119 + inst._zod.parse = (payload, ctx) => {
5120 + value ?? (value = _normalized.value);
5121 + const input = payload.value;
5122 + if (!isObject$1(input)) {
5123 + payload.issues.push({
5124 + expected: "object",
5125 + code: "invalid_type",
5126 + input,
5127 + inst
5128 + });
5129 + return payload;
5130 + }
5131 + const proms = [];
5132 + if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
5133 + if (!fastpass) fastpass = generateFastpass(def.shape);
5134 + payload = fastpass(payload, ctx);
5135 + } else {
5136 + payload.value = {};
5137 + const shape = value.shape;
5138 + for (const key of value.keys) {
5139 + const el = shape[key];
5140 + const r = el._zod.run({
5141 + value: input[key],
5142 + issues: []
5143 + }, ctx);
5144 + const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
5145 + if (r instanceof Promise) proms.push(r.then((r) => isOptional ? handleOptionalObjectResult(r, payload, key, input) : handleObjectResult(r, payload, key)));
5146 + else if (isOptional) handleOptionalObjectResult(r, payload, key, input);
5147 + else handleObjectResult(r, payload, key);
5148 + }
5149 + }
5150 + if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
5151 + const unrecognized = [];
5152 + const keySet = value.keySet;
5153 + const _catchall = catchall._zod;
5154 + const t = _catchall.def.type;
5155 + for (const key of Object.keys(input)) {
5156 + if (keySet.has(key)) continue;
5157 + if (t === "never") {
5158 + unrecognized.push(key);
5159 + continue;
5160 + }
5161 + const r = _catchall.run({
5162 + value: input[key],
5163 + issues: []
5164 + }, ctx);
5165 + if (r instanceof Promise) proms.push(r.then((r) => handleObjectResult(r, payload, key)));
5166 + else handleObjectResult(r, payload, key);
5167 + }
5168 + if (unrecognized.length) payload.issues.push({
5169 + code: "unrecognized_keys",
5170 + keys: unrecognized,
5171 + input,
5172 + inst
5173 + });
5174 + if (!proms.length) return payload;
5175 + return Promise.all(proms).then(() => {
5176 + return payload;
5177 + });
5178 + };
5179 + });
5180 + function handleUnionResults(results, final, inst, ctx) {
5181 + for (const result of results) if (result.issues.length === 0) {
5182 + final.value = result.value;
5183 + return final;
5184 + }
5185 + final.issues.push({
5186 + code: "invalid_union",
5187 + input: final.value,
5188 + inst,
5189 + errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
5190 + });
5191 + return final;
5192 + }
5193 + var $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
5194 + $ZodType.init(inst, def);
5195 + defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
5196 + defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
5197 + defineLazy(inst._zod, "values", () => {
5198 + if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
5199 + });
5200 + defineLazy(inst._zod, "pattern", () => {
5201 + if (def.options.every((o) => o._zod.pattern)) {
5202 + const patterns = def.options.map((o) => o._zod.pattern);
5203 + return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
5204 + }
5205 + });
5206 + inst._zod.parse = (payload, ctx) => {
5207 + let async = false;
5208 + const results = [];
5209 + for (const option of def.options) {
5210 + const result = option._zod.run({
5211 + value: payload.value,
5212 + issues: []
5213 + }, ctx);
5214 + if (result instanceof Promise) {
5215 + results.push(result);
5216 + async = true;
5217 + } else {
5218 + if (result.issues.length === 0) return result;
5219 + results.push(result);
5220 + }
5221 + }
5222 + if (!async) return handleUnionResults(results, payload, inst, ctx);
5223 + return Promise.all(results).then((results) => {
5224 + return handleUnionResults(results, payload, inst, ctx);
5225 + });
5226 + };
5227 + });
5228 + var $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
5229 + $ZodUnion.init(inst, def);
5230 + const _super = inst._zod.parse;
5231 + defineLazy(inst._zod, "propValues", () => {
5232 + const propValues = {};
5233 + for (const option of def.options) {
5234 + const pv = option._zod.propValues;
5235 + if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
5236 + for (const [k, v] of Object.entries(pv)) {
5237 + if (!propValues[k]) propValues[k] = /* @__PURE__ */ new Set();
5238 + for (const val of v) propValues[k].add(val);
5239 + }
5240 + }
5241 + return propValues;
5242 + });
5243 + const disc = cached(() => {
5244 + const opts = def.options;
5245 + const map = /* @__PURE__ */ new Map();
5246 + for (const o of opts) {
5247 + const values = o._zod.propValues[def.discriminator];
5248 + if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
5249 + for (const v of values) {
5250 + if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
5251 + map.set(v, o);
5252 + }
5253 + }
5254 + return map;
5255 + });
5256 + inst._zod.parse = (payload, ctx) => {
5257 + const input = payload.value;
5258 + if (!isObject(input)) {
5259 + payload.issues.push({
5260 + code: "invalid_type",
5261 + expected: "object",
5262 + input,
5263 + inst
5264 + });
5265 + return payload;
5266 + }
5267 + const opt = disc.value.get(input?.[def.discriminator]);
5268 + if (opt) return opt._zod.run(payload, ctx);
5269 + if (def.unionFallback) return _super(payload, ctx);
5270 + payload.issues.push({
5271 + code: "invalid_union",
5272 + errors: [],
5273 + note: "No matching discriminator",
5274 + input,
5275 + path: [def.discriminator],
5276 + inst
5277 + });
5278 + return payload;
5279 + };
5280 + });
5281 + var $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def) => {
5282 + $ZodType.init(inst, def);
5283 + inst._zod.parse = (payload, ctx) => {
5284 + const input = payload.value;
5285 + const left = def.left._zod.run({
5286 + value: input,
5287 + issues: []
5288 + }, ctx);
5289 + const right = def.right._zod.run({
5290 + value: input,
5291 + issues: []
5292 + }, ctx);
5293 + if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left, right]) => {
5294 + return handleIntersectionResults(payload, left, right);
5295 + });
5296 + return handleIntersectionResults(payload, left, right);
5297 + };
5298 + });
5299 + function mergeValues(a, b) {
5300 + if (a === b) return {
5301 + valid: true,
5302 + data: a
5303 + };
5304 + if (a instanceof Date && b instanceof Date && +a === +b) return {
5305 + valid: true,
5306 + data: a
5307 + };
5308 + if (isPlainObject$1(a) && isPlainObject$1(b)) {
5309 + const bKeys = Object.keys(b);
5310 + const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
5311 + const newObj = {
5312 + ...a,
5313 + ...b
5314 + };
5315 + for (const key of sharedKeys) {
5316 + const sharedValue = mergeValues(a[key], b[key]);
5317 + if (!sharedValue.valid) return {
5318 + valid: false,
5319 + mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
5320 + };
5321 + newObj[key] = sharedValue.data;
5322 + }
5323 + return {
5324 + valid: true,
5325 + data: newObj
5326 + };
5327 + }
5328 + if (Array.isArray(a) && Array.isArray(b)) {
5329 + if (a.length !== b.length) return {
5330 + valid: false,
5331 + mergeErrorPath: []
5332 + };
5333 + const newArray = [];
5334 + for (let index = 0; index < a.length; index++) {
5335 + const itemA = a[index];
5336 + const itemB = b[index];
5337 + const sharedValue = mergeValues(itemA, itemB);
5338 + if (!sharedValue.valid) return {
5339 + valid: false,
5340 + mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
5341 + };
5342 + newArray.push(sharedValue.data);
5343 + }
5344 + return {
5345 + valid: true,
5346 + data: newArray
5347 + };
5348 + }
5349 + return {
5350 + valid: false,
5351 + mergeErrorPath: []
5352 + };
5353 + }
5354 + function handleIntersectionResults(result, left, right) {
5355 + if (left.issues.length) result.issues.push(...left.issues);
5356 + if (right.issues.length) result.issues.push(...right.issues);
5357 + if (aborted(result)) return result;
5358 + const merged = mergeValues(left.value, right.value);
5359 + if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
5360 + result.value = merged.data;
5361 + return result;
5362 + }
5363 + var $ZodRecord = /*@__PURE__*/ $constructor("$ZodRecord", (inst, def) => {
5364 + $ZodType.init(inst, def);
5365 + inst._zod.parse = (payload, ctx) => {
5366 + const input = payload.value;
5367 + if (!isPlainObject$1(input)) {
5368 + payload.issues.push({
5369 + expected: "record",
5370 + code: "invalid_type",
5371 + input,
5372 + inst
5373 + });
5374 + return payload;
5375 + }
5376 + const proms = [];
5377 + if (def.keyType._zod.values) {
5378 + const values = def.keyType._zod.values;
5379 + payload.value = {};
5380 + for (const key of values) if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
5381 + const result = def.valueType._zod.run({
5382 + value: input[key],
5383 + issues: []
5384 + }, ctx);
5385 + if (result instanceof Promise) proms.push(result.then((result) => {
5386 + if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
5387 + payload.value[key] = result.value;
5388 + }));
5389 + else {
5390 + if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
5391 + payload.value[key] = result.value;
5392 + }
5393 + }
5394 + let unrecognized;
5395 + for (const key in input) if (!values.has(key)) {
5396 + unrecognized = unrecognized ?? [];
5397 + unrecognized.push(key);
5398 + }
5399 + if (unrecognized && unrecognized.length > 0) payload.issues.push({
5400 + code: "unrecognized_keys",
5401 + input,
5402 + inst,
5403 + keys: unrecognized
5404 + });
5405 + } else {
5406 + payload.value = {};
5407 + for (const key of Reflect.ownKeys(input)) {
5408 + if (key === "__proto__") continue;
5409 + const keyResult = def.keyType._zod.run({
5410 + value: key,
5411 + issues: []
5412 + }, ctx);
5413 + if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
5414 + if (keyResult.issues.length) {
5415 + payload.issues.push({
5416 + origin: "record",
5417 + code: "invalid_key",
5418 + issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
5419 + input: key,
5420 + path: [key],
5421 + inst
5422 + });
5423 + payload.value[keyResult.value] = keyResult.value;
5424 + continue;
5425 + }
5426 + const result = def.valueType._zod.run({
5427 + value: input[key],
5428 + issues: []
5429 + }, ctx);
5430 + if (result instanceof Promise) proms.push(result.then((result) => {
5431 + if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
5432 + payload.value[keyResult.value] = result.value;
5433 + }));
5434 + else {
5435 + if (result.issues.length) payload.issues.push(...prefixIssues(key, result.issues));
5436 + payload.value[keyResult.value] = result.value;
5437 + }
5438 + }
5439 + }
5440 + if (proms.length) return Promise.all(proms).then(() => payload);
5441 + return payload;
5442 + };
5443 + });
5444 + var $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
5445 + $ZodType.init(inst, def);
5446 + const values = getEnumValues(def.entries);
5447 + inst._zod.values = new Set(values);
5448 + inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
5449 + inst._zod.parse = (payload, _ctx) => {
5450 + const input = payload.value;
5451 + if (inst._zod.values.has(input)) return payload;
5452 + payload.issues.push({
5453 + code: "invalid_value",
5454 + values,
5455 + input,
5456 + inst
5457 + });
5458 + return payload;
5459 + };
5460 + });
5461 + var $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
5462 + $ZodType.init(inst, def);
5463 + inst._zod.values = new Set(def.values);
5464 + inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? o.toString() : String(o)).join("|")})$`);
5465 + inst._zod.parse = (payload, _ctx) => {
5466 + const input = payload.value;
5467 + if (inst._zod.values.has(input)) return payload;
5468 + payload.issues.push({
5469 + code: "invalid_value",
5470 + values: def.values,
5471 + input,
5472 + inst
5473 + });
5474 + return payload;
5475 + };
5476 + });
5477 + var $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
5478 + $ZodType.init(inst, def);
5479 + inst._zod.parse = (payload, _ctx) => {
5480 + const _out = def.transform(payload.value, payload);
5481 + if (_ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
5482 + payload.value = output;
5483 + return payload;
5484 + });
5485 + if (_out instanceof Promise) throw new $ZodAsyncError();
5486 + payload.value = _out;
5487 + return payload;
5488 + };
5489 + });
5490 + var $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
5491 + $ZodType.init(inst, def);
5492 + inst._zod.optin = "optional";
5493 + inst._zod.optout = "optional";
5494 + defineLazy(inst._zod, "values", () => {
5495 + return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
5496 + });
5497 + defineLazy(inst._zod, "pattern", () => {
5498 + const pattern = def.innerType._zod.pattern;
5499 + return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
5500 + });
5501 + inst._zod.parse = (payload, ctx) => {
5502 + if (def.innerType._zod.optin === "optional") return def.innerType._zod.run(payload, ctx);
5503 + if (payload.value === void 0) return payload;
5504 + return def.innerType._zod.run(payload, ctx);
5505 + };
5506 + });
5507 + var $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
5508 + $ZodType.init(inst, def);
5509 + defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
5510 + defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
5511 + defineLazy(inst._zod, "pattern", () => {
5512 + const pattern = def.innerType._zod.pattern;
5513 + return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
5514 + });
5515 + defineLazy(inst._zod, "values", () => {
5516 + return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
5517 + });
5518 + inst._zod.parse = (payload, ctx) => {
5519 + if (payload.value === null) return payload;
5520 + return def.innerType._zod.run(payload, ctx);
5521 + };
5522 + });
5523 + var $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
5524 + $ZodType.init(inst, def);
5525 + inst._zod.optin = "optional";
5526 + defineLazy(inst._zod, "values", () => def.innerType._zod.values);
5527 + inst._zod.parse = (payload, ctx) => {
5528 + if (payload.value === void 0) {
5529 + payload.value = def.defaultValue;
5530 + /**
5531 + * $ZodDefault always returns the default value immediately.
5532 + * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
5533 + return payload;
5534 + }
5535 + const result = def.innerType._zod.run(payload, ctx);
5536 + if (result instanceof Promise) return result.then((result) => handleDefaultResult(result, def));
5537 + return handleDefaultResult(result, def);
5538 + };
5539 + });
5540 + function handleDefaultResult(payload, def) {
5541 + if (payload.value === void 0) payload.value = def.defaultValue;
5542 + return payload;
5543 + }
5544 + var $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
5545 + $ZodType.init(inst, def);
5546 + inst._zod.optin = "optional";
5547 + defineLazy(inst._zod, "values", () => def.innerType._zod.values);
5548 + inst._zod.parse = (payload, ctx) => {
5549 + if (payload.value === void 0) payload.value = def.defaultValue;
5550 + return def.innerType._zod.run(payload, ctx);
5551 + };
5552 + });
5553 + var $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
5554 + $ZodType.init(inst, def);
5555 + defineLazy(inst._zod, "values", () => {
5556 + const v = def.innerType._zod.values;
5557 + return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
5558 + });
5559 + inst._zod.parse = (payload, ctx) => {
5560 + const result = def.innerType._zod.run(payload, ctx);
5561 + if (result instanceof Promise) return result.then((result) => handleNonOptionalResult(result, inst));
5562 + return handleNonOptionalResult(result, inst);
5563 + };
5564 + });
5565 + function handleNonOptionalResult(payload, inst) {
5566 + if (!payload.issues.length && payload.value === void 0) payload.issues.push({
5567 + code: "invalid_type",
5568 + expected: "nonoptional",
5569 + input: payload.value,
5570 + inst
5571 + });
5572 + return payload;
5573 + }
5574 + var $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
5575 + $ZodType.init(inst, def);
5576 + inst._zod.optin = "optional";
5577 + defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
5578 + defineLazy(inst._zod, "values", () => def.innerType._zod.values);
5579 + inst._zod.parse = (payload, ctx) => {
5580 + const result = def.innerType._zod.run(payload, ctx);
5581 + if (result instanceof Promise) return result.then((result) => {
5582 + payload.value = result.value;
5583 + if (result.issues.length) {
5584 + payload.value = def.catchValue({
5585 + ...payload,
5586 + error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
5587 + input: payload.value
5588 + });
5589 + payload.issues = [];
5590 + }
5591 + return payload;
5592 + });
5593 + payload.value = result.value;
5594 + if (result.issues.length) {
5595 + payload.value = def.catchValue({
5596 + ...payload,
5597 + error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
5598 + input: payload.value
5599 + });
5600 + payload.issues = [];
5601 + }
5602 + return payload;
5603 + };
5604 + });
5605 + var $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
5606 + $ZodType.init(inst, def);
5607 + defineLazy(inst._zod, "values", () => def.in._zod.values);
5608 + defineLazy(inst._zod, "optin", () => def.in._zod.optin);
5609 + defineLazy(inst._zod, "optout", () => def.out._zod.optout);
5610 + inst._zod.parse = (payload, ctx) => {
5611 + const left = def.in._zod.run(payload, ctx);
5612 + if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def, ctx));
5613 + return handlePipeResult(left, def, ctx);
5614 + };
5615 + });
5616 + function handlePipeResult(left, def, ctx) {
5617 + if (aborted(left)) return left;
5618 + return def.out._zod.run({
5619 + value: left.value,
5620 + issues: left.issues
5621 + }, ctx);
5622 + }
5623 + var $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
5624 + $ZodType.init(inst, def);
5625 + defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
5626 + defineLazy(inst._zod, "values", () => def.innerType._zod.values);
5627 + defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
5628 + defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
5629 + inst._zod.parse = (payload, ctx) => {
5630 + const result = def.innerType._zod.run(payload, ctx);
5631 + if (result instanceof Promise) return result.then(handleReadonlyResult);
5632 + return handleReadonlyResult(result);
5633 + };
5634 + });
5635 + function handleReadonlyResult(payload) {
5636 + payload.value = Object.freeze(payload.value);
5637 + return payload;
5638 + }
5639 + var $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
5640 + $ZodCheck.init(inst, def);
5641 + $ZodType.init(inst, def);
5642 + inst._zod.parse = (payload, _) => {
5643 + return payload;
5644 + };
5645 + inst._zod.check = (payload) => {
5646 + const input = payload.value;
5647 + const r = def.fn(input);
5648 + if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
5649 + handleRefineResult(r, payload, input, inst);
5650 + };
5651 + });
5652 + function handleRefineResult(result, payload, input, inst) {
5653 + if (!result) {
5654 + const _iss = {
5655 + code: "custom",
5656 + input,
5657 + inst,
5658 + path: [...inst._zod.def.path ?? []],
5659 + continue: !inst._zod.def.abort
5660 + };
5661 + if (inst._zod.def.params) _iss.params = inst._zod.def.params;
5662 + payload.issues.push(issue(_iss));
5663 + }
5664 + }
5665 +
5666 +//#endregion
5667 +//#region node_modules/zod/v4/core/registries.js
5668 + var $ZodRegistry = class {
5669 + constructor() {
5670 + this._map = /* @__PURE__ */ new Map();
5671 + this._idmap = /* @__PURE__ */ new Map();
5672 + }
5673 + add(schema, ..._meta) {
5674 + const meta = _meta[0];
5675 + this._map.set(schema, meta);
5676 + if (meta && typeof meta === "object" && "id" in meta) {
5677 + if (this._idmap.has(meta.id)) throw new Error(`ID ${meta.id} already exists in the registry`);
5678 + this._idmap.set(meta.id, schema);
5679 + }
5680 + return this;
5681 + }
5682 + clear() {
5683 + this._map = /* @__PURE__ */ new Map();
5684 + this._idmap = /* @__PURE__ */ new Map();
5685 + return this;
5686 + }
5687 + remove(schema) {
5688 + const meta = this._map.get(schema);
5689 + if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
5690 + this._map.delete(schema);
5691 + return this;
5692 + }
5693 + get(schema) {
5694 + const p = schema._zod.parent;
5695 + if (p) {
5696 + const pm = { ...this.get(p) ?? {} };
5697 + delete pm.id;
5698 + return {
5699 + ...pm,
5700 + ...this._map.get(schema)
5701 + };
5702 + }
5703 + return this._map.get(schema);
5704 + }
5705 + has(schema) {
5706 + return this._map.has(schema);
5707 + }
5708 + };
5709 + function registry() {
5710 + return new $ZodRegistry();
5711 + }
5712 + var globalRegistry = /*@__PURE__*/ registry();
5713 +
5714 +//#endregion
5715 +//#region node_modules/zod/v4/core/api.js
5716 + function _string(Class, params) {
5717 + return new Class({
5718 + type: "string",
5719 + ...normalizeParams(params)
5720 + });
5721 + }
5722 + function _email(Class, params) {
5723 + return new Class({
5724 + type: "string",
5725 + format: "email",
5726 + check: "string_format",
5727 + abort: false,
5728 + ...normalizeParams(params)
5729 + });
5730 + }
5731 + function _guid(Class, params) {
5732 + return new Class({
5733 + type: "string",
5734 + format: "guid",
5735 + check: "string_format",
5736 + abort: false,
5737 + ...normalizeParams(params)
5738 + });
5739 + }
5740 + function _uuid(Class, params) {
5741 + return new Class({
5742 + type: "string",
5743 + format: "uuid",
5744 + check: "string_format",
5745 + abort: false,
5746 + ...normalizeParams(params)
5747 + });
5748 + }
5749 + function _uuidv4(Class, params) {
5750 + return new Class({
5751 + type: "string",
5752 + format: "uuid",
5753 + check: "string_format",
5754 + abort: false,
5755 + version: "v4",
5756 + ...normalizeParams(params)
5757 + });
5758 + }
5759 + function _uuidv6(Class, params) {
5760 + return new Class({
5761 + type: "string",
5762 + format: "uuid",
5763 + check: "string_format",
5764 + abort: false,
5765 + version: "v6",
5766 + ...normalizeParams(params)
5767 + });
5768 + }
5769 + function _uuidv7(Class, params) {
5770 + return new Class({
5771 + type: "string",
5772 + format: "uuid",
5773 + check: "string_format",
5774 + abort: false,
5775 + version: "v7",
5776 + ...normalizeParams(params)
5777 + });
5778 + }
5779 + function _url(Class, params) {
5780 + return new Class({
5781 + type: "string",
5782 + format: "url",
5783 + check: "string_format",
5784 + abort: false,
5785 + ...normalizeParams(params)
5786 + });
5787 + }
5788 + function _emoji(Class, params) {
5789 + return new Class({
5790 + type: "string",
5791 + format: "emoji",
5792 + check: "string_format",
5793 + abort: false,
5794 + ...normalizeParams(params)
5795 + });
5796 + }
5797 + function _nanoid(Class, params) {
5798 + return new Class({
5799 + type: "string",
5800 + format: "nanoid",
5801 + check: "string_format",
5802 + abort: false,
5803 + ...normalizeParams(params)
5804 + });
5805 + }
5806 + function _cuid(Class, params) {
5807 + return new Class({
5808 + type: "string",
5809 + format: "cuid",
5810 + check: "string_format",
5811 + abort: false,
5812 + ...normalizeParams(params)
5813 + });
5814 + }
5815 + function _cuid2(Class, params) {
5816 + return new Class({
5817 + type: "string",
5818 + format: "cuid2",
5819 + check: "string_format",
5820 + abort: false,
5821 + ...normalizeParams(params)
5822 + });
5823 + }
5824 + function _ulid(Class, params) {
5825 + return new Class({
5826 + type: "string",
5827 + format: "ulid",
5828 + check: "string_format",
5829 + abort: false,
5830 + ...normalizeParams(params)
5831 + });
5832 + }
5833 + function _xid(Class, params) {
5834 + return new Class({
5835 + type: "string",
5836 + format: "xid",
5837 + check: "string_format",
5838 + abort: false,
5839 + ...normalizeParams(params)
5840 + });
5841 + }
5842 + function _ksuid(Class, params) {
5843 + return new Class({
5844 + type: "string",
5845 + format: "ksuid",
5846 + check: "string_format",
5847 + abort: false,
5848 + ...normalizeParams(params)
5849 + });
5850 + }
5851 + function _ipv4(Class, params) {
5852 + return new Class({
5853 + type: "string",
5854 + format: "ipv4",
5855 + check: "string_format",
5856 + abort: false,
5857 + ...normalizeParams(params)
5858 + });
5859 + }
5860 + function _ipv6(Class, params) {
5861 + return new Class({
5862 + type: "string",
5863 + format: "ipv6",
5864 + check: "string_format",
5865 + abort: false,
5866 + ...normalizeParams(params)
5867 + });
5868 + }
5869 + function _cidrv4(Class, params) {
5870 + return new Class({
5871 + type: "string",
5872 + format: "cidrv4",
5873 + check: "string_format",
5874 + abort: false,
5875 + ...normalizeParams(params)
5876 + });
5877 + }
5878 + function _cidrv6(Class, params) {
5879 + return new Class({
5880 + type: "string",
5881 + format: "cidrv6",
5882 + check: "string_format",
5883 + abort: false,
5884 + ...normalizeParams(params)
5885 + });
5886 + }
5887 + function _base64(Class, params) {
5888 + return new Class({
5889 + type: "string",
5890 + format: "base64",
5891 + check: "string_format",
5892 + abort: false,
5893 + ...normalizeParams(params)
5894 + });
5895 + }
5896 + function _base64url(Class, params) {
5897 + return new Class({
5898 + type: "string",
5899 + format: "base64url",
5900 + check: "string_format",
5901 + abort: false,
5902 + ...normalizeParams(params)
5903 + });
5904 + }
5905 + function _e164(Class, params) {
5906 + return new Class({
5907 + type: "string",
5908 + format: "e164",
5909 + check: "string_format",
5910 + abort: false,
5911 + ...normalizeParams(params)
5912 + });
5913 + }
5914 + function _jwt(Class, params) {
5915 + return new Class({
5916 + type: "string",
5917 + format: "jwt",
5918 + check: "string_format",
5919 + abort: false,
5920 + ...normalizeParams(params)
5921 + });
5922 + }
5923 + function _isoDateTime(Class, params) {
5924 + return new Class({
5925 + type: "string",
5926 + format: "datetime",
5927 + check: "string_format",
5928 + offset: false,
5929 + local: false,
5930 + precision: null,
5931 + ...normalizeParams(params)
5932 + });
5933 + }
5934 + function _isoDate(Class, params) {
5935 + return new Class({
5936 + type: "string",
5937 + format: "date",
5938 + check: "string_format",
5939 + ...normalizeParams(params)
5940 + });
5941 + }
5942 + function _isoTime(Class, params) {
5943 + return new Class({
5944 + type: "string",
5945 + format: "time",
5946 + check: "string_format",
5947 + precision: null,
5948 + ...normalizeParams(params)
5949 + });
5950 + }
5951 + function _isoDuration(Class, params) {
5952 + return new Class({
5953 + type: "string",
5954 + format: "duration",
5955 + check: "string_format",
5956 + ...normalizeParams(params)
5957 + });
5958 + }
5959 + function _number(Class, params) {
5960 + return new Class({
5961 + type: "number",
5962 + checks: [],
5963 + ...normalizeParams(params)
5964 + });
5965 + }
5966 + function _int(Class, params) {
5967 + return new Class({
5968 + type: "number",
5969 + check: "number_format",
5970 + abort: false,
5971 + format: "safeint",
5972 + ...normalizeParams(params)
5973 + });
5974 + }
5975 + function _boolean(Class, params) {
5976 + return new Class({
5977 + type: "boolean",
5978 + ...normalizeParams(params)
5979 + });
5980 + }
5981 + function _null$1(Class, params) {
5982 + return new Class({
5983 + type: "null",
5984 + ...normalizeParams(params)
5985 + });
5986 + }
5987 + __name(_null$1, "_null");
5988 + function _unknown(Class) {
5989 + return new Class({ type: "unknown" });
5990 + }
5991 + function _never(Class, params) {
5992 + return new Class({
5993 + type: "never",
5994 + ...normalizeParams(params)
5995 + });
5996 + }
5997 + function _lt(value, params) {
5998 + return new $ZodCheckLessThan({
5999 + check: "less_than",
6000 + ...normalizeParams(params),
6001 + value,
6002 + inclusive: false
6003 + });
6004 + }
6005 + function _lte(value, params) {
6006 + return new $ZodCheckLessThan({
6007 + check: "less_than",
6008 + ...normalizeParams(params),
6009 + value,
6010 + inclusive: true
6011 + });
6012 + }
6013 + function _gt(value, params) {
6014 + return new $ZodCheckGreaterThan({
6015 + check: "greater_than",
6016 + ...normalizeParams(params),
6017 + value,
6018 + inclusive: false
6019 + });
6020 + }
6021 + function _gte(value, params) {
6022 + return new $ZodCheckGreaterThan({
6023 + check: "greater_than",
6024 + ...normalizeParams(params),
6025 + value,
6026 + inclusive: true
6027 + });
6028 + }
6029 + function _multipleOf(value, params) {
6030 + return new $ZodCheckMultipleOf({
6031 + check: "multiple_of",
6032 + ...normalizeParams(params),
6033 + value
6034 + });
6035 + }
6036 + function _maxLength(maximum, params) {
6037 + return new $ZodCheckMaxLength({
6038 + check: "max_length",
6039 + ...normalizeParams(params),
6040 + maximum
6041 + });
6042 + }
6043 + function _minLength(minimum, params) {
6044 + return new $ZodCheckMinLength({
6045 + check: "min_length",
6046 + ...normalizeParams(params),
6047 + minimum
6048 + });
6049 + }
6050 + function _length(length, params) {
6051 + return new $ZodCheckLengthEquals({
6052 + check: "length_equals",
6053 + ...normalizeParams(params),
6054 + length
6055 + });
6056 + }
6057 + function _regex(pattern, params) {
6058 + return new $ZodCheckRegex({
6059 + check: "string_format",
6060 + format: "regex",
6061 + ...normalizeParams(params),
6062 + pattern
6063 + });
6064 + }
6065 + function _lowercase(params) {
6066 + return new $ZodCheckLowerCase({
6067 + check: "string_format",
6068 + format: "lowercase",
6069 + ...normalizeParams(params)
6070 + });
6071 + }
6072 + function _uppercase(params) {
6073 + return new $ZodCheckUpperCase({
6074 + check: "string_format",
6075 + format: "uppercase",
6076 + ...normalizeParams(params)
6077 + });
6078 + }
6079 + function _includes(includes, params) {
6080 + return new $ZodCheckIncludes({
6081 + check: "string_format",
6082 + format: "includes",
6083 + ...normalizeParams(params),
6084 + includes
6085 + });
6086 + }
6087 + function _startsWith(prefix, params) {
6088 + return new $ZodCheckStartsWith({
6089 + check: "string_format",
6090 + format: "starts_with",
6091 + ...normalizeParams(params),
6092 + prefix
6093 + });
6094 + }
6095 + function _endsWith(suffix, params) {
6096 + return new $ZodCheckEndsWith({
6097 + check: "string_format",
6098 + format: "ends_with",
6099 + ...normalizeParams(params),
6100 + suffix
6101 + });
6102 + }
6103 + function _overwrite(tx) {
6104 + return new $ZodCheckOverwrite({
6105 + check: "overwrite",
6106 + tx
6107 + });
6108 + }
6109 + function _normalize(form) {
6110 + return _overwrite((input) => input.normalize(form));
6111 + }
6112 + function _trim() {
6113 + return _overwrite((input) => input.trim());
6114 + }
6115 + function _toLowerCase() {
6116 + return _overwrite((input) => input.toLowerCase());
6117 + }
6118 + function _toUpperCase() {
6119 + return _overwrite((input) => input.toUpperCase());
6120 + }
6121 + function _array(Class, element, params) {
6122 + return new Class({
6123 + type: "array",
6124 + element,
6125 + ...normalizeParams(params)
6126 + });
6127 + }
6128 + function _custom(Class, fn, _params) {
6129 + const norm = normalizeParams(_params);
6130 + norm.abort ?? (norm.abort = true);
6131 + return new Class({
6132 + type: "custom",
6133 + check: "custom",
6134 + fn,
6135 + ...norm
6136 + });
6137 + }
6138 + function _refine(Class, fn, _params) {
6139 + return new Class({
6140 + type: "custom",
6141 + check: "custom",
6142 + fn,
6143 + ...normalizeParams(_params)
6144 + });
6145 + }
6146 +
6147 +//#endregion
6148 +//#region node_modules/zod/v4/core/to-json-schema.js
6149 + var JSONSchemaGenerator = class {
6150 + constructor(params) {
6151 + this.counter = 0;
6152 + this.metadataRegistry = params?.metadata ?? globalRegistry;
6153 + this.target = params?.target ?? "draft-2020-12";
6154 + this.unrepresentable = params?.unrepresentable ?? "throw";
6155 + this.override = params?.override ?? (() => {});
6156 + this.io = params?.io ?? "output";
6157 + this.seen = /* @__PURE__ */ new Map();
6158 + }
6159 + process(schema, _params = {
6160 + path: [],
6161 + schemaPath: []
6162 + }) {
6163 + var _a;
6164 + const def = schema._zod.def;
6165 + const formatMap = {
6166 + guid: "uuid",
6167 + url: "uri",
6168 + datetime: "date-time",
6169 + json_string: "json-string",
6170 + regex: ""
6171 + };
6172 + const seen = this.seen.get(schema);
6173 + if (seen) {
6174 + seen.count++;
6175 + if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
6176 + return seen.schema;
6177 + }
6178 + const result = {
6179 + schema: {},
6180 + count: 1,
6181 + cycle: void 0,
6182 + path: _params.path
6183 + };
6184 + this.seen.set(schema, result);
6185 + const overrideSchema = schema._zod.toJSONSchema?.();
6186 + if (overrideSchema) result.schema = overrideSchema;
6187 + else {
6188 + const params = {
6189 + ..._params,
6190 + schemaPath: [..._params.schemaPath, schema],
6191 + path: _params.path
6192 + };
6193 + const parent = schema._zod.parent;
6194 + if (parent) {
6195 + result.ref = parent;
6196 + this.process(parent, params);
6197 + this.seen.get(parent).isParent = true;
6198 + } else {
6199 + const _json = result.schema;
6200 + switch (def.type) {
6201 + case "string": {
6202 + const json = _json;
6203 + json.type = "string";
6204 + const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
6205 + if (typeof minimum === "number") json.minLength = minimum;
6206 + if (typeof maximum === "number") json.maxLength = maximum;
6207 + if (format) {
6208 + json.format = formatMap[format] ?? format;
6209 + if (json.format === "") delete json.format;
6210 + }
6211 + if (contentEncoding) json.contentEncoding = contentEncoding;
6212 + if (patterns && patterns.size > 0) {
6213 + const regexes = [...patterns];
6214 + if (regexes.length === 1) json.pattern = regexes[0].source;
6215 + else if (regexes.length > 1) result.schema.allOf = [...regexes.map((regex) => ({
6216 + ...this.target === "draft-7" ? { type: "string" } : {},
6217 + pattern: regex.source
6218 + }))];
6219 + }
6220 + break;
6221 + }
6222 + case "number": {
6223 + const json = _json;
6224 + const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
6225 + if (typeof format === "string" && format.includes("int")) json.type = "integer";
6226 + else json.type = "number";
6227 + if (typeof exclusiveMinimum === "number") json.exclusiveMinimum = exclusiveMinimum;
6228 + if (typeof minimum === "number") {
6229 + json.minimum = minimum;
6230 + if (typeof exclusiveMinimum === "number") if (exclusiveMinimum >= minimum) delete json.minimum;
6231 + else delete json.exclusiveMinimum;
6232 + }
6233 + if (typeof exclusiveMaximum === "number") json.exclusiveMaximum = exclusiveMaximum;
6234 + if (typeof maximum === "number") {
6235 + json.maximum = maximum;
6236 + if (typeof exclusiveMaximum === "number") if (exclusiveMaximum <= maximum) delete json.maximum;
6237 + else delete json.exclusiveMaximum;
6238 + }
6239 + if (typeof multipleOf === "number") json.multipleOf = multipleOf;
6240 + break;
6241 + }
6242 + case "boolean": {
6243 + const json = _json;
6244 + json.type = "boolean";
6245 + break;
6246 + }
6247 + case "bigint":
6248 + if (this.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
6249 + break;
6250 + case "symbol":
6251 + if (this.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
6252 + break;
6253 + case "null":
6254 + _json.type = "null";
6255 + break;
6256 + case "any": break;
6257 + case "unknown": break;
6258 + case "undefined":
6259 + if (this.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
6260 + break;
6261 + case "void":
6262 + if (this.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
6263 + break;
6264 + case "never":
6265 + _json.not = {};
6266 + break;
6267 + case "date":
6268 + if (this.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
6269 + break;
6270 + case "array": {
6271 + const json = _json;
6272 + const { minimum, maximum } = schema._zod.bag;
6273 + if (typeof minimum === "number") json.minItems = minimum;
6274 + if (typeof maximum === "number") json.maxItems = maximum;
6275 + json.type = "array";
6276 + json.items = this.process(def.element, {
6277 + ...params,
6278 + path: [...params.path, "items"]
6279 + });
6280 + break;
6281 + }
6282 + case "object": {
6283 + const json = _json;
6284 + json.type = "object";
6285 + json.properties = {};
6286 + const shape = def.shape;
6287 + for (const key in shape) json.properties[key] = this.process(shape[key], {
6288 + ...params,
6289 + path: [
6290 + ...params.path,
6291 + "properties",
6292 + key
6293 + ]
6294 + });
6295 + const allKeys = new Set(Object.keys(shape));
6296 + const requiredKeys = new Set([...allKeys].filter((key) => {
6297 + const v = def.shape[key]._zod;
6298 + if (this.io === "input") return v.optin === void 0;
6299 + else return v.optout === void 0;
6300 + }));
6301 + if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
6302 + if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
6303 + else if (!def.catchall) {
6304 + if (this.io === "output") json.additionalProperties = false;
6305 + } else if (def.catchall) json.additionalProperties = this.process(def.catchall, {
6306 + ...params,
6307 + path: [...params.path, "additionalProperties"]
6308 + });
6309 + break;
6310 + }
6311 + case "union": {
6312 + const json = _json;
6313 + json.anyOf = def.options.map((x, i) => this.process(x, {
6314 + ...params,
6315 + path: [
6316 + ...params.path,
6317 + "anyOf",
6318 + i
6319 + ]
6320 + }));
6321 + break;
6322 + }
6323 + case "intersection": {
6324 + const json = _json;
6325 + const a = this.process(def.left, {
6326 + ...params,
6327 + path: [
6328 + ...params.path,
6329 + "allOf",
6330 + 0
6331 + ]
6332 + });
6333 + const b = this.process(def.right, {
6334 + ...params,
6335 + path: [
6336 + ...params.path,
6337 + "allOf",
6338 + 1
6339 + ]
6340 + });
6341 + const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
6342 + json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
6343 + break;
6344 + }
6345 + case "tuple": {
6346 + const json = _json;
6347 + json.type = "array";
6348 + const prefixItems = def.items.map((x, i) => this.process(x, {
6349 + ...params,
6350 + path: [
6351 + ...params.path,
6352 + "prefixItems",
6353 + i
6354 + ]
6355 + }));
6356 + if (this.target === "draft-2020-12") json.prefixItems = prefixItems;
6357 + else json.items = prefixItems;
6358 + if (def.rest) {
6359 + const rest = this.process(def.rest, {
6360 + ...params,
6361 + path: [...params.path, "items"]
6362 + });
6363 + if (this.target === "draft-2020-12") json.items = rest;
6364 + else json.additionalItems = rest;
6365 + }
6366 + if (def.rest) json.items = this.process(def.rest, {
6367 + ...params,
6368 + path: [...params.path, "items"]
6369 + });
6370 + const { minimum, maximum } = schema._zod.bag;
6371 + if (typeof minimum === "number") json.minItems = minimum;
6372 + if (typeof maximum === "number") json.maxItems = maximum;
6373 + break;
6374 + }
6375 + case "record": {
6376 + const json = _json;
6377 + json.type = "object";
6378 + json.propertyNames = this.process(def.keyType, {
6379 + ...params,
6380 + path: [...params.path, "propertyNames"]
6381 + });
6382 + json.additionalProperties = this.process(def.valueType, {
6383 + ...params,
6384 + path: [...params.path, "additionalProperties"]
6385 + });
6386 + break;
6387 + }
6388 + case "map":
6389 + if (this.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
6390 + break;
6391 + case "set":
6392 + if (this.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
6393 + break;
6394 + case "enum": {
6395 + const json = _json;
6396 + const values = getEnumValues(def.entries);
6397 + if (values.every((v) => typeof v === "number")) json.type = "number";
6398 + if (values.every((v) => typeof v === "string")) json.type = "string";
6399 + json.enum = values;
6400 + break;
6401 + }
6402 + case "literal": {
6403 + const json = _json;
6404 + const vals = [];
6405 + for (const val of def.values) if (val === void 0) {
6406 + if (this.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
6407 + } else if (typeof val === "bigint") if (this.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
6408 + else vals.push(Number(val));
6409 + else vals.push(val);
6410 + if (vals.length === 0) {} else if (vals.length === 1) {
6411 + const val = vals[0];
6412 + json.type = val === null ? "null" : typeof val;
6413 + json.const = val;
6414 + } else {
6415 + if (vals.every((v) => typeof v === "number")) json.type = "number";
6416 + if (vals.every((v) => typeof v === "string")) json.type = "string";
6417 + if (vals.every((v) => typeof v === "boolean")) json.type = "string";
6418 + if (vals.every((v) => v === null)) json.type = "null";
6419 + json.enum = vals;
6420 + }
6421 + break;
6422 + }
6423 + case "file": {
6424 + const json = _json;
6425 + const file = {
6426 + type: "string",
6427 + format: "binary",
6428 + contentEncoding: "binary"
6429 + };
6430 + const { minimum, maximum, mime } = schema._zod.bag;
6431 + if (minimum !== void 0) file.minLength = minimum;
6432 + if (maximum !== void 0) file.maxLength = maximum;
6433 + if (mime) if (mime.length === 1) {
6434 + file.contentMediaType = mime[0];
6435 + Object.assign(json, file);
6436 + } else json.anyOf = mime.map((m) => {
6437 + return {
6438 + ...file,
6439 + contentMediaType: m
6440 + };
6441 + });
6442 + else Object.assign(json, file);
6443 + break;
6444 + }
6445 + case "transform":
6446 + if (this.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
6447 + break;
6448 + case "nullable":
6449 + _json.anyOf = [this.process(def.innerType, params), { type: "null" }];
6450 + break;
6451 + case "nonoptional":
6452 + this.process(def.innerType, params);
6453 + result.ref = def.innerType;
6454 + break;
6455 + case "success": {
6456 + const json = _json;
6457 + json.type = "boolean";
6458 + break;
6459 + }
6460 + case "default":
6461 + this.process(def.innerType, params);
6462 + result.ref = def.innerType;
6463 + _json.default = JSON.parse(JSON.stringify(def.defaultValue));
6464 + break;
6465 + case "prefault":
6466 + this.process(def.innerType, params);
6467 + result.ref = def.innerType;
6468 + if (this.io === "input") _json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
6469 + break;
6470 + case "catch": {
6471 + this.process(def.innerType, params);
6472 + result.ref = def.innerType;
6473 + let catchValue;
6474 + try {
6475 + catchValue = def.catchValue(void 0);
6476 + } catch {
6477 + throw new Error("Dynamic catch values are not supported in JSON Schema");
6478 + }
6479 + _json.default = catchValue;
6480 + break;
6481 + }
6482 + case "nan":
6483 + if (this.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
6484 + break;
6485 + case "template_literal": {
6486 + const json = _json;
6487 + const pattern = schema._zod.pattern;
6488 + if (!pattern) throw new Error("Pattern not found in template literal");
6489 + json.type = "string";
6490 + json.pattern = pattern.source;
6491 + break;
6492 + }
6493 + case "pipe": {
6494 + const innerType = this.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
6495 + this.process(innerType, params);
6496 + result.ref = innerType;
6497 + break;
6498 + }
6499 + case "readonly":
6500 + this.process(def.innerType, params);
6501 + result.ref = def.innerType;
6502 + _json.readOnly = true;
6503 + break;
6504 + case "promise":
6505 + this.process(def.innerType, params);
6506 + result.ref = def.innerType;
6507 + break;
6508 + case "optional":
6509 + this.process(def.innerType, params);
6510 + result.ref = def.innerType;
6511 + break;
6512 + case "lazy": {
6513 + const innerType = schema._zod.innerType;
6514 + this.process(innerType, params);
6515 + result.ref = innerType;
6516 + break;
6517 + }
6518 + case "custom":
6519 + if (this.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
6520 + break;
6521 + default:
6522 + }
6523 + }
6524 + }
6525 + const meta = this.metadataRegistry.get(schema);
6526 + if (meta) Object.assign(result.schema, meta);
6527 + if (this.io === "input" && isTransforming(schema)) {
6528 + delete result.schema.examples;
6529 + delete result.schema.default;
6530 + }
6531 + if (this.io === "input" && result.schema._prefault) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
6532 + delete result.schema._prefault;
6533 + return this.seen.get(schema).schema;
6534 + }
6535 + emit(schema, _params) {
6536 + const params = {
6537 + cycles: _params?.cycles ?? "ref",
6538 + reused: _params?.reused ?? "inline",
6539 + external: _params?.external ?? void 0
6540 + };
6541 + const root = this.seen.get(schema);
6542 + if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
6543 + const makeURI = (entry) => {
6544 + const defsSegment = this.target === "draft-2020-12" ? "$defs" : "definitions";
6545 + if (params.external) {
6546 + const externalId = params.external.registry.get(entry[0])?.id;
6547 + const uriGenerator = params.external.uri ?? ((id) => id);
6548 + if (externalId) return { ref: uriGenerator(externalId) };
6549 + const id = entry[1].defId ?? entry[1].schema.id ?? `schema${this.counter++}`;
6550 + entry[1].defId = id;
6551 + return {
6552 + defId: id,
6553 + ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
6554 + };
6555 + }
6556 + if (entry[1] === root) return { ref: "#" };
6557 + const defUriPrefix = `#/${defsSegment}/`;
6558 + const defId = entry[1].schema.id ?? `__schema${this.counter++}`;
6559 + return {
6560 + defId,
6561 + ref: defUriPrefix + defId
6562 + };
6563 + };
6564 + const extractToDef = (entry) => {
6565 + if (entry[1].schema.$ref) return;
6566 + const seen = entry[1];
6567 + const { ref, defId } = makeURI(entry);
6568 + seen.def = { ...seen.schema };
6569 + if (defId) seen.defId = defId;
6570 + const schema = seen.schema;
6571 + for (const key in schema) delete schema[key];
6572 + schema.$ref = ref;
6573 + };
6574 + if (params.cycles === "throw") for (const entry of this.seen.entries()) {
6575 + const seen = entry[1];
6576 + if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
6577 +
6578 +Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
6579 + }
6580 + for (const entry of this.seen.entries()) {
6581 + const seen = entry[1];
6582 + if (schema === entry[0]) {
6583 + extractToDef(entry);
6584 + continue;
6585 + }
6586 + if (params.external) {
6587 + const ext = params.external.registry.get(entry[0])?.id;
6588 + if (schema !== entry[0] && ext) {
6589 + extractToDef(entry);
6590 + continue;
6591 + }
6592 + }
6593 + if (this.metadataRegistry.get(entry[0])?.id) {
6594 + extractToDef(entry);
6595 + continue;
6596 + }
6597 + if (seen.cycle) {
6598 + extractToDef(entry);
6599 + continue;
6600 + }
6601 + if (seen.count > 1) {
6602 + if (params.reused === "ref") {
6603 + extractToDef(entry);
6604 + continue;
6605 + }
6606 + }
6607 + }
6608 + const flattenRef = (zodSchema, params) => {
6609 + const seen = this.seen.get(zodSchema);
6610 + const schema = seen.def ?? seen.schema;
6611 + const _cached = { ...schema };
6612 + if (seen.ref === null) return;
6613 + const ref = seen.ref;
6614 + seen.ref = null;
6615 + if (ref) {
6616 + flattenRef(ref, params);
6617 + const refSchema = this.seen.get(ref).schema;
6618 + if (refSchema.$ref && params.target === "draft-7") {
6619 + schema.allOf = schema.allOf ?? [];
6620 + schema.allOf.push(refSchema);
6621 + } else {
6622 + Object.assign(schema, refSchema);
6623 + Object.assign(schema, _cached);
6624 + }
6625 + }
6626 + if (!seen.isParent) this.override({
6627 + zodSchema,
6628 + jsonSchema: schema,
6629 + path: seen.path ?? []
6630 + });
6631 + };
6632 + for (const entry of [...this.seen.entries()].reverse()) flattenRef(entry[0], { target: this.target });
6633 + const result = {};
6634 + if (this.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
6635 + else if (this.target === "draft-7") result.$schema = "http://json-schema.org/draft-07/schema#";
6636 + else console.warn(`Invalid target: ${this.target}`);
6637 + if (params.external?.uri) {
6638 + const id = params.external.registry.get(schema)?.id;
6639 + if (!id) throw new Error("Schema is missing an `id` property");
6640 + result.$id = params.external.uri(id);
6641 + }
6642 + Object.assign(result, root.def);
6643 + const defs = params.external?.defs ?? {};
6644 + for (const entry of this.seen.entries()) {
6645 + const seen = entry[1];
6646 + if (seen.def && seen.defId) defs[seen.defId] = seen.def;
6647 + }
6648 + if (params.external) {} else if (Object.keys(defs).length > 0) if (this.target === "draft-2020-12") result.$defs = defs;
6649 + else result.definitions = defs;
6650 + try {
6651 + return JSON.parse(JSON.stringify(result));
6652 + } catch (_err) {
6653 + throw new Error("Error converting schema to JSON.");
6654 + }
6655 + }
6656 + };
6657 + function toJSONSchema(input, _params) {
6658 + if (input instanceof $ZodRegistry) {
6659 + const gen = new JSONSchemaGenerator(_params);
6660 + const defs = {};
6661 + for (const entry of input._idmap.entries()) {
6662 + const [_, schema] = entry;
6663 + gen.process(schema);
6664 + }
6665 + const schemas = {};
6666 + const external = {
6667 + registry: input,
6668 + uri: _params?.uri,
6669 + defs
6670 + };
6671 + for (const entry of input._idmap.entries()) {
6672 + const [key, schema] = entry;
6673 + schemas[key] = gen.emit(schema, {
6674 + ..._params,
6675 + external
6676 + });
6677 + }
6678 + if (Object.keys(defs).length > 0) schemas.__shared = { [gen.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
6679 + return { schemas };
6680 + }
6681 + const gen = new JSONSchemaGenerator(_params);
6682 + gen.process(input);
6683 + return gen.emit(input, _params);
6684 + }
6685 + function isTransforming(_schema, _ctx) {
6686 + const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
6687 + if (ctx.seen.has(_schema)) return false;
6688 + ctx.seen.add(_schema);
6689 + const def = _schema._zod.def;
6690 + switch (def.type) {
6691 + case "string":
6692 + case "number":
6693 + case "bigint":
6694 + case "boolean":
6695 + case "date":
6696 + case "symbol":
6697 + case "undefined":
6698 + case "null":
6699 + case "any":
6700 + case "unknown":
6701 + case "never":
6702 + case "void":
6703 + case "literal":
6704 + case "enum":
6705 + case "nan":
6706 + case "file":
6707 + case "template_literal": return false;
6708 + case "array": return isTransforming(def.element, ctx);
6709 + case "object":
6710 + for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
6711 + return false;
6712 + case "union":
6713 + for (const option of def.options) if (isTransforming(option, ctx)) return true;
6714 + return false;
6715 + case "intersection": return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
6716 + case "tuple":
6717 + for (const item of def.items) if (isTransforming(item, ctx)) return true;
6718 + if (def.rest && isTransforming(def.rest, ctx)) return true;
6719 + return false;
6720 + case "record": return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
6721 + case "map": return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
6722 + case "set": return isTransforming(def.valueType, ctx);
6723 + case "promise":
6724 + case "optional":
6725 + case "nonoptional":
6726 + case "nullable":
6727 + case "readonly": return isTransforming(def.innerType, ctx);
6728 + case "lazy": return isTransforming(def.getter(), ctx);
6729 + case "default": return isTransforming(def.innerType, ctx);
6730 + case "prefault": return isTransforming(def.innerType, ctx);
6731 + case "custom": return false;
6732 + case "transform": return true;
6733 + case "pipe": return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
6734 + case "success": return false;
6735 + case "catch": return false;
6736 + default:
6737 + }
6738 + throw new Error(`Unknown schema type: ${def.type}`);
6739 + }
6740 +
6741 +//#endregion
6742 +//#region node_modules/zod/v4/mini/schemas.js
6743 + var ZodMiniType = /*@__PURE__*/ $constructor("ZodMiniType", (inst, def) => {
6744 + if (!inst._zod) throw new Error("Uninitialized schema in ZodMiniType.");
6745 + $ZodType.init(inst, def);
6746 + inst.def = def;
6747 + inst.parse = (data, params) => parse$1(inst, data, params, { callee: inst.parse });
6748 + inst.safeParse = (data, params) => safeParse$2(inst, data, params);
6749 + inst.parseAsync = async (data, params) => parseAsync$1(inst, data, params, { callee: inst.parseAsync });
6750 + inst.safeParseAsync = async (data, params) => safeParseAsync$2(inst, data, params);
6751 + inst.check = (...checks) => {
6752 + return inst.clone({
6753 + ...def,
6754 + checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
6755 + check: ch,
6756 + def: { check: "custom" },
6757 + onattach: []
6758 + } } : ch)]
6759 + });
6760 + };
6761 + inst.clone = (_def, params) => clone(inst, _def, params);
6762 + inst.brand = () => inst;
6763 + inst.register = ((reg, meta) => {
6764 + reg.add(inst, meta);
6765 + return inst;
6766 + });
6767 + });
6768 + var ZodMiniObject = /*@__PURE__*/ $constructor("ZodMiniObject", (inst, def) => {
6769 + $ZodObject.init(inst, def);
6770 + ZodMiniType.init(inst, def);
6771 + defineLazy(inst, "shape", () => def.shape);
6772 + });
6773 + function object$1(shape, params) {
6774 + const def = {
6775 + type: "object",
6776 + get shape() {
6777 + assignProp(this, "shape", { ...shape });
6778 + return this.shape;
6779 + },
6780 + ...normalizeParams(params)
6781 + };
6782 + return new ZodMiniObject(def);
6783 + }
6784 + __name(object$1, "object");
6785 +
6786 +//#endregion
6787 +//#region node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
6788 + function isZ4Schema(s) {
6789 + return !!s._zod;
6790 + }
6791 + function objectFromShape(shape) {
6792 + const values = Object.values(shape);
6793 + if (values.length === 0) return object$1({});
6794 + const allV4 = values.every(isZ4Schema);
6795 + const allV3 = values.every((s) => !isZ4Schema(s));
6796 + if (allV4) return object$1(shape);
6797 + if (allV3) return objectType(shape);
6798 + throw new Error("Mixed Zod versions detected in object shape.");
6799 + }
6800 + function safeParse$1(schema, data) {
6801 + if (isZ4Schema(schema)) return safeParse$2(schema, data);
6802 + return schema.safeParse(data);
6803 + }
6804 + __name(safeParse$1, "safeParse");
6805 + async function safeParseAsync$1(schema, data) {
6806 + if (isZ4Schema(schema)) return await safeParseAsync$2(schema, data);
6807 + return await schema.safeParseAsync(data);
6808 + }
6809 + __name(safeParseAsync$1, "safeParseAsync");
6810 + function getObjectShape(schema) {
6811 + if (!schema) return void 0;
6812 + let rawShape;
6813 + if (isZ4Schema(schema)) rawShape = schema._zod?.def?.shape;
6814 + else rawShape = schema.shape;
6815 + if (!rawShape) return void 0;
6816 + if (typeof rawShape === "function") try {
6817 + return rawShape();
6818 + } catch {
6819 + return;
6820 + }
6821 + return rawShape;
6822 + }
6823 + /**
6824 + * Normalizes a schema to an object schema. Handles both:
6825 + * - Already-constructed object schemas (v3 or v4)
6826 + * - Raw shapes that need to be wrapped into object schemas
6827 + */
6828 + function normalizeObjectSchema(schema) {
6829 + if (!schema) return void 0;
6830 + if (typeof schema === "object") {
6831 + const asV3 = schema;
6832 + const asV4 = schema;
6833 + if (!asV3._def && !asV4._zod) {
6834 + const values = Object.values(schema);
6835 + if (values.length > 0 && values.every((v) => typeof v === "object" && v !== null && (v._def !== void 0 || v._zod !== void 0 || typeof v.parse === "function"))) return objectFromShape(schema);
6836 + }
6837 + }
6838 + if (isZ4Schema(schema)) {
6839 + const def = schema._zod?.def;
6840 + if (def && (def.type === "object" || def.shape !== void 0)) return schema;
6841 + } else if (schema.shape !== void 0) return schema;
6842 + }
6843 + /**
6844 + * Safely extracts an error message from a parse result error.
6845 + * Zod errors can have different structures, so we handle various cases.
6846 + */
6847 + function getParseErrorMessage(error) {
6848 + if (error && typeof error === "object") {
6849 + if ("message" in error && typeof error.message === "string") return error.message;
6850 + if ("issues" in error && Array.isArray(error.issues) && error.issues.length > 0) {
6851 + const firstIssue = error.issues[0];
6852 + if (firstIssue && typeof firstIssue === "object" && "message" in firstIssue) return String(firstIssue.message);
6853 + }
6854 + try {
6855 + return JSON.stringify(error);
6856 + } catch {
6857 + return String(error);
6858 + }
6859 + }
6860 + return String(error);
6861 + }
6862 + /**
6863 + * Gets the description from a schema, if available.
6864 + * Works with both Zod v3 and v4.
6865 + *
6866 + * Both versions expose a `.description` getter that returns the description
6867 + * from their respective internal storage (v3: _def, v4: globalRegistry).
6868 + */
6869 + function getSchemaDescription(schema) {
6870 + return schema.description;
6871 + }
6872 + /**
6873 + * Checks if a schema is optional.
6874 + * Works with both Zod v3 and v4.
6875 + */
6876 + function isSchemaOptional(schema) {
6877 + if (isZ4Schema(schema)) return schema._zod?.def?.type === "optional";
6878 + const v3Schema = schema;
6879 + if (typeof schema.isOptional === "function") return schema.isOptional();
6880 + return v3Schema._def?.typeName === "ZodOptional";
6881 + }
6882 + /**
6883 + * Gets the literal value from a schema, if it's a literal schema.
6884 + * Works with both Zod v3 and v4.
6885 + * Returns undefined if the schema is not a literal or the value cannot be determined.
6886 + */
6887 + function getLiteralValue(schema) {
6888 + if (isZ4Schema(schema)) {
6889 + const def = schema._zod?.def;
6890 + if (def) {
6891 + if (def.value !== void 0) return def.value;
6892 + if (Array.isArray(def.values) && def.values.length > 0) return def.values[0];
6893 + }
6894 + }
6895 + const def = schema._def;
6896 + if (def) {
6897 + if (def.value !== void 0) return def.value;
6898 + if (Array.isArray(def.values) && def.values.length > 0) return def.values[0];
6899 + }
6900 + const directValue = schema.value;
6901 + if (directValue !== void 0) return directValue;
6902 + }
6903 +
6904 +//#endregion
6905 +//#region node_modules/zod/v4/classic/iso.js
6906 + var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
6907 + $ZodISODateTime.init(inst, def);
6908 + ZodStringFormat.init(inst, def);
6909 + });
6910 + function datetime(params) {
6911 + return _isoDateTime(ZodISODateTime, params);
6912 + }
6913 + var ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
6914 + $ZodISODate.init(inst, def);
6915 + ZodStringFormat.init(inst, def);
6916 + });
6917 + function date(params) {
6918 + return _isoDate(ZodISODate, params);
6919 + }
6920 + var ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
6921 + $ZodISOTime.init(inst, def);
6922 + ZodStringFormat.init(inst, def);
6923 + });
6924 + function time(params) {
6925 + return _isoTime(ZodISOTime, params);
6926 + }
6927 + var ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
6928 + $ZodISODuration.init(inst, def);
6929 + ZodStringFormat.init(inst, def);
6930 + });
6931 + function duration(params) {
6932 + return _isoDuration(ZodISODuration, params);
6933 + }
6934 +
6935 +//#endregion
6936 +//#region node_modules/zod/v4/classic/errors.js
6937 + var initializer = (inst, issues) => {
6938 + $ZodError.init(inst, issues);
6939 + inst.name = "ZodError";
6940 + Object.defineProperties(inst, {
6941 + format: { value: (mapper) => formatError(inst, mapper) },
6942 + flatten: { value: (mapper) => flattenError(inst, mapper) },
6943 + addIssue: { value: (issue) => inst.issues.push(issue) },
6944 + addIssues: { value: (issues) => inst.issues.push(...issues) },
6945 + isEmpty: { get() {
6946 + return inst.issues.length === 0;
6947 + } }
6948 + });
6949 + };
6950 + var ZodError = $constructor("ZodError", initializer);
6951 + var ZodRealError = $constructor("ZodError", initializer, { Parent: Error });
6952 +
6953 +//#endregion
6954 +//#region node_modules/zod/v4/classic/parse.js
6955 + var parse = /* @__PURE__ */ _parse(ZodRealError);
6956 + var parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
6957 + var safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
6958 + var safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
6959 +
6960 +//#endregion
6961 +//#region node_modules/zod/v4/classic/schemas.js
6962 + var ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
6963 + $ZodType.init(inst, def);
6964 + inst.def = def;
6965 + Object.defineProperty(inst, "_def", { value: def });
6966 + inst.check = (...checks) => {
6967 + return inst.clone({
6968 + ...def,
6969 + checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
6970 + check: ch,
6971 + def: { check: "custom" },
6972 + onattach: []
6973 + } } : ch)]
6974 + });
6975 + };
6976 + inst.clone = (def, params) => clone(inst, def, params);
6977 + inst.brand = () => inst;
6978 + inst.register = ((reg, meta) => {
6979 + reg.add(inst, meta);
6980 + return inst;
6981 + });
6982 + inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
6983 + inst.safeParse = (data, params) => safeParse(inst, data, params);
6984 + inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
6985 + inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
6986 + inst.spa = inst.safeParseAsync;
6987 + inst.refine = (check, params) => inst.check(refine(check, params));
6988 + inst.superRefine = (refinement) => inst.check(superRefine(refinement));
6989 + inst.overwrite = (fn) => inst.check(_overwrite(fn));
6990 + inst.optional = () => optional(inst);
6991 + inst.nullable = () => nullable(inst);
6992 + inst.nullish = () => optional(nullable(inst));
6993 + inst.nonoptional = (params) => nonoptional(inst, params);
6994 + inst.array = () => array(inst);
6995 + inst.or = (arg) => union([inst, arg]);
6996 + inst.and = (arg) => intersection(inst, arg);
6997 + inst.transform = (tx) => pipe(inst, transform(tx));
6998 + inst.default = (def) => _default(inst, def);
6999 + inst.prefault = (def) => prefault(inst, def);
7000 + inst.catch = (params) => _catch(inst, params);
7001 + inst.pipe = (target) => pipe(inst, target);
7002 + inst.readonly = () => readonly(inst);
7003 + inst.describe = (description) => {
7004 + const cl = inst.clone();
7005 + globalRegistry.add(cl, { description });
7006 + return cl;
7007 + };
7008 + Object.defineProperty(inst, "description", {
7009 + get() {
7010 + return globalRegistry.get(inst)?.description;
7011 + },
7012 + configurable: true
7013 + });
7014 + inst.meta = (...args) => {
7015 + if (args.length === 0) return globalRegistry.get(inst);
7016 + const cl = inst.clone();
7017 + globalRegistry.add(cl, args[0]);
7018 + return cl;
7019 + };
7020 + inst.isOptional = () => inst.safeParse(void 0).success;
7021 + inst.isNullable = () => inst.safeParse(null).success;
7022 + return inst;
7023 + });
7024 + /** @internal */
7025 + var _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
7026 + $ZodString.init(inst, def);
7027 + ZodType.init(inst, def);
7028 + const bag = inst._zod.bag;
7029 + inst.format = bag.format ?? null;
7030 + inst.minLength = bag.minimum ?? null;
7031 + inst.maxLength = bag.maximum ?? null;
7032 + inst.regex = (...args) => inst.check(_regex(...args));
7033 + inst.includes = (...args) => inst.check(_includes(...args));
7034 + inst.startsWith = (...args) => inst.check(_startsWith(...args));
7035 + inst.endsWith = (...args) => inst.check(_endsWith(...args));
7036 + inst.min = (...args) => inst.check(_minLength(...args));
7037 + inst.max = (...args) => inst.check(_maxLength(...args));
7038 + inst.length = (...args) => inst.check(_length(...args));
7039 + inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
7040 + inst.lowercase = (params) => inst.check(_lowercase(params));
7041 + inst.uppercase = (params) => inst.check(_uppercase(params));
7042 + inst.trim = () => inst.check(_trim());
7043 + inst.normalize = (...args) => inst.check(_normalize(...args));
7044 + inst.toLowerCase = () => inst.check(_toLowerCase());
7045 + inst.toUpperCase = () => inst.check(_toUpperCase());
7046 + });
7047 + var ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
7048 + $ZodString.init(inst, def);
7049 + _ZodString.init(inst, def);
7050 + inst.email = (params) => inst.check(_email(ZodEmail, params));
7051 + inst.url = (params) => inst.check(_url(ZodURL, params));
7052 + inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
7053 + inst.emoji = (params) => inst.check(_emoji(ZodEmoji, params));
7054 + inst.guid = (params) => inst.check(_guid(ZodGUID, params));
7055 + inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
7056 + inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
7057 + inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
7058 + inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
7059 + inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
7060 + inst.guid = (params) => inst.check(_guid(ZodGUID, params));
7061 + inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
7062 + inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
7063 + inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
7064 + inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
7065 + inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
7066 + inst.xid = (params) => inst.check(_xid(ZodXID, params));
7067 + inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
7068 + inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
7069 + inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
7070 + inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
7071 + inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
7072 + inst.e164 = (params) => inst.check(_e164(ZodE164, params));
7073 + inst.datetime = (params) => inst.check(datetime(params));
7074 + inst.date = (params) => inst.check(date(params));
7075 + inst.time = (params) => inst.check(time(params));
7076 + inst.duration = (params) => inst.check(duration(params));
7077 + });
7078 + function string(params) {
7079 + return _string(ZodString, params);
7080 + }
7081 + var ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def) => {
7082 + $ZodStringFormat.init(inst, def);
7083 + _ZodString.init(inst, def);
7084 + });
7085 + var ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
7086 + $ZodEmail.init(inst, def);
7087 + ZodStringFormat.init(inst, def);
7088 + });
7089 + var ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def) => {
7090 + $ZodGUID.init(inst, def);
7091 + ZodStringFormat.init(inst, def);
7092 + });
7093 + var ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def) => {
7094 + $ZodUUID.init(inst, def);
7095 + ZodStringFormat.init(inst, def);
7096 + });
7097 + var ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
7098 + $ZodURL.init(inst, def);
7099 + ZodStringFormat.init(inst, def);
7100 + });
7101 + var ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def) => {
7102 + $ZodEmoji.init(inst, def);
7103 + ZodStringFormat.init(inst, def);
7104 + });
7105 + var ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def) => {
7106 + $ZodNanoID.init(inst, def);
7107 + ZodStringFormat.init(inst, def);
7108 + });
7109 + var ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def) => {
7110 + $ZodCUID.init(inst, def);
7111 + ZodStringFormat.init(inst, def);
7112 + });
7113 + var ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (inst, def) => {
7114 + $ZodCUID2.init(inst, def);
7115 + ZodStringFormat.init(inst, def);
7116 + });
7117 + var ZodULID = /*@__PURE__*/ $constructor("ZodULID", (inst, def) => {
7118 + $ZodULID.init(inst, def);
7119 + ZodStringFormat.init(inst, def);
7120 + });
7121 + var ZodXID = /*@__PURE__*/ $constructor("ZodXID", (inst, def) => {
7122 + $ZodXID.init(inst, def);
7123 + ZodStringFormat.init(inst, def);
7124 + });
7125 + var ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (inst, def) => {
7126 + $ZodKSUID.init(inst, def);
7127 + ZodStringFormat.init(inst, def);
7128 + });
7129 + var ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (inst, def) => {
7130 + $ZodIPv4.init(inst, def);
7131 + ZodStringFormat.init(inst, def);
7132 + });
7133 + var ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (inst, def) => {
7134 + $ZodIPv6.init(inst, def);
7135 + ZodStringFormat.init(inst, def);
7136 + });
7137 + var ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (inst, def) => {
7138 + $ZodCIDRv4.init(inst, def);
7139 + ZodStringFormat.init(inst, def);
7140 + });
7141 + var ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (inst, def) => {
7142 + $ZodCIDRv6.init(inst, def);
7143 + ZodStringFormat.init(inst, def);
7144 + });
7145 + var ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (inst, def) => {
7146 + $ZodBase64.init(inst, def);
7147 + ZodStringFormat.init(inst, def);
7148 + });
7149 + var ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (inst, def) => {
7150 + $ZodBase64URL.init(inst, def);
7151 + ZodStringFormat.init(inst, def);
7152 + });
7153 + var ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def) => {
7154 + $ZodE164.init(inst, def);
7155 + ZodStringFormat.init(inst, def);
7156 + });
7157 + var ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
7158 + $ZodJWT.init(inst, def);
7159 + ZodStringFormat.init(inst, def);
7160 + });
7161 + var ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
7162 + $ZodNumber.init(inst, def);
7163 + ZodType.init(inst, def);
7164 + inst.gt = (value, params) => inst.check(_gt(value, params));
7165 + inst.gte = (value, params) => inst.check(_gte(value, params));
7166 + inst.min = (value, params) => inst.check(_gte(value, params));
7167 + inst.lt = (value, params) => inst.check(_lt(value, params));
7168 + inst.lte = (value, params) => inst.check(_lte(value, params));
7169 + inst.max = (value, params) => inst.check(_lte(value, params));
7170 + inst.int = (params) => inst.check(int(params));
7171 + inst.safe = (params) => inst.check(int(params));
7172 + inst.positive = (params) => inst.check(_gt(0, params));
7173 + inst.nonnegative = (params) => inst.check(_gte(0, params));
7174 + inst.negative = (params) => inst.check(_lt(0, params));
7175 + inst.nonpositive = (params) => inst.check(_lte(0, params));
7176 + inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
7177 + inst.step = (value, params) => inst.check(_multipleOf(value, params));
7178 + inst.finite = () => inst;
7179 + const bag = inst._zod.bag;
7180 + inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
7181 + inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
7182 + inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
7183 + inst.isFinite = true;
7184 + inst.format = bag.format ?? null;
7185 + });
7186 + function number(params) {
7187 + return _number(ZodNumber, params);
7188 + }
7189 + var ZodNumberFormat = /*@__PURE__*/ $constructor("ZodNumberFormat", (inst, def) => {
7190 + $ZodNumberFormat.init(inst, def);
7191 + ZodNumber.init(inst, def);
7192 + });
7193 + function int(params) {
7194 + return _int(ZodNumberFormat, params);
7195 + }
7196 + var ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def) => {
7197 + $ZodBoolean.init(inst, def);
7198 + ZodType.init(inst, def);
7199 + });
7200 + function boolean(params) {
7201 + return _boolean(ZodBoolean, params);
7202 + }
7203 + var ZodNull = /*@__PURE__*/ $constructor("ZodNull", (inst, def) => {
7204 + $ZodNull.init(inst, def);
7205 + ZodType.init(inst, def);
7206 + });
7207 + function _null(params) {
7208 + return _null$1(ZodNull, params);
7209 + }
7210 + var ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
7211 + $ZodUnknown.init(inst, def);
7212 + ZodType.init(inst, def);
7213 + });
7214 + function unknown() {
7215 + return _unknown(ZodUnknown);
7216 + }
7217 + var ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
7218 + $ZodNever.init(inst, def);
7219 + ZodType.init(inst, def);
7220 + });
7221 + function never(params) {
7222 + return _never(ZodNever, params);
7223 + }
7224 + var ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
7225 + $ZodArray.init(inst, def);
7226 + ZodType.init(inst, def);
7227 + inst.element = def.element;
7228 + inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
7229 + inst.nonempty = (params) => inst.check(_minLength(1, params));
7230 + inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
7231 + inst.length = (len, params) => inst.check(_length(len, params));
7232 + inst.unwrap = () => inst.element;
7233 + });
7234 + function array(element, params) {
7235 + return _array(ZodArray, element, params);
7236 + }
7237 + var ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
7238 + $ZodObject.init(inst, def);
7239 + ZodType.init(inst, def);
7240 + defineLazy(inst, "shape", () => def.shape);
7241 + inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
7242 + inst.catchall = (catchall) => inst.clone({
7243 + ...inst._zod.def,
7244 + catchall
7245 + });
7246 + inst.passthrough = () => inst.clone({
7247 + ...inst._zod.def,
7248 + catchall: unknown()
7249 + });
7250 + inst.loose = () => inst.clone({
7251 + ...inst._zod.def,
7252 + catchall: unknown()
7253 + });
7254 + inst.strict = () => inst.clone({
7255 + ...inst._zod.def,
7256 + catchall: never()
7257 + });
7258 + inst.strip = () => inst.clone({
7259 + ...inst._zod.def,
7260 + catchall: void 0
7261 + });
7262 + inst.extend = (incoming) => {
7263 + return extend(inst, incoming);
7264 + };
7265 + inst.merge = (other) => merge(inst, other);
7266 + inst.pick = (mask) => pick(inst, mask);
7267 + inst.omit = (mask) => omit(inst, mask);
7268 + inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
7269 + inst.required = (...args) => required$1(ZodNonOptional, inst, args[0]);
7270 + });
7271 + function object(shape, params) {
7272 + const def = {
7273 + type: "object",
7274 + get shape() {
7275 + assignProp(this, "shape", { ...shape });
7276 + return this.shape;
7277 + },
7278 + ...normalizeParams(params)
7279 + };
7280 + return new ZodObject(def);
7281 + }
7282 + function looseObject(shape, params) {
7283 + return new ZodObject({
7284 + type: "object",
7285 + get shape() {
7286 + assignProp(this, "shape", { ...shape });
7287 + return this.shape;
7288 + },
7289 + catchall: unknown(),
7290 + ...normalizeParams(params)
7291 + });
7292 + }
7293 + var ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
7294 + $ZodUnion.init(inst, def);
7295 + ZodType.init(inst, def);
7296 + inst.options = def.options;
7297 + });
7298 + function union(options, params) {
7299 + return new ZodUnion({
7300 + type: "union",
7301 + options,
7302 + ...normalizeParams(params)
7303 + });
7304 + }
7305 + var ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("ZodDiscriminatedUnion", (inst, def) => {
7306 + ZodUnion.init(inst, def);
7307 + $ZodDiscriminatedUnion.init(inst, def);
7308 + });
7309 + function discriminatedUnion(discriminator, options, params) {
7310 + return new ZodDiscriminatedUnion({
7311 + type: "union",
7312 + options,
7313 + discriminator,
7314 + ...normalizeParams(params)
7315 + });
7316 + }
7317 + var ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
7318 + $ZodIntersection.init(inst, def);
7319 + ZodType.init(inst, def);
7320 + });
7321 + function intersection(left, right) {
7322 + return new ZodIntersection({
7323 + type: "intersection",
7324 + left,
7325 + right
7326 + });
7327 + }
7328 + var ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
7329 + $ZodRecord.init(inst, def);
7330 + ZodType.init(inst, def);
7331 + inst.keyType = def.keyType;
7332 + inst.valueType = def.valueType;
7333 + });
7334 + function record(keyType, valueType, params) {
7335 + return new ZodRecord({
7336 + type: "record",
7337 + keyType,
7338 + valueType,
7339 + ...normalizeParams(params)
7340 + });
7341 + }
7342 + var ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
7343 + $ZodEnum.init(inst, def);
7344 + ZodType.init(inst, def);
7345 + inst.enum = def.entries;
7346 + inst.options = Object.values(def.entries);
7347 + const keys = new Set(Object.keys(def.entries));
7348 + inst.extract = (values, params) => {
7349 + const newEntries = {};
7350 + for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
7351 + else throw new Error(`Key ${value} not found in enum`);
7352 + return new ZodEnum({
7353 + ...def,
7354 + checks: [],
7355 + ...normalizeParams(params),
7356 + entries: newEntries
7357 + });
7358 + };
7359 + inst.exclude = (values, params) => {
7360 + const newEntries = { ...def.entries };
7361 + for (const value of values) if (keys.has(value)) delete newEntries[value];
7362 + else throw new Error(`Key ${value} not found in enum`);
7363 + return new ZodEnum({
7364 + ...def,
7365 + checks: [],
7366 + ...normalizeParams(params),
7367 + entries: newEntries
7368 + });
7369 + };
7370 + });
7371 + function _enum(values, params) {
7372 + const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
7373 + return new ZodEnum({
7374 + type: "enum",
7375 + entries,
7376 + ...normalizeParams(params)
7377 + });
7378 + }
7379 + var ZodLiteral = /*@__PURE__*/ $constructor("ZodLiteral", (inst, def) => {
7380 + $ZodLiteral.init(inst, def);
7381 + ZodType.init(inst, def);
7382 + inst.values = new Set(def.values);
7383 + Object.defineProperty(inst, "value", { get() {
7384 + if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
7385 + return def.values[0];
7386 + } });
7387 + });
7388 + function literal(value, params) {
7389 + return new ZodLiteral({
7390 + type: "literal",
7391 + values: Array.isArray(value) ? value : [value],
7392 + ...normalizeParams(params)
7393 + });
7394 + }
7395 + var ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
7396 + $ZodTransform.init(inst, def);
7397 + ZodType.init(inst, def);
7398 + inst._zod.parse = (payload, _ctx) => {
7399 + payload.addIssue = (issue$2) => {
7400 + if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, def));
7401 + else {
7402 + const _issue = issue$2;
7403 + if (_issue.fatal) _issue.continue = false;
7404 + _issue.code ?? (_issue.code = "custom");
7405 + _issue.input ?? (_issue.input = payload.value);
7406 + _issue.inst ?? (_issue.inst = inst);
7407 + _issue.continue ?? (_issue.continue = true);
7408 + payload.issues.push(issue(_issue));
7409 + }
7410 + };
7411 + const output = def.transform(payload.value, payload);
7412 + if (output instanceof Promise) return output.then((output) => {
7413 + payload.value = output;
7414 + return payload;
7415 + });
7416 + payload.value = output;
7417 + return payload;
7418 + };
7419 + });
7420 + function transform(fn) {
7421 + return new ZodTransform({
7422 + type: "transform",
7423 + transform: fn
7424 + });
7425 + }
7426 + var ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
7427 + $ZodOptional.init(inst, def);
7428 + ZodType.init(inst, def);
7429 + inst.unwrap = () => inst._zod.def.innerType;
7430 + });
7431 + function optional(innerType) {
7432 + return new ZodOptional({
7433 + type: "optional",
7434 + innerType
7435 + });
7436 + }
7437 + var ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
7438 + $ZodNullable.init(inst, def);
7439 + ZodType.init(inst, def);
7440 + inst.unwrap = () => inst._zod.def.innerType;
7441 + });
7442 + function nullable(innerType) {
7443 + return new ZodNullable({
7444 + type: "nullable",
7445 + innerType
7446 + });
7447 + }
7448 + var ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def) => {
7449 + $ZodDefault.init(inst, def);
7450 + ZodType.init(inst, def);
7451 + inst.unwrap = () => inst._zod.def.innerType;
7452 + inst.removeDefault = inst.unwrap;
7453 + });
7454 + function _default(innerType, defaultValue) {
7455 + return new ZodDefault({
7456 + type: "default",
7457 + innerType,
7458 + get defaultValue() {
7459 + return typeof defaultValue === "function" ? defaultValue() : defaultValue;
7460 + }
7461 + });
7462 + }
7463 + var ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def) => {
7464 + $ZodPrefault.init(inst, def);
7465 + ZodType.init(inst, def);
7466 + inst.unwrap = () => inst._zod.def.innerType;
7467 + });
7468 + function prefault(innerType, defaultValue) {
7469 + return new ZodPrefault({
7470 + type: "prefault",
7471 + innerType,
7472 + get defaultValue() {
7473 + return typeof defaultValue === "function" ? defaultValue() : defaultValue;
7474 + }
7475 + });
7476 + }
7477 + var ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def) => {
7478 + $ZodNonOptional.init(inst, def);
7479 + ZodType.init(inst, def);
7480 + inst.unwrap = () => inst._zod.def.innerType;
7481 + });
7482 + function nonoptional(innerType, params) {
7483 + return new ZodNonOptional({
7484 + type: "nonoptional",
7485 + innerType,
7486 + ...normalizeParams(params)
7487 + });
7488 + }
7489 + var ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def) => {
7490 + $ZodCatch.init(inst, def);
7491 + ZodType.init(inst, def);
7492 + inst.unwrap = () => inst._zod.def.innerType;
7493 + inst.removeCatch = inst.unwrap;
7494 + });
7495 + function _catch(innerType, catchValue) {
7496 + return new ZodCatch({
7497 + type: "catch",
7498 + innerType,
7499 + catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
7500 + });
7501 + }
7502 + var ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
7503 + $ZodPipe.init(inst, def);
7504 + ZodType.init(inst, def);
7505 + inst.in = def.in;
7506 + inst.out = def.out;
7507 + });
7508 + function pipe(in_, out) {
7509 + return new ZodPipe({
7510 + type: "pipe",
7511 + in: in_,
7512 + out
7513 + });
7514 + }
7515 + var ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
7516 + $ZodReadonly.init(inst, def);
7517 + ZodType.init(inst, def);
7518 + });
7519 + function readonly(innerType) {
7520 + return new ZodReadonly({
7521 + type: "readonly",
7522 + innerType
7523 + });
7524 + }
7525 + var ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
7526 + $ZodCustom.init(inst, def);
7527 + ZodType.init(inst, def);
7528 + });
7529 + function check(fn) {
7530 + const ch = new $ZodCheck({ check: "custom" });
7531 + ch._zod.check = fn;
7532 + return ch;
7533 + }
7534 + function custom(fn, _params) {
7535 + return _custom(ZodCustom, fn ?? (() => true), _params);
7536 + }
7537 + function refine(fn, _params = {}) {
7538 + return _refine(ZodCustom, fn, _params);
7539 + }
7540 + function superRefine(fn) {
7541 + const ch = check((payload) => {
7542 + payload.addIssue = (issue$1) => {
7543 + if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
7544 + else {
7545 + const _issue = issue$1;
7546 + if (_issue.fatal) _issue.continue = false;
7547 + _issue.code ?? (_issue.code = "custom");
7548 + _issue.input ?? (_issue.input = payload.value);
7549 + _issue.inst ?? (_issue.inst = ch);
7550 + _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
7551 + payload.issues.push(issue(_issue));
7552 + }
7553 + };
7554 + return fn(payload.value, payload);
7555 + });
7556 + return ch;
7557 + }
7558 + function preprocess(fn, schema) {
7559 + return pipe(transform(fn), schema);
7560 + }
7561 +
7562 +//#endregion
7563 +//#region node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
7564 + var LATEST_PROTOCOL_VERSION = "2025-11-25";
7565 + var SUPPORTED_PROTOCOL_VERSIONS = [
7566 + LATEST_PROTOCOL_VERSION,
7567 + "2025-06-18",
7568 + "2025-03-26",
7569 + "2024-11-05",
7570 + "2024-10-07"
7571 + ];
7572 + var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
7573 + var JSONRPC_VERSION = "2.0";
7574 + /**
7575 + * Assert 'object' type schema.
7576 + *
7577 + * @internal
7578 + */
7579 + var AssertObjectSchema = custom((v) => v !== null && (typeof v === "object" || typeof v === "function"));
7580 + /**
7581 + * A progress token, used to associate progress notifications with the original request.
7582 + */
7583 + var ProgressTokenSchema = union([string(), number().int()]);
7584 + /**
7585 + * An opaque token used to represent a cursor for pagination.
7586 + */
7587 + var CursorSchema = string();
7588 + /**
7589 + * Task creation parameters, used to ask that the server create a task to represent a request.
7590 + */
7591 + var TaskCreationParamsSchema = looseObject({
7592 + /**
7593 + * Time in milliseconds to keep task results available after completion.
7594 + * If null, the task has unlimited lifetime until manually cleaned up.
7595 + */
7596 + ttl: union([number(), _null()]).optional(),
7597 + /**
7598 + * Time in milliseconds to wait between task status requests.
7599 + */
7600 + pollInterval: number().optional()
7601 + });
7602 + var TaskMetadataSchema = object({ ttl: number().optional() });
7603 + /**
7604 + * Metadata for associating messages with a task.
7605 + * Include this in the `_meta` field under the key `io.modelcontextprotocol/related-task`.
7606 + */
7607 + var RelatedTaskMetadataSchema = object({ taskId: string() });
7608 + var RequestMetaSchema = looseObject({
7609 + /**
7610 + * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
7611 + */
7612 + progressToken: ProgressTokenSchema.optional(),
7613 + /**
7614 + * If specified, this request is related to the provided task.
7615 + */
7616 + [RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
7617 + });
7618 + /**
7619 + * Common params for any request.
7620 + */
7621 + var BaseRequestParamsSchema = object({
7622 + /**
7623 + * See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
7624 + */
7625 +_meta: RequestMetaSchema.optional() });
7626 + /**
7627 + * Common params for any task-augmented request.
7628 + */
7629 + var TaskAugmentedRequestParamsSchema = BaseRequestParamsSchema.extend({
7630 + /**
7631 + * If specified, the caller is requesting task-augmented execution for this request.
7632 + * The request will return a CreateTaskResult immediately, and the actual result can be
7633 + * retrieved later via tasks/result.
7634 + *
7635 + * Task augmentation is subject to capability negotiation - receivers MUST declare support
7636 + * for task augmentation of specific request types in their capabilities.
7637 + */
7638 +task: TaskMetadataSchema.optional() });
7639 + /**
7640 + * Checks if a value is a valid TaskAugmentedRequestParams.
7641 + * @param value - The value to check.
7642 + *
7643 + * @returns True if the value is a valid TaskAugmentedRequestParams, false otherwise.
7644 + */
7645 + var isTaskAugmentedRequestParams = (value) => TaskAugmentedRequestParamsSchema.safeParse(value).success;
7646 + var RequestSchema = object({
7647 + method: string(),
7648 + params: BaseRequestParamsSchema.loose().optional()
7649 + });
7650 + var NotificationsParamsSchema = object({
7651 + /**
7652 + * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
7653 + * for notes on _meta usage.
7654 + */
7655 +_meta: RequestMetaSchema.optional() });
7656 + var NotificationSchema = object({
7657 + method: string(),
7658 + params: NotificationsParamsSchema.loose().optional()
7659 + });
7660 + var ResultSchema = looseObject({
7661 + /**
7662 + * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
7663 + * for notes on _meta usage.
7664 + */
7665 +_meta: RequestMetaSchema.optional() });
7666 + /**
7667 + * A uniquely identifying ID for a request in JSON-RPC.
7668 + */
7669 + var RequestIdSchema = union([string(), number().int()]);
7670 + /**
7671 + * A request that expects a response.
7672 + */
7673 + var JSONRPCRequestSchema = object({
7674 + jsonrpc: literal("2.0"),
7675 + id: RequestIdSchema,
7676 + ...RequestSchema.shape
7677 + }).strict();
7678 + var isJSONRPCRequest = (value) => JSONRPCRequestSchema.safeParse(value).success;
7679 + /**
7680 + * A notification which does not expect a response.
7681 + */
7682 + var JSONRPCNotificationSchema = object({
7683 + jsonrpc: literal("2.0"),
7684 + ...NotificationSchema.shape
7685 + }).strict();
7686 + var isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safeParse(value).success;
7687 + /**
7688 + * A successful (non-error) response to a request.
7689 + */
7690 + var JSONRPCResultResponseSchema = object({
7691 + jsonrpc: literal("2.0"),
7692 + id: RequestIdSchema,
7693 + result: ResultSchema
7694 + }).strict();
7695 + /**
7696 + * Checks if a value is a valid JSONRPCResultResponse.
7697 + * @param value - The value to check.
7698 + *
7699 + * @returns True if the value is a valid JSONRPCResultResponse, false otherwise.
7700 + */
7701 + var isJSONRPCResultResponse = (value) => JSONRPCResultResponseSchema.safeParse(value).success;
7702 + /**
7703 + * Error codes defined by the JSON-RPC specification.
7704 + */
7705 + var ErrorCode;
7706 + (function(ErrorCode) {
7707 + ErrorCode[ErrorCode["ConnectionClosed"] = -32e3] = "ConnectionClosed";
7708 + ErrorCode[ErrorCode["RequestTimeout"] = -32001] = "RequestTimeout";
7709 + ErrorCode[ErrorCode["ParseError"] = -32700] = "ParseError";
7710 + ErrorCode[ErrorCode["InvalidRequest"] = -32600] = "InvalidRequest";
7711 + ErrorCode[ErrorCode["MethodNotFound"] = -32601] = "MethodNotFound";
7712 + ErrorCode[ErrorCode["InvalidParams"] = -32602] = "InvalidParams";
7713 + ErrorCode[ErrorCode["InternalError"] = -32603] = "InternalError";
7714 + ErrorCode[ErrorCode["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
7715 + })(ErrorCode || (ErrorCode = {}));
7716 + /**
7717 + * A response to a request that indicates an error occurred.
7718 + */
7719 + var JSONRPCErrorResponseSchema = object({
7720 + jsonrpc: literal("2.0"),
7721 + id: RequestIdSchema.optional(),
7722 + error: object({
7723 + /**
7724 + * The error type that occurred.
7725 + */
7726 + code: number().int(),
7727 + /**
7728 + * A short description of the error. The message SHOULD be limited to a concise single sentence.
7729 + */
7730 + message: string(),
7731 + /**
7732 + * Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
7733 + */
7734 + data: unknown().optional()
7735 + })
7736 + }).strict();
7737 + /**
7738 + * Checks if a value is a valid JSONRPCErrorResponse.
7739 + * @param value - The value to check.
7740 + *
7741 + * @returns True if the value is a valid JSONRPCErrorResponse, false otherwise.
7742 + */
7743 + var isJSONRPCErrorResponse = (value) => JSONRPCErrorResponseSchema.safeParse(value).success;
7744 + var JSONRPCMessageSchema = union([
7745 + JSONRPCRequestSchema,
7746 + JSONRPCNotificationSchema,
7747 + JSONRPCResultResponseSchema,
7748 + JSONRPCErrorResponseSchema
7749 + ]);
7750 + var JSONRPCResponseSchema = union([JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema]);
7751 + /**
7752 + * A response that indicates success but carries no data.
7753 + */
7754 + var EmptyResultSchema = ResultSchema.strict();
7755 + var CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
7756 + /**
7757 + * The ID of the request to cancel.
7758 + *
7759 + * This MUST correspond to the ID of a request previously issued in the same direction.
7760 + */
7761 + requestId: RequestIdSchema.optional(),
7762 + /**
7763 + * An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
7764 + */
7765 + reason: string().optional()
7766 + });
7767 + /**
7768 + * This notification can be sent by either side to indicate that it is cancelling a previously-issued request.
7769 + *
7770 + * The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished.
7771 + *
7772 + * This notification indicates that the result will be unused, so any associated processing SHOULD cease.
7773 + *
7774 + * A client MUST NOT attempt to cancel its `initialize` request.
7775 + */
7776 + var CancelledNotificationSchema = NotificationSchema.extend({
7777 + method: literal("notifications/cancelled"),
7778 + params: CancelledNotificationParamsSchema
7779 + });
7780 + /**
7781 + * Icon schema for use in tools, prompts, resources, and implementations.
7782 + */
7783 + var IconSchema = object({
7784 + /**
7785 + * URL or data URI for the icon.
7786 + */
7787 + src: string(),
7788 + /**
7789 + * Optional MIME type for the icon.
7790 + */
7791 + mimeType: string().optional(),
7792 + /**
7793 + * Optional array of strings that specify sizes at which the icon can be used.
7794 + * Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.
7795 + *
7796 + * If not provided, the client should assume that the icon can be used at any size.
7797 + */
7798 + sizes: array(string()).optional(),
7799 + /**
7800 + * Optional specifier for the theme this icon is designed for. `light` indicates
7801 + * the icon is designed to be used with a light background, and `dark` indicates
7802 + * the icon is designed to be used with a dark background.
7803 + *
7804 + * If not provided, the client should assume the icon can be used with any theme.
7805 + */
7806 + theme: _enum(["light", "dark"]).optional()
7807 + });
7808 + /**
7809 + * Base schema to add `icons` property.
7810 + *
7811 + */
7812 + var IconsSchema = object({
7813 + /**
7814 + * Optional set of sized icons that the client can display in a user interface.
7815 + *
7816 + * Clients that support rendering icons MUST support at least the following MIME types:
7817 + * - `image/png` - PNG images (safe, universal compatibility)
7818 + * - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
7819 + *
7820 + * Clients that support rendering icons SHOULD also support:
7821 + * - `image/svg+xml` - SVG images (scalable but requires security precautions)
7822 + * - `image/webp` - WebP images (modern, efficient format)
7823 + */
7824 +icons: array(IconSchema).optional() });
7825 + /**
7826 + * Base metadata interface for common properties across resources, tools, prompts, and implementations.
7827 + */
7828 + var BaseMetadataSchema = object({
7829 + /** Intended for programmatic or logical use, but used as a display name in past specs or fallback */
7830 + name: string(),
7831 + /**
7832 + * Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
7833 + * even by those unfamiliar with domain-specific terminology.
7834 + *
7835 + * If not provided, the name should be used for display (except for Tool,
7836 + * where `annotations.title` should be given precedence over using `name`,
7837 + * if present).
7838 + */
7839 + title: string().optional()
7840 + });
7841 + /**
7842 + * Describes the name and version of an MCP implementation.
7843 + */
7844 + var ImplementationSchema = BaseMetadataSchema.extend({
7845 + ...BaseMetadataSchema.shape,
7846 + ...IconsSchema.shape,
7847 + version: string(),
7848 + /**
7849 + * An optional URL of the website for this implementation.
7850 + */
7851 + websiteUrl: string().optional(),
7852 + /**
7853 + * An optional human-readable description of what this implementation does.
7854 + *
7855 + * This can be used by clients or servers to provide context about their purpose
7856 + * and capabilities. For example, a server might describe the types of resources
7857 + * or tools it provides, while a client might describe its intended use case.
7858 + */
7859 + description: string().optional()
7860 + });
7861 + var FormElicitationCapabilitySchema = intersection(object({ applyDefaults: boolean().optional() }), record(string(), unknown()));
7862 + var ElicitationCapabilitySchema = preprocess((value) => {
7863 + if (value && typeof value === "object" && !Array.isArray(value)) {
7864 + if (Object.keys(value).length === 0) return { form: {} };
7865 + }
7866 + return value;
7867 + }, intersection(object({
7868 + form: FormElicitationCapabilitySchema.optional(),
7869 + url: AssertObjectSchema.optional()
7870 + }), record(string(), unknown()).optional()));
7871 + /**
7872 + * Task capabilities for clients, indicating which request types support task creation.
7873 + */
7874 + var ClientTasksCapabilitySchema = looseObject({
7875 + /**
7876 + * Present if the client supports listing tasks.
7877 + */
7878 + list: AssertObjectSchema.optional(),
7879 + /**
7880 + * Present if the client supports cancelling tasks.
7881 + */
7882 + cancel: AssertObjectSchema.optional(),
7883 + /**
7884 + * Capabilities for task creation on specific request types.
7885 + */
7886 + requests: looseObject({
7887 + /**
7888 + * Task support for sampling requests.
7889 + */
7890 + sampling: looseObject({ createMessage: AssertObjectSchema.optional() }).optional(),
7891 + /**
7892 + * Task support for elicitation requests.
7893 + */
7894 + elicitation: looseObject({ create: AssertObjectSchema.optional() }).optional()
7895 + }).optional()
7896 + });
7897 + /**
7898 + * Task capabilities for servers, indicating which request types support task creation.
7899 + */
7900 + var ServerTasksCapabilitySchema = looseObject({
7901 + /**
7902 + * Present if the server supports listing tasks.
7903 + */
7904 + list: AssertObjectSchema.optional(),
7905 + /**
7906 + * Present if the server supports cancelling tasks.
7907 + */
7908 + cancel: AssertObjectSchema.optional(),
7909 + /**
7910 + * Capabilities for task creation on specific request types.
7911 + */
7912 + requests: looseObject({
7913 + /**
7914 + * Task support for tool requests.
7915 + */
7916 +tools: looseObject({ call: AssertObjectSchema.optional() }).optional() }).optional()
7917 + });
7918 + /**
7919 + * Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities.
7920 + */
7921 + var ClientCapabilitiesSchema = object({
7922 + /**
7923 + * Experimental, non-standard capabilities that the client supports.
7924 + */
7925 + experimental: record(string(), AssertObjectSchema).optional(),
7926 + /**
7927 + * Present if the client supports sampling from an LLM.
7928 + */
7929 + sampling: object({
7930 + /**
7931 + * Present if the client supports context inclusion via includeContext parameter.
7932 + * If not declared, servers SHOULD only use `includeContext: "none"` (or omit it).
7933 + */
7934 + context: AssertObjectSchema.optional(),
7935 + /**
7936 + * Present if the client supports tool use via tools and toolChoice parameters.
7937 + */
7938 + tools: AssertObjectSchema.optional()
7939 + }).optional(),
7940 + /**
7941 + * Present if the client supports eliciting user input.
7942 + */
7943 + elicitation: ElicitationCapabilitySchema.optional(),
7944 + /**
7945 + * Present if the client supports listing roots.
7946 + */
7947 + roots: object({
7948 + /**
7949 + * Whether the client supports issuing notifications for changes to the roots list.
7950 + */
7951 +listChanged: boolean().optional() }).optional(),
7952 + /**
7953 + * Present if the client supports task creation.
7954 + */
7955 + tasks: ClientTasksCapabilitySchema.optional()
7956 + });
7957 + var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
7958 + /**
7959 + * The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.
7960 + */
7961 + protocolVersion: string(),
7962 + capabilities: ClientCapabilitiesSchema,
7963 + clientInfo: ImplementationSchema
7964 + });
7965 + /**
7966 + * This request is sent from the client to the server when it first connects, asking it to begin initialization.
7967 + */
7968 + var InitializeRequestSchema = RequestSchema.extend({
7969 + method: literal("initialize"),
7970 + params: InitializeRequestParamsSchema
7971 + });
7972 + /**
7973 + * Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities.
7974 + */
7975 + var ServerCapabilitiesSchema = object({
7976 + /**
7977 + * Experimental, non-standard capabilities that the server supports.
7978 + */
7979 + experimental: record(string(), AssertObjectSchema).optional(),
7980 + /**
7981 + * Present if the server supports sending log messages to the client.
7982 + */
7983 + logging: AssertObjectSchema.optional(),
7984 + /**
7985 + * Present if the server supports sending completions to the client.
7986 + */
7987 + completions: AssertObjectSchema.optional(),
7988 + /**
7989 + * Present if the server offers any prompt templates.
7990 + */
7991 + prompts: object({
7992 + /**
7993 + * Whether this server supports issuing notifications for changes to the prompt list.
7994 + */
7995 +listChanged: boolean().optional() }).optional(),
7996 + /**
7997 + * Present if the server offers any resources to read.
7998 + */
7999 + resources: object({
8000 + /**
8001 + * Whether this server supports clients subscribing to resource updates.
8002 + */
8003 + subscribe: boolean().optional(),
8004 + /**
8005 + * Whether this server supports issuing notifications for changes to the resource list.
8006 + */
8007 + listChanged: boolean().optional()
8008 + }).optional(),
8009 + /**
8010 + * Present if the server offers any tools to call.
8011 + */
8012 + tools: object({
8013 + /**
8014 + * Whether this server supports issuing notifications for changes to the tool list.
8015 + */
8016 +listChanged: boolean().optional() }).optional(),
8017 + /**
8018 + * Present if the server supports task creation.
8019 + */
8020 + tasks: ServerTasksCapabilitySchema.optional()
8021 + });
8022 + /**
8023 + * After receiving an initialize request from the client, the server sends this response.
8024 + */
8025 + var InitializeResultSchema = ResultSchema.extend({
8026 + /**
8027 + * The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect.
8028 + */
8029 + protocolVersion: string(),
8030 + capabilities: ServerCapabilitiesSchema,
8031 + serverInfo: ImplementationSchema,
8032 + /**
8033 + * Instructions describing how to use the server and its features.
8034 + *
8035 + * This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt.
8036 + */
8037 + instructions: string().optional()
8038 + });
8039 + /**
8040 + * This notification is sent from the client to the server after initialization has finished.
8041 + */
8042 + var InitializedNotificationSchema = NotificationSchema.extend({
8043 + method: literal("notifications/initialized"),
8044 + params: NotificationsParamsSchema.optional()
8045 + });
8046 + /**
8047 + * A ping, issued by either the server or the client, to check that the other party is still alive. The receiver must promptly respond, or else may be disconnected.
8048 + */
8049 + var PingRequestSchema = RequestSchema.extend({
8050 + method: literal("ping"),
8051 + params: BaseRequestParamsSchema.optional()
8052 + });
8053 + var ProgressSchema = object({
8054 + /**
8055 + * The progress thus far. This should increase every time progress is made, even if the total is unknown.
8056 + */
8057 + progress: number(),
8058 + /**
8059 + * Total number of items to process (or total progress required), if known.
8060 + */
8061 + total: optional(number()),
8062 + /**
8063 + * An optional message describing the current progress.
8064 + */
8065 + message: optional(string())
8066 + });
8067 + var ProgressNotificationParamsSchema = object({
8068 + ...NotificationsParamsSchema.shape,
8069 + ...ProgressSchema.shape,
8070 + /**
8071 + * The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.
8072 + */
8073 + progressToken: ProgressTokenSchema
8074 + });
8075 + /**
8076 + * An out-of-band notification used to inform the receiver of a progress update for a long-running request.
8077 + *
8078 + * @category notifications/progress
8079 + */
8080 + var ProgressNotificationSchema = NotificationSchema.extend({
8081 + method: literal("notifications/progress"),
8082 + params: ProgressNotificationParamsSchema
8083 + });
8084 + var PaginatedRequestParamsSchema = BaseRequestParamsSchema.extend({
8085 + /**
8086 + * An opaque token representing the current pagination position.
8087 + * If provided, the server should return results starting after this cursor.
8088 + */
8089 +cursor: CursorSchema.optional() });
8090 + var PaginatedRequestSchema = RequestSchema.extend({ params: PaginatedRequestParamsSchema.optional() });
8091 + var PaginatedResultSchema = ResultSchema.extend({
8092 + /**
8093 + * An opaque token representing the pagination position after the last returned result.
8094 + * If present, there may be more results available.
8095 + */
8096 +nextCursor: CursorSchema.optional() });
8097 + /**
8098 + * The status of a task.
8099 + * */
8100 + var TaskStatusSchema = _enum([
8101 + "working",
8102 + "input_required",
8103 + "completed",
8104 + "failed",
8105 + "cancelled"
8106 + ]);
8107 + /**
8108 + * A pollable state object associated with a request.
8109 + */
8110 + var TaskSchema = object({
8111 + taskId: string(),
8112 + status: TaskStatusSchema,
8113 + /**
8114 + * Time in milliseconds to keep task results available after completion.
8115 + * If null, the task has unlimited lifetime until manually cleaned up.
8116 + */
8117 + ttl: union([number(), _null()]),
8118 + /**
8119 + * ISO 8601 timestamp when the task was created.
8120 + */
8121 + createdAt: string(),
8122 + /**
8123 + * ISO 8601 timestamp when the task was last updated.
8124 + */
8125 + lastUpdatedAt: string(),
8126 + pollInterval: optional(number()),
8127 + /**
8128 + * Optional diagnostic message for failed tasks or other status information.
8129 + */
8130 + statusMessage: optional(string())
8131 + });
8132 + /**
8133 + * Result returned when a task is created, containing the task data wrapped in a task field.
8134 + */
8135 + var CreateTaskResultSchema = ResultSchema.extend({ task: TaskSchema });
8136 + /**
8137 + * Parameters for task status notification.
8138 + */
8139 + var TaskStatusNotificationParamsSchema = NotificationsParamsSchema.merge(TaskSchema);
8140 + /**
8141 + * A notification sent when a task's status changes.
8142 + */
8143 + var TaskStatusNotificationSchema = NotificationSchema.extend({
8144 + method: literal("notifications/tasks/status"),
8145 + params: TaskStatusNotificationParamsSchema
8146 + });
8147 + /**
8148 + * A request to get the state of a specific task.
8149 + */
8150 + var GetTaskRequestSchema = RequestSchema.extend({
8151 + method: literal("tasks/get"),
8152 + params: BaseRequestParamsSchema.extend({ taskId: string() })
8153 + });
8154 + /**
8155 + * The response to a tasks/get request.
8156 + */
8157 + var GetTaskResultSchema = ResultSchema.merge(TaskSchema);
8158 + /**
8159 + * A request to get the result of a specific task.
8160 + */
8161 + var GetTaskPayloadRequestSchema = RequestSchema.extend({
8162 + method: literal("tasks/result"),
8163 + params: BaseRequestParamsSchema.extend({ taskId: string() })
8164 + });
8165 + /**
8166 + * The response to a tasks/result request.
8167 + * The structure matches the result type of the original request.
8168 + * For example, a tools/call task would return the CallToolResult structure.
8169 + *
8170 + */
8171 + var GetTaskPayloadResultSchema = ResultSchema.loose();
8172 + /**
8173 + * A request to list tasks.
8174 + */
8175 + var ListTasksRequestSchema = PaginatedRequestSchema.extend({ method: literal("tasks/list") });
8176 + /**
8177 + * The response to a tasks/list request.
8178 + */
8179 + var ListTasksResultSchema = PaginatedResultSchema.extend({ tasks: array(TaskSchema) });
8180 + /**
8181 + * A request to cancel a specific task.
8182 + */
8183 + var CancelTaskRequestSchema = RequestSchema.extend({
8184 + method: literal("tasks/cancel"),
8185 + params: BaseRequestParamsSchema.extend({ taskId: string() })
8186 + });
8187 + /**
8188 + * The response to a tasks/cancel request.
8189 + */
8190 + var CancelTaskResultSchema = ResultSchema.merge(TaskSchema);
8191 + /**
8192 + * The contents of a specific resource or sub-resource.
8193 + */
8194 + var ResourceContentsSchema = object({
8195 + /**
8196 + * The URI of this resource.
8197 + */
8198 + uri: string(),
8199 + /**
8200 + * The MIME type of this resource, if known.
8201 + */
8202 + mimeType: optional(string()),
8203 + /**
8204 + * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
8205 + * for notes on _meta usage.
8206 + */
8207 + _meta: record(string(), unknown()).optional()
8208 + });
8209 + var TextResourceContentsSchema = ResourceContentsSchema.extend({
8210 + /**
8211 + * The text of the item. This must only be set if the item can actually be represented as text (not binary data).
8212 + */
8213 +text: string() });
8214 + /**
8215 + * A Zod schema for validating Base64 strings that is more performant and
8216 + * robust for very large inputs than the default regex-based check. It avoids
8217 + * stack overflows by using the native `atob` function for validation.
8218 + */
8219 + var Base64Schema = string().refine((val) => {
8220 + try {
8221 + atob(val);
8222 + return true;
8223 + } catch {
8224 + return false;
8225 + }
8226 + }, { message: "Invalid Base64 string" });
8227 + var BlobResourceContentsSchema = ResourceContentsSchema.extend({
8228 + /**
8229 + * A base64-encoded string representing the binary data of the item.
8230 + */
8231 +blob: Base64Schema });
8232 + /**
8233 + * The sender or recipient of messages and data in a conversation.
8234 + */
8235 + var RoleSchema = _enum(["user", "assistant"]);
8236 + /**
8237 + * Optional annotations providing clients additional context about a resource.
8238 + */
8239 + var AnnotationsSchema = object({
8240 + /**
8241 + * Intended audience(s) for the resource.
8242 + */
8243 + audience: array(RoleSchema).optional(),
8244 + /**
8245 + * Importance hint for the resource, from 0 (least) to 1 (most).
8246 + */
8247 + priority: number().min(0).max(1).optional(),
8248 + /**
8249 + * ISO 8601 timestamp for the most recent modification.
8250 + */
8251 + lastModified: datetime({ offset: true }).optional()
8252 + });
8253 + /**
8254 + * A known resource that the server is capable of reading.
8255 + */
8256 + var ResourceSchema = object({
8257 + ...BaseMetadataSchema.shape,
8258 + ...IconsSchema.shape,
8259 + /**
8260 + * The URI of this resource.
8261 + */
8262 + uri: string(),
8263 + /**
8264 + * A description of what this resource represents.
8265 + *
8266 + * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model.
8267 + */
8268 + description: optional(string()),
8269 + /**
8270 + * The MIME type of this resource, if known.
8271 + */
8272 + mimeType: optional(string()),
8273 + /**
8274 + * Optional annotations for the client.
8275 + */
8276 + annotations: AnnotationsSchema.optional(),
8277 + /**
8278 + * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
8279 + * for notes on _meta usage.
8280 + */
8281 + _meta: optional(looseObject({}))
8282 + });
8283 + /**
8284 + * A template description for resources available on the server.
8285 + */
8286 + var ResourceTemplateSchema = object({
8287 + ...BaseMetadataSchema.shape,
8288 + ...IconsSchema.shape,
8289 + /**
8290 + * A URI template (according to RFC 6570) that can be used to construct resource URIs.
8291 + */
8292 + uriTemplate: string(),
8293 + /**
8294 + * A description of what this template is for.
8295 + *
8296 + * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model.
8297 + */
8298 + description: optional(string()),
8299 + /**
8300 + * The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type.
8301 + */
8302 + mimeType: optional(string()),
8303 + /**
8304 + * Optional annotations for the client.
8305 + */
8306 + annotations: AnnotationsSchema.optional(),
8307 + /**
8308 + * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
8309 + * for notes on _meta usage.
8310 + */
8311 + _meta: optional(looseObject({}))
8312 + });
8313 + /**
8314 + * Sent from the client to request a list of resources the server has.
8315 + */
8316 + var ListResourcesRequestSchema = PaginatedRequestSchema.extend({ method: literal("resources/list") });
8317 + /**
8318 + * The server's response to a resources/list request from the client.
8319 + */
8320 + var ListResourcesResultSchema = PaginatedResultSchema.extend({ resources: array(ResourceSchema) });
8321 + /**
8322 + * Sent from the client to request a list of resource templates the server has.
8323 + */
8324 + var ListResourceTemplatesRequestSchema = PaginatedRequestSchema.extend({ method: literal("resources/templates/list") });
8325 + /**
8326 + * The server's response to a resources/templates/list request from the client.
8327 + */
8328 + var ListResourceTemplatesResultSchema = PaginatedResultSchema.extend({ resourceTemplates: array(ResourceTemplateSchema) });
8329 + var ResourceRequestParamsSchema = BaseRequestParamsSchema.extend({
8330 + /**
8331 + * The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.
8332 + *
8333 + * @format uri
8334 + */
8335 +uri: string() });
8336 + /**
8337 + * Parameters for a `resources/read` request.
8338 + */
8339 + var ReadResourceRequestParamsSchema = ResourceRequestParamsSchema;
8340 + /**
8341 + * Sent from the client to the server, to read a specific resource URI.
8342 + */
8343 + var ReadResourceRequestSchema = RequestSchema.extend({
8344 + method: literal("resources/read"),
8345 + params: ReadResourceRequestParamsSchema
8346 + });
8347 + /**
8348 + * The server's response to a resources/read request from the client.
8349 + */
8350 + var ReadResourceResultSchema = ResultSchema.extend({ contents: array(union([TextResourceContentsSchema, BlobResourceContentsSchema])) });
8351 + /**
8352 + * An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This may be issued by servers without any previous subscription from the client.
8353 + */
8354 + var ResourceListChangedNotificationSchema = NotificationSchema.extend({
8355 + method: literal("notifications/resources/list_changed"),
8356 + params: NotificationsParamsSchema.optional()
8357 + });
8358 + var SubscribeRequestParamsSchema = ResourceRequestParamsSchema;
8359 + /**
8360 + * Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.
8361 + */
8362 + var SubscribeRequestSchema = RequestSchema.extend({
8363 + method: literal("resources/subscribe"),
8364 + params: SubscribeRequestParamsSchema
8365 + });
8366 + var UnsubscribeRequestParamsSchema = ResourceRequestParamsSchema;
8367 + /**
8368 + * Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.
8369 + */
8370 + var UnsubscribeRequestSchema = RequestSchema.extend({
8371 + method: literal("resources/unsubscribe"),
8372 + params: UnsubscribeRequestParamsSchema
8373 + });
8374 + /**
8375 + * Parameters for a `notifications/resources/updated` notification.
8376 + */
8377 + var ResourceUpdatedNotificationParamsSchema = NotificationsParamsSchema.extend({
8378 + /**
8379 + * The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.
8380 + */
8381 +uri: string() });
8382 + /**
8383 + * A notification from the server to the client, informing it that a resource has changed and may need to be read again. This should only be sent if the client previously sent a resources/subscribe request.
8384 + */
8385 + var ResourceUpdatedNotificationSchema = NotificationSchema.extend({
8386 + method: literal("notifications/resources/updated"),
8387 + params: ResourceUpdatedNotificationParamsSchema
8388 + });
8389 + /**
8390 + * Describes an argument that a prompt can accept.
8391 + */
8392 + var PromptArgumentSchema = object({
8393 + /**
8394 + * The name of the argument.
8395 + */
8396 + name: string(),
8397 + /**
8398 + * A human-readable description of the argument.
8399 + */
8400 + description: optional(string()),
8401 + /**
8402 + * Whether this argument must be provided.
8403 + */
8404 + required: optional(boolean())
8405 + });
8406 + /**
8407 + * A prompt or prompt template that the server offers.
8408 + */
8409 + var PromptSchema = object({
8410 + ...BaseMetadataSchema.shape,
8411 + ...IconsSchema.shape,
8412 + /**
8413 + * An optional description of what this prompt provides
8414 + */
8415 + description: optional(string()),
8416 + /**
8417 + * A list of arguments to use for templating the prompt.
8418 + */
8419 + arguments: optional(array(PromptArgumentSchema)),
8420 + /**
8421 + * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
8422 + * for notes on _meta usage.
8423 + */
8424 + _meta: optional(looseObject({}))
8425 + });
8426 + /**
8427 + * Sent from the client to request a list of prompts and prompt templates the server has.
8428 + */
8429 + var ListPromptsRequestSchema = PaginatedRequestSchema.extend({ method: literal("prompts/list") });
8430 + /**
8431 + * The server's response to a prompts/list request from the client.
8432 + */
8433 + var ListPromptsResultSchema = PaginatedResultSchema.extend({ prompts: array(PromptSchema) });
8434 + /**
8435 + * Parameters for a `prompts/get` request.
8436 + */
8437 + var GetPromptRequestParamsSchema = BaseRequestParamsSchema.extend({
8438 + /**
8439 + * The name of the prompt or prompt template.
8440 + */
8441 + name: string(),
8442 + /**
8443 + * Arguments to use for templating the prompt.
8444 + */
8445 + arguments: record(string(), string()).optional()
8446 + });
8447 + /**
8448 + * Used by the client to get a prompt provided by the server.
8449 + */
8450 + var GetPromptRequestSchema = RequestSchema.extend({
8451 + method: literal("prompts/get"),
8452 + params: GetPromptRequestParamsSchema
8453 + });
8454 + /**
8455 + * Text provided to or from an LLM.
8456 + */
8457 + var TextContentSchema = object({
8458 + type: literal("text"),
8459 + /**
8460 + * The text content of the message.
8461 + */
8462 + text: string(),
8463 + /**
8464 + * Optional annotations for the client.
8465 + */
8466 + annotations: AnnotationsSchema.optional(),
8467 + /**
8468 + * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
8469 + * for notes on _meta usage.
8470 + */
8471 + _meta: record(string(), unknown()).optional()
8472 + });
8473 + /**
8474 + * An image provided to or from an LLM.
8475 + */
8476 + var ImageContentSchema = object({
8477 + type: literal("image"),
8478 + /**
8479 + * The base64-encoded image data.
8480 + */
8481 + data: Base64Schema,
8482 + /**
8483 + * The MIME type of the image. Different providers may support different image types.
8484 + */
8485 + mimeType: string(),
8486 + /**
8487 + * Optional annotations for the client.
8488 + */
8489 + annotations: AnnotationsSchema.optional(),
8490 + /**
8491 + * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
8492 + * for notes on _meta usage.
8493 + */
8494 + _meta: record(string(), unknown()).optional()
8495 + });
8496 + /**
8497 + * An Audio provided to or from an LLM.
8498 + */
8499 + var AudioContentSchema = object({
8500 + type: literal("audio"),
8501 + /**
8502 + * The base64-encoded audio data.
8503 + */
8504 + data: Base64Schema,
8505 + /**
8506 + * The MIME type of the audio. Different providers may support different audio types.
8507 + */
8508 + mimeType: string(),
8509 + /**
8510 + * Optional annotations for the client.
8511 + */
8512 + annotations: AnnotationsSchema.optional(),
8513 + /**
8514 + * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
8515 + * for notes on _meta usage.
8516 + */
8517 + _meta: record(string(), unknown()).optional()
8518 + });
8519 + /**
8520 + * A tool call request from an assistant (LLM).
8521 + * Represents the assistant's request to use a tool.
8522 + */
8523 + var ToolUseContentSchema = object({
8524 + type: literal("tool_use"),
8525 + /**
8526 + * The name of the tool to invoke.
8527 + * Must match a tool name from the request's tools array.
8528 + */
8529 + name: string(),
8530 + /**
8531 + * Unique identifier for this tool call.
8532 + * Used to correlate with ToolResultContent in subsequent messages.
8533 + */
8534 + id: string(),
8535 + /**
8536 + * Arguments to pass to the tool.
8537 + * Must conform to the tool's inputSchema.
8538 + */
8539 + input: record(string(), unknown()),
8540 + /**
8541 + * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
8542 + * for notes on _meta usage.
8543 + */
8544 + _meta: record(string(), unknown()).optional()
8545 + });
8546 + /**
8547 + * The contents of a resource, embedded into a prompt or tool call result.
8548 + */
8549 + var EmbeddedResourceSchema = object({
8550 + type: literal("resource"),
8551 + resource: union([TextResourceContentsSchema, BlobResourceContentsSchema]),
8552 + /**
8553 + * Optional annotations for the client.
8554 + */
8555 + annotations: AnnotationsSchema.optional(),
8556 + /**
8557 + * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
8558 + * for notes on _meta usage.
8559 + */
8560 + _meta: record(string(), unknown()).optional()
8561 + });
8562 + /**
8563 + * A resource that the server is capable of reading, included in a prompt or tool call result.
8564 + *
8565 + * Note: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests.
8566 + */
8567 + var ResourceLinkSchema = ResourceSchema.extend({ type: literal("resource_link") });
8568 + /**
8569 + * A content block that can be used in prompts and tool results.
8570 + */
8571 + var ContentBlockSchema = union([
8572 + TextContentSchema,
8573 + ImageContentSchema,
8574 + AudioContentSchema,
8575 + ResourceLinkSchema,
8576 + EmbeddedResourceSchema
8577 + ]);
8578 + /**
8579 + * Describes a message returned as part of a prompt.
8580 + */
8581 + var PromptMessageSchema = object({
8582 + role: RoleSchema,
8583 + content: ContentBlockSchema
8584 + });
8585 + /**
8586 + * The server's response to a prompts/get request from the client.
8587 + */
8588 + var GetPromptResultSchema = ResultSchema.extend({
8589 + /**
8590 + * An optional description for the prompt.
8591 + */
8592 + description: string().optional(),
8593 + messages: array(PromptMessageSchema)
8594 + });
8595 + /**
8596 + * An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This may be issued by servers without any previous subscription from the client.
8597 + */
8598 + var PromptListChangedNotificationSchema = NotificationSchema.extend({
8599 + method: literal("notifications/prompts/list_changed"),
8600 + params: NotificationsParamsSchema.optional()
8601 + });
8602 + /**
8603 + * Additional properties describing a Tool to clients.
8604 + *
8605 + * NOTE: all properties in ToolAnnotations are **hints**.
8606 + * They are not guaranteed to provide a faithful description of
8607 + * tool behavior (including descriptive properties like `title`).
8608 + *
8609 + * Clients should never make tool use decisions based on ToolAnnotations
8610 + * received from untrusted servers.
8611 + */
8612 + var ToolAnnotationsSchema = object({
8613 + /**
8614 + * A human-readable title for the tool.
8615 + */
8616 + title: string().optional(),
8617 + /**
8618 + * If true, the tool does not modify its environment.
8619 + *
8620 + * Default: false
8621 + */
8622 + readOnlyHint: boolean().optional(),
8623 + /**
8624 + * If true, the tool may perform destructive updates to its environment.
8625 + * If false, the tool performs only additive updates.
8626 + *
8627 + * (This property is meaningful only when `readOnlyHint == false`)
8628 + *
8629 + * Default: true
8630 + */
8631 + destructiveHint: boolean().optional(),
8632 + /**
8633 + * If true, calling the tool repeatedly with the same arguments
8634 + * will have no additional effect on the its environment.
8635 + *
8636 + * (This property is meaningful only when `readOnlyHint == false`)
8637 + *
8638 + * Default: false
8639 + */
8640 + idempotentHint: boolean().optional(),
8641 + /**
8642 + * If true, this tool may interact with an "open world" of external
8643 + * entities. If false, the tool's domain of interaction is closed.
8644 + * For example, the world of a web search tool is open, whereas that
8645 + * of a memory tool is not.
8646 + *
8647 + * Default: true
8648 + */
8649 + openWorldHint: boolean().optional()
8650 + });
8651 + /**
8652 + * Execution-related properties for a tool.
8653 + */
8654 + var ToolExecutionSchema = object({
8655 + /**
8656 + * Indicates the tool's preference for task-augmented execution.
8657 + * - "required": Clients MUST invoke the tool as a task
8658 + * - "optional": Clients MAY invoke the tool as a task or normal request
8659 + * - "forbidden": Clients MUST NOT attempt to invoke the tool as a task
8660 + *
8661 + * If not present, defaults to "forbidden".
8662 + */
8663 +taskSupport: _enum([
8664 + "required",
8665 + "optional",
8666 + "forbidden"
8667 + ]).optional() });
8668 + /**
8669 + * Definition for a tool the client can call.
8670 + */
8671 + var ToolSchema = object({
8672 + ...BaseMetadataSchema.shape,
8673 + ...IconsSchema.shape,
8674 + /**
8675 + * A human-readable description of the tool.
8676 + */
8677 + description: string().optional(),
8678 + /**
8679 + * A JSON Schema 2020-12 object defining the expected parameters for the tool.
8680 + * Must have type: 'object' at the root level per MCP spec.
8681 + */
8682 + inputSchema: object({
8683 + type: literal("object"),
8684 + properties: record(string(), AssertObjectSchema).optional(),
8685 + required: array(string()).optional()
8686 + }).catchall(unknown()),
8687 + /**
8688 + * An optional JSON Schema 2020-12 object defining the structure of the tool's output
8689 + * returned in the structuredContent field of a CallToolResult.
8690 + * Must have type: 'object' at the root level per MCP spec.
8691 + */
8692 + outputSchema: object({
8693 + type: literal("object"),
8694 + properties: record(string(), AssertObjectSchema).optional(),
8695 + required: array(string()).optional()
8696 + }).catchall(unknown()).optional(),
8697 + /**
8698 + * Optional additional tool information.
8699 + */
8700 + annotations: ToolAnnotationsSchema.optional(),
8701 + /**
8702 + * Execution-related properties for this tool.
8703 + */
8704 + execution: ToolExecutionSchema.optional(),
8705 + /**
8706 + * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
8707 + * for notes on _meta usage.
8708 + */
8709 + _meta: record(string(), unknown()).optional()
8710 + });
8711 + /**
8712 + * Sent from the client to request a list of tools the server has.
8713 + */
8714 + var ListToolsRequestSchema = PaginatedRequestSchema.extend({ method: literal("tools/list") });
8715 + /**
8716 + * The server's response to a tools/list request from the client.
8717 + */
8718 + var ListToolsResultSchema = PaginatedResultSchema.extend({ tools: array(ToolSchema) });
8719 + /**
8720 + * The server's response to a tool call.
8721 + */
8722 + var CallToolResultSchema = ResultSchema.extend({
8723 + /**
8724 + * A list of content objects that represent the result of the tool call.
8725 + *
8726 + * If the Tool does not define an outputSchema, this field MUST be present in the result.
8727 + * For backwards compatibility, this field is always present, but it may be empty.
8728 + */
8729 + content: array(ContentBlockSchema).default([]),
8730 + /**
8731 + * An object containing structured tool output.
8732 + *
8733 + * If the Tool defines an outputSchema, this field MUST be present in the result, and contain a JSON object that matches the schema.
8734 + */
8735 + structuredContent: record(string(), unknown()).optional(),
8736 + /**
8737 + * Whether the tool call ended in an error.
8738 + *
8739 + * If not set, this is assumed to be false (the call was successful).
8740 + *
8741 + * Any errors that originate from the tool SHOULD be reported inside the result
8742 + * object, with `isError` set to true, _not_ as an MCP protocol-level error
8743 + * response. Otherwise, the LLM would not be able to see that an error occurred
8744 + * and self-correct.
8745 + *
8746 + * However, any errors in _finding_ the tool, an error indicating that the
8747 + * server does not support tool calls, or any other exceptional conditions,
8748 + * should be reported as an MCP error response.
8749 + */
8750 + isError: boolean().optional()
8751 + });
8752 + /**
8753 + * CallToolResultSchema extended with backwards compatibility to protocol version 2024-10-07.
8754 + */
8755 + var CompatibilityCallToolResultSchema = CallToolResultSchema.or(ResultSchema.extend({ toolResult: unknown() }));
8756 + /**
8757 + * Parameters for a `tools/call` request.
8758 + */
8759 + var CallToolRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
8760 + /**
8761 + * The name of the tool to call.
8762 + */
8763 + name: string(),
8764 + /**
8765 + * Arguments to pass to the tool.
8766 + */
8767 + arguments: record(string(), unknown()).optional()
8768 + });
8769 + /**
8770 + * Used by the client to invoke a tool provided by the server.
8771 + */
8772 + var CallToolRequestSchema = RequestSchema.extend({
8773 + method: literal("tools/call"),
8774 + params: CallToolRequestParamsSchema
8775 + });
8776 + /**
8777 + * An optional notification from the server to the client, informing it that the list of tools it offers has changed. This may be issued by servers without any previous subscription from the client.
8778 + */
8779 + var ToolListChangedNotificationSchema = NotificationSchema.extend({
8780 + method: literal("notifications/tools/list_changed"),
8781 + params: NotificationsParamsSchema.optional()
8782 + });
8783 + /**
8784 + * Base schema for list changed subscription options (without callback).
8785 + * Used internally for Zod validation of autoRefresh and debounceMs.
8786 + */
8787 + var ListChangedOptionsBaseSchema = object({
8788 + /**
8789 + * If true, the list will be refreshed automatically when a list changed notification is received.
8790 + * The callback will be called with the updated list.
8791 + *
8792 + * If false, the callback will be called with null items, allowing manual refresh.
8793 + *
8794 + * @default true
8795 + */
8796 + autoRefresh: boolean().default(true),
8797 + /**
8798 + * Debounce time in milliseconds for list changed notification processing.
8799 + *
8800 + * Multiple notifications received within this timeframe will only trigger one refresh.
8801 + * Set to 0 to disable debouncing.
8802 + *
8803 + * @default 300
8804 + */
8805 + debounceMs: number().int().nonnegative().default(300)
8806 + });
8807 + /**
8808 + * The severity of a log message.
8809 + */
8810 + var LoggingLevelSchema = _enum([
8811 + "debug",
8812 + "info",
8813 + "notice",
8814 + "warning",
8815 + "error",
8816 + "critical",
8817 + "alert",
8818 + "emergency"
8819 + ]);
8820 + /**
8821 + * Parameters for a `logging/setLevel` request.
8822 + */
8823 + var SetLevelRequestParamsSchema = BaseRequestParamsSchema.extend({
8824 + /**
8825 + * The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/logging/message.
8826 + */
8827 +level: LoggingLevelSchema });
8828 + /**
8829 + * A request from the client to the server, to enable or adjust logging.
8830 + */
8831 + var SetLevelRequestSchema = RequestSchema.extend({
8832 + method: literal("logging/setLevel"),
8833 + params: SetLevelRequestParamsSchema
8834 + });
8835 + /**
8836 + * Parameters for a `notifications/message` notification.
8837 + */
8838 + var LoggingMessageNotificationParamsSchema = NotificationsParamsSchema.extend({
8839 + /**
8840 + * The severity of this log message.
8841 + */
8842 + level: LoggingLevelSchema,
8843 + /**
8844 + * An optional name of the logger issuing this message.
8845 + */
8846 + logger: string().optional(),
8847 + /**
8848 + * The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.
8849 + */
8850 + data: unknown()
8851 + });
8852 + /**
8853 + * Notification of a log message passed from server to client. If no logging/setLevel request has been sent from the client, the server MAY decide which messages to send automatically.
8854 + */
8855 + var LoggingMessageNotificationSchema = NotificationSchema.extend({
8856 + method: literal("notifications/message"),
8857 + params: LoggingMessageNotificationParamsSchema
8858 + });
8859 + /**
8860 + * Hints to use for model selection.
8861 + */
8862 + var ModelHintSchema = object({
8863 + /**
8864 + * A hint for a model name.
8865 + */
8866 +name: string().optional() });
8867 + /**
8868 + * The server's preferences for model selection, requested of the client during sampling.
8869 + */
8870 + var ModelPreferencesSchema = object({
8871 + /**
8872 + * Optional hints to use for model selection.
8873 + */
8874 + hints: array(ModelHintSchema).optional(),
8875 + /**
8876 + * How much to prioritize cost when selecting a model.
8877 + */
8878 + costPriority: number().min(0).max(1).optional(),
8879 + /**
8880 + * How much to prioritize sampling speed (latency) when selecting a model.
8881 + */
8882 + speedPriority: number().min(0).max(1).optional(),
8883 + /**
8884 + * How much to prioritize intelligence and capabilities when selecting a model.
8885 + */
8886 + intelligencePriority: number().min(0).max(1).optional()
8887 + });
8888 + /**
8889 + * Controls tool usage behavior in sampling requests.
8890 + */
8891 + var ToolChoiceSchema = object({
8892 + /**
8893 + * Controls when tools are used:
8894 + * - "auto": Model decides whether to use tools (default)
8895 + * - "required": Model MUST use at least one tool before completing
8896 + * - "none": Model MUST NOT use any tools
8897 + */
8898 +mode: _enum([
8899 + "auto",
8900 + "required",
8901 + "none"
8902 + ]).optional() });
8903 + /**
8904 + * The result of a tool execution, provided by the user (server).
8905 + * Represents the outcome of invoking a tool requested via ToolUseContent.
8906 + */
8907 + var ToolResultContentSchema = object({
8908 + type: literal("tool_result"),
8909 + toolUseId: string().describe("The unique identifier for the corresponding tool call."),
8910 + content: array(ContentBlockSchema).default([]),
8911 + structuredContent: object({}).loose().optional(),
8912 + isError: boolean().optional(),
8913 + /**
8914 + * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
8915 + * for notes on _meta usage.
8916 + */
8917 + _meta: record(string(), unknown()).optional()
8918 + });
8919 + /**
8920 + * Basic content types for sampling responses (without tool use).
8921 + * Used for backwards-compatible CreateMessageResult when tools are not used.
8922 + */
8923 + var SamplingContentSchema = discriminatedUnion("type", [
8924 + TextContentSchema,
8925 + ImageContentSchema,
8926 + AudioContentSchema
8927 + ]);
8928 + /**
8929 + * Content block types allowed in sampling messages.
8930 + * This includes text, image, audio, tool use requests, and tool results.
8931 + */
8932 + var SamplingMessageContentBlockSchema = discriminatedUnion("type", [
8933 + TextContentSchema,
8934 + ImageContentSchema,
8935 + AudioContentSchema,
8936 + ToolUseContentSchema,
8937 + ToolResultContentSchema
8938 + ]);
8939 + /**
8940 + * Describes a message issued to or received from an LLM API.
8941 + */
8942 + var SamplingMessageSchema = object({
8943 + role: RoleSchema,
8944 + content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)]),
8945 + /**
8946 + * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
8947 + * for notes on _meta usage.
8948 + */
8949 + _meta: record(string(), unknown()).optional()
8950 + });
8951 + /**
8952 + * Parameters for a `sampling/createMessage` request.
8953 + */
8954 + var CreateMessageRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
8955 + messages: array(SamplingMessageSchema),
8956 + /**
8957 + * The server's preferences for which model to select. The client MAY modify or omit this request.
8958 + */
8959 + modelPreferences: ModelPreferencesSchema.optional(),
8960 + /**
8961 + * An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.
8962 + */
8963 + systemPrompt: string().optional(),
8964 + /**
8965 + * A request to include context from one or more MCP servers (including the caller), to be attached to the prompt.
8966 + * The client MAY ignore this request.
8967 + *
8968 + * Default is "none". Values "thisServer" and "allServers" are soft-deprecated. Servers SHOULD only use these values if the client
8969 + * declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.
8970 + */
8971 + includeContext: _enum([
8972 + "none",
8973 + "thisServer",
8974 + "allServers"
8975 + ]).optional(),
8976 + temperature: number().optional(),
8977 + /**
8978 + * The requested maximum number of tokens to sample (to prevent runaway completions).
8979 + *
8980 + * The client MAY choose to sample fewer tokens than the requested maximum.
8981 + */
8982 + maxTokens: number().int(),
8983 + stopSequences: array(string()).optional(),
8984 + /**
8985 + * Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
8986 + */
8987 + metadata: AssertObjectSchema.optional(),
8988 + /**
8989 + * Tools that the model may use during generation.
8990 + * The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
8991 + */
8992 + tools: array(ToolSchema).optional(),
8993 + /**
8994 + * Controls how the model uses tools.
8995 + * The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
8996 + * Default is `{ mode: "auto" }`.
8997 + */
8998 + toolChoice: ToolChoiceSchema.optional()
8999 + });
9000 + /**
9001 + * A request from the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling, to allow them to inspect the request (human in the loop) and decide whether to approve it.
9002 + */
9003 + var CreateMessageRequestSchema = RequestSchema.extend({
9004 + method: literal("sampling/createMessage"),
9005 + params: CreateMessageRequestParamsSchema
9006 + });
9007 + /**
9008 + * The client's response to a sampling/create_message request from the server.
9009 + * This is the backwards-compatible version that returns single content (no arrays).
9010 + * Used when the request does not include tools.
9011 + */
9012 + var CreateMessageResultSchema = ResultSchema.extend({
9013 + /**
9014 + * The name of the model that generated the message.
9015 + */
9016 + model: string(),
9017 + /**
9018 + * The reason why sampling stopped, if known.
9019 + *
9020 + * Standard values:
9021 + * - "endTurn": Natural end of the assistant's turn
9022 + * - "stopSequence": A stop sequence was encountered
9023 + * - "maxTokens": Maximum token limit was reached
9024 + *
9025 + * This field is an open string to allow for provider-specific stop reasons.
9026 + */
9027 + stopReason: optional(_enum([
9028 + "endTurn",
9029 + "stopSequence",
9030 + "maxTokens"
9031 + ]).or(string())),
9032 + role: RoleSchema,
9033 + /**
9034 + * Response content. Single content block (text, image, or audio).
9035 + */
9036 + content: SamplingContentSchema
9037 + });
9038 + /**
9039 + * The client's response to a sampling/create_message request when tools were provided.
9040 + * This version supports array content for tool use flows.
9041 + */
9042 + var CreateMessageResultWithToolsSchema = ResultSchema.extend({
9043 + /**
9044 + * The name of the model that generated the message.
9045 + */
9046 + model: string(),
9047 + /**
9048 + * The reason why sampling stopped, if known.
9049 + *
9050 + * Standard values:
9051 + * - "endTurn": Natural end of the assistant's turn
9052 + * - "stopSequence": A stop sequence was encountered
9053 + * - "maxTokens": Maximum token limit was reached
9054 + * - "toolUse": The model wants to use one or more tools
9055 + *
9056 + * This field is an open string to allow for provider-specific stop reasons.
9057 + */
9058 + stopReason: optional(_enum([
9059 + "endTurn",
9060 + "stopSequence",
9061 + "maxTokens",
9062 + "toolUse"
9063 + ]).or(string())),
9064 + role: RoleSchema,
9065 + /**
9066 + * Response content. May be a single block or array. May include ToolUseContent if stopReason is "toolUse".
9067 + */
9068 + content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)])
9069 + });
9070 + /**
9071 + * Primitive schema definition for boolean fields.
9072 + */
9073 + var BooleanSchemaSchema = object({
9074 + type: literal("boolean"),
9075 + title: string().optional(),
9076 + description: string().optional(),
9077 + default: boolean().optional()
9078 + });
9079 + /**
9080 + * Primitive schema definition for string fields.
9081 + */
9082 + var StringSchemaSchema = object({
9083 + type: literal("string"),
9084 + title: string().optional(),
9085 + description: string().optional(),
9086 + minLength: number().optional(),
9087 + maxLength: number().optional(),
9088 + format: _enum([
9089 + "email",
9090 + "uri",
9091 + "date",
9092 + "date-time"
9093 + ]).optional(),
9094 + default: string().optional()
9095 + });
9096 + /**
9097 + * Primitive schema definition for number fields.
9098 + */
9099 + var NumberSchemaSchema = object({
9100 + type: _enum(["number", "integer"]),
9101 + title: string().optional(),
9102 + description: string().optional(),
9103 + minimum: number().optional(),
9104 + maximum: number().optional(),
9105 + default: number().optional()
9106 + });
9107 + /**
9108 + * Schema for single-selection enumeration without display titles for options.
9109 + */
9110 + var UntitledSingleSelectEnumSchemaSchema = object({
9111 + type: literal("string"),
9112 + title: string().optional(),
9113 + description: string().optional(),
9114 + enum: array(string()),
9115 + default: string().optional()
9116 + });
9117 + /**
9118 + * Schema for single-selection enumeration with display titles for each option.
9119 + */
9120 + var TitledSingleSelectEnumSchemaSchema = object({
9121 + type: literal("string"),
9122 + title: string().optional(),
9123 + description: string().optional(),
9124 + oneOf: array(object({
9125 + const: string(),
9126 + title: string()
9127 + })),
9128 + default: string().optional()
9129 + });
9130 + /**
9131 + * Use TitledSingleSelectEnumSchema instead.
9132 + * This interface will be removed in a future version.
9133 + */
9134 + var LegacyTitledEnumSchemaSchema = object({
9135 + type: literal("string"),
9136 + title: string().optional(),
9137 + description: string().optional(),
9138 + enum: array(string()),
9139 + enumNames: array(string()).optional(),
9140 + default: string().optional()
9141 + });
9142 + var SingleSelectEnumSchemaSchema = union([UntitledSingleSelectEnumSchemaSchema, TitledSingleSelectEnumSchemaSchema]);
9143 + /**
9144 + * Schema for multiple-selection enumeration without display titles for options.
9145 + */
9146 + var UntitledMultiSelectEnumSchemaSchema = object({
9147 + type: literal("array"),
9148 + title: string().optional(),
9149 + description: string().optional(),
9150 + minItems: number().optional(),
9151 + maxItems: number().optional(),
9152 + items: object({
9153 + type: literal("string"),
9154 + enum: array(string())
9155 + }),
9156 + default: array(string()).optional()
9157 + });
9158 + /**
9159 + * Schema for multiple-selection enumeration with display titles for each option.
9160 + */
9161 + var TitledMultiSelectEnumSchemaSchema = object({
9162 + type: literal("array"),
9163 + title: string().optional(),
9164 + description: string().optional(),
9165 + minItems: number().optional(),
9166 + maxItems: number().optional(),
9167 + items: object({ anyOf: array(object({
9168 + const: string(),
9169 + title: string()
9170 + })) }),
9171 + default: array(string()).optional()
9172 + });
9173 + /**
9174 + * Combined schema for multiple-selection enumeration
9175 + */
9176 + var MultiSelectEnumSchemaSchema = union([UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema]);
9177 + /**
9178 + * Primitive schema definition for enum fields.
9179 + */
9180 + var EnumSchemaSchema = union([
9181 + LegacyTitledEnumSchemaSchema,
9182 + SingleSelectEnumSchemaSchema,
9183 + MultiSelectEnumSchemaSchema
9184 + ]);
9185 + /**
9186 + * Union of all primitive schema definitions.
9187 + */
9188 + var PrimitiveSchemaDefinitionSchema = union([
9189 + EnumSchemaSchema,
9190 + BooleanSchemaSchema,
9191 + StringSchemaSchema,
9192 + NumberSchemaSchema
9193 + ]);
9194 + /**
9195 + * Parameters for an `elicitation/create` request for form-based elicitation.
9196 + */
9197 + var ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.extend({
9198 + /**
9199 + * The elicitation mode.
9200 + *
9201 + * Optional for backward compatibility. Clients MUST treat missing mode as "form".
9202 + */
9203 + mode: literal("form").optional(),
9204 + /**
9205 + * The message to present to the user describing what information is being requested.
9206 + */
9207 + message: string(),
9208 + /**
9209 + * A restricted subset of JSON Schema.
9210 + * Only top-level properties are allowed, without nesting.
9211 + */
9212 + requestedSchema: object({
9213 + type: literal("object"),
9214 + properties: record(string(), PrimitiveSchemaDefinitionSchema),
9215 + required: array(string()).optional()
9216 + })
9217 + });
9218 + /**
9219 + * Parameters for an `elicitation/create` request for URL-based elicitation.
9220 + */
9221 + var ElicitRequestURLParamsSchema = TaskAugmentedRequestParamsSchema.extend({
9222 + /**
9223 + * The elicitation mode.
9224 + */
9225 + mode: literal("url"),
9226 + /**
9227 + * The message to present to the user explaining why the interaction is needed.
9228 + */
9229 + message: string(),
9230 + /**
9231 + * The ID of the elicitation, which must be unique within the context of the server.
9232 + * The client MUST treat this ID as an opaque value.
9233 + */
9234 + elicitationId: string(),
9235 + /**
9236 + * The URL that the user should navigate to.
9237 + */
9238 + url: string().url()
9239 + });
9240 + /**
9241 + * The parameters for a request to elicit additional information from the user via the client.
9242 + */
9243 + var ElicitRequestParamsSchema = union([ElicitRequestFormParamsSchema, ElicitRequestURLParamsSchema]);
9244 + /**
9245 + * A request from the server to elicit user input via the client.
9246 + * The client should present the message and form fields to the user (form mode)
9247 + * or navigate to a URL (URL mode).
9248 + */
9249 + var ElicitRequestSchema = RequestSchema.extend({
9250 + method: literal("elicitation/create"),
9251 + params: ElicitRequestParamsSchema
9252 + });
9253 + /**
9254 + * Parameters for a `notifications/elicitation/complete` notification.
9255 + *
9256 + * @category notifications/elicitation/complete
9257 + */
9258 + var ElicitationCompleteNotificationParamsSchema = NotificationsParamsSchema.extend({
9259 + /**
9260 + * The ID of the elicitation that completed.
9261 + */
9262 +elicitationId: string() });
9263 + /**
9264 + * A notification from the server to the client, informing it of a completion of an out-of-band elicitation request.
9265 + *
9266 + * @category notifications/elicitation/complete
9267 + */
9268 + var ElicitationCompleteNotificationSchema = NotificationSchema.extend({
9269 + method: literal("notifications/elicitation/complete"),
9270 + params: ElicitationCompleteNotificationParamsSchema
9271 + });
9272 + /**
9273 + * The client's response to an elicitation/create request from the server.
9274 + */
9275 + var ElicitResultSchema = ResultSchema.extend({
9276 + /**
9277 + * The user action in response to the elicitation.
9278 + * - "accept": User submitted the form/confirmed the action
9279 + * - "decline": User explicitly decline the action
9280 + * - "cancel": User dismissed without making an explicit choice
9281 + */
9282 + action: _enum([
9283 + "accept",
9284 + "decline",
9285 + "cancel"
9286 + ]),
9287 + /**
9288 + * The submitted form data, only present when action is "accept".
9289 + * Contains values matching the requested schema.
9290 + * Per MCP spec, content is "typically omitted" for decline/cancel actions.
9291 + * We normalize null to undefined for leniency while maintaining type compatibility.
9292 + */
9293 + content: preprocess((val) => val === null ? void 0 : val, record(string(), union([
9294 + string(),
9295 + number(),
9296 + boolean(),
9297 + array(string())
9298 + ])).optional())
9299 + });
9300 + /**
9301 + * A reference to a resource or resource template definition.
9302 + */
9303 + var ResourceTemplateReferenceSchema = object({
9304 + type: literal("ref/resource"),
9305 + /**
9306 + * The URI or URI template of the resource.
9307 + */
9308 + uri: string()
9309 + });
9310 + /**
9311 + * Identifies a prompt.
9312 + */
9313 + var PromptReferenceSchema = object({
9314 + type: literal("ref/prompt"),
9315 + /**
9316 + * The name of the prompt or prompt template
9317 + */
9318 + name: string()
9319 + });
9320 + /**
9321 + * Parameters for a `completion/complete` request.
9322 + */
9323 + var CompleteRequestParamsSchema = BaseRequestParamsSchema.extend({
9324 + ref: union([PromptReferenceSchema, ResourceTemplateReferenceSchema]),
9325 + /**
9326 + * The argument's information
9327 + */
9328 + argument: object({
9329 + /**
9330 + * The name of the argument
9331 + */
9332 + name: string(),
9333 + /**
9334 + * The value of the argument to use for completion matching.
9335 + */
9336 + value: string()
9337 + }),
9338 + context: object({
9339 + /**
9340 + * Previously-resolved variables in a URI template or prompt.
9341 + */
9342 +arguments: record(string(), string()).optional() }).optional()
9343 + });
9344 + /**
9345 + * A request from the client to the server, to ask for completion options.
9346 + */
9347 + var CompleteRequestSchema = RequestSchema.extend({
9348 + method: literal("completion/complete"),
9349 + params: CompleteRequestParamsSchema
9350 + });
9351 + function assertCompleteRequestPrompt(request) {
9352 + if (request.params.ref.type !== "ref/prompt") throw new TypeError(`Expected CompleteRequestPrompt, but got ${request.params.ref.type}`);
9353 + }
9354 + function assertCompleteRequestResourceTemplate(request) {
9355 + if (request.params.ref.type !== "ref/resource") throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${request.params.ref.type}`);
9356 + }
9357 + /**
9358 + * The server's response to a completion/complete request
9359 + */
9360 + var CompleteResultSchema = ResultSchema.extend({ completion: looseObject({
9361 + /**
9362 + * An array of completion values. Must not exceed 100 items.
9363 + */
9364 + values: array(string()).max(100),
9365 + /**
9366 + * The total number of completion options available. This can exceed the number of values actually sent in the response.
9367 + */
9368 + total: optional(number().int()),
9369 + /**
9370 + * Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.
9371 + */
9372 + hasMore: optional(boolean())
9373 + }) });
9374 + /**
9375 + * Represents a root directory or file that the server can operate on.
9376 + */
9377 + var RootSchema = object({
9378 + /**
9379 + * The URI identifying the root. This *must* start with file:// for now.
9380 + */
9381 + uri: string().startsWith("file://"),
9382 + /**
9383 + * An optional name for the root.
9384 + */
9385 + name: string().optional(),
9386 + /**
9387 + * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
9388 + * for notes on _meta usage.
9389 + */
9390 + _meta: record(string(), unknown()).optional()
9391 + });
9392 + /**
9393 + * Sent from the server to request a list of root URIs from the client.
9394 + */
9395 + var ListRootsRequestSchema = RequestSchema.extend({
9396 + method: literal("roots/list"),
9397 + params: BaseRequestParamsSchema.optional()
9398 + });
9399 + /**
9400 + * The client's response to a roots/list request from the server.
9401 + */
9402 + var ListRootsResultSchema = ResultSchema.extend({ roots: array(RootSchema) });
9403 + /**
9404 + * A notification from the client to the server, informing it that the list of roots has changed.
9405 + */
9406 + var RootsListChangedNotificationSchema = NotificationSchema.extend({
9407 + method: literal("notifications/roots/list_changed"),
9408 + params: NotificationsParamsSchema.optional()
9409 + });
9410 + var ClientRequestSchema = union([
9411 + PingRequestSchema,
9412 + InitializeRequestSchema,
9413 + CompleteRequestSchema,
9414 + SetLevelRequestSchema,
9415 + GetPromptRequestSchema,
9416 + ListPromptsRequestSchema,
9417 + ListResourcesRequestSchema,
9418 + ListResourceTemplatesRequestSchema,
9419 + ReadResourceRequestSchema,
9420 + SubscribeRequestSchema,
9421 + UnsubscribeRequestSchema,
9422 + CallToolRequestSchema,
9423 + ListToolsRequestSchema,
9424 + GetTaskRequestSchema,
9425 + GetTaskPayloadRequestSchema,
9426 + ListTasksRequestSchema,
9427 + CancelTaskRequestSchema
9428 + ]);
9429 + var ClientNotificationSchema = union([
9430 + CancelledNotificationSchema,
9431 + ProgressNotificationSchema,
9432 + InitializedNotificationSchema,
9433 + RootsListChangedNotificationSchema,
9434 + TaskStatusNotificationSchema
9435 + ]);
9436 + var ClientResultSchema = union([
9437 + EmptyResultSchema,
9438 + CreateMessageResultSchema,
9439 + CreateMessageResultWithToolsSchema,
9440 + ElicitResultSchema,
9441 + ListRootsResultSchema,
9442 + GetTaskResultSchema,
9443 + ListTasksResultSchema,
9444 + CreateTaskResultSchema
9445 + ]);
9446 + var ServerRequestSchema = union([
9447 + PingRequestSchema,
9448 + CreateMessageRequestSchema,
9449 + ElicitRequestSchema,
9450 + ListRootsRequestSchema,
9451 + GetTaskRequestSchema,
9452 + GetTaskPayloadRequestSchema,
9453 + ListTasksRequestSchema,
9454 + CancelTaskRequestSchema
9455 + ]);
9456 + var ServerNotificationSchema = union([
9457 + CancelledNotificationSchema,
9458 + ProgressNotificationSchema,
9459 + LoggingMessageNotificationSchema,
9460 + ResourceUpdatedNotificationSchema,
9461 + ResourceListChangedNotificationSchema,
9462 + ToolListChangedNotificationSchema,
9463 + PromptListChangedNotificationSchema,
9464 + TaskStatusNotificationSchema,
9465 + ElicitationCompleteNotificationSchema
9466 + ]);
9467 + var ServerResultSchema = union([
9468 + EmptyResultSchema,
9469 + InitializeResultSchema,
9470 + CompleteResultSchema,
9471 + GetPromptResultSchema,
9472 + ListPromptsResultSchema,
9473 + ListResourcesResultSchema,
9474 + ListResourceTemplatesResultSchema,
9475 + ReadResourceResultSchema,
9476 + CallToolResultSchema,
9477 + ListToolsResultSchema,
9478 + GetTaskResultSchema,
9479 + ListTasksResultSchema,
9480 + CreateTaskResultSchema
9481 + ]);
9482 + var McpError = class McpError extends Error {
9483 + constructor(code, message, data) {
9484 + super(`MCP error ${code}: ${message}`);
9485 + this.code = code;
9486 + this.data = data;
9487 + this.name = "McpError";
9488 + }
9489 + /**
9490 + * Factory method to create the appropriate error type based on the error code and data
9491 + */
9492 + static fromError(code, message, data) {
9493 + if (code === ErrorCode.UrlElicitationRequired && data) {
9494 + const errorData = data;
9495 + if (errorData.elicitations) return new UrlElicitationRequiredError(errorData.elicitations, message);
9496 + }
9497 + return new McpError(code, message, data);
9498 + }
9499 + };
9500 + /**
9501 + * Specialized error type when a tool requires a URL mode elicitation.
9502 + * This makes it nicer for the client to handle since there is specific data to work with instead of just a code to check against.
9503 + */
9504 + var UrlElicitationRequiredError = class extends McpError {
9505 + constructor(elicitations, message = `URL elicitation${elicitations.length > 1 ? "s" : ""} required`) {
9506 + super(ErrorCode.UrlElicitationRequired, message, { elicitations });
9507 + }
9508 + get elicitations() {
9509 + return this.data?.elicitations ?? [];
9510 + }
9511 + };
9512 +
9513 +//#endregion
9514 +//#region node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
9515 +/**
9516 + * Experimental task interfaces for MCP SDK.
9517 + * WARNING: These APIs are experimental and may change without notice.
9518 + */
9519 + /**
9520 + * Checks if a task status represents a terminal state.
9521 + * Terminal states are those where the task has finished and will not change.
9522 + *
9523 + * @param status - The task status to check
9524 + * @returns True if the status is terminal (completed, failed, or cancelled)
9525 + * @experimental
9526 + */
9527 + function isTerminal(status) {
9528 + return status === "completed" || status === "failed" || status === "cancelled";
9529 + }
9530 +
9531 +//#endregion
9532 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/Options.js
9533 + var ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
9534 + var defaultOptions = {
9535 + name: void 0,
9536 + $refStrategy: "root",
9537 + basePath: ["#"],
9538 + effectStrategy: "input",
9539 + pipeStrategy: "all",
9540 + dateStrategy: "format:date-time",
9541 + mapStrategy: "entries",
9542 + removeAdditionalStrategy: "passthrough",
9543 + allowedAdditionalProperties: true,
9544 + rejectedAdditionalProperties: false,
9545 + definitionPath: "definitions",
9546 + target: "jsonSchema7",
9547 + strictUnions: false,
9548 + definitions: {},
9549 + errorMessages: false,
9550 + markdownDescription: false,
9551 + patternStrategy: "escape",
9552 + applyRegexFlags: false,
9553 + emailStrategy: "format:email",
9554 + base64Strategy: "contentEncoding:base64",
9555 + nameStrategy: "ref",
9556 + openAiAnyTypeName: "OpenAiAnyType"
9557 + };
9558 + var getDefaultOptions = (options) => typeof options === "string" ? {
9559 + ...defaultOptions,
9560 + name: options
9561 + } : {
9562 + ...defaultOptions,
9563 + ...options
9564 + };
9565 +
9566 +//#endregion
9567 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/Refs.js
9568 + var getRefs = (options) => {
9569 + const _options = getDefaultOptions(options);
9570 + const currentPath = _options.name !== void 0 ? [
9571 + ..._options.basePath,
9572 + _options.definitionPath,
9573 + _options.name
9574 + ] : _options.basePath;
9575 + return {
9576 + ..._options,
9577 + flags: { hasReferencedOpenAiAnyType: false },
9578 + currentPath,
9579 + propertyPath: void 0,
9580 + seen: new Map(Object.entries(_options.definitions).map(([name, def]) => [def._def, {
9581 + def: def._def,
9582 + path: [
9583 + ..._options.basePath,
9584 + _options.definitionPath,
9585 + name
9586 + ],
9587 + jsonSchema: void 0
9588 + }]))
9589 + };
9590 + };
9591 +
9592 +//#endregion
9593 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/errorMessages.js
9594 + function addErrorMessage(res, key, errorMessage, refs) {
9595 + if (!refs?.errorMessages) return;
9596 + if (errorMessage) res.errorMessage = {
9597 + ...res.errorMessage,
9598 + [key]: errorMessage
9599 + };
9600 + }
9601 + function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
9602 + res[key] = value;
9603 + addErrorMessage(res, key, errorMessage, refs);
9604 + }
9605 +
9606 +//#endregion
9607 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/getRelativePath.js
9608 + var getRelativePath = (pathA, pathB) => {
9609 + let i = 0;
9610 + for (; i < pathA.length && i < pathB.length; i++) if (pathA[i] !== pathB[i]) break;
9611 + return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
9612 + };
9613 +
9614 +//#endregion
9615 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/any.js
9616 + function parseAnyDef(refs) {
9617 + if (refs.target !== "openAi") return {};
9618 + const anyDefinitionPath = [
9619 + ...refs.basePath,
9620 + refs.definitionPath,
9621 + refs.openAiAnyTypeName
9622 + ];
9623 + refs.flags.hasReferencedOpenAiAnyType = true;
9624 + return { $ref: refs.$refStrategy === "relative" ? getRelativePath(anyDefinitionPath, refs.currentPath) : anyDefinitionPath.join("/") };
9625 + }
9626 +
9627 +//#endregion
9628 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/array.js
9629 + function parseArrayDef(def, refs) {
9630 + const res = { type: "array" };
9631 + if (def.type?._def && def.type?._def?.typeName !== ZodFirstPartyTypeKind.ZodAny) res.items = parseDef(def.type._def, {
9632 + ...refs,
9633 + currentPath: [...refs.currentPath, "items"]
9634 + });
9635 + if (def.minLength) setResponseValueAndErrors(res, "minItems", def.minLength.value, def.minLength.message, refs);
9636 + if (def.maxLength) setResponseValueAndErrors(res, "maxItems", def.maxLength.value, def.maxLength.message, refs);
9637 + if (def.exactLength) {
9638 + setResponseValueAndErrors(res, "minItems", def.exactLength.value, def.exactLength.message, refs);
9639 + setResponseValueAndErrors(res, "maxItems", def.exactLength.value, def.exactLength.message, refs);
9640 + }
9641 + return res;
9642 + }
9643 +
9644 +//#endregion
9645 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/bigint.js
9646 + function parseBigintDef(def, refs) {
9647 + const res = {
9648 + type: "integer",
9649 + format: "int64"
9650 + };
9651 + if (!def.checks) return res;
9652 + for (const check of def.checks) switch (check.kind) {
9653 + case "min":
9654 + if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
9655 + else setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
9656 + else {
9657 + if (!check.inclusive) res.exclusiveMinimum = true;
9658 + setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
9659 + }
9660 + break;
9661 + case "max":
9662 + if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
9663 + else setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
9664 + else {
9665 + if (!check.inclusive) res.exclusiveMaximum = true;
9666 + setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
9667 + }
9668 + break;
9669 + case "multipleOf":
9670 + setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
9671 + break;
9672 + }
9673 + return res;
9674 + }
9675 +
9676 +//#endregion
9677 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/boolean.js
9678 + function parseBooleanDef() {
9679 + return { type: "boolean" };
9680 + }
9681 +
9682 +//#endregion
9683 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/branded.js
9684 + function parseBrandedDef(_def, refs) {
9685 + return parseDef(_def.type._def, refs);
9686 + }
9687 +
9688 +//#endregion
9689 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/catch.js
9690 + var parseCatchDef = (def, refs) => {
9691 + return parseDef(def.innerType._def, refs);
9692 + };
9693 +
9694 +//#endregion
9695 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/date.js
9696 + function parseDateDef(def, refs, overrideDateStrategy) {
9697 + const strategy = overrideDateStrategy ?? refs.dateStrategy;
9698 + if (Array.isArray(strategy)) return { anyOf: strategy.map((item, i) => parseDateDef(def, refs, item)) };
9699 + switch (strategy) {
9700 + case "string":
9701 + case "format:date-time": return {
9702 + type: "string",
9703 + format: "date-time"
9704 + };
9705 + case "format:date": return {
9706 + type: "string",
9707 + format: "date"
9708 + };
9709 + case "integer": return integerDateParser(def, refs);
9710 + }
9711 + }
9712 + var integerDateParser = (def, refs) => {
9713 + const res = {
9714 + type: "integer",
9715 + format: "unix-time"
9716 + };
9717 + if (refs.target === "openApi3") return res;
9718 + for (const check of def.checks) switch (check.kind) {
9719 + case "min":
9720 + setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
9721 + break;
9722 + case "max":
9723 + setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
9724 + break;
9725 + }
9726 + return res;
9727 + };
9728 +
9729 +//#endregion
9730 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/default.js
9731 + function parseDefaultDef(_def, refs) {
9732 + return {
9733 + ...parseDef(_def.innerType._def, refs),
9734 + default: _def.defaultValue()
9735 + };
9736 + }
9737 +
9738 +//#endregion
9739 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/effects.js
9740 + function parseEffectsDef(_def, refs) {
9741 + return refs.effectStrategy === "input" ? parseDef(_def.schema._def, refs) : parseAnyDef(refs);
9742 + }
9743 +
9744 +//#endregion
9745 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/enum.js
9746 + function parseEnumDef(def) {
9747 + return {
9748 + type: "string",
9749 + enum: Array.from(def.values)
9750 + };
9751 + }
9752 +
9753 +//#endregion
9754 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/intersection.js
9755 + var isJsonSchema7AllOfType = (type) => {
9756 + if ("type" in type && type.type === "string") return false;
9757 + return "allOf" in type;
9758 + };
9759 + function parseIntersectionDef(def, refs) {
9760 + const allOf = [parseDef(def.left._def, {
9761 + ...refs,
9762 + currentPath: [
9763 + ...refs.currentPath,
9764 + "allOf",
9765 + "0"
9766 + ]
9767 + }), parseDef(def.right._def, {
9768 + ...refs,
9769 + currentPath: [
9770 + ...refs.currentPath,
9771 + "allOf",
9772 + "1"
9773 + ]
9774 + })].filter((x) => !!x);
9775 + let unevaluatedProperties = refs.target === "jsonSchema2019-09" ? { unevaluatedProperties: false } : void 0;
9776 + const mergedAllOf = [];
9777 + allOf.forEach((schema) => {
9778 + if (isJsonSchema7AllOfType(schema)) {
9779 + mergedAllOf.push(...schema.allOf);
9780 + if (schema.unevaluatedProperties === void 0) unevaluatedProperties = void 0;
9781 + } else {
9782 + let nestedSchema = schema;
9783 + if ("additionalProperties" in schema && schema.additionalProperties === false) {
9784 + const { additionalProperties, ...rest } = schema;
9785 + nestedSchema = rest;
9786 + } else unevaluatedProperties = void 0;
9787 + mergedAllOf.push(nestedSchema);
9788 + }
9789 + });
9790 + return mergedAllOf.length ? {
9791 + allOf: mergedAllOf,
9792 + ...unevaluatedProperties
9793 + } : void 0;
9794 + }
9795 +
9796 +//#endregion
9797 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/literal.js
9798 + function parseLiteralDef(def, refs) {
9799 + const parsedType = typeof def.value;
9800 + if (parsedType !== "bigint" && parsedType !== "number" && parsedType !== "boolean" && parsedType !== "string") return { type: Array.isArray(def.value) ? "array" : "object" };
9801 + if (refs.target === "openApi3") return {
9802 + type: parsedType === "bigint" ? "integer" : parsedType,
9803 + enum: [def.value]
9804 + };
9805 + return {
9806 + type: parsedType === "bigint" ? "integer" : parsedType,
9807 + const: def.value
9808 + };
9809 + }
9810 +
9811 +//#endregion
9812 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/string.js
9813 + var emojiRegex = void 0;
9814 + /**
9815 + * Generated from the regular expressions found here as of 2024-05-22:
9816 + * https://github.com/colinhacks/zod/blob/master/src/types.ts.
9817 + *
9818 + * Expressions with /i flag have been changed accordingly.
9819 + */
9820 + var zodPatterns = {
9821 + /**
9822 + * `c` was changed to `[cC]` to replicate /i flag
9823 + */
9824 + cuid: /^[cC][^\s-]{8,}$/,
9825 + cuid2: /^[0-9a-z]+$/,
9826 + ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
9827 + /**
9828 + * `a-z` was added to replicate /i flag
9829 + */
9830 + email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
9831 + /**
9832 + * Constructed a valid Unicode RegExp
9833 + *
9834 + * Lazily instantiate since this type of regex isn't supported
9835 + * in all envs (e.g. React Native).
9836 + *
9837 + * See:
9838 + * https://github.com/colinhacks/zod/issues/2433
9839 + * Fix in Zod:
9840 + * https://github.com/colinhacks/zod/commit/9340fd51e48576a75adc919bff65dbc4a5d4c99b
9841 + */
9842 + emoji: () => {
9843 + if (emojiRegex === void 0) emojiRegex = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
9844 + return emojiRegex;
9845 + },
9846 + /**
9847 + * Unused
9848 + */
9849 + uuid: /^[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}$/,
9850 + /**
9851 + * Unused
9852 + */
9853 + ipv4: /^(?:(?: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])$/,
9854 + ipv4Cidr: /^(?:(?: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])$/,
9855 + /**
9856 + * Unused
9857 + */
9858 + ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
9859 + ipv6Cidr: /^(([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])$/,
9860 + base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
9861 + base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
9862 + nanoid: /^[a-zA-Z0-9_-]{21}$/,
9863 + jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
9864 + };
9865 + function parseStringDef(def, refs) {
9866 + const res = { type: "string" };
9867 + if (def.checks) for (const check of def.checks) switch (check.kind) {
9868 + case "min":
9869 + setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
9870 + break;
9871 + case "max":
9872 + setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
9873 + break;
9874 + case "email":
9875 + switch (refs.emailStrategy) {
9876 + case "format:email":
9877 + addFormat(res, "email", check.message, refs);
9878 + break;
9879 + case "format:idn-email":
9880 + addFormat(res, "idn-email", check.message, refs);
9881 + break;
9882 + case "pattern:zod":
9883 + addPattern(res, zodPatterns.email, check.message, refs);
9884 + break;
9885 + }
9886 + break;
9887 + case "url":
9888 + addFormat(res, "uri", check.message, refs);
9889 + break;
9890 + case "uuid":
9891 + addFormat(res, "uuid", check.message, refs);
9892 + break;
9893 + case "regex":
9894 + addPattern(res, check.regex, check.message, refs);
9895 + break;
9896 + case "cuid":
9897 + addPattern(res, zodPatterns.cuid, check.message, refs);
9898 + break;
9899 + case "cuid2":
9900 + addPattern(res, zodPatterns.cuid2, check.message, refs);
9901 + break;
9902 + case "startsWith":
9903 + addPattern(res, RegExp(`^${escapeLiteralCheckValue(check.value, refs)}`), check.message, refs);
9904 + break;
9905 + case "endsWith":
9906 + addPattern(res, RegExp(`${escapeLiteralCheckValue(check.value, refs)}$`), check.message, refs);
9907 + break;
9908 + case "datetime":
9909 + addFormat(res, "date-time", check.message, refs);
9910 + break;
9911 + case "date":
9912 + addFormat(res, "date", check.message, refs);
9913 + break;
9914 + case "time":
9915 + addFormat(res, "time", check.message, refs);
9916 + break;
9917 + case "duration":
9918 + addFormat(res, "duration", check.message, refs);
9919 + break;
9920 + case "length":
9921 + setResponseValueAndErrors(res, "minLength", typeof res.minLength === "number" ? Math.max(res.minLength, check.value) : check.value, check.message, refs);
9922 + setResponseValueAndErrors(res, "maxLength", typeof res.maxLength === "number" ? Math.min(res.maxLength, check.value) : check.value, check.message, refs);
9923 + break;
9924 + case "includes":
9925 + addPattern(res, RegExp(escapeLiteralCheckValue(check.value, refs)), check.message, refs);
9926 + break;
9927 + case "ip":
9928 + if (check.version !== "v6") addFormat(res, "ipv4", check.message, refs);
9929 + if (check.version !== "v4") addFormat(res, "ipv6", check.message, refs);
9930 + break;
9931 + case "base64url":
9932 + addPattern(res, zodPatterns.base64url, check.message, refs);
9933 + break;
9934 + case "jwt":
9935 + addPattern(res, zodPatterns.jwt, check.message, refs);
9936 + break;
9937 + case "cidr":
9938 + if (check.version !== "v6") addPattern(res, zodPatterns.ipv4Cidr, check.message, refs);
9939 + if (check.version !== "v4") addPattern(res, zodPatterns.ipv6Cidr, check.message, refs);
9940 + break;
9941 + case "emoji":
9942 + addPattern(res, zodPatterns.emoji(), check.message, refs);
9943 + break;
9944 + case "ulid":
9945 + addPattern(res, zodPatterns.ulid, check.message, refs);
9946 + break;
9947 + case "base64":
9948 + switch (refs.base64Strategy) {
9949 + case "format:binary":
9950 + addFormat(res, "binary", check.message, refs);
9951 + break;
9952 + case "contentEncoding:base64":
9953 + setResponseValueAndErrors(res, "contentEncoding", "base64", check.message, refs);
9954 + break;
9955 + case "pattern:zod":
9956 + addPattern(res, zodPatterns.base64, check.message, refs);
9957 + break;
9958 + }
9959 + break;
9960 + case "nanoid": addPattern(res, zodPatterns.nanoid, check.message, refs);
9961 + case "toLowerCase":
9962 + case "toUpperCase":
9963 + case "trim": break;
9964 + default:
9965 + }
9966 + return res;
9967 + }
9968 + function escapeLiteralCheckValue(literal, refs) {
9969 + return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric(literal) : literal;
9970 + }
9971 + var ALPHA_NUMERIC = /* @__PURE__ */ new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
9972 + function escapeNonAlphaNumeric(source) {
9973 + let result = "";
9974 + for (let i = 0; i < source.length; i++) {
9975 + if (!ALPHA_NUMERIC.has(source[i])) result += "\\";
9976 + result += source[i];
9977 + }
9978 + return result;
9979 + }
9980 + function addFormat(schema, value, message, refs) {
9981 + if (schema.format || schema.anyOf?.some((x) => x.format)) {
9982 + if (!schema.anyOf) schema.anyOf = [];
9983 + if (schema.format) {
9984 + schema.anyOf.push({
9985 + format: schema.format,
9986 + ...schema.errorMessage && refs.errorMessages && { errorMessage: { format: schema.errorMessage.format } }
9987 + });
9988 + delete schema.format;
9989 + if (schema.errorMessage) {
9990 + delete schema.errorMessage.format;
9991 + if (Object.keys(schema.errorMessage).length === 0) delete schema.errorMessage;
9992 + }
9993 + }
9994 + schema.anyOf.push({
9995 + format: value,
9996 + ...message && refs.errorMessages && { errorMessage: { format: message } }
9997 + });
9998 + } else setResponseValueAndErrors(schema, "format", value, message, refs);
9999 + }
10000 + function addPattern(schema, regex, message, refs) {
10001 + if (schema.pattern || schema.allOf?.some((x) => x.pattern)) {
10002 + if (!schema.allOf) schema.allOf = [];
10003 + if (schema.pattern) {
10004 + schema.allOf.push({
10005 + pattern: schema.pattern,
10006 + ...schema.errorMessage && refs.errorMessages && { errorMessage: { pattern: schema.errorMessage.pattern } }
10007 + });
10008 + delete schema.pattern;
10009 + if (schema.errorMessage) {
10010 + delete schema.errorMessage.pattern;
10011 + if (Object.keys(schema.errorMessage).length === 0) delete schema.errorMessage;
10012 + }
10013 + }
10014 + schema.allOf.push({
10015 + pattern: stringifyRegExpWithFlags(regex, refs),
10016 + ...message && refs.errorMessages && { errorMessage: { pattern: message } }
10017 + });
10018 + } else setResponseValueAndErrors(schema, "pattern", stringifyRegExpWithFlags(regex, refs), message, refs);
10019 + }
10020 + function stringifyRegExpWithFlags(regex, refs) {
10021 + if (!refs.applyRegexFlags || !regex.flags) return regex.source;
10022 + const flags = {
10023 + i: regex.flags.includes("i"),
10024 + m: regex.flags.includes("m"),
10025 + s: regex.flags.includes("s")
10026 + };
10027 + const source = flags.i ? regex.source.toLowerCase() : regex.source;
10028 + let pattern = "";
10029 + let isEscaped = false;
10030 + let inCharGroup = false;
10031 + let inCharRange = false;
10032 + for (let i = 0; i < source.length; i++) {
10033 + if (isEscaped) {
10034 + pattern += source[i];
10035 + isEscaped = false;
10036 + continue;
10037 + }
10038 + if (flags.i) {
10039 + if (inCharGroup) {
10040 + if (source[i].match(/[a-z]/)) {
10041 + if (inCharRange) {
10042 + pattern += source[i];
10043 + pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
10044 + inCharRange = false;
10045 + } else if (source[i + 1] === "-" && source[i + 2]?.match(/[a-z]/)) {
10046 + pattern += source[i];
10047 + inCharRange = true;
10048 + } else pattern += `${source[i]}${source[i].toUpperCase()}`;
10049 + continue;
10050 + }
10051 + } else if (source[i].match(/[a-z]/)) {
10052 + pattern += `[${source[i]}${source[i].toUpperCase()}]`;
10053 + continue;
10054 + }
10055 + }
10056 + if (flags.m) {
10057 + if (source[i] === "^") {
10058 + pattern += `(^|(?<=[\r\n]))`;
10059 + continue;
10060 + } else if (source[i] === "$") {
10061 + pattern += `($|(?=[\r\n]))`;
10062 + continue;
10063 + }
10064 + }
10065 + if (flags.s && source[i] === ".") {
10066 + pattern += inCharGroup ? `${source[i]}\r\n` : `[${source[i]}\r\n]`;
10067 + continue;
10068 + }
10069 + pattern += source[i];
10070 + if (source[i] === "\\") isEscaped = true;
10071 + else if (inCharGroup && source[i] === "]") inCharGroup = false;
10072 + else if (!inCharGroup && source[i] === "[") inCharGroup = true;
10073 + }
10074 + try {
10075 + new RegExp(pattern);
10076 + } catch {
10077 + console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
10078 + return regex.source;
10079 + }
10080 + return pattern;
10081 + }
10082 +
10083 +//#endregion
10084 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/record.js
10085 + function parseRecordDef(def, refs) {
10086 + if (refs.target === "openAi") console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
10087 + if (refs.target === "openApi3" && def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) return {
10088 + type: "object",
10089 + required: def.keyType._def.values,
10090 + properties: def.keyType._def.values.reduce((acc, key) => ({
10091 + ...acc,
10092 + [key]: parseDef(def.valueType._def, {
10093 + ...refs,
10094 + currentPath: [
10095 + ...refs.currentPath,
10096 + "properties",
10097 + key
10098 + ]
10099 + }) ?? parseAnyDef(refs)
10100 + }), {}),
10101 + additionalProperties: refs.rejectedAdditionalProperties
10102 + };
10103 + const schema = {
10104 + type: "object",
10105 + additionalProperties: parseDef(def.valueType._def, {
10106 + ...refs,
10107 + currentPath: [...refs.currentPath, "additionalProperties"]
10108 + }) ?? refs.allowedAdditionalProperties
10109 + };
10110 + if (refs.target === "openApi3") return schema;
10111 + if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
10112 + const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
10113 + return {
10114 + ...schema,
10115 + propertyNames: keyType
10116 + };
10117 + } else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodEnum) return {
10118 + ...schema,
10119 + propertyNames: { enum: def.keyType._def.values }
10120 + };
10121 + else if (def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
10122 + const { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);
10123 + return {
10124 + ...schema,
10125 + propertyNames: keyType
10126 + };
10127 + }
10128 + return schema;
10129 + }
10130 +
10131 +//#endregion
10132 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/map.js
10133 + function parseMapDef(def, refs) {
10134 + if (refs.mapStrategy === "record") return parseRecordDef(def, refs);
10135 + return {
10136 + type: "array",
10137 + maxItems: 125,
10138 + items: {
10139 + type: "array",
10140 + items: [parseDef(def.keyType._def, {
10141 + ...refs,
10142 + currentPath: [
10143 + ...refs.currentPath,
10144 + "items",
10145 + "items",
10146 + "0"
10147 + ]
10148 + }) || parseAnyDef(refs), parseDef(def.valueType._def, {
10149 + ...refs,
10150 + currentPath: [
10151 + ...refs.currentPath,
10152 + "items",
10153 + "items",
10154 + "1"
10155 + ]
10156 + }) || parseAnyDef(refs)],
10157 + minItems: 2,
10158 + maxItems: 2
10159 + }
10160 + };
10161 + }
10162 +
10163 +//#endregion
10164 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/nativeEnum.js
10165 + function parseNativeEnumDef(def) {
10166 + const object = def.values;
10167 + const actualValues = Object.keys(def.values).filter((key) => {
10168 + return typeof object[object[key]] !== "number";
10169 + }).map((key) => object[key]);
10170 + const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
10171 + return {
10172 + type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
10173 + enum: actualValues
10174 + };
10175 + }
10176 +
10177 +//#endregion
10178 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/never.js
10179 + function parseNeverDef(refs) {
10180 + return refs.target === "openAi" ? void 0 : { not: parseAnyDef({
10181 + ...refs,
10182 + currentPath: [...refs.currentPath, "not"]
10183 + }) };
10184 + }
10185 +
10186 +//#endregion
10187 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/null.js
10188 + function parseNullDef(refs) {
10189 + return refs.target === "openApi3" ? {
10190 + enum: ["null"],
10191 + nullable: true
10192 + } : { type: "null" };
10193 + }
10194 +
10195 +//#endregion
10196 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/union.js
10197 + var primitiveMappings = {
10198 + ZodString: "string",
10199 + ZodNumber: "number",
10200 + ZodBigInt: "integer",
10201 + ZodBoolean: "boolean",
10202 + ZodNull: "null"
10203 + };
10204 + function parseUnionDef(def, refs) {
10205 + if (refs.target === "openApi3") return asAnyOf(def, refs);
10206 + const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
10207 + if (options.every((x) => x._def.typeName in primitiveMappings && (!x._def.checks || !x._def.checks.length))) {
10208 + const types = options.reduce((types, x) => {
10209 + const type = primitiveMappings[x._def.typeName];
10210 + return type && !types.includes(type) ? [...types, type] : types;
10211 + }, []);
10212 + return { type: types.length > 1 ? types : types[0] };
10213 + } else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
10214 + const types = options.reduce((acc, x) => {
10215 + const type = typeof x._def.value;
10216 + switch (type) {
10217 + case "string":
10218 + case "number":
10219 + case "boolean": return [...acc, type];
10220 + case "bigint": return [...acc, "integer"];
10221 + case "object": if (x._def.value === null) return [...acc, "null"];
10222 + default: return acc;
10223 + }
10224 + }, []);
10225 + if (types.length === options.length) {
10226 + const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
10227 + return {
10228 + type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
10229 + enum: options.reduce((acc, x) => {
10230 + return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
10231 + }, [])
10232 + };
10233 + }
10234 + } else if (options.every((x) => x._def.typeName === "ZodEnum")) return {
10235 + type: "string",
10236 + enum: options.reduce((acc, x) => [...acc, ...x._def.values.filter((x) => !acc.includes(x))], [])
10237 + };
10238 + return asAnyOf(def, refs);
10239 + }
10240 + var asAnyOf = (def, refs) => {
10241 + const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef(x._def, {
10242 + ...refs,
10243 + currentPath: [
10244 + ...refs.currentPath,
10245 + "anyOf",
10246 + `${i}`
10247 + ]
10248 + })).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
10249 + return anyOf.length ? { anyOf } : void 0;
10250 + };
10251 +
10252 +//#endregion
10253 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/nullable.js
10254 + function parseNullableDef(def, refs) {
10255 + if ([
10256 + "ZodString",
10257 + "ZodNumber",
10258 + "ZodBigInt",
10259 + "ZodBoolean",
10260 + "ZodNull"
10261 + ].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
10262 + if (refs.target === "openApi3") return {
10263 + type: primitiveMappings[def.innerType._def.typeName],
10264 + nullable: true
10265 + };
10266 + return { type: [primitiveMappings[def.innerType._def.typeName], "null"] };
10267 + }
10268 + if (refs.target === "openApi3") {
10269 + const base = parseDef(def.innerType._def, {
10270 + ...refs,
10271 + currentPath: [...refs.currentPath]
10272 + });
10273 + if (base && "$ref" in base) return {
10274 + allOf: [base],
10275 + nullable: true
10276 + };
10277 + return base && {
10278 + ...base,
10279 + nullable: true
10280 + };
10281 + }
10282 + const base = parseDef(def.innerType._def, {
10283 + ...refs,
10284 + currentPath: [
10285 + ...refs.currentPath,
10286 + "anyOf",
10287 + "0"
10288 + ]
10289 + });
10290 + return base && { anyOf: [base, { type: "null" }] };
10291 + }
10292 +
10293 +//#endregion
10294 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/number.js
10295 + function parseNumberDef(def, refs) {
10296 + const res = { type: "number" };
10297 + if (!def.checks) return res;
10298 + for (const check of def.checks) switch (check.kind) {
10299 + case "int":
10300 + res.type = "integer";
10301 + addErrorMessage(res, "type", check.message, refs);
10302 + break;
10303 + case "min":
10304 + if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
10305 + else setResponseValueAndErrors(res, "exclusiveMinimum", check.value, check.message, refs);
10306 + else {
10307 + if (!check.inclusive) res.exclusiveMinimum = true;
10308 + setResponseValueAndErrors(res, "minimum", check.value, check.message, refs);
10309 + }
10310 + break;
10311 + case "max":
10312 + if (refs.target === "jsonSchema7") if (check.inclusive) setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
10313 + else setResponseValueAndErrors(res, "exclusiveMaximum", check.value, check.message, refs);
10314 + else {
10315 + if (!check.inclusive) res.exclusiveMaximum = true;
10316 + setResponseValueAndErrors(res, "maximum", check.value, check.message, refs);
10317 + }
10318 + break;
10319 + case "multipleOf":
10320 + setResponseValueAndErrors(res, "multipleOf", check.value, check.message, refs);
10321 + break;
10322 + }
10323 + return res;
10324 + }
10325 +
10326 +//#endregion
10327 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/object.js
10328 + function parseObjectDef(def, refs) {
10329 + const forceOptionalIntoNullable = refs.target === "openAi";
10330 + const result = {
10331 + type: "object",
10332 + properties: {}
10333 + };
10334 + const required = [];
10335 + const shape = def.shape();
10336 + for (const propName in shape) {
10337 + let propDef = shape[propName];
10338 + if (propDef === void 0 || propDef._def === void 0) continue;
10339 + let propOptional = safeIsOptional(propDef);
10340 + if (propOptional && forceOptionalIntoNullable) {
10341 + if (propDef._def.typeName === "ZodOptional") propDef = propDef._def.innerType;
10342 + if (!propDef.isNullable()) propDef = propDef.nullable();
10343 + propOptional = false;
10344 + }
10345 + const parsedDef = parseDef(propDef._def, {
10346 + ...refs,
10347 + currentPath: [
10348 + ...refs.currentPath,
10349 + "properties",
10350 + propName
10351 + ],
10352 + propertyPath: [
10353 + ...refs.currentPath,
10354 + "properties",
10355 + propName
10356 + ]
10357 + });
10358 + if (parsedDef === void 0) continue;
10359 + result.properties[propName] = parsedDef;
10360 + if (!propOptional) required.push(propName);
10361 + }
10362 + if (required.length) result.required = required;
10363 + const additionalProperties = decideAdditionalProperties(def, refs);
10364 + if (additionalProperties !== void 0) result.additionalProperties = additionalProperties;
10365 + return result;
10366 + }
10367 + function decideAdditionalProperties(def, refs) {
10368 + if (def.catchall._def.typeName !== "ZodNever") return parseDef(def.catchall._def, {
10369 + ...refs,
10370 + currentPath: [...refs.currentPath, "additionalProperties"]
10371 + });
10372 + switch (def.unknownKeys) {
10373 + case "passthrough": return refs.allowedAdditionalProperties;
10374 + case "strict": return refs.rejectedAdditionalProperties;
10375 + case "strip": return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
10376 + }
10377 + }
10378 + function safeIsOptional(schema) {
10379 + try {
10380 + return schema.isOptional();
10381 + } catch {
10382 + return true;
10383 + }
10384 + }
10385 +
10386 +//#endregion
10387 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/optional.js
10388 + var parseOptionalDef = (def, refs) => {
10389 + if (refs.currentPath.toString() === refs.propertyPath?.toString()) return parseDef(def.innerType._def, refs);
10390 + const innerSchema = parseDef(def.innerType._def, {
10391 + ...refs,
10392 + currentPath: [
10393 + ...refs.currentPath,
10394 + "anyOf",
10395 + "1"
10396 + ]
10397 + });
10398 + return innerSchema ? { anyOf: [{ not: parseAnyDef(refs) }, innerSchema] } : parseAnyDef(refs);
10399 + };
10400 +
10401 +//#endregion
10402 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/pipeline.js
10403 + var parsePipelineDef = (def, refs) => {
10404 + if (refs.pipeStrategy === "input") return parseDef(def.in._def, refs);
10405 + else if (refs.pipeStrategy === "output") return parseDef(def.out._def, refs);
10406 + const a = parseDef(def.in._def, {
10407 + ...refs,
10408 + currentPath: [
10409 + ...refs.currentPath,
10410 + "allOf",
10411 + "0"
10412 + ]
10413 + });
10414 + return { allOf: [a, parseDef(def.out._def, {
10415 + ...refs,
10416 + currentPath: [
10417 + ...refs.currentPath,
10418 + "allOf",
10419 + a ? "1" : "0"
10420 + ]
10421 + })].filter((x) => x !== void 0) };
10422 + };
10423 +
10424 +//#endregion
10425 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/promise.js
10426 + function parsePromiseDef(def, refs) {
10427 + return parseDef(def.type._def, refs);
10428 + }
10429 +
10430 +//#endregion
10431 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/set.js
10432 + function parseSetDef(def, refs) {
10433 + const schema = {
10434 + type: "array",
10435 + uniqueItems: true,
10436 + items: parseDef(def.valueType._def, {
10437 + ...refs,
10438 + currentPath: [...refs.currentPath, "items"]
10439 + })
10440 + };
10441 + if (def.minSize) setResponseValueAndErrors(schema, "minItems", def.minSize.value, def.minSize.message, refs);
10442 + if (def.maxSize) setResponseValueAndErrors(schema, "maxItems", def.maxSize.value, def.maxSize.message, refs);
10443 + return schema;
10444 + }
10445 +
10446 +//#endregion
10447 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/tuple.js
10448 + function parseTupleDef(def, refs) {
10449 + if (def.rest) return {
10450 + type: "array",
10451 + minItems: def.items.length,
10452 + items: def.items.map((x, i) => parseDef(x._def, {
10453 + ...refs,
10454 + currentPath: [
10455 + ...refs.currentPath,
10456 + "items",
10457 + `${i}`
10458 + ]
10459 + })).reduce((acc, x) => x === void 0 ? acc : [...acc, x], []),
10460 + additionalItems: parseDef(def.rest._def, {
10461 + ...refs,
10462 + currentPath: [...refs.currentPath, "additionalItems"]
10463 + })
10464 + };
10465 + else return {
10466 + type: "array",
10467 + minItems: def.items.length,
10468 + maxItems: def.items.length,
10469 + items: def.items.map((x, i) => parseDef(x._def, {
10470 + ...refs,
10471 + currentPath: [
10472 + ...refs.currentPath,
10473 + "items",
10474 + `${i}`
10475 + ]
10476 + })).reduce((acc, x) => x === void 0 ? acc : [...acc, x], [])
10477 + };
10478 + }
10479 +
10480 +//#endregion
10481 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/undefined.js
10482 + function parseUndefinedDef(refs) {
10483 + return { not: parseAnyDef(refs) };
10484 + }
10485 +
10486 +//#endregion
10487 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/unknown.js
10488 + function parseUnknownDef(refs) {
10489 + return parseAnyDef(refs);
10490 + }
10491 +
10492 +//#endregion
10493 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parsers/readonly.js
10494 + var parseReadonlyDef = (def, refs) => {
10495 + return parseDef(def.innerType._def, refs);
10496 + };
10497 +
10498 +//#endregion
10499 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/selectParser.js
10500 + var selectParser = (def, typeName, refs) => {
10501 + switch (typeName) {
10502 + case ZodFirstPartyTypeKind.ZodString: return parseStringDef(def, refs);
10503 + case ZodFirstPartyTypeKind.ZodNumber: return parseNumberDef(def, refs);
10504 + case ZodFirstPartyTypeKind.ZodObject: return parseObjectDef(def, refs);
10505 + case ZodFirstPartyTypeKind.ZodBigInt: return parseBigintDef(def, refs);
10506 + case ZodFirstPartyTypeKind.ZodBoolean: return parseBooleanDef();
10507 + case ZodFirstPartyTypeKind.ZodDate: return parseDateDef(def, refs);
10508 + case ZodFirstPartyTypeKind.ZodUndefined: return parseUndefinedDef(refs);
10509 + case ZodFirstPartyTypeKind.ZodNull: return parseNullDef(refs);
10510 + case ZodFirstPartyTypeKind.ZodArray: return parseArrayDef(def, refs);
10511 + case ZodFirstPartyTypeKind.ZodUnion:
10512 + case ZodFirstPartyTypeKind.ZodDiscriminatedUnion: return parseUnionDef(def, refs);
10513 + case ZodFirstPartyTypeKind.ZodIntersection: return parseIntersectionDef(def, refs);
10514 + case ZodFirstPartyTypeKind.ZodTuple: return parseTupleDef(def, refs);
10515 + case ZodFirstPartyTypeKind.ZodRecord: return parseRecordDef(def, refs);
10516 + case ZodFirstPartyTypeKind.ZodLiteral: return parseLiteralDef(def, refs);
10517 + case ZodFirstPartyTypeKind.ZodEnum: return parseEnumDef(def);
10518 + case ZodFirstPartyTypeKind.ZodNativeEnum: return parseNativeEnumDef(def);
10519 + case ZodFirstPartyTypeKind.ZodNullable: return parseNullableDef(def, refs);
10520 + case ZodFirstPartyTypeKind.ZodOptional: return parseOptionalDef(def, refs);
10521 + case ZodFirstPartyTypeKind.ZodMap: return parseMapDef(def, refs);
10522 + case ZodFirstPartyTypeKind.ZodSet: return parseSetDef(def, refs);
10523 + case ZodFirstPartyTypeKind.ZodLazy: return () => def.getter()._def;
10524 + case ZodFirstPartyTypeKind.ZodPromise: return parsePromiseDef(def, refs);
10525 + case ZodFirstPartyTypeKind.ZodNaN:
10526 + case ZodFirstPartyTypeKind.ZodNever: return parseNeverDef(refs);
10527 + case ZodFirstPartyTypeKind.ZodEffects: return parseEffectsDef(def, refs);
10528 + case ZodFirstPartyTypeKind.ZodAny: return parseAnyDef(refs);
10529 + case ZodFirstPartyTypeKind.ZodUnknown: return parseUnknownDef(refs);
10530 + case ZodFirstPartyTypeKind.ZodDefault: return parseDefaultDef(def, refs);
10531 + case ZodFirstPartyTypeKind.ZodBranded: return parseBrandedDef(def, refs);
10532 + case ZodFirstPartyTypeKind.ZodReadonly: return parseReadonlyDef(def, refs);
10533 + case ZodFirstPartyTypeKind.ZodCatch: return parseCatchDef(def, refs);
10534 + case ZodFirstPartyTypeKind.ZodPipeline: return parsePipelineDef(def, refs);
10535 + case ZodFirstPartyTypeKind.ZodFunction:
10536 + case ZodFirstPartyTypeKind.ZodVoid:
10537 + case ZodFirstPartyTypeKind.ZodSymbol: return;
10538 + default: return ((_) => void 0)(typeName);
10539 + }
10540 + };
10541 +
10542 +//#endregion
10543 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/parseDef.js
10544 + function parseDef(def, refs, forceResolution = false) {
10545 + const seenItem = refs.seen.get(def);
10546 + if (refs.override) {
10547 + const overrideResult = refs.override?.(def, refs, seenItem, forceResolution);
10548 + if (overrideResult !== ignoreOverride) return overrideResult;
10549 + }
10550 + if (seenItem && !forceResolution) {
10551 + const seenSchema = get$ref(seenItem, refs);
10552 + if (seenSchema !== void 0) return seenSchema;
10553 + }
10554 + const newItem = {
10555 + def,
10556 + path: refs.currentPath,
10557 + jsonSchema: void 0
10558 + };
10559 + refs.seen.set(def, newItem);
10560 + const jsonSchemaOrGetter = selectParser(def, def.typeName, refs);
10561 + const jsonSchema = typeof jsonSchemaOrGetter === "function" ? parseDef(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
10562 + if (jsonSchema) addMeta(def, refs, jsonSchema);
10563 + if (refs.postProcess) {
10564 + const postProcessResult = refs.postProcess(jsonSchema, def, refs);
10565 + newItem.jsonSchema = jsonSchema;
10566 + return postProcessResult;
10567 + }
10568 + newItem.jsonSchema = jsonSchema;
10569 + return jsonSchema;
10570 + }
10571 + var get$ref = (item, refs) => {
10572 + switch (refs.$refStrategy) {
10573 + case "root": return { $ref: item.path.join("/") };
10574 + case "relative": return { $ref: getRelativePath(refs.currentPath, item.path) };
10575 + case "none":
10576 + case "seen":
10577 + if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
10578 + console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
10579 + return parseAnyDef(refs);
10580 + }
10581 + return refs.$refStrategy === "seen" ? parseAnyDef(refs) : void 0;
10582 + }
10583 + };
10584 + var addMeta = (def, refs, jsonSchema) => {
10585 + if (def.description) {
10586 + jsonSchema.description = def.description;
10587 + if (refs.markdownDescription) jsonSchema.markdownDescription = def.description;
10588 + }
10589 + return jsonSchema;
10590 + };
10591 +
10592 +//#endregion
10593 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/zod-to-json-schema/dist/esm/zodToJsonSchema.js
10594 + var zodToJsonSchema = (schema, options) => {
10595 + const refs = getRefs(options);
10596 + let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name, schema]) => ({
10597 + ...acc,
10598 + [name]: parseDef(schema._def, {
10599 + ...refs,
10600 + currentPath: [
10601 + ...refs.basePath,
10602 + refs.definitionPath,
10603 + name
10604 + ]
10605 + }, true) ?? parseAnyDef(refs)
10606 + }), {}) : void 0;
10607 + const name = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
10608 + const main = parseDef(schema._def, name === void 0 ? refs : {
10609 + ...refs,
10610 + currentPath: [
10611 + ...refs.basePath,
10612 + refs.definitionPath,
10613 + name
10614 + ]
10615 + }, false) ?? parseAnyDef(refs);
10616 + const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
10617 + if (title !== void 0) main.title = title;
10618 + if (refs.flags.hasReferencedOpenAiAnyType) {
10619 + if (!definitions) definitions = {};
10620 + if (!definitions[refs.openAiAnyTypeName]) definitions[refs.openAiAnyTypeName] = {
10621 + type: [
10622 + "string",
10623 + "number",
10624 + "integer",
10625 + "boolean",
10626 + "array",
10627 + "null"
10628 + ],
10629 + items: { $ref: refs.$refStrategy === "relative" ? "1" : [
10630 + ...refs.basePath,
10631 + refs.definitionPath,
10632 + refs.openAiAnyTypeName
10633 + ].join("/") }
10634 + };
10635 + }
10636 + const combined = name === void 0 ? definitions ? {
10637 + ...main,
10638 + [refs.definitionPath]: definitions
10639 + } : main : {
10640 + $ref: [
10641 + ...refs.$refStrategy === "relative" ? [] : refs.basePath,
10642 + refs.definitionPath,
10643 + name
10644 + ].join("/"),
10645 + [refs.definitionPath]: {
10646 + ...definitions,
10647 + [name]: main
10648 + }
10649 + };
10650 + if (refs.target === "jsonSchema7") combined.$schema = "http://json-schema.org/draft-07/schema#";
10651 + else if (refs.target === "jsonSchema2019-09" || refs.target === "openAi") combined.$schema = "https://json-schema.org/draft/2019-09/schema#";
10652 + if (refs.target === "openAi" && ("anyOf" in combined || "oneOf" in combined || "allOf" in combined || "type" in combined && Array.isArray(combined.type))) console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");
10653 + return combined;
10654 + };
10655 +
10656 +//#endregion
10657 +//#region node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
10658 + function mapMiniTarget(t) {
10659 + if (!t) return "draft-7";
10660 + if (t === "jsonSchema7" || t === "draft-7") return "draft-7";
10661 + if (t === "jsonSchema2019-09" || t === "draft-2020-12") return "draft-2020-12";
10662 + return "draft-7";
10663 + }
10664 + function toJsonSchemaCompat(schema, opts) {
10665 + if (isZ4Schema(schema)) return toJSONSchema(schema, {
10666 + target: mapMiniTarget(opts?.target),
10667 + io: opts?.pipeStrategy ?? "input"
10668 + });
10669 + return zodToJsonSchema(schema, {
10670 + strictUnions: opts?.strictUnions ?? true,
10671 + pipeStrategy: opts?.pipeStrategy ?? "input"
10672 + });
10673 + }
10674 + function getMethodLiteral(schema) {
10675 + const methodSchema = getObjectShape(schema)?.method;
10676 + if (!methodSchema) throw new Error("Schema is missing a method literal");
10677 + const value = getLiteralValue(methodSchema);
10678 + if (typeof value !== "string") throw new Error("Schema method literal must be a string");
10679 + return value;
10680 + }
10681 + function parseWithCompat(schema, data) {
10682 + const result = safeParse$1(schema, data);
10683 + if (!result.success) throw result.error;
10684 + return result.data;
10685 + }
10686 +
10687 +//#endregion
10688 +//#region node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
10689 +/**
10690 + * The default request timeout, in miliseconds.
10691 + */
10692 + var DEFAULT_REQUEST_TIMEOUT_MSEC = 6e4;
10693 + /**
10694 + * Implements MCP protocol framing on top of a pluggable transport, including
10695 + * features like request/response linking, notifications, and progress.
10696 + */
10697 + var Protocol = class {
10698 + constructor(_options) {
10699 + this._options = _options;
10700 + this._requestMessageId = 0;
10701 + this._requestHandlers = /* @__PURE__ */ new Map();
10702 + this._requestHandlerAbortControllers = /* @__PURE__ */ new Map();
10703 + this._notificationHandlers = /* @__PURE__ */ new Map();
10704 + this._responseHandlers = /* @__PURE__ */ new Map();
10705 + this._progressHandlers = /* @__PURE__ */ new Map();
10706 + this._timeoutInfo = /* @__PURE__ */ new Map();
10707 + this._pendingDebouncedNotifications = /* @__PURE__ */ new Set();
10708 + this._taskProgressTokens = /* @__PURE__ */ new Map();
10709 + this._requestResolvers = /* @__PURE__ */ new Map();
10710 + this.setNotificationHandler(CancelledNotificationSchema, (notification) => {
10711 + this._oncancel(notification);
10712 + });
10713 + this.setNotificationHandler(ProgressNotificationSchema, (notification) => {
10714 + this._onprogress(notification);
10715 + });
10716 + this.setRequestHandler(PingRequestSchema, (_request) => ({}));
10717 + this._taskStore = _options?.taskStore;
10718 + this._taskMessageQueue = _options?.taskMessageQueue;
10719 + if (this._taskStore) {
10720 + this.setRequestHandler(GetTaskRequestSchema, async (request, extra) => {
10721 + const task = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
10722 + if (!task) throw new McpError(ErrorCode.InvalidParams, "Failed to retrieve task: Task not found");
10723 + return { ...task };
10724 + });
10725 + this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
10726 + const handleTaskResult = async () => {
10727 + const taskId = request.params.taskId;
10728 + if (this._taskMessageQueue) {
10729 + let queuedMessage;
10730 + while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
10731 + if (queuedMessage.type === "response" || queuedMessage.type === "error") {
10732 + const message = queuedMessage.message;
10733 + const requestId = message.id;
10734 + const resolver = this._requestResolvers.get(requestId);
10735 + if (resolver) {
10736 + this._requestResolvers.delete(requestId);
10737 + if (queuedMessage.type === "response") resolver(message);
10738 + else {
10739 + const errorMessage = message;
10740 + resolver(new McpError(errorMessage.error.code, errorMessage.error.message, errorMessage.error.data));
10741 + }
10742 + } else {
10743 + const messageType = queuedMessage.type === "response" ? "Response" : "Error";
10744 + this._onerror(/* @__PURE__ */ new Error(`${messageType} handler missing for request ${requestId}`));
10745 + }
10746 + continue;
10747 + }
10748 + await this._transport?.send(queuedMessage.message, { relatedRequestId: extra.requestId });
10749 + }
10750 + }
10751 + const task = await this._taskStore.getTask(taskId, extra.sessionId);
10752 + if (!task) throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
10753 + if (!isTerminal(task.status)) {
10754 + await this._waitForTaskUpdate(taskId, extra.signal);
10755 + return await handleTaskResult();
10756 + }
10757 + if (isTerminal(task.status)) {
10758 + const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
10759 + this._clearTaskQueue(taskId);
10760 + return {
10761 + ...result,
10762 + _meta: {
10763 + ...result._meta,
10764 + [RELATED_TASK_META_KEY]: { taskId }
10765 + }
10766 + };
10767 + }
10768 + return await handleTaskResult();
10769 + };
10770 + return await handleTaskResult();
10771 + });
10772 + this.setRequestHandler(ListTasksRequestSchema, async (request, extra) => {
10773 + try {
10774 + const { tasks, nextCursor } = await this._taskStore.listTasks(request.params?.cursor, extra.sessionId);
10775 + return {
10776 + tasks,
10777 + nextCursor,
10778 + _meta: {}
10779 + };
10780 + } catch (error) {
10781 + throw new McpError(ErrorCode.InvalidParams, `Failed to list tasks: ${error instanceof Error ? error.message : String(error)}`);
10782 + }
10783 + });
10784 + this.setRequestHandler(CancelTaskRequestSchema, async (request, extra) => {
10785 + try {
10786 + const task = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
10787 + if (!task) throw new McpError(ErrorCode.InvalidParams, `Task not found: ${request.params.taskId}`);
10788 + if (isTerminal(task.status)) throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
10789 + await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
10790 + this._clearTaskQueue(request.params.taskId);
10791 + const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
10792 + if (!cancelledTask) throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
10793 + return {
10794 + _meta: {},
10795 + ...cancelledTask
10796 + };
10797 + } catch (error) {
10798 + if (error instanceof McpError) throw error;
10799 + throw new McpError(ErrorCode.InvalidRequest, `Failed to cancel task: ${error instanceof Error ? error.message : String(error)}`);
10800 + }
10801 + });
10802 + }
10803 + }
10804 + async _oncancel(notification) {
10805 + if (!notification.params.requestId) return;
10806 + this._requestHandlerAbortControllers.get(notification.params.requestId)?.abort(notification.params.reason);
10807 + }
10808 + _setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
10809 + this._timeoutInfo.set(messageId, {
10810 + timeoutId: setTimeout(onTimeout, timeout),
10811 + startTime: Date.now(),
10812 + timeout,
10813 + maxTotalTimeout,
10814 + resetTimeoutOnProgress,
10815 + onTimeout
10816 + });
10817 + }
10818 + _resetTimeout(messageId) {
10819 + const info = this._timeoutInfo.get(messageId);
10820 + if (!info) return false;
10821 + const totalElapsed = Date.now() - info.startTime;
10822 + if (info.maxTotalTimeout && totalElapsed >= info.maxTotalTimeout) {
10823 + this._timeoutInfo.delete(messageId);
10824 + throw McpError.fromError(ErrorCode.RequestTimeout, "Maximum total timeout exceeded", {
10825 + maxTotalTimeout: info.maxTotalTimeout,
10826 + totalElapsed
10827 + });
10828 + }
10829 + clearTimeout(info.timeoutId);
10830 + info.timeoutId = setTimeout(info.onTimeout, info.timeout);
10831 + return true;
10832 + }
10833 + _cleanupTimeout(messageId) {
10834 + const info = this._timeoutInfo.get(messageId);
10835 + if (info) {
10836 + clearTimeout(info.timeoutId);
10837 + this._timeoutInfo.delete(messageId);
10838 + }
10839 + }
10840 + /**
10841 + * Attaches to the given transport, starts it, and starts listening for messages.
10842 + *
10843 + * The Protocol object assumes ownership of the Transport, replacing any callbacks that have already been set, and expects that it is the only user of the Transport instance going forward.
10844 + */
10845 + async connect(transport) {
10846 + if (this._transport) throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");
10847 + this._transport = transport;
10848 + const _onclose = this.transport?.onclose;
10849 + this._transport.onclose = () => {
10850 + _onclose?.();
10851 + this._onclose();
10852 + };
10853 + const _onerror = this.transport?.onerror;
10854 + this._transport.onerror = (error) => {
10855 + _onerror?.(error);
10856 + this._onerror(error);
10857 + };
10858 + const _onmessage = this._transport?.onmessage;
10859 + this._transport.onmessage = (message, extra) => {
10860 + _onmessage?.(message, extra);
10861 + if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) this._onresponse(message);
10862 + else if (isJSONRPCRequest(message)) this._onrequest(message, extra);
10863 + else if (isJSONRPCNotification(message)) this._onnotification(message);
10864 + else this._onerror(/* @__PURE__ */ new Error(`Unknown message type: ${JSON.stringify(message)}`));
10865 + };
10866 + await this._transport.start();
10867 + }
10868 + _onclose() {
10869 + const responseHandlers = this._responseHandlers;
10870 + this._responseHandlers = /* @__PURE__ */ new Map();
10871 + this._progressHandlers.clear();
10872 + this._taskProgressTokens.clear();
10873 + this._pendingDebouncedNotifications.clear();
10874 + for (const controller of this._requestHandlerAbortControllers.values()) controller.abort();
10875 + this._requestHandlerAbortControllers.clear();
10876 + const error = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
10877 + this._transport = void 0;
10878 + this.onclose?.();
10879 + for (const handler of responseHandlers.values()) handler(error);
10880 + }
10881 + _onerror(error) {
10882 + this.onerror?.(error);
10883 + }
10884 + _onnotification(notification) {
10885 + const handler = this._notificationHandlers.get(notification.method) ?? this.fallbackNotificationHandler;
10886 + if (handler === void 0) return;
10887 + Promise.resolve().then(() => handler(notification)).catch((error) => this._onerror(/* @__PURE__ */ new Error(`Uncaught error in notification handler: ${error}`)));
10888 + }
10889 + _onrequest(request, extra) {
10890 + const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
10891 + const capturedTransport = this._transport;
10892 + const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
10893 + if (handler === void 0) {
10894 + const errorResponse = {
10895 + jsonrpc: "2.0",
10896 + id: request.id,
10897 + error: {
10898 + code: ErrorCode.MethodNotFound,
10899 + message: "Method not found"
10900 + }
10901 + };
10902 + if (relatedTaskId && this._taskMessageQueue) this._enqueueTaskMessage(relatedTaskId, {
10903 + type: "error",
10904 + message: errorResponse,
10905 + timestamp: Date.now()
10906 + }, capturedTransport?.sessionId).catch((error) => this._onerror(/* @__PURE__ */ new Error(`Failed to enqueue error response: ${error}`)));
10907 + else capturedTransport?.send(errorResponse).catch((error) => this._onerror(/* @__PURE__ */ new Error(`Failed to send an error response: ${error}`)));
10908 + return;
10909 + }
10910 + const abortController = new AbortController();
10911 + this._requestHandlerAbortControllers.set(request.id, abortController);
10912 + const taskCreationParams = isTaskAugmentedRequestParams(request.params) ? request.params.task : void 0;
10913 + const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport?.sessionId) : void 0;
10914 + const fullExtra = {
10915 + signal: abortController.signal,
10916 + sessionId: capturedTransport?.sessionId,
10917 + _meta: request.params?._meta,
10918 + sendNotification: async (notification) => {
10919 + if (abortController.signal.aborted) return;
10920 + const notificationOptions = { relatedRequestId: request.id };
10921 + if (relatedTaskId) notificationOptions.relatedTask = { taskId: relatedTaskId };
10922 + await this.notification(notification, notificationOptions);
10923 + },
10924 + sendRequest: async (r, resultSchema, options) => {
10925 + if (abortController.signal.aborted) throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
10926 + const requestOptions = {
10927 + ...options,
10928 + relatedRequestId: request.id
10929 + };
10930 + if (relatedTaskId && !requestOptions.relatedTask) requestOptions.relatedTask = { taskId: relatedTaskId };
10931 + const effectiveTaskId = requestOptions.relatedTask?.taskId ?? relatedTaskId;
10932 + if (effectiveTaskId && taskStore) await taskStore.updateTaskStatus(effectiveTaskId, "input_required");
10933 + return await this.request(r, resultSchema, requestOptions);
10934 + },
10935 + authInfo: extra?.authInfo,
10936 + requestId: request.id,
10937 + requestInfo: extra?.requestInfo,
10938 + taskId: relatedTaskId,
10939 + taskStore,
10940 + taskRequestedTtl: taskCreationParams?.ttl,
10941 + closeSSEStream: extra?.closeSSEStream,
10942 + closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
10943 + };
10944 + Promise.resolve().then(() => {
10945 + if (taskCreationParams) this.assertTaskHandlerCapability(request.method);
10946 + }).then(() => handler(request, fullExtra)).then(async (result) => {
10947 + if (abortController.signal.aborted) return;
10948 + const response = {
10949 + result,
10950 + jsonrpc: "2.0",
10951 + id: request.id
10952 + };
10953 + if (relatedTaskId && this._taskMessageQueue) await this._enqueueTaskMessage(relatedTaskId, {
10954 + type: "response",
10955 + message: response,
10956 + timestamp: Date.now()
10957 + }, capturedTransport?.sessionId);
10958 + else await capturedTransport?.send(response);
10959 + }, async (error) => {
10960 + if (abortController.signal.aborted) return;
10961 + const errorResponse = {
10962 + jsonrpc: "2.0",
10963 + id: request.id,
10964 + error: {
10965 + code: Number.isSafeInteger(error["code"]) ? error["code"] : ErrorCode.InternalError,
10966 + message: error.message ?? "Internal error",
10967 + ...error["data"] !== void 0 && { data: error["data"] }
10968 + }
10969 + };
10970 + if (relatedTaskId && this._taskMessageQueue) await this._enqueueTaskMessage(relatedTaskId, {
10971 + type: "error",
10972 + message: errorResponse,
10973 + timestamp: Date.now()
10974 + }, capturedTransport?.sessionId);
10975 + else await capturedTransport?.send(errorResponse);
10976 + }).catch((error) => this._onerror(/* @__PURE__ */ new Error(`Failed to send response: ${error}`))).finally(() => {
10977 + this._requestHandlerAbortControllers.delete(request.id);
10978 + });
10979 + }
10980 + _onprogress(notification) {
10981 + const { progressToken, ...params } = notification.params;
10982 + const messageId = Number(progressToken);
10983 + const handler = this._progressHandlers.get(messageId);
10984 + if (!handler) {
10985 + this._onerror(/* @__PURE__ */ new Error(`Received a progress notification for an unknown token: ${JSON.stringify(notification)}`));
10986 + return;
10987 + }
10988 + const responseHandler = this._responseHandlers.get(messageId);
10989 + const timeoutInfo = this._timeoutInfo.get(messageId);
10990 + if (timeoutInfo && responseHandler && timeoutInfo.resetTimeoutOnProgress) try {
10991 + this._resetTimeout(messageId);
10992 + } catch (error) {
10993 + this._responseHandlers.delete(messageId);
10994 + this._progressHandlers.delete(messageId);
10995 + this._cleanupTimeout(messageId);
10996 + responseHandler(error);
10997 + return;
10998 + }
10999 + handler(params);
11000 + }
11001 + _onresponse(response) {
11002 + const messageId = Number(response.id);
11003 + const resolver = this._requestResolvers.get(messageId);
11004 + if (resolver) {
11005 + this._requestResolvers.delete(messageId);
11006 + if (isJSONRPCResultResponse(response)) resolver(response);
11007 + else resolver(new McpError(response.error.code, response.error.message, response.error.data));
11008 + return;
11009 + }
11010 + const handler = this._responseHandlers.get(messageId);
11011 + if (handler === void 0) {
11012 + this._onerror(/* @__PURE__ */ new Error(`Received a response for an unknown message ID: ${JSON.stringify(response)}`));
11013 + return;
11014 + }
11015 + this._responseHandlers.delete(messageId);
11016 + this._cleanupTimeout(messageId);
11017 + let isTaskResponse = false;
11018 + if (isJSONRPCResultResponse(response) && response.result && typeof response.result === "object") {
11019 + const result = response.result;
11020 + if (result.task && typeof result.task === "object") {
11021 + const task = result.task;
11022 + if (typeof task.taskId === "string") {
11023 + isTaskResponse = true;
11024 + this._taskProgressTokens.set(task.taskId, messageId);
11025 + }
11026 + }
11027 + }
11028 + if (!isTaskResponse) this._progressHandlers.delete(messageId);
11029 + if (isJSONRPCResultResponse(response)) handler(response);
11030 + else handler(McpError.fromError(response.error.code, response.error.message, response.error.data));
11031 + }
11032 + get transport() {
11033 + return this._transport;
11034 + }
11035 + /**
11036 + * Closes the connection.
11037 + */
11038 + async close() {
11039 + await this._transport?.close();
11040 + }
11041 + /**
11042 + * Sends a request and returns an AsyncGenerator that yields response messages.
11043 + * The generator is guaranteed to end with either a 'result' or 'error' message.
11044 + *
11045 + * @example
11046 + * ```typescript
11047 + * const stream = protocol.requestStream(request, resultSchema, options);
11048 + * for await (const message of stream) {
11049 + * switch (message.type) {
11050 + * case 'taskCreated':
11051 + * console.log('Task created:', message.task.taskId);
11052 + * break;
11053 + * case 'taskStatus':
11054 + * console.log('Task status:', message.task.status);
11055 + * break;
11056 + * case 'result':
11057 + * console.log('Final result:', message.result);
11058 + * break;
11059 + * case 'error':
11060 + * console.error('Error:', message.error);
11061 + * break;
11062 + * }
11063 + * }
11064 + * ```
11065 + *
11066 + * @experimental Use `client.experimental.tasks.requestStream()` to access this method.
11067 + */
11068 + async *requestStream(request, resultSchema, options) {
11069 + const { task } = options ?? {};
11070 + if (!task) {
11071 + try {
11072 + yield {
11073 + type: "result",
11074 + result: await this.request(request, resultSchema, options)
11075 + };
11076 + } catch (error) {
11077 + yield {
11078 + type: "error",
11079 + error: error instanceof McpError ? error : new McpError(ErrorCode.InternalError, String(error))
11080 + };
11081 + }
11082 + return;
11083 + }
11084 + let taskId;
11085 + try {
11086 + const createResult = await this.request(request, CreateTaskResultSchema, options);
11087 + if (createResult.task) {
11088 + taskId = createResult.task.taskId;
11089 + yield {
11090 + type: "taskCreated",
11091 + task: createResult.task
11092 + };
11093 + } else throw new McpError(ErrorCode.InternalError, "Task creation did not return a task");
11094 + while (true) {
11095 + const task = await this.getTask({ taskId }, options);
11096 + yield {
11097 + type: "taskStatus",
11098 + task
11099 + };
11100 + if (isTerminal(task.status)) {
11101 + if (task.status === "completed") yield {
11102 + type: "result",
11103 + result: await this.getTaskResult({ taskId }, resultSchema, options)
11104 + };
11105 + else if (task.status === "failed") yield {
11106 + type: "error",
11107 + error: new McpError(ErrorCode.InternalError, `Task ${taskId} failed`)
11108 + };
11109 + else if (task.status === "cancelled") yield {
11110 + type: "error",
11111 + error: new McpError(ErrorCode.InternalError, `Task ${taskId} was cancelled`)
11112 + };
11113 + return;
11114 + }
11115 + if (task.status === "input_required") {
11116 + yield {
11117 + type: "result",
11118 + result: await this.getTaskResult({ taskId }, resultSchema, options)
11119 + };
11120 + return;
11121 + }
11122 + const pollInterval = task.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
11123 + await new Promise((resolve) => setTimeout(resolve, pollInterval));
11124 + options?.signal?.throwIfAborted();
11125 + }
11126 + } catch (error) {
11127 + yield {
11128 + type: "error",
11129 + error: error instanceof McpError ? error : new McpError(ErrorCode.InternalError, String(error))
11130 + };
11131 + }
11132 + }
11133 + /**
11134 + * Sends a request and waits for a response.
11135 + *
11136 + * Do not use this method to emit notifications! Use notification() instead.
11137 + */
11138 + request(request, resultSchema, options) {
11139 + const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
11140 + return new Promise((resolve, reject) => {
11141 + const earlyReject = (error) => {
11142 + reject(error);
11143 + };
11144 + if (!this._transport) {
11145 + earlyReject(/* @__PURE__ */ new Error("Not connected"));
11146 + return;
11147 + }
11148 + if (this._options?.enforceStrictCapabilities === true) try {
11149 + this.assertCapabilityForMethod(request.method);
11150 + if (task) this.assertTaskCapability(request.method);
11151 + } catch (e) {
11152 + earlyReject(e);
11153 + return;
11154 + }
11155 + options?.signal?.throwIfAborted();
11156 + const messageId = this._requestMessageId++;
11157 + const jsonrpcRequest = {
11158 + ...request,
11159 + jsonrpc: "2.0",
11160 + id: messageId
11161 + };
11162 + if (options?.onprogress) {
11163 + this._progressHandlers.set(messageId, options.onprogress);
11164 + jsonrpcRequest.params = {
11165 + ...request.params,
11166 + _meta: {
11167 + ...request.params?._meta || {},
11168 + progressToken: messageId
11169 + }
11170 + };
11171 + }
11172 + if (task) jsonrpcRequest.params = {
11173 + ...jsonrpcRequest.params,
11174 + task
11175 + };
11176 + if (relatedTask) jsonrpcRequest.params = {
11177 + ...jsonrpcRequest.params,
11178 + _meta: {
11179 + ...jsonrpcRequest.params?._meta || {},
11180 + [RELATED_TASK_META_KEY]: relatedTask
11181 + }
11182 + };
11183 + const cancel = (reason) => {
11184 + this._responseHandlers.delete(messageId);
11185 + this._progressHandlers.delete(messageId);
11186 + this._cleanupTimeout(messageId);
11187 + this._transport?.send({
11188 + jsonrpc: "2.0",
11189 + method: "notifications/cancelled",
11190 + params: {
11191 + requestId: messageId,
11192 + reason: String(reason)
11193 + }
11194 + }, {
11195 + relatedRequestId,
11196 + resumptionToken,
11197 + onresumptiontoken
11198 + }).catch((error) => this._onerror(/* @__PURE__ */ new Error(`Failed to send cancellation: ${error}`)));
11199 + reject(reason instanceof McpError ? reason : new McpError(ErrorCode.RequestTimeout, String(reason)));
11200 + };
11201 + this._responseHandlers.set(messageId, (response) => {
11202 + if (options?.signal?.aborted) return;
11203 + if (response instanceof Error) return reject(response);
11204 + try {
11205 + const parseResult = safeParse$1(resultSchema, response.result);
11206 + if (!parseResult.success) reject(parseResult.error);
11207 + else resolve(parseResult.data);
11208 + } catch (error) {
11209 + reject(error);
11210 + }
11211 + });
11212 + options?.signal?.addEventListener("abort", () => {
11213 + cancel(options?.signal?.reason);
11214 + });
11215 + const timeout = options?.timeout ?? 6e4;
11216 + const timeoutHandler = () => cancel(McpError.fromError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
11217 + this._setupTimeout(messageId, timeout, options?.maxTotalTimeout, timeoutHandler, options?.resetTimeoutOnProgress ?? false);
11218 + const relatedTaskId = relatedTask?.taskId;
11219 + if (relatedTaskId) {
11220 + const responseResolver = (response) => {
11221 + const handler = this._responseHandlers.get(messageId);
11222 + if (handler) handler(response);
11223 + else this._onerror(/* @__PURE__ */ new Error(`Response handler missing for side-channeled request ${messageId}`));
11224 + };
11225 + this._requestResolvers.set(messageId, responseResolver);
11226 + this._enqueueTaskMessage(relatedTaskId, {
11227 + type: "request",
11228 + message: jsonrpcRequest,
11229 + timestamp: Date.now()
11230 + }).catch((error) => {
11231 + this._cleanupTimeout(messageId);
11232 + reject(error);
11233 + });
11234 + } else this._transport.send(jsonrpcRequest, {
11235 + relatedRequestId,
11236 + resumptionToken,
11237 + onresumptiontoken
11238 + }).catch((error) => {
11239 + this._cleanupTimeout(messageId);
11240 + reject(error);
11241 + });
11242 + });
11243 + }
11244 + /**
11245 + * Gets the current status of a task.
11246 + *
11247 + * @experimental Use `client.experimental.tasks.getTask()` to access this method.
11248 + */
11249 + async getTask(params, options) {
11250 + return this.request({
11251 + method: "tasks/get",
11252 + params
11253 + }, GetTaskResultSchema, options);
11254 + }
11255 + /**
11256 + * Retrieves the result of a completed task.
11257 + *
11258 + * @experimental Use `client.experimental.tasks.getTaskResult()` to access this method.
11259 + */
11260 + async getTaskResult(params, resultSchema, options) {
11261 + return this.request({
11262 + method: "tasks/result",
11263 + params
11264 + }, resultSchema, options);
11265 + }
11266 + /**
11267 + * Lists tasks, optionally starting from a pagination cursor.
11268 + *
11269 + * @experimental Use `client.experimental.tasks.listTasks()` to access this method.
11270 + */
11271 + async listTasks(params, options) {
11272 + return this.request({
11273 + method: "tasks/list",
11274 + params
11275 + }, ListTasksResultSchema, options);
11276 + }
11277 + /**
11278 + * Cancels a specific task.
11279 + *
11280 + * @experimental Use `client.experimental.tasks.cancelTask()` to access this method.
11281 + */
11282 + async cancelTask(params, options) {
11283 + return this.request({
11284 + method: "tasks/cancel",
11285 + params
11286 + }, CancelTaskResultSchema, options);
11287 + }
11288 + /**
11289 + * Emits a notification, which is a one-way message that does not expect a response.
11290 + */
11291 + async notification(notification, options) {
11292 + if (!this._transport) throw new Error("Not connected");
11293 + this.assertNotificationCapability(notification.method);
11294 + const relatedTaskId = options?.relatedTask?.taskId;
11295 + if (relatedTaskId) {
11296 + const jsonrpcNotification = {
11297 + ...notification,
11298 + jsonrpc: "2.0",
11299 + params: {
11300 + ...notification.params,
11301 + _meta: {
11302 + ...notification.params?._meta || {},
11303 + [RELATED_TASK_META_KEY]: options.relatedTask
11304 + }
11305 + }
11306 + };
11307 + await this._enqueueTaskMessage(relatedTaskId, {
11308 + type: "notification",
11309 + message: jsonrpcNotification,
11310 + timestamp: Date.now()
11311 + });
11312 + return;
11313 + }
11314 + if ((this._options?.debouncedNotificationMethods ?? []).includes(notification.method) && !notification.params && !options?.relatedRequestId && !options?.relatedTask) {
11315 + if (this._pendingDebouncedNotifications.has(notification.method)) return;
11316 + this._pendingDebouncedNotifications.add(notification.method);
11317 + Promise.resolve().then(() => {
11318 + this._pendingDebouncedNotifications.delete(notification.method);
11319 + if (!this._transport) return;
11320 + let jsonrpcNotification = {
11321 + ...notification,
11322 + jsonrpc: "2.0"
11323 + };
11324 + if (options?.relatedTask) jsonrpcNotification = {
11325 + ...jsonrpcNotification,
11326 + params: {
11327 + ...jsonrpcNotification.params,
11328 + _meta: {
11329 + ...jsonrpcNotification.params?._meta || {},
11330 + [RELATED_TASK_META_KEY]: options.relatedTask
11331 + }
11332 + }
11333 + };
11334 + this._transport?.send(jsonrpcNotification, options).catch((error) => this._onerror(error));
11335 + });
11336 + return;
11337 + }
11338 + let jsonrpcNotification = {
11339 + ...notification,
11340 + jsonrpc: "2.0"
11341 + };
11342 + if (options?.relatedTask) jsonrpcNotification = {
11343 + ...jsonrpcNotification,
11344 + params: {
11345 + ...jsonrpcNotification.params,
11346 + _meta: {
11347 + ...jsonrpcNotification.params?._meta || {},
11348 + [RELATED_TASK_META_KEY]: options.relatedTask
11349 + }
11350 + }
11351 + };
11352 + await this._transport.send(jsonrpcNotification, options);
11353 + }
11354 + /**
11355 + * Registers a handler to invoke when this protocol object receives a request with the given method.
11356 + *
11357 + * Note that this will replace any previous request handler for the same method.
11358 + */
11359 + setRequestHandler(requestSchema, handler) {
11360 + const method = getMethodLiteral(requestSchema);
11361 + this.assertRequestHandlerCapability(method);
11362 + this._requestHandlers.set(method, (request, extra) => {
11363 + const parsed = parseWithCompat(requestSchema, request);
11364 + return Promise.resolve(handler(parsed, extra));
11365 + });
11366 + }
11367 + /**
11368 + * Removes the request handler for the given method.
11369 + */
11370 + removeRequestHandler(method) {
11371 + this._requestHandlers.delete(method);
11372 + }
11373 + /**
11374 + * Asserts that a request handler has not already been set for the given method, in preparation for a new one being automatically installed.
11375 + */
11376 + assertCanSetRequestHandler(method) {
11377 + if (this._requestHandlers.has(method)) throw new Error(`A request handler for ${method} already exists, which would be overridden`);
11378 + }
11379 + /**
11380 + * Registers a handler to invoke when this protocol object receives a notification with the given method.
11381 + *
11382 + * Note that this will replace any previous notification handler for the same method.
11383 + */
11384 + setNotificationHandler(notificationSchema, handler) {
11385 + const method = getMethodLiteral(notificationSchema);
11386 + this._notificationHandlers.set(method, (notification) => {
11387 + const parsed = parseWithCompat(notificationSchema, notification);
11388 + return Promise.resolve(handler(parsed));
11389 + });
11390 + }
11391 + /**
11392 + * Removes the notification handler for the given method.
11393 + */
11394 + removeNotificationHandler(method) {
11395 + this._notificationHandlers.delete(method);
11396 + }
11397 + /**
11398 + * Cleans up the progress handler associated with a task.
11399 + * This should be called when a task reaches a terminal status.
11400 + */
11401 + _cleanupTaskProgressHandler(taskId) {
11402 + const progressToken = this._taskProgressTokens.get(taskId);
11403 + if (progressToken !== void 0) {
11404 + this._progressHandlers.delete(progressToken);
11405 + this._taskProgressTokens.delete(taskId);
11406 + }
11407 + }
11408 + /**
11409 + * Enqueues a task-related message for side-channel delivery via tasks/result.
11410 + * @param taskId The task ID to associate the message with
11411 + * @param message The message to enqueue
11412 + * @param sessionId Optional session ID for binding the operation to a specific session
11413 + * @throws Error if taskStore is not configured or if enqueue fails (e.g., queue overflow)
11414 + *
11415 + * Note: If enqueue fails, it's the TaskMessageQueue implementation's responsibility to handle
11416 + * the error appropriately (e.g., by failing the task, logging, etc.). The Protocol layer
11417 + * simply propagates the error.
11418 + */
11419 + async _enqueueTaskMessage(taskId, message, sessionId) {
11420 + if (!this._taskStore || !this._taskMessageQueue) throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
11421 + const maxQueueSize = this._options?.maxTaskQueueSize;
11422 + await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
11423 + }
11424 + /**
11425 + * Clears the message queue for a task and rejects any pending request resolvers.
11426 + * @param taskId The task ID whose queue should be cleared
11427 + * @param sessionId Optional session ID for binding the operation to a specific session
11428 + */
11429 + async _clearTaskQueue(taskId, sessionId) {
11430 + if (this._taskMessageQueue) {
11431 + const messages = await this._taskMessageQueue.dequeueAll(taskId, sessionId);
11432 + for (const message of messages) if (message.type === "request" && isJSONRPCRequest(message.message)) {
11433 + const requestId = message.message.id;
11434 + const resolver = this._requestResolvers.get(requestId);
11435 + if (resolver) {
11436 + resolver(new McpError(ErrorCode.InternalError, "Task cancelled or completed"));
11437 + this._requestResolvers.delete(requestId);
11438 + } else this._onerror(/* @__PURE__ */ new Error(`Resolver missing for request ${requestId} during task ${taskId} cleanup`));
11439 + }
11440 + }
11441 + }
11442 + /**
11443 + * Waits for a task update (new messages or status change) with abort signal support.
11444 + * Uses polling to check for updates at the task's configured poll interval.
11445 + * @param taskId The task ID to wait for
11446 + * @param signal Abort signal to cancel the wait
11447 + * @returns Promise that resolves when an update occurs or rejects if aborted
11448 + */
11449 + async _waitForTaskUpdate(taskId, signal) {
11450 + let interval = this._options?.defaultTaskPollInterval ?? 1e3;
11451 + try {
11452 + const task = await this._taskStore?.getTask(taskId);
11453 + if (task?.pollInterval) interval = task.pollInterval;
11454 + } catch {}
11455 + return new Promise((resolve, reject) => {
11456 + if (signal.aborted) {
11457 + reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
11458 + return;
11459 + }
11460 + const timeoutId = setTimeout(resolve, interval);
11461 + signal.addEventListener("abort", () => {
11462 + clearTimeout(timeoutId);
11463 + reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
11464 + }, { once: true });
11465 + });
11466 + }
11467 + requestTaskStore(request, sessionId) {
11468 + const taskStore = this._taskStore;
11469 + if (!taskStore) throw new Error("No task store configured");
11470 + return {
11471 + createTask: async (taskParams) => {
11472 + if (!request) throw new Error("No request provided");
11473 + return await taskStore.createTask(taskParams, request.id, {
11474 + method: request.method,
11475 + params: request.params
11476 + }, sessionId);
11477 + },
11478 + getTask: async (taskId) => {
11479 + const task = await taskStore.getTask(taskId, sessionId);
11480 + if (!task) throw new McpError(ErrorCode.InvalidParams, "Failed to retrieve task: Task not found");
11481 + return task;
11482 + },
11483 + storeTaskResult: async (taskId, status, result) => {
11484 + await taskStore.storeTaskResult(taskId, status, result, sessionId);
11485 + const task = await taskStore.getTask(taskId, sessionId);
11486 + if (task) {
11487 + const notification = TaskStatusNotificationSchema.parse({
11488 + method: "notifications/tasks/status",
11489 + params: task
11490 + });
11491 + await this.notification(notification);
11492 + if (isTerminal(task.status)) this._cleanupTaskProgressHandler(taskId);
11493 + }
11494 + },
11495 + getTaskResult: (taskId) => {
11496 + return taskStore.getTaskResult(taskId, sessionId);
11497 + },
11498 + updateTaskStatus: async (taskId, status, statusMessage) => {
11499 + const task = await taskStore.getTask(taskId, sessionId);
11500 + if (!task) throw new McpError(ErrorCode.InvalidParams, `Task "${taskId}" not found - it may have been cleaned up`);
11501 + if (isTerminal(task.status)) throw new McpError(ErrorCode.InvalidParams, `Cannot update task "${taskId}" from terminal status "${task.status}" to "${status}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);
11502 + await taskStore.updateTaskStatus(taskId, status, statusMessage, sessionId);
11503 + const updatedTask = await taskStore.getTask(taskId, sessionId);
11504 + if (updatedTask) {
11505 + const notification = TaskStatusNotificationSchema.parse({
11506 + method: "notifications/tasks/status",
11507 + params: updatedTask
11508 + });
11509 + await this.notification(notification);
11510 + if (isTerminal(updatedTask.status)) this._cleanupTaskProgressHandler(taskId);
11511 + }
11512 + },
11513 + listTasks: (cursor) => {
11514 + return taskStore.listTasks(cursor, sessionId);
11515 + }
11516 + };
11517 + }
11518 + };
11519 + function isPlainObject(value) {
11520 + return value !== null && typeof value === "object" && !Array.isArray(value);
11521 + }
11522 + function mergeCapabilities(base, additional) {
11523 + const result = { ...base };
11524 + for (const key in additional) {
11525 + const k = key;
11526 + const addValue = additional[k];
11527 + if (addValue === void 0) continue;
11528 + const baseValue = result[k];
11529 + if (isPlainObject(baseValue) && isPlainObject(addValue)) result[k] = {
11530 + ...baseValue,
11531 + ...addValue
11532 + };
11533 + else result[k] = addValue;
11534 + }
11535 + return result;
11536 + }
11537 +
11538 +//#endregion
11539 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/codegen/code.js
11540 + var require_code$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
11541 + Object.defineProperty(exports, "__esModule", { value: true });
11542 + exports.regexpCode = exports.getEsmExportName = exports.getProperty = exports.safeStringify = exports.stringify = exports.strConcat = exports.addCodeArg = exports.str = exports._ = exports.nil = exports._Code = exports.Name = exports.IDENTIFIER = exports._CodeOrName = void 0;
11543 + var _CodeOrName = class {};
11544 + exports._CodeOrName = _CodeOrName;
11545 + exports.IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
11546 + var Name = class extends _CodeOrName {
11547 + constructor(s) {
11548 + super();
11549 + if (!exports.IDENTIFIER.test(s)) throw new Error("CodeGen: name must be a valid identifier");
11550 + this.str = s;
11551 + }
11552 + toString() {
11553 + return this.str;
11554 + }
11555 + emptyStr() {
11556 + return false;
11557 + }
11558 + get names() {
11559 + return { [this.str]: 1 };
11560 + }
11561 + };
11562 + exports.Name = Name;
11563 + var _Code = class extends _CodeOrName {
11564 + constructor(code) {
11565 + super();
11566 + this._items = typeof code === "string" ? [code] : code;
11567 + }
11568 + toString() {
11569 + return this.str;
11570 + }
11571 + emptyStr() {
11572 + if (this._items.length > 1) return false;
11573 + const item = this._items[0];
11574 + return item === "" || item === "\"\"";
11575 + }
11576 + get str() {
11577 + var _a;
11578 + return (_a = this._str) !== null && _a !== void 0 ? _a : this._str = this._items.reduce((s, c) => `${s}${c}`, "");
11579 + }
11580 + get names() {
11581 + var _a;
11582 + return (_a = this._names) !== null && _a !== void 0 ? _a : this._names = this._items.reduce((names, c) => {
11583 + if (c instanceof Name) names[c.str] = (names[c.str] || 0) + 1;
11584 + return names;
11585 + }, {});
11586 + }
11587 + };
11588 + exports._Code = _Code;
11589 + exports.nil = new _Code("");
11590 + function _(strs, ...args) {
11591 + const code = [strs[0]];
11592 + let i = 0;
11593 + while (i < args.length) {
11594 + addCodeArg(code, args[i]);
11595 + code.push(strs[++i]);
11596 + }
11597 + return new _Code(code);
11598 + }
11599 + exports._ = _;
11600 + var plus = new _Code("+");
11601 + function str(strs, ...args) {
11602 + const expr = [safeStringify(strs[0])];
11603 + let i = 0;
11604 + while (i < args.length) {
11605 + expr.push(plus);
11606 + addCodeArg(expr, args[i]);
11607 + expr.push(plus, safeStringify(strs[++i]));
11608 + }
11609 + optimize(expr);
11610 + return new _Code(expr);
11611 + }
11612 + exports.str = str;
11613 + function addCodeArg(code, arg) {
11614 + if (arg instanceof _Code) code.push(...arg._items);
11615 + else if (arg instanceof Name) code.push(arg);
11616 + else code.push(interpolate(arg));
11617 + }
11618 + exports.addCodeArg = addCodeArg;
11619 + function optimize(expr) {
11620 + let i = 1;
11621 + while (i < expr.length - 1) {
11622 + if (expr[i] === plus) {
11623 + const res = mergeExprItems(expr[i - 1], expr[i + 1]);
11624 + if (res !== void 0) {
11625 + expr.splice(i - 1, 3, res);
11626 + continue;
11627 + }
11628 + expr[i++] = "+";
11629 + }
11630 + i++;
11631 + }
11632 + }
11633 + function mergeExprItems(a, b) {
11634 + if (b === "\"\"") return a;
11635 + if (a === "\"\"") return b;
11636 + if (typeof a == "string") {
11637 + if (b instanceof Name || a[a.length - 1] !== "\"") return;
11638 + if (typeof b != "string") return `${a.slice(0, -1)}${b}"`;
11639 + if (b[0] === "\"") return a.slice(0, -1) + b.slice(1);
11640 + return;
11641 + }
11642 + if (typeof b == "string" && b[0] === "\"" && !(a instanceof Name)) return `"${a}${b.slice(1)}`;
11643 + }
11644 + function strConcat(c1, c2) {
11645 + return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str`${c1}${c2}`;
11646 + }
11647 + exports.strConcat = strConcat;
11648 + function interpolate(x) {
11649 + return typeof x == "number" || typeof x == "boolean" || x === null ? x : safeStringify(Array.isArray(x) ? x.join(",") : x);
11650 + }
11651 + function stringify(x) {
11652 + return new _Code(safeStringify(x));
11653 + }
11654 + exports.stringify = stringify;
11655 + function safeStringify(x) {
11656 + return JSON.stringify(x).replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
11657 + }
11658 + exports.safeStringify = safeStringify;
11659 + function getProperty(key) {
11660 + return typeof key == "string" && exports.IDENTIFIER.test(key) ? new _Code(`.${key}`) : _`[${key}]`;
11661 + }
11662 + exports.getProperty = getProperty;
11663 + function getEsmExportName(key) {
11664 + if (typeof key == "string" && exports.IDENTIFIER.test(key)) return new _Code(`${key}`);
11665 + throw new Error(`CodeGen: invalid export name: ${key}, use explicit $id name mapping`);
11666 + }
11667 + exports.getEsmExportName = getEsmExportName;
11668 + function regexpCode(rx) {
11669 + return new _Code(rx.toString());
11670 + }
11671 + exports.regexpCode = regexpCode;
11672 + }));
11673 +
11674 +//#endregion
11675 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/codegen/scope.js
11676 + var require_scope = /* @__PURE__ */ __commonJSMin(((exports) => {
11677 + Object.defineProperty(exports, "__esModule", { value: true });
11678 + exports.ValueScope = exports.ValueScopeName = exports.Scope = exports.varKinds = exports.UsedValueState = void 0;
11679 + var code_1 = require_code$1();
11680 + var ValueError = class extends Error {
11681 + constructor(name) {
11682 + super(`CodeGen: "code" for ${name} not defined`);
11683 + this.value = name.value;
11684 + }
11685 + };
11686 + var UsedValueState;
11687 + (function(UsedValueState) {
11688 + UsedValueState[UsedValueState["Started"] = 0] = "Started";
11689 + UsedValueState[UsedValueState["Completed"] = 1] = "Completed";
11690 + })(UsedValueState || (exports.UsedValueState = UsedValueState = {}));
11691 + exports.varKinds = {
11692 + const: new code_1.Name("const"),
11693 + let: new code_1.Name("let"),
11694 + var: new code_1.Name("var")
11695 + };
11696 + var Scope = class {
11697 + constructor({ prefixes, parent } = {}) {
11698 + this._names = {};
11699 + this._prefixes = prefixes;
11700 + this._parent = parent;
11701 + }
11702 + toName(nameOrPrefix) {
11703 + return nameOrPrefix instanceof code_1.Name ? nameOrPrefix : this.name(nameOrPrefix);
11704 + }
11705 + name(prefix) {
11706 + return new code_1.Name(this._newName(prefix));
11707 + }
11708 + _newName(prefix) {
11709 + const ng = this._names[prefix] || this._nameGroup(prefix);
11710 + return `${prefix}${ng.index++}`;
11711 + }
11712 + _nameGroup(prefix) {
11713 + var _a;
11714 + var _b;
11715 + if (((_b = (_a = this._parent) === null || _a === void 0 ? void 0 : _a._prefixes) === null || _b === void 0 ? void 0 : _b.has(prefix)) || this._prefixes && !this._prefixes.has(prefix)) throw new Error(`CodeGen: prefix "${prefix}" is not allowed in this scope`);
11716 + return this._names[prefix] = {
11717 + prefix,
11718 + index: 0
11719 + };
11720 + }
11721 + };
11722 + exports.Scope = Scope;
11723 + var ValueScopeName = class extends code_1.Name {
11724 + constructor(prefix, nameStr) {
11725 + super(nameStr);
11726 + this.prefix = prefix;
11727 + }
11728 + setValue(value, { property, itemIndex }) {
11729 + this.value = value;
11730 + this.scopePath = (0, code_1._)`.${new code_1.Name(property)}[${itemIndex}]`;
11731 + }
11732 + };
11733 + exports.ValueScopeName = ValueScopeName;
11734 + var line = (0, code_1._)`\n`;
11735 + var ValueScope = class extends Scope {
11736 + constructor(opts) {
11737 + super(opts);
11738 + this._values = {};
11739 + this._scope = opts.scope;
11740 + this.opts = {
11741 + ...opts,
11742 + _n: opts.lines ? line : code_1.nil
11743 + };
11744 + }
11745 + get() {
11746 + return this._scope;
11747 + }
11748 + name(prefix) {
11749 + return new ValueScopeName(prefix, this._newName(prefix));
11750 + }
11751 + value(nameOrPrefix, value) {
11752 + var _a;
11753 + if (value.ref === void 0) throw new Error("CodeGen: ref must be passed in value");
11754 + const name = this.toName(nameOrPrefix);
11755 + const { prefix } = name;
11756 + const valueKey = (_a = value.key) !== null && _a !== void 0 ? _a : value.ref;
11757 + let vs = this._values[prefix];
11758 + if (vs) {
11759 + const _name = vs.get(valueKey);
11760 + if (_name) return _name;
11761 + } else vs = this._values[prefix] = /* @__PURE__ */ new Map();
11762 + vs.set(valueKey, name);
11763 + const s = this._scope[prefix] || (this._scope[prefix] = []);
11764 + const itemIndex = s.length;
11765 + s[itemIndex] = value.ref;
11766 + name.setValue(value, {
11767 + property: prefix,
11768 + itemIndex
11769 + });
11770 + return name;
11771 + }
11772 + getValue(prefix, keyOrRef) {
11773 + const vs = this._values[prefix];
11774 + if (!vs) return;
11775 + return vs.get(keyOrRef);
11776 + }
11777 + scopeRefs(scopeName, values = this._values) {
11778 + return this._reduceValues(values, (name) => {
11779 + if (name.scopePath === void 0) throw new Error(`CodeGen: name "${name}" has no value`);
11780 + return (0, code_1._)`${scopeName}${name.scopePath}`;
11781 + });
11782 + }
11783 + scopeCode(values = this._values, usedValues, getCode) {
11784 + return this._reduceValues(values, (name) => {
11785 + if (name.value === void 0) throw new Error(`CodeGen: name "${name}" has no value`);
11786 + return name.value.code;
11787 + }, usedValues, getCode);
11788 + }
11789 + _reduceValues(values, valueCode, usedValues = {}, getCode) {
11790 + let code = code_1.nil;
11791 + for (const prefix in values) {
11792 + const vs = values[prefix];
11793 + if (!vs) continue;
11794 + const nameSet = usedValues[prefix] = usedValues[prefix] || /* @__PURE__ */ new Map();
11795 + vs.forEach((name) => {
11796 + if (nameSet.has(name)) return;
11797 + nameSet.set(name, UsedValueState.Started);
11798 + let c = valueCode(name);
11799 + if (c) {
11800 + const def = this.opts.es5 ? exports.varKinds.var : exports.varKinds.const;
11801 + code = (0, code_1._)`${code}${def} ${name} = ${c};${this.opts._n}`;
11802 + } else if (c = getCode === null || getCode === void 0 ? void 0 : getCode(name)) code = (0, code_1._)`${code}${c}${this.opts._n}`;
11803 + else throw new ValueError(name);
11804 + nameSet.set(name, UsedValueState.Completed);
11805 + });
11806 + }
11807 + return code;
11808 + }
11809 + };
11810 + exports.ValueScope = ValueScope;
11811 + }));
11812 +
11813 +//#endregion
11814 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/codegen/index.js
11815 + var require_codegen = /* @__PURE__ */ __commonJSMin(((exports) => {
11816 + Object.defineProperty(exports, "__esModule", { value: true });
11817 + exports.or = exports.and = exports.not = exports.CodeGen = exports.operators = exports.varKinds = exports.ValueScopeName = exports.ValueScope = exports.Scope = exports.Name = exports.regexpCode = exports.stringify = exports.getProperty = exports.nil = exports.strConcat = exports.str = exports._ = void 0;
11818 + var code_1 = require_code$1();
11819 + var scope_1 = require_scope();
11820 + var code_2 = require_code$1();
11821 + Object.defineProperty(exports, "_", {
11822 + enumerable: true,
11823 + get: function() {
11824 + return code_2._;
11825 + }
11826 + });
11827 + Object.defineProperty(exports, "str", {
11828 + enumerable: true,
11829 + get: function() {
11830 + return code_2.str;
11831 + }
11832 + });
11833 + Object.defineProperty(exports, "strConcat", {
11834 + enumerable: true,
11835 + get: function() {
11836 + return code_2.strConcat;
11837 + }
11838 + });
11839 + Object.defineProperty(exports, "nil", {
11840 + enumerable: true,
11841 + get: function() {
11842 + return code_2.nil;
11843 + }
11844 + });
11845 + Object.defineProperty(exports, "getProperty", {
11846 + enumerable: true,
11847 + get: function() {
11848 + return code_2.getProperty;
11849 + }
11850 + });
11851 + Object.defineProperty(exports, "stringify", {
11852 + enumerable: true,
11853 + get: function() {
11854 + return code_2.stringify;
11855 + }
11856 + });
11857 + Object.defineProperty(exports, "regexpCode", {
11858 + enumerable: true,
11859 + get: function() {
11860 + return code_2.regexpCode;
11861 + }
11862 + });
11863 + Object.defineProperty(exports, "Name", {
11864 + enumerable: true,
11865 + get: function() {
11866 + return code_2.Name;
11867 + }
11868 + });
11869 + var scope_2 = require_scope();
11870 + Object.defineProperty(exports, "Scope", {
11871 + enumerable: true,
11872 + get: function() {
11873 + return scope_2.Scope;
11874 + }
11875 + });
11876 + Object.defineProperty(exports, "ValueScope", {
11877 + enumerable: true,
11878 + get: function() {
11879 + return scope_2.ValueScope;
11880 + }
11881 + });
11882 + Object.defineProperty(exports, "ValueScopeName", {
11883 + enumerable: true,
11884 + get: function() {
11885 + return scope_2.ValueScopeName;
11886 + }
11887 + });
11888 + Object.defineProperty(exports, "varKinds", {
11889 + enumerable: true,
11890 + get: function() {
11891 + return scope_2.varKinds;
11892 + }
11893 + });
11894 + exports.operators = {
11895 + GT: new code_1._Code(">"),
11896 + GTE: new code_1._Code(">="),
11897 + LT: new code_1._Code("<"),
11898 + LTE: new code_1._Code("<="),
11899 + EQ: new code_1._Code("==="),
11900 + NEQ: new code_1._Code("!=="),
11901 + NOT: new code_1._Code("!"),
11902 + OR: new code_1._Code("||"),
11903 + AND: new code_1._Code("&&"),
11904 + ADD: new code_1._Code("+")
11905 + };
11906 + var Node = class {
11907 + optimizeNodes() {
11908 + return this;
11909 + }
11910 + optimizeNames(_names, _constants) {
11911 + return this;
11912 + }
11913 + };
11914 + var Def = class extends Node {
11915 + constructor(varKind, name, rhs) {
11916 + super();
11917 + this.varKind = varKind;
11918 + this.name = name;
11919 + this.rhs = rhs;
11920 + }
11921 + render({ es5, _n }) {
11922 + const varKind = es5 ? scope_1.varKinds.var : this.varKind;
11923 + const rhs = this.rhs === void 0 ? "" : ` = ${this.rhs}`;
11924 + return `${varKind} ${this.name}${rhs};` + _n;
11925 + }
11926 + optimizeNames(names, constants) {
11927 + if (!names[this.name.str]) return;
11928 + if (this.rhs) this.rhs = optimizeExpr(this.rhs, names, constants);
11929 + return this;
11930 + }
11931 + get names() {
11932 + return this.rhs instanceof code_1._CodeOrName ? this.rhs.names : {};
11933 + }
11934 + };
11935 + var Assign = class extends Node {
11936 + constructor(lhs, rhs, sideEffects) {
11937 + super();
11938 + this.lhs = lhs;
11939 + this.rhs = rhs;
11940 + this.sideEffects = sideEffects;
11941 + }
11942 + render({ _n }) {
11943 + return `${this.lhs} = ${this.rhs};` + _n;
11944 + }
11945 + optimizeNames(names, constants) {
11946 + if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects) return;
11947 + this.rhs = optimizeExpr(this.rhs, names, constants);
11948 + return this;
11949 + }
11950 + get names() {
11951 + return addExprNames(this.lhs instanceof code_1.Name ? {} : { ...this.lhs.names }, this.rhs);
11952 + }
11953 + };
11954 + var AssignOp = class extends Assign {
11955 + constructor(lhs, op, rhs, sideEffects) {
11956 + super(lhs, rhs, sideEffects);
11957 + this.op = op;
11958 + }
11959 + render({ _n }) {
11960 + return `${this.lhs} ${this.op}= ${this.rhs};` + _n;
11961 + }
11962 + };
11963 + var Label = class extends Node {
11964 + constructor(label) {
11965 + super();
11966 + this.label = label;
11967 + this.names = {};
11968 + }
11969 + render({ _n }) {
11970 + return `${this.label}:` + _n;
11971 + }
11972 + };
11973 + var Break = class extends Node {
11974 + constructor(label) {
11975 + super();
11976 + this.label = label;
11977 + this.names = {};
11978 + }
11979 + render({ _n }) {
11980 + return `break${this.label ? ` ${this.label}` : ""};` + _n;
11981 + }
11982 + };
11983 + var Throw = class extends Node {
11984 + constructor(error) {
11985 + super();
11986 + this.error = error;
11987 + }
11988 + render({ _n }) {
11989 + return `throw ${this.error};` + _n;
11990 + }
11991 + get names() {
11992 + return this.error.names;
11993 + }
11994 + };
11995 + var AnyCode = class extends Node {
11996 + constructor(code) {
11997 + super();
11998 + this.code = code;
11999 + }
12000 + render({ _n }) {
12001 + return `${this.code};` + _n;
12002 + }
12003 + optimizeNodes() {
12004 + return `${this.code}` ? this : void 0;
12005 + }
12006 + optimizeNames(names, constants) {
12007 + this.code = optimizeExpr(this.code, names, constants);
12008 + return this;
12009 + }
12010 + get names() {
12011 + return this.code instanceof code_1._CodeOrName ? this.code.names : {};
12012 + }
12013 + };
12014 + var ParentNode = class extends Node {
12015 + constructor(nodes = []) {
12016 + super();
12017 + this.nodes = nodes;
12018 + }
12019 + render(opts) {
12020 + return this.nodes.reduce((code, n) => code + n.render(opts), "");
12021 + }
12022 + optimizeNodes() {
12023 + const { nodes } = this;
12024 + let i = nodes.length;
12025 + while (i--) {
12026 + const n = nodes[i].optimizeNodes();
12027 + if (Array.isArray(n)) nodes.splice(i, 1, ...n);
12028 + else if (n) nodes[i] = n;
12029 + else nodes.splice(i, 1);
12030 + }
12031 + return nodes.length > 0 ? this : void 0;
12032 + }
12033 + optimizeNames(names, constants) {
12034 + const { nodes } = this;
12035 + let i = nodes.length;
12036 + while (i--) {
12037 + const n = nodes[i];
12038 + if (n.optimizeNames(names, constants)) continue;
12039 + subtractNames(names, n.names);
12040 + nodes.splice(i, 1);
12041 + }
12042 + return nodes.length > 0 ? this : void 0;
12043 + }
12044 + get names() {
12045 + return this.nodes.reduce((names, n) => addNames(names, n.names), {});
12046 + }
12047 + };
12048 + var BlockNode = class extends ParentNode {
12049 + render(opts) {
12050 + return "{" + opts._n + super.render(opts) + "}" + opts._n;
12051 + }
12052 + };
12053 + var Root = class extends ParentNode {};
12054 + var Else = class extends BlockNode {};
12055 + Else.kind = "else";
12056 + var If = class If extends BlockNode {
12057 + constructor(condition, nodes) {
12058 + super(nodes);
12059 + this.condition = condition;
12060 + }
12061 + render(opts) {
12062 + let code = `if(${this.condition})` + super.render(opts);
12063 + if (this.else) code += "else " + this.else.render(opts);
12064 + return code;
12065 + }
12066 + optimizeNodes() {
12067 + super.optimizeNodes();
12068 + const cond = this.condition;
12069 + if (cond === true) return this.nodes;
12070 + let e = this.else;
12071 + if (e) {
12072 + const ns = e.optimizeNodes();
12073 + e = this.else = Array.isArray(ns) ? new Else(ns) : ns;
12074 + }
12075 + if (e) {
12076 + if (cond === false) return e instanceof If ? e : e.nodes;
12077 + if (this.nodes.length) return this;
12078 + return new If(not(cond), e instanceof If ? [e] : e.nodes);
12079 + }
12080 + if (cond === false || !this.nodes.length) return void 0;
12081 + return this;
12082 + }
12083 + optimizeNames(names, constants) {
12084 + var _a;
12085 + this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
12086 + if (!(super.optimizeNames(names, constants) || this.else)) return;
12087 + this.condition = optimizeExpr(this.condition, names, constants);
12088 + return this;
12089 + }
12090 + get names() {
12091 + const names = super.names;
12092 + addExprNames(names, this.condition);
12093 + if (this.else) addNames(names, this.else.names);
12094 + return names;
12095 + }
12096 + };
12097 + If.kind = "if";
12098 + var For = class extends BlockNode {};
12099 + For.kind = "for";
12100 + var ForLoop = class extends For {
12101 + constructor(iteration) {
12102 + super();
12103 + this.iteration = iteration;
12104 + }
12105 + render(opts) {
12106 + return `for(${this.iteration})` + super.render(opts);
12107 + }
12108 + optimizeNames(names, constants) {
12109 + if (!super.optimizeNames(names, constants)) return;
12110 + this.iteration = optimizeExpr(this.iteration, names, constants);
12111 + return this;
12112 + }
12113 + get names() {
12114 + return addNames(super.names, this.iteration.names);
12115 + }
12116 + };
12117 + var ForRange = class extends For {
12118 + constructor(varKind, name, from, to) {
12119 + super();
12120 + this.varKind = varKind;
12121 + this.name = name;
12122 + this.from = from;
12123 + this.to = to;
12124 + }
12125 + render(opts) {
12126 + const varKind = opts.es5 ? scope_1.varKinds.var : this.varKind;
12127 + const { name, from, to } = this;
12128 + return `for(${varKind} ${name}=${from}; ${name}<${to}; ${name}++)` + super.render(opts);
12129 + }
12130 + get names() {
12131 + return addExprNames(addExprNames(super.names, this.from), this.to);
12132 + }
12133 + };
12134 + var ForIter = class extends For {
12135 + constructor(loop, varKind, name, iterable) {
12136 + super();
12137 + this.loop = loop;
12138 + this.varKind = varKind;
12139 + this.name = name;
12140 + this.iterable = iterable;
12141 + }
12142 + render(opts) {
12143 + return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
12144 + }
12145 + optimizeNames(names, constants) {
12146 + if (!super.optimizeNames(names, constants)) return;
12147 + this.iterable = optimizeExpr(this.iterable, names, constants);
12148 + return this;
12149 + }
12150 + get names() {
12151 + return addNames(super.names, this.iterable.names);
12152 + }
12153 + };
12154 + var Func = class extends BlockNode {
12155 + constructor(name, args, async) {
12156 + super();
12157 + this.name = name;
12158 + this.args = args;
12159 + this.async = async;
12160 + }
12161 + render(opts) {
12162 + return `${this.async ? "async " : ""}function ${this.name}(${this.args})` + super.render(opts);
12163 + }
12164 + };
12165 + Func.kind = "func";
12166 + var Return = class extends ParentNode {
12167 + render(opts) {
12168 + return "return " + super.render(opts);
12169 + }
12170 + };
12171 + Return.kind = "return";
12172 + var Try = class extends BlockNode {
12173 + render(opts) {
12174 + let code = "try" + super.render(opts);
12175 + if (this.catch) code += this.catch.render(opts);
12176 + if (this.finally) code += this.finally.render(opts);
12177 + return code;
12178 + }
12179 + optimizeNodes() {
12180 + var _a;
12181 + var _b;
12182 + super.optimizeNodes();
12183 + (_a = this.catch) === null || _a === void 0 || _a.optimizeNodes();
12184 + (_b = this.finally) === null || _b === void 0 || _b.optimizeNodes();
12185 + return this;
12186 + }
12187 + optimizeNames(names, constants) {
12188 + var _a;
12189 + var _b;
12190 + super.optimizeNames(names, constants);
12191 + (_a = this.catch) === null || _a === void 0 || _a.optimizeNames(names, constants);
12192 + (_b = this.finally) === null || _b === void 0 || _b.optimizeNames(names, constants);
12193 + return this;
12194 + }
12195 + get names() {
12196 + const names = super.names;
12197 + if (this.catch) addNames(names, this.catch.names);
12198 + if (this.finally) addNames(names, this.finally.names);
12199 + return names;
12200 + }
12201 + };
12202 + var Catch = class extends BlockNode {
12203 + constructor(error) {
12204 + super();
12205 + this.error = error;
12206 + }
12207 + render(opts) {
12208 + return `catch(${this.error})` + super.render(opts);
12209 + }
12210 + };
12211 + Catch.kind = "catch";
12212 + var Finally = class extends BlockNode {
12213 + render(opts) {
12214 + return "finally" + super.render(opts);
12215 + }
12216 + };
12217 + Finally.kind = "finally";
12218 + var CodeGen = class {
12219 + constructor(extScope, opts = {}) {
12220 + this._values = {};
12221 + this._blockStarts = [];
12222 + this._constants = {};
12223 + this.opts = {
12224 + ...opts,
12225 + _n: opts.lines ? "\n" : ""
12226 + };
12227 + this._extScope = extScope;
12228 + this._scope = new scope_1.Scope({ parent: extScope });
12229 + this._nodes = [new Root()];
12230 + }
12231 + toString() {
12232 + return this._root.render(this.opts);
12233 + }
12234 + name(prefix) {
12235 + return this._scope.name(prefix);
12236 + }
12237 + scopeName(prefix) {
12238 + return this._extScope.name(prefix);
12239 + }
12240 + scopeValue(prefixOrName, value) {
12241 + const name = this._extScope.value(prefixOrName, value);
12242 + (this._values[name.prefix] || (this._values[name.prefix] = /* @__PURE__ */ new Set())).add(name);
12243 + return name;
12244 + }
12245 + getScopeValue(prefix, keyOrRef) {
12246 + return this._extScope.getValue(prefix, keyOrRef);
12247 + }
12248 + scopeRefs(scopeName) {
12249 + return this._extScope.scopeRefs(scopeName, this._values);
12250 + }
12251 + scopeCode() {
12252 + return this._extScope.scopeCode(this._values);
12253 + }
12254 + _def(varKind, nameOrPrefix, rhs, constant) {
12255 + const name = this._scope.toName(nameOrPrefix);
12256 + if (rhs !== void 0 && constant) this._constants[name.str] = rhs;
12257 + this._leafNode(new Def(varKind, name, rhs));
12258 + return name;
12259 + }
12260 + const(nameOrPrefix, rhs, _constant) {
12261 + return this._def(scope_1.varKinds.const, nameOrPrefix, rhs, _constant);
12262 + }
12263 + let(nameOrPrefix, rhs, _constant) {
12264 + return this._def(scope_1.varKinds.let, nameOrPrefix, rhs, _constant);
12265 + }
12266 + var(nameOrPrefix, rhs, _constant) {
12267 + return this._def(scope_1.varKinds.var, nameOrPrefix, rhs, _constant);
12268 + }
12269 + assign(lhs, rhs, sideEffects) {
12270 + return this._leafNode(new Assign(lhs, rhs, sideEffects));
12271 + }
12272 + add(lhs, rhs) {
12273 + return this._leafNode(new AssignOp(lhs, exports.operators.ADD, rhs));
12274 + }
12275 + code(c) {
12276 + if (typeof c == "function") c();
12277 + else if (c !== code_1.nil) this._leafNode(new AnyCode(c));
12278 + return this;
12279 + }
12280 + object(...keyValues) {
12281 + const code = ["{"];
12282 + for (const [key, value] of keyValues) {
12283 + if (code.length > 1) code.push(",");
12284 + code.push(key);
12285 + if (key !== value || this.opts.es5) {
12286 + code.push(":");
12287 + (0, code_1.addCodeArg)(code, value);
12288 + }
12289 + }
12290 + code.push("}");
12291 + return new code_1._Code(code);
12292 + }
12293 + if(condition, thenBody, elseBody) {
12294 + this._blockNode(new If(condition));
12295 + if (thenBody && elseBody) this.code(thenBody).else().code(elseBody).endIf();
12296 + else if (thenBody) this.code(thenBody).endIf();
12297 + else if (elseBody) throw new Error("CodeGen: \"else\" body without \"then\" body");
12298 + return this;
12299 + }
12300 + elseIf(condition) {
12301 + return this._elseNode(new If(condition));
12302 + }
12303 + else() {
12304 + return this._elseNode(new Else());
12305 + }
12306 + endIf() {
12307 + return this._endBlockNode(If, Else);
12308 + }
12309 + _for(node, forBody) {
12310 + this._blockNode(node);
12311 + if (forBody) this.code(forBody).endFor();
12312 + return this;
12313 + }
12314 + for(iteration, forBody) {
12315 + return this._for(new ForLoop(iteration), forBody);
12316 + }
12317 + forRange(nameOrPrefix, from, to, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.let) {
12318 + const name = this._scope.toName(nameOrPrefix);
12319 + return this._for(new ForRange(varKind, name, from, to), () => forBody(name));
12320 + }
12321 + forOf(nameOrPrefix, iterable, forBody, varKind = scope_1.varKinds.const) {
12322 + const name = this._scope.toName(nameOrPrefix);
12323 + if (this.opts.es5) {
12324 + const arr = iterable instanceof code_1.Name ? iterable : this.var("_arr", iterable);
12325 + return this.forRange("_i", 0, (0, code_1._)`${arr}.length`, (i) => {
12326 + this.var(name, (0, code_1._)`${arr}[${i}]`);
12327 + forBody(name);
12328 + });
12329 + }
12330 + return this._for(new ForIter("of", varKind, name, iterable), () => forBody(name));
12331 + }
12332 + forIn(nameOrPrefix, obj, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.const) {
12333 + if (this.opts.ownProperties) return this.forOf(nameOrPrefix, (0, code_1._)`Object.keys(${obj})`, forBody);
12334 + const name = this._scope.toName(nameOrPrefix);
12335 + return this._for(new ForIter("in", varKind, name, obj), () => forBody(name));
12336 + }
12337 + endFor() {
12338 + return this._endBlockNode(For);
12339 + }
12340 + label(label) {
12341 + return this._leafNode(new Label(label));
12342 + }
12343 + break(label) {
12344 + return this._leafNode(new Break(label));
12345 + }
12346 + return(value) {
12347 + const node = new Return();
12348 + this._blockNode(node);
12349 + this.code(value);
12350 + if (node.nodes.length !== 1) throw new Error("CodeGen: \"return\" should have one node");
12351 + return this._endBlockNode(Return);
12352 + }
12353 + try(tryBody, catchCode, finallyCode) {
12354 + if (!catchCode && !finallyCode) throw new Error("CodeGen: \"try\" without \"catch\" and \"finally\"");
12355 + const node = new Try();
12356 + this._blockNode(node);
12357 + this.code(tryBody);
12358 + if (catchCode) {
12359 + const error = this.name("e");
12360 + this._currNode = node.catch = new Catch(error);
12361 + catchCode(error);
12362 + }
12363 + if (finallyCode) {
12364 + this._currNode = node.finally = new Finally();
12365 + this.code(finallyCode);
12366 + }
12367 + return this._endBlockNode(Catch, Finally);
12368 + }
12369 + throw(error) {
12370 + return this._leafNode(new Throw(error));
12371 + }
12372 + block(body, nodeCount) {
12373 + this._blockStarts.push(this._nodes.length);
12374 + if (body) this.code(body).endBlock(nodeCount);
12375 + return this;
12376 + }
12377 + endBlock(nodeCount) {
12378 + const len = this._blockStarts.pop();
12379 + if (len === void 0) throw new Error("CodeGen: not in self-balancing block");
12380 + const toClose = this._nodes.length - len;
12381 + if (toClose < 0 || nodeCount !== void 0 && toClose !== nodeCount) throw new Error(`CodeGen: wrong number of nodes: ${toClose} vs ${nodeCount} expected`);
12382 + this._nodes.length = len;
12383 + return this;
12384 + }
12385 + func(name, args = code_1.nil, async, funcBody) {
12386 + this._blockNode(new Func(name, args, async));
12387 + if (funcBody) this.code(funcBody).endFunc();
12388 + return this;
12389 + }
12390 + endFunc() {
12391 + return this._endBlockNode(Func);
12392 + }
12393 + optimize(n = 1) {
12394 + while (n-- > 0) {
12395 + this._root.optimizeNodes();
12396 + this._root.optimizeNames(this._root.names, this._constants);
12397 + }
12398 + }
12399 + _leafNode(node) {
12400 + this._currNode.nodes.push(node);
12401 + return this;
12402 + }
12403 + _blockNode(node) {
12404 + this._currNode.nodes.push(node);
12405 + this._nodes.push(node);
12406 + }
12407 + _endBlockNode(N1, N2) {
12408 + const n = this._currNode;
12409 + if (n instanceof N1 || N2 && n instanceof N2) {
12410 + this._nodes.pop();
12411 + return this;
12412 + }
12413 + throw new Error(`CodeGen: not in block "${N2 ? `${N1.kind}/${N2.kind}` : N1.kind}"`);
12414 + }
12415 + _elseNode(node) {
12416 + const n = this._currNode;
12417 + if (!(n instanceof If)) throw new Error("CodeGen: \"else\" without \"if\"");
12418 + this._currNode = n.else = node;
12419 + return this;
12420 + }
12421 + get _root() {
12422 + return this._nodes[0];
12423 + }
12424 + get _currNode() {
12425 + const ns = this._nodes;
12426 + return ns[ns.length - 1];
12427 + }
12428 + set _currNode(node) {
12429 + const ns = this._nodes;
12430 + ns[ns.length - 1] = node;
12431 + }
12432 + };
12433 + exports.CodeGen = CodeGen;
12434 + function addNames(names, from) {
12435 + for (const n in from) names[n] = (names[n] || 0) + (from[n] || 0);
12436 + return names;
12437 + }
12438 + function addExprNames(names, from) {
12439 + return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
12440 + }
12441 + function optimizeExpr(expr, names, constants) {
12442 + if (expr instanceof code_1.Name) return replaceName(expr);
12443 + if (!canOptimize(expr)) return expr;
12444 + return new code_1._Code(expr._items.reduce((items, c) => {
12445 + if (c instanceof code_1.Name) c = replaceName(c);
12446 + if (c instanceof code_1._Code) items.push(...c._items);
12447 + else items.push(c);
12448 + return items;
12449 + }, []));
12450 + function replaceName(n) {
12451 + const c = constants[n.str];
12452 + if (c === void 0 || names[n.str] !== 1) return n;
12453 + delete names[n.str];
12454 + return c;
12455 + }
12456 + function canOptimize(e) {
12457 + return e instanceof code_1._Code && e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants[c.str] !== void 0);
12458 + }
12459 + }
12460 + function subtractNames(names, from) {
12461 + for (const n in from) names[n] = (names[n] || 0) - (from[n] || 0);
12462 + }
12463 + function not(x) {
12464 + return typeof x == "boolean" || typeof x == "number" || x === null ? !x : (0, code_1._)`!${par(x)}`;
12465 + }
12466 + exports.not = not;
12467 + var andCode = mappend(exports.operators.AND);
12468 + function and(...args) {
12469 + return args.reduce(andCode);
12470 + }
12471 + exports.and = and;
12472 + var orCode = mappend(exports.operators.OR);
12473 + function or(...args) {
12474 + return args.reduce(orCode);
12475 + }
12476 + exports.or = or;
12477 + function mappend(op) {
12478 + return (x, y) => x === code_1.nil ? y : y === code_1.nil ? x : (0, code_1._)`${par(x)} ${op} ${par(y)}`;
12479 + }
12480 + function par(x) {
12481 + return x instanceof code_1.Name ? x : (0, code_1._)`(${x})`;
12482 + }
12483 + }));
12484 +
12485 +//#endregion
12486 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/util.js
12487 + var require_util = /* @__PURE__ */ __commonJSMin(((exports) => {
12488 + Object.defineProperty(exports, "__esModule", { value: true });
12489 + exports.checkStrictMode = exports.getErrorPath = exports.Type = exports.useFunc = exports.setEvaluated = exports.evaluatedPropsToName = exports.mergeEvaluated = exports.eachItem = exports.unescapeJsonPointer = exports.escapeJsonPointer = exports.escapeFragment = exports.unescapeFragment = exports.schemaRefOrVal = exports.schemaHasRulesButRef = exports.schemaHasRules = exports.checkUnknownRules = exports.alwaysValidSchema = exports.toHash = void 0;
12490 + var codegen_1 = require_codegen();
12491 + var code_1 = require_code$1();
12492 + function toHash(arr) {
12493 + const hash = {};
12494 + for (const item of arr) hash[item] = true;
12495 + return hash;
12496 + }
12497 + exports.toHash = toHash;
12498 + function alwaysValidSchema(it, schema) {
12499 + if (typeof schema == "boolean") return schema;
12500 + if (Object.keys(schema).length === 0) return true;
12501 + checkUnknownRules(it, schema);
12502 + return !schemaHasRules(schema, it.self.RULES.all);
12503 + }
12504 + exports.alwaysValidSchema = alwaysValidSchema;
12505 + function checkUnknownRules(it, schema = it.schema) {
12506 + const { opts, self } = it;
12507 + if (!opts.strictSchema) return;
12508 + if (typeof schema === "boolean") return;
12509 + const rules = self.RULES.keywords;
12510 + for (const key in schema) if (!rules[key]) checkStrictMode(it, `unknown keyword: "${key}"`);
12511 + }
12512 + exports.checkUnknownRules = checkUnknownRules;
12513 + function schemaHasRules(schema, rules) {
12514 + if (typeof schema == "boolean") return !schema;
12515 + for (const key in schema) if (rules[key]) return true;
12516 + return false;
12517 + }
12518 + exports.schemaHasRules = schemaHasRules;
12519 + function schemaHasRulesButRef(schema, RULES) {
12520 + if (typeof schema == "boolean") return !schema;
12521 + for (const key in schema) if (key !== "$ref" && RULES.all[key]) return true;
12522 + return false;
12523 + }
12524 + exports.schemaHasRulesButRef = schemaHasRulesButRef;
12525 + function schemaRefOrVal({ topSchemaRef, schemaPath }, schema, keyword, $data) {
12526 + if (!$data) {
12527 + if (typeof schema == "number" || typeof schema == "boolean") return schema;
12528 + if (typeof schema == "string") return (0, codegen_1._)`${schema}`;
12529 + }
12530 + return (0, codegen_1._)`${topSchemaRef}${schemaPath}${(0, codegen_1.getProperty)(keyword)}`;
12531 + }
12532 + exports.schemaRefOrVal = schemaRefOrVal;
12533 + function unescapeFragment(str) {
12534 + return unescapeJsonPointer(decodeURIComponent(str));
12535 + }
12536 + exports.unescapeFragment = unescapeFragment;
12537 + function escapeFragment(str) {
12538 + return encodeURIComponent(escapeJsonPointer(str));
12539 + }
12540 + exports.escapeFragment = escapeFragment;
12541 + function escapeJsonPointer(str) {
12542 + if (typeof str == "number") return `${str}`;
12543 + return str.replace(/~/g, "~0").replace(/\//g, "~1");
12544 + }
12545 + exports.escapeJsonPointer = escapeJsonPointer;
12546 + function unescapeJsonPointer(str) {
12547 + return str.replace(/~1/g, "/").replace(/~0/g, "~");
12548 + }
12549 + exports.unescapeJsonPointer = unescapeJsonPointer;
12550 + function eachItem(xs, f) {
12551 + if (Array.isArray(xs)) for (const x of xs) f(x);
12552 + else f(xs);
12553 + }
12554 + exports.eachItem = eachItem;
12555 + function makeMergeEvaluated({ mergeNames, mergeToName, mergeValues, resultToName }) {
12556 + return (gen, from, to, toName) => {
12557 + const res = to === void 0 ? from : to instanceof codegen_1.Name ? (from instanceof codegen_1.Name ? mergeNames(gen, from, to) : mergeToName(gen, from, to), to) : from instanceof codegen_1.Name ? (mergeToName(gen, to, from), from) : mergeValues(from, to);
12558 + return toName === codegen_1.Name && !(res instanceof codegen_1.Name) ? resultToName(gen, res) : res;
12559 + };
12560 + }
12561 + exports.mergeEvaluated = {
12562 + props: makeMergeEvaluated({
12563 + mergeNames: (gen, from, to) => gen.if((0, codegen_1._)`${to} !== true && ${from} !== undefined`, () => {
12564 + gen.if((0, codegen_1._)`${from} === true`, () => gen.assign(to, true), () => gen.assign(to, (0, codegen_1._)`${to} || {}`).code((0, codegen_1._)`Object.assign(${to}, ${from})`));
12565 + }),
12566 + mergeToName: (gen, from, to) => gen.if((0, codegen_1._)`${to} !== true`, () => {
12567 + if (from === true) gen.assign(to, true);
12568 + else {
12569 + gen.assign(to, (0, codegen_1._)`${to} || {}`);
12570 + setEvaluated(gen, to, from);
12571 + }
12572 + }),
12573 + mergeValues: (from, to) => from === true ? true : {
12574 + ...from,
12575 + ...to
12576 + },
12577 + resultToName: evaluatedPropsToName
12578 + }),
12579 + items: makeMergeEvaluated({
12580 + mergeNames: (gen, from, to) => gen.if((0, codegen_1._)`${to} !== true && ${from} !== undefined`, () => gen.assign(to, (0, codegen_1._)`${from} === true ? true : ${to} > ${from} ? ${to} : ${from}`)),
12581 + mergeToName: (gen, from, to) => gen.if((0, codegen_1._)`${to} !== true`, () => gen.assign(to, from === true ? true : (0, codegen_1._)`${to} > ${from} ? ${to} : ${from}`)),
12582 + mergeValues: (from, to) => from === true ? true : Math.max(from, to),
12583 + resultToName: (gen, items) => gen.var("items", items)
12584 + })
12585 + };
12586 + function evaluatedPropsToName(gen, ps) {
12587 + if (ps === true) return gen.var("props", true);
12588 + const props = gen.var("props", (0, codegen_1._)`{}`);
12589 + if (ps !== void 0) setEvaluated(gen, props, ps);
12590 + return props;
12591 + }
12592 + exports.evaluatedPropsToName = evaluatedPropsToName;
12593 + function setEvaluated(gen, props, ps) {
12594 + Object.keys(ps).forEach((p) => gen.assign((0, codegen_1._)`${props}${(0, codegen_1.getProperty)(p)}`, true));
12595 + }
12596 + exports.setEvaluated = setEvaluated;
12597 + var snippets = {};
12598 + function useFunc(gen, f) {
12599 + return gen.scopeValue("func", {
12600 + ref: f,
12601 + code: snippets[f.code] || (snippets[f.code] = new code_1._Code(f.code))
12602 + });
12603 + }
12604 + exports.useFunc = useFunc;
12605 + var Type;
12606 + (function(Type) {
12607 + Type[Type["Num"] = 0] = "Num";
12608 + Type[Type["Str"] = 1] = "Str";
12609 + })(Type || (exports.Type = Type = {}));
12610 + function getErrorPath(dataProp, dataPropType, jsPropertySyntax) {
12611 + if (dataProp instanceof codegen_1.Name) {
12612 + const isNumber = dataPropType === Type.Num;
12613 + return jsPropertySyntax ? isNumber ? (0, codegen_1._)`"[" + ${dataProp} + "]"` : (0, codegen_1._)`"['" + ${dataProp} + "']"` : isNumber ? (0, codegen_1._)`"/" + ${dataProp}` : (0, codegen_1._)`"/" + ${dataProp}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
12614 + }
12615 + return jsPropertySyntax ? (0, codegen_1.getProperty)(dataProp).toString() : "/" + escapeJsonPointer(dataProp);
12616 + }
12617 + exports.getErrorPath = getErrorPath;
12618 + function checkStrictMode(it, msg, mode = it.opts.strictSchema) {
12619 + if (!mode) return;
12620 + msg = `strict mode: ${msg}`;
12621 + if (mode === true) throw new Error(msg);
12622 + it.self.logger.warn(msg);
12623 + }
12624 + exports.checkStrictMode = checkStrictMode;
12625 + }));
12626 +
12627 +//#endregion
12628 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/names.js
12629 + var require_names = /* @__PURE__ */ __commonJSMin(((exports) => {
12630 + Object.defineProperty(exports, "__esModule", { value: true });
12631 + var codegen_1 = require_codegen();
12632 + var names = {
12633 + data: new codegen_1.Name("data"),
12634 + valCxt: new codegen_1.Name("valCxt"),
12635 + instancePath: new codegen_1.Name("instancePath"),
12636 + parentData: new codegen_1.Name("parentData"),
12637 + parentDataProperty: new codegen_1.Name("parentDataProperty"),
12638 + rootData: new codegen_1.Name("rootData"),
12639 + dynamicAnchors: new codegen_1.Name("dynamicAnchors"),
12640 + vErrors: new codegen_1.Name("vErrors"),
12641 + errors: new codegen_1.Name("errors"),
12642 + this: new codegen_1.Name("this"),
12643 + self: new codegen_1.Name("self"),
12644 + scope: new codegen_1.Name("scope"),
12645 + json: new codegen_1.Name("json"),
12646 + jsonPos: new codegen_1.Name("jsonPos"),
12647 + jsonLen: new codegen_1.Name("jsonLen"),
12648 + jsonPart: new codegen_1.Name("jsonPart")
12649 + };
12650 + exports.default = names;
12651 + }));
12652 +
12653 +//#endregion
12654 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/errors.js
12655 + var require_errors = /* @__PURE__ */ __commonJSMin(((exports) => {
12656 + Object.defineProperty(exports, "__esModule", { value: true });
12657 + exports.extendErrors = exports.resetErrorsCount = exports.reportExtraError = exports.reportError = exports.keyword$DataError = exports.keywordError = void 0;
12658 + var codegen_1 = require_codegen();
12659 + var util_1 = require_util();
12660 + var names_1 = require_names();
12661 + exports.keywordError = { message: ({ keyword }) => (0, codegen_1.str)`must pass "${keyword}" keyword validation` };
12662 + exports.keyword$DataError = { message: ({ keyword, schemaType }) => schemaType ? (0, codegen_1.str)`"${keyword}" keyword must be ${schemaType} ($data)` : (0, codegen_1.str)`"${keyword}" keyword is invalid ($data)` };
12663 + function reportError(cxt, error = exports.keywordError, errorPaths, overrideAllErrors) {
12664 + const { it } = cxt;
12665 + const { gen, compositeRule, allErrors } = it;
12666 + const errObj = errorObjectCode(cxt, error, errorPaths);
12667 + if (overrideAllErrors !== null && overrideAllErrors !== void 0 ? overrideAllErrors : compositeRule || allErrors) addError(gen, errObj);
12668 + else returnErrors(it, (0, codegen_1._)`[${errObj}]`);
12669 + }
12670 + exports.reportError = reportError;
12671 + function reportExtraError(cxt, error = exports.keywordError, errorPaths) {
12672 + const { it } = cxt;
12673 + const { gen, compositeRule, allErrors } = it;
12674 + addError(gen, errorObjectCode(cxt, error, errorPaths));
12675 + if (!(compositeRule || allErrors)) returnErrors(it, names_1.default.vErrors);
12676 + }
12677 + exports.reportExtraError = reportExtraError;
12678 + function resetErrorsCount(gen, errsCount) {
12679 + gen.assign(names_1.default.errors, errsCount);
12680 + gen.if((0, codegen_1._)`${names_1.default.vErrors} !== null`, () => gen.if(errsCount, () => gen.assign((0, codegen_1._)`${names_1.default.vErrors}.length`, errsCount), () => gen.assign(names_1.default.vErrors, null)));
12681 + }
12682 + exports.resetErrorsCount = resetErrorsCount;
12683 + function extendErrors({ gen, keyword, schemaValue, data, errsCount, it }) {
12684 + /* istanbul ignore if */
12685 + if (errsCount === void 0) throw new Error("ajv implementation error");
12686 + const err = gen.name("err");
12687 + gen.forRange("i", errsCount, names_1.default.errors, (i) => {
12688 + gen.const(err, (0, codegen_1._)`${names_1.default.vErrors}[${i}]`);
12689 + gen.if((0, codegen_1._)`${err}.instancePath === undefined`, () => gen.assign((0, codegen_1._)`${err}.instancePath`, (0, codegen_1.strConcat)(names_1.default.instancePath, it.errorPath)));
12690 + gen.assign((0, codegen_1._)`${err}.schemaPath`, (0, codegen_1.str)`${it.errSchemaPath}/${keyword}`);
12691 + if (it.opts.verbose) {
12692 + gen.assign((0, codegen_1._)`${err}.schema`, schemaValue);
12693 + gen.assign((0, codegen_1._)`${err}.data`, data);
12694 + }
12695 + });
12696 + }
12697 + exports.extendErrors = extendErrors;
12698 + function addError(gen, errObj) {
12699 + const err = gen.const("err", errObj);
12700 + gen.if((0, codegen_1._)`${names_1.default.vErrors} === null`, () => gen.assign(names_1.default.vErrors, (0, codegen_1._)`[${err}]`), (0, codegen_1._)`${names_1.default.vErrors}.push(${err})`);
12701 + gen.code((0, codegen_1._)`${names_1.default.errors}++`);
12702 + }
12703 + function returnErrors(it, errs) {
12704 + const { gen, validateName, schemaEnv } = it;
12705 + if (schemaEnv.$async) gen.throw((0, codegen_1._)`new ${it.ValidationError}(${errs})`);
12706 + else {
12707 + gen.assign((0, codegen_1._)`${validateName}.errors`, errs);
12708 + gen.return(false);
12709 + }
12710 + }
12711 + var E = {
12712 + keyword: new codegen_1.Name("keyword"),
12713 + schemaPath: new codegen_1.Name("schemaPath"),
12714 + params: new codegen_1.Name("params"),
12715 + propertyName: new codegen_1.Name("propertyName"),
12716 + message: new codegen_1.Name("message"),
12717 + schema: new codegen_1.Name("schema"),
12718 + parentSchema: new codegen_1.Name("parentSchema")
12719 + };
12720 + function errorObjectCode(cxt, error, errorPaths) {
12721 + const { createErrors } = cxt.it;
12722 + if (createErrors === false) return (0, codegen_1._)`{}`;
12723 + return errorObject(cxt, error, errorPaths);
12724 + }
12725 + function errorObject(cxt, error, errorPaths = {}) {
12726 + const { gen, it } = cxt;
12727 + const keyValues = [errorInstancePath(it, errorPaths), errorSchemaPath(cxt, errorPaths)];
12728 + extraErrorProps(cxt, error, keyValues);
12729 + return gen.object(...keyValues);
12730 + }
12731 + function errorInstancePath({ errorPath }, { instancePath }) {
12732 + const instPath = instancePath ? (0, codegen_1.str)`${errorPath}${(0, util_1.getErrorPath)(instancePath, util_1.Type.Str)}` : errorPath;
12733 + return [names_1.default.instancePath, (0, codegen_1.strConcat)(names_1.default.instancePath, instPath)];
12734 + }
12735 + function errorSchemaPath({ keyword, it: { errSchemaPath } }, { schemaPath, parentSchema }) {
12736 + let schPath = parentSchema ? errSchemaPath : (0, codegen_1.str)`${errSchemaPath}/${keyword}`;
12737 + if (schemaPath) schPath = (0, codegen_1.str)`${schPath}${(0, util_1.getErrorPath)(schemaPath, util_1.Type.Str)}`;
12738 + return [E.schemaPath, schPath];
12739 + }
12740 + function extraErrorProps(cxt, { params, message }, keyValues) {
12741 + const { keyword, data, schemaValue, it } = cxt;
12742 + const { opts, propertyName, topSchemaRef, schemaPath } = it;
12743 + keyValues.push([E.keyword, keyword], [E.params, typeof params == "function" ? params(cxt) : params || (0, codegen_1._)`{}`]);
12744 + if (opts.messages) keyValues.push([E.message, typeof message == "function" ? message(cxt) : message]);
12745 + if (opts.verbose) keyValues.push([E.schema, schemaValue], [E.parentSchema, (0, codegen_1._)`${topSchemaRef}${schemaPath}`], [names_1.default.data, data]);
12746 + if (propertyName) keyValues.push([E.propertyName, propertyName]);
12747 + }
12748 + }));
12749 +
12750 +//#endregion
12751 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/validate/boolSchema.js
12752 + var require_boolSchema = /* @__PURE__ */ __commonJSMin(((exports) => {
12753 + Object.defineProperty(exports, "__esModule", { value: true });
12754 + exports.boolOrEmptySchema = exports.topBoolOrEmptySchema = void 0;
12755 + var errors_1 = require_errors();
12756 + var codegen_1 = require_codegen();
12757 + var names_1 = require_names();
12758 + var boolError = { message: "boolean schema is false" };
12759 + function topBoolOrEmptySchema(it) {
12760 + const { gen, schema, validateName } = it;
12761 + if (schema === false) falseSchemaError(it, false);
12762 + else if (typeof schema == "object" && schema.$async === true) gen.return(names_1.default.data);
12763 + else {
12764 + gen.assign((0, codegen_1._)`${validateName}.errors`, null);
12765 + gen.return(true);
12766 + }
12767 + }
12768 + exports.topBoolOrEmptySchema = topBoolOrEmptySchema;
12769 + function boolOrEmptySchema(it, valid) {
12770 + const { gen, schema } = it;
12771 + if (schema === false) {
12772 + gen.var(valid, false);
12773 + falseSchemaError(it);
12774 + } else gen.var(valid, true);
12775 + }
12776 + exports.boolOrEmptySchema = boolOrEmptySchema;
12777 + function falseSchemaError(it, overrideAllErrors) {
12778 + const { gen, data } = it;
12779 + const cxt = {
12780 + gen,
12781 + keyword: "false schema",
12782 + data,
12783 + schema: false,
12784 + schemaCode: false,
12785 + schemaValue: false,
12786 + params: {},
12787 + it
12788 + };
12789 + (0, errors_1.reportError)(cxt, boolError, void 0, overrideAllErrors);
12790 + }
12791 + }));
12792 +
12793 +//#endregion
12794 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/rules.js
12795 + var require_rules = /* @__PURE__ */ __commonJSMin(((exports) => {
12796 + Object.defineProperty(exports, "__esModule", { value: true });
12797 + exports.getRules = exports.isJSONType = void 0;
12798 + var jsonTypes = /* @__PURE__ */ new Set([
12799 + "string",
12800 + "number",
12801 + "integer",
12802 + "boolean",
12803 + "null",
12804 + "object",
12805 + "array"
12806 + ]);
12807 + function isJSONType(x) {
12808 + return typeof x == "string" && jsonTypes.has(x);
12809 + }
12810 + exports.isJSONType = isJSONType;
12811 + function getRules() {
12812 + const groups = {
12813 + number: {
12814 + type: "number",
12815 + rules: []
12816 + },
12817 + string: {
12818 + type: "string",
12819 + rules: []
12820 + },
12821 + array: {
12822 + type: "array",
12823 + rules: []
12824 + },
12825 + object: {
12826 + type: "object",
12827 + rules: []
12828 + }
12829 + };
12830 + return {
12831 + types: {
12832 + ...groups,
12833 + integer: true,
12834 + boolean: true,
12835 + null: true
12836 + },
12837 + rules: [
12838 + { rules: [] },
12839 + groups.number,
12840 + groups.string,
12841 + groups.array,
12842 + groups.object
12843 + ],
12844 + post: { rules: [] },
12845 + all: {},
12846 + keywords: {}
12847 + };
12848 + }
12849 + exports.getRules = getRules;
12850 + }));
12851 +
12852 +//#endregion
12853 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/validate/applicability.js
12854 + var require_applicability = /* @__PURE__ */ __commonJSMin(((exports) => {
12855 + Object.defineProperty(exports, "__esModule", { value: true });
12856 + exports.shouldUseRule = exports.shouldUseGroup = exports.schemaHasRulesForType = void 0;
12857 + function schemaHasRulesForType({ schema, self }, type) {
12858 + const group = self.RULES.types[type];
12859 + return group && group !== true && shouldUseGroup(schema, group);
12860 + }
12861 + exports.schemaHasRulesForType = schemaHasRulesForType;
12862 + function shouldUseGroup(schema, group) {
12863 + return group.rules.some((rule) => shouldUseRule(schema, rule));
12864 + }
12865 + exports.shouldUseGroup = shouldUseGroup;
12866 + function shouldUseRule(schema, rule) {
12867 + var _a;
12868 + return schema[rule.keyword] !== void 0 || ((_a = rule.definition.implements) === null || _a === void 0 ? void 0 : _a.some((kwd) => schema[kwd] !== void 0));
12869 + }
12870 + exports.shouldUseRule = shouldUseRule;
12871 + }));
12872 +
12873 +//#endregion
12874 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/validate/dataType.js
12875 + var require_dataType = /* @__PURE__ */ __commonJSMin(((exports) => {
12876 + Object.defineProperty(exports, "__esModule", { value: true });
12877 + exports.reportTypeError = exports.checkDataTypes = exports.checkDataType = exports.coerceAndCheckDataType = exports.getJSONTypes = exports.getSchemaTypes = exports.DataType = void 0;
12878 + var rules_1 = require_rules();
12879 + var applicability_1 = require_applicability();
12880 + var errors_1 = require_errors();
12881 + var codegen_1 = require_codegen();
12882 + var util_1 = require_util();
12883 + var DataType;
12884 + (function(DataType) {
12885 + DataType[DataType["Correct"] = 0] = "Correct";
12886 + DataType[DataType["Wrong"] = 1] = "Wrong";
12887 + })(DataType || (exports.DataType = DataType = {}));
12888 + function getSchemaTypes(schema) {
12889 + const types = getJSONTypes(schema.type);
12890 + if (types.includes("null")) {
12891 + if (schema.nullable === false) throw new Error("type: null contradicts nullable: false");
12892 + } else {
12893 + if (!types.length && schema.nullable !== void 0) throw new Error("\"nullable\" cannot be used without \"type\"");
12894 + if (schema.nullable === true) types.push("null");
12895 + }
12896 + return types;
12897 + }
12898 + exports.getSchemaTypes = getSchemaTypes;
12899 + function getJSONTypes(ts) {
12900 + const types = Array.isArray(ts) ? ts : ts ? [ts] : [];
12901 + if (types.every(rules_1.isJSONType)) return types;
12902 + throw new Error("type must be JSONType or JSONType[]: " + types.join(","));
12903 + }
12904 + exports.getJSONTypes = getJSONTypes;
12905 + function coerceAndCheckDataType(it, types) {
12906 + const { gen, data, opts } = it;
12907 + const coerceTo = coerceToTypes(types, opts.coerceTypes);
12908 + const checkTypes = types.length > 0 && !(coerceTo.length === 0 && types.length === 1 && (0, applicability_1.schemaHasRulesForType)(it, types[0]));
12909 + if (checkTypes) {
12910 + const wrongType = checkDataTypes(types, data, opts.strictNumbers, DataType.Wrong);
12911 + gen.if(wrongType, () => {
12912 + if (coerceTo.length) coerceData(it, types, coerceTo);
12913 + else reportTypeError(it);
12914 + });
12915 + }
12916 + return checkTypes;
12917 + }
12918 + exports.coerceAndCheckDataType = coerceAndCheckDataType;
12919 + var COERCIBLE = /* @__PURE__ */ new Set([
12920 + "string",
12921 + "number",
12922 + "integer",
12923 + "boolean",
12924 + "null"
12925 + ]);
12926 + function coerceToTypes(types, coerceTypes) {
12927 + return coerceTypes ? types.filter((t) => COERCIBLE.has(t) || coerceTypes === "array" && t === "array") : [];
12928 + }
12929 + function coerceData(it, types, coerceTo) {
12930 + const { gen, data, opts } = it;
12931 + const dataType = gen.let("dataType", (0, codegen_1._)`typeof ${data}`);
12932 + const coerced = gen.let("coerced", (0, codegen_1._)`undefined`);
12933 + if (opts.coerceTypes === "array") gen.if((0, codegen_1._)`${dataType} == 'object' && Array.isArray(${data}) && ${data}.length == 1`, () => gen.assign(data, (0, codegen_1._)`${data}[0]`).assign(dataType, (0, codegen_1._)`typeof ${data}`).if(checkDataTypes(types, data, opts.strictNumbers), () => gen.assign(coerced, data)));
12934 + gen.if((0, codegen_1._)`${coerced} !== undefined`);
12935 + for (const t of coerceTo) if (COERCIBLE.has(t) || t === "array" && opts.coerceTypes === "array") coerceSpecificType(t);
12936 + gen.else();
12937 + reportTypeError(it);
12938 + gen.endIf();
12939 + gen.if((0, codegen_1._)`${coerced} !== undefined`, () => {
12940 + gen.assign(data, coerced);
12941 + assignParentData(it, coerced);
12942 + });
12943 + function coerceSpecificType(t) {
12944 + switch (t) {
12945 + case "string":
12946 + gen.elseIf((0, codegen_1._)`${dataType} == "number" || ${dataType} == "boolean"`).assign(coerced, (0, codegen_1._)`"" + ${data}`).elseIf((0, codegen_1._)`${data} === null`).assign(coerced, (0, codegen_1._)`""`);
12947 + return;
12948 + case "number":
12949 + gen.elseIf((0, codegen_1._)`${dataType} == "boolean" || ${data} === null
12950 + || (${dataType} == "string" && ${data} && ${data} == +${data})`).assign(coerced, (0, codegen_1._)`+${data}`);
12951 + return;
12952 + case "integer":
12953 + gen.elseIf((0, codegen_1._)`${dataType} === "boolean" || ${data} === null
12954 + || (${dataType} === "string" && ${data} && ${data} == +${data} && !(${data} % 1))`).assign(coerced, (0, codegen_1._)`+${data}`);
12955 + return;
12956 + case "boolean":
12957 + gen.elseIf((0, codegen_1._)`${data} === "false" || ${data} === 0 || ${data} === null`).assign(coerced, false).elseIf((0, codegen_1._)`${data} === "true" || ${data} === 1`).assign(coerced, true);
12958 + return;
12959 + case "null":
12960 + gen.elseIf((0, codegen_1._)`${data} === "" || ${data} === 0 || ${data} === false`);
12961 + gen.assign(coerced, null);
12962 + return;
12963 + case "array": gen.elseIf((0, codegen_1._)`${dataType} === "string" || ${dataType} === "number"
12964 + || ${dataType} === "boolean" || ${data} === null`).assign(coerced, (0, codegen_1._)`[${data}]`);
12965 + }
12966 + }
12967 + }
12968 + function assignParentData({ gen, parentData, parentDataProperty }, expr) {
12969 + gen.if((0, codegen_1._)`${parentData} !== undefined`, () => gen.assign((0, codegen_1._)`${parentData}[${parentDataProperty}]`, expr));
12970 + }
12971 + function checkDataType(dataType, data, strictNums, correct = DataType.Correct) {
12972 + const EQ = correct === DataType.Correct ? codegen_1.operators.EQ : codegen_1.operators.NEQ;
12973 + let cond;
12974 + switch (dataType) {
12975 + case "null": return (0, codegen_1._)`${data} ${EQ} null`;
12976 + case "array":
12977 + cond = (0, codegen_1._)`Array.isArray(${data})`;
12978 + break;
12979 + case "object":
12980 + cond = (0, codegen_1._)`${data} && typeof ${data} == "object" && !Array.isArray(${data})`;
12981 + break;
12982 + case "integer":
12983 + cond = numCond((0, codegen_1._)`!(${data} % 1) && !isNaN(${data})`);
12984 + break;
12985 + case "number":
12986 + cond = numCond();
12987 + break;
12988 + default: return (0, codegen_1._)`typeof ${data} ${EQ} ${dataType}`;
12989 + }
12990 + return correct === DataType.Correct ? cond : (0, codegen_1.not)(cond);
12991 + function numCond(_cond = codegen_1.nil) {
12992 + return (0, codegen_1.and)((0, codegen_1._)`typeof ${data} == "number"`, _cond, strictNums ? (0, codegen_1._)`isFinite(${data})` : codegen_1.nil);
12993 + }
12994 + }
12995 + exports.checkDataType = checkDataType;
12996 + function checkDataTypes(dataTypes, data, strictNums, correct) {
12997 + if (dataTypes.length === 1) return checkDataType(dataTypes[0], data, strictNums, correct);
12998 + let cond;
12999 + const types = (0, util_1.toHash)(dataTypes);
13000 + if (types.array && types.object) {
13001 + const notObj = (0, codegen_1._)`typeof ${data} != "object"`;
13002 + cond = types.null ? notObj : (0, codegen_1._)`!${data} || ${notObj}`;
13003 + delete types.null;
13004 + delete types.array;
13005 + delete types.object;
13006 + } else cond = codegen_1.nil;
13007 + if (types.number) delete types.integer;
13008 + for (const t in types) cond = (0, codegen_1.and)(cond, checkDataType(t, data, strictNums, correct));
13009 + return cond;
13010 + }
13011 + exports.checkDataTypes = checkDataTypes;
13012 + var typeError = {
13013 + message: ({ schema }) => `must be ${schema}`,
13014 + params: ({ schema, schemaValue }) => typeof schema == "string" ? (0, codegen_1._)`{type: ${schema}}` : (0, codegen_1._)`{type: ${schemaValue}}`
13015 + };
13016 + function reportTypeError(it) {
13017 + const cxt = getTypeErrorContext(it);
13018 + (0, errors_1.reportError)(cxt, typeError);
13019 + }
13020 + exports.reportTypeError = reportTypeError;
13021 + function getTypeErrorContext(it) {
13022 + const { gen, data, schema } = it;
13023 + const schemaCode = (0, util_1.schemaRefOrVal)(it, schema, "type");
13024 + return {
13025 + gen,
13026 + keyword: "type",
13027 + data,
13028 + schema: schema.type,
13029 + schemaCode,
13030 + schemaValue: schemaCode,
13031 + parentSchema: schema,
13032 + params: {},
13033 + it
13034 + };
13035 + }
13036 + }));
13037 +
13038 +//#endregion
13039 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/validate/defaults.js
13040 + var require_defaults = /* @__PURE__ */ __commonJSMin(((exports) => {
13041 + Object.defineProperty(exports, "__esModule", { value: true });
13042 + exports.assignDefaults = void 0;
13043 + var codegen_1 = require_codegen();
13044 + var util_1 = require_util();
13045 + function assignDefaults(it, ty) {
13046 + const { properties, items } = it.schema;
13047 + if (ty === "object" && properties) for (const key in properties) assignDefault(it, key, properties[key].default);
13048 + else if (ty === "array" && Array.isArray(items)) items.forEach((sch, i) => assignDefault(it, i, sch.default));
13049 + }
13050 + exports.assignDefaults = assignDefaults;
13051 + function assignDefault(it, prop, defaultValue) {
13052 + const { gen, compositeRule, data, opts } = it;
13053 + if (defaultValue === void 0) return;
13054 + const childData = (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(prop)}`;
13055 + if (compositeRule) {
13056 + (0, util_1.checkStrictMode)(it, `default is ignored for: ${childData}`);
13057 + return;
13058 + }
13059 + let condition = (0, codegen_1._)`${childData} === undefined`;
13060 + if (opts.useDefaults === "empty") condition = (0, codegen_1._)`${condition} || ${childData} === null || ${childData} === ""`;
13061 + gen.if(condition, (0, codegen_1._)`${childData} = ${(0, codegen_1.stringify)(defaultValue)}`);
13062 + }
13063 + }));
13064 +
13065 +//#endregion
13066 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/code.js
13067 + var require_code = /* @__PURE__ */ __commonJSMin(((exports) => {
13068 + Object.defineProperty(exports, "__esModule", { value: true });
13069 + exports.validateUnion = exports.validateArray = exports.usePattern = exports.callValidateCode = exports.schemaProperties = exports.allSchemaProperties = exports.noPropertyInData = exports.propertyInData = exports.isOwnProperty = exports.hasPropFunc = exports.reportMissingProp = exports.checkMissingProp = exports.checkReportMissingProp = void 0;
13070 + var codegen_1 = require_codegen();
13071 + var util_1 = require_util();
13072 + var names_1 = require_names();
13073 + var util_2 = require_util();
13074 + function checkReportMissingProp(cxt, prop) {
13075 + const { gen, data, it } = cxt;
13076 + gen.if(noPropertyInData(gen, data, prop, it.opts.ownProperties), () => {
13077 + cxt.setParams({ missingProperty: (0, codegen_1._)`${prop}` }, true);
13078 + cxt.error();
13079 + });
13080 + }
13081 + exports.checkReportMissingProp = checkReportMissingProp;
13082 + function checkMissingProp({ gen, data, it: { opts } }, properties, missing) {
13083 + return (0, codegen_1.or)(...properties.map((prop) => (0, codegen_1.and)(noPropertyInData(gen, data, prop, opts.ownProperties), (0, codegen_1._)`${missing} = ${prop}`)));
13084 + }
13085 + exports.checkMissingProp = checkMissingProp;
13086 + function reportMissingProp(cxt, missing) {
13087 + cxt.setParams({ missingProperty: missing }, true);
13088 + cxt.error();
13089 + }
13090 + exports.reportMissingProp = reportMissingProp;
13091 + function hasPropFunc(gen) {
13092 + return gen.scopeValue("func", {
13093 + ref: Object.prototype.hasOwnProperty,
13094 + code: (0, codegen_1._)`Object.prototype.hasOwnProperty`
13095 + });
13096 + }
13097 + exports.hasPropFunc = hasPropFunc;
13098 + function isOwnProperty(gen, data, property) {
13099 + return (0, codegen_1._)`${hasPropFunc(gen)}.call(${data}, ${property})`;
13100 + }
13101 + exports.isOwnProperty = isOwnProperty;
13102 + function propertyInData(gen, data, property, ownProperties) {
13103 + const cond = (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(property)} !== undefined`;
13104 + return ownProperties ? (0, codegen_1._)`${cond} && ${isOwnProperty(gen, data, property)}` : cond;
13105 + }
13106 + exports.propertyInData = propertyInData;
13107 + function noPropertyInData(gen, data, property, ownProperties) {
13108 + const cond = (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(property)} === undefined`;
13109 + return ownProperties ? (0, codegen_1.or)(cond, (0, codegen_1.not)(isOwnProperty(gen, data, property))) : cond;
13110 + }
13111 + exports.noPropertyInData = noPropertyInData;
13112 + function allSchemaProperties(schemaMap) {
13113 + return schemaMap ? Object.keys(schemaMap).filter((p) => p !== "__proto__") : [];
13114 + }
13115 + exports.allSchemaProperties = allSchemaProperties;
13116 + function schemaProperties(it, schemaMap) {
13117 + return allSchemaProperties(schemaMap).filter((p) => !(0, util_1.alwaysValidSchema)(it, schemaMap[p]));
13118 + }
13119 + exports.schemaProperties = schemaProperties;
13120 + function callValidateCode({ schemaCode, data, it: { gen, topSchemaRef, schemaPath, errorPath }, it }, func, context, passSchema) {
13121 + const dataAndSchema = passSchema ? (0, codegen_1._)`${schemaCode}, ${data}, ${topSchemaRef}${schemaPath}` : data;
13122 + const valCxt = [
13123 + [names_1.default.instancePath, (0, codegen_1.strConcat)(names_1.default.instancePath, errorPath)],
13124 + [names_1.default.parentData, it.parentData],
13125 + [names_1.default.parentDataProperty, it.parentDataProperty],
13126 + [names_1.default.rootData, names_1.default.rootData]
13127 + ];
13128 + if (it.opts.dynamicRef) valCxt.push([names_1.default.dynamicAnchors, names_1.default.dynamicAnchors]);
13129 + const args = (0, codegen_1._)`${dataAndSchema}, ${gen.object(...valCxt)}`;
13130 + return context !== codegen_1.nil ? (0, codegen_1._)`${func}.call(${context}, ${args})` : (0, codegen_1._)`${func}(${args})`;
13131 + }
13132 + exports.callValidateCode = callValidateCode;
13133 + var newRegExp = (0, codegen_1._)`new RegExp`;
13134 + function usePattern({ gen, it: { opts } }, pattern) {
13135 + const u = opts.unicodeRegExp ? "u" : "";
13136 + const { regExp } = opts.code;
13137 + const rx = regExp(pattern, u);
13138 + return gen.scopeValue("pattern", {
13139 + key: rx.toString(),
13140 + ref: rx,
13141 + code: (0, codegen_1._)`${regExp.code === "new RegExp" ? newRegExp : (0, util_2.useFunc)(gen, regExp)}(${pattern}, ${u})`
13142 + });
13143 + }
13144 + exports.usePattern = usePattern;
13145 + function validateArray(cxt) {
13146 + const { gen, data, keyword, it } = cxt;
13147 + const valid = gen.name("valid");
13148 + if (it.allErrors) {
13149 + const validArr = gen.let("valid", true);
13150 + validateItems(() => gen.assign(validArr, false));
13151 + return validArr;
13152 + }
13153 + gen.var(valid, true);
13154 + validateItems(() => gen.break());
13155 + return valid;
13156 + function validateItems(notValid) {
13157 + const len = gen.const("len", (0, codegen_1._)`${data}.length`);
13158 + gen.forRange("i", 0, len, (i) => {
13159 + cxt.subschema({
13160 + keyword,
13161 + dataProp: i,
13162 + dataPropType: util_1.Type.Num
13163 + }, valid);
13164 + gen.if((0, codegen_1.not)(valid), notValid);
13165 + });
13166 + }
13167 + }
13168 + exports.validateArray = validateArray;
13169 + function validateUnion(cxt) {
13170 + const { gen, schema, keyword, it } = cxt;
13171 + /* istanbul ignore if */
13172 + if (!Array.isArray(schema)) throw new Error("ajv implementation error");
13173 + if (schema.some((sch) => (0, util_1.alwaysValidSchema)(it, sch)) && !it.opts.unevaluated) return;
13174 + const valid = gen.let("valid", false);
13175 + const schValid = gen.name("_valid");
13176 + gen.block(() => schema.forEach((_sch, i) => {
13177 + const schCxt = cxt.subschema({
13178 + keyword,
13179 + schemaProp: i,
13180 + compositeRule: true
13181 + }, schValid);
13182 + gen.assign(valid, (0, codegen_1._)`${valid} || ${schValid}`);
13183 + if (!cxt.mergeValidEvaluated(schCxt, schValid)) gen.if((0, codegen_1.not)(valid));
13184 + }));
13185 + cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
13186 + }
13187 + exports.validateUnion = validateUnion;
13188 + }));
13189 +
13190 +//#endregion
13191 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/validate/keyword.js
13192 + var require_keyword = /* @__PURE__ */ __commonJSMin(((exports) => {
13193 + Object.defineProperty(exports, "__esModule", { value: true });
13194 + exports.validateKeywordUsage = exports.validSchemaType = exports.funcKeywordCode = exports.macroKeywordCode = void 0;
13195 + var codegen_1 = require_codegen();
13196 + var names_1 = require_names();
13197 + var code_1 = require_code();
13198 + var errors_1 = require_errors();
13199 + function macroKeywordCode(cxt, def) {
13200 + const { gen, keyword, schema, parentSchema, it } = cxt;
13201 + const macroSchema = def.macro.call(it.self, schema, parentSchema, it);
13202 + const schemaRef = useKeyword(gen, keyword, macroSchema);
13203 + if (it.opts.validateSchema !== false) it.self.validateSchema(macroSchema, true);
13204 + const valid = gen.name("valid");
13205 + cxt.subschema({
13206 + schema: macroSchema,
13207 + schemaPath: codegen_1.nil,
13208 + errSchemaPath: `${it.errSchemaPath}/${keyword}`,
13209 + topSchemaRef: schemaRef,
13210 + compositeRule: true
13211 + }, valid);
13212 + cxt.pass(valid, () => cxt.error(true));
13213 + }
13214 + exports.macroKeywordCode = macroKeywordCode;
13215 + function funcKeywordCode(cxt, def) {
13216 + var _a;
13217 + const { gen, keyword, schema, parentSchema, $data, it } = cxt;
13218 + checkAsyncKeyword(it, def);
13219 + const validateRef = useKeyword(gen, keyword, !$data && def.compile ? def.compile.call(it.self, schema, parentSchema, it) : def.validate);
13220 + const valid = gen.let("valid");
13221 + cxt.block$data(valid, validateKeyword);
13222 + cxt.ok((_a = def.valid) !== null && _a !== void 0 ? _a : valid);
13223 + function validateKeyword() {
13224 + if (def.errors === false) {
13225 + assignValid();
13226 + if (def.modifying) modifyData(cxt);
13227 + reportErrs(() => cxt.error());
13228 + } else {
13229 + const ruleErrs = def.async ? validateAsync() : validateSync();
13230 + if (def.modifying) modifyData(cxt);
13231 + reportErrs(() => addErrs(cxt, ruleErrs));
13232 + }
13233 + }
13234 + function validateAsync() {
13235 + const ruleErrs = gen.let("ruleErrs", null);
13236 + gen.try(() => assignValid((0, codegen_1._)`await `), (e) => gen.assign(valid, false).if((0, codegen_1._)`${e} instanceof ${it.ValidationError}`, () => gen.assign(ruleErrs, (0, codegen_1._)`${e}.errors`), () => gen.throw(e)));
13237 + return ruleErrs;
13238 + }
13239 + function validateSync() {
13240 + const validateErrs = (0, codegen_1._)`${validateRef}.errors`;
13241 + gen.assign(validateErrs, null);
13242 + assignValid(codegen_1.nil);
13243 + return validateErrs;
13244 + }
13245 + function assignValid(_await = def.async ? (0, codegen_1._)`await ` : codegen_1.nil) {
13246 + const passCxt = it.opts.passContext ? names_1.default.this : names_1.default.self;
13247 + const passSchema = !("compile" in def && !$data || def.schema === false);
13248 + gen.assign(valid, (0, codegen_1._)`${_await}${(0, code_1.callValidateCode)(cxt, validateRef, passCxt, passSchema)}`, def.modifying);
13249 + }
13250 + function reportErrs(errors) {
13251 + var _a;
13252 + gen.if((0, codegen_1.not)((_a = def.valid) !== null && _a !== void 0 ? _a : valid), errors);
13253 + }
13254 + }
13255 + exports.funcKeywordCode = funcKeywordCode;
13256 + function modifyData(cxt) {
13257 + const { gen, data, it } = cxt;
13258 + gen.if(it.parentData, () => gen.assign(data, (0, codegen_1._)`${it.parentData}[${it.parentDataProperty}]`));
13259 + }
13260 + function addErrs(cxt, errs) {
13261 + const { gen } = cxt;
13262 + gen.if((0, codegen_1._)`Array.isArray(${errs})`, () => {
13263 + gen.assign(names_1.default.vErrors, (0, codegen_1._)`${names_1.default.vErrors} === null ? ${errs} : ${names_1.default.vErrors}.concat(${errs})`).assign(names_1.default.errors, (0, codegen_1._)`${names_1.default.vErrors}.length`);
13264 + (0, errors_1.extendErrors)(cxt);
13265 + }, () => cxt.error());
13266 + }
13267 + function checkAsyncKeyword({ schemaEnv }, def) {
13268 + if (def.async && !schemaEnv.$async) throw new Error("async keyword in sync schema");
13269 + }
13270 + function useKeyword(gen, keyword, result) {
13271 + if (result === void 0) throw new Error(`keyword "${keyword}" failed to compile`);
13272 + return gen.scopeValue("keyword", typeof result == "function" ? { ref: result } : {
13273 + ref: result,
13274 + code: (0, codegen_1.stringify)(result)
13275 + });
13276 + }
13277 + function validSchemaType(schema, schemaType, allowUndefined = false) {
13278 + return !schemaType.length || schemaType.some((st) => st === "array" ? Array.isArray(schema) : st === "object" ? schema && typeof schema == "object" && !Array.isArray(schema) : typeof schema == st || allowUndefined && typeof schema == "undefined");
13279 + }
13280 + exports.validSchemaType = validSchemaType;
13281 + function validateKeywordUsage({ schema, opts, self, errSchemaPath }, def, keyword) {
13282 + /* istanbul ignore if */
13283 + if (Array.isArray(def.keyword) ? !def.keyword.includes(keyword) : def.keyword !== keyword) throw new Error("ajv implementation error");
13284 + const deps = def.dependencies;
13285 + if (deps === null || deps === void 0 ? void 0 : deps.some((kwd) => !Object.prototype.hasOwnProperty.call(schema, kwd))) throw new Error(`parent schema must have dependencies of ${keyword}: ${deps.join(",")}`);
13286 + if (def.validateSchema) {
13287 + if (!def.validateSchema(schema[keyword])) {
13288 + const msg = `keyword "${keyword}" value is invalid at path "${errSchemaPath}": ` + self.errorsText(def.validateSchema.errors);
13289 + if (opts.validateSchema === "log") self.logger.error(msg);
13290 + else throw new Error(msg);
13291 + }
13292 + }
13293 + }
13294 + exports.validateKeywordUsage = validateKeywordUsage;
13295 + }));
13296 +
13297 +//#endregion
13298 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/validate/subschema.js
13299 + var require_subschema = /* @__PURE__ */ __commonJSMin(((exports) => {
13300 + Object.defineProperty(exports, "__esModule", { value: true });
13301 + exports.extendSubschemaMode = exports.extendSubschemaData = exports.getSubschema = void 0;
13302 + var codegen_1 = require_codegen();
13303 + var util_1 = require_util();
13304 + function getSubschema(it, { keyword, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
13305 + if (keyword !== void 0 && schema !== void 0) throw new Error("both \"keyword\" and \"schema\" passed, only one allowed");
13306 + if (keyword !== void 0) {
13307 + const sch = it.schema[keyword];
13308 + return schemaProp === void 0 ? {
13309 + schema: sch,
13310 + schemaPath: (0, codegen_1._)`${it.schemaPath}${(0, codegen_1.getProperty)(keyword)}`,
13311 + errSchemaPath: `${it.errSchemaPath}/${keyword}`
13312 + } : {
13313 + schema: sch[schemaProp],
13314 + schemaPath: (0, codegen_1._)`${it.schemaPath}${(0, codegen_1.getProperty)(keyword)}${(0, codegen_1.getProperty)(schemaProp)}`,
13315 + errSchemaPath: `${it.errSchemaPath}/${keyword}/${(0, util_1.escapeFragment)(schemaProp)}`
13316 + };
13317 + }
13318 + if (schema !== void 0) {
13319 + if (schemaPath === void 0 || errSchemaPath === void 0 || topSchemaRef === void 0) throw new Error("\"schemaPath\", \"errSchemaPath\" and \"topSchemaRef\" are required with \"schema\"");
13320 + return {
13321 + schema,
13322 + schemaPath,
13323 + topSchemaRef,
13324 + errSchemaPath
13325 + };
13326 + }
13327 + throw new Error("either \"keyword\" or \"schema\" must be passed");
13328 + }
13329 + exports.getSubschema = getSubschema;
13330 + function extendSubschemaData(subschema, it, { dataProp, dataPropType: dpType, data, dataTypes, propertyName }) {
13331 + if (data !== void 0 && dataProp !== void 0) throw new Error("both \"data\" and \"dataProp\" passed, only one allowed");
13332 + const { gen } = it;
13333 + if (dataProp !== void 0) {
13334 + const { errorPath, dataPathArr, opts } = it;
13335 + dataContextProps(gen.let("data", (0, codegen_1._)`${it.data}${(0, codegen_1.getProperty)(dataProp)}`, true));
13336 + subschema.errorPath = (0, codegen_1.str)`${errorPath}${(0, util_1.getErrorPath)(dataProp, dpType, opts.jsPropertySyntax)}`;
13337 + subschema.parentDataProperty = (0, codegen_1._)`${dataProp}`;
13338 + subschema.dataPathArr = [...dataPathArr, subschema.parentDataProperty];
13339 + }
13340 + if (data !== void 0) {
13341 + dataContextProps(data instanceof codegen_1.Name ? data : gen.let("data", data, true));
13342 + if (propertyName !== void 0) subschema.propertyName = propertyName;
13343 + }
13344 + if (dataTypes) subschema.dataTypes = dataTypes;
13345 + function dataContextProps(_nextData) {
13346 + subschema.data = _nextData;
13347 + subschema.dataLevel = it.dataLevel + 1;
13348 + subschema.dataTypes = [];
13349 + it.definedProperties = /* @__PURE__ */ new Set();
13350 + subschema.parentData = it.data;
13351 + subschema.dataNames = [...it.dataNames, _nextData];
13352 + }
13353 + }
13354 + exports.extendSubschemaData = extendSubschemaData;
13355 + function extendSubschemaMode(subschema, { jtdDiscriminator, jtdMetadata, compositeRule, createErrors, allErrors }) {
13356 + if (compositeRule !== void 0) subschema.compositeRule = compositeRule;
13357 + if (createErrors !== void 0) subschema.createErrors = createErrors;
13358 + if (allErrors !== void 0) subschema.allErrors = allErrors;
13359 + subschema.jtdDiscriminator = jtdDiscriminator;
13360 + subschema.jtdMetadata = jtdMetadata;
13361 + }
13362 + exports.extendSubschemaMode = extendSubschemaMode;
13363 + }));
13364 +
13365 +//#endregion
13366 +//#region node_modules/fast-deep-equal/index.js
13367 + var require_fast_deep_equal = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13368 + module.exports = function equal(a, b) {
13369 + if (a === b) return true;
13370 + if (a && b && typeof a == "object" && typeof b == "object") {
13371 + if (a.constructor !== b.constructor) return false;
13372 + var length;
13373 + var i;
13374 + var keys;
13375 + if (Array.isArray(a)) {
13376 + length = a.length;
13377 + if (length != b.length) return false;
13378 + for (i = length; i-- !== 0;) if (!equal(a[i], b[i])) return false;
13379 + return true;
13380 + }
13381 + if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
13382 + if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
13383 + if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
13384 + keys = Object.keys(a);
13385 + length = keys.length;
13386 + if (length !== Object.keys(b).length) return false;
13387 + for (i = length; i-- !== 0;) if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
13388 + for (i = length; i-- !== 0;) {
13389 + var key = keys[i];
13390 + if (!equal(a[key], b[key])) return false;
13391 + }
13392 + return true;
13393 + }
13394 + return a !== a && b !== b;
13395 + };
13396 + }));
13397 +
13398 +//#endregion
13399 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/json-schema-traverse/index.js
13400 + var require_json_schema_traverse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
13401 + var traverse = module.exports = function(schema, opts, cb) {
13402 + if (typeof opts == "function") {
13403 + cb = opts;
13404 + opts = {};
13405 + }
13406 + cb = opts.cb || cb;
13407 + var pre = typeof cb == "function" ? cb : cb.pre || function() {};
13408 + var post = cb.post || function() {};
13409 + _traverse(opts, pre, post, schema, "", schema);
13410 + };
13411 + traverse.keywords = {
13412 + additionalItems: true,
13413 + items: true,
13414 + contains: true,
13415 + additionalProperties: true,
13416 + propertyNames: true,
13417 + not: true,
13418 + if: true,
13419 + then: true,
13420 + else: true
13421 + };
13422 + traverse.arrayKeywords = {
13423 + items: true,
13424 + allOf: true,
13425 + anyOf: true,
13426 + oneOf: true
13427 + };
13428 + traverse.propsKeywords = {
13429 + $defs: true,
13430 + definitions: true,
13431 + properties: true,
13432 + patternProperties: true,
13433 + dependencies: true
13434 + };
13435 + traverse.skipKeywords = {
13436 + default: true,
13437 + enum: true,
13438 + const: true,
13439 + required: true,
13440 + maximum: true,
13441 + minimum: true,
13442 + exclusiveMaximum: true,
13443 + exclusiveMinimum: true,
13444 + multipleOf: true,
13445 + maxLength: true,
13446 + minLength: true,
13447 + pattern: true,
13448 + format: true,
13449 + maxItems: true,
13450 + minItems: true,
13451 + uniqueItems: true,
13452 + maxProperties: true,
13453 + minProperties: true
13454 + };
13455 + function _traverse(opts, pre, post, schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex) {
13456 + if (schema && typeof schema == "object" && !Array.isArray(schema)) {
13457 + pre(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
13458 + for (var key in schema) {
13459 + var sch = schema[key];
13460 + if (Array.isArray(sch)) {
13461 + if (key in traverse.arrayKeywords) for (var i = 0; i < sch.length; i++) _traverse(opts, pre, post, sch[i], jsonPtr + "/" + key + "/" + i, rootSchema, jsonPtr, key, schema, i);
13462 + } else if (key in traverse.propsKeywords) {
13463 + if (sch && typeof sch == "object") for (var prop in sch) _traverse(opts, pre, post, sch[prop], jsonPtr + "/" + key + "/" + escapeJsonPtr(prop), rootSchema, jsonPtr, key, schema, prop);
13464 + } else if (key in traverse.keywords || opts.allKeys && !(key in traverse.skipKeywords)) _traverse(opts, pre, post, sch, jsonPtr + "/" + key, rootSchema, jsonPtr, key, schema);
13465 + }
13466 + post(schema, jsonPtr, rootSchema, parentJsonPtr, parentKeyword, parentSchema, keyIndex);
13467 + }
13468 + }
13469 + function escapeJsonPtr(str) {
13470 + return str.replace(/~/g, "~0").replace(/\//g, "~1");
13471 + }
13472 + }));
13473 +
13474 +//#endregion
13475 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/resolve.js
13476 + var require_resolve = /* @__PURE__ */ __commonJSMin(((exports) => {
13477 + Object.defineProperty(exports, "__esModule", { value: true });
13478 + exports.getSchemaRefs = exports.resolveUrl = exports.normalizeId = exports._getFullPath = exports.getFullPath = exports.inlineRef = void 0;
13479 + var util_1 = require_util();
13480 + var equal = require_fast_deep_equal();
13481 + var traverse = require_json_schema_traverse();
13482 + var SIMPLE_INLINED = /* @__PURE__ */ new Set([
13483 + "type",
13484 + "format",
13485 + "pattern",
13486 + "maxLength",
13487 + "minLength",
13488 + "maxProperties",
13489 + "minProperties",
13490 + "maxItems",
13491 + "minItems",
13492 + "maximum",
13493 + "minimum",
13494 + "uniqueItems",
13495 + "multipleOf",
13496 + "required",
13497 + "enum",
13498 + "const"
13499 + ]);
13500 + function inlineRef(schema, limit = true) {
13501 + if (typeof schema == "boolean") return true;
13502 + if (limit === true) return !hasRef(schema);
13503 + if (!limit) return false;
13504 + return countKeys(schema) <= limit;
13505 + }
13506 + exports.inlineRef = inlineRef;
13507 + var REF_KEYWORDS = /* @__PURE__ */ new Set([
13508 + "$ref",
13509 + "$recursiveRef",
13510 + "$recursiveAnchor",
13511 + "$dynamicRef",
13512 + "$dynamicAnchor"
13513 + ]);
13514 + function hasRef(schema) {
13515 + for (const key in schema) {
13516 + if (REF_KEYWORDS.has(key)) return true;
13517 + const sch = schema[key];
13518 + if (Array.isArray(sch) && sch.some(hasRef)) return true;
13519 + if (typeof sch == "object" && hasRef(sch)) return true;
13520 + }
13521 + return false;
13522 + }
13523 + function countKeys(schema) {
13524 + let count = 0;
13525 + for (const key in schema) {
13526 + if (key === "$ref") return Infinity;
13527 + count++;
13528 + if (SIMPLE_INLINED.has(key)) continue;
13529 + if (typeof schema[key] == "object") (0, util_1.eachItem)(schema[key], (sch) => count += countKeys(sch));
13530 + if (count === Infinity) return Infinity;
13531 + }
13532 + return count;
13533 + }
13534 + function getFullPath(resolver, id = "", normalize) {
13535 + if (normalize !== false) id = normalizeId(id);
13536 + return _getFullPath(resolver, resolver.parse(id));
13537 + }
13538 + exports.getFullPath = getFullPath;
13539 + function _getFullPath(resolver, p) {
13540 + return resolver.serialize(p).split("#")[0] + "#";
13541 + }
13542 + exports._getFullPath = _getFullPath;
13543 + var TRAILING_SLASH_HASH = /#\/?$/;
13544 + function normalizeId(id) {
13545 + return id ? id.replace(TRAILING_SLASH_HASH, "") : "";
13546 + }
13547 + exports.normalizeId = normalizeId;
13548 + function resolveUrl(resolver, baseId, id) {
13549 + id = normalizeId(id);
13550 + return resolver.resolve(baseId, id);
13551 + }
13552 + exports.resolveUrl = resolveUrl;
13553 + var ANCHOR = /^[a-z_][-a-z0-9._]*$/i;
13554 + function getSchemaRefs(schema, baseId) {
13555 + if (typeof schema == "boolean") return {};
13556 + const { schemaId, uriResolver } = this.opts;
13557 + const schId = normalizeId(schema[schemaId] || baseId);
13558 + const baseIds = { "": schId };
13559 + const pathPrefix = getFullPath(uriResolver, schId, false);
13560 + const localRefs = {};
13561 + const schemaRefs = /* @__PURE__ */ new Set();
13562 + traverse(schema, { allKeys: true }, (sch, jsonPtr, _, parentJsonPtr) => {
13563 + if (parentJsonPtr === void 0) return;
13564 + const fullPath = pathPrefix + jsonPtr;
13565 + let innerBaseId = baseIds[parentJsonPtr];
13566 + if (typeof sch[schemaId] == "string") innerBaseId = addRef.call(this, sch[schemaId]);
13567 + addAnchor.call(this, sch.$anchor);
13568 + addAnchor.call(this, sch.$dynamicAnchor);
13569 + baseIds[jsonPtr] = innerBaseId;
13570 + function addRef(ref) {
13571 + const _resolve = this.opts.uriResolver.resolve;
13572 + ref = normalizeId(innerBaseId ? _resolve(innerBaseId, ref) : ref);
13573 + if (schemaRefs.has(ref)) throw ambiguos(ref);
13574 + schemaRefs.add(ref);
13575 + let schOrRef = this.refs[ref];
13576 + if (typeof schOrRef == "string") schOrRef = this.refs[schOrRef];
13577 + if (typeof schOrRef == "object") checkAmbiguosRef(sch, schOrRef.schema, ref);
13578 + else if (ref !== normalizeId(fullPath)) if (ref[0] === "#") {
13579 + checkAmbiguosRef(sch, localRefs[ref], ref);
13580 + localRefs[ref] = sch;
13581 + } else this.refs[ref] = fullPath;
13582 + return ref;
13583 + }
13584 + function addAnchor(anchor) {
13585 + if (typeof anchor == "string") {
13586 + if (!ANCHOR.test(anchor)) throw new Error(`invalid anchor "${anchor}"`);
13587 + addRef.call(this, `#${anchor}`);
13588 + }
13589 + }
13590 + });
13591 + return localRefs;
13592 + function checkAmbiguosRef(sch1, sch2, ref) {
13593 + if (sch2 !== void 0 && !equal(sch1, sch2)) throw ambiguos(ref);
13594 + }
13595 + function ambiguos(ref) {
13596 + return /* @__PURE__ */ new Error(`reference "${ref}" resolves to more than one schema`);
13597 + }
13598 + }
13599 + exports.getSchemaRefs = getSchemaRefs;
13600 + }));
13601 +
13602 +//#endregion
13603 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/validate/index.js
13604 + var require_validate = /* @__PURE__ */ __commonJSMin(((exports) => {
13605 + Object.defineProperty(exports, "__esModule", { value: true });
13606 + exports.getData = exports.KeywordCxt = exports.validateFunctionCode = void 0;
13607 + var boolSchema_1 = require_boolSchema();
13608 + var dataType_1 = require_dataType();
13609 + var applicability_1 = require_applicability();
13610 + var dataType_2 = require_dataType();
13611 + var defaults_1 = require_defaults();
13612 + var keyword_1 = require_keyword();
13613 + var subschema_1 = require_subschema();
13614 + var codegen_1 = require_codegen();
13615 + var names_1 = require_names();
13616 + var resolve_1 = require_resolve();
13617 + var util_1 = require_util();
13618 + var errors_1 = require_errors();
13619 + function validateFunctionCode(it) {
13620 + if (isSchemaObj(it)) {
13621 + checkKeywords(it);
13622 + if (schemaCxtHasRules(it)) {
13623 + topSchemaObjCode(it);
13624 + return;
13625 + }
13626 + }
13627 + validateFunction(it, () => (0, boolSchema_1.topBoolOrEmptySchema)(it));
13628 + }
13629 + exports.validateFunctionCode = validateFunctionCode;
13630 + function validateFunction({ gen, validateName, schema, schemaEnv, opts }, body) {
13631 + if (opts.code.es5) gen.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${names_1.default.valCxt}`, schemaEnv.$async, () => {
13632 + gen.code((0, codegen_1._)`"use strict"; ${funcSourceUrl(schema, opts)}`);
13633 + destructureValCxtES5(gen, opts);
13634 + gen.code(body);
13635 + });
13636 + else gen.func(validateName, (0, codegen_1._)`${names_1.default.data}, ${destructureValCxt(opts)}`, schemaEnv.$async, () => gen.code(funcSourceUrl(schema, opts)).code(body));
13637 + }
13638 + function destructureValCxt(opts) {
13639 + return (0, codegen_1._)`{${names_1.default.instancePath}="", ${names_1.default.parentData}, ${names_1.default.parentDataProperty}, ${names_1.default.rootData}=${names_1.default.data}${opts.dynamicRef ? (0, codegen_1._)`, ${names_1.default.dynamicAnchors}={}` : codegen_1.nil}}={}`;
13640 + }
13641 + function destructureValCxtES5(gen, opts) {
13642 + gen.if(names_1.default.valCxt, () => {
13643 + gen.var(names_1.default.instancePath, (0, codegen_1._)`${names_1.default.valCxt}.${names_1.default.instancePath}`);
13644 + gen.var(names_1.default.parentData, (0, codegen_1._)`${names_1.default.valCxt}.${names_1.default.parentData}`);
13645 + gen.var(names_1.default.parentDataProperty, (0, codegen_1._)`${names_1.default.valCxt}.${names_1.default.parentDataProperty}`);
13646 + gen.var(names_1.default.rootData, (0, codegen_1._)`${names_1.default.valCxt}.${names_1.default.rootData}`);
13647 + if (opts.dynamicRef) gen.var(names_1.default.dynamicAnchors, (0, codegen_1._)`${names_1.default.valCxt}.${names_1.default.dynamicAnchors}`);
13648 + }, () => {
13649 + gen.var(names_1.default.instancePath, (0, codegen_1._)`""`);
13650 + gen.var(names_1.default.parentData, (0, codegen_1._)`undefined`);
13651 + gen.var(names_1.default.parentDataProperty, (0, codegen_1._)`undefined`);
13652 + gen.var(names_1.default.rootData, names_1.default.data);
13653 + if (opts.dynamicRef) gen.var(names_1.default.dynamicAnchors, (0, codegen_1._)`{}`);
13654 + });
13655 + }
13656 + function topSchemaObjCode(it) {
13657 + const { schema, opts, gen } = it;
13658 + validateFunction(it, () => {
13659 + if (opts.$comment && schema.$comment) commentKeyword(it);
13660 + checkNoDefault(it);
13661 + gen.let(names_1.default.vErrors, null);
13662 + gen.let(names_1.default.errors, 0);
13663 + if (opts.unevaluated) resetEvaluated(it);
13664 + typeAndKeywords(it);
13665 + returnResults(it);
13666 + });
13667 + }
13668 + function resetEvaluated(it) {
13669 + const { gen, validateName } = it;
13670 + it.evaluated = gen.const("evaluated", (0, codegen_1._)`${validateName}.evaluated`);
13671 + gen.if((0, codegen_1._)`${it.evaluated}.dynamicProps`, () => gen.assign((0, codegen_1._)`${it.evaluated}.props`, (0, codegen_1._)`undefined`));
13672 + gen.if((0, codegen_1._)`${it.evaluated}.dynamicItems`, () => gen.assign((0, codegen_1._)`${it.evaluated}.items`, (0, codegen_1._)`undefined`));
13673 + }
13674 + function funcSourceUrl(schema, opts) {
13675 + const schId = typeof schema == "object" && schema[opts.schemaId];
13676 + return schId && (opts.code.source || opts.code.process) ? (0, codegen_1._)`/*# sourceURL=${schId} */` : codegen_1.nil;
13677 + }
13678 + function subschemaCode(it, valid) {
13679 + if (isSchemaObj(it)) {
13680 + checkKeywords(it);
13681 + if (schemaCxtHasRules(it)) {
13682 + subSchemaObjCode(it, valid);
13683 + return;
13684 + }
13685 + }
13686 + (0, boolSchema_1.boolOrEmptySchema)(it, valid);
13687 + }
13688 + function schemaCxtHasRules({ schema, self }) {
13689 + if (typeof schema == "boolean") return !schema;
13690 + for (const key in schema) if (self.RULES.all[key]) return true;
13691 + return false;
13692 + }
13693 + function isSchemaObj(it) {
13694 + return typeof it.schema != "boolean";
13695 + }
13696 + function subSchemaObjCode(it, valid) {
13697 + const { schema, gen, opts } = it;
13698 + if (opts.$comment && schema.$comment) commentKeyword(it);
13699 + updateContext(it);
13700 + checkAsyncSchema(it);
13701 + const errsCount = gen.const("_errs", names_1.default.errors);
13702 + typeAndKeywords(it, errsCount);
13703 + gen.var(valid, (0, codegen_1._)`${errsCount} === ${names_1.default.errors}`);
13704 + }
13705 + function checkKeywords(it) {
13706 + (0, util_1.checkUnknownRules)(it);
13707 + checkRefsAndKeywords(it);
13708 + }
13709 + function typeAndKeywords(it, errsCount) {
13710 + if (it.opts.jtd) return schemaKeywords(it, [], false, errsCount);
13711 + const types = (0, dataType_1.getSchemaTypes)(it.schema);
13712 + schemaKeywords(it, types, !(0, dataType_1.coerceAndCheckDataType)(it, types), errsCount);
13713 + }
13714 + function checkRefsAndKeywords(it) {
13715 + const { schema, errSchemaPath, opts, self } = it;
13716 + if (schema.$ref && opts.ignoreKeywordsWithRef && (0, util_1.schemaHasRulesButRef)(schema, self.RULES)) self.logger.warn(`$ref: keywords ignored in schema at path "${errSchemaPath}"`);
13717 + }
13718 + function checkNoDefault(it) {
13719 + const { schema, opts } = it;
13720 + if (schema.default !== void 0 && opts.useDefaults && opts.strictSchema) (0, util_1.checkStrictMode)(it, "default is ignored in the schema root");
13721 + }
13722 + function updateContext(it) {
13723 + const schId = it.schema[it.opts.schemaId];
13724 + if (schId) it.baseId = (0, resolve_1.resolveUrl)(it.opts.uriResolver, it.baseId, schId);
13725 + }
13726 + function checkAsyncSchema(it) {
13727 + if (it.schema.$async && !it.schemaEnv.$async) throw new Error("async schema in sync schema");
13728 + }
13729 + function commentKeyword({ gen, schemaEnv, schema, errSchemaPath, opts }) {
13730 + const msg = schema.$comment;
13731 + if (opts.$comment === true) gen.code((0, codegen_1._)`${names_1.default.self}.logger.log(${msg})`);
13732 + else if (typeof opts.$comment == "function") {
13733 + const schemaPath = (0, codegen_1.str)`${errSchemaPath}/$comment`;
13734 + const rootName = gen.scopeValue("root", { ref: schemaEnv.root });
13735 + gen.code((0, codegen_1._)`${names_1.default.self}.opts.$comment(${msg}, ${schemaPath}, ${rootName}.schema)`);
13736 + }
13737 + }
13738 + function returnResults(it) {
13739 + const { gen, schemaEnv, validateName, ValidationError, opts } = it;
13740 + if (schemaEnv.$async) gen.if((0, codegen_1._)`${names_1.default.errors} === 0`, () => gen.return(names_1.default.data), () => gen.throw((0, codegen_1._)`new ${ValidationError}(${names_1.default.vErrors})`));
13741 + else {
13742 + gen.assign((0, codegen_1._)`${validateName}.errors`, names_1.default.vErrors);
13743 + if (opts.unevaluated) assignEvaluated(it);
13744 + gen.return((0, codegen_1._)`${names_1.default.errors} === 0`);
13745 + }
13746 + }
13747 + function assignEvaluated({ gen, evaluated, props, items }) {
13748 + if (props instanceof codegen_1.Name) gen.assign((0, codegen_1._)`${evaluated}.props`, props);
13749 + if (items instanceof codegen_1.Name) gen.assign((0, codegen_1._)`${evaluated}.items`, items);
13750 + }
13751 + function schemaKeywords(it, types, typeErrors, errsCount) {
13752 + const { gen, schema, data, allErrors, opts, self } = it;
13753 + const { RULES } = self;
13754 + if (schema.$ref && (opts.ignoreKeywordsWithRef || !(0, util_1.schemaHasRulesButRef)(schema, RULES))) {
13755 + gen.block(() => keywordCode(it, "$ref", RULES.all.$ref.definition));
13756 + return;
13757 + }
13758 + if (!opts.jtd) checkStrictTypes(it, types);
13759 + gen.block(() => {
13760 + for (const group of RULES.rules) groupKeywords(group);
13761 + groupKeywords(RULES.post);
13762 + });
13763 + function groupKeywords(group) {
13764 + if (!(0, applicability_1.shouldUseGroup)(schema, group)) return;
13765 + if (group.type) {
13766 + gen.if((0, dataType_2.checkDataType)(group.type, data, opts.strictNumbers));
13767 + iterateKeywords(it, group);
13768 + if (types.length === 1 && types[0] === group.type && typeErrors) {
13769 + gen.else();
13770 + (0, dataType_2.reportTypeError)(it);
13771 + }
13772 + gen.endIf();
13773 + } else iterateKeywords(it, group);
13774 + if (!allErrors) gen.if((0, codegen_1._)`${names_1.default.errors} === ${errsCount || 0}`);
13775 + }
13776 + }
13777 + function iterateKeywords(it, group) {
13778 + const { gen, schema, opts: { useDefaults } } = it;
13779 + if (useDefaults) (0, defaults_1.assignDefaults)(it, group.type);
13780 + gen.block(() => {
13781 + for (const rule of group.rules) if ((0, applicability_1.shouldUseRule)(schema, rule)) keywordCode(it, rule.keyword, rule.definition, group.type);
13782 + });
13783 + }
13784 + function checkStrictTypes(it, types) {
13785 + if (it.schemaEnv.meta || !it.opts.strictTypes) return;
13786 + checkContextTypes(it, types);
13787 + if (!it.opts.allowUnionTypes) checkMultipleTypes(it, types);
13788 + checkKeywordTypes(it, it.dataTypes);
13789 + }
13790 + function checkContextTypes(it, types) {
13791 + if (!types.length) return;
13792 + if (!it.dataTypes.length) {
13793 + it.dataTypes = types;
13794 + return;
13795 + }
13796 + types.forEach((t) => {
13797 + if (!includesType(it.dataTypes, t)) strictTypesError(it, `type "${t}" not allowed by context "${it.dataTypes.join(",")}"`);
13798 + });
13799 + narrowSchemaTypes(it, types);
13800 + }
13801 + function checkMultipleTypes(it, ts) {
13802 + if (ts.length > 1 && !(ts.length === 2 && ts.includes("null"))) strictTypesError(it, "use allowUnionTypes to allow union type keyword");
13803 + }
13804 + function checkKeywordTypes(it, ts) {
13805 + const rules = it.self.RULES.all;
13806 + for (const keyword in rules) {
13807 + const rule = rules[keyword];
13808 + if (typeof rule == "object" && (0, applicability_1.shouldUseRule)(it.schema, rule)) {
13809 + const { type } = rule.definition;
13810 + if (type.length && !type.some((t) => hasApplicableType(ts, t))) strictTypesError(it, `missing type "${type.join(",")}" for keyword "${keyword}"`);
13811 + }
13812 + }
13813 + }
13814 + function hasApplicableType(schTs, kwdT) {
13815 + return schTs.includes(kwdT) || kwdT === "number" && schTs.includes("integer");
13816 + }
13817 + function includesType(ts, t) {
13818 + return ts.includes(t) || t === "integer" && ts.includes("number");
13819 + }
13820 + function narrowSchemaTypes(it, withTypes) {
13821 + const ts = [];
13822 + for (const t of it.dataTypes) if (includesType(withTypes, t)) ts.push(t);
13823 + else if (withTypes.includes("integer") && t === "number") ts.push("integer");
13824 + it.dataTypes = ts;
13825 + }
13826 + function strictTypesError(it, msg) {
13827 + const schemaPath = it.schemaEnv.baseId + it.errSchemaPath;
13828 + msg += ` at "${schemaPath}" (strictTypes)`;
13829 + (0, util_1.checkStrictMode)(it, msg, it.opts.strictTypes);
13830 + }
13831 + var KeywordCxt = class {
13832 + constructor(it, def, keyword) {
13833 + (0, keyword_1.validateKeywordUsage)(it, def, keyword);
13834 + this.gen = it.gen;
13835 + this.allErrors = it.allErrors;
13836 + this.keyword = keyword;
13837 + this.data = it.data;
13838 + this.schema = it.schema[keyword];
13839 + this.$data = def.$data && it.opts.$data && this.schema && this.schema.$data;
13840 + this.schemaValue = (0, util_1.schemaRefOrVal)(it, this.schema, keyword, this.$data);
13841 + this.schemaType = def.schemaType;
13842 + this.parentSchema = it.schema;
13843 + this.params = {};
13844 + this.it = it;
13845 + this.def = def;
13846 + if (this.$data) this.schemaCode = it.gen.const("vSchema", getData(this.$data, it));
13847 + else {
13848 + this.schemaCode = this.schemaValue;
13849 + if (!(0, keyword_1.validSchemaType)(this.schema, def.schemaType, def.allowUndefined)) throw new Error(`${keyword} value must be ${JSON.stringify(def.schemaType)}`);
13850 + }
13851 + if ("code" in def ? def.trackErrors : def.errors !== false) this.errsCount = it.gen.const("_errs", names_1.default.errors);
13852 + }
13853 + result(condition, successAction, failAction) {
13854 + this.failResult((0, codegen_1.not)(condition), successAction, failAction);
13855 + }
13856 + failResult(condition, successAction, failAction) {
13857 + this.gen.if(condition);
13858 + if (failAction) failAction();
13859 + else this.error();
13860 + if (successAction) {
13861 + this.gen.else();
13862 + successAction();
13863 + if (this.allErrors) this.gen.endIf();
13864 + } else if (this.allErrors) this.gen.endIf();
13865 + else this.gen.else();
13866 + }
13867 + pass(condition, failAction) {
13868 + this.failResult((0, codegen_1.not)(condition), void 0, failAction);
13869 + }
13870 + fail(condition) {
13871 + if (condition === void 0) {
13872 + this.error();
13873 + if (!this.allErrors) this.gen.if(false);
13874 + return;
13875 + }
13876 + this.gen.if(condition);
13877 + this.error();
13878 + if (this.allErrors) this.gen.endIf();
13879 + else this.gen.else();
13880 + }
13881 + fail$data(condition) {
13882 + if (!this.$data) return this.fail(condition);
13883 + const { schemaCode } = this;
13884 + this.fail((0, codegen_1._)`${schemaCode} !== undefined && (${(0, codegen_1.or)(this.invalid$data(), condition)})`);
13885 + }
13886 + error(append, errorParams, errorPaths) {
13887 + if (errorParams) {
13888 + this.setParams(errorParams);
13889 + this._error(append, errorPaths);
13890 + this.setParams({});
13891 + return;
13892 + }
13893 + this._error(append, errorPaths);
13894 + }
13895 + _error(append, errorPaths) {
13896 + (append ? errors_1.reportExtraError : errors_1.reportError)(this, this.def.error, errorPaths);
13897 + }
13898 + $dataError() {
13899 + (0, errors_1.reportError)(this, this.def.$dataError || errors_1.keyword$DataError);
13900 + }
13901 + reset() {
13902 + if (this.errsCount === void 0) throw new Error("add \"trackErrors\" to keyword definition");
13903 + (0, errors_1.resetErrorsCount)(this.gen, this.errsCount);
13904 + }
13905 + ok(cond) {
13906 + if (!this.allErrors) this.gen.if(cond);
13907 + }
13908 + setParams(obj, assign) {
13909 + if (assign) Object.assign(this.params, obj);
13910 + else this.params = obj;
13911 + }
13912 + block$data(valid, codeBlock, $dataValid = codegen_1.nil) {
13913 + this.gen.block(() => {
13914 + this.check$data(valid, $dataValid);
13915 + codeBlock();
13916 + });
13917 + }
13918 + check$data(valid = codegen_1.nil, $dataValid = codegen_1.nil) {
13919 + if (!this.$data) return;
13920 + const { gen, schemaCode, schemaType, def } = this;
13921 + gen.if((0, codegen_1.or)((0, codegen_1._)`${schemaCode} === undefined`, $dataValid));
13922 + if (valid !== codegen_1.nil) gen.assign(valid, true);
13923 + if (schemaType.length || def.validateSchema) {
13924 + gen.elseIf(this.invalid$data());
13925 + this.$dataError();
13926 + if (valid !== codegen_1.nil) gen.assign(valid, false);
13927 + }
13928 + gen.else();
13929 + }
13930 + invalid$data() {
13931 + const { gen, schemaCode, schemaType, def, it } = this;
13932 + return (0, codegen_1.or)(wrong$DataType(), invalid$DataSchema());
13933 + function wrong$DataType() {
13934 + if (schemaType.length) {
13935 + /* istanbul ignore if */
13936 + if (!(schemaCode instanceof codegen_1.Name)) throw new Error("ajv implementation error");
13937 + const st = Array.isArray(schemaType) ? schemaType : [schemaType];
13938 + return (0, codegen_1._)`${(0, dataType_2.checkDataTypes)(st, schemaCode, it.opts.strictNumbers, dataType_2.DataType.Wrong)}`;
13939 + }
13940 + return codegen_1.nil;
13941 + }
13942 + function invalid$DataSchema() {
13943 + if (def.validateSchema) {
13944 + const validateSchemaRef = gen.scopeValue("validate$data", { ref: def.validateSchema });
13945 + return (0, codegen_1._)`!${validateSchemaRef}(${schemaCode})`;
13946 + }
13947 + return codegen_1.nil;
13948 + }
13949 + }
13950 + subschema(appl, valid) {
13951 + const subschema = (0, subschema_1.getSubschema)(this.it, appl);
13952 + (0, subschema_1.extendSubschemaData)(subschema, this.it, appl);
13953 + (0, subschema_1.extendSubschemaMode)(subschema, appl);
13954 + const nextContext = {
13955 + ...this.it,
13956 + ...subschema,
13957 + items: void 0,
13958 + props: void 0
13959 + };
13960 + subschemaCode(nextContext, valid);
13961 + return nextContext;
13962 + }
13963 + mergeEvaluated(schemaCxt, toName) {
13964 + const { it, gen } = this;
13965 + if (!it.opts.unevaluated) return;
13966 + if (it.props !== true && schemaCxt.props !== void 0) it.props = util_1.mergeEvaluated.props(gen, schemaCxt.props, it.props, toName);
13967 + if (it.items !== true && schemaCxt.items !== void 0) it.items = util_1.mergeEvaluated.items(gen, schemaCxt.items, it.items, toName);
13968 + }
13969 + mergeValidEvaluated(schemaCxt, valid) {
13970 + const { it, gen } = this;
13971 + if (it.opts.unevaluated && (it.props !== true || it.items !== true)) {
13972 + gen.if(valid, () => this.mergeEvaluated(schemaCxt, codegen_1.Name));
13973 + return true;
13974 + }
13975 + }
13976 + };
13977 + exports.KeywordCxt = KeywordCxt;
13978 + function keywordCode(it, keyword, def, ruleType) {
13979 + const cxt = new KeywordCxt(it, def, keyword);
13980 + if ("code" in def) def.code(cxt, ruleType);
13981 + else if (cxt.$data && def.validate) (0, keyword_1.funcKeywordCode)(cxt, def);
13982 + else if ("macro" in def) (0, keyword_1.macroKeywordCode)(cxt, def);
13983 + else if (def.compile || def.validate) (0, keyword_1.funcKeywordCode)(cxt, def);
13984 + }
13985 + var JSON_POINTER = /^\/(?:[^~]|~0|~1)*$/;
13986 + var RELATIVE_JSON_POINTER = /^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;
13987 + function getData($data, { dataLevel, dataNames, dataPathArr }) {
13988 + let jsonPointer;
13989 + let data;
13990 + if ($data === "") return names_1.default.rootData;
13991 + if ($data[0] === "/") {
13992 + if (!JSON_POINTER.test($data)) throw new Error(`Invalid JSON-pointer: ${$data}`);
13993 + jsonPointer = $data;
13994 + data = names_1.default.rootData;
13995 + } else {
13996 + const matches = RELATIVE_JSON_POINTER.exec($data);
13997 + if (!matches) throw new Error(`Invalid JSON-pointer: ${$data}`);
13998 + const up = +matches[1];
13999 + jsonPointer = matches[2];
14000 + if (jsonPointer === "#") {
14001 + if (up >= dataLevel) throw new Error(errorMsg("property/index", up));
14002 + return dataPathArr[dataLevel - up];
14003 + }
14004 + if (up > dataLevel) throw new Error(errorMsg("data", up));
14005 + data = dataNames[dataLevel - up];
14006 + if (!jsonPointer) return data;
14007 + }
14008 + let expr = data;
14009 + const segments = jsonPointer.split("/");
14010 + for (const segment of segments) if (segment) {
14011 + data = (0, codegen_1._)`${data}${(0, codegen_1.getProperty)((0, util_1.unescapeJsonPointer)(segment))}`;
14012 + expr = (0, codegen_1._)`${expr} && ${data}`;
14013 + }
14014 + return expr;
14015 + function errorMsg(pointerType, up) {
14016 + return `Cannot access ${pointerType} ${up} levels up, current level is ${dataLevel}`;
14017 + }
14018 + }
14019 + exports.getData = getData;
14020 + }));
14021 +
14022 +//#endregion
14023 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/runtime/validation_error.js
14024 + var require_validation_error = /* @__PURE__ */ __commonJSMin(((exports) => {
14025 + Object.defineProperty(exports, "__esModule", { value: true });
14026 + var ValidationError = class extends Error {
14027 + constructor(errors) {
14028 + super("validation failed");
14029 + this.errors = errors;
14030 + this.ajv = this.validation = true;
14031 + }
14032 + };
14033 + exports.default = ValidationError;
14034 + }));
14035 +
14036 +//#endregion
14037 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/ref_error.js
14038 + var require_ref_error = /* @__PURE__ */ __commonJSMin(((exports) => {
14039 + Object.defineProperty(exports, "__esModule", { value: true });
14040 + var resolve_1 = require_resolve();
14041 + var MissingRefError = class extends Error {
14042 + constructor(resolver, baseId, ref, msg) {
14043 + super(msg || `can't resolve reference ${ref} from id ${baseId}`);
14044 + this.missingRef = (0, resolve_1.resolveUrl)(resolver, baseId, ref);
14045 + this.missingSchema = (0, resolve_1.normalizeId)((0, resolve_1.getFullPath)(resolver, this.missingRef));
14046 + }
14047 + };
14048 + exports.default = MissingRefError;
14049 + }));
14050 +
14051 +//#endregion
14052 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/compile/index.js
14053 + var require_compile = /* @__PURE__ */ __commonJSMin(((exports) => {
14054 + Object.defineProperty(exports, "__esModule", { value: true });
14055 + exports.resolveSchema = exports.getCompilingSchema = exports.resolveRef = exports.compileSchema = exports.SchemaEnv = void 0;
14056 + var codegen_1 = require_codegen();
14057 + var validation_error_1 = require_validation_error();
14058 + var names_1 = require_names();
14059 + var resolve_1 = require_resolve();
14060 + var util_1 = require_util();
14061 + var validate_1 = require_validate();
14062 + var SchemaEnv = class {
14063 + constructor(env) {
14064 + var _a;
14065 + this.refs = {};
14066 + this.dynamicAnchors = {};
14067 + let schema;
14068 + if (typeof env.schema == "object") schema = env.schema;
14069 + this.schema = env.schema;
14070 + this.schemaId = env.schemaId;
14071 + this.root = env.root || this;
14072 + this.baseId = (_a = env.baseId) !== null && _a !== void 0 ? _a : (0, resolve_1.normalizeId)(schema === null || schema === void 0 ? void 0 : schema[env.schemaId || "$id"]);
14073 + this.schemaPath = env.schemaPath;
14074 + this.localRefs = env.localRefs;
14075 + this.meta = env.meta;
14076 + this.$async = schema === null || schema === void 0 ? void 0 : schema.$async;
14077 + this.refs = {};
14078 + }
14079 + };
14080 + exports.SchemaEnv = SchemaEnv;
14081 + function compileSchema(sch) {
14082 + const _sch = getCompilingSchema.call(this, sch);
14083 + if (_sch) return _sch;
14084 + const rootId = (0, resolve_1.getFullPath)(this.opts.uriResolver, sch.root.baseId);
14085 + const { es5, lines } = this.opts.code;
14086 + const { ownProperties } = this.opts;
14087 + const gen = new codegen_1.CodeGen(this.scope, {
14088 + es5,
14089 + lines,
14090 + ownProperties
14091 + });
14092 + let _ValidationError;
14093 + if (sch.$async) _ValidationError = gen.scopeValue("Error", {
14094 + ref: validation_error_1.default,
14095 + code: (0, codegen_1._)`require("ajv/dist/runtime/validation_error").default`
14096 + });
14097 + const validateName = gen.scopeName("validate");
14098 + sch.validateName = validateName;
14099 + const schemaCxt = {
14100 + gen,
14101 + allErrors: this.opts.allErrors,
14102 + data: names_1.default.data,
14103 + parentData: names_1.default.parentData,
14104 + parentDataProperty: names_1.default.parentDataProperty,
14105 + dataNames: [names_1.default.data],
14106 + dataPathArr: [codegen_1.nil],
14107 + dataLevel: 0,
14108 + dataTypes: [],
14109 + definedProperties: /* @__PURE__ */ new Set(),
14110 + topSchemaRef: gen.scopeValue("schema", this.opts.code.source === true ? {
14111 + ref: sch.schema,
14112 + code: (0, codegen_1.stringify)(sch.schema)
14113 + } : { ref: sch.schema }),
14114 + validateName,
14115 + ValidationError: _ValidationError,
14116 + schema: sch.schema,
14117 + schemaEnv: sch,
14118 + rootId,
14119 + baseId: sch.baseId || rootId,
14120 + schemaPath: codegen_1.nil,
14121 + errSchemaPath: sch.schemaPath || (this.opts.jtd ? "" : "#"),
14122 + errorPath: (0, codegen_1._)`""`,
14123 + opts: this.opts,
14124 + self: this
14125 + };
14126 + let sourceCode;
14127 + try {
14128 + this._compilations.add(sch);
14129 + (0, validate_1.validateFunctionCode)(schemaCxt);
14130 + gen.optimize(this.opts.code.optimize);
14131 + const validateCode = gen.toString();
14132 + sourceCode = `${gen.scopeRefs(names_1.default.scope)}return ${validateCode}`;
14133 + if (this.opts.code.process) sourceCode = this.opts.code.process(sourceCode, sch);
14134 + const validate = new Function(`${names_1.default.self}`, `${names_1.default.scope}`, sourceCode)(this, this.scope.get());
14135 + this.scope.value(validateName, { ref: validate });
14136 + validate.errors = null;
14137 + validate.schema = sch.schema;
14138 + validate.schemaEnv = sch;
14139 + if (sch.$async) validate.$async = true;
14140 + if (this.opts.code.source === true) validate.source = {
14141 + validateName,
14142 + validateCode,
14143 + scopeValues: gen._values
14144 + };
14145 + if (this.opts.unevaluated) {
14146 + const { props, items } = schemaCxt;
14147 + validate.evaluated = {
14148 + props: props instanceof codegen_1.Name ? void 0 : props,
14149 + items: items instanceof codegen_1.Name ? void 0 : items,
14150 + dynamicProps: props instanceof codegen_1.Name,
14151 + dynamicItems: items instanceof codegen_1.Name
14152 + };
14153 + if (validate.source) validate.source.evaluated = (0, codegen_1.stringify)(validate.evaluated);
14154 + }
14155 + sch.validate = validate;
14156 + return sch;
14157 + } catch (e) {
14158 + delete sch.validate;
14159 + delete sch.validateName;
14160 + if (sourceCode) this.logger.error("Error compiling schema, function code:", sourceCode);
14161 + throw e;
14162 + } finally {
14163 + this._compilations.delete(sch);
14164 + }
14165 + }
14166 + exports.compileSchema = compileSchema;
14167 + function resolveRef(root, baseId, ref) {
14168 + var _a;
14169 + ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
14170 + const schOrFunc = root.refs[ref];
14171 + if (schOrFunc) return schOrFunc;
14172 + let _sch = resolve.call(this, root, ref);
14173 + if (_sch === void 0) {
14174 + const schema = (_a = root.localRefs) === null || _a === void 0 ? void 0 : _a[ref];
14175 + const { schemaId } = this.opts;
14176 + if (schema) _sch = new SchemaEnv({
14177 + schema,
14178 + schemaId,
14179 + root,
14180 + baseId
14181 + });
14182 + }
14183 + if (_sch === void 0) return;
14184 + return root.refs[ref] = inlineOrCompile.call(this, _sch);
14185 + }
14186 + exports.resolveRef = resolveRef;
14187 + function inlineOrCompile(sch) {
14188 + if ((0, resolve_1.inlineRef)(sch.schema, this.opts.inlineRefs)) return sch.schema;
14189 + return sch.validate ? sch : compileSchema.call(this, sch);
14190 + }
14191 + function getCompilingSchema(schEnv) {
14192 + for (const sch of this._compilations) if (sameSchemaEnv(sch, schEnv)) return sch;
14193 + }
14194 + exports.getCompilingSchema = getCompilingSchema;
14195 + function sameSchemaEnv(s1, s2) {
14196 + return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
14197 + }
14198 + function resolve(root, ref) {
14199 + let sch;
14200 + while (typeof (sch = this.refs[ref]) == "string") ref = sch;
14201 + return sch || this.schemas[ref] || resolveSchema.call(this, root, ref);
14202 + }
14203 + function resolveSchema(root, ref) {
14204 + const p = this.opts.uriResolver.parse(ref);
14205 + const refPath = (0, resolve_1._getFullPath)(this.opts.uriResolver, p);
14206 + let baseId = (0, resolve_1.getFullPath)(this.opts.uriResolver, root.baseId, void 0);
14207 + if (Object.keys(root.schema).length > 0 && refPath === baseId) return getJsonPointer.call(this, p, root);
14208 + const id = (0, resolve_1.normalizeId)(refPath);
14209 + const schOrRef = this.refs[id] || this.schemas[id];
14210 + if (typeof schOrRef == "string") {
14211 + const sch = resolveSchema.call(this, root, schOrRef);
14212 + if (typeof (sch === null || sch === void 0 ? void 0 : sch.schema) !== "object") return;
14213 + return getJsonPointer.call(this, p, sch);
14214 + }
14215 + if (typeof (schOrRef === null || schOrRef === void 0 ? void 0 : schOrRef.schema) !== "object") return;
14216 + if (!schOrRef.validate) compileSchema.call(this, schOrRef);
14217 + if (id === (0, resolve_1.normalizeId)(ref)) {
14218 + const { schema } = schOrRef;
14219 + const { schemaId } = this.opts;
14220 + const schId = schema[schemaId];
14221 + if (schId) baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
14222 + return new SchemaEnv({
14223 + schema,
14224 + schemaId,
14225 + root,
14226 + baseId
14227 + });
14228 + }
14229 + return getJsonPointer.call(this, p, schOrRef);
14230 + }
14231 + exports.resolveSchema = resolveSchema;
14232 + var PREVENT_SCOPE_CHANGE = /* @__PURE__ */ new Set([
14233 + "properties",
14234 + "patternProperties",
14235 + "enum",
14236 + "dependencies",
14237 + "definitions"
14238 + ]);
14239 + function getJsonPointer(parsedRef, { baseId, schema, root }) {
14240 + var _a;
14241 + if (((_a = parsedRef.fragment) === null || _a === void 0 ? void 0 : _a[0]) !== "/") return;
14242 + for (const part of parsedRef.fragment.slice(1).split("/")) {
14243 + if (typeof schema === "boolean") return;
14244 + const partSchema = schema[(0, util_1.unescapeFragment)(part)];
14245 + if (partSchema === void 0) return;
14246 + schema = partSchema;
14247 + const schId = typeof schema === "object" && schema[this.opts.schemaId];
14248 + if (!PREVENT_SCOPE_CHANGE.has(part) && schId) baseId = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schId);
14249 + }
14250 + let env;
14251 + if (typeof schema != "boolean" && schema.$ref && !(0, util_1.schemaHasRulesButRef)(schema, this.RULES)) {
14252 + const $ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, schema.$ref);
14253 + env = resolveSchema.call(this, root, $ref);
14254 + }
14255 + const { schemaId } = this.opts;
14256 + env = env || new SchemaEnv({
14257 + schema,
14258 + schemaId,
14259 + root,
14260 + baseId
14261 + });
14262 + if (env.schema !== env.root.schema) return env;
14263 + }
14264 + }));
14265 +
14266 +//#endregion
14267 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/refs/data.json
14268 + var data_exports = /* @__PURE__ */ __exportAll({
14269 + $id: () => $id$1,
14270 + additionalProperties: () => false,
14271 + default: () => data_default,
14272 + description: () => description,
14273 + properties: () => properties$1,
14274 + required: () => required,
14275 + type: () => type$1
14276 + });
14277 + var $id$1, description, type$1, required, properties$1, additionalProperties, data_default;
14278 + var init_data = __esmMin((() => {
14279 + $id$1 = "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#";
14280 + description = "Meta-schema for $data reference (JSON AnySchema extension proposal)";
14281 + type$1 = "object";
14282 + required = ["$data"];
14283 + properties$1 = { "$data": {
14284 + "type": "string",
14285 + "anyOf": [{ "format": "relative-json-pointer" }, { "format": "json-pointer" }]
14286 + } };
14287 + additionalProperties = false;
14288 + data_default = {
14289 + $id: $id$1,
14290 + description,
14291 + type: type$1,
14292 + required,
14293 + properties: properties$1,
14294 + additionalProperties: false
14295 + };
14296 + }));
14297 +
14298 +//#endregion
14299 +//#region node_modules/fast-uri/lib/utils.js
14300 + var require_utils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14301 + /** @type {(value: string) => boolean} */
14302 + var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
14303 + /** @type {(value: string) => boolean} */
14304 + var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
14305 + /**
14306 + * @param {Array<string>} input
14307 + * @returns {string}
14308 + */
14309 + function stringArrayToHexStripped(input) {
14310 + let acc = "";
14311 + let code = 0;
14312 + let i = 0;
14313 + for (i = 0; i < input.length; i++) {
14314 + code = input[i].charCodeAt(0);
14315 + if (code === 48) continue;
14316 + if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) return "";
14317 + acc += input[i];
14318 + break;
14319 + }
14320 + for (i += 1; i < input.length; i++) {
14321 + code = input[i].charCodeAt(0);
14322 + if (!(code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102)) return "";
14323 + acc += input[i];
14324 + }
14325 + return acc;
14326 + }
14327 + /**
14328 + * @typedef {Object} GetIPV6Result
14329 + * @property {boolean} error - Indicates if there was an error parsing the IPv6 address.
14330 + * @property {string} address - The parsed IPv6 address.
14331 + * @property {string} [zone] - The zone identifier, if present.
14332 + */
14333 + /**
14334 + * @param {string} value
14335 + * @returns {boolean}
14336 + */
14337 + var nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
14338 + /**
14339 + * @param {Array<string>} buffer
14340 + * @returns {boolean}
14341 + */
14342 + function consumeIsZone(buffer) {
14343 + buffer.length = 0;
14344 + return true;
14345 + }
14346 + /**
14347 + * @param {Array<string>} buffer
14348 + * @param {Array<string>} address
14349 + * @param {GetIPV6Result} output
14350 + * @returns {boolean}
14351 + */
14352 + function consumeHextets(buffer, address, output) {
14353 + if (buffer.length) {
14354 + const hex = stringArrayToHexStripped(buffer);
14355 + if (hex !== "") address.push(hex);
14356 + else {
14357 + output.error = true;
14358 + return false;
14359 + }
14360 + buffer.length = 0;
14361 + }
14362 + return true;
14363 + }
14364 + /**
14365 + * @param {string} input
14366 + * @returns {GetIPV6Result}
14367 + */
14368 + function getIPV6(input) {
14369 + let tokenCount = 0;
14370 + const output = {
14371 + error: false,
14372 + address: "",
14373 + zone: ""
14374 + };
14375 + /** @type {Array<string>} */
14376 + const address = [];
14377 + /** @type {Array<string>} */
14378 + const buffer = [];
14379 + let endipv6Encountered = false;
14380 + let endIpv6 = false;
14381 + let consume = consumeHextets;
14382 + for (let i = 0; i < input.length; i++) {
14383 + const cursor = input[i];
14384 + if (cursor === "[" || cursor === "]") continue;
14385 + if (cursor === ":") {
14386 + if (endipv6Encountered === true) endIpv6 = true;
14387 + if (!consume(buffer, address, output)) break;
14388 + if (++tokenCount > 7) {
14389 + output.error = true;
14390 + break;
14391 + }
14392 + if (i > 0 && input[i - 1] === ":") endipv6Encountered = true;
14393 + address.push(":");
14394 + continue;
14395 + } else if (cursor === "%") {
14396 + if (!consume(buffer, address, output)) break;
14397 + consume = consumeIsZone;
14398 + } else {
14399 + buffer.push(cursor);
14400 + continue;
14401 + }
14402 + }
14403 + if (buffer.length) if (consume === consumeIsZone) output.zone = buffer.join("");
14404 + else if (endIpv6) address.push(buffer.join(""));
14405 + else address.push(stringArrayToHexStripped(buffer));
14406 + output.address = address.join("");
14407 + return output;
14408 + }
14409 + /**
14410 + * @typedef {Object} NormalizeIPv6Result
14411 + * @property {string} host - The normalized host.
14412 + * @property {string} [escapedHost] - The escaped host.
14413 + * @property {boolean} isIPV6 - Indicates if the host is an IPv6 address.
14414 + */
14415 + /**
14416 + * @param {string} host
14417 + * @returns {NormalizeIPv6Result}
14418 + */
14419 + function normalizeIPv6(host) {
14420 + if (findToken(host, ":") < 2) return {
14421 + host,
14422 + isIPV6: false
14423 + };
14424 + const ipv6 = getIPV6(host);
14425 + if (!ipv6.error) {
14426 + let newHost = ipv6.address;
14427 + let escapedHost = ipv6.address;
14428 + if (ipv6.zone) {
14429 + newHost += "%" + ipv6.zone;
14430 + escapedHost += "%25" + ipv6.zone;
14431 + }
14432 + return {
14433 + host: newHost,
14434 + isIPV6: true,
14435 + escapedHost
14436 + };
14437 + } else return {
14438 + host,
14439 + isIPV6: false
14440 + };
14441 + }
14442 + /**
14443 + * @param {string} str
14444 + * @param {string} token
14445 + * @returns {number}
14446 + */
14447 + function findToken(str, token) {
14448 + let ind = 0;
14449 + for (let i = 0; i < str.length; i++) if (str[i] === token) ind++;
14450 + return ind;
14451 + }
14452 + /**
14453 + * @param {string} path
14454 + * @returns {string}
14455 + *
14456 + * @see https://datatracker.ietf.org/doc/html/rfc3986#section-5.2.4
14457 + */
14458 + function removeDotSegments(path) {
14459 + let input = path;
14460 + const output = [];
14461 + let nextSlash = -1;
14462 + let len = 0;
14463 + while (len = input.length) {
14464 + if (len === 1) if (input === ".") break;
14465 + else if (input === "/") {
14466 + output.push("/");
14467 + break;
14468 + } else {
14469 + output.push(input);
14470 + break;
14471 + }
14472 + else if (len === 2) {
14473 + if (input[0] === ".") {
14474 + if (input[1] === ".") break;
14475 + else if (input[1] === "/") {
14476 + input = input.slice(2);
14477 + continue;
14478 + }
14479 + } else if (input[0] === "/") {
14480 + if (input[1] === "." || input[1] === "/") {
14481 + output.push("/");
14482 + break;
14483 + }
14484 + }
14485 + } else if (len === 3) {
14486 + if (input === "/..") {
14487 + if (output.length !== 0) output.pop();
14488 + output.push("/");
14489 + break;
14490 + }
14491 + }
14492 + if (input[0] === ".") {
14493 + if (input[1] === ".") {
14494 + if (input[2] === "/") {
14495 + input = input.slice(3);
14496 + continue;
14497 + }
14498 + } else if (input[1] === "/") {
14499 + input = input.slice(2);
14500 + continue;
14501 + }
14502 + } else if (input[0] === "/") {
14503 + if (input[1] === ".") {
14504 + if (input[2] === "/") {
14505 + input = input.slice(2);
14506 + continue;
14507 + } else if (input[2] === ".") {
14508 + if (input[3] === "/") {
14509 + input = input.slice(3);
14510 + if (output.length !== 0) output.pop();
14511 + continue;
14512 + }
14513 + }
14514 + }
14515 + }
14516 + if ((nextSlash = input.indexOf("/", 1)) === -1) {
14517 + output.push(input);
14518 + break;
14519 + } else {
14520 + output.push(input.slice(0, nextSlash));
14521 + input = input.slice(nextSlash);
14522 + }
14523 + }
14524 + return output.join("");
14525 + }
14526 + /**
14527 + * @param {import('../types/index').URIComponent} component
14528 + * @param {boolean} esc
14529 + * @returns {import('../types/index').URIComponent}
14530 + */
14531 + function normalizeComponentEncoding(component, esc) {
14532 + const func = esc !== true ? escape : unescape;
14533 + if (component.scheme !== void 0) component.scheme = func(component.scheme);
14534 + if (component.userinfo !== void 0) component.userinfo = func(component.userinfo);
14535 + if (component.host !== void 0) component.host = func(component.host);
14536 + if (component.path !== void 0) component.path = func(component.path);
14537 + if (component.query !== void 0) component.query = func(component.query);
14538 + if (component.fragment !== void 0) component.fragment = func(component.fragment);
14539 + return component;
14540 + }
14541 + /**
14542 + * @param {import('../types/index').URIComponent} component
14543 + * @returns {string|undefined}
14544 + */
14545 + function recomposeAuthority(component) {
14546 + const uriTokens = [];
14547 + if (component.userinfo !== void 0) {
14548 + uriTokens.push(component.userinfo);
14549 + uriTokens.push("@");
14550 + }
14551 + if (component.host !== void 0) {
14552 + let host = unescape(component.host);
14553 + if (!isIPv4(host)) {
14554 + const ipV6res = normalizeIPv6(host);
14555 + if (ipV6res.isIPV6 === true) host = `[${ipV6res.escapedHost}]`;
14556 + else host = component.host;
14557 + }
14558 + uriTokens.push(host);
14559 + }
14560 + if (typeof component.port === "number" || typeof component.port === "string") {
14561 + uriTokens.push(":");
14562 + uriTokens.push(String(component.port));
14563 + }
14564 + return uriTokens.length ? uriTokens.join("") : void 0;
14565 + }
14566 + module.exports = {
14567 + nonSimpleDomain,
14568 + recomposeAuthority,
14569 + normalizeComponentEncoding,
14570 + removeDotSegments,
14571 + isIPv4,
14572 + isUUID,
14573 + normalizeIPv6,
14574 + stringArrayToHexStripped
14575 + };
14576 + }));
14577 +
14578 +//#endregion
14579 +//#region node_modules/fast-uri/lib/schemes.js
14580 + var require_schemes = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14581 + var { isUUID } = require_utils();
14582 + var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
14583 + var supportedSchemeNames = [
14584 + "http",
14585 + "https",
14586 + "ws",
14587 + "wss",
14588 + "urn",
14589 + "urn:uuid"
14590 + ];
14591 + /** @typedef {supportedSchemeNames[number]} SchemeName */
14592 + /**
14593 + * @param {string} name
14594 + * @returns {name is SchemeName}
14595 + */
14596 + function isValidSchemeName(name) {
14597 + return supportedSchemeNames.indexOf(name) !== -1;
14598 + }
14599 + /**
14600 + * @callback SchemeFn
14601 + * @param {import('../types/index').URIComponent} component
14602 + * @param {import('../types/index').Options} options
14603 + * @returns {import('../types/index').URIComponent}
14604 + */
14605 + /**
14606 + * @typedef {Object} SchemeHandler
14607 + * @property {SchemeName} scheme - The scheme name.
14608 + * @property {boolean} [domainHost] - Indicates if the scheme supports domain hosts.
14609 + * @property {SchemeFn} parse - Function to parse the URI component for this scheme.
14610 + * @property {SchemeFn} serialize - Function to serialize the URI component for this scheme.
14611 + * @property {boolean} [skipNormalize] - Indicates if normalization should be skipped for this scheme.
14612 + * @property {boolean} [absolutePath] - Indicates if the scheme uses absolute paths.
14613 + * @property {boolean} [unicodeSupport] - Indicates if the scheme supports Unicode.
14614 + */
14615 + /**
14616 + * @param {import('../types/index').URIComponent} wsComponent
14617 + * @returns {boolean}
14618 + */
14619 + function wsIsSecure(wsComponent) {
14620 + if (wsComponent.secure === true) return true;
14621 + else if (wsComponent.secure === false) return false;
14622 + else if (wsComponent.scheme) return wsComponent.scheme.length === 3 && (wsComponent.scheme[0] === "w" || wsComponent.scheme[0] === "W") && (wsComponent.scheme[1] === "s" || wsComponent.scheme[1] === "S") && (wsComponent.scheme[2] === "s" || wsComponent.scheme[2] === "S");
14623 + else return false;
14624 + }
14625 + /** @type {SchemeFn} */
14626 + function httpParse(component) {
14627 + if (!component.host) component.error = component.error || "HTTP URIs must have a host.";
14628 + return component;
14629 + }
14630 + /** @type {SchemeFn} */
14631 + function httpSerialize(component) {
14632 + const secure = String(component.scheme).toLowerCase() === "https";
14633 + if (component.port === (secure ? 443 : 80) || component.port === "") component.port = void 0;
14634 + if (!component.path) component.path = "/";
14635 + return component;
14636 + }
14637 + /** @type {SchemeFn} */
14638 + function wsParse(wsComponent) {
14639 + wsComponent.secure = wsIsSecure(wsComponent);
14640 + wsComponent.resourceName = (wsComponent.path || "/") + (wsComponent.query ? "?" + wsComponent.query : "");
14641 + wsComponent.path = void 0;
14642 + wsComponent.query = void 0;
14643 + return wsComponent;
14644 + }
14645 + /** @type {SchemeFn} */
14646 + function wsSerialize(wsComponent) {
14647 + if (wsComponent.port === (wsIsSecure(wsComponent) ? 443 : 80) || wsComponent.port === "") wsComponent.port = void 0;
14648 + if (typeof wsComponent.secure === "boolean") {
14649 + wsComponent.scheme = wsComponent.secure ? "wss" : "ws";
14650 + wsComponent.secure = void 0;
14651 + }
14652 + if (wsComponent.resourceName) {
14653 + const [path, query] = wsComponent.resourceName.split("?");
14654 + wsComponent.path = path && path !== "/" ? path : void 0;
14655 + wsComponent.query = query;
14656 + wsComponent.resourceName = void 0;
14657 + }
14658 + wsComponent.fragment = void 0;
14659 + return wsComponent;
14660 + }
14661 + /** @type {SchemeFn} */
14662 + function urnParse(urnComponent, options) {
14663 + if (!urnComponent.path) {
14664 + urnComponent.error = "URN can not be parsed";
14665 + return urnComponent;
14666 + }
14667 + const matches = urnComponent.path.match(URN_REG);
14668 + if (matches) {
14669 + const scheme = options.scheme || urnComponent.scheme || "urn";
14670 + urnComponent.nid = matches[1].toLowerCase();
14671 + urnComponent.nss = matches[2];
14672 + const schemeHandler = getSchemeHandler(`${scheme}:${options.nid || urnComponent.nid}`);
14673 + urnComponent.path = void 0;
14674 + if (schemeHandler) urnComponent = schemeHandler.parse(urnComponent, options);
14675 + } else urnComponent.error = urnComponent.error || "URN can not be parsed.";
14676 + return urnComponent;
14677 + }
14678 + /** @type {SchemeFn} */
14679 + function urnSerialize(urnComponent, options) {
14680 + if (urnComponent.nid === void 0) throw new Error("URN without nid cannot be serialized");
14681 + const scheme = options.scheme || urnComponent.scheme || "urn";
14682 + const nid = urnComponent.nid.toLowerCase();
14683 + const schemeHandler = getSchemeHandler(`${scheme}:${options.nid || nid}`);
14684 + if (schemeHandler) urnComponent = schemeHandler.serialize(urnComponent, options);
14685 + const uriComponent = urnComponent;
14686 + const nss = urnComponent.nss;
14687 + uriComponent.path = `${nid || options.nid}:${nss}`;
14688 + options.skipEscape = true;
14689 + return uriComponent;
14690 + }
14691 + /** @type {SchemeFn} */
14692 + function urnuuidParse(urnComponent, options) {
14693 + const uuidComponent = urnComponent;
14694 + uuidComponent.uuid = uuidComponent.nss;
14695 + uuidComponent.nss = void 0;
14696 + if (!options.tolerant && (!uuidComponent.uuid || !isUUID(uuidComponent.uuid))) uuidComponent.error = uuidComponent.error || "UUID is not valid.";
14697 + return uuidComponent;
14698 + }
14699 + /** @type {SchemeFn} */
14700 + function urnuuidSerialize(uuidComponent) {
14701 + const urnComponent = uuidComponent;
14702 + urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
14703 + return urnComponent;
14704 + }
14705 + var http = {
14706 + scheme: "http",
14707 + domainHost: true,
14708 + parse: httpParse,
14709 + serialize: httpSerialize
14710 + };
14711 + var https = {
14712 + scheme: "https",
14713 + domainHost: http.domainHost,
14714 + parse: httpParse,
14715 + serialize: httpSerialize
14716 + };
14717 + var ws = {
14718 + scheme: "ws",
14719 + domainHost: true,
14720 + parse: wsParse,
14721 + serialize: wsSerialize
14722 + };
14723 + var SCHEMES = {
14724 + http,
14725 + https,
14726 + ws,
14727 + wss: {
14728 + scheme: "wss",
14729 + domainHost: ws.domainHost,
14730 + parse: ws.parse,
14731 + serialize: ws.serialize
14732 + },
14733 + urn: {
14734 + scheme: "urn",
14735 + parse: urnParse,
14736 + serialize: urnSerialize,
14737 + skipNormalize: true
14738 + },
14739 + "urn:uuid": {
14740 + scheme: "urn:uuid",
14741 + parse: urnuuidParse,
14742 + serialize: urnuuidSerialize,
14743 + skipNormalize: true
14744 + }
14745 + };
14746 + Object.setPrototypeOf(SCHEMES, null);
14747 + /**
14748 + * @param {string|undefined} scheme
14749 + * @returns {SchemeHandler|undefined}
14750 + */
14751 + function getSchemeHandler(scheme) {
14752 + return scheme && (SCHEMES[scheme] || SCHEMES[scheme.toLowerCase()]) || void 0;
14753 + }
14754 + module.exports = {
14755 + wsIsSecure,
14756 + SCHEMES,
14757 + isValidSchemeName,
14758 + getSchemeHandler
14759 + };
14760 + }));
14761 +
14762 +//#endregion
14763 +//#region node_modules/fast-uri/index.js
14764 + var require_fast_uri = /* @__PURE__ */ __commonJSMin(((exports, module) => {
14765 + var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = require_utils();
14766 + var { SCHEMES, getSchemeHandler } = require_schemes();
14767 + /**
14768 + * @template {import('./types/index').URIComponent|string} T
14769 + * @param {T} uri
14770 + * @param {import('./types/index').Options} [options]
14771 + * @returns {T}
14772 + */
14773 + function normalize(uri, options) {
14774 + if (typeof uri === "string") uri = serialize(parse(uri, options), options);
14775 + else if (typeof uri === "object") uri = parse(serialize(uri, options), options);
14776 + return uri;
14777 + }
14778 + /**
14779 + * @param {string} baseURI
14780 + * @param {string} relativeURI
14781 + * @param {import('./types/index').Options} [options]
14782 + * @returns {string}
14783 + */
14784 + function resolve(baseURI, relativeURI, options) {
14785 + const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
14786 + const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
14787 + schemelessOptions.skipEscape = true;
14788 + return serialize(resolved, schemelessOptions);
14789 + }
14790 + /**
14791 + * @param {import ('./types/index').URIComponent} base
14792 + * @param {import ('./types/index').URIComponent} relative
14793 + * @param {import('./types/index').Options} [options]
14794 + * @param {boolean} [skipNormalization=false]
14795 + * @returns {import ('./types/index').URIComponent}
14796 + */
14797 + function resolveComponent(base, relative, options, skipNormalization) {
14798 + /** @type {import('./types/index').URIComponent} */
14799 + const target = {};
14800 + if (!skipNormalization) {
14801 + base = parse(serialize(base, options), options);
14802 + relative = parse(serialize(relative, options), options);
14803 + }
14804 + options = options || {};
14805 + if (!options.tolerant && relative.scheme) {
14806 + target.scheme = relative.scheme;
14807 + target.userinfo = relative.userinfo;
14808 + target.host = relative.host;
14809 + target.port = relative.port;
14810 + target.path = removeDotSegments(relative.path || "");
14811 + target.query = relative.query;
14812 + } else {
14813 + if (relative.userinfo !== void 0 || relative.host !== void 0 || relative.port !== void 0) {
14814 + target.userinfo = relative.userinfo;
14815 + target.host = relative.host;
14816 + target.port = relative.port;
14817 + target.path = removeDotSegments(relative.path || "");
14818 + target.query = relative.query;
14819 + } else {
14820 + if (!relative.path) {
14821 + target.path = base.path;
14822 + if (relative.query !== void 0) target.query = relative.query;
14823 + else target.query = base.query;
14824 + } else {
14825 + if (relative.path[0] === "/") target.path = removeDotSegments(relative.path);
14826 + else {
14827 + if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) target.path = "/" + relative.path;
14828 + else if (!base.path) target.path = relative.path;
14829 + else target.path = base.path.slice(0, base.path.lastIndexOf("/") + 1) + relative.path;
14830 + target.path = removeDotSegments(target.path);
14831 + }
14832 + target.query = relative.query;
14833 + }
14834 + target.userinfo = base.userinfo;
14835 + target.host = base.host;
14836 + target.port = base.port;
14837 + }
14838 + target.scheme = base.scheme;
14839 + }
14840 + target.fragment = relative.fragment;
14841 + return target;
14842 + }
14843 + /**
14844 + * @param {import ('./types/index').URIComponent|string} uriA
14845 + * @param {import ('./types/index').URIComponent|string} uriB
14846 + * @param {import ('./types/index').Options} options
14847 + * @returns {boolean}
14848 + */
14849 + function equal(uriA, uriB, options) {
14850 + if (typeof uriA === "string") {
14851 + uriA = unescape(uriA);
14852 + uriA = serialize(normalizeComponentEncoding(parse(uriA, options), true), {
14853 + ...options,
14854 + skipEscape: true
14855 + });
14856 + } else if (typeof uriA === "object") uriA = serialize(normalizeComponentEncoding(uriA, true), {
14857 + ...options,
14858 + skipEscape: true
14859 + });
14860 + if (typeof uriB === "string") {
14861 + uriB = unescape(uriB);
14862 + uriB = serialize(normalizeComponentEncoding(parse(uriB, options), true), {
14863 + ...options,
14864 + skipEscape: true
14865 + });
14866 + } else if (typeof uriB === "object") uriB = serialize(normalizeComponentEncoding(uriB, true), {
14867 + ...options,
14868 + skipEscape: true
14869 + });
14870 + return uriA.toLowerCase() === uriB.toLowerCase();
14871 + }
14872 + /**
14873 + * @param {Readonly<import('./types/index').URIComponent>} cmpts
14874 + * @param {import('./types/index').Options} [opts]
14875 + * @returns {string}
14876 + */
14877 + function serialize(cmpts, opts) {
14878 + const component = {
14879 + host: cmpts.host,
14880 + scheme: cmpts.scheme,
14881 + userinfo: cmpts.userinfo,
14882 + port: cmpts.port,
14883 + path: cmpts.path,
14884 + query: cmpts.query,
14885 + nid: cmpts.nid,
14886 + nss: cmpts.nss,
14887 + uuid: cmpts.uuid,
14888 + fragment: cmpts.fragment,
14889 + reference: cmpts.reference,
14890 + resourceName: cmpts.resourceName,
14891 + secure: cmpts.secure,
14892 + error: ""
14893 + };
14894 + const options = Object.assign({}, opts);
14895 + const uriTokens = [];
14896 + const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
14897 + if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
14898 + if (component.path !== void 0) if (!options.skipEscape) {
14899 + component.path = escape(component.path);
14900 + if (component.scheme !== void 0) component.path = component.path.split("%3A").join(":");
14901 + } else component.path = unescape(component.path);
14902 + if (options.reference !== "suffix" && component.scheme) uriTokens.push(component.scheme, ":");
14903 + const authority = recomposeAuthority(component);
14904 + if (authority !== void 0) {
14905 + if (options.reference !== "suffix") uriTokens.push("//");
14906 + uriTokens.push(authority);
14907 + if (component.path && component.path[0] !== "/") uriTokens.push("/");
14908 + }
14909 + if (component.path !== void 0) {
14910 + let s = component.path;
14911 + if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) s = removeDotSegments(s);
14912 + if (authority === void 0 && s[0] === "/" && s[1] === "/") s = "/%2F" + s.slice(2);
14913 + uriTokens.push(s);
14914 + }
14915 + if (component.query !== void 0) uriTokens.push("?", component.query);
14916 + if (component.fragment !== void 0) uriTokens.push("#", component.fragment);
14917 + return uriTokens.join("");
14918 + }
14919 + var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
14920 + /**
14921 + * @param {string} uri
14922 + * @param {import('./types/index').Options} [opts]
14923 + * @returns
14924 + */
14925 + function parse(uri, opts) {
14926 + const options = Object.assign({}, opts);
14927 + /** @type {import('./types/index').URIComponent} */
14928 + const parsed = {
14929 + scheme: void 0,
14930 + userinfo: void 0,
14931 + host: "",
14932 + port: void 0,
14933 + path: "",
14934 + query: void 0,
14935 + fragment: void 0
14936 + };
14937 + let isIP = false;
14938 + if (options.reference === "suffix") if (options.scheme) uri = options.scheme + ":" + uri;
14939 + else uri = "//" + uri;
14940 + const matches = uri.match(URI_PARSE);
14941 + if (matches) {
14942 + parsed.scheme = matches[1];
14943 + parsed.userinfo = matches[3];
14944 + parsed.host = matches[4];
14945 + parsed.port = parseInt(matches[5], 10);
14946 + parsed.path = matches[6] || "";
14947 + parsed.query = matches[7];
14948 + parsed.fragment = matches[8];
14949 + if (isNaN(parsed.port)) parsed.port = matches[5];
14950 + if (parsed.host) if (isIPv4(parsed.host) === false) {
14951 + const ipv6result = normalizeIPv6(parsed.host);
14952 + parsed.host = ipv6result.host.toLowerCase();
14953 + isIP = ipv6result.isIPV6;
14954 + } else isIP = true;
14955 + if (parsed.scheme === void 0 && parsed.userinfo === void 0 && parsed.host === void 0 && parsed.port === void 0 && parsed.query === void 0 && !parsed.path) parsed.reference = "same-document";
14956 + else if (parsed.scheme === void 0) parsed.reference = "relative";
14957 + else if (parsed.fragment === void 0) parsed.reference = "absolute";
14958 + else parsed.reference = "uri";
14959 + if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
14960 + const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
14961 + if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
14962 + if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) try {
14963 + parsed.host = URL.domainToASCII(parsed.host.toLowerCase());
14964 + } catch (e) {
14965 + parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
14966 + }
14967 + }
14968 + if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
14969 + if (uri.indexOf("%") !== -1) {
14970 + if (parsed.scheme !== void 0) parsed.scheme = unescape(parsed.scheme);
14971 + if (parsed.host !== void 0) parsed.host = unescape(parsed.host);
14972 + }
14973 + if (parsed.path) parsed.path = escape(unescape(parsed.path));
14974 + if (parsed.fragment) parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
14975 + }
14976 + if (schemeHandler && schemeHandler.parse) schemeHandler.parse(parsed, options);
14977 + } else parsed.error = parsed.error || "URI can not be parsed.";
14978 + return parsed;
14979 + }
14980 + var fastUri = {
14981 + SCHEMES,
14982 + normalize,
14983 + resolve,
14984 + resolveComponent,
14985 + equal,
14986 + serialize,
14987 + parse
14988 + };
14989 + module.exports = fastUri;
14990 + module.exports.default = fastUri;
14991 + module.exports.fastUri = fastUri;
14992 + }));
14993 +
14994 +//#endregion
14995 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/runtime/uri.js
14996 + var require_uri = /* @__PURE__ */ __commonJSMin(((exports) => {
14997 + Object.defineProperty(exports, "__esModule", { value: true });
14998 + var uri = require_fast_uri();
14999 + uri.code = "require(\"ajv/dist/runtime/uri\").default";
15000 + exports.default = uri;
15001 + }));
15002 +
15003 +//#endregion
15004 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/core.js
15005 + var require_core$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
15006 + Object.defineProperty(exports, "__esModule", { value: true });
15007 + exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = void 0;
15008 + var validate_1 = require_validate();
15009 + Object.defineProperty(exports, "KeywordCxt", {
15010 + enumerable: true,
15011 + get: function() {
15012 + return validate_1.KeywordCxt;
15013 + }
15014 + });
15015 + var codegen_1 = require_codegen();
15016 + Object.defineProperty(exports, "_", {
15017 + enumerable: true,
15018 + get: function() {
15019 + return codegen_1._;
15020 + }
15021 + });
15022 + Object.defineProperty(exports, "str", {
15023 + enumerable: true,
15024 + get: function() {
15025 + return codegen_1.str;
15026 + }
15027 + });
15028 + Object.defineProperty(exports, "stringify", {
15029 + enumerable: true,
15030 + get: function() {
15031 + return codegen_1.stringify;
15032 + }
15033 + });
15034 + Object.defineProperty(exports, "nil", {
15035 + enumerable: true,
15036 + get: function() {
15037 + return codegen_1.nil;
15038 + }
15039 + });
15040 + Object.defineProperty(exports, "Name", {
15041 + enumerable: true,
15042 + get: function() {
15043 + return codegen_1.Name;
15044 + }
15045 + });
15046 + Object.defineProperty(exports, "CodeGen", {
15047 + enumerable: true,
15048 + get: function() {
15049 + return codegen_1.CodeGen;
15050 + }
15051 + });
15052 + var validation_error_1 = require_validation_error();
15053 + var ref_error_1 = require_ref_error();
15054 + var rules_1 = require_rules();
15055 + var compile_1 = require_compile();
15056 + var codegen_2 = require_codegen();
15057 + var resolve_1 = require_resolve();
15058 + var dataType_1 = require_dataType();
15059 + var util_1 = require_util();
15060 + var $dataRefSchema = (init_data(), __toCommonJS(data_exports).default);
15061 + var uri_1 = require_uri();
15062 + var defaultRegExp = (str, flags) => new RegExp(str, flags);
15063 + defaultRegExp.code = "new RegExp";
15064 + var META_IGNORE_OPTIONS = [
15065 + "removeAdditional",
15066 + "useDefaults",
15067 + "coerceTypes"
15068 + ];
15069 + var EXT_SCOPE_NAMES = /* @__PURE__ */ new Set([
15070 + "validate",
15071 + "serialize",
15072 + "parse",
15073 + "wrapper",
15074 + "root",
15075 + "schema",
15076 + "keyword",
15077 + "pattern",
15078 + "formats",
15079 + "validate$data",
15080 + "func",
15081 + "obj",
15082 + "Error"
15083 + ]);
15084 + var removedOptions = {
15085 + errorDataPath: "",
15086 + format: "`validateFormats: false` can be used instead.",
15087 + nullable: "\"nullable\" keyword is supported by default.",
15088 + jsonPointers: "Deprecated jsPropertySyntax can be used instead.",
15089 + extendRefs: "Deprecated ignoreKeywordsWithRef can be used instead.",
15090 + missingRefs: "Pass empty schema with $id that should be ignored to ajv.addSchema.",
15091 + processCode: "Use option `code: {process: (code, schemaEnv: object) => string}`",
15092 + sourceCode: "Use option `code: {source: true}`",
15093 + strictDefaults: "It is default now, see option `strict`.",
15094 + strictKeywords: "It is default now, see option `strict`.",
15095 + uniqueItems: "\"uniqueItems\" keyword is always validated.",
15096 + unknownFormats: "Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",
15097 + cache: "Map is used as cache, schema object as key.",
15098 + serialize: "Map is used as cache, schema object as key.",
15099 + ajvErrors: "It is default now."
15100 + };
15101 + var deprecatedOptions = {
15102 + ignoreKeywordsWithRef: "",
15103 + jsPropertySyntax: "",
15104 + unicode: "\"minLength\"/\"maxLength\" account for unicode characters by default."
15105 + };
15106 + var MAX_EXPRESSION = 200;
15107 + function requiredOptions(o) {
15108 + var _a;
15109 + var _b;
15110 + var _c;
15111 + var _d;
15112 + var _e;
15113 + var _f;
15114 + var _g;
15115 + var _h;
15116 + var _j;
15117 + var _k;
15118 + var _l;
15119 + var _m;
15120 + var _o;
15121 + var _p;
15122 + var _q;
15123 + var _r;
15124 + var _s;
15125 + var _t;
15126 + var _u;
15127 + var _v;
15128 + var _w;
15129 + var _x;
15130 + var _y;
15131 + var _z;
15132 + var _0;
15133 + const s = o.strict;
15134 + const _optz = (_a = o.code) === null || _a === void 0 ? void 0 : _a.optimize;
15135 + const optimize = _optz === true || _optz === void 0 ? 1 : _optz || 0;
15136 + const regExp = (_c = (_b = o.code) === null || _b === void 0 ? void 0 : _b.regExp) !== null && _c !== void 0 ? _c : defaultRegExp;
15137 + const uriResolver = (_d = o.uriResolver) !== null && _d !== void 0 ? _d : uri_1.default;
15138 + return {
15139 + strictSchema: (_f = (_e = o.strictSchema) !== null && _e !== void 0 ? _e : s) !== null && _f !== void 0 ? _f : true,
15140 + strictNumbers: (_h = (_g = o.strictNumbers) !== null && _g !== void 0 ? _g : s) !== null && _h !== void 0 ? _h : true,
15141 + strictTypes: (_k = (_j = o.strictTypes) !== null && _j !== void 0 ? _j : s) !== null && _k !== void 0 ? _k : "log",
15142 + strictTuples: (_m = (_l = o.strictTuples) !== null && _l !== void 0 ? _l : s) !== null && _m !== void 0 ? _m : "log",
15143 + strictRequired: (_p = (_o = o.strictRequired) !== null && _o !== void 0 ? _o : s) !== null && _p !== void 0 ? _p : false,
15144 + code: o.code ? {
15145 + ...o.code,
15146 + optimize,
15147 + regExp
15148 + } : {
15149 + optimize,
15150 + regExp
15151 + },
15152 + loopRequired: (_q = o.loopRequired) !== null && _q !== void 0 ? _q : MAX_EXPRESSION,
15153 + loopEnum: (_r = o.loopEnum) !== null && _r !== void 0 ? _r : MAX_EXPRESSION,
15154 + meta: (_s = o.meta) !== null && _s !== void 0 ? _s : true,
15155 + messages: (_t = o.messages) !== null && _t !== void 0 ? _t : true,
15156 + inlineRefs: (_u = o.inlineRefs) !== null && _u !== void 0 ? _u : true,
15157 + schemaId: (_v = o.schemaId) !== null && _v !== void 0 ? _v : "$id",
15158 + addUsedSchema: (_w = o.addUsedSchema) !== null && _w !== void 0 ? _w : true,
15159 + validateSchema: (_x = o.validateSchema) !== null && _x !== void 0 ? _x : true,
15160 + validateFormats: (_y = o.validateFormats) !== null && _y !== void 0 ? _y : true,
15161 + unicodeRegExp: (_z = o.unicodeRegExp) !== null && _z !== void 0 ? _z : true,
15162 + int32range: (_0 = o.int32range) !== null && _0 !== void 0 ? _0 : true,
15163 + uriResolver
15164 + };
15165 + }
15166 + var Ajv = class {
15167 + constructor(opts = {}) {
15168 + this.schemas = {};
15169 + this.refs = {};
15170 + this.formats = {};
15171 + this._compilations = /* @__PURE__ */ new Set();
15172 + this._loading = {};
15173 + this._cache = /* @__PURE__ */ new Map();
15174 + opts = this.opts = {
15175 + ...opts,
15176 + ...requiredOptions(opts)
15177 + };
15178 + const { es5, lines } = this.opts.code;
15179 + this.scope = new codegen_2.ValueScope({
15180 + scope: {},
15181 + prefixes: EXT_SCOPE_NAMES,
15182 + es5,
15183 + lines
15184 + });
15185 + this.logger = getLogger(opts.logger);
15186 + const formatOpt = opts.validateFormats;
15187 + opts.validateFormats = false;
15188 + this.RULES = (0, rules_1.getRules)();
15189 + checkOptions.call(this, removedOptions, opts, "NOT SUPPORTED");
15190 + checkOptions.call(this, deprecatedOptions, opts, "DEPRECATED", "warn");
15191 + this._metaOpts = getMetaSchemaOptions.call(this);
15192 + if (opts.formats) addInitialFormats.call(this);
15193 + this._addVocabularies();
15194 + this._addDefaultMetaSchema();
15195 + if (opts.keywords) addInitialKeywords.call(this, opts.keywords);
15196 + if (typeof opts.meta == "object") this.addMetaSchema(opts.meta);
15197 + addInitialSchemas.call(this);
15198 + opts.validateFormats = formatOpt;
15199 + }
15200 + _addVocabularies() {
15201 + this.addKeyword("$async");
15202 + }
15203 + _addDefaultMetaSchema() {
15204 + const { $data, meta, schemaId } = this.opts;
15205 + let _dataRefSchema = $dataRefSchema;
15206 + if (schemaId === "id") {
15207 + _dataRefSchema = { ...$dataRefSchema };
15208 + _dataRefSchema.id = _dataRefSchema.$id;
15209 + delete _dataRefSchema.$id;
15210 + }
15211 + if (meta && $data) this.addMetaSchema(_dataRefSchema, _dataRefSchema[schemaId], false);
15212 + }
15213 + defaultMeta() {
15214 + const { meta, schemaId } = this.opts;
15215 + return this.opts.defaultMeta = typeof meta == "object" ? meta[schemaId] || meta : void 0;
15216 + }
15217 + validate(schemaKeyRef, data) {
15218 + let v;
15219 + if (typeof schemaKeyRef == "string") {
15220 + v = this.getSchema(schemaKeyRef);
15221 + if (!v) throw new Error(`no schema with key or ref "${schemaKeyRef}"`);
15222 + } else v = this.compile(schemaKeyRef);
15223 + const valid = v(data);
15224 + if (!("$async" in v)) this.errors = v.errors;
15225 + return valid;
15226 + }
15227 + compile(schema, _meta) {
15228 + const sch = this._addSchema(schema, _meta);
15229 + return sch.validate || this._compileSchemaEnv(sch);
15230 + }
15231 + compileAsync(schema, meta) {
15232 + if (typeof this.opts.loadSchema != "function") throw new Error("options.loadSchema should be a function");
15233 + const { loadSchema } = this.opts;
15234 + return runCompileAsync.call(this, schema, meta);
15235 + async function runCompileAsync(_schema, _meta) {
15236 + await loadMetaSchema.call(this, _schema.$schema);
15237 + const sch = this._addSchema(_schema, _meta);
15238 + return sch.validate || _compileAsync.call(this, sch);
15239 + }
15240 + async function loadMetaSchema($ref) {
15241 + if ($ref && !this.getSchema($ref)) await runCompileAsync.call(this, { $ref }, true);
15242 + }
15243 + async function _compileAsync(sch) {
15244 + try {
15245 + return this._compileSchemaEnv(sch);
15246 + } catch (e) {
15247 + if (!(e instanceof ref_error_1.default)) throw e;
15248 + checkLoaded.call(this, e);
15249 + await loadMissingSchema.call(this, e.missingSchema);
15250 + return _compileAsync.call(this, sch);
15251 + }
15252 + }
15253 + function checkLoaded({ missingSchema: ref, missingRef }) {
15254 + if (this.refs[ref]) throw new Error(`AnySchema ${ref} is loaded but ${missingRef} cannot be resolved`);
15255 + }
15256 + async function loadMissingSchema(ref) {
15257 + const _schema = await _loadSchema.call(this, ref);
15258 + if (!this.refs[ref]) await loadMetaSchema.call(this, _schema.$schema);
15259 + if (!this.refs[ref]) this.addSchema(_schema, ref, meta);
15260 + }
15261 + async function _loadSchema(ref) {
15262 + const p = this._loading[ref];
15263 + if (p) return p;
15264 + try {
15265 + return await (this._loading[ref] = loadSchema(ref));
15266 + } finally {
15267 + delete this._loading[ref];
15268 + }
15269 + }
15270 + }
15271 + addSchema(schema, key, _meta, _validateSchema = this.opts.validateSchema) {
15272 + if (Array.isArray(schema)) {
15273 + for (const sch of schema) this.addSchema(sch, void 0, _meta, _validateSchema);
15274 + return this;
15275 + }
15276 + let id;
15277 + if (typeof schema === "object") {
15278 + const { schemaId } = this.opts;
15279 + id = schema[schemaId];
15280 + if (id !== void 0 && typeof id != "string") throw new Error(`schema ${schemaId} must be string`);
15281 + }
15282 + key = (0, resolve_1.normalizeId)(key || id);
15283 + this._checkUnique(key);
15284 + this.schemas[key] = this._addSchema(schema, _meta, key, _validateSchema, true);
15285 + return this;
15286 + }
15287 + addMetaSchema(schema, key, _validateSchema = this.opts.validateSchema) {
15288 + this.addSchema(schema, key, true, _validateSchema);
15289 + return this;
15290 + }
15291 + validateSchema(schema, throwOrLogError) {
15292 + if (typeof schema == "boolean") return true;
15293 + let $schema;
15294 + $schema = schema.$schema;
15295 + if ($schema !== void 0 && typeof $schema != "string") throw new Error("$schema must be a string");
15296 + $schema = $schema || this.opts.defaultMeta || this.defaultMeta();
15297 + if (!$schema) {
15298 + this.logger.warn("meta-schema not available");
15299 + this.errors = null;
15300 + return true;
15301 + }
15302 + const valid = this.validate($schema, schema);
15303 + if (!valid && throwOrLogError) {
15304 + const message = "schema is invalid: " + this.errorsText();
15305 + if (this.opts.validateSchema === "log") this.logger.error(message);
15306 + else throw new Error(message);
15307 + }
15308 + return valid;
15309 + }
15310 + getSchema(keyRef) {
15311 + let sch;
15312 + while (typeof (sch = getSchEnv.call(this, keyRef)) == "string") keyRef = sch;
15313 + if (sch === void 0) {
15314 + const { schemaId } = this.opts;
15315 + const root = new compile_1.SchemaEnv({
15316 + schema: {},
15317 + schemaId
15318 + });
15319 + sch = compile_1.resolveSchema.call(this, root, keyRef);
15320 + if (!sch) return;
15321 + this.refs[keyRef] = sch;
15322 + }
15323 + return sch.validate || this._compileSchemaEnv(sch);
15324 + }
15325 + removeSchema(schemaKeyRef) {
15326 + if (schemaKeyRef instanceof RegExp) {
15327 + this._removeAllSchemas(this.schemas, schemaKeyRef);
15328 + this._removeAllSchemas(this.refs, schemaKeyRef);
15329 + return this;
15330 + }
15331 + switch (typeof schemaKeyRef) {
15332 + case "undefined":
15333 + this._removeAllSchemas(this.schemas);
15334 + this._removeAllSchemas(this.refs);
15335 + this._cache.clear();
15336 + return this;
15337 + case "string": {
15338 + const sch = getSchEnv.call(this, schemaKeyRef);
15339 + if (typeof sch == "object") this._cache.delete(sch.schema);
15340 + delete this.schemas[schemaKeyRef];
15341 + delete this.refs[schemaKeyRef];
15342 + return this;
15343 + }
15344 + case "object": {
15345 + const cacheKey = schemaKeyRef;
15346 + this._cache.delete(cacheKey);
15347 + let id = schemaKeyRef[this.opts.schemaId];
15348 + if (id) {
15349 + id = (0, resolve_1.normalizeId)(id);
15350 + delete this.schemas[id];
15351 + delete this.refs[id];
15352 + }
15353 + return this;
15354 + }
15355 + default: throw new Error("ajv.removeSchema: invalid parameter");
15356 + }
15357 + }
15358 + addVocabulary(definitions) {
15359 + for (const def of definitions) this.addKeyword(def);
15360 + return this;
15361 + }
15362 + addKeyword(kwdOrDef, def) {
15363 + let keyword;
15364 + if (typeof kwdOrDef == "string") {
15365 + keyword = kwdOrDef;
15366 + if (typeof def == "object") {
15367 + this.logger.warn("these parameters are deprecated, see docs for addKeyword");
15368 + def.keyword = keyword;
15369 + }
15370 + } else if (typeof kwdOrDef == "object" && def === void 0) {
15371 + def = kwdOrDef;
15372 + keyword = def.keyword;
15373 + if (Array.isArray(keyword) && !keyword.length) throw new Error("addKeywords: keyword must be string or non-empty array");
15374 + } else throw new Error("invalid addKeywords parameters");
15375 + checkKeyword.call(this, keyword, def);
15376 + if (!def) {
15377 + (0, util_1.eachItem)(keyword, (kwd) => addRule.call(this, kwd));
15378 + return this;
15379 + }
15380 + keywordMetaschema.call(this, def);
15381 + const definition = {
15382 + ...def,
15383 + type: (0, dataType_1.getJSONTypes)(def.type),
15384 + schemaType: (0, dataType_1.getJSONTypes)(def.schemaType)
15385 + };
15386 + (0, util_1.eachItem)(keyword, definition.type.length === 0 ? (k) => addRule.call(this, k, definition) : (k) => definition.type.forEach((t) => addRule.call(this, k, definition, t)));
15387 + return this;
15388 + }
15389 + getKeyword(keyword) {
15390 + const rule = this.RULES.all[keyword];
15391 + return typeof rule == "object" ? rule.definition : !!rule;
15392 + }
15393 + removeKeyword(keyword) {
15394 + const { RULES } = this;
15395 + delete RULES.keywords[keyword];
15396 + delete RULES.all[keyword];
15397 + for (const group of RULES.rules) {
15398 + const i = group.rules.findIndex((rule) => rule.keyword === keyword);
15399 + if (i >= 0) group.rules.splice(i, 1);
15400 + }
15401 + return this;
15402 + }
15403 + addFormat(name, format) {
15404 + if (typeof format == "string") format = new RegExp(format);
15405 + this.formats[name] = format;
15406 + return this;
15407 + }
15408 + errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
15409 + if (!errors || errors.length === 0) return "No errors";
15410 + return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text, msg) => text + separator + msg);
15411 + }
15412 + $dataMetaSchema(metaSchema, keywordsJsonPointers) {
15413 + const rules = this.RULES.all;
15414 + metaSchema = JSON.parse(JSON.stringify(metaSchema));
15415 + for (const jsonPointer of keywordsJsonPointers) {
15416 + const segments = jsonPointer.split("/").slice(1);
15417 + let keywords = metaSchema;
15418 + for (const seg of segments) keywords = keywords[seg];
15419 + for (const key in rules) {
15420 + const rule = rules[key];
15421 + if (typeof rule != "object") continue;
15422 + const { $data } = rule.definition;
15423 + const schema = keywords[key];
15424 + if ($data && schema) keywords[key] = schemaOrData(schema);
15425 + }
15426 + }
15427 + return metaSchema;
15428 + }
15429 + _removeAllSchemas(schemas, regex) {
15430 + for (const keyRef in schemas) {
15431 + const sch = schemas[keyRef];
15432 + if (!regex || regex.test(keyRef)) {
15433 + if (typeof sch == "string") delete schemas[keyRef];
15434 + else if (sch && !sch.meta) {
15435 + this._cache.delete(sch.schema);
15436 + delete schemas[keyRef];
15437 + }
15438 + }
15439 + }
15440 + }
15441 + _addSchema(schema, meta, baseId, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) {
15442 + let id;
15443 + const { schemaId } = this.opts;
15444 + if (typeof schema == "object") id = schema[schemaId];
15445 + else if (this.opts.jtd) throw new Error("schema must be object");
15446 + else if (typeof schema != "boolean") throw new Error("schema must be object or boolean");
15447 + let sch = this._cache.get(schema);
15448 + if (sch !== void 0) return sch;
15449 + baseId = (0, resolve_1.normalizeId)(id || baseId);
15450 + const localRefs = resolve_1.getSchemaRefs.call(this, schema, baseId);
15451 + sch = new compile_1.SchemaEnv({
15452 + schema,
15453 + schemaId,
15454 + meta,
15455 + baseId,
15456 + localRefs
15457 + });
15458 + this._cache.set(sch.schema, sch);
15459 + if (addSchema && !baseId.startsWith("#")) {
15460 + if (baseId) this._checkUnique(baseId);
15461 + this.refs[baseId] = sch;
15462 + }
15463 + if (validateSchema) this.validateSchema(schema, true);
15464 + return sch;
15465 + }
15466 + _checkUnique(id) {
15467 + if (this.schemas[id] || this.refs[id]) throw new Error(`schema with key or id "${id}" already exists`);
15468 + }
15469 + _compileSchemaEnv(sch) {
15470 + if (sch.meta) this._compileMetaSchema(sch);
15471 + else compile_1.compileSchema.call(this, sch);
15472 + /* istanbul ignore if */
15473 + if (!sch.validate) throw new Error("ajv implementation error");
15474 + return sch.validate;
15475 + }
15476 + _compileMetaSchema(sch) {
15477 + const currentOpts = this.opts;
15478 + this.opts = this._metaOpts;
15479 + try {
15480 + compile_1.compileSchema.call(this, sch);
15481 + } finally {
15482 + this.opts = currentOpts;
15483 + }
15484 + }
15485 + };
15486 + Ajv.ValidationError = validation_error_1.default;
15487 + Ajv.MissingRefError = ref_error_1.default;
15488 + exports.default = Ajv;
15489 + function checkOptions(checkOpts, options, msg, log = "error") {
15490 + for (const key in checkOpts) {
15491 + const opt = key;
15492 + if (opt in options) this.logger[log](`${msg}: option ${key}. ${checkOpts[opt]}`);
15493 + }
15494 + }
15495 + function getSchEnv(keyRef) {
15496 + keyRef = (0, resolve_1.normalizeId)(keyRef);
15497 + return this.schemas[keyRef] || this.refs[keyRef];
15498 + }
15499 + function addInitialSchemas() {
15500 + const optsSchemas = this.opts.schemas;
15501 + if (!optsSchemas) return;
15502 + if (Array.isArray(optsSchemas)) this.addSchema(optsSchemas);
15503 + else for (const key in optsSchemas) this.addSchema(optsSchemas[key], key);
15504 + }
15505 + function addInitialFormats() {
15506 + for (const name in this.opts.formats) {
15507 + const format = this.opts.formats[name];
15508 + if (format) this.addFormat(name, format);
15509 + }
15510 + }
15511 + function addInitialKeywords(defs) {
15512 + if (Array.isArray(defs)) {
15513 + this.addVocabulary(defs);
15514 + return;
15515 + }
15516 + this.logger.warn("keywords option as map is deprecated, pass array");
15517 + for (const keyword in defs) {
15518 + const def = defs[keyword];
15519 + if (!def.keyword) def.keyword = keyword;
15520 + this.addKeyword(def);
15521 + }
15522 + }
15523 + function getMetaSchemaOptions() {
15524 + const metaOpts = { ...this.opts };
15525 + for (const opt of META_IGNORE_OPTIONS) delete metaOpts[opt];
15526 + return metaOpts;
15527 + }
15528 + var noLogs = {
15529 + log() {},
15530 + warn() {},
15531 + error() {}
15532 + };
15533 + function getLogger(logger) {
15534 + if (logger === false) return noLogs;
15535 + if (logger === void 0) return console;
15536 + if (logger.log && logger.warn && logger.error) return logger;
15537 + throw new Error("logger must implement log, warn and error methods");
15538 + }
15539 + var KEYWORD_NAME = /^[a-z_$][a-z0-9_$:-]*$/i;
15540 + function checkKeyword(keyword, def) {
15541 + const { RULES } = this;
15542 + (0, util_1.eachItem)(keyword, (kwd) => {
15543 + if (RULES.keywords[kwd]) throw new Error(`Keyword ${kwd} is already defined`);
15544 + if (!KEYWORD_NAME.test(kwd)) throw new Error(`Keyword ${kwd} has invalid name`);
15545 + });
15546 + if (!def) return;
15547 + if (def.$data && !("code" in def || "validate" in def)) throw new Error("$data keyword must have \"code\" or \"validate\" function");
15548 + }
15549 + function addRule(keyword, definition, dataType) {
15550 + var _a;
15551 + const post = definition === null || definition === void 0 ? void 0 : definition.post;
15552 + if (dataType && post) throw new Error("keyword with \"post\" flag cannot have \"type\"");
15553 + const { RULES } = this;
15554 + let ruleGroup = post ? RULES.post : RULES.rules.find(({ type: t }) => t === dataType);
15555 + if (!ruleGroup) {
15556 + ruleGroup = {
15557 + type: dataType,
15558 + rules: []
15559 + };
15560 + RULES.rules.push(ruleGroup);
15561 + }
15562 + RULES.keywords[keyword] = true;
15563 + if (!definition) return;
15564 + const rule = {
15565 + keyword,
15566 + definition: {
15567 + ...definition,
15568 + type: (0, dataType_1.getJSONTypes)(definition.type),
15569 + schemaType: (0, dataType_1.getJSONTypes)(definition.schemaType)
15570 + }
15571 + };
15572 + if (definition.before) addBeforeRule.call(this, ruleGroup, rule, definition.before);
15573 + else ruleGroup.rules.push(rule);
15574 + RULES.all[keyword] = rule;
15575 + (_a = definition.implements) === null || _a === void 0 || _a.forEach((kwd) => this.addKeyword(kwd));
15576 + }
15577 + function addBeforeRule(ruleGroup, rule, before) {
15578 + const i = ruleGroup.rules.findIndex((_rule) => _rule.keyword === before);
15579 + if (i >= 0) ruleGroup.rules.splice(i, 0, rule);
15580 + else {
15581 + ruleGroup.rules.push(rule);
15582 + this.logger.warn(`rule ${before} is not defined`);
15583 + }
15584 + }
15585 + function keywordMetaschema(def) {
15586 + let { metaSchema } = def;
15587 + if (metaSchema === void 0) return;
15588 + if (def.$data && this.opts.$data) metaSchema = schemaOrData(metaSchema);
15589 + def.validateSchema = this.compile(metaSchema, true);
15590 + }
15591 + var $dataRef = { $ref: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#" };
15592 + function schemaOrData(schema) {
15593 + return { anyOf: [schema, $dataRef] };
15594 + }
15595 + }));
15596 +
15597 +//#endregion
15598 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/core/id.js
15599 + var require_id = /* @__PURE__ */ __commonJSMin(((exports) => {
15600 + Object.defineProperty(exports, "__esModule", { value: true });
15601 + var def = {
15602 + keyword: "id",
15603 + code() {
15604 + throw new Error("NOT SUPPORTED: keyword \"id\", use \"$id\" for schema ID");
15605 + }
15606 + };
15607 + exports.default = def;
15608 + }));
15609 +
15610 +//#endregion
15611 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/core/ref.js
15612 + var require_ref = /* @__PURE__ */ __commonJSMin(((exports) => {
15613 + Object.defineProperty(exports, "__esModule", { value: true });
15614 + exports.callRef = exports.getValidate = void 0;
15615 + var ref_error_1 = require_ref_error();
15616 + var code_1 = require_code();
15617 + var codegen_1 = require_codegen();
15618 + var names_1 = require_names();
15619 + var compile_1 = require_compile();
15620 + var util_1 = require_util();
15621 + var def = {
15622 + keyword: "$ref",
15623 + schemaType: "string",
15624 + code(cxt) {
15625 + const { gen, schema: $ref, it } = cxt;
15626 + const { baseId, schemaEnv: env, validateName, opts, self } = it;
15627 + const { root } = env;
15628 + if (($ref === "#" || $ref === "#/") && baseId === root.baseId) return callRootRef();
15629 + const schOrEnv = compile_1.resolveRef.call(self, root, baseId, $ref);
15630 + if (schOrEnv === void 0) throw new ref_error_1.default(it.opts.uriResolver, baseId, $ref);
15631 + if (schOrEnv instanceof compile_1.SchemaEnv) return callValidate(schOrEnv);
15632 + return inlineRefSchema(schOrEnv);
15633 + function callRootRef() {
15634 + if (env === root) return callRef(cxt, validateName, env, env.$async);
15635 + const rootName = gen.scopeValue("root", { ref: root });
15636 + return callRef(cxt, (0, codegen_1._)`${rootName}.validate`, root, root.$async);
15637 + }
15638 + function callValidate(sch) {
15639 + callRef(cxt, getValidate(cxt, sch), sch, sch.$async);
15640 + }
15641 + function inlineRefSchema(sch) {
15642 + const schName = gen.scopeValue("schema", opts.code.source === true ? {
15643 + ref: sch,
15644 + code: (0, codegen_1.stringify)(sch)
15645 + } : { ref: sch });
15646 + const valid = gen.name("valid");
15647 + const schCxt = cxt.subschema({
15648 + schema: sch,
15649 + dataTypes: [],
15650 + schemaPath: codegen_1.nil,
15651 + topSchemaRef: schName,
15652 + errSchemaPath: $ref
15653 + }, valid);
15654 + cxt.mergeEvaluated(schCxt);
15655 + cxt.ok(valid);
15656 + }
15657 + }
15658 + };
15659 + function getValidate(cxt, sch) {
15660 + const { gen } = cxt;
15661 + return sch.validate ? gen.scopeValue("validate", { ref: sch.validate }) : (0, codegen_1._)`${gen.scopeValue("wrapper", { ref: sch })}.validate`;
15662 + }
15663 + exports.getValidate = getValidate;
15664 + function callRef(cxt, v, sch, $async) {
15665 + const { gen, it } = cxt;
15666 + const { allErrors, schemaEnv: env, opts } = it;
15667 + const passCxt = opts.passContext ? names_1.default.this : codegen_1.nil;
15668 + if ($async) callAsyncRef();
15669 + else callSyncRef();
15670 + function callAsyncRef() {
15671 + if (!env.$async) throw new Error("async schema referenced by sync schema");
15672 + const valid = gen.let("valid");
15673 + gen.try(() => {
15674 + gen.code((0, codegen_1._)`await ${(0, code_1.callValidateCode)(cxt, v, passCxt)}`);
15675 + addEvaluatedFrom(v);
15676 + if (!allErrors) gen.assign(valid, true);
15677 + }, (e) => {
15678 + gen.if((0, codegen_1._)`!(${e} instanceof ${it.ValidationError})`, () => gen.throw(e));
15679 + addErrorsFrom(e);
15680 + if (!allErrors) gen.assign(valid, false);
15681 + });
15682 + cxt.ok(valid);
15683 + }
15684 + function callSyncRef() {
15685 + cxt.result((0, code_1.callValidateCode)(cxt, v, passCxt), () => addEvaluatedFrom(v), () => addErrorsFrom(v));
15686 + }
15687 + function addErrorsFrom(source) {
15688 + const errs = (0, codegen_1._)`${source}.errors`;
15689 + gen.assign(names_1.default.vErrors, (0, codegen_1._)`${names_1.default.vErrors} === null ? ${errs} : ${names_1.default.vErrors}.concat(${errs})`);
15690 + gen.assign(names_1.default.errors, (0, codegen_1._)`${names_1.default.vErrors}.length`);
15691 + }
15692 + function addEvaluatedFrom(source) {
15693 + var _a;
15694 + if (!it.opts.unevaluated) return;
15695 + const schEvaluated = (_a = sch === null || sch === void 0 ? void 0 : sch.validate) === null || _a === void 0 ? void 0 : _a.evaluated;
15696 + if (it.props !== true) if (schEvaluated && !schEvaluated.dynamicProps) {
15697 + if (schEvaluated.props !== void 0) it.props = util_1.mergeEvaluated.props(gen, schEvaluated.props, it.props);
15698 + } else {
15699 + const props = gen.var("props", (0, codegen_1._)`${source}.evaluated.props`);
15700 + it.props = util_1.mergeEvaluated.props(gen, props, it.props, codegen_1.Name);
15701 + }
15702 + if (it.items !== true) if (schEvaluated && !schEvaluated.dynamicItems) {
15703 + if (schEvaluated.items !== void 0) it.items = util_1.mergeEvaluated.items(gen, schEvaluated.items, it.items);
15704 + } else {
15705 + const items = gen.var("items", (0, codegen_1._)`${source}.evaluated.items`);
15706 + it.items = util_1.mergeEvaluated.items(gen, items, it.items, codegen_1.Name);
15707 + }
15708 + }
15709 + }
15710 + exports.callRef = callRef;
15711 + exports.default = def;
15712 + }));
15713 +
15714 +//#endregion
15715 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/core/index.js
15716 + var require_core = /* @__PURE__ */ __commonJSMin(((exports) => {
15717 + Object.defineProperty(exports, "__esModule", { value: true });
15718 + var id_1 = require_id();
15719 + var ref_1 = require_ref();
15720 + var core = [
15721 + "$schema",
15722 + "$id",
15723 + "$defs",
15724 + "$vocabulary",
15725 + { keyword: "$comment" },
15726 + "definitions",
15727 + id_1.default,
15728 + ref_1.default
15729 + ];
15730 + exports.default = core;
15731 + }));
15732 +
15733 +//#endregion
15734 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/limitNumber.js
15735 + var require_limitNumber = /* @__PURE__ */ __commonJSMin(((exports) => {
15736 + Object.defineProperty(exports, "__esModule", { value: true });
15737 + var codegen_1 = require_codegen();
15738 + var ops = codegen_1.operators;
15739 + var KWDs = {
15740 + maximum: {
15741 + okStr: "<=",
15742 + ok: ops.LTE,
15743 + fail: ops.GT
15744 + },
15745 + minimum: {
15746 + okStr: ">=",
15747 + ok: ops.GTE,
15748 + fail: ops.LT
15749 + },
15750 + exclusiveMaximum: {
15751 + okStr: "<",
15752 + ok: ops.LT,
15753 + fail: ops.GTE
15754 + },
15755 + exclusiveMinimum: {
15756 + okStr: ">",
15757 + ok: ops.GT,
15758 + fail: ops.LTE
15759 + }
15760 + };
15761 + var def = {
15762 + keyword: Object.keys(KWDs),
15763 + type: "number",
15764 + schemaType: "number",
15765 + $data: true,
15766 + error: {
15767 + message: ({ keyword, schemaCode }) => (0, codegen_1.str)`must be ${KWDs[keyword].okStr} ${schemaCode}`,
15768 + params: ({ keyword, schemaCode }) => (0, codegen_1._)`{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`
15769 + },
15770 + code(cxt) {
15771 + const { keyword, data, schemaCode } = cxt;
15772 + cxt.fail$data((0, codegen_1._)`${data} ${KWDs[keyword].fail} ${schemaCode} || isNaN(${data})`);
15773 + }
15774 + };
15775 + exports.default = def;
15776 + }));
15777 +
15778 +//#endregion
15779 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/multipleOf.js
15780 + var require_multipleOf = /* @__PURE__ */ __commonJSMin(((exports) => {
15781 + Object.defineProperty(exports, "__esModule", { value: true });
15782 + var codegen_1 = require_codegen();
15783 + var def = {
15784 + keyword: "multipleOf",
15785 + type: "number",
15786 + schemaType: "number",
15787 + $data: true,
15788 + error: {
15789 + message: ({ schemaCode }) => (0, codegen_1.str)`must be multiple of ${schemaCode}`,
15790 + params: ({ schemaCode }) => (0, codegen_1._)`{multipleOf: ${schemaCode}}`
15791 + },
15792 + code(cxt) {
15793 + const { gen, data, schemaCode, it } = cxt;
15794 + const prec = it.opts.multipleOfPrecision;
15795 + const res = gen.let("res");
15796 + const invalid = prec ? (0, codegen_1._)`Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}` : (0, codegen_1._)`${res} !== parseInt(${res})`;
15797 + cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid}))`);
15798 + }
15799 + };
15800 + exports.default = def;
15801 + }));
15802 +
15803 +//#endregion
15804 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/runtime/ucs2length.js
15805 + var require_ucs2length = /* @__PURE__ */ __commonJSMin(((exports) => {
15806 + Object.defineProperty(exports, "__esModule", { value: true });
15807 + function ucs2length(str) {
15808 + const len = str.length;
15809 + let length = 0;
15810 + let pos = 0;
15811 + let value;
15812 + while (pos < len) {
15813 + length++;
15814 + value = str.charCodeAt(pos++);
15815 + if (value >= 55296 && value <= 56319 && pos < len) {
15816 + value = str.charCodeAt(pos);
15817 + if ((value & 64512) === 56320) pos++;
15818 + }
15819 + }
15820 + return length;
15821 + }
15822 + exports.default = ucs2length;
15823 + ucs2length.code = "require(\"ajv/dist/runtime/ucs2length\").default";
15824 + }));
15825 +
15826 +//#endregion
15827 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/limitLength.js
15828 + var require_limitLength = /* @__PURE__ */ __commonJSMin(((exports) => {
15829 + Object.defineProperty(exports, "__esModule", { value: true });
15830 + var codegen_1 = require_codegen();
15831 + var util_1 = require_util();
15832 + var ucs2length_1 = require_ucs2length();
15833 + var def = {
15834 + keyword: ["maxLength", "minLength"],
15835 + type: "string",
15836 + schemaType: "number",
15837 + $data: true,
15838 + error: {
15839 + message({ keyword, schemaCode }) {
15840 + const comp = keyword === "maxLength" ? "more" : "fewer";
15841 + return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} characters`;
15842 + },
15843 + params: ({ schemaCode }) => (0, codegen_1._)`{limit: ${schemaCode}}`
15844 + },
15845 + code(cxt) {
15846 + const { keyword, data, schemaCode, it } = cxt;
15847 + const op = keyword === "maxLength" ? codegen_1.operators.GT : codegen_1.operators.LT;
15848 + const len = it.opts.unicode === false ? (0, codegen_1._)`${data}.length` : (0, codegen_1._)`${(0, util_1.useFunc)(cxt.gen, ucs2length_1.default)}(${data})`;
15849 + cxt.fail$data((0, codegen_1._)`${len} ${op} ${schemaCode}`);
15850 + }
15851 + };
15852 + exports.default = def;
15853 + }));
15854 +
15855 +//#endregion
15856 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/pattern.js
15857 + var require_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
15858 + Object.defineProperty(exports, "__esModule", { value: true });
15859 + var code_1 = require_code();
15860 + var util_1 = require_util();
15861 + var codegen_1 = require_codegen();
15862 + var def = {
15863 + keyword: "pattern",
15864 + type: "string",
15865 + schemaType: "string",
15866 + $data: true,
15867 + error: {
15868 + message: ({ schemaCode }) => (0, codegen_1.str)`must match pattern "${schemaCode}"`,
15869 + params: ({ schemaCode }) => (0, codegen_1._)`{pattern: ${schemaCode}}`
15870 + },
15871 + code(cxt) {
15872 + const { gen, data, $data, schema, schemaCode, it } = cxt;
15873 + const u = it.opts.unicodeRegExp ? "u" : "";
15874 + if ($data) {
15875 + const { regExp } = it.opts.code;
15876 + const regExpCode = regExp.code === "new RegExp" ? (0, codegen_1._)`new RegExp` : (0, util_1.useFunc)(gen, regExp);
15877 + const valid = gen.let("valid");
15878 + gen.try(() => gen.assign(valid, (0, codegen_1._)`${regExpCode}(${schemaCode}, ${u}).test(${data})`), () => gen.assign(valid, false));
15879 + cxt.fail$data((0, codegen_1._)`!${valid}`);
15880 + } else {
15881 + const regExp = (0, code_1.usePattern)(cxt, schema);
15882 + cxt.fail$data((0, codegen_1._)`!${regExp}.test(${data})`);
15883 + }
15884 + }
15885 + };
15886 + exports.default = def;
15887 + }));
15888 +
15889 +//#endregion
15890 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/limitProperties.js
15891 + var require_limitProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
15892 + Object.defineProperty(exports, "__esModule", { value: true });
15893 + var codegen_1 = require_codegen();
15894 + var def = {
15895 + keyword: ["maxProperties", "minProperties"],
15896 + type: "object",
15897 + schemaType: "number",
15898 + $data: true,
15899 + error: {
15900 + message({ keyword, schemaCode }) {
15901 + const comp = keyword === "maxProperties" ? "more" : "fewer";
15902 + return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} properties`;
15903 + },
15904 + params: ({ schemaCode }) => (0, codegen_1._)`{limit: ${schemaCode}}`
15905 + },
15906 + code(cxt) {
15907 + const { keyword, data, schemaCode } = cxt;
15908 + const op = keyword === "maxProperties" ? codegen_1.operators.GT : codegen_1.operators.LT;
15909 + cxt.fail$data((0, codegen_1._)`Object.keys(${data}).length ${op} ${schemaCode}`);
15910 + }
15911 + };
15912 + exports.default = def;
15913 + }));
15914 +
15915 +//#endregion
15916 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/required.js
15917 + var require_required = /* @__PURE__ */ __commonJSMin(((exports) => {
15918 + Object.defineProperty(exports, "__esModule", { value: true });
15919 + var code_1 = require_code();
15920 + var codegen_1 = require_codegen();
15921 + var util_1 = require_util();
15922 + var def = {
15923 + keyword: "required",
15924 + type: "object",
15925 + schemaType: "array",
15926 + $data: true,
15927 + error: {
15928 + message: ({ params: { missingProperty } }) => (0, codegen_1.str)`must have required property '${missingProperty}'`,
15929 + params: ({ params: { missingProperty } }) => (0, codegen_1._)`{missingProperty: ${missingProperty}}`
15930 + },
15931 + code(cxt) {
15932 + const { gen, schema, schemaCode, data, $data, it } = cxt;
15933 + const { opts } = it;
15934 + if (!$data && schema.length === 0) return;
15935 + const useLoop = schema.length >= opts.loopRequired;
15936 + if (it.allErrors) allErrorsMode();
15937 + else exitOnErrorMode();
15938 + if (opts.strictRequired) {
15939 + const props = cxt.parentSchema.properties;
15940 + const { definedProperties } = cxt.it;
15941 + for (const requiredKey of schema) if ((props === null || props === void 0 ? void 0 : props[requiredKey]) === void 0 && !definedProperties.has(requiredKey)) {
15942 + const msg = `required property "${requiredKey}" is not defined at "${it.schemaEnv.baseId + it.errSchemaPath}" (strictRequired)`;
15943 + (0, util_1.checkStrictMode)(it, msg, it.opts.strictRequired);
15944 + }
15945 + }
15946 + function allErrorsMode() {
15947 + if (useLoop || $data) cxt.block$data(codegen_1.nil, loopAllRequired);
15948 + else for (const prop of schema) (0, code_1.checkReportMissingProp)(cxt, prop);
15949 + }
15950 + function exitOnErrorMode() {
15951 + const missing = gen.let("missing");
15952 + if (useLoop || $data) {
15953 + const valid = gen.let("valid", true);
15954 + cxt.block$data(valid, () => loopUntilMissing(missing, valid));
15955 + cxt.ok(valid);
15956 + } else {
15957 + gen.if((0, code_1.checkMissingProp)(cxt, schema, missing));
15958 + (0, code_1.reportMissingProp)(cxt, missing);
15959 + gen.else();
15960 + }
15961 + }
15962 + function loopAllRequired() {
15963 + gen.forOf("prop", schemaCode, (prop) => {
15964 + cxt.setParams({ missingProperty: prop });
15965 + gen.if((0, code_1.noPropertyInData)(gen, data, prop, opts.ownProperties), () => cxt.error());
15966 + });
15967 + }
15968 + function loopUntilMissing(missing, valid) {
15969 + cxt.setParams({ missingProperty: missing });
15970 + gen.forOf(missing, schemaCode, () => {
15971 + gen.assign(valid, (0, code_1.propertyInData)(gen, data, missing, opts.ownProperties));
15972 + gen.if((0, codegen_1.not)(valid), () => {
15973 + cxt.error();
15974 + gen.break();
15975 + });
15976 + }, codegen_1.nil);
15977 + }
15978 + }
15979 + };
15980 + exports.default = def;
15981 + }));
15982 +
15983 +//#endregion
15984 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/limitItems.js
15985 + var require_limitItems = /* @__PURE__ */ __commonJSMin(((exports) => {
15986 + Object.defineProperty(exports, "__esModule", { value: true });
15987 + var codegen_1 = require_codegen();
15988 + var def = {
15989 + keyword: ["maxItems", "minItems"],
15990 + type: "array",
15991 + schemaType: "number",
15992 + $data: true,
15993 + error: {
15994 + message({ keyword, schemaCode }) {
15995 + const comp = keyword === "maxItems" ? "more" : "fewer";
15996 + return (0, codegen_1.str)`must NOT have ${comp} than ${schemaCode} items`;
15997 + },
15998 + params: ({ schemaCode }) => (0, codegen_1._)`{limit: ${schemaCode}}`
15999 + },
16000 + code(cxt) {
16001 + const { keyword, data, schemaCode } = cxt;
16002 + const op = keyword === "maxItems" ? codegen_1.operators.GT : codegen_1.operators.LT;
16003 + cxt.fail$data((0, codegen_1._)`${data}.length ${op} ${schemaCode}`);
16004 + }
16005 + };
16006 + exports.default = def;
16007 + }));
16008 +
16009 +//#endregion
16010 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/runtime/equal.js
16011 + var require_equal = /* @__PURE__ */ __commonJSMin(((exports) => {
16012 + Object.defineProperty(exports, "__esModule", { value: true });
16013 + var equal = require_fast_deep_equal();
16014 + equal.code = "require(\"ajv/dist/runtime/equal\").default";
16015 + exports.default = equal;
16016 + }));
16017 +
16018 +//#endregion
16019 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js
16020 + var require_uniqueItems = /* @__PURE__ */ __commonJSMin(((exports) => {
16021 + Object.defineProperty(exports, "__esModule", { value: true });
16022 + var dataType_1 = require_dataType();
16023 + var codegen_1 = require_codegen();
16024 + var util_1 = require_util();
16025 + var equal_1 = require_equal();
16026 + var def = {
16027 + keyword: "uniqueItems",
16028 + type: "array",
16029 + schemaType: "boolean",
16030 + $data: true,
16031 + error: {
16032 + message: ({ params: { i, j } }) => (0, codegen_1.str)`must NOT have duplicate items (items ## ${j} and ${i} are identical)`,
16033 + params: ({ params: { i, j } }) => (0, codegen_1._)`{i: ${i}, j: ${j}}`
16034 + },
16035 + code(cxt) {
16036 + const { gen, data, $data, schema, parentSchema, schemaCode, it } = cxt;
16037 + if (!$data && !schema) return;
16038 + const valid = gen.let("valid");
16039 + const itemTypes = parentSchema.items ? (0, dataType_1.getSchemaTypes)(parentSchema.items) : [];
16040 + cxt.block$data(valid, validateUniqueItems, (0, codegen_1._)`${schemaCode} === false`);
16041 + cxt.ok(valid);
16042 + function validateUniqueItems() {
16043 + const i = gen.let("i", (0, codegen_1._)`${data}.length`);
16044 + const j = gen.let("j");
16045 + cxt.setParams({
16046 + i,
16047 + j
16048 + });
16049 + gen.assign(valid, true);
16050 + gen.if((0, codegen_1._)`${i} > 1`, () => (canOptimize() ? loopN : loopN2)(i, j));
16051 + }
16052 + function canOptimize() {
16053 + return itemTypes.length > 0 && !itemTypes.some((t) => t === "object" || t === "array");
16054 + }
16055 + function loopN(i, j) {
16056 + const item = gen.name("item");
16057 + const wrongType = (0, dataType_1.checkDataTypes)(itemTypes, item, it.opts.strictNumbers, dataType_1.DataType.Wrong);
16058 + const indices = gen.const("indices", (0, codegen_1._)`{}`);
16059 + gen.for((0, codegen_1._)`;${i}--;`, () => {
16060 + gen.let(item, (0, codegen_1._)`${data}[${i}]`);
16061 + gen.if(wrongType, (0, codegen_1._)`continue`);
16062 + if (itemTypes.length > 1) gen.if((0, codegen_1._)`typeof ${item} == "string"`, (0, codegen_1._)`${item} += "_"`);
16063 + gen.if((0, codegen_1._)`typeof ${indices}[${item}] == "number"`, () => {
16064 + gen.assign(j, (0, codegen_1._)`${indices}[${item}]`);
16065 + cxt.error();
16066 + gen.assign(valid, false).break();
16067 + }).code((0, codegen_1._)`${indices}[${item}] = ${i}`);
16068 + });
16069 + }
16070 + function loopN2(i, j) {
16071 + const eql = (0, util_1.useFunc)(gen, equal_1.default);
16072 + const outer = gen.name("outer");
16073 + gen.label(outer).for((0, codegen_1._)`;${i}--;`, () => gen.for((0, codegen_1._)`${j} = ${i}; ${j}--;`, () => gen.if((0, codegen_1._)`${eql}(${data}[${i}], ${data}[${j}])`, () => {
16074 + cxt.error();
16075 + gen.assign(valid, false).break(outer);
16076 + })));
16077 + }
16078 + }
16079 + };
16080 + exports.default = def;
16081 + }));
16082 +
16083 +//#endregion
16084 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/const.js
16085 + var require_const = /* @__PURE__ */ __commonJSMin(((exports) => {
16086 + Object.defineProperty(exports, "__esModule", { value: true });
16087 + var codegen_1 = require_codegen();
16088 + var util_1 = require_util();
16089 + var equal_1 = require_equal();
16090 + var def = {
16091 + keyword: "const",
16092 + $data: true,
16093 + error: {
16094 + message: "must be equal to constant",
16095 + params: ({ schemaCode }) => (0, codegen_1._)`{allowedValue: ${schemaCode}}`
16096 + },
16097 + code(cxt) {
16098 + const { gen, data, $data, schemaCode, schema } = cxt;
16099 + if ($data || schema && typeof schema == "object") cxt.fail$data((0, codegen_1._)`!${(0, util_1.useFunc)(gen, equal_1.default)}(${data}, ${schemaCode})`);
16100 + else cxt.fail((0, codegen_1._)`${schema} !== ${data}`);
16101 + }
16102 + };
16103 + exports.default = def;
16104 + }));
16105 +
16106 +//#endregion
16107 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/enum.js
16108 + var require_enum = /* @__PURE__ */ __commonJSMin(((exports) => {
16109 + Object.defineProperty(exports, "__esModule", { value: true });
16110 + var codegen_1 = require_codegen();
16111 + var util_1 = require_util();
16112 + var equal_1 = require_equal();
16113 + var def = {
16114 + keyword: "enum",
16115 + schemaType: "array",
16116 + $data: true,
16117 + error: {
16118 + message: "must be equal to one of the allowed values",
16119 + params: ({ schemaCode }) => (0, codegen_1._)`{allowedValues: ${schemaCode}}`
16120 + },
16121 + code(cxt) {
16122 + const { gen, data, $data, schema, schemaCode, it } = cxt;
16123 + if (!$data && schema.length === 0) throw new Error("enum must have non-empty array");
16124 + const useLoop = schema.length >= it.opts.loopEnum;
16125 + let eql;
16126 + const getEql = () => eql !== null && eql !== void 0 ? eql : eql = (0, util_1.useFunc)(gen, equal_1.default);
16127 + let valid;
16128 + if (useLoop || $data) {
16129 + valid = gen.let("valid");
16130 + cxt.block$data(valid, loopEnum);
16131 + } else {
16132 + /* istanbul ignore if */
16133 + if (!Array.isArray(schema)) throw new Error("ajv implementation error");
16134 + const vSchema = gen.const("vSchema", schemaCode);
16135 + valid = (0, codegen_1.or)(...schema.map((_x, i) => equalCode(vSchema, i)));
16136 + }
16137 + cxt.pass(valid);
16138 + function loopEnum() {
16139 + gen.assign(valid, false);
16140 + gen.forOf("v", schemaCode, (v) => gen.if((0, codegen_1._)`${getEql()}(${data}, ${v})`, () => gen.assign(valid, true).break()));
16141 + }
16142 + function equalCode(vSchema, i) {
16143 + const sch = schema[i];
16144 + return typeof sch === "object" && sch !== null ? (0, codegen_1._)`${getEql()}(${data}, ${vSchema}[${i}])` : (0, codegen_1._)`${data} === ${sch}`;
16145 + }
16146 + }
16147 + };
16148 + exports.default = def;
16149 + }));
16150 +
16151 +//#endregion
16152 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/validation/index.js
16153 + var require_validation = /* @__PURE__ */ __commonJSMin(((exports) => {
16154 + Object.defineProperty(exports, "__esModule", { value: true });
16155 + var limitNumber_1 = require_limitNumber();
16156 + var multipleOf_1 = require_multipleOf();
16157 + var limitLength_1 = require_limitLength();
16158 + var pattern_1 = require_pattern();
16159 + var limitProperties_1 = require_limitProperties();
16160 + var required_1 = require_required();
16161 + var limitItems_1 = require_limitItems();
16162 + var uniqueItems_1 = require_uniqueItems();
16163 + var const_1 = require_const();
16164 + var enum_1 = require_enum();
16165 + var validation = [
16166 + limitNumber_1.default,
16167 + multipleOf_1.default,
16168 + limitLength_1.default,
16169 + pattern_1.default,
16170 + limitProperties_1.default,
16171 + required_1.default,
16172 + limitItems_1.default,
16173 + uniqueItems_1.default,
16174 + {
16175 + keyword: "type",
16176 + schemaType: ["string", "array"]
16177 + },
16178 + {
16179 + keyword: "nullable",
16180 + schemaType: "boolean"
16181 + },
16182 + const_1.default,
16183 + enum_1.default
16184 + ];
16185 + exports.default = validation;
16186 + }));
16187 +
16188 +//#endregion
16189 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js
16190 + var require_additionalItems = /* @__PURE__ */ __commonJSMin(((exports) => {
16191 + Object.defineProperty(exports, "__esModule", { value: true });
16192 + exports.validateAdditionalItems = void 0;
16193 + var codegen_1 = require_codegen();
16194 + var util_1 = require_util();
16195 + var def = {
16196 + keyword: "additionalItems",
16197 + type: "array",
16198 + schemaType: ["boolean", "object"],
16199 + before: "uniqueItems",
16200 + error: {
16201 + message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`,
16202 + params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}`
16203 + },
16204 + code(cxt) {
16205 + const { parentSchema, it } = cxt;
16206 + const { items } = parentSchema;
16207 + if (!Array.isArray(items)) {
16208 + (0, util_1.checkStrictMode)(it, "\"additionalItems\" is ignored when \"items\" is not an array of schemas");
16209 + return;
16210 + }
16211 + validateAdditionalItems(cxt, items);
16212 + }
16213 + };
16214 + function validateAdditionalItems(cxt, items) {
16215 + const { gen, schema, data, keyword, it } = cxt;
16216 + it.items = true;
16217 + const len = gen.const("len", (0, codegen_1._)`${data}.length`);
16218 + if (schema === false) {
16219 + cxt.setParams({ len: items.length });
16220 + cxt.pass((0, codegen_1._)`${len} <= ${items.length}`);
16221 + } else if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
16222 + const valid = gen.var("valid", (0, codegen_1._)`${len} <= ${items.length}`);
16223 + gen.if((0, codegen_1.not)(valid), () => validateItems(valid));
16224 + cxt.ok(valid);
16225 + }
16226 + function validateItems(valid) {
16227 + gen.forRange("i", items.length, len, (i) => {
16228 + cxt.subschema({
16229 + keyword,
16230 + dataProp: i,
16231 + dataPropType: util_1.Type.Num
16232 + }, valid);
16233 + if (!it.allErrors) gen.if((0, codegen_1.not)(valid), () => gen.break());
16234 + });
16235 + }
16236 + }
16237 + exports.validateAdditionalItems = validateAdditionalItems;
16238 + exports.default = def;
16239 + }));
16240 +
16241 +//#endregion
16242 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/items.js
16243 + var require_items = /* @__PURE__ */ __commonJSMin(((exports) => {
16244 + Object.defineProperty(exports, "__esModule", { value: true });
16245 + exports.validateTuple = void 0;
16246 + var codegen_1 = require_codegen();
16247 + var util_1 = require_util();
16248 + var code_1 = require_code();
16249 + var def = {
16250 + keyword: "items",
16251 + type: "array",
16252 + schemaType: [
16253 + "object",
16254 + "array",
16255 + "boolean"
16256 + ],
16257 + before: "uniqueItems",
16258 + code(cxt) {
16259 + const { schema, it } = cxt;
16260 + if (Array.isArray(schema)) return validateTuple(cxt, "additionalItems", schema);
16261 + it.items = true;
16262 + if ((0, util_1.alwaysValidSchema)(it, schema)) return;
16263 + cxt.ok((0, code_1.validateArray)(cxt));
16264 + }
16265 + };
16266 + function validateTuple(cxt, extraItems, schArr = cxt.schema) {
16267 + const { gen, parentSchema, data, keyword, it } = cxt;
16268 + checkStrictTuple(parentSchema);
16269 + if (it.opts.unevaluated && schArr.length && it.items !== true) it.items = util_1.mergeEvaluated.items(gen, schArr.length, it.items);
16270 + const valid = gen.name("valid");
16271 + const len = gen.const("len", (0, codegen_1._)`${data}.length`);
16272 + schArr.forEach((sch, i) => {
16273 + if ((0, util_1.alwaysValidSchema)(it, sch)) return;
16274 + gen.if((0, codegen_1._)`${len} > ${i}`, () => cxt.subschema({
16275 + keyword,
16276 + schemaProp: i,
16277 + dataProp: i
16278 + }, valid));
16279 + cxt.ok(valid);
16280 + });
16281 + function checkStrictTuple(sch) {
16282 + const { opts, errSchemaPath } = it;
16283 + const l = schArr.length;
16284 + const fullTuple = l === sch.minItems && (l === sch.maxItems || sch[extraItems] === false);
16285 + if (opts.strictTuples && !fullTuple) {
16286 + const msg = `"${keyword}" is ${l}-tuple, but minItems or maxItems/${extraItems} are not specified or different at path "${errSchemaPath}"`;
16287 + (0, util_1.checkStrictMode)(it, msg, opts.strictTuples);
16288 + }
16289 + }
16290 + }
16291 + exports.validateTuple = validateTuple;
16292 + exports.default = def;
16293 + }));
16294 +
16295 +//#endregion
16296 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js
16297 + var require_prefixItems = /* @__PURE__ */ __commonJSMin(((exports) => {
16298 + Object.defineProperty(exports, "__esModule", { value: true });
16299 + var items_1 = require_items();
16300 + var def = {
16301 + keyword: "prefixItems",
16302 + type: "array",
16303 + schemaType: ["array"],
16304 + before: "uniqueItems",
16305 + code: (cxt) => (0, items_1.validateTuple)(cxt, "items")
16306 + };
16307 + exports.default = def;
16308 + }));
16309 +
16310 +//#endregion
16311 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/items2020.js
16312 + var require_items2020 = /* @__PURE__ */ __commonJSMin(((exports) => {
16313 + Object.defineProperty(exports, "__esModule", { value: true });
16314 + var codegen_1 = require_codegen();
16315 + var util_1 = require_util();
16316 + var code_1 = require_code();
16317 + var additionalItems_1 = require_additionalItems();
16318 + var def = {
16319 + keyword: "items",
16320 + type: "array",
16321 + schemaType: ["object", "boolean"],
16322 + before: "uniqueItems",
16323 + error: {
16324 + message: ({ params: { len } }) => (0, codegen_1.str)`must NOT have more than ${len} items`,
16325 + params: ({ params: { len } }) => (0, codegen_1._)`{limit: ${len}}`
16326 + },
16327 + code(cxt) {
16328 + const { schema, parentSchema, it } = cxt;
16329 + const { prefixItems } = parentSchema;
16330 + it.items = true;
16331 + if ((0, util_1.alwaysValidSchema)(it, schema)) return;
16332 + if (prefixItems) (0, additionalItems_1.validateAdditionalItems)(cxt, prefixItems);
16333 + else cxt.ok((0, code_1.validateArray)(cxt));
16334 + }
16335 + };
16336 + exports.default = def;
16337 + }));
16338 +
16339 +//#endregion
16340 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/contains.js
16341 + var require_contains = /* @__PURE__ */ __commonJSMin(((exports) => {
16342 + Object.defineProperty(exports, "__esModule", { value: true });
16343 + var codegen_1 = require_codegen();
16344 + var util_1 = require_util();
16345 + var def = {
16346 + keyword: "contains",
16347 + type: "array",
16348 + schemaType: ["object", "boolean"],
16349 + before: "uniqueItems",
16350 + trackErrors: true,
16351 + error: {
16352 + message: ({ params: { min, max } }) => max === void 0 ? (0, codegen_1.str)`must contain at least ${min} valid item(s)` : (0, codegen_1.str)`must contain at least ${min} and no more than ${max} valid item(s)`,
16353 + params: ({ params: { min, max } }) => max === void 0 ? (0, codegen_1._)`{minContains: ${min}}` : (0, codegen_1._)`{minContains: ${min}, maxContains: ${max}}`
16354 + },
16355 + code(cxt) {
16356 + const { gen, schema, parentSchema, data, it } = cxt;
16357 + let min;
16358 + let max;
16359 + const { minContains, maxContains } = parentSchema;
16360 + if (it.opts.next) {
16361 + min = minContains === void 0 ? 1 : minContains;
16362 + max = maxContains;
16363 + } else min = 1;
16364 + const len = gen.const("len", (0, codegen_1._)`${data}.length`);
16365 + cxt.setParams({
16366 + min,
16367 + max
16368 + });
16369 + if (max === void 0 && min === 0) {
16370 + (0, util_1.checkStrictMode)(it, `"minContains" == 0 without "maxContains": "contains" keyword ignored`);
16371 + return;
16372 + }
16373 + if (max !== void 0 && min > max) {
16374 + (0, util_1.checkStrictMode)(it, `"minContains" > "maxContains" is always invalid`);
16375 + cxt.fail();
16376 + return;
16377 + }
16378 + if ((0, util_1.alwaysValidSchema)(it, schema)) {
16379 + let cond = (0, codegen_1._)`${len} >= ${min}`;
16380 + if (max !== void 0) cond = (0, codegen_1._)`${cond} && ${len} <= ${max}`;
16381 + cxt.pass(cond);
16382 + return;
16383 + }
16384 + it.items = true;
16385 + const valid = gen.name("valid");
16386 + if (max === void 0 && min === 1) validateItems(valid, () => gen.if(valid, () => gen.break()));
16387 + else if (min === 0) {
16388 + gen.let(valid, true);
16389 + if (max !== void 0) gen.if((0, codegen_1._)`${data}.length > 0`, validateItemsWithCount);
16390 + } else {
16391 + gen.let(valid, false);
16392 + validateItemsWithCount();
16393 + }
16394 + cxt.result(valid, () => cxt.reset());
16395 + function validateItemsWithCount() {
16396 + const schValid = gen.name("_valid");
16397 + const count = gen.let("count", 0);
16398 + validateItems(schValid, () => gen.if(schValid, () => checkLimits(count)));
16399 + }
16400 + function validateItems(_valid, block) {
16401 + gen.forRange("i", 0, len, (i) => {
16402 + cxt.subschema({
16403 + keyword: "contains",
16404 + dataProp: i,
16405 + dataPropType: util_1.Type.Num,
16406 + compositeRule: true
16407 + }, _valid);
16408 + block();
16409 + });
16410 + }
16411 + function checkLimits(count) {
16412 + gen.code((0, codegen_1._)`${count}++`);
16413 + if (max === void 0) gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(valid, true).break());
16414 + else {
16415 + gen.if((0, codegen_1._)`${count} > ${max}`, () => gen.assign(valid, false).break());
16416 + if (min === 1) gen.assign(valid, true);
16417 + else gen.if((0, codegen_1._)`${count} >= ${min}`, () => gen.assign(valid, true));
16418 + }
16419 + }
16420 + }
16421 + };
16422 + exports.default = def;
16423 + }));
16424 +
16425 +//#endregion
16426 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/dependencies.js
16427 + var require_dependencies = /* @__PURE__ */ __commonJSMin(((exports) => {
16428 + Object.defineProperty(exports, "__esModule", { value: true });
16429 + exports.validateSchemaDeps = exports.validatePropertyDeps = exports.error = void 0;
16430 + var codegen_1 = require_codegen();
16431 + var util_1 = require_util();
16432 + var code_1 = require_code();
16433 + exports.error = {
16434 + message: ({ params: { property, depsCount, deps } }) => {
16435 + const property_ies = depsCount === 1 ? "property" : "properties";
16436 + return (0, codegen_1.str)`must have ${property_ies} ${deps} when property ${property} is present`;
16437 + },
16438 + params: ({ params: { property, depsCount, deps, missingProperty } }) => (0, codegen_1._)`{property: ${property},
16439 + missingProperty: ${missingProperty},
16440 + depsCount: ${depsCount},
16441 + deps: ${deps}}`
16442 + };
16443 + var def = {
16444 + keyword: "dependencies",
16445 + type: "object",
16446 + schemaType: "object",
16447 + error: exports.error,
16448 + code(cxt) {
16449 + const [propDeps, schDeps] = splitDependencies(cxt);
16450 + validatePropertyDeps(cxt, propDeps);
16451 + validateSchemaDeps(cxt, schDeps);
16452 + }
16453 + };
16454 + function splitDependencies({ schema }) {
16455 + const propertyDeps = {};
16456 + const schemaDeps = {};
16457 + for (const key in schema) {
16458 + if (key === "__proto__") continue;
16459 + const deps = Array.isArray(schema[key]) ? propertyDeps : schemaDeps;
16460 + deps[key] = schema[key];
16461 + }
16462 + return [propertyDeps, schemaDeps];
16463 + }
16464 + function validatePropertyDeps(cxt, propertyDeps = cxt.schema) {
16465 + const { gen, data, it } = cxt;
16466 + if (Object.keys(propertyDeps).length === 0) return;
16467 + const missing = gen.let("missing");
16468 + for (const prop in propertyDeps) {
16469 + const deps = propertyDeps[prop];
16470 + if (deps.length === 0) continue;
16471 + const hasProperty = (0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties);
16472 + cxt.setParams({
16473 + property: prop,
16474 + depsCount: deps.length,
16475 + deps: deps.join(", ")
16476 + });
16477 + if (it.allErrors) gen.if(hasProperty, () => {
16478 + for (const depProp of deps) (0, code_1.checkReportMissingProp)(cxt, depProp);
16479 + });
16480 + else {
16481 + gen.if((0, codegen_1._)`${hasProperty} && (${(0, code_1.checkMissingProp)(cxt, deps, missing)})`);
16482 + (0, code_1.reportMissingProp)(cxt, missing);
16483 + gen.else();
16484 + }
16485 + }
16486 + }
16487 + exports.validatePropertyDeps = validatePropertyDeps;
16488 + function validateSchemaDeps(cxt, schemaDeps = cxt.schema) {
16489 + const { gen, data, keyword, it } = cxt;
16490 + const valid = gen.name("valid");
16491 + for (const prop in schemaDeps) {
16492 + if ((0, util_1.alwaysValidSchema)(it, schemaDeps[prop])) continue;
16493 + gen.if((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties), () => {
16494 + const schCxt = cxt.subschema({
16495 + keyword,
16496 + schemaProp: prop
16497 + }, valid);
16498 + cxt.mergeValidEvaluated(schCxt, valid);
16499 + }, () => gen.var(valid, true));
16500 + cxt.ok(valid);
16501 + }
16502 + }
16503 + exports.validateSchemaDeps = validateSchemaDeps;
16504 + exports.default = def;
16505 + }));
16506 +
16507 +//#endregion
16508 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js
16509 + var require_propertyNames = /* @__PURE__ */ __commonJSMin(((exports) => {
16510 + Object.defineProperty(exports, "__esModule", { value: true });
16511 + var codegen_1 = require_codegen();
16512 + var util_1 = require_util();
16513 + var def = {
16514 + keyword: "propertyNames",
16515 + type: "object",
16516 + schemaType: ["object", "boolean"],
16517 + error: {
16518 + message: "property name must be valid",
16519 + params: ({ params }) => (0, codegen_1._)`{propertyName: ${params.propertyName}}`
16520 + },
16521 + code(cxt) {
16522 + const { gen, schema, data, it } = cxt;
16523 + if ((0, util_1.alwaysValidSchema)(it, schema)) return;
16524 + const valid = gen.name("valid");
16525 + gen.forIn("key", data, (key) => {
16526 + cxt.setParams({ propertyName: key });
16527 + cxt.subschema({
16528 + keyword: "propertyNames",
16529 + data: key,
16530 + dataTypes: ["string"],
16531 + propertyName: key,
16532 + compositeRule: true
16533 + }, valid);
16534 + gen.if((0, codegen_1.not)(valid), () => {
16535 + cxt.error(true);
16536 + if (!it.allErrors) gen.break();
16537 + });
16538 + });
16539 + cxt.ok(valid);
16540 + }
16541 + };
16542 + exports.default = def;
16543 + }));
16544 +
16545 +//#endregion
16546 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js
16547 + var require_additionalProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
16548 + Object.defineProperty(exports, "__esModule", { value: true });
16549 + var code_1 = require_code();
16550 + var codegen_1 = require_codegen();
16551 + var names_1 = require_names();
16552 + var util_1 = require_util();
16553 + var def = {
16554 + keyword: "additionalProperties",
16555 + type: ["object"],
16556 + schemaType: ["boolean", "object"],
16557 + allowUndefined: true,
16558 + trackErrors: true,
16559 + error: {
16560 + message: "must NOT have additional properties",
16561 + params: ({ params }) => (0, codegen_1._)`{additionalProperty: ${params.additionalProperty}}`
16562 + },
16563 + code(cxt) {
16564 + const { gen, schema, parentSchema, data, errsCount, it } = cxt;
16565 + /* istanbul ignore if */
16566 + if (!errsCount) throw new Error("ajv implementation error");
16567 + const { allErrors, opts } = it;
16568 + it.props = true;
16569 + if (opts.removeAdditional !== "all" && (0, util_1.alwaysValidSchema)(it, schema)) return;
16570 + const props = (0, code_1.allSchemaProperties)(parentSchema.properties);
16571 + const patProps = (0, code_1.allSchemaProperties)(parentSchema.patternProperties);
16572 + checkAdditionalProperties();
16573 + cxt.ok((0, codegen_1._)`${errsCount} === ${names_1.default.errors}`);
16574 + function checkAdditionalProperties() {
16575 + gen.forIn("key", data, (key) => {
16576 + if (!props.length && !patProps.length) additionalPropertyCode(key);
16577 + else gen.if(isAdditional(key), () => additionalPropertyCode(key));
16578 + });
16579 + }
16580 + function isAdditional(key) {
16581 + let definedProp;
16582 + if (props.length > 8) {
16583 + const propsSchema = (0, util_1.schemaRefOrVal)(it, parentSchema.properties, "properties");
16584 + definedProp = (0, code_1.isOwnProperty)(gen, propsSchema, key);
16585 + } else if (props.length) definedProp = (0, codegen_1.or)(...props.map((p) => (0, codegen_1._)`${key} === ${p}`));
16586 + else definedProp = codegen_1.nil;
16587 + if (patProps.length) definedProp = (0, codegen_1.or)(definedProp, ...patProps.map((p) => (0, codegen_1._)`${(0, code_1.usePattern)(cxt, p)}.test(${key})`));
16588 + return (0, codegen_1.not)(definedProp);
16589 + }
16590 + function deleteAdditional(key) {
16591 + gen.code((0, codegen_1._)`delete ${data}[${key}]`);
16592 + }
16593 + function additionalPropertyCode(key) {
16594 + if (opts.removeAdditional === "all" || opts.removeAdditional && schema === false) {
16595 + deleteAdditional(key);
16596 + return;
16597 + }
16598 + if (schema === false) {
16599 + cxt.setParams({ additionalProperty: key });
16600 + cxt.error();
16601 + if (!allErrors) gen.break();
16602 + return;
16603 + }
16604 + if (typeof schema == "object" && !(0, util_1.alwaysValidSchema)(it, schema)) {
16605 + const valid = gen.name("valid");
16606 + if (opts.removeAdditional === "failing") {
16607 + applyAdditionalSchema(key, valid, false);
16608 + gen.if((0, codegen_1.not)(valid), () => {
16609 + cxt.reset();
16610 + deleteAdditional(key);
16611 + });
16612 + } else {
16613 + applyAdditionalSchema(key, valid);
16614 + if (!allErrors) gen.if((0, codegen_1.not)(valid), () => gen.break());
16615 + }
16616 + }
16617 + }
16618 + function applyAdditionalSchema(key, valid, errors) {
16619 + const subschema = {
16620 + keyword: "additionalProperties",
16621 + dataProp: key,
16622 + dataPropType: util_1.Type.Str
16623 + };
16624 + if (errors === false) Object.assign(subschema, {
16625 + compositeRule: true,
16626 + createErrors: false,
16627 + allErrors: false
16628 + });
16629 + cxt.subschema(subschema, valid);
16630 + }
16631 + }
16632 + };
16633 + exports.default = def;
16634 + }));
16635 +
16636 +//#endregion
16637 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/properties.js
16638 + var require_properties = /* @__PURE__ */ __commonJSMin(((exports) => {
16639 + Object.defineProperty(exports, "__esModule", { value: true });
16640 + var validate_1 = require_validate();
16641 + var code_1 = require_code();
16642 + var util_1 = require_util();
16643 + var additionalProperties_1 = require_additionalProperties();
16644 + var def = {
16645 + keyword: "properties",
16646 + type: "object",
16647 + schemaType: "object",
16648 + code(cxt) {
16649 + const { gen, schema, parentSchema, data, it } = cxt;
16650 + if (it.opts.removeAdditional === "all" && parentSchema.additionalProperties === void 0) additionalProperties_1.default.code(new validate_1.KeywordCxt(it, additionalProperties_1.default, "additionalProperties"));
16651 + const allProps = (0, code_1.allSchemaProperties)(schema);
16652 + for (const prop of allProps) it.definedProperties.add(prop);
16653 + if (it.opts.unevaluated && allProps.length && it.props !== true) it.props = util_1.mergeEvaluated.props(gen, (0, util_1.toHash)(allProps), it.props);
16654 + const properties = allProps.filter((p) => !(0, util_1.alwaysValidSchema)(it, schema[p]));
16655 + if (properties.length === 0) return;
16656 + const valid = gen.name("valid");
16657 + for (const prop of properties) {
16658 + if (hasDefault(prop)) applyPropertySchema(prop);
16659 + else {
16660 + gen.if((0, code_1.propertyInData)(gen, data, prop, it.opts.ownProperties));
16661 + applyPropertySchema(prop);
16662 + if (!it.allErrors) gen.else().var(valid, true);
16663 + gen.endIf();
16664 + }
16665 + cxt.it.definedProperties.add(prop);
16666 + cxt.ok(valid);
16667 + }
16668 + function hasDefault(prop) {
16669 + return it.opts.useDefaults && !it.compositeRule && schema[prop].default !== void 0;
16670 + }
16671 + function applyPropertySchema(prop) {
16672 + cxt.subschema({
16673 + keyword: "properties",
16674 + schemaProp: prop,
16675 + dataProp: prop
16676 + }, valid);
16677 + }
16678 + }
16679 + };
16680 + exports.default = def;
16681 + }));
16682 +
16683 +//#endregion
16684 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js
16685 + var require_patternProperties = /* @__PURE__ */ __commonJSMin(((exports) => {
16686 + Object.defineProperty(exports, "__esModule", { value: true });
16687 + var code_1 = require_code();
16688 + var codegen_1 = require_codegen();
16689 + var util_1 = require_util();
16690 + var util_2 = require_util();
16691 + var def = {
16692 + keyword: "patternProperties",
16693 + type: "object",
16694 + schemaType: "object",
16695 + code(cxt) {
16696 + const { gen, schema, data, parentSchema, it } = cxt;
16697 + const { opts } = it;
16698 + const patterns = (0, code_1.allSchemaProperties)(schema);
16699 + const alwaysValidPatterns = patterns.filter((p) => (0, util_1.alwaysValidSchema)(it, schema[p]));
16700 + if (patterns.length === 0 || alwaysValidPatterns.length === patterns.length && (!it.opts.unevaluated || it.props === true)) return;
16701 + const checkProperties = opts.strictSchema && !opts.allowMatchingProperties && parentSchema.properties;
16702 + const valid = gen.name("valid");
16703 + if (it.props !== true && !(it.props instanceof codegen_1.Name)) it.props = (0, util_2.evaluatedPropsToName)(gen, it.props);
16704 + const { props } = it;
16705 + validatePatternProperties();
16706 + function validatePatternProperties() {
16707 + for (const pat of patterns) {
16708 + if (checkProperties) checkMatchingProperties(pat);
16709 + if (it.allErrors) validateProperties(pat);
16710 + else {
16711 + gen.var(valid, true);
16712 + validateProperties(pat);
16713 + gen.if(valid);
16714 + }
16715 + }
16716 + }
16717 + function checkMatchingProperties(pat) {
16718 + for (const prop in checkProperties) if (new RegExp(pat).test(prop)) (0, util_1.checkStrictMode)(it, `property ${prop} matches pattern ${pat} (use allowMatchingProperties)`);
16719 + }
16720 + function validateProperties(pat) {
16721 + gen.forIn("key", data, (key) => {
16722 + gen.if((0, codegen_1._)`${(0, code_1.usePattern)(cxt, pat)}.test(${key})`, () => {
16723 + const alwaysValid = alwaysValidPatterns.includes(pat);
16724 + if (!alwaysValid) cxt.subschema({
16725 + keyword: "patternProperties",
16726 + schemaProp: pat,
16727 + dataProp: key,
16728 + dataPropType: util_2.Type.Str
16729 + }, valid);
16730 + if (it.opts.unevaluated && props !== true) gen.assign((0, codegen_1._)`${props}[${key}]`, true);
16731 + else if (!alwaysValid && !it.allErrors) gen.if((0, codegen_1.not)(valid), () => gen.break());
16732 + });
16733 + });
16734 + }
16735 + }
16736 + };
16737 + exports.default = def;
16738 + }));
16739 +
16740 +//#endregion
16741 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/not.js
16742 + var require_not = /* @__PURE__ */ __commonJSMin(((exports) => {
16743 + Object.defineProperty(exports, "__esModule", { value: true });
16744 + var util_1 = require_util();
16745 + var def = {
16746 + keyword: "not",
16747 + schemaType: ["object", "boolean"],
16748 + trackErrors: true,
16749 + code(cxt) {
16750 + const { gen, schema, it } = cxt;
16751 + if ((0, util_1.alwaysValidSchema)(it, schema)) {
16752 + cxt.fail();
16753 + return;
16754 + }
16755 + const valid = gen.name("valid");
16756 + cxt.subschema({
16757 + keyword: "not",
16758 + compositeRule: true,
16759 + createErrors: false,
16760 + allErrors: false
16761 + }, valid);
16762 + cxt.failResult(valid, () => cxt.reset(), () => cxt.error());
16763 + },
16764 + error: { message: "must NOT be valid" }
16765 + };
16766 + exports.default = def;
16767 + }));
16768 +
16769 +//#endregion
16770 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/anyOf.js
16771 + var require_anyOf = /* @__PURE__ */ __commonJSMin(((exports) => {
16772 + Object.defineProperty(exports, "__esModule", { value: true });
16773 + var def = {
16774 + keyword: "anyOf",
16775 + schemaType: "array",
16776 + trackErrors: true,
16777 + code: require_code().validateUnion,
16778 + error: { message: "must match a schema in anyOf" }
16779 + };
16780 + exports.default = def;
16781 + }));
16782 +
16783 +//#endregion
16784 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/oneOf.js
16785 + var require_oneOf = /* @__PURE__ */ __commonJSMin(((exports) => {
16786 + Object.defineProperty(exports, "__esModule", { value: true });
16787 + var codegen_1 = require_codegen();
16788 + var util_1 = require_util();
16789 + var def = {
16790 + keyword: "oneOf",
16791 + schemaType: "array",
16792 + trackErrors: true,
16793 + error: {
16794 + message: "must match exactly one schema in oneOf",
16795 + params: ({ params }) => (0, codegen_1._)`{passingSchemas: ${params.passing}}`
16796 + },
16797 + code(cxt) {
16798 + const { gen, schema, parentSchema, it } = cxt;
16799 + /* istanbul ignore if */
16800 + if (!Array.isArray(schema)) throw new Error("ajv implementation error");
16801 + if (it.opts.discriminator && parentSchema.discriminator) return;
16802 + const schArr = schema;
16803 + const valid = gen.let("valid", false);
16804 + const passing = gen.let("passing", null);
16805 + const schValid = gen.name("_valid");
16806 + cxt.setParams({ passing });
16807 + gen.block(validateOneOf);
16808 + cxt.result(valid, () => cxt.reset(), () => cxt.error(true));
16809 + function validateOneOf() {
16810 + schArr.forEach((sch, i) => {
16811 + let schCxt;
16812 + if ((0, util_1.alwaysValidSchema)(it, sch)) gen.var(schValid, true);
16813 + else schCxt = cxt.subschema({
16814 + keyword: "oneOf",
16815 + schemaProp: i,
16816 + compositeRule: true
16817 + }, schValid);
16818 + if (i > 0) gen.if((0, codegen_1._)`${schValid} && ${valid}`).assign(valid, false).assign(passing, (0, codegen_1._)`[${passing}, ${i}]`).else();
16819 + gen.if(schValid, () => {
16820 + gen.assign(valid, true);
16821 + gen.assign(passing, i);
16822 + if (schCxt) cxt.mergeEvaluated(schCxt, codegen_1.Name);
16823 + });
16824 + });
16825 + }
16826 + }
16827 + };
16828 + exports.default = def;
16829 + }));
16830 +
16831 +//#endregion
16832 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/allOf.js
16833 + var require_allOf = /* @__PURE__ */ __commonJSMin(((exports) => {
16834 + Object.defineProperty(exports, "__esModule", { value: true });
16835 + var util_1 = require_util();
16836 + var def = {
16837 + keyword: "allOf",
16838 + schemaType: "array",
16839 + code(cxt) {
16840 + const { gen, schema, it } = cxt;
16841 + /* istanbul ignore if */
16842 + if (!Array.isArray(schema)) throw new Error("ajv implementation error");
16843 + const valid = gen.name("valid");
16844 + schema.forEach((sch, i) => {
16845 + if ((0, util_1.alwaysValidSchema)(it, sch)) return;
16846 + const schCxt = cxt.subschema({
16847 + keyword: "allOf",
16848 + schemaProp: i
16849 + }, valid);
16850 + cxt.ok(valid);
16851 + cxt.mergeEvaluated(schCxt);
16852 + });
16853 + }
16854 + };
16855 + exports.default = def;
16856 + }));
16857 +
16858 +//#endregion
16859 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/if.js
16860 + var require_if = /* @__PURE__ */ __commonJSMin(((exports) => {
16861 + Object.defineProperty(exports, "__esModule", { value: true });
16862 + var codegen_1 = require_codegen();
16863 + var util_1 = require_util();
16864 + var def = {
16865 + keyword: "if",
16866 + schemaType: ["object", "boolean"],
16867 + trackErrors: true,
16868 + error: {
16869 + message: ({ params }) => (0, codegen_1.str)`must match "${params.ifClause}" schema`,
16870 + params: ({ params }) => (0, codegen_1._)`{failingKeyword: ${params.ifClause}}`
16871 + },
16872 + code(cxt) {
16873 + const { gen, parentSchema, it } = cxt;
16874 + if (parentSchema.then === void 0 && parentSchema.else === void 0) (0, util_1.checkStrictMode)(it, "\"if\" without \"then\" and \"else\" is ignored");
16875 + const hasThen = hasSchema(it, "then");
16876 + const hasElse = hasSchema(it, "else");
16877 + if (!hasThen && !hasElse) return;
16878 + const valid = gen.let("valid", true);
16879 + const schValid = gen.name("_valid");
16880 + validateIf();
16881 + cxt.reset();
16882 + if (hasThen && hasElse) {
16883 + const ifClause = gen.let("ifClause");
16884 + cxt.setParams({ ifClause });
16885 + gen.if(schValid, validateClause("then", ifClause), validateClause("else", ifClause));
16886 + } else if (hasThen) gen.if(schValid, validateClause("then"));
16887 + else gen.if((0, codegen_1.not)(schValid), validateClause("else"));
16888 + cxt.pass(valid, () => cxt.error(true));
16889 + function validateIf() {
16890 + const schCxt = cxt.subschema({
16891 + keyword: "if",
16892 + compositeRule: true,
16893 + createErrors: false,
16894 + allErrors: false
16895 + }, schValid);
16896 + cxt.mergeEvaluated(schCxt);
16897 + }
16898 + function validateClause(keyword, ifClause) {
16899 + return () => {
16900 + const schCxt = cxt.subschema({ keyword }, schValid);
16901 + gen.assign(valid, schValid);
16902 + cxt.mergeValidEvaluated(schCxt, valid);
16903 + if (ifClause) gen.assign(ifClause, (0, codegen_1._)`${keyword}`);
16904 + else cxt.setParams({ ifClause: keyword });
16905 + };
16906 + }
16907 + }
16908 + };
16909 + function hasSchema(it, keyword) {
16910 + const schema = it.schema[keyword];
16911 + return schema !== void 0 && !(0, util_1.alwaysValidSchema)(it, schema);
16912 + }
16913 + exports.default = def;
16914 + }));
16915 +
16916 +//#endregion
16917 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/thenElse.js
16918 + var require_thenElse = /* @__PURE__ */ __commonJSMin(((exports) => {
16919 + Object.defineProperty(exports, "__esModule", { value: true });
16920 + var util_1 = require_util();
16921 + var def = {
16922 + keyword: ["then", "else"],
16923 + schemaType: ["object", "boolean"],
16924 + code({ keyword, parentSchema, it }) {
16925 + if (parentSchema.if === void 0) (0, util_1.checkStrictMode)(it, `"${keyword}" without "if" is ignored`);
16926 + }
16927 + };
16928 + exports.default = def;
16929 + }));
16930 +
16931 +//#endregion
16932 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/applicator/index.js
16933 + var require_applicator = /* @__PURE__ */ __commonJSMin(((exports) => {
16934 + Object.defineProperty(exports, "__esModule", { value: true });
16935 + var additionalItems_1 = require_additionalItems();
16936 + var prefixItems_1 = require_prefixItems();
16937 + var items_1 = require_items();
16938 + var items2020_1 = require_items2020();
16939 + var contains_1 = require_contains();
16940 + var dependencies_1 = require_dependencies();
16941 + var propertyNames_1 = require_propertyNames();
16942 + var additionalProperties_1 = require_additionalProperties();
16943 + var properties_1 = require_properties();
16944 + var patternProperties_1 = require_patternProperties();
16945 + var not_1 = require_not();
16946 + var anyOf_1 = require_anyOf();
16947 + var oneOf_1 = require_oneOf();
16948 + var allOf_1 = require_allOf();
16949 + var if_1 = require_if();
16950 + var thenElse_1 = require_thenElse();
16951 + function getApplicator(draft2020 = false) {
16952 + const applicator = [
16953 + not_1.default,
16954 + anyOf_1.default,
16955 + oneOf_1.default,
16956 + allOf_1.default,
16957 + if_1.default,
16958 + thenElse_1.default,
16959 + propertyNames_1.default,
16960 + additionalProperties_1.default,
16961 + dependencies_1.default,
16962 + properties_1.default,
16963 + patternProperties_1.default
16964 + ];
16965 + if (draft2020) applicator.push(prefixItems_1.default, items2020_1.default);
16966 + else applicator.push(additionalItems_1.default, items_1.default);
16967 + applicator.push(contains_1.default);
16968 + return applicator;
16969 + }
16970 + exports.default = getApplicator;
16971 + }));
16972 +
16973 +//#endregion
16974 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/format/format.js
16975 + var require_format$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
16976 + Object.defineProperty(exports, "__esModule", { value: true });
16977 + var codegen_1 = require_codegen();
16978 + var def = {
16979 + keyword: "format",
16980 + type: ["number", "string"],
16981 + schemaType: "string",
16982 + $data: true,
16983 + error: {
16984 + message: ({ schemaCode }) => (0, codegen_1.str)`must match format "${schemaCode}"`,
16985 + params: ({ schemaCode }) => (0, codegen_1._)`{format: ${schemaCode}}`
16986 + },
16987 + code(cxt, ruleType) {
16988 + const { gen, data, $data, schema, schemaCode, it } = cxt;
16989 + const { opts, errSchemaPath, schemaEnv, self } = it;
16990 + if (!opts.validateFormats) return;
16991 + if ($data) validate$DataFormat();
16992 + else validateFormat();
16993 + function validate$DataFormat() {
16994 + const fmts = gen.scopeValue("formats", {
16995 + ref: self.formats,
16996 + code: opts.code.formats
16997 + });
16998 + const fDef = gen.const("fDef", (0, codegen_1._)`${fmts}[${schemaCode}]`);
16999 + const fType = gen.let("fType");
17000 + const format = gen.let("format");
17001 + gen.if((0, codegen_1._)`typeof ${fDef} == "object" && !(${fDef} instanceof RegExp)`, () => gen.assign(fType, (0, codegen_1._)`${fDef}.type || "string"`).assign(format, (0, codegen_1._)`${fDef}.validate`), () => gen.assign(fType, (0, codegen_1._)`"string"`).assign(format, fDef));
17002 + cxt.fail$data((0, codegen_1.or)(unknownFmt(), invalidFmt()));
17003 + function unknownFmt() {
17004 + if (opts.strictSchema === false) return codegen_1.nil;
17005 + return (0, codegen_1._)`${schemaCode} && !${format}`;
17006 + }
17007 + function invalidFmt() {
17008 + const callFormat = schemaEnv.$async ? (0, codegen_1._)`(${fDef}.async ? await ${format}(${data}) : ${format}(${data}))` : (0, codegen_1._)`${format}(${data})`;
17009 + const validData = (0, codegen_1._)`(typeof ${format} == "function" ? ${callFormat} : ${format}.test(${data}))`;
17010 + return (0, codegen_1._)`${format} && ${format} !== true && ${fType} === ${ruleType} && !${validData}`;
17011 + }
17012 + }
17013 + function validateFormat() {
17014 + const formatDef = self.formats[schema];
17015 + if (!formatDef) {
17016 + unknownFormat();
17017 + return;
17018 + }
17019 + if (formatDef === true) return;
17020 + const [fmtType, format, fmtRef] = getFormat(formatDef);
17021 + if (fmtType === ruleType) cxt.pass(validCondition());
17022 + function unknownFormat() {
17023 + if (opts.strictSchema === false) {
17024 + self.logger.warn(unknownMsg());
17025 + return;
17026 + }
17027 + throw new Error(unknownMsg());
17028 + function unknownMsg() {
17029 + return `unknown format "${schema}" ignored in schema at path "${errSchemaPath}"`;
17030 + }
17031 + }
17032 + function getFormat(fmtDef) {
17033 + const code = fmtDef instanceof RegExp ? (0, codegen_1.regexpCode)(fmtDef) : opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(schema)}` : void 0;
17034 + const fmt = gen.scopeValue("formats", {
17035 + key: schema,
17036 + ref: fmtDef,
17037 + code
17038 + });
17039 + if (typeof fmtDef == "object" && !(fmtDef instanceof RegExp)) return [
17040 + fmtDef.type || "string",
17041 + fmtDef.validate,
17042 + (0, codegen_1._)`${fmt}.validate`
17043 + ];
17044 + return [
17045 + "string",
17046 + fmtDef,
17047 + fmt
17048 + ];
17049 + }
17050 + function validCondition() {
17051 + if (typeof formatDef == "object" && !(formatDef instanceof RegExp) && formatDef.async) {
17052 + if (!schemaEnv.$async) throw new Error("async format in sync schema");
17053 + return (0, codegen_1._)`await ${fmtRef}(${data})`;
17054 + }
17055 + return typeof format == "function" ? (0, codegen_1._)`${fmtRef}(${data})` : (0, codegen_1._)`${fmtRef}.test(${data})`;
17056 + }
17057 + }
17058 + }
17059 + };
17060 + exports.default = def;
17061 + }));
17062 +
17063 +//#endregion
17064 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/format/index.js
17065 + var require_format = /* @__PURE__ */ __commonJSMin(((exports) => {
17066 + Object.defineProperty(exports, "__esModule", { value: true });
17067 + var format = [require_format$1().default];
17068 + exports.default = format;
17069 + }));
17070 +
17071 +//#endregion
17072 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/metadata.js
17073 + var require_metadata = /* @__PURE__ */ __commonJSMin(((exports) => {
17074 + Object.defineProperty(exports, "__esModule", { value: true });
17075 + exports.contentVocabulary = exports.metadataVocabulary = void 0;
17076 + exports.metadataVocabulary = [
17077 + "title",
17078 + "description",
17079 + "default",
17080 + "deprecated",
17081 + "readOnly",
17082 + "writeOnly",
17083 + "examples"
17084 + ];
17085 + exports.contentVocabulary = [
17086 + "contentMediaType",
17087 + "contentEncoding",
17088 + "contentSchema"
17089 + ];
17090 + }));
17091 +
17092 +//#endregion
17093 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/draft7.js
17094 + var require_draft7 = /* @__PURE__ */ __commonJSMin(((exports) => {
17095 + Object.defineProperty(exports, "__esModule", { value: true });
17096 + var core_1 = require_core();
17097 + var validation_1 = require_validation();
17098 + var applicator_1 = require_applicator();
17099 + var format_1 = require_format();
17100 + var metadata_1 = require_metadata();
17101 + var draft7Vocabularies = [
17102 + core_1.default,
17103 + validation_1.default,
17104 + (0, applicator_1.default)(),
17105 + format_1.default,
17106 + metadata_1.metadataVocabulary,
17107 + metadata_1.contentVocabulary
17108 + ];
17109 + exports.default = draft7Vocabularies;
17110 + }));
17111 +
17112 +//#endregion
17113 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/discriminator/types.js
17114 + var require_types = /* @__PURE__ */ __commonJSMin(((exports) => {
17115 + Object.defineProperty(exports, "__esModule", { value: true });
17116 + exports.DiscrError = void 0;
17117 + var DiscrError;
17118 + (function(DiscrError) {
17119 + DiscrError["Tag"] = "tag";
17120 + DiscrError["Mapping"] = "mapping";
17121 + })(DiscrError || (exports.DiscrError = DiscrError = {}));
17122 + }));
17123 +
17124 +//#endregion
17125 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/vocabularies/discriminator/index.js
17126 + var require_discriminator = /* @__PURE__ */ __commonJSMin(((exports) => {
17127 + Object.defineProperty(exports, "__esModule", { value: true });
17128 + var codegen_1 = require_codegen();
17129 + var types_1 = require_types();
17130 + var compile_1 = require_compile();
17131 + var ref_error_1 = require_ref_error();
17132 + var util_1 = require_util();
17133 + var def = {
17134 + keyword: "discriminator",
17135 + type: "object",
17136 + schemaType: "object",
17137 + error: {
17138 + message: ({ params: { discrError, tagName } }) => discrError === types_1.DiscrError.Tag ? `tag "${tagName}" must be string` : `value of tag "${tagName}" must be in oneOf`,
17139 + params: ({ params: { discrError, tag, tagName } }) => (0, codegen_1._)`{error: ${discrError}, tag: ${tagName}, tagValue: ${tag}}`
17140 + },
17141 + code(cxt) {
17142 + const { gen, data, schema, parentSchema, it } = cxt;
17143 + const { oneOf } = parentSchema;
17144 + if (!it.opts.discriminator) throw new Error("discriminator: requires discriminator option");
17145 + const tagName = schema.propertyName;
17146 + if (typeof tagName != "string") throw new Error("discriminator: requires propertyName");
17147 + if (schema.mapping) throw new Error("discriminator: mapping is not supported");
17148 + if (!oneOf) throw new Error("discriminator: requires oneOf keyword");
17149 + const valid = gen.let("valid", false);
17150 + const tag = gen.const("tag", (0, codegen_1._)`${data}${(0, codegen_1.getProperty)(tagName)}`);
17151 + gen.if((0, codegen_1._)`typeof ${tag} == "string"`, () => validateMapping(), () => cxt.error(false, {
17152 + discrError: types_1.DiscrError.Tag,
17153 + tag,
17154 + tagName
17155 + }));
17156 + cxt.ok(valid);
17157 + function validateMapping() {
17158 + const mapping = getMapping();
17159 + gen.if(false);
17160 + for (const tagValue in mapping) {
17161 + gen.elseIf((0, codegen_1._)`${tag} === ${tagValue}`);
17162 + gen.assign(valid, applyTagSchema(mapping[tagValue]));
17163 + }
17164 + gen.else();
17165 + cxt.error(false, {
17166 + discrError: types_1.DiscrError.Mapping,
17167 + tag,
17168 + tagName
17169 + });
17170 + gen.endIf();
17171 + }
17172 + function applyTagSchema(schemaProp) {
17173 + const _valid = gen.name("valid");
17174 + const schCxt = cxt.subschema({
17175 + keyword: "oneOf",
17176 + schemaProp
17177 + }, _valid);
17178 + cxt.mergeEvaluated(schCxt, codegen_1.Name);
17179 + return _valid;
17180 + }
17181 + function getMapping() {
17182 + var _a;
17183 + const oneOfMapping = {};
17184 + const topRequired = hasRequired(parentSchema);
17185 + let tagRequired = true;
17186 + for (let i = 0; i < oneOf.length; i++) {
17187 + let sch = oneOf[i];
17188 + if ((sch === null || sch === void 0 ? void 0 : sch.$ref) && !(0, util_1.schemaHasRulesButRef)(sch, it.self.RULES)) {
17189 + const ref = sch.$ref;
17190 + sch = compile_1.resolveRef.call(it.self, it.schemaEnv.root, it.baseId, ref);
17191 + if (sch instanceof compile_1.SchemaEnv) sch = sch.schema;
17192 + if (sch === void 0) throw new ref_error_1.default(it.opts.uriResolver, it.baseId, ref);
17193 + }
17194 + const propSch = (_a = sch === null || sch === void 0 ? void 0 : sch.properties) === null || _a === void 0 ? void 0 : _a[tagName];
17195 + if (typeof propSch != "object") throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${tagName}"`);
17196 + tagRequired = tagRequired && (topRequired || hasRequired(sch));
17197 + addMappings(propSch, i);
17198 + }
17199 + if (!tagRequired) throw new Error(`discriminator: "${tagName}" must be required`);
17200 + return oneOfMapping;
17201 + function hasRequired({ required }) {
17202 + return Array.isArray(required) && required.includes(tagName);
17203 + }
17204 + function addMappings(sch, i) {
17205 + if (sch.const) addMapping(sch.const, i);
17206 + else if (sch.enum) for (const tagValue of sch.enum) addMapping(tagValue, i);
17207 + else throw new Error(`discriminator: "properties/${tagName}" must have "const" or "enum"`);
17208 + }
17209 + function addMapping(tagValue, i) {
17210 + if (typeof tagValue != "string" || tagValue in oneOfMapping) throw new Error(`discriminator: "${tagName}" values must be unique strings`);
17211 + oneOfMapping[tagValue] = i;
17212 + }
17213 + }
17214 + }
17215 + };
17216 + exports.default = def;
17217 + }));
17218 +
17219 +//#endregion
17220 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/refs/json-schema-draft-07.json
17221 + var json_schema_draft_07_exports = /* @__PURE__ */ __exportAll({
17222 + $id: () => $id,
17223 + $schema: () => $schema,
17224 + default: () => json_schema_draft_07_default,
17225 + definitions: () => definitions,
17226 + properties: () => properties,
17227 + title: () => title,
17228 + type: () => type
17229 + });
17230 + var $schema, $id, title, definitions, type, properties, json_schema_draft_07_default;
17231 + var init_json_schema_draft_07 = __esmMin((() => {
17232 + $schema = "http://json-schema.org/draft-07/schema#";
17233 + $id = "http://json-schema.org/draft-07/schema#";
17234 + title = "Core schema meta-schema";
17235 + definitions = {
17236 + "schemaArray": {
17237 + "type": "array",
17238 + "minItems": 1,
17239 + "items": { "$ref": "#" }
17240 + },
17241 + "nonNegativeInteger": {
17242 + "type": "integer",
17243 + "minimum": 0
17244 + },
17245 + "nonNegativeIntegerDefault0": { "allOf": [{ "$ref": "#/definitions/nonNegativeInteger" }, { "default": 0 }] },
17246 + "simpleTypes": { "enum": [
17247 + "array",
17248 + "boolean",
17249 + "integer",
17250 + "null",
17251 + "number",
17252 + "object",
17253 + "string"
17254 + ] },
17255 + "stringArray": {
17256 + "type": "array",
17257 + "items": { "type": "string" },
17258 + "uniqueItems": true,
17259 + "default": []
17260 + }
17261 + };
17262 + type = ["object", "boolean"];
17263 + properties = {
17264 + "$id": {
17265 + "type": "string",
17266 + "format": "uri-reference"
17267 + },
17268 + "$schema": {
17269 + "type": "string",
17270 + "format": "uri"
17271 + },
17272 + "$ref": {
17273 + "type": "string",
17274 + "format": "uri-reference"
17275 + },
17276 + "$comment": { "type": "string" },
17277 + "title": { "type": "string" },
17278 + "description": { "type": "string" },
17279 + "default": true,
17280 + "readOnly": {
17281 + "type": "boolean",
17282 + "default": false
17283 + },
17284 + "examples": {
17285 + "type": "array",
17286 + "items": true
17287 + },
17288 + "multipleOf": {
17289 + "type": "number",
17290 + "exclusiveMinimum": 0
17291 + },
17292 + "maximum": { "type": "number" },
17293 + "exclusiveMaximum": { "type": "number" },
17294 + "minimum": { "type": "number" },
17295 + "exclusiveMinimum": { "type": "number" },
17296 + "maxLength": { "$ref": "#/definitions/nonNegativeInteger" },
17297 + "minLength": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
17298 + "pattern": {
17299 + "type": "string",
17300 + "format": "regex"
17301 + },
17302 + "additionalItems": { "$ref": "#" },
17303 + "items": {
17304 + "anyOf": [{ "$ref": "#" }, { "$ref": "#/definitions/schemaArray" }],
17305 + "default": true
17306 + },
17307 + "maxItems": { "$ref": "#/definitions/nonNegativeInteger" },
17308 + "minItems": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
17309 + "uniqueItems": {
17310 + "type": "boolean",
17311 + "default": false
17312 + },
17313 + "contains": { "$ref": "#" },
17314 + "maxProperties": { "$ref": "#/definitions/nonNegativeInteger" },
17315 + "minProperties": { "$ref": "#/definitions/nonNegativeIntegerDefault0" },
17316 + "required": { "$ref": "#/definitions/stringArray" },
17317 + "additionalProperties": { "$ref": "#" },
17318 + "definitions": {
17319 + "type": "object",
17320 + "additionalProperties": { "$ref": "#" },
17321 + "default": {}
17322 + },
17323 + "properties": {
17324 + "type": "object",
17325 + "additionalProperties": { "$ref": "#" },
17326 + "default": {}
17327 + },
17328 + "patternProperties": {
17329 + "type": "object",
17330 + "additionalProperties": { "$ref": "#" },
17331 + "propertyNames": { "format": "regex" },
17332 + "default": {}
17333 + },
17334 + "dependencies": {
17335 + "type": "object",
17336 + "additionalProperties": { "anyOf": [{ "$ref": "#" }, { "$ref": "#/definitions/stringArray" }] }
17337 + },
17338 + "propertyNames": { "$ref": "#" },
17339 + "const": true,
17340 + "enum": {
17341 + "type": "array",
17342 + "items": true,
17343 + "minItems": 1,
17344 + "uniqueItems": true
17345 + },
17346 + "type": { "anyOf": [{ "$ref": "#/definitions/simpleTypes" }, {
17347 + "type": "array",
17348 + "items": { "$ref": "#/definitions/simpleTypes" },
17349 + "minItems": 1,
17350 + "uniqueItems": true
17351 + }] },
17352 + "format": { "type": "string" },
17353 + "contentMediaType": { "type": "string" },
17354 + "contentEncoding": { "type": "string" },
17355 + "if": { "$ref": "#" },
17356 + "then": { "$ref": "#" },
17357 + "else": { "$ref": "#" },
17358 + "allOf": { "$ref": "#/definitions/schemaArray" },
17359 + "anyOf": { "$ref": "#/definitions/schemaArray" },
17360 + "oneOf": { "$ref": "#/definitions/schemaArray" },
17361 + "not": { "$ref": "#" }
17362 + };
17363 + json_schema_draft_07_default = {
17364 + $schema,
17365 + $id,
17366 + title,
17367 + definitions,
17368 + type,
17369 + properties,
17370 + "default": true
17371 + };
17372 + }));
17373 +
17374 +//#endregion
17375 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv/dist/ajv.js
17376 + var require_ajv = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17377 + Object.defineProperty(exports, "__esModule", { value: true });
17378 + exports.MissingRefError = exports.ValidationError = exports.CodeGen = exports.Name = exports.nil = exports.stringify = exports.str = exports._ = exports.KeywordCxt = exports.Ajv = void 0;
17379 + var core_1 = require_core$1();
17380 + var draft7_1 = require_draft7();
17381 + var discriminator_1 = require_discriminator();
17382 + var draft7MetaSchema = (init_json_schema_draft_07(), __toCommonJS(json_schema_draft_07_exports).default);
17383 + var META_SUPPORT_DATA = ["/properties"];
17384 + var META_SCHEMA_ID = "http://json-schema.org/draft-07/schema";
17385 + var Ajv = class extends core_1.default {
17386 + _addVocabularies() {
17387 + super._addVocabularies();
17388 + draft7_1.default.forEach((v) => this.addVocabulary(v));
17389 + if (this.opts.discriminator) this.addKeyword(discriminator_1.default);
17390 + }
17391 + _addDefaultMetaSchema() {
17392 + super._addDefaultMetaSchema();
17393 + if (!this.opts.meta) return;
17394 + const metaSchema = this.opts.$data ? this.$dataMetaSchema(draft7MetaSchema, META_SUPPORT_DATA) : draft7MetaSchema;
17395 + this.addMetaSchema(metaSchema, META_SCHEMA_ID, false);
17396 + this.refs["http://json-schema.org/schema"] = META_SCHEMA_ID;
17397 + }
17398 + defaultMeta() {
17399 + return this.opts.defaultMeta = super.defaultMeta() || (this.getSchema(META_SCHEMA_ID) ? META_SCHEMA_ID : void 0);
17400 + }
17401 + };
17402 + exports.Ajv = Ajv;
17403 + module.exports = exports = Ajv;
17404 + module.exports.Ajv = Ajv;
17405 + Object.defineProperty(exports, "__esModule", { value: true });
17406 + exports.default = Ajv;
17407 + var validate_1 = require_validate();
17408 + Object.defineProperty(exports, "KeywordCxt", {
17409 + enumerable: true,
17410 + get: function() {
17411 + return validate_1.KeywordCxt;
17412 + }
17413 + });
17414 + var codegen_1 = require_codegen();
17415 + Object.defineProperty(exports, "_", {
17416 + enumerable: true,
17417 + get: function() {
17418 + return codegen_1._;
17419 + }
17420 + });
17421 + Object.defineProperty(exports, "str", {
17422 + enumerable: true,
17423 + get: function() {
17424 + return codegen_1.str;
17425 + }
17426 + });
17427 + Object.defineProperty(exports, "stringify", {
17428 + enumerable: true,
17429 + get: function() {
17430 + return codegen_1.stringify;
17431 + }
17432 + });
17433 + Object.defineProperty(exports, "nil", {
17434 + enumerable: true,
17435 + get: function() {
17436 + return codegen_1.nil;
17437 + }
17438 + });
17439 + Object.defineProperty(exports, "Name", {
17440 + enumerable: true,
17441 + get: function() {
17442 + return codegen_1.Name;
17443 + }
17444 + });
17445 + Object.defineProperty(exports, "CodeGen", {
17446 + enumerable: true,
17447 + get: function() {
17448 + return codegen_1.CodeGen;
17449 + }
17450 + });
17451 + var validation_error_1 = require_validation_error();
17452 + Object.defineProperty(exports, "ValidationError", {
17453 + enumerable: true,
17454 + get: function() {
17455 + return validation_error_1.default;
17456 + }
17457 + });
17458 + var ref_error_1 = require_ref_error();
17459 + Object.defineProperty(exports, "MissingRefError", {
17460 + enumerable: true,
17461 + get: function() {
17462 + return ref_error_1.default;
17463 + }
17464 + });
17465 + }));
17466 +
17467 +//#endregion
17468 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv-formats/dist/formats.js
17469 + var require_formats = /* @__PURE__ */ __commonJSMin(((exports) => {
17470 + Object.defineProperty(exports, "__esModule", { value: true });
17471 + exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
17472 + function fmtDef(validate, compare) {
17473 + return {
17474 + validate,
17475 + compare
17476 + };
17477 + }
17478 + exports.fullFormats = {
17479 + date: fmtDef(date, compareDate),
17480 + time: fmtDef(getTime(true), compareTime),
17481 + "date-time": fmtDef(getDateTime(true), compareDateTime),
17482 + "iso-time": fmtDef(getTime(), compareIsoTime),
17483 + "iso-date-time": fmtDef(getDateTime(), compareIsoDateTime),
17484 + duration: /^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,
17485 + uri,
17486 + "uri-reference": /^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,
17487 + "uri-template": /^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,
17488 + url: /^(?:https?|ftp):\/\/(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,
17489 + email: /^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,
17490 + hostname: /^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,
17491 + ipv4: /^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$/,
17492 + ipv6: /^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i,
17493 + regex,
17494 + uuid: /^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,
17495 + "json-pointer": /^(?:\/(?:[^~/]|~0|~1)*)*$/,
17496 + "json-pointer-uri-fragment": /^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,
17497 + "relative-json-pointer": /^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,
17498 + byte,
17499 + int32: {
17500 + type: "number",
17501 + validate: validateInt32
17502 + },
17503 + int64: {
17504 + type: "number",
17505 + validate: validateInt64
17506 + },
17507 + float: {
17508 + type: "number",
17509 + validate: validateNumber
17510 + },
17511 + double: {
17512 + type: "number",
17513 + validate: validateNumber
17514 + },
17515 + password: true,
17516 + binary: true
17517 + };
17518 + exports.fastFormats = {
17519 + ...exports.fullFormats,
17520 + date: fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\d$/, compareDate),
17521 + time: fmtDef(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i, compareTime),
17522 + "date-time": fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i, compareDateTime),
17523 + "iso-time": fmtDef(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i, compareIsoTime),
17524 + "iso-date-time": fmtDef(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i, compareIsoDateTime),
17525 + uri: /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,
17526 + "uri-reference": /^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,
17527 + email: /^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i
17528 + };
17529 + exports.formatNames = Object.keys(exports.fullFormats);
17530 + function isLeapYear(year) {
17531 + return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
17532 + }
17533 + var DATE = /^(\d\d\d\d)-(\d\d)-(\d\d)$/;
17534 + var DAYS = [
17535 + 0,
17536 + 31,
17537 + 28,
17538 + 31,
17539 + 30,
17540 + 31,
17541 + 30,
17542 + 31,
17543 + 31,
17544 + 30,
17545 + 31,
17546 + 30,
17547 + 31
17548 + ];
17549 + function date(str) {
17550 + const matches = DATE.exec(str);
17551 + if (!matches) return false;
17552 + const year = +matches[1];
17553 + const month = +matches[2];
17554 + const day = +matches[3];
17555 + return month >= 1 && month <= 12 && day >= 1 && day <= (month === 2 && isLeapYear(year) ? 29 : DAYS[month]);
17556 + }
17557 + function compareDate(d1, d2) {
17558 + if (!(d1 && d2)) return void 0;
17559 + if (d1 > d2) return 1;
17560 + if (d1 < d2) return -1;
17561 + return 0;
17562 + }
17563 + var TIME = /^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;
17564 + function getTime(strictTimeZone) {
17565 + return function time(str) {
17566 + const matches = TIME.exec(str);
17567 + if (!matches) return false;
17568 + const hr = +matches[1];
17569 + const min = +matches[2];
17570 + const sec = +matches[3];
17571 + const tz = matches[4];
17572 + const tzSign = matches[5] === "-" ? -1 : 1;
17573 + const tzH = +(matches[6] || 0);
17574 + const tzM = +(matches[7] || 0);
17575 + if (tzH > 23 || tzM > 59 || strictTimeZone && !tz) return false;
17576 + if (hr <= 23 && min <= 59 && sec < 60) return true;
17577 + const utcMin = min - tzM * tzSign;
17578 + const utcHr = hr - tzH * tzSign - (utcMin < 0 ? 1 : 0);
17579 + return (utcHr === 23 || utcHr === -1) && (utcMin === 59 || utcMin === -1) && sec < 61;
17580 + };
17581 + }
17582 + function compareTime(s1, s2) {
17583 + if (!(s1 && s2)) return void 0;
17584 + const t1 = (/* @__PURE__ */ new Date("2020-01-01T" + s1)).valueOf();
17585 + const t2 = (/* @__PURE__ */ new Date("2020-01-01T" + s2)).valueOf();
17586 + if (!(t1 && t2)) return void 0;
17587 + return t1 - t2;
17588 + }
17589 + function compareIsoTime(t1, t2) {
17590 + if (!(t1 && t2)) return void 0;
17591 + const a1 = TIME.exec(t1);
17592 + const a2 = TIME.exec(t2);
17593 + if (!(a1 && a2)) return void 0;
17594 + t1 = a1[1] + a1[2] + a1[3];
17595 + t2 = a2[1] + a2[2] + a2[3];
17596 + if (t1 > t2) return 1;
17597 + if (t1 < t2) return -1;
17598 + return 0;
17599 + }
17600 + var DATE_TIME_SEPARATOR = /t|\s/i;
17601 + function getDateTime(strictTimeZone) {
17602 + const time = getTime(strictTimeZone);
17603 + return function date_time(str) {
17604 + const dateTime = str.split(DATE_TIME_SEPARATOR);
17605 + return dateTime.length === 2 && date(dateTime[0]) && time(dateTime[1]);
17606 + };
17607 + }
17608 + function compareDateTime(dt1, dt2) {
17609 + if (!(dt1 && dt2)) return void 0;
17610 + const d1 = new Date(dt1).valueOf();
17611 + const d2 = new Date(dt2).valueOf();
17612 + if (!(d1 && d2)) return void 0;
17613 + return d1 - d2;
17614 + }
17615 + function compareIsoDateTime(dt1, dt2) {
17616 + if (!(dt1 && dt2)) return void 0;
17617 + const [d1, t1] = dt1.split(DATE_TIME_SEPARATOR);
17618 + const [d2, t2] = dt2.split(DATE_TIME_SEPARATOR);
17619 + const res = compareDate(d1, d2);
17620 + if (res === void 0) return void 0;
17621 + return res || compareTime(t1, t2);
17622 + }
17623 + var NOT_URI_FRAGMENT = /\/|:/;
17624 + var URI = /^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
17625 + function uri(str) {
17626 + return NOT_URI_FRAGMENT.test(str) && URI.test(str);
17627 + }
17628 + var BYTE = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;
17629 + function byte(str) {
17630 + BYTE.lastIndex = 0;
17631 + return BYTE.test(str);
17632 + }
17633 + var MIN_INT32 = -(2 ** 31);
17634 + var MAX_INT32 = 2 ** 31 - 1;
17635 + function validateInt32(value) {
17636 + return Number.isInteger(value) && value <= MAX_INT32 && value >= MIN_INT32;
17637 + }
17638 + function validateInt64(value) {
17639 + return Number.isInteger(value);
17640 + }
17641 + function validateNumber() {
17642 + return true;
17643 + }
17644 + var Z_ANCHOR = /[^\\]\\Z/;
17645 + function regex(str) {
17646 + if (Z_ANCHOR.test(str)) return false;
17647 + try {
17648 + new RegExp(str);
17649 + return true;
17650 + } catch (e) {
17651 + return false;
17652 + }
17653 + }
17654 + }));
17655 +
17656 +//#endregion
17657 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv-formats/dist/limit.js
17658 + var require_limit = /* @__PURE__ */ __commonJSMin(((exports) => {
17659 + Object.defineProperty(exports, "__esModule", { value: true });
17660 + exports.formatLimitDefinition = void 0;
17661 + var ajv_1 = require_ajv();
17662 + var codegen_1 = require_codegen();
17663 + var ops = codegen_1.operators;
17664 + var KWDs = {
17665 + formatMaximum: {
17666 + okStr: "<=",
17667 + ok: ops.LTE,
17668 + fail: ops.GT
17669 + },
17670 + formatMinimum: {
17671 + okStr: ">=",
17672 + ok: ops.GTE,
17673 + fail: ops.LT
17674 + },
17675 + formatExclusiveMaximum: {
17676 + okStr: "<",
17677 + ok: ops.LT,
17678 + fail: ops.GTE
17679 + },
17680 + formatExclusiveMinimum: {
17681 + okStr: ">",
17682 + ok: ops.GT,
17683 + fail: ops.LTE
17684 + }
17685 + };
17686 + var error = {
17687 + message: ({ keyword, schemaCode }) => (0, codegen_1.str)`should be ${KWDs[keyword].okStr} ${schemaCode}`,
17688 + params: ({ keyword, schemaCode }) => (0, codegen_1._)`{comparison: ${KWDs[keyword].okStr}, limit: ${schemaCode}}`
17689 + };
17690 + exports.formatLimitDefinition = {
17691 + keyword: Object.keys(KWDs),
17692 + type: "string",
17693 + schemaType: "string",
17694 + $data: true,
17695 + error,
17696 + code(cxt) {
17697 + const { gen, data, schemaCode, keyword, it } = cxt;
17698 + const { opts, self } = it;
17699 + if (!opts.validateFormats) return;
17700 + const fCxt = new ajv_1.KeywordCxt(it, self.RULES.all.format.definition, "format");
17701 + if (fCxt.$data) validate$DataFormat();
17702 + else validateFormat();
17703 + function validate$DataFormat() {
17704 + const fmts = gen.scopeValue("formats", {
17705 + ref: self.formats,
17706 + code: opts.code.formats
17707 + });
17708 + const fmt = gen.const("fmt", (0, codegen_1._)`${fmts}[${fCxt.schemaCode}]`);
17709 + cxt.fail$data((0, codegen_1.or)((0, codegen_1._)`typeof ${fmt} != "object"`, (0, codegen_1._)`${fmt} instanceof RegExp`, (0, codegen_1._)`typeof ${fmt}.compare != "function"`, compareCode(fmt)));
17710 + }
17711 + function validateFormat() {
17712 + const format = fCxt.schema;
17713 + const fmtDef = self.formats[format];
17714 + if (!fmtDef || fmtDef === true) return;
17715 + if (typeof fmtDef != "object" || fmtDef instanceof RegExp || typeof fmtDef.compare != "function") throw new Error(`"${keyword}": format "${format}" does not define "compare" function`);
17716 + const fmt = gen.scopeValue("formats", {
17717 + key: format,
17718 + ref: fmtDef,
17719 + code: opts.code.formats ? (0, codegen_1._)`${opts.code.formats}${(0, codegen_1.getProperty)(format)}` : void 0
17720 + });
17721 + cxt.fail$data(compareCode(fmt));
17722 + }
17723 + function compareCode(fmt) {
17724 + return (0, codegen_1._)`${fmt}.compare(${data}, ${schemaCode}) ${KWDs[keyword].fail} 0`;
17725 + }
17726 + },
17727 + dependencies: ["format"]
17728 + };
17729 + var formatLimitPlugin = (ajv) => {
17730 + ajv.addKeyword(exports.formatLimitDefinition);
17731 + return ajv;
17732 + };
17733 + exports.default = formatLimitPlugin;
17734 + }));
17735 +
17736 +//#endregion
17737 +//#region node_modules/@modelcontextprotocol/sdk/node_modules/ajv-formats/dist/index.js
17738 + var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
17739 + Object.defineProperty(exports, "__esModule", { value: true });
17740 + var formats_1 = require_formats();
17741 + var limit_1 = require_limit();
17742 + var codegen_1 = require_codegen();
17743 + var fullName = new codegen_1.Name("fullFormats");
17744 + var fastName = new codegen_1.Name("fastFormats");
17745 + var formatsPlugin = (ajv, opts = { keywords: true }) => {
17746 + if (Array.isArray(opts)) {
17747 + addFormats(ajv, opts, formats_1.fullFormats, fullName);
17748 + return ajv;
17749 + }
17750 + const [formats, exportName] = opts.mode === "fast" ? [formats_1.fastFormats, fastName] : [formats_1.fullFormats, fullName];
17751 + addFormats(ajv, opts.formats || formats_1.formatNames, formats, exportName);
17752 + if (opts.keywords) (0, limit_1.default)(ajv);
17753 + return ajv;
17754 + };
17755 + formatsPlugin.get = (name, mode = "full") => {
17756 + const f = (mode === "fast" ? formats_1.fastFormats : formats_1.fullFormats)[name];
17757 + if (!f) throw new Error(`Unknown format "${name}"`);
17758 + return f;
17759 + };
17760 + function addFormats(ajv, list, fs, exportName) {
17761 + var _a;
17762 + var _b;
17763 + (_a = (_b = ajv.opts.code).formats) !== null && _a !== void 0 || (_b.formats = (0, codegen_1._)`require("ajv-formats/dist/formats").${exportName}`);
17764 + for (const f of list) ajv.addFormat(f, fs[f]);
17765 + }
17766 + module.exports = exports = formatsPlugin;
17767 + Object.defineProperty(exports, "__esModule", { value: true });
17768 + exports.default = formatsPlugin;
17769 + }));
17770 +
17771 +//#endregion
17772 +//#region node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
17773 + var import_ajv = /* @__PURE__ */ __toESM(require_ajv(), 1);
17774 + var import_dist = /* @__PURE__ */ __toESM(require_dist(), 1);
17775 + function createDefaultAjvInstance() {
17776 + const ajv = new import_ajv.default({
17777 + strict: false,
17778 + validateFormats: true,
17779 + validateSchema: false,
17780 + allErrors: true
17781 + });
17782 + (0, import_dist.default)(ajv);
17783 + return ajv;
17784 + }
17785 + /**
17786 + * @example
17787 + * ```typescript
17788 + * // Use with default AJV instance (recommended)
17789 + * import { AjvJsonSchemaValidator } from '@modelcontextprotocol/sdk/validation/ajv';
17790 + * const validator = new AjvJsonSchemaValidator();
17791 + *
17792 + * // Use with custom AJV instance
17793 + * import { Ajv } from 'ajv';
17794 + * const ajv = new Ajv({ strict: true, allErrors: true });
17795 + * const validator = new AjvJsonSchemaValidator(ajv);
17796 + * ```
17797 + */
17798 + var AjvJsonSchemaValidator = class {
17799 + /**
17800 + * Create an AJV validator
17801 + *
17802 + * @param ajv - Optional pre-configured AJV instance. If not provided, a default instance will be created.
17803 + *
17804 + * @example
17805 + * ```typescript
17806 + * // Use default configuration (recommended for most cases)
17807 + * import { AjvJsonSchemaValidator } from '@modelcontextprotocol/sdk/validation/ajv';
17808 + * const validator = new AjvJsonSchemaValidator();
17809 + *
17810 + * // Or provide custom AJV instance for advanced configuration
17811 + * import { Ajv } from 'ajv';
17812 + * import addFormats from 'ajv-formats';
17813 + *
17814 + * const ajv = new Ajv({ validateFormats: true });
17815 + * addFormats(ajv);
17816 + * const validator = new AjvJsonSchemaValidator(ajv);
17817 + * ```
17818 + */
17819 + constructor(ajv) {
17820 + this._ajv = ajv ?? createDefaultAjvInstance();
17821 + }
17822 + /**
17823 + * Create a validator for the given JSON Schema
17824 + *
17825 + * The validator is compiled once and can be reused multiple times.
17826 + * If the schema has an $id, it will be cached by AJV automatically.
17827 + *
17828 + * @param schema - Standard JSON Schema object
17829 + * @returns A validator function that validates input data
17830 + */
17831 + getValidator(schema) {
17832 + const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? this._ajv.getSchema(schema.$id) ?? this._ajv.compile(schema) : this._ajv.compile(schema);
17833 + return (input) => {
17834 + if (ajvValidator(input)) return {
17835 + valid: true,
17836 + data: input,
17837 + errorMessage: void 0
17838 + };
17839 + else return {
17840 + valid: false,
17841 + data: void 0,
17842 + errorMessage: this._ajv.errorsText(ajvValidator.errors)
17843 + };
17844 + };
17845 + }
17846 + };
17847 +
17848 +//#endregion
17849 +//#region node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
17850 +/**
17851 + * Experimental server task features for MCP SDK.
17852 + * WARNING: These APIs are experimental and may change without notice.
17853 + *
17854 + * @experimental
17855 + */
17856 + /**
17857 + * Experimental task features for low-level MCP servers.
17858 + *
17859 + * Access via `server.experimental.tasks`:
17860 + * ```typescript
17861 + * const stream = server.experimental.tasks.requestStream(request, schema, options);
17862 + * ```
17863 + *
17864 + * For high-level server usage with task-based tools, use `McpServer.experimental.tasks` instead.
17865 + *
17866 + * @experimental
17867 + */
17868 + var ExperimentalServerTasks = class {
17869 + constructor(_server) {
17870 + this._server = _server;
17871 + }
17872 + /**
17873 + * Sends a request and returns an AsyncGenerator that yields response messages.
17874 + * The generator is guaranteed to end with either a 'result' or 'error' message.
17875 + *
17876 + * This method provides streaming access to request processing, allowing you to
17877 + * observe intermediate task status updates for task-augmented requests.
17878 + *
17879 + * @param request - The request to send
17880 + * @param resultSchema - Zod schema for validating the result
17881 + * @param options - Optional request options (timeout, signal, task creation params, etc.)
17882 + * @returns AsyncGenerator that yields ResponseMessage objects
17883 + *
17884 + * @experimental
17885 + */
17886 + requestStream(request, resultSchema, options) {
17887 + return this._server.requestStream(request, resultSchema, options);
17888 + }
17889 + /**
17890 + * Sends a sampling request and returns an AsyncGenerator that yields response messages.
17891 + * The generator is guaranteed to end with either a 'result' or 'error' message.
17892 + *
17893 + * For task-augmented requests, yields 'taskCreated' and 'taskStatus' messages
17894 + * before the final result.
17895 + *
17896 + * @example
17897 + * ```typescript
17898 + * const stream = server.experimental.tasks.createMessageStream({
17899 + * messages: [{ role: 'user', content: { type: 'text', text: 'Hello' } }],
17900 + * maxTokens: 100
17901 + * }, {
17902 + * onprogress: (progress) => {
17903 + * // Handle streaming tokens via progress notifications
17904 + * console.log('Progress:', progress.message);
17905 + * }
17906 + * });
17907 + *
17908 + * for await (const message of stream) {
17909 + * switch (message.type) {
17910 + * case 'taskCreated':
17911 + * console.log('Task created:', message.task.taskId);
17912 + * break;
17913 + * case 'taskStatus':
17914 + * console.log('Task status:', message.task.status);
17915 + * break;
17916 + * case 'result':
17917 + * console.log('Final result:', message.result);
17918 + * break;
17919 + * case 'error':
17920 + * console.error('Error:', message.error);
17921 + * break;
17922 + * }
17923 + * }
17924 + * ```
17925 + *
17926 + * @param params - The sampling request parameters
17927 + * @param options - Optional request options (timeout, signal, task creation params, onprogress, etc.)
17928 + * @returns AsyncGenerator that yields ResponseMessage objects
17929 + *
17930 + * @experimental
17931 + */
17932 + createMessageStream(params, options) {
17933 + const clientCapabilities = this._server.getClientCapabilities();
17934 + if ((params.tools || params.toolChoice) && !clientCapabilities?.sampling?.tools) throw new Error("Client does not support sampling tools capability.");
17935 + if (params.messages.length > 0) {
17936 + const lastMessage = params.messages[params.messages.length - 1];
17937 + const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
17938 + const hasToolResults = lastContent.some((c) => c.type === "tool_result");
17939 + const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
17940 + const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
17941 + const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
17942 + if (hasToolResults) {
17943 + if (lastContent.some((c) => c.type !== "tool_result")) throw new Error("The last message must contain only tool_result content if any is present");
17944 + if (!hasPreviousToolUse) throw new Error("tool_result blocks are not matching any tool_use from the previous message");
17945 + }
17946 + if (hasPreviousToolUse) {
17947 + const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
17948 + const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
17949 + if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
17950 + }
17951 + }
17952 + return this.requestStream({
17953 + method: "sampling/createMessage",
17954 + params
17955 + }, CreateMessageResultSchema, options);
17956 + }
17957 + /**
17958 + * Sends an elicitation request and returns an AsyncGenerator that yields response messages.
17959 + * The generator is guaranteed to end with either a 'result' or 'error' message.
17960 + *
17961 + * For task-augmented requests (especially URL-based elicitation), yields 'taskCreated'
17962 + * and 'taskStatus' messages before the final result.
17963 + *
17964 + * @example
17965 + * ```typescript
17966 + * const stream = server.experimental.tasks.elicitInputStream({
17967 + * mode: 'url',
17968 + * message: 'Please authenticate',
17969 + * elicitationId: 'auth-123',
17970 + * url: 'https://example.com/auth'
17971 + * }, {
17972 + * task: { ttl: 300000 } // Task-augmented for long-running auth flow
17973 + * });
17974 + *
17975 + * for await (const message of stream) {
17976 + * switch (message.type) {
17977 + * case 'taskCreated':
17978 + * console.log('Task created:', message.task.taskId);
17979 + * break;
17980 + * case 'taskStatus':
17981 + * console.log('Task status:', message.task.status);
17982 + * break;
17983 + * case 'result':
17984 + * console.log('User action:', message.result.action);
17985 + * break;
17986 + * case 'error':
17987 + * console.error('Error:', message.error);
17988 + * break;
17989 + * }
17990 + * }
17991 + * ```
17992 + *
17993 + * @param params - The elicitation request parameters
17994 + * @param options - Optional request options (timeout, signal, task creation params, etc.)
17995 + * @returns AsyncGenerator that yields ResponseMessage objects
17996 + *
17997 + * @experimental
17998 + */
17999 + elicitInputStream(params, options) {
18000 + const clientCapabilities = this._server.getClientCapabilities();
18001 + const mode = params.mode ?? "form";
18002 + switch (mode) {
18003 + case "url":
18004 + if (!clientCapabilities?.elicitation?.url) throw new Error("Client does not support url elicitation.");
18005 + break;
18006 + case "form":
18007 + if (!clientCapabilities?.elicitation?.form) throw new Error("Client does not support form elicitation.");
18008 + break;
18009 + }
18010 + const normalizedParams = mode === "form" && params.mode === void 0 ? {
18011 + ...params,
18012 + mode: "form"
18013 + } : params;
18014 + return this.requestStream({
18015 + method: "elicitation/create",
18016 + params: normalizedParams
18017 + }, ElicitResultSchema, options);
18018 + }
18019 + /**
18020 + * Gets the current status of a task.
18021 + *
18022 + * @param taskId - The task identifier
18023 + * @param options - Optional request options
18024 + * @returns The task status
18025 + *
18026 + * @experimental
18027 + */
18028 + async getTask(taskId, options) {
18029 + return this._server.getTask({ taskId }, options);
18030 + }
18031 + /**
18032 + * Retrieves the result of a completed task.
18033 + *
18034 + * @param taskId - The task identifier
18035 + * @param resultSchema - Zod schema for validating the result
18036 + * @param options - Optional request options
18037 + * @returns The task result
18038 + *
18039 + * @experimental
18040 + */
18041 + async getTaskResult(taskId, resultSchema, options) {
18042 + return this._server.getTaskResult({ taskId }, resultSchema, options);
18043 + }
18044 + /**
18045 + * Lists tasks with optional pagination.
18046 + *
18047 + * @param cursor - Optional pagination cursor
18048 + * @param options - Optional request options
18049 + * @returns List of tasks with optional next cursor
18050 + *
18051 + * @experimental
18052 + */
18053 + async listTasks(cursor, options) {
18054 + return this._server.listTasks(cursor ? { cursor } : void 0, options);
18055 + }
18056 + /**
18057 + * Cancels a running task.
18058 + *
18059 + * @param taskId - The task identifier
18060 + * @param options - Optional request options
18061 + *
18062 + * @experimental
18063 + */
18064 + async cancelTask(taskId, options) {
18065 + return this._server.cancelTask({ taskId }, options);
18066 + }
18067 + };
18068 +
18069 +//#endregion
18070 +//#region node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
18071 +/**
18072 + * Experimental task capability assertion helpers.
18073 + * WARNING: These APIs are experimental and may change without notice.
18074 + *
18075 + * @experimental
18076 + */
18077 + /**
18078 + * Asserts that task creation is supported for tools/call.
18079 + * Used by Client.assertTaskCapability and Server.assertTaskHandlerCapability.
18080 + *
18081 + * @param requests - The task requests capability object
18082 + * @param method - The method being checked
18083 + * @param entityName - 'Server' or 'Client' for error messages
18084 + * @throws Error if the capability is not supported
18085 + *
18086 + * @experimental
18087 + */
18088 + function assertToolsCallTaskCapability(requests, method, entityName) {
18089 + if (!requests) throw new Error(`${entityName} does not support task creation (required for ${method})`);
18090 + switch (method) {
18091 + case "tools/call":
18092 + if (!requests.tools?.call) throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
18093 + break;
18094 + default: break;
18095 + }
18096 + }
18097 + /**
18098 + * Asserts that task creation is supported for sampling/createMessage or elicitation/create.
18099 + * Used by Server.assertTaskCapability and Client.assertTaskHandlerCapability.
18100 + *
18101 + * @param requests - The task requests capability object
18102 + * @param method - The method being checked
18103 + * @param entityName - 'Server' or 'Client' for error messages
18104 + * @throws Error if the capability is not supported
18105 + *
18106 + * @experimental
18107 + */
18108 + function assertClientRequestTaskCapability(requests, method, entityName) {
18109 + if (!requests) throw new Error(`${entityName} does not support task creation (required for ${method})`);
18110 + switch (method) {
18111 + case "sampling/createMessage":
18112 + if (!requests.sampling?.createMessage) throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
18113 + break;
18114 + case "elicitation/create":
18115 + if (!requests.elicitation?.create) throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
18116 + break;
18117 + default: break;
18118 + }
18119 + }
18120 +
18121 +//#endregion
18122 +//#region node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
18123 +/**
18124 + * An MCP server on top of a pluggable transport.
18125 + *
18126 + * This server will automatically respond to the initialization flow as initiated from the client.
18127 + *
18128 + * To use with custom types, extend the base Request/Notification/Result types and pass them as type parameters:
18129 + *
18130 + * ```typescript
18131 + * // Custom schemas
18132 + * const CustomRequestSchema = RequestSchema.extend({...})
18133 + * const CustomNotificationSchema = NotificationSchema.extend({...})
18134 + * const CustomResultSchema = ResultSchema.extend({...})
18135 + *
18136 + * // Type aliases
18137 + * type CustomRequest = z.infer<typeof CustomRequestSchema>
18138 + * type CustomNotification = z.infer<typeof CustomNotificationSchema>
18139 + * type CustomResult = z.infer<typeof CustomResultSchema>
18140 + *
18141 + * // Create typed server
18142 + * const server = new Server<CustomRequest, CustomNotification, CustomResult>({
18143 + * name: "CustomServer",
18144 + * version: "1.0.0"
18145 + * })
18146 + * ```
18147 + * @deprecated Use `McpServer` instead for the high-level API. Only use `Server` for advanced use cases.
18148 + */
18149 + var Server = class extends Protocol {
18150 + /**
18151 + * Initializes this server with the given name and version information.
18152 + */
18153 + constructor(_serverInfo, options) {
18154 + super(options);
18155 + this._serverInfo = _serverInfo;
18156 + this._loggingLevels = /* @__PURE__ */ new Map();
18157 + this.LOG_LEVEL_SEVERITY = new Map(LoggingLevelSchema.options.map((level, index) => [level, index]));
18158 + this.isMessageIgnored = (level, sessionId) => {
18159 + const currentLevel = this._loggingLevels.get(sessionId);
18160 + return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
18161 + };
18162 + this._capabilities = options?.capabilities ?? {};
18163 + this._instructions = options?.instructions;
18164 + this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
18165 + this.setRequestHandler(InitializeRequestSchema, (request) => this._oninitialize(request));
18166 + this.setNotificationHandler(InitializedNotificationSchema, () => this.oninitialized?.());
18167 + if (this._capabilities.logging) this.setRequestHandler(SetLevelRequestSchema, async (request, extra) => {
18168 + const transportSessionId = extra.sessionId || extra.requestInfo?.headers["mcp-session-id"] || void 0;
18169 + const { level } = request.params;
18170 + const parseResult = LoggingLevelSchema.safeParse(level);
18171 + if (parseResult.success) this._loggingLevels.set(transportSessionId, parseResult.data);
18172 + return {};
18173 + });
18174 + }
18175 + /**
18176 + * Access experimental features.
18177 + *
18178 + * WARNING: These APIs are experimental and may change without notice.
18179 + *
18180 + * @experimental
18181 + */
18182 + get experimental() {
18183 + if (!this._experimental) this._experimental = { tasks: new ExperimentalServerTasks(this) };
18184 + return this._experimental;
18185 + }
18186 + /**
18187 + * Registers new capabilities. This can only be called before connecting to a transport.
18188 + *
18189 + * The new capabilities will be merged with any existing capabilities previously given (e.g., at initialization).
18190 + */
18191 + registerCapabilities(capabilities) {
18192 + if (this.transport) throw new Error("Cannot register capabilities after connecting to transport");
18193 + this._capabilities = mergeCapabilities(this._capabilities, capabilities);
18194 + }
18195 + /**
18196 + * Override request handler registration to enforce server-side validation for tools/call.
18197 + */
18198 + setRequestHandler(requestSchema, handler) {
18199 + const methodSchema = getObjectShape(requestSchema)?.method;
18200 + if (!methodSchema) throw new Error("Schema is missing a method literal");
18201 + let methodValue;
18202 + if (isZ4Schema(methodSchema)) {
18203 + const v4Schema = methodSchema;
18204 + methodValue = (v4Schema._zod?.def)?.value ?? v4Schema.value;
18205 + } else {
18206 + const v3Schema = methodSchema;
18207 + methodValue = v3Schema._def?.value ?? v3Schema.value;
18208 + }
18209 + if (typeof methodValue !== "string") throw new Error("Schema method literal must be a string");
18210 + if (methodValue === "tools/call") {
18211 + const wrappedHandler = async (request, extra) => {
18212 + const validatedRequest = safeParse$1(CallToolRequestSchema, request);
18213 + if (!validatedRequest.success) {
18214 + const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
18215 + throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call request: ${errorMessage}`);
18216 + }
18217 + const { params } = validatedRequest.data;
18218 + const result = await Promise.resolve(handler(request, extra));
18219 + if (params.task) {
18220 + const taskValidationResult = safeParse$1(CreateTaskResultSchema, result);
18221 + if (!taskValidationResult.success) {
18222 + const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
18223 + throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
18224 + }
18225 + return taskValidationResult.data;
18226 + }
18227 + const validationResult = safeParse$1(CallToolResultSchema, result);
18228 + if (!validationResult.success) {
18229 + const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
18230 + throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call result: ${errorMessage}`);
18231 + }
18232 + return validationResult.data;
18233 + };
18234 + return super.setRequestHandler(requestSchema, wrappedHandler);
18235 + }
18236 + return super.setRequestHandler(requestSchema, handler);
18237 + }
18238 + assertCapabilityForMethod(method) {
18239 + switch (method) {
18240 + case "sampling/createMessage":
18241 + if (!this._clientCapabilities?.sampling) throw new Error(`Client does not support sampling (required for ${method})`);
18242 + break;
18243 + case "elicitation/create":
18244 + if (!this._clientCapabilities?.elicitation) throw new Error(`Client does not support elicitation (required for ${method})`);
18245 + break;
18246 + case "roots/list":
18247 + if (!this._clientCapabilities?.roots) throw new Error(`Client does not support listing roots (required for ${method})`);
18248 + break;
18249 + case "ping": break;
18250 + }
18251 + }
18252 + assertNotificationCapability(method) {
18253 + switch (method) {
18254 + case "notifications/message":
18255 + if (!this._capabilities.logging) throw new Error(`Server does not support logging (required for ${method})`);
18256 + break;
18257 + case "notifications/resources/updated":
18258 + case "notifications/resources/list_changed":
18259 + if (!this._capabilities.resources) throw new Error(`Server does not support notifying about resources (required for ${method})`);
18260 + break;
18261 + case "notifications/tools/list_changed":
18262 + if (!this._capabilities.tools) throw new Error(`Server does not support notifying of tool list changes (required for ${method})`);
18263 + break;
18264 + case "notifications/prompts/list_changed":
18265 + if (!this._capabilities.prompts) throw new Error(`Server does not support notifying of prompt list changes (required for ${method})`);
18266 + break;
18267 + case "notifications/elicitation/complete":
18268 + if (!this._clientCapabilities?.elicitation?.url) throw new Error(`Client does not support URL elicitation (required for ${method})`);
18269 + break;
18270 + case "notifications/cancelled": break;
18271 + case "notifications/progress": break;
18272 + }
18273 + }
18274 + assertRequestHandlerCapability(method) {
18275 + if (!this._capabilities) return;
18276 + switch (method) {
18277 + case "completion/complete":
18278 + if (!this._capabilities.completions) throw new Error(`Server does not support completions (required for ${method})`);
18279 + break;
18280 + case "logging/setLevel":
18281 + if (!this._capabilities.logging) throw new Error(`Server does not support logging (required for ${method})`);
18282 + break;
18283 + case "prompts/get":
18284 + case "prompts/list":
18285 + if (!this._capabilities.prompts) throw new Error(`Server does not support prompts (required for ${method})`);
18286 + break;
18287 + case "resources/list":
18288 + case "resources/templates/list":
18289 + case "resources/read":
18290 + if (!this._capabilities.resources) throw new Error(`Server does not support resources (required for ${method})`);
18291 + break;
18292 + case "tools/call":
18293 + case "tools/list":
18294 + if (!this._capabilities.tools) throw new Error(`Server does not support tools (required for ${method})`);
18295 + break;
18296 + case "tasks/get":
18297 + case "tasks/list":
18298 + case "tasks/result":
18299 + case "tasks/cancel":
18300 + if (!this._capabilities.tasks) throw new Error(`Server does not support tasks capability (required for ${method})`);
18301 + break;
18302 + case "ping":
18303 + case "initialize": break;
18304 + }
18305 + }
18306 + assertTaskCapability(method) {
18307 + assertClientRequestTaskCapability(this._clientCapabilities?.tasks?.requests, method, "Client");
18308 + }
18309 + assertTaskHandlerCapability(method) {
18310 + if (!this._capabilities) return;
18311 + assertToolsCallTaskCapability(this._capabilities.tasks?.requests, method, "Server");
18312 + }
18313 + async _oninitialize(request) {
18314 + const requestedVersion = request.params.protocolVersion;
18315 + this._clientCapabilities = request.params.capabilities;
18316 + this._clientVersion = request.params.clientInfo;
18317 + return {
18318 + protocolVersion: SUPPORTED_PROTOCOL_VERSIONS.includes(requestedVersion) ? requestedVersion : LATEST_PROTOCOL_VERSION,
18319 + capabilities: this.getCapabilities(),
18320 + serverInfo: this._serverInfo,
18321 + ...this._instructions && { instructions: this._instructions }
18322 + };
18323 + }
18324 + /**
18325 + * After initialization has completed, this will be populated with the client's reported capabilities.
18326 + */
18327 + getClientCapabilities() {
18328 + return this._clientCapabilities;
18329 + }
18330 + /**
18331 + * After initialization has completed, this will be populated with information about the client's name and version.
18332 + */
18333 + getClientVersion() {
18334 + return this._clientVersion;
18335 + }
18336 + getCapabilities() {
18337 + return this._capabilities;
18338 + }
18339 + async ping() {
18340 + return this.request({ method: "ping" }, EmptyResultSchema);
18341 + }
18342 + async createMessage(params, options) {
18343 + if (params.tools || params.toolChoice) {
18344 + if (!this._clientCapabilities?.sampling?.tools) throw new Error("Client does not support sampling tools capability.");
18345 + }
18346 + if (params.messages.length > 0) {
18347 + const lastMessage = params.messages[params.messages.length - 1];
18348 + const lastContent = Array.isArray(lastMessage.content) ? lastMessage.content : [lastMessage.content];
18349 + const hasToolResults = lastContent.some((c) => c.type === "tool_result");
18350 + const previousMessage = params.messages.length > 1 ? params.messages[params.messages.length - 2] : void 0;
18351 + const previousContent = previousMessage ? Array.isArray(previousMessage.content) ? previousMessage.content : [previousMessage.content] : [];
18352 + const hasPreviousToolUse = previousContent.some((c) => c.type === "tool_use");
18353 + if (hasToolResults) {
18354 + if (lastContent.some((c) => c.type !== "tool_result")) throw new Error("The last message must contain only tool_result content if any is present");
18355 + if (!hasPreviousToolUse) throw new Error("tool_result blocks are not matching any tool_use from the previous message");
18356 + }
18357 + if (hasPreviousToolUse) {
18358 + const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
18359 + const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
18360 + if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id) => toolResultIds.has(id))) throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
18361 + }
18362 + }
18363 + if (params.tools) return this.request({
18364 + method: "sampling/createMessage",
18365 + params
18366 + }, CreateMessageResultWithToolsSchema, options);
18367 + return this.request({
18368 + method: "sampling/createMessage",
18369 + params
18370 + }, CreateMessageResultSchema, options);
18371 + }
18372 + /**
18373 + * Creates an elicitation request for the given parameters.
18374 + * For backwards compatibility, `mode` may be omitted for form requests and will default to `'form'`.
18375 + * @param params The parameters for the elicitation request.
18376 + * @param options Optional request options.
18377 + * @returns The result of the elicitation request.
18378 + */
18379 + async elicitInput(params, options) {
18380 + switch (params.mode ?? "form") {
18381 + case "url": {
18382 + if (!this._clientCapabilities?.elicitation?.url) throw new Error("Client does not support url elicitation.");
18383 + const urlParams = params;
18384 + return this.request({
18385 + method: "elicitation/create",
18386 + params: urlParams
18387 + }, ElicitResultSchema, options);
18388 + }
18389 + case "form": {
18390 + if (!this._clientCapabilities?.elicitation?.form) throw new Error("Client does not support form elicitation.");
18391 + const formParams = params.mode === "form" ? params : {
18392 + ...params,
18393 + mode: "form"
18394 + };
18395 + const result = await this.request({
18396 + method: "elicitation/create",
18397 + params: formParams
18398 + }, ElicitResultSchema, options);
18399 + if (result.action === "accept" && result.content && formParams.requestedSchema) try {
18400 + const validationResult = this._jsonSchemaValidator.getValidator(formParams.requestedSchema)(result.content);
18401 + if (!validationResult.valid) throw new McpError(ErrorCode.InvalidParams, `Elicitation response content does not match requested schema: ${validationResult.errorMessage}`);
18402 + } catch (error) {
18403 + if (error instanceof McpError) throw error;
18404 + throw new McpError(ErrorCode.InternalError, `Error validating elicitation response: ${error instanceof Error ? error.message : String(error)}`);
18405 + }
18406 + return result;
18407 + }
18408 + }
18409 + }
18410 + /**
18411 + * Creates a reusable callback that, when invoked, will send a `notifications/elicitation/complete`
18412 + * notification for the specified elicitation ID.
18413 + *
18414 + * @param elicitationId The ID of the elicitation to mark as complete.
18415 + * @param options Optional notification options. Useful when the completion notification should be related to a prior request.
18416 + * @returns A function that emits the completion notification when awaited.
18417 + */
18418 + createElicitationCompletionNotifier(elicitationId, options) {
18419 + if (!this._clientCapabilities?.elicitation?.url) throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");
18420 + return () => this.notification({
18421 + method: "notifications/elicitation/complete",
18422 + params: { elicitationId }
18423 + }, options);
18424 + }
18425 + async listRoots(params, options) {
18426 + return this.request({
18427 + method: "roots/list",
18428 + params
18429 + }, ListRootsResultSchema, options);
18430 + }
18431 + /**
18432 + * Sends a logging message to the client, if connected.
18433 + * Note: You only need to send the parameters object, not the entire JSON RPC message
18434 + * @see LoggingMessageNotification
18435 + * @param params
18436 + * @param sessionId optional for stateless and backward compatibility
18437 + */
18438 + async sendLoggingMessage(params, sessionId) {
18439 + if (this._capabilities.logging) {
18440 + if (!this.isMessageIgnored(params.level, sessionId)) return this.notification({
18441 + method: "notifications/message",
18442 + params
18443 + });
18444 + }
18445 + }
18446 + async sendResourceUpdated(params) {
18447 + return this.notification({
18448 + method: "notifications/resources/updated",
18449 + params
18450 + });
18451 + }
18452 + async sendResourceListChanged() {
18453 + return this.notification({ method: "notifications/resources/list_changed" });
18454 + }
18455 + async sendToolListChanged() {
18456 + return this.notification({ method: "notifications/tools/list_changed" });
18457 + }
18458 + async sendPromptListChanged() {
18459 + return this.notification({ method: "notifications/prompts/list_changed" });
18460 + }
18461 + };
18462 +
18463 +//#endregion
18464 +//#region node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
18465 + var COMPLETABLE_SYMBOL = Symbol.for("mcp.completable");
18466 + /**
18467 + * Checks if a schema is completable (has completion metadata).
18468 + */
18469 + function isCompletable(schema) {
18470 + return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
18471 + }
18472 + /**
18473 + * Gets the completer callback from a completable schema, if it exists.
18474 + */
18475 + function getCompleter(schema) {
18476 + return schema[COMPLETABLE_SYMBOL]?.complete;
18477 + }
18478 + var McpZodTypeKind;
18479 + (function(McpZodTypeKind) {
18480 + McpZodTypeKind["Completable"] = "McpCompletable";
18481 + })(McpZodTypeKind || (McpZodTypeKind = {}));
18482 +
18483 +//#endregion
18484 +//#region node_modules/@modelcontextprotocol/sdk/dist/esm/shared/uriTemplate.js
18485 + var MAX_TEMPLATE_LENGTH = 1e6;
18486 + var MAX_VARIABLE_LENGTH = 1e6;
18487 + var MAX_TEMPLATE_EXPRESSIONS = 1e4;
18488 + var MAX_REGEX_LENGTH = 1e6;
18489 + var UriTemplate = class UriTemplate {
18490 + /**
18491 + * Returns true if the given string contains any URI template expressions.
18492 + * A template expression is a sequence of characters enclosed in curly braces,
18493 + * like {foo} or {?bar}.
18494 + */
18495 + static isTemplate(str) {
18496 + return /\{[^}\s]+\}/.test(str);
18497 + }
18498 + static validateLength(str, max, context) {
18499 + if (str.length > max) throw new Error(`${context} exceeds maximum length of ${max} characters (got ${str.length})`);
18500 + }
18501 + get variableNames() {
18502 + return this.parts.flatMap((part) => typeof part === "string" ? [] : part.names);
18503 + }
18504 + constructor(template) {
18505 + UriTemplate.validateLength(template, MAX_TEMPLATE_LENGTH, "Template");
18506 + this.template = template;
18507 + this.parts = this.parse(template);
18508 + }
18509 + toString() {
18510 + return this.template;
18511 + }
18512 + parse(template) {
18513 + const parts = [];
18514 + let currentText = "";
18515 + let i = 0;
18516 + let expressionCount = 0;
18517 + while (i < template.length) if (template[i] === "{") {
18518 + if (currentText) {
18519 + parts.push(currentText);
18520 + currentText = "";
18521 + }
18522 + const end = template.indexOf("}", i);
18523 + if (end === -1) throw new Error("Unclosed template expression");
18524 + expressionCount++;
18525 + if (expressionCount > MAX_TEMPLATE_EXPRESSIONS) throw new Error(`Template contains too many expressions (max ${MAX_TEMPLATE_EXPRESSIONS})`);
18526 + const expr = template.slice(i + 1, end);
18527 + const operator = this.getOperator(expr);
18528 + const exploded = expr.includes("*");
18529 + const names = this.getNames(expr);
18530 + const name = names[0];
18531 + for (const name of names) UriTemplate.validateLength(name, MAX_VARIABLE_LENGTH, "Variable name");
18532 + parts.push({
18533 + name,
18534 + operator,
18535 + names,
18536 + exploded
18537 + });
18538 + i = end + 1;
18539 + } else {
18540 + currentText += template[i];
18541 + i++;
18542 + }
18543 + if (currentText) parts.push(currentText);
18544 + return parts;
18545 + }
18546 + getOperator(expr) {
18547 + return [
18548 + "+",
18549 + "#",
18550 + ".",
18551 + "/",
18552 + "?",
18553 + "&"
18554 + ].find((op) => expr.startsWith(op)) || "";
18555 + }
18556 + getNames(expr) {
18557 + const operator = this.getOperator(expr);
18558 + return expr.slice(operator.length).split(",").map((name) => name.replace("*", "").trim()).filter((name) => name.length > 0);
18559 + }
18560 + encodeValue(value, operator) {
18561 + UriTemplate.validateLength(value, MAX_VARIABLE_LENGTH, "Variable value");
18562 + if (operator === "+" || operator === "#") return encodeURI(value);
18563 + return encodeURIComponent(value);
18564 + }
18565 + expandPart(part, variables) {
18566 + if (part.operator === "?" || part.operator === "&") {
18567 + const pairs = part.names.map((name) => {
18568 + const value = variables[name];
18569 + if (value === void 0) return "";
18570 + return `${name}=${Array.isArray(value) ? value.map((v) => this.encodeValue(v, part.operator)).join(",") : this.encodeValue(value.toString(), part.operator)}`;
18571 + }).filter((pair) => pair.length > 0);
18572 + if (pairs.length === 0) return "";
18573 + return (part.operator === "?" ? "?" : "&") + pairs.join("&");
18574 + }
18575 + if (part.names.length > 1) {
18576 + const values = part.names.map((name) => variables[name]).filter((v) => v !== void 0);
18577 + if (values.length === 0) return "";
18578 + return values.map((v) => Array.isArray(v) ? v[0] : v).join(",");
18579 + }
18580 + const value = variables[part.name];
18581 + if (value === void 0) return "";
18582 + const encoded = (Array.isArray(value) ? value : [value]).map((v) => this.encodeValue(v, part.operator));
18583 + switch (part.operator) {
18584 + case "": return encoded.join(",");
18585 + case "+": return encoded.join(",");
18586 + case "#": return "#" + encoded.join(",");
18587 + case ".": return "." + encoded.join(".");
18588 + case "/": return "/" + encoded.join("/");
18589 + default: return encoded.join(",");
18590 + }
18591 + }
18592 + expand(variables) {
18593 + let result = "";
18594 + let hasQueryParam = false;
18595 + for (const part of this.parts) {
18596 + if (typeof part === "string") {
18597 + result += part;
18598 + continue;
18599 + }
18600 + const expanded = this.expandPart(part, variables);
18601 + if (!expanded) continue;
18602 + if ((part.operator === "?" || part.operator === "&") && hasQueryParam) result += expanded.replace("?", "&");
18603 + else result += expanded;
18604 + if (part.operator === "?" || part.operator === "&") hasQueryParam = true;
18605 + }
18606 + return result;
18607 + }
18608 + escapeRegExp(str) {
18609 + return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
18610 + }
18611 + partToRegExp(part) {
18612 + const patterns = [];
18613 + for (const name of part.names) UriTemplate.validateLength(name, MAX_VARIABLE_LENGTH, "Variable name");
18614 + if (part.operator === "?" || part.operator === "&") {
18615 + for (let i = 0; i < part.names.length; i++) {
18616 + const name = part.names[i];
18617 + const prefix = i === 0 ? "\\" + part.operator : "&";
18618 + patterns.push({
18619 + pattern: prefix + this.escapeRegExp(name) + "=([^&]+)",
18620 + name
18621 + });
18622 + }
18623 + return patterns;
18624 + }
18625 + let pattern;
18626 + const name = part.name;
18627 + switch (part.operator) {
18628 + case "":
18629 + pattern = part.exploded ? "([^/,]+(?:,[^/,]+)*)" : "([^/,]+)";
18630 + break;
18631 + case "+":
18632 + case "#":
18633 + pattern = "(.+)";
18634 + break;
18635 + case ".":
18636 + pattern = "\\.([^/,]+)";
18637 + break;
18638 + case "/":
18639 + pattern = "/" + (part.exploded ? "([^/,]+(?:,[^/,]+)*)" : "([^/,]+)");
18640 + break;
18641 + default: pattern = "([^/]+)";
18642 + }
18643 + patterns.push({
18644 + pattern,
18645 + name
18646 + });
18647 + return patterns;
18648 + }
18649 + match(uri) {
18650 + UriTemplate.validateLength(uri, MAX_TEMPLATE_LENGTH, "URI");
18651 + let pattern = "^";
18652 + const names = [];
18653 + for (const part of this.parts) if (typeof part === "string") pattern += this.escapeRegExp(part);
18654 + else {
18655 + const patterns = this.partToRegExp(part);
18656 + for (const { pattern: partPattern, name } of patterns) {
18657 + pattern += partPattern;
18658 + names.push({
18659 + name,
18660 + exploded: part.exploded
18661 + });
18662 + }
18663 + }
18664 + pattern += "$";
18665 + UriTemplate.validateLength(pattern, MAX_REGEX_LENGTH, "Generated regex pattern");
18666 + const regex = new RegExp(pattern);
18667 + const match = uri.match(regex);
18668 + if (!match) return null;
18669 + const result = {};
18670 + for (let i = 0; i < names.length; i++) {
18671 + const { name, exploded } = names[i];
18672 + const value = match[i + 1];
18673 + const cleanName = name.replace("*", "");
18674 + if (exploded && value.includes(",")) result[cleanName] = value.split(",");
18675 + else result[cleanName] = value;
18676 + }
18677 + return result;
18678 + }
18679 + };
18680 +
18681 +//#endregion
18682 +//#region node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
18683 +/**
18684 + * Tool name validation utilities according to SEP: Specify Format for Tool Names
18685 + *
18686 + * Tool names SHOULD be between 1 and 128 characters in length (inclusive).
18687 + * Tool names are case-sensitive.
18688 + * Allowed characters: uppercase and lowercase ASCII letters (A-Z, a-z), digits
18689 + * (0-9), underscore (_), dash (-), and dot (.).
18690 + * Tool names SHOULD NOT contain spaces, commas, or other special characters.
18691 + */
18692 + /**
18693 + * Regular expression for valid tool names according to SEP-986 specification
18694 + */
18695 + var TOOL_NAME_REGEX = /^[A-Za-z0-9._-]{1,128}$/;
18696 + /**
18697 + * Validates a tool name according to the SEP specification
18698 + * @param name - The tool name to validate
18699 + * @returns An object containing validation result and any warnings
18700 + */
18701 + function validateToolName(name) {
18702 + const warnings = [];
18703 + if (name.length === 0) return {
18704 + isValid: false,
18705 + warnings: ["Tool name cannot be empty"]
18706 + };
18707 + if (name.length > 128) return {
18708 + isValid: false,
18709 + warnings: [`Tool name exceeds maximum length of 128 characters (current: ${name.length})`]
18710 + };
18711 + if (name.includes(" ")) warnings.push("Tool name contains spaces, which may cause parsing issues");
18712 + if (name.includes(",")) warnings.push("Tool name contains commas, which may cause parsing issues");
18713 + if (name.startsWith("-") || name.endsWith("-")) warnings.push("Tool name starts or ends with a dash, which may cause parsing issues in some contexts");
18714 + if (name.startsWith(".") || name.endsWith(".")) warnings.push("Tool name starts or ends with a dot, which may cause parsing issues in some contexts");
18715 + if (!TOOL_NAME_REGEX.test(name)) {
18716 + const invalidChars = name.split("").filter((char) => !/[A-Za-z0-9._-]/.test(char)).filter((char, index, arr) => arr.indexOf(char) === index);
18717 + warnings.push(`Tool name contains invalid characters: ${invalidChars.map((c) => `"${c}"`).join(", ")}`, "Allowed characters are: A-Z, a-z, 0-9, underscore (_), dash (-), and dot (.)");
18718 + return {
18719 + isValid: false,
18720 + warnings
18721 + };
18722 + }
18723 + return {
18724 + isValid: true,
18725 + warnings
18726 + };
18727 + }
18728 + /**
18729 + * Issues warnings for non-conforming tool names
18730 + * @param name - The tool name that triggered the warnings
18731 + * @param warnings - Array of warning messages
18732 + */
18733 + function issueToolNameWarning(name, warnings) {
18734 + if (warnings.length > 0) {
18735 + console.warn(`Tool name validation warning for "${name}":`);
18736 + for (const warning of warnings) console.warn(` - ${warning}`);
18737 + console.warn("Tool registration will proceed, but this may cause compatibility issues.");
18738 + console.warn("Consider updating the tool name to conform to the MCP tool naming standard.");
18739 + console.warn("See SEP: Specify Format for Tool Names (https://github.com/modelcontextprotocol/modelcontextprotocol/issues/986) for more details.");
18740 + }
18741 + }
18742 + /**
18743 + * Validates a tool name and issues warnings for non-conforming names
18744 + * @param name - The tool name to validate
18745 + * @returns true if the name is valid, false otherwise
18746 + */
18747 + function validateAndWarnToolName(name) {
18748 + const result = validateToolName(name);
18749 + issueToolNameWarning(name, result.warnings);
18750 + return result.isValid;
18751 + }
18752 +
18753 +//#endregion
18754 +//#region node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
18755 +/**
18756 + * Experimental McpServer task features for MCP SDK.
18757 + * WARNING: These APIs are experimental and may change without notice.
18758 + *
18759 + * @experimental
18760 + */
18761 + /**
18762 + * Experimental task features for McpServer.
18763 + *
18764 + * Access via `server.experimental.tasks`:
18765 + * ```typescript
18766 + * server.experimental.tasks.registerToolTask('long-running', config, handler);
18767 + * ```
18768 + *
18769 + * @experimental
18770 + */
18771 + var ExperimentalMcpServerTasks = class {
18772 + constructor(_mcpServer) {
18773 + this._mcpServer = _mcpServer;
18774 + }
18775 + registerToolTask(name, config, handler) {
18776 + const execution = {
18777 + taskSupport: "required",
18778 + ...config.execution
18779 + };
18780 + if (execution.taskSupport === "forbidden") throw new Error(`Cannot register task-based tool '${name}' with taskSupport 'forbidden'. Use registerTool() instead.`);
18781 + return this._mcpServer._createRegisteredTool(name, config.title, config.description, config.inputSchema, config.outputSchema, config.annotations, execution, config._meta, handler);
18782 + }
18783 + };
18784 +
18785 +//#endregion
18786 +//#region node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
18787 +/**
18788 + * High-level MCP server that provides a simpler API for working with resources, tools, and prompts.
18789 + * For advanced usage (like sending notifications or setting custom request handlers), use the underlying
18790 + * Server instance available via the `server` property.
18791 + */
18792 + var McpServer = class {
18793 + constructor(serverInfo, options) {
18794 + this._registeredResources = {};
18795 + this._registeredResourceTemplates = {};
18796 + this._registeredTools = {};
18797 + this._registeredPrompts = {};
18798 + this._toolHandlersInitialized = false;
18799 + this._completionHandlerInitialized = false;
18800 + this._resourceHandlersInitialized = false;
18801 + this._promptHandlersInitialized = false;
18802 + this.server = new Server(serverInfo, options);
18803 + }
18804 + /**
18805 + * Access experimental features.
18806 + *
18807 + * WARNING: These APIs are experimental and may change without notice.
18808 + *
18809 + * @experimental
18810 + */
18811 + get experimental() {
18812 + if (!this._experimental) this._experimental = { tasks: new ExperimentalMcpServerTasks(this) };
18813 + return this._experimental;
18814 + }
18815 + /**
18816 + * Attaches to the given transport, starts it, and starts listening for messages.
18817 + *
18818 + * The `server` object assumes ownership of the Transport, replacing any callbacks that have already been set, and expects that it is the only user of the Transport instance going forward.
18819 + */
18820 + async connect(transport) {
18821 + return await this.server.connect(transport);
18822 + }
18823 + /**
18824 + * Closes the connection.
18825 + */
18826 + async close() {
18827 + await this.server.close();
18828 + }
18829 + setToolRequestHandlers() {
18830 + if (this._toolHandlersInitialized) return;
18831 + this.server.assertCanSetRequestHandler(getMethodValue(ListToolsRequestSchema));
18832 + this.server.assertCanSetRequestHandler(getMethodValue(CallToolRequestSchema));
18833 + this.server.registerCapabilities({ tools: { listChanged: true } });
18834 + this.server.setRequestHandler(ListToolsRequestSchema, () => ({ tools: Object.entries(this._registeredTools).filter(([, tool]) => tool.enabled).map(([name, tool]) => {
18835 + const toolDefinition = {
18836 + name,
18837 + title: tool.title,
18838 + description: tool.description,
18839 + inputSchema: (() => {
18840 + const obj = normalizeObjectSchema(tool.inputSchema);
18841 + return obj ? toJsonSchemaCompat(obj, {
18842 + strictUnions: true,
18843 + pipeStrategy: "input"
18844 + }) : EMPTY_OBJECT_JSON_SCHEMA;
18845 + })(),
18846 + annotations: tool.annotations,
18847 + execution: tool.execution,
18848 + _meta: tool._meta
18849 + };
18850 + if (tool.outputSchema) {
18851 + const obj = normalizeObjectSchema(tool.outputSchema);
18852 + if (obj) toolDefinition.outputSchema = toJsonSchemaCompat(obj, {
18853 + strictUnions: true,
18854 + pipeStrategy: "output"
18855 + });
18856 + }
18857 + return toolDefinition;
18858 + }) }));
18859 + this.server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
18860 + try {
18861 + const tool = this._registeredTools[request.params.name];
18862 + if (!tool) throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} not found`);
18863 + if (!tool.enabled) throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} disabled`);
18864 + const isTaskRequest = !!request.params.task;
18865 + const taskSupport = tool.execution?.taskSupport;
18866 + const isTaskHandler = "createTask" in tool.handler;
18867 + if ((taskSupport === "required" || taskSupport === "optional") && !isTaskHandler) throw new McpError(ErrorCode.InternalError, `Tool ${request.params.name} has taskSupport '${taskSupport}' but was not registered with registerToolTask`);
18868 + if (taskSupport === "required" && !isTaskRequest) throw new McpError(ErrorCode.MethodNotFound, `Tool ${request.params.name} requires task augmentation (taskSupport: 'required')`);
18869 + if (taskSupport === "optional" && !isTaskRequest && isTaskHandler) return await this.handleAutomaticTaskPolling(tool, request, extra);
18870 + const args = await this.validateToolInput(tool, request.params.arguments, request.params.name);
18871 + const result = await this.executeToolHandler(tool, args, extra);
18872 + if (isTaskRequest) return result;
18873 + await this.validateToolOutput(tool, result, request.params.name);
18874 + return result;
18875 + } catch (error) {
18876 + if (error instanceof McpError) {
18877 + if (error.code === ErrorCode.UrlElicitationRequired) throw error;
18878 + }
18879 + return this.createToolError(error instanceof Error ? error.message : String(error));
18880 + }
18881 + });
18882 + this._toolHandlersInitialized = true;
18883 + }
18884 + /**
18885 + * Creates a tool error result.
18886 + *
18887 + * @param errorMessage - The error message.
18888 + * @returns The tool error result.
18889 + */
18890 + createToolError(errorMessage) {
18891 + return {
18892 + content: [{
18893 + type: "text",
18894 + text: errorMessage
18895 + }],
18896 + isError: true
18897 + };
18898 + }
18899 + /**
18900 + * Validates tool input arguments against the tool's input schema.
18901 + */
18902 + async validateToolInput(tool, args, toolName) {
18903 + if (!tool.inputSchema) return;
18904 + const parseResult = await safeParseAsync$1(normalizeObjectSchema(tool.inputSchema) ?? tool.inputSchema, args);
18905 + if (!parseResult.success) {
18906 + const errorMessage = getParseErrorMessage("error" in parseResult ? parseResult.error : "Unknown error");
18907 + throw new McpError(ErrorCode.InvalidParams, `Input validation error: Invalid arguments for tool ${toolName}: ${errorMessage}`);
18908 + }
18909 + return parseResult.data;
18910 + }
18911 + /**
18912 + * Validates tool output against the tool's output schema.
18913 + */
18914 + async validateToolOutput(tool, result, toolName) {
18915 + if (!tool.outputSchema) return;
18916 + if (!("content" in result)) return;
18917 + if (result.isError) return;
18918 + if (!result.structuredContent) throw new McpError(ErrorCode.InvalidParams, `Output validation error: Tool ${toolName} has an output schema but no structured content was provided`);
18919 + const parseResult = await safeParseAsync$1(normalizeObjectSchema(tool.outputSchema), result.structuredContent);
18920 + if (!parseResult.success) {
18921 + const errorMessage = getParseErrorMessage("error" in parseResult ? parseResult.error : "Unknown error");
18922 + throw new McpError(ErrorCode.InvalidParams, `Output validation error: Invalid structured content for tool ${toolName}: ${errorMessage}`);
18923 + }
18924 + }
18925 + /**
18926 + * Executes a tool handler (either regular or task-based).
18927 + */
18928 + async executeToolHandler(tool, args, extra) {
18929 + const handler = tool.handler;
18930 + if ("createTask" in handler) {
18931 + if (!extra.taskStore) throw new Error("No task store provided.");
18932 + const taskExtra = {
18933 + ...extra,
18934 + taskStore: extra.taskStore
18935 + };
18936 + if (tool.inputSchema) {
18937 + const typedHandler = handler;
18938 + return await Promise.resolve(typedHandler.createTask(args, taskExtra));
18939 + } else {
18940 + const typedHandler = handler;
18941 + return await Promise.resolve(typedHandler.createTask(taskExtra));
18942 + }
18943 + }
18944 + if (tool.inputSchema) {
18945 + const typedHandler = handler;
18946 + return await Promise.resolve(typedHandler(args, extra));
18947 + } else {
18948 + const typedHandler = handler;
18949 + return await Promise.resolve(typedHandler(extra));
18950 + }
18951 + }
18952 + /**
18953 + * Handles automatic task polling for tools with taskSupport 'optional'.
18954 + */
18955 + async handleAutomaticTaskPolling(tool, request, extra) {
18956 + if (!extra.taskStore) throw new Error("No task store provided for task-capable tool.");
18957 + const args = await this.validateToolInput(tool, request.params.arguments, request.params.name);
18958 + const handler = tool.handler;
18959 + const taskExtra = {
18960 + ...extra,
18961 + taskStore: extra.taskStore
18962 + };
18963 + const createTaskResult = args ? await Promise.resolve(handler.createTask(args, taskExtra)) : await Promise.resolve(handler.createTask(taskExtra));
18964 + const taskId = createTaskResult.task.taskId;
18965 + let task = createTaskResult.task;
18966 + const pollInterval = task.pollInterval ?? 5e3;
18967 + while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
18968 + await new Promise((resolve) => setTimeout(resolve, pollInterval));
18969 + const updatedTask = await extra.taskStore.getTask(taskId);
18970 + if (!updatedTask) throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
18971 + task = updatedTask;
18972 + }
18973 + return await extra.taskStore.getTaskResult(taskId);
18974 + }
18975 + setCompletionRequestHandler() {
18976 + if (this._completionHandlerInitialized) return;
18977 + this.server.assertCanSetRequestHandler(getMethodValue(CompleteRequestSchema));
18978 + this.server.registerCapabilities({ completions: {} });
18979 + this.server.setRequestHandler(CompleteRequestSchema, async (request) => {
18980 + switch (request.params.ref.type) {
18981 + case "ref/prompt":
18982 + assertCompleteRequestPrompt(request);
18983 + return this.handlePromptCompletion(request, request.params.ref);
18984 + case "ref/resource":
18985 + assertCompleteRequestResourceTemplate(request);
18986 + return this.handleResourceCompletion(request, request.params.ref);
18987 + default: throw new McpError(ErrorCode.InvalidParams, `Invalid completion reference: ${request.params.ref}`);
18988 + }
18989 + });
18990 + this._completionHandlerInitialized = true;
18991 + }
18992 + async handlePromptCompletion(request, ref) {
18993 + const prompt = this._registeredPrompts[ref.name];
18994 + if (!prompt) throw new McpError(ErrorCode.InvalidParams, `Prompt ${ref.name} not found`);
18995 + if (!prompt.enabled) throw new McpError(ErrorCode.InvalidParams, `Prompt ${ref.name} disabled`);
18996 + if (!prompt.argsSchema) return EMPTY_COMPLETION_RESULT;
18997 + const field = getObjectShape(prompt.argsSchema)?.[request.params.argument.name];
18998 + if (!isCompletable(field)) return EMPTY_COMPLETION_RESULT;
18999 + const completer = getCompleter(field);
19000 + if (!completer) return EMPTY_COMPLETION_RESULT;
19001 + return createCompletionResult(await completer(request.params.argument.value, request.params.context));
19002 + }
19003 + async handleResourceCompletion(request, ref) {
19004 + const template = Object.values(this._registeredResourceTemplates).find((t) => t.resourceTemplate.uriTemplate.toString() === ref.uri);
19005 + if (!template) {
19006 + if (this._registeredResources[ref.uri]) return EMPTY_COMPLETION_RESULT;
19007 + throw new McpError(ErrorCode.InvalidParams, `Resource template ${request.params.ref.uri} not found`);
19008 + }
19009 + const completer = template.resourceTemplate.completeCallback(request.params.argument.name);
19010 + if (!completer) return EMPTY_COMPLETION_RESULT;
19011 + return createCompletionResult(await completer(request.params.argument.value, request.params.context));
19012 + }
19013 + setResourceRequestHandlers() {
19014 + if (this._resourceHandlersInitialized) return;
19015 + this.server.assertCanSetRequestHandler(getMethodValue(ListResourcesRequestSchema));
19016 + this.server.assertCanSetRequestHandler(getMethodValue(ListResourceTemplatesRequestSchema));
19017 + this.server.assertCanSetRequestHandler(getMethodValue(ReadResourceRequestSchema));
19018 + this.server.registerCapabilities({ resources: { listChanged: true } });
19019 + this.server.setRequestHandler(ListResourcesRequestSchema, async (request, extra) => {
19020 + const resources = Object.entries(this._registeredResources).filter(([_, resource]) => resource.enabled).map(([uri, resource]) => ({
19021 + uri,
19022 + name: resource.name,
19023 + ...resource.metadata
19024 + }));
19025 + const templateResources = [];
19026 + for (const template of Object.values(this._registeredResourceTemplates)) {
19027 + if (!template.resourceTemplate.listCallback) continue;
19028 + const result = await template.resourceTemplate.listCallback(extra);
19029 + for (const resource of result.resources) templateResources.push({
19030 + ...template.metadata,
19031 + ...resource
19032 + });
19033 + }
19034 + return { resources: [...resources, ...templateResources] };
19035 + });
19036 + this.server.setRequestHandler(ListResourceTemplatesRequestSchema, async () => {
19037 + return { resourceTemplates: Object.entries(this._registeredResourceTemplates).map(([name, template]) => ({
19038 + name,
19039 + uriTemplate: template.resourceTemplate.uriTemplate.toString(),
19040 + ...template.metadata
19041 + })) };
19042 + });
19043 + this.server.setRequestHandler(ReadResourceRequestSchema, async (request, extra) => {
19044 + const uri = new URL(request.params.uri);
19045 + const resource = this._registeredResources[uri.toString()];
19046 + if (resource) {
19047 + if (!resource.enabled) throw new McpError(ErrorCode.InvalidParams, `Resource ${uri} disabled`);
19048 + return resource.readCallback(uri, extra);
19049 + }
19050 + for (const template of Object.values(this._registeredResourceTemplates)) {
19051 + const variables = template.resourceTemplate.uriTemplate.match(uri.toString());
19052 + if (variables) return template.readCallback(uri, variables, extra);
19053 + }
19054 + throw new McpError(ErrorCode.InvalidParams, `Resource ${uri} not found`);
19055 + });
19056 + this._resourceHandlersInitialized = true;
19057 + }
19058 + setPromptRequestHandlers() {
19059 + if (this._promptHandlersInitialized) return;
19060 + this.server.assertCanSetRequestHandler(getMethodValue(ListPromptsRequestSchema));
19061 + this.server.assertCanSetRequestHandler(getMethodValue(GetPromptRequestSchema));
19062 + this.server.registerCapabilities({ prompts: { listChanged: true } });
19063 + this.server.setRequestHandler(ListPromptsRequestSchema, () => ({ prompts: Object.entries(this._registeredPrompts).filter(([, prompt]) => prompt.enabled).map(([name, prompt]) => {
19064 + return {
19065 + name,
19066 + title: prompt.title,
19067 + description: prompt.description,
19068 + arguments: prompt.argsSchema ? promptArgumentsFromSchema(prompt.argsSchema) : void 0
19069 + };
19070 + }) }));
19071 + this.server.setRequestHandler(GetPromptRequestSchema, async (request, extra) => {
19072 + const prompt = this._registeredPrompts[request.params.name];
19073 + if (!prompt) throw new McpError(ErrorCode.InvalidParams, `Prompt ${request.params.name} not found`);
19074 + if (!prompt.enabled) throw new McpError(ErrorCode.InvalidParams, `Prompt ${request.params.name} disabled`);
19075 + if (prompt.argsSchema) {
19076 + const parseResult = await safeParseAsync$1(normalizeObjectSchema(prompt.argsSchema), request.params.arguments);
19077 + if (!parseResult.success) {
19078 + const errorMessage = getParseErrorMessage("error" in parseResult ? parseResult.error : "Unknown error");
19079 + throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for prompt ${request.params.name}: ${errorMessage}`);
19080 + }
19081 + const args = parseResult.data;
19082 + const cb = prompt.callback;
19083 + return await Promise.resolve(cb(args, extra));
19084 + } else {
19085 + const cb = prompt.callback;
19086 + return await Promise.resolve(cb(extra));
19087 + }
19088 + });
19089 + this._promptHandlersInitialized = true;
19090 + }
19091 + resource(name, uriOrTemplate, ...rest) {
19092 + let metadata;
19093 + if (typeof rest[0] === "object") metadata = rest.shift();
19094 + const readCallback = rest[0];
19095 + if (typeof uriOrTemplate === "string") {
19096 + if (this._registeredResources[uriOrTemplate]) throw new Error(`Resource ${uriOrTemplate} is already registered`);
19097 + const registeredResource = this._createRegisteredResource(name, void 0, uriOrTemplate, metadata, readCallback);
19098 + this.setResourceRequestHandlers();
19099 + this.sendResourceListChanged();
19100 + return registeredResource;
19101 + } else {
19102 + if (this._registeredResourceTemplates[name]) throw new Error(`Resource template ${name} is already registered`);
19103 + const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, void 0, uriOrTemplate, metadata, readCallback);
19104 + this.setResourceRequestHandlers();
19105 + this.sendResourceListChanged();
19106 + return registeredResourceTemplate;
19107 + }
19108 + }
19109 + registerResource(name, uriOrTemplate, config, readCallback) {
19110 + if (typeof uriOrTemplate === "string") {
19111 + if (this._registeredResources[uriOrTemplate]) throw new Error(`Resource ${uriOrTemplate} is already registered`);
19112 + const registeredResource = this._createRegisteredResource(name, config.title, uriOrTemplate, config, readCallback);
19113 + this.setResourceRequestHandlers();
19114 + this.sendResourceListChanged();
19115 + return registeredResource;
19116 + } else {
19117 + if (this._registeredResourceTemplates[name]) throw new Error(`Resource template ${name} is already registered`);
19118 + const registeredResourceTemplate = this._createRegisteredResourceTemplate(name, config.title, uriOrTemplate, config, readCallback);
19119 + this.setResourceRequestHandlers();
19120 + this.sendResourceListChanged();
19121 + return registeredResourceTemplate;
19122 + }
19123 + }
19124 + _createRegisteredResource(name, title, uri, metadata, readCallback) {
19125 + const registeredResource = {
19126 + name,
19127 + title,
19128 + metadata,
19129 + readCallback,
19130 + enabled: true,
19131 + disable: () => registeredResource.update({ enabled: false }),
19132 + enable: () => registeredResource.update({ enabled: true }),
19133 + remove: () => registeredResource.update({ uri: null }),
19134 + update: (updates) => {
19135 + if (typeof updates.uri !== "undefined" && updates.uri !== uri) {
19136 + delete this._registeredResources[uri];
19137 + if (updates.uri) this._registeredResources[updates.uri] = registeredResource;
19138 + }
19139 + if (typeof updates.name !== "undefined") registeredResource.name = updates.name;
19140 + if (typeof updates.title !== "undefined") registeredResource.title = updates.title;
19141 + if (typeof updates.metadata !== "undefined") registeredResource.metadata = updates.metadata;
19142 + if (typeof updates.callback !== "undefined") registeredResource.readCallback = updates.callback;
19143 + if (typeof updates.enabled !== "undefined") registeredResource.enabled = updates.enabled;
19144 + this.sendResourceListChanged();
19145 + }
19146 + };
19147 + this._registeredResources[uri] = registeredResource;
19148 + return registeredResource;
19149 + }
19150 + _createRegisteredResourceTemplate(name, title, template, metadata, readCallback) {
19151 + const registeredResourceTemplate = {
19152 + resourceTemplate: template,
19153 + title,
19154 + metadata,
19155 + readCallback,
19156 + enabled: true,
19157 + disable: () => registeredResourceTemplate.update({ enabled: false }),
19158 + enable: () => registeredResourceTemplate.update({ enabled: true }),
19159 + remove: () => registeredResourceTemplate.update({ name: null }),
19160 + update: (updates) => {
19161 + if (typeof updates.name !== "undefined" && updates.name !== name) {
19162 + delete this._registeredResourceTemplates[name];
19163 + if (updates.name) this._registeredResourceTemplates[updates.name] = registeredResourceTemplate;
19164 + }
19165 + if (typeof updates.title !== "undefined") registeredResourceTemplate.title = updates.title;
19166 + if (typeof updates.template !== "undefined") registeredResourceTemplate.resourceTemplate = updates.template;
19167 + if (typeof updates.metadata !== "undefined") registeredResourceTemplate.metadata = updates.metadata;
19168 + if (typeof updates.callback !== "undefined") registeredResourceTemplate.readCallback = updates.callback;
19169 + if (typeof updates.enabled !== "undefined") registeredResourceTemplate.enabled = updates.enabled;
19170 + this.sendResourceListChanged();
19171 + }
19172 + };
19173 + this._registeredResourceTemplates[name] = registeredResourceTemplate;
19174 + const variableNames = template.uriTemplate.variableNames;
19175 + if (Array.isArray(variableNames) && variableNames.some((v) => !!template.completeCallback(v))) this.setCompletionRequestHandler();
19176 + return registeredResourceTemplate;
19177 + }
19178 + _createRegisteredPrompt(name, title, description, argsSchema, callback) {
19179 + const registeredPrompt = {
19180 + title,
19181 + description,
19182 + argsSchema: argsSchema === void 0 ? void 0 : objectFromShape(argsSchema),
19183 + callback,
19184 + enabled: true,
19185 + disable: () => registeredPrompt.update({ enabled: false }),
19186 + enable: () => registeredPrompt.update({ enabled: true }),
19187 + remove: () => registeredPrompt.update({ name: null }),
19188 + update: (updates) => {
19189 + if (typeof updates.name !== "undefined" && updates.name !== name) {
19190 + delete this._registeredPrompts[name];
19191 + if (updates.name) this._registeredPrompts[updates.name] = registeredPrompt;
19192 + }
19193 + if (typeof updates.title !== "undefined") registeredPrompt.title = updates.title;
19194 + if (typeof updates.description !== "undefined") registeredPrompt.description = updates.description;
19195 + if (typeof updates.argsSchema !== "undefined") registeredPrompt.argsSchema = objectFromShape(updates.argsSchema);
19196 + if (typeof updates.callback !== "undefined") registeredPrompt.callback = updates.callback;
19197 + if (typeof updates.enabled !== "undefined") registeredPrompt.enabled = updates.enabled;
19198 + this.sendPromptListChanged();
19199 + }
19200 + };
19201 + this._registeredPrompts[name] = registeredPrompt;
19202 + if (argsSchema) {
19203 + if (Object.values(argsSchema).some((field) => {
19204 + return isCompletable(field instanceof ZodOptional$1 ? field._def?.innerType : field);
19205 + })) this.setCompletionRequestHandler();
19206 + }
19207 + return registeredPrompt;
19208 + }
19209 + _createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, execution, _meta, handler) {
19210 + validateAndWarnToolName(name);
19211 + const registeredTool = {
19212 + title,
19213 + description,
19214 + inputSchema: getZodSchemaObject(inputSchema),
19215 + outputSchema: getZodSchemaObject(outputSchema),
19216 + annotations,
19217 + execution,
19218 + _meta,
19219 + handler,
19220 + enabled: true,
19221 + disable: () => registeredTool.update({ enabled: false }),
19222 + enable: () => registeredTool.update({ enabled: true }),
19223 + remove: () => registeredTool.update({ name: null }),
19224 + update: (updates) => {
19225 + if (typeof updates.name !== "undefined" && updates.name !== name) {
19226 + if (typeof updates.name === "string") validateAndWarnToolName(updates.name);
19227 + delete this._registeredTools[name];
19228 + if (updates.name) this._registeredTools[updates.name] = registeredTool;
19229 + }
19230 + if (typeof updates.title !== "undefined") registeredTool.title = updates.title;
19231 + if (typeof updates.description !== "undefined") registeredTool.description = updates.description;
19232 + if (typeof updates.paramsSchema !== "undefined") registeredTool.inputSchema = objectFromShape(updates.paramsSchema);
19233 + if (typeof updates.outputSchema !== "undefined") registeredTool.outputSchema = objectFromShape(updates.outputSchema);
19234 + if (typeof updates.callback !== "undefined") registeredTool.handler = updates.callback;
19235 + if (typeof updates.annotations !== "undefined") registeredTool.annotations = updates.annotations;
19236 + if (typeof updates._meta !== "undefined") registeredTool._meta = updates._meta;
19237 + if (typeof updates.enabled !== "undefined") registeredTool.enabled = updates.enabled;
19238 + this.sendToolListChanged();
19239 + }
19240 + };
19241 + this._registeredTools[name] = registeredTool;
19242 + this.setToolRequestHandlers();
19243 + this.sendToolListChanged();
19244 + return registeredTool;
19245 + }
19246 + /**
19247 + * tool() implementation. Parses arguments passed to overrides defined above.
19248 + */
19249 + tool(name, ...rest) {
19250 + if (this._registeredTools[name]) throw new Error(`Tool ${name} is already registered`);
19251 + let description;
19252 + let inputSchema;
19253 + let outputSchema;
19254 + let annotations;
19255 + if (typeof rest[0] === "string") description = rest.shift();
19256 + if (rest.length > 1) {
19257 + const firstArg = rest[0];
19258 + if (isZodRawShapeCompat(firstArg)) {
19259 + inputSchema = rest.shift();
19260 + if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !isZodRawShapeCompat(rest[0])) annotations = rest.shift();
19261 + } else if (typeof firstArg === "object" && firstArg !== null) annotations = rest.shift();
19262 + }
19263 + const callback = rest[0];
19264 + return this._createRegisteredTool(name, void 0, description, inputSchema, outputSchema, annotations, { taskSupport: "forbidden" }, void 0, callback);
19265 + }
19266 + /**
19267 + * Registers a tool with a config object and callback.
19268 + */
19269 + registerTool(name, config, cb) {
19270 + if (this._registeredTools[name]) throw new Error(`Tool ${name} is already registered`);
19271 + const { title, description, inputSchema, outputSchema, annotations, _meta } = config;
19272 + return this._createRegisteredTool(name, title, description, inputSchema, outputSchema, annotations, { taskSupport: "forbidden" }, _meta, cb);
19273 + }
19274 + prompt(name, ...rest) {
19275 + if (this._registeredPrompts[name]) throw new Error(`Prompt ${name} is already registered`);
19276 + let description;
19277 + if (typeof rest[0] === "string") description = rest.shift();
19278 + let argsSchema;
19279 + if (rest.length > 1) argsSchema = rest.shift();
19280 + const cb = rest[0];
19281 + const registeredPrompt = this._createRegisteredPrompt(name, void 0, description, argsSchema, cb);
19282 + this.setPromptRequestHandlers();
19283 + this.sendPromptListChanged();
19284 + return registeredPrompt;
19285 + }
19286 + /**
19287 + * Registers a prompt with a config object and callback.
19288 + */
19289 + registerPrompt(name, config, cb) {
19290 + if (this._registeredPrompts[name]) throw new Error(`Prompt ${name} is already registered`);
19291 + const { title, description, argsSchema } = config;
19292 + const registeredPrompt = this._createRegisteredPrompt(name, title, description, argsSchema, cb);
19293 + this.setPromptRequestHandlers();
19294 + this.sendPromptListChanged();
19295 + return registeredPrompt;
19296 + }
19297 + /**
19298 + * Checks if the server is connected to a transport.
19299 + * @returns True if the server is connected
19300 + */
19301 + isConnected() {
19302 + return this.server.transport !== void 0;
19303 + }
19304 + /**
19305 + * Sends a logging message to the client, if connected.
19306 + * Note: You only need to send the parameters object, not the entire JSON RPC message
19307 + * @see LoggingMessageNotification
19308 + * @param params
19309 + * @param sessionId optional for stateless and backward compatibility
19310 + */
19311 + async sendLoggingMessage(params, sessionId) {
19312 + return this.server.sendLoggingMessage(params, sessionId);
19313 + }
19314 + /**
19315 + * Sends a resource list changed event to the client, if connected.
19316 + */
19317 + sendResourceListChanged() {
19318 + if (this.isConnected()) this.server.sendResourceListChanged();
19319 + }
19320 + /**
19321 + * Sends a tool list changed event to the client, if connected.
19322 + */
19323 + sendToolListChanged() {
19324 + if (this.isConnected()) this.server.sendToolListChanged();
19325 + }
19326 + /**
19327 + * Sends a prompt list changed event to the client, if connected.
19328 + */
19329 + sendPromptListChanged() {
19330 + if (this.isConnected()) this.server.sendPromptListChanged();
19331 + }
19332 + };
19333 + /**
19334 + * A resource template combines a URI pattern with optional functionality to enumerate
19335 + * all resources matching that pattern.
19336 + */
19337 + var ResourceTemplate = class {
19338 + constructor(uriTemplate, _callbacks) {
19339 + this._callbacks = _callbacks;
19340 + this._uriTemplate = typeof uriTemplate === "string" ? new UriTemplate(uriTemplate) : uriTemplate;
19341 + }
19342 + /**
19343 + * Gets the URI template pattern.
19344 + */
19345 + get uriTemplate() {
19346 + return this._uriTemplate;
19347 + }
19348 + /**
19349 + * Gets the list callback, if one was provided.
19350 + */
19351 + get listCallback() {
19352 + return this._callbacks.list;
19353 + }
19354 + /**
19355 + * Gets the callback for completing a specific URI template variable, if one was provided.
19356 + */
19357 + completeCallback(variable) {
19358 + return this._callbacks.complete?.[variable];
19359 + }
19360 + };
19361 + var EMPTY_OBJECT_JSON_SCHEMA = {
19362 + type: "object",
19363 + properties: {}
19364 + };
19365 + /**
19366 + * Checks if a value looks like a Zod schema by checking for parse/safeParse methods.
19367 + */
19368 + function isZodTypeLike(value) {
19369 + return value !== null && typeof value === "object" && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
19370 + }
19371 + /**
19372 + * Checks if an object is a Zod schema instance (v3 or v4).
19373 + *
19374 + * Zod schemas have internal markers:
19375 + * - v3: `_def` property
19376 + * - v4: `_zod` property
19377 + *
19378 + * This includes transformed schemas like z.preprocess(), z.transform(), z.pipe().
19379 + */
19380 + function isZodSchemaInstance(obj) {
19381 + return "_def" in obj || "_zod" in obj || isZodTypeLike(obj);
19382 + }
19383 + /**
19384 + * Checks if an object is a "raw shape" - a plain object where values are Zod schemas.
19385 + *
19386 + * Raw shapes are used as shorthand: `{ name: z.string() }` instead of `z.object({ name: z.string() })`.
19387 + *
19388 + * IMPORTANT: This must NOT match actual Zod schema instances (like z.preprocess, z.pipe),
19389 + * which have internal properties that could be mistaken for schema values.
19390 + */
19391 + function isZodRawShapeCompat(obj) {
19392 + if (typeof obj !== "object" || obj === null) return false;
19393 + if (isZodSchemaInstance(obj)) return false;
19394 + if (Object.keys(obj).length === 0) return true;
19395 + return Object.values(obj).some(isZodTypeLike);
19396 + }
19397 + /**
19398 + * Converts a provided Zod schema to a Zod object if it is a ZodRawShapeCompat,
19399 + * otherwise returns the schema as is.
19400 + */
19401 + function getZodSchemaObject(schema) {
19402 + if (!schema) return;
19403 + if (isZodRawShapeCompat(schema)) return objectFromShape(schema);
19404 + return schema;
19405 + }
19406 + function promptArgumentsFromSchema(schema) {
19407 + const shape = getObjectShape(schema);
19408 + if (!shape) return [];
19409 + return Object.entries(shape).map(([name, field]) => {
19410 + return {
19411 + name,
19412 + description: getSchemaDescription(field),
19413 + required: !isSchemaOptional(field)
19414 + };
19415 + });
19416 + }
19417 + function getMethodValue(schema) {
19418 + const methodSchema = getObjectShape(schema)?.method;
19419 + if (!methodSchema) throw new Error("Schema is missing a method literal");
19420 + const value = getLiteralValue(methodSchema);
19421 + if (typeof value === "string") return value;
19422 + throw new Error("Schema method literal must be a string");
19423 + }
19424 + function createCompletionResult(suggestions) {
19425 + return { completion: {
19426 + values: suggestions.slice(0, 100),
19427 + total: suggestions.length,
19428 + hasMore: suggestions.length > 100
19429 + } };
19430 + }
19431 + var EMPTY_COMPLETION_RESULT = { completion: {
19432 + values: [],
19433 + hasMore: false
19434 + } };
19435 +
19436 +//#endregion
19437 +//#region packages/packages/libs/elementor-mcp-common/src/utils.ts
19438 + var getElementor = () => window.elementor;
19439 + var getElementorFrontend = () => window.elementorFrontend;
19440 + var get$e = () => window.$e;
19441 + var getElementorCommon = () => window.elementorCommon;
19442 + var getWpApiSettings = () => window.wpApiSettings;
19443 + var getAjaxUrl = () => window.ajaxurl;
19444 + var getWp = () => window.wp;
19445 + var getJQuery = () => window.jQuery;
19446 + var getElementorAiConfig = () => window.ElementorAiConfig;
19447 +
19448 +//#endregion
19449 +//#region packages/packages/libs/elementor-mcp-common/src/editor-detection.ts
19450 + var ELEMENTOR_LOAD_TIMEOUT_MS = 5e3;
19451 + var ELEMENTOR_CHECK_INTERVAL_MS = 100;
19452 + var DEFAULT_WAIT_FOR_ELEMENTOR_OPTIONS = {
19453 + maxRetries: ELEMENTOR_LOAD_TIMEOUT_MS / ELEMENTOR_CHECK_INTERVAL_MS,
19454 + retryInterval: ELEMENTOR_CHECK_INTERVAL_MS,
19455 + checkFn: () => !!(getElementor() && get$e())
19456 + };
19457 + function isGutenbergEditor() {
19458 + return getWp()?.data?.select("core/editor") !== void 0;
19459 + }
19460 + function isElementorEditor() {
19461 + const params = new URLSearchParams(window.location.search);
19462 + for (const [, value] of params.entries()) if (value.includes("elementor")) return true;
19463 + return false;
19464 + }
19465 + function isElementorAIActive() {
19466 + return !!getElementorAiConfig();
19467 + }
19468 + function hasGutenbergUI() {
19469 + return !!document.querySelector(".edit-post-header-toolbar");
19470 + }
19471 + function ensureElementorFrontend() {
19472 + if (!getElementorFrontend()?.elements?.$body) throw new Error("elementorFrontend or its required components not available");
19473 + }
19474 + function isElementorEditorReady() {
19475 + return !!get$e()?.components.get("panel");
19476 + }
19477 + function waitForElementorEditor() {
19478 + return new Promise((resolve) => {
19479 + if (isElementorEditorReady()) {
19480 + resolve();
19481 + return;
19482 + }
19483 + const checkReady = () => {
19484 + if (isElementorEditorReady()) resolve();
19485 + else setTimeout(checkReady, 100);
19486 + };
19487 + if (document.readyState === "loading") window.addEventListener("DOMContentLoaded", checkReady, { once: true });
19488 + else checkReady();
19489 + });
19490 + }
19491 + function waitForElementor(options = DEFAULT_WAIT_FOR_ELEMENTOR_OPTIONS) {
19492 + const { maxRetries, retryInterval, checkFn } = options;
19493 + return new Promise((resolve, reject) => {
19494 + let attempts = 0;
19495 + const check = () => {
19496 + if (checkFn()) {
19497 + resolve();
19498 + return;
19499 + }
19500 + attempts++;
19501 + if (attempts >= maxRetries) {
19502 + reject(/* @__PURE__ */ new Error(`Elementor not loaded after ${maxRetries} attempts`));
19503 + return;
19504 + }
19505 + setTimeout(check, retryInterval);
19506 + };
19507 + check();
19508 + });
19509 + }
19510 + async function whenElementorReady(fn, options = DEFAULT_WAIT_FOR_ELEMENTOR_OPTIONS) {
19511 + await waitForElementor(options);
19512 + await waitForElementorEditor();
19513 + return await fn();
19514 + }
19515 +
19516 +//#endregion
19517 +//#region packages/packages/libs/elementor-mcp-common/src/elements.ts
19518 + function injectElementCSS(elementId, css) {
19519 + const style = document.createElement("style");
19520 + style.id = elementId;
19521 + style.appendChild(document.createTextNode(css));
19522 + ensureElementorFrontend();
19523 + const frontend = getElementorFrontend();
19524 + if (frontend) frontend.elements.$body[0].appendChild(style);
19525 + }
19526 + function removeElementCSS(elementId) {
19527 + ensureElementorFrontend();
19528 + const frontend = getElementorFrontend();
19529 + if (!frontend) return;
19530 + const bodyElement = frontend.elements.$body[0];
19531 + const styleTags = bodyElement.querySelectorAll(`#${CSS.escape(elementId)}`);
19532 + if (styleTags?.length > 0) styleTags.forEach((tag) => {
19533 + bodyElement.removeChild(tag);
19534 + });
19535 + }
19536 + async function updateElementSettings({ id, settings }) {
19537 + const containerToUpdateSettings = getElementor()?.getContainer(id);
19538 + if (!containerToUpdateSettings) throw new Error(`Element with ID "${id}" not found.`);
19539 + const updateResult = await get$e()?.run("document/elements/settings", {
19540 + container: containerToUpdateSettings,
19541 + settings,
19542 + options: {
19543 + external: true,
19544 + render: true
19545 + }
19546 + });
19547 + getElementorFrontend()?.elements.$body.resize();
19548 + return updateResult;
19549 + }
19550 + function getElementSettings(id) {
19551 + const container = getElementor()?.getContainer(id);
19552 + if (!container) throw new Error(`Element with ID "${id}" not found.`);
19553 + return container.settings;
19554 + }
19555 + function getGutenbergBlockEditorApis() {
19556 + const wp = getWp();
19557 + if (!isGutenbergEditor() || !wp) throw new Error("WordPress editor API is not available");
19558 + const blockEditorDispatch = wp.data.dispatch("core/block-editor");
19559 + const blockEditorSelect = wp.data.select("core/block-editor");
19560 + if (!blockEditorDispatch || !blockEditorSelect) throw new Error("Block editor API is not available");
19561 + return {
19562 + blockEditorDispatch,
19563 + blockEditorSelect
19564 + };
19565 + }
19566 + function validateAndGetGutenbergBlock(blockEditorSelect, blockId) {
19567 + const block = blockEditorSelect.getBlock(blockId);
19568 + if (!block) throw new Error(`Block with ID "${blockId}" not found`);
19569 + return block;
19570 + }
19571 + function updateGutenbergBlockAttributes(blockId, attributes) {
19572 + const { blockEditorDispatch, blockEditorSelect } = getGutenbergBlockEditorApis();
19573 + const block = validateAndGetGutenbergBlock(blockEditorSelect, blockId);
19574 + blockEditorDispatch.updateBlockAttributes(blockId, attributes);
19575 + return {
19576 + blockId,
19577 + blockName: block.name,
19578 + updatedAttributes: Object.keys(attributes)
19579 + };
19580 + }
19581 + function extractElementImageData(targetElementId, fallbackImageId = "", fallbackImageUrl = "") {
19582 + let extractedImageId = fallbackImageId;
19583 + let extractedImageUrl = fallbackImageUrl;
19584 + if (targetElementId && (!extractedImageId || !extractedImageUrl)) {
19585 + const targetContainer = getElementor()?.getContainer?.(targetElementId);
19586 + if (targetContainer) {
19587 + const imageData = targetContainer.settings.get("image");
19588 + if (imageData && typeof imageData === "object") {
19589 + const imageObj = imageData;
19590 + extractedImageId = extractedImageId || imageObj.id?.toString() || "";
19591 + extractedImageUrl = extractedImageUrl || imageObj.url || "";
19592 + }
19593 + }
19594 + }
19595 + return {
19596 + imageId: extractedImageId,
19597 + imageUrl: extractedImageUrl
19598 + };
19599 + }
19600 + function isSelectAllCheckbox(input) {
19601 + if (input.id && input.id.includes("select-all") || input.name && input.name.includes("select-all")) return true;
19602 + return false;
19603 + }
19604 +
19605 +//#endregion
19606 +//#region packages/packages/libs/elementor-mcp-common/src/nonce-refresh.ts
19607 + var isNonceRefreshInitialized = false;
19608 + var nonceRefreshPromise = null;
19609 + function initNonceRefresh() {
19610 + const jQuery = getJQuery();
19611 + const wpApiSettings = getWpApiSettings();
19612 + if (isNonceRefreshInitialized || typeof jQuery === "undefined" || !wpApiSettings) return;
19613 + isNonceRefreshInitialized = true;
19614 + jQuery?.(document).on("heartbeat-tick.angieNonceRefresh", (_event, data) => {
19615 + try {
19616 + const tickData = data;
19617 + const currentSettings = getWpApiSettings();
19618 + if (tickData.angie_nonce && currentSettings && currentSettings.nonce !== tickData.angie_nonce) currentSettings.nonce = tickData.angie_nonce;
19619 + } catch (error) {
19620 + console.error("Failed to refresh nonce:", error);
19621 + }
19622 + });
19623 + }
19624 + async function refreshNonce() {
19625 + if (nonceRefreshPromise) return nonceRefreshPromise;
19626 + nonceRefreshPromise = fetchFreshNonce();
19627 + try {
19628 + return await nonceRefreshPromise;
19629 + } finally {
19630 + nonceRefreshPromise = null;
19631 + }
19632 + }
19633 + async function fetchFreshNonce() {
19634 + const ajaxUrl = new URL(getAjaxUrl() || "/wp-admin/admin-ajax.php", window.location.origin);
19635 + ajaxUrl.searchParams.set("action", "rest-nonce");
19636 + const response = await fetch(ajaxUrl.toString(), { credentials: "same-origin" });
19637 + if (!response.ok) throw new Error(`Failed to refresh nonce: HTTP ${response.status}`);
19638 + const nonce = await response.text();
19639 + if (!nonce || nonce === "0") throw new Error("Session expired — received invalid nonce");
19640 + const wpApiSettings = getWpApiSettings();
19641 + if (!wpApiSettings) throw new Error("wpApiSettings not available — cannot refresh nonce");
19642 + wpApiSettings.nonce = nonce;
19643 + return nonce;
19644 + }
19645 + function isNonceError(status, responseText) {
19646 + return status === 403 && responseText.includes("rest_cookie_invalid_nonce");
19647 + }
19648 +
19649 +//#endregion
19650 +//#region packages/packages/libs/elementor-mcp-common/src/rest-client.ts
19651 + async function callWpApi(endpoint, method, data, options) {
19652 + return executeWpApiCall(endpoint, method, data, options, true);
19653 + }
19654 + async function executeWpApiCall(endpoint, method, data, options, allowNonceRetry = false) {
19655 + const wpApiSettings = getWpApiSettings();
19656 + if (!wpApiSettings?.nonce || !wpApiSettings.root) throw new Error("wpApiSettings not available");
19657 + const baseUrl = wpApiSettings.root;
19658 + const urlObject = new URL(baseUrl);
19659 + const endpointUrl = new URL(endpoint, baseUrl);
19660 + urlObject.searchParams.set("rest_route", endpointUrl.pathname);
19661 + for (const [key, value] of endpointUrl.searchParams.entries()) urlObject.searchParams.append(key, value);
19662 + const url = urlObject.toString();
19663 + const headers = {
19664 + "X-WP-Nonce": wpApiSettings.nonce,
19665 + ...options?.customHeaders || {}
19666 + };
19667 + if (!options?.binaryData && !options?.customHeaders?.["Content-Type"]) headers["Content-Type"] = "application/json";
19668 + const requestOptions = {
19669 + method,
19670 + headers,
19671 + credentials: "same-origin"
19672 + };
19673 + if (options?.binaryData) requestOptions.body = options.binaryData;
19674 + else if (data && (method === "POST" || method === "PUT" || method === "PATCH")) requestOptions.body = JSON.stringify(data);
19675 + const response = await fetch(url, requestOptions);
19676 + if (!response.ok) {
19677 + const responseText2 = await response.text();
19678 + if (allowNonceRetry && isNonceError(response.status, responseText2)) {
19679 + await refreshNonce();
19680 + return executeWpApiCall(endpoint, method, data, options, false);
19681 + }
19682 + throw new Error(`HTTP error ${response.status}: ${responseText2}`);
19683 + }
19684 + const responseText = await response.text();
19685 + const json = extractJSONFromResponse(responseText);
19686 + if (json === null) throw new Error(`Invalid response: no JSON found in: ${responseText.substring(0, 200)}`);
19687 + const jsonObj = json;
19688 + if (jsonObj?.success !== void 0 && !jsonObj.success) throw new Error(`API errors: ${JSON.stringify(json)}`);
19689 + const totalItemsHeader = response.headers.get("X-WP-Total");
19690 + const totalPagesHeader = response.headers.get("X-WP-TotalPages");
19691 + return {
19692 + data: json,
19693 + totalItems: totalItemsHeader ? parseInt(totalItemsHeader, 10) : void 0,
19694 + totalPages: totalPagesHeader ? parseInt(totalPagesHeader, 10) : void 0
19695 + };
19696 + }
19697 + function extractJSONFromResponse(responseText) {
19698 + const objectStart = responseText.indexOf("{");
19699 + const arrayStart = responseText.indexOf("[");
19700 + let startIndex = -1;
19701 + let isArray = false;
19702 + if (objectStart === -1 && arrayStart === -1) return null;
19703 + if (objectStart === -1) {
19704 + startIndex = arrayStart;
19705 + isArray = true;
19706 + } else if (arrayStart === -1) {
19707 + startIndex = objectStart;
19708 + isArray = false;
19709 + } else if (arrayStart < objectStart) {
19710 + startIndex = arrayStart;
19711 + isArray = true;
19712 + } else {
19713 + startIndex = objectStart;
19714 + isArray = false;
19715 + }
19716 + let delimiterCount = 0;
19717 + let endIndex = -1;
19718 + const openChar = isArray ? "[" : "{";
19719 + const closeChar = isArray ? "]" : "}";
19720 + for (let i = startIndex; i < responseText.length; i++) if (responseText[i] === openChar) delimiterCount++;
19721 + else if (responseText[i] === closeChar) {
19722 + delimiterCount--;
19723 + if (delimiterCount === 0) {
19724 + endIndex = i;
19725 + break;
19726 + }
19727 + }
19728 + if (endIndex === -1) return null;
19729 + const jsonString = responseText.substring(startIndex, endIndex + 1);
19730 + try {
19731 + return JSON.parse(jsonString);
19732 + } catch {
19733 + return null;
19734 + }
19735 + }
19736 +
19737 +//#endregion
19738 +//#region packages/packages/libs/elementor-mcp-common/src/validation-utils.ts
19739 + function requireConfirmationMessage(confirmationMessage, context) {
19740 + if (!confirmationMessage || confirmationMessage.trim() === "") throw new Error(`LLM Instructions: ${context} changes require user confirmation. You MUST provide a confirmationMessage parameter explaining what will be changed and its impact.`);
19741 + }
19742 +
19743 +//#endregion
19744 +//#region packages/packages/libs/elementor-mcp-common/src/index.ts
19745 + var src_exports = /* @__PURE__ */ __exportAll({
19746 + McpServer: () => McpServer,
19747 + ResourceTemplate: () => ResourceTemplate,
19748 + SamplingMessageSchema: () => SamplingMessageSchema,
19749 + callWpApi: () => callWpApi,
19750 + ensureElementorFrontend: () => ensureElementorFrontend,
19751 + extractElementImageData: () => extractElementImageData,
19752 + extractJSONFromResponse: () => extractJSONFromResponse,
19753 + get$e: () => get$e,
19754 + getAjaxUrl: () => getAjaxUrl,
19755 + getElementSettings: () => getElementSettings,
19756 + getElementor: () => getElementor,
19757 + getElementorAiConfig: () => getElementorAiConfig,
19758 + getElementorCommon: () => getElementorCommon,
19759 + getElementorFrontend: () => getElementorFrontend,
19760 + getGutenbergBlockEditorApis: () => getGutenbergBlockEditorApis,
19761 + getJQuery: () => getJQuery,
19762 + getWp: () => getWp,
19763 + getWpApiSettings: () => getWpApiSettings,
19764 + hasGutenbergUI: () => hasGutenbergUI,
19765 + initNonceRefresh: () => initNonceRefresh,
19766 + injectElementCSS: () => injectElementCSS,
19767 + isElementorAIActive: () => isElementorAIActive,
19768 + isElementorEditor: () => isElementorEditor,
19769 + isElementorEditorReady: () => isElementorEditorReady,
19770 + isGutenbergEditor: () => isGutenbergEditor,
19771 + isNonceError: () => isNonceError,
19772 + isSelectAllCheckbox: () => isSelectAllCheckbox,
19773 + refreshNonce: () => refreshNonce,
19774 + removeElementCSS: () => removeElementCSS,
19775 + requireConfirmationMessage: () => requireConfirmationMessage,
19776 + updateElementSettings: () => updateElementSettings,
19777 + updateGutenbergBlockAttributes: () => updateGutenbergBlockAttributes,
19778 + validateAndGetGutenbergBlock: () => validateAndGetGutenbergBlock,
19779 + waitForElementor: () => waitForElementor,
19780 + waitForElementorEditor: () => waitForElementorEditor,
19781 + whenElementorReady: () => whenElementorReady
19782 + });
19783 +
19784 +//#endregion
19785 +//#region \0elementor-package-library-entry
19786 + (window.elementorV2 = window.elementorV2 || {}).elementorMcpCommon = src_exports;
19787 +
19788 +//#endregion
19789 +})();
19790 +window.elementorV2.elementorMcpCommon?.init?.();
3 19791 //# sourceMappingURL=elementor-mcp-common.js.map