likec4 1.55.0 → 1.56.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.
Files changed (263) hide show
  1. package/__app__/chunks/ColorSchemeToggle.mjs +1 -0
  2. package/__app__/chunks/DiagramActorProvider.mjs +10 -0
  3. package/__app__/chunks/Fallback.mjs +1 -0
  4. package/__app__/chunks/Header.mjs +13 -0
  5. package/__app__/chunks/IconRenderer.mjs +1 -0
  6. package/__app__/chunks/LikeC4Diagram.mjs +19 -0
  7. package/__app__/chunks/LikeC4ModelContext.mjs +1 -0
  8. package/__app__/chunks/LikeC4ModelContext2.mjs +1 -0
  9. package/__app__/chunks/LikeC4Styles.mjs +48 -0
  10. package/__app__/chunks/NavigationPanel.mjs +1 -0
  11. package/__app__/chunks/StaticLikeC4Diagram.mjs +1 -0
  12. package/__app__/chunks/ViewReact.mjs +1 -0
  13. package/__app__/chunks/__root.mjs +1 -0
  14. package/__app__/chunks/adhoc-editor.mjs +1 -0
  15. package/__app__/chunks/hooks.mjs +1 -0
  16. package/__app__/chunks/libs/@dagrejs/dagre.mjs +1 -0
  17. package/__app__/chunks/libs/@floating-ui/core.mjs +1 -0
  18. package/__app__/chunks/libs/@floating-ui/dom.mjs +1 -0
  19. package/__app__/chunks/libs/@floating-ui/react.mjs +1 -0
  20. package/__app__/chunks/libs/@mantine/core.mjs +41 -0
  21. package/__app__/chunks/libs/@mantine/hooks.mjs +1 -0
  22. package/__app__/chunks/libs/@nanostores/react.mjs +1 -0
  23. package/__app__/chunks/libs/@react-hookz/web.mjs +1 -0
  24. package/__app__/chunks/libs/@tabler/icons-react.mjs +15 -0
  25. package/__app__/chunks/libs/@tanstack/history.mjs +1 -0
  26. package/__app__/chunks/libs/@tanstack/react-router.mjs +3 -0
  27. package/__app__/chunks/libs/@tanstack/router-core.mjs +1 -0
  28. package/__app__/chunks/libs/@xstate/react.mjs +1 -0
  29. package/__app__/chunks/libs/@xstate/store.mjs +1 -0
  30. package/__app__/chunks/libs/@xyflow/react.mjs +7 -0
  31. package/__app__/chunks/libs/@zag-js/anatomy.mjs +1 -0
  32. package/__app__/chunks/libs/@zag-js/collection.mjs +1 -0
  33. package/__app__/chunks/libs/@zag-js/core.mjs +1 -0
  34. package/__app__/chunks/libs/@zag-js/react.mjs +1 -0
  35. package/__app__/chunks/libs/@zag-js/tree-view.mjs +1 -0
  36. package/__app__/chunks/libs/bezier-js.mjs +1 -0
  37. package/__app__/chunks/libs/d3-path.mjs +1 -0
  38. package/__app__/chunks/libs/d3-shape.mjs +1 -0
  39. package/__app__/chunks/libs/fast-equals.mjs +1 -0
  40. package/__app__/chunks/libs/framer-motion.mjs +9 -0
  41. package/__app__/chunks/libs/html-to-image.mjs +2 -0
  42. package/__app__/chunks/libs/motion-dom.mjs +1 -0
  43. package/__app__/chunks/libs/motion.mjs +1 -0
  44. package/__app__/chunks/libs/nanostores.mjs +1 -0
  45. package/__app__/chunks/libs/react-error-boundary.mjs +1 -0
  46. package/__app__/chunks/libs/react-resizable-panels.mjs +1 -0
  47. package/__app__/chunks/libs/remeda.mjs +1 -0
  48. package/__app__/chunks/libs/xstate.mjs +1 -0
  49. package/__app__/chunks/libs/zod.mjs +39 -0
  50. package/__app__/chunks/rolldown-runtime.mjs +1 -0
  51. package/__app__/chunks/safeCtx.mjs +1 -0
  52. package/__app__/chunks/searchParams.mjs +1 -0
  53. package/__app__/chunks/single-index.mjs +1 -0
  54. package/__app__/chunks/styled-system.mjs +1 -0
  55. package/__app__/chunks/styles.css.mjs +1 -0
  56. package/__app__/chunks/useLikeC4Project.mjs +1 -0
  57. package/__app__/chunks/useUpdateEffect.mjs +1 -0
  58. package/__app__/codegen/react.mjs +11 -0
  59. package/__app__/codegen/webcomponent.mjs +790 -0
  60. package/__app__/src/fonts.css +1 -1
  61. package/__app__/src/main.mjs +1 -0
  62. package/__app__/src/pages/AdHocViewEditor.mjs +1 -0
  63. package/__app__/src/pages/EmbedPage.mjs +1 -0
  64. package/__app__/src/pages/ExportPage.mjs +1 -0
  65. package/__app__/src/pages/ProjectsOverview.mjs +1 -0
  66. package/__app__/src/pages/ViewAsD2.mjs +1 -0
  67. package/__app__/src/pages/ViewAsDot.mjs +1 -0
  68. package/__app__/src/pages/ViewAsMmd.mjs +1 -0
  69. package/__app__/src/pages/ViewAsPuml.mjs +1 -0
  70. package/__app__/src/pages/ViewEditor.mjs +1 -0
  71. package/__app__/src/pages/ViewReact.mjs +1 -0
  72. package/__app__/src/routeTree.gen.mjs +1 -0
  73. package/__app__/src/routes/__root.mjs +1 -0
  74. package/__app__/src/routes/_single/adhoc.mjs +1 -0
  75. package/__app__/src/routes/_single/embed._viewId.mjs +1 -0
  76. package/__app__/src/routes/_single/export._viewId.mjs +1 -0
  77. package/__app__/src/routes/_single/route.mjs +1 -0
  78. package/__app__/src/routes/_single/single-index.mjs +1 -0
  79. package/__app__/src/routes/_single/view._viewId.d2.mjs +1 -0
  80. package/__app__/src/routes/_single/view._viewId.dot.mjs +1 -0
  81. package/__app__/src/routes/_single/view._viewId.index.mjs +1 -0
  82. package/__app__/src/routes/_single/view._viewId.mjs +1 -0
  83. package/__app__/src/routes/_single/view._viewId.mmd.mjs +1 -0
  84. package/__app__/src/routes/_single/view._viewId.puml.mjs +1 -0
  85. package/__app__/src/routes/_single/webcomponent._.mjs +33 -0
  86. package/__app__/src/routes/index.mjs +1 -0
  87. package/__app__/src/routes/project._projectId/-components.mjs +1 -0
  88. package/__app__/src/routes/project._projectId/adhoc.mjs +1 -0
  89. package/__app__/src/routes/project._projectId/embed._viewId.mjs +1 -0
  90. package/__app__/src/routes/project._projectId/export._viewId.mjs +1 -0
  91. package/__app__/src/routes/project._projectId/index.mjs +1 -0
  92. package/__app__/src/routes/project._projectId/route.mjs +1 -0
  93. package/__app__/src/routes/project._projectId/view._viewId.d2.mjs +1 -0
  94. package/__app__/src/routes/project._projectId/view._viewId.dot.mjs +1 -0
  95. package/__app__/src/routes/project._projectId/view._viewId.index.mjs +1 -0
  96. package/__app__/src/routes/project._projectId/view._viewId.mjs +1 -0
  97. package/__app__/src/routes/project._projectId/view._viewId.mmd.mjs +1 -0
  98. package/__app__/src/routes/project._projectId/view._viewId.puml.mjs +1 -0
  99. package/__app__/src/routes/projects.mjs +1 -0
  100. package/__app__/src/style.css +1 -1
  101. package/dist/chunks/filenames.mjs +17 -0
  102. package/dist/{_chunks → chunks}/index.d.mts +2 -1
  103. package/dist/{_chunks → chunks}/index2.d.mts +71 -12
  104. package/dist/chunks/libs/@chevrotain/gast.mjs +1 -0
  105. package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +9 -0
  106. package/dist/chunks/libs/@chevrotain/utils.mjs +1 -0
  107. package/dist/chunks/libs/@hono/mcp.mjs +45 -0
  108. package/dist/chunks/libs/@hono/node-server.mjs +1 -0
  109. package/dist/{_chunks → chunks}/libs/@logtape/logtape.d.mts +2 -0
  110. package/dist/chunks/libs/@logtape/logtape.mjs +4 -0
  111. package/dist/chunks/libs/@lume/kiwi.mjs +1 -0
  112. package/dist/chunks/libs/@modelcontextprotocol/sdk.mjs +12 -0
  113. package/dist/chunks/libs/ajv.mjs +1 -0
  114. package/dist/chunks/libs/ansi-align.mjs +2 -0
  115. package/dist/chunks/libs/ansi-regex.mjs +1 -0
  116. package/dist/chunks/libs/ansi-styles.mjs +1 -0
  117. package/dist/chunks/libs/atomically.mjs +1 -0
  118. package/dist/chunks/libs/birpc.mjs +1 -0
  119. package/dist/chunks/libs/boxen.mjs +22 -0
  120. package/dist/chunks/libs/chevrotain-allstar.mjs +2 -0
  121. package/dist/chunks/libs/chevrotain.mjs +58 -0
  122. package/dist/chunks/libs/conf.mjs +1 -0
  123. package/dist/chunks/libs/defu.mjs +1 -0
  124. package/dist/chunks/libs/destr.mjs +1 -0
  125. package/dist/chunks/libs/eventemitter3.mjs +1 -0
  126. package/dist/chunks/libs/find-up-simple.mjs +1 -0
  127. package/dist/chunks/libs/get-port.mjs +1 -0
  128. package/dist/chunks/libs/hono.mjs +1 -0
  129. package/dist/chunks/libs/is-docker.mjs +1 -0
  130. package/dist/chunks/libs/is-error-instance.mjs +1 -0
  131. package/dist/chunks/libs/is-inside-container.mjs +1 -0
  132. package/dist/chunks/libs/is-plain-obj.mjs +1 -0
  133. package/dist/chunks/libs/isexe.mjs +1 -0
  134. package/dist/chunks/libs/json5.mjs +14 -0
  135. package/dist/chunks/libs/khroma.mjs +1 -0
  136. package/dist/chunks/libs/ky.mjs +3 -0
  137. package/dist/{_chunks → chunks}/libs/langium.d.mts +4 -4
  138. package/dist/chunks/libs/langium.mjs +32 -0
  139. package/dist/chunks/libs/merge-error-cause.mjs +2 -0
  140. package/dist/chunks/libs/p-debounce.mjs +1 -0
  141. package/dist/chunks/libs/p-limit.mjs +1 -0
  142. package/dist/chunks/libs/p-queue.mjs +1 -0
  143. package/dist/chunks/libs/p-timeout.mjs +1 -0
  144. package/dist/chunks/libs/package-manager-detector.mjs +1 -0
  145. package/dist/chunks/libs/package-up.mjs +1 -0
  146. package/dist/chunks/libs/pako.mjs +1 -0
  147. package/dist/chunks/libs/parse-ms.mjs +1 -0
  148. package/dist/chunks/libs/pathe.mjs +1 -0
  149. package/dist/chunks/libs/picomatch.mjs +1 -0
  150. package/dist/chunks/libs/pretty-ms.mjs +1 -0
  151. package/dist/chunks/libs/remeda.mjs +1 -0
  152. package/dist/chunks/libs/safe-stringify.mjs +1 -0
  153. package/dist/chunks/libs/strip-indent.mjs +1 -0
  154. package/dist/chunks/libs/tinyrainbow.mjs +1 -0
  155. package/dist/{_chunks → chunks}/libs/ts-graphviz.d.mts +2 -0
  156. package/dist/chunks/libs/ts-graphviz.mjs +4 -0
  157. package/dist/chunks/libs/ufo.mjs +1 -0
  158. package/dist/chunks/libs/unstorage.mjs +1 -0
  159. package/dist/chunks/libs/which.mjs +1 -0
  160. package/dist/chunks/libs/word-wrap.mjs +12 -0
  161. package/dist/{_chunks → chunks}/libs/zod.d.mts +2 -0
  162. package/dist/chunks/node.mjs +76 -0
  163. package/dist/chunks/plugin.mjs +400 -0
  164. package/dist/chunks/rolldown-runtime.mjs +1 -0
  165. package/dist/chunks/sequence-view.mjs +1 -0
  166. package/dist/cli/index.mjs +262 -123
  167. package/dist/config/index.d.mts +1 -2
  168. package/dist/config/index.mjs +1 -1
  169. package/dist/index.d.mts +4 -8
  170. package/dist/index.mjs +1 -1
  171. package/dist/model/index.d.mts +2 -1
  172. package/dist/model/index.mjs +1 -1
  173. package/dist/vite-plugin/index.d.mts +38 -8
  174. package/dist/vite-plugin/index.mjs +1 -1
  175. package/dist/{_chunks → vite-plugin/internal/chunks}/libs/@nanostores/react.d.mts +2 -56
  176. package/dist/vite-plugin/internal/chunks/libs/@nanostores/react.mjs +1 -0
  177. package/dist/vite-plugin/internal/chunks/libs/birpc.mjs +1 -0
  178. package/dist/vite-plugin/internal/chunks/libs/fast-equals.mjs +1 -0
  179. package/dist/vite-plugin/internal/chunks/libs/nanostores.d.mts +59 -0
  180. package/dist/vite-plugin/internal/chunks/libs/nanostores.mjs +1 -0
  181. package/dist/vite-plugin/internal/chunks/libs/remeda.mjs +1 -0
  182. package/dist/vite-plugin/internal/chunks/rolldown-runtime.mjs +1 -0
  183. package/dist/vite-plugin/{internal.d.mts → internal/index.d.mts} +12 -3
  184. package/dist/vite-plugin/internal/index.mjs +1 -0
  185. package/package.json +37 -57
  186. package/react/index.d.mts +2 -28
  187. package/react/index.mjs +50520 -53827
  188. package/vite-plugin/internal/package.json +2 -2
  189. package/vite-plugin-modules.d.ts +14 -0
  190. package/__app__/react/likec4.tsx +0 -25
  191. package/__app__/src/ProjectsOverview.js +0 -16
  192. package/__app__/src/const.js +0 -19
  193. package/__app__/src/likec4.js +0 -21225
  194. package/__app__/src/main.js +0 -7
  195. package/__app__/src/routes/index.js +0 -324
  196. package/__app__/src/routes/projects.js +0 -189
  197. package/__app__/src/routes/single.js +0 -1924
  198. package/__app__/src/vendors.js +0 -52672
  199. package/__app__/src/webcomponent.js +0 -68
  200. package/dist/THIRD-PARTY-LICENSES.md +0 -1609
  201. package/dist/_chunks/libs/@chevrotain/cst-dts-gen.mjs +0 -30
  202. package/dist/_chunks/libs/@chevrotain/regexp-to-ast.mjs +0 -9
  203. package/dist/_chunks/libs/@chevrotain/types.d.mts +0 -1
  204. package/dist/_chunks/libs/@chevrotain/utils.mjs +0 -1
  205. package/dist/_chunks/libs/@hono/mcp.mjs +0 -45
  206. package/dist/_chunks/libs/@hono/node-server.mjs +0 -1
  207. package/dist/_chunks/libs/@logtape/logtape.mjs +0 -4
  208. package/dist/_chunks/libs/@lume/kiwi.mjs +0 -1
  209. package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +0 -12
  210. package/dist/_chunks/libs/@nanostores/react.mjs +0 -1
  211. package/dist/_chunks/libs/ajv.mjs +0 -1
  212. package/dist/_chunks/libs/ansi-align.mjs +0 -2
  213. package/dist/_chunks/libs/ansi-regex.mjs +0 -1
  214. package/dist/_chunks/libs/ansi-styles.mjs +0 -1
  215. package/dist/_chunks/libs/atomically.mjs +0 -1
  216. package/dist/_chunks/libs/birpc.mjs +0 -1
  217. package/dist/_chunks/libs/boxen.mjs +0 -22
  218. package/dist/_chunks/libs/chevrotain-allstar.mjs +0 -2
  219. package/dist/_chunks/libs/chevrotain.mjs +0 -58
  220. package/dist/_chunks/libs/conf.mjs +0 -1
  221. package/dist/_chunks/libs/defu.mjs +0 -1
  222. package/dist/_chunks/libs/destr.mjs +0 -1
  223. package/dist/_chunks/libs/esm-env.mjs +0 -1
  224. package/dist/_chunks/libs/eventemitter3.mjs +0 -1
  225. package/dist/_chunks/libs/fast-equals.mjs +0 -1
  226. package/dist/_chunks/libs/find-up-simple.mjs +0 -1
  227. package/dist/_chunks/libs/get-port.mjs +0 -1
  228. package/dist/_chunks/libs/is-docker.mjs +0 -1
  229. package/dist/_chunks/libs/is-error-instance.mjs +0 -1
  230. package/dist/_chunks/libs/is-inside-container.mjs +0 -1
  231. package/dist/_chunks/libs/is-plain-obj.mjs +0 -1
  232. package/dist/_chunks/libs/isexe.mjs +0 -1
  233. package/dist/_chunks/libs/json5.mjs +0 -14
  234. package/dist/_chunks/libs/khroma.mjs +0 -1
  235. package/dist/_chunks/libs/ky.mjs +0 -3
  236. package/dist/_chunks/libs/langium.mjs +0 -33
  237. package/dist/_chunks/libs/merge-error-cause.mjs +0 -2
  238. package/dist/_chunks/libs/p-limit.mjs +0 -1
  239. package/dist/_chunks/libs/p-queue.mjs +0 -1
  240. package/dist/_chunks/libs/p-timeout.mjs +0 -1
  241. package/dist/_chunks/libs/package-manager-detector.mjs +0 -1
  242. package/dist/_chunks/libs/package-up.mjs +0 -1
  243. package/dist/_chunks/libs/pako.mjs +0 -1
  244. package/dist/_chunks/libs/parse-ms.mjs +0 -1
  245. package/dist/_chunks/libs/pathe.mjs +0 -1
  246. package/dist/_chunks/libs/picomatch.mjs +0 -1
  247. package/dist/_chunks/libs/pretty-ms.mjs +0 -1
  248. package/dist/_chunks/libs/remeda.mjs +0 -2
  249. package/dist/_chunks/libs/safe-stringify.mjs +0 -1
  250. package/dist/_chunks/libs/strip-indent.mjs +0 -1
  251. package/dist/_chunks/libs/tinyrainbow.mjs +0 -1
  252. package/dist/_chunks/libs/ts-graphviz.mjs +0 -4
  253. package/dist/_chunks/libs/ufo.mjs +0 -1
  254. package/dist/_chunks/libs/unstorage.mjs +0 -1
  255. package/dist/_chunks/libs/which.mjs +0 -1
  256. package/dist/_chunks/libs/word-wrap.mjs +0 -12
  257. package/dist/_chunks/node.mjs +0 -76
  258. package/dist/_chunks/rolldown-runtime.mjs +0 -1
  259. package/dist/_chunks/sequence.mjs +0 -1
  260. package/dist/_chunks/src.mjs +0 -17
  261. package/dist/_chunks/src2.mjs +0 -499
  262. package/dist/vite-plugin/internal.mjs +0 -1
  263. /package/dist/{_chunks → chunks}/libs/vscode-languageserver.mjs +0 -0
