@likec4/mcp 1.29.0

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.
@@ -0,0 +1,24 @@
1
+
2
+ > @likec4/mcp@1.29.0 build /home/runner/work/likec4/likec4/packages/mcp
3
+ > wireit
4
+
5
+ Analyzing
6
+ 0% [0 / 1] [1 running] build
7
+ [info] Automatically detected entries: src/index [esm]
8
+ [info] Building mcp
9
+ [info] Cleaning dist directory: `./dist`
10
+ ../../node_modules/.pnpm/@mantine+colors-generator@7.17.4_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@7.17.4_chroma-js@3.1.2/node_modules/@mantine/colors-generator/esm/generate-colors.mjs" was ignored.
11
+ [success] Build succeeded for mcp
12
+ [log] dist/index.mjs (total size: 75.4 kB, chunk size: 75.4 kB)
13
+ 📦 ../../node_modules/.pnpm/zod@3.24.2/node_modules/zod/lib/index.mjs (155 kB)
14
+ 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.9.0/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js (32.2 kB)
15
+ 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.9.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/uriTemplate.js (8.73 kB)
16
+ 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.9.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js (2.75 kB)
17
+ 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.9.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js (2.02 kB)
18
+ 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.9.0/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js (916 B)
19
+ 📦 ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.9.0/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js (821 B)
20
+ 📦 ../../node_modules/.pnpm/zod-to-json-schema@3.24.5_zod@3.24.2/node_modules/zod-to-json-schema/dist/esm/parsers/string.js (72 B)
21
+ 📦 ../../node_modules/.pnpm/remeda@2.21.2/node_modules/remeda/dist/chunk-ENOHV5LT.js (42 B)
22
+ Σ Total dist size (byte size): 75.4 kB
23
+ [log]
24
+ ✅ Ran 1 script and skipped 0 in 3s.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-2025 Denis Davydkov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # `@likec4/mcp`
2
+
3
+ ## Usage
4
+
5
+ ```json
6
+ {
7
+ "mcpServers": {
8
+ "likec4": {
9
+ "command": "npx",
10
+ "args": [
11
+ "-y",
12
+ "@likec4/mcp"
13
+ ],
14
+ "env": {
15
+ "LIKEC4_WORKSPACE": "${workspaceFolder}"
16
+ }
17
+ }
18
+ }
19
+ }
20
+ ```
@@ -0,0 +1,17 @@
1
+ import { defineBuildConfig } from 'unbuild'
2
+
3
+ export default defineBuildConfig({
4
+ clean: true,
5
+ stub: false,
6
+ declaration: false,
7
+ rollup: {
8
+ esbuild: {
9
+ minify: true,
10
+ },
11
+ emitCJS: false,
12
+ inlineDependencies: true,
13
+ resolve: {
14
+ exportConditions: ['sources'],
15
+ },
16
+ },
17
+ })
package/dist/index.mjs ADDED
@@ -0,0 +1,4 @@
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,e){if(!s)throw new Error("Invariant failed")}function wt(s){return typeof s=="function"}function St(s,e){const t=e??s;kt(wt(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)});
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@likec4/mcp",
3
+ "license": "MIT",
4
+ "version": "1.29.0",
5
+ "bugs": "https://github.com/likec4/likec4/issues",
6
+ "homepage": "https://likec4.dev",
7
+ "author": "Denis Davydkov <denis@davydkov.com>",
8
+ "type": "module",
9
+ "bin": {
10
+ "likec4-mcp-server": "dist/index.mjs"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/likec4/likec4.git",
15
+ "directory": "packages/mcp"
16
+ },
17
+ "publishConfig": {
18
+ "registry": "https://registry.npmjs.org",
19
+ "access": "public"
20
+ },
21
+ "keywords": [
22
+ "likec4",
23
+ "mcp",
24
+ "model context protocol",
25
+ "server"
26
+ ],
27
+ "wireit": {
28
+ "build": {
29
+ "command": "unbuild",
30
+ "files": [
31
+ "src/**/*"
32
+ ]
33
+ },
34
+ "inspector": {
35
+ "dependencies": [
36
+ "build"
37
+ ],
38
+ "command": "pnpx @modelcontextprotocol/inspector node dist/index.mjs",
39
+ "env": {
40
+ "LIKEC4_WORKSPACE": "../../examples/"
41
+ },
42
+ "service": {
43
+ "readyWhen": {
44
+ "lineMatches": "MCP Inspector is up"
45
+ }
46
+ }
47
+ }
48
+ },
49
+ "dependencies": {
50
+ "likec4": "1.29.0"
51
+ },
52
+ "devDependencies": {
53
+ "@modelcontextprotocol/sdk": "^1.9.0",
54
+ "@types/node": "^20.17.30",
55
+ "remeda": "^2.21.2",
56
+ "tsx": "~4.19.3",
57
+ "turbo": "^2.5.0",
58
+ "typescript": "^5.8.3",
59
+ "unbuild": "^3.5.0",
60
+ "vitest": "^3.1.1",
61
+ "zod": "^3.24.2",
62
+ "wireit": "^0.14.12",
63
+ "@likec4/core": "1.29.0",
64
+ "@likec4/tsconfig": "1.29.0"
65
+ },
66
+ "scripts": {
67
+ "typecheck": "tsc --noEmit",
68
+ "build": "wireit",
69
+ "inspector": "wireit"
70
+ }
71
+ }
package/src/index.ts ADDED
@@ -0,0 +1,98 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {
4
+ type ProjectId,
5
+ ifilter,
6
+ } from '@likec4/core'
7
+ import { ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js'
8
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js'
9
+ import type { Resource } from '@modelcontextprotocol/sdk/types.js'
10
+ import { LikeC4 } from 'likec4'
11
+ import { resolve } from 'node:path'
12
+
13
+ const LIKEC4_WORKSPACE = resolve(process.env['LIKEC4_WORKSPACE'] || '.')
14
+
15
+ async function main() {
16
+ console.error(`Loading LikeC4 from workspace ${LIKEC4_WORKSPACE}`)
17
+ const likec4 = await LikeC4.fromWorkspace(LIKEC4_WORKSPACE, {
18
+ logger: false,
19
+ })
20
+
21
+ const mcpTools = likec4.langium.mcp.Tools
22
+ const mcp = likec4.langium.mcp.ServerFactory.create({
23
+ capabilities: {
24
+ completions: {},
25
+ tools: {},
26
+ resources: {},
27
+ },
28
+ })
29
+
30
+ mcp.resource(
31
+ 'likec4 element',
32
+ new ResourceTemplate('likec4://projects/{project}/elements/{id}', {
33
+ list: async () => {
34
+ const projects = await likec4.languageServices.projects()
35
+ const resources: Resource[] = []
36
+ for (const { id } of projects) {
37
+ const model = likec4.computedModel(id)
38
+ for (const el of model.elements()) {
39
+ resources.push({
40
+ uri: `likec4://projects/${id}/elements/${el.id}`,
41
+ name: el.title,
42
+ id: el.id,
43
+ description: `Model element of kind "${el.kind}"`,
44
+ })
45
+ }
46
+ }
47
+ return ({
48
+ resources,
49
+ })
50
+ },
51
+ complete: {
52
+ project: async (name) => {
53
+ const projects = await likec4.projects()
54
+ const newLocal = name.toLowerCase()
55
+ return projects.filter(id => id.toLowerCase().startsWith(newLocal))
56
+ },
57
+ id: async (name) => {
58
+ const { id } = likec4.languageServices.projects()[0]
59
+ const model = likec4.computedModel(id)
60
+ return [...ifilter(model.elements(), el => el.id.startsWith(name))].map(i => i.id)
61
+ },
62
+ },
63
+ }),
64
+ async (uri, { project, id }) => {
65
+ const text = await mcpTools.readElement({
66
+ id: id as string,
67
+ project: project as ProjectId,
68
+ })
69
+ return {
70
+ contents: [{
71
+ uri: uri.href,
72
+ mimeType: 'application/json',
73
+ text,
74
+ }],
75
+ }
76
+ },
77
+ )
78
+
79
+ mcp.server.oninitialized = () => {
80
+ mcp.server.sendLoggingMessage({
81
+ level: 'info',
82
+ data: {
83
+ message: 'Server initialized',
84
+ workspace: likec4.workspace,
85
+ },
86
+ })
87
+ }
88
+
89
+ const transport = new StdioServerTransport()
90
+ console.error('Connecting server to transport...')
91
+ await mcp.connect(transport)
92
+ console.error('LikeC4 MCP Server running on stdio')
93
+ }
94
+
95
+ main().catch(err => {
96
+ console.error(err)
97
+ process.exit(1)
98
+ })
package/tsconfig.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "@likec4/tsconfig/base.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "types": [
6
+ "node"
7
+ ]
8
+ },
9
+ "include": [
10
+ "src"
11
+ ],
12
+ }
package/turbo.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://turbo.build/schema.json",
3
+ "extends": [
4
+ "//"
5
+ ],
6
+ "tasks": {
7
+ "build": {
8
+ "dependsOn": [
9
+ "^generate",
10
+ "^build"
11
+ ],
12
+ "outputs": [
13
+ "dist/**"
14
+ ],
15
+ "outputLogs": "new-only"
16
+ }
17
+ }
18
+ }