@likec4/mcp 1.32.0 → 1.32.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
 
2
- > @likec4/mcp@1.32.0 build /home/runner/work/likec4/likec4/packages/mcp
2
+ > @likec4/mcp@1.32.2 build /home/runner/work/likec4/likec4/packages/mcp
3
3
  > wireit
4
4
 
5
5
  Analyzing
@@ -8,16 +8,22 @@ Analyzing
8
8
  [info] Cleaning dist directory: `./dist`
9
9
  ../../node_modules/.pnpm/@mantine+colors-generator@8.1.0_chroma-js@3.1.2/node_modules/@mantine/colors-generator/esm/generate-colors.mjs (1:0): Module level directives cause errors when bundled, "use client" in "../../node_modules/.pnpm/@mantine+colors-generator@8.1.0_chroma-js@3.1.2/node_modules/@mantine/colors-generator/esm/generate-colors.mjs" was ignored.
10
10
  [success] Build succeeded for mcp
11
- [log] dist/index.mjs (total size: 75.4 kB, chunk size: 75.4 kB)
12
- 📦 ../../node_modules/.pnpm/zod@3.24.3/node_modules/zod/lib/index.mjs (155 kB)
13
- 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.10.2/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js (32.2 kB)
14
- 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.10.2/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/uriTemplate.js (8.73 kB)
15
- 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.10.2/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js (2.75 kB)
16
- 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.10.2/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js (2.02 kB)
17
- 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.10.2/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js (916 B)
18
- 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.10.2/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js (821 B)
19
- 📦 ../../node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@3.24.3/node_modules/zod-to-json-schema/dist/esm/parsers/string.js (72 B)
11
+ [log] dist/index.mjs (total size: 68.8 kB, chunk size: 68.8 kB)
12
+ 📦 ../../node_modules/.pnpm/zod@3.25.64/node_modules/zod/dist/esm/v3/types.js (122 kB)
13
+ 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.12.1/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js (36 kB)
14
+ 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.12.1/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/uriTemplate.js (8.73 kB)
15
+ 📦 ../../node_modules/.pnpm/zod@3.25.64/node_modules/zod/dist/esm/v3/locales/en.js (5.26 kB)
16
+ 📦 ../../node_modules/.pnpm/zod@3.25.64/node_modules/zod/dist/esm/v3/ZodError.js (4.12 kB)
17
+ 📦 ../../node_modules/.pnpm/zod@3.25.64/node_modules/zod/dist/esm/v3/helpers/util.js (4.03 kB)
18
+ 📦 ../../node_modules/.pnpm/zod@3.25.64/node_modules/zod/dist/esm/v3/helpers/parseUtil.js (3.39 kB)
19
+ 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.12.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js (2.75 kB)
20
+ 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.12.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js (2.02 kB)
21
+ 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.12.1/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js (916 B)
22
+ 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.12.1/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js (821 B)
23
+ 📦 ../../node_modules/.pnpm/zod@3.25.64/node_modules/zod/dist/esm/v3/helpers/errorUtil.js (292 B)
24
+ 📦 ../../node_modules/.pnpm/zod@3.25.64/node_modules/zod/dist/esm/v3/errors.js (88 B)
25
+ 📦 ../../node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@3.25.64/node_modules/zod-to-json-schema/dist/esm/parsers/string.js (72 B)
20
26
  📦 ../../node_modules/.pnpm/remeda@2.23.0/node_modules/remeda/dist/chunk-ENOHV5LT.js (42 B)
21
- Σ Total dist size (byte size): 75.4 kB
27
+ Σ Total dist size (byte size): 68.8 kB
22
28
  [log]
