likec4 1.60.0 → 1.61.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/README.md +2 -0
- package/__app__/codegen/react.mjs +4 -10
- package/__app__/codegen/webcomponent.mjs +5 -208
- package/__app__/index.html +15 -15
- package/__app__/src/aichat/index.mjs +1 -2
- package/__app__/src/chunks/AIChat.mjs +292 -117
- package/__app__/src/chunks/ErrorComponent.mjs +444 -0
- package/__app__/src/chunks/Header.mjs +269 -0
- package/__app__/src/chunks/ViewReact.mjs +438 -0
- package/__app__/src/chunks/find.mjs +38 -0
- package/__app__/src/chunks/hooks.mjs +18 -541
- package/__app__/src/chunks/libs/@tabler/icons-react.mjs +340 -0
- package/__app__/src/chunks/libs/@tanstack-ai.mjs +11101 -1797
- package/__app__/src/chunks/libs/@tanstack.mjs +4563 -3083
- package/__app__/src/chunks/libs/fast-equals.mjs +140 -71
- package/__app__/src/chunks/{es.mjs → libs/html-to-image.mjs} +16 -22
- package/__app__/src/chunks/libs/nanostores.mjs +4 -8
- package/__app__/src/chunks/libs/react-resizable-panels.mjs +2792 -0
- package/__app__/src/chunks/react.mjs +22 -0
- package/__app__/src/chunks/rolldown-runtime.mjs +3 -32
- package/__app__/src/chunks/router.mjs +106 -0
- package/__app__/src/chunks/scope.mjs +106 -0
- package/__app__/src/chunks/searchParams.mjs +29 -0
- package/__app__/src/chunks/single-index.mjs +465 -0
- package/__app__/src/chunks/styled-system.mjs +1916 -2946
- package/__app__/src/chunks/useAsync.mjs +69 -0
- package/__app__/src/chunks/useSyncedRef.mjs +16 -0
- package/__app__/src/components/ColorSchemeToggle.mjs +124 -0
- package/__app__/src/components/CopyToClipboard.mjs +53 -0
- package/__app__/src/components/ErrorComponent.mjs +1 -0
- package/__app__/src/components/NavigationPanel.mjs +63 -0
- package/__app__/src/components/NotFound.mjs +155 -0
- package/__app__/src/components/ViewOutlet.mjs +9 -0
- package/__app__/src/components/model-diff/CompareModelProvider.mjs +44 -0
- package/__app__/src/components/model-diff/ModelDiffPanel.mjs +179 -0
- package/__app__/src/components/model-diff/compare-model.mjs +76 -0
- package/__app__/src/components/model-diff/state.mjs +45 -0
- package/__app__/src/components/search/OverviewSearch.mjs +92 -0
- package/__app__/src/components/search/OverviewSearchAdapter.mjs +94 -0
- package/__app__/src/components/sidebar/DiagramTree.css.mjs +48 -0
- package/__app__/src/components/sidebar/DiagramsTree.mjs +304 -0
- package/__app__/src/components/sidebar/Drawer.mjs +178 -0
- package/__app__/src/components/sidebar/SidebarBurger.mjs +28 -0
- package/__app__/src/components/sidebar/data.mjs +94 -0
- package/__app__/src/components/sidebar/state.mjs +16 -0
- package/__app__/src/components/view-page/Header.mjs +1 -0
- package/__app__/src/components/view-page/SelectProject.mjs +258 -0
- package/__app__/src/components/view-page/ShareModal.mjs +111 -0
- package/__app__/src/components/view-page/share-modal/AlertLocalhost.mjs +31 -0
- package/__app__/src/components/view-page/share-modal/CopyButtonChild.mjs +36 -0
- package/__app__/src/components/view-page/share-modal/EmbedPanel.mjs +100 -0
- package/__app__/src/components/view-page/share-modal/WebcomponentsPanel.mjs +264 -0
- package/__app__/src/components/view-page/state.mjs +17 -0
- package/__app__/src/context/LikeC4CustomizationContext.mjs +26 -0
- package/__app__/src/context/LikeC4IconRendererContext.mjs +29 -0
- package/__app__/src/context/LikeC4ModelContext.mjs +34 -0
- package/__app__/src/context/LikeC4ProjectsContext.mjs +40 -0
- package/__app__/src/context/ModelDiffsContext.mjs +33 -0
- package/__app__/src/context/safeCtx.mjs +14 -0
- package/__app__/src/hooks.mjs +1 -0
- package/__app__/src/main.mjs +4 -48126
- package/__app__/src/pages/EmbedPage.mjs +93 -0
- package/__app__/src/pages/ExportPage.mjs +691 -0
- package/__app__/src/pages/ProjectsOverview.mjs +23 -0
- package/__app__/src/pages/ViewAsD2.mjs +105 -0
- package/__app__/src/pages/ViewAsDot.mjs +65 -0
- package/__app__/src/pages/ViewAsMmd.mjs +109 -0
- package/__app__/src/pages/ViewAsPuml.mjs +105 -0
- package/__app__/src/pages/ViewEditor.mjs +220 -0
- package/__app__/src/pages/ViewReact.mjs +1 -0
- package/__app__/src/pages/export-layout.mjs +95 -0
- package/__app__/src/pages/export-page-params.mjs +9 -0
- package/__app__/src/pages/styles.css.mjs +23 -0
- package/__app__/src/routeTree.gen.mjs +105 -0
- package/__app__/src/router.mjs +1 -0
- package/__app__/src/routes/__root.mjs +65 -0
- package/__app__/src/routes/index.css.mjs +29 -0
- package/__app__/src/routes/index.mjs +32 -0
- package/__app__/src/routes/project._projectId/-components.mjs +100 -0
- package/__app__/src/routes/project._projectId/embed._viewId.mjs +5 -0
- package/__app__/src/routes/project._projectId/export._viewId.mjs +24 -0
- package/__app__/src/routes/project._projectId/index.mjs +14 -0
- package/__app__/src/routes/project._projectId/route.mjs +93 -0
- package/__app__/src/routes/project._projectId/view._viewId.d2.mjs +34 -0
- package/__app__/src/routes/project._projectId/view._viewId.dot.mjs +41 -0
- package/__app__/src/routes/project._projectId/view._viewId.index.mjs +7 -0
- package/__app__/src/routes/project._projectId/view._viewId.mjs +23 -0
- package/__app__/src/routes/project._projectId/view._viewId.mmd.mjs +39 -0
- package/__app__/src/routes/project._projectId/view._viewId.puml.mjs +34 -0
- package/__app__/src/routes/projects.mjs +36 -0
- package/__app__/src/routes/single-index.mjs +1 -0
- package/__app__/src/routes/webcomponent._.mjs +94 -0
- package/__app__/src/style.css +1156 -1147
- package/config/schema.json +26 -2
- package/dist/app/render-view-client.css +1 -1
- package/dist/app/render-view-client.js +375 -393
- package/dist/chunks/filenames.mjs +26 -20
- package/dist/chunks/generate-likec4.mjs +4 -4
- package/dist/chunks/index.d.mts +16 -15
- package/dist/chunks/index2.d.mts +7041 -3293
- package/dist/chunks/libs/@chenglou/pretext.mjs +9 -0
- package/dist/chunks/libs/@logtape/logtape.mjs +5 -5
- package/dist/chunks/libs/@ts-graphviz/common.d.mts +2 -4
- package/dist/chunks/libs/chevrotain.mjs +19 -19
- package/dist/chunks/libs/clone.mjs +1 -0
- package/dist/chunks/libs/eventemitter3.mjs +1 -1
- package/dist/chunks/libs/fast-equals.mjs +1 -0
- package/dist/chunks/libs/fontkit.mjs +1 -0
- package/dist/chunks/libs/langium.d.mts +80 -2933
- package/dist/chunks/libs/langium.mjs +6 -6
- package/dist/chunks/libs/pako.mjs +1 -1
- package/dist/chunks/libs/pathe.mjs +1 -1
- package/dist/chunks/libs/remeda.mjs +1 -1
- package/dist/chunks/node.mjs +110 -77
- package/dist/chunks/rolldown-runtime.mjs +1 -1
- package/dist/chunks/sequence-view.mjs +1 -1
- package/dist/chunks/vite-plugin.mjs +183 -164
- package/dist/cli/index.mjs +157 -101
- package/dist/config/index.d.mts +65 -4
- package/dist/config/index.mjs +1 -1
- package/dist/generators/likec4.d.mts +16 -64
- package/dist/index.d.mts +2 -4
- package/dist/model/index.d.mts +0 -10
- package/dist/vite-plugin/index.d.mts +83 -61
- package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +1 -2
- package/dist/vite-plugin/internal/index.d.mts +91 -17
- package/dist/vite-plugin/internal/index.mjs +156 -110
- package/package.json +60 -55
- package/react/index.d.mts +3010 -4014
- package/react/index.mjs +170 -171
- package/react/rolldown-runtime-CfRud99p.js +1 -0
- package/skills/likec4-dsl/SKILL.md +71 -25
- package/skills/likec4-dsl/evals/evals-public.json +5 -0
- package/skills/likec4-dsl/evals/grading-spec.json +15 -1
- package/skills/likec4-dsl/references/cli.md +39 -10
- package/skills/likec4-dsl/references/configuration.md +5 -5
- package/skills/likec4-dsl/references/diffs.md +52 -0
- package/skills/likec4-dsl/references/examples.md +2 -2
- package/skills/likec4-dsl/references/identifier-validity.md +31 -31
- package/skills/likec4-dsl/references/include-predicates-wildcards.md +16 -15
- package/skills/likec4-dsl/references/model.md +42 -11
- package/skills/likec4-dsl/references/specification.md +11 -7
- package/skills/likec4-dsl/references/troubleshooting.md +47 -42
- package/skills/likec4-dsl/references/views.md +2 -2
- package/vite-plugin-modules.d.ts +126 -51
- package/__app__/src/chunks/LikeC4Styles.mjs +0 -4522
- package/__app__/src/chunks/ProjectsOverview.mjs +0 -827
- package/__app__/src/chunks/libs/@floating-ui.mjs +0 -3286
- package/__app__/src/chunks/libs/@mantine.mjs +0 -17731
- package/__app__/src/chunks/libs/@xstate/react.mjs +0 -3471
- package/__app__/src/chunks/libs/@xyflow/react.mjs +0 -7927
- package/__app__/src/chunks/libs/bezier-js.mjs +0 -1593
- package/__app__/src/chunks/libs/d3.mjs +0 -4531
- package/__app__/src/chunks/libs/framer.mjs +0 -11331
- package/__app__/src/chunks/libs/zod.mjs +0 -5404
- package/dist/chunks/libs/@chevrotain/types.d.mts +0 -111
- package/react/rolldown-runtime-DnkiqaRY.js +0 -1
|
@@ -1,20 +1,26 @@
|
|
|
1
|
-
import"./rolldown-runtime.mjs";import{t as e}from"./libs/json5.mjs";import t from"zod/v4";import{BorderStyles as
|
|
2
|
-
|
|
3
|
-
`
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
(must be a valid color name from the theme)`}),
|
|
11
|
-
These values will be used if such property is not defined`}),
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
These values will be used if such property is not defined`}),
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
`
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import"./rolldown-runtime.mjs";import{t as e}from"./libs/json5.mjs";import{O as t}from"./libs/remeda.mjs";import n from"zod/v4";import{BorderStyles as r,ElementShapes as i,IconPositions as a,RelationshipArrowTypes as o,Sizes as s,ThemeColors as c,computeColorValues as l}from"@likec4/core/styles";import{exact as u}from"@likec4/core/types";const d=/^@[A-Za-z0-9_-]*$/,f=/^(?!\/|[A-Za-z]:[\\\/])(?!.*:\/\/).*$/,p=n.string().min(1,`Image alias key cannot be empty`).regex(d,`Image alias key must match /^@\\w+$/`),m=n.string().min(1,`Image alias value cannot be empty`).regex(f,`Image alias value must be a relative path (no leading slash or protocol)`),h=n.record(p,m).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).`}),g=n.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)`),_=n.strictObject({paths:n.array(g).meta({description:`Additional relative directory paths to include LikeC4 source files from, searched recursively.
|
|
2
|
+
Paths are relative to the project folder (the folder containing this config file).
|
|
3
|
+
Example: ["../shared", "../common/specs"]`}),maxDepth:n.number().int().min(1).max(20).default(3).meta({description:`Maximum directory depth to scan when searching for .c4 files in include paths.
|
|
4
|
+
Prevents excessive scanning of deeply nested directories.
|
|
5
|
+
Default: 3`}),fileThreshold:n.number().int().min(1).max(1e4).default(30).meta({description:`Maximum number of files to load from include paths before warning.
|
|
6
|
+
Helps identify performance issues from accidentally including large directories.
|
|
7
|
+
Default: 30`})}).meta({id:`include-config`,description:`Configuration for including additional LikeC4 source files from other directories.
|
|
8
|
+
Example: { "paths": ["../shared", "../common/specs"], "maxDepth": 5, "fileThreshold": 50 }`}),v=n.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%`}),y=n.enum(i).meta({id:`ElementShape`}),b=n.enum(r).meta({id:`BorderStyle`}),x=n.enum(s).meta({id:`ElementSize`}),S=n.enum(a).meta({id:`IconPosition`}),C=n.enum(o).meta({id:`ArrowType`}),ee=n.enum([`dashed`,`solid`,`dotted`]).meta({id:`LineType`}),te=n.enum([`spline`,`ortho`]).meta({id:`EdgeRouting`}),w=n.enum(c).meta({id:`ThemeColorName`}),T=n.custom().refine(e=>typeof e==`string`,`Custom color name must be a string`).transform(e=>e).meta({id:`CustomColorName`}),E=w.or(T).transform(e=>e).meta({id:`ColorName`}),D=n.string().min(1,`Color value cannot be empty`).meta({id:`ColorLiteral`}),O=n.strictObject({fill:D.meta({description:`Background color`}),stroke:D.meta({description:`Stroke color (border, paths above background)`}),hiContrast:D.meta({description:`High contrast text color (title)`}),loContrast:D.meta({description:`Low contrast text color (description)`})}).meta({id:`ElementColorValues`}).transform(e=>e),k=n.strictObject({line:D.meta({description:`Line color`}),label:D.meta({description:`Label text color`}),labelBg:D.optional().default(`rgba(0, 0, 0, 0.5)`).meta({description:`Label background color`})}).meta({id:`RelationshipColorValues`}).transform(e=>e),A=n.strictObject({elements:O.or(D.transform(e=>l(e).elements)).meta({description:`Exact color value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values`}),relationships:k.or(D.transform(e=>l(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(D.transform(e=>l(e))).transform(e=>e).meta({id:`ThemeColorValues`,description:`Exact value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values`}),j=n.partialRecord(E,A).transform(e=>e),M=n.strictObject({width:n.number().min(50),height:n.number().min(50)}).meta({id:`Dimensions`,description:`Defines dimensions for theme size`}),N=n.partialRecord(x,M),P=n.strictObject({colors:j.optional().meta({description:`Override theme colors`}),sizes:N.optional().meta({description:`Override theme sizes`})}).meta({id:`ThemeCustomization`,description:`Customize theme colors and sizes`}).transform(({colors:e,sizes:t})=>u({colors:e?u(e):void 0,sizes:t?u(t):void 0})),F=n.strictObject({color:E.optional().meta({description:`Default color for groups
|
|
9
|
+
(must be a valid color name from the theme)`}),opacity:v.optional().meta({description:`Default opacity for groups`}),border:b.optional().meta({description:`Default border for groups`})}).meta({id:`GroupDefaultStyleValues`}),I=n.strictObject({color:E.optional().meta({description:`Default color for relationships
|
|
10
|
+
(must be a valid color name from the theme)`}),line:ee.optional().meta({description:`Default line style for relationships`}),arrow:C.optional().meta({description:`Default arrow style for relationships`})}).meta({id:`RelationshipDefaultStyleValues`,description:`Override default values for relationship style properties
|
|
11
|
+
These values will be used if such property is not defined`}),L=n.strictObject({routing:te.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.
|
|
12
|
+
Explicit settings in a view override these defaults.`}),R=n.strictObject({color:E.optional().meta({description:`Default color for elements
|
|
13
|
+
(must be a valid color name from the theme)`}),opacity:v.optional().meta({description:`Default opacity (0-100%) for elements when displayed as a group (like a container)`}),border:b.optional().meta({description:`Default border style for elements when displayed as a group (like a container)`}),size:x.optional().meta({description:`Default size for elements`}),shape:y.optional().meta({description:`Default shape for elements`}),iconPosition:S.optional().meta({description:`Default icon position for elements`}),group:F.optional().meta({description:`Override default values for group style properties
|
|
14
|
+
These values will be used if such property is not defined`}),relationship:I.optional().meta({description:`Override default values for relationship style properties
|
|
15
|
+
These values will be used if such property is not defined`}),view:L.optional().meta({description:`Default view settings.
|
|
16
|
+
Explicit settings in a view override these defaults.`})}).meta({id:`DefaultStyleValues`}),ne=n.union([n.string().min(1,`Custom CSS file path cannot be empty`),n.array(n.string().min(1,`Custom CSS file path cannot be empty`))]).meta({id:`CustomStylesheets`}),z=n.strictObject({paths:n.array(n.string()).readonly(),content:n.string()}),B=n.strictObject({theme:P.optional().meta({description:`Project theme customization`}),defaults:R.optional().meta({description:`Override default values for style properties
|
|
17
|
+
These values will be used if such property is not defined`}),customCss:n.union([ne,z]).optional().meta({description:`Custom CSS (or list of CSS files) to be included in the generated diagrams`})}).transform(({theme:e,defaults:t,customCss:n})=>u({defaults:normalizeDefaults(t),customCss:normalizeStylesheets(n),theme:e}));function normalizeDefaults(e){if(!e)return;let{relationship:t,group:n,view:r,...i}=e;return u({...i,relationship:t&&u(t),group:n&&u(n),view:r&&u(r)})}function normalizeStylesheets(e){if(!e)return;if(t(e))return e;let n=(Array.isArray(e)?e:[e]).filter(Boolean);if(n.length!==0)return{paths:n,content:``}}const V=[`png`,`jpg`,`dot`,`d2`,`mmd`,`puml`,`drawio`],H=n.strictObject({outDir:n.string().default(`.likec4`).meta({description:`Path to the directory where manual layouts will be stored,
|
|
18
|
+
relative to the folder containing the project config.
|
|
19
|
+
|
|
20
|
+
Defaults to '.likec4'.`})}).meta({id:`ManualLayoutsConfig`,description:`Configuration for manual layouts`}),U=n.enum(V),W=n.enum([`global`,`view`]),G=n.strictObject({defaultScope:W.default(`view`)}),K=n.strictObject({exportFormats:n.array(U).refine(e=>new Set(e).size===e.length,{message:`Export formats cannot contain duplicates`}).default([...V]).meta({description:`Webapp export formats enabled in the generated application.
|
|
21
|
+
Omit to enable all export formats. Use an empty array to disable webapp exports.`}),relationshipsBrowser:G.optional()}).meta({id:`WebappConfig`,description:`Configuration for the generated web application`}),q=n.union([n.strictObject({redirect:n.literal(!0)}),n.strictObject({include:n.array(n.string().nonempty().refine(e=>e!==`#`,{message:`selector cannot be "#"`})).nonempty(`include list cannot be empty`)}),n.strictObject({exclude:n.array(n.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.`}),J=n.object({name:n.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:n.union([n.string().min(1,`Extend path cannot be empty`),n.array(n.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:n.string().nonempty(`Project title cannot be empty if specified`).optional().meta({description:`A human readable title for the project`}),contactPerson:n.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:n.record(n.string(),n.any()).optional().meta({description:`Arbitrary metadata as key-value pairs for custom project information`}),styles:B.optional().meta({description:`Project styles customization`}),imageAliases:h.optional(),include:_.optional(),exclude:n.array(n.string()).optional().meta({description:`List of file patterns to exclude from the project, default is ["**/node_modules/**"]`}),manualLayouts:H.optional(),inferTechnologyFromIcon:n.boolean().optional().meta({description:`Automatically derive element technology from icon name when technology is not set explicitly.
|
|
22
|
+
Applies to aws:, azure:, gcp:, and tech: icons. Generic bootstrap: and md: icons are excluded.
|
|
23
|
+
Defaults to true.`}),implicitViews:n.boolean().optional().meta({description:`Auto-generate scoped views for elements without explicit views. Defaults to false.`}),landingPage:q.optional(),webapp:K.optional()}).meta({id:`LikeC4ProjectConfig`,description:`LikeC4 Project Configuration`}),Y=n.instanceof(Function),X=n.record(n.string(),Y),Z=J.extend({generators:X.optional()});function validateProjectConfig(e){let t=e.landingPage,r=null;if(t!=null){let e=q.safeParse(t);if(!e.success)throw Error(`Config validation failed:
|
|
24
|
+
`+n.prettifyError(e.error));r=e.data}let i=J.safeParse(e);if(!i.success)throw Error(`Config validation failed:
|
|
25
|
+
`+n.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=X.safeParse(o);if(!e.success)throw Error(`Config validation failed (generators):
|
|
26
|
+
`+n.prettifyError(e.error));return{...a,generators:e.data}}return a}function parseProjectConfigJSON(t){return validateProjectConfig(e.parse(t.trim()||`{}`))}const re={parse:parseProjectConfigJSON,validate:validateProjectConfig,normalizeInclude:e=>{let t=_.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{re as a,validateProjectConfig as c,B as d,A as f,X as i,V as l,isLikeC4JsonConfig as n,Z as o,isLikeC4NonJsonConfig as r,J as s,isLikeC4Config as t,P as u};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{i as e,r as t}from"./rolldown-runtime.mjs";import{
|
|
2
|
-
`);function toStringLF(e,t){return
|
|
1
|
+
import{i as e,r as t}from"./rolldown-runtime.mjs";import{S as n,v as r,x as i,y as a}from"./libs/langium.mjs";import{$ as ee,A as o,B as s,C as te,E as c,F as l,H as ne,M as re,N as u,P as ie,b as ae,d as oe,et as d,f as se,h as ce,j as f,k as le,l as ue,p,t as m,tt as de,u as fe,x as pe,y as me,z as h}from"./libs/remeda.mjs";import*as g from"zod/v4";import{BorderStyles as he,ElementShapes as ge,IconPositions as _e,RelationshipArrowTypes as ve,RelationshipLineTypes as ye,Sizes as be,Sizings as xe,ThemeColors as Se}from"@likec4/core/styles";import{exact as Ce}from"@likec4/core/types";import{hasProp as we,invariant as _,nonexhaustive as v}from"@likec4/core";import y,*as Te from"zod";import{invariant as Ee,nameFromFqn as b,parentFqn as De,sortParentsFirst as Oe}from"@likec4/core/utils";import{produce as ke}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 Ae=new i(`
|
|
2
|
+
`);function toStringLF(e,t){return n(e,t).replaceAll(`\r
|
|
3
3
|
`,`
|
|
4
|
-
`)}var
|
|
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};
|
|
4
|
+
`)}var je=/* @__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 a&&e.contents.some(e=>hasContent(e))}function hasContentOrNewLine(e){return typeof e==`string`?e.trimStart().length!==0:e instanceof i?!e.ifNotEmpty:e instanceof a&&e.contents.some(e=>hasContentOrNewLine(e))}function fresh(e){return{ctx:e??void 0,out:new a}}function materialize(...e){let t,n=2;if(e.length===1){let[n]=e;if(ie(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 _(c(n)||o(n),`defaultIndentation must be a string or a number`),toStringLF(t.out,n)}function executeOnCtx(e,t,...n){h(t)?(_(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 h(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 n=typeof e==`function`?e:t,wrapped=e=>{let t=n(e);return t instanceof a?{...e,out:t}:e};return typeof e==`string`&&n.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;f(r)||r===``||(_(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:Ae})]}).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=ce(e);if(c(t))return body(t+` {`,`}`);if(e.length===2&&c(e[0])&&c(e[1])){let[t,n]=e;return(...e)=>operation(function body({ctx:i,out:a}){let ee=indent(lines(...e))(fresh(i)).out;a.appendIf(hasContent(ee),r([t,ee,n]))})}let n=e;return body(`{`,`}`)(...n)}function inlineText(e){return operation(({ctx:t,out:n})=>{let r=e??t;if(f(r))return;_(c(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(!f(r))return _(c(r),`Value must be a string - got `+typeof r),r.includes(`
|
|
5
|
+
`)?multilineText(r)({ctx:r,out:n}):inlineText()({ctx:r,out:n})})}const Me=`'`.repeat(3);function markdown(e){return operation(function markdown(t){let n=e??t.ctx;if(!f(n))return _(c(n),`Value must be a string - got `+typeof n),multilineText(n,Me)(t)})}function markdownOrString$1(e){return operation(function markdownOrString(t){let n=e??t.ctx;if(!f(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,o=Array.isArray(i)?i:[i];_(de(o,1),`At least one operation is required`);let s;return s=o.length===1?o[0](fresh(t)).out.contents:se(eachOnFresh(t,o),pe(e=>e.out)),s=ee(s,hasContentOrNewLine),n.appendIf(s.length>0,r(s,a))})}function spaceBetween(...e){return join({operations:e,suffix:(e,t,n)=>!n&&hasContent(e)?` `:void 0})}function lines(...e){let t=ce(e);if(o(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=le(n)&&we(n,e)?n[e]:void 0;i!=null&&(t?t({ctx:i,out:r}):(_(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&&!ie(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(Ae)}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: ${Te.prettifyError(i.error)}`)}else _(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);u(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:n,out:r})=>{let i=Te.safeParse(e,n);if(i.success){let e=t({ctx:i.data,out:r,exec:execToOut(r)});return f(e)?{ctx:n,out:r}:e instanceof a?{ctx:n,out:e}:typeof e==`function`?{ctx:n,out:r,...e({ctx:n,out:r})}:we(e,`ctx`)&&we(e,`out`)?e:{ctx:n,out:r}}throw i.error};return zodParseOp.noparse=()=>({ctx:e,out:n})=>{let r=t({ctx:e,out:n,exec:execToOut(n)});return r instanceof a?{ctx:e,out:r}:typeof r==`function`?{ctx:e,out:n,...r({ctx:e,out:n})}:{ctx:e,out:n}},zodParseOp}}var Ne=/* @__PURE__ */ t({arrow:()=>O,border:()=>Fe,color:()=>M,customColor:()=>Ve,fqn:()=>C,icon:()=>E,iconPosition:()=>Ie,id:()=>x,kind:()=>w,line:()=>k,link:()=>Re,links:()=>ze,markdownOrString:()=>j,metadata:()=>We,metadataValue:()=>Ue,opacity:()=>Pe,props:()=>P,shape:()=>T,size:()=>D,sizing:()=>Le,style:()=>N,tag:()=>A,tags:()=>He,themeColor:()=>Be,viewId:()=>S});const x=g.string().regex(/^[a-zA-Z0-9_.-]+$/,`id must consist of alphanumeric characters, underscores or hyphens`),S=x.transform(e=>e),C=g.string().regex(/^[a-zA-Z0-9_.-]+$/,`FQN must consist of alphanumeric characters, dots, underscores or hyphens`).transform(e=>e),w=g.string().regex(/^[a-zA-Z0-9_-]+$/,`Kind must consist of alphanumeric characters, underscores or hyphens`).transform(e=>e),Pe=g.int().min(0,`Opacity must be between 0 and 100`).max(100,`Opacity must be between 0 and 100`),T=g.enum(ge),E=g.string().nonempty(`Icon cannot be empty`).transform(e=>e),Fe=g.enum(he),D=g.enum(be),Ie=g.enum(_e),Le=g.enum(xe),O=g.enum(ve),k=g.enum(ye),Re=g.union([g.string(),g.object({title:g.string().optional(),url:g.string()})]).transform(e=>Ce(typeof e==`string`?{url:e}:e)),ze=g.array(Re).readonly(),Be=g.enum(Se),Ve=g.string().nonempty(`Custom color name cannot be empty`).transform(e=>e),A=g.string().nonempty(`Tag cannot be empty`).transform(e=>e.startsWith(`#`)?e.slice(1):e),He=g.array(A).readonly(),j=g.union([g.string().transform(e=>({txt:e})),g.strictObject({md:g.string()}),g.strictObject({txt:g.string()})]),M=Be.or(Ve),N=g.object({shape:T,icon:E,iconColor:M,iconSize:D,iconPosition:Ie,color:M,border:Fe,opacity:Pe,size:D,padding:D,textSize:D,sizing:Le,multiple:g.boolean()}).partial().transform(p(u)),Ue=g.union([g.string(),g.boolean(),g.number()]),We=g.record(g.string(),Ue.or(g.array(Ue))),P=g.object({tags:He.nullish(),title:g.string().nullish(),summary:j.nullish(),description:j.nullish(),notation:g.string().nullish(),technology:g.string().nullish(),links:ze.nullish(),metadata:We.nullish()});var Ge=/* @__PURE__ */ t({directRelationExpr:()=>pt,elementKindExpr:()=>ot,elementTagExpr:()=>st,expression:()=>H,fqnExpr:()=>I,fqnExprAny:()=>ft,fqnExprCustom:()=>R,fqnExprOrWhere:()=>L,fqnRef:()=>Je,incomingRelationExpr:()=>mt,inoutRelationExpr:()=>gt,outgoingRelationExpr:()=>ht,refDeployment:()=>qe,refExpr:()=>at,refModel:()=>Ke,relationExpr:()=>z,relationExprAny:()=>vt,relationExprCustom:()=>V,relationExprOrWhere:()=>B,selector:()=>Ye,whereAnd:()=>tt,whereExpr:()=>yt,whereKind:()=>Ze,whereMetadata:()=>Qe,whereNot:()=>nt,whereOperator:()=>F,whereOr:()=>rt,whereParticipant:()=>et,whereTag:()=>Xe,wildcardExpr:()=>it});const Ke=g.strictObject({model:C,project:g.string().optional()}),qe=g.strictObject({deployment:C,element:C.nullish()}),Je=g.union([Ke,qe]),Ye=g.enum([`children`,`expanded`,`descendants`,`*`,`_`,`**`]).transform(e=>{switch(e){case`*`:return`children`;case`_`:return`expanded`;case`**`:return`descendants`;default:return e}});function equalOp(e){return g.xor([g.object({eq:e}),g.object({neq:e}),e.transform(e=>({eq:e}))])}const Xe=g.strictObject({tag:equalOp(A)}),Ze=g.strictObject({kind:equalOp(w)}),Qe=g.strictObject({metadata:g.strictObject({key:g.string(),value:equalOp(g.string()).optional()})}),$e=g.union([Xe,Ze,Qe]),et=g.strictObject({participant:g.enum([`source`,`target`]),operator:$e}),tt=g.object({get and(){return g.array(F)}}),nt=g.object({get not(){return F}}),rt=g.object({get or(){return g.array(F)}}),F=g.union([Xe,Ze,Qe,et,tt,rt,nt]),it=g.strictObject({wildcard:g.literal(!0)}),at=g.object({ref:Je,selector:Ye.nullish()}).transform(p(u)),ot=g.object({elementKind:w,isEqual:g.boolean()}),st=g.object({elementTag:A,isEqual:g.boolean()}),I=g.union([it,at,ot,st]),ct=g.strictObject({where:g.strictObject({expr:I,condition:F})}),L=g.union([I,ct]),lt=g.object({title:g.string(),description:j,technology:g.string(),notation:g.string(),notes:j,navigateTo:S,color:M}),ut=g.object({...lt.shape,shape:T,icon:E,iconColor:M,iconSize:D,iconPosition:Ie,border:Fe,opacity:Pe,multiple:g.boolean(),size:D,padding:D,textSize:D,sizing:Le}).partial(),dt=g.object({...lt.shape,line:k,head:O,tail:O}).partial(),R=g.strictObject({custom:ut.extend({expr:L})}),ft=g.union([L,R]),pt=g.strictObject({source:I,target:I,isBidirectional:g.boolean().optional()}),mt=g.object({incoming:I}),ht=g.object({outgoing:I}),gt=g.object({inout:I}),z=g.union([pt,mt,ht,gt]),_t=g.strictObject({where:g.strictObject({expr:z,condition:F})}),B=g.union([z,_t]),V=g.strictObject({customRelation:dt.extend({expr:B})}),vt=g.union([B,V]),yt=g.strictObject({where:g.object({expr:g.xor([I,z]),condition:F})}),H=g.union([I,R,z,V,yt]);var bt=/* @__PURE__ */ t({element:()=>Et,instance:()=>St,node:()=>xt,relationship:()=>Tt,schema:()=>At});const xt=P.extend({id:C,kind:w,style:N.optional(),shape:T.optional(),color:M.optional(),icon:E.optional()}).readonly().transform(e=>{let{shape:t,color:n,icon:r,...i}=e;return p(ke(i,e=>{e.style=i.style||{},t&&(e.style.shape=t),n&&(e.style.color=n),r&&(e.style.icon=r)}),u)}),St=P.extend({id:C,element:C,style:N.optional(),shape:T.optional(),color:M.optional(),icon:E.optional()}).readonly().transform(e=>{let{shape:t,color:n,icon:r,...i}=e;return p(ke(i,e=>{e.style=i.style||{},t&&(e.style.shape=t),n&&(e.style.color=n),r&&(e.style.icon=r)}),u)}),Ct=qe,wt=x.transform(e=>e),Tt=P.extend({id:wt.optional(),title:g.string().nullish(),source:Ct,target:Ct,isBidirectional:g.boolean().nullish(),navigateTo:S.nullish(),color:M.nullish(),kind:w.nullish(),line:k.nullish(),head:O.nullish(),tail:O.nullish()}).readonly().transform(p(u)),Et=g.union([xt,St]),Dt=g.record(C,Et),Ot=g.record(wt,Tt),kt=/* @__PURE__ */ e(e=>e.id??ue(8),`genRelationshipId`),At=g.object({elements:g.union([Dt,g.array(Et)]).transform(e=>h(e)?s(e,fe(`id`)):e).optional(),relations:g.union([Ot,g.array(Tt)]).transform(e=>h(e)?s(e,kt):e).optional()});var jt=/* @__PURE__ */ t({element:()=>Mt,elements:()=>It,relationship:()=>Ft,relationshipEndpoint:()=>Nt,relationshipId:()=>Pt,relationships:()=>Lt,schema:()=>Bt});const Mt=g.object({...P.shape,id:C,kind:w,style:N.optional(),shape:T.optional(),color:M.optional(),icon:E.optional()}).transform(e=>{let{shape:t,color:n,icon:r,...i}=e;return(t||n||r)&&(i=ke(i,e=>{e.style=i.style||{},t&&(e.style.shape=t),n&&(e.style.color=n),r&&(e.style.icon=r)})),p(i,u)}).readonly(),Nt=g.union([C,g.strictObject({model:C})]).transform(e=>typeof e==`string`?{model:e}:e),Pt=x.transform(e=>e),Ft=g.object({...P.shape,id:Pt.optional(),title:g.string().nullish(),source:Nt,target:Nt,isBidirectional:g.boolean().nullish(),navigateTo:S.nullish(),color:M.nullish(),kind:w.nullish(),line:k.nullish(),head:O.nullish(),tail:O.nullish()}).transform(p(u)).readonly(),It=g.record(C,Mt),Lt=g.record(Pt,Ft),genRelationshipId=e=>e.id??ue(8),Rt=g.union([It,g.array(Mt).transform(e=>s(e,fe(`id`)))]),zt=g.union([Lt,g.array(Ft).transform(e=>s(e,genRelationshipId))]),Bt=g.object({elements:Rt.optional(),relations:zt.optional()});var Vt=/* @__PURE__ */ t({element:()=>U,relationship:()=>Ht,schema:()=>Wt,tagSpec:()=>Ut});const U=g.object({tags:He.nullable(),title:g.string().nullable(),summary:j.nullable(),description:j.nullable(),technology:g.string().nullable(),notation:g.string().nullable(),links:ze.nullable(),style:N.nullable()}).partial().transform(p(u)),Ht=g.object({technology:g.string().nullable(),notation:g.string().nullable(),color:M.nullable(),line:k.nullable(),head:O.nullable(),tail:O.nullable()}).partial().transform(p(u)),Ut=g.object({color:M.nullable()}).partial().transform(p(u)),Wt=g.object({elements:g.record(w,U),deployments:g.record(w,U),relationships:g.record(w,Ht),tags:g.union([g.record(A,Ut),g.array(A).transform(e=>ae(e,e=>[e,{}]))])}).partial();var Gt=/* @__PURE__ */ t({anyView:()=>bn,autoLayoutDirection:()=>qt,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:()=>W,viewRuleExclude:()=>Xt,viewRuleGlobalPredicate:()=>G,viewRuleGlobalStyle:()=>$t,viewRuleGroup:()=>nn,viewRuleInclude:()=>Yt,viewRulePredicate:()=>Zt,viewRuleRank:()=>tn,viewRuleStyle:()=>Qt,views:()=>xn});const Kt={TB:`TopBottom`,BT:`BottomTop`,LR:`LeftRight`,RL:`RightLeft`},qt=y.enum([...te(Kt),...m(Kt)]).transform(e=>Kt[e]??e),W=y.object({direction:qt,nodeSep:y.number().nullish(),rankSep:y.number().nullish()}),Jt=y.strictObject({includeAncestors:y.boolean()}),Yt=y.strictObject({include:y.array(H)}),Xt=y.strictObject({exclude:y.array(H)}),Zt=y.xor([Yt,Xt]),Qt=y.object({targets:y.array(I),notation:y.string().optional(),style:N}).transform(e=>e),$t=y.object({styleId:y.string()}).transform(e=>e),G=y.object({predicateId:y.string()}).transform(e=>e),en=y.literal([`max`,`min`,`same`,`sink`,`source`]),tn=y.object({targets:y.array(I),rank:en}).transform(e=>e),nn=y.lazy(()=>y.object({groupRules:y.array(y.union([Zt,G,nn])),title:y.string().nullable(),color:M.optional(),border:Fe.optional(),opacity:Pe.optional(),multiple:y.boolean().optional(),size:D.nullish(),padding:D.nullish(),textSize:D.nullish()}).transform(p(u))),rn=y.union([Zt,W,Qt,$t,G,tn,nn]),an=y.object({id:S,title:y.string().nullish().default(null),description:j.nullish().default(null),order:y.number().int().nonnegative().optional(),routing:y.literal([`spline`,`ortho`]).optional(),tags:He.nullish(),links:ze.nullish()});function defineView(e){return y.object({...an.shape,...e})}const on=defineView({_type:y.literal(`element`),viewOf:C.nullish(),extends:S.nullish(),rules:y.array(rn).optional().default([])}),sn=y.union([Zt,W,Qt,$t,G,Jt,nn]),cn=defineView({_type:y.literal(`deployment`),rules:y.array(sn).optional().default([])}),ln=y.object({_type:y.never().exactOptional(),source:C,target:C,title:y.string().nullish().default(null),kind:y.string().nullish(),description:j.nullish(),technology:y.string().nullish(),notation:y.string().nullish(),notes:j.nullish(),color:M.optional(),line:k.optional(),head:O.optional(),tail:O.optional(),isBackward:y.boolean().optional(),navigateTo:S.nullish()}),K=y.object({title:y.string().optional(),get steps(){return y.array(gn).nonempty(`must have at least one step`)}}),un=y.object({_type:y.literal(`series`),steps:y.array(ln).nonempty(`must have at least one step`)}),dn=K.extend({_type:y.enum([`par`,`parallel`,`loop`,`opt`,`break`])}),fn=y.object({_type:y.literal(`try`),try:K,catch:K.optional(),finally:K.optional()}),pn=K.extend({_type:y.enum([`when`,`if`,`else`])}),mn=y.object({_type:y.literal(`alt`),title:y.string().optional(),branches:y.array(pn).nonempty(`alt block must have at least one branch`)}),hn=y.union([mn,un,dn,fn]),gn=y.union([ln,hn]),_n=y.union([Yt,G,Qt,$t,W]),vn=y.enum([`diagram`,`sequence`]),yn=defineView({_type:y.literal(`dynamic`),variant:vn.optional(),steps:y.array(gn).optional(),rules:y.array(_n).optional()}),bn=y.union([on,cn,yn]),xn=y.record(S,bn),Sn=g.object({...Bt.shape,views:xn,deployment:At,deployments:At,specification:Wt}).partial().transform(normalizeStyles);function normalizeStyles(e){let t=e.specification?.elements;return!l(t)&&!l(e.elements)&&(e={...e,elements:me(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 ke(e,t=>{for(let r of[`description`,`technology`,`tags`,`summary`]){let i=n[r],a=e[r];ne(i,a)&&delete t[r]}let i=e.style;if(i)for(let[e,n]of d(r))ne(i[e],n)&&delete t.style[e]})}const q={common:Ne,expr:Ge,specification:Vt,model:jt,deployment:bt,views:Gt,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})=>c(e)?text()({ctx:e,out:t}):print$1()({ctx:e,out:t}))}function metadataValue(){return oe(guard(re(h),printMetadataValue()),guard(h,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}:Ce({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(N)(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:()=>Un,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:v(t)}return e}const Tn=zodOp(Xe)(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}`;v(e)}),En=zodOp(Ze)(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}`;v(e)});function quoteMetadataValue(e){return e===`true`||e===`false`?e:`"${e}"`}const Dn=zodOp(Qe)(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)}`);v(r)}),On=zodOp(nt)(property(`not`,spaceBetween(print$1(`not (`),lazy(()=>Y.noparse()),print$1(`)`)))),kn=zodOp(et)(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}):v(t)}),An=zodOp(tt)(function whereAndOp({ctx:{and:e},out:t}){let n=pe(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(rt)(({ctx:{or:e},out:t})=>{let n=pe(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(F)(({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());v(e)}),X=zodOp(Je)(({ctx:e,out:t})=>(`model`in e?t.append(e.model):(t.append(e.deployment),e.element&&t.append(`.`,e.element)),t)),Z=zodOp(I)(({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;v(e)}),Mn=zodOp(R)(({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(L)(({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(ft)(({ctx:e,exec:t})=>`custom`in e?t(e,Mn.noparse()):t(e,Nn.noparse())),Fn=zodOp(pt)(merge(property(`source`,Z.noparse()),print$1(e=>e.isBidirectional?` <-> `:` -> `),property(`target`,Z.noparse()))),In=zodOp(mt)(merge(print$1(`-> `),property(`incoming`,Z.noparse()))),Ln=zodOp(ht)(merge(property(`outgoing`,Z.noparse()),print$1(` ->`))),Rn=zodOp(gt)(merge(print$1(`-> `),property(`inout`,Z.noparse()),print$1(` ->`))),zn=zodOp(z)(({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());v(e)}),Bn=zodOp(B)(({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(V)(({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(vt)(({ctx:e,exec:t})=>`customRelation`in e?t(e,Vn.noparse()):t(e,Bn.noparse())),Un=zodOp(H)(({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())}v(e)});var Wn=/* @__PURE__ */ t({deployment:()=>Jn,instance:()=>Kn,node:()=>node,relationship:()=>qn});function buildTree$1(e){let t=/* @__PURE__ */ new Map,n=[],r=se(e,Oe);for(let e of r){let r;r=`element`in e?e:{...e,children:[]},t.set(e.id,r);let i=De(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!l(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||!l(e.metadata)||hasStyleProps$1(e))}e(hasElementProps$1,`hasElementProps`);const Gn=zodOp(q.deployment.element)(lines(tagsProperty(),technologyProperty(),summaryProperty(),descriptionProperty(),linksProperty(),metadataProperty(),select(e=>hasStyleProps$1(e)?e.style:void 0,body(`style`)(J())))),Kn=zodOp(q.deployment.instance)(spaceBetween(when(e=>b(e.id)!==b(e.element),print$1(e=>b(e.id)),print$1(` =`)),print$1(`instanceOf`),printProperty(`element`),when(e=>!!e.title&&e.title!==b(e.id),property(`title`,inlineText())),when(e=>hasElementProps$1(e),body(Gn()))));function node(){return function nodeOp({ctx:e,out:t}){let n=e;if(`element`in n)return Kn()({ctx:n,out:t}),{ctx:e,out:t};Ee(`children`in n,`Node must have children property`);let r=n.children.length>0||hasElementProps$1(n),i=b(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,Gn()),...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||!l(e.metadata)||hasRelationStyle$1(e)||e.navigateTo)}e(hasRelationProps$1,`hasRelationProps`);const qn=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`))))))),Jn=zodOp(q.deployment.schema)(body(`deployment`)(lines(2)(select(e=>buildTree$1(e.elements?m(e.elements):[]).roots,lines(2)(foreach(node()))),select(e=>e.relations?m(e.relations):void 0,lines(2)(foreach(qn()))))));var Yn=/* @__PURE__ */ t({element:()=>Qn,model:()=>$n,relationship:()=>Zn});function buildTree(e){let t=/* @__PURE__ */ new Map,n=[],r=se(e,Oe);for(let e of r){let r={...e,children:[]};t.set(e.id,r);let i=De(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!l(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||!l(e.metadata)||hasStyleProps(e))}const Xn=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=b(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,Xn()),...(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||!l(e.metadata)||hasRelationStyle(e)||e.navigateTo)}const Zn=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`))))))),Qn=zodOp(q.model.element)(elementTree()),$n=zodOp(q.model.schema)(body(`model`)(lines(2)(select(e=>buildTree(e.elements?m(e.elements):[]).roots,lines(2)(foreach(elementTree()))),select(e=>e.relations?m(e.relations):void 0,lines(2)(foreach(Zn()))))));var er=/* @__PURE__ */ t({elementKind:()=>elementKind,relationshipKind:()=>nr,specification:()=>rr,tagSpecification:()=>tr});const tr=zodOp(g.tuple([g.string(),Ut]))(spaceBetween(print$1(`tag`),printProperty(`0`),property(`1`,property(`color`,body(spaceBetween(print$1(`color`),print$1())))))),elementKind=e=>zodOp(g.tuple([g.string(),U]))(spaceBetween(print$1(e),printProperty(`0`),property(`1`,body(tagsProperty(),titleProperty(),summaryProperty(),descriptionProperty(),technologyProperty(),notationProperty(),linksProperty(),property(`style`,body(`style`)(J())))))),nr=zodOp(g.tuple([g.string(),Ht]))(spaceBetween(print$1(`relationship`),printProperty(`0`),property(`1`,body(technologyProperty(),notationProperty(),colorProperty(),property(`line`),property(`head`),property(`tail`))))),rr=zodOp(Wt)(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(nr())),select(e=>e.tags&&d(e.tags),foreachNewLine(tr())))));var ir=/* @__PURE__ */ t({anyView:()=>kr,deploymentView:()=>gr,deploymentViewRule:()=>hr,deploymentViewRuleIncludeAncestors:()=>dr,dynamicView:()=>Or,dynamicViewRule:()=>Dr,elementView:()=>mr,elementViewRule:()=>pr,step:()=>Er,stepAny:()=>Tr,viewRuleAutoLayout:()=>$,viewRuleExclude:()=>or,viewRuleGlobalPredicate:()=>ur,viewRuleGlobalStyle:()=>lr,viewRuleGroup:()=>cr,viewRuleInclude:()=>ar,viewRulePredicate:()=>sr,viewRuleRank:()=>fr,viewRuleStyle:()=>Q,views:()=>Ar});const viewTitleProperty=()=>property(`title`,spaceBetween(print$1(`title`),inlineText())),viewPredicateOp=e=>operation(`viewPredicateOp`,({ctx:t,out:n})=>{let r=t;if(!de(r,1))return;let i=de(r,2),a=foreach(Un(),separateComma(i));executeOnCtx({ctx:t,out:n},merge(print$1(e),...i?[indent(a)]:[space(),a]))}),ar=zodOp(q.views.viewRuleInclude)(property(`include`,viewPredicateOp(`include`))),or=zodOp(q.views.viewRuleExclude)(property(`exclude`,viewPredicateOp(`exclude`))),sr=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`),_(n&&r,`Invalid view rule predicate`),t(n,viewPredicateOp(r))}),Q=zodOp(q.views.viewRuleStyle)(spaceBetween(print$1(`style`),property(`targets`,foreach(Un(),separateComma())),body(notationProperty(),property(`style`,J.noparse())))),cr=zodOp(q.views.viewRuleGroup)(spaceBetween(print$1(`group`),property(`title`,inlineText()),body(lines(colorProperty(),property(`border`,spaceBetween(print$1(`border`),print$1())),property(`opacity`,spaceBetween(print$1(`opacity`),print$1(e=>`${e}%`))),property(`multiple`),property(`size`),property(`padding`),property(`textSize`),property(`groupRules`,foreachNewLine(lazy(()=>pr.noparse()))))))),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(we(`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,Q.noparse());v(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(`groupRules`in e)return t(e,cr.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,Q.noparse());v(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:v(e)}}),Tr=zodOp(q.views.dynamicViewStep)(({ctx:e,exec:t})=>`source`in e&&`target`in e?t(e,vr.noparse()):(_(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,Q.noparse());if(`styleId`in e)return t(e,lr.noparse());if(`direction`in e)return t(e,$.noparse());v(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())}v(e)}),Ar=zodOp(q.views.views)(body(`views`)(select(e=>m(e),foreach(kr.noparse(),{separator:new a().appendNewLine().appendNewLine(),prefix:(e,t,n)=>t===0&&!n?Ae:void 0})))),jr=zodOp(q.likec4data)(lines(2)(property(`specification`,rr.noparse()),$n(),property(`deployment`,Jn.noparse()),property(`deployments`,Jn.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,Ae as Q,newline as R,je 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,er as d,dedent as et,$n as f,Un as g,Wn as h,jr as i,join as j,indent as k,ir as l,Jn as m,print as n,Or as o,Yn as p,space as q,printWithTabIndent as r,mr as s,generateLikeC4 as t,stripIndent as tt,rr as u,descriptionProperty as v,eachOnFresh as w,q as x,Cn as y,noop as z};
|
package/dist/chunks/index.d.mts
CHANGED
|
@@ -2,16 +2,12 @@ import { i as __name } from "./rolldown-runtime.mjs";
|
|
|
2
2
|
import z from "zod/v4";
|
|
3
3
|
import { LikeC4ProjectStylesConfig, LikeC4ProjectTheme, ProjectId, ThemeColorValues as ThemeColorValues$1, aux } from "@likec4/core/types";
|
|
4
4
|
import { DeploymentElementModel, DeploymentRelationModel, ElementModel, LikeC4Model, LikeC4ViewModel, RelationshipModel } from "@likec4/core/model";
|
|
5
|
-
//#region ../config/dist/chunks/index.d.mts
|
|
6
|
-
//#region src/schema.include.d.ts
|
|
7
5
|
declare const IncludeSchema: z.ZodObject<{
|
|
8
6
|
paths: z.ZodArray<z.ZodString>;
|
|
9
7
|
maxDepth: z.ZodDefault<z.ZodNumber>;
|
|
10
8
|
fileThreshold: z.ZodDefault<z.ZodNumber>;
|
|
11
9
|
}, z.core.$strict>;
|
|
12
10
|
type IncludeConfig = z.infer<typeof IncludeSchema>;
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/schema.d.ts
|
|
15
11
|
interface VscodeURI {
|
|
16
12
|
readonly scheme: string;
|
|
17
13
|
readonly authority: string;
|
|
@@ -153,7 +149,10 @@ declare const LikeC4ProjectJsonConfigSchema: z.ZodObject<{
|
|
|
153
149
|
}>>;
|
|
154
150
|
}, z.core.$strict>>;
|
|
155
151
|
}, z.core.$strict>>;
|
|
156
|
-
customCss: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]
|
|
152
|
+
customCss: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>, z.ZodObject<{
|
|
153
|
+
paths: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
154
|
+
content: z.ZodString;
|
|
155
|
+
}, z.core.$strict>]>>;
|
|
157
156
|
}, z.core.$strict>, z.ZodTransform<any, {
|
|
158
157
|
theme?: any;
|
|
159
158
|
defaults?: {
|
|
@@ -177,7 +176,10 @@ declare const LikeC4ProjectJsonConfigSchema: z.ZodObject<{
|
|
|
177
176
|
routing?: "spline" | "ortho" | undefined;
|
|
178
177
|
} | undefined;
|
|
179
178
|
} | undefined;
|
|
180
|
-
customCss?: string | string[] |
|
|
179
|
+
customCss?: string | string[] | {
|
|
180
|
+
paths: readonly string[];
|
|
181
|
+
content: string;
|
|
182
|
+
} | undefined;
|
|
181
183
|
}>>>;
|
|
182
184
|
imageAliases: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
183
185
|
include: z.ZodOptional<z.ZodObject<{
|
|
@@ -358,8 +360,6 @@ declare const LikeC4ProjectConfigOps: {
|
|
|
358
360
|
validate: typeof validateProjectConfig;
|
|
359
361
|
normalizeInclude: (include: z.input<typeof IncludeSchema> | undefined) => IncludeConfig;
|
|
360
362
|
};
|
|
361
|
-
//#endregion
|
|
362
|
-
//#region src/schema.theme.d.ts
|
|
363
363
|
declare const ThemeColorValuesSchema: z.ZodPipe<z.ZodUnion<[z.ZodPipe<z.ZodObject<{
|
|
364
364
|
elements: z.ZodUnion<[z.ZodPipe<z.ZodObject<{
|
|
365
365
|
fill: z.ZodString;
|
|
@@ -516,7 +516,10 @@ declare const LikeC4StylesConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
516
516
|
}>>;
|
|
517
517
|
}, z.core.$strict>>;
|
|
518
518
|
}, z.core.$strict>>;
|
|
519
|
-
customCss: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]
|
|
519
|
+
customCss: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>, z.ZodObject<{
|
|
520
|
+
paths: z.ZodReadonly<z.ZodArray<z.ZodString>>;
|
|
521
|
+
content: z.ZodString;
|
|
522
|
+
}, z.core.$strict>]>>;
|
|
520
523
|
}, z.core.$strict>, z.ZodTransform<any, {
|
|
521
524
|
theme?: any;
|
|
522
525
|
defaults?: {
|
|
@@ -540,12 +543,13 @@ declare const LikeC4StylesConfigSchema: z.ZodPipe<z.ZodObject<{
|
|
|
540
543
|
routing?: "spline" | "ortho" | undefined;
|
|
541
544
|
} | undefined;
|
|
542
545
|
} | undefined;
|
|
543
|
-
customCss?: string | string[] |
|
|
546
|
+
customCss?: string | string[] | {
|
|
547
|
+
paths: readonly string[];
|
|
548
|
+
content: string;
|
|
549
|
+
} | undefined;
|
|
544
550
|
}>>;
|
|
545
551
|
interface LikeC4StylesConfig extends z.infer<typeof LikeC4StylesConfigSchema> {}
|
|
546
552
|
type LikeC4StylesConfigInput = z.input<typeof LikeC4StylesConfigSchema>;
|
|
547
|
-
//#endregion
|
|
548
|
-
//#region src/filenames.d.ts
|
|
549
553
|
/** All known LikeC4 config filenames (JSON and non-JSON). */
|
|
550
554
|
declare const ConfigFilenames: readonly [".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"];
|
|
551
555
|
/** Returns true if the **basename** of the given path matches a known config filename. */
|
|
@@ -558,8 +562,6 @@ declare function isLikeC4NonJsonConfig(filename: string): boolean;
|
|
|
558
562
|
* Returns true if the **basename** of the given path matches a known LikeC4 config file (JSON or non-JSON).
|
|
559
563
|
*/
|
|
560
564
|
declare function isLikeC4Config(filename: string): boolean;
|
|
561
|
-
//#endregion
|
|
562
|
-
//#region src/define-config.d.ts
|
|
563
565
|
/**
|
|
564
566
|
* Defines LikeC4 Project, allows custom generators that can be executed using CLI:
|
|
565
567
|
*
|
|
@@ -666,5 +668,4 @@ declare function defineTheme<const S extends LikeC4ConfigThemeInput>(theme: S):
|
|
|
666
668
|
* })
|
|
667
669
|
*/
|
|
668
670
|
declare function defineStyle<const S extends LikeC4StylesConfigInput>(styles: S): LikeC4ProjectStylesConfig;
|
|
669
|
-
//#endregion
|
|
670
671
|
export { defineGenerators as C, isLikeC4Config as D, defineThemeColor as E, isLikeC4JsonConfig as O, defineConfig as S, defineTheme as T, RelationshipsBrowserConfigSchema as _, IncludeConfig as a, WebappConfigSchema as b, LikeC4ProjectConfigInput as c, LikeC4StylesConfig as d, LikeC4StylesConfigInput as f, RelationshipBrowserScopeSchema as g, RelationshipBrowserScope as h, GeneratorFnParams as i, isLikeC4NonJsonConfig as k, LikeC4ProjectConfigOps as l, LocateResult as m, GeneratorFn as n, LikeC4ConfigThemeInput as o, LikeC4StylesConfigSchema as p, GeneratorFnContext as r, LikeC4ProjectConfig as s, ConfigFilenames as t, LikeC4ProjectJsonConfig as u, ThemeColorValuesInput as v, defineStyle as w, WebappExportFormatSchema as x, WebappConfig as y };
|