likec4 1.59.4 → 1.60.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.
- package/__app__/codegen/react.mjs +6 -6
- package/__app__/codegen/webcomponent.mjs +147 -69
- package/__app__/src/aichat/index.mjs +10 -5
- package/__app__/src/chunks/AIChat.mjs +1134 -693
- package/__app__/src/chunks/LikeC4Styles.mjs +3995 -1779
- package/__app__/src/chunks/ProjectsOverview.mjs +624 -334
- package/__app__/src/chunks/es.mjs +515 -335
- package/__app__/src/chunks/hooks.mjs +578 -369
- package/__app__/src/chunks/libs/@floating-ui.mjs +2720 -1966
- package/__app__/src/chunks/libs/@mantine.mjs +13920 -10057
- package/__app__/src/chunks/libs/@tanstack-ai.mjs +2266 -1146
- package/__app__/src/chunks/libs/@tanstack.mjs +3152 -1926
- package/__app__/src/chunks/libs/@xstate/react.mjs +2924 -1468
- package/__app__/src/chunks/libs/@xyflow/react.mjs +6627 -4067
- package/__app__/src/chunks/libs/bezier-js.mjs +1312 -726
- package/__app__/src/chunks/libs/d3.mjs +3219 -1505
- package/__app__/src/chunks/libs/fast-equals.mjs +434 -210
- package/__app__/src/chunks/libs/framer.mjs +9251 -3846
- package/__app__/src/chunks/libs/nanostores.mjs +174 -0
- package/__app__/src/chunks/libs/zod.mjs +4591 -2363
- package/__app__/src/chunks/rolldown-runtime.mjs +39 -23
- package/__app__/src/chunks/styled-system.mjs +2279 -1951
- package/__app__/src/fonts.css +112 -1
- package/__app__/src/main.mjs +40817 -21840
- package/__app__/src/style.css +18488 -1
- package/config/schema.json +122 -97
- package/dist/app/render-view-client.css +1 -1
- package/dist/app/render-view-client.js +508 -334
- package/dist/chunks/enableServer.mjs +1 -1
- package/dist/chunks/filenames.mjs +11 -9
- package/dist/chunks/generate-likec4.mjs +5 -0
- package/dist/chunks/index.d.mts +243 -183
- package/dist/chunks/index2.d.mts +2865 -1977
- package/dist/chunks/libs/@chevrotain/gast.mjs +27 -1
- package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +81 -9
- package/dist/chunks/libs/@chevrotain/types.d.mts +4 -1
- package/dist/chunks/libs/@logtape/logtape.mjs +5 -4
- package/dist/chunks/libs/@lume/kiwi.mjs +1 -1
- package/dist/chunks/libs/@ts-graphviz/core.mjs +1 -1
- package/dist/chunks/libs/birpc.mjs +1 -1
- package/dist/chunks/libs/chevrotain-allstar.mjs +2 -2
- package/dist/chunks/libs/chevrotain.mjs +87 -35
- package/dist/chunks/libs/eventemitter3.mjs +1 -1
- package/dist/chunks/libs/json5.mjs +4 -4
- package/dist/chunks/libs/langium.d.mts +9038 -6193
- package/dist/chunks/libs/langium.mjs +16 -24
- package/dist/chunks/libs/merge-error-cause.mjs +1 -1
- package/dist/chunks/libs/p-limit.mjs +1 -0
- package/dist/chunks/libs/p-queue.mjs +1 -1
- package/dist/chunks/libs/package-manager-detector.mjs +1 -1
- package/dist/chunks/libs/pako.mjs +1 -1
- package/dist/chunks/libs/pretty-ms.mjs +1 -1
- package/dist/chunks/libs/remeda.mjs +1 -1
- package/dist/chunks/libs/ufo.mjs +1 -1
- package/dist/chunks/libs/unstorage.mjs +1 -1
- package/dist/chunks/libs/which.mjs +1 -1
- package/dist/chunks/node.mjs +59 -58
- package/dist/chunks/rolldown-runtime.mjs +1 -1
- package/dist/chunks/sequence-view.mjs +1 -1
- package/dist/chunks/vite-plugin.mjs +45 -45
- package/dist/cli/index.mjs +207 -1315
- package/dist/config/index.d.mts +2 -2
- package/dist/generators/likec4.d.mts +6578 -0
- package/dist/generators/likec4.mjs +1 -0
- package/dist/model/index.d.mts +4 -1
- package/dist/vite-plugin/index.d.mts +4 -1
- package/dist/vite-plugin/index.mjs +1 -1
- package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +9 -0
- package/dist/vite-plugin/internal/index.d.mts +6 -5
- package/dist/vite-plugin/internal/index.mjs +83 -30
- package/generators/likec4/package.json +4 -0
- package/package.json +113 -106
- package/react/index.d.mts +8500 -26659
- package/react/index.mjs +534 -63936
- package/react/rolldown-runtime-DnkiqaRY.js +1 -0
- package/skills/likec4-dsl/SKILL.md +428 -0
- package/skills/likec4-dsl/evals/evals-public.json +202 -0
- package/skills/likec4-dsl/evals/grading-spec.json +589 -0
- package/skills/likec4-dsl/references/bridge-leanix-drawio.md +42 -0
- package/skills/likec4-dsl/references/cli.md +139 -0
- package/skills/likec4-dsl/references/configuration.md +266 -0
- package/skills/likec4-dsl/references/deployment.md +160 -0
- package/skills/likec4-dsl/references/dynamic-views.md +455 -0
- package/skills/likec4-dsl/references/examples.md +370 -0
- package/skills/likec4-dsl/references/identifier-validity.md +90 -0
- package/skills/likec4-dsl/references/include-predicates-wildcards.md +179 -0
- package/skills/likec4-dsl/references/model.md +151 -0
- package/skills/likec4-dsl/references/predicates.md +123 -0
- package/skills/likec4-dsl/references/relationships-bidirectional.md +176 -0
- package/skills/likec4-dsl/references/specification.md +75 -0
- package/skills/likec4-dsl/references/style-tokens-colors.md +150 -0
- package/skills/likec4-dsl/references/troubleshooting.md +96 -0
- package/skills/likec4-dsl/references/views.md +329 -0
- package/dist/chunks/libs/picomatch.mjs +0 -1
- package/dist/chunks/libs/zod.d.mts +0 -3840
- package/dist/chunks/libs/zod.mjs +0 -65
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime.mjs";import{
|
|
1
|
+
import"./rolldown-runtime.mjs";import{u as e}from"./vite-plugin.mjs";import{ElementShapes as t}from"@likec4/core/styles";import{invariant as n}from"@likec4/core";import{z as r}from"zod";import{Readable as i}from"node:stream";import{chat as a,convertMessagesToModelMessages as o,toServerSentEventsResponse as s,toolDefinition as c}from"@tanstack/ai";const l=r.object({id:r.string().meta({description:`Node ID`}),title:r.string(),shape:r.enum(t),color:r.string().meta({description:`Node color, from theme or custom`}),icon:r.string().nullish(),parentId:r.string().nullish().meta({description:`Parent node ID (if node is nested)`}),children:r.array(r.string()).nullish().meta({description:`Nested node IDs (if node is compound)`}),x:r.number(),y:r.number(),width:r.number(),height:r.number(),modelFqn:r.string().nullish().meta({description:`Model element FQN (if node has reference)`})}),u=c({name:`read_ui`,description:`Read current UI state. Use arguments to include additional data.`,needsApproval:!1,inputSchema:r.object({selectedNode:r.boolean().default(!1).meta({description:`Include selected node (if any)`}),nodes:r.boolean().default(!1).meta({description:`Include all nodes from the view`})}),outputSchema:r.object({projectId:r.string(),editMode:r.boolean().meta({description:`Whether the UI is in edit mode`}),view:r.object({id:r.string(),title:r.string(),type:r.enum([`element`,`deployment`,`dynamic`]).meta({description:`Type of the current view`})}).meta({description:`Current view`}),nodes:r.array(l).nullish(),selectedNode:l.nullish()})}),d=r.object({type:r.literal(`focus`),elementId:r.string().meta({description:`Element ID (FQN)`})}).meta({description:`Focus UI on an element by its FQN`}),f=r.object({type:r.literal(`fitview`)}).meta({description:`Zoom out to fit all elements in the viewport, and clear any selection/focus`}),p=c({name:`update_ui`,description:`Update UI state by executing a command.`,needsApproval:!1,inputSchema:r.object({command:r.discriminatedUnion(`type`,[d,f])}),outputSchema:r.object({})}),m=c({name:`navigate_to`,description:`Navigates UI to another view`,needsApproval:!1,inputSchema:r.object({viewId:r.string().meta({description:`View ID`})}),outputSchema:r.object({})});async function readJsonBody(t){let n=[];e.info(`Reading request`);for await(let e of t){let t=Buffer.from(e).toString();process.stdout.write(t),n.push(t)}return JSON.parse(n.join(``))}function enableAIServer(e){let{ai:t,server:r,logger:c}=e;n(t,`AI is not configured`),r.middlewares.use(`/__likec4_ai`,async(e,n,r)=>{if(e.method!==`POST`)r();else try{let r=await readJsonBody(i.toWeb(e)),l=o(r.messages??[]),d=a({...t,messages:l,debug:!0,conversationId:r.data.conversationId,systemPrompts:[`You are a helpful assistant that can answer questions about LikeC4 model and update UI.`],tools:[m,p,u]}),f=s(d);if(f.headers.forEach((e,t)=>{n.setHeader(t,e)}),n.writeHead(f.status,f.statusText),!f.body){n.end();return}i.fromWeb(f.body).on(`error`,e=>{c.error(`AI stream error`,{error:e}),n.writableEnded||n.end()}).pipe(n,{end:!0})}catch(e){c.error(`AI request failed`,{error:e}),n.headersSent?n.end():(n.writeHead(500,{"Content-Type":`application/json`}),n.end(JSON.stringify({error:e instanceof Error?e.message:String(e)})))}})}export{enableAIServer};
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
-
import"./rolldown-runtime.mjs";import{t as e}from"./libs/json5.mjs";import
|
|
1
|
+
import"./rolldown-runtime.mjs";import{t as e}from"./libs/json5.mjs";import t from"zod/v4";import{BorderStyles as n,ElementShapes as r,IconPositions as i,RelationshipArrowTypes as a,Sizes as o,ThemeColors as s,computeColorValues as c}from"@likec4/core/styles";import{exact as l}from"@likec4/core/types";const u=/^@[A-Za-z0-9_-]*$/,d=/^(?!\/|[A-Za-z]:[\\\/])(?!.*:\/\/).*$/,f=t.string().min(1,`Image alias key cannot be empty`).regex(u,`Image alias key must match /^@\\w+$/`),p=t.string().min(1,`Image alias value cannot be empty`).regex(d,`Image alias value must be a relative path (no leading slash or protocol)`),m=t.record(f,p).meta({id:`ImageAliases`,description:`Map of image alias prefixes to relative paths (keys must match /^@\\w+$/; values must be relative paths without protocol or leading slash).`}),h=t.string().min(1,`Include path cannot be empty`).regex(/^(?!\/|[A-Za-z]:[\\\/])(?!.*:\/\/).*$/,`Include path must be a relative path (no leading slash, drive letter, or protocol)`),g=t.strictObject({paths:t.array(h).meta({description:[`Additional relative directory paths to include LikeC4 source files from, searched recursively.`,`Paths are relative to the project folder (the folder containing this config file).`,`Example: ["../shared", "../common/specs"]`].join(`
|
|
2
2
|
`)}),maxDepth:t.number().int().min(1).max(20).default(3).meta({description:[`Maximum directory depth to scan when searching for .c4 files in include paths.`,`Prevents excessive scanning of deeply nested directories.`,`Default: 3`].join(`
|
|
3
3
|
`)}),fileThreshold:t.number().int().min(1).max(1e4).default(30).meta({description:[`Maximum number of files to load from include paths before warning.`,`Helps identify performance issues from accidentally including large directories.`,`Default: 30`].join(`
|
|
4
4
|
`)})}).meta({id:`include-config`,description:[`Configuration for including additional LikeC4 source files from other directories.`,`Example: { "paths": ["../shared", "../common/specs"], "maxDepth": 5, "fileThreshold": 50 }`].join(`
|
|
5
|
-
`)}),_=t.int().min(0,`Opacity must be between 0 and 100`).max(100,`Opacity must be between 0 and 100`).meta({id:`Opacity`,description:`Opacity 0-100%`}),v=t.enum(r).meta({id:`ElementShape`}),y=t.enum(n).meta({id:`BorderStyle`}),b=t.enum(o).meta({id:`ElementSize`}),x=t.enum(i).meta({id:`IconPosition`}),S=t.enum(a).meta({id:`ArrowType`}),C=t.enum([`dashed`,`solid`,`dotted`]).meta({id:`LineType`}),
|
|
6
|
-
(must be a valid color name from the theme)`}),opacity:_.optional().meta({description:`Default opacity for groups`}),border:y.optional().meta({description:`Default border for groups`})}).meta({id:`GroupDefaultStyleValues`}),
|
|
5
|
+
`)}),_=t.int().min(0,`Opacity must be between 0 and 100`).max(100,`Opacity must be between 0 and 100`).meta({id:`Opacity`,description:`Opacity 0-100%`}),v=t.enum(r).meta({id:`ElementShape`}),y=t.enum(n).meta({id:`BorderStyle`}),b=t.enum(o).meta({id:`ElementSize`}),x=t.enum(i).meta({id:`IconPosition`}),S=t.enum(a).meta({id:`ArrowType`}),C=t.enum([`dashed`,`solid`,`dotted`]).meta({id:`LineType`}),ee=t.enum([`spline`,`ortho`]).meta({id:`EdgeRouting`}),te=t.enum(s).meta({id:`ThemeColorName`}),w=t.custom().refine(e=>typeof e==`string`,`Custom color name must be a string`).transform(e=>e).meta({id:`CustomColorName`}),T=te.or(w).transform(e=>e).meta({id:`ColorName`}),E=t.string().min(1,`Color value cannot be empty`).meta({id:`ColorLiteral`}),D=t.strictObject({fill:E.meta({description:`Background color`}),stroke:E.meta({description:`Stroke color (border, paths above background)`}),hiContrast:E.meta({description:`High contrast text color (title)`}),loContrast:E.meta({description:`Low contrast text color (description)`})}).meta({id:`ElementColorValues`}).transform(e=>e),O=t.strictObject({line:E.meta({description:`Line color`}),label:E.meta({description:`Label text color`}),labelBg:E.optional().default(`rgba(0, 0, 0, 0.5)`).meta({description:`Label background color`})}).meta({id:`RelationshipColorValues`}).transform(e=>e),k=t.strictObject({elements:D.or(E.transform(e=>c(e).elements)).meta({description:`Exact color value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values`}),relationships:O.or(E.transform(e=>c(e).relationships)).meta({description:`Exact color value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values`})}).transform(e=>e).meta({id:`StrictThemeColorValues`,description:`Exact color value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color value`}).or(E.transform(e=>c(e))).transform(e=>e).meta({id:`ThemeColorValues`,description:`Exact value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values`}),A=t.partialRecord(T,k).transform(e=>e),j=t.strictObject({width:t.number().min(50),height:t.number().min(50)}).meta({id:`Dimensions`,description:`Defines dimensions for theme size`}),M=t.partialRecord(b,j),N=t.strictObject({colors:A.optional().meta({description:`Override theme colors`}),sizes:M.optional().meta({description:`Override theme sizes`})}).meta({id:`ThemeCustomization`,description:`Customize theme colors and sizes`}).transform(({colors:e,sizes:t})=>l({colors:e?l(e):void 0,sizes:t?l(t):void 0})),P=t.strictObject({color:T.optional().meta({description:`Default color for groups
|
|
6
|
+
(must be a valid color name from the theme)`}),opacity:_.optional().meta({description:`Default opacity for groups`}),border:y.optional().meta({description:`Default border for groups`})}).meta({id:`GroupDefaultStyleValues`}),F=t.strictObject({color:T.optional().meta({description:`Default color for relationships
|
|
7
7
|
(must be a valid color name from the theme)`}),line:C.optional().meta({description:`Default line style for relationships`}),arrow:S.optional().meta({description:`Default arrow style for relationships`})}).meta({id:`RelationshipDefaultStyleValues`,description:`Override default values for relationship style properties
|
|
8
|
-
These values will be used if such property is not defined`}),
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
These values will be used if such property is not defined`})
|
|
12
|
-
These values will be used if such property is not defined`}),
|
|
8
|
+
These values will be used if such property is not defined`}),I=t.strictObject({routing:ee.optional().meta({description:"Default edge routing: `spline` for curves or `ortho` for right-angle bends.\nA view can override this default with its `routing` property or `autoLayout` routing parameter."})}).meta({id:`ViewDefaultValues`,description:`Default view settings.
|
|
9
|
+
Explicit settings in a view override these defaults.`}),L=t.strictObject({color:T.optional().meta({description:`Default color for elements
|
|
10
|
+
(must be a valid color name from the theme)`}),opacity:_.optional().meta({description:`Default opacity (0-100%) for elements when displayed as a group (like a container)`}),border:y.optional().meta({description:`Default border style for elements when displayed as a group (like a container)`}),size:b.optional().meta({description:`Default size for elements`}),shape:v.optional().meta({description:`Default shape for elements`}),iconPosition:x.optional().meta({description:`Default icon position for elements`}),group:P.optional().meta({description:`Override default values for group style properties
|
|
11
|
+
These values will be used if such property is not defined`}),relationship:F.optional().meta({description:`Override default values for relationship style properties
|
|
12
|
+
These values will be used if such property is not defined`}),view:I.optional().meta({description:`Default view settings.
|
|
13
|
+
Explicit settings in a view override these defaults.`})}).meta({id:`DefaultStyleValues`}),R=t.union([t.string().min(1,`Custom CSS file path cannot be empty`),t.array(t.string().min(1,`Custom CSS file path cannot be empty`))]).meta({id:`CustomStylesheets`}),z=t.strictObject({theme:N.optional().meta({description:`Project theme customization`}),defaults:L.optional().meta({description:`Override default values for style properties
|
|
14
|
+
These values will be used if such property is not defined`}),customCss:R.optional().meta({description:`Custom CSS (or list of CSS files) to be included in the generated diagrams`})}).transform(({theme:e,defaults:t,customCss:n})=>l({defaults:normalizeDefaults(t),customCss:normalizeStylesheets(n),theme:e}));function normalizeDefaults(e){if(!e)return;let{relationship:t,group:n,view:r,...i}=e;return l({...i,relationship:t&&l(t),group:n&&l(n),view:r&&l(r)})}function normalizeStylesheets(e){if(!e)return;let t=(Array.isArray(e)?e:[e]).filter(Boolean);if(t.length!==0)return{paths:t,content:``}}const B=[`png`,`jpg`,`dot`,`d2`,`mmd`,`puml`,`drawio`],V=t.strictObject({outDir:t.string().default(`.likec4`).meta({description:[`Path to the directory where manual layouts will be stored,`,`relative to the folder containing the project config. `,``,`Defaults to '.likec4'.`].join(`
|
|
13
15
|
`)})}).meta({id:`ManualLayoutsConfig`,description:`Configuration for manual layouts`}),H=t.enum(B),U=t.enum([`global`,`view`]),W=t.strictObject({defaultScope:U.default(`view`)}),G=t.strictObject({exportFormats:t.array(H).refine(e=>new Set(e).size===e.length,{message:`Export formats cannot contain duplicates`}).default([...B]).meta({description:[`Webapp export formats enabled in the generated application.`,`Omit to enable all export formats. Use an empty array to disable webapp exports.`].join(`
|
|
14
16
|
`)}),relationshipsBrowser:W.optional()}).meta({id:`WebappConfig`,description:`Configuration for the generated web application`}),K=t.union([t.strictObject({redirect:t.literal(!0)}),t.strictObject({include:t.array(t.string().nonempty().refine(e=>e!==`#`,{message:`selector cannot be "#"`})).nonempty(`include list cannot be empty`)}),t.strictObject({exclude:t.array(t.string().nonempty().refine(e=>e!==`#`,{message:`selector cannot be "#"`})).nonempty(`exclude list cannot be empty`)})]).meta({id:`LandingPageConfig`,description:`Configure the landing page. Use redirect to go to the index view, or include/exclude to filter the view grid.`}),q=t.object({name:t.string().nonempty(`Project name cannot be empty`).refine(e=>e!=="default",{abort:!0,error:`Project name cannot be "default"`}).refine(e=>!e.includes(`.`)&&!e.includes(`@`)&&!e.includes(`#`),{abort:!0,error:`Project name cannot contain ".", "@" or "#", try to use A-z, 0-9, _ and -`}).meta({description:`Project name, must be unique in the workspace`}),extends:t.union([t.string().min(1,`Extend path cannot be empty`),t.array(t.string().min(1,`Extend path cannot be empty`)).min(1,`Extend list cannot be empty`)]).optional().meta({description:`Extend styles from other config files`}),title:t.string().nonempty(`Project title cannot be empty if specified`).optional().meta({description:`A human readable title for the project`}),contactPerson:t.string().nonempty(`Contact person cannot be empty if specified`).optional().meta({description:`A person who has been involved in creating or maintaining this project`}),metadata:t.record(t.string(),t.any()).optional().meta({description:`Arbitrary metadata as key-value pairs for custom project information`}),styles:z.optional().meta({description:`Project styles customization`}),imageAliases:m.optional(),include:g.optional(),exclude:t.array(t.string()).optional().meta({description:`List of file patterns to exclude from the project, default is ["**/node_modules/**"]`}),manualLayouts:V.optional(),inferTechnologyFromIcon:t.boolean().optional().meta({description:[`Automatically derive element technology from icon name when technology is not set explicitly.`,`Applies to aws:, azure:, gcp:, and tech: icons. Bootstrap icons are excluded.`,`Defaults to true.`].join(`
|
|
15
17
|
`)}),implicitViews:t.boolean().optional().meta({description:`Auto-generate scoped views for elements without explicit views. Defaults to false.`}),landingPage:K.optional(),webapp:G.optional()}).meta({id:`LikeC4ProjectConfig`,description:`LikeC4 Project Configuration`}),J=t.instanceof(Function),Y=t.record(t.string(),J),X=q.extend({generators:Y.optional()});function validateProjectConfig(e){let n=e.landingPage,r=null;if(n!=null){let e=K.safeParse(n);if(!e.success)throw Error(`Config validation failed:
|
|
16
18
|
`+t.prettifyError(e.error));r=e.data}let i=q.safeParse(e);if(!i.success)throw Error(`Config validation failed:
|
|
17
19
|
`+t.prettifyError(i.error));let a=i.data;r!==null&&(a={...a,landingPage:r});let o=e.generators;if(typeof o==`object`&&o&&!Array.isArray(o)){let e=Y.safeParse(o);if(!e.success)throw Error(`Config validation failed (generators):
|
|
18
|
-
`+t.prettifyError(e.error));return{...a,generators:e.data}}return a}function parseProjectConfigJSON(t){return validateProjectConfig(e.parse(t.trim()||`{}`))}const Z={parse:parseProjectConfigJSON,validate:validateProjectConfig,normalizeInclude:e=>{let t=g.safeParse(e);return t.success?t.data:{paths:[],maxDepth:3,fileThreshold:30}}};function trimTrailingSlashes(e){let t=e.length;for(;t>0&&(e[t-1]===`/`||e[t-1]===`\\`);)t--;return e.slice(0,t)}function splitPath(e){return e.split(`/`).flatMap(e=>e.split(`\\`))}function basename(e){let t=trimTrailingSlashes(e),n=splitPath(t);return n[n.length-1]||t}const Q=[`.likec4rc`,`.likec4.config.json`,`likec4.config.json`],$=[`likec4.config.js`,`likec4.config.cjs`,`likec4.config.mjs`,`likec4.config.ts`,`likec4.config.cts`,`likec4.config.mts`];[...Q,...$];function isLikeC4JsonConfig(e){return Q.includes(basename(e))}function isLikeC4NonJsonConfig(e){return $.includes(basename(e))}function isLikeC4Config(e){return isLikeC4JsonConfig(e)||isLikeC4NonJsonConfig(e)}export{Z as a,validateProjectConfig as c,z as d,
|
|
20
|
+
`+t.prettifyError(e.error));return{...a,generators:e.data}}return a}function parseProjectConfigJSON(t){return validateProjectConfig(e.parse(t.trim()||`{}`))}const Z={parse:parseProjectConfigJSON,validate:validateProjectConfig,normalizeInclude:e=>{let t=g.safeParse(e);return t.success?t.data:{paths:[],maxDepth:3,fileThreshold:30}}};function trimTrailingSlashes(e){let t=e.length;for(;t>0&&(e[t-1]===`/`||e[t-1]===`\\`);)t--;return e.slice(0,t)}function splitPath(e){return e.split(`/`).flatMap(e=>e.split(`\\`))}function basename(e){let t=trimTrailingSlashes(e),n=splitPath(t);return n[n.length-1]||t}const Q=[`.likec4rc`,`.likec4.config.json`,`likec4.config.json`],$=[`likec4.config.js`,`likec4.config.cjs`,`likec4.config.mjs`,`likec4.config.ts`,`likec4.config.cts`,`likec4.config.mts`];[...Q,...$];function isLikeC4JsonConfig(e){return Q.includes(basename(e))}function isLikeC4NonJsonConfig(e){return $.includes(basename(e))}function isLikeC4Config(e){return isLikeC4JsonConfig(e)||isLikeC4NonJsonConfig(e)}export{Z as a,validateProjectConfig as c,z as d,k as f,Y as i,B as l,isLikeC4JsonConfig as n,X as o,isLikeC4NonJsonConfig as r,q as s,isLikeC4Config as t,N as u};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{i as e,r as t}from"./rolldown-runtime.mjs";import{g as n,h as r,v as i,y as a}from"./libs/langium.mjs";import{$ as o,A as s,B as c,D as ee,L as l,M as te,N as u,O as ne,Q as d,R as re,S as ie,T as f,Z as ae,b as oe,d as se,f as p,j as m,k as h,l as ce,m as le,t as g,tt as ue,u as de,v as fe,y as pe}from"./libs/remeda.mjs";import*as _ from"zod/v4";import{BorderStyles as me,ElementShapes as he,IconPositions as ge,RelationshipArrowTypes as _e,RelationshipLineTypes as ve,Sizes as ye,Sizings as be,ThemeColors as xe}from"@likec4/core/styles";import{exact as Se}from"@likec4/core/types";import{hasProp as Ce,invariant as v,nonexhaustive as y}from"@likec4/core";import b,*as we from"zod";import{invariant as Te,nameFromFqn as x,parentFqn as Ee,sortParentsFirst as De}from"@likec4/core/utils";import{produce as S}from"immer";function stripIndent(e){let t=e.match(/^[ \t]*(?=\S)/gm);if(!t)return e;let n=1/0;for(let e of t)n=Math.min(n,e.length);return n===0||n===1/0?e:e.replace(RegExp(`^[ \\t]{${n}}`,`gm`),``)}function dedent(e){return stripIndent(e.replace(/^(?:[ \t]*\r?\n)+|(?:\r?\n[ \t]*)+$/g,``))}const Oe=new i(`
|
|
2
|
+
`);function toStringLF(e,t){return a(e,t).replaceAll(`\r
|
|
3
|
+
`,`
|
|
4
|
+
`)}var ke=/* @__PURE__ */ t({body:()=>body,eachOnFresh:()=>eachOnFresh,eq:()=>eq,executeOnCtx:()=>executeOnCtx,executeOnFresh:()=>executeOnFresh,foreach:()=>foreach,foreachNewLine:()=>foreachNewLine,fresh:()=>fresh,guard:()=>guard,indent:()=>indent,inlineText:()=>inlineText,join:()=>join,lazy:()=>lazy,lines:()=>lines,markdown:()=>markdown,markdownOrString:()=>markdownOrString$1,materialize:()=>materialize,merge:()=>merge,newline:()=>newline,noop:()=>noop,operation:()=>operation,print:()=>print$1,printProperty:()=>printProperty,property:()=>property,select:()=>select,separateComma:()=>separateComma,separateNewLine:()=>separateNewLine,separateWith:()=>separateWith,space:()=>space,spaceBetween:()=>spaceBetween,text:()=>text,when:()=>when,withctx:()=>withctx,zodOp:()=>zodOp});function hasContent(e){return typeof e==`string`?e.trimStart().length!==0:e instanceof n&&e.contents.some(e=>hasContent(e))}function hasContentOrNewLine(e){return typeof e==`string`?e.trimStart().length!==0:e instanceof i?!e.ifNotEmpty:e instanceof n&&e.contents.some(e=>hasContentOrNewLine(e))}function fresh(e){return{ctx:e??void 0,out:new n}}function materialize(...e){let t,n=2;if(e.length===1){let[n]=e;if(te(n))return e=>materialize(n,e);if(`op`in n){let{op:e,...t}=n;return n=>materialize(e,n,{indent:2,...t})}t=n}else{let[r,i,a]=e;t=executeOnFresh(i,[r]),n=a?.indent??2}return v(f(n)||ne(n),`defaultIndentation must be a string or a number`),toStringLF(t.out,n)}function executeOnCtx(e,t,...n){l(t)?(v(n.length===0,`When first argument is an array, no additional operations are allowed`),n=t):n=[t,...n];for(let t of n)e=t(e);return e}function executeOnFresh(e,t,...n){return l(t)?executeOnCtx(fresh(e),t):executeOnCtx(fresh(e),[t,...n])}function eachOnFresh(e,t){return t.map(t=>t(fresh(e)))}function operation(e,t){let r=typeof e==`function`?e:t,wrapped=e=>{let t=r(e);return t instanceof n?{...e,out:t}:e};return typeof e==`string`&&r.name==``&&Object.defineProperties(wrapped,{name:{value:`wrapped(${e})`}}),wrapped}function isPrintable(e){return typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function print$1(e){return operation(function printOp({ctx:t,out:n}){let r=typeof e==`function`?e(t):e??t;h(r)||r===``||(v(isPrintable(r),`Value must be a string, number or boolean - got `+typeof r),n.append(String(r)))})}e(print$1,`print`);const eq=()=>print$1(`=`),space=()=>print$1(` `);function noop(){return e=>e}function lazy(e){return t=>(e()(t),t)}function newline(e){return operation(({out:t})=>{e===`ifNotEmpty`?t.appendNewLineIfNotEmpty():t.appendNewLine()})}function merge(...e){return operation(function merge({ctx:t,out:n}){let r=executeOnFresh(t,e);n.appendIf(hasContent(r.out),r.out)})}function indent(...e){if(e.length===1&&typeof e[0]==`string`){let t=dedent(e[0]);return t.trimStart().length===0?noop():operation(function indent1({out:e}){e.appendNewLineIfNotEmpty().indent({indentEmptyLines:!0,indentedChildren:[r(t.split(/\r?\n/),{separator:Oe})]}).appendNewLineIfNotEmpty()})}let t=e;return operation(function indent2({ctx:e,out:n}){let r=executeOnFresh(e,t);hasContent(r.out)&&n.appendNewLineIfNotEmpty().indent({indentEmptyLines:!0,indentedChildren:r.out.contents}).appendNewLineIfNotEmpty()})}function body(...e){let t=le(e);if(f(t))return body(t+` {`,`}`);if(e.length===2&&f(e[0])&&f(e[1])){let[t,n]=e;return(...e)=>operation(function body({ctx:i,out:a}){let o=indent(lines(...e))(fresh(i)).out;a.appendIf(hasContent(o),r([t,o,n]))})}let n=e;return body(`{`,`}`)(...n)}function inlineText(e){return operation(({ctx:t,out:n})=>{let r=e??t;if(h(r))return;v(f(r),`Value must be a string - got `+typeof r);let i=r.replace(/(\r?\n|\t)+/g,` `).replaceAll(`'`,`\\'`).trim();n.append(`'${i}'`)})}function multilineText(e,t=`'`){return merge(print$1(t),indent(e.replaceAll(`'`,`\\'`)),print$1(t))}function text(e){return operation(function text({ctx:t,out:n}){let r=typeof e==`function`?e(t):e??t;if(!h(r))return v(f(r),`Value must be a string - got `+typeof r),r.includes(`
|
|
5
|
+
`)?multilineText(r)({ctx:r,out:n}):inlineText()({ctx:r,out:n})})}const Ae=`'`.repeat(3);function markdown(e){return operation(function markdown(t){let n=e??t.ctx;if(!h(n))return v(f(n),`Value must be a string - got `+typeof n),multilineText(n,Ae)(t)})}function markdownOrString$1(e){return operation(function markdownOrString(t){let n=e??t.ctx;if(!h(n)){if(typeof n==`string`)return text(n)(t);if(`md`in n)return markdown(n.md)(t);if(`txt`in n)return multilineText(n.txt)(t);throw Error(`Invalid MarkdownOrString value: `+n)}})}e(markdownOrString$1,`markdownOrString`);function join(e){return operation(function joinOp({ctx:t,out:n}){let{operations:i,...a}=e,s=Array.isArray(i)?i:[i];v(o(s,1),`At least one operation is required`);let c;return c=s.length===1?s[0](fresh(t)).out.contents:ue(eachOnFresh(t,s),oe(e=>e.out)),c=ae(c,hasContentOrNewLine),n.appendIf(c.length>0,r(c,a))})}function spaceBetween(...e){return join({operations:e,suffix:(e,t,n)=>!n&&hasContent(e)?` `:void 0})}function lines(...e){let t=le(e);if(ne(t)){let e=fresh(void 0);for(let n=0;n<t;n++)e.out.appendNewLine();return(...t)=>join({operations:t,suffix:(t,n,r)=>r?void 0:e.out})}return join({operations:e,appendNewLineIfNotEmpty:!0,skipNewLineAfterLastItem:!0})}function withctx(...e){if(e.length===0)return(...e)=>operation(function withctx1(t){return executeOnCtx(t,e)});let t=e[0];if(e.length===1)return(...e)=>operation(function withctx1({out:n}){return executeOnCtx({ctx:t,out:n},e)});let n=e.slice(1);return operation(function withctx2({out:e}){return executeOnCtx({ctx:t,out:e},n)})}function property(e,t){return operation(function propertyOp({ctx:n,out:r}){let i=ee(n)&&Ce(n,e)?n[e]:void 0;i!=null&&(t?t({ctx:i,out:r}):(v(isPrintable(i),`Property ${e} is not printable "${i}"`),r.append(e,` `,String(i))))})}function printProperty(e){return property(e,print$1())}function foreach(...e){let[t,n]=e;if(e.length===2&&!te(n)){let e=t,i=n;return operation(function foreachSingleOp({ctx:t,out:n}){let a=[];for(let n of t){let t=e(fresh(n)).out;hasContent(t)&&a.push(t)}n.appendIf(a.length>0,r(a,i))})}let i=e;return operation(({ctx:e,out:t})=>{for(let n of e)executeOnCtx({ctx:n,out:t},i)})}function separateWith(e){return{separator:e}}function separateNewLine(e=1){if(e>1){let t=fresh(void 0);for(let n=0;n<e;n++)t.out.appendNewLine();return separateWith(t.out)}return separateWith(Oe)}function separateComma(e){return e?{separator:`,`,appendNewLineIfNotEmpty:!0,skipNewLineAfterLastItem:!0}:{separator:`, `}}function foreachNewLine(...e){return operation(function foreachNewLineOp({ctx:t,out:n}){let i=[];for(let n of t){let t=executeOnFresh(n,e).out;hasContent(t)&&i.push(t)}n.appendIf(i.length>0,r(i,separateNewLine()))})}function guard(e,...t){return operation(`guard`,({ctx:n,out:r})=>{if(`safeParse`in e){let i=e.safeParse(n);if(i.success)executeOnCtx({ctx:i.data,out:r},t);else throw Error(`Guard failed: ${we.prettifyError(i.error)}`)}else v(typeof e==`function`),e(n)&&executeOnCtx({ctx:n,out:r},t)})}function when(e,...t){return operation(function whenOp({ctx:n,out:r}){e(n)&&executeOnCtx({ctx:n,out:r},t)})}function select(e,...t){return operation(function selectOp({ctx:n,out:r}){let i=e(n);m(i)&&executeOnCtx({ctx:i,out:r},t)})}function execToOut(e){return(t,...n)=>executeOnCtx({ctx:t,out:e},n)}function zodOp(e){return t=>{let zodParseOp=()=>({ctx:r,out:i})=>{let a=we.safeParse(e,r);if(a.success){let e=t({ctx:a.data,out:i,exec:execToOut(i)});return h(e)?{ctx:r,out:i}:e instanceof n?{ctx:r,out:e}:typeof e==`function`?{ctx:r,out:i,...e({ctx:r,out:i})}:Ce(e,`ctx`)&&Ce(e,`out`)?e:{ctx:r,out:i}}throw a.error};return zodParseOp.noparse=()=>({ctx:e,out:r})=>{let i=t({ctx:e,out:r,exec:execToOut(r)});return i instanceof n?{ctx:e,out:i}:typeof i==`function`?{ctx:e,out:r,...i({ctx:e,out:r})}:{ctx:e,out:r}},zodParseOp}}var je=/* @__PURE__ */ t({arrow:()=>k,border:()=>Pe,color:()=>P,customColor:()=>ze,fqn:()=>w,icon:()=>D,iconPosition:()=>Fe,id:()=>Me,kind:()=>T,line:()=>A,link:()=>Le,links:()=>j,markdownOrString:()=>N,metadata:()=>He,metadataValue:()=>Ve,opacity:()=>Ne,props:()=>I,shape:()=>E,size:()=>O,sizing:()=>Ie,style:()=>F,tag:()=>M,tags:()=>Be,themeColor:()=>Re,viewId:()=>C});const Me=_.string().regex(/^[a-zA-Z0-9_.-]+$/,`id must consist of alphanumeric characters, underscores or hyphens`),C=Me.transform(e=>e),w=_.string().regex(/^[a-zA-Z0-9_.-]+$/,`FQN must consist of alphanumeric characters, dots, underscores or hyphens`).transform(e=>e),T=_.string().regex(/^[a-zA-Z0-9_-]+$/,`Kind must consist of alphanumeric characters, underscores or hyphens`).transform(e=>e),Ne=_.int().min(0,`Opacity must be between 0 and 100`).max(100,`Opacity must be between 0 and 100`),E=_.enum(he),D=_.string().nonempty(`Icon cannot be empty`).transform(e=>e),Pe=_.enum(me),O=_.enum(ye),Fe=_.enum(ge),Ie=_.enum(be),k=_.enum(_e),A=_.enum(ve),Le=_.union([_.string(),_.object({title:_.string().optional(),url:_.string()})]).transform(e=>Se(typeof e==`string`?{url:e}:e)),j=_.array(Le).readonly(),Re=_.enum(xe),ze=_.string().nonempty(`Custom color name cannot be empty`).transform(e=>e),M=_.string().nonempty(`Tag cannot be empty`).transform(e=>e.startsWith(`#`)?e.slice(1):e),Be=_.array(M).readonly(),N=_.union([_.string().transform(e=>({txt:e})),_.strictObject({md:_.string()}),_.strictObject({txt:_.string()})]),P=Re.or(ze),F=_.object({shape:E,icon:D,iconColor:P,iconSize:O,iconPosition:Fe,color:P,border:Pe,opacity:Ne,size:O,padding:O,textSize:O,sizing:Ie,multiple:_.boolean()}).partial().transform(p(m)),Ve=_.union([_.string(),_.boolean(),_.number()]),He=_.record(_.string(),Ve.or(_.array(Ve))),I=_.object({tags:Be.nullish(),title:_.string().nullish(),summary:N.nullish(),description:N.nullish(),notation:_.string().nullish(),technology:_.string().nullish(),links:j.nullish(),metadata:He.nullish()});var Ue=/* @__PURE__ */ t({directRelationExpr:()=>dt,elementKindExpr:()=>it,elementTagExpr:()=>at,expression:()=>W,fqnExpr:()=>R,fqnExprAny:()=>ut,fqnExprCustom:()=>B,fqnExprOrWhere:()=>z,fqnRef:()=>Ke,incomingRelationExpr:()=>ft,inoutRelationExpr:()=>mt,outgoingRelationExpr:()=>pt,refDeployment:()=>Ge,refExpr:()=>rt,refModel:()=>We,relationExpr:()=>V,relationExprAny:()=>gt,relationExprCustom:()=>U,relationExprOrWhere:()=>H,selector:()=>qe,whereAnd:()=>$e,whereExpr:()=>_t,whereKind:()=>Ye,whereMetadata:()=>Xe,whereNot:()=>et,whereOperator:()=>L,whereOr:()=>tt,whereParticipant:()=>Qe,whereTag:()=>Je,wildcardExpr:()=>nt});const We=_.strictObject({model:w,project:_.string().optional()}),Ge=_.strictObject({deployment:w,element:w.nullish()}),Ke=_.union([We,Ge]),qe=_.enum([`children`,`expanded`,`descendants`,`*`,`_`,`**`]).transform(e=>{switch(e){case`*`:return`children`;case`_`:return`expanded`;case`**`:return`descendants`;default:return e}});function equalOp(e){return _.xor([_.object({eq:e}),_.object({neq:e}),e.transform(e=>({eq:e}))])}const Je=_.strictObject({tag:equalOp(M)}),Ye=_.strictObject({kind:equalOp(T)}),Xe=_.strictObject({metadata:_.strictObject({key:_.string(),value:equalOp(_.string()).optional()})}),Ze=_.union([Je,Ye,Xe]),Qe=_.strictObject({participant:_.enum([`source`,`target`]),operator:Ze}),$e=_.object({get and(){return _.array(L)}}),et=_.object({get not(){return L}}),tt=_.object({get or(){return _.array(L)}}),L=_.union([Je,Ye,Xe,Qe,$e,tt,et]),nt=_.strictObject({wildcard:_.literal(!0)}),rt=_.object({ref:Ke,selector:qe.nullish()}).transform(p(m)),it=_.object({elementKind:T,isEqual:_.boolean()}),at=_.object({elementTag:M,isEqual:_.boolean()}),R=_.union([nt,rt,it,at]),ot=_.strictObject({where:_.strictObject({expr:R,condition:L})}),z=_.union([R,ot]),st=_.object({title:_.string(),description:N,technology:_.string(),notation:_.string(),notes:N,navigateTo:C,color:P}),ct=_.object({...st.shape,shape:E,icon:D,iconColor:P,iconSize:O,iconPosition:Fe,border:Pe,opacity:Ne,multiple:_.boolean(),size:O,padding:O,textSize:O,sizing:Ie}).partial(),lt=_.object({...st.shape,line:A,head:k,tail:k}).partial(),B=_.strictObject({custom:ct.extend({expr:z})}),ut=_.union([z,B]),dt=_.strictObject({source:R,target:R,isBidirectional:_.boolean().optional()}),ft=_.object({incoming:R}),pt=_.object({outgoing:R}),mt=_.object({inout:R}),V=_.union([dt,ft,pt,mt]),ht=_.strictObject({where:_.strictObject({expr:V,condition:L})}),H=_.union([V,ht]),U=_.strictObject({customRelation:lt.extend({expr:H})}),gt=_.union([H,U]),_t=_.strictObject({where:_.object({expr:_.xor([R,V]),condition:L})}),W=_.union([R,B,V,U,_t]);var vt=/* @__PURE__ */ t({element:()=>wt,instance:()=>bt,node:()=>yt,relationship:()=>Ct,schema:()=>Ot});const yt=I.extend({id:w,kind:T,style:F.optional(),shape:E.optional(),color:P.optional(),icon:D.optional()}).readonly().transform(e=>{let{shape:t,color:n,icon:r,...i}=e;return p(S(i,e=>{e.style=i.style||{},t&&(e.style.shape=t),n&&(e.style.color=n),r&&(e.style.icon=r)}),m)}),bt=I.extend({id:w,element:w,style:F.optional(),shape:E.optional(),color:P.optional(),icon:D.optional()}).readonly().transform(e=>{let{shape:t,color:n,icon:r,...i}=e;return p(S(i,e=>{e.style=i.style||{},t&&(e.style.shape=t),n&&(e.style.color=n),r&&(e.style.icon=r)}),m)}),xt=Ge,St=Me.transform(e=>e),Ct=I.extend({id:St.optional(),title:_.string().nullish(),source:xt,target:xt,isBidirectional:_.boolean().nullish(),navigateTo:C.nullish(),color:P.nullish(),kind:T.nullish(),line:A.nullish(),head:k.nullish(),tail:k.nullish()}).readonly().transform(p(m)),wt=_.union([yt,bt]),Tt=_.record(w,wt),Et=_.record(St,Ct),Dt=/* @__PURE__ */ e(e=>e.id??ce(8),`genRelationshipId`),Ot=_.object({elements:_.union([Tt,_.array(wt)]).transform(e=>l(e)?re(e,de(`id`)):e).optional(),relations:_.union([Et,_.array(Ct)]).transform(e=>l(e)?re(e,Dt):e).optional()});var kt=/* @__PURE__ */ t({element:()=>At,elements:()=>Pt,relationship:()=>Nt,relationshipEndpoint:()=>jt,relationshipId:()=>Mt,relationships:()=>Ft,schema:()=>Rt});const At=_.object({...I.shape,id:w,kind:T,style:F.optional(),shape:E.optional(),color:P.optional(),icon:D.optional()}).transform(e=>{let{shape:t,color:n,icon:r,...i}=e;return(t||n||r)&&(i=S(i,e=>{e.style=i.style||{},t&&(e.style.shape=t),n&&(e.style.color=n),r&&(e.style.icon=r)})),p(i,m)}).readonly(),jt=_.union([w,_.strictObject({model:w})]).transform(e=>typeof e==`string`?{model:e}:e),Mt=Me.transform(e=>e),Nt=_.object({...I.shape,id:Mt.optional(),title:_.string().nullish(),source:jt,target:jt,isBidirectional:_.boolean().nullish(),navigateTo:C.nullish(),color:P.nullish(),kind:T.nullish(),line:A.nullish(),head:k.nullish(),tail:k.nullish()}).transform(p(m)).readonly(),Pt=_.record(w,At),Ft=_.record(Mt,Nt),genRelationshipId=e=>e.id??ce(8),It=_.union([Pt,_.array(At).transform(e=>re(e,de(`id`)))]),Lt=_.union([Ft,_.array(Nt).transform(e=>re(e,genRelationshipId))]),Rt=_.object({elements:It.optional(),relations:Lt.optional()});var zt=/* @__PURE__ */ t({element:()=>Bt,relationship:()=>Vt,schema:()=>Ut,tagSpec:()=>Ht});const Bt=_.object({tags:Be.nullable(),title:_.string().nullable(),summary:N.nullable(),description:N.nullable(),technology:_.string().nullable(),notation:_.string().nullable(),links:j.nullable(),style:F.nullable()}).partial().transform(p(m)),Vt=_.object({technology:_.string().nullable(),notation:_.string().nullable(),color:P.nullable(),line:A.nullable(),head:k.nullable(),tail:k.nullable()}).partial().transform(p(m)),Ht=_.object({color:P.nullable()}).partial().transform(p(m)),Ut=_.object({elements:_.record(T,Bt),deployments:_.record(T,Bt),relationships:_.record(T,Vt),tags:_.union([_.record(M,Ht),_.array(M).transform(e=>pe(e,e=>[e,{}]))])}).partial();var Wt=/* @__PURE__ */ t({anyView:()=>bn,autoLayoutDirection:()=>Kt,deploymentView:()=>cn,deploymentViewRule:()=>sn,deploymentViewRuleIncludeAncestors:()=>Jt,dynamicStep:()=>ln,dynamicStepAlt:()=>mn,dynamicStepAltBranch:()=>pn,dynamicStepBlock:()=>dn,dynamicStepSeries:()=>un,dynamicStepTry:()=>fn,dynamicView:()=>yn,dynamicViewRule:()=>_n,dynamicViewStep:()=>gn,dynamicViewSubflow:()=>hn,dynamicViewVariant:()=>vn,elementView:()=>on,elementViewRule:()=>rn,viewRuleAutoLayout:()=>qt,viewRuleExclude:()=>Xt,viewRuleGlobalPredicate:()=>G,viewRuleGlobalStyle:()=>$t,viewRuleGroup:()=>nn,viewRuleInclude:()=>Yt,viewRulePredicate:()=>Zt,viewRuleRank:()=>tn,viewRuleStyle:()=>Qt,views:()=>xn});const Gt={TB:`TopBottom`,BT:`BottomTop`,LR:`LeftRight`,RL:`RightLeft`},Kt=b.enum([...ie(Gt),...g(Gt)]).transform(e=>Gt[e]??e),qt=b.object({direction:Kt,nodeSep:b.number().nullish(),rankSep:b.number().nullish()}),Jt=b.strictObject({includeAncestors:b.boolean()}),Yt=b.strictObject({include:b.array(W)}),Xt=b.strictObject({exclude:b.array(W)}),Zt=b.xor([Yt,Xt]),Qt=b.object({targets:b.array(R),notation:b.string().optional(),style:F}).transform(e=>e),$t=b.object({styleId:b.string()}).transform(e=>e),G=b.object({predicateId:b.string()}).transform(e=>e),en=b.literal([`max`,`min`,`same`,`sink`,`source`]),tn=b.object({targets:b.array(R),rank:en}).transform(e=>e),nn=b.lazy(()=>b.object({groupRules:b.array(b.union([Zt,G,nn])),title:b.string().nullable(),color:P.optional(),border:Pe.optional(),opacity:Ne.optional(),multiple:b.boolean().optional(),size:O.nullish(),padding:O.nullish(),textSize:O.nullish()}).transform(p(m))),rn=b.union([Zt,qt,Qt,$t,G,tn,nn]),an=b.object({id:C,title:b.string().nullish().default(null),description:N.nullish().default(null),order:b.number().int().nonnegative().optional(),routing:b.literal([`spline`,`ortho`]).optional(),tags:Be.nullish(),links:j.nullish()});function defineView(e){return b.object({...an.shape,...e})}const on=defineView({_type:b.literal(`element`),viewOf:w.nullish(),extends:C.nullish(),rules:b.array(rn).optional().default([])}),sn=b.union([Zt,qt,Qt,$t,G,Jt]),cn=defineView({_type:b.literal(`deployment`),rules:b.array(sn).optional().default([])}),ln=b.object({_type:b.never().exactOptional(),source:w,target:w,title:b.string().nullish().default(null),kind:b.string().nullish(),description:N.nullish(),technology:b.string().nullish(),notation:b.string().nullish(),notes:N.nullish(),color:P.optional(),line:A.optional(),head:k.optional(),tail:k.optional(),isBackward:b.boolean().optional(),navigateTo:C.nullish()}),K=b.object({title:b.string().optional(),get steps(){return b.array(gn).nonempty(`must have at least one step`)}}),un=b.object({_type:b.literal(`series`),steps:b.array(ln).nonempty(`must have at least one step`)}),dn=K.extend({_type:b.enum([`par`,`parallel`,`loop`,`opt`,`break`])}),fn=b.object({_type:b.literal(`try`),try:K,catch:K.optional(),finally:K.optional()}),pn=K.extend({_type:b.enum([`when`,`if`,`else`])}),mn=b.object({_type:b.literal(`alt`),title:b.string().optional(),branches:b.array(pn).nonempty(`alt block must have at least one branch`)}),hn=b.union([mn,un,dn,fn]),gn=b.union([ln,hn]),_n=b.union([Yt,G,Qt,$t,qt]),vn=b.enum([`diagram`,`sequence`]),yn=defineView({_type:b.literal(`dynamic`),variant:vn.optional(),steps:b.array(gn).optional(),rules:b.array(_n).optional()}),bn=b.union([on,cn,yn]),xn=b.record(C,bn),Sn=_.object({...Rt.shape,views:xn,deployment:Ot,deployments:Ot,specification:Ut}).partial().transform(normalizeStyles);function normalizeStyles(e){let t=e.specification?.elements;return!u(t)&&!u(e.elements)&&(e={...e,elements:fe(e.elements,e=>normalizeElementStyles(e,t))}),e}function normalizeElementStyles(e,t){let n=t[e.kind];if(!n)return e;let r=n.style??{};return S(e,t=>{for(let r of[`description`,`technology`,`tags`,`summary`]){let i=n[r],a=e[r];c(i,a)&&delete t[r]}let i=e.style;if(i)for(let[e,n]of d(r))c(i[e],n)&&delete t.style[e]})}const q={common:je,expr:Ue,specification:zt,model:kt,deployment:vt,views:Wt,likec4data:Sn};var Cn=/* @__PURE__ */ t({colorProperty:()=>colorProperty,descriptionProperty:()=>descriptionProperty,iconProperty:()=>iconProperty,linkProperty:()=>linkProperty,linksProperty:()=>linksProperty,markdownProperty:()=>markdownProperty,metadataProperty:()=>metadataProperty,metadataValue:()=>metadataValue,notationProperty:()=>notationProperty,notesProperty:()=>notesProperty,opacityProperty:()=>opacityProperty,relationConnector:()=>relationConnector,styleBlockProperty:()=>styleBlockProperty,styleProperties:()=>J,summaryProperty:()=>summaryProperty,tagsProperty:()=>tagsProperty,technologyProperty:()=>technologyProperty,textProperty:()=>textProperty,titleProperty:()=>titleProperty});function textProperty(e,t){return select(t=>t[e],spaceBetween(print$1(t??e),text()))}function markdownProperty(e,t){return select(t=>t[e],spaceBetween(print$1(t??e),markdownOrString$1()))}const titleProperty=()=>property(`title`,spaceBetween(print$1(`title`),text())),summaryProperty=()=>property(`summary`,spaceBetween(print$1(`summary`),markdownOrString$1())),descriptionProperty=()=>property(`description`,spaceBetween(print$1(`description`),markdownOrString$1())),notesProperty=()=>property(`notes`,spaceBetween(print$1(`notes`),markdownOrString$1())),technologyProperty=()=>property(`technology`,spaceBetween(print$1(`technology`),text())),notationProperty=()=>property(`notation`,spaceBetween(print$1(`notation`),text()));function printMetadataValue(){return operation(({ctx:e,out:t})=>f(e)?text()({ctx:e,out:t}):print$1()({ctx:e,out:t}))}function metadataValue(){return se(guard(s(l),printMetadataValue()),guard(l,body(`[`,`]`)(foreach(printMetadataValue(),{appendNewLineIfNotEmpty:!0,suffix(e,t,n){return n?void 0:`,`}}))))}const metadataProperty=()=>select(e=>e.metadata?d(e.metadata):void 0,body(`metadata`)(foreach(spaceBetween(print$1(e=>e[0]),property(`1`,metadataValue())),separateNewLine()))),tagsProperty=()=>property(`tags`,print$1(e=>e.map(e=>`#${e}`).join(`, `)));function linkProperty(){return spaceBetween(select(e=>typeof e==`string`?{url:e}:Se({url:e.url,title:e.title}),print$1(`link`),print$1(e=>e.url),property(`title`,inlineText())))}const linksProperty=()=>property(`links`,foreachNewLine(linkProperty()));function styleBlockProperty(){return select(e=>e.style,body(`style`)(J()))}function colorProperty(){return property(`color`,spaceBetween(print$1(`color`),print$1()))}function opacityProperty(){return property(`opacity`,spaceBetween(print$1(`opacity`),print$1(e=>`${e}%`)))}function iconProperty(){return property(`icon`,spaceBetween(print$1(`icon`),print$1()))}const J=zodOp(F)(lines(property(`shape`),colorProperty(),iconProperty(),property(`iconColor`),property(`iconSize`),property(`iconPosition`),property(`border`),opacityProperty(),property(`size`),property(`padding`),property(`textSize`),property(`sizing`),property(`multiple`)));function relationConnector(e,t){let n=t?`<->`:`->`;return e?`-[${e}]${n}`:n}var wn=/* @__PURE__ */ t({directRelationExpr:()=>Fn,expression:()=>Q,fqnExpr:()=>Z,fqnExprAny:()=>Pn,fqnExprCustom:()=>Mn,fqnExprOrWhere:()=>Nn,fqnRef:()=>X,inOutRelationExpr:()=>Rn,incomingRelationExpr:()=>In,outgoingRelationExpr:()=>Ln,relationExpr:()=>zn,relationExprAny:()=>Hn,relationExprCustom:()=>Vn,relationExprOrWhere:()=>Bn,whereAnd:()=>An,whereKindEqual:()=>En,whereMetadataEqual:()=>Dn,whereNot:()=>On,whereOperator:()=>Y,whereOr:()=>jn,whereParticipant:()=>kn,whereTagEqual:()=>Tn});function appendSelector(e,t){if(t)switch(t){case`children`:e.append(`.*`);break;case`descendants`:e.append(`.**`);break;case`expanded`:e.append(`._`);break;default:y(t)}return e}const Tn=zodOp(Je)(function whereTagEqualOp({ctx:{tag:e},out:t}){if(`eq`in e)return t.appendTemplate`tag is #${e.eq}`;if(`neq`in e)return t.appendTemplate`tag is not #${e.neq}`;y(e)}),En=zodOp(Ye)(function whereKindEqualOp({ctx:{kind:e},out:t}){if(`eq`in e)return t.appendTemplate`kind is ${e.eq}`;if(`neq`in e)return t.appendTemplate`kind is not ${e.neq}`;y(e)});function quoteMetadataValue(e){return e===`true`||e===`false`?e:`"${e}"`}const Dn=zodOp(Xe)(function whereMetadataEqualOp({ctx:{metadata:e},out:t}){let{key:n,value:r}=e;if(r===void 0)return t.appendTemplate`metadata.${n}`;if(`eq`in r)return t.append(`metadata.${n} is ${quoteMetadataValue(r.eq)}`);if(`neq`in r)return t.append(`metadata.${n} is not ${quoteMetadataValue(r.neq)}`);y(r)}),On=zodOp(et)(property(`not`,spaceBetween(print$1(`not (`),lazy(()=>Y.noparse()),print$1(`)`)))),kn=zodOp(Qe)(function whereParticipantOp({ctx:{participant:e,operator:t},out:n}){n.append(e,`.`),`tag`in t?Tn()({ctx:t,out:n}):`kind`in t?En()({ctx:t,out:n}):`metadata`in t?Dn()({ctx:t,out:n}):y(t)}),An=zodOp($e)(function whereAndOp({ctx:{and:e},out:t}){let n=oe(e,e=>{let{out:t}=executeOnFresh(e,Y.noparse());return`or`in e&&(t=fresh().out.append(`(`,...t.contents,`)`)),t});return t.append(r(n,{appendNewLineIfNotEmpty:!0,skipNewLineAfterLastItem:!0,prefix(e,t){return t>0?`and `:void 0}}))}),jn=zodOp(tt)(({ctx:{or:e},out:t})=>{let n=oe(e,e=>{let{out:t}=executeOnFresh(e,Y.noparse());return`and`in e&&(t=fresh().out.append(`(`,...t.contents,`)`)),t});return t.append(r(n,{appendNewLineIfNotEmpty:!0,skipNewLineAfterLastItem:!0,prefix(e,t){return t>0?`or `:void 0}}))}),Y=zodOp(L)(({ctx:e,exec:t})=>{if(`and`in e)return t(e,An.noparse());if(`or`in e)return t(e,jn.noparse());if(`not`in e)return t(e,On.noparse());if(`tag`in e)return t(e,Tn.noparse());if(`kind`in e)return t(e,En.noparse());if(`metadata`in e)return t(e,Dn.noparse());if(`participant`in e)return t(e,kn.noparse());y(e)}),X=zodOp(Ke)(({ctx:e,out:t})=>(`model`in e?t.append(e.model):(t.append(e.deployment),e.element&&t.append(`.`,e.element)),t)),Z=zodOp(R)(({ctx:e,out:t,exec:n})=>{if(`wildcard`in e)return t.append(`*`);if(`elementKind`in e)return t.append(`element.kind`).append(e.isEqual?` = `:` != `).append(e.elementKind);if(`elementTag`in e)return t.append(`element.tag`).append(e.isEqual?` = `:` != `).append(`#${e.elementTag}`);if(`ref`in e)return n(e.ref,X()),appendSelector(t,e.selector),t;y(e)}),Mn=zodOp(B)(({ctx:{custom:e},exec:t})=>{t(e.expr,Nn());let n=withctx()(body(`with`)(titleProperty(),descriptionProperty(),notationProperty(),notesProperty(),property(`navigateTo`),J()));return`where`in e.expr?t(e,indent(n)):t(e,space(),n)}),Nn=zodOp(z)(({ctx:e,exec:t})=>{`where`in e?(t(e.where.expr,Z.noparse()),t(e.where.condition,indent(print$1(`where`),indent(Y.noparse())))):t(e,Z.noparse())}),Pn=zodOp(ut)(({ctx:e,exec:t})=>`custom`in e?t(e,Mn.noparse()):t(e,Nn.noparse())),Fn=zodOp(dt)(merge(property(`source`,Z.noparse()),print$1(e=>e.isBidirectional?` <-> `:` -> `),property(`target`,Z.noparse()))),In=zodOp(ft)(merge(print$1(`-> `),property(`incoming`,Z.noparse()))),Ln=zodOp(pt)(merge(property(`outgoing`,Z.noparse()),print$1(` ->`))),Rn=zodOp(mt)(merge(print$1(`-> `),property(`inout`,Z.noparse()),print$1(` ->`))),zn=zodOp(V)(({ctx:e,exec:t})=>{if(`source`in e)return t(e,Fn.noparse());if(`incoming`in e)return t(e,In.noparse());if(`outgoing`in e)return t(e,Ln.noparse());if(`inout`in e)return t(e,Rn.noparse());y(e)}),Bn=zodOp(H)(({ctx:e,exec:t})=>{if(`where`in e)t(e.where.expr,zn.noparse()),t(e.where.condition,indent(print$1(`where`),indent(Y.noparse())));else return t(e,zn.noparse())}),Vn=zodOp(U)(({ctx:{customRelation:e},exec:t})=>{t(e.expr,Bn.noparse());let n=withctx(e)(body(`with`)(titleProperty(),descriptionProperty(),notationProperty(),markdownProperty(`notes`),property(`navigateTo`),J(),property(`head`),property(`tail`),property(`line`)));`where`in e.expr?t(e,indent(n)):t(e,space(),n)}),Hn=zodOp(gt)(({ctx:e,exec:t})=>`customRelation`in e?t(e,Vn.noparse()):t(e,Bn.noparse())),Q=zodOp(W)(({ctx:e,exec:t})=>{if(`custom`in e)return t(e,Mn.noparse());if(`customRelation`in e)return t(e,Vn.noparse());if(`wildcard`in e||`ref`in e||`elementKind`in e||`elementTag`in e)return t(e,Z.noparse());if(`source`in e||`incoming`in e||`outgoing`in e||`inout`in e)return t(e,zn.noparse());if(`where`in e){let{expr:n,condition:r}=e.where;return`source`in n||`incoming`in n||`outgoing`in n||`inout`in n?t({where:{expr:n,condition:r}},Bn.noparse()):t({where:{expr:n,condition:r}},Nn.noparse())}y(e)});var Un=/* @__PURE__ */ t({deployment:()=>qn,instance:()=>Gn,node:()=>node,relationship:()=>Kn});function buildTree$1(e){let t=/* @__PURE__ */ new Map,n=[],r=ue(e,De);for(let e of r){let r;r=`element`in e?e:{...e,children:[]},t.set(e.id,r);let i=Ee(e.id),a=i?t.get(i):void 0;a&&`children`in a?a.children.push(r):n.push(r)}return{roots:n,nodes:t,exists:e=>t.has(e)}}e(buildTree$1,`buildTree`);function hasStyleProps$1(e){return!u(e.style)}e(hasStyleProps$1,`hasStyleProps`);function hasElementProps$1(e){return!!(e.description||e.summary||e.technology||e.notation||e.tags&&e.tags.length>0||e.links&&e.links.length>0||!u(e.metadata)||hasStyleProps$1(e))}e(hasElementProps$1,`hasElementProps`);const Wn=zodOp(q.deployment.element)(lines(tagsProperty(),technologyProperty(),summaryProperty(),descriptionProperty(),linksProperty(),metadataProperty(),select(e=>hasStyleProps$1(e)?e.style:void 0,body(`style`)(J())))),Gn=zodOp(q.deployment.instance)(spaceBetween(when(e=>x(e.id)!==x(e.element),print$1(e=>x(e.id)),print$1(` =`)),print$1(`instanceOf`),printProperty(`element`),when(e=>!!e.title&&e.title!==x(e.id),property(`title`,inlineText())),when(e=>hasElementProps$1(e),body(Wn()))));function node(){return function nodeOp({ctx:e,out:t}){let n=e;if(`element`in n)return Gn()({ctx:n,out:t}),{ctx:e,out:t};Te(`children`in n,`Node must have children property`);let r=n.children.length>0||hasElementProps$1(n),i=x(n.id),a=[print$1(i),print$1(`=`),print$1(n.kind)];return n.title&&n.title!==i&&a.push(inlineText(n.title)),r&&a.push(body(lines(2)(withctx(n,Wn()),...n.children.map(e=>withctx(e,nodeOp))))),spaceBetween(...a)({ctx:e,out:t})}}function hasRelationStyle$1(e){return!!(e.color||e.line||e.head||e.tail)}e(hasRelationStyle$1,`hasRelationStyle`);function hasRelationProps$1(e){return!!(e.description||e.summary||e.technology||e.tags&&e.tags.length>0||e.links&&e.links.length>0||!u(e.metadata)||hasRelationStyle$1(e)||e.navigateTo)}e(hasRelationProps$1,`hasRelationProps`);const Kn=zodOp(q.deployment.relationship)(spaceBetween(property(`source`,X()),print$1(e=>relationConnector(e.kind,e.isBidirectional)),property(`target`,X()),property(`title`,inlineText()),when(hasRelationProps$1,body(tagsProperty(),technologyProperty(),summaryProperty(),descriptionProperty(),property(`navigateTo`),linksProperty(),metadataProperty(),when(hasRelationStyle$1,body(`style`)(colorProperty(),property(`line`),property(`head`),property(`tail`))))))),qn=zodOp(q.deployment.schema)(body(`deployment`)(lines(2)(select(e=>buildTree$1(e.elements?g(e.elements):[]).roots,lines(2)(foreach(node()))),select(e=>e.relations?g(e.relations):void 0,lines(2)(foreach(Kn()))))));var Jn=/* @__PURE__ */ t({element:()=>Zn,model:()=>Qn,relationship:()=>Xn});function buildTree(e){let t=/* @__PURE__ */ new Map,n=[],r=ue(e,De);for(let e of r){let r={...e,children:[]};t.set(e.id,r);let i=Ee(e.id),a=i?t.get(i):void 0;a?a.children.push(r):n.push(r)}return{roots:n,nodes:t,exists:e=>t.has(e)}}function hasStyleProps(e){return!u(e.style)}function hasElementProps(e){return!!(e.description||e.summary||e.technology||e.notation||e.tags&&e.tags.length>0||e.links&&e.links.length>0||!u(e.metadata)||hasStyleProps(e))}const Yn=zodOp(q.model.element)(lines(tagsProperty(),technologyProperty(),summaryProperty(),descriptionProperty(),linksProperty(),metadataProperty(),select(e=>hasStyleProps(e)?e.style:void 0,body(`style`)(J()))));function elementTree(){return function elementTreeNodeOp({ctx:e,out:t}){let n=e,r=(e.children?.length??0)>0||hasElementProps(n),i=x(n.id),a=[print$1(i),print$1(`=`),print$1(n.kind)];return n.title&&n.title!==i&&a.push(inlineText(n.title)),r&&a.push(body(lines(2)(withctx(n,Yn()),...(e.children??[]).map(e=>withctx(e,elementTree()))))),spaceBetween(...a)({ctx:e,out:t})}}function hasRelationStyle(e){return!!(e.color||e.line||e.head||e.tail)}function hasRelationProps(e){return!!(e.description||e.summary||e.technology||e.tags&&e.tags.length>0||e.links&&e.links.length>0||!u(e.metadata)||hasRelationStyle(e)||e.navigateTo)}const Xn=zodOp(q.model.relationship)(spaceBetween(property(`source`,X()),print$1(e=>relationConnector(e.kind,e.isBidirectional)),property(`target`,X()),property(`title`,inlineText()),when(hasRelationProps,body(tagsProperty(),technologyProperty(),summaryProperty(),descriptionProperty(),property(`navigateTo`),linksProperty(),metadataProperty(),when(hasRelationStyle,body(`style`)(colorProperty(),property(`line`),property(`head`),property(`tail`))))))),Zn=zodOp(q.model.element)(elementTree()),Qn=zodOp(q.model.schema)(body(`model`)(lines(2)(select(e=>buildTree(e.elements?g(e.elements):[]).roots,lines(2)(foreach(elementTree()))),select(e=>e.relations?g(e.relations):void 0,lines(2)(foreach(Xn()))))));var $n=/* @__PURE__ */ t({elementKind:()=>elementKind,relationshipKind:()=>tr,specification:()=>nr,tagSpecification:()=>er});const er=zodOp(_.tuple([_.string(),Ht]))(spaceBetween(print$1(`tag`),printProperty(`0`),property(`1`,property(`color`,body(spaceBetween(print$1(`color`),print$1())))))),elementKind=e=>zodOp(_.tuple([_.string(),Bt]))(spaceBetween(print$1(e),printProperty(`0`),property(`1`,body(tagsProperty(),titleProperty(),summaryProperty(),descriptionProperty(),technologyProperty(),notationProperty(),linksProperty(),property(`style`,body(`style`)(J())))))),tr=zodOp(_.tuple([_.string(),Vt]))(spaceBetween(print$1(`relationship`),printProperty(`0`),property(`1`,body(technologyProperty(),notationProperty(),colorProperty(),property(`line`),property(`head`),property(`tail`))))),nr=zodOp(Ut)(body(`specification`)(lines(2)(select(e=>e.elements&&d(e.elements),foreachNewLine(elementKind(`element`)())),select(e=>e.deployments&&d(e.deployments),foreachNewLine(elementKind(`deploymentNode`)())),select(e=>e.relationships&&d(e.relationships),foreachNewLine(tr())),select(e=>e.tags&&d(e.tags),foreachNewLine(er())))));var rr=/* @__PURE__ */ t({anyView:()=>kr,deploymentView:()=>gr,deploymentViewRule:()=>hr,deploymentViewRuleIncludeAncestors:()=>dr,dynamicView:()=>Or,dynamicViewRule:()=>Dr,elementView:()=>mr,elementViewRule:()=>pr,step:()=>Er,stepAny:()=>Tr,viewRuleAutoLayout:()=>$,viewRuleExclude:()=>ar,viewRuleGlobalPredicate:()=>ur,viewRuleGlobalStyle:()=>lr,viewRuleGroup:()=>cr,viewRuleInclude:()=>ir,viewRulePredicate:()=>or,viewRuleRank:()=>fr,viewRuleStyle:()=>sr,views:()=>Ar});const viewTitleProperty=()=>property(`title`,spaceBetween(print$1(`title`),inlineText())),viewPredicateOp=e=>operation(`viewPredicateOp`,({ctx:t,out:n})=>{let r=t;if(!o(r,1))return;let i=o(r,2),a=foreach(Q(),separateComma(i));executeOnCtx({ctx:t,out:n},merge(print$1(e),...i?[indent(a)]:[space(),a]))}),ir=zodOp(q.views.viewRuleInclude)(property(`include`,viewPredicateOp(`include`))),ar=zodOp(q.views.viewRuleExclude)(property(`exclude`,viewPredicateOp(`exclude`))),or=zodOp(q.views.viewRulePredicate)(({ctx:e,exec:t})=>{let n,r;return`include`in e?(n=e.include,r=`include`):`exclude`in e&&(n=e.exclude,r=`exclude`),v(n&&r,`Invalid view rule predicate`),t(n,viewPredicateOp(r))}),sr=zodOp(q.views.viewRuleStyle)(spaceBetween(print$1(`style`),property(`targets`,foreach(Q(),separateComma())),body(notationProperty(),property(`style`,J.noparse())))),cr=zodOp(q.views.viewRuleGroup)(({ctx:e,exec:t})=>{throw Error(`not implemented`)}),lr=zodOp(q.views.viewRuleGlobalStyle)(({ctx:e,exec:t})=>{throw Error(`not implemented`)}),ur=zodOp(q.views.viewRuleGlobalPredicate)(({ctx:e,exec:t})=>{throw Error(`not implemented`)}),$=zodOp(q.views.viewRuleAutoLayout)(spaceBetween(print$1(`autoLayout`),printProperty(`direction`),guard(Ce(`rankSep`),spaceBetween(printProperty(`rankSep`),printProperty(`nodeSep`))))),dr=zodOp(q.views.deploymentViewRuleIncludeAncestors)(spaceBetween(print$1(`includeAncestors`),printProperty(`includeAncestors`))),fr=zodOp(q.views.viewRuleRank)(({ctx:e,exec:t})=>{throw Error(`not implemented`)}),pr=zodOp(q.views.elementViewRule)(({ctx:e,exec:t})=>{if(`include`in e)return t(e.include,viewPredicateOp(`include`));if(`exclude`in e)return t(e.exclude,viewPredicateOp(`exclude`));if(`groupRules`in e)return t(e,cr.noparse());if(`rank`in e)return t(e,fr.noparse());if(`direction`in e)return t(e,$.noparse());if(`styleId`in e)return t(e,lr.noparse());if(`predicateId`in e)return t(e,ur.noparse());if(`targets`in e&&`style`in e)return t(e,sr.noparse());y(e)}),mr=zodOp(q.views.elementView.partial({_type:!0}))(spaceBetween(print$1(`view`),print$1(e=>e.id),property(`viewOf`,spaceBetween(print$1(`of`),print$1())),body(lines(2)(lines(tagsProperty(),viewTitleProperty(),property(`order`),property(`routing`),descriptionProperty(),linksProperty()),property(`rules`,foreachNewLine(pr.noparse())))))),hr=zodOp(q.views.deploymentViewRule)(({ctx:e,exec:t})=>{if(`include`in e)return t(e.include,viewPredicateOp(`include`));if(`exclude`in e)return t(e.exclude,viewPredicateOp(`exclude`));if(`includeAncestors`in e)return t(e,dr.noparse());if(`direction`in e)return t(e,$.noparse());if(`styleId`in e)return t(e,lr.noparse());if(`predicateId`in e)return t(e,ur.noparse());if(`targets`in e&&`style`in e)return t(e,sr.noparse());y(e)}),gr=zodOp(q.views.deploymentView.partial({_type:!0}))(spaceBetween(print$1(`deployment view`),print$1(e=>e.id),body(lines(2)(lines(tagsProperty(),viewTitleProperty(),property(`order`),property(`routing`),descriptionProperty(),linksProperty()),property(`rules`,foreachNewLine(hr.noparse())))))),_r=zodOp(q.views.dynamicStep.partial({source:!0}))(spaceBetween(print$1(e=>e.isBackward?`<-`:e.kind?`-[${e.kind}]->`:`->`),printProperty(`target`),property(`title`,text()),body(lines(technologyProperty(),descriptionProperty(),notesProperty(),property(`navigateTo`),notationProperty(),colorProperty(),property(`line`),property(`head`),property(`tail`))))),vr=zodOp(q.views.dynamicStep)(spaceBetween(printProperty(`source`),_r.noparse())),bodyWithSteps=()=>property(`steps`,body(foreachNewLine(lazy(()=>Tr.noparse())))),yr=zodOp(q.views.dynamicStepBlock)(spaceBetween(printProperty(`_type`),property(`title`,text()),bodyWithSteps())),br=zodOp(q.views.dynamicStepSeries)(merge(select(e=>e.steps[0],printProperty(`source`)),indent(property(`steps`,foreachNewLine(_r.noparse()))))),xr=zodOp(q.views.dynamicStepTry)(spaceBetween(select(e=>e.try,spaceBetween(print$1(`try`),property(`title`,text()),bodyWithSteps())),select(e=>e.catch,spaceBetween(print$1(`catch`),property(`title`,text()),bodyWithSteps())),select(e=>e.finally,spaceBetween(print$1(`finally`),property(`title`,text()),bodyWithSteps())))),Sr=zodOp(q.views.dynamicStepAltBranch)(spaceBetween(printProperty(`_type`),property(`title`,text()),bodyWithSteps())),Cr=zodOp(q.views.dynamicStepAlt)(spaceBetween(print$1(`alt`),property(`title`,text()),body(property(`branches`,foreachNewLine(Sr.noparse()))))),wr=zodOp(q.views.dynamicViewSubflow)(({ctx:e,exec:t})=>{switch(e._type){case`alt`:return t(e,Cr.noparse());case`series`:return t(e,br.noparse());case`try`:return t(e,xr.noparse());case`par`:case`parallel`:case`loop`:case`opt`:case`break`:return t(e,yr.noparse());default:y(e)}}),Tr=zodOp(q.views.dynamicViewStep)(({ctx:e,exec:t})=>`source`in e&&`target`in e?t(e,vr.noparse()):(v(e._type,`Step must have a type`),t(e,wr.noparse()))),Er=Object.assign(vr,{subflow:wr,block:yr,alt:Cr,series:br,try:xr,any:Tr}),Dr=zodOp(q.views.dynamicViewRule)(({ctx:e,exec:t})=>{if(`include`in e)return t(e.include,viewPredicateOp(`include`));if(`predicateId`in e)return t(e,ur.noparse());if(`targets`in e&&`style`in e)return t(e,sr.noparse());if(`styleId`in e)return t(e,lr.noparse());if(`direction`in e)return t(e,$.noparse());y(e)}),Or=zodOp(q.views.dynamicView.partial({_type:!0}))(spaceBetween(print$1(`dynamic view`),print$1(e=>e.id),body(lines(2)(lines(tagsProperty(),viewTitleProperty(),property(`order`),property(`routing`),descriptionProperty(),linksProperty(),property(`variant`)),property(`steps`,foreachNewLine(Er.any.noparse())),property(`rules`,foreachNewLine(Dr.noparse())))))),kr=zodOp(q.views.anyView)(({ctx:e,exec:t})=>{if(`_type`in e){if(e._type==`element`)return t(e,mr.noparse());if(e._type===`deployment`)return t(e,gr.noparse());if(e._type===`dynamic`)return t(e,Or.noparse())}y(e)}),Ar=zodOp(q.views.views)(body(`views`)(select(e=>g(e),foreach(kr.noparse(),{separator:new n().appendNewLine().appendNewLine(),prefix:(e,t,n)=>t===0&&!n?Oe:void 0})))),jr=zodOp(q.likec4data)(lines(2)(property(`specification`,nr.noparse()),Qn(),property(`deployment`,qn.noparse()),property(`deployments`,qn.noparse()),property(`views`,Ar.noparse())));function generateLikeC4(e,t){return t={indent:2,...t},materialize(jr(),e,t)}function print(e,t,n){return materialize(e,t??{},n)}function printWithTabIndent(e,t){return materialize(e,t??{},{indent:` `})}export{toStringLF as $,inlineText as A,print$1 as B,body as C,foreachNewLine as D,foreach as E,markdownOrString$1 as F,separateNewLine as G,property as H,materialize as I,spaceBetween as J,separateWith as K,merge as L,lazy as M,lines as N,guard as O,markdown as P,Oe as Q,newline as R,ke as S,eq as T,select as U,printProperty as V,separateComma as W,when as X,text as Y,withctx as Z,wn as _,gr as a,titleProperty as b,$ as c,$n as d,dedent as et,Qn as f,Q as g,Un as h,jr as i,join as j,indent as k,rr as l,qn as m,print as n,Or as o,Jn as p,space as q,printWithTabIndent as r,mr as s,generateLikeC4 as t,stripIndent as tt,nr as u,descriptionProperty as v,eachOnFresh as w,q as x,Cn as y,noop as z};
|