23
29
  ✅ Ran 1 script and skipped 0 in 2.3s.
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import qe from"node:process";import{LikeC4 as xt}from"likec4";import{resolve as bt}from"node:path";function kt(s){return typeof s=="function"}function wt(s,e){if(!s)throw new Error("Invariant failed")}function St(s,e){const t=e??s;wt(kt(t));function*r(n){for(const a of n)t(a)&&(yield a)}return e?r(s):r}var x;(function(s){s.assertEqual=n=>n;function e(n){}s.assertIs=e;function t(n){throw new Error}s.assertNever=t,s.arrayToEnum=n=>{const a={};for(const c of n)a[c]=c;return a},s.getValidEnumValues=n=>{const a=s.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),c={};for(const o of a)c[o]=n[o];return s.objectValues(c)},s.objectValues=n=>s.objectKeys(n).map(function(a){return n[a]}),s.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const c in n)Object.prototype.hasOwnProperty.call(n,c)&&a.push(c);return a},s.find=(n,a)=>{for(const c of n)if(a(c))return c},s.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function r(n,a=" | "){return n.map(c=>typeof c=="string"?`'${c}'`:c).join(a)}s.joinValues=r,s.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Ie;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Ie||(Ie={}));const p=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),M=s=>{switch(typeof s){case"undefined":return p.undefined;case"string":return p.string;case"number":return isNaN(s)?p.nan:p.number;case"boolean":return p.boolean;case"function":return p.function;case"bigint":return p.bigint;case"symbol":return p.symbol;case"object":return Array.isArray(s)?p.array:s===null?p.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?p.promise:typeof Map<"u"&&s instanceof Map?p.map:typeof Set<"u"&&s instanceof Set?p.set:typeof Date<"u"&&s instanceof Date?p.date:p.object;default:return p.unknown}},d=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Tt=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");class R extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},r={_errors:[]},n=a=>{for(const c of a.issues)if(c.code==="invalid_union")c.unionErrors.map(n);else if(c.code==="invalid_return_type")n(c.returnTypeError);else if(c.code==="invalid_arguments")n(c.argumentsError);else if(c.path.length===0)r._errors.push(t(c));else{let o=r,l=0;for(;l<c.path.length;){const u=c.path[l];l===c.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(t(c))):o[u]=o[u]||{_errors:[]},o=o[u],l++}}};return n(this),r}static assert(e){if(!(e instanceof R))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},r=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):r.push(e(n));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}R.create=s=>new R(s);const H=(s,e)=>{let t;switch(s.code){case d.invalid_type:s.received===p.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,x.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(s.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(s.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(s.options)}, received '${s.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:x.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case d.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case d.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(s)}return{message:t}};let Be=H;function Rt(s){Be=s}function ye(){return Be}const _e=s=>{const{data:e,path:t,errorMaps:r,issueData:n}=s,a=[...t,...n.path||[]],c={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let o="";const l=r.filter(u=>!!u).slice().reverse();for(const u of l)o=u(c,{data:e,defaultError:o}).message;return{...n,path:a,message:o}},Ct=[];function h(s,e){const t=ye(),r=_e({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===H?void 0:H].filter(n=>!!n)});s.common.issues.push(r)}class w{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const n of t){if(n.status==="aborted")return v;n.status==="dirty"&&e.dirty(),r.push(n.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const n of t){const a=await n.key,c=await n.value;r.push({key:a,value:c})}return w.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const n of t){const{key:a,value:c}=n;if(a.status==="aborted"||c.status==="aborted")return v;a.status==="dirty"&&e.dirty(),c.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof c.value<"u"||n.alwaysSet)&&(r[a.value]=c.value)}return{status:e.value,value:r}}}const v=Object.freeze({status:"aborted"}),X=s=>({status:"dirty",value:s}),S=s=>({status:"valid",value:s}),Pe=s=>s.status==="aborted",Me=s=>s.status==="dirty",U=s=>s.status==="valid",te=s=>typeof Promise<"u"&&s instanceof Promise;function xe(s,e,t,r){if(typeof e=="function"?s!==e||!0:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(s)}function Ue(s,e,t,r,n){if(typeof e=="function"?s!==e||!0:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(s,t),t}typeof SuppressedError=="function"&&SuppressedError;var m;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}));var se,re;class A{constructor(e,t,r,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Fe=(s,e)=>{if(U(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new R(s.common.issues);return this._error=t,this._error}}};function y(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:n}=s;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(c,o)=>{var l,u;const{message:f}=s;return c.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(l=f??r)!==null&&l!==void 0?l:o.defaultError}:c.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:n}}class _{get description(){return this._def.description}_getType(e){return M(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new w,ctx:{common:e.parent.common,data:e.data,parsedType:M(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(te(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){var r;const n={common:{issues:[],async:(r=t?.async)!==null&&r!==void 0?r:!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},a=this._parseSync({data:e,path:n.path,parent:n});return Fe(n,a)}"~validate"(e){var t,r;const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)};if(!this["~standard"].async)try{const a=this._parseSync({data:e,path:[],parent:n});return U(a)?{value:a.value}:{issues:n.common.issues}}catch(a){!((r=(t=a?.message)===null||t===void 0?void 0:t.toLowerCase())===null||r===void 0)&&r.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(a=>U(a)?{value:a.value}:{issues:n.common.issues})}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:M(e)},n=this._parse({data:e,path:r.path,parent:r}),a=await(te(n)?n:Promise.resolve(n));return Fe(r,a)}refine(e,t){const r=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const c=e(n),o=()=>a.addIssue({code:d.custom,...r(n)});return typeof Promise<"u"&&c instanceof Promise?c.then(l=>l?!0:(o(),!1)):c?!0:(o(),!1)})}refinement(e,t){return this._refinement((r,n)=>e(r)?!0:(n.addIssue(typeof t=="function"?t(r,n):t),!1))}_refinement(e){return new C({schema:this,typeName:g.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return O.create(this,this._def)}nullable(){return V.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Z.create(this)}promise(){return Q.create(this,this._def)}or(e){return oe.create([this,e],this._def)}and(e){return ce.create(this,e,this._def)}transform(e){return new C({...y(this._def),schema:this,typeName:g.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new he({...y(this._def),innerType:this,defaultValue:t,typeName:g.ZodDefault})}brand(){return new Ve({typeName:g.ZodBranded,type:this,...y(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new fe({...y(this._def),innerType:this,catchValue:t,typeName:g.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ge.create(this,e)}readonly(){return pe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const jt=/^c[^\s-]{8,}$/i,Nt=/^[0-9a-z]+$/,Zt=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Et=/^[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,At=/^[a-z0-9_-]{21}$/i,Ot=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,It=/^[-+]?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)?)??$/,Pt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Mt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Le;const Lt=/^(?:(?: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])$/,$t=/^(?:(?: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])$/,Vt=/^(([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]))$/,zt=/^(([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])$/,Dt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,qt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,We="((\\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])))",Bt=new RegExp(`^${We}$`);function Je(s){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Ut(s){return new RegExp(`^${Je(s)}$`)}function Ge(s){let e=`${We}T${Je(s)}`;const t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ft(s,e){return!!((e==="v4"||!e)&&Lt.test(s)||(e==="v6"||!e)&&Vt.test(s))}function Wt(s,e){if(!Ot.test(s))return!1;try{const[t]=s.split("."),r=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(r));return!(typeof n!="object"||n===null||!n.typ||!n.alg||e&&n.alg!==e)}catch{return!1}}function Jt(s,e){return!!((e==="v4"||!e)&&$t.test(s)||(e==="v6"||!e)&&zt.test(s))}class E extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==p.string){const a=this._getOrReturnCtx(e);return h(a,{code:d.invalid_type,expected:p.string,received:a.parsedType}),v}const r=new w;let n;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),h(n,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),h(n,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),r.dirty());else if(a.kind==="length"){const c=e.data.length>a.value,o=e.data.length<a.value;(c||o)&&(n=this._getOrReturnCtx(e,n),c?h(n,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&h(n,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),r.dirty())}else if(a.kind==="email")Pt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"email",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="emoji")Le||(Le=new RegExp(Mt,"u")),Le.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"emoji",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="uuid")Et.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"uuid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="nanoid")At.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"nanoid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid")jt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"cuid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="cuid2")Nt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"cuid2",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="ulid")Zt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"ulid",code:d.invalid_string,message:a.message}),r.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),h(n,{validation:"url",code:d.invalid_string,message:a.message}),r.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"regex",code:d.invalid_string,message:a.message}),r.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),h(n,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),r.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),h(n,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),r.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),h(n,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),r.dirty()):a.kind==="datetime"?Ge(a).test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:d.invalid_string,validation:"datetime",message:a.message}),r.dirty()):a.kind==="date"?Bt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:d.invalid_string,validation:"date",message:a.message}),r.dirty()):a.kind==="time"?Ut(a).test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{code:d.invalid_string,validation:"time",message:a.message}),r.dirty()):a.kind==="duration"?It.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"duration",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="ip"?Ft(e.data,a.version)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"ip",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="jwt"?Wt(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"jwt",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="cidr"?Jt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"cidr",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="base64"?Dt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"base64",code:d.invalid_string,message:a.message}),r.dirty()):a.kind==="base64url"?qt.test(e.data)||(n=this._getOrReturnCtx(e,n),h(n,{validation:"base64url",code:d.invalid_string,message:a.message}),r.dirty()):x.assertNever(a);return{status:r.value,value:e.data}}_regex(e,t,r){return this.refinement(n=>e.test(n),{validation:t,code:d.invalid_string,...m.errToObj(r)})}_addCheck(e){return new E({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...m.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...m.errToObj(e)})}datetime(e){var t,r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:(t=e?.offset)!==null&&t!==void 0?t:!1,local:(r=e?.local)!==null&&r!==void 0?r:!1,...m.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...m.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...m.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...m.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...m.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...m.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...m.errToObj(t)})}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new E({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new E({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new E({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}E.create=s=>{var e;return new E({checks:[],typeName:g.ZodString,coerce:(e=s?.coerce)!==null&&e!==void 0?e:!1,...y(s)})};function Gt(s,e){const t=(s.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,n=t>r?t:r,a=parseInt(s.toFixed(n).replace(".","")),c=parseInt(e.toFixed(n).replace(".",""));return a%c/Math.pow(10,n)}class D extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==p.number){const a=this._getOrReturnCtx(e);return h(a,{code:d.invalid_type,expected:p.number,received:a.parsedType}),v}let r;const n=new w;for(const a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?Gt(e.data,a.value)!==0&&(r=this._getOrReturnCtx(e,r),h(r,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),h(r,{code:d.not_finite,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,r,n){return new D({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:m.toString(n)}]})}_addCheck(e){return new D({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(t===null||r.value>t)&&(t=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}D.create=s=>new D({checks:[],typeName:g.ZodNumber,coerce:s?.coerce||!1,...y(s)});class q extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==p.bigint)return this._getInvalidInput(e);let r;const n=new w;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:d.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(r=this._getOrReturnCtx(e,r),h(r,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),h(r,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return h(t,{code:d.invalid_type,expected:p.bigint,received:t.parsedType}),v}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,r,n){return new q({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:m.toString(n)}]})}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}q.create=s=>{var e;return new q({checks:[],typeName:g.ZodBigInt,coerce:(e=s?.coerce)!==null&&e!==void 0?e:!1,...y(s)})};class ne extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==p.boolean){const r=this._getOrReturnCtx(e);return h(r,{code:d.invalid_type,expected:p.boolean,received:r.parsedType}),v}return S(e.data)}}ne.create=s=>new ne({typeName:g.ZodBoolean,coerce:s?.coerce||!1,...y(s)});class W extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==p.date){const a=this._getOrReturnCtx(e);return h(a,{code:d.invalid_type,expected:p.date,received:a.parsedType}),v}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return h(a,{code:d.invalid_date}),v}const r=new w;let n;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),h(n,{code:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),r.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),h(n,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),r.dirty()):x.assertNever(a);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}W.create=s=>new W({checks:[],coerce:s?.coerce||!1,typeName:g.ZodDate,...y(s)});class be extends _{_parse(e){if(this._getType(e)!==p.symbol){const r=this._getOrReturnCtx(e);return h(r,{code:d.invalid_type,expected:p.symbol,received:r.parsedType}),v}return S(e.data)}}be.create=s=>new be({typeName:g.ZodSymbol,...y(s)});class ae extends _{_parse(e){if(this._getType(e)!==p.undefined){const r=this._getOrReturnCtx(e);return h(r,{code:d.invalid_type,expected:p.undefined,received:r.parsedType}),v}return S(e.data)}}ae.create=s=>new ae({typeName:g.ZodUndefined,...y(s)});class ie extends _{_parse(e){if(this._getType(e)!==p.null){const r=this._getOrReturnCtx(e);return h(r,{code:d.invalid_type,expected:p.null,received:r.parsedType}),v}return S(e.data)}}ie.create=s=>new ie({typeName:g.ZodNull,...y(s)});class Y extends _{constructor(){super(...arguments),this._any=!0}_parse(e){return S(e.data)}}Y.create=s=>new Y({typeName:g.ZodAny,...y(s)});class F extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return S(e.data)}}F.create=s=>new F({typeName:g.ZodUnknown,...y(s)});class L extends _{_parse(e){const t=this._getOrReturnCtx(e);return h(t,{code:d.invalid_type,expected:p.never,received:t.parsedType}),v}}L.create=s=>new L({typeName:g.ZodNever,...y(s)});class ke extends _{_parse(e){if(this._getType(e)!==p.undefined){const r=this._getOrReturnCtx(e);return h(r,{code:d.invalid_type,expected:p.void,received:r.parsedType}),v}return S(e.data)}}ke.create=s=>new ke({typeName:g.ZodVoid,...y(s)});class Z extends _{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),n=this._def;if(t.parsedType!==p.array)return h(t,{code:d.invalid_type,expected:p.array,received:t.parsedType}),v;if(n.exactLength!==null){const c=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(c||o)&&(h(t,{code:c?d.too_big:d.too_small,minimum:o?n.exactLength.value:void 0,maximum:c?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),r.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(h(t,{code:d.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),r.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(h(t,{code:d.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map((c,o)=>n.type._parseAsync(new A(t,c,t.path,o)))).then(c=>w.mergeArray(r,c));const a=[...t.data].map((c,o)=>n.type._parseSync(new A(t,c,t.path,o)));return w.mergeArray(r,a)}get element(){return this._def.type}min(e,t){return new Z({...this._def,minLength:{value:e,message:m.toString(t)}})}max(e,t){return new Z({...this._def,maxLength:{value:e,message:m.toString(t)}})}length(e,t){return new Z({...this._def,exactLength:{value:e,message:m.toString(t)}})}nonempty(e){return this.min(1,e)}}Z.create=(s,e)=>new Z({type:s,minLength:null,maxLength:null,exactLength:null,typeName:g.ZodArray,...y(e)});function K(s){if(s instanceof b){const e={};for(const t in s.shape){const r=s.shape[t];e[t]=O.create(K(r))}return new b({...s._def,shape:()=>e})}else return s instanceof Z?new Z({...s._def,type:K(s.element)}):s instanceof O?O.create(K(s.unwrap())):s instanceof V?V.create(K(s.unwrap())):s instanceof P?P.create(s.items.map(e=>K(e))):s}class b extends _{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=x.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==p.object){const u=this._getOrReturnCtx(e);return h(u,{code:d.invalid_type,expected:p.object,received:u.parsedType}),v}const{status:r,ctx:n}=this._processInputParams(e),{shape:a,keys:c}=this._getCached(),o=[];if(!(this._def.catchall instanceof L&&this._def.unknownKeys==="strip"))for(const u in n.data)c.includes(u)||o.push(u);const l=[];for(const u of c){const f=a[u],k=n.data[u];l.push({key:{status:"valid",value:u},value:f._parse(new A(n,k,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof L){const u=this._def.unknownKeys;if(u==="passthrough")for(const f of o)l.push({key:{status:"valid",value:f},value:{status:"valid",value:n.data[f]}});else if(u==="strict")o.length>0&&(h(n,{code:d.unrecognized_keys,keys:o}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const f of o){const k=n.data[f];l.push({key:{status:"valid",value:f},value:u._parse(new A(n,k,n.path,f)),alwaysSet:f in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const f of l){const k=await f.key,G=await f.value;u.push({key:k,value:G,alwaysSet:f.alwaysSet})}return u}).then(u=>w.mergeObjectSync(r,u)):w.mergeObjectSync(r,l)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new b({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,r)=>{var n,a,c,o;const l=(c=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,r).message)!==null&&c!==void 0?c:r.defaultError;return t.code==="unrecognized_keys"?{message:(o=m.errToObj(e).message)!==null&&o!==void 0?o:l}:{message:l}}}:{}})}strip(){return new b({...this._def,unknownKeys:"strip"})}passthrough(){return new b({...this._def,unknownKeys:"passthrough"})}extend(e){return new b({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new b({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:g.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new b({...this._def,catchall:e})}pick(e){const t={};return x.objectKeys(e).forEach(r=>{e[r]&&this.shape[r]&&(t[r]=this.shape[r])}),new b({...this._def,shape:()=>t})}omit(e){const t={};return x.objectKeys(this.shape).forEach(r=>{e[r]||(t[r]=this.shape[r])}),new b({...this._def,shape:()=>t})}deepPartial(){return K(this)}partial(e){const t={};return x.objectKeys(this.shape).forEach(r=>{const n=this.shape[r];e&&!e[r]?t[r]=n:t[r]=n.optional()}),new b({...this._def,shape:()=>t})}required(e){const t={};return x.objectKeys(this.shape).forEach(r=>{if(e&&!e[r])t[r]=this.shape[r];else{let a=this.shape[r];for(;a instanceof O;)a=a._def.innerType;t[r]=a}}),new b({...this._def,shape:()=>t})}keyof(){return He(x.objectKeys(this.shape))}}b.create=(s,e)=>new b({shape:()=>s,unknownKeys:"strip",catchall:L.create(),typeName:g.ZodObject,...y(e)}),b.strictCreate=(s,e)=>new b({shape:()=>s,unknownKeys:"strict",catchall:L.create(),typeName:g.ZodObject,...y(e)}),b.lazycreate=(s,e)=>new b({shape:s,unknownKeys:"strip",catchall:L.create(),typeName:g.ZodObject,...y(e)});class oe extends _{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;function n(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const c=a.map(o=>new R(o.ctx.common.issues));return h(t,{code:d.invalid_union,unionErrors:c}),v}if(t.common.async)return Promise.all(r.map(async a=>{const c={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:c}),ctx:c}})).then(n);{let a;const c=[];for(const l of r){const u={...t,common:{...t.common,issues:[]},parent:null},f=l._parseSync({data:t.data,path:t.path,parent:u});if(f.status==="valid")return f;f.status==="dirty"&&!a&&(a={result:f,ctx:u}),u.common.issues.length&&c.push(u.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=c.map(l=>new R(l));return h(t,{code:d.invalid_union,unionErrors:o}),v}}get options(){return this._def.options}}oe.create=(s,e)=>new oe({options:s,typeName:g.ZodUnion,...y(e)});const $=s=>s instanceof de?$(s.schema):s instanceof C?$(s.innerType()):s instanceof le?[s.value]:s instanceof B?s.options:s instanceof ue?x.objectValues(s.enum):s instanceof he?$(s._def.innerType):s instanceof ae?[void 0]:s instanceof ie?[null]:s instanceof O?[void 0,...$(s.unwrap())]:s instanceof V?[null,...$(s.unwrap())]:s instanceof Ve||s instanceof pe?$(s.unwrap()):s instanceof fe?$(s._def.innerType):[];class Ae extends _{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.object)return h(t,{code:d.invalid_type,expected:p.object,received:t.parsedType}),v;const r=this.discriminator,n=t.data[r],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(h(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),v)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const n=new Map;for(const a of t){const c=$(a.shape[e]);if(!c.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of c){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new Ae({typeName:g.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...y(r)})}}function $e(s,e){const t=M(s),r=M(e);if(s===e)return{valid:!0,data:s};if(t===p.object&&r===p.object){const n=x.objectKeys(e),a=x.objectKeys(s).filter(o=>n.indexOf(o)!==-1),c={...s,...e};for(const o of a){const l=$e(s[o],e[o]);if(!l.valid)return{valid:!1};c[o]=l.data}return{valid:!0,data:c}}else if(t===p.array&&r===p.array){if(s.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<s.length;a++){const c=s[a],o=e[a],l=$e(c,o);if(!l.valid)return{valid:!1};n.push(l.data)}return{valid:!0,data:n}}else return t===p.date&&r===p.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class ce extends _{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=(a,c)=>{if(Pe(a)||Pe(c))return v;const o=$e(a.value,c.value);return o.valid?((Me(a)||Me(c))&&t.dirty(),{status:t.value,value:o.data}):(h(r,{code:d.invalid_intersection_types}),v)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([a,c])=>n(a,c)):n(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}ce.create=(s,e,t)=>new ce({left:s,right:e,typeName:g.ZodIntersection,...y(t)});class P extends _{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.array)return h(r,{code:d.invalid_type,expected:p.array,received:r.parsedType}),v;if(r.data.length<this._def.items.length)return h(r,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),v;!this._def.rest&&r.data.length>this._def.items.length&&(h(r,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...r.data].map((c,o)=>{const l=this._def.items[o]||this._def.rest;return l?l._parse(new A(r,c,r.path,o)):null}).filter(c=>!!c);return r.common.async?Promise.all(a).then(c=>w.mergeArray(t,c)):w.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new P({...this._def,rest:e})}}P.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new P({items:s,typeName:g.ZodTuple,rest:null,...y(e)})};class ve extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.object)return h(r,{code:d.invalid_type,expected:p.object,received:r.parsedType}),v;const n=[],a=this._def.keyType,c=this._def.valueType;for(const o in r.data)n.push({key:a._parse(new A(r,o,r.path,o)),value:c._parse(new A(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?w.mergeObjectAsync(t,n):w.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,r){return t instanceof _?new ve({keyType:e,valueType:t,typeName:g.ZodRecord,...y(r)}):new ve({keyType:E.create(),valueType:e,typeName:g.ZodRecord,...y(t)})}}class we extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.map)return h(r,{code:d.invalid_type,expected:p.map,received:r.parsedType}),v;const n=this._def.keyType,a=this._def.valueType,c=[...r.data.entries()].map(([o,l],u)=>({key:n._parse(new A(r,o,r.path,[u,"key"])),value:a._parse(new A(r,l,r.path,[u,"value"]))}));if(r.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of c){const u=await l.key,f=await l.value;if(u.status==="aborted"||f.status==="aborted")return v;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const l of c){const u=l.key,f=l.value;if(u.status==="aborted"||f.status==="aborted")return v;(u.status==="dirty"||f.status==="dirty")&&t.dirty(),o.set(u.value,f.value)}return{status:t.value,value:o}}}}we.create=(s,e,t)=>new we({valueType:e,keyType:s,typeName:g.ZodMap,...y(t)});class J extends _{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==p.set)return h(r,{code:d.invalid_type,expected:p.set,received:r.parsedType}),v;const n=this._def;n.minSize!==null&&r.data.size<n.minSize.value&&(h(r,{code:d.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&r.data.size>n.maxSize.value&&(h(r,{code:d.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function c(l){const u=new Set;for(const f of l){if(f.status==="aborted")return v;f.status==="dirty"&&t.dirty(),u.add(f.value)}return{status:t.value,value:u}}const o=[...r.data.values()].map((l,u)=>a._parse(new A(r,l,r.path,u)));return r.common.async?Promise.all(o).then(l=>c(l)):c(o)}min(e,t){return new J({...this._def,minSize:{value:e,message:m.toString(t)}})}max(e,t){return new J({...this._def,maxSize:{value:e,message:m.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}J.create=(s,e)=>new J({valueType:s,minSize:null,maxSize:null,typeName:g.ZodSet,...y(e)});class ee extends _{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.function)return h(t,{code:d.invalid_type,expected:p.function,received:t.parsedType}),v;function r(o,l){return _e({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ye(),H].filter(u=>!!u),issueData:{code:d.invalid_arguments,argumentsError:l}})}function n(o,l){return _e({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ye(),H].filter(u=>!!u),issueData:{code:d.invalid_return_type,returnTypeError:l}})}const a={errorMap:t.common.contextualErrorMap},c=t.data;if(this._def.returns instanceof Q){const o=this;return S(async function(...l){const u=new R([]),f=await o._def.args.parseAsync(l,a).catch(Oe=>{throw u.addIssue(r(l,Oe)),u}),k=await Reflect.apply(c,this,f);return await o._def.returns._def.type.parseAsync(k,a).catch(Oe=>{throw u.addIssue(n(k,Oe)),u})})}else{const o=this;return S(function(...l){const u=o._def.args.safeParse(l,a);if(!u.success)throw new R([r(l,u.error)]);const f=Reflect.apply(c,this,u.data),k=o._def.returns.safeParse(f,a);if(!k.success)throw new R([n(f,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ee({...this._def,args:P.create(e).rest(F.create())})}returns(e){return new ee({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,r){return new ee({args:e||P.create([]).rest(F.create()),returns:t||F.create(),typeName:g.ZodFunction,...y(r)})}}class de extends _{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}de.create=(s,e)=>new de({getter:s,typeName:g.ZodLazy,...y(e)});class le extends _{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return h(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),v}return{status:"valid",value:e.data}}get value(){return this._def.value}}le.create=(s,e)=>new le({value:s,typeName:g.ZodLiteral,...y(e)});function He(s,e){return new B({values:s,typeName:g.ZodEnum,...y(e)})}class B extends _{constructor(){super(...arguments),se.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{expected:x.joinValues(r),received:t.parsedType,code:d.invalid_type}),v}if(xe(this,se)||Ue(this,se,new Set(this._def.values)),!xe(this,se).has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return h(t,{received:t.data,code:d.invalid_enum_value,options:r}),v}return S(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return B.create(e,{...this._def,...t})}exclude(e,t=this._def){return B.create(this.options.filter(r=>!e.includes(r)),{...this._def,...t})}}se=new WeakMap,B.create=He;class ue extends _{constructor(){super(...arguments),re.set(this,void 0)}_parse(e){const t=x.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==p.string&&r.parsedType!==p.number){const n=x.objectValues(t);return h(r,{expected:x.joinValues(n),received:r.parsedType,code:d.invalid_type}),v}if(xe(this,re)||Ue(this,re,new Set(x.getValidEnumValues(this._def.values))),!xe(this,re).has(e.data)){const n=x.objectValues(t);return h(r,{received:r.data,code:d.invalid_enum_value,options:n}),v}return S(e.data)}get enum(){return this._def.values}}re=new WeakMap,ue.create=(s,e)=>new ue({values:s,typeName:g.ZodNativeEnum,...y(e)});class Q extends _{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==p.promise&&t.common.async===!1)return h(t,{code:d.invalid_type,expected:p.promise,received:t.parsedType}),v;const r=t.parsedType===p.promise?t.data:Promise.resolve(t.data);return S(r.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Q.create=(s,e)=>new Q({type:s,typeName:g.ZodPromise,...y(e)});class C extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===g.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:r}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:c=>{h(r,c),c.fatal?t.abort():t.dirty()},get path(){return r.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const c=n.transform(r.data,a);if(r.common.async)return Promise.resolve(c).then(async o=>{if(t.value==="aborted")return v;const l=await this._def.schema._parseAsync({data:o,path:r.path,parent:r});return l.status==="aborted"?v:l.status==="dirty"||t.value==="dirty"?X(l.value):l});{if(t.value==="aborted")return v;const o=this._def.schema._parseSync({data:c,path:r.path,parent:r});return o.status==="aborted"?v:o.status==="dirty"||t.value==="dirty"?X(o.value):o}}if(n.type==="refinement"){const c=o=>{const l=n.refinement(o,a);if(r.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),c(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>o.status==="aborted"?v:(o.status==="dirty"&&t.dirty(),c(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(r.common.async===!1){const c=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!U(c))return c;const o=n.transform(c.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(c=>U(c)?Promise.resolve(n.transform(c.value,a)).then(o=>({status:t.value,value:o})):c);x.assertNever(n)}}C.create=(s,e,t)=>new C({schema:s,typeName:g.ZodEffects,effect:e,...y(t)}),C.createWithPreprocess=(s,e,t)=>new C({schema:e,effect:{type:"preprocess",transform:s},typeName:g.ZodEffects,...y(t)});class O extends _{_parse(e){return this._getType(e)===p.undefined?S(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}O.create=(s,e)=>new O({innerType:s,typeName:g.ZodOptional,...y(e)});class V extends _{_parse(e){return this._getType(e)===p.null?S(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}V.create=(s,e)=>new V({innerType:s,typeName:g.ZodNullable,...y(e)});class he extends _{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===p.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}he.create=(s,e)=>new he({innerType:s,typeName:g.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...y(e)});class fe extends _{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return te(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new R(r.common.issues)},input:r.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new R(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}fe.create=(s,e)=>new fe({innerType:s,typeName:g.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...y(e)});class Se extends _{_parse(e){if(this._getType(e)!==p.nan){const r=this._getOrReturnCtx(e);return h(r,{code:d.invalid_type,expected:p.nan,received:r.parsedType}),v}return{status:"valid",value:e.data}}}Se.create=s=>new Se({typeName:g.ZodNaN,...y(s)});const Ht=Symbol("zod_brand");class Ve extends _{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class ge extends _{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return a.status==="aborted"?v:a.status==="dirty"?(t.dirty(),X(a.value)):this._def.out._parseAsync({data:a.value,path:r.path,parent:r})})();{const n=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return n.status==="aborted"?v:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:r.path,parent:r})}}static create(e,t){return new ge({in:e,out:t,typeName:g.ZodPipeline})}}class pe extends _{_parse(e){const t=this._def.innerType._parse(e),r=n=>(U(n)&&(n.value=Object.freeze(n.value)),n);return te(t)?t.then(n=>r(n)):r(t)}unwrap(){return this._def.innerType}}pe.create=(s,e)=>new pe({innerType:s,typeName:g.ZodReadonly,...y(e)});function Xe(s,e){const t=typeof s=="function"?s(e):typeof s=="string"?{message:s}:s;return typeof t=="string"?{message:t}:t}function Ye(s,e={},t){return s?Y.create().superRefine((r,n)=>{var a,c;const o=s(r);if(o instanceof Promise)return o.then(l=>{var u,f;if(!l){const k=Xe(e,r),G=(f=(u=k.fatal)!==null&&u!==void 0?u:t)!==null&&f!==void 0?f:!0;n.addIssue({code:"custom",...k,fatal:G})}});if(!o){const l=Xe(e,r),u=(c=(a=l.fatal)!==null&&a!==void 0?a:t)!==null&&c!==void 0?c:!0;n.addIssue({code:"custom",...l,fatal:u})}}):Y.create()}const Xt={object:b.lazycreate};var g;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(g||(g={}));const Yt=(s,e={message:`Input not instance of ${s.name}`})=>Ye(t=>t instanceof s,e),Ke=E.create,Qe=D.create,Kt=Se.create,Qt=q.create,et=ne.create,es=W.create,ts=be.create,ss=ae.create,rs=ie.create,ns=Y.create,as=F.create,is=L.create,os=ke.create,cs=Z.create,ds=b.create,ls=b.strictCreate,us=oe.create,hs=Ae.create,fs=ce.create,ps=P.create,ms=ve.create,gs=we.create,vs=J.create,ys=ee.create,_s=de.create,xs=le.create,bs=B.create,ks=ue.create,ws=Q.create,tt=C.create,Ss=O.create,Ts=V.create,Rs=C.createWithPreprocess,Cs=ge.create,js=()=>Ke().optional(),Ns=()=>Qe().optional(),Zs=()=>et().optional(),Es={string:s=>E.create({...s,coerce:!0}),number:s=>D.create({...s,coerce:!0}),boolean:s=>ne.create({...s,coerce:!0}),bigint:s=>q.create({...s,coerce:!0}),date:s=>W.create({...s,coerce:!0})},As=v;var i=Object.freeze({__proto__:null,defaultErrorMap:H,setErrorMap:Rt,getErrorMap:ye,makeIssue:_e,EMPTY_PATH:Ct,addIssueToContext:h,ParseStatus:w,INVALID:v,DIRTY:X,OK:S,isAborted:Pe,isDirty:Me,isValid:U,isAsync:te,get util(){return x},get objectUtil(){return Ie},ZodParsedType:p,getParsedType:M,ZodType:_,datetimeRegex:Ge,ZodString:E,ZodNumber:D,ZodBigInt:q,ZodBoolean:ne,ZodDate:W,ZodSymbol:be,ZodUndefined:ae,ZodNull:ie,ZodAny:Y,ZodUnknown:F,ZodNever:L,ZodVoid:ke,ZodArray:Z,ZodObject:b,ZodUnion:oe,ZodDiscriminatedUnion:Ae,ZodIntersection:ce,ZodTuple:P,ZodRecord:ve,ZodMap:we,ZodSet:J,ZodFunction:ee,ZodLazy:de,ZodLiteral:le,ZodEnum:B,ZodNativeEnum:ue,ZodPromise:Q,ZodEffects:C,ZodTransformer:C,ZodOptional:O,ZodNullable:V,ZodDefault:he,ZodCatch:fe,ZodNaN:Se,BRAND:Ht,ZodBranded:Ve,ZodPipeline:ge,ZodReadonly:pe,custom:Ye,Schema:_,ZodSchema:_,late:Xt,get ZodFirstPartyTypeKind(){return g},coerce:Es,any:ns,array:cs,bigint:Qt,boolean:et,date:es,discriminatedUnion:hs,effect:tt,enum:bs,function:ys,instanceof:Yt,intersection:fs,lazy:_s,literal:xs,map:gs,nan:Kt,nativeEnum:ks,never:is,null:rs,nullable:Ts,number:Qe,object:ds,oboolean:Zs,onumber:Ns,optional:Ss,ostring:js,pipeline:Cs,preprocess:Rs,promise:ws,record:ms,set:vs,strictObject:ls,string:Ke,symbol:ts,transformer:tt,tuple:ps,undefined:ss,union:us,unknown:as,void:os,NEVER:As,ZodIssueCode:d,quotelessJson:Tt,ZodError:R});const Te="2.0",st=i.union([i.string(),i.number().int()]),rt=i.string(),j=i.object({_meta:i.optional(i.object({progressToken:i.optional(st)}).passthrough())}).passthrough(),T=i.object({method:i.string(),params:i.optional(j)}),me=i.object({_meta:i.optional(i.object({}).passthrough())}).passthrough(),I=i.object({method:i.string(),params:i.optional(me)}),N=i.object({_meta:i.optional(i.object({}).passthrough())}).passthrough(),Re=i.union([i.string(),i.number().int()]),Os=i.object({jsonrpc:i.literal(Te),id:Re}).merge(T).strict(),Is=i.object({jsonrpc:i.literal(Te)}).merge(I).strict(),Ps=i.object({jsonrpc:i.literal(Te),id:Re,result:N}).strict();var nt;(function(s){s[s.ConnectionClosed=-32e3]="ConnectionClosed",s[s.RequestTimeout=-32001]="RequestTimeout",s[s.ParseError=-32700]="ParseError",s[s.InvalidRequest=-32600]="InvalidRequest",s[s.MethodNotFound=-32601]="MethodNotFound",s[s.InvalidParams=-32602]="InvalidParams",s[s.InternalError=-32603]="InternalError"})(nt||(nt={}));const Ms=i.object({jsonrpc:i.literal(Te),id:Re,error:i.object({code:i.number().int(),message:i.string(),data:i.optional(i.unknown())})}).strict(),Ls=i.union([Os,Is,Ps,Ms]),at=N.strict(),it=I.extend({method:i.literal("notifications/cancelled"),params:me.extend({requestId:Re,reason:i.string().optional()})}),ot=i.object({name:i.string(),version:i.string()}).passthrough(),$s=i.object({experimental:i.optional(i.object({}).passthrough()),sampling:i.optional(i.object({}).passthrough()),roots:i.optional(i.object({listChanged:i.optional(i.boolean())}).passthrough())}).passthrough(),Vs=T.extend({method:i.literal("initialize"),params:j.extend({protocolVersion:i.string(),capabilities:$s,clientInfo:ot})}),zs=i.object({experimental:i.optional(i.object({}).passthrough()),logging:i.optional(i.object({}).passthrough()),completions:i.optional(i.object({}).passthrough()),prompts:i.optional(i.object({listChanged:i.optional(i.boolean())}).passthrough()),resources:i.optional(i.object({subscribe:i.optional(i.boolean()),listChanged:i.optional(i.boolean())}).passthrough()),tools:i.optional(i.object({listChanged:i.optional(i.boolean())}).passthrough())}).passthrough(),Ds=N.extend({protocolVersion:i.string(),capabilities:zs,serverInfo:ot,instructions:i.optional(i.string())}),qs=I.extend({method:i.literal("notifications/initialized")}),ct=T.extend({method:i.literal("ping")}),Bs=i.object({progress:i.number(),total:i.optional(i.number())}).passthrough(),dt=I.extend({method:i.literal("notifications/progress"),params:me.merge(Bs).extend({progressToken:st})}),Ce=T.extend({params:j.extend({cursor:i.optional(rt)}).optional()}),je=N.extend({nextCursor:i.optional(rt)}),lt=i.object({uri:i.string(),mimeType:i.optional(i.string())}).passthrough(),ut=lt.extend({text:i.string()}),ht=lt.extend({blob:i.string().base64()}),Us=i.object({uri:i.string(),name:i.string(),description:i.optional(i.string()),mimeType:i.optional(i.string())}).passthrough(),Fs=i.object({uriTemplate:i.string(),name:i.string(),description:i.optional(i.string()),mimeType:i.optional(i.string())}).passthrough(),Ws=Ce.extend({method:i.literal("resources/list")}),Js=je.extend({resources:i.array(Us)}),Gs=Ce.extend({method:i.literal("resources/templates/list")}),Hs=je.extend({resourceTemplates:i.array(Fs)}),Xs=T.extend({method:i.literal("resources/read"),params:j.extend({uri:i.string()})}),Ys=N.extend({contents:i.array(i.union([ut,ht]))}),Ks=I.extend({method:i.literal("notifications/resources/list_changed")}),Qs=T.extend({method:i.literal("resources/subscribe"),params:j.extend({uri:i.string()})}),er=T.extend({method:i.literal("resources/unsubscribe"),params:j.extend({uri:i.string()})}),tr=I.extend({method:i.literal("notifications/resources/updated"),params:me.extend({uri:i.string()})}),sr=i.object({name:i.string(),description:i.optional(i.string()),required:i.optional(i.boolean())}).passthrough(),rr=i.object({name:i.string(),description:i.optional(i.string()),arguments:i.optional(i.array(sr))}).passthrough(),nr=Ce.extend({method:i.literal("prompts/list")}),ar=je.extend({prompts:i.array(rr)}),ir=T.extend({method:i.literal("prompts/get"),params:j.extend({name:i.string(),arguments:i.optional(i.record(i.string()))})}),Ne=i.object({type:i.literal("text"),text:i.string()}).passthrough(),Ze=i.object({type:i.literal("image"),data:i.string().base64(),mimeType:i.string()}).passthrough(),Ee=i.object({type:i.literal("audio"),data:i.string().base64(),mimeType:i.string()}).passthrough(),ft=i.object({type:i.literal("resource"),resource:i.union([ut,ht])}).passthrough(),or=i.object({role:i.enum(["user","assistant"]),content:i.union([Ne,Ze,Ee,ft])}).passthrough(),cr=N.extend({description:i.optional(i.string()),messages:i.array(or)}),dr=I.extend({method:i.literal("notifications/prompts/list_changed")}),lr=i.object({name:i.string(),description:i.optional(i.string()),inputSchema:i.object({type:i.literal("object"),properties:i.optional(i.object({}).passthrough())}).passthrough()}).passthrough(),ur=Ce.extend({method:i.literal("tools/list")}),hr=je.extend({tools:i.array(lr)}),pt=N.extend({content:i.array(i.union([Ne,Ze,Ee,ft])),isError:i.boolean().default(!1).optional()});pt.or(N.extend({toolResult:i.unknown()}));const fr=T.extend({method:i.literal("tools/call"),params:j.extend({name:i.string(),arguments:i.optional(i.record(i.unknown()))})}),pr=I.extend({method:i.literal("notifications/tools/list_changed")}),mt=i.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),mr=T.extend({method:i.literal("logging/setLevel"),params:j.extend({level:mt})}),gr=I.extend({method:i.literal("notifications/message"),params:me.extend({level:mt,logger:i.optional(i.string()),data:i.unknown()})}),vr=i.object({name:i.string().optional()}).passthrough(),yr=i.object({hints:i.optional(i.array(vr)),costPriority:i.optional(i.number().min(0).max(1)),speedPriority:i.optional(i.number().min(0).max(1)),intelligencePriority:i.optional(i.number().min(0).max(1))}).passthrough(),_r=i.object({role:i.enum(["user","assistant"]),content:i.union([Ne,Ze,Ee])}).passthrough(),xr=T.extend({method:i.literal("sampling/createMessage"),params:j.extend({messages:i.array(_r),systemPrompt:i.optional(i.string()),includeContext:i.optional(i.enum(["none","thisServer","allServers"])),temperature:i.optional(i.number()),maxTokens:i.number().int(),stopSequences:i.optional(i.array(i.string())),metadata:i.optional(i.object({}).passthrough()),modelPreferences:i.optional(yr)})}),br=N.extend({model:i.string(),stopReason:i.optional(i.enum(["endTurn","stopSequence","maxTokens"]).or(i.string())),role:i.enum(["user","assistant"]),content:i.discriminatedUnion("type",[Ne,Ze,Ee])}),kr=i.object({type:i.literal("ref/resource"),uri:i.string()}).passthrough(),wr=i.object({type:i.literal("ref/prompt"),name:i.string()}).passthrough(),Sr=T.extend({method:i.literal("completion/complete"),params:j.extend({ref:i.union([wr,kr]),argument:i.object({name:i.string(),value:i.string()}).passthrough()})}),Tr=N.extend({completion:i.object({values:i.array(i.string()).max(100),total:i.optional(i.number().int()),hasMore:i.optional(i.boolean())}).passthrough()}),Rr=i.object({uri:i.string().startsWith("file://"),name:i.optional(i.string())}).passthrough(),Cr=T.extend({method:i.literal("roots/list")}),jr=N.extend({roots:i.array(Rr)}),Nr=I.extend({method:i.literal("notifications/roots/list_changed")});i.union([ct,Vs,Sr,mr,ir,nr,Ws,Gs,Xs,Qs,er,fr,ur]),i.union([it,dt,qs,Nr]),i.union([at,br,jr]),i.union([ct,xr,Cr]),i.union([it,dt,gr,tr,Ks,pr,dr]),i.union([at,Ds,Tr,cr,ar,Js,Hs,Ys,pt,hr]),new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");var ze;(function(s){s.Completable="McpCompletable"})(ze||(ze={}));class gt extends _{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}gt.create=(s,e)=>new gt({type:s,typeName:ze.Completable,complete:e.complete,...Zr(e)});function Zr(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:r,description:n}=s;if(e&&(t||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(c,o)=>{var l,u;const{message:f}=s;return c.code==="invalid_enum_value"?{message:f??o.defaultError}:typeof o.data>"u"?{message:(l=f??r)!==null&&l!==void 0?l:o.defaultError}:c.code!=="invalid_type"?{message:o.defaultError}:{message:(u=f??t)!==null&&u!==void 0?u:o.defaultError}},description:n}}const vt=1e6,De=1e6,yt=1e4,Er=1e6;class z{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,t,r){if(e.length>t)throw new Error(`${r} exceeds maximum length of ${t} characters (got ${e.length})`)}get variableNames(){return this.parts.flatMap(e=>typeof e=="string"?[]:e.names)}constructor(e){z.validateLength(e,vt,"Template"),this.template=e,this.parts=this.parse(e)}toString(){return this.template}parse(e){const t=[];let r="",n=0,a=0;for(;n<e.length;)if(e[n]==="{"){r&&(t.push(r),r="");const c=e.indexOf("}",n);if(c===-1)throw new Error("Unclosed template expression");if(a++,a>yt)throw new Error(`Template contains too many expressions (max ${yt})`);const o=e.slice(n+1,c),l=this.getOperator(o),u=o.includes("*"),f=this.getNames(o),k=f[0];for(const G of f)z.validateLength(G,De,"Variable name");t.push({name:k,operator:l,names:f,exploded:u}),n=c+1}else r+=e[n],n++;return r&&t.push(r),t}getOperator(e){return["+","#",".","/","?","&"].find(r=>e.startsWith(r))||""}getNames(e){const t=this.getOperator(e);return e.slice(t.length).split(",").map(r=>r.replace("*","").trim()).filter(r=>r.length>0)}encodeValue(e,t){return z.validateLength(e,De,"Variable value"),t==="+"||t==="#"?encodeURI(e):encodeURIComponent(e)}expandPart(e,t){if(e.operator==="?"||e.operator==="&"){const c=e.names.map(l=>{const u=t[l];if(u===void 0)return"";const f=Array.isArray(u)?u.map(k=>this.encodeValue(k,e.operator)).join(","):this.encodeValue(u.toString(),e.operator);return`${l}=${f}`}).filter(l=>l.length>0);return c.length===0?"":(e.operator==="?"?"?":"&")+c.join("&")}if(e.names.length>1){const c=e.names.map(o=>t[o]).filter(o=>o!==void 0);return c.length===0?"":c.map(o=>Array.isArray(o)?o[0]:o).join(",")}const r=t[e.name];if(r===void 0)return"";const a=(Array.isArray(r)?r:[r]).map(c=>this.encodeValue(c,e.operator));switch(e.operator){case"":return a.join(",");case"+":return a.join(",");case"#":return"#"+a.join(",");case".":return"."+a.join(".");case"/":return"/"+a.join("/");default:return a.join(",")}}expand(e){let t="",r=!1;for(const n of this.parts){if(typeof n=="string"){t+=n;continue}const a=this.expandPart(n,e);a&&((n.operator==="?"||n.operator==="&")&&r?t+=a.replace("?","&"):t+=a,(n.operator==="?"||n.operator==="&")&&(r=!0))}return t}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}partToRegExp(e){const t=[];for(const a of e.names)z.validateLength(a,De,"Variable name");if(e.operator==="?"||e.operator==="&"){for(let a=0;a<e.names.length;a++){const c=e.names[a],o=a===0?"\\"+e.operator:"&";t.push({pattern:o+this.escapeRegExp(c)+"=([^&]+)",name:c})}return t}let r;const n=e.name;switch(e.operator){case"":r=e.exploded?"([^/]+(?:,[^/]+)*)":"([^/,]+)";break;case"+":case"#":r="(.+)";break;case".":r="\\.([^/,]+)";break;case"/":r="/"+(e.exploded?"([^/]+(?:,[^/]+)*)":"([^/,]+)");break;default:r="([^/]+)"}return t.push({pattern:r,name:n}),t}match(e){z.validateLength(e,vt,"URI");let t="^";const r=[];for(const o of this.parts)if(typeof o=="string")t+=this.escapeRegExp(o);else{const l=this.partToRegExp(o);for(const{pattern:u,name:f}of l)t+=u,r.push({name:f,exploded:o.exploded})}t+="$",z.validateLength(t,Er,"Generated regex pattern");const n=new RegExp(t),a=e.match(n);if(!a)return null;const c={};for(let o=0;o<r.length;o++){const{name:l,exploded:u}=r[o],f=a[o+1],k=l.replace("*","");u&&f.includes(",")?c[k]=f.split(","):c[k]=f}return c}}class Ar{constructor(e,t){this._callbacks=t,this._uriTemplate=typeof e=="string"?new z(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){var t;return(t=this._callbacks.complete)===null||t===void 0?void 0:t[e]}}class Or{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;const e=this._buffer.indexOf(`
3
- `);if(e===-1)return null;const t=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),Ir(t)}clear(){this._buffer=void 0}}function Ir(s){return Ls.parse(JSON.parse(s))}function Pr(s){return JSON.stringify(s)+`
4
- `}class Mr{constructor(e=qe.stdin,t=qe.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new Or,this._started=!1,this._ondata=r=>{this._readBuffer.append(r),this.processReadBuffer()},this._onerror=r=>{var n;(n=this.onerror)===null||n===void 0||n.call(this,r)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(var e,t;;)try{const r=this._readBuffer.readMessage();if(r===null)break;(e=this.onmessage)===null||e===void 0||e.call(this,r)}catch(r){(t=this.onerror)===null||t===void 0||t.call(this,r)}}async close(){var e;this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),(e=this.onclose)===null||e===void 0||e.call(this)}send(e){return new Promise(t=>{const r=Pr(e);this._stdout.write(r)?t():this._stdout.once("drain",t)})}}const _t=bt(process.env.LIKEC4_WORKSPACE||".");async function Lr(){console.error(`Loading LikeC4 from workspace ${_t}`);const s=await xt.fromWorkspace(_t,{logger:!1}),e=s.langium.mcp.Tools,t=s.langium.mcp.ServerFactory.create({capabilities:{completions:{},tools:{},resources:{}}});t.resource("likec4 element",new Ar("likec4://projects/{project}/elements/{id}",{list:async()=>{const n=await s.languageServices.projects(),a=[];for(const{id:c}of n){const o=s.computedModel(c);for(const l of o.elements())a.push({uri:`likec4://projects/${c}/elements/${l.id}`,name:l.title,id:l.id,description:`Model element of kind "${l.kind}"`})}return{resources:a}},complete:{project:async n=>{const a=await s.projects(),c=n.toLowerCase();return a.filter(o=>o.toLowerCase().startsWith(c))},id:async n=>{const{id:a}=s.languageServices.projects()[0],c=s.computedModel(a);return[...St(c.elements(),o=>o.id.startsWith(n))].map(o=>o.id)}}}),async(n,{project:a,id:c})=>{const o=await e.readElement({id:c,project:a});return{contents:[{uri:n.href,mimeType:"application/json",text:o}]}}),t.server.oninitialized=()=>{t.server.sendLoggingMessage({level:"info",data:{message:"Server initialized",workspace:s.workspace}})};const r=new Mr;console.error("Connecting server to transport..."),await t.connect(r),console.error("LikeC4 MCP Server running on stdio")}Lr().catch(s=>{console.error(s),process.exit(1)});
2
+ import Me from"node:process";import{LikeC4 as mt}from"likec4";import{resolve as pt}from"node:path";function gt(r){return typeof r=="function"}function _t(r,e){if(!r)throw new Error("Invariant failed")}function yt(r,e){const t=e??r;_t(gt(t));function*s(n){for(const a of n)t(a)&&(yield a)}return e?s(r):s}var w;(function(r){r.assertEqual=n=>{};function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{const a={};for(const o of n)a[o]=o;return a},r.getValidEnumValues=n=>{const a=r.objectKeys(n).filter(i=>typeof n[n[i]]!="number"),o={};for(const i of a)o[i]=n[i];return r.objectValues(o)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const o in n)Object.prototype.hasOwnProperty.call(n,o)&&a.push(o);return a},r.find=(n,a)=>{for(const o of n)if(a(o))return o},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(w||(w={}));var Pe;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Pe||(Pe={}));const h=w.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),D=r=>{switch(typeof r){case"undefined":return h.undefined;case"string":return h.string;case"number":return Number.isNaN(r)?h.nan:h.number;case"boolean":return h.boolean;case"function":return h.function;case"bigint":return h.bigint;case"symbol":return h.symbol;case"object":return Array.isArray(r)?h.array:r===null?h.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?h.promise:typeof Map<"u"&&r instanceof Map?h.map:typeof Set<"u"&&r instanceof Set?h.set:typeof Date<"u"&&r instanceof Date?h.date:h.object;default:return h.unknown}},c=w.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class z extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(const o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(n);else if(o.code==="invalid_return_type")n(o.returnTypeError);else if(o.code==="invalid_arguments")n(o.argumentsError);else if(o.path.length===0)s._errors.push(t(o));else{let i=s,d=0;for(;d<o.path.length;){const l=o.path[d];d===o.path.length-1?(i[l]=i[l]||{_errors:[]},i[l]._errors.push(t(o))):i[l]=i[l]||{_errors:[]},i=i[l],d++}}};return n(this),s}static assert(e){if(!(e instanceof z))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,w.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}z.create=r=>new z(r);const be=(r,e)=>{let t;switch(r.code){case c.invalid_type:r.received===h.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case c.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,w.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:t=`Unrecognized key(s) in object: ${w.joinValues(r.keys,", ")}`;break;case c.invalid_union:t="Invalid input";break;case c.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${w.joinValues(r.options)}`;break;case c.invalid_enum_value:t=`Invalid enum value. Expected ${w.joinValues(r.options)}, received '${r.received}'`;break;case c.invalid_arguments:t="Invalid function arguments";break;case c.invalid_return_type:t="Invalid function return type";break;case c.invalid_date:t="Invalid date";break;case c.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:w.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case c.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case c.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case c.custom:t="Invalid input";break;case c.invalid_intersection_types:t="Intersection results could not be merged";break;case c.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case c.not_finite:t="Number must be finite";break;default:t=e.defaultError,w.assertNever(r)}return{message:t}};let vt=be;function xt(){return vt}const kt=r=>{const{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],o={...n,path:a};if(n.message!==void 0)return{...n,path:a,message:n.message};let i="";const d=s.filter(l=>!!l).slice().reverse();for(const l of d)i=l(o,{data:e,defaultError:i}).message;return{...n,path:a,message:i}};function u(r,e){const t=xt(),s=kt({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===be?void 0:be].filter(n=>!!n)});r.common.issues.push(s)}class C{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const n of t){if(n.status==="aborted")return y;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const n of t){const a=await n.key,o=await n.value;s.push({key:a,value:o})}return C.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const n of t){const{key:a,value:o}=n;if(a.status==="aborted"||o.status==="aborted")return y;a.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||n.alwaysSet)&&(s[a.value]=o.value)}return{status:e.value,value:s}}}const y=Object.freeze({status:"aborted"}),K=r=>({status:"dirty",value:r}),A=r=>({status:"valid",value:r}),Le=r=>r.status==="aborted",$e=r=>r.status==="dirty",G=r=>r.status==="valid",re=r=>typeof Promise<"u"&&r instanceof Promise;var m;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(m||(m={}));class M{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Ve=(r,e)=>{if(G(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new z(r.common.issues);return this._error=t,this._error}}};function x(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(o,i)=>{const{message:d}=r;return o.code==="invalid_enum_value"?{message:d??i.defaultError}:typeof i.data>"u"?{message:d??s??i.defaultError}:o.code!=="invalid_type"?{message:i.defaultError}:{message:d??t??i.defaultError}},description:n}}class k{get description(){return this._def.description}_getType(e){return D(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:D(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new C,ctx:{common:e.parent.common,data:e.data,parsedType:D(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(re(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)},n=this._parseSync({data:e,path:s.path,parent:s});return Ve(s,n)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return G(s)?{value:s.value}:{issues:t.common.issues}}catch(s){s?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(s=>G(s)?{value:s.value}:{issues:t.common.issues})}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:D(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(re(n)?n:Promise.resolve(n));return Ve(s,a)}refine(e,t){const s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const o=e(n),i=()=>a.addIssue({code:c.custom,...s(n)});return typeof Promise<"u"&&o instanceof Promise?o.then(d=>d?!0:(i(),!1)):o?!0:(i(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new W({schema:this,typeName:v.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return V.create(this,this._def)}nullable(){return F.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return L.create(this)}promise(){return oe.create(this,this._def)}or(e){return ne.create([this,e],this._def)}and(e){return ae.create(this,e,this._def)}transform(e){return new W({...x(this._def),schema:this,typeName:v.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ce({...x(this._def),innerType:this,defaultValue:t,typeName:v.ZodDefault})}brand(){return new He({typeName:v.ZodBranded,type:this,...x(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new de({...x(this._def),innerType:this,catchValue:t,typeName:v.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Ze.create(this,e)}readonly(){return ue.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const bt=/^c[^\s-]{8,}$/i,wt=/^[0-9a-z]+$/,St=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Tt=/^[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,Rt=/^[a-z0-9_-]{21}$/i,Ct=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Nt=/^[-+]?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)?)??$/,Ot=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,At="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let we;const jt=/^(?:(?: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])$/,It=/^(?:(?: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])$/,Et=/^(([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]))$/,Zt=/^(([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])$/,Mt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Pt=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ze="((\\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])))",Lt=new RegExp(`^${ze}$`);function qe(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);const t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function $t(r){return new RegExp(`^${qe(r)}$`)}function Vt(r){let e=`${ze}T${qe(r)}`;const t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function zt(r,e){return!!((e==="v4"||!e)&&jt.test(r)||(e==="v6"||!e)&&Et.test(r))}function qt(r,e){if(!Ct.test(r))return!1;try{const[t]=r.split("."),s=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),n=JSON.parse(atob(s));return!(typeof n!="object"||n===null||"typ"in n&&n?.typ!=="JWT"||!n.alg||e&&n.alg!==e)}catch{return!1}}function Dt(r,e){return!!((e==="v4"||!e)&&It.test(r)||(e==="v6"||!e)&&Zt.test(r))}class q extends k{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==h.string){const a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_type,expected:h.string,received:a.parsedType}),y}const s=new C;let n;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="max")e.data.length>a.value&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),s.dirty());else if(a.kind==="length"){const o=e.data.length>a.value,i=e.data.length<a.value;(o||i)&&(n=this._getOrReturnCtx(e,n),o?u(n,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):i&&u(n,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),s.dirty())}else if(a.kind==="email")Ot.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"email",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="emoji")we||(we=new RegExp(At,"u")),we.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"emoji",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="uuid")Tt.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"uuid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="nanoid")Rt.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"nanoid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid")bt.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"cuid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="cuid2")wt.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"cuid2",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="ulid")St.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"ulid",code:c.invalid_string,message:a.message}),s.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),u(n,{validation:"url",code:c.invalid_string,message:a.message}),s.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"regex",code:c.invalid_string,message:a.message}),s.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),s.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:{startsWith:a.value},message:a.message}),s.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:{endsWith:a.value},message:a.message}),s.dirty()):a.kind==="datetime"?Vt(a).test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:"datetime",message:a.message}),s.dirty()):a.kind==="date"?Lt.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:"date",message:a.message}),s.dirty()):a.kind==="time"?$t(a).test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_string,validation:"time",message:a.message}),s.dirty()):a.kind==="duration"?Nt.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"duration",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="ip"?zt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"ip",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="jwt"?qt(e.data,a.alg)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"jwt",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="cidr"?Dt(e.data,a.version)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"cidr",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="base64"?Mt.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"base64",code:c.invalid_string,message:a.message}),s.dirty()):a.kind==="base64url"?Pt.test(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{validation:"base64url",code:c.invalid_string,message:a.message}),s.dirty()):w.assertNever(a);return{status:s.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:c.invalid_string,...m.errToObj(s)})}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...m.errToObj(e)})}url(e){return this._addCheck({kind:"url",...m.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...m.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...m.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...m.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...m.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...m.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...m.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...m.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...m.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...m.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...m.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...m.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...m.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...m.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...m.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...m.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...m.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...m.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...m.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...m.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...m.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...m.errToObj(t)})}nonempty(e){return this.min(1,m.errToObj(e))}trim(){return new q({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}q.create=r=>new q({checks:[],typeName:v.ZodString,coerce:r?.coerce??!1,...x(r)});function Bt(r,e){const t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=Number.parseInt(r.toFixed(n).replace(".","")),o=Number.parseInt(e.toFixed(n).replace(".",""));return a%o/10**n}class Q extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==h.number){const a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_type,expected:h.number,received:a.parsedType}),y}let s;const n=new C;for(const a of this._def.checks)a.kind==="int"?w.isInteger(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:c.invalid_type,expected:"integer",received:"float",message:a.message}),n.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),n.dirty()):a.kind==="multipleOf"?Bt(e.data,a.value)!==0&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(s=this._getOrReturnCtx(e,s),u(s,{code:c.not_finite,message:a.message}),n.dirty()):w.assertNever(a);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,s,n){return new Q({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.toString(n)}]})}_addCheck(e){return new Q({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:m.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:m.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:m.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:m.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&w.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Q.create=r=>new Q({checks:[],typeName:v.ZodNumber,coerce:r?.coerce||!1,...x(r)});class te extends k{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==h.bigint)return this._getInvalidInput(e);let s;const n=new C;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),n.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(s=this._getOrReturnCtx(e,s),u(s,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),n.dirty()):w.assertNever(a);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return u(t,{code:c.invalid_type,expected:h.bigint,received:t.parsedType}),y}gte(e,t){return this.setLimit("min",e,!0,m.toString(t))}gt(e,t){return this.setLimit("min",e,!1,m.toString(t))}lte(e,t){return this.setLimit("max",e,!0,m.toString(t))}lt(e,t){return this.setLimit("max",e,!1,m.toString(t))}setLimit(e,t,s,n){return new te({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:m.toString(n)}]})}_addCheck(e){return new te({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:m.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:m.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:m.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:m.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:m.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}te.create=r=>new te({checks:[],typeName:v.ZodBigInt,coerce:r?.coerce??!1,...x(r)});class Se extends k{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==h.boolean){const s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:h.boolean,received:s.parsedType}),y}return A(e.data)}}Se.create=r=>new Se({typeName:v.ZodBoolean,coerce:r?.coerce||!1,...x(r)});class ve extends k{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==h.date){const a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_type,expected:h.date,received:a.parsedType}),y}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return u(a,{code:c.invalid_date}),y}const s=new C;let n;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),s.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),s.dirty()):w.assertNever(a);return{status:s.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ve({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:m.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:m.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}ve.create=r=>new ve({checks:[],coerce:r?.coerce||!1,typeName:v.ZodDate,...x(r)});class De extends k{_parse(e){if(this._getType(e)!==h.symbol){const s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:h.symbol,received:s.parsedType}),y}return A(e.data)}}De.create=r=>new De({typeName:v.ZodSymbol,...x(r)});class Te extends k{_parse(e){if(this._getType(e)!==h.undefined){const s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:h.undefined,received:s.parsedType}),y}return A(e.data)}}Te.create=r=>new Te({typeName:v.ZodUndefined,...x(r)});class Re extends k{_parse(e){if(this._getType(e)!==h.null){const s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:h.null,received:s.parsedType}),y}return A(e.data)}}Re.create=r=>new Re({typeName:v.ZodNull,...x(r)});class Be extends k{constructor(){super(...arguments),this._any=!0}_parse(e){return A(e.data)}}Be.create=r=>new Be({typeName:v.ZodAny,...x(r)});class Ce extends k{constructor(){super(...arguments),this._unknown=!0}_parse(e){return A(e.data)}}Ce.create=r=>new Ce({typeName:v.ZodUnknown,...x(r)});class B extends k{_parse(e){const t=this._getOrReturnCtx(e);return u(t,{code:c.invalid_type,expected:h.never,received:t.parsedType}),y}}B.create=r=>new B({typeName:v.ZodNever,...x(r)});class Ue extends k{_parse(e){if(this._getType(e)!==h.undefined){const s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:h.void,received:s.parsedType}),y}return A(e.data)}}Ue.create=r=>new Ue({typeName:v.ZodVoid,...x(r)});class L extends k{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==h.array)return u(t,{code:c.invalid_type,expected:h.array,received:t.parsedType}),y;if(n.exactLength!==null){const o=t.data.length>n.exactLength.value,i=t.data.length<n.exactLength.value;(o||i)&&(u(t,{code:o?c.too_big:c.too_small,minimum:i?n.exactLength.value:void 0,maximum:o?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(u(t,{code:c.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(u(t,{code:c.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((o,i)=>n.type._parseAsync(new M(t,o,t.path,i)))).then(o=>C.mergeArray(s,o));const a=[...t.data].map((o,i)=>n.type._parseSync(new M(t,o,t.path,i)));return C.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new L({...this._def,minLength:{value:e,message:m.toString(t)}})}max(e,t){return new L({...this._def,maxLength:{value:e,message:m.toString(t)}})}length(e,t){return new L({...this._def,exactLength:{value:e,message:m.toString(t)}})}nonempty(e){return this.min(1,e)}}L.create=(r,e)=>new L({type:r,minLength:null,maxLength:null,exactLength:null,typeName:v.ZodArray,...x(e)});function X(r){if(r instanceof S){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=V.create(X(s))}return new S({...r._def,shape:()=>e})}else return r instanceof L?new L({...r._def,type:X(r.element)}):r instanceof V?V.create(X(r.unwrap())):r instanceof F?F.create(X(r.unwrap())):r instanceof J?J.create(r.items.map(e=>X(e))):r}class S extends k{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=w.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==h.object){const l=this._getOrReturnCtx(e);return u(l,{code:c.invalid_type,expected:h.object,received:l.parsedType}),y}const{status:s,ctx:n}=this._processInputParams(e),{shape:a,keys:o}=this._getCached(),i=[];if(!(this._def.catchall instanceof B&&this._def.unknownKeys==="strip"))for(const l in n.data)o.includes(l)||i.push(l);const d=[];for(const l of o){const g=a[l],O=n.data[l];d.push({key:{status:"valid",value:l},value:g._parse(new M(n,O,n.path,l)),alwaysSet:l in n.data})}if(this._def.catchall instanceof B){const l=this._def.unknownKeys;if(l==="passthrough")for(const g of i)d.push({key:{status:"valid",value:g},value:{status:"valid",value:n.data[g]}});else if(l==="strict")i.length>0&&(u(n,{code:c.unrecognized_keys,keys:i}),s.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const g of i){const O=n.data[g];d.push({key:{status:"valid",value:g},value:l._parse(new M(n,O,n.path,g)),alwaysSet:g in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const l=[];for(const g of d){const O=await g.key,ke=await g.value;l.push({key:O,value:ke,alwaysSet:g.alwaysSet})}return l}).then(l=>C.mergeObjectSync(s,l)):C.mergeObjectSync(s,d)}get shape(){return this._def.shape()}strict(e){return m.errToObj,new S({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{const n=this._def.errorMap?.(t,s).message??s.defaultError;return t.code==="unrecognized_keys"?{message:m.errToObj(e).message??n}:{message:n}}}:{}})}strip(){return new S({...this._def,unknownKeys:"strip"})}passthrough(){return new S({...this._def,unknownKeys:"passthrough"})}extend(e){return new S({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new S({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:v.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new S({...this._def,catchall:e})}pick(e){const t={};for(const s of w.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new S({...this._def,shape:()=>t})}omit(e){const t={};for(const s of w.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new S({...this._def,shape:()=>t})}deepPartial(){return X(this)}partial(e){const t={};for(const s of w.objectKeys(this.shape)){const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}return new S({...this._def,shape:()=>t})}required(e){const t={};for(const s of w.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let a=this.shape[s];for(;a instanceof V;)a=a._def.innerType;t[s]=a}return new S({...this._def,shape:()=>t})}keyof(){return Fe(w.objectKeys(this.shape))}}S.create=(r,e)=>new S({shape:()=>r,unknownKeys:"strip",catchall:B.create(),typeName:v.ZodObject,...x(e)}),S.strictCreate=(r,e)=>new S({shape:()=>r,unknownKeys:"strict",catchall:B.create(),typeName:v.ZodObject,...x(e)}),S.lazycreate=(r,e)=>new S({shape:r,unknownKeys:"strip",catchall:B.create(),typeName:v.ZodObject,...x(e)});class ne extends k{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(const i of a)if(i.result.status==="valid")return i.result;for(const i of a)if(i.result.status==="dirty")return t.common.issues.push(...i.ctx.common.issues),i.result;const o=a.map(i=>new z(i.ctx.common.issues));return u(t,{code:c.invalid_union,unionErrors:o}),y}if(t.common.async)return Promise.all(s.map(async a=>{const o={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(n);{let a;const o=[];for(const d of s){const l={...t,common:{...t.common,issues:[]},parent:null},g=d._parseSync({data:t.data,path:t.path,parent:l});if(g.status==="valid")return g;g.status==="dirty"&&!a&&(a={result:g,ctx:l}),l.common.issues.length&&o.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const i=o.map(d=>new z(d));return u(t,{code:c.invalid_union,unionErrors:i}),y}}get options(){return this._def.options}}ne.create=(r,e)=>new ne({options:r,typeName:v.ZodUnion,...x(e)});const $=r=>r instanceof Oe?$(r.schema):r instanceof W?$(r.innerType()):r instanceof ie?[r.value]:r instanceof H?r.options:r instanceof Ae?w.objectValues(r.enum):r instanceof ce?$(r._def.innerType):r instanceof Te?[void 0]:r instanceof Re?[null]:r instanceof V?[void 0,...$(r.unwrap())]:r instanceof F?[null,...$(r.unwrap())]:r instanceof He||r instanceof ue?$(r.unwrap()):r instanceof de?$(r._def.innerType):[];class Ee extends k{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.object)return u(t,{code:c.invalid_type,expected:h.object,received:t.parsedType}),y;const s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(u(t,{code:c.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const n=new Map;for(const a of t){const o=$(a.shape[e]);if(!o.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const i of o){if(n.has(i))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(i)}`);n.set(i,a)}}return new Ee({typeName:v.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...x(s)})}}function Ne(r,e){const t=D(r),s=D(e);if(r===e)return{valid:!0,data:r};if(t===h.object&&s===h.object){const n=w.objectKeys(e),a=w.objectKeys(r).filter(i=>n.indexOf(i)!==-1),o={...r,...e};for(const i of a){const d=Ne(r[i],e[i]);if(!d.valid)return{valid:!1};o[i]=d.data}return{valid:!0,data:o}}else if(t===h.array&&s===h.array){if(r.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<r.length;a++){const o=r[a],i=e[a],d=Ne(o,i);if(!d.valid)return{valid:!1};n.push(d.data)}return{valid:!0,data:n}}else return t===h.date&&s===h.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ae extends k{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,o)=>{if(Le(a)||Le(o))return y;const i=Ne(a.value,o.value);return i.valid?(($e(a)||$e(o))&&t.dirty(),{status:t.value,value:i.data}):(u(s,{code:c.invalid_intersection_types}),y)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,o])=>n(a,o)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ae.create=(r,e,t)=>new ae({left:r,right:e,typeName:v.ZodIntersection,...x(t)});class J extends k{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.array)return u(s,{code:c.invalid_type,expected:h.array,received:s.parsedType}),y;if(s.data.length<this._def.items.length)return u(s,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),y;!this._def.rest&&s.data.length>this._def.items.length&&(u(s,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map((o,i)=>{const d=this._def.items[i]||this._def.rest;return d?d._parse(new M(s,o,s.path,i)):null}).filter(o=>!!o);return s.common.async?Promise.all(a).then(o=>C.mergeArray(t,o)):C.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new J({...this._def,rest:e})}}J.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new J({items:r,typeName:v.ZodTuple,rest:null,...x(e)})};class xe extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.object)return u(s,{code:c.invalid_type,expected:h.object,received:s.parsedType}),y;const n=[],a=this._def.keyType,o=this._def.valueType;for(const i in s.data)n.push({key:a._parse(new M(s,i,s.path,i)),value:o._parse(new M(s,s.data[i],s.path,i)),alwaysSet:i in s.data});return s.common.async?C.mergeObjectAsync(t,n):C.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof k?new xe({keyType:e,valueType:t,typeName:v.ZodRecord,...x(s)}):new xe({keyType:q.create(),valueType:e,typeName:v.ZodRecord,...x(t)})}}class We extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.map)return u(s,{code:c.invalid_type,expected:h.map,received:s.parsedType}),y;const n=this._def.keyType,a=this._def.valueType,o=[...s.data.entries()].map(([i,d],l)=>({key:n._parse(new M(s,i,s.path,[l,"key"])),value:a._parse(new M(s,d,s.path,[l,"value"]))}));if(s.common.async){const i=new Map;return Promise.resolve().then(async()=>{for(const d of o){const l=await d.key,g=await d.value;if(l.status==="aborted"||g.status==="aborted")return y;(l.status==="dirty"||g.status==="dirty")&&t.dirty(),i.set(l.value,g.value)}return{status:t.value,value:i}})}else{const i=new Map;for(const d of o){const l=d.key,g=d.value;if(l.status==="aborted"||g.status==="aborted")return y;(l.status==="dirty"||g.status==="dirty")&&t.dirty(),i.set(l.value,g.value)}return{status:t.value,value:i}}}}We.create=(r,e,t)=>new We({valueType:e,keyType:r,typeName:v.ZodMap,...x(t)});class se extends k{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==h.set)return u(s,{code:c.invalid_type,expected:h.set,received:s.parsedType}),y;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(u(s,{code:c.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(u(s,{code:c.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function o(d){const l=new Set;for(const g of d){if(g.status==="aborted")return y;g.status==="dirty"&&t.dirty(),l.add(g.value)}return{status:t.value,value:l}}const i=[...s.data.values()].map((d,l)=>a._parse(new M(s,d,s.path,l)));return s.common.async?Promise.all(i).then(d=>o(d)):o(i)}min(e,t){return new se({...this._def,minSize:{value:e,message:m.toString(t)}})}max(e,t){return new se({...this._def,maxSize:{value:e,message:m.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}se.create=(r,e)=>new se({valueType:r,minSize:null,maxSize:null,typeName:v.ZodSet,...x(e)});class Oe extends k{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Oe.create=(r,e)=>new Oe({getter:r,typeName:v.ZodLazy,...x(e)});class ie extends k{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:c.invalid_literal,expected:this._def.value}),y}return{status:"valid",value:e.data}}get value(){return this._def.value}}ie.create=(r,e)=>new ie({value:r,typeName:v.ZodLiteral,...x(e)});function Fe(r,e){return new H({values:r,typeName:v.ZodEnum,...x(e)})}class H extends k{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return u(t,{expected:w.joinValues(s),received:t.parsedType,code:c.invalid_type}),y}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return u(t,{received:t.data,code:c.invalid_enum_value,options:s}),y}return A(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return H.create(e,{...this._def,...t})}exclude(e,t=this._def){return H.create(this.options.filter(s=>!e.includes(s)),{...this._def,...t})}}H.create=Fe;class Ae extends k{_parse(e){const t=w.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==h.string&&s.parsedType!==h.number){const n=w.objectValues(t);return u(s,{expected:w.joinValues(n),received:s.parsedType,code:c.invalid_type}),y}if(this._cache||(this._cache=new Set(w.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const n=w.objectValues(t);return u(s,{received:s.data,code:c.invalid_enum_value,options:n}),y}return A(e.data)}get enum(){return this._def.values}}Ae.create=(r,e)=>new Ae({values:r,typeName:v.ZodNativeEnum,...x(e)});class oe extends k{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==h.promise&&t.common.async===!1)return u(t,{code:c.invalid_type,expected:h.promise,received:t.parsedType}),y;const s=t.parsedType===h.promise?t.data:Promise.resolve(t.data);return A(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}oe.create=(r,e)=>new oe({type:r,typeName:v.ZodPromise,...x(e)});class W extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===v.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:o=>{u(s,o),o.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const o=n.transform(s.data,a);if(s.common.async)return Promise.resolve(o).then(async i=>{if(t.value==="aborted")return y;const d=await this._def.schema._parseAsync({data:i,path:s.path,parent:s});return d.status==="aborted"?y:d.status==="dirty"||t.value==="dirty"?K(d.value):d});{if(t.value==="aborted")return y;const i=this._def.schema._parseSync({data:o,path:s.path,parent:s});return i.status==="aborted"?y:i.status==="dirty"||t.value==="dirty"?K(i.value):i}}if(n.type==="refinement"){const o=i=>{const d=n.refinement(i,a);if(s.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return i};if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return i.status==="aborted"?y:(i.status==="dirty"&&t.dirty(),o(i.value),{status:t.value,value:i.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>i.status==="aborted"?y:(i.status==="dirty"&&t.dirty(),o(i.value).then(()=>({status:t.value,value:i.value}))))}if(n.type==="transform")if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!G(o))return y;const i=n.transform(o.value,a);if(i instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:i}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>G(o)?Promise.resolve(n.transform(o.value,a)).then(i=>({status:t.value,value:i})):y);w.assertNever(n)}}W.create=(r,e,t)=>new W({schema:r,typeName:v.ZodEffects,effect:e,...x(t)}),W.createWithPreprocess=(r,e,t)=>new W({schema:e,effect:{type:"preprocess",transform:r},typeName:v.ZodEffects,...x(t)});class V extends k{_parse(e){return this._getType(e)===h.undefined?A(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}V.create=(r,e)=>new V({innerType:r,typeName:v.ZodOptional,...x(e)});class F extends k{_parse(e){return this._getType(e)===h.null?A(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}F.create=(r,e)=>new F({innerType:r,typeName:v.ZodNullable,...x(e)});class ce extends k{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===h.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ce.create=(r,e)=>new ce({innerType:r,typeName:v.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...x(e)});class de extends k{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return re(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new z(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new z(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}de.create=(r,e)=>new de({innerType:r,typeName:v.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...x(e)});class Je extends k{_parse(e){if(this._getType(e)!==h.nan){const s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:h.nan,received:s.parsedType}),y}return{status:"valid",value:e.data}}}Je.create=r=>new Je({typeName:v.ZodNaN,...x(r)});class He extends k{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ze extends k{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return a.status==="aborted"?y:a.status==="dirty"?(t.dirty(),K(a.value)):this._def.out._parseAsync({data:a.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?y:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new Ze({in:e,out:t,typeName:v.ZodPipeline})}}class ue extends k{_parse(e){const t=this._def.innerType._parse(e),s=n=>(G(n)&&(n.value=Object.freeze(n.value)),n);return re(t)?t.then(n=>s(n)):s(t)}unwrap(){return this._def.innerType}}ue.create=(r,e)=>new ue({innerType:r,typeName:v.ZodReadonly,...x(e)});var v;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(v||(v={}));const p=q.create,I=Q.create,j=Se.create,le=Ce.create;B.create;const T=L.create,_=S.create,R=ne.create,Ut=Ee.create;ae.create,J.create;const Ge=xe.create,b=ie.create,Y=H.create;oe.create;const f=V.create;F.create;const he="2.0",Xe=R([p(),I().int()]),Ye=p(),Wt=_({progressToken:f(Xe)}).passthrough(),E=_({_meta:f(Wt)}).passthrough(),N=_({method:p(),params:f(E)}),ee=_({_meta:f(_({}).passthrough())}).passthrough(),P=_({method:p(),params:f(ee)}),Z=_({_meta:f(_({}).passthrough())}).passthrough(),fe=R([p(),I().int()]),Ft=_({jsonrpc:b(he),id:fe}).merge(N).strict(),Jt=_({jsonrpc:b(he)}).merge(P).strict(),Ht=_({jsonrpc:b(he),id:fe,result:Z}).strict();var Qe;(function(r){r[r.ConnectionClosed=-32e3]="ConnectionClosed",r[r.RequestTimeout=-32001]="RequestTimeout",r[r.ParseError=-32700]="ParseError",r[r.InvalidRequest=-32600]="InvalidRequest",r[r.MethodNotFound=-32601]="MethodNotFound",r[r.InvalidParams=-32602]="InvalidParams",r[r.InternalError=-32603]="InternalError"})(Qe||(Qe={}));const Gt=_({jsonrpc:b(he),id:fe,error:_({code:I().int(),message:p(),data:f(le())})}).strict(),Xt=R([Ft,Jt,Ht,Gt]),Ke=Z.strict(),et=P.extend({method:b("notifications/cancelled"),params:ee.extend({requestId:fe,reason:p().optional()})}),tt=_({name:p(),version:p()}).passthrough(),Yt=_({experimental:f(_({}).passthrough()),sampling:f(_({}).passthrough()),roots:f(_({listChanged:f(j())}).passthrough())}).passthrough(),Qt=N.extend({method:b("initialize"),params:E.extend({protocolVersion:p(),capabilities:Yt,clientInfo:tt})}),Kt=_({experimental:f(_({}).passthrough()),logging:f(_({}).passthrough()),completions:f(_({}).passthrough()),prompts:f(_({listChanged:f(j())}).passthrough()),resources:f(_({subscribe:f(j()),listChanged:f(j())}).passthrough()),tools:f(_({listChanged:f(j())}).passthrough())}).passthrough(),es=Z.extend({protocolVersion:p(),capabilities:Kt,serverInfo:tt,instructions:f(p())}),ts=P.extend({method:b("notifications/initialized")}),st=N.extend({method:b("ping")}),ss=_({progress:I(),total:f(I()),message:f(p())}).passthrough(),rt=P.extend({method:b("notifications/progress"),params:ee.merge(ss).extend({progressToken:Xe})}),me=N.extend({params:E.extend({cursor:f(Ye)}).optional()}),pe=Z.extend({nextCursor:f(Ye)}),nt=_({uri:p(),mimeType:f(p())}).passthrough(),at=nt.extend({text:p()}),it=nt.extend({blob:p().base64()}),rs=_({uri:p(),name:p(),description:f(p()),mimeType:f(p())}).passthrough(),ns=_({uriTemplate:p(),name:p(),description:f(p()),mimeType:f(p())}).passthrough(),as=me.extend({method:b("resources/list")}),is=pe.extend({resources:T(rs)}),os=me.extend({method:b("resources/templates/list")}),cs=pe.extend({resourceTemplates:T(ns)}),ds=N.extend({method:b("resources/read"),params:E.extend({uri:p()})}),us=Z.extend({contents:T(R([at,it]))}),ls=P.extend({method:b("notifications/resources/list_changed")}),hs=N.extend({method:b("resources/subscribe"),params:E.extend({uri:p()})}),fs=N.extend({method:b("resources/unsubscribe"),params:E.extend({uri:p()})}),ms=P.extend({method:b("notifications/resources/updated"),params:ee.extend({uri:p()})}),ps=_({name:p(),description:f(p()),required:f(j())}).passthrough(),gs=_({name:p(),description:f(p()),arguments:f(T(ps))}).passthrough(),_s=me.extend({method:b("prompts/list")}),ys=pe.extend({prompts:T(gs)}),vs=N.extend({method:b("prompts/get"),params:E.extend({name:p(),arguments:f(Ge(p()))})}),ge=_({type:b("text"),text:p()}).passthrough(),_e=_({type:b("image"),data:p().base64(),mimeType:p()}).passthrough(),ye=_({type:b("audio"),data:p().base64(),mimeType:p()}).passthrough(),ot=_({type:b("resource"),resource:R([at,it])}).passthrough(),xs=_({role:Y(["user","assistant"]),content:R([ge,_e,ye,ot])}).passthrough(),ks=Z.extend({description:f(p()),messages:T(xs)}),bs=P.extend({method:b("notifications/prompts/list_changed")}),ws=_({title:f(p()),readOnlyHint:f(j()),destructiveHint:f(j()),idempotentHint:f(j()),openWorldHint:f(j())}).passthrough(),Ss=_({name:p(),description:f(p()),inputSchema:_({type:b("object"),properties:f(_({}).passthrough()),required:f(T(p()))}).passthrough(),outputSchema:f(_({type:b("object"),properties:f(_({}).passthrough()),required:f(T(p()))}).passthrough()),annotations:f(ws)}).passthrough(),Ts=me.extend({method:b("tools/list")}),Rs=pe.extend({tools:T(Ss)}),ct=Z.extend({content:T(R([ge,_e,ye,ot])).default([]),structuredContent:_({}).passthrough().optional(),isError:f(j())});ct.or(Z.extend({toolResult:le()}));const Cs=N.extend({method:b("tools/call"),params:E.extend({name:p(),arguments:f(Ge(le()))})}),Ns=P.extend({method:b("notifications/tools/list_changed")}),dt=Y(["debug","info","notice","warning","error","critical","alert","emergency"]),Os=N.extend({method:b("logging/setLevel"),params:E.extend({level:dt})}),As=P.extend({method:b("notifications/message"),params:ee.extend({level:dt,logger:f(p()),data:le()})}),js=_({name:p().optional()}).passthrough(),Is=_({hints:f(T(js)),costPriority:f(I().min(0).max(1)),speedPriority:f(I().min(0).max(1)),intelligencePriority:f(I().min(0).max(1))}).passthrough(),Es=_({role:Y(["user","assistant"]),content:R([ge,_e,ye])}).passthrough(),Zs=N.extend({method:b("sampling/createMessage"),params:E.extend({messages:T(Es),systemPrompt:f(p()),includeContext:f(Y(["none","thisServer","allServers"])),temperature:f(I()),maxTokens:I().int(),stopSequences:f(T(p())),metadata:f(_({}).passthrough()),modelPreferences:f(Is)})}),Ms=Z.extend({model:p(),stopReason:f(Y(["endTurn","stopSequence","maxTokens"]).or(p())),role:Y(["user","assistant"]),content:Ut("type",[ge,_e,ye])}),Ps=_({type:b("ref/resource"),uri:p()}).passthrough(),Ls=_({type:b("ref/prompt"),name:p()}).passthrough(),$s=N.extend({method:b("completion/complete"),params:E.extend({ref:R([Ls,Ps]),argument:_({name:p(),value:p()}).passthrough()})}),Vs=Z.extend({completion:_({values:T(p()).max(100),total:f(I().int()),hasMore:f(j())}).passthrough()}),zs=_({uri:p().startsWith("file://"),name:f(p())}).passthrough(),qs=N.extend({method:b("roots/list")}),Ds=Z.extend({roots:T(zs)}),Bs=P.extend({method:b("notifications/roots/list_changed")});R([st,Qt,$s,Os,vs,_s,as,os,ds,hs,fs,Cs,Ts]),R([et,rt,ts,Bs]),R([Ke,Ms,Ds]),R([st,Zs,qs]),R([et,rt,As,ms,ls,Ns,bs]),R([Ke,es,Vs,ks,ys,is,cs,us,ct,Rs]),new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");var je;(function(r){r.Completable="McpCompletable"})(je||(je={}));class ut extends k{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}ut.create=(r,e)=>new ut({type:r,typeName:je.Completable,complete:e.complete,...Us(e)});function Us(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(o,i)=>{var d,l;const{message:g}=r;return o.code==="invalid_enum_value"?{message:g??i.defaultError}:typeof i.data>"u"?{message:(d=g??s)!==null&&d!==void 0?d:i.defaultError}:o.code!=="invalid_type"?{message:i.defaultError}:{message:(l=g??t)!==null&&l!==void 0?l:i.defaultError}},description:n}}const lt=1e6,Ie=1e6,ht=1e4,Ws=1e6;class U{static isTemplate(e){return/\{[^}\s]+\}/.test(e)}static validateLength(e,t,s){if(e.length>t)throw new Error(`${s} exceeds maximum length of ${t} characters (got ${e.length})`)}get variableNames(){return this.parts.flatMap(e=>typeof e=="string"?[]:e.names)}constructor(e){U.validateLength(e,lt,"Template"),this.template=e,this.parts=this.parse(e)}toString(){return this.template}parse(e){const t=[];let s="",n=0,a=0;for(;n<e.length;)if(e[n]==="{"){s&&(t.push(s),s="");const o=e.indexOf("}",n);if(o===-1)throw new Error("Unclosed template expression");if(a++,a>ht)throw new Error(`Template contains too many expressions (max ${ht})`);const i=e.slice(n+1,o),d=this.getOperator(i),l=i.includes("*"),g=this.getNames(i),O=g[0];for(const ke of g)U.validateLength(ke,Ie,"Variable name");t.push({name:O,operator:d,names:g,exploded:l}),n=o+1}else s+=e[n],n++;return s&&t.push(s),t}getOperator(e){return["+","#",".","/","?","&"].find(s=>e.startsWith(s))||""}getNames(e){const t=this.getOperator(e);return e.slice(t.length).split(",").map(s=>s.replace("*","").trim()).filter(s=>s.length>0)}encodeValue(e,t){return U.validateLength(e,Ie,"Variable value"),t==="+"||t==="#"?encodeURI(e):encodeURIComponent(e)}expandPart(e,t){if(e.operator==="?"||e.operator==="&"){const o=e.names.map(d=>{const l=t[d];if(l===void 0)return"";const g=Array.isArray(l)?l.map(O=>this.encodeValue(O,e.operator)).join(","):this.encodeValue(l.toString(),e.operator);return`${d}=${g}`}).filter(d=>d.length>0);return o.length===0?"":(e.operator==="?"?"?":"&")+o.join("&")}if(e.names.length>1){const o=e.names.map(i=>t[i]).filter(i=>i!==void 0);return o.length===0?"":o.map(i=>Array.isArray(i)?i[0]:i).join(",")}const s=t[e.name];if(s===void 0)return"";const a=(Array.isArray(s)?s:[s]).map(o=>this.encodeValue(o,e.operator));switch(e.operator){case"":return a.join(",");case"+":return a.join(",");case"#":return"#"+a.join(",");case".":return"."+a.join(".");case"/":return"/"+a.join("/");default:return a.join(",")}}expand(e){let t="",s=!1;for(const n of this.parts){if(typeof n=="string"){t+=n;continue}const a=this.expandPart(n,e);a&&((n.operator==="?"||n.operator==="&")&&s?t+=a.replace("?","&"):t+=a,(n.operator==="?"||n.operator==="&")&&(s=!0))}return t}escapeRegExp(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}partToRegExp(e){const t=[];for(const a of e.names)U.validateLength(a,Ie,"Variable name");if(e.operator==="?"||e.operator==="&"){for(let a=0;a<e.names.length;a++){const o=e.names[a],i=a===0?"\\"+e.operator:"&";t.push({pattern:i+this.escapeRegExp(o)+"=([^&]+)",name:o})}return t}let s;const n=e.name;switch(e.operator){case"":s=e.exploded?"([^/]+(?:,[^/]+)*)":"([^/,]+)";break;case"+":case"#":s="(.+)";break;case".":s="\\.([^/,]+)";break;case"/":s="/"+(e.exploded?"([^/]+(?:,[^/]+)*)":"([^/,]+)");break;default:s="([^/]+)"}return t.push({pattern:s,name:n}),t}match(e){U.validateLength(e,lt,"URI");let t="^";const s=[];for(const i of this.parts)if(typeof i=="string")t+=this.escapeRegExp(i);else{const d=this.partToRegExp(i);for(const{pattern:l,name:g}of d)t+=l,s.push({name:g,exploded:i.exploded})}t+="$",U.validateLength(t,Ws,"Generated regex pattern");const n=new RegExp(t),a=e.match(n);if(!a)return null;const o={};for(let i=0;i<s.length;i++){const{name:d,exploded:l}=s[i],g=a[i+1],O=d.replace("*","");l&&g.includes(",")?o[O]=g.split(","):o[O]=g}return o}}class Fs{constructor(e,t){this._callbacks=t,this._uriTemplate=typeof e=="string"?new U(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){var t;return(t=this._callbacks.complete)===null||t===void 0?void 0:t[e]}}class Js{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;const e=this._buffer.indexOf(`
3
+ `);if(e===-1)return null;const t=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),Hs(t)}clear(){this._buffer=void 0}}function Hs(r){return Xt.parse(JSON.parse(r))}function Gs(r){return JSON.stringify(r)+`
4
+ `}class Xs{constructor(e=Me.stdin,t=Me.stdout){this._stdin=e,this._stdout=t,this._readBuffer=new Js,this._started=!1,this._ondata=s=>{this._readBuffer.append(s),this.processReadBuffer()},this._onerror=s=>{var n;(n=this.onerror)===null||n===void 0||n.call(this,s)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(var e,t;;)try{const s=this._readBuffer.readMessage();if(s===null)break;(e=this.onmessage)===null||e===void 0||e.call(this,s)}catch(s){(t=this.onerror)===null||t===void 0||t.call(this,s)}}async close(){var e;this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),(e=this.onclose)===null||e===void 0||e.call(this)}send(e){return new Promise(t=>{const s=Gs(e);this._stdout.write(s)?t():this._stdout.once("drain",t)})}}const ft=pt(process.env.LIKEC4_WORKSPACE||".");async function Ys(){console.error(`Loading LikeC4 from workspace ${ft}`);const r=await mt.fromWorkspace(ft,{logger:!1}),e=r.langium.mcp.Tools,t=r.langium.mcp.ServerFactory.create({capabilities:{completions:{},tools:{},resources:{}}});t.resource("likec4 element",new Fs("likec4://projects/{project}/elements/{id}",{list:async()=>{const n=await r.languageServices.projects(),a=[];for(const{id:o}of n){const i=r.computedModel(o);for(const d of i.elements())a.push({uri:`likec4://projects/${o}/elements/${d.id}`,name:d.title,id:d.id,description:`Model element of kind "${d.kind}"`})}return{resources:a}},complete:{project:async n=>{const a=await r.projects(),o=n.toLowerCase();return a.filter(i=>i.toLowerCase().startsWith(o))},id:async n=>{const{id:a}=r.languageServices.projects()[0],o=r.computedModel(a);return[...yt(o.elements(),i=>i.id.startsWith(n))].map(i=>i.id)}}}),async(n,{project:a,id:o})=>{const i=await e.readElement({id:o,project:a});return{contents:[{uri:n.href,mimeType:"application/json",text:i}]}}),t.server.oninitialized=()=>{t.server.sendLoggingMessage({level:"info",data:{message:"Server initialized",workspace:r.workspace}})};const s=new Xs;console.error("Connecting server to transport..."),await t.connect(s),console.error("LikeC4 MCP Server running on stdio")}Ys().catch(r=>{console.error(r),process.exit(1)});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@likec4/mcp",
3
3
  "license": "MIT",
4
- "version": "1.32.0",
4
+ "version": "1.32.2",
5
5
  "bugs": "https://github.com/likec4/likec4/issues",
6
6
  "homepage": "https://likec4.dev",
7
7
  "author": "Denis Davydkov <denis@davydkov.com>",
@@ -47,25 +47,26 @@
47
47
  }
48
48
  },
49
49
  "dependencies": {
50
- "likec4": "1.32.0"
50
+ "likec4": "1.32.2"
51
51
  },
52
52
  "devDependencies": {
53
- "@modelcontextprotocol/sdk": "^1.10.2",
54
- "@types/node": "^20.19.0",
53
+ "@modelcontextprotocol/sdk": "^1.12.1",
54
+ "@types/node": "~20.19.0",
55
55
  "remeda": "^2.23.0",
56
- "tsx": "~4.19.4",
57
- "turbo": "^2.5.4",
58
- "typescript": "^5.8.3",
59
- "unbuild": "^3.5.0",
60
- "vitest": "^3.2.3",
61
- "zod": "^3.24.3",
62
- "wireit": "^0.14.12",
63
- "@likec4/core": "1.32.0",
64
- "@likec4/tsconfig": "1.32.0"
56
+ "tsx": "4.19.4",
57
+ "turbo": "2.5.4",
58
+ "typescript": "5.8.3",
59
+ "unbuild": "3.5.0",
60
+ "vitest": "3.2.3",
61
+ "zod": "^3.25.64",
62
+ "wireit": "0.14.12",
63
+ "@likec4/core": "1.32.2",
64
+ "@likec4/tsconfig": "1.32.2"
65
65
  },
66
66
  "scripts": {
67
67
  "typecheck": "tsc -b --verbose",
68
68
  "build": "wireit",
69
- "inspector": "wireit"
69
+ "inspector": "wireit",
70
+ "clean": "pnpm rimraf dist lib"
70
71
  }
71
72
  }