@@ -1 +0,0 @@
1
- import{createRequire as e}from"node:module";var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(e&&(t=e(e=0)),t),c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),l=(e,t)=>{let r={};for(var i in e)n(r,i,{get:e[i],enumerable:!0});return t||n(r,Symbol.toStringTag,{value:`Module`}),r},u=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},d=(e,t,n)=>(u(e,t,`default`),n&&u(n,t,`default`)),f=(e,r,i)=>(i=e==null?{}:t(a(e)),u(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)),p=e=>o.call(e,`module.exports`)?e[`module.exports`]:u(n({},`__esModule`,{value:!0}),e),m=e(import.meta.url);export{m as a,d as i,s as n,p as o,l as r,f as s,c as t};
@@ -1 +0,0 @@
1
- import{L as e,R as t,U as n,Y as r,Z as i,_ as a,b as o,p as s,t as c,y as l}from"./libs/remeda.mjs";import{a as u,i as d,n as f,r as p,t as m}from"./libs/@lume/kiwi.mjs";import{getParallelStepsPrefix as h,isStepEdgeId as g}from"@likec4/core/types";import{DefaultMap as _,Stack as v,invariant as y,isAncestor as b,nonNullable as x,nonexhaustive as S}from"@likec4/core/utils";function C(e){return i(e,t(e=>e.parallelPrefix??void 0),a((e,t)=>e.reduce((e,t)=>(e.min.column=Math.min(e.min.column,t.from.column,t.to.column),e.min.row=Math.min(e.min.row,t.from.row,t.to.row),e.max.column=Math.max(e.max.column,t.from.column,t.to.column),e.max.row=Math.max(e.max.row,t.from.row,t.to.row),e),{parallelPrefix:t,min:{column:1/0,row:1/0},max:{column:-1/0,row:-1/0}})),c())}function w(e,t){if(e.length===0||e.length===t.length)return[];let n=e=>x(t.find(t=>t.id===e));function r(e){let t=e.parent?n(e.parent):null;return t?[t,...r(t)]:[]}let i=new v,a=[];return e.forEach(e=>{let t=r(e);if(t.length===0){i.clear();return}let n=v.from(t),o,s;for(;o=i.peek()?.node,s=n.peek(),!(!s||!o);){if(b(s.id,o.id)||s.id===o.id){n.pop();continue}if(!b(o.id,s.id)){i.pop();continue}break}for(;s=n.pop();){let t={node:s,from:e,to:e,nested:[]},n=i.peek();n?n.nested.push(t):a.push(t),i.push(t)}i.forEach(t=>t.to=e)}),a}var T=class{#e=new m;#t;#n=[];#r;#i;#a;#o=[];#s=[];constructor({actors:e,steps:t,compounds:n}){this.#a=this.newVar(30),this.#r=this.newVar(0),this.#i=this.newVar(0),this.#t=this.addActors(e);for(let e of n){let t=this.addCompound(e),n=t[0];this.constraint(n.y1,`==`,0,d.strong),this.put(this.#i).after(n.bottom),this.put(this.#a).after(n.y2),this.#n.push(...t)}for(let e of t)this.addStep(e);for(let e of C(t))this.addParallelRect(e);let r=this.#t[0];this.constraint(r.offset.left,`==`,0,d.strong);let i=this.#t.reduce((e,t)=>(this.put(t.x).after(e.right,60),this.put(t.offset.left,d.strong).after(e.offset.right,32),this.constraint(t.centerY,`==`,e.centerY,d.strong),this.put(this.#a).after(t.offset.bottom),t));if(this.put(this.#r).after(i.offset.right),this.put(this.#i).after(o(this.#o)?.bottom??this.#a),n.length>0)for(let e of this.#n){let t=e.from.column,n=e.to.column,r=Math.max(e.from.maxRow,e.to.maxRow);for(let e=t+1;e<n;e++){let t=this.actorBox(e);r=Math.max(r,t.maxRow)}let i=x(this.#o[r],`row ${r} not found`);this.put(e.bottom).after(i.bottom,16),this.put(this.#i).after(e.bottom)}this.#e.updateVariables()}getParallelBoxes(){return this.#s.map(({parallelPrefix:e,x1:t,y1:n,x2:r,y2:i})=>({parallelPrefix:e,x:t.value(),y:n.value(),width:r.value()-t.value(),height:i.value()-n.value()}))}getActorBox(e){let t=this.actorBox(e);return{x:t.x.value(),y:t.y.value(),width:t.width,height:t.height}}getCompoundBoxes(){return this.#n.map(({node:e,depth:t,x1:n,y1:r,x2:i,bottom:a})=>({node:e,depth:t,x:n.value(),y:r.value(),width:i.value()-n.value(),height:a.value()-r.value()}))}getPortCenter(e,t){let{column:n,row:r}=t===`source`?e.from:e.to,i=this.actorBox(n).centerX,{y:a}=x(this.#o[r]);return{cx:i.value(),cy:a.value()+32/2+e.offset,height:t===`source`?40:24}}getViewBounds(){return{x:0,y:0,width:this.#r.value(),height:this.#i.value()}}actorBox(e){if(typeof e!=`number`){let t=typeof e==`string`?e:e.id;e=this.#t.findIndex(e=>e.actor.id===t),y(e>=0,`actor ${t} not found`)}return x(this.#t[e],`actor at index ${e} not found`)}addActors(e){let t=0;return l(e,(e,n)=>{let r=this.newVar(t);t+=e.width+60;let i=this.newVar(0),a={column:n,actor:e,x:r,y:i,centerX:r.plus(Math.round(e.width/2)),centerY:i.plus(Math.round(e.height/2)),width:e.width,height:e.height,right:r.plus(e.width),bottom:i.plus(e.height),minRow:1/0,maxRow:-1/0},o=this.newVar(0),s=this.newVar(0),c=this.newVar(0),l=this.newVar(0);return this.put(o,d.strong).before(i),this.put(s,d.strong).before(r),this.put(c,d.strong).after(a.right),this.put(l,d.strong).after(a.bottom),{...a,offset:{top:o,left:s,right:c,bottom:l}}})}addStep(e){let t=this.actorBox(e.source),n=this.actorBox(e.target);t.minRow=Math.min(t.minRow,e.from.row),t.maxRow=Math.max(t.maxRow,e.from.row),n.minRow=Math.min(n.minRow,e.to.row),n.maxRow=Math.max(n.maxRow,e.to.row);let[r,i]=t.column<=n.column?[t,n]:[n,t],a=(e.label?.width??100)+50;r===i?this.constraint(r.centerX.plus(a),`<=`,r.offset.right):this.constraint(r.centerX.plus(a),`<=`,i.centerX);let o=e.label?.height?e.label.height+50+32/2:80;return o=Math.max(o,80)+e.offset,this.ensureRow(e.from.row,o),e.isSelfLoop&&this.ensureRow(e.to.row,80),this}addParallelRect({parallelPrefix:e,min:t,max:n}){let r=this.actorBox(t.column).centerX.minus(30),i=this.actorBox(n.column).centerX.plus(30),a=this.#o[t.row],o=this.#o[n.row];y(a&&o,`parallel box invalid minRow=${t.row} maxRow=${n.row}`);let s=this.newVar(0);this.put(s).before(a.y,40);let c=o.bottom,l=t.row>0&&this.#o[t.row-1];l&&this.put(s).after(l.bottom,16);let u=n.row<this.#o.length-1&&this.#o[n.row+1];u&&this.put(c).before(u.y,16),this.#s.push({parallelPrefix:e,x1:r,y1:s,x2:i,y2:c})}addCompound(e){let t=[],n=e.nested.flatMap(e=>{let n=this.addCompound(e);return t.push(n[0]),n}),r=Math.max(...n.map(e=>e.depth+1),0),i=this.actorBox(e.from),a=this.actorBox(e.to),o=i.offset.left.minus(32);i.offset.left=o;let c=a.offset.right.plus(32);a.offset.right=c;let l=this.newVar(0),u=s(t),d,f;switch(!0){case!!u:d=u.y1.minus(40),f=u.y2.plus(32),this.put(l).after(u.bottom,32);break;case a===i:d=this.newVar(0),f=this.newVar(0),this.put(d).before(i.offset.top,52),this.put(f).after(i.offset.bottom,32),this.put(l).after(f);break;case t.length>0:d=this.newVar(0),f=this.newVar(0);for(let e of t)this.put(d).before(e.y1,32),this.put(f).after(e.y2,32),this.put(l).after(e.bottom,32);break;default:d=this.newVar(0),f=this.newVar(0);for(var p=i.column;p<=a.column;p++){let e=this.actorBox(p).offset;this.put(d).before(e.top,52),this.put(f).after(e.bottom,32)}this.put(l).after(f);break}for(var p=i.column;p<=a.column;p++){let e=this.actorBox(p).offset;e.top=d,e.bottom=f}return[{node:e.node,depth:r,from:i,to:a,x1:o,y1:d,x2:c,y2:f,bottom:l},...n]}ensureRow(e,t){for(;e>=this.#o.length;){let e=this.#o.length>0&&this.#o[this.#o.length-1]?.bottom||this.#a.plus(30),t=this.newVar(this.#o.length*80);this.put(t).after(e);let n=this.newVar(80);this.require(n,`>=`,80),this.#o.push({y:t,height:n,bottom:t.plus(n),lastHeight:80})}let n=x(this.#o[e]);t>n.lastHeight&&(n.lastHeight=t,this.require(n.height,`>=`,t),this.#e.suggestValue(n.height,t))}newVar(e){let t=new u;return this.#e.addEditVariable(t,d.weak),typeof e==`number`&&(this.#e.suggestValue(t,e),this.constraint(t,`>=`,0,d.strong)),t}require(e,t,n=void 0){switch(this.constraint(e,t,n,d.required),t){case`<=`:case`>=`:this.constraint(e,`==`,n,d.weak);break;case`<= 0`:case`>= 0`:this.constraint(e,`== 0`,void 0,d.weak);break}}constraint(e,t,n=void 0,r=d.medium){let i;switch(t){case`==`:i=p.Eq;break;case`>=`:i=p.Ge;break;case`<=`:i=p.Le;break;case`== 0`:i=p.Eq,n=0;break;case`>= 0`:i=p.Ge,n=0;break;case`<= 0`:i=p.Le,n=0;break;default:S(t)}this.#e.addConstraint(new f(e,i,n??0,r))}put(e,t=d.required){let n=t===d.required?d.medium:d.weak;return{before:(r,i)=>{i&&(r=r.minus(i)),this.constraint(e,`<=`,r,t),this.constraint(e,`==`,r,n)},after:(r,i)=>{i&&(r=r.plus(i)),this.constraint(e,`>=`,r,t),this.constraint(e,`==`,r,n)}}}};function E(t){let o=new Set,s=e=>x(t.nodes.find(t=>t.id===e)),u=[];for(let e of t.edges.filter(e=>g(e.id))){let t=s(e.source),n=s(e.target);if(t.children.length||n.children.length){console.error(`Sequence view does not support nested actors`);continue}o.add(t),o.add(n),u.push({edge:e,source:t,target:n})}let d=t.nodes.filter(e=>o.has(e));y(r(d,1),`actors array must not be empty`);let f=new _(()=>[]),p=[],m=0;for(let{edge:e,source:t,target:n}of u){let r=p.at(-1),i=d.indexOf(t),a=d.indexOf(n),o=t===n,s=i>a,c=h(e.id),l=!1;r&&r.target==t&&r.parallelPrefix===c&&(l=r.isSelfLoop!==o||r.isBack===s),l||m++;let u={id:e.id,from:{column:i,row:m},to:{column:a,row:o?++m:m},edge:e,isSelfLoop:o,isBack:s,parallelPrefix:c,offset:l?(r?.offset??0)+22:0,source:t,target:n,label:e.labelBBox?{height:e.labelBBox.height+8+(e.navigateTo?20:0),width:e.labelBBox.width+16,text:e.label}:null};p.push(u),f.get(t).push({step:u,row:m,type:`source`,position:s&&!o?`left`:`right`}),f.get(n).push({step:u,row:m,type:`target`,position:s||o?`right`:`left`})}let v=new T({actors:d,steps:p,compounds:w(d,t.nodes)}),b=v.getViewBounds(),S=i(v.getCompoundBoxes(),l(({node:e,...t})=>({...t,id:e.id,origin:e.id})),e(`id`),a((e,t)=>r(e,2)?l(e,(e,n)=>({...e,id:`${t}-${n+1}`})):e),c(),n());return{actors:d.map(e=>D({actor:e,ports:f.get(e),layout:v})),compounds:S,steps:l(p,e=>({id:e.id,sourceHandle:e.id+`_source`,targetHandle:e.id+`_target`,...e.label&&{labelBBox:{width:e.label.width,height:e.label.height}}})),parallelAreas:v.getParallelBoxes(),bounds:b}}function D({actor:e,ports:t,layout:n}){let{x:r,y:i,width:a,height:o}=n.getActorBox(e);return{id:e.id,x:r,y:i,width:a,height:o,ports:t.map(e=>{let t=n.getPortCenter(e.step,e.type);return{id:`${e.step.id}_${e.type}`,cx:t.cx-r,cy:t.cy-i,height:t.height,type:e.type,position:e.position}})}}export{E as t};
@@ -1,17 +0,0 @@
1
- import{t as e}from"./libs/json5.mjs";import{J as t}from"./libs/@hono/mcp.mjs";import{BorderStyles as n,ElementShapes as r,IconPositions as i,RelationshipArrowTypes as a,Sizes as o,ThemeColors as s,computeColorValues as c}from"@likec4/core/styles";import{exact as l}from"@likec4/core/types";const u=/^@[A-Za-z0-9_-]*$/,ee=/^(?!\/|[A-Za-z]:[\\\/])(?!.*:\/\/).*$/,d=t.string().min(1,`Image alias key cannot be empty`).regex(u,`Image alias key must match /^@\\w+$/`),te=t.string().min(1,`Image alias value cannot be empty`).regex(ee,`Image alias value must be a relative path (no leading slash or protocol)`),ne=t.record(d,te).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).`}),f=t.string().min(1,`Include path cannot be empty`).regex(/^(?!\/|[A-Za-z]:[\\\/])(?!.*:\/\/).*$/,`Include path must be a relative path (no leading slash, drive letter, or protocol)`),p=t.strictObject({paths:t.array(f).meta({description:[`Additional relative directory paths to include LikeC4 source files from, searched recursively.`,`Paths are relative to the project folder (the folder containing this config file).`,`Example: ["../shared", "../common/specs"]`].join(`
2
- `)}),maxDepth:t.number().int().min(1).max(20).default(3).meta({description:[`Maximum directory depth to scan when searching for .c4 files in include paths.`,`Prevents excessive scanning of deeply nested directories.`,`Default: 3`].join(`
3
- `)}),fileThreshold:t.number().int().min(1).max(1e4).default(30).meta({description:[`Maximum number of files to load from include paths before warning.`,`Helps identify performance issues from accidentally including large directories.`,`Default: 30`].join(`
4
- `)})}).meta({id:`include-config`,description:[`Configuration for including additional LikeC4 source files from other directories.`,`Example: { "paths": ["../shared", "../common/specs"], "maxDepth": 5, "fileThreshold": 50 }`].join(`
5
- `)}),m=t.int().min(0,`Opacity must be between 0 and 100`).max(100,`Opacity must be between 0 and 100`).meta({id:`Opacity`,description:`Opacity 0-100%`}),h=t.enum(r).meta({id:`ElementShape`}),g=t.enum(n).meta({id:`BorderStyle`}),_=t.enum(o).meta({id:`ElementSize`}),v=t.enum(i).meta({id:`IconPosition`}),y=t.enum(a).meta({id:`ArrowType`}),b=t.enum([`dashed`,`solid`,`dotted`]).meta({id:`LineType`}),re=t.enum(s).meta({id:`ThemeColorName`}),ie=t.custom().refine(e=>typeof e==`string`,`Custom color name must be a string`).transform(e=>e).meta({id:`CustomColorName`}),x=re.or(ie).transform(e=>e).meta({id:`ColorName`}),S=t.string().min(1,`Color value cannot be empty`).meta({id:`ColorLiteral`}),C=t.strictObject({fill:S.meta({description:`Background color`}),stroke:S.meta({description:`Stroke color (border, paths above background)`}),hiContrast:S.meta({description:`High contrast text color (title)`}),loContrast:S.meta({description:`Low contrast text color (description)`})}).meta({id:`ElementColorValues`}).transform(e=>e),w=t.strictObject({line:S.meta({description:`Line color`}),label:S.meta({description:`Label text color`}),labelBg:S.optional().default(`rgba(0, 0, 0, 0.5)`).meta({description:`Label background color`})}).meta({id:`RelationshipColorValues`}).transform(e=>e),T=t.strictObject({elements:C.or(S.transform(e=>c(e).elements)).meta({description:`Exact color value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values`}),relationships:w.or(S.transform(e=>c(e).relationships)).meta({description:`Exact color value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values`})}).transform(e=>e).meta({id:`StrictThemeColorValues`,description:`Exact color value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color value`}).or(S.transform(e=>c(e))).transform(e=>e).meta({id:`ThemeColorValues`,description:`Exact value (hex, rgb, rgba, hsl, hsla ...) or break down of specific color values`}),E=t.partialRecord(x,T).transform(e=>e),D=t.strictObject({width:t.number().min(50),height:t.number().min(50)}).meta({id:`Dimensions`,description:`Defines dimensions for theme size`}),O=t.partialRecord(_,D),k=t.strictObject({colors:E.optional().meta({description:`Override theme colors`}),sizes:O.optional().meta({description:`Override theme sizes`})}).meta({id:`ThemeCustomization`,description:`Customize theme colors and sizes`}).transform(({colors:e,sizes:t})=>l({colors:e?l(e):void 0,sizes:t?l(t):void 0})),A=t.strictObject({color:x.optional().meta({description:`Default color for groups
6
- (must be a valid color name from the theme)`}),opacity:m.optional().meta({description:`Default opacity for groups`}),border:g.optional().meta({description:`Default border for groups`})}).meta({id:`GroupDefaultStyleValues`}),j=t.strictObject({color:x.optional().meta({description:`Default color for relationships
7
- (must be a valid color name from the theme)`}),line:b.optional().meta({description:`Default line style for relationships`}),arrow:y.optional().meta({description:`Default arrow style for relationships`})}).meta({id:`RelationshipDefaultStyleValues`,description:`Override default values for relationship style properties
8
- These values will be used if such property is not defined`}),M=t.strictObject({color:x.optional().meta({description:`Default color for elements
9
- (must be a valid color name from the theme)`}),opacity:m.optional().meta({description:`Default opacity (0-100%) for elements when displayed as a group (like a container)`}),border:g.optional().meta({description:`Default border style for elements when displayed as a group (like a container)`}),size:_.optional().meta({description:`Default size for elements`}),shape:h.optional().meta({description:`Default shape for elements`}),iconPosition:v.optional().meta({description:`Default icon position for elements`}),group:A.optional().meta({description:`Override default values for group style properties
10
- These values will be used if such property is not defined`}),relationship:j.optional().meta({description:`Override default values for relationship style properties
11
- These values will be used if such property is not defined`})}).meta({id:`DefaultStyleValues`}),N=t.union([t.string().min(1,`Custom CSS file path cannot be empty`),t.array(t.string().min(1,`Custom CSS file path cannot be empty`))]).meta({id:`CustomStylesheets`}),P=t.strictObject({theme:k.optional().meta({description:`Project theme customization`}),defaults:M.optional().meta({description:`Override default values for style properties
12
- These values will be used if such property is not defined`}),customCss:N.optional().meta({description:`Custom CSS (or list of CSS files) to be included in the generated diagrams`})}).transform(({theme:e,defaults:t,customCss:n})=>l({defaults:F(t),customCss:I(n),theme:e}));function F(e){if(!e)return;let{relationship:t,group:n,...r}=e;return l({...r,relationship:t&&l(t),group:n&&l(n)})}function I(e){if(!e)return;let t=(Array.isArray(e)?e:[e]).filter(Boolean);if(t.length!==0)return{paths:t,content:``}}const L=t.strictObject({outDir:t.string().default(`.likec4`).meta({description:[`Path to the directory where manual layouts will be stored,`,`relative to the folder containing the project config. `,``,`Defaults to '.likec4'.`].join(`
13
- `)})}).meta({id:`ManualLayoutsConfig`,description:`Configuration for manual layouts`}),R=t.union([t.strictObject({redirect:t.literal(!0)}),t.strictObject({include:t.array(t.string().nonempty().refine(e=>e!==`#`,{message:`selector cannot be "#"`})).nonempty(`include list cannot be empty`)}),t.strictObject({exclude:t.array(t.string().nonempty().refine(e=>e!==`#`,{message:`selector cannot be "#"`})).nonempty(`exclude list cannot be empty`)})]).meta({id:`LandingPageConfig`,description:`Configure the landing page. Use redirect to go to the index view, or include/exclude to filter the view grid.`}),z=t.object({name:t.string().nonempty(`Project name cannot be empty`).refine(e=>e!==`default`,{abort:!0,error:`Project name cannot be "default"`}).refine(e=>!e.includes(`.`)&&!e.includes(`@`)&&!e.includes(`#`),{abort:!0,error:`Project name cannot contain ".", "@" or "#", try to use A-z, 0-9, _ and -`}).meta({description:`Project name, must be unique in the workspace`}),extends:t.union([t.string().min(1,`Extend path cannot be empty`),t.array(t.string().min(1,`Extend path cannot be empty`)).min(1,`Extend list cannot be empty`)]).optional().meta({description:`Extend styles from other config files`}),title:t.string().nonempty(`Project title cannot be empty if specified`).optional().meta({description:`A human readable title for the project`}),contactPerson:t.string().nonempty(`Contact person cannot be empty if specified`).optional().meta({description:`A person who has been involved in creating or maintaining this project`}),metadata:t.record(t.string(),t.any()).optional().meta({description:`Arbitrary metadata as key-value pairs for custom project information`}),styles:P.optional().meta({description:`Project styles customization`}),imageAliases:ne.optional(),include:p.optional(),exclude:t.array(t.string()).optional().meta({description:`List of file patterns to exclude from the project, default is ["**/node_modules/**"]`}),manualLayouts:L.optional(),inferTechnologyFromIcon:t.boolean().optional().meta({description:[`Automatically derive element technology from icon name when technology is not set explicitly.`,`Applies to aws:, azure:, gcp:, and tech: icons. Bootstrap icons are excluded.`,`Defaults to true.`].join(`
14
- `)}),implicitViews:t.boolean().optional().meta({description:`Auto-generate scoped views for elements without explicit views. Defaults to false.`}),landingPage:R.optional()}).meta({id:`LikeC4ProjectConfig`,description:`LikeC4 Project Configuration`}),B=t.instanceof(Function),V=t.record(t.string(),B),H=z.extend({generators:V.optional()});function U(e){let n=e.landingPage,r=null;if(n!=null){let e=R.safeParse(n);if(!e.success)throw Error(`Config validation failed:
15
- `+t.prettifyError(e.error));r=e.data}let i=z.safeParse(e);if(!i.success)throw Error(`Config validation failed:
16
- `+t.prettifyError(i.error));let a=i.data;r!==null&&(a={...a,landingPage:r});let o=e.generators;if(typeof o==`object`&&o&&!Array.isArray(o)){let e=V.safeParse(o);if(!e.success)throw Error(`Config validation failed (generators):
17
- `+t.prettifyError(e.error));return{...a,generators:e.data}}return a}function W(t){return U(e.parse(t.trim()||`{}`))}const G={parse:W,validate:U,normalizeInclude:e=>{let t=p.safeParse(e);return t.success?t.data:{paths:[],maxDepth:3,fileThreshold:30}}};function K(e){let t=e.length;for(;t>0&&(e[t-1]===`/`||e[t-1]===`\\`);)t--;return e.slice(0,t)}function q(e){return e.split(`/`).flatMap(e=>e.split(`\\`))}function J(e){let t=K(e),n=q(t);return n[n.length-1]||t}const Y=[`.likec4rc`,`.likec4.config.json`,`likec4.config.json`],X=[`likec4.config.js`,`likec4.config.cjs`,`likec4.config.mjs`,`likec4.config.ts`,`likec4.config.cts`,`likec4.config.mts`];[...Y,...X];function Z(e){return Y.includes(J(e))}function Q(e){return X.includes(J(e))}function ae(e){return Z(e)||Q(e)}function oe(e){return H.parse(e)}function se(e){return V.parse(e)}function ce(e){return T.parse(e)}function le(e){return k.parse(e)}function $(e){return P.parse(e)}export{ce as a,Q as c,U as d,le as i,G as l,se as n,ae as o,$ as r,Z as s,oe as t,z as u};
@@ -1,499 +0,0 @@
1
- import{t as e}from"./libs/birpc.mjs";import{C as t,D as n,I as r,W as i,Z as a,k as o,o as s,q as c,r as l,t as u,v as d,x as f,y as p}from"./libs/remeda.mjs";import{c as m,f as h,n as g}from"./node.mjs";import{a as _,i as v,n as y,r as b,t as x}from"./libs/langium.mjs";import{t as S}from"./libs/tinyrainbow.mjs";import{o as C}from"./libs/ufo.mjs";import{t as w}from"./libs/json5.mjs";import{t as T}from"./libs/pako.mjs";import"@likec4/core/model";import{LikeC4Styles as E,invariant as D,isNonEmptyArray as ee,nonexhaustive as O}from"@likec4/core";import{RichText as k,flattenMarkdownOrString as A}from"@likec4/core/types";import{compareNatural as j,invariant as M,sortNaturalByFqn as N}from"@likec4/core/utils";const P=m.getChild(`vite`);async function te({logger:e,likec4:t},n){e.info([S.green(`adhoc:view`),S.dim(`project:`),n.projectId].join(` `));let r=await t.views.adhocView(n.predicates,n.projectId);return e.info([S.green(`adhoc:view`),`✅`].join(` `)),r}function F(e){let t=e.split(`
2
- `),n=/^\s+at\s+/,r=t.findIndex(e=>n.test(e));return r===-1&&(r=1),{message:t.slice(0,r).join(`
3
- `),stack:t.slice(r).join(`
4
- `)}}function ne(e,{name:t,error:n}){e.hot.send({type:`error`,err:{...F(n),name:t??`LikeC4PluginError`,plugin:`vite-plugin-likec4`}})}async function re({logger:e,likec4:t},n){e.info([S.green(`view:onChange`),S.dim(`project`),n.projectId,S.dim(`view`),n.viewId,S.dim(`change`),n.change.op].join(` `));let r=await t.editor.applyChange(n);if(!r.success){e.error(`Failed to apply view change:\n${r.error}`);let t=Error(r.error);throw t.stack=r.error,t}e.info([S.green(`view:onChange`),`✅`].join(` `))}function ie(t){let n=null,r=t.server;e({updateView:e=>re(t,e),calcAdhocView:e=>te(t,e)},{on:e=>r.hot.on(`likec4:rpc`,e),post:e=>r.hot.send(`likec4:rpc`,e),onFunctionError:(e,i)=>{t.logger.error(`RPC error in ${i}`,{error:e});let a=e.stack??e.message;try{n!==a&&(n=a,ne(r,{name:e.name,error:a}))}catch(e){t.logger.error(`Failed to send error to client`,{error:e})}}})}const ae=e=>e.charAt(0).toLocaleUpperCase()+e.slice(1),oe=e=>e.split(`.`).map(ae).join(``),se=e=>oe(e.parent?e.id.slice(e.parent.length+1):e.id),ce=({autoLayout:e})=>{switch(e.direction){case`TB`:return`down`;case`BT`:return`up`;case`LR`:return`right`;case`RL`:return`left`}},le=({shape:e})=>{switch(e){case`queue`:case`cylinder`:case`rectangle`:case`document`:return e;case`person`:return`c4-person`;case`storage`:return`stored_data`;case`component`:case`bucket`:case`mobile`:case`browser`:return`rectangle`}};function ue(e){let t=e.$view,{nodes:r,edges:i}=t,a=new Map,o=(e,t)=>{let n=se(e),i=(t?t+`.`:``)+n;a.set(e.id,i);let s=JSON.stringify(e.title),c=le(e);return new y().append(n,`: {`,b).indent({indentedChildren:t=>t.append(`label: `,s,b).appendIf(c!==`rectangle`,`shape: `,c,b).appendIf(e.children.length>0,b,x(r.filter(t=>t.parent===e.id),e=>o(e,i))),indentation:2}).append(`}`,b)},s=e=>new y().append(a.get(e.source),` -> `,a.get(e.target)).append(t=>e.label&&t.append(`: `,JSON.stringify(e.label)));return v(new y().append(`direction: `,ce(t),b,b).append(x(r.filter(e=>n(e.parent)),e=>o(e),{appendNewLineIfNotEmpty:!0})).appendIf(i.length>0,b,x(i,e=>s(e),{appendNewLineIfNotEmpty:!0})))}const de=`data:page/id,likec4-`,fe=1e4,pe=`#dae8fc`,me=`#2563eb`,I=`#1e40af`,he=`diagrams.drawio`,ge=`#74c0fc`;function L(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`).replaceAll(`"`,`&quot;`).replaceAll(`'`,`&apos;`)}function _e(e){let t=e.split(/\r?\n/),n={},r={},i={},a={},o=!1,s=0;for(;s<t.length;){let e=t[s];if(e==null){s+=1;continue}if(e.trim()===`// <likec4.layout.drawio>`){o=!0,s+=1;let e=[];for(;s<t.length&&t[s]?.trim()!==`// </likec4.layout.drawio>`;){let n=t[s]?.trim();n?.startsWith(`// `)&&e.push(n.slice(3)),s+=1}if(e.length>0)try{let t=e.join(`
5
- `);n=JSON.parse(t)}catch{}s+=1;continue}if(e.trim()===`// <likec4.strokeColor.vertices>`){for(o=!0,s+=1;s<t.length&&t[s]?.trim()!==`// </likec4.strokeColor.vertices>`;){let e=t[s]?.trim();if(e?.startsWith(`// `)&&e.includes(`=`)){let t=e.slice(3).trim(),n=t.indexOf(`=`);if(n>0){let e=t.slice(0,n).trim(),i=t.slice(n+1).trim();e&&i&&(r[e]=i)}}s+=1}s+=1;continue}if(e.trim()===`// <likec4.strokeWidth.vertices>`){for(o=!0,s+=1;s<t.length&&t[s]?.trim()!==`// </likec4.strokeWidth.vertices>`;){let e=t[s]?.trim();if(e?.startsWith(`// `)&&e.includes(`=`)){let t=e.slice(3).trim(),n=t.indexOf(`=`);if(n>0){let e=t.slice(0,n).trim(),r=t.slice(n+1).trim();e&&r!==``&&(i[e]=r)}}s+=1}s+=1;continue}if(e.trim()===`// <likec4.edge.waypoints>`){for(o=!0,s+=1;s<t.length&&t[s]?.trim()!==`// </likec4.edge.waypoints>`;){let e=t[s]?.trim();if(e?.startsWith(`// `)){let t=e.slice(3).trim(),n=t.indexOf(` `);if(n>0){let e=t.slice(0,n).trim(),r=t.slice(n+1).trim();if(e&&r)try{let t=JSON.parse(r);Array.isArray(t)&&(a[e]=t)}catch{}}}s+=1}s+=1;continue}s+=1}return o?{layoutByView:n,strokeColorByFqn:r,strokeWidthByFqn:i,edgeWaypoints:a}:null}function ve(e){let t=encodeURIComponent(e),n=new TextEncoder().encode(t);return ye(T.deflateRaw(n))}function ye(e){if(typeof Buffer<`u`)return Buffer.from(e).toString(`base64`);let t=``;for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}const R={getNotes(e){return e.notes},getSummary(e){return e.summary},getTags(e){return e.tags},getNavigateTo(e){return e.navigateTo},getIcon(e){return e.icon},getLinks(e){return e.links},getNotation(e){return e.notation},getCustomData(e){return e.customData},getChildren(e){return e.children}},z={getKind(e){return e.kind},getNotation(e){return e.notation},getLinks(e){return e.links},getMetadata(e){return e.metadata},getCustomData(e){return e.customData}};function be(e){return e.$styles??E.DEFAULT}function B(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`).replaceAll(`"`,`&quot;`)}function V(e){if(e==null)return``;let t=typeof e;if(t===`string`){let t=e;return t.trim()===``?``:t}return t===`number`||t===`boolean`?String(e):``}function xe(e,t){return e&&t!==`none`||t===`dashed`?`dashed=1;`:``}function Se(e,t){return e===`none`?`0`:t||e?`1`:``}function Ce(e,t){return{fill:e?.fill??pe,stroke:t,font:e?.font??t}}function we(e,t,n){return t&&t in e.theme.colors?t:n}function H(e,t,n){let r=be(e),i=we(r,t??n,n);try{return r.colors(i)}catch{return E.DEFAULT.colors(n)}}function Te(e){let t=`shape=rectangle;rounded=1;arcSize=12;`;switch(e){case`person`:return`shape=actor;`;case`rectangle`:case`browser`:case`mobile`:case`bucket`:return t;case`cylinder`:case`queue`:case`storage`:return`shape=cylinder3;whiteSpace=wrap;boundedLbl=1;backgroundOutline=1;size=15;`;case`document`:return`shape=document;whiteSpace=wrap;html=1;boundedLbl=1;`;case`component`:return`shape=component;`;default:return t}}function Ee(e,t){let n=H(e,t,`primary`).elements;return{fill:String(n.fill??pe),stroke:String(n.stroke??me),font:String(n.hiContrast??n.stroke??I)}}function De(e,t){let n=H(e,t??`gray`,`gray`);return String(n.relationships?.line??I)}function Oe(e,t){let n=H(e,t??`gray`,`gray`).relationships;return{font:String(n?.label??n?.line??I),background:String(n?.labelBg??`#ffffff`)}}function ke(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,i=t.x+t.width/2,a=t.y+t.height/2,o=i-n,s=a-r,c=Math.abs(o)>=Math.abs(s);return{exitX:c?o>=0?1:0:.5,exitY:c?.5:s>=0?1:0,entryX:c?o>=0?0:1:.5,entryY:c?.5:s>=0?0:1}}function Ae(e){if(Array.isArray(e)&&e.length>=2&&typeof e[0]==`number`&&typeof e[1]==`number`)return[[e[0],e[1]]];let t=e;return typeof t.x==`number`&&typeof t.y==`number`?[[t.x,t.y]]:[]}function je(e,t,n,r,i,a){return n?``:t===``?`<div style="box-sizing:border-box;width:100%;min-height:100%;display:flex;align-items:center;justify-content:center;text-align:center;color:${r};font-family:${i};"><b style="font-size:${a}px;">${B(e)}</b></div>`:`<div style="box-sizing:border-box;width:100%;min-height:100%;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;color:${r};font-family:${i};"><b style="font-size:${a}px;">${B(e)}</b><br/><span style="font-weight:normal;font-size:${a}px;">${B(t)}</span></div>`}function U(e,t,n){n!=null&&n!==``&&e.push(`${t}=${encodeURIComponent(n)}`)}function Me(e,t,n){n!=null&&e.push(`${t}=${n}`)}function Ne(e){return e===``?``:`link=${encodeURIComponent(`${de}${e}`)};`}function W(e){let t=e==null?null:A(e);return t!=null&&!o(t)?t.trim():``}function Pe(e){return!Array.isArray(e)||e.length===0?``:encodeURIComponent(JSON.stringify(e.map(e=>({url:e.url,title:e.title}))))}function Fe(e){return typeof e!=`object`||!e||Array.isArray(e)||Object.keys(e).length===0?``:encodeURIComponent(JSON.stringify(e))}const Ie=/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/;function Le(e){let t=[];return U(t,`likec4Description`,e.desc),U(t,`likec4Technology`,e.tech),U(t,`likec4Notes`,e.notes),U(t,`likec4Tags`,e.tagList),U(t,`likec4NavigateTo`,e.navTo),U(t,`likec4Icon`,e.iconName),U(t,`likec4Summary`,e.summaryStr),e.linksJson!==``&&t.push(`likec4Links=${e.linksJson}`),U(t,`likec4Border`,e.borderVal),Me(t,`likec4Opacity`,e.containerOpacityNum),U(t,`likec4StrokeWidth`,e.strokeWidth),e.colorNameForRoundtrip!==``&&t.push(`likec4ColorName=${e.colorNameForRoundtrip}`),U(t,`likec4Size`,e.nodeStyle?.size),U(t,`likec4Padding`,e.nodeStyle?.padding),U(t,`likec4TextSize`,e.nodeStyle?.textSize),U(t,`likec4IconPosition`,e.nodeStyle?.iconPosition),e.strokeHex&&Ie.test(e.strokeHex)&&U(t,`likec4StrokeColor`,e.strokeHex),U(t,`likec4Notation`,e.nodeNotation??void 0),t.length>0?t.join(`;`)+`;`:``}function Re(e,t,n,r){if(r?.profile!==`leanix`)return``;let i=[`bridgeManaged=true`,`likec4Id=${encodeURIComponent(e)}`,`likec4Kind=${encodeURIComponent(t)}`,`likec4ViewId=${encodeURIComponent(n)}`];r.projectId!=null&&r.projectId!==``&&i.push(`likec4ProjectId=${encodeURIComponent(r.projectId)}`);let a=r.leanixFactSheetTypeByKind?.[t];return a!=null&&a!==``&&i.push(`leanixFactSheetType=${encodeURIComponent(a)}`),i.join(`;`)+`;`}function ze(e,t){return t?.profile===`leanix`?`bridgeManaged=true;likec4RelationId=${encodeURIComponent(e)};`:``}function Be(e){return!e||typeof e!=`object`||Array.isArray(e)||Object.keys(e).length===0?``:`
6
- <mxUserObject>`+Object.entries(e).map(([e,t])=>{let n=typeof t==`string`?t:t==null?``:String(t);return`<data key="${L(e)}">${L(n)}</data>`}).join(``)+`</mxUserObject>`}function Ve(e){let t=[];return U(t,`likec4Description`,e.edgeDesc),U(t,`likec4Technology`,e.edgeTech),U(t,`likec4Notes`,e.edgeNotes),U(t,`likec4NavigateTo`,e.edgeNavTo),U(t,`likec4RelationshipKind`,e.edgeKind??void 0),U(t,`likec4Notation`,e.edgeNotation??void 0),e.edgeLinksJson!==``&&t.push(`likec4Links=${e.edgeLinksJson}`),e.edgeMetadataJson!==``&&t.push(`likec4Metadata=${e.edgeMetadataJson}`),t.length>0?t.join(`;`)+`;`:``}function He(e){return e.label?L(e.label):``}function Ue(e,t){let n=t?.[`${e.source}|${e.target}|${e.id}`]??t?.[`${e.source}|${e.target}`],r=Array.isArray(n)?n.flatMap(Ae):[];return r.length>0?`<mxGeometry relative="1" as="geometry">${`<Array as="points">`+r.map(([e,t])=>`<mxPoint x="${Math.round(e)}" y="${Math.round(t)}"/>`).join(``)+`</Array>`}</mxGeometry>`:`<mxGeometry relative="1" as="geometry" />`}function We(e,t,n,r,i){let{bboxes:a,fontFamily:o}=t,s=a.get(e.source),c=a.get(e.target),l=s&&c?ke(s,c):{exitX:1,exitY:.5,entryX:0,entryY:.5},u=`exitX=${l.exitX};exitY=${l.exitY};entryX=${l.entryX};entryY=${l.entryY};`,d=De(n,e.color),f=e.line===`dashed`?`dashed=1;`:e.line===`dotted`?`dashed=1;dashPattern=1 1;`:``,p=tt(e.head),m=e.tail==null||e.tail===`none`?`none`:tt(e.tail),h=Ve({edgeDesc:W(e.description),edgeTech:W(e.technology),edgeNotes:W(e.notes),edgeNavTo:V(e.navigateTo),edgeKind:z.getKind(e),edgeNotation:z.getNotation(e),edgeLinksJson:Pe(z.getLinks(e)),edgeMetadataJson:Fe(z.getMetadata(e))}),g=ze(e.id,i),_=Oe(n,e.color);return`endArrow=${p};startArrow=${m};html=1;rounded=0;${u}strokeColor=${d};strokeWidth=2;${f}${r===``?``:`fontColor=${_.font};fontSize=12;align=center;verticalAlign=middle;labelBackgroundColor=none;fontFamily=${encodeURIComponent(o)};`}${h}${g}`}function Ge(e,t,n,r,i,a){let{defaultParentId:o}=t,s=i(e.source),c=i(e.target),l=He(e),u=Ue(e,n?.edgeWaypoints);return`<mxCell id="${a}" value="${l}" style="${We(e,t,r,l,n)}" edge="1" parent="${o}" source="${s}" target="${c}">
7
- ${u}${Be(z.getCustomData(e))}
8
- </mxCell>`}function Ke(e,t,n){let{bboxes:r,defaultParentId:i,nodeIdsInView:a}=t,o=n(e.id),s=r.get(e.id),{width:c,height:l}=s,u=e.parent!=null&&a.has(e.parent)?n(e.parent):i,d=e.parent==null?void 0:r.get(e.parent);return{id:o,parentId:u,x:d==null?s.x+t.offsetX:s.x-d.x,y:d==null?s.y+t.offsetY:s.y-d.y,width:c,height:l}}function qe(e,t,n,r){let{containerNodeIds:i,effectiveStyles:a,fontFamily:o,containerTitleFontSizePx:s,containerTitleColor:c}=t,l=n?.strokeColorByNodeId,u=n?.strokeWidthByNodeId,d=i.has(e.id),f=e.kind??``,p=e.title,m=W(e.description),h=W(e.technology),g=W(R.getNotes(e)),_=R.getTags(e),v=Array.isArray(_)&&_.length>0?_.join(`,`):``,y=V(R.getNavigateTo(e)),b=V(R.getIcon(e)),x=f===`actor`||e.shape===`person`,S=d?`shape=rectangle;rounded=0;container=1;collapsible=0;startSize=0;`:x?`shape=actor;`:Te(e.shape),C=l?.[e.id],w=u?.[e.id],T=C?Ce(Ee(r,e.color),C):Ee(r,e.color),E=T?.fill??pe,D=T?.stroke??me,ee=T?.font??T?.stroke??I,O=`fillColor=${E};strokeColor=${D};fontColor=${ee};`,k=e.style,A=a.fontSize(k?.textSize),j=L(je(p,m,d,ee,o,A)),M=k?.border,N=w??Se(M,d),P=N===``?``:`strokeWidth=${N};`,te=xe(d,M),F=d===!0?k?.opacity??15:void 0,ne=F!=null&&d===!0?`fillOpacity=${Math.min(100,Math.max(0,F))};`:``,re=Le({desc:m,tech:h,notes:g,tagList:v,navTo:y,iconName:b,summaryStr:W(R.getSummary(e)),linksJson:Pe(R.getLinks(e)),borderVal:M,containerOpacityNum:F,strokeWidth:N,colorNameForRoundtrip:e.color?encodeURIComponent(String(e.color)):``,nodeStyle:k,strokeHex:D,nodeNotation:R.getNotation(e)})+Re(e.id,f,t.view.id,n),ie=Be(R.getCustomData(e)),ae=Ne(y);return{value:j,styleStr:`${d?`align=left;verticalAlign=top;overflow=fill;whiteSpace=wrap;html=1;`:`align=center;verticalAlign=middle;verticalLabelPosition=middle;labelPosition=center;fontSize=${A};fontStyle=1;spacingTop=4;spacingLeft=2;spacingRight=2;spacingBottom=2;overflow=fill;whiteSpace=wrap;html=1;fontFamily=${encodeURIComponent(o)};`}${S}${O}${P}${te}${ne}${ae}${re}`,userObjectXml:ie,navTo:y,isContainer:d,title:p,fontFamily:o,containerTitleFontSizePx:s,containerTitleColor:c}}function Je(e,t,n,r,i,a){let o=Ke(e,t,i),s=qe(e,t,n,r);return{...o,value:s.value,styleStr:s.styleStr,userObjectXml:s.userObjectXml,navTo:s.navTo,isContainer:s.isContainer,fontFamily:s.fontFamily,...s.isContainer&&{title:s.title??``,titleCellId:String(a),containerTitleFontSizePx:s.containerTitleFontSizePx,containerTitleColor:s.containerTitleColor}}}function Ye(e){let t=`<mxGeometry height="${Math.round(e.height)}" width="${Math.round(e.width)}" x="${Math.round(e.x)}" y="${Math.round(e.y)}" as="geometry" />`,n=e.userObjectXml===``?`\n ${t}`:`${e.userObjectXml}\n ${t}`,r=e.isContainer&&e.title!=null?L(e.title):e.value,i=e.navTo===``?`<mxCell id="${e.id}" value="${e.value}" style="${e.styleStr}" vertex="1" parent="${e.parentId}">\n ${n}\n</mxCell>`:`<UserObject label="${r}" link="${de}${L(e.navTo)}" id="${e.id}">\n <mxCell parent="${e.parentId}" style="${e.styleStr}" value="${e.value}" vertex="1">\n ${n}\n</mxCell>\n</UserObject>`;return e.isContainer?{vertexXml:i,titleCellXml:Xe(e.title??``,e.titleCellId??e.id,e.navTo,e.id,e.fontFamily,e.containerTitleFontSizePx??12,e.containerTitleColor??ge),isContainer:!0}:{vertexXml:i,isContainer:!1}}function Xe(e,t,n,r,i,a,o){let s=L(e),c=Math.max(60,Math.min(260,e.length*8)),l=Ne(n),u=`shape=text;html=1;fillColor=none;strokeColor=none;align=left;verticalAlign=top;fontSize=${a};fontStyle=1;fontColor=${o};fontFamily=${encodeURIComponent(i)};${l}`;if(n===``)return`<mxCell id="${t}" value="${s}" style="${u}" vertex="1" parent="${r}">\n <mxGeometry x="8" y="8" width="${c}" height="18" as="geometry" />\n</mxCell>`;let d=`<mxCell parent="${r}" style="${u}" value="${s}" vertex="1">\n <mxGeometry x="8" y="8" width="${c}" height="18" as="geometry" />\n</mxCell>`;return`<UserObject label="${L(e)}" link="${de}${L(n)}" id="${t}">\n ${d}\n</UserObject>`}function Ze(e){return typeof e.title==`string`?e.title:null}function Qe(e){let t=e.description;return typeof t==`object`&&t&&`txt`in t?String(t.txt):typeof t==`object`&&t&&`md`in t?String(t.md):typeof t==`string`?t:``}function $e(e,t){let n=[`bridgeManaged=true;`,`likec4ViewId=${encodeURIComponent(e.id)};`];return t.projectId!=null&&t.projectId!==``&&n.push(`likec4ProjectId=${encodeURIComponent(t.projectId)};`),n}function et(e,t){let n=Ze(e),r=Qe(e),i=r.trim()===``?``:encodeURIComponent(r.trim()),a=e.notation,o=typeof a==`string`&&a!==``?a:void 0,s=o==null?``:encodeURIComponent(o),c=[`rounded=1;whiteSpace=wrap;html=1;fillColor=none;strokeColor=none;`,`likec4ViewTitle=${encodeURIComponent(n??e.id)};`,i===``?``:`likec4ViewDescription=${i};`,s===``?``:`likec4ViewNotation=${s};`];return t?.profile===`leanix`&&c.push(...$e(e,t)),c.join(``)}function tt(e){switch(e){case`none`:return`none`;case`open`:case`onormal`:case`vee`:return`open`;case`diamond`:case`odiamond`:return`diamond`;case`dot`:case`odot`:return`oval`;case`crow`:return`block`;default:return`block`}}const G={x:0,y:0,width:120,height:60};function nt(e){return e.x===G.x&&e.y===G.y&&e.width===G.width&&e.height===G.height}function rt(e,t,n){let r=e=>`${e.x},${e.y},${e.width},${e.height}`,i=t.filter(e=>!n.has(e.id)),a=new Map;for(let t of i){let n=e.get(t.id);if(!n)continue;let i=r(n),o=a.get(i)??[];o.push(t),a.set(i,o)}for(let t of a.values()){if(t.length<=1)continue;let n=t[0],r=n?e.get(n.id):void 0;r&&nt(r)&&t.forEach((t,n)=>{e.set(t.id,{...r,x:r.x,y:r.y+n*(r.height+24)})})}}function it(e,t,n,r,i,a){let o=[...n].filter(e=>t.has(e.id)).sort((e,t)=>(t.level??0)-(e.level??0));for(let t of o){let n=(R.getChildren(t)??[]).filter(e=>r.has(e));if(n.length===0||!nt(e.get(t.id)))continue;let o=1/0,s=1/0,c=-1/0,l=-1/0;for(let t of n){let n=e.get(t);n&&(o=Math.min(o,n.x),s=Math.min(s,n.y),c=Math.max(c,n.x+n.width),l=Math.max(l,n.y+n.height))}o!==1/0&&e.set(t.id,{x:o-i,y:s-a,width:c-o+2*i,height:l-s+2*a})}}function at(e){let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e.values())t=Math.min(t,a.x),n=Math.min(n,a.y),r=Math.max(r,a.x+a.width),i=Math.max(i,a.y+a.height);t===1/0&&(t=0),n===1/0&&(n=0),r===-1/0&&(r=t+800),i===-1/0&&(i=n+600);let a=t+(r-t)/2,o=n+(i-n)/2;return{offsetX:800/2-a,offsetY:600/2-o,canvasWidth:800,canvasHeight:600}}function ot(e,t){let r=e.$view,{nodes:i}=r,a=t?.layoutOverride,o=[...i].sort((e,t)=>n(e.parent)&&n(t.parent)?0:n(e.parent)?-1:n(t.parent)?1:e.parent===t.parent?0:e.id.startsWith(t.id+`.`)?1:t.id.startsWith(e.id+`.`)?-1:0),s=e=>{let t=a?.[e.id];if(t)return t;let n=e;return{x:typeof n.x==`number`?n.x:Array.isArray(n.position)?n.position[0]:0,y:typeof n.y==`number`?n.y:Array.isArray(n.position)?n.position[1]:0,width:typeof n.width==`number`?n.width:n.size?.width??120,height:typeof n.height==`number`?n.height:n.size?.height??60}},c=new Map;for(let e of o)c.set(e.id,s(e));let l=new Set(i.map(e=>e.id)),u=new Set(i.filter(e=>{let t=R.getChildren(e);return Array.isArray(t)&&t.some(e=>l.has(e))}).map(e=>e.id));rt(c,o,u);let d=be(e),f=d.theme.spacing.xl;it(c,u,o,l,f,d.theme.spacing.xl+d.theme.spacing.md);let{offsetX:p,offsetY:m,canvasWidth:h,canvasHeight:g}=at(c);return{view:r,bboxes:c,containerNodeIds:u,sortedNodes:o,offsetX:p,offsetY:m,canvasWidth:h,canvasHeight:g,defaultParentId:`1`,rootId:`0`,effectiveStyles:d,fontFamily:`'IBM Plex Sans Variable',ui-sans-serif,system-ui,sans-serif`,containerTitleFontSizePx:Math.round(d.theme.textSizes.xs),containerTitleColor:ge,nodeIdsInView:l}}function st(e,t){let n=e.$view,{edges:r}=n,i=t?.compressed!==!1,a=ot(e,t),{sortedNodes:o,defaultParentId:s,rootId:c,canvasWidth:l,canvasHeight:u}=a,d=new Map,f=2,p=e=>{let t=d.get(e);if(!t){if(f>=fe)throw Error(`DrawIO cell ID range exhausted`);t=String(f++),d.set(e,t)}return t},m=[],h=[],g=[],_=fe;for(let n of o){let r=Ye(Je(n,a,t,e,p,_));r.isContainer?(m.push(r.vertexXml),r.titleCellXml&&m.push(r.titleCellXml),_++):h.push(r.vertexXml)}for(let n of r){if(f>=fe)throw Error(`DrawIO cell ID range exhausted`);let r=String(f++);g.push(Ge(n,a,t,e,p,r))}let v=[`<mxCell id="${s}" value="" style="${et(n,t)}" vertex="1" parent="${c}">
9
- <mxGeometry x="0" y="0" width="${l}" height="${u}" as="geometry" />
10
- </mxCell>`,...m,...h,...g].join(`
11
- `),y=(Ze(n)??n.id).trim()||n.id,b=`<mxGraphModel dx="800" dy="800" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
12
- <root>
13
- <mxCell id="${c}" />
14
- ${v}
15
- </root>
16
- </mxGraphModel>`,x=i?ve(b):b;return{name:y,id:n.id,content:x}}function ct(e,t){let n=L(t??new Date().toISOString());return e.length===0?`<?xml version="1.0" encoding="UTF-8"?>
17
- <mxfile host="LikeC4" modified="${n}" agent="LikeC4" version="1.0" etag="" type="device">
18
- </mxfile>
19
- `:`<?xml version="1.0" encoding="UTF-8"?>
20
- <mxfile host="LikeC4" modified="${n}" agent="LikeC4" version="1.0" etag="" type="device"${e.length>1?` pages="${e.length}"`:``}>
21
- ${e.map(e=>` <diagram name="${L(e.name)}" id="likec4-${L(e.id)}">${e.content}</diagram>`).join(`
22
- `)}
23
- </mxfile>
24
- `}function lt(e,t){return ct([st(e,t)],t?.modified)}function ut(e,t,n){return ct(e.map(e=>st(e,t?.[e.$view.id])),n)}function dt(e,t,n){let r={compressed:!1,...n};if(!t)return r;let i=t.layoutByView[e]?.nodes;return i!=null&&(r.layoutOverride=i),Object.keys(t.strokeColorByFqn).length>0&&(r.strokeColorByNodeId=t.strokeColorByFqn),Object.keys(t.strokeWidthByFqn).length>0&&(r.strokeWidthByNodeId=t.strokeWidthByFqn),Object.keys(t.edgeWaypoints).length>0&&(r.edgeWaypoints=t.edgeWaypoints),r}function ft(e,t,n){let r=t?_e(t):null;return Object.fromEntries(e.map(e=>[e,dt(e,r,n)]))}function pt(e){let t=ve(e),n=JSON.stringify({type:`xml`,compressed:!0,data:t});return`https://app.diagrams.net/#create=`+encodeURIComponent(n)}const mt=e=>e.charAt(0).toLocaleUpperCase()+e.slice(1),ht=e=>e.split(`.`).map(mt).join(``),gt=e=>ht(e.parent?e.id.slice(e.parent.length+1):e.id),K=e=>e.replace(/\\?"/g,`'`),_t=({shape:e,title:t})=>{let n=`label: ${JSON.stringify(t)}`;switch(e){case`queue`:return`@{ shape: horizontal-cylinder, ${n} }`;case`person`:return`@{ icon: "fa:user", shape: rounded, ${n} }`;case`storage`:return`@{ shape: disk, ${n} }`;case`cylinder`:return`@{ shape: cylinder, ${n} }`;case`mobile`:case`browser`:return`@{ shape: rounded, ${n} }`;case`bucket`:return`@{ shape: trap-t, ${n} }`;case`rectangle`:return`@{ shape: rectangle, ${n} }`;case`document`:return`@{ shape: doc, ${n} }`;case`component`:return`@{ shape: rectangle, ${n} }`;default:O(e)}};function vt(e){let t=e.$view,{nodes:r,edges:i}=t,a=new Map,o=(e,t)=>{let n=gt(e),i=(t?t+`.`:``)+n;a.set(e.id,i);let s=new y;if(e.children.length>0){let t=K(e.title);s.append(`subgraph `,i,'["`',t,'`"]',b).indent({indentedChildren:[x(r.filter(t=>t.parent===e.id),e=>o(e,i),{appendNewLineIfNotEmpty:!0})],indentation:2}).append(`end`,b)}else s.append(i,_t(e));return s},s=e=>new y().append(a.get(e.source),` -.`,e.label?' "`'+K(e.label)+'`" .-':`-`,`> `,a.get(e.target));return v(new y().append(`---`,b,`title: ${JSON.stringify(K(e.titleOrId))}`,b,`---`,b).append(`graph `,t.autoLayout.direction,b).indent({indentedChildren:e=>{e.append(x(r.filter(e=>n(e.parent)),e=>o(e),{appendNewLineIfNotEmpty:!0})).appendIf(i.length>0,x(i,e=>s(e),{appendNewLineIfNotEmpty:!0}))},indentation:2}))}function q(e){return e.length===0?`never`:e.sort(j).map(e=>` | ${JSON.stringify(e)}`).join(`
25
- `).trimStart()}function yt(e){let t=u(e);return t.length===0?`never`:a(t,N,p(e=>` | ${JSON.stringify(e.id)}`)).join(`
26
- `).trimStart()}function bt(e,t={}){let{useCorePackage:n=!1}=t;return`
27
- import type { Aux, SpecAux } from '${n?`@likec4/core/types`:`likec4/model`}';
28
-
29
- export type $Specs = SpecAux<
30
- // Element kinds
31
- ${q(f(e.specification.elements))},
32
- // Deployment kinds
33
- ${q(f(e.specification.deployments??{}))},
34
- // Relationship kinds
35
- ${q(f(e.specification.relationships??{}))},
36
- // Tags
37
- ${q(f(e.specification.tags??{}))},
38
- // Metadata keys
39
- ${q(e.specification.metadataKeys??[])}
40
- >
41
-
42
- export type $Aux = Aux<
43
- ${JSON.stringify(e.stage)},
44
- // Elements
45
- ${yt(e.$data.elements)},
46
- // Deployments
47
- ${yt(e.$data.deployments.elements)},
48
- // Views
49
- ${q(f(e.$data.views))},
50
- // Project ID
51
- ${JSON.stringify(e.projectId)},
52
- $Specs
53
- >
54
-
55
- export type $ElementId = $Aux['ElementId']
56
- export type $DeploymentId = $Aux['DeploymentId']
57
- export type $ViewId = $Aux['ViewId']
58
-
59
- export type $ElementKind = $Aux['ElementKind']
60
- export type $RelationKind = $Aux['RelationKind']
61
- export type $DeploymentKind = $Aux['DeploymentKind']
62
- export type $Tag = $Aux['Tag']
63
- export type $Tags = readonly $Aux['Tag'][]
64
- export type $MetadataKey = $Aux['MetadataKey']
65
- `.trimStart()}function xt(e,t={}){let n=bt(e,t),{useCorePackage:r=!1}=t;return`
66
- /* prettier-ignore-start */
67
- /* eslint-disable */
68
-
69
- /******************************************************************************
70
- * This file was generated
71
- * DO NOT EDIT MANUALLY!
72
- ******************************************************************************/
73
-
74
- import { LikeC4Model } from '${r?`@likec4/core`:`likec4`}/model'
75
- ${n}
76
-
77
- export const likec4model: LikeC4Model<$Aux> = new LikeC4Model(${w.stringify(e.$data,{space:2,quote:`'`})} as any) as any
78
-
79
- /* prettier-ignore-end */
80
- `.trimStart()}const St=e=>e.charAt(0).toLocaleUpperCase()+e.slice(1),J=e=>e.split(/[.-]/).map(St).join(``),Ct=e=>J(e.parent?e.id.slice(e.parent.length+1):e.id),Y=(e,t,n=`#3b82f6`)=>e?t(e)??n:n,wt=({autoLayout:e})=>{switch(e.direction){case`TB`:return`top to bottom`;case`BT`:return console.warn(`Bottom to top direction is not supported. Defaulting to top to bottom.`),`top to bottom`;case`LR`:return`left to right`;case`RL`:return console.warn(`Right to left direction is not supported. Defaulting to left to right.`),`left to right`}},Tt=({shape:e})=>{switch(e){case`queue`:case`rectangle`:case`person`:return e;case`storage`:case`cylinder`:return`database`;case`component`:return`component`;case`document`:case`mobile`:case`bucket`:case`browser`:return`rectangle`;default:O(e)}},X=e=>o(e)?null:JSON.stringify(e).slice(1,-1).replace(/\\"/g,`"`);function Et(e){let t=e.$view,r=e.$model.$styles.theme.colors,{nodes:i,edges:a}=t,s=e=>t=>t in r?r[t].elements[e]:void 0,c=e=>t=>t in r?r[t].relationships[e]:void 0,l=new Map,u=()=>new y().append(`title "`,e.titleOrId,`"`,b).append(wt(t),` direction`,b),d=()=>new y().append(`hide stereotype`,b).append(`skinparam ranksep `,`60`,b).append(`skinparam nodesep `,`30`,b).append(`skinparam {`,b).indent({indentedChildren:e=>e.append(`arrowFontSize `,`10`,b).append(`defaultTextAlignment `,`center`,b).append(`wrapWidth `,`200`,b).append(`maxMessageSize `,`100`,b).append(`shadowing `,`false`,b),indentation:2}).append(`}`,b),f=e=>{let t=Tt(e),n=J(e.id);return new y().append(`skinparam `,t,`<<`,n,`>>`,`{`,b).indent({indentedChildren:t=>t.append(`BackgroundColor `,Y(e.color,s(`fill`)),b).append(`FontColor `,Y(e.color,s(`hiContrast`),`#FFFFFF`),b).append(`BorderColor `,Y(e.color,s(`stroke`)),b),indentation:2}).append(`}`,b)},p=e=>{let t=Tt(e),n=J(e.id),r=X(e.title)||Ct(e),i=X(e.technology);l.set(e.id,n);let a=k.from(e.description);return new y().append(t,` `).append(`"`).append(`==`,r).appendIf(!!i,`\\n<size:10>[`,i,`]</size>`).appendIf(a.nonEmpty,`\\n\\n`,X(a.text)).append(`"`,` <<`,n,`>> `,`as `,n,b)},m=e=>{let t=X(e.title)||Ct(e),n=J(e.id);return l.set(e.id,n),new y().append(`rectangle "`,t,`" <<`,n,`>> as `,n,` {`,b).indent({indentedChildren:t=>t.append(`skinparam `,`RectangleBorderColor<<`,n,`>> `,Y(e.color,s(`fill`)),b).append(`skinparam `,`RectangleFontColor<<`,n,`>> `,Y(e.color,s(`fill`)),b).append(`skinparam `,`RectangleBorderStyle<<`,n,`>> `,`dashed`,b,b).append(x(i.filter(t=>t.parent===e.id),e=>e.children.length>0?m(e):p(e))),indentation:2}).append(`}`,b)},h=e=>{let t=e.technology||``,n=e.label||t,r=Y(e.color,c(`line`),`#777777`),i=e=>`<color:${r}>${e.replaceAll(`"`,`'`)}`,a=new y().append(l.get(e.source),` .[`,r,`,thickness=2].> `,l.get(e.target));return(n||t)&&(a.append(` : `,n.split(`
81
- `).map(e=>o(e)?e:i(e)).join(`\\n`)),t&&t!==n&&a.append(`\\n<size:8>[`,i(t),`]</size>`)),a.append(b)};return v(new y().append(`@startuml`,b).append(u(),b).append(d(),b).append(x(i.filter(e=>e.children.length==0),e=>f(e),{appendNewLineIfNotEmpty:!0})).append(x(i.filter(e=>n(e.parent)),e=>e.children.length>0?m(e):p(e),{appendNewLineIfNotEmpty:!0})).appendIf(a.length>0,b,x(a,e=>h(e),{appendNewLineIfNotEmpty:!0})).append(`@enduml`,b))}function Dt(e){return x(e,e=>_`${w.stringify(e.id)}`,{separator:` | `})}function Ot(e){let t=Array.from(e),n=new y;return n.appendTemplate`
82
- /******************************************************************************
83
- * This file was generated
84
- * DO NOT EDIT MANUALLY!
85
- ******************************************************************************/
86
- /* prettier-ignore-start */
87
- /* eslint-disable */
88
-
89
- // @ts-nocheck
90
-
91
- import type { DiagramView } from 'likec4'
92
- `.append(b,b),t.length===0?(n.append(`export {}`,b),v(n)):(n.appendTemplate`
93
- export type LikeC4ViewId = ${Dt(t)};
94
- export const LikeC4Views = {
95
- `.indent({indentation:2,indentedChildren(e){e.appendNewLineIf(t.length>1).append(x(t,e=>_`${w.stringify(e.id)}: (${w.stringify(e)} as unknown) as DiagramView`,{separator:`,`,appendNewLineIfNotEmpty:!0}))}}).append(`} as const satisfies Record<LikeC4ViewId, DiagramView>`,b,b).appendTemplate`
96
- export type LikeC4Views = typeof LikeC4Views
97
-
98
- export function isLikeC4ViewId(value: unknown): value is LikeC4ViewId {
99
- return (
100
- value != null &&
101
- typeof value === 'string' &&
102
- !!LikeC4Views[value]
103
- )
104
- }
105
-
106
- /* prettier-ignore-end */
107
- `.append(b),v(n))}function kt(e,t={}){let{useCorePackage:n=!1}=t;M(!e.isParsed(),`can not generate react types for parsed model`);let r=bt(e,t);return`
108
- /* prettier-ignore-start */
109
- /* eslint-disable */
110
-
111
- /******************************************************************************
112
- * This file was generated
113
- * DO NOT EDIT MANUALLY!
114
- ******************************************************************************/
115
-
116
- import type { PropsWithChildren } from 'react'
117
- import type { JSX } from 'react/jsx-runtime'
118
- import type { LikeC4Model } from '${n?`@likec4/core`:`likec4`}/model'
119
- import type { LayoutedView } from '${n?`@likec4/core/types`:`likec4/model`}'
120
- import type {
121
- LikeC4ViewProps as GenericLikeC4ViewProps,
122
- ReactLikeC4Props as GenericReactLikeC4Props
123
- } from 'likec4/react'
124
-
125
- ${r}
126
-
127
- declare function isLikeC4ViewId(value: unknown): value is $ViewId;
128
-
129
- declare const likec4model: LikeC4Model<$Aux>;
130
- declare function useLikeC4Model(): LikeC4Model<$Aux>;
131
- declare function useLikeC4View(viewId: $ViewId): LayoutedView<$Aux>;
132
-
133
- declare function LikeC4ModelProvider(props: PropsWithChildren): JSX.Element;
134
-
135
- type IconRendererProps = {
136
- node: {
137
- id: string
138
- title: string
139
- icon?: string | undefined
140
- }
141
- }
142
- declare function RenderIcon(props: IconRendererProps): JSX.Element;
143
-
144
- type LikeC4ViewProps = GenericLikeC4ViewProps<$Aux>;
145
- declare function LikeC4View({viewId, ...props}: LikeC4ViewProps): JSX.Element;
146
-
147
- type ReactLikeC4Props = GenericReactLikeC4Props<$Aux>
148
- declare function ReactLikeC4({viewId, ...props}: ReactLikeC4Props): JSX.Element;
149
-
150
- export {
151
- type LikeC4ViewProps,
152
- type ReactLikeC4Props,
153
- isLikeC4ViewId,
154
- useLikeC4Model,
155
- useLikeC4View,
156
- likec4model,
157
- LikeC4ModelProvider,
158
- LikeC4View,
159
- RenderIcon,
160
- ReactLikeC4
161
- }
162
- /* prettier-ignore-end */
163
- `.trimStart()}function At(e){if(e.length===0)return!1;try{return JSON.parse(e),!0}catch{return!1}}function Z(e){if(typeof e!=`string`)throw TypeError(`hardenJsonStringLiteralForEmbeddedScript: expected JSON.stringify(...) output as a string`);if(!At(e))throw TypeError(`hardenJsonStringLiteralForEmbeddedScript: expected JSON.stringify(...) output (string, object, array, number, boolean, or null)`);return e.replaceAll(`<`,`\\u003C`).replaceAll(`>`,`\\u003E`).replaceAll(`/`,`\\u002F`).replaceAll(`\u2028`,`\\u2028`).replaceAll(`\u2029`,`\\u2029`)}function Q(e,t=`.js`){return{matches:n=>{let{module:r,projectId:i}=n.match(/^likec4:plugin\/(?<projectId>.+)\/(?<module>.+)$/)?.groups??n.match(/^likec4:(?<module>.+)\/(?<projectId>.+)$/)?.groups??{};return!r||!i?null:(r.endsWith(t)&&(r=r.slice(0,-t.length)),r===e?i:null)},virtualId:n=>C(`likec4:plugin`,n,e)+t}}function $(e,t){return{id:`likec4:${e}`,virtualId:`likec4:plugin/${e}.js`,async load({logger:n,projects:r}){return n.info(S.dim(`generating likec4:${e}`)),`
164
- export let ${t}Fn = {
165
- ${r.map(({id:t})=>`${Z(JSON.stringify(t))}: () => import(${Z(JSON.stringify(C(`likec4:${e}`,t)))})`).join(`,
166
- `)}
167
- }
168
-
169
- export async function ${t}(projectId) {
170
- let fn = ${t}Fn[projectId]
171
- if (!fn) {
172
- const projects = Object.keys(${t}Fn)
173
- console.error('Unknown projectId: ' + projectId + ' (available: ' + projects + ')')
174
- if (projects.length === 0) {
175
- throw new Error('No projects found, invalid state')
176
- }
177
- projectId = projects[0]
178
- console.warn('Falling back to project: ' + projectId)
179
- fn = ${t}Fn[projectId]
180
- }
181
- return await fn()
182
- }
183
-
184
- if (import.meta.hot) {
185
- import.meta.hot.accept(md => {
186
- if (!import.meta.hot.data.$update) {
187
- import.meta.hot.data.$update = ${t}Fn
188
- }
189
- const update = md.${t}Fn
190
- if (update) {
191
- Object.assign(import.meta.hot.data.$update, update)
192
- } else {
193
- import.meta.hot.invalidate()
194
- }
195
- })
196
- }
197
- `}}}function jt(e){let t=new y;return t.appendTemplate`
198
- /******************************************************************************
199
- * This file was generated
200
- * DO NOT EDIT MANUALLY!
201
- ******************************************************************************/
202
- /* eslint-disable */
203
-
204
- export function d2Source(viewId) {
205
- switch (viewId) {
206
- `.appendNewLine().indent({indentation:4,indentedChildren(t){t.append(x([...e.views()],e=>_`
207
- case ${JSON.stringify(e.id)}: {
208
- return ${JSON.stringify(ue(e))}
209
- }
210
- `,{appendNewLineIfNotEmpty:!0})).appendTemplate`
211
- default: {
212
- throw new Error('Unknown viewId: ' + viewId)
213
- }
214
- `}}).append(b,` }`,b).appendTemplate`
215
- }
216
- `.append(b,b),v(t)}const Mt={...Q(`d2`),async load({likec4:e,project:t,logger:n}){return n.info(S.dim(`generating likec4:d2/${t.id}`)),jt(await e.computedModel(t.id))}},Nt=$(`d2`,`loadD2Sources`);function Pt(e){let t=new y;return t.appendTemplate`
217
- /******************************************************************************
218
- * This file was generated
219
- * DO NOT EDIT MANUALLY!
220
- ******************************************************************************/
221
- /* eslint-disable */
222
-
223
- export function dotSource(viewId) {
224
- switch (viewId) {
225
- `.appendNewLine().indent({indentation:4,indentedChildren(t){t.append(x(Object.keys(e),t=>_`
226
- case ${JSON.stringify(t)}: {
227
- return ${JSON.stringify(e[t].dot)}
228
- }
229
- `,{appendNewLineIfNotEmpty:!0})).appendTemplate`
230
- default: {
231
- throw new Error('Unknown viewId: ' + viewId)
232
- }
233
- `}}).append(b,` }`,b).appendTemplate`
234
- }
235
-
236
- export function svgSource(viewId) {
237
- switch (viewId) {
238
- `.appendNewLine().indent({indentation:4,indentedChildren(t){t.append(x(Object.keys(e),t=>_`
239
- case ${Z(JSON.stringify(t))}: {
240
- return ${Z(JSON.stringify(e[t].svg))}
241
- }
242
- `,{appendNewLineIfNotEmpty:!0})).appendTemplate`
243
- default: {
244
- throw new Error('Unknown viewId: ' + viewId)
245
- }
246
- `}}).append(b,` }`,b,`}`,b,b),v(t)}const Ft={...Q(`dot`),async load({likec4:e,project:t,logger:n}){return n.info(S.dim(`generating likec4:dot/${t.id}`)),Pt(d(await e.views.viewsAsGraphvizOut(t.id),({id:e,svg:t,dot:n})=>[e,{dot:n,svg:t}]))}},It=$(`dot`,`loadDotSources`);function Lt(e){let t=new y;return t.appendTemplate`
247
- /******************************************************************************
248
- * This file was generated
249
- * DO NOT EDIT MANUALLY!
250
- ******************************************************************************/
251
- /* eslint-disable */
252
-
253
- export function drawioEditUrl(viewId) {
254
- switch (viewId) {
255
- `.appendNewLine().indent({indentation:4,indentedChildren(t){t.append(x([...e.views()],e=>_`
256
- case ${JSON.stringify(e.id)}: {
257
- return ${JSON.stringify(pt(lt(e)))}
258
- }
259
- `,{appendNewLineIfNotEmpty:!0})).appendTemplate`
260
- default: {
261
- throw new Error('Unknown viewId: ' + viewId)
262
- }
263
- `}}).append(b,` }`,b).appendTemplate`
264
- }
265
- `.append(b,b),v(t)}const Rt={...Q(`drawio`),async load({likec4:e,project:t,logger:n}){return n.info(S.dim(`generating likec4:drawio/${t.id}`)),Lt(await e.layoutedModel(t.id))}},zt=$(`drawio`,`loadDrawioSources`);function Bt(e){let{imports:n,cases:r}=a(e.flatMap(e=>e.nodes.map(e=>e.icon)),c(e=>t(e)&&!(e.toLowerCase().startsWith(`http:`)||e.toLowerCase().startsWith(`https:`))),l(),s(j)).reduce((e,t,n)=>{let r=t.startsWith(`file:`),i=`Icon`+n.toString().padStart(2,`0`);if(r)return e.imports.push(`import ${i} from '${t}?inline'`),e.cases.push(` '${t}': () => jsx('img', { src: ${i} })`),e;let[a,o]=t.split(`:`);return e.imports.push(`import ${i} from '@likec4/icons/${a}/${o}'`),e.cases.push(` '${a}:${o}': ${i}`),e},{imports:[],cases:[]});return`
266
- import { jsx } from 'react/jsx-runtime'
267
- ${n.join(`
268
- `)}
269
-
270
- const Icons = {
271
- ${r.join(`,
272
- `)}
273
- }
274
- export function IconRenderer({ node, ...props }) {
275
- const IconComponent = Icons[node.icon ?? '']
276
- if (!IconComponent) {
277
- return null
278
- }
279
- return jsx(IconComponent, props)
280
- }
281
- `}const Vt={...Q(`icons`,`.jsx`),async load({likec4:e,project:t,logger:n}){return n.info(S.dim(`generating likec4:icons/${t.id}`)),Bt(await e.views.computedViews(t.id))}},Ht=/^[a-zA-Z0-9_.-]+$/;function Ut(e){if(!Ht.test(e))throw Error(`Unsafe value for code generation: ${e}`);return JSON.stringify(e)}function Wt(e){return JSON.stringify(e)}const Gt={id:`likec4:icons`,virtualId:`likec4:plugin/icons.jsx`,async load({projects:e,logger:t}){return t.info(S.dim(`generating likec4:icons`)),`
282
- import { jsx } from 'react/jsx-runtime'
283
- import { lazy, Suspense } from 'react'
284
- export let ProjectIconsRegistry = {
285
- ${e.filter(e=>Ht.test(e.id)?!0:(t.warn(S.yellow(`Skipping project with unsafe id for icons registry: ${e.id}`)),!1)).map(e=>`${Z(Ut(e.id))}: lazy(() => import(${Z(Wt(C(`likec4:icons`,e.id)))}).then(m => ({default: m.IconRenderer})))`).join(`,
286
- `)}
287
- }
288
-
289
-
290
- export function getProjectIcons(projectId) {
291
- let fn = ProjectIconsRegistry[projectId]
292
- if (!fn) {
293
- const projects = Object.keys(ProjectIconsRegistry)
294
- console.error('Unknown projectId: ' + projectId + ' (available: ' + projects + ')')
295
- if (projects.length === 0) {
296
- throw new Error('No projects found, invalid state')
297
- }
298
- projectId = projects[0]
299
- console.warn('Falling back to project: ' + projectId)
300
- fn = ProjectIconsRegistry[projectId]
301
- }
302
- return (props) => jsx(Suspense, { children: jsx(fn, props) })
303
- }
304
-
305
- if (import.meta.hot) {
306
- import.meta.hot.accept(md => {
307
- if (!import.meta.hot.data.$update) {
308
- import.meta.hot.data.$update = ProjectIconsRegistry
309
- }
310
- const update = md.ProjectIconsRegistry
311
- if (update) {
312
- Object.assign(import.meta.hot.data.$update, update)
313
- } else {
314
- import.meta.hot.invalidate()
315
- }
316
- })
317
- }
318
- `}};function Kt(e){let t=new y;return t.appendTemplate`
319
- /******************************************************************************
320
- * This file was generated
321
- * DO NOT EDIT MANUALLY!
322
- ******************************************************************************/
323
- /* eslint-disable */
324
-
325
- export function mmdSource(viewId) {
326
- switch (viewId) {
327
- `.appendNewLine().indent({indentation:4,indentedChildren(t){t.append(x([...e.views()],e=>_`
328
- case ${Z(JSON.stringify(e.id))}: {
329
- return ${Z(JSON.stringify(vt(e)))}
330
- }
331
- `,{appendNewLineIfNotEmpty:!0})).appendTemplate`
332
- default: {
333
- throw new Error('Unknown viewId: ' + viewId)
334
- }
335
- `}}).append(b,` }`,b).appendTemplate`
336
- }
337
-
338
- `.append(b,b),v(t)}const qt={...Q(`mmd`),async load({likec4:e,project:t,logger:n}){return n.info(S.dim(`generating virtual:likec4/mmd/${t.id}`)),Kt(await e.computedModel(t.id))}},Jt=$(`mmd`,`loadMmdSources`),Yt=e=>`
339
- import { createHooksForModel, atom } from 'likec4/vite-plugin/internal'
340
-
341
- export const $likec4data = atom(${w.stringify(e.$data)})
342
-
343
- export const {
344
- updateModel,
345
- $likec4model,
346
- useLikeC4Model,
347
- useLikeC4Views,
348
- useLikeC4View
349
- } = createHooksForModel($likec4data)
350
-
351
- if (import.meta.hot) {
352
- import.meta.hot.accept(md => {
353
- if (!import.meta.hot.data.$update) {
354
- import.meta.hot.data.$update = updateModel
355
- }
356
- const update = md.$likec4data?.get()
357
- if (update) {
358
- import.meta.hot.data.$update(update)
359
- } else {
360
- import.meta.hot.invalidate()
361
- }
362
- })
363
- }
364
- `,Xt={...Q(`model`),async load({likec4:e,project:t,logger:n}){return n.info(S.dim(`generating likec4:model/${t.id}`)),Yt(await e.layoutedModel(t.id))}},Zt=$(`model`,`loadModel`),Qt=e=>`
365
- import { atom, useStore } from 'likec4/vite-plugin/internal'
366
-
367
- export const isSingleProject = ${e.length===1};
368
- export const projects = ${w.stringify(e,null,2)};
369
-
370
- export const $projects = atom([...projects])
371
-
372
- export function useLikeC4Projects() {
373
- return useStore($projects)
374
- }
375
-
376
- if (import.meta.hot) {
377
- import.meta.hot.accept(md => {
378
- if (!import.meta.hot.data.$projects) {
379
- import.meta.hot.data.$projects = $projects
380
- }
381
- if (!import.meta.hot.data.projects) {
382
- import.meta.hot.data.projects = projects
383
- }
384
- const update = md.projects
385
- if (update) {
386
- import.meta.hot.data.projects.length = 0
387
- import.meta.hot.data.projects.push(...update)
388
- import.meta.hot.data.$projects.set(update)
389
- } else {
390
- import.meta.hot.invalidate()
391
- }
392
- })
393
- }
394
- `,$t={id:`likec4:projects`,virtualId:`likec4:plugin/projects.js`,async load({logger:e,projects:t}){return e.info(S.dim(`generating likec4:projects`)),Qt(p(t,e=>({id:e.id,title:e.title,landingPage:e.config.landingPage})))}},en=e=>`
395
- import { atom, useStore } from 'likec4/vite-plugin/internal'
396
-
397
- export const $viewdata = atom(${w.stringify(e)})
398
-
399
- export function useLikeC4ProjectsOverview() {
400
- return useStore($viewdata)
401
- }
402
-
403
- if (import.meta.hot) {
404
- import.meta.hot.accept(md => {
405
- if (!import.meta.hot.data.$viewdata) {
406
- import.meta.hot.data.$viewdata = $viewdata
407
- }
408
- const update = md.$viewdata?.value
409
- if (update) {
410
- import.meta.hot.data.$viewdata.set(update)
411
- } else {
412
- import.meta.hot.invalidate()
413
- }
414
- })
415
- }
416
- `,tn=()=>`
417
- export function useLikeC4ProjectsOverview() {
418
- throw new Error('No projects overview available for this workspace: single project mode is enabled')
419
- }
420
- `,nn={id:`likec4:projects-overview`,virtualId:`likec4:plugin/projects-overview.js`,async load({logger:e,projects:t,likec4:n}){return t.length<2?tn():(e.info(S.dim(`generating likec4:projects-overview`)),en(await n.projectsOverview()))}};function rn(e){let t=new y;return t.appendTemplate`
421
- /******************************************************************************
422
- * This file was generated
423
- * DO NOT EDIT MANUALLY!
424
- ******************************************************************************/
425
- /* eslint-disable */
426
-
427
- export function pumlSource(viewId) {
428
- switch (viewId) {
429
- `.appendNewLine().indent({indentation:4,indentedChildren(t){t.append(x([...e.views()],e=>_`
430
- case ${Z(JSON.stringify(e.id))}: {
431
- return ${Z(JSON.stringify(Et(e)))}
432
- }
433
- `,{appendNewLineIfNotEmpty:!0})).appendTemplate`
434
- default: {
435
- throw new Error('Unknown viewId: ' + viewId)
436
- }
437
- `}}).append(b,` }`,b).appendTemplate`
438
- }
439
- `.append(b,b),v(t)}const an={...Q(`puml`),async load({likec4:e,project:t,logger:n}){return n.info(S.dim(`generating likec4:puml/${t.id}`)),rn(await e.computedModel(t.id))}},on=$(`puml`,`loadPumlSources`),sn=e=>`
440
- import { jsx as _jsx } from "react/jsx-runtime";
441
- import { LikeC4ModelProvider as Provider, LikeC4View as GenericView, ReactLikeC4 as GenericReactLikeC4 } from 'likec4/react';
442
- import { IconRenderer } from 'likec4:icons/${e}'
443
-
444
- import { useLikeC4Model, useLikeC4Views, useLikeC4View } from 'likec4:model/${e}'
445
-
446
- export function LikeC4ModelProvider({ children }) {
447
- const likeC4Model = useLikeC4Model()
448
- return (_jsx(Provider, { likec4model: likeC4Model, children: children }));
449
- }
450
- export function LikeC4View(props) {
451
- return (_jsx(LikeC4ModelProvider, { children: _jsx(GenericView, { renderIcon: IconRenderer, ...props }) }));
452
- }
453
- export function ReactLikeC4(props) {
454
- return (_jsx(LikeC4ModelProvider, { children: _jsx(GenericReactLikeC4, { renderIcon: IconRenderer, ...props }) }));
455
- }
456
-
457
- export {
458
- useLikeC4Model,
459
- useLikeC4View,
460
- useLikeC4Views
461
- }
462
- `,cn={...Q(`react`),async load({project:e,logger:t}){return t.info(S.dim(`generating likec4:react/${e.id}`)),sn(e.id)}},ln={id:`likec4:react`,virtualId:`likec4:plugin/react.js`,async load({logger:e,projects:t}){let n=i(t);return e.info(S.dim(`generating likec4:react for`)+` `+n.id),sn(n.id)}},un={id:`likec4:rpc`,virtualId:`likec4:plugin/rpc.js`,async load({logger:e}){return e.info(S.dim(`generating likec4:rpc`)),`
463
- import { createRpc } from 'likec4/vite-plugin/internal'
464
-
465
- export const isRpcAvailable = !!import.meta.hot
466
-
467
- let rpc
468
- if (import.meta.hot) {
469
- rpc = createRpc({
470
- send: (event, data) => {
471
- import.meta.hot.send(event, data)
472
- },
473
- on: (event, fn) => {
474
- import.meta.hot.on(event, fn)
475
- }
476
- })
477
-
478
- import.meta.hot.accept()
479
- }
480
-
481
- export const likec4rpc = rpc ?? {
482
- updateView: () => {
483
- throw new Error('likec4rpc.updateView is not available in production')
484
- },
485
- calcAdhocView: () => {
486
- throw new Error('likec4rpc.calcAdhocView is not available in production')
487
- },
488
- }
489
- `}},dn=e=>`
490
- export { IconRenderer } from 'likec4:icons/${e}'
491
- export {
492
- $likec4data,
493
- $likec4model,
494
- useLikeC4Model,
495
- useLikeC4Views,
496
- useLikeC4View
497
- } from 'likec4:model/${e}'
498
- export const projectId = ${Z(JSON.stringify(e))}
499
- `,fn={id:`likec4:single-project`,virtualId:`likec4:plugin/single-project.js`,async load({logger:e,projects:t}){let n=i(t);return e.info(S.dim(`generating likec4:single-project for`)+` `+n.id),dn(n.id)}},pn=[Xt,Vt,Mt,Ft,qt,an,Rt],mn=[...pn,cn],hn=[$t,Zt,nn,fn,ln,Nt,It,Jt,on,zt,Gt,un];function gn({environments:e,...t}){let n,i,a=t.watch??!1;return{name:`vite-plugin-likec4`,applyToEnvironment(t){return e?e.includes(t.name):!0},async configResolved(e){if(t.languageServices)n=t.languageServices;else{let r=a=t.watch??e.mode===`development`;n=(await g(t.workspace??e.root,{graphviz:t.graphviz??`wasm`,configureLogger:`console`,printErrors:t.printErrors??!0,throwIfInvalid:t.throwIfInvalid??!1,watch:r})).languageServices}i=n.workspaceUri.fsPath},resolveId(e){for(let t of mn){let n=t.matches(e);if(n)return t.virtualId(n)}for(let t of hn)if(t.id===e)return t.virtualId;return null},async load(e){for(let t of mn){let r=t.matches(e);if(r){let e=n.project(r);return await t.load({logger:P,likec4:n,project:e,assetsDir:i})}}for(let t of hn)if(t.virtualId===e){let e=n.projects();return D(ee(e)),await t.load({logger:P,likec4:n,projects:e,assetsDir:i})}return null},configureServer(e){let t=e.hot;ie.call(this,{logger:P,likec4:n,server:e});let i=()=>p(n.projects(),e=>({id:e.id,title:e.title,folder:e.folder.toString(),landingPage:e.config.landingPage})),a=i(),o=async t=>{let n=e.moduleGraph.getModuleById(t);if(n&&n.importers.size>0)try{await e.reloadModule(n)}catch(e){P.error(h(e))}};n.builder.onModelParsed(async()=>{let[e]=n.getErrors();if(e){t.send({type:`error`,err:{name:`LikeC4ValidationError`,...F(e.message),plugin:`vite-plugin-likec4`,loc:{file:e.sourceFsPath,line:e.line,column:e.range.start.character+1}}});return}let s=i();if(!r(s,a)){a=s,await o($t.virtualId),await o(Gt.virtualId),await o(Zt.virtualId),a.length>1&&await o(nn.virtualId);return}for(let e of s)for(let t of pn)await o(t.virtualId(e.id))})},async buildEnd(){a&&await n.dispose()}}}export{xt as a,lt as c,ue as d,Et as i,ut as l,kt as n,vt as o,Ot as r,ft as s,gn as t,he as u};
@@ -1 +0,0 @@
1
- import{a as e,i as t,n,r,t as i}from"../_chunks/libs/@nanostores/react.mjs";import{t as a}from"../_chunks/libs/birpc.mjs";import{I as o,_ as s}from"../_chunks/libs/remeda.mjs";import{LikeC4Model as c}from"@likec4/core/model";import{useMemo as l}from"react";function u(e){return a({},{post:t=>e.send(`likec4:rpc`,t),on:t=>e.on(`likec4:rpc`,t),onGeneralError(e,t){console.error(`RPC error in ${t}`,{error:e})},onFunctionError:(e,t)=>{console.error(`RPC error in ${t}`,{error:e})}})}const d=e=>{let n=t(e,e=>c.create(e));function r(t){let n=e.get();if(o(n,t))return;let r={...t,views:s(t.views,e=>{let t=n.views[e.id];return o(t,e)?t:e})};e.set(r)}let a=t(n,e=>[...e.views()].map(e=>e.$layouted));function u(){return i(n)}function d(){return i(a)}function f(e){return i(l(()=>t(n,t=>t.findView(e)?.$layouted??null),[e]))}return{updateModel:r,$likec4model:n,useLikeC4Model:u,useLikeC4Views:d,useLikeC4View:f}};export{e as atom,r as batched,t as computed,d as createHooksForModel,u as createRpc,n as map,i as useStore};