@likec4/core 1.52.0 → 1.53.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.
@@ -1 +1 @@
1
- import{C as e,H as t,K as n,M as r,O as i,Q as a,T as o,V as s,X as c,Y as l,_ as u,c as d,et as f,h as p,i as m,j as h,m as g}from"./libs/remeda.mjs";import{g as _,h as v,ht as y}from"./types.mjs";import{D as b,Q as x,S,l as C}from"./utils.mjs";import{castDraft as w,produce as T}from"immer";function E(r){return f(r,l(e=>!!e.notation),t(g(`notation`)),e(p(t(g(`shape`)),e(p(t(g(`color`)),e(p(o(g(`kind`)),m())),c(),o(([e,t])=>({kinds:t,color:e})))),c(),n(([e,t])=>t.map(({color:t,kinds:n})=>({shape:e,color:t,kinds:n}))))),c(),n(([e,t])=>t.map(({shape:t,color:n,kinds:r})=>({title:e,shape:t,color:n,kinds:r}))),d(g(`shape`),g(`title`),[e=>e.kinds.length,`desc`]))}const D=(e,t)=>e===t||r(e)&&r(t)?!1:!s(e,t);function O(e,t){e.color=t.color,e.kind=t.kind,e.navigateTo=t.navigateTo??null,e.links=t.links?[...t.links]:null,e.tags=[...t.tags],r(t.style.border)?delete e.style.border:e.style.border=t.style.border,h(t.style.opacity)?e.style.opacity=t.style.opacity:delete e.style.opacity,r(t.style.multiple)?delete e.style.multiple:e.style.multiple=t.style.multiple}function k(e,t,n){if(D(t.icon??`none`,e.icon??`none`)){let a=i(e.icon)&&e.icon!==`none`;switch(!0){case a&&i(t.icon)&&t.icon!==`none`:return e.icon=t.icon,!0;case a&&(r(t.icon)||t.icon===`none`):return e.icon=`none`,!0;case!a&&i(t.icon)&&t.icon!==`none`:return n?(e.icon=t.icon,!0):!1}}return!0}function A(e,t,n){let i=!0;return D(e.style.iconColor,t.style.iconColor)&&(r(t.style.iconColor)?delete e.style.iconColor:e.style.iconColor=t.style.iconColor),D(e.style.iconSize,t.style.iconSize)&&(n?r(t.style.iconSize)?delete e.style.iconSize:e.style.iconSize=t.style.iconSize:i=!1),D(e.style.iconPosition,t.style.iconPosition)&&(n?r(t.style.iconPosition)?delete e.style.iconPosition:e.style.iconPosition=t.style.iconPosition:i=!1),i}function j(e,t){return e?`md`in t?(e.md=t.md,delete e.txt,e):(`txt`in t&&(e.txt=t.txt,delete e.md),e):t}function M(e,t,n){let i=!0;return D(e.title,t.title)&&(n?e.title=t.title:i=!1),D(e.description,t.description)&&(r(t.description)?delete e.description:n?e.description=j(e.description,t.description):i=!1),D(e.technology,t.technology)&&(r(t.technology)?delete e.technology:n?e.technology=t.technology:i=!1),i}function N(e,t,n){return e.title=t.title,r(t.description)?delete e.description:e.description=j(e.description,t.description),r(t.technology)?delete e.technology:e.technology=t.technology,!0}function P(e,t){x(e.id===t.id,`applyManualLayout: view ids do not match`),x(e._stage===`layouted`,`applyManualLayout: expected layouted view`),x(t._stage===`layouted`,`applyManualLayout: expected layouted snapshot`),x(e._layout!==`manual`,`applyManualLayout: expected auto-layouted view`);let n=new Set;e._type!==t._type&&n.add(`type-changed`);let r=F(t.nodes,e.nodes,n),i=I(t.edges,e.edges,n),o=E(r);return T(t,s=>{s.title=e.title??t.title,s.description=e.description??t.description,s.tags=e.tags?[...e.tags]:null,s.links=e.links?[...e.links]:null,s.sourcePath=e.sourcePath,s[y]=`manual`,o&&o.length>0?s.notation={nodes:o}:delete s.notation,s.nodes=w(r),s.edges=w(i),v(e)&&s._type===`dynamic`&&(s.variant=e.variant),_(e)&&s._type===`element`&&(e.viewOf?s.viewOf=e.viewOf:delete s.viewOf,e.extends?s.extends=e.extends:delete s.extends);let c=[...n];a(c,1)?s.drifts=c:(s.hash=e.hash,delete s.drifts)})}function F(e,t,n){let i=new Map(t.map(e=>[e.id,e])),o=e.map(e=>{let t=i.get(e.id);return t?(i.delete(t.id),T(e,i=>{O(i,t);let o=new Set,s=e.children.length>0,c=t.children.length>0;(D(i.modelRef,t.modelRef)||D(i.deploymentRef,t.deploymentRef))&&o.add(`modelRef-changed`),c&&!s&&o.add(`became-compound`),!c&&s&&o.add(`became-leaf`),D(i.parent,t.parent)&&o.add(`parent-changed`);let l=i.width+5>=t.width&&i.height+5>=t.height;D(i.shape,t.shape)&&(l?i.shape=t.shape:o.add(`shape-changed`)),A(i,t,l)||o.add(`label-changed`),k(i,t,l&&c===s)||o.add(`label-changed`),(s?N:M)(i,t,l)||o.add(`label-changed`),D(i.notes,t.notes)&&(r(t.notes)?delete i.notes:i.notes=j(i.notes,t.notes)),D(e.notation,t.notation)&&(i.notation=t.notation??null),s&&c&&C(new Set(e.children),new Set(t.children)).size>0&&o.add(`children-changed`);let u=[...o];a(u,1)?(n.add(`nodes-drift`),i.drifts=u):delete i.drifts})):(n.add(`nodes-removed`),{...e,drifts:[`removed`]})});return i.size>0&&n.add(`nodes-added`),o}function I(e,t,n){let i=new Map(t.map(e=>[e.id,e])),o=e.map(e=>{let t=i.get(e.id)??f(i.values(),b(t=>t.source===e.source&&t.target===e.target),S());return t&&i.delete(t.id),T(e,i=>{if(!t){i.drifts=[`removed`],n.add(`edges-removed`);return}let o=new Set,s=e.id===t.id;switch(!0){case s&&e.source==t.source&&e.target==t.target:D(i.dir??`forward`,t.dir??`forward`)&&o.add(`direction-changed`);break;case s&&e.source==t.target&&e.target==t.source:e.source!==e.target&&o.add(`direction-changed`);break;case s:e.source!=t.source&&o.add(`source-changed`),e.target!=t.target&&o.add(`target-changed`);break;default:x(e.id!=t.id,`Unexpected case in edge drift detection, ids should not match`),x(e.source==t.source,`Unexpected case in edge drift detection, sources should match`),x(e.target==t.target,`Unexpected case in edge drift detection, targets should match`),D(i.dir??`forward`,t.dir??`forward`)&&o.add(`direction-changed`);break}if(i.color=t.color,i.line=t.line,i.navigateTo=t.navigateTo??null,i.tags=t.tags?[...t.tags]:null,D(e.notes,t.notes)&&(r(e.notes)!==r(t.notes)&&o.add(`notes-changed`),i.notes=t.notes??e.notes),t.astPath?i.astPath=t.astPath:delete i.astPath,D(u(e,[`label`,`description`,`technology`,`labelBBox`]),u(t,[`label`,`description`,`technology`,`labelBBox`])))switch(!0){case t.labelBBox&&!e.labelBBox:o.add(`label-added`);break;case e.labelBBox&&!t.labelBBox:o.add(`label-removed`);break;case!!e.labelBBox&&!!t.labelBBox:t.labelBBox.width*t.labelBBox.height>(e.labelBBox.width+5)*(e.labelBBox.height+5)&&(i.labelBBox.width=Math.round(t.labelBBox.width),i.labelBBox.height=Math.round(t.labelBBox.height)),D(e.label,t.label)&&(r(t.label)!==r(e.label)&&o.add(`label-changed`),i.label=t.label??e.label),D(e.description,t.description)&&(r(t.description)!==r(e.description)&&o.add(`label-changed`),t.description&&(i.description=j(e.description,t.description))),D(e.technology,t.technology)&&(r(t.technology)!==r(e.technology)&&o.add(`label-changed`),i.technology=t.technology??e.technology??null);break;default:x(!e.labelBBox,`Unexpected case in edge labelBBox drift detection`),x(!t.labelBBox,`Unexpected case in next labelBBox drift detection`);break}let c=[...o];a(c,1)?(n.add(`edges-drift`),i.drifts=c):delete i.drifts})});return i.size>0&&n.add(`edges-added`),o}function L(e,t){let{drifts:n,...r}=P(e,t);if(!n||n.length===0)return T(e,e=>{delete e.drifts,e[y]=`auto`});let i=new Set;n.includes(`type-changed`)&&i.add(`type-changed`);let o=new Map(r.nodes.map(e=>[e.id,e])),s=new Map(r.edges.map(e=>[e.id,e])),c=e.nodes.map(e=>{let t=o.get(e.id);return t&&o.delete(t.id),T(e,e=>{if(!t){i.add(`nodes-added`),e.drifts=[`added`];return}t.drifts?(i.add(`nodes-drift`),e.drifts=[...t.drifts]):delete e.drifts})});o.size>0&&i.add(`nodes-removed`);let l=e.edges.map(e=>{let t=s.get(e.id)??f(s.values(),b(t=>t.source===e.source&&t.target===e.target),S());return t&&s.delete(t.id),T(e,e=>{if(!t){i.add(`edges-added`),e.drifts=[`added`];return}t.drifts?(i.add(`edges-drift`),e.drifts=[...t.drifts]):delete e.drifts})});s.size>0&&i.add(`edges-removed`);let u=[...i];return T(e,e=>{a(u,1)?e.drifts=u:delete e.drifts,e.nodes=w(c),e.edges=w(l),e[y]=`auto`})}export{P as n,E as r,L as t};
1
+ import{C as e,H as t,K as n,M as r,O as i,Q as a,T as o,V as s,X as c,Y as l,_ as u,c as d,et as f,h as p,i as m,j as h,m as g}from"./libs/remeda.mjs";import{_t as _,g as v,gt as y,h as b}from"./types.mjs";import{D as x,Q as S,S as C,l as w}from"./utils.mjs";import{castDraft as T,produce as E}from"immer";function D(e,t){let{nodes:n,edges:r,hasManualLayout:i,...a}=e,o=new Map(n.map(e=>[e.id,e])),s=new Map(r.map(e=>[e.id,e])),c=t.nodes.map(e=>{let t=o.get(e.id);return t?{...t,x:e.x,y:e.y,width:e.width,height:e.height,labelBBox:e.labelBBox}:e}),l=t.edges.map(e=>{let t=s.get(e.id);return t?{...t,points:e.points,label:e.label,labelBBox:e.labelBBox,...e.controlPoints!=null&&{controlPoints:e.controlPoints}}:e}),u={...t,...a,[_]:`layouted`,bounds:t.bounds,nodes:c,edges:l};return i?u[y]=`auto`:delete u[y],u}function O(r){return f(r,l(e=>!!e.notation),t(g(`notation`)),e(p(t(g(`shape`)),e(p(t(g(`color`)),e(p(o(g(`kind`)),m())),c(),o(([e,t])=>({kinds:t,color:e})))),c(),n(([e,t])=>t.map(({color:t,kinds:n})=>({shape:e,color:t,kinds:n}))))),c(),n(([e,t])=>t.map(({shape:t,color:n,kinds:r})=>({title:e,shape:t,color:n,kinds:r}))),d(g(`shape`),g(`title`),[e=>e.kinds.length,`desc`]))}const k=(e,t)=>e===t||r(e)&&r(t)?!1:!s(e,t);function A(e,t){e.color=t.color,e.kind=t.kind,e.navigateTo=t.navigateTo??null,e.links=t.links?[...t.links]:null,e.tags=[...t.tags],r(t.style.border)?delete e.style.border:e.style.border=t.style.border,h(t.style.opacity)?e.style.opacity=t.style.opacity:delete e.style.opacity,r(t.style.multiple)?delete e.style.multiple:e.style.multiple=t.style.multiple}function j(e,t,n){if(k(t.icon??`none`,e.icon??`none`)){let a=i(e.icon)&&e.icon!==`none`;switch(!0){case a&&i(t.icon)&&t.icon!==`none`:return e.icon=t.icon,!0;case a&&(r(t.icon)||t.icon===`none`):return e.icon=`none`,!0;case!a&&i(t.icon)&&t.icon!==`none`:return n?(e.icon=t.icon,!0):!1}}return!0}function M(e,t,n){let i=!0;return k(e.style.iconColor,t.style.iconColor)&&(r(t.style.iconColor)?delete e.style.iconColor:e.style.iconColor=t.style.iconColor),k(e.style.iconSize,t.style.iconSize)&&(n?r(t.style.iconSize)?delete e.style.iconSize:e.style.iconSize=t.style.iconSize:i=!1),k(e.style.iconPosition,t.style.iconPosition)&&(n?r(t.style.iconPosition)?delete e.style.iconPosition:e.style.iconPosition=t.style.iconPosition:i=!1),i}function N(e,t){return e?`md`in t?(e.md=t.md,delete e.txt,e):(`txt`in t&&(e.txt=t.txt,delete e.md),e):t}function P(e,t,n){let i=!0;return k(e.title,t.title)&&(n?e.title=t.title:i=!1),k(e.description,t.description)&&(r(t.description)?delete e.description:n?e.description=N(e.description,t.description):i=!1),k(e.technology,t.technology)&&(r(t.technology)?delete e.technology:n?e.technology=t.technology:i=!1),i}function F(e,t,n){return e.title=t.title,r(t.description)?delete e.description:e.description=N(e.description,t.description),r(t.technology)?delete e.technology:e.technology=t.technology,!0}function I(e,t){S(e.id===t.id,`applyManualLayout: view ids do not match`),S(e._stage===`layouted`,`applyManualLayout: expected layouted view`),S(t._stage===`layouted`,`applyManualLayout: expected layouted snapshot`),S(e._layout!==`manual`,`applyManualLayout: expected auto-layouted view`);let n=new Set;e._type!==t._type&&n.add(`type-changed`);let r=L(t.nodes,e.nodes,n),i=R(t.edges,e.edges,n),o=O(r);return E(t,s=>{s.title=e.title??t.title,s.description=e.description??t.description,s.tags=e.tags?[...e.tags]:null,s.links=e.links?[...e.links]:null,s.sourcePath=e.sourcePath,s[y]=`manual`,o&&o.length>0?s.notation={nodes:o}:delete s.notation,s.nodes=T(r),s.edges=T(i),b(e)&&s._type===`dynamic`&&(s.variant=e.variant),v(e)&&s._type===`element`&&(e.viewOf?s.viewOf=e.viewOf:delete s.viewOf,e.extends?s.extends=e.extends:delete s.extends);let c=[...n];a(c,1)?s.drifts=c:(s.hash=e.hash,delete s.drifts)})}function L(e,t,n){let i=new Map(t.map(e=>[e.id,e])),o=e.map(e=>{let t=i.get(e.id);return t?(i.delete(t.id),E(e,i=>{A(i,t);let o=new Set,s=e.children.length>0,c=t.children.length>0;(k(i.modelRef,t.modelRef)||k(i.deploymentRef,t.deploymentRef))&&o.add(`modelRef-changed`),c&&!s&&o.add(`became-compound`),!c&&s&&o.add(`became-leaf`),k(i.parent,t.parent)&&o.add(`parent-changed`);let l=i.width+5>=t.width&&i.height+5>=t.height;k(i.shape,t.shape)&&(l?i.shape=t.shape:o.add(`shape-changed`)),M(i,t,l)||o.add(`label-changed`),j(i,t,l&&c===s)||o.add(`label-changed`),(s?F:P)(i,t,l)||o.add(`label-changed`),k(i.notes,t.notes)&&(r(t.notes)?delete i.notes:i.notes=N(i.notes,t.notes)),k(e.notation,t.notation)&&(i.notation=t.notation??null),s&&c&&w(new Set(e.children),new Set(t.children)).size>0&&o.add(`children-changed`);let u=[...o];a(u,1)?(n.add(`nodes-drift`),i.drifts=u):delete i.drifts})):(n.add(`nodes-removed`),{...e,drifts:[`removed`]})});return i.size>0&&n.add(`nodes-added`),o}function R(e,t,n){let i=new Map(t.map(e=>[e.id,e])),o=e.map(e=>{let t=i.get(e.id)??f(i.values(),x(t=>t.source===e.source&&t.target===e.target),C());return t&&i.delete(t.id),E(e,i=>{if(!t){i.drifts=[`removed`],n.add(`edges-removed`);return}let o=new Set,s=e.id===t.id;switch(!0){case s&&e.source==t.source&&e.target==t.target:k(i.dir??`forward`,t.dir??`forward`)&&o.add(`direction-changed`);break;case s&&e.source==t.target&&e.target==t.source:e.source!==e.target&&o.add(`direction-changed`);break;case s:e.source!=t.source&&o.add(`source-changed`),e.target!=t.target&&o.add(`target-changed`);break;default:S(e.id!=t.id,`Unexpected case in edge drift detection, ids should not match`),S(e.source==t.source,`Unexpected case in edge drift detection, sources should match`),S(e.target==t.target,`Unexpected case in edge drift detection, targets should match`),k(i.dir??`forward`,t.dir??`forward`)&&o.add(`direction-changed`);break}if(i.color=t.color,i.line=t.line,i.navigateTo=t.navigateTo??null,i.tags=t.tags?[...t.tags]:null,k(e.notes,t.notes)&&(r(e.notes)!==r(t.notes)&&o.add(`notes-changed`),i.notes=t.notes??e.notes),t.astPath?i.astPath=t.astPath:delete i.astPath,k(u(e,[`label`,`description`,`technology`,`labelBBox`]),u(t,[`label`,`description`,`technology`,`labelBBox`])))switch(!0){case t.labelBBox&&!e.labelBBox:o.add(`label-added`);break;case e.labelBBox&&!t.labelBBox:o.add(`label-removed`);break;case!!e.labelBBox&&!!t.labelBBox:t.labelBBox.width*t.labelBBox.height>(e.labelBBox.width+5)*(e.labelBBox.height+5)&&(i.labelBBox.width=Math.round(t.labelBBox.width),i.labelBBox.height=Math.round(t.labelBBox.height)),k(e.label,t.label)&&(r(t.label)!==r(e.label)&&o.add(`label-changed`),i.label=t.label??e.label),k(e.description,t.description)&&(r(t.description)!==r(e.description)&&o.add(`label-changed`),t.description&&(i.description=N(e.description,t.description))),k(e.technology,t.technology)&&(r(t.technology)!==r(e.technology)&&o.add(`label-changed`),i.technology=t.technology??e.technology??null);break;default:S(!e.labelBBox,`Unexpected case in edge labelBBox drift detection`),S(!t.labelBBox,`Unexpected case in next labelBBox drift detection`);break}let c=[...o];a(c,1)?(n.add(`edges-drift`),i.drifts=c):delete i.drifts})});return i.size>0&&n.add(`edges-added`),o}function z(e,t){let{drifts:n,...r}=I(e,t);if(!n||n.length===0)return E(e,e=>{delete e.drifts,e[y]=`auto`});let i=new Set;n.includes(`type-changed`)&&i.add(`type-changed`);let o=new Map(r.nodes.map(e=>[e.id,e])),s=new Map(r.edges.map(e=>[e.id,e])),c=e.nodes.map(e=>{let t=o.get(e.id);return t&&o.delete(t.id),E(e,e=>{if(!t){i.add(`nodes-added`),e.drifts=[`added`];return}t.drifts?(i.add(`nodes-drift`),e.drifts=[...t.drifts]):delete e.drifts})});o.size>0&&i.add(`nodes-removed`);let l=e.edges.map(e=>{let t=s.get(e.id)??f(s.values(),x(t=>t.source===e.source&&t.target===e.target),C());return t&&s.delete(t.id),E(e,e=>{if(!t){i.add(`edges-added`),e.drifts=[`added`];return}t.drifts?(i.add(`edges-drift`),e.drifts=[...t.drifts]):delete e.drifts})});s.size>0&&i.add(`edges-removed`);let u=[...i];return E(e,e=>{a(u,1)?e.drifts=u:delete e.drifts,e.nodes=T(c),e.edges=T(l),e[y]=`auto`})}export{D as i,I as n,O as r,z as t};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime.mjs";import{A as t,E as n,I as r,L as i,N as a,O as o,Q as s,T as c,X as ee,c as te,et as l,i as u,l as d,m as ne,r as f,s as re}from"./libs/remeda.mjs";import{A as ie,D as ae,J as p,Q as oe,V as se,_t as m,bt as h,dt as ce,gt as g,lt as le,pt as ue,st as de,t as _,ut as fe,vt as pe,xt as v,yt as y}from"./types.mjs";import{$ as b,A as x,B as S,D as me,E as he,F as C,H as ge,I as w,J as _e,L as T,Q as E,R as ve,S as D,U as ye,Y as be,a as O,c as k,h as A,j,k as xe,o as M,q as Se,r as Ce,u as N,y as we,z as Te}from"./utils.mjs";import{t as P}from"./libs/mnemonist.mjs";import{n as Ee,t as De}from"./manual-layout.mjs";var F=class{Aux;id;_literalId;hierarchyLevel;imported;constructor(e,t){this.$model=e,this.$element=t,this.id=this.$element.id,this._literalId=this.$element.id;let[n,r]=ue(this.id);n?(this.imported={from:n,fqn:r},this.hierarchyLevel=C(r)):(this.imported=null,this.hierarchyLevel=C(this.id))}get name(){return Te(this.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$element.kind}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get tags(){return A(this,Symbol.for(`tags`),()=>u([...this.$element.tags??[],...this.$model.specification.elements[this.$element.kind]?.tags??[]]))}get title(){return this.$element.title}get hasSummary(){return!!this.$element.summary&&!!this.$element.description&&!t(this.$element.summary,this.$element.description)}get summary(){return _.memoize(this,`summary`,h(this.$element))}get description(){return _.memoize(this,`description`,y(this.$element))}get technology(){return this.$element.technology??null}get links(){return this.$element.links??[]}get defaultView(){return A(this,Symbol.for(`defaultView`),()=>D(this.scopedViews())??null)}get isRoot(){return this.parent===null}get style(){return A(this,`style`,()=>v({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$element.style}))}get projectId(){return this.imported?.from??this.$model.projectId}isAncestorOf(e){return w(this,e)}isDescendantOf(e){return w(e,this)}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=j(this.id,e.id);return t?this.$model.element(t):null}children(){return this.$model.children(this)}descendants(e){return e?ge([...this.$model.descendants(this)],e)[Symbol.iterator]():this.$model.descendants(this)}siblings(){return this.$model.siblings(this)}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}get allOutgoing(){return A(this,Symbol.for(`allOutgoing`),()=>new Set(this.outgoing()))}get allIncoming(){return A(this,Symbol.for(`allIncoming`),()=>new Set(this.incoming()))}views(){return A(this,Symbol.for(`views`),()=>{let e=new Set;for(let t of this.$model.views())t.includesElement(this.id)&&e.add(t);return e})}scopedViews(){return A(this,Symbol.for(`scopedViews`),()=>{let e=new Set;for(let t of this.$model.views())t.isScopedElementView()&&t.viewOf.id===this.id&&e.add(t);return e})}isDeployed(){return o(D(this.deployments()))}deployments(){return this.$model.deployment.instancesOf(this)}hasMetadata(){return!!this.$element.metadata&&!i(this.$element.metadata)}getMetadata(e){return e?this.$element.metadata?.[e]:this.$element.metadata??{}}isTagged(e){return this.tags.includes(e)}},Oe=class{Aux;get style(){return A(this,`style`,()=>v({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$node.style}))}get name(){return Te(this.id)}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get summary(){return _.memoize(this,`summary`,h(this.$node))}get description(){return _.memoize(this,`description`,y(this.$node))}get technology(){return this.$node.technology??null}get links(){return this.$node.links??[]}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=j(this.id,e.id);return t?this.$model.node(t):null}siblings(){return this.$model.siblings(this)}isSibling(e){return this.parent===e.parent}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}*views(){for(let e of this.$model.views())e._type===`deployment`&&e.includesDeployment(this.id)&&(yield e)}isDeploymentNode(){return!1}isInstance(){return!1}get allOutgoing(){return A(this,Symbol.for(`allOutgoing`),()=>z.from(new Set(this.outgoingModelRelationships()),new Set(this.outgoing())))}get allIncoming(){return A(this,Symbol.for(`allIncoming`),()=>z.from(new Set(this.incomingModelRelationships()),new Set(this.incoming())))}hasMetadata(){return!!this.$node.metadata&&!i(this.$node.metadata)}getMetadata(e){return e?this.$node.metadata?.[e]:this.$node.metadata??{}}isTagged(e){return this.tags.includes(e)}},I=class extends Oe{id;_literalId;title;hierarchyLevel;constructor(e,t){super(),this.$model=e,this.$node=t,this.id=t.id,this._literalId=t.id,this.title=t.title,this.hierarchyLevel=C(t.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$node.kind}get tags(){return A(this,Symbol.for(`tags`),()=>u([...this.$node.tags??[],...this.$model.$model.specification.deployments[this.kind]?.tags??[]]))}children(){return this.$model.children(this)}descendants(e=`desc`){return this.$model.descendants(this,e)}isDeploymentNode(){return!0}*instances(){for(let e of this.descendants(`desc`))e.isInstance()&&(yield e)}onlyOneInstance(){let e=this.children();if(e.size!==1)return null;let t=D(e);return t?t.isInstance()?t:t.onlyOneInstance():null}_relationshipsFromInstances=null;relationshipsFromInstances(){if(this._relationshipsFromInstances)return this._relationshipsFromInstances;let{outgoing:e,incoming:t}=this._relationshipsFromInstances={outgoing:new Set,incoming:new Set};for(let n of this.instances()){for(let t of n.element.outgoing())e.add(t);for(let e of n.element.incoming())t.add(e)}return this._relationshipsFromInstances}outgoingModelRelationships(){return this.relationshipsFromInstances().outgoing.values()}incomingModelRelationships(){return this.relationshipsFromInstances().incoming.values()}internalModelRelationships(){let{outgoing:e,incoming:t}=this.relationshipsFromInstances();return k(t,e)}},L=class extends Oe{id;_literalId;title;hierarchyLevel;constructor(e,t,n){super(),this.$model=e,this.$instance=t,this.element=n,this.id=t.id,this._literalId=t.id,this.title=t.title??n.title,this.hierarchyLevel=C(t.id)}get $node(){return this.$instance}get parent(){return b(this.$model.parent(this),`Parent of ${this.id} not found`)}get style(){return A(this,`style`,()=>v({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.element.$element.style,...this.$instance.style}))}get tags(){return A(this,Symbol.for(`tags`),()=>u([...this.$instance.tags??[],...this.element.tags]))}get kind(){return this.element.kind}get summary(){return _.memoize(this,`summary`,h(this.$instance)??h(this.element.$element))}get description(){return _.memoize(this,`description`,y(this.$instance)??y(this.element.$element))}get technology(){return this.$instance.technology??this.element.technology??null}get links(){return this.$instance.links??this.element.links}isInstance(){return!0}outgoingModelRelationships(){return this.element.outgoing()}incomingModelRelationships(){return this.element.incoming()}*views(){for(let e of this.$model.views())if(e._type===`deployment`){if(e.includesDeployment(this.id)){yield e;continue}e.includesDeployment(this.parent.id)&&this.parent.onlyOneInstance()&&(yield e)}}},ke=class{constructor(e,t){this.instance=e,this.element=t}get id(){return this.instance.id}get _literalId(){return this.instance.id}get style(){return A(this,`style `,()=>({shape:this.element.shape,color:this.element.color,...this.element.$element.style}))}get shape(){return this.element.shape}get color(){return this.element.color}get title(){return this.element.title}get summary(){return this.element.summary}get description(){return this.element.description}get technology(){return this.element.technology}isDeploymentNode(){return!1}isInstance(){return!1}},R=class{boundary;source;target;constructor(e,t){this.$model=e,this.$relationship=t,this.source=e.deploymentRef(t.source),this.target=e.deploymentRef(t.target);let n=j(this.source.id,this.target.id);this.boundary=n?this.$model.node(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return o(this.$relationship.title)?this.$relationship.title:null}get technology(){return r(this.$relationship.technology)?(this.kind&&this.$model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return _.memoize(this,`summary`,h(this.$relationship))}get description(){return _.memoize(this,`description`,y(this.$relationship))}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get navigateTo(){return this.$relationship.navigateTo?this.$model.$model.view(this.$relationship.navigateTo):null}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.$model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.$model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.$model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.$model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!0}isModelRelation(){return!1}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},z=class e{static empty(){return new e}static from(t,n){return new e(new Set(t),new Set(n))}constructor(e=new Set,t=new Set){this.model=e,this.deployment=t}get isEmpty(){return this.model.size===0&&this.deployment.size===0}get nonEmpty(){return this.model.size>0||this.deployment.size>0}get size(){return this.model.size+this.deployment.size}intersect(t){return e.from(k(this.model,t.model),k(this.deployment,t.deployment))}difference(t){return e.from(O(this.model,t.model),O(this.deployment,t.deployment))}union(t){return e.from(N(this.model,t.model),N(this.deployment,t.deployment))}};const B=e=>typeof e==`string`?e:e.id,Ae=`/`,V=e=>{if(E(!e.includes(`
2
- `),`View title cannot contain newlines`),e.includes(`/`)){let t=e.split(`/`).map(e=>e.trim()).filter(e=>e.length>0);return s(t,1)?t:[``]}return[e.trim()]},H=e=>V(e).join(`/`),je=e=>{let t=V(e);return s(t,2)?t.slice(0,-1).join(`/`):null},Me=e=>e.includes(`/`)?V(e).pop()??e:e.trim();var Ne=class{#e=new Map;#t=new Map;#n=new P.default(()=>new Set);#r=new P.default(()=>new Set);#i=new Set;#a=new Map;#o=new P.default(()=>new Set);#s=new P.default(()=>new Set);#c=new P.default(()=>new Set);#l=new P.default(()=>new Set);#u=new Map;$deployments;constructor(e){this.$model=e;let t=this.$deployments=e.$data.deployments,n=f(t.elements);for(let e of ye(n)){let t=this.addElement(e);for(let e of t.tags)this.#l.get(e).add(t);t.isInstance()&&this.#r.get(t.element.id).add(t)}for(let e of f(t.relations)){let t=this.addRelation(e);for(let e of t.tags)this.#l.get(e).add(t)}}get $styles(){return this.$model.$styles}get projectId(){return this.$model.projectId}get project(){return this.$model.project}get specification(){return this.$model.specification}element(e){if(e instanceof I||e instanceof L)return e;let t=B(e);return b(this.#e.get(t),`Element ${t} not found`)}findElement(e){return this.#e.get(e)??null}node(e){let t=this.element(e);return E(t.isDeploymentNode(),`Element ${t.id} is not a deployment node`),t}findNode(e){let t=this.findElement(e);return t?(E(t.isDeploymentNode(),`Element ${t?.id} is not a deployment node`),t):null}instance(e){let t=this.element(e);return E(t.isInstance(),`Element ${t.id} is not a deployed instance`),t}findInstance(e){let t=this.findElement(e);return t?(E(t.isInstance(),`Element ${t?.id} is not a deployed instance`),t):null}roots(){return this.#i.values()}elements(){return this.#e.values()}*nodes(){for(let e of this.#e.values())e.isDeploymentNode()&&(yield e)}*nodesOfKind(e){for(let t of this.#e.values())t.isDeploymentNode()&&t.kind===e&&(yield t)}*instances(){for(let e of this.#e.values())e.isInstance()&&(yield e)}*instancesOf(e){let t=B(e),n=this.#r.get(t);n&&(yield*n)}deploymentRef(e){if(p.isInsideInstanceRef(e)){let{deployment:t,element:n}=e;return xe(this.#u,`${t}@${n}`,()=>new ke(this.instance(t),this.$model.element(n)))}return this.element(e.deployment)}relationships(){return this.#a.values()}relationship(e){let t=B(e);return b(this.#a.get(t),`DeploymentRelationModel ${t} not found`)}findRelationship(e){return this.#a.get(e)??null}*views(){for(let e of this.$model.views())e.isDeploymentView()&&(yield e)}parent(e){let t=B(e);return this.#t.get(t)||null}children(e){let t=B(e);return this.#n.get(t)}*siblings(e){let t=B(e),n=this.parent(e)?.children()??this.roots();for(let e of n)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this.#t.get(t);)yield n,t=n.id}*descendants(e,t=`desc`){for(let n of this.children(e))t===`asc`?(yield n,yield*this.descendants(n.id)):(yield*this.descendants(n.id),yield n)}*incoming(e,t=`all`){let n=B(e);for(let e of this.#o.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this.#s.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}addElement(e){if(this.#e.has(e.id))throw Error(`Element ${e.id} already exists`);let t=se(e)?new I(this,Object.freeze(e)):new L(this,Object.freeze(e),this.$model.element(e.element));this.#e.set(t.id,t);let n=S(t.id);return n?(E(this.#e.has(n),`Parent ${n} of ${t.id} not found`),this.#t.set(t.id,this.node(n)),this.#n.get(n).add(t)):(E(t.isDeploymentNode(),`Root element ${t.id} is not a deployment node`),this.#i.add(t)),t}addRelation(e){if(this.#a.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new R(this,Object.freeze(e));this.#a.set(t.id,t),this.#o.get(t.target.id).add(t),this.#s.get(t.source.id).add(t);let n=t.boundary?.id??null;if(n)for(let e of[n,...x(n)])this.#c.get(e).add(t);for(let e of x(t.source.id)){if(e===n)break;this.#s.get(e).add(t)}for(let e of x(t.target.id)){if(e===n)break;this.#o.get(e).add(t)}return t}},U=class{source;target;boundary;constructor(e,t){this.model=e,this.$relationship=t,this.source=e.element(p.flatten(t.source)),this.target=e.element(p.flatten(t.target));let n=j(this.source.id,this.target.id);this.boundary=n?this.model.element(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return r(this.$relationship.title)?null:this.$relationship.title}get technology(){return r(this.$relationship.technology)?(this.kind&&this.model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return _.memoize(this,`summary`,h(this.$relationship))}get description(){return _.memoize(this,`description`,y(this.$relationship))}get navigateTo(){return this.$relationship.navigateTo?this.model.view(this.$relationship.navigateTo):null}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!1}isModelRelation(){return!0}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},W=class{Aux;$viewModel;$view;$edge;constructor(e,t,n,r){this.source=n,this.target=r,this.$viewModel=e,this.$view=e.$view,this.$edge=t}get id(){return this.$edge.id}get parent(){return this.$edge.parent?this.$viewModel.node(this.$edge.parent):null}get label(){return this.$edge.label??null}get description(){return _.memoize(this,`description`,this.$edge.description)}get technology(){return this.$edge.technology??null}hasParent(){return this.$edge.parent!==null}get tags(){return this.$edge.tags??[]}get stepNumber(){return this.isStep()?de(this.id):null}get navigateTo(){return this.$edge.navigateTo?this.$viewModel.$model.view(this.$edge.navigateTo):null}get color(){return this.$edge.color}get line(){return this.$edge.line??this.$viewModel.$styles.defaults.relationship.line}get head(){return this.$edge.head??this.$viewModel.$styles.defaults.relationship.arrow}get tail(){return this.$edge.tail}isStep(){return ce(this.id)}*relationships(e){for(let t of this.$edge.relations)if(e){let n=this.$viewModel.$model.findRelationship(t,e);n&&(yield n)}else yield this.$viewModel.$model.relationship(t)}includesRelation(e){let t=typeof e==`string`?e:e.id;return this.$edge.relations.includes(t)}isTagged(e){return this.tags.includes(e)}},G=class{Aux;$viewModel;$view;$node;constructor(e,t){this.$viewModel=e,this.$view=e.$view,this.$node=t}get id(){return this.$node.id}get title(){return this.$node.title}get kind(){return this.$node.kind}get description(){return _.memoize(this,`description`,this.$node.description)}get technology(){return this.$node.technology??null}get notes(){return _.memoize(this,`notes`,this.$node.notes)}get parent(){return this.$node.parent?this.$viewModel.node(this.$node.parent):null}get element(){let e=this.$node.modelRef;return e?this.$viewModel.$model.element(e):null}get deployment(){let e=this.$node.deploymentRef;return e?this.$viewModel.$model.deployment.element(e):null}get shape(){return this.$node.shape}get color(){return this.$node.color}get icon(){return this.$node.icon??null}get tags(){return this.$node.tags}get links(){return this.$node.links??[]}get navigateTo(){return this.$node.navigateTo?this.$viewModel.$model.view(this.$node.navigateTo):null}get style(){return this.$node.style}get x(){return`x`in this.$node?this.$node.x:void 0}get y(){return`y`in this.$node?this.$node.y:void 0}get width(){return`width`in this.$node?this.$node.width:void 0}get height(){return`height`in this.$node?this.$node.height:void 0}children(){return A(this,`children`,()=>new Set(this.$node.children.map(e=>this.$viewModel.node(e))))}*ancestors(){let e=this.parent;for(;e;)yield e,e=e.parent}*siblings(){let e=this.parent?.children()??this.$viewModel.roots();for(let t of e)t.id!==this.id&&(yield t)}*incoming(e=`all`){for(let t of this.$node.inEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.target.id===this.id:case e===`to-descendants`&&n.target.id!==this.id:yield n;break}}}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoing(e=`all`){for(let t of this.$node.outEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.source.id===this.id:case e===`from-descendants`&&n.source.id!==this.id:yield n;break}}}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}isLayouted(){return`width`in this.$node&&`height`in this.$node}hasChildren(){return this.$node.children.length>0}hasParent(){return this.$node.parent!==null}hasElement(){return o(this.$node.modelRef)}hasDeployment(){return o(this.$node.deploymentRef)}hasDeployedInstance(){return this.hasElement()&&this.hasDeployment()}isGroup(){return fe(this.$node)}isTagged(e){return this.tags.includes(e)}},K=class{Aux;#e;#t=new Set;#n=new Map;#r=new Map;#i=new Set;#a=new Set;#o=new Set;#s=new P.default(e=>new Set);#c;id;$model;title;folder;viewPath;constructor(e,t,n,r){this.$model=e,this.#e=n,this.id=n.id,this.folder=t,this.#c=r;for(let e of this.#e.nodes){let t=new G(this,Object.freeze(e));this.#n.set(e.id,t),e.parent||this.#t.add(t),e.deploymentRef&&this.#a.add(e.deploymentRef),e.modelRef&&this.#i.add(e.modelRef);for(let e of t.tags)this.#s.get(e).add(t)}for(let e of this.#e.edges){let t=new W(this,Object.freeze(e),this.node(e.source),this.node(e.target));for(let e of t.tags)this.#s.get(e).add(t);for(let t of e.relations)this.#o.add(t);this.#r.set(e.id,t)}this.title=n.title?Me(n.title):null,this.viewPath=n.title?H(n.title):n.id}get $styles(){return this.$model.$styles}get _type(){return this.#e[m]}get stage(){return this.#e[g]}get bounds(){if(`bounds`in this.#e)return this.#e.bounds;if(this.#c)return this.#c.bounds;throw Error(`View is not layouted`)}get titleOrId(){return this.title??this.viewOf?.title??this.id}get titleOrUntitled(){return this.title??`Untitled`}get breadcrumbs(){return A(this,`breadcrumbs`,()=>this.folder.isRoot?[this]:[...this.folder.breadcrumbs,this])}get description(){return _.memoize(this,`description`,this.#e.description)}get tags(){return this.#e.tags??[]}get links(){return this.#e.links??[]}get viewOf(){if(this.isElementView()){let e=this.#e.viewOf;return e?this.$model.element(e):null}return null}get mode(){return this.isDynamicView()?this.#e.variant??`diagram`:null}get includedTags(){return[...this.#s.keys()]}get $view(){if(!this.isLayouted()||`drifts`in this.#e)return this.#e;let e=this.#c;return e?A(this,`withDriftReasons`,()=>De(this.#e,e)):this.#e}get $layouted(){if(!this.isLayouted())throw Error(`View is not layouted`);return this.$manual??this.#e}get hasManualLayout(){return this.#c!==void 0}get hasLayoutDrifts(){if(!this.isLayouted())return!1;let e=this.$manual;return!!e?.drifts&&e.drifts.length>0}get $manual(){if(!this.isLayouted())return null;let e=this.#c;return e?A(this,`snapshotWithManualLayout`,()=>Ee(this.#e,e)):null}get projectId(){return this.$model.projectId}roots(){return this.#t.values()}*compounds(){for(let e of this.#n.values())e.hasChildren()&&(yield e)}node(e){let t=B(e);return b(this.#n.get(t),`Node ${t} not found in view ${this.#e.id}`)}findNode(e){return this.#n.get(B(e))??null}findNodeWithElement(e){let t=B(e);return this.#i.has(t)?he(this.#n.values(),e=>e.hasElement()&&e.element.id===t)??null:null}nodes(){return this.#n.values()}edge(e){let t=B(e);return b(this.#r.get(t),`Edge ${t} not found in view ${this.#e.id}`)}findEdge(e){return this.#r.get(B(e))??null}edges(){return this.#r.values()}*edgesWithRelation(e){for(let t of this.#r.values())t.includesRelation(e)&&(yield t)}*elements(){for(let e of this.#n.values())e.hasElement()&&(yield e)}isTagged(e){return this.tags.includes(e)}includesElement(e){return this.#i.has(B(e))}includesDeployment(e){return this.#a.has(B(e))}includesRelation(e){return this.#o.has(B(e))}isComputed(){return this.#e[g]===`computed`}isLayouted(){return this.#e[g]===`layouted`}isDiagram(){return this.#e[g]===`layouted`}isElementView(){return this.#e[m]===`element`}isScopedElementView(){return this.#e[m]===`element`&&o(this.#e.viewOf)}isDeploymentView(){return this.#e[m]===`deployment`}isDynamicView(){return this.#e[m]===`dynamic`}},q=class e{$model;path;title;isRoot;parentPath;defaultViewId;constructor(e,t,r){this.$model=e,this.path=t.join(`/`),this.isRoot=this.path===``,this.title=n(t),this.isRoot?this.parentPath=void 0:this.parentPath=t.slice(0,-1).join(`/`),this.defaultViewId=r}get defaultView(){return this.defaultViewId?this.$model.view(this.defaultViewId):null}get breadcrumbs(){return E(!this.isRoot,`Root view folder has no breadcrumbs`),A(this,`breadcrumbs`,()=>{let e=this.parent;return e?e.isRoot?[e,this]:[...e.breadcrumbs,this]:[this]})}get parent(){return E(!this.isRoot,`Root view folder has no parent`),r(this.parentPath)?null:this.$model.viewFolder(this.parentPath)}get children(){return this.$model.viewFolderItems(this.path)}get folders(){return A(this,`folders`,()=>{let t=[];for(let n of this.children)n instanceof e&&t.push(n);return t})}get views(){return A(this,`views`,()=>{let e=[];for(let t of this.children)t instanceof K&&e.push(t);return e})}},J=class e{Aux;_elements=new Map;_parents=new Map;_children=new P.default(()=>new Set);_rootElements=new Set;_relations=new Map;_incoming=new P.default(()=>new Set);_outgoing=new P.default(()=>new Set);_internal=new P.default(()=>new Set);_views=new Map;_rootViewFolder;_viewFolders=new Map;_viewFolderItems=new P.default(()=>new Set);_allTags=new P.default(()=>new Set);static fromParsed(t){return new e(t)}static create(t){return new e(t)}static fromDump(t){let{_stage:n=`layouted`,projectId:r=`unknown`,project:i,globals:a,imports:o,deployments:s,views:c,relations:ee,elements:te,specification:l}=t;return new e({[g]:n,projectId:r,project:i,globals:{predicates:a?.predicates??{},dynamicPredicates:a?.dynamicPredicates??{},styles:a?.styles??{}},imports:o??{},deployments:{elements:s?.elements??{},relations:s?.relations??{}},views:c??{},relations:ee??{},elements:te??{},specification:l})}deployment;$data;constructor(e){this.$data=e;for(let[,t]of ee(e.elements)){let e=this.addElement(t);for(let t of e.tags)this._allTags.get(t).add(e)}for(let[t,n]of ee(e.imports??{}))for(let e of ye(n)){let n=this.addImportedElement(t,e);for(let e of n.tags)this._allTags.get(e).add(n)}for(let t of f(e.relations)){let e=this.addRelation(t);for(let t of e.tags)this._allTags.get(t).add(e)}if(this.deployment=new Ne(this),pe(e,`computed`)||pe(e,`layouted`)){let t=be(`/`),n=l(f(e.views),c(e=>({view:e,path:H(e.title??e.id),folderPath:e.title&&je(e.title)||``})),d((e,n)=>t(e.folderPath,n.folderPath))),r=e=>{let t=this._viewFolders.get(e);if(!t){let r=re(e,`/`);E(s(r,1),`View group path "${e}" must have at least one element`);let i;i=e===``?n.find(e=>e.view.id===`index`):n.find(t=>t.path===e),t=new q(this,r,i?.view.id),this._viewFolders.set(e,t)}return t};this._rootViewFolder=r(``);for(let{folderPath:e}of n)this._viewFolders.has(e)||re(e,`/`).reduce((e,t)=>{let n=e.join(`/`),a=r(i(n)?t:n+`/`+t);return this._viewFolderItems.get(n).add(a),e.push(t),e},[]);for(let{view:t,folderPath:i}of n){let n=new K(this,r(i),t,e.manualLayouts?.[t.id]);this._viewFolderItems.get(i).add(n),this._views.set(t.id,n);for(let e of n.tags)this._allTags.get(e).add(n)}}else this._rootViewFolder=new q(this,[``],void 0),this._viewFolders.set(this._rootViewFolder.path,this._rootViewFolder)}get asParsed(){return this}get asComputed(){return this}get asLayouted(){return this}get $styles(){return A(this,`styles`,()=>ie.from(this.project.styles,this.specification.customColors))}isParsed(){return this.stage===`parsed`}isLayouted(){return this.stage===`layouted`}isComputed(){return this.stage===`computed`}get $model(){return this.$data}get stage(){return this.$data[g]}get projectId(){return this.$data.projectId??`default`}get project(){return this.$data.project??A(this,Symbol.for(`project`),()=>({id:this.projectId,styles:{},manualLayouts:{}}))}get specification(){return this.$data.specification}get globals(){return A(this,Symbol.for(`globals`),()=>({predicates:{...this.$data.globals?.predicates},dynamicPredicates:{...this.$data.globals?.dynamicPredicates},styles:{...this.$data.globals?.styles}}))}element(e){if(e instanceof F)return e;let t=B(e);return b(this._elements.get(t),`Element ${t} not found`)}findElement(e){return this._elements.get(B(e))??null}roots(){return this._rootElements.values()}elements(){return this._elements.values()}relationships(){return this._relations.values()}relationship(e,t){if(t===`deployment`)return this.deployment.relationship(e);let n=B(e),r=this._relations.get(n)??null;return r||t===`model`?b(r,`Model relation ${n} not found`):b(this.deployment.findRelationship(n),`No model/deployment relation ${n} not found`)}findRelationship(e,t){if(t===`deployment`)return this.deployment.findRelationship(e);let n=this._relations.get(B(e))??null;return n||t===`model`?n:this.deployment.findRelationship(e)}views(){return this._views.values()}view(e){let t=B(e);return b(this._views.get(t),`View ${t} not found`)}findView(e){return this._views.get(e)??null}findManualLayout(e){return`manualLayouts`in this.$data?this.$data.manualLayouts?.[e]??null:null}viewFolder(e){return b(this._viewFolders.get(e),`View folder ${e} not found`)}get rootViewFolder(){return this._rootViewFolder}get hasViewFolders(){return this._viewFolders.size>1}viewFolderItems(e){return E(this._viewFolders.has(e),`View folder ${e} not found`),this._viewFolderItems.get(e)}parent(e){let t=B(e);return this._parents.get(t)||null}children(e){let t=B(e);return this._children.get(t)}*siblings(e){let t=B(e),n=this._parents.get(t),r=n?this._children.get(n.id).values():this.roots();for(let e of r)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this._parents.get(t);)yield n,t=n.id}*descendants(e){for(let t of this.children(e))yield t,yield*this.descendants(t.id)}*incoming(e,t=`all`){let n=B(e);for(let e of this._incoming.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this._outgoing.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}get tags(){return A(this,`tags`,()=>d([...this._allTags.keys()],_e))}get tagsSortedByUsage(){return A(this,`tagsSortedByUsage`,()=>l([...this._allTags.entries()],c(([e,t])=>({tag:e,count:t.size,tagged:t})),d((e,t)=>_e(e.tag,t.tag)),te([ne(`count`),`desc`])))}findByTag(e,t){return me(this._allTags.get(e),e=>t===`elements`?e instanceof F:t===`views`?e instanceof K:t===`relationships`?e instanceof U:!0)}*elementsOfKind(e){for(let t of this._elements.values())t.kind===e&&(yield t)}*elementsWhere(e){let t=ae(e);for(let e of this._elements.values())t(e)&&(yield e)}*relationshipsWhere(e){let t=ae(e);for(let e of this._relations.values())t(e)&&(yield e)}addElement(e){if(this._elements.has(e.id))throw Error(`Element ${e.id} already exists`);let t=new F(this,Object.freeze(e));this._elements.set(t.id,t);let n=S(t.id);return n?(E(this._elements.has(n),`Parent ${n} of ${t.id} not found`),this._parents.set(t.id,this.element(n)),this._children.get(n).add(t)):this._rootElements.add(t),t}addImportedElement(e,t){E(!le(t.id),`Imported element already has global FQN`);let n=oe(e,t.id);if(this._elements.has(n))throw Error(`Element ${n} already exists`);let r=new F(this,Object.freeze({...t,id:n}));this._elements.set(r.id,r);let i=S(r.id);for(;i;){if(i.includes(`.`)&&this._elements.has(i))return this._parents.set(r.id,this.element(i)),this._children.get(i).add(r),r;i=S(i)}return this._rootElements.add(r),r}addRelation(e){if(this._relations.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new U(this,Object.freeze(e)),{source:n,target:r}=t;this._relations.set(t.id,t),this._incoming.get(r.id).add(t),this._outgoing.get(n.id).add(t);let i=j(n.id,r.id);if(i)for(let e of[i,...x(i)])this._internal.get(e).add(t);for(let e of x(n.id)){if(e===i)break;this._outgoing.get(e).add(t)}for(let e of x(r.id)){if(e===i)break;this._incoming.get(e).add(t)}return t}};(function(e){e.EMPTY=J.create({_stage:`computed`,projectId:`default`,project:{id:`default`},specification:{elements:{},relationships:{},deployments:{},tags:{}},globals:{predicates:{},dynamicPredicates:{},styles:{}},deployments:{elements:{},relations:{}},elements:{},relations:{},views:{},imports:{}})})(J||={});let Pe;(function(e){e.isInside=e=>t=>w(e,t.source.id)&&w(e,t.target.id);let t=e.isDirectedBetween=(e,t)=>n=>(n.source.id===e||w(e,n.source.id))&&(n.target.id===t||w(t,n.target.id));e.isAnyBetween=(e,n)=>{let r=t(e,n),i=t(n,e);return e=>r(e)||i(e)};let n=e.isIncoming=e=>t=>(t.target.id===e||w(e,t.target.id))&&!w(e,t.source.id),r=e.isOutgoing=e=>t=>(t.source.id===e||w(e,t.source.id))&&!w(e,t.target.id);e.isAnyInOut=e=>{let t=n(e),i=r(e);return e=>t(e)||i(e)}})(Pe||={});const Y=Symbol.for(`nodejs.util.inspect.custom`);var Fe=class e{id;constructor(e,t,n){this.source=e,this.target=t,this.relations=n,this.id=Ce(`deployment:${e.id}:${t.id}`)}get expression(){return`${this.source.id} -> ${this.target.id}`}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target),this._boundary}nonEmpty(){return this.relations.nonEmpty}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,`constructor`,{value:e,enumerable:!1}),i}toString(){let e=[...this.relations.model].map(e=>` `+e.expression);e.length?e.unshift(` model:`):e.unshift(` model: []`);let t=[...this.relations.deployment].map(e=>` `+e.expression);return t.length?t.unshift(` deployment:`):t.unshift(` deployment: []`),[this.expression,...e,...t].join(`
3
- `)}hasDirectDeploymentRelation(){for(let e of this.relations.deployment)if(e.source.id===this.source.id||e.target.id===this.target.id)return!0;return!1}*values(){yield*this.relations.model,yield*this.relations.deployment}mergeWith(t){return Array.isArray(t)?t.reduce((e,t)=>e.mergeWith(t),this):(E(this.source.id===t.source.id,`Cannot merge connections with different sources`),E(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,this.relations.union(t.relations)))}difference(t){return new e(this.source,this.target,this.relations.difference(t.relations))}intersect(t){return new e(this.source,this.target,this.relations.intersect(t.relations))}equals(t){return E(t instanceof e,`Other should ne DeploymentConnectionModel`),this.id===t.id&&this.source.id===t.source.id&&this.target.id===t.target.id&&M(this.relations.model,t.relations.model)&&M(this.relations.deployment,t.relations.deployment)}update(t){return t&&={model:this.relations.model,deployment:this.relations.deployment,...t},new e(this.source,this.target,t?new z(t.model??new Set,t.deployment??new Set):this.relations)}};function X(e,t){if(!t){let t=e;return e=>X(e,t)}let n=e.source===t.source,r=e.target===t.target;if(n&&r)return!1;let i=w(t.source.id,e.source.id),a=w(t.target.id,e.target.id);return i&&a||n&&a||r&&i}function Ie(e,t){let n=t;for(let t of e)X(t,n)&&(n=t);return n===t?null:n}function Le(e){let t=[],n=e.slice(),r;for(;r=n.shift();){let e;for(;e=Ie(n,r);){let r=n.indexOf(e);t.push(n.splice(r,1)[0])}t.push(r)}return t}function Re(e){return e.boundary?.id?`.${e.boundary.id}`:``}function ze(e,t){if(!e||Se(e)){let t=e??`asc`;return e=>Be(e,t)}return Be(e,t??`asc`)}function Be(e,t){return l(e,c(e=>({id:Re(e),conn:e})),ge(t),c(e=>e.conn))}function Ve(e,t){return e.filter(e=>X(t,e))}function He(e,t){return e.filter(X(t))}function Ue(e){let t=new Map;for(let n of e){let e=t.get(n.id);e?t.set(n.id,n.mergeWith(e)):t.set(n.id,n)}return[...t.values()]}function We(e,t){let n=new Map([...t].map(e=>[e.id,e]));return[...e].reduce((e,t)=>{let r=n.get(t.id);if(!r)return e.push(t),e;let i=t.difference(r);return i.nonEmpty()&&e.push(i),e},[])}function Z(e,t){return t?e.source===t.source&&e.target===t.target:t=>e.source===t.source&&e.target===t.target}function Ge(e,t){return t?e.source===t.source:t=>e.source===t.source}function Ke(e,t){return t?e.target===t.target:t=>e.target===t.target}function qe(e,t){if(!t){let t=e;return e=>qe(e,t)}let n=e;return T(n.source,t)&&!T(n.target,t)}function Je(e,t){if(!t){let t=e;return e=>Je(e,t)}let n=e;return T(n.target,t)&&!T(n.source,t)}function Ye(e,t){if(!t){let t=e;return e=>Ye(e,t)}let n=e;return T(n.source,t)!==T(n.target,t)}var Q=class e{id;constructor(e,t,n=new Set){this.source=e,this.target=t,this.relations=n,this.id=Ce(`model:${e.id}:${t.id}`)}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target)}get expression(){return`${this.source.id} -> ${this.target.id}`}get isDirect(){return this.nonEmpty()&&!this.isImplicit}get isImplicit(){return this.nonEmpty()&&we(this.relations,a(Z(this)))}get directRelations(){return new Set(me(this.relations,Z(this)))}nonEmpty(){return this.relations.size>0}mergeWith(t){return E(this.source.id===t.source.id,`Cannot merge connections with different sources`),E(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,N(this.relations,t.relations))}difference(t){return new e(this.source,this.target,O(this.relations,t.relations))}intersect(t){return E(t instanceof e,`Cannot intersect connection with different type`),new e(this.source,this.target,k(this.relations,t.relations))}equals(t){E(t instanceof e,`Cannot merge connection with different type`);let n=t;return this.id===n.id&&this.source.id===n.source.id&&this.target.id===n.target.id&&M(this.relations,n.relations)}update(t){return new e(this.source,this.target,t)}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,`constructor`,{value:e,enumerable:!1}),i}toString(){return[this.expression,this.relations.size?` relations:`:` relations: [ ]`,...[...this.relations].map(e=>` `+e.expression)].join(`
1
+ import{n as e}from"./rolldown-runtime.mjs";import{A as t,E as n,I as r,L as i,N as a,O as o,Q as s,T as c,X as l,c as ee,et as u,i as d,l as te,m as ne,r as f,s as re}from"./libs/remeda.mjs";import{$ as ie,H as ae,O as oe,St as p,Y as m,_t as h,bt as g,ct as se,dt as ce,ft as le,j as ue,mt as de,t as _,ut as fe,vt as v,xt as y,yt as pe}from"./types.mjs";import{$ as b,A as x,B as S,D as me,E as he,F as C,H as ge,I as w,J as _e,L as T,Q as E,R as ve,S as D,U as ye,Y as be,a as O,c as k,h as A,j,k as xe,o as M,q as Se,r as Ce,u as N,y as we,z as Te}from"./utils.mjs";import{t as P}from"./libs/mnemonist.mjs";import{n as Ee,t as De}from"./manual-layout.mjs";var F=class{Aux;id;_literalId;hierarchyLevel;imported;constructor(e,t){this.$model=e,this.$element=t,this.id=this.$element.id,this._literalId=this.$element.id;let[n,r]=de(this.id);n?(this.imported={from:n,fqn:r},this.hierarchyLevel=C(r)):(this.imported=null,this.hierarchyLevel=C(this.id))}get name(){return Te(this.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$element.kind}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get tags(){return A(this,Symbol.for(`tags`),()=>d([...this.$element.tags??[],...this.$model.specification.elements[this.$element.kind]?.tags??[]]))}get metadata(){return this.$element.metadata??{}}get title(){return this.$element.title}get hasSummary(){return!!this.$element.summary&&!!this.$element.description&&!t(this.$element.summary,this.$element.description)}get summary(){return _.memoize(this,`summary`,y(this.$element))}get description(){return _.memoize(this,`description`,g(this.$element))}get technology(){return this.$element.technology??null}get links(){return this.$element.links??[]}get defaultView(){return A(this,Symbol.for(`defaultView`),()=>D(this.scopedViews())??null)}get isRoot(){return this.parent===null}get style(){return A(this,`style`,()=>p({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$element.style}))}get projectId(){return this.imported?.from??this.$model.projectId}isAncestorOf(e){return w(this,e)}isDescendantOf(e){return w(e,this)}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=j(this.id,e.id);return t?this.$model.element(t):null}children(){return this.$model.children(this)}descendants(e){return e?ge([...this.$model.descendants(this)],e)[Symbol.iterator]():this.$model.descendants(this)}siblings(){return this.$model.siblings(this)}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}get allOutgoing(){return A(this,Symbol.for(`allOutgoing`),()=>new Set(this.outgoing()))}get allIncoming(){return A(this,Symbol.for(`allIncoming`),()=>new Set(this.incoming()))}views(){return A(this,Symbol.for(`views`),()=>{let e=new Set;for(let t of this.$model.views())t.includesElement(this.id)&&e.add(t);return e})}scopedViews(){return A(this,Symbol.for(`scopedViews`),()=>{let e=new Set;for(let t of this.$model.views())t.isScopedElementView()&&t.viewOf.id===this.id&&e.add(t);return e})}isDeployed(){return o(D(this.deployments()))}deployments(){return this.$model.deployment.instancesOf(this)}hasMetadata(){return!!this.$element.metadata&&!i(this.$element.metadata)}getMetadata(e){return e?this.$element.metadata?.[e]:this.$element.metadata??{}}isTagged(e){return this.tags.includes(e)}},Oe=class{Aux;get style(){return A(this,`style`,()=>p({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$node.style}))}get name(){return Te(this.id)}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get summary(){return _.memoize(this,`summary`,y(this.$node))}get description(){return _.memoize(this,`description`,g(this.$node))}get technology(){return this.$node.technology??null}get links(){return this.$node.links??[]}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=j(this.id,e.id);return t?this.$model.node(t):null}siblings(){return this.$model.siblings(this)}isSibling(e){return this.parent===e.parent}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}*views(){for(let e of this.$model.views())e._type===`deployment`&&e.includesDeployment(this.id)&&(yield e)}isDeploymentNode(){return!1}isInstance(){return!1}get allOutgoing(){return A(this,Symbol.for(`allOutgoing`),()=>z.from(new Set(this.outgoingModelRelationships()),new Set(this.outgoing())))}get allIncoming(){return A(this,Symbol.for(`allIncoming`),()=>z.from(new Set(this.incomingModelRelationships()),new Set(this.incoming())))}hasMetadata(){return!!this.$node.metadata&&!i(this.$node.metadata)}getMetadata(e){return e?this.$node.metadata?.[e]:this.$node.metadata??{}}isTagged(e){return this.tags.includes(e)}},I=class extends Oe{id;_literalId;title;hierarchyLevel;constructor(e,t){super(),this.$model=e,this.$node=t,this.id=t.id,this._literalId=t.id,this.title=t.title,this.hierarchyLevel=C(t.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$node.kind}get metadata(){return this.$node.metadata??{}}get tags(){return A(this,Symbol.for(`tags`),()=>d([...this.$node.tags??[],...this.$model.$model.specification.deployments[this.kind]?.tags??[]]))}children(){return this.$model.children(this)}descendants(e=`desc`){return this.$model.descendants(this,e)}isDeploymentNode(){return!0}*instances(){for(let e of this.descendants(`desc`))e.isInstance()&&(yield e)}onlyOneInstance(){let e=this.children();if(e.size!==1)return null;let t=D(e);return t?t.isInstance()?t:t.onlyOneInstance():null}_relationshipsFromInstances=null;relationshipsFromInstances(){if(this._relationshipsFromInstances)return this._relationshipsFromInstances;let{outgoing:e,incoming:t}=this._relationshipsFromInstances={outgoing:new Set,incoming:new Set};for(let n of this.instances()){for(let t of n.element.outgoing())e.add(t);for(let e of n.element.incoming())t.add(e)}return this._relationshipsFromInstances}outgoingModelRelationships(){return this.relationshipsFromInstances().outgoing.values()}incomingModelRelationships(){return this.relationshipsFromInstances().incoming.values()}internalModelRelationships(){let{outgoing:e,incoming:t}=this.relationshipsFromInstances();return k(t,e)}},L=class extends Oe{id;_literalId;title;hierarchyLevel;constructor(e,t,n){super(),this.$model=e,this.$instance=t,this.element=n,this.id=t.id,this._literalId=t.id,this.title=t.title??n.title,this.hierarchyLevel=C(t.id)}get $node(){return this.$instance}get parent(){return b(this.$model.parent(this),`Parent of ${this.id} not found`)}get style(){return A(this,`style`,()=>p({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.element.$element.style,...this.$instance.style}))}get tags(){return A(this,Symbol.for(`tags`),()=>d([...this.$instance.tags??[],...this.element.tags]))}get kind(){return this.element.kind}get metadata(){return this.$instance.metadata??this.element.metadata??{}}get summary(){return _.memoize(this,`summary`,y(this.$instance)??y(this.element.$element))}get description(){return _.memoize(this,`description`,g(this.$instance)??g(this.element.$element))}get technology(){return this.$instance.technology??this.element.technology??null}get links(){return this.$instance.links??this.element.links}isInstance(){return!0}outgoingModelRelationships(){return this.element.outgoing()}incomingModelRelationships(){return this.element.incoming()}*views(){for(let e of this.$model.views())if(e._type===`deployment`){if(e.includesDeployment(this.id)){yield e;continue}e.includesDeployment(this.parent.id)&&this.parent.onlyOneInstance()&&(yield e)}}},ke=class{constructor(e,t){this.instance=e,this.element=t}get id(){return this.instance.id}get _literalId(){return this.instance.id}get style(){return A(this,`style `,()=>({shape:this.element.shape,color:this.element.color,...this.element.$element.style}))}get shape(){return this.element.shape}get color(){return this.element.color}get title(){return this.element.title}get summary(){return this.element.summary}get description(){return this.element.description}get technology(){return this.element.technology}isDeploymentNode(){return!1}isInstance(){return!1}},R=class{boundary;source;target;constructor(e,t){this.$model=e,this.$relationship=t,this.source=e.deploymentRef(t.source),this.target=e.deploymentRef(t.target);let n=j(this.source.id,this.target.id);this.boundary=n?this.$model.node(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return o(this.$relationship.title)?this.$relationship.title:null}get technology(){return r(this.$relationship.technology)?(this.kind&&this.$model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return _.memoize(this,`summary`,y(this.$relationship))}get description(){return _.memoize(this,`description`,g(this.$relationship))}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get metadata(){return this.$relationship.metadata??{}}get navigateTo(){return this.$relationship.navigateTo?this.$model.$model.view(this.$relationship.navigateTo):null}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.$model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.$model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.$model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.$model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!0}isModelRelation(){return!1}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},z=class e{static empty(){return new e}static from(t,n){return new e(new Set(t),new Set(n))}constructor(e=new Set,t=new Set){this.model=e,this.deployment=t}get isEmpty(){return this.model.size===0&&this.deployment.size===0}get nonEmpty(){return this.model.size>0||this.deployment.size>0}get size(){return this.model.size+this.deployment.size}intersect(t){return e.from(k(this.model,t.model),k(this.deployment,t.deployment))}difference(t){return e.from(O(this.model,t.model),O(this.deployment,t.deployment))}union(t){return e.from(N(this.model,t.model),N(this.deployment,t.deployment))}};const B=e=>typeof e==`string`?e:e.id,Ae=`/`,V=e=>{if(E(!e.includes(`
2
+ `),`View title cannot contain newlines`),e.includes(`/`)){let t=e.split(`/`).map(e=>e.trim()).filter(e=>e.length>0);return s(t,1)?t:[``]}return[e.trim()]},H=e=>V(e).join(`/`),je=e=>{let t=V(e);return s(t,2)?t.slice(0,-1).join(`/`):null},Me=e=>e.includes(`/`)?V(e).pop()??e:e.trim();var Ne=class{#e=new Map;#t=new Map;#n=new P.default(()=>new Set);#r=new P.default(()=>new Set);#i=new Set;#a=new Map;#o=new P.default(()=>new Set);#s=new P.default(()=>new Set);#c=new P.default(()=>new Set);#l=new P.default(()=>new Set);#u=new Map;$deployments;constructor(e){this.$model=e;let t=this.$deployments=e.$data.deployments,n=f(t.elements);for(let e of ye(n)){let t=this.addElement(e);for(let e of t.tags)this.#l.get(e).add(t);t.isInstance()&&this.#r.get(t.element.id).add(t)}for(let e of f(t.relations)){let t=this.addRelation(e);for(let e of t.tags)this.#l.get(e).add(t)}}get $styles(){return this.$model.$styles}get projectId(){return this.$model.projectId}get project(){return this.$model.project}get specification(){return this.$model.specification}element(e){if(e instanceof I||e instanceof L)return e;let t=B(e);return b(this.#e.get(t),`Element ${t} not found`)}findElement(e){return this.#e.get(e)??null}node(e){let t=this.element(e);return E(t.isDeploymentNode(),`Element ${t.id} is not a deployment node`),t}findNode(e){let t=this.findElement(e);return t?(E(t.isDeploymentNode(),`Element ${t?.id} is not a deployment node`),t):null}instance(e){let t=this.element(e);return E(t.isInstance(),`Element ${t.id} is not a deployed instance`),t}findInstance(e){let t=this.findElement(e);return t?(E(t.isInstance(),`Element ${t?.id} is not a deployed instance`),t):null}roots(){return this.#i.values()}elements(){return this.#e.values()}*nodes(){for(let e of this.#e.values())e.isDeploymentNode()&&(yield e)}*nodesOfKind(e){for(let t of this.#e.values())t.isDeploymentNode()&&t.kind===e&&(yield t)}*instances(){for(let e of this.#e.values())e.isInstance()&&(yield e)}*instancesOf(e){let t=B(e),n=this.#r.get(t);n&&(yield*n)}deploymentRef(e){if(m.isInsideInstanceRef(e)){let{deployment:t,element:n}=e;return xe(this.#u,`${t}@${n}`,()=>new ke(this.instance(t),this.$model.element(n)))}return this.element(e.deployment)}relationships(){return this.#a.values()}relationship(e){let t=B(e);return b(this.#a.get(t),`DeploymentRelationModel ${t} not found`)}findRelationship(e){return this.#a.get(e)??null}*views(){for(let e of this.$model.views())e.isDeploymentView()&&(yield e)}parent(e){let t=B(e);return this.#t.get(t)||null}children(e){let t=B(e);return this.#n.get(t)}*siblings(e){let t=B(e),n=this.parent(e)?.children()??this.roots();for(let e of n)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this.#t.get(t);)yield n,t=n.id}*descendants(e,t=`desc`){for(let n of this.children(e))t===`asc`?(yield n,yield*this.descendants(n.id)):(yield*this.descendants(n.id),yield n)}*incoming(e,t=`all`){let n=B(e);for(let e of this.#o.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this.#s.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}addElement(e){if(this.#e.has(e.id))throw Error(`Element ${e.id} already exists`);let t=ae(e)?new I(this,Object.freeze(e)):new L(this,Object.freeze(e),this.$model.element(e.element));this.#e.set(t.id,t);let n=S(t.id);return n?(E(this.#e.has(n),`Parent ${n} of ${t.id} not found`),this.#t.set(t.id,this.node(n)),this.#n.get(n).add(t)):(E(t.isDeploymentNode(),`Root element ${t.id} is not a deployment node`),this.#i.add(t)),t}addRelation(e){if(this.#a.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new R(this,Object.freeze(e));this.#a.set(t.id,t),this.#o.get(t.target.id).add(t),this.#s.get(t.source.id).add(t);let n=t.boundary?.id??null;if(n)for(let e of[n,...x(n)])this.#c.get(e).add(t);for(let e of x(t.source.id)){if(e===n)break;this.#s.get(e).add(t)}for(let e of x(t.target.id)){if(e===n)break;this.#o.get(e).add(t)}return t}},U=class{source;target;boundary;constructor(e,t){this.model=e,this.$relationship=t,this.source=e.element(m.flatten(t.source)),this.target=e.element(m.flatten(t.target));let n=j(this.source.id,this.target.id);this.boundary=n?this.model.element(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return r(this.$relationship.title)?null:this.$relationship.title}get technology(){return r(this.$relationship.technology)?(this.kind&&this.model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return _.memoize(this,`summary`,y(this.$relationship))}get description(){return _.memoize(this,`description`,g(this.$relationship))}get navigateTo(){return this.$relationship.navigateTo?this.model.view(this.$relationship.navigateTo):null}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get metadata(){return this.$relationship.metadata??{}}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!1}isModelRelation(){return!0}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},W=class{Aux;$viewModel;$view;$edge;constructor(e,t,n,r){this.source=n,this.target=r,this.$viewModel=e,this.$view=e.$view,this.$edge=t}get id(){return this.$edge.id}get parent(){return this.$edge.parent?this.$viewModel.node(this.$edge.parent):null}get label(){return this.$edge.label??null}get description(){return _.memoize(this,`description`,this.$edge.description)}get technology(){return this.$edge.technology??null}hasParent(){return this.$edge.parent!==null}get tags(){return this.$edge.tags??[]}get stepNumber(){return this.isStep()?se(this.id):null}get navigateTo(){return this.$edge.navigateTo?this.$viewModel.$model.view(this.$edge.navigateTo):null}get color(){return this.$edge.color}get line(){return this.$edge.line??this.$viewModel.$styles.defaults.relationship.line}get head(){return this.$edge.head??this.$viewModel.$styles.defaults.relationship.arrow}get tail(){return this.$edge.tail}isStep(){return le(this.id)}*relationships(e){for(let t of this.$edge.relations)if(e){let n=this.$viewModel.$model.findRelationship(t,e);n&&(yield n)}else yield this.$viewModel.$model.relationship(t)}includesRelation(e){let t=typeof e==`string`?e:e.id;return this.$edge.relations.includes(t)}isTagged(e){return this.tags.includes(e)}},G=class{Aux;$viewModel;$view;$node;constructor(e,t){this.$viewModel=e,this.$view=e.$view,this.$node=t}get id(){return this.$node.id}get title(){return this.$node.title}get kind(){return this.$node.kind}get description(){return _.memoize(this,`description`,this.$node.description)}get technology(){return this.$node.technology??null}get notes(){return _.memoize(this,`notes`,this.$node.notes)}get parent(){return this.$node.parent?this.$viewModel.node(this.$node.parent):null}get element(){let e=this.$node.modelRef;return e?this.$viewModel.$model.element(e):null}get deployment(){let e=this.$node.deploymentRef;return e?this.$viewModel.$model.deployment.element(e):null}get shape(){return this.$node.shape}get color(){return this.$node.color}get icon(){return this.$node.icon??null}get tags(){return this.$node.tags}get links(){return this.$node.links??[]}get navigateTo(){return this.$node.navigateTo?this.$viewModel.$model.view(this.$node.navigateTo):null}get style(){return this.$node.style}get x(){return`x`in this.$node?this.$node.x:void 0}get y(){return`y`in this.$node?this.$node.y:void 0}get width(){return`width`in this.$node?this.$node.width:void 0}get height(){return`height`in this.$node?this.$node.height:void 0}children(){return A(this,`children`,()=>new Set(this.$node.children.map(e=>this.$viewModel.node(e))))}*ancestors(){let e=this.parent;for(;e;)yield e,e=e.parent}*siblings(){let e=this.parent?.children()??this.$viewModel.roots();for(let t of e)t.id!==this.id&&(yield t)}*incoming(e=`all`){for(let t of this.$node.inEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.target.id===this.id:case e===`to-descendants`&&n.target.id!==this.id:yield n;break}}}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoing(e=`all`){for(let t of this.$node.outEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.source.id===this.id:case e===`from-descendants`&&n.source.id!==this.id:yield n;break}}}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}isLayouted(){return`width`in this.$node&&`height`in this.$node}hasChildren(){return this.$node.children.length>0}hasParent(){return this.$node.parent!==null}hasElement(){return o(this.$node.modelRef)}hasDeployment(){return o(this.$node.deploymentRef)}hasDeployedInstance(){return this.hasElement()&&this.hasDeployment()}isGroup(){return ce(this.$node)}isTagged(e){return this.tags.includes(e)}},K=class{Aux;#e;#t=new Set;#n=new Map;#r=new Map;#i=new Set;#a=new Set;#o=new Set;#s=new P.default(e=>new Set);#c;id;$model;title;folder;viewPath;constructor(e,t,n,r){this.$model=e,this.#e=n,this.id=n.id,this.folder=t,this.#c=r;for(let e of this.#e.nodes){let t=new G(this,Object.freeze(e));this.#n.set(e.id,t),e.parent||this.#t.add(t),e.deploymentRef&&this.#a.add(e.deploymentRef),e.modelRef&&this.#i.add(e.modelRef);for(let e of t.tags)this.#s.get(e).add(t)}for(let e of this.#e.edges){let t=new W(this,Object.freeze(e),this.node(e.source),this.node(e.target));for(let e of t.tags)this.#s.get(e).add(t);for(let t of e.relations)this.#o.add(t);this.#r.set(e.id,t)}this.title=n.title?Me(n.title):null,this.viewPath=n.title?H(n.title):n.id}get $styles(){return this.$model.$styles}get _type(){return this.#e[v]}get stage(){return this.#e[h]}get bounds(){if(`bounds`in this.#e)return this.#e.bounds;if(this.#c)return this.#c.bounds;throw Error(`View is not layouted`)}get titleOrId(){return this.title??this.viewOf?.title??this.id}get titleOrUntitled(){return this.title??`Untitled`}get breadcrumbs(){return A(this,`breadcrumbs`,()=>this.folder.isRoot?[this]:[...this.folder.breadcrumbs,this])}get description(){return _.memoize(this,`description`,this.#e.description)}get tags(){return this.#e.tags??[]}get links(){return this.#e.links??[]}get viewOf(){if(this.isElementView()){let e=this.#e.viewOf;return e?this.$model.element(e):null}return null}get mode(){return this.isDynamicView()?this.#e.variant??`diagram`:null}get includedTags(){return[...this.#s.keys()]}get $view(){if(!this.isLayouted()||`drifts`in this.#e)return this.#e;let e=this.#c;return e?A(this,`withDriftReasons`,()=>De(this.#e,e)):this.#e}get $layouted(){if(!this.isLayouted())throw Error(`View is not layouted`);return this.$manual??this.#e}get hasManualLayout(){return this.#c!==void 0}get hasLayoutDrifts(){if(!this.isLayouted())return!1;let e=this.$manual;return!!e?.drifts&&e.drifts.length>0}get $manual(){if(!this.isLayouted())return null;let e=this.#c;return e?A(this,`snapshotWithManualLayout`,()=>Ee(this.#e,e)):null}get projectId(){return this.$model.projectId}roots(){return this.#t.values()}*compounds(){for(let e of this.#n.values())e.hasChildren()&&(yield e)}node(e){let t=B(e);return b(this.#n.get(t),`Node ${t} not found in view ${this.#e.id}`)}findNode(e){return this.#n.get(B(e))??null}findNodeWithElement(e){let t=B(e);return this.#i.has(t)?he(this.#n.values(),e=>e.hasElement()&&e.element.id===t)??null:null}nodes(){return this.#n.values()}edge(e){let t=B(e);return b(this.#r.get(t),`Edge ${t} not found in view ${this.#e.id}`)}findEdge(e){return this.#r.get(B(e))??null}edges(){return this.#r.values()}*edgesWithRelation(e){for(let t of this.#r.values())t.includesRelation(e)&&(yield t)}*elements(){for(let e of this.#n.values())e.hasElement()&&(yield e)}isTagged(e){return this.tags.includes(e)}includesElement(e){return this.#i.has(B(e))}includesDeployment(e){return this.#a.has(B(e))}includesRelation(e){return this.#o.has(B(e))}isComputed(){return this.#e[h]===`computed`}isLayouted(){return this.#e[h]===`layouted`}isDiagram(){return this.#e[h]===`layouted`}isElementView(){return this.#e[v]===`element`}isScopedElementView(){return this.#e[v]===`element`&&o(this.#e.viewOf)}isDeploymentView(){return this.#e[v]===`deployment`}isDynamicView(){return this.#e[v]===`dynamic`}},q=class e{$model;path;title;isRoot;parentPath;defaultViewId;constructor(e,t,r){this.$model=e,this.path=t.join(`/`),this.isRoot=this.path===``,this.title=n(t),this.isRoot?this.parentPath=void 0:this.parentPath=t.slice(0,-1).join(`/`),this.defaultViewId=r}get defaultView(){return this.defaultViewId?this.$model.view(this.defaultViewId):null}get breadcrumbs(){return E(!this.isRoot,`Root view folder has no breadcrumbs`),A(this,`breadcrumbs`,()=>{let e=this.parent;return e?e.isRoot?[e,this]:[...e.breadcrumbs,this]:[this]})}get parent(){return E(!this.isRoot,`Root view folder has no parent`),r(this.parentPath)?null:this.$model.viewFolder(this.parentPath)}get children(){return this.$model.viewFolderItems(this.path)}get folders(){return A(this,`folders`,()=>{let t=[];for(let n of this.children)n instanceof e&&t.push(n);return t})}get views(){return A(this,`views`,()=>{let e=[];for(let t of this.children)t instanceof K&&e.push(t);return e})}},J=class e{Aux;_elements=new Map;_parents=new Map;_children=new P.default(()=>new Set);_rootElements=new Set;_relations=new Map;_incoming=new P.default(()=>new Set);_outgoing=new P.default(()=>new Set);_internal=new P.default(()=>new Set);_views=new Map;_rootViewFolder;_viewFolders=new Map;_viewFolderItems=new P.default(()=>new Set);_allTags=new P.default(()=>new Set);static fromParsed(t){return new e(t)}static create(t){return new e(t)}static fromDump(t){let{_stage:n=`layouted`,projectId:r=`unknown`,project:i,globals:a,imports:o,deployments:s,views:c,relations:l,elements:ee,specification:u}=t;return new e({[h]:n,projectId:r,project:i,globals:{predicates:a?.predicates??{},dynamicPredicates:a?.dynamicPredicates??{},styles:a?.styles??{}},imports:o??{},deployments:{elements:s?.elements??{},relations:s?.relations??{}},views:c??{},relations:l??{},elements:ee??{},specification:u})}deployment;$data;constructor(e){this.$data=e;for(let[,t]of l(e.elements)){let e=this.addElement(t);for(let t of e.tags)this._allTags.get(t).add(e)}for(let[t,n]of l(e.imports??{}))for(let e of ye(n)){let n=this.addImportedElement(t,e);for(let e of n.tags)this._allTags.get(e).add(n)}for(let t of f(e.relations)){let e=this.addRelation(t);for(let t of e.tags)this._allTags.get(t).add(e)}if(this.deployment=new Ne(this),pe(e,`computed`)||pe(e,`layouted`)){let t=be(`/`),n=u(f(e.views),c(e=>({view:e,path:H(e.title??e.id),folderPath:e.title&&je(e.title)||``})),te((e,n)=>t(e.folderPath,n.folderPath))),r=e=>{let t=this._viewFolders.get(e);if(!t){let r=re(e,`/`);E(s(r,1),`View group path "${e}" must have at least one element`);let i;i=e===``?n.find(e=>e.view.id===`index`):n.find(t=>t.path===e),t=new q(this,r,i?.view.id),this._viewFolders.set(e,t)}return t};this._rootViewFolder=r(``);for(let{folderPath:e}of n)this._viewFolders.has(e)||re(e,`/`).reduce((e,t)=>{let n=e.join(`/`),a=r(i(n)?t:n+`/`+t);return this._viewFolderItems.get(n).add(a),e.push(t),e},[]);for(let{view:t,folderPath:i}of n){let n=new K(this,r(i),t,e.manualLayouts?.[t.id]);this._viewFolderItems.get(i).add(n),this._views.set(t.id,n);for(let e of n.tags)this._allTags.get(e).add(n)}}else this._rootViewFolder=new q(this,[``],void 0),this._viewFolders.set(this._rootViewFolder.path,this._rootViewFolder)}get asParsed(){return this}get asComputed(){return this}get asLayouted(){return this}get $styles(){return A(this,`styles`,()=>ue.from(this.project.styles,this.specification.customColors))}isParsed(){return this.stage===`parsed`}isLayouted(){return this.stage===`layouted`}isComputed(){return this.stage===`computed`}get $model(){return this.$data}get stage(){return this.$data[h]}get projectId(){return this.$data.projectId??`default`}get project(){return this.$data.project??A(this,Symbol.for(`project`),()=>({id:this.projectId,styles:{},manualLayouts:{}}))}get specification(){return this.$data.specification}get globals(){return A(this,Symbol.for(`globals`),()=>({predicates:{...this.$data.globals?.predicates},dynamicPredicates:{...this.$data.globals?.dynamicPredicates},styles:{...this.$data.globals?.styles}}))}element(e){if(e instanceof F)return e;let t=B(e);return b(this._elements.get(t),`Element ${t} not found`)}findElement(e){return this._elements.get(B(e))??null}roots(){return this._rootElements.values()}elements(){return this._elements.values()}relationships(){return this._relations.values()}relationship(e,t){if(t===`deployment`)return this.deployment.relationship(e);let n=B(e),r=this._relations.get(n)??null;return r||t===`model`?b(r,`Model relation ${n} not found`):b(this.deployment.findRelationship(n),`No model/deployment relation ${n} not found`)}findRelationship(e,t){if(t===`deployment`)return this.deployment.findRelationship(e);let n=this._relations.get(B(e))??null;return n||t===`model`?n:this.deployment.findRelationship(e)}views(){return this._views.values()}view(e){let t=B(e);return b(this._views.get(t),`View ${t} not found`)}findView(e){return this._views.get(e)??null}findManualLayout(e){return`manualLayouts`in this.$data?this.$data.manualLayouts?.[e]??null:null}viewFolder(e){return b(this._viewFolders.get(e),`View folder ${e} not found`)}get rootViewFolder(){return this._rootViewFolder}get hasViewFolders(){return this._viewFolders.size>1}viewFolderItems(e){return E(this._viewFolders.has(e),`View folder ${e} not found`),this._viewFolderItems.get(e)}parent(e){let t=B(e);return this._parents.get(t)||null}children(e){let t=B(e);return this._children.get(t)}*siblings(e){let t=B(e),n=this._parents.get(t),r=n?this._children.get(n.id).values():this.roots();for(let e of r)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this._parents.get(t);)yield n,t=n.id}*descendants(e){for(let t of this.children(e))yield t,yield*this.descendants(t.id)}*incoming(e,t=`all`){let n=B(e);for(let e of this._incoming.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this._outgoing.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}get tags(){return A(this,`tags`,()=>te([...this._allTags.keys()],_e))}get tagsSortedByUsage(){return A(this,`tagsSortedByUsage`,()=>u([...this._allTags.entries()],c(([e,t])=>({tag:e,count:t.size,tagged:t})),te((e,t)=>_e(e.tag,t.tag)),ee([ne(`count`),`desc`])))}findByTag(e,t){return me(this._allTags.get(e),e=>t===`elements`?e instanceof F:t===`views`?e instanceof K:t===`relationships`?e instanceof U:!0)}*elementsOfKind(e){for(let t of this._elements.values())t.kind===e&&(yield t)}*elementsWhere(e){let t=oe(e);for(let e of this._elements.values())t(e)&&(yield e)}*relationshipsWhere(e){let t=oe(e);for(let e of this._relations.values())t(e)&&(yield e)}addElement(e){if(this._elements.has(e.id))throw Error(`Element ${e.id} already exists`);let t=new F(this,Object.freeze(e));this._elements.set(t.id,t);let n=S(t.id);return n?(E(this._elements.has(n),`Parent ${n} of ${t.id} not found`),this._parents.set(t.id,this.element(n)),this._children.get(n).add(t)):this._rootElements.add(t),t}addImportedElement(e,t){E(!fe(t.id),`Imported element already has global FQN`);let n=ie(e,t.id);if(this._elements.has(n))throw Error(`Element ${n} already exists`);let r=new F(this,Object.freeze({...t,id:n}));this._elements.set(r.id,r);let i=S(r.id);for(;i;){if(i.includes(`.`)&&this._elements.has(i))return this._parents.set(r.id,this.element(i)),this._children.get(i).add(r),r;i=S(i)}return this._rootElements.add(r),r}addRelation(e){if(this._relations.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new U(this,Object.freeze(e)),{source:n,target:r}=t;this._relations.set(t.id,t),this._incoming.get(r.id).add(t),this._outgoing.get(n.id).add(t);let i=j(n.id,r.id);if(i)for(let e of[i,...x(i)])this._internal.get(e).add(t);for(let e of x(n.id)){if(e===i)break;this._outgoing.get(e).add(t)}for(let e of x(r.id)){if(e===i)break;this._incoming.get(e).add(t)}return t}};(function(e){e.EMPTY=J.create({_stage:`computed`,projectId:`default`,project:{id:`default`},specification:{elements:{},relationships:{},deployments:{},tags:{}},globals:{predicates:{},dynamicPredicates:{},styles:{}},deployments:{elements:{},relations:{}},elements:{},relations:{},views:{},imports:{}})})(J||={});let Pe;(function(e){e.isInside=e=>t=>w(e,t.source.id)&&w(e,t.target.id);let t=e.isDirectedBetween=(e,t)=>n=>(n.source.id===e||w(e,n.source.id))&&(n.target.id===t||w(t,n.target.id));e.isAnyBetween=(e,n)=>{let r=t(e,n),i=t(n,e);return e=>r(e)||i(e)};let n=e.isIncoming=e=>t=>(t.target.id===e||w(e,t.target.id))&&!w(e,t.source.id),r=e.isOutgoing=e=>t=>(t.source.id===e||w(e,t.source.id))&&!w(e,t.target.id);e.isAnyInOut=e=>{let t=n(e),i=r(e);return e=>t(e)||i(e)}})(Pe||={});const Y=Symbol.for(`nodejs.util.inspect.custom`);var Fe=class e{id;constructor(e,t,n){this.source=e,this.target=t,this.relations=n,this.id=Ce(`deployment:${e.id}:${t.id}`)}get expression(){return`${this.source.id} -> ${this.target.id}`}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target),this._boundary}nonEmpty(){return this.relations.nonEmpty}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,`constructor`,{value:e,enumerable:!1}),i}toString(){let e=[...this.relations.model].map(e=>` `+e.expression);e.length?e.unshift(` model:`):e.unshift(` model: []`);let t=[...this.relations.deployment].map(e=>` `+e.expression);return t.length?t.unshift(` deployment:`):t.unshift(` deployment: []`),[this.expression,...e,...t].join(`
3
+ `)}hasDirectDeploymentRelation(){for(let e of this.relations.deployment)if(e.source.id===this.source.id||e.target.id===this.target.id)return!0;return!1}*values(){yield*this.relations.model,yield*this.relations.deployment}mergeWith(t){return Array.isArray(t)?t.reduce((e,t)=>e.mergeWith(t),this):(E(this.source.id===t.source.id,`Cannot merge connections with different sources`),E(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,this.relations.union(t.relations)))}difference(t){return new e(this.source,this.target,this.relations.difference(t.relations))}intersect(t){return new e(this.source,this.target,this.relations.intersect(t.relations))}equals(t){return E(t instanceof e,`Other should ne DeploymentConnectionModel`),this.id===t.id&&this.source.id===t.source.id&&this.target.id===t.target.id&&M(this.relations.model,t.relations.model)&&M(this.relations.deployment,t.relations.deployment)}update(t){return t&&={model:this.relations.model,deployment:this.relations.deployment,...t},new e(this.source,this.target,t?new z(t.model??new Set,t.deployment??new Set):this.relations)}};function X(e,t){if(!t){let t=e;return e=>X(e,t)}let n=e.source===t.source,r=e.target===t.target;if(n&&r)return!1;let i=w(t.source.id,e.source.id),a=w(t.target.id,e.target.id);return i&&a||n&&a||r&&i}function Ie(e,t){let n=t;for(let t of e)X(t,n)&&(n=t);return n===t?null:n}function Le(e){let t=[],n=e.slice(),r;for(;r=n.shift();){let e;for(;e=Ie(n,r);){let r=n.indexOf(e);t.push(n.splice(r,1)[0])}t.push(r)}return t}function Re(e){return e.boundary?.id?`.${e.boundary.id}`:``}function ze(e,t){if(!e||Se(e)){let t=e??`asc`;return e=>Be(e,t)}return Be(e,t??`asc`)}function Be(e,t){return u(e,c(e=>({id:Re(e),conn:e})),ge(t),c(e=>e.conn))}function Ve(e,t){return e.filter(e=>X(t,e))}function He(e,t){return e.filter(X(t))}function Ue(e){let t=new Map;for(let n of e){let e=t.get(n.id);e?t.set(n.id,n.mergeWith(e)):t.set(n.id,n)}return[...t.values()]}function We(e,t){let n=new Map([...t].map(e=>[e.id,e]));return[...e].reduce((e,t)=>{let r=n.get(t.id);if(!r)return e.push(t),e;let i=t.difference(r);return i.nonEmpty()&&e.push(i),e},[])}function Z(e,t){return t?e.source===t.source&&e.target===t.target:t=>e.source===t.source&&e.target===t.target}function Ge(e,t){return t?e.source===t.source:t=>e.source===t.source}function Ke(e,t){return t?e.target===t.target:t=>e.target===t.target}function qe(e,t){if(!t){let t=e;return e=>qe(e,t)}let n=e;return T(n.source,t)&&!T(n.target,t)}function Je(e,t){if(!t){let t=e;return e=>Je(e,t)}let n=e;return T(n.target,t)&&!T(n.source,t)}function Ye(e,t){if(!t){let t=e;return e=>Ye(e,t)}let n=e;return T(n.source,t)!==T(n.target,t)}var Q=class e{id;constructor(e,t,n=new Set){this.source=e,this.target=t,this.relations=n,this.id=Ce(`model:${e.id}:${t.id}`)}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target)}get expression(){return`${this.source.id} -> ${this.target.id}`}get isDirect(){return this.nonEmpty()&&!this.isImplicit}get isImplicit(){return this.nonEmpty()&&we(this.relations,a(Z(this)))}get directRelations(){return new Set(me(this.relations,Z(this)))}nonEmpty(){return this.relations.size>0}mergeWith(t){return E(this.source.id===t.source.id,`Cannot merge connections with different sources`),E(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,N(this.relations,t.relations))}difference(t){return new e(this.source,this.target,O(this.relations,t.relations))}intersect(t){return E(t instanceof e,`Cannot intersect connection with different type`),new e(this.source,this.target,k(this.relations,t.relations))}equals(t){E(t instanceof e,`Cannot merge connection with different type`);let n=t;return this.id===n.id&&this.source.id===n.source.id&&this.target.id===n.target.id&&M(this.relations,n.relations)}update(t){return new e(this.source,this.target,t)}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,`constructor`,{value:e,enumerable:!1}),i}toString(){return[this.expression,this.relations.size?` relations:`:` relations: [ ]`,...[...this.relations].map(e=>` `+e.expression)].join(`
4
4
  `)}reversed(){return new e(this.target,this.source)}},Xe=e({findConnection:()=>$,findConnectionsBetween:()=>Ze,findConnectionsWithin:()=>Qe});function $(e,t,n=`directed`){if(e===t||ve(e,t))return[];let r=e.allOutgoing.intersect(t.allIncoming),i=r.nonEmpty?[new Fe(e,t,r)]:[];return n===`directed`?i:[...i,...$(t,e,`directed`)]}function Ze(e,t,n=`both`){if(e.allIncoming.isEmpty&&e.allOutgoing.isEmpty)return[];let r=[],i=[];for(let a of t)if(e!==a)for(let t of $(e,a,n))t.source===e?r.push(t):i.push(t);return[...r,...i]}function Qe(e){return[...e].reduce((e,t,n,r)=>(n===r.length-1||e.push(...Ze(t,r.slice(n+1),`both`)),e),[])}var $e=e({findConnection:()=>et,findConnectionsBetween:()=>tt,findConnectionsWithin:()=>nt});function et(e,t,n=`directed`){if(e===t||ve(e,t))return[];let r=k(e.allOutgoing,t.allIncoming),i=r.size>0?new Q(e,t,r):null;if(n===`directed`)return i?[i]:[];let a=k(e.allIncoming,t.allOutgoing),o=a.size>0?new Q(t,e,a):null;return i&&o?[i,o]:i?[i]:o?[o]:[]}function tt(e,t,n=`both`){if(e.allIncoming.size===0&&e.allOutgoing.size===0)return[];let r=[],i=[];for(let a of t)if(e!==a)for(let t of et(e,a,n))t.source===e?r.push(t):i.push(t);return[...r,...i]}function nt(e){return[...e].reduce((e,t,n,r)=>(n===r.length-1||e.push(...tt(t,r.slice(n+1),`both`)),e),[])}function rt(e){return e instanceof I}function it(e){return e instanceof L}function at(e){return rt(e)||it(e)}function ot(e){return e instanceof ke}function st(e){return e instanceof R}function ct(e){return e instanceof U}function lt(e){return e instanceof F}function ut(e){return e instanceof K}function dt(e){return e instanceof G}function ft(e){return e instanceof W}export{Fe as A,Ae as B,Ye as C,Ue as D,qe as E,K as F,I as G,je as H,G as I,F as J,R as K,W as L,Pe as M,J as N,ze as O,q as P,U as R,Ke as S,X as T,H as U,Me as V,L as W,Ve as _,ft as a,Ge as b,ot as c,et as d,tt as f,We as g,Q as h,st as i,Y as j,Le as k,dt as l,Xe as m,at as n,lt as o,$e as p,z as q,rt as r,ut as s,it as t,ct as u,Ie as v,Je as w,Z as x,He as y,Ne as z};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime.mjs";import{t}from"./libs/defu.mjs";import{B as n,I as r,M as i,N as a,O as o,T as s,V as c,et as l,it as ee,k as u,rt as te,t as ne,x as re}from"./libs/remeda.mjs";import{Q as d,et as f,h as p,n as ie,t as ae}from"./utils.mjs";import{i as m,n as oe,t as se}from"./libs/mnemonist.mjs";import{a as ce,c as le,d as ue,f as de,h as fe,i as pe,l as me,m as he,n as ge,o as _e,p as ve,r as ye,s as be,t as xe,u as Se}from"./libs/@radix-ui/colors.mjs";import{n as h,t as Ce}from"./libs/@mantine/colors-generator.mjs";function we(e){return re(e,e=>e===void 0)}function Te(e){return e.summary??e.description}function Ee(e){return e.description??e.summary}function De(e,t){return e[g]===t}const g=`_stage`,Oe=`_type`,ke=`_layout`;var Ae=e({DeploymentFqn:()=>w,EdgeId:()=>j,Fqn:()=>x,GlobalFqn:()=>D,GroupElementKind:()=>S,MarkdownOrString:()=>v,NodeId:()=>A,NoneIcon:()=>b,ProjectId:()=>_,RelationId:()=>E,StepEdgeKind:()=>je,ViewId:()=>T,extractStep:()=>P,flattenMarkdownOrString:()=>y,isGlobalFqn:()=>O,isGroupElementKind:()=>C,isStepEdgeId:()=>N,splitGlobalFqn:()=>k,stepEdgeId:()=>M});function _(e){return e}function v(e){return typeof e==`string`?{txt:e}:e}function y(e){if(r(e))return null;let t=u(e)?e:e.txt??e.md;return o(t?.trim())?t:null}const b=`none`;function x(e,t){return t?t+`.`+e:e}const S=`@group`;function C(e){return e.kind===S}function w(e,t){return t?t+`.`+e:e}function T(e){return e}function E(e){return e}function D(e,t){return d(typeof e==`string`&&e!=``),`@`+e+`.`+t}function O(e){return e.startsWith(`@`)}function k(e){if(!e.startsWith(`@`))return[null,e];let t=e.indexOf(`.`);if(t<2)throw Error(`Invalid global FQN`);return[e.slice(1,t),e.slice(t+1)]}function A(e){return e}function j(e){return e}function M(e,t){let n=`step-${String(e).padStart(2,`0`)}`;return t?`${n}.${t}`:n}const je=`@step`;function N(e){return e.startsWith(`step-`)}function P(e){if(!N(e))throw Error(`Invalid step edge id: ${e}`);return parseFloat(e.slice(5))}let F;(function(e){function t(e){return`model`in e&&!(`project`in e)}e.isElementRef=t;function n(e){return`project`in e&&`model`in e}e.isImportRef=n;function r(e){if(u(e))throw Error(`Expected FqnRef, got: "${e}"`);if(n(e))return D(e.project,e.model);if(t(e))return e.model;throw Error(`Expected FqnRef.ModelRef or FqnRef.ImportRef`)}e.flatten=r;function i(e){return t(e)||n(e)}e.isModelRef=i;function a(e){return`deployment`in e&&`element`in e}e.isInsideInstanceRef=a;function o(e){return`deployment`in e&&!(`element`in e)}e.isDeploymentElementRef=o;function s(e){return o(e)||a(e)}e.isDeploymentRef=s})(F||={});let I;(function(e){function t(e){return`wildcard`in e&&e.wildcard===!0}e.isWildcard=t;function n(e){return`ref`in e&&F.isModelRef(e.ref)}e.isModelRef=n;function r(e){return`ref`in e&&F.isDeploymentRef(e.ref)}e.isDeploymentRef=r;function i(e){return`elementKind`in e&&`isEqual`in e}e.isElementKindExpr=i;function a(e){return`elementTag`in e&&`isEqual`in e}e.isElementTagExpr=a;function o(e){return`where`in e&&c(e.where.expr)}e.isWhere=o;function s(e){return`custom`in e&&(c(e.custom.expr)||o(e.custom.expr))}e.isCustom=s;function c(e){return t(e)||n(e)||r(e)||i(e)||a(e)}e.is=c;function l(e){return s(e)&&(e=e.custom.expr),o(e)&&(e=e.where.expr),e}e.unwrap=l})(I||={});let L;(function(e){function t(e){return`source`in e&&`target`in e}e.isDirect=t;function n(e){return`incoming`in e}e.isIncoming=n;function r(e){return`outgoing`in e}e.isOutgoing=r;function i(e){return`inout`in e}e.isInOut=i;function a(e){return`where`in e&&(t(e.where.expr)||n(e.where.expr)||r(e.where.expr)||i(e.where.expr))}e.isWhere=a;function o(e){return`customRelation`in e}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.customRelation.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(L||={});let R;(function(e){function t(e){return`where`in e}e.isWhere=t;function n(e){return L.isWhere(e)}e.isRelationWhere=n;function r(e){return I.isWhere(e)}e.isFqnExprWhere=r;function i(e){return I.is(e)||I.isWhere(e)||I.isCustom(e)}e.isFqnExpr=i;function a(e){return L.is(e)||L.isWhere(e)||L.isCustom(e)}e.isRelation=a})(R||={});let z;(function(e){function t(e){return`wildcard`in e&&e.wildcard===!0}e.isWildcard=t;function n(e){return`ref`in e&&F.isModelRef(e.ref)}e.isModelRef=n;function r(e){return`elementKind`in e&&`isEqual`in e}e.isElementKindExpr=r;function i(e){return`elementTag`in e&&`isEqual`in e}e.isElementTagExpr=i;function a(e){return`where`in e&&s(e.where.expr)}e.isWhere=a;function o(e){return`custom`in e&&(s(e.custom.expr)||a(e.custom.expr))}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.custom.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(z||={});let B;(function(e){function t(e){return`source`in e&&`target`in e}e.isDirect=t;function n(e){return`incoming`in e}e.isIncoming=n;function r(e){return`outgoing`in e}e.isOutgoing=r;function i(e){return`inout`in e}e.isInOut=i;function a(e){return`where`in e&&(t(e.where.expr)||n(e.where.expr)||r(e.where.expr)||i(e.where.expr))}e.isWhere=a;function o(e){return`customRelation`in e}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.customRelation.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(B||={});let V;(function(e){function t(e){return`where`in e}e.isWhere=t;function n(e){return B.isWhere(e)}e.isRelationWhere=n;function r(e){return z.isWhere(e)}e.isFqnExprWhere=r;function i(e){return z.is(e)||z.isWhere(e)||z.isCustom(e)}e.isFqnExpr=i;function a(e){return B.is(e)||B.isWhere(e)||B.isCustom(e)}e.isRelationExpr=a})(V||={});function Me(e){return o(e.kind)&&!o(e.element)}function Ne(e){return o(e.element)&&!o(e.kind)}const H={fill:`#3b82f6`,stroke:`#2563eb`,hiContrast:`#eff6ff`,loContrast:`#bfdbfe`},U={fill:`#0284c7`,stroke:`#0369a1`,hiContrast:`#f0f9ff`,loContrast:`#B6ECF7`},W={fill:`#64748b`,stroke:`#475569`,hiContrast:`#f8fafc`,loContrast:`#cbd5e1`},Pe={primary:H,blue:H,secondary:U,sky:U,muted:W,slate:W,gray:{fill:`#737373`,stroke:`#525252`,hiContrast:`#fafafa`,loContrast:`#d4d4d4`},red:{fill:`#AC4D39`,stroke:`#853A2D`,hiContrast:`#FBD3CB`,loContrast:`#f5b2a3`},green:{fill:`#428a4f`,stroke:`#2d5d39`,hiContrast:`#f8fafc`,loContrast:`#c2f0c2`},amber:{fill:`#A35829`,stroke:`#7E451D`,hiContrast:`#FFE0C2`,loContrast:`#f9b27c`},indigo:{fill:`#6366f1`,stroke:`#4f46e5`,hiContrast:`#eef2ff`,loContrast:`#c7d2fe`}},Fe={line:`#8D8D8D`,labelBg:`#18191B`,label:`#C9C9C9`},G={line:`#64748b`,labelBg:`#0f172a`,label:`#cbd5e1`},K={line:`#3b82f6`,labelBg:`#172554`,label:`#60a5fa`},q={line:`#0ea5e9`,labelBg:`#082f49`,label:`#38bdf8`},Ie={amber:{line:`#b45309`,labelBg:`#78350f`,label:`#FFE0C2`},blue:K,gray:Fe,green:{line:`#15803d`,labelBg:`#052e16`,label:`#22c55e`},indigo:{line:`#6366f1`,labelBg:`#1e1b4b`,label:`#818cf8`},muted:G,primary:K,red:{line:`#AC4D39`,labelBg:`#b91c1c`,label:`#f5b2a3`},secondary:q,sky:q,slate:G},Le={sizes:{xs:{width:180,height:100},sm:{width:240,height:135},md:{width:320,height:180},lg:{width:420,height:234},xl:{width:520,height:290}},spacing:{xs:8,sm:10,md:16,lg:24,xl:32},textSizes:{xs:13.33,sm:16,md:19.2,lg:23.04,xl:27.65},iconSizes:{xs:24,sm:36,md:60,lg:82,xl:90}},Re=[`xs`,`sm`,`md`,`lg`,`xl`],ze=[`left`,`right`,`top`,`bottom`],Be=[`solid`,`dashed`,`dotted`,`none`],Ve=[`rectangle`,`person`,`browser`,`mobile`,`cylinder`,`storage`,`queue`,`bucket`,`document`,`component`],J=[`amber`,`blue`,`gray`,`slate`,`green`,`indigo`,`muted`,`primary`,`red`,`secondary`,`sky`],He=[`tomato`,`grass`,`blue`,`ruby`,`orange`,`indigo`,`pink`,`teal`,`purple`,`amber`,`crimson`,`red`,`lime`,`yellow`,`violet`],Y={tomato:ve.tomato9,grass:pe.grass9,blue:ge.blue9,ruby:ue.ruby9,orange:be.orange9,indigo:ce.indigo9,pink:le.pink9,teal:de.teal9,purple:me.purple9,amber:xe.amber9,crimson:ye.crimson9,red:Se.red9,lime:_e.lime9,yellow:fe.yellow9,violet:he.violet9};function Ue(e){return e in Y}const We={colors:J.reduce((e,t)=>(e[t]={elements:Pe[t],relationships:Ie[t]},e),{}),...Le};function Ge(e){d(h.valid(e),`Invalid color: ${e}`);let t=Ce(e),n=t[6],r=Ke(n);return{elements:{fill:n,stroke:t[7],...r},relationships:{line:t[4],label:t[3],labelBg:t[9]}}}function Ke(e){let t=h(e),n=t.brighten(2),r=t.darken(2),i,a,o,s;do i=n,a=r,n=n.brighten(1),r=r.darken(1),o=h.contrastAPCA(t,n),s=h.contrastAPCA(t,r);while(Math.abs(o)<60&&Math.abs(s)<60&&(!c(n,i)||!c(r,a)));return Math.abs(o)>Math.abs(s)?{hiContrast:n.brighten(.4).hex(),loContrast:n.hex()}:{hiContrast:r.darken(.4).hex(),loContrast:r.hex()}}function qe(e,t){let n=t??6,r=h(e.fill),i=h(e.stroke),a=r.luminance()>.8,o=l(ne(h.scale(a?[r.darken(.02).desaturate(.05),r.darken(.1).desaturate(.1)]:[r.shade(.12,`lch`).desaturate(.05),r.shade(.35,`lch`).desaturate(.4)]).mode(`oklch`).correctLightness().colors(n,null),h.scale(a?[i.darken(.04).desaturate(.05),i.darken(.12).desaturate(.1)]:[i.shade(.15,`lch`).desaturate(.08),i.shade(.4,`lch`).desaturate(.4)]).mode(`oklch`).correctLightness().colors(n,null)),s(([t,n])=>({...e,fill:t.hex(),stroke:n.hex()})));return d(o.length===n,`Expected ${n} colors, got ${o.length}`),o}const Je={color:`primary`,size:`md`,opacity:15,shape:`rectangle`,group:{opacity:15,border:`dashed`},relationship:{color:`gray`,line:`dashed`,arrow:`normal`}},Ye=We,X={theme:Ye,defaults:Je};var Xe=class e{theme;defaults;static DEFAULT=new e(X);static from(n,i){if(!n&&!i)return this.DEFAULT;let{customCss:a,theme:o,defaults:s}={...n},l=t({theme:o},{defaults:{...s}},{theme:{colors:{...i}}},X);return r(a?.content)&&c(l,X)?this.DEFAULT:new e(l,a)}constructor(e,t){this.config=e,this.customCss=t,this.theme=e.theme,this.defaults=e.defaults}get elementColors(){return this.theme.colors[this.defaults.color].elements}get relationshipColors(){return this.theme.colors[this.defaults.relationship.color].relationships}get groupColors(){let e=this.defaults.group?.color;if(!e)return this.elementColors;if(!this.isThemeColor(e))throw Error(`Default group color not found in theme: ${e}`);return p(this,`defaultGroup`,()=>({...this.elementColors,...this.theme.colors[e].elements}))}isDefaultColor(e){return e===this.defaults.color}colors(e){return this.computeFrom(e??=this.defaults.color)}compoundColorsCache=new oe.default(e=>new se.default(t=>qe(e,t)));colorsForCompounds(e,t){return this.compoundColorsCache.get(e).get(t??6)}fontSize(e){return e??=this.defaults.text??this.defaults.size,this.theme.textSizes[e]}padding(e){return e??=this.defaults.padding??this.defaults.size,this.theme.spacing[e]}iconSize(e){return e??=this.defaults.size,this.theme.iconSizes[e]}isThemeColor(e){return e in this.theme.colors}nodeSizes(e){let t=Ze(e,this.defaults.size);return{sizes:t,values:{sizes:this.theme.sizes[t.size],padding:this.padding(t.padding),textSize:this.fontSize(t.textSize),iconSize:this.iconSize(t.iconSize)}}}computeFrom(e){if(this.isThemeColor(e))return this.theme.colors[e];if(!h.valid(e))throw Error(`Invalid color value: "${e}" (not a theme color and not a valid CSS color)`);return Ge(e)}equals(e){return e===this?!0:this.constructor===e.constructor?c(this.config,e.config)&&c(this.customCss??null,e.customCss??null):!1}tagColor(e){return this.isThemeColor(e)?this.theme.colors[e].elements:Ue(e)?this.computeFrom(Y[e]).elements:this.computeFrom(e).elements}};function Ze({size:e,padding:t,textSize:n,iconSize:r,...i},a=X.defaults.size){return e??=a,n??=e,t??=e,r??=e,{...i,size:e,padding:t,textSize:n,iconSize:r}}function Qe(e){let t=typeof e==`string`?e:e.color;return t.startsWith(`#`)||t.startsWith(`rgb`)}function $e(e){return`tag`in e}function et(e){return`kind`in e}function tt(e){return`participant`in e}function nt(e){return`not`in e}function rt(e){return`and`in e}function Z(e){return`or`in e}function Q(e){switch(!0){case tt(e):{let t=e.participant;return it(t,Q(e.operator))}case $e(e):{if(u(e.tag)||`eq`in e.tag){let t=u(e.tag)?e.tag:e.tag.eq;return e=>Array.isArray(e.tags)&&e.tags.includes(t)}let t=e.tag.neq;return e=>!Array.isArray(e.tags)||!e.tags.includes(t)}case et(e):{if(u(e.kind)||`eq`in e.kind){let t=u(e.kind)?e.kind:e.kind.eq;return e=>e.kind===t}let t=e.kind.neq;return e=>i(e.kind)||e.kind!==t}case nt(e):return a(Q(e.not));case rt(e):return ee(e.and.map(Q));case Z(e):return te(e.or.map(Q));default:f(e)}}function it(e,t){return n=>{if(!n.source||!n.target)return!1;switch(e){case`source`:return t(n.source);case`target`:return t(n.target)}}}function at(e){return`include`in e||`exclude`in e}function ot(e){return`targets`in e&&`style`in e}function st(e){return e._stage===`computed`}function ct(e){return e._stage===`layouted`}function $(e){return e._type===`element`}function lt(e){return $(e)&&o(e.viewOf)}function ut(e){return $(e)&&o(e.extends)}function dt(e){return e._type===`deployment`}function ft(e){return e._type===`dynamic`}function pt(e){return`styleId`in e}function mt(e){return`predicateId`in e}function ht(e){return e===`TB`||e===`BT`||e===`LR`||e===`RL`}function gt(e){return`direction`in e}function _t(e){return N(e)&&e.includes(`.`)?e.slice(0,e.indexOf(`.`)+1):null}function vt(e){return!!e&&!(`__series`in e||`__parallel`in e)}function yt(e){return!!e&&`__parallel`in e&&n(e.__parallel)}function bt(e){return!!e&&`__series`in e&&n(e.__series)}function xt(e){return`title`in e&&`groupRules`in e&&Array.isArray(e.groupRules)}function St(e){return`rank`in e&&Array.isArray(e.targets)}const Ct=Symbol.for(`text`),wt=Symbol.for(`html`);var Tt=class e{static mdcache=new m.default(500);static txtcache=new m.default(500);static getOrCreateFromText(t){if(t=t.trimEnd(),t===``)return e.EMPTY;let n=e.txtcache.get(t);return n||(n=new e({txt:t}),e.txtcache.set(t,n),n)}static getOrCreateFromMarkdown(t){if(t=t.trimEnd(),t===``)return e.EMPTY;let n=e.mdcache.get(t);return n||(n=new e({md:t}),e.mdcache.set(t,n),n)}static memoize(t,n,r){return p(t,n,()=>e.from(r))}static from(t){return t==null||t===e.EMPTY?e.EMPTY:t instanceof e?t:typeof t==`string`?this.getOrCreateFromText(t):`isEmpty`in t&&t.isEmpty?e.EMPTY:`md`in t?this.getOrCreateFromMarkdown(t.md):this.getOrCreateFromText(t.txt)}static EMPTY=new class extends e{isEmpty=!0;nonEmpty=!1;isMarkdown=!1;$source=null;constructor(){super({txt:``})}get text(){return null}get md(){return null}get html(){return null}};$source;isEmpty;nonEmpty;isMarkdown;constructor(e){this.isMarkdown=!1,typeof e==`string`?(this.$source={txt:e},this.isEmpty=e.trim()===``):(this.$source=e,this.isEmpty=!0,`md`in e?(this.isEmpty=e.md===``,this.isMarkdown=!0):this.isEmpty=e.txt===``),this.nonEmpty=!this.isEmpty}get text(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;return`txt`in e?e.txt:p(this,Ct,()=>ae(e.md))}get md(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;if(`md`in e)return e.md;if(`txt`in e)return e.txt;f(e)}get html(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;return`txt`in e?e.txt:p(this,wt,()=>ie(e.md))}equals(t){return this===t?!0:t instanceof e?this.isEmpty&&t.isEmpty?!0:this.isEmpty!==t.isEmpty||this.isMarkdown!==t.isMarkdown?!1:this.isMarkdown?this.$source?.md===t.$source?.md:this.$source?.txt===t.$source?.txt:!1}};export{S as $,Xe as A,Ne as B,nt as C,Q as D,$e as E,He as F,R as G,V as H,Ve as I,F as J,I as K,ze as L,Je as M,Ge as N,Qe as O,Be as P,D as Q,Re as R,et as S,tt as T,z as U,Me as V,B as W,j as X,w as Y,x as Z,ut as _,Oe as _t,vt as a,je as at,ot as b,Te as bt,ht as c,y as ct,pt as d,N as dt,v as et,st as f,Ae as ft,$ as g,g as gt,ft as h,ke as ht,_t as i,E as it,Ye as j,Ze as k,gt as l,O as lt,ct as m,M as mt,xt as n,b as nt,yt as o,T as ot,dt as p,k as pt,L as q,St as r,_ as rt,bt as s,P as st,Tt as t,A as tt,mt as u,C as ut,lt as v,De as vt,Z as w,rt as x,we as xt,at as y,Ee as yt,J as z};
1
+ import{n as e}from"./rolldown-runtime.mjs";import{t}from"./libs/defu.mjs";import{B as n,I as r,M as i,N as a,O as o,T as s,V as c,et as l,it as ee,k as u,rt as te,t as ne,x as re}from"./libs/remeda.mjs";import{Q as d,et as f,h as p,i as ie,n as ae,t as oe}from"./utils.mjs";import{i as m,n as se,t as ce}from"./libs/mnemonist.mjs";import{a as le,c as ue,d as de,f as fe,h as pe,i as me,l as he,m as ge,n as _e,o as ve,p as ye,r as be,s as xe,t as Se,u as Ce}from"./libs/@radix-ui/colors.mjs";import{n as h,t as we}from"./libs/@mantine/colors-generator.mjs";function Te(e){return re(e,e=>e===void 0)}function Ee(e){return e.summary??e.description}function De(e){return e.description??e.summary}function Oe(e,t){return e[g]===t}const g=`_stage`,ke=`_type`,Ae=`_layout`;var je=e({DeploymentFqn:()=>w,EdgeId:()=>j,Fqn:()=>x,GlobalFqn:()=>D,GroupElementKind:()=>S,MarkdownOrString:()=>v,NodeId:()=>A,NoneIcon:()=>b,ProjectId:()=>_,RelationId:()=>E,StepEdgeKind:()=>Me,ViewId:()=>T,extractStep:()=>P,flattenMarkdownOrString:()=>y,isGlobalFqn:()=>O,isGroupElementKind:()=>C,isStepEdgeId:()=>N,splitGlobalFqn:()=>k,stepEdgeId:()=>M});function _(e){return e}function v(e){return typeof e==`string`?{txt:e}:e}function y(e){if(r(e))return null;let t=u(e)?e:e.txt??e.md;return o(t?.trim())?t:null}const b=`none`;function x(e,t){return t?t+`.`+e:e}const S=`@group`;function C(e){return e.kind===S}function w(e,t){return t?t+`.`+e:e}function T(e){return e}function E(e){return e}function D(e,t){return d(typeof e==`string`&&e!=``),`@`+e+`.`+t}function O(e){return e.startsWith(`@`)}function k(e){if(!e.startsWith(`@`))return[null,e];let t=e.indexOf(`.`);if(t<2)throw Error(`Invalid global FQN`);return[e.slice(1,t),e.slice(t+1)]}function A(e){return e}function j(e){return e}function M(e,t){let n=`step-${String(e).padStart(2,`0`)}`;return t?`${n}.${t}`:n}const Me=`@step`;function N(e){return e.startsWith(`step-`)}function P(e){if(!N(e))throw Error(`Invalid step edge id: ${e}`);return parseFloat(e.slice(5))}let F;(function(e){function t(e){return`model`in e&&!(`project`in e)}e.isElementRef=t;function n(e){return`project`in e&&`model`in e}e.isImportRef=n;function r(e){if(u(e))throw Error(`Expected FqnRef, got: "${e}"`);if(n(e))return D(e.project,e.model);if(t(e))return e.model;throw Error(`Expected FqnRef.ModelRef or FqnRef.ImportRef`)}e.flatten=r;function i(e){return t(e)||n(e)}e.isModelRef=i;function a(e){return`deployment`in e&&`element`in e}e.isInsideInstanceRef=a;function o(e){return`deployment`in e&&!(`element`in e)}e.isDeploymentElementRef=o;function s(e){return o(e)||a(e)}e.isDeploymentRef=s})(F||={});let I;(function(e){function t(e){return`wildcard`in e&&e.wildcard===!0}e.isWildcard=t;function n(e){return`ref`in e&&F.isModelRef(e.ref)}e.isModelRef=n;function r(e){return`ref`in e&&F.isDeploymentRef(e.ref)}e.isDeploymentRef=r;function i(e){return`elementKind`in e&&`isEqual`in e}e.isElementKindExpr=i;function a(e){return`elementTag`in e&&`isEqual`in e}e.isElementTagExpr=a;function o(e){return`where`in e&&c(e.where.expr)}e.isWhere=o;function s(e){return`custom`in e&&(c(e.custom.expr)||o(e.custom.expr))}e.isCustom=s;function c(e){return t(e)||n(e)||r(e)||i(e)||a(e)}e.is=c;function l(e){return s(e)&&(e=e.custom.expr),o(e)&&(e=e.where.expr),e}e.unwrap=l})(I||={});let L;(function(e){function t(e){return`source`in e&&`target`in e}e.isDirect=t;function n(e){return`incoming`in e}e.isIncoming=n;function r(e){return`outgoing`in e}e.isOutgoing=r;function i(e){return`inout`in e}e.isInOut=i;function a(e){return`where`in e&&(t(e.where.expr)||n(e.where.expr)||r(e.where.expr)||i(e.where.expr))}e.isWhere=a;function o(e){return`customRelation`in e}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.customRelation.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(L||={});let R;(function(e){function t(e){return`where`in e}e.isWhere=t;function n(e){return L.isWhere(e)}e.isRelationWhere=n;function r(e){return I.isWhere(e)}e.isFqnExprWhere=r;function i(e){return I.is(e)||I.isWhere(e)||I.isCustom(e)}e.isFqnExpr=i;function a(e){return L.is(e)||L.isWhere(e)||L.isCustom(e)}e.isRelation=a})(R||={});let z;(function(e){function t(e){return`wildcard`in e&&e.wildcard===!0}e.isWildcard=t;function n(e){return`ref`in e&&F.isModelRef(e.ref)}e.isModelRef=n;function r(e){return`elementKind`in e&&`isEqual`in e}e.isElementKindExpr=r;function i(e){return`elementTag`in e&&`isEqual`in e}e.isElementTagExpr=i;function a(e){return`where`in e&&s(e.where.expr)}e.isWhere=a;function o(e){return`custom`in e&&(s(e.custom.expr)||a(e.custom.expr))}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.custom.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(z||={});let B;(function(e){function t(e){return`source`in e&&`target`in e}e.isDirect=t;function n(e){return`incoming`in e}e.isIncoming=n;function r(e){return`outgoing`in e}e.isOutgoing=r;function i(e){return`inout`in e}e.isInOut=i;function a(e){return`where`in e&&(t(e.where.expr)||n(e.where.expr)||r(e.where.expr)||i(e.where.expr))}e.isWhere=a;function o(e){return`customRelation`in e}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.customRelation.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(B||={});let V;(function(e){function t(e){return`where`in e}e.isWhere=t;function n(e){return B.isWhere(e)}e.isRelationWhere=n;function r(e){return z.isWhere(e)}e.isFqnExprWhere=r;function i(e){return z.is(e)||z.isWhere(e)||z.isCustom(e)}e.isFqnExpr=i;function a(e){return B.is(e)||B.isWhere(e)||B.isCustom(e)}e.isRelationExpr=a})(V||={});function Ne(e){return o(e.kind)&&!o(e.element)}function Pe(e){return o(e.element)&&!o(e.kind)}const H={fill:`#3b82f6`,stroke:`#2563eb`,hiContrast:`#eff6ff`,loContrast:`#bfdbfe`},U={fill:`#0284c7`,stroke:`#0369a1`,hiContrast:`#f0f9ff`,loContrast:`#B6ECF7`},W={fill:`#64748b`,stroke:`#475569`,hiContrast:`#f8fafc`,loContrast:`#cbd5e1`},Fe={primary:H,blue:H,secondary:U,sky:U,muted:W,slate:W,gray:{fill:`#737373`,stroke:`#525252`,hiContrast:`#fafafa`,loContrast:`#d4d4d4`},red:{fill:`#AC4D39`,stroke:`#853A2D`,hiContrast:`#FBD3CB`,loContrast:`#f5b2a3`},green:{fill:`#428a4f`,stroke:`#2d5d39`,hiContrast:`#f8fafc`,loContrast:`#c2f0c2`},amber:{fill:`#A35829`,stroke:`#7E451D`,hiContrast:`#FFE0C2`,loContrast:`#f9b27c`},indigo:{fill:`#6366f1`,stroke:`#4f46e5`,hiContrast:`#eef2ff`,loContrast:`#c7d2fe`}},Ie={line:`#8D8D8D`,labelBg:`#18191B`,label:`#C9C9C9`},G={line:`#64748b`,labelBg:`#0f172a`,label:`#cbd5e1`},K={line:`#3b82f6`,labelBg:`#172554`,label:`#60a5fa`},q={line:`#0ea5e9`,labelBg:`#082f49`,label:`#38bdf8`},Le={amber:{line:`#b45309`,labelBg:`#78350f`,label:`#FFE0C2`},blue:K,gray:Ie,green:{line:`#15803d`,labelBg:`#052e16`,label:`#22c55e`},indigo:{line:`#6366f1`,labelBg:`#1e1b4b`,label:`#818cf8`},muted:G,primary:K,red:{line:`#AC4D39`,labelBg:`#b91c1c`,label:`#f5b2a3`},secondary:q,sky:q,slate:G},Re={sizes:{xs:{width:180,height:100},sm:{width:240,height:135},md:{width:320,height:180},lg:{width:420,height:234},xl:{width:520,height:290}},spacing:{xs:8,sm:10,md:16,lg:24,xl:32},textSizes:{xs:13.33,sm:16,md:19.2,lg:23.04,xl:27.65},iconSizes:{xs:24,sm:36,md:60,lg:82,xl:90}},ze=[`xs`,`sm`,`md`,`lg`,`xl`],Be=[`left`,`right`,`top`,`bottom`],Ve=[`solid`,`dashed`,`dotted`,`none`],He=[`rectangle`,`person`,`browser`,`mobile`,`cylinder`,`storage`,`queue`,`bucket`,`document`,`component`],J=[`amber`,`blue`,`gray`,`slate`,`green`,`indigo`,`muted`,`primary`,`red`,`secondary`,`sky`],Ue=[`tomato`,`grass`,`blue`,`ruby`,`orange`,`indigo`,`pink`,`teal`,`purple`,`amber`,`crimson`,`red`,`lime`,`yellow`,`violet`],Y={tomato:ye.tomato9,grass:me.grass9,blue:_e.blue9,ruby:de.ruby9,orange:xe.orange9,indigo:le.indigo9,pink:ue.pink9,teal:fe.teal9,purple:he.purple9,amber:Se.amber9,crimson:be.crimson9,red:Ce.red9,lime:ve.lime9,yellow:pe.yellow9,violet:ge.violet9};function We(e){return e in Y}const Ge={colors:J.reduce((e,t)=>(e[t]={elements:Fe[t],relationships:Le[t]},e),{}),...Re};function Ke(e){d(h.valid(e),`Invalid color: ${e}`);let t=we(e),n=t[6],r=qe(n);return{elements:{fill:n,stroke:t[7],...r},relationships:{line:t[4],label:t[3],labelBg:t[9]}}}function qe(e){let t=h(e),n=t.brighten(2),r=t.darken(2),i,a,o,s;do i=n,a=r,n=n.brighten(1),r=r.darken(1),o=h.contrastAPCA(t,n),s=h.contrastAPCA(t,r);while(Math.abs(o)<60&&Math.abs(s)<60&&(!c(n,i)||!c(r,a)));return Math.abs(o)>Math.abs(s)?{hiContrast:n.brighten(.4).hex(),loContrast:n.hex()}:{hiContrast:r.darken(.4).hex(),loContrast:r.hex()}}function Je(e,t){let n=t??6,r=h(e.fill),i=h(e.stroke),a=r.luminance()>.8,o=l(ne(h.scale(a?[r.darken(.02).desaturate(.05),r.darken(.1).desaturate(.1)]:[r.shade(.12,`lch`).desaturate(.05),r.shade(.35,`lch`).desaturate(.4)]).mode(`oklch`).correctLightness().colors(n,null),h.scale(a?[i.darken(.04).desaturate(.05),i.darken(.12).desaturate(.1)]:[i.shade(.15,`lch`).desaturate(.08),i.shade(.4,`lch`).desaturate(.4)]).mode(`oklch`).correctLightness().colors(n,null)),s(([t,n])=>({...e,fill:t.hex(),stroke:n.hex()})));return d(o.length===n,`Expected ${n} colors, got ${o.length}`),o}const Ye={color:`primary`,size:`md`,opacity:15,shape:`rectangle`,group:{opacity:15,border:`dashed`},relationship:{color:`gray`,line:`dashed`,arrow:`normal`}},Xe=Ge,X={theme:Xe,defaults:Ye};var Ze=class e{theme;defaults;static DEFAULT=new e(X);static from(n,i){if(!n&&!i)return this.DEFAULT;let{customCss:a,theme:o,defaults:s}={...n},l=t({theme:o},{defaults:{...s}},{theme:{colors:{...i}}},X);return r(a?.content)&&c(l,X)?this.DEFAULT:new e(l,a)}constructor(e,t){this.config=e,this.customCss=t,this.theme=e.theme,this.defaults=e.defaults}get fingerprint(){return p(this,`fingerprint`,()=>ie({config:this.config,customCss:this.customCss}))}get elementColors(){return this.theme.colors[this.defaults.color].elements}get relationshipColors(){return this.theme.colors[this.defaults.relationship.color].relationships}get groupColors(){let e=this.defaults.group?.color;if(!e)return this.elementColors;if(!this.isThemeColor(e))throw Error(`Default group color not found in theme: ${e}`);return p(this,`defaultGroup`,()=>({...this.elementColors,...this.theme.colors[e].elements}))}isDefaultColor(e){return e===this.defaults.color}colors(e){return this.computeFrom(e??this.defaults.color)}compoundColorsCache=new se.default(e=>new ce.default(t=>Je(e,t)));colorsForCompounds(e,t){return this.compoundColorsCache.get(e).get(t??6)}fontSize(e){return e??=this.defaults.text??this.defaults.size,this.theme.textSizes[e]}padding(e){return e??=this.defaults.padding??this.defaults.size,this.theme.spacing[e]}iconSize(e){return e??=this.defaults.size,this.theme.iconSizes[e]}isThemeColor(e){return e in this.theme.colors}nodeSizes(e){let t=Qe(e,this.defaults.size);return{sizes:t,values:{sizes:this.theme.sizes[t.size],padding:this.padding(t.padding),textSize:this.fontSize(t.textSize),iconSize:this.iconSize(t.iconSize)}}}computeFrom(e){if(this.isThemeColor(e))return this.theme.colors[e];if(!h.valid(e))throw Error(`Invalid color value: "${e}" (not a theme color and not a valid CSS color)`);return Ke(e)}equals(e){return e===this?!0:this.constructor===e.constructor?this.fingerprint===e.fingerprint:!1}tagColor(e){return this.isThemeColor(e)?this.theme.colors[e].elements:We(e)?this.computeFrom(Y[e]).elements:this.computeFrom(e).elements}};function Qe({size:e,padding:t,textSize:n,iconSize:r,...i},a=X.defaults.size){return e??=a,n??=e,t??=e,r??=e,{...i,size:e,padding:t,textSize:n,iconSize:r}}function $e(e){let t=typeof e==`string`?e:e.color;return t.startsWith(`#`)||t.startsWith(`rgb`)}function et(e){return`tag`in e}function tt(e){return`kind`in e}function nt(e){return`metadata`in e}function rt(e){return`participant`in e}function it(e){return`not`in e}function at(e){return`and`in e}function Z(e){return`or`in e}function Q(e){switch(!0){case rt(e):{let t=e.participant;return ot(t,Q(e.operator))}case et(e):{if(u(e.tag)||`eq`in e.tag){let t=u(e.tag)?e.tag:e.tag.eq;return e=>Array.isArray(e.tags)&&e.tags.includes(t)}let t=e.tag.neq;return e=>!Array.isArray(e.tags)||!e.tags.includes(t)}case tt(e):{if(u(e.kind)||`eq`in e.kind){let t=u(e.kind)?e.kind:e.kind.eq;return e=>e.kind===t}let t=e.kind.neq;return e=>i(e.kind)||e.kind!==t}case nt(e):{let{key:t,value:n}=e.metadata;if(n===void 0)return e=>e.metadata!=null&&t in e.metadata&&e.metadata[t]!=null;if(u(n)||`eq`in n){let e=u(n)?n:n.eq;return n=>{if(!n.metadata)return!1;let r=n.metadata[t];return Array.isArray(r)?r.includes(e):r===e}}let r=n.neq;return e=>{if(!e.metadata)return!0;let n=e.metadata[t];return n==null?!0:Array.isArray(n)?!n.includes(r):n!==r}}case it(e):return a(Q(e.not));case at(e):return ee(e.and.map(Q));case Z(e):return te(e.or.map(Q));default:f(e)}}function ot(e,t){return n=>{if(!n.source||!n.target)return!1;switch(e){case`source`:return t(n.source);case`target`:return t(n.target)}}}function st(e){return`include`in e||`exclude`in e}function ct(e){return`targets`in e&&`style`in e}function lt(e){return e._stage===`computed`}function ut(e){return e._stage===`layouted`}function $(e){return e._type===`element`}function dt(e){return $(e)&&o(e.viewOf)}function ft(e){return $(e)&&o(e.extends)}function pt(e){return e._type===`deployment`}function mt(e){return e._type===`dynamic`}function ht(e){return`styleId`in e}function gt(e){return`predicateId`in e}function _t(e){return e===`TB`||e===`BT`||e===`LR`||e===`RL`}function vt(e){return`direction`in e}function yt(e){return N(e)&&e.includes(`.`)?e.slice(0,e.indexOf(`.`)+1):null}function bt(e){return!!e&&!(`__series`in e||`__parallel`in e)}function xt(e){return!!e&&`__parallel`in e&&n(e.__parallel)}function St(e){return!!e&&`__series`in e&&n(e.__series)}function Ct(e){return`title`in e&&`groupRules`in e&&Array.isArray(e.groupRules)}function wt(e){return`rank`in e&&Array.isArray(e.targets)}const Tt=Symbol.for(`text`),Et=Symbol.for(`html`);var Dt=class e{static mdcache=new m.default(500);static txtcache=new m.default(500);static getOrCreateFromText(t){if(t=t.trimEnd(),t===``)return e.EMPTY;let n=e.txtcache.get(t);return n||(n=new e({txt:t}),e.txtcache.set(t,n),n)}static getOrCreateFromMarkdown(t){if(t=t.trimEnd(),t===``)return e.EMPTY;let n=e.mdcache.get(t);return n||(n=new e({md:t}),e.mdcache.set(t,n),n)}static memoize(t,n,r){return p(t,n,()=>e.from(r))}static from(t){return t==null||t===e.EMPTY?e.EMPTY:t instanceof e?t:typeof t==`string`?this.getOrCreateFromText(t):`isEmpty`in t&&t.isEmpty?e.EMPTY:`md`in t?this.getOrCreateFromMarkdown(t.md):this.getOrCreateFromText(t.txt)}static EMPTY=new class extends e{isEmpty=!0;nonEmpty=!1;isMarkdown=!1;$source=null;constructor(){super({txt:``})}get text(){return null}get md(){return null}get html(){return null}};$source;isEmpty;nonEmpty;isMarkdown;constructor(e){this.isMarkdown=!1,typeof e==`string`?(this.$source={txt:e},this.isEmpty=e.trim()===``):(this.$source=e,this.isEmpty=!0,`md`in e?(this.isEmpty=e.md===``,this.isMarkdown=!0):this.isEmpty=e.txt===``),this.nonEmpty=!this.isEmpty}get text(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;return`txt`in e?e.txt:p(this,Tt,()=>oe(e.md))}get md(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;if(`md`in e)return e.md;if(`txt`in e)return e.txt;f(e)}get html(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;return`txt`in e?e.txt:p(this,Et,()=>ae(e.md))}equals(t){return this===t?!0:t instanceof e?this.isEmpty&&t.isEmpty?!0:this.isEmpty!==t.isEmpty||this.isMarkdown!==t.isMarkdown?!1:this.isMarkdown?this.$source?.md===t.$source?.md:this.$source?.txt===t.$source?.txt:!1}};export{D as $,Qe as A,J as B,nt as C,et as D,rt as E,Ve as F,B as G,Ne as H,Ue as I,L as J,R as K,He as L,Xe as M,Ye as N,Q as O,Ke as P,x as Q,Be as R,tt as S,Te as St,Z as T,V as U,Pe as V,z as W,w as X,F as Y,j as Z,ft as _,g as _t,bt as a,E as at,ct as b,De as bt,_t as c,P as ct,ht as d,C as dt,S as et,lt as f,N as ft,$ as g,Ae as gt,mt as h,M as ht,yt as i,_ as it,Ze as j,$e as k,vt as l,y as lt,ut as m,k as mt,Ct as n,A as nt,xt as o,Me as ot,pt as p,je as pt,I as q,wt as r,b as rt,St as s,T as st,Dt as t,v as tt,gt as u,O as ut,dt as v,ke as vt,it as w,at as x,Ee as xt,st as y,Oe as yt,ze as z};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime.mjs";import{t}from"./libs/defu.mjs";import{F as n,P as r,Q as i,R as a,T as o,a as s,et as c,f as l,k as u,l as d,t as f}from"./libs/remeda.mjs";import{s as p}from"./libs/mnemonist.mjs";import{t as m}from"./libs/natural-compare-lite.mjs";import{t as h}from"./libs/ohash.mjs";import{n as g}from"./libs/hast-util-sanitize.mjs";import{t as _}from"./libs/rehype-sanitize.mjs";import{t as v}from"./libs/rehype-stringify.mjs";import{l as y,t as b}from"./libs/mdast-util-from-markdown.mjs";import{t as ee}from"./libs/remark-gfm.mjs";import{t as te}from"./libs/remark-github-blockquote-alert.mjs";import{t as ne}from"./libs/remark-parse.mjs";import{t as re}from"./libs/remark-rehype.mjs";import{t as ie}from"./libs/unified.mjs";function x(e,t){if(e===void 0||e==null){let n=typeof t==`function`?t():t;throw Error(n??`Expected defined value, but received ${e}`)}return e}function S(e,t){if(!e)throw Error(t??`Invariant failed`)}function C(e){throw Error(`NonExhaustive value: ${e}`)}function w(e,t,n){return e.length===0||t.length===0?[]:(n??=Object.is,c(f(e,t),s(([e,t])=>n(e,t)),o(([e,t])=>e)))}var T=e(m(),1);function E(e,t){return e===t?0:u(e)?u(t)?(0,T.default)(e,t):1:u(t)?-1:0}function D(e){return d(e,E)}function O(...e){return e.length===0?D:D(e[0])}function k(e=`.`,t=!1){return(n,r)=>{if(n===r)return 0;if(!n)return-1;if(!r)return 1;let i=n.split(e),a=r.split(e),o=Math.min(i.length,a.length);for(let e=0;e<o;e++){let t=i[e],n=a[e],r=(0,T.default)(t,n);if(r!==0)return r}let s=i.length-a.length;return t?-1*s:s}}function A(e){return e!=null&&typeof e==`string`}function j(e){return!!e&&Array.isArray(e)&&e.length>0}function M(e,t){return e[t]!=null}function N(...e){return(t=>e.some(e=>e(t)))}function P(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(0,t):null}function F(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(t+1):e}const I=e=>A(e)?e:e.id;function L(e,t){let n=I(e);return t?I(t).startsWith(n+`.`):e=>{let t=I(e);return n.startsWith(t+`.`)}}function R(e,t){if(!t)return t=>R(e,t);let n=I(e),r=I(t);return n===r||r.startsWith(n+`.`)||n.startsWith(r+`.`)}function z(e,t){return t?L(t,e):t=>L(e,t)}function B(e){return(A(e)?e:e.id).split(`.`).length}function V(e,t){let n=A(e)?e:e.id,r=A(t)?t:t.id;if(n===r)return 0;let i=B(n),a=B(r);if(R(n,r))return Math.abs(i-a);let o=H(n,r),s=o?B(o):0;return i+a-(2*s+1)}function H(e,t){let n=e.split(`.`);if(n.length<2)return null;let r=t.split(`.`);if(r.length<2)return null;let i=[];for(let e=0;e<Math.min(n.length,r.length)-1&&n[e]===r[e];e++)i.push(n[e]);return i.length===0?null:i.join(`.`)}function U(e){let t=e.split(`.`);if(t.pop(),!i(t,2))return t;for(let e=1;e<t.length;e++)t[e]=t[e-1]+`.`+t[e];return t.reverse()}function W(e,t){let n=e.split(`.`).length,r=t.split(`.`).length;switch(!0){case n>r:return 1;case n<r:return-1;default:return 0}}function G(e,t){return W(e.id,t.id)}function K(e){return e.map(e=>({item:e,fqn:e.id.split(`.`)})).sort((e,t)=>e.fqn.length-t.fqn.length).map(({item:e})=>e)}function q(e,t){let n=t;for(let t of e)t!==n&&L(t,n)&&(n=t);return n===t?null:n}function J(e){let t=[],n=[...e],r;for(;r=n.shift();){let e;for(;e=q(n,r);)t.push(...n.splice(n.indexOf(e),1));t.push(r)}return t}function Y(e,t){if(!e||A(e)){let t=e??`asc`;return e=>Y(e,t)}let n=t===`desc`?-1:1;return e.map(e=>({item:e,fqn:e.id.split(`.`)})).sort((e,t)=>{if(e.fqn.length!==t.fqn.length)return(e.fqn.length-t.fqn.length)*n;for(let n=0;n<e.fqn.length;n++){let r=E(e.fqn[n],t.fqn[n]);if(r!==0)return r}return 0}).map(({item:e})=>e)}function ae(e,t,n){let r=e.get(t);return r||(r=n(t),e.set(t,r)),r}function oe(e){return typeof e==`object`&&!!e&&Symbol.iterator in e}function se(e,t){let r=t??e;S(n(r));function*i(e){for(let t of e)r(t)&&(yield t)}return t?i(e):i}function ce(e,t){let r=t??e;S(n(r));function i(e){for(let t of e)if(r(t))return t}return t?i(e):i}function le(e,t){let n=t??e;S(typeof n==`number`&&n>=0,`Count must be a non-negative number`);function*r(e){let t=0;for(let r of e){if(t>=n)break;yield r,t++}}return t===void 0?e=>r(e):r(e)}function ue(e){return e?X(e):X}function*X(e){for(let t of e)yield*t}function de(e,t){let r=t??e;S(n(r));function*i(e){for(let t of e)yield*r(t)}return t?i(e):i}function fe(e){return e?Z(e):Z}function Z(e){let{value:t}=e[Symbol.iterator]().next();return t}function pe(e,t){let r=t??e;S(n(r));function*i(e){for(let t of e)yield r(t)}return t?i(e):i}function me(e,t,r){let i=a(r)?t:e,o=r??t;S(n(i));function s(e){let t=o;for(let n of e)t=i(t,n);return t}return a(r)?s(e):s}function he(e,t){let r=t??e;S(n(r));function i(e){for(let t of e)if(r(t))return!0;return!1}return t?i(e):i}function ge(e){return e?Array.from(e):e=>Array.from(e)}function _e(e){return e?new Set(e):e=>new Set(e)}function ve(e){return e?Q(e):Q}function*Q(e){let t=new Set;for(let n of e)t.has(n)||(t.add(n),yield n)}function ye(e,t,n){let r=typeof t==`symbol`?t:Symbol.for(t);return e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!1,writable:!1,value:n()}),e[r]}function be(...e){let t=100;return e.length===2?t=l(e[0],e[1]):e.length===1&&(t=e[0]),new Promise(e=>{setTimeout(()=>{e(`LIKEC4_DELAY`)},t??100)})}function xe(){return Promise.resolve().then(()=>void 0)}function Se(e){Promise.resolve().then(e)}const Ce=(e,t)=>{let n=H(e.source.id,e.target.id),r=H(t.source.id,t.target.id);if(n&&!r)return 1;if(!n&&r)return-1;let i=n&&r?W(n,r):0;if(i!==0)return i;let a=W(e.source.id,t.source.id);return a===0?W(e.target.id,t.target.id):a};function we(...e){let t=new Set;for(let n of e)for(let e of n)t.add(e);return t}function Te(e,...t){let n=new Set;if(e.size===0)return n;let r=i(t,2)?(0,p.intersection)(...t):t[0];if(r.size===0)return n;for(let t of e)r.has(t)&&n.add(t);return n}function Ee(e,t){if(e.size===0)return new Set;if(t.size===0)return new Set(e);let n=new Set;for(let r of e)t.has(r)||n.add(r);return n}function De(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function $(e,t){return(0,p.symmetricDifference)(e,t)}function Oe(e,t){if(e.size===0||t.size===0)return!1;t.size<e.size&&([e,t]=[t,e]);for(let n of e)if(t.has(n))return!0;return!1}function ke(e){return S(typeof e==`object`&&r(e),`objectHash: value must be an object`),h(e)}function Ae(e){let t=5381,n=e.length;S(n>0,`stringHash: empty string`);for(let r=0;r<n;r++)t=t*33^e.charCodeAt(r);return(t>>>0).toString(36)}function je(){return ie().use(ne).use(ee).use(te).use(re,{allowDangerousHtml:!0}).use(_,t({attributes:{"*":[`className`],svg:[`width`,`height`,`viewBox`,`fill`,`ariaHidden`],path:[`d`,`fill`,`stroke`,`strokeWidth`,`strokeLinecap`,`strokeLinejoin`]},tagNames:[`svg`,`g`,`path`,`div`]},g)).use(v,{allowDangerousHtml:!0})}function Me(e){return(``+je().processSync(e)).trim()}function Ne(e){return y(b(e),{includeHtml:!1,includeImageAlt:!1})}export{x as $,U as A,P as B,de as C,se as D,ce as E,B as F,N as G,Y as H,L as I,E as J,j as K,z as L,G as M,W as N,oe as O,V as P,S as Q,R,fe as S,le as T,J as U,K as V,M as W,O as X,k as Y,w as Z,ge as _,Ee as a,me as b,Te as c,Ce as d,C as et,be as f,ve as g,ye as h,ke as i,H as j,ae as k,$ as l,xe as m,Me as n,De as o,Se as p,A as q,Ae as r,Oe as s,Ne as t,we as u,_e as v,ue as w,pe as x,he as y,F as z};
1
+ import{r as e}from"./rolldown-runtime.mjs";import{t}from"./libs/defu.mjs";import{F as n,P as r,Q as i,R as a,T as o,a as s,et as ee,f as c,k as l,l as u,t as d}from"./libs/remeda.mjs";import{s as f}from"./libs/mnemonist.mjs";import{t as te}from"./libs/natural-compare-lite.mjs";import{t as p}from"./libs/ohash.mjs";import{n as m}from"./libs/hast-util-sanitize.mjs";import{t as h}from"./libs/rehype-sanitize.mjs";import{t as g}from"./libs/rehype-stringify.mjs";import{l as _,t as v}from"./libs/mdast-util-from-markdown.mjs";import{t as y}from"./libs/remark-gfm.mjs";import{t as b}from"./libs/remark-github-blockquote-alert.mjs";import{t as ne}from"./libs/remark-parse.mjs";import{t as re}from"./libs/remark-rehype.mjs";import{t as ie}from"./libs/unified.mjs";function ae(e,t){if(e===void 0||e==null){let n=typeof t==`function`?t():t;throw Error(n??`Expected defined value, but received ${e}`)}return e}function x(e,t){if(!e)throw Error(t??`Invariant failed`)}function S(e){throw Error(`NonExhaustive value: ${e}`)}function C(e,t,n){return e.length===0||t.length===0?[]:(n??=Object.is,ee(d(e,t),s(([e,t])=>n(e,t)),o(([e,t])=>e)))}var w=e(te(),1);function T(e,t){return e===t?0:l(e)?l(t)?(0,w.default)(e,t):1:l(t)?-1:0}function E(e){return u(e,T)}function D(...e){return e.length===0?E:E(e[0])}function O(e=`.`,t=!1){return(n,r)=>{if(n===r)return 0;if(!n)return-1;if(!r)return 1;let i=n.split(e),a=r.split(e),o=Math.min(i.length,a.length);for(let e=0;e<o;e++){let t=i[e],n=a[e],r=(0,w.default)(t,n);if(r!==0)return r}let s=i.length-a.length;return t?-1*s:s}}function k(e){return e!=null&&typeof e==`string`}function A(e){return!!e&&Array.isArray(e)&&e.length>0}function j(e,t){return x(typeof t==`string`,`Path must be string`),typeof e==`object`&&!!e&&e[t]!=null}function M(e){return t=>j(t,e)}function N(...e){if(e.length===1&&typeof e[0]==`string`)return M(e[0]);let[t,n]=e;return j(t,n)}function P(...e){return(t=>e.some(e=>e(t)))}function F(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(0,t):null}function I(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(t+1):e}const L=e=>k(e)?e:e.id;function R(e,t){let n=L(e);return t?L(t).startsWith(n+`.`):e=>{let t=L(e);return n.startsWith(t+`.`)}}function z(e,t){if(!t)return t=>z(e,t);let n=L(e),r=L(t);return n===r||r.startsWith(n+`.`)||n.startsWith(r+`.`)}function B(e,t){return t?R(t,e):t=>R(e,t)}function V(e){return(k(e)?e:e.id).split(`.`).length}function H(e,t){let n=k(e)?e:e.id,r=k(t)?t:t.id;if(n===r)return 0;let i=V(n),a=V(r);if(z(n,r))return Math.abs(i-a);let o=U(n,r),s=o?V(o):0;return i+a-(2*s+1)}function U(e,t){let n=e.split(`.`);if(n.length<2)return null;let r=t.split(`.`);if(r.length<2)return null;let i=[];for(let e=0;e<Math.min(n.length,r.length)-1&&n[e]===r[e];e++)i.push(n[e]);return i.length===0?null:i.join(`.`)}function W(e){let t=e.split(`.`);if(t.pop(),!i(t,2))return t;for(let e=1;e<t.length;e++)t[e]=t[e-1]+`.`+t[e];return t.reverse()}function G(e,t){let n=e.split(`.`).length,r=t.split(`.`).length;switch(!0){case n>r:return 1;case n<r:return-1;default:return 0}}function K(e,t){return G(e.id,t.id)}function q(e){return e.map(e=>({item:e,fqn:e.id.split(`.`)})).sort((e,t)=>e.fqn.length-t.fqn.length).map(({item:e})=>e)}function J(e,t){let n=t;for(let t of e)t!==n&&R(t,n)&&(n=t);return n===t?null:n}function oe(e){let t=[],n=[...e],r;for(;r=n.shift();){let e;for(;e=J(n,r);)t.push(...n.splice(n.indexOf(e),1));t.push(r)}return t}function Y(e,t){if(!e||k(e)){let t=e??`asc`;return e=>Y(e,t)}let n=t===`desc`?-1:1;return e.map(e=>({item:e,fqn:e.id.split(`.`)})).sort((e,t)=>{if(e.fqn.length!==t.fqn.length)return(e.fqn.length-t.fqn.length)*n;for(let n=0;n<e.fqn.length;n++){let r=T(e.fqn[n],t.fqn[n]);if(r!==0)return r}return 0}).map(({item:e})=>e)}function se(e,t,n){let r=e.get(t);return r||(r=n(t),e.set(t,r)),r}function ce(e){return typeof e==`object`&&!!e&&Symbol.iterator in e}function le(e,t){let r=t??e;x(n(r));function*i(e){for(let t of e)r(t)&&(yield t)}return t?i(e):i}function ue(e,t){let r=t??e;x(n(r));function i(e){for(let t of e)if(r(t))return t}return t?i(e):i}function de(e,t){let n=t??e;x(typeof n==`number`&&n>=0,`Count must be a non-negative number`);function*r(e){let t=0;for(let r of e){if(t>=n)break;yield r,t++}}return t===void 0?e=>r(e):r(e)}function fe(e){return e?X(e):X}function*X(e){for(let t of e)yield*t}function pe(e,t){let r=t??e;x(n(r));function*i(e){for(let t of e)yield*r(t)}return t?i(e):i}function me(e){return e?Z(e):Z}function Z(e){let{value:t}=e[Symbol.iterator]().next();return t}function he(e,t){let r=t??e;x(n(r));function*i(e){for(let t of e)yield r(t)}return t?i(e):i}function ge(e,t,r){let i=a(r)?t:e,o=r??t;x(n(i));function s(e){let t=o;for(let n of e)t=i(t,n);return t}return a(r)?s(e):s}function _e(e,t){let r=t??e;x(n(r));function i(e){for(let t of e)if(r(t))return!0;return!1}return t?i(e):i}function ve(e){return e?Array.from(e):e=>Array.from(e)}function ye(e){return e?new Set(e):e=>new Set(e)}function be(e){return e?Q(e):Q}function*Q(e){let t=new Set;for(let n of e)t.has(n)||(t.add(n),yield n)}function xe(e,t,n){let r=typeof t==`symbol`?t:Symbol.for(t);return e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!1,writable:!1,value:n()}),e[r]}function Se(...e){let t=100;return e.length===2?t=c(e[0],e[1]):e.length===1&&(t=e[0]),new Promise(e=>{setTimeout(()=>{e(`LIKEC4_DELAY`)},t??100)})}function Ce(){return Promise.resolve().then(()=>void 0)}function we(e){Promise.resolve().then(e)}const Te=(e,t)=>{let n=U(e.source.id,e.target.id),r=U(t.source.id,t.target.id);if(n&&!r)return 1;if(!n&&r)return-1;let i=n&&r?G(n,r):0;if(i!==0)return i;let a=G(e.source.id,t.source.id);return a===0?G(e.target.id,t.target.id):a};function Ee(...e){let t=new Set;for(let n of e)for(let e of n)t.add(e);return t}function $(e,...t){let n=new Set;if(e.size===0)return n;let r=i(t,2)?(0,f.intersection)(...t):t[0];if(r.size===0)return n;for(let t of e)r.has(t)&&n.add(t);return n}function De(e,t){if(e.size===0)return new Set;if(t.size===0)return new Set(e);let n=new Set;for(let r of e)t.has(r)||n.add(r);return n}function Oe(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function ke(e,t){return(0,f.symmetricDifference)(e,t)}function Ae(e,t){if(e.size===0||t.size===0)return!1;t.size<e.size&&([e,t]=[t,e]);for(let n of e)if(t.has(n))return!0;return!1}function je(e){return x(typeof e==`object`&&r(e),`objectHash: value must be an object`),p(e)}function Me(e){let t=5381,n=e.length;x(n>0,`stringHash: empty string`);for(let r=0;r<n;r++)t=t*33^e.charCodeAt(r);return(t>>>0).toString(36)}function Ne(){return ie().use(ne).use(y).use(b).use(re,{allowDangerousHtml:!0}).use(h,t({attributes:{"*":[`className`],svg:[`width`,`height`,`viewBox`,`fill`,`ariaHidden`],path:[`d`,`fill`,`stroke`,`strokeWidth`,`strokeLinecap`,`strokeLinejoin`]},tagNames:[`svg`,`g`,`path`,`div`]},m)).use(g,{allowDangerousHtml:!0})}function Pe(e){return(``+Ne().processSync(e)).trim()}function Fe(e){return _(v(e),{includeHtml:!1,includeImageAlt:!1})}export{ae as $,W as A,F as B,pe as C,le as D,ue as E,V as F,P as G,Y as H,R as I,T as J,A as K,B as L,K as M,G as N,ce as O,H as P,x as Q,z as R,me as S,de as T,oe as U,q as V,N as W,D as X,O as Y,C as Z,ve as _,De as a,ge as b,$ as c,Te as d,S as et,Se as f,be as g,xe as h,je as i,U as j,se as k,ke as l,Ce as m,Pe as n,Oe as o,we as p,k as q,Me as r,Ae as s,Fe as t,Ee as u,ye as v,fe as w,he as x,_e as y,I as z};
@@ -1 +1 @@
1
- import{t as e}from"../_chunks/libs/defu.mjs";import{B as t,C as n,F as r,M as i,Q as a,T as o,U as s,W as c,X as l,Y as u,et as d,k as f,w as p}from"../_chunks/libs/remeda.mjs";import{B as m,J as h,U as g,_t as _,g as v,gt as y,lt as b,pt as x,xt as S}from"../_chunks/types.mjs";import"../_chunks/geometry.mjs";import{B as C,Q as w,R as T,z as E}from"../_chunks/utils.mjs";import"../_chunks/libs/graphology-dag.mjs";import{t as D}from"../_chunks/libs/mnemonist.mjs";import"../_chunks/libs/natural-compare-lite.mjs";import"../_chunks/libs/ohash.mjs";import"../_chunks/libs/@ungap/structured-clone.mjs";import"../_chunks/libs/hast-util-sanitize.mjs";import"../_chunks/libs/rehype-sanitize.mjs";import"../_chunks/libs/hast-util-to-html.mjs";import"../_chunks/libs/character-entities-legacy.mjs";import"../_chunks/libs/character-entities-html4.mjs";import"../_chunks/libs/ccount.mjs";import"../_chunks/libs/comma-separated-tokens.mjs";import"../_chunks/libs/rehype-stringify.mjs";import"../_chunks/libs/devlop.mjs";import"../_chunks/libs/mdast-util-from-markdown.mjs";import"../_chunks/libs/escape-string-regexp.mjs";import"../_chunks/libs/mdast-util-find-and-replace.mjs";import"../_chunks/libs/mdast-util-gfm.mjs";import"../_chunks/libs/markdown-table.mjs";import"../_chunks/libs/longest-streak.mjs";import"../_chunks/libs/character-entities.mjs";import"../_chunks/libs/decode-named-character-reference.mjs";import"../_chunks/libs/micromark-extension-gfm.mjs";import"../_chunks/libs/remark-gfm.mjs";import"../_chunks/libs/remark-github-blockquote-alert.mjs";import"../_chunks/libs/remark-parse.mjs";import"../_chunks/libs/mdast-util-to-hast.mjs";import"../_chunks/libs/remark-rehype.mjs";import"../_chunks/libs/bail.mjs";import"../_chunks/libs/extend.mjs";import"../_chunks/libs/is-plain-obj.mjs";import"../_chunks/libs/trough.mjs";import"../_chunks/libs/unified.mjs";import"../_chunks/libs/@radix-ui/colors.mjs";import"../_chunks/libs/@mantine/colors-generator.mjs";import"../_chunks/model.mjs";import"../_chunks/manual-layout.mjs";import{n as O,t as k}from"../_chunks/Builder.view-element.mjs";import"../_chunks/libs/graphology.mjs";import{t as A}from"../_chunks/assignTagColors.mjs";function j(e){if(f(e)){let t=e;switch(!0){case t.startsWith(`tag is not #`):return{tag:{neq:t.replace(`tag is not #`,``)}};case t.startsWith(`tag is #`):return{tag:{eq:t.replace(`tag is #`,``)}};case t.startsWith(`kind is not `):return{kind:{neq:t.replace(`kind is not `,``)}};case t.startsWith(`kind is `):return{kind:{eq:t.replace(`kind is `,``)}};case t.startsWith(`source.`):return{operator:j(t.replace(`source.`,``)),participant:`source`};case t.startsWith(`target.`):return{operator:j(t.replace(`target.`,``)),participant:`target`};default:throw Error(`Unknown where operator: ${e}`)}}if(e.and)return{and:o(e.and,j)};if(e.or)return{or:o(e.or,j)};if(e.not)return{not:j(e.not)};throw Error(`Unknown where operator: ${e}`)}function M(...e){return t=>{let n=t.$expr(e[0]);if(e.length===2){let t=e[1].where?j(e[1].where):void 0;t&&(n={where:{expr:n,condition:t}});let r=e[1].with;r&&(n=g.is(n)?{custom:{...r,expr:n}}:{customRelation:{...r,expr:n}})}return t.include(n),t}}function N(...e){return t=>{let n=t.$expr(e[0]);if(e.length===2&&e[1].where){let t=j(e[1].where);n={where:{expr:n,condition:t}}}return t.exclude(n),t}}function P(e,{notation:n,...r}){return i=>i.style({targets:(t(e)?e:[e]).map(e=>i.$expr(e)),...n?{notation:n}:{},style:{...r}})}function F(e){return t=>t.autoLayout(e)}function I(...e){return t=>e.reduce((e,t)=>t(e),t)}function L(e){if(!f(e))return e;let t=e=>e;if(e===`*`)return t({wildcard:!0});if(e.startsWith(`->`))return e.endsWith(`->`)?t({inout:L(e.replace(/->/g,``).trim())}):t({incoming:L(e.replace(`-> `,``))});if(e.endsWith(` ->`))return t({outgoing:L(e.replace(` ->`,``))});if(e.includes(` <-> `)){let[n,r]=e.split(` <-> `);return t({source:L(n),target:L(r),isBidirectional:!0})}if(e.includes(` -> `)){let[n,r]=e.split(` -> `);return t({source:L(n),target:L(r)})}return e.endsWith(`._`)?t({ref:{deployment:e.replace(`._`,``)},selector:`expanded`}):e.endsWith(`.**`)?t({ref:{deployment:e.replace(`.**`,``)},selector:`descendants`}):e.endsWith(`.*`)?t({ref:{deployment:e.replace(`.*`,``)},selector:`children`}):t({ref:{deployment:e}})}function R(e){let t={$expr:e[_]===`deployment`?L:k,autoLayout(n){return e.rules.push({direction:n}),t},exclude(n){return e.rules.push({exclude:[n]}),t},include(n){return e.rules.push({include:[n]}),t},style(n){return e.rules.push(n),t}};return t}function z(e){return t(e)?s(e,e=>({})):e}function B({tags:e,elements:t,deployments:n,relationships:r,...i}){let a={};e&&Object.assign(a,z(e));let o=z(t);for(let[e,t]of l(o))if(t.tags)for(let n of t.tags)w(n in a,`Invalid specification for element kind "${e}": tag "${n}" not found`);let s=z(n??{});for(let[e,t]of l(s))if(t.tags)for(let n of t.tags)w(n in a,`Invalid specification for deployment kind "${e}": tag "${n}" not found`);return{...i,tags:a,elements:o,deployments:s,relationships:z(r??{})}}function V(e){return i(e)?null:typeof e==`string`?{txt:e}:e}function H(t,s=new Map,l=[],f=new Map,g={predicates:{},dynamicPredicates:{},styles:{}},k=new Map,j=[],L=new D.default(()=>new Map)){let z=B(t),U=()=>({elements:structuredClone(z.elements),deployments:structuredClone(z.deployments),relationships:structuredClone(z.relationships),tags:A(structuredClone(z.tags)),...z.metadataKeys?{metadataKeys:z.metadataKeys}:{},customColors:{}}),W=e=>{if(!(!e||!a(e,1)))return o(e,e=>typeof e==`string`?{url:e}:e)},G=(e,t,n)=>{r(t)&&(n=t,t={}),t??={};let{links:i=[],title:a=null,description:o=null,tags:s=[],...c}=typeof t==`string`?{title:t}:{...t},l=W(i);return[S({id:e,title:a,description:V(o),tags:s,links:l,_stage:`parsed`,...c}),n]},K=e=>{let[t,n]=x(e),r=(t?L.get(t):s).get(n);return w(r,`Element with id "${e}" not found`),r},q=e=>{if(typeof e==`string`){let[t,n]=x(e);return t?{project:t,model:n}:{model:n}}return`project`in e||`deployment`in e?e:q(e.model)},J={get Types(){throw Error(`Types are not available in runtime`)},clone:()=>{let e=new D.default(()=>new Map);for(let[t,n]of L)e.set(t,structuredClone(n));return H(structuredClone(z),structuredClone(s),structuredClone(l),structuredClone(f),structuredClone(g),structuredClone(k),structuredClone(j),e)},__addElement:e=>{let[t,n]=x(e.id),r=C(n),i=t?L.get(t):s;if(r&&w(i.get(r),`Parent element with id "${r}" not found for element with id "${e.id}"`),i.has(n))throw Error(`Element with id "${e.id}" already exists`);return i.set(n,t?{...e,id:n}:e),J},__addRelation(e){let t=q(e.source),n=h.flatten(t),r=q(e.target),i=h.flatten(r),a=K(n),o=K(i);if(b(n)&&b(i))throw Error(`Cannot create relationship between global elements`);return!b(n)&&!b(i)&&w(!T(a,o),`Cannot create relationship between elements in the same hierarchy`),l.push({id:`rel${l.length+1}`,...e,source:t,target:r}),J},__fqn(e){return w(e.trim()!==``,`Id must be non-empty`),e},__deploymentFqn(e){return w(e.trim()!==``,`Id must be non-empty`),e},__addSourcelessRelation(){throw Error(`Can be called only in nested model`)},__addView:e=>{if(f.has(e.id))throw Error(`View with id "${e.id}" already exists`);return v(e)&&`viewOf`in e&&w(s.get(e.viewOf),`Invalid scoped view ${e.id}, wlement with id "${e.viewOf}" not found`),f.set(e.id,e),J},__addDeployment:e=>{if(k.has(e.id))throw Error(`Deployment with id "${e.id}" already exists`);let t=C(e.id);return t&&w(k.get(t),`Parent element with id "${t}" not found for node with id "${e.id}"`),m(e)&&(w(t,`Instance ${e.id} of ${e.element} must be deployed under a parent node`),w(s.get(e.element),`Instance "${e.id}" references non-existing element "${e.element}"`)),k.set(e.id,e),J},__addDeploymentRelation:e=>(w(!T(e.source.deployment,e.target.deployment),`Cannot create relationship between elements in the same hierarchy`),w(k.has(e.source.deployment),`Relation "${e.source.deployment} -> ${e.target.deployment}" references non-existing source`),w(k.has(e.target.deployment),`Relation "${e.source.deployment} -> ${e.target.deployment}" references non-existing target`),j.push({id:`deploy_rel${j.length+1}`,...e}),J),build:e=>({[y]:`parsed`,projectId:typeof e==`string`?e:e?.id??`from-builder`,project:{id:typeof e==`string`?e:`from-builder`,...typeof e==`object`&&e?e:{}},specification:U(),elements:c(structuredClone(Array.from(s.entries()))),relations:p(l,e=>[e.id,structuredClone(e)]),globals:structuredClone(g),deployments:{elements:c(structuredClone(Array.from(k.entries()))),relations:p(j,e=>[e.id,structuredClone(e)])},views:c(structuredClone(Array.from(f.entries()))),imports:d(Array.from(L.entries()),o(([e,t])=>[e,structuredClone([...t.values()])]),u(([e,t])=>t.length>0),c())}),toLikeC4Model:e=>O(J.build(e)),helpers:()=>({model:{model:(...e)=>t=>e.reduce((e,t)=>t(e),t),rel:(t,n,r)=>i=>{let{title:a=``,links:o=[],description:s=null,notes:c=null,...l}=e(typeof r==`string`?{title:r}:{...r},{title:null,links:null}),u=W(o);return i.__addRelation(S({source:{model:t},target:{model:n},title:a,...s&&{description:V(s)},...c&&{notes:V(c)},links:u,...l})),i},relTo:(t,n)=>r=>{let{title:i=``,links:a,description:o=null,notes:s=null,...c}=e(typeof n==`string`?{title:n}:{...n},{title:null,links:null});return r.__addSourcelessRelation(S({target:{model:t},title:i,...o&&{description:V(o)},...s&&{notes:V(s)},links:W(a),...c})),r},...n(z.elements,({style:e,...t},n)=>(r,i)=>{let a=(a=>{let{links:o,icon:s,color:c,shape:l,style:u,title:d,description:f,summary:p,...m}=typeof i==`string`?{title:i}:{...i},h=s??e?.icon,g=a.__fqn(r);return a.__addElement(S({id:g,kind:n,title:d??E(g),...f&&{description:V(f)},...p&&{summary:V(p)},style:S({icon:h,color:c??e?.color,shape:l??e?.shape,border:e?.border,opacity:e?.opacity,size:e?.size,padding:e?.padding,textSize:e?.textSize,...u}),links:W(o),...t,...m})),a});return a.with=(...e)=>t=>{a(t);let{__fqn:n,__addSourcelessRelation:i}=t;try{t.__fqn=e=>`${n(r)}.${e}`,t.__addSourcelessRelation=e=>t.__addRelation({...e,source:{model:n(r)}}),e.reduce((e,t)=>t(e),t)}finally{t.__fqn=n,t.__addSourcelessRelation=i}return t},a})},views:{views:(...e)=>t=>e.reduce((e,t)=>t(e),t),view:(e,t,n)=>{let[r,i]=G(e,t,n),a={...r,[_]:`element`,rules:[]},o=e=>(e.__addView(a),i&&i(R(a)),e);return o.with=(...e)=>t=>{o(t);let n=R(a);for(let t of e)t(n);return t},o},viewOf:(e,t,n,r)=>{let[i,a]=G(e,n,r),o={...i,viewOf:t,[_]:`element`,rules:[]},s=e=>(e.__addView(o),a&&a(R(o)),e);return s.with=(...e)=>t=>{s(t);let n=R(o);for(let t of e)t(n);return t},s},deploymentView:(e,t,n)=>{let[r,i]=G(e,t,n),a={...r,[_]:`deployment`,rules:[]},o=e=>(e.__addView(a),i&&i(R(a)),e);return o.with=(...e)=>t=>{o(t);let n=R(a);for(let t of e)t(n);return t},o},$autoLayout:F,$exclude:N,$include:M,$rules:I,$style:P},deployment:{deployment:(...e)=>t=>e.reduce((e,t)=>t(e),t),instanceOf:(e,t,n)=>r=>{i(t)?(t=e,e=E(e)):typeof t==`string`?n??={}:(n=t,t=e,e=E(e));let{links:a,title:o,description:s,summary:c,icon:l,color:u,shape:d,style:f,...p}=typeof n==`string`?{title:n}:{...n},m=r.__deploymentFqn(e);return r.__addDeployment(S({id:m,element:t,...o&&{title:o},...c&&{summary:V(c)},...s&&{description:V(s)},style:S({icon:l,color:u,shape:d,...f}),links:W(a),...p})),r},rel:(e,t,n)=>r=>{let{title:i=null,links:a,description:o=null,notes:s=null,...c}=typeof n==`string`?{title:n}:{...n};return r.__addDeploymentRelation(S({source:{deployment:e},target:{deployment:t},title:i,...o&&{description:V(o)},...s&&{notes:V(s)},links:W(a),...c})),r},...n(z.deployments??{},({style:e,...t},n)=>(r,i)=>{let a=(a=>{let{links:o,icon:s,style:c,title:l,description:u,summary:d,color:f,shape:p,...m}=typeof i==`string`?{title:i}:{...i},h=s??e?.icon,g=a.__deploymentFqn(r);return a.__addDeployment(S({id:g,kind:n,title:l??E(g),...u&&{description:V(u)},...d&&{summary:V(d)},style:S({icon:h,color:f??e?.color,shape:p??e?.shape,border:e?.border,opacity:e?.opacity,size:e?.size,padding:e?.padding,textSize:e?.textSize,...c}),links:W(o),...t,...m})),a});return a.with=(...e)=>t=>{a(t);let{__deploymentFqn:n}=t;try{t.__deploymentFqn=e=>`${n(r)}.${e}`,e.reduce((e,t)=>t(e),t)}finally{t.__deploymentFqn=n}return t},a})}}),with:(...e)=>{let t=J.clone();return e.reduce((e,t)=>t(e),t)},model:e=>{let t=J.clone(),n=t.helpers().model,r=n.model;return e({...n,_:r},r)(t)},deployment:e=>{let t=J.clone(),n=t.helpers().deployment,r=n.deployment;return e({...n,_:r},r)(t)},views:e=>{let t=J.clone(),n=t.helpers().views;return e({...n,_:n.views},n.views)(t)}};return J}const U={forSpecification(e){let t=H(e);return{...t.helpers(),builder:t}},specification(e){return H(e)}};export{U as Builder};
1
+ import{t as e}from"../_chunks/libs/defu.mjs";import{B as t,C as n,F as r,M as i,Q as a,T as o,U as s,W as c,X as l,Y as u,et as d,k as f,w as p}from"../_chunks/libs/remeda.mjs";import{St as m,V as h,W as g,Y as _,_t as v,g as y,mt as b,ut as x,vt as S}from"../_chunks/types.mjs";import"../_chunks/geometry.mjs";import{B as C,Q as w,R as T,z as E}from"../_chunks/utils.mjs";import"../_chunks/libs/graphology-dag.mjs";import{t as D}from"../_chunks/libs/mnemonist.mjs";import"../_chunks/libs/natural-compare-lite.mjs";import"../_chunks/libs/ohash.mjs";import"../_chunks/libs/@ungap/structured-clone.mjs";import"../_chunks/libs/hast-util-sanitize.mjs";import"../_chunks/libs/rehype-sanitize.mjs";import"../_chunks/libs/hast-util-to-html.mjs";import"../_chunks/libs/character-entities-legacy.mjs";import"../_chunks/libs/character-entities-html4.mjs";import"../_chunks/libs/ccount.mjs";import"../_chunks/libs/comma-separated-tokens.mjs";import"../_chunks/libs/rehype-stringify.mjs";import"../_chunks/libs/devlop.mjs";import"../_chunks/libs/mdast-util-from-markdown.mjs";import"../_chunks/libs/escape-string-regexp.mjs";import"../_chunks/libs/mdast-util-find-and-replace.mjs";import"../_chunks/libs/mdast-util-gfm.mjs";import"../_chunks/libs/markdown-table.mjs";import"../_chunks/libs/longest-streak.mjs";import"../_chunks/libs/character-entities.mjs";import"../_chunks/libs/decode-named-character-reference.mjs";import"../_chunks/libs/micromark-extension-gfm.mjs";import"../_chunks/libs/remark-gfm.mjs";import"../_chunks/libs/remark-github-blockquote-alert.mjs";import"../_chunks/libs/remark-parse.mjs";import"../_chunks/libs/mdast-util-to-hast.mjs";import"../_chunks/libs/remark-rehype.mjs";import"../_chunks/libs/bail.mjs";import"../_chunks/libs/extend.mjs";import"../_chunks/libs/is-plain-obj.mjs";import"../_chunks/libs/trough.mjs";import"../_chunks/libs/unified.mjs";import"../_chunks/libs/@radix-ui/colors.mjs";import"../_chunks/libs/@mantine/colors-generator.mjs";import"../_chunks/model.mjs";import"../_chunks/manual-layout.mjs";import{n as O,t as k}from"../_chunks/Builder.view-element.mjs";import"../_chunks/libs/graphology.mjs";import{t as A}from"../_chunks/assignTagColors.mjs";function j(e){if(f(e)){let t=e;switch(!0){case t.startsWith(`tag is not #`):return{tag:{neq:t.replace(`tag is not #`,``)}};case t.startsWith(`tag is #`):return{tag:{eq:t.replace(`tag is #`,``)}};case t.startsWith(`kind is not `):return{kind:{neq:t.replace(`kind is not `,``)}};case t.startsWith(`kind is `):return{kind:{eq:t.replace(`kind is `,``)}};case t.startsWith(`source.`):return{operator:j(t.replace(`source.`,``)),participant:`source`};case t.startsWith(`target.`):return{operator:j(t.replace(`target.`,``)),participant:`target`};default:throw Error(`Unknown where operator: ${e}`)}}if(e.and)return{and:o(e.and,j)};if(e.or)return{or:o(e.or,j)};if(e.not)return{not:j(e.not)};throw Error(`Unknown where operator: ${e}`)}function M(...e){return t=>{if(e.length===2&&typeof e[1]!=`string`&&(`where`in e[1]||`with`in e[1])){let n=t.$expr(e[0]),r=e[1].where?j(e[1].where):void 0;r&&(n={where:{expr:n,condition:r}});let i=e[1].with;return i&&(n=g.is(e[0])?{custom:{...i,expr:n}}:{customRelation:{...i,expr:n}}),t.include(n),t}return t.include(...e.map(e=>t.$expr(e))),t}}function N(...e){return t=>{let n=t.$expr(e[0]);if(e.length===2&&e[1].where){let t=j(e[1].where);n={where:{expr:n,condition:t}}}return t.exclude(n),t}}function P(e,{notation:n,...r}){return i=>i.style({targets:(t(e)?e:[e]).map(e=>i.$expr(e)),...n?{notation:n}:{},style:{...r}})}function F(e,t){return n=>n.autoLayout(e,t)}function I(...e){return t=>e.reduce((e,t)=>t(e),t)}function L(e){if(!f(e))return e;let t=e=>e;if(e===`*`)return t({wildcard:!0});if(e.startsWith(`->`))return e.endsWith(`->`)?t({inout:L(e.replace(/->/g,``).trim())}):t({incoming:L(e.replace(`-> `,``))});if(e.endsWith(` ->`))return t({outgoing:L(e.replace(` ->`,``))});if(e.includes(` <-> `)){let[n,r]=e.split(` <-> `);return t({source:L(n),target:L(r),isBidirectional:!0})}if(e.includes(` -> `)){let[n,r]=e.split(` -> `);return t({source:L(n),target:L(r)})}return e.endsWith(`._`)?t({ref:{deployment:e.replace(`._`,``)},selector:`expanded`}):e.endsWith(`.**`)?t({ref:{deployment:e.replace(`.**`,``)},selector:`descendants`}):e.endsWith(`.*`)?t({ref:{deployment:e.replace(`.*`,``)},selector:`children`}):t({ref:{deployment:e}})}function R(e){let t={$expr:e[S]===`deployment`?L:k,autoLayout(n,r){return e.rules.push(m({direction:n,rankSep:r?.rank,nodeSep:r?.node})),t},exclude(...n){return e.rules.push({exclude:n}),t},include(...n){return e.rules.push({include:n}),t},style(n){return e.rules.push(n),t},get Expr(){throw Error(`Expr is not available in runtime`)},get Types(){throw Error(`Types are not available in runtime`)},get ElementExpr(){throw Error(`ElementExpr is not available in runtime`)},get TypedExpr(){throw Error(`TypedExpr is not available in runtime`)}};return t}function z(e){return t(e)?s(e,e=>({})):e}function B({tags:e,elements:t,deployments:n,relationships:r,...i}){let a={};e&&Object.assign(a,z(e));let o=z(t);for(let[e,t]of l(o))if(t.tags)for(let n of t.tags)w(n in a,`Invalid specification for element kind "${e}": tag "${n}" not found`);let s=z(n??{});for(let[e,t]of l(s))if(t.tags)for(let n of t.tags)w(n in a,`Invalid specification for deployment kind "${e}": tag "${n}" not found`);return{...i,tags:a,elements:o,deployments:s,relationships:z(r??{})}}function V(e){return i(e)?null:typeof e==`string`?{txt:e}:e}function H(t,s=new Map,l=[],f=new Map,g={predicates:{},dynamicPredicates:{},styles:{}},k=new Map,j=[],L=new D.default(()=>new Map)){let z=B(t),U=()=>({elements:structuredClone(z.elements),deployments:structuredClone(z.deployments),relationships:structuredClone(z.relationships),tags:A(structuredClone(z.tags)),...z.metadataKeys?{metadataKeys:z.metadataKeys}:{},customColors:{}}),W=e=>{if(!(!e||!a(e,1)))return o(e,e=>typeof e==`string`?{url:e}:e)},G=(e,t,n)=>{r(t)&&(n=t,t={}),t??={};let{links:i=[],title:a=null,description:o=null,tags:s=[],...c}=typeof t==`string`?{title:t}:{...t},l=W(i);return[m({id:e,title:a,description:V(o),tags:s,links:l,_stage:`parsed`,...c}),n]},K=e=>{let[t,n]=b(e),r=(t?L.get(t):s).get(n);return w(r,`Element with id "${e}" not found`),r},q=e=>{if(typeof e==`string`){let[t,n]=b(e);return t?{project:t,model:n}:{model:n}}return`project`in e||`deployment`in e?e:q(e.model)},J={get Types(){throw Error(`Types are not available in runtime`)},clone:()=>{let e=new D.default(()=>new Map);for(let[t,n]of L)e.set(t,structuredClone(n));return H(structuredClone(z),structuredClone(s),structuredClone(l),structuredClone(f),structuredClone(g),structuredClone(k),structuredClone(j),e)},__addElement:e=>{let[t,n]=b(e.id),r=C(n),i=t?L.get(t):s;if(r&&w(i.get(r),`Parent element with id "${r}" not found for element with id "${e.id}"`),i.has(n))throw Error(`Element with id "${e.id}" already exists`);return i.set(n,t?{...e,id:n}:e),J},__addRelation(e){let t=q(e.source),n=_.flatten(t),r=q(e.target),i=_.flatten(r),a=K(n),o=K(i);if(x(n)&&x(i))throw Error(`Cannot create relationship between global elements`);return!x(n)&&!x(i)&&w(!T(a,o),`Cannot create relationship between elements in the same hierarchy`),l.push({id:`rel${l.length+1}`,...e,source:t,target:r}),J},__fqn(e){return w(e.trim()!==``,`Id must be non-empty`),e},__deploymentFqn(e){return w(e.trim()!==``,`Id must be non-empty`),e},__addSourcelessRelation(){throw Error(`Can be called only in nested model`)},__addView:e=>{if(f.has(e.id))throw Error(`View with id "${e.id}" already exists`);return y(e)&&`viewOf`in e&&w(s.get(e.viewOf),`Invalid scoped view ${e.id}, wlement with id "${e.viewOf}" not found`),f.set(e.id,e),J},__addDeployment:e=>{if(k.has(e.id))throw Error(`Deployment with id "${e.id}" already exists`);let t=C(e.id);return t&&w(k.get(t),`Parent element with id "${t}" not found for node with id "${e.id}"`),h(e)&&(w(t,`Instance ${e.id} of ${e.element} must be deployed under a parent node`),w(s.get(e.element),`Instance "${e.id}" references non-existing element "${e.element}"`)),k.set(e.id,e),J},__addDeploymentRelation:e=>(w(!T(e.source.deployment,e.target.deployment),`Cannot create relationship between elements in the same hierarchy`),w(k.has(e.source.deployment),`Relation "${e.source.deployment} -> ${e.target.deployment}" references non-existing source`),w(k.has(e.target.deployment),`Relation "${e.source.deployment} -> ${e.target.deployment}" references non-existing target`),j.push({id:`deploy_rel${j.length+1}`,...e}),J),build:e=>({[v]:`parsed`,projectId:typeof e==`string`?e:e?.id??`from-builder`,project:{id:typeof e==`string`?e:`from-builder`,...typeof e==`object`&&e?e:{}},specification:U(),elements:c(structuredClone(Array.from(s.entries()))),relations:p(l,e=>[e.id,structuredClone(e)]),globals:structuredClone(g),deployments:{elements:c(structuredClone(Array.from(k.entries()))),relations:p(j,e=>[e.id,structuredClone(e)])},views:c(structuredClone(Array.from(f.entries()))),imports:d(Array.from(L.entries()),o(([e,t])=>[e,structuredClone([...t.values()])]),u(([e,t])=>t.length>0),c())}),toLikeC4Model:e=>O(J.build(e)),helpers:()=>({model:{model:(...e)=>t=>e.reduce((e,t)=>t(e),t),rel:(t,n,r)=>i=>{let{title:a=``,links:o=[],description:s=null,notes:c=null,...l}=e(typeof r==`string`?{title:r}:{...r},{title:null,links:null}),u=W(o);return i.__addRelation(m({source:{model:t},target:{model:n},title:a,...s&&{description:V(s)},...c&&{notes:V(c)},links:u,...l})),i},relTo:(t,n)=>r=>{let{title:i=``,links:a,description:o=null,notes:s=null,...c}=e(typeof n==`string`?{title:n}:{...n},{title:null,links:null});return r.__addSourcelessRelation(m({target:{model:t},title:i,...o&&{description:V(o)},...s&&{notes:V(s)},links:W(a),...c})),r},...n(z.elements,({style:e,...t},n)=>(r,i)=>{let a=(a=>{let{links:o,icon:s,color:c,shape:l,style:u,title:d,description:f,summary:p,...h}=typeof i==`string`?{title:i}:{...i},g=s??e?.icon,_=a.__fqn(r);return a.__addElement(m({id:_,kind:n,title:d??E(_),...f&&{description:V(f)},...p&&{summary:V(p)},style:m({icon:g,color:c??e?.color,shape:l??e?.shape,border:e?.border,opacity:e?.opacity,size:e?.size,padding:e?.padding,textSize:e?.textSize,...u}),links:W(o),...t,...h})),a});return a.with=(...e)=>t=>{a(t);let{__fqn:n,__addSourcelessRelation:i}=t;try{t.__fqn=e=>`${n(r)}.${e}`,t.__addSourcelessRelation=e=>t.__addRelation({...e,source:{model:n(r)}}),e.reduce((e,t)=>t(e),t)}finally{t.__fqn=n,t.__addSourcelessRelation=i}return t},a})},views:{views:(...e)=>t=>e.reduce((e,t)=>t(e),t),view:(e,t,n)=>{let[r,i]=G(e,t,n),a={...r,[S]:`element`,rules:[]},o=e=>(e.__addView(a),i&&i(R(a)),e);return o.with=(...e)=>t=>{o(t);let n=R(a);for(let t of e)t(n);return t},o},viewOf:(e,t,n,r)=>{let[i,a]=G(e,n,r),o={...i,viewOf:t,[S]:`element`,rules:[]},s=e=>(e.__addView(o),a&&a(R(o)),e);return s.with=(...e)=>t=>{s(t);let n=R(o);for(let t of e)t(n);return t},s},deploymentView:(e,t,n)=>{let[r,i]=G(e,t,n),a={...r,[S]:`deployment`,rules:[]},o=e=>(e.__addView(a),i&&i(R(a)),e);return o.with=(...e)=>t=>{o(t);let n=R(a);for(let t of e)t(n);return t},o},$autoLayout:F,$exclude:N,$include:M,$rules:I,$style:P},deployment:{deployment:(...e)=>t=>e.reduce((e,t)=>t(e),t),instanceOf:(e,t,n)=>r=>{i(t)?(t=e,e=E(e)):typeof t==`string`?n??={}:(n=t,t=e,e=E(e));let{links:a,title:o,description:s,summary:c,icon:l,color:u,shape:d,style:f,...p}=typeof n==`string`?{title:n}:{...n},h=r.__deploymentFqn(e);return r.__addDeployment(m({id:h,element:t,...o&&{title:o},...c&&{summary:V(c)},...s&&{description:V(s)},style:m({icon:l,color:u,shape:d,...f}),links:W(a),...p})),r},rel:(e,t,n)=>r=>{let{title:i=null,links:a,description:o=null,notes:s=null,...c}=typeof n==`string`?{title:n}:{...n};return r.__addDeploymentRelation(m({source:{deployment:e},target:{deployment:t},title:i,...o&&{description:V(o)},...s&&{notes:V(s)},links:W(a),...c})),r},...n(z.deployments??{},({style:e,...t},n)=>(r,i)=>{let a=(a=>{let{links:o,icon:s,style:c,title:l,description:u,summary:d,color:f,shape:p,...h}=typeof i==`string`?{title:i}:{...i},g=s??e?.icon,_=a.__deploymentFqn(r);return a.__addDeployment(m({id:_,kind:n,title:l??E(_),...u&&{description:V(u)},...d&&{summary:V(d)},style:m({icon:g,color:f??e?.color,shape:p??e?.shape,border:e?.border,opacity:e?.opacity,size:e?.size,padding:e?.padding,textSize:e?.textSize,...c}),links:W(o),...t,...h})),a});return a.with=(...e)=>t=>{a(t);let{__deploymentFqn:n}=t;try{t.__deploymentFqn=e=>`${n(r)}.${e}`,e.reduce((e,t)=>t(e),t)}finally{t.__deploymentFqn=n}return t},a})}}),with:(...e)=>{let t=J.clone();return e.reduce((e,t)=>t(e),t)},model:e=>{let t=J.clone(),n=t.helpers().model,r=n.model;return e({...n,_:r},r)(t)},deployment:e=>{let t=J.clone(),n=t.helpers().deployment,r=n.deployment;return e({...n,_:r},r)(t)},views:e=>{let t=J.clone(),n=t.helpers().views;return e({...n,_:n.views},n.views)(t)}};return J}const U={forSpecification(e){let t=H(e);return{...t.helpers(),builder:t}},specification(e){return H(e)}};export{U as Builder};
@@ -1,4 +1,4 @@
1
- import { Ar as Any, Dn as ModelExpression, Ji as _type, Nr as AnyParsed, S as ComputedView, _ as ComputedLikeC4ModelData, at as ComputedNode, b as ParsedLikeC4ModelData, cn as AnyIncludePredicate, fi as toComputed, fn as BaseViewProperties, hn as ViewAutoLayout, qi as _stage, ra as NonEmptyArray, ri as Unknown, rt as ComputedEdge, si as ViewId, sn as AnyExcludePredicate, w as ParsedView, zr as ElementId } from "../_chunks/index.mjs";
1
+ import { Dn as ModelExpression, Fr as AnyParsed, Mr as Any, S as ComputedView, Vr as ElementId, Xi as _type, Yi as _stage, _ as ComputedLikeC4ModelData, aa as NonEmptyArray, ai as Unknown, at as ComputedNode, b as ParsedLikeC4ModelData, cn as AnyIncludePredicate, fn as BaseViewProperties, hn as ViewAutoLayout, li as ViewId, mi as toComputed, rt as ComputedEdge, sn as AnyExcludePredicate, w as ParsedView } from "../_chunks/index.mjs";
2
2
  import "../_chunks/index2.mjs";
3
3
  import "../_chunks/index3.mjs";
4
4
  import "../_chunks/libs/mnemonist.mjs";
@@ -1,2 +1,2 @@
1
- import{r as e}from"../_chunks/rolldown-runtime.mjs";import"../_chunks/libs/defu.mjs";import{$ as t,C as n,D as r,K as i,L as a,Q as o,S as s,T as c,X as l,Y as u,b as d,d as f,et as p,i as m,m as h,r as ee,w as te,y as ne}from"../_chunks/libs/remeda.mjs";import{Q as g,_,_t as v,bt as y,g as re,gt as ie,ot as ae,rt as b}from"../_chunks/types.mjs";import"../_chunks/geometry.mjs";import{$ as x,D as S,I as C,K as w,L as T,Q as E,U as D,_ as O,r as k,v as A,x as j}from"../_chunks/utils.mjs";import{n as M,t as N}from"../_chunks/libs/graphology-dag.mjs";import{t as P}from"../_chunks/libs/mnemonist.mjs";import"../_chunks/libs/natural-compare-lite.mjs";import"../_chunks/libs/ohash.mjs";import"../_chunks/libs/@ungap/structured-clone.mjs";import"../_chunks/libs/hast-util-sanitize.mjs";import"../_chunks/libs/rehype-sanitize.mjs";import"../_chunks/libs/hast-util-to-html.mjs";import"../_chunks/libs/character-entities-legacy.mjs";import"../_chunks/libs/character-entities-html4.mjs";import"../_chunks/libs/ccount.mjs";import"../_chunks/libs/comma-separated-tokens.mjs";import"../_chunks/libs/rehype-stringify.mjs";import"../_chunks/libs/devlop.mjs";import"../_chunks/libs/mdast-util-from-markdown.mjs";import"../_chunks/libs/escape-string-regexp.mjs";import"../_chunks/libs/mdast-util-find-and-replace.mjs";import"../_chunks/libs/mdast-util-gfm.mjs";import"../_chunks/libs/markdown-table.mjs";import"../_chunks/libs/longest-streak.mjs";import"../_chunks/libs/character-entities.mjs";import"../_chunks/libs/decode-named-character-reference.mjs";import"../_chunks/libs/micromark-extension-gfm.mjs";import"../_chunks/libs/remark-gfm.mjs";import"../_chunks/libs/remark-github-blockquote-alert.mjs";import"../_chunks/libs/remark-parse.mjs";import"../_chunks/libs/mdast-util-to-hast.mjs";import"../_chunks/libs/remark-rehype.mjs";import"../_chunks/libs/bail.mjs";import"../_chunks/libs/extend.mjs";import"../_chunks/libs/is-plain-obj.mjs";import"../_chunks/libs/trough.mjs";import"../_chunks/libs/unified.mjs";import"../_chunks/libs/@radix-ui/colors.mjs";import"../_chunks/libs/@mantine/colors-generator.mjs";import"../_chunks/model.mjs";import"../_chunks/manual-layout.mjs";import{a as F,c as I,i as L,n as R,o as z,r as B,s as V,t as H}from"../_chunks/Builder.view-element.mjs";import{t as U}from"../_chunks/libs/graphology.mjs";var W=M(),G=e(N(),1);function K(e){let t=new U({type:`directed`}),n=[];for(let r of ee(e))t.addNode(r.id,{view:r}),_(r)&&n.push(r);if(n.length===0)return e;for(let e of n){if(!t.hasNode(e.extends)){console.warn(`View "${e.id}" extends from "${e.extends}" which does not exist`);continue}if((0,G.default)(t,e.id,e.extends)){console.warn(`View "${e.id}" extends from "${e.extends}" which creates a cycle`);continue}t.addDirectedEdge(e.id,e.extends)}return(0,W.topologicalSort)(t).reverse().reduce((e,n)=>{let r=t.getNodeAttribute(n,`view`);if(!_(r))return e[r.id]=r,e;let i=e[r.extends];if(!i||!re(i))return e;let a=m([...i.tags??[],...r.tags??[]]),o=[...i.links??[],...r.links??[]];return e[r.id]={...i,...r,title:r.title??i.title??null,description:r.description??i.description??null,tags:a,links:w(o)?o:null,rules:[...i.rules,...r.rules]},e},{})}function q({edges:e,nodes:t,...n},r=`:`){let i=te(e,e=>[e.id,`${e.source}${r}${e.target}`]);return{...n,edges:e.map(e=>({...e,id:i[e.id]})),nodes:t.map(e=>({...e,inEdges:c(e.inEdges,e=>i[e]),outEdges:c(e.outEdges,e=>i[e])})),nodeIds:t.map(e=>e.id),edgeIds:e.map(e=>i[e.id])}}function oe({views:e,...t}){return{...t,views:n(e,e=>s(q(e),[`nodeIds`,`edgeIds`]))}}const J=e=>r(e).length,Y=e=>k(e);function se(e){let t=ce(e),n=(e,t)=>`${e}->${t}`,r=new P.default(e=>{let[t,n]=e.split(`->`);return{from:t,to:n,relationships:new Set}}),s=(e,t)=>r.get(n(e,t)).relationships,u=(e,t)=>{let n=t.projectId;E(n!==e.projectId,`Imported element must have a different project id`);let r=s(e.projectId,n);for(let n of t.incoming(`direct`))n.source.projectId===e.projectId&&r.add(n);let i=s(n,e.projectId);for(let n of t.outgoing(`direct`))n.target.projectId===e.projectId&&i.add(n)};for(let t of e)if(!a(t.$data.imports))for(let[e,n]of l(t.$data.imports))for(let r of n){let n=g(e,r.id);u(t,x(t.findElement(n),`Element ${r.id} from project ${e} not found in model ${t.projectId}`))}let d=Array.from(r.entries()).filter(([e,{relationships:t}])=>t.size>0).map(([e,{from:t,to:n,relationships:r}])=>{let a=[...r];E(o(a,1),`Relationships set must have at least one relationship`);let s={id:k(e),source:Y(t),target:Y(n),projectId:t,relations:c(a,h(`id`)),label:null,color:`gray`,parent:null,line:`solid`,tags:m(i(a,h(`tags`)))},l=ne(a);return l&&(s.label=l.title,s.description=y(l.$relationship)??null,s.technology=l.technology,s.color=l.color,s.line=l.line,l.kind&&(s.kind=l.kind),l.$relationship.navigateTo&&(s.navigateTo=l.$relationship.navigateTo)),s});I(t,d);let f=V({nodes:t,edges:d});return{id:`projects-view`,[v]:`projects`,[ie]:`computed`,title:`Projects`,description:{txt:`Overview of all projects and their relationships`},autoLayout:{direction:`TB`},...f}}function ce(e){let t=new Map;for(let n of e){let e=b(n.projectId),r={id:Y(e),kind:`@project`,parent:null,projectId:e,title:n.project.title??n.project.id,description:{txt:[`Elements: ${J(n.$data.elements)}`,`Relationships: ${J(n.$data.relations)}`,`Views: ${J(n.$data.views)}`].join(`
2
- `)},shape:`rectangle`,children:[],inEdges:[],outEdges:[],color:`primary`,level:0,style:{},tags:[]};t.set(r.id,r)}return t}function X(e){let n=D([...e]),r=new Set(n),i=new Map,a=new P.default(()=>null),o=n.reduce((e,n,o,s)=>(i.set(n.id,n),e.set(n.id,p(s,t(o+1),u(T(n)),f((e,t)=>(r.delete(t),e.some(C(t))||(e.push(t),a.set(t.id,n)),e),[]))),e),new P.default(()=>[]));return{sorted:n,byId:e=>x(i.get(e),`Element not found by id: ${e}`),root:r,parent:e=>a.get(typeof e==`string`?e:e.id),children:e=>o.get(typeof e==`string`?e:e.id),flatten:d(()=>new Set([...r,...n.reduce((e,t)=>{let n=o.get(t.id);return n.length===0?(e.push(t),e):(n.length>1&&e.push(...n),e)},[])]))}}const Z=(e,t)=>e.size>2&&t.size!==e.size?new Set(D([...X(e).flatten(),...t])):e.size>1?new Set(D([...e])):e;function Q(e,t,n){let r=e=>t.has(e),i=new Set([e]),a={incomers:new Set,subjects:new Set([e]),outgoers:new Set},o=new Set(n.incoming.flatMap(t=>{if(a.subjects.add(t.target),a.incomers.add(t.source),i.add(t.target),t.target!==e){let n=t.target.parent;for(;n&&n!==e;)i.add(n),n=n.parent}let n=t.source,o=[];for(;o.push(n),!(r(n)||!n.parent);)n=n.parent;return o})),s=new Set(n.outgoing.flatMap(t=>{if(a.subjects.add(t.source),a.outgoers.add(t.target),i.add(t.source),t.source!==e){let n=t.source.parent;for(;n&&n!==e;)i.add(n),n=n.parent}let n=t.target,o=[];for(;o.push(n),!(r(n)||!n.parent);)n=n.parent;return o}));return{incomers:Z(o,a.incomers),incoming:new Set(n.incoming),subjects:Z(i,a.subjects),outgoing:new Set(n.outgoing),outgoers:Z(s,a.outgoers)}}function le(e,t,n,r=`global`){let i=n?t.findView(n):null;if(r===`view`)return E(i,`Scope view id is required when scope is "view"`),ue(e,i,t);let a=t.element(e);return Q(a,A(a.ascendingSiblings()),{incoming:[...a.incoming()],outgoing:[...a.outgoing()]})}function ue(e,t,n){let r=n.element(e),i={incoming:O(S(r.incoming(),e=>t.includesRelation(e.id))),outgoing:O(S(r.outgoing(),e=>t.includesRelation(e.id)))},a=T(r);return Q(r,new Set([...r.ascendingSiblings(),...p(t.elements(),j(e=>e.element),S(e=>e!==r&&a(e)))]),i)}function $(e,t){return{...z(e,{id:ae(`adhoc`),_stage:`parsed`,_type:`element`,rules:t,title:null,description:null}),_type:`adhoc`,_stage:`computed`}}var de=class e{static use(t){return new e(t)}#e=[];constructor(e){this.model=e}Expr;include(...e){return this.#e.push({include:e.map(e=>H(e))}),this}exclude(...e){return this.#e.push({exclude:e.map(e=>H(e))}),this}compute(){return $(this.model,this.#e)}};export{de as AdhocView,$ as computeAdhocView,R as computeLikeC4Model,B as computeParsedModelData,se as computeProjectsView,le as computeRelationshipsView,L as computeView,K as resolveRulesExtendedViews,X as treeFromElements,F as unsafeComputeView,oe as viewsWithReadableEdges,q as withReadableEdges};
1
+ import{r as e}from"../_chunks/rolldown-runtime.mjs";import"../_chunks/libs/defu.mjs";import{$ as t,C as n,D as r,K as i,L as a,Q as o,S as s,T as c,X as l,Y as u,b as d,d as f,et as p,i as m,m as h,r as ee,w as te,y as ne}from"../_chunks/libs/remeda.mjs";import{$ as g,_,_t as v,g as y,it as re,st as ie,vt as ae,xt as b}from"../_chunks/types.mjs";import"../_chunks/geometry.mjs";import{$ as x,D as S,I as C,K as w,L as T,Q as E,U as D,_ as O,r as k,v as A,x as j}from"../_chunks/utils.mjs";import{n as M,t as N}from"../_chunks/libs/graphology-dag.mjs";import{t as P}from"../_chunks/libs/mnemonist.mjs";import"../_chunks/libs/natural-compare-lite.mjs";import"../_chunks/libs/ohash.mjs";import"../_chunks/libs/@ungap/structured-clone.mjs";import"../_chunks/libs/hast-util-sanitize.mjs";import"../_chunks/libs/rehype-sanitize.mjs";import"../_chunks/libs/hast-util-to-html.mjs";import"../_chunks/libs/character-entities-legacy.mjs";import"../_chunks/libs/character-entities-html4.mjs";import"../_chunks/libs/ccount.mjs";import"../_chunks/libs/comma-separated-tokens.mjs";import"../_chunks/libs/rehype-stringify.mjs";import"../_chunks/libs/devlop.mjs";import"../_chunks/libs/mdast-util-from-markdown.mjs";import"../_chunks/libs/escape-string-regexp.mjs";import"../_chunks/libs/mdast-util-find-and-replace.mjs";import"../_chunks/libs/mdast-util-gfm.mjs";import"../_chunks/libs/markdown-table.mjs";import"../_chunks/libs/longest-streak.mjs";import"../_chunks/libs/character-entities.mjs";import"../_chunks/libs/decode-named-character-reference.mjs";import"../_chunks/libs/micromark-extension-gfm.mjs";import"../_chunks/libs/remark-gfm.mjs";import"../_chunks/libs/remark-github-blockquote-alert.mjs";import"../_chunks/libs/remark-parse.mjs";import"../_chunks/libs/mdast-util-to-hast.mjs";import"../_chunks/libs/remark-rehype.mjs";import"../_chunks/libs/bail.mjs";import"../_chunks/libs/extend.mjs";import"../_chunks/libs/is-plain-obj.mjs";import"../_chunks/libs/trough.mjs";import"../_chunks/libs/unified.mjs";import"../_chunks/libs/@radix-ui/colors.mjs";import"../_chunks/libs/@mantine/colors-generator.mjs";import"../_chunks/model.mjs";import"../_chunks/manual-layout.mjs";import{a as F,c as I,i as L,n as R,o as z,r as B,s as V,t as H}from"../_chunks/Builder.view-element.mjs";import{t as U}from"../_chunks/libs/graphology.mjs";var W=M(),G=e(N(),1);function K(e){let t=new U({type:`directed`}),n=[];for(let r of ee(e))t.addNode(r.id,{view:r}),_(r)&&n.push(r);if(n.length===0)return e;for(let e of n){if(!t.hasNode(e.extends)){console.warn(`View "${e.id}" extends from "${e.extends}" which does not exist`);continue}if((0,G.default)(t,e.id,e.extends)){console.warn(`View "${e.id}" extends from "${e.extends}" which creates a cycle`);continue}t.addDirectedEdge(e.id,e.extends)}return(0,W.topologicalSort)(t).reverse().reduce((e,n)=>{let r=t.getNodeAttribute(n,`view`);if(!_(r))return e[r.id]=r,e;let i=e[r.extends];if(!i||!y(i))return e;let a=m([...i.tags??[],...r.tags??[]]),o=[...i.links??[],...r.links??[]];return e[r.id]={...i,...r,title:r.title??i.title??null,description:r.description??i.description??null,tags:a,links:w(o)?o:null,rules:[...i.rules,...r.rules]},e},{})}function q({edges:e,nodes:t,...n},r=`:`){let i=te(e,e=>[e.id,`${e.source}${r}${e.target}`]);return{...n,edges:e.map(e=>({...e,id:i[e.id]})),nodes:t.map(e=>({...e,inEdges:c(e.inEdges,e=>i[e]),outEdges:c(e.outEdges,e=>i[e])})),nodeIds:t.map(e=>e.id),edgeIds:e.map(e=>i[e.id])}}function oe({views:e,...t}){return{...t,views:n(e,e=>s(q(e),[`nodeIds`,`edgeIds`]))}}const J=e=>r(e).length,Y=e=>k(e);function se(e){let t=ce(e),n=(e,t)=>`${e}->${t}`,r=new P.default(e=>{let[t,n]=e.split(`->`);return{from:t,to:n,relationships:new Set}}),s=(e,t)=>r.get(n(e,t)).relationships,u=(e,t)=>{let n=t.projectId;E(n!==e.projectId,`Imported element must have a different project id`);let r=s(e.projectId,n);for(let n of t.incoming(`direct`))n.source.projectId===e.projectId&&r.add(n);let i=s(n,e.projectId);for(let n of t.outgoing(`direct`))n.target.projectId===e.projectId&&i.add(n)};for(let t of e)if(!a(t.$data.imports))for(let[e,n]of l(t.$data.imports))for(let r of n){let n=g(e,r.id);u(t,x(t.findElement(n),`Element ${r.id} from project ${e} not found in model ${t.projectId}`))}let d=Array.from(r.entries()).filter(([e,{relationships:t}])=>t.size>0).map(([e,{from:t,to:n,relationships:r}])=>{let a=[...r];E(o(a,1),`Relationships set must have at least one relationship`);let s={id:k(e),source:Y(t),target:Y(n),projectId:t,relations:c(a,h(`id`)),label:null,color:`gray`,parent:null,line:`solid`,tags:m(i(a,h(`tags`)))},l=ne(a);return l&&(s.label=l.title,s.description=b(l.$relationship)??null,s.technology=l.technology,s.color=l.color,s.line=l.line,l.kind&&(s.kind=l.kind),l.$relationship.navigateTo&&(s.navigateTo=l.$relationship.navigateTo)),s});I(t,d);let f=V({nodes:t,edges:d});return{id:`projects-view`,[ae]:`projects`,[v]:`computed`,title:`Projects`,description:{txt:`Overview of all projects and their relationships`},autoLayout:{direction:`TB`},...f}}function ce(e){let t=new Map;for(let n of e){let e=re(n.projectId),r={id:Y(e),kind:`@project`,parent:null,projectId:e,title:n.project.title??n.project.id,description:{txt:[`Elements: ${J(n.$data.elements)}`,`Relationships: ${J(n.$data.relations)}`,`Views: ${J(n.$data.views)}`].join(`
2
+ `)},shape:`rectangle`,children:[],inEdges:[],outEdges:[],color:`primary`,level:0,style:{},tags:[]};t.set(r.id,r)}return t}function X(e){let n=D([...e]),r=new Set(n),i=new Map,a=new P.default(()=>null),o=n.reduce((e,n,o,s)=>(i.set(n.id,n),e.set(n.id,p(s,t(o+1),u(T(n)),f((e,t)=>(r.delete(t),e.some(C(t))||(e.push(t),a.set(t.id,n)),e),[]))),e),new P.default(()=>[]));return{sorted:n,byId:e=>x(i.get(e),`Element not found by id: ${e}`),root:r,parent:e=>a.get(typeof e==`string`?e:e.id),children:e=>o.get(typeof e==`string`?e:e.id),flatten:d(()=>new Set([...r,...n.reduce((e,t)=>{let n=o.get(t.id);return n.length===0?(e.push(t),e):(n.length>1&&e.push(...n),e)},[])]))}}const Z=(e,t)=>e.size>2&&t.size!==e.size?new Set(D([...X(e).flatten(),...t])):e.size>1?new Set(D([...e])):e;function Q(e,t,n){let r=e=>t.has(e),i=new Set([e]),a={incomers:new Set,subjects:new Set([e]),outgoers:new Set},o=new Set(n.incoming.flatMap(t=>{if(a.subjects.add(t.target),a.incomers.add(t.source),i.add(t.target),t.target!==e){let n=t.target.parent;for(;n&&n!==e;)i.add(n),n=n.parent}let n=t.source,o=[];for(;o.push(n),!(r(n)||!n.parent);)n=n.parent;return o})),s=new Set(n.outgoing.flatMap(t=>{if(a.subjects.add(t.source),a.outgoers.add(t.target),i.add(t.source),t.source!==e){let n=t.source.parent;for(;n&&n!==e;)i.add(n),n=n.parent}let n=t.target,o=[];for(;o.push(n),!(r(n)||!n.parent);)n=n.parent;return o}));return{incomers:Z(o,a.incomers),incoming:new Set(n.incoming),subjects:Z(i,a.subjects),outgoing:new Set(n.outgoing),outgoers:Z(s,a.outgoers)}}function le(e,t,n,r=`global`){let i=n?t.findView(n):null;if(r===`view`)return E(i,`Scope view id is required when scope is "view"`),ue(e,i,t);let a=t.element(e);return Q(a,A(a.ascendingSiblings()),{incoming:[...a.incoming()],outgoing:[...a.outgoing()]})}function ue(e,t,n){let r=n.element(e),i={incoming:O(S(r.incoming(),e=>t.includesRelation(e.id))),outgoing:O(S(r.outgoing(),e=>t.includesRelation(e.id)))},a=T(r);return Q(r,new Set([...r.ascendingSiblings(),...p(t.elements(),j(e=>e.element),S(e=>e!==r&&a(e)))]),i)}function $(e,t){return{...z(e,{id:ie(`adhoc`),_stage:`parsed`,_type:`element`,rules:t,title:null,description:null}),_type:`adhoc`,_stage:`computed`}}var de=class e{static use(t){return new e(t)}#e=[];constructor(e){this.model=e}Expr;include(...e){return this.#e.push({include:e.map(e=>H(e))}),this}exclude(...e){return this.#e.push({exclude:e.map(e=>H(e))}),this}compute(){return $(this.model,this.#e)}};export{de as AdhocView,$ as computeAdhocView,R as computeLikeC4Model,B as computeParsedModelData,se as computeProjectsView,le as computeRelationshipsView,L as computeView,K as resolveRulesExtendedViews,X as treeFromElements,F as unsafeComputeView,oe as viewsWithReadableEdges,q as withReadableEdges};
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as LayoutedViewDriftReason, $i as IteratorLike, $n as BorderStyle, $t as ElementViewPredicate, A as isComputedView, Ai as RelationshipKind, An as Expression, Ar as Any, At as ModelRelation, B as DeploymentViewIncludePredicate, Bi as isStepEdgeId, Bn as OrOperator, Bt as DynamicStepsParallel, C as LayoutedView, Ci as IconUrl, Cn as isAutoLayoutDirection, Cr as isThemeColor, Ct as DeploymentRelation, D as ViewRule, Di as ProjectId, Dn as ModelExpression, Dr as IconPositions, Dt as AbstractRelationship, E as ViewOnStage, Ei as NoneIcon, En as isViewRuleGlobalStyle, Er as ElementShapes, Et as isDeploymentNode, F as isExtendsElementView, Fi as ViewId, Fn as EqualOperator, Ft as GlobalPredicates, G as DiagramEdge, Gi as ModelStage, Gn as isAndOperator, Gt as DynamicViewStep, H as DeploymentViewRule, Hi as splitGlobalFqn, Hn as ParticipantOperator, Ht as DynamicViewDisplayVariant, I as isScopedElementView, Ii as extractStep, In as Filterable, It as GlobalStyleID, J as LayoutedDeploymentView, Ji as _type, Jn as isOrOperator, Jt as isDynamicStep, K as DiagramNode, Ki as _layout, Kn as isKindEqual, Kt as ParsedDynamicView, L as isViewRulePredicate, Li as flattenMarkdownOrString, Ln as KindEqual, Lt as GlobalStyles, M as isDiagramView, Mi as StepEdgeIdLiteral, Mn as PredicateSelector, Mr as AnyLayouted, Mt as ensureSizes, N as isDynamicView, Ni as StepEdgeKind, Nn as RelationExpr, Nr as AnyParsed, Nt as GlobalDynamicPredicates, O as ViewRulePredicate, Oi as RelationId, On as ModelFqnExpr, Or as Sizes, Ot as Element, P as isElementView, Pi as Tag, Pn as AndOperator, Pr as Aux, Pt as GlobalPredicateId, Q as DiagramNodeDriftReason, Qi as IterableContainer, Qn as FqnRef, Qr as SpecAux, Qt as ElementViewIncludePredicate, R as isViewRuleStyle, Ri as isGlobalFqn, Rn as NotOperator, Rt as ModelGlobals, S as ComputedView, Si as Icon, Sn as ViewWithNotation, Sr as isCustomColor, St as DeploymentNode, T as ProcessedView, Ti as NodeId, Tn as isViewRuleGlobalPredicateRef, Tt as isDeployedInstance, U as DeploymentViewRuleStyle, Ui as stepEdgeId, Un as TagEqual, Ut as DynamicViewIncludeRule, V as DeploymentViewPredicate, Vi as scalar_d_exports, Vn as Participant, Vt as DynamicStepsSeries, W as ParsedDeploymentView, Wi as ExtractOnStage, Wn as WhereOperator, Wr as LooseLiteral, Wt as DynamicViewRule, X as LayoutedElementView, Xi as Coalesce, Xn as isTagEqual, Xt as isDynamicStepsSeries, Y as LayoutedDynamicView, Yi as isOnStage, Yn as isParticipantOperator, Yt as isDynamicStepsParallel, Z as DiagramEdgeDriftReason, Zi as ExclusiveUnion, Zn as whereOperatorAsPredicate, Zt as ElementViewExcludePredicate, _ as ComputedLikeC4ModelData, _i as EdgeId, _n as ViewRuleGlobalPredicateRef, _r as Size, _t as TagSpecification, a as isNonEmptyArray, aa as Predicate, ai as UnknownLayouted, an as isViewRuleGroup, ar as ElementShape, at as ComputedNode, b as ParsedLikeC4ModelData, bi as GlobalFqn, bn as ViewType, br as ThemeColor, bt as DeploymentElement, c as RichTextEmpty, ci as _aux_d_exports, cn as AnyIncludePredicate, cr as IconSize, ct as LikeC4Project, d as AuxFromDump, dn as BaseParsedViewProperties, dr as LikeC4Theme, dt as LikeC4ProjectStylesConfig, ea as KeysOf, en as ElementViewRule, er as Color, et as ViewManualLayoutSnapshot, f as LikeC4ModelDump, fn as BaseViewProperties, fr as RelationshipArrowType, ft as LikeC4ProjectStylesCustomStylesheets, g as AuxFromLikeC4ModelData, gi as DeploymentKind, gn as ViewRuleAutoLayout, gr as ShapeSize, gt as Specification, h as SpecificationDump, hi as DeploymentFqn, hn as ViewAutoLayout, hr as RelationshipLineType, ht as RelationshipSpecification, i as isAnyOf, ia as NonEmptyReadonlyArray, ii as UnknownComputed, in as ParsedElementView, ir as ElementColorValues, it as ComputedElementView, j as isDeploymentView, ji as StepEdgeId, jn as FqnExpr, jr as AnyComputed, jt as Relationship, k as ViewWithType, ki as RelationKind, kn as ModelRelationExpr, kr as ThemeColors, kt as ElementStyle, l as RichTextOrEmpty, li as preferDescription, ln as AnyViewRuleStyle, lr as LikeC4StyleDefaults, lt as LikeC4ProjectManualLayoutsConfig, m as SpecTypesFromDump, mi as BuiltInIcon, mn as RankValue, mr as RelationshipColorValues, mt as ElementSpecification, n as GuardedBy, na as NTuple, nn as ElementViewRuleRank, nr as CustomColor, nt as ComputedDynamicView, o as isString, oa as ReorderedArray, oi as UnknownParsed, on as isViewRuleRank, or as HexColor, ot as ComputedNodeStyle, p as ProjectDump, pi as AnyFqn, pn as NodeNotation, pr as RelationshipArrowTypes, pt as LikeC4ProjectTheme, q as LayoutType, qi as _stage, qn as isNotOperator, qt as getParallelStepsPrefix, r as hasProp, ra as NonEmptyArray, ri as Unknown, rn as ElementViewRuleStyle, rr as CustomColorDefinitions, rt as ComputedEdge, s as RichText, sa as exact, sn as AnyExcludePredicate, sr as IconPosition, st as ComputedRankConstraint, t as Guard, ta as Link, tn as ElementViewRuleGroup, tr as ColorLiteral, tt as ComputedDeploymentView, u as ViewChange, ui as preferSummary, un as AutoLayoutDirection, ur as LikeC4StylesConfig, ut as LikeC4ProjectStyleDefaults, v as LayoutedLikeC4ModelData, vi as ElementKind, vn as ViewRuleGlobalStyle, vr as SpacingSize, vt as isTagColorSpecified, w as ParsedView, wi as MarkdownOrString, wn as isViewRuleAutoLayout, wr as BorderStyles, wt as DeploymentRelationship, x as AnyView, xi as GroupElementKind, xn as ViewWithHash, xr as ThemeColorValues, xt as DeploymentElementRef, y as LikeC4ModelData, yi as Fqn, yn as ViewRuleRank, yr as TextSize, yt as DeployedInstance, z as DeploymentViewExcludePredicate, zi as isGroupElementKind, zn as OperatorPredicate, zt as DynamicStep } from "./_chunks/index.mjs";
1
+ import { $ as LayoutedViewDriftReason, $i as ExclusiveUnion, $n as whereOperatorAsPredicate, $t as ElementViewPredicate, A as isComputedView, Ai as RelationId, An as Expression, Ar as Sizes, At as ModelRelation, B as DeploymentViewIncludePredicate, Bi as isGlobalFqn, Bn as OperatorPredicate, Bt as DynamicStepsParallel, C as LayoutedView, Ci as GroupElementKind, Cn as isAutoLayoutDirection, Cr as ThemeColorValues, Ct as DeploymentRelation, D as ViewRule, Di as NodeId, Dn as ModelExpression, Dt as AbstractRelationship, E as ViewOnStage, Ei as MarkdownOrString, En as isViewRuleGlobalStyle, Er as BorderStyles, Et as isDeploymentNode, F as isExtendsElementView, Fi as StepEdgeKind, Fn as EqualOperator, Fr as AnyParsed, Ft as GlobalPredicates, G as DiagramEdge, Gi as stepEdgeId, Gn as WhereOperator, Gt as DynamicViewStep, H as DeploymentViewRule, Hi as isStepEdgeId, Hn as Participant, Ht as DynamicViewDisplayVariant, I as isScopedElementView, Ii as Tag, In as Filterable, Ir as Aux, It as GlobalStyleID, J as LayoutedDeploymentView, Ji as _layout, Jn as isMetadataEqual, Jt as isDynamicStep, K as DiagramNode, Ki as ExtractOnStage, Kn as isAndOperator, Kr as LooseLiteral, Kt as ParsedDynamicView, L as isViewRulePredicate, Li as ViewId, Ln as KindEqual, Lt as GlobalStyles, M as isDiagramView, Mi as RelationshipKind, Mn as PredicateSelector, Mr as Any, Mt as ensureSizes, N as isDynamicView, Ni as StepEdgeId, Nn as RelationExpr, Nr as AnyComputed, Nt as GlobalDynamicPredicates, O as ViewRulePredicate, Oi as NoneIcon, On as ModelFqnExpr, Or as ElementShapes, Ot as Element, P as isElementView, Pi as StepEdgeIdLiteral, Pn as AndOperator, Pr as AnyLayouted, Pt as GlobalPredicateId, Q as DiagramNodeDriftReason, Qi as Coalesce, Qn as isTagEqual, Qt as ElementViewIncludePredicate, R as isViewRuleStyle, Ri as extractStep, Rn as MetadataEqual, Rt as ModelGlobals, S as ComputedView, Si as GlobalFqn, Sn as ViewWithNotation, Sr as ThemeColor, St as DeploymentNode, T as ProcessedView, Ti as IconUrl, Tn as isViewRuleGlobalPredicateRef, Tr as isThemeColor, Tt as isDeployedInstance, U as DeploymentViewRuleStyle, Ui as scalar_d_exports, Un as ParticipantOperator, Ut as DynamicViewIncludeRule, V as DeploymentViewPredicate, Vi as isGroupElementKind, Vn as OrOperator, Vt as DynamicStepsSeries, W as ParsedDeploymentView, Wi as splitGlobalFqn, Wn as TagEqual, Wt as DynamicViewRule, X as LayoutedElementView, Xi as _type, Xn as isOrOperator, Xt as isDynamicStepsSeries, Y as LayoutedDynamicView, Yi as _stage, Yn as isNotOperator, Yt as isDynamicStepsParallel, Z as DiagramEdgeDriftReason, Zi as isOnStage, Zn as isParticipantOperator, Zt as ElementViewExcludePredicate, _ as ComputedLikeC4ModelData, _i as DeploymentFqn, _n as ViewRuleGlobalPredicateRef, _r as RelationshipLineType, _t as TagSpecification, a as isNonEmptyArray, aa as NonEmptyArray, ai as Unknown, an as isViewRuleGroup, ar as CustomColorDefinitions, at as ComputedNode, b as ParsedLikeC4ModelData, bi as ElementKind, bn as ViewType, br as SpacingSize, bt as DeploymentElement, c as RichTextEmpty, ca as ReorderedArray, ci as UnknownParsed, cn as AnyIncludePredicate, cr as HexColor, ct as LikeC4Project, d as AuxFromDump, di as preferDescription, dn as BaseParsedViewProperties, dr as LikeC4StyleDefaults, dt as LikeC4ProjectStylesConfig, ea as IterableContainer, ei as SpecAux, en as ElementViewRule, er as FqnRef, et as ViewManualLayoutSnapshot, f as LikeC4ModelDump, fi as preferSummary, fn as BaseViewProperties, fr as LikeC4StylesConfig, ft as LikeC4ProjectStylesCustomStylesheets, g as AuxFromLikeC4ModelData, gi as BuiltInIcon, gn as ViewRuleAutoLayout, gr as RelationshipColorValues, gt as Specification, h as SpecificationDump, hi as AnyFqn, hn as ViewAutoLayout, hr as RelationshipArrowTypes, ht as RelationshipSpecification, i as isAnyOf, ia as NTuple, in as ParsedElementView, ir as CustomColor, it as ComputedElementView, j as isDeploymentView, ji as RelationKind, jn as FqnExpr, jr as ThemeColors, jt as Relationship, k as ViewWithType, ki as ProjectId, kn as ModelRelationExpr, kr as IconPositions, kt as ElementStyle, l as RichTextOrEmpty, la as exact, ln as AnyViewRuleStyle, lr as IconPosition, lt as LikeC4ProjectManualLayoutsConfig, m as SpecTypesFromDump, mn as RankValue, mr as RelationshipArrowType, mt as ElementSpecification, n as GuardedBy, na as KeysOf, nn as ElementViewRuleRank, nr as Color, nt as ComputedDynamicView, o as isString, oa as NonEmptyReadonlyArray, oi as UnknownComputed, on as isViewRuleRank, or as ElementColorValues, ot as ComputedNodeStyle, p as ProjectDump, pn as NodeNotation, pr as LikeC4Theme, pt as LikeC4ProjectTheme, q as LayoutType, qi as ModelStage, qn as isKindEqual, qt as getParallelStepsPrefix, r as hasProp, ra as Link, rn as ElementViewRuleStyle, rr as ColorLiteral, rt as ComputedEdge, s as RichText, sa as Predicate, si as UnknownLayouted, sn as AnyExcludePredicate, sr as ElementShape, st as ComputedRankConstraint, t as Guard, ta as IteratorLike, tn as ElementViewRuleGroup, tr as BorderStyle, tt as ComputedDeploymentView, u as ViewChange, ui as _aux_d_exports, un as AutoLayoutDirection, ur as IconSize, ut as LikeC4ProjectStyleDefaults, v as LayoutedLikeC4ModelData, vi as DeploymentKind, vn as ViewRuleGlobalStyle, vr as ShapeSize, vt as isTagColorSpecified, w as ParsedView, wi as Icon, wn as isViewRuleAutoLayout, wr as isCustomColor, wt as DeploymentRelationship, x as AnyView, xi as Fqn, xn as ViewWithHash, xr as TextSize, xt as DeploymentElementRef, y as LikeC4ModelData, yi as EdgeId, yn as ViewRuleRank, yr as Size, yt as DeployedInstance, z as DeploymentViewExcludePredicate, zi as flattenMarkdownOrString, zn as NotOperator, zt as DynamicStep } from "./_chunks/index.mjs";
2
2
  import { a as RectBox, c as XYPoint, i as BBox, l as convertPoint, n as VectorValue, o as Dimensions, r as vector, s as Point, t as Vector, u as isPoint } from "./_chunks/index2.mjs";
3
3
  import { i as LikeC4Styles } from "./_chunks/index3.mjs";
4
4
  import { a as DefaultWeakMap, i as LinkedList, n as MultiMap, o as DefaultMap, r as Queue } from "./_chunks/libs/mnemonist.mjs";
@@ -6,6 +6,15 @@ import "./_chunks/mnemonist.mjs";
6
6
  import { o as LayoutedProjectsView, r as ComputedProjectsView } from "./_chunks/_types2.mjs";
7
7
  import { D as isIterable, F as isAncestor, H as sortParentsFirst, I as isDescendantOf, J as nonNullable, L as isSameHierarchy, R as nameFromFqn, V as sortNaturalByFqn, Y as nonexhaustive, k as ancestorsFqn, m as memoizeProp, q as invariant, z as parentFqn } from "./_chunks/index5.mjs";
8
8
 
9
+ //#region src/manual-layout/applyCachedLayout.d.ts
10
+ /**
11
+ * When restoring a LayoutedView from cache, the cached view may have stale
12
+ * non-layout data (colors, links, tags, title, navigateTo, etc.)
13
+ * because view-hash only covers layout-affecting properties.
14
+ * This merges current ComputedView data onto the cached layout.
15
+ */
16
+ declare function applyCachedLayout(current: ComputedView, cached: LayoutedView): LayoutedView;
17
+ //#endregion
9
18
  //#region src/manual-layout/applyManualLayout.d.ts
10
19
  /**
11
20
  * Proof-of-concept
@@ -25,4 +34,4 @@ declare function applyManualLayout<V extends LayoutedView>(autoLayouted: V, snap
25
34
  */
26
35
  declare function calcDriftsFromSnapshot<V extends LayoutedView>(autoLayouted: V, snapshot: ViewManualLayoutSnapshot): V;
27
36
  //#endregion
28
- export { AbstractRelationship, AndOperator, Any, Any as AnyAux, AnyComputed, AnyExcludePredicate, AnyFqn, AnyIncludePredicate, AnyLayouted, AnyParsed, AnyView, AnyViewRuleStyle, AutoLayoutDirection, Aux, AuxFromDump, AuxFromLikeC4ModelData, BBox, BaseParsedViewProperties, BaseViewProperties, BorderStyle, BorderStyles, BuiltInIcon, Coalesce, Color, ColorLiteral, ComputedDeploymentView, ComputedDynamicView, ComputedEdge, ComputedElementView, ComputedLikeC4ModelData, ComputedNode, ComputedNodeStyle, type ComputedProjectsView, ComputedRankConstraint, ComputedView, CustomColor, CustomColorDefinitions, DefaultMap, DefaultWeakMap, DeployedInstance, DeploymentElement, DeploymentElementRef, DeploymentFqn, DeploymentKind, DeploymentNode, DeploymentRelation, DeploymentRelationship, DeploymentViewExcludePredicate, DeploymentViewIncludePredicate, DeploymentViewPredicate, DeploymentViewRule, DeploymentViewRuleStyle, DiagramEdge, DiagramEdgeDriftReason, DiagramNode, DiagramNodeDriftReason, LayoutedView as DiagramView, LayoutedView, Dimensions, DynamicStep, DynamicStepsParallel, DynamicStepsSeries, DynamicViewDisplayVariant, DynamicViewIncludeRule, DynamicViewRule, DynamicViewStep, EdgeId, Element, ElementColorValues, ElementKind, ElementShape, ElementShapes, ElementSpecification, ElementStyle, ElementViewExcludePredicate, ElementViewIncludePredicate, ElementViewPredicate, ElementViewRule, ElementViewRuleGroup, ElementViewRuleRank, ElementViewRuleStyle, EqualOperator, ExclusiveUnion, Expression, ExtractOnStage, Filterable, Fqn, FqnExpr, FqnRef, GlobalDynamicPredicates, GlobalFqn, GlobalPredicateId, GlobalPredicates, GlobalStyleID, GlobalStyles, GroupElementKind, Guard, GuardedBy, HexColor, Icon, IconPosition, IconPositions, IconSize, IconUrl, IterableContainer, IteratorLike, KeysOf, KindEqual, LayoutType, LayoutedDeploymentView, LayoutedDynamicView, LayoutedElementView, LayoutedLikeC4ModelData, type LayoutedProjectsView, LayoutedViewDriftReason, LikeC4ModelData, LikeC4ModelDump, LikeC4Project, LikeC4ProjectManualLayoutsConfig, LikeC4ProjectStyleDefaults, LikeC4ProjectStylesConfig, LikeC4ProjectStylesCustomStylesheets, LikeC4ProjectTheme, type LikeC4StyleDefaults, LikeC4Styles, type LikeC4StylesConfig, type LikeC4Theme, ParsedView as LikeC4View, ParsedView, Link, LinkedList, LooseLiteral, MarkdownOrString, ModelExpression, ModelFqnExpr, ModelGlobals, ModelRelation, ModelRelationExpr, ModelStage, MultiMap, NTuple, NodeId, NodeNotation, NonEmptyArray, NonEmptyReadonlyArray, NoneIcon, NotOperator, OperatorPredicate, OrOperator, ParsedDeploymentView, ParsedDynamicView, ParsedElementView, ParsedLikeC4ModelData, Participant, ParticipantOperator, Point, Predicate, PredicateSelector, ProcessedView, ProjectDump, ProjectId, Queue, RankValue, RectBox, RelationExpr, RelationId, RelationKind, Relationship, RelationshipArrowType, RelationshipArrowTypes, RelationshipColorValues, RelationshipKind, RelationshipLineType, RelationshipSpecification, ReorderedArray, RichText, RichTextEmpty, RichTextOrEmpty, ShapeSize, Size, Sizes, SpacingSize, SpecAux, SpecTypesFromDump, Specification, SpecificationDump, StepEdgeId, StepEdgeIdLiteral, StepEdgeKind, Tag, TagEqual, TagSpecification, TextSize, ThemeColor, type ThemeColorValues, ThemeColors, Unknown, UnknownComputed, UnknownLayouted, UnknownParsed, Vector, VectorValue, ViewAutoLayout, ViewChange, ViewId, ViewManualLayoutSnapshot, ViewOnStage, ViewRule, ViewRuleAutoLayout, ViewRuleGlobalPredicateRef, ViewRuleGlobalStyle, ViewRulePredicate, ViewRuleRank, ViewType, ViewWithHash, ViewWithNotation, ViewWithType, WhereOperator, XYPoint, _layout, _stage, _type, ancestorsFqn, applyManualLayout, _aux_d_exports as aux, calcDriftsFromSnapshot, convertPoint, ensureSizes, exact, extractStep, flattenMarkdownOrString, getParallelStepsPrefix, hasProp, invariant, isAncestor, isAndOperator, isAnyOf, isAutoLayoutDirection, isComputedView, isCustomColor, isDeployedInstance, isDeploymentNode, isDeploymentView, isDescendantOf, isDiagramView, isDiagramView as isLayoutedView, isDynamicStep, isDynamicStepsParallel, isDynamicStepsSeries, isDynamicView, isElementView, isExtendsElementView, isGlobalFqn, isGroupElementKind, isIterable, isKindEqual, isNonEmptyArray, isNotOperator, isOnStage, isOrOperator, isParticipantOperator, isPoint, isSameHierarchy, isScopedElementView, isStepEdgeId, isString, isTagColorSpecified, isTagEqual, isThemeColor, isViewRuleAutoLayout, isViewRuleGlobalPredicateRef, isViewRuleGlobalStyle, isViewRuleGroup, isViewRulePredicate, isViewRuleRank, isViewRuleStyle, memoizeProp, nameFromFqn, nonNullable, nonexhaustive, parentFqn, preferDescription, preferSummary, scalar_d_exports as scalar, sortNaturalByFqn, sortParentsFirst, splitGlobalFqn, stepEdgeId, vector, whereOperatorAsPredicate };
37
+ export { AbstractRelationship, AndOperator, Any, Any as AnyAux, AnyComputed, AnyExcludePredicate, AnyFqn, AnyIncludePredicate, AnyLayouted, AnyParsed, AnyView, AnyViewRuleStyle, AutoLayoutDirection, Aux, AuxFromDump, AuxFromLikeC4ModelData, BBox, BaseParsedViewProperties, BaseViewProperties, BorderStyle, BorderStyles, BuiltInIcon, Coalesce, Color, ColorLiteral, ComputedDeploymentView, ComputedDynamicView, ComputedEdge, ComputedElementView, ComputedLikeC4ModelData, ComputedNode, ComputedNodeStyle, type ComputedProjectsView, ComputedRankConstraint, ComputedView, CustomColor, CustomColorDefinitions, DefaultMap, DefaultWeakMap, DeployedInstance, DeploymentElement, DeploymentElementRef, DeploymentFqn, DeploymentKind, DeploymentNode, DeploymentRelation, DeploymentRelationship, DeploymentViewExcludePredicate, DeploymentViewIncludePredicate, DeploymentViewPredicate, DeploymentViewRule, DeploymentViewRuleStyle, DiagramEdge, DiagramEdgeDriftReason, DiagramNode, DiagramNodeDriftReason, LayoutedView as DiagramView, LayoutedView, Dimensions, DynamicStep, DynamicStepsParallel, DynamicStepsSeries, DynamicViewDisplayVariant, DynamicViewIncludeRule, DynamicViewRule, DynamicViewStep, EdgeId, Element, ElementColorValues, ElementKind, ElementShape, ElementShapes, ElementSpecification, ElementStyle, ElementViewExcludePredicate, ElementViewIncludePredicate, ElementViewPredicate, ElementViewRule, ElementViewRuleGroup, ElementViewRuleRank, ElementViewRuleStyle, EqualOperator, ExclusiveUnion, Expression, ExtractOnStage, Filterable, Fqn, FqnExpr, FqnRef, GlobalDynamicPredicates, GlobalFqn, GlobalPredicateId, GlobalPredicates, GlobalStyleID, GlobalStyles, GroupElementKind, Guard, GuardedBy, HexColor, Icon, IconPosition, IconPositions, IconSize, IconUrl, IterableContainer, IteratorLike, KeysOf, KindEqual, LayoutType, LayoutedDeploymentView, LayoutedDynamicView, LayoutedElementView, LayoutedLikeC4ModelData, type LayoutedProjectsView, LayoutedViewDriftReason, LikeC4ModelData, LikeC4ModelDump, LikeC4Project, LikeC4ProjectManualLayoutsConfig, LikeC4ProjectStyleDefaults, LikeC4ProjectStylesConfig, LikeC4ProjectStylesCustomStylesheets, LikeC4ProjectTheme, type LikeC4StyleDefaults, LikeC4Styles, type LikeC4StylesConfig, type LikeC4Theme, ParsedView as LikeC4View, ParsedView, Link, LinkedList, LooseLiteral, MarkdownOrString, MetadataEqual, ModelExpression, ModelFqnExpr, ModelGlobals, ModelRelation, ModelRelationExpr, ModelStage, MultiMap, NTuple, NodeId, NodeNotation, NonEmptyArray, NonEmptyReadonlyArray, NoneIcon, NotOperator, OperatorPredicate, OrOperator, ParsedDeploymentView, ParsedDynamicView, ParsedElementView, ParsedLikeC4ModelData, Participant, ParticipantOperator, Point, Predicate, PredicateSelector, ProcessedView, ProjectDump, ProjectId, Queue, RankValue, RectBox, RelationExpr, RelationId, RelationKind, Relationship, RelationshipArrowType, RelationshipArrowTypes, RelationshipColorValues, RelationshipKind, RelationshipLineType, RelationshipSpecification, ReorderedArray, RichText, RichTextEmpty, RichTextOrEmpty, ShapeSize, Size, Sizes, SpacingSize, SpecAux, SpecTypesFromDump, Specification, SpecificationDump, StepEdgeId, StepEdgeIdLiteral, StepEdgeKind, Tag, TagEqual, TagSpecification, TextSize, ThemeColor, type ThemeColorValues, ThemeColors, Unknown, UnknownComputed, UnknownLayouted, UnknownParsed, Vector, VectorValue, ViewAutoLayout, ViewChange, ViewId, ViewManualLayoutSnapshot, ViewOnStage, ViewRule, ViewRuleAutoLayout, ViewRuleGlobalPredicateRef, ViewRuleGlobalStyle, ViewRulePredicate, ViewRuleRank, ViewType, ViewWithHash, ViewWithNotation, ViewWithType, WhereOperator, XYPoint, _layout, _stage, _type, ancestorsFqn, applyCachedLayout, applyManualLayout, _aux_d_exports as aux, calcDriftsFromSnapshot, convertPoint, ensureSizes, exact, extractStep, flattenMarkdownOrString, getParallelStepsPrefix, hasProp, invariant, isAncestor, isAndOperator, isAnyOf, isAutoLayoutDirection, isComputedView, isCustomColor, isDeployedInstance, isDeploymentNode, isDeploymentView, isDescendantOf, isDiagramView, isDiagramView as isLayoutedView, isDynamicStep, isDynamicStepsParallel, isDynamicStepsSeries, isDynamicView, isElementView, isExtendsElementView, isGlobalFqn, isGroupElementKind, isIterable, isKindEqual, isMetadataEqual, isNonEmptyArray, isNotOperator, isOnStage, isOrOperator, isParticipantOperator, isPoint, isSameHierarchy, isScopedElementView, isStepEdgeId, isString, isTagColorSpecified, isTagEqual, isThemeColor, isViewRuleAutoLayout, isViewRuleGlobalPredicateRef, isViewRuleGlobalStyle, isViewRuleGroup, isViewRulePredicate, isViewRuleRank, isViewRuleStyle, memoizeProp, nameFromFqn, nonNullable, nonexhaustive, parentFqn, preferDescription, preferSummary, scalar_d_exports as scalar, sortNaturalByFqn, sortParentsFirst, splitGlobalFqn, stepEdgeId, vector, whereOperatorAsPredicate };