@likec4/core 1.52.0 → 1.54.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,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime.mjs";import{B as t,C as n,E as r,G as i,H as a,I as o,J as s,K as c,L as l,M as u,N as d,O as f,P as p,Q as m,R as h,S as g,T as _,V as v,Y as y,Z as ee,_ as te,a as ne,d as re,et as b,g as ie,h as ae,i as oe,k as se,m as ce,n as le,nt as ue,o as de,q as fe,r as pe,rt as x,t as me,tt as he,u as ge,v as _e,w as ve,x as ye,y as S,z as be}from"./libs/remeda.mjs";import{$ as xe,D as C,H as Se,J as w,K as T,U as E,W as D,_t as Ce,b as we,bt as Te,ct as Ee,d as De,et as Oe,g as ke,gt as Ae,h as je,l as Me,mt as Ne,n as Pe,o as Fe,p as Ie,q as O,r as Le,s as Re,u as ze,ut as Be,xt as k,y as Ve}from"./types.mjs";import{$ as A,A as He,B as Ue,D as j,I as M,K as We,L as Ge,M as Ke,O as N,Q as P,R as qe,U as Je,V as Ye,Z as Xe,_ as F,a as I,c as L,d as Ze,et as R,g as Qe,i as $e,j as et,s as tt,u as z,v as B,w as nt,x as rt,y as it}from"./utils.mjs";import{n as at,t as ot}from"./libs/graphology-dag.mjs";import{c as st,t as ct}from"./libs/mnemonist.mjs";import{A as lt,C as ut,D as dt,E as ft,M as V,N as pt,O as mt,T as ht,_ as gt,c as _t,d as vt,f as yt,g as bt,h as xt,j as St,m as Ct,n as wt,o as Tt,p as Et,q as Dt,r as Ot,t as kt,v as At,w as jt,y as Mt}from"./model.mjs";import{r as Nt}from"./manual-layout.mjs";import{t as Pt}from"./libs/graphology.mjs";function Ft(e,t){let n=[],r=e.parent;for(;r;){let e=A(t.get(r),`Parent node ${r} not found`);n.push(e),r=e.parent}return n}function It(e,t){for(let n of t){let t=e.get(n.source),i=e.get(n.target);P(t,`Source node ${n.source} not found`),P(i,`Target node ${n.target} not found`),t.outEdges.push(n.id),i.inEdges.push(n.id);let a=Ft(t,e),o=Ft(i,e),s=a.length>0&&o.length>0?r(Xe(ge(a),ge(o))):null;n.parent=s?s.id:null;for(let e of a){if(e===s)break;e.outEdges.push(n.id)}for(let e of o){if(e===s)break;e.inEdges.push(n.id)}}}var Lt=at(),Rt=e(ot(),1);function zt(e){let t=[],n=[...e],r;for(;r=n.shift();){let e=r.parent;if(e){let r=[];for(;e;){let t=n.findIndex(t=>t.id===e);if(t<0)break;let[i]=n.splice(t,1);if(!i)throw Error(`Invalid state, should not happen`);r.unshift(i),e=i.parent}t.push(...r)}t.push(r)}return t}function Bt(e){return e.forEach(t=>{t.children.length>0&&(t.children=e.reduce((e,n)=>(n.parent===t.id&&e.push(n.id),e),[]))}),e}function Vt(e){let t=zt([...e.nodes.values()]),n=[...e.edges];if(t.length<2||n.length===0)return{nodes:t,edges:n};let r=t=>A(e.nodes.get(t)),a=new Pt({multi:!0,allowSelfLoops:!0,type:`directed`}),[o,s]=_e(b(n,_(e=>{let t=r(e.source),n=r(e.target),i=e.parent?r(e.parent):null;return{id:e.id,edge:e,parent:i,source:t,target:n}})),({source:e,target:t})=>e.children.length===0&&t.children.length===0),c=[],l=e=>{a.mergeNode(e.source),a.mergeNode(e.target),c.push(e),(0,Rt.default)(a,e.source,e.target)||a.mergeDirectedEdge(e.source,e.target)};for(let{edge:t,source:n,target:s}of o)if(l(t),s.parent&&s.parent!==t.parent&&b(Ft(s,e.nodes),ne(e=>e.inEdges.includes(t.id)),i(e=>{a.mergeNode(e.id),(0,Rt.default)(a,t.source,e.id)||a.mergeDirectedEdge(t.source,e.id),(0,Rt.default)(a,e.id,t.target)||a.mergeDirectedEdge(e.id,t.target)})),n.parent){let e=r(n.parent);a.mergeNode(e.id),(0,Rt.default)(a,e.id,n.id)||a.mergeDirectedEdge(e.id,n.id),s.parent&&s.parent!==n.parent&&((0,Rt.default)(a,e.id,s.parent)||a.mergeDirectedEdge(e.id,s.parent))}for(let{edge:e}of s)l(e);P(c.length===n.length,`Not all edges were added to the graph`);let u=(0,Lt.topologicalSort)(a),d=[],f=t.slice();for(let e of u){let t=f.findIndex(t=>t.id===e);P(t>=0,`Node "${e}" not found`),d.push(...f.splice(t,1))}return f.length>0&&d.length>0&&(d=d.flatMap(e=>{if(f.length===0)return e;let n=t.slice(0,t.indexOf(e)).filter(e=>f.includes(e));return n.length>0?(f=f.filter(e=>!n.includes(e)),[...n,e]):e})),d.push(...f),{nodes:Bt(zt(d)),edges:c}}function Ht(e){return e.hash=$e({id:e.id,__:e._type??`element`,autoLayout:e.autoLayout,nodes:b(e.nodes,_(e=>({id:e.id,icon:f(e.icon)&&e.icon!==`none`?`Y`:`N`,title:e.title,description:Ee(e.description),technology:e.technology??null,shape:e.shape,size:e.style.size??null,iconSize:e.style.iconSize??null,iconPosition:e.style.iconPosition??null,textSize:e.style.textSize??null,padding:e.style.padding??null,children:e.children})),ve(({id:e,...t})=>[e,t])),edges:b(e.edges,_(e=>({source:e.source,target:e.target,label:e.label,description:Ee(e.description),technology:e.technology??null,dir:e.dir,head:e.head,tail:e.tail,line:e.line})),ve(({source:e,target:t,...n})=>[`${e}:${t}`,n]))}),e}var Ut=class{get Ctx(){throw Error(`Should not be called in runtime`)}constructor(e){this.state=e}get elements(){return this.state.elements}get explicits(){return this.state.explicits}get final(){return this.state.final}get connections(){return this.state.connections}isEmpty(){return this.elements.size===0&&this.connections.length===0&&this.explicits.size===0&&this.final.size===0}},Wt=class{excluded={elements:new Set,connections:[]};constructor(e,t){this.memory=e,this.expression=t}markedToMoveExplicitToImplicit=!1;_removeElement(e){this.excluded.elements.add(e)}exclude(e){if(!e)return this;if(N(e)){for(let t of e)this._removeElement(t);return this}return this._removeElement(e),this}_removeConnection(e){this.excluded.connections.push(e)}excludeConnections(e,t){if(be(t)&&(P(!this.markedToMoveExplicitToImplicit,`Already marked to move explicits`),this.markedToMoveExplicitToImplicit=t),N(e)){for(let t of e)this._removeConnection(t);return this}return this._removeConnection(e),this}isDirty(){return this.excluded.elements.size>0||this.excluded.connections.length>0}isEmpty(){return!this.isDirty()}filterForMoveToImplicits(e){return this.markedToMoveExplicitToImplicit||this.excluded.elements.size>0?e:new Set}moveDisconnectedExplicitsToImplicits(e){let t=I(new Set(this.memory.connections.flatMap(e=>[e.source,e.target])),new Set(e.connections.flatMap(e=>[e.source,e.target])));return t=L(t,e.elements),t=b(t,j(t=>e.explicits.has(t)&&!it(e.final,Ge(t))),B()),t.size>0&&(t=this.filterForMoveToImplicits(t),e.explicits=I(e.explicits,t),e.final=I(e.final,t)),e}removeElements(e){return e.elements=I(e.elements,this.excluded.elements),e.explicits=I(e.explicits,this.excluded.elements),e.final=I(e.final,this.excluded.elements),e}removeConnections(e){let t=this.excluded.connections.reduce((e,t)=>{let n=e.get(t.id);return n?e.set(t.id,n.mergeWith(t)):e.set(t.id,t),e},new Map),n=new Set;e.connections=e.connections.reduce((e,r)=>{let i=t.get(r.id);if(i){n.add(r.source),n.add(r.target);let t=r.difference(i);t.nonEmpty()&&e.push(t)}else e.push(r);return e},[]);for(let t of e.connections)n.delete(t.source),n.delete(t.target),t.boundary&&e.elements.has(t.boundary)&&n.delete(t.boundary);return n.size===0?e:(n=I(n,e.explicits),e.final=I(e.final,n),e)}precommit(e){return e}postcommit(e){return P(I(e.explicits,e.elements).size===0,`Explicits must be subset of elements`),P(I(e.final,e.elements).size===0,`Final elements must be subset of elements`),e}commit(){let e=this.precommit(this.memory.mutableState());if(this.excluded.elements.size>0){let t=e.connections.filter(e=>this.excluded.elements.has(e.source)||this.excluded.elements.has(e.target)).flatMap(t=>[t,...gt(e.connections,t).map(e=>e.intersect(t))]).filter(e=>e.nonEmpty());this.excludeConnections(t)}return this.excluded.connections.length>0&&(e=this.removeConnections(e)),this.excluded.elements.size>0&&(e=this.removeElements(e)),this.memory.update(this.postcommit(e))}},Gt=class{explicits=new Set;implicits=new Set;_ordered=new Set;_connections=[];constructor(e,t){this.memory=e,this.expression=t}get elements(){return this.explicits}get connections(){return this._connections}mergedConnections(){return dt([...this.memory.connections,...this._connections])}connectWithExisting(e,t){throw Error(`Method not implements, depends on the model`)}_addExplicit(e){this._ordered.add(e),this.explicits.add(e),this.implicits.delete(e)}addExplicit(e){if(!e)return this;if(N(e)){for(let t of e)this._addExplicit(t);return this}return this._addExplicit(e),this}_addImplicit(e){this.explicits.has(e)||(this._ordered.add(e),this.implicits.add(e))}addImplicit(e){if(!e)return this;if(N(e)){for(let t of e)this._addImplicit(t);return this}return this._addImplicit(e),this}_addConnection(e){this._connections.push(e),this._addImplicit(e.source),this._addImplicit(e.target)}addConnections(e){if(N(e)){for(let t of e)this._addConnection(t);return this}return this._addConnection(e),this}isDirty(){return this.explicits.size>0||this.implicits.size>0||this._connections.length>0}isEmpty(){return!this.isDirty()}precommit(e){return e}postcommit(e){return e}processConnections(e){return e}commit(){let e=this.precommit(this.memory.mutableState()),t=new Set;if(this._connections.length>0){let[n,r]=_e(this._connections,t=>e.final.has(t.source));e.connections=this.processConnections(dt([...e.connections,...n,...r])),t=new Set(e.connections.flatMap(e=>[e.source,e.target]))}return e.elements=z(e.elements,this._ordered,this.explicits,t,this.implicits),e.explicits=L(e.elements,z(e.explicits,this.explicits)),e.final=L(e.elements,z(e.final,this.explicits,t)),this.memory.update(this.postcommit(e))}};function Kt(e,t=`final`){let n=Je(F(t===`final`?e.final:e.elements)),r=new Set(e.connections.flatMap(e=>[e.source,e.target])),i=new Set(n),a=new ct.default(()=>null),o=n.reduce((e,t,n,r)=>(e.set(t,r.slice(n+1).filter(e=>M(t,e)).map(e=>(i.delete(e),e)).reduce((e,n)=>(e.some(e=>M(e,n))||(e.push(n),a.set(n,t)),e),[])),e),new ct.default(()=>[]));return{root:i,connected:r,hasInOut:t=>e.connections.some(V.isAnyInOut(t.id)),parent:e=>a.get(e),children:e=>o.get(e)}}var qt=class extends Wt{};function H(e){if(E.isCustom(e))return H(e.custom.expr);if(E.isWhere(e)){let t=H(e.where.expr),n=C(e.where.condition);return e=>t(e)&&n(e)}if(E.isElementKindExpr(e))return e.isEqual?t=>t.kind===e.elementKind:t=>t.kind!==e.elementKind;if(E.isElementTagExpr(e))return e.isEqual?({tags:t})=>t.includes(e.elementTag):({tags:t})=>!t.includes(e.elementTag);if(E.isWildcard(e))return()=>!0;if(E.isModelRef(e)){let t=w.flatten(e.ref);if(e.selector===`expanded`)return e=>e.id===t||Ue(e.id)===t;if(e.selector===`descendants`||e.selector===`children`){let e=t+`.`;return t=>t.id.startsWith(e)}return e=>e.id===t}R(e)}function Jt(e,t,n){let{shape:r,color:a,icon:o,...s}=e.style,c=!l(s);b(n,y(d(Be)),y(t),i(t=>{t.shape=r??t.shape,t.color=a??t.color,h(o)&&(t.icon=o),h(e.notation)&&(t.notation=e.notation),c&&(t.style={...t.style,...s})}))}function Yt(e,t){for(let n of e)!we(n)||n.targets.length===0||Jt(n,x(n.targets.map(H)),t);return t}var Xt=class e{static kind=xe;constructor(e,t,n=null,r=new Set){this.id=e,this.viewRule=t,this.parent=n,this.elements=r}isEmpty(){return this.elements.size===0}update(t){return new e(this.id,this.viewRule,this.parent,t)}clone(){return new e(this.id,this.viewRule,this.parent,new Set(this.elements))}},Zt=class extends Wt{excludeRelations(e){return b(this.memory.connections,y(t=>tt(t.relations,e)),i(t=>{this.excludeConnections(t.update(L(t.relations,e)))})),this}precommit(e){if(this.excluded.elements.size>0){let e=new Set([...this.excluded.elements].flatMap(e=>[...e.incoming(`direct`),...e.outgoing(`direct`)]));this.excludeRelations(e)}return e}postcommit(e){let t=I(this.memory.explicits,e.explicits);for(let n of t)e.explicitFirstSeenIn.delete(n);let n=I(this.memory.elements,e.elements);for(let t of n)e.lastSeenIn.delete(t);return e}},Qt=class extends Zt{constructor(e,t){super(e,t),this.memory=e,this.expression=t}};const{findConnection:$t,findConnectionsBetween:en}=Et;var tn=class extends Gt{connectWithExisting(e,t=`both`){let n=this._connections.length,r=()=>this._connections.length>n;if(!N(e)){if(t===`in`||t===`both`)for(let t of this.memory.elements)this.addConnections($t(t,e,`directed`));return(t===`out`||t===`both`)&&this.addConnections(en(e,this.memory.elements,`directed`)),r()}let i=[...e];if(t===`in`||t===`both`)for(let e of this.memory.elements)this.addConnections(en(e,i,`directed`));if(t===`out`||t===`both`)for(let e of i)this.addConnections(en(e,this.memory.elements,`directed`));return r()}addImplicitWithinScope(e){e&&(!this.memory.scope||M(this.memory.scope,e))&&this.addImplicit(e)}processConnections(e){return Se.isRelationExpr(this.expression)||b(e,i(({source:e,target:t,boundary:n})=>{b(me([...F(e.ancestors()).reverse(),e],[...F(t.ancestors()).reverse(),t]),ee(([e,t])=>e===t),de(1),i(([r,i])=>{if(r===e&&i===t){this.addImplicitWithinScope(n);return}r!==e&&this.addImplicitWithinScope(r),i!==t&&this.addImplicitWithinScope(i)}))})),e}postcommit(e){let t=I(e.explicits,this.memory.explicits);for(let n of t)e.explicitFirstSeenIn.set(n,`@root`);return e}},nn=class extends tn{constructor(e,t){super(e,t),this.memory=e,this.expression=t}postcommit(e){let t=I(e.explicits,this.memory.explicits);for(let n of t)e.explicitFirstSeenIn.set(n,this.memory.activeGroupId);for(let t of[...this.explicits,...this.implicits])e.lastSeenIn.set(t,this.memory.activeGroupId);return e}},rn=class e extends Ut{static empty(t){return new e({elements:new Set,explicits:new Set,final:new Set,connections:[],groups:[],explicitFirstSeenIn:new Map,lastSeenIn:new Map},t)}constructor(e,t){super(e),this.state=e,this.scope=t}get groups(){return this.state.groups}get explicitFirstSeenIn(){return this.state.explicitFirstSeenIn}get lastSeenIn(){return this.state.lastSeenIn}stageInclude(e){return new tn(this,e)}stageExclude(e){return new Zt(this,e)}mutableState(){return{elements:new Set(this.state.elements),explicits:new Set(this.state.explicits),final:new Set(this.state.final),connections:[...this.state.connections],groups:this.state.groups.map(e=>e.clone()),explicitFirstSeenIn:new Map(this.state.explicitFirstSeenIn),lastSeenIn:new Map(this.state.lastSeenIn)}}update(t){return new e({...this.state,...t},this.scope)}},an=class e extends rn{static enter(t,n){let r=`@gr${t.groups.length+1}`;if(t instanceof e){let i=st.default.from([...t.stack].reverse()),a=t.mutableState();return a.groups.push(new Xt(r,n,t.activeGroupId)),i.push(r),new e(a,t.scope,i)}let i=t.mutableState();i.groups.push(new Xt(r,n,null));let a=st.default.of(r);return new e(i,t.scope,a)}constructor(e,t,n){super(e,t),this.state=e,this.scope=t,this.stack=n}get activeGroupId(){return A(this.stack.peek(),`Stack must not be empty`)}mutableState(){return{...super.mutableState()}}update(t){return new e({...this.state,...t},this.scope,this.stack)}stageInclude(e){return new nn(this,e)}stageExclude(e){return new Qt(this,e)}leave(){let t=this.mutableState();return this.stack.pop(),this.stack.peek()?new e(t,this.scope,this.stack):new rn(t,this.scope)}};function on(e,t){let n;for(;e.parent&&(n=t.get(e.parent));){let t=n.depth??1;if(n.depth=Math.max(t,(e.depth??0)+1),n.depth===t)break;e=n}}function sn(e){let{id:t,title:n,...r}=g(e.$element,[`summary`,`description`,`metadata`,`style`,`tags`]),{color:i,icon:a,shape:o,...s}=e.style;return k({id:t,title:n,modelRef:t,shape:o,color:i,icon:a,style:s,description:Te(e.$element),tags:[...e.tags],...r})}function cn({defaults:e},t,n){let r=new Map,i=new Map;n?.forEach(({id:t,parent:n,viewRule:a,elements:o})=>{n&&A(r.get(n),`Parent group node ${n} not found`).children.push(t),r.set(t,{id:t,parent:n,kind:xe,title:a.title??``,color:a.color??e.group.color??e.color,shape:`rectangle`,children:[],inEdges:[],outEdges:[],level:0,depth:0,tags:[],style:k({border:a.border??e.group.border,opacity:a.opacity??e.group.opacity,size:a.size,multiple:a.multiple,padding:a.padding,textSize:a.textSize})});for(let e of o)i.set(e.id,t)}),Array.from(t).sort(Ke).forEach(({id:e,...t})=>{let n=Ue(e),a=0,o;for(;n&&(o=r.get(n),!o);)n=Ue(n);let s=t.modelRef??e;if(!o&&i.has(s)){let e=A(i.get(s));o=r.get(e),n=e}o&&(o.children.length==0&&(o.depth=1,on(o,r)),o.children.push(e),a=o.level+1);let c=k({id:e,parent:n,level:a,children:[],inEdges:[],outEdges:[],...t});r.set(e,c)});let a=new Map;return n?.forEach(({id:e})=>{a.set(e,A(r.get(e)))}),t.forEach(({id:e})=>{a.set(e,A(r.get(e)))}),a}function ln(e){let{title:t,description:n=null}=e;return{...t&&{title:t,description:n},...te(e,[`color`,`technology`,`head`,`line`,`tail`,`kind`,`navigateTo`])}}function un(e,t){let n=b(e,re((e,t)=>(f(t.title)&&!e.title.includes(t.title)&&e.title.push(t.title),f(t.description)&&!e.description.some(v(t.description))&&e.description.push(t.description),f(t.technology)&&!e.technology.includes(t.technology)&&e.technology.push(t.technology),f(t.kind)&&!e.kind.includes(t.kind)&&e.kind.push(t.kind),f(t.color)&&!e.color.includes(t.color)&&e.color.push(t.color),f(t.line)&&!e.line.includes(t.line)&&e.line.push(t.line),f(t.head)&&!e.head.includes(t.head)&&e.head.push(t.head),f(t.tail)&&!e.tail.includes(t.tail)&&e.tail.push(t.tail),f(t.navigateTo)&&!e.navigateTo.includes(t.navigateTo)&&e.navigateTo.push(t.navigateTo),t.tags&&e.tags.push(...t.tags),e),{title:[],description:[],technology:[],kind:[],head:[],tail:[],color:[],tags:[],line:[],navigateTo:[]})),r=S(n.title)??(n.title.length>1?`[...]`:void 0),i=oe(n.tags),a=k({title:r,description:S(n.description),technology:S(n.technology),kind:S(n.kind),head:S(n.head),tail:S(n.tail),color:S(n.color),line:S(n.line),navigateTo:S(n.navigateTo),...We(i)&&{tags:i}});if(t){let e=ln(t);a=ie({...a,...e},f)}return u(a.title)&&f(a.technology)&&(a.title=`[${a.technology}]`,delete a.technology),a}const{findConnection:dn,findConnectionsBetween:U,findConnectionsWithin:fn}=Ct;function W(e,t){let n=e.element(t.ref.deployment);if(n.isDeploymentNode()){if(t.selector===`children`)return[...n.children()];if(t.selector===`expanded`)return[n,...n.children()];if(t.selector===`descendants`)return[...n.descendants()]}return[n]}function pn(e,t){let n=e.$model.element(t.ref.model);return t.selector===`children`?[...n.children()]:t.selector===`expanded`?[n,...n.children()]:t.selector===`descendants`?[...n.descendants()]:[n]}function mn(e){if(T.isWildcard(e))return()=>!0;if(T.isElementTagExpr(e)||T.isElementKindExpr(e))throw Error(`element kind and tag expressions are not supported in deployment view rules`);if(T.isDeploymentRef(e)){let t=e.ref.deployment;if(e.selector===`expanded`){let e=t+`.`;return n=>n.id===t||n.id.startsWith(e)}if(e.selector===`descendants`){let e=t+`.`;return t=>t.id.startsWith(e)}return e.selector===`children`?e=>Ue(e.id)===t:e=>e.id===t}if(T.isModelRef(e)){let t=e.ref.model;if(e.selector===`expanded`){let e=t+`.`;return n=>{let r=n.modelRef??null;return r?r===t||r.startsWith(e):!0}}if(e.selector===`descendants`){let e=t+`.`;return t=>{let n=t.modelRef??null;return n?n.startsWith(e):!0}}return e.selector===`children`?e=>{let n=e.modelRef??null;return n?Ue(n)===t:!0}:e=>{let n=e.modelRef??null;return n?n===t:!0}}R(e)}function hn(e){return Te(e.$instance)??Te(e.element.$element)}function gn(e){let t=e.id,n=e.onlyOneInstance();return k({id:t,deploymentRef:t,title:e.title,kind:e.kind,technology:e.technology??void 0,links:m(e.links,1)?[...e.links]:void 0,notation:e.$node.notation??void 0,color:e.color,shape:e.shape,modelRef:n?.element.id,icon:e.style.icon,description:Te(e.$node)??void 0,tags:[...e.tags],style:g(e.style,[`icon`,`shape`,`color`])})}function _n(e){let t=e.$instance,n=e.element,{icon:r,color:i,shape:a,...o}=e.style,s=[...n.links,...t.links??[]];return k({id:e.id,kind:`instance`,title:e.title,description:hn(e)??void 0,technology:e.technology??void 0,tags:[...e.tags],links:m(s,1)?s:void 0,icon:r,color:i,shape:a,style:o,deploymentRef:t.id,modelRef:n.id,notation:t.notation})}function vn(e){return e.isInstance()?_n(e):gn(e)}function yn(e){return e.reduce((e,t)=>{let n=[...t.relations.model,...t.relations.deployment];P(m(n,1),`Edge must have at least one relation`);let r=t.source.$model.$styles.defaults,i=t.source.id,a=t.target.id,{title:o,color:s=r.relationship.color,line:c=r.relationship.line,head:l=r.relationship.arrow,...u}=un(n.map(e=>e.$relationship)),d=k({id:t.id,parent:t.boundary?.id??null,source:i,target:a,label:o??null,relations:n.map(e=>e.id),color:s,line:c,head:l,...u}),f=e.find(e=>e.source===a&&e.target===i);if(f&&d.label===f.label){f.dir=`both`;let n=f.head??d.head??t.source.$model.$styles.defaults.relationship.arrow;return f.head??=n,f.tail??=n,d.color&&(f.color??=d.color),d.line&&(f.line??=d.line),e}return e.push(d),e},[])}function bn(e,t){let n=cn(e.$styles,[...t.final].map(vn));for(let t of n.values()){if(!t.deploymentRef||!t.modelRef||t.children.length>0)continue;let n=e.deployment.element(t.deploymentRef),r=n.isDeploymentNode()&&n.onlyOneInstance();if(!r)continue;t.title===n.name&&(t.title=r.title),t.description??=hn(r)??null,t.technology??=r.technology,l(t.tags)&&(t.tags=[...r.tags]),(!t.links||l(t.links))&&m(r.links,1)&&(t.links=[...r.links]);let i=e.$styles.defaults;t.shape===i.shape&&t.shape!==r.shape&&(t.shape=r.shape,t.notation=null),t.color===i.color&&t.color!==r.color&&(t.color=r.color,t.notation=null),!t.icon&&r.icon&&(t.icon=r.icon)}return n}function xn(e,t){for(let n of e)!we(n)||n.targets.length===0||Jt(n,x(n.targets.map(mn)),t);return t}function Sn(e){let t=new ct.default(()=>[]);for(let n of e)for(let e of n.relations.model)t.get(e).push(n);let n=new ct.default(()=>new Set);for(let[e,r]of t)m(r,2)&&b(r,c(e=>[{group:`$source-${e.source.id}`,conn:e},{group:`$target-${e.target.id}`,conn:e}]),a(ce(`group`)),pe(),y(m(2)),i(ae(_(ce(`conn`)),mt(`desc`),ee((e,t,n)=>t===0||e.boundary===n[t-1].boundary),i(t=>{n.get(t).add(e)}))));return n}function Cn(e){e=dt(e);let t=Sn(e);for(let n of e){let{source:e,target:r}=n,i=n.relations.model;if(e.isDeploymentNode()!==r.isDeploymentNode()){let r=e.isDeploymentNode()?e:n.target;P(r.isDeploymentNode());let a=L(i,r.internalModelRelationships());for(let e of a)t.get(n).add(e);continue}if(e.isDeploymentNode()&&r.isDeploymentNode()){let i=z(L(n.relations.model,e.internalModelRelationships()),L(n.relations.model,r.internalModelRelationships()));for(let e of i)t.get(n).add(e)}}return b(t.entries(),rt(([e,t])=>e.update({model:t,deployment:null})),F())}function wn(e){return bt(e,Cn(e))}function Tn(e){return b(e,dt,re((t,n)=>{let{source:r,target:i,relations:a}=n;if(r.isInstance()&&i.isInstance())return t;let o=Dt.empty();if(r.isDeploymentNode()&&i.isDeploymentNode()){let[e]=dn(i,r,`directed`);e&&(o=a.intersect(e.relations))}for(let t of e)ht(t,n)&&(o=o.union(a.intersect(t.relations)));return o.nonEmpty&&t.push(new lt(r,i,o)),t},[]))}function En(e){return bt(e,Tn(e))}var Dn=class extends Gt{connectWithExisting(e,t=`both`){let n=this._connections.length,r=()=>this._connections.length>n;if(!N(e)){if(t===`in`||t===`both`)for(let t of this.memory.elements)this.addConnections(dn(t,e,`directed`));return(t===`out`||t===`both`)&&this.addConnections(U(e,this.memory.elements,`directed`)),r()}let i=[...e];if(t===`in`||t===`both`)for(let e of this.memory.elements)this.addConnections(U(e,i,`directed`));if(t===`out`||t===`both`)for(let e of i)this.addConnections(U(e,this.memory.elements,`directed`));return r()}processConnections(e){let t=b(e,wn,En);return b(t,i(({source:e,target:t,boundary:n})=>{b(me([...F(e.ancestors()).reverse(),e],[...F(t.ancestors()).reverse(),t]),ee(([e,t])=>e===t),de(1),i(([r,i])=>{if(e===r&&t===i){this.addImplicit(n);return}r!==e&&r.isDeploymentNode()&&!r.onlyOneInstance()&&this.addImplicit(r),i!==t&&i.isDeploymentNode()&&!i.onlyOneInstance()&&this.addImplicit(i)}))})),t}},On=class e extends Ut{static empty(){return new e({elements:new Set,explicits:new Set,final:new Set,connections:[]})}stageInclude(e){return new Dn(this,e)}stageExclude(e){return new qt(this,e)}mutableState(){return{elements:new Set(this.state.elements),explicits:new Set(this.state.explicits),final:new Set(this.state.final),connections:[...this.state.connections]}}update(t){return new e({...this.state,...t})}equals(t){return t instanceof e&&v(this.state,t.state)}diff(e){return{added:{elements:F(I(e.elements,this.elements)),explicits:F(I(e.explicits,this.explicits)),final:F(I(e.final,this.final)),connections:F(bt(e.connections,this.connections))},removed:{elements:F(I(this.elements,e.elements)),explicits:F(I(this.explicits,e.explicits)),final:F(I(this.final,e.final)),connections:bt(this.connections,e.connections)}}}toString(){return[`final:`,...[...this.final].map(e=>` `+e.id),`connections:`,...this.connections.map(e=>` `+e.expression)].join(`
2
- `)}[St](e,t,n){return this.toString()}};const kn={include:({expr:e,model:t,memory:n,stage:r})=>{let i=C(e.where.condition);return Vn(`include`,{expr:e.where.expr,model:t,stage:r,memory:n,where:i})},exclude:({expr:e,model:t,memory:n,stage:r})=>{let i=C(e.where.condition);return Vn(`exclude`,{expr:e.where.expr,model:t,stage:r,memory:n,where:i})}},An={include:({expr:e,model:t,memory:n,stage:r,where:i})=>{let a=[...n.elements];if(T.isWildcard(e.incoming)){for(let e of a){if(e.allOutgoing.isEmpty)continue;let t=K(U(e,[...Kn(e)],`directed`),i);r.addConnections(t)}return r}P(T.isDeploymentRef(e.incoming),`Only deployment refs are supported in include`);let o=W(t,e.incoming);for(let e of a){let t=K(U(e,o,`directed`),i);r.addConnections(t)}return r},exclude:({expr:e,model:t,memory:n,stage:r,where:i})=>{if(T.isElementTagExpr(e.incoming)||T.isElementKindExpr(e.incoming))throw Error(`element kind and tag expressions are not supported in exclude`);if(T.isModelRef(e.incoming))return G(Mn(t,e.incoming),{stage:r,memory:n},i);if(T.isWildcard(e.incoming))return r;let a=jn(W(t,e.incoming)),o=b(n.connections,y(a),K(i));return r.excludeConnections(o),r}};function jn(e){return x(e.map(e=>{let t=t=>t===e||M(e,t);return e=>!t(e.source)&&t(e.target)}))}function Mn(e,t){let n=pn(e,t);return new Set(n.flatMap(e=>[...e.allIncoming]))}const Nn={include:({expr:e,model:t,memory:n,stage:r,where:i})=>{let a=[...n.elements];if(T.isWildcard(e.outgoing)){for(let e of a)if(!e.allIncoming.isEmpty)for(let t of Kn(e)){let n=K(dn(t,e,`directed`),i);r.addConnections(n)}return r}P(T.isDeploymentRef(e.outgoing),`Only deployment refs are supported in include`);let o=W(t,e.outgoing);for(let e of o){let t=K(U(e,a,`directed`),i);r.addConnections(t)}return r},exclude:({expr:e,model:t,memory:n,stage:r,where:i})=>{if(T.isElementTagExpr(e.outgoing)||T.isElementKindExpr(e.outgoing))throw Error(`element kind and tag expressions are not supported in exclude`);if(T.isModelRef(e.outgoing))return G(Fn(t,e.outgoing),{stage:r,memory:n},i);if(T.isWildcard(e.outgoing))return r;let a=Pn(W(t,e.outgoing)),o=b(n.connections,y(a),K(i));return r.excludeConnections(o),r}};function Pn(e){return x(e.map(e=>{let t=t=>t===e||M(e,t);return e=>t(e.source)&&!t(e.target)}))}function Fn(e,t){let n=pn(e,t);return new Set(n.flatMap(e=>[...e.allOutgoing]))}const In={include:({expr:{source:e,target:t,isBidirectional:n=!1},model:r,stage:i,where:a})=>{if(T.isElementTagExpr(e)||T.isElementKindExpr(e)||T.isElementTagExpr(t)||T.isElementKindExpr(t))throw Error(`element kind and tag expressions are not supported in include`);P(!T.isModelRef(e),`Invalid source model ref in direct relation`),P(!T.isModelRef(t),`Invalid target model ref in direct relation`);let o=T.isWildcard(e),s=T.isWildcard(t),l=n?`both`:`directed`,u;switch(!0){case o&&s:u=b(fn(r.instances()),K(a),_(e=>(i.addImplicit(e.boundary),e)));break;case!o&&s:{let t=W(r,e),i=Pn(t),o=i;if(n){let e=jn(t);o=t=>i(t)!==e(t)}u=b(t,c(e=>U(e,Kn(e),l)),y(o),K(a));break}case o&&!s:{let e=W(r,t),i=jn(e),o=i;if(n){let t=Pn(e);o=e=>t(e)!==i(e)}u=b(e,c(e=>[...Kn(e)].flatMap(t=>dn(t,e,l))),y(o),K(a));break}default:{P(!o,`Inference failed - source should be a deployment ref`),P(!s,`Inference failed - target should be a deployment ref`);let n=W(r,e),i=W(r,t),d=Pn(n),f=jn(i);u=b(n,c(e=>U(e,i,l)),y(e=>d(e)&&f(e)),K(a))}}return i.addConnections(u),T.isDeploymentRef(e)&&p(e.selector)&&i.addImplicit(r.element(e.ref.deployment)),T.isDeploymentRef(t)&&p(t.selector)&&i.addImplicit(r.element(t.ref.deployment)),i},exclude:({expr:e,model:t,memory:n,stage:r,where:i})=>{let a=mn(e.target),o=mn(e.source),s;switch(!0){case T.isWildcard(e.source)&&T.isWildcard(e.target):return r.excludeConnections(K(n.connections,i)),r;case T.isModelRef(e.source)&&T.isModelRef(e.target):return s=Ln({source:e.source,target:e.target,expr:e,model:t}),G(s,{stage:r,memory:n},i);case T.isModelRef(e.source)&&T.isWildcard(e.target):return s=Fn(t,e.source),G(s,{stage:r,memory:n},i);case T.isModelRef(e.source):return s=Fn(t,e.source),G(s,{stage:r,memory:n},i,e=>a(e.target));case T.isModelRef(e.target):return s=Mn(t,e.target),G(s,{stage:r,memory:n},i,e=>o(e.source));default:let c=t=>o(t.source)&&a(t.target)||e.isBidirectional===!0&&o(t.target)&&a(t.source),l=b(n.connections,y(c),K(i));return l.length===0||r.excludeConnections(l),r}}};function Ln({source:e,target:t,expr:n,model:r}){let i=pn(r,e),a=pn(r,t),o=n.isBidirectional?`both`:`directed`,s=[];for(let e of i)s.push(...yt(e,a,o));return new Set(s.flatMap(e=>[...e.relations]))}const Rn={include:({expr:e,model:t,memory:n,stage:r,where:i})=>{let a=[...n.elements];if(T.isWildcard(e.inout)){for(let e of a){let t=Un(U(e,[...Kn(e)],`both`),i);r.addConnections(t)}return r}P(T.isDeploymentRef(e.inout),`Only deployment refs are supported in include`);let o=W(t,e.inout);for(let e of a){let t=Un(U(e,o,`both`),i);r.addConnections(t)}return r},exclude:({expr:e,model:t,memory:n,stage:r,where:i})=>{if(T.isElementTagExpr(e.inout)||T.isElementKindExpr(e.inout))throw Error(`element kind and tag expressions are not supported in exclude`);if(T.isModelRef(e.inout)){let a=pn(t,e.inout);return a.length===0?r:G(z(new Set,...a.flatMap(e=>[e.allIncoming,e.allOutgoing])),{stage:r,memory:n},i)}if(T.isWildcard(e.inout))return r;let a=W(t,e.inout),o=jn(a),s=Pn(a),c=b(n.connections,y(e=>o(e)!==s(e)),K(i));return r.excludeConnections(c),r}},zn={include:({expr:e,model:t,memory:n,stage:r})=>{let i=C(e.where.condition);return Vn(`include`,{expr:e.where.expr,model:t,stage:r,memory:n,where:i})},exclude:({expr:e,model:t,memory:n,stage:r})=>{let i=C(e.where.condition);return Vn(`exclude`,{expr:e.where.expr,model:t,stage:r,memory:n,where:i})}},Bn={include:({model:e,stage:t,where:n})=>{let r=[],i=b([...e.roots()],q(n),_(e=>(e.onlyOneInstance()||r.push(...e.children()),e)));return t.addExplicit(i),r.length>1&&t.addConnections(fn([...i,...r])),t},exclude:({stage:e,memory:t,where:n})=>{let r=b([...t.elements],q(n));return e.exclude(r),e}};function Vn(e,{expr:t,where:n,...r}){switch(!0){case T.isElementTagExpr(t):case T.isElementKindExpr(t):throw Error(`element kind and tag expressions are not supported in deployment view rules`);case O.isCustom(t):case T.isCustom(t):case T.isModelRef(t):return;case T.isWhere(t):return kn[e]({...r,expr:t,where:n});case O.isWhere(t):return zn[e]({...r,expr:t,where:n});case T.isDeploymentRef(t):return qn[e]({...r,expr:t,where:n});case T.isWildcard(t):return Bn[e]({...r,expr:t,where:n});case O.isDirect(t):return In[e]({...r,expr:t,where:n});case O.isInOut(t):return Rn[e]({...r,expr:t,where:n});case O.isOutgoing(t):return Nn[e]({...r,expr:t,where:n});case O.isIncoming(t):return An[e]({...r,expr:t,where:n});default:R(t)}}function G(e,{stage:t,memory:n},r,i=()=>!0){if(e.size===0)return t;let a=b(n.connections,y(e=>i(e)),y(t=>tt(t.relations.model,e)),_(t=>t.update({deployment:null,model:L(t.relations.model,e)})),K(r),y(e=>e.nonEmpty()));return a.length===0?t:t.excludeConnections(a)}function Hn(e,t){return K(e,t).nonEmpty()}function K(...e){if(e.length===1)return t=>K(t,e[0]);let[n,r]=e;return r===null?n:t(n)?n.map(e=>K(e,r)).filter(e=>e.nonEmpty()):n.update({model:new Set([...n.relations.model.values()].filter(e=>r(Gn(n)(e)))),deployment:new Set([...n.relations.deployment.values()].filter(e=>r(Gn(n)(e))))})}function q(...e){if(e.length===1)return t=>q(t,e[0]);let[n,r]=e;return t(n)?n.filter(e=>q(e,r)):r?.(Wn(n,n))??!0}function Un(e,t){return t?b(e,y(e=>Hn(e,t))):e}function Wn(e,t){if(Tt(e)){let n=wt(t)&&kt(t)?t:null;return{kind:e.kind,tags:[...e.tags,...n?.tags??[]]}}if(_t(e))return te(e.element,[`tags`,`kind`]);if(kt(e))return{kind:e.element.kind,tags:[...e.tags,...e.element.tags]};if(Ot(e))return te(e,[`tags`,`kind`]);R(e)}function Gn(e){return t=>({tags:t.tags,kind:t.kind,source:Wn(t.source,e.source),target:Wn(t.target,e.target)})}function Kn(e){let t=new Set;for(let n of e.descendingSiblings())t.add(n);return t}const qn={include:e=>{let{expr:t,where:n}=e,r=e.model.element(t.ref.deployment);if(kt(r))return q(r,n)&&(e.stage.addExplicit(r),e.stage.connectWithExisting(r)),e.stage;switch(!0){case t.selector===`expanded`:Yn(r,e);break;case t.selector===`children`:Jn(r,e);break;case t.selector===`descendants`:Xn(r,e);break;default:q(r,n)&&(e.stage.addExplicit(r),e.stage.connectWithExisting(r))}return e.stage},exclude:({expr:e,stage:t,memory:n,where:r})=>{let i=mn(e),a=b([...n.elements],y(i),q(r));return t.exclude(a),t}};function Jn(e,{stage:t,where:n}){let r=q([...e.children()],n);r.length!==0&&(t.addImplicit(e),t.addConnections(fn(r)),t.connectWithExisting(r),t.addExplicit(r))}function Yn(e,{memory:t,stage:n,where:r}){n.addImplicit(e),n.connectWithExisting(e);let i=q([...e.children()],r),a=!1;for(let e of i)if(U(e,t.elements).length>0){a=!0;break}a&&(n.connectWithExisting(i,`in`),n.addConnections(fn(i)),n.connectWithExisting(i,`out`)),n.addImplicit(i),n.connections.length>0&&n.addExplicit(e)}function Xn(e,{stage:t,where:n}){let r=e=>{let i=[];for(let t of e.children())t.isDeploymentNode()&&i.push(...r(t)),q(t,n)&&i.push(t);return t.connectWithExisting(i,`in`),t.addConnections(fn(i)),t.addImplicit(i),i},a=r(e);if(a.length===0)return;t.connectWithExisting(a,`out`);let o=Zn(t);b(a,y(e=>o.has(e)),i(e=>t.addExplicit(e)))}function Zn(e){return b(e.mergedConnections(),wn,En,re((e,t)=>(e.add(t.source),e.add(t.target),e),new Set))}var Qn=class e{static for(t){return new e(t)}constructor(e){this.memory=e}step1CleanConnections(e){if(e.connections.length<2)return e;let t=b(e.connections,wn,En),n=bt(e.connections,t);if(n.length===0)return e;let r=e.stageExclude({});return r.excludeConnections(n,!0),r.commit()}step2ProcessImplicits(e){let t=z(this.memory.elements,e.elements),n=z(e.final,this.memory.explicits),r=new ct.default(()=>new Set);for(let t of e.connections)if(t.boundary)for(let e of t.relations.model)r.get(e).add(t.boundary);for(let[e,i]of r)if(!(i.size<2))for(let e of i)t.delete(e)&&n.add(e);let a=new Set(n),o=e=>{for(let t of a)if(e===t||M(e,t))return!0;return!1};return b(I(t,a),j(e=>e.isDeploymentNode()),F(),Ye,i(e=>{let t=[...e.children()].filter(o).length;if(t>=2){n.add(e);return}t===1&&it(e.siblings(),o)&&n.add(e)})),e.update({final:n})}step3ProcessBoundaries(e){let t=new Set;for(let n of e.connections)n.boundary&&t.add(n.boundary);let n=Kt(e,`final`),r=e.stageExclude({}),i=r=>!(t.has(r)||e.explicits.has(r)||n.hasInOut(r)||n.root.has(r)),a=S([...n.root]);a&&!e.explicits.has(a)&&r.exclude(a);for(let t of e.final){let e=S(n.children(t));e&&!n.hasInOut(e)&&i(t)&&r.exclude(t)}return r.isDirty()?r.commit():e}commit(){let e=this.step1CleanConnections(this.memory),t=this.step2ProcessImplicits(e);return this.step3ProcessBoundaries(t)}};function $n(e,t){let n=On.empty();for(let r of t)if(Ve(r)){let t=`include`in r?`include`:`exclude`,i=r.include??r.exclude;for(let r of i){let i=t===`include`?n.stageInclude(r):n.stageExclude(r);i=Vn(t,{expr:r,model:e,stage:i,memory:n,where:null})??i,n=i.commit()}}return Qn.for(n).commit()}function er(e,{docUri:t,rules:n,...r}){let i=$n(e.deployment,n),a=bn(e,i),o=yn(i.connections);It(a,o);let c=Vt({nodes:a,edges:o}),l=xn(n,c.nodes),u=s(n,Me),d=Nt(l);return Ht({...r,[Ae]:`computed`,[Ce]:`deployment`,autoLayout:{direction:u?.direction??`TB`,...u?.nodeSep&&{nodeSep:u.nodeSep},...u?.rankSep&&{rankSep:u.rankSep}},edges:c.edges,nodes:_(l,e=>(e.icon===`none`&&delete e.icon,e)),...d.length>0&&{notation:{nodes:d}}})}function tr(e){return t=>Pe(t)?t.groupRules.flatMap(tr(e)):Ve(t)&&`include`in t?t.include.filter(e):[]}function nr(e,t){let n=e.flatMap(tr(E.isCustom));if(n.length===0)return t;let r=[...t];for(let{custom:{expr:e,...t}}of n){let{border:n,opacity:i,multiple:a,iconColor:s,iconSize:c,iconPosition:l,padding:d,size:f,textSize:p,...m}=ye(t,u),h=k({border:n,opacity:i,multiple:a,iconColor:s,iconSize:c,iconPosition:l,padding:d,size:f,textSize:p}),g=!o(h),_=!o(m),v=H(e);r.forEach((e,t)=>{Be(e)||!v(e)||(_&&(e={...e,...m,isCustomized:!0}),g&&(e={...e,isCustomized:!0,style:{...e.style,...h}}),r[t]=e)})}return r}function rr(e,t){return e.reduce((e,n)=>{if(ze(n)){let r=t.predicates[n.predicateId];return u(r)?e:e.concat(r)}if(De(n)){let r=t.styles[n.styleId];return u(r)?e:e.concat(r)}return e.push(n),e},[])}function ir(e,t){return e.reduce((e,n)=>{if(ze(n)){let r=t.dynamicPredicates[n.predicateId];return u(r)?e:e.concat(r)}if(De(n)){let r=t.styles[n.styleId];return u(r)?e:e.concat(r)}return e.push(n),e},[])}function ar(e,t){let n=new Set;for(let r of t)if(Ve(r))for(let t of r.include){let r=H(t);for(let t of e.elements())r(t)&&n.add(t)}return n}const or=e=>{if(Fe(e)){let t=[],n=[];for(let r of e.__parallel)if(Re(r)){let[e,...i]=r.__series;t.push(e),n.push(...i)}else t.push(r);return[...t,...n]}return Re(e)?[...e.__series]:e};function sr(e,t){let n=[],r=(...[e,t])=>{if(!n.includes(e)){let r=n.indexOf(t);if(r>0){n.splice(r,0,e);return}else n.push(e)}n.includes(t)||n.push(t)};for(let i of c(t,or)){let t=e.element(i.source),a=e.element(i.target),o=n.indexOf(t),s=n.indexOf(a);o>=0&&s>=0||(i.isBackward?r(a,t):r(t,a))}return new Set(n)}function cr(e,t,n){let r=vt(e,t,`directed`).flatMap(e=>[...e.relations]).sort(Ze);if(!We(r))return{};if(r.length===1){let e=r[0];return k({title:e.title??void 0,kind:e.kind??void 0,tags:e.tags,relations:[e.id],navigateTo:e.$relationship.navigateTo,color:e.$relationship.color,line:e.$relationship.line,technology:e.technology??void 0,description:e.$relationship.description??void 0})}let i=b(r,c(e=>e.tags),oe()),a=m(i,1)?i:void 0,o=_(r,e=>e.id),s=fe(r).$relationship.navigateTo;s===n&&(s=void 0),s||=b(r,c(e=>e.$relationship.navigateTo&&e.$relationship.navigateTo!==n?e.$relationship.navigateTo:[]),oe(),S());let l=b(r,re((e,{title:t,technology:n,$relationship:r})=>(f(t)&&e.title.add(t),f(r.color)&&e.color.add(r.color),f(r.line)&&e.line.add(r.line),f(r.kind)&&e.kind.add(r.kind),f(n)&&e.technology.add(n),f(r.description)&&!e.description.some(v(r.description))&&e.description.push(r.description),e),{kind:new Set,color:new Set,line:new Set,title:new Set,technology:new Set,description:[]}));return k({tags:a??void 0,relations:o,navigateTo:s,kind:S([...l.kind]),title:S([...l.title]),color:S([...l.color]),line:S([...l.line]),technology:S([...l.technology]),description:S(l.description)})}var lr=class{steps=[];constructor(e,t){this.model=e,this.view=t}compute(){let{docUri:e,rules:t,steps:n,...r}=this.view,i=ir(t,this.model.globals),a=ar(this.model,i),o=sr(this.model,n),c=b(z(L(a,o),o,a),F(),Je),l=c.reduce((e,t,n,r)=>{for(let i=n+1;i<r.length;i++){let n=r[i];if(M(t,n)){e.push(t);break}}return e},[]),u=(e,t,n)=>{if(Re(e)){for(let r of e.__series)t=u(r,t,n);return t}let r=n?Ne(n,t):Ne(t),{source:i,target:a,title:o,isBackward:s,navigateTo:d,notation:p,...m}=e,h=this.model.element(i),g=c.indexOf(h);P(g>=0,`Source ${i} not found`);let _=this.model.element(a),v=c.indexOf(_);P(v>=0,`Target ${a} not found`),(l.includes(h)||l.includes(_))&&console.error(`Step ${h.id} -> ${_.id} because it involves a compound`);let{title:y,relations:ee,navigateTo:te,...ne}=cr(h,_,this.view.id),re=f(d)&&d!==this.view.id?d:te,b=e.kind&&!e.technology?this.model.specification.relationships[e.kind]?.technology:void 0;return this.steps.push(k({...ne,...m,...b&&{technology:b},id:r,source:h,target:_,navigateTo:re,title:o??y,relations:ee??[],isBackward:g>v})),t+1},d=1;for(let e of n){if(Fe(e)){let t=1;for(let n of e.__parallel)t=u(n,t,d);d++;continue}d=u(e,d)}let p=cn(this.model.$styles,c.map(sn)),m=this.model.$styles.defaults.relationship,h=this.steps.map(({id:e,source:t,target:n,relations:r,title:i,isBackward:a,tags:o,...s})=>{let c=A(p.get(t.id),`Source node ${t.id} not found`),l=A(p.get(n.id),`Target node ${n.id} not found`),u={id:e,parent:et(t.id,n.id),source:c.id,target:l.id,label:i??null,relations:r,color:m.color,line:m.line,head:m.arrow,tags:o??[],...s};for(a&&(u.dir=`back`);u.parent&&!p.has(u.parent);)u.parent=Ue(u.parent);c.outEdges.push(u.id),l.inEdges.push(u.id);for(let e of He(u.source)){if(e===u.parent)break;p.get(e)?.outEdges.push(u.id)}for(let e of He(u.target)){if(e===u.parent)break;p.get(e)?.inEdges.push(u.id)}return u}),g=nr(i,Yt(i,c.map(e=>A(p.get(e.id))))),v=s(i,Me),y=Nt(g);return Ht({...r,[Ce]:`dynamic`,[Ae]:`computed`,variant:r.variant??`diagram`,autoLayout:{direction:v?.direction??`LR`,...v?.nodeSep&&{nodeSep:v.nodeSep},...v?.rankSep&&{rankSep:v.rankSep}},nodes:_(g,e=>(e.icon===`none`&&delete e.icon,e)),edges:h,...y.length>0&&{notation:{nodes:y}}})}};function ur(e,t){return new lr(e,t).compute()}function dr(e){switch(!0){case D.isCustom(e):return dr(e.customRelation.expr);case D.isWhere(e):{let t=dr(e.where.expr),n=C(e.where.condition);return e=>t(e)&&n({source:{tags:e.source.tags,kind:e.source.kind},target:{tags:e.target.tags,kind:e.target.kind},...e.tags&&{tags:e.tags},...e.kind&&{kind:e.kind}})}case D.isDirect(e):{let t=H(e.source),n=H(e.target);return r=>t(r.source)&&n(r.target)||!!e.isBidirectional&&t(r.target)&&n(r.source)}case D.isInOut(e):{let t=H(e.inout);return e=>t(e.source)||t(e.target)}case D.isIncoming(e):{let t=H(e.incoming);return e=>t(e.target)}case D.isOutgoing(e):{let t=H(e.outgoing);return e=>t(e.source)}default:R(e)}}function fr(e,t,n){let r=e.flatMap(tr(D.isCustom)),i=Array.from(n);if(r.length===0||i.length===0)return i;for(let{customRelation:{expr:e,title:n,description:a,notes:o,...s}}of r){let r=a?{description:Oe(a)}:{},c=o?{notes:Oe(o)}:{},l=ye(s,u),d=dr(e);i.forEach((e,a)=>{let o,s;for(let n of t)if(n.id===e.source&&(o=n),n.id===e.target&&(s=n),o&&s)break;!o||!s||d({source:o,target:s,...te(e,[`kind`,`tags`])})&&(i[a]={...e,...l,...r,...c,label:n??e.label,isCustomized:!0})})}return i}function pr(e){return b([...e],dt,re((e,t,n,r)=>{let i=Mt(r,t),a=z(...i.map(ce(`relations`))),o=L(t.relations,a);if(i.length>0&&(o=z(o,t.directRelations)),At(r,t.reversed())&&(o=z(o,t.directRelations)),o.size<t.relations.size){let e=r.some(ut(t.source)),n=r.some(ut(t.target));e&&(o=z(o,B(j(t.relations,ft(t.source))))),n&&(o=z(o,B(j(t.relations,jt(t.target)))))}return o.size>0&&e.push(t.update(o)),e},[]))}var mr=class e{static for(t){return new e(t)}constructor(e){this.memory=e}step1CleanConnections(e){if(e.connections.length<2)return e;let t=pr(e.connections);if(t.length===0)return e;let n=e.stageExclude({});return n.excludeConnections(t,!0),n.commit()}step2ProcessImplicits(e){let t=z(this.memory.elements,e.elements),n=z(e.final,this.memory.explicits),r=new Set(n),a=e=>{for(let t of r)if(e===t||M(e,t))return!0;return!1};return b(I(t,r),F(),Ye,i(e=>{let t=[...e.children()].filter(a).length;if(t>=2){n.add(e);return}t===1&&it(e.siblings(),a)&&n.add(e)})),e.update({final:n})}step3ProcessBoundaries(e){let t=new Set;for(let n of e.connections)n.boundary&&n.boundary!==n.source&&n.boundary!==n.target&&t.add(n.boundary);let n=Kt(e,`final`),r=e.stageExclude({}),i=r=>!(t.has(r)||e.explicits.has(r)||n.hasInOut(r)||n.root.has(r)),a=S([...n.root]);a&&!e.explicits.has(a)&&r.exclude(a);for(let t of e.final){let e=S(n.children(t));e&&!n.hasInOut(e)&&i(t)&&r.exclude(t)}return r.isDirty()?r.commit():e}commit(){let e=this.step1CleanConnections(this.memory),t=this.step2ProcessImplicits(e);return this.step3ProcessBoundaries(t)}};const{findConnection:hr,findConnectionsBetween:J,findConnectionsWithin:Y}=Et;function X(e,t){switch(!0){case E.isElementKindExpr(t):return[...j(e.elements(),e=>t.isEqual===(e.kind===t.elementKind))];case E.isElementTagExpr(t):return[...j(e.elements(),e=>t.isEqual===e.tags.includes(t.elementTag))];case t.selector===`expanded`:{let n=e.element(w.flatten(t.ref));return[n,...n.children()]}case t.selector===`children`:case t.selector===`descendants`:{let n=e.element(w.flatten(t.ref)),r=t.selector===`children`?F(n.children()):F(n.descendants());return r&&r.length>0?r:[n]}case E.isModelRef(t):return[e.element(w.flatten(t.ref))];default:R(t)}}function gr(e,t){if(t.isEmpty()||e.length===0)return e;let n=x(e.map(e=>Ge(e))),r=F(j(t.elements,t=>!e.includes(t)&&n(t)));return[...e,...r]}function _r(e,{memory:t,model:n}){let r=X(n,e);return E.isModelRef(e)?e.selector===`descendants`?r:gr(r,t):r}const vr={include:({expr:e,model:t,stage:n,where:r})=>{let i=t.element(w.flatten(e.ref));r(i)&&(n.addExplicit(i),n.connectWithExisting(i));let a=[...i.children()].filter(r),o=[];for(let e of a)n.addImplicit(e),n.connectWithExisting(e)&&o.push(e);return n.addConnections(Y(o)),n},exclude:({expr:e,model:t,stage:n,filterWhere:r})=>{let i=r(X(t,e));return n.exclude(i),n}},yr={include:({expr:e,model:t,stage:n,filterWhere:r})=>{let i=r(X(t,e));if(i.length!==0)return n.addExplicit(i),n.connectWithExisting(i),n.addConnections(Y(i)),n},exclude:({expr:e,model:t,stage:n,filterWhere:r})=>{let i=r(X(t,e));return n.exclude(i),n}},br={include:({expr:e,model:t,stage:n,filterWhere:r})=>{let i=r(X(t,e));if(i.length!==0)return n.addExplicit(i),n.connectWithExisting(i),n.addConnections(Y(i)),n},exclude:({expr:e,model:t,stage:n,filterWhere:r})=>{let i=r(X(t,e));return n.exclude(i),n}},xr=()=>!0,Sr=e=>e;function Cr(e){return e.reduce((e,t)=>{let n=[...t.relations];P(m(n,1),`Edge must have at least one relation`);let r=t.source.$model.$styles.defaults,i=t.source.id,a=t.target.id,{title:o,color:s=r.relationship.color,line:c=r.relationship.line,head:l=r.relationship.arrow,...u}=un(n.map(e=>e.$relationship),S(y(n,e=>e.source.id===i&&e.target.id===a))?.$relationship),d=k({id:t.id,parent:t.boundary?.id??null,source:i,target:a,label:o??null,relations:n.map(e=>e.id),color:s,line:c,head:l,...u});return e.push(d),e},[])}function wr(e,t){return cn(e.$styles,[...t.final].map(sn),t.groups)}const Z=E.isWildcard,Tr=(e,t)=>e.isAncestorOf(t)||e.isDescendantOf(t),Er={include:({expr:{source:e,target:t,isBidirectional:n=!1},memory:r,model:i,stage:a,where:o,filterWhere:s})=>{let l=Z(e),u=Z(t),d=[];switch(!0){case l&&u&&r.isEmpty()&&o!==xr:{let e=b(i.relationships(),j(o),F(),_(e=>new xt(e.source,e.target,new Set([e]))));return a.addConnections(e),a}case l&&u&&!r.isEmpty()&&o!==xr:d.push(...Y(r.elements));break;case l&&u:d.push(...Y(i.roots()));break;case!l&&u&&o!==xr:{let t=b(X(i,e),c(e=>b(e,le(he(n===!0),{onTrue:e=>z(e.allIncoming,e.allOutgoing),onFalse:e=>e.allOutgoing}),j(o),Qe(),F(),_e(t=>t.source===e),([t,n])=>ue(b(t,y(t=>!Tr(e,t.target)),_(t=>new xt(e,t.target,new Set([t])))),b(n,y(t=>!Tr(e,t.source)),_(t=>new xt(t.source,e,new Set([t]))))))));return a.addConnections(t),a}case!l&&u:{let[t,a]=Dr(e,{memory:r,model:i}),o=n?`both`:`directed`;for(let e of t)d.push(...J(e,a,o));break}case l&&!u&&o!==xr:{let e=b(X(i,t),c(e=>b(e,le(he(n===!0),{onTrue:e=>z(e.allIncoming,e.allOutgoing),onFalse:e=>e.allIncoming}),j(o),F(),_e(t=>t.target===e),([t,n])=>ue(b(n,y(t=>!Tr(e,t.target)),_(t=>new xt(e,t.target,new Set([t])))),b(t,y(t=>!Tr(e,t.source)),_(t=>new xt(t.source,e,new Set([t]))))))));return a.addConnections(e),a}case l&&!u:{let[e,a]=Dr(t,{memory:r,model:i}),o=n?`both`:`directed`;for(let t of a)d.push(...J(t,e,o));break}default:{P(!Z(e),`Inference failed - source must be not a wildcard`),P(!Z(t),`Inference failed - target must be not a wildcard`);let a=_r(e,{memory:r,model:i}),o=_r(t,{memory:r,model:i}),s=n?`both`:`directed`;for(let e of a)d.push(...J(e,o,s))}}return a.addConnections(s(d)),a},exclude:({expr:{source:e,target:t,isBidirectional:n},model:r,memory:i,stage:a,where:o})=>{let s=Z(e),l=Z(t),u;switch(!0){case s&&l:u=b(i.connections,c(ae(ce(`relations`),j(o),F())),B());break;case!s&&l:u=b(X(r,e),c(e=>b(e,le(he(n===!0),{onTrue:e=>z(e.allIncoming,e.allOutgoing),onFalse:e=>e.allOutgoing}),j(o),F())),B());break;case s&&!l:u=b(X(r,t),c(e=>b(e,le(he(n===!0),{onTrue:e=>z(e.allIncoming,e.allOutgoing),onFalse:e=>e.allIncoming}),j(o),F())),B());break;default:{P(!Z(e),`Inference failed - source must be not a wildcard`),P(!Z(t),`Inference failed - target must be not a wildcard`);let i=X(r,e),a=X(r,t),s=new Set;for(let e of i)for(let t of a)qe(e,t)||(s=z(s,L(e.allOutgoing,t.allIncoming),n?L(t.allOutgoing,e.allIncoming):new Set));u=B(j(s,o))}}return a.excludeRelations(u),a}};function Dr(e,{memory:t,model:n}){let r=X(n,e);if(!m(r,1))return[[],[]];if(E.isModelRef(e)){let i=F(n.element(w.flatten(e.ref)).ascendingSiblings());return[gr(r,t),gr(i,t)]}return[r,b(r,_(e=>e.ascendingSiblings()),nt(),Qe(),F(),e=>gr(e,t))]}const Or={include:({expr:e,scope:t,model:n,memory:r,stage:i,filterWhere:a})=>{let o=e.incoming,s=[];if(E.isWildcard(o)){if(!t)return;for(let e of t.ascendingSiblings())s.push(...hr(e,t,`directed`))}else{let e=_r(o,{memory:r,model:n}),t=[...r.elements];t.length===0&&t.push(...oe(e.flatMap(e=>[...e.ascendingSiblings()])));let i=kr(n,o);for(let n of t)s.push(...J(n,e,`directed`).filter(i))}return i.addConnections(a(s)),i},exclude:({expr:{incoming:e},model:t,scope:n,stage:r,where:i})=>{let a=[];if(E.isWildcard(e)){if(!n)return;a.push(...n.allIncoming)}else{let n=X(t,e);a.push(...n.flatMap(e=>[...e.allIncoming]))}return r.excludeRelations(new Set(a.filter(i))),r}};function kr(e,t){switch(!0){case E.isElementKindExpr(t):case E.isElementTagExpr(t):{let e=H(t);return t=>e(t.target)}case E.isModelRef(t)&&t.selector===`children`:{let n=w.flatten(t.ref);return x([...e.children(n)].map(e=>V.isIncoming(e.id)))}case E.isModelRef(t)&&t.selector===`descendants`:{let n=w.flatten(t.ref);return x([V.isInside(n),...[...e.children(n)].map(e=>V.isIncoming(e.id))])}case E.isModelRef(t)&&t.selector===`expanded`:{let e=w.flatten(t.ref);return x([V.isIncoming(e),V.isInside(e)])}case E.isModelRef(t):{let e=w.flatten(t.ref);return V.isIncoming(e)}default:R(t)}}const Ar={include:({expr:{inout:e},scope:t,model:n,memory:r,stage:i,filterWhere:a})=>{let o=[];if(E.isWildcard(e)){if(!t)return;o.push(...J(t,t.ascendingSiblings()))}else{let t=_r(e,{memory:r,model:n}),i=[...r.elements];i.length===0&&(i=oe(t.flatMap(e=>F(e.ascendingSiblings()))));for(let e of t)o.push(...J(e,i))}return i.addConnections(a(o)),i},exclude:({expr:{inout:e},model:t,scope:n,stage:r,where:i})=>{let a=[];if(E.isWildcard(e)){if(!n)return;a.push(...n.allOutgoing),a.push(...n.allIncoming)}else{let n=X(t,e);a.push(...n.flatMap(e=>[...e.allOutgoing,...e.allIncoming]))}return r.excludeRelations(B(a.filter(i))),r}},jr={include:({expr:e,scope:t,model:n,memory:r,stage:i,filterWhere:a})=>{let o=e.outgoing,s=[];if(E.isWildcard(o)){if(!t)return;s.push(...J(t,t.ascendingSiblings(),`directed`))}else{let e=_r(o,{memory:r,model:n}),t=[...r.elements];t.length===0&&t.push(...oe(e.flatMap(e=>[...e.ascendingSiblings()])));let i=Mr(n,o);for(let n of e)s.push(...J(n,t,`directed`).filter(i))}return i.addConnections(a(s)),i},exclude:({expr:{outgoing:e},model:t,scope:n,stage:r,where:i})=>{let a=[];if(E.isWildcard(e)){if(!n)return;a.push(...n.allOutgoing)}else{let n=X(t,e);a.push(...n.flatMap(e=>[...e.allOutgoing]))}return r.excludeRelations(B(a.filter(i))),r}};function Mr(e,t){switch(!0){case E.isElementKindExpr(t):case E.isElementTagExpr(t):{let e=H(t);return t=>e(t.source)}case E.isModelRef(t)&&t.selector===`children`:{let n=w.flatten(t.ref);return x([...e.children(n)].map(e=>V.isOutgoing(e.id)))}case E.isModelRef(t)&&t.selector===`descendants`:{let n=w.flatten(t.ref);return x([V.isInside(n),...[...e.children(n)].map(e=>V.isOutgoing(e.id))])}case E.isModelRef(t)&&t.selector===`expanded`:{let e=w.flatten(t.ref);return x([V.isOutgoing(e),V.isInside(e)])}case E.isModelRef(t):{let e=w.flatten(t.ref);return V.isOutgoing(e)}default:R(t)}}const Nr={include:({scope:e,model:t,stage:n,memory:r,where:i})=>{if(!e){let e=[...t.roots()].filter(i);if(e.length===0)return;let[r,a]=_e(e,e=>!e.imported);return n.addExplicit(r),n.addImplicit(a),n.addConnections(Y(e)),n.connectWithExisting(e),n}let a=i(e)?e:null,o=F(j(e.children(),i)),s=o.length>0;if(!s)if(a){if(J(a,a.siblings()).length===0){let e=a.parent;e&&i(e)&&n.addExplicit(e)}o.push(a)}else return n;a&&n.addExplicit(a);let c=B([...r.elements,...e.descendingSiblings()]);for(let e of c)n.addConnections(J(e,o,`directed`));s&&(n.addConnections(Y(o)),n.addExplicit(o));for(let e of o)n.addConnections(J(e,c,`directed`));return n},exclude:({scope:e,memory:t,stage:n,where:r})=>r===xr?e?(n.exclude([e,...e.descendants()]),n):rn.empty(t.scope).stageExclude(n.expression):(n.exclude(y([...t.elements],r)),n)};function Pr(e,t,n){switch(!0){case E.isCustom(e):return t===`include`?Pr(e.custom.expr,t,n):n.stage;case E.isWhere(e):{let r=C(e.where.condition),i=e=>y(e,r);return Pr(e.where.expr,t,{...n,where:r,filterWhere:i})}case E.isModelRef(e)&&e.selector===`expanded`:return vr[t]({...n,expr:e})??n.stage;case E.isWildcard(e):return Nr[t]({...n,expr:e})??n.stage;case E.isElementKindExpr(e):case E.isElementTagExpr(e):return yr[t]({...n,expr:e})??n.stage;case E.isModelRef(e):return br[t]({...n,expr:e})??n.stage;default:R(e)}}function Fr(e,t,n){switch(!0){case D.isCustom(e):return t===`include`?Fr(e.customRelation.expr,t,n):n.stage;case D.isWhere(e):{let r=C(e.where.condition),i=e=>new Set(y([...e],r)),a=e=>b(e,_(e=>new xt(e.source,e.target,i(e.relations))),y(e=>e.nonEmpty()));return Fr(e.where.expr,t,{...n,where:r,filterWhere:a})}case D.isInOut(e):return Ar[t]({...n,expr:e})??n.stage;case D.isDirect(e):return Er[t]({...n,expr:e})??n.stage;case D.isOutgoing(e):return jr[t]({...n,expr:e})??n.stage;case D.isIncoming(e):return Or[t]({...n,expr:e})??n.stage;default:R(e)}}function Ir(e,t,n){let r={model:e,scope:t.scope,where:xr,filterWhere:Sr};for(let i of n){if(Pe(i)){t=Ir(e,an.enter(t,i),i.groupRules),P(t instanceof an,`processPredicates must return ActiveGroupMemory`),t=t.leave();continue}if(Ve(i)){let e=`include`in i?`include`:`exclude`,n=i.include??i.exclude;for(let i of n){let n=e===`include`?t.stageInclude(i):t.stageExclude(i);switch(!0){case Se.isFqnExpr(i):n=Pr(i,e,{...r,stage:n,memory:t})??n;break;case Se.isRelationExpr(i):n=Fr(i,e,{...r,stage:n,memory:t})??n;break;default:R(i)}t=n.commit()}}}return t}function Lr(e,t,n){return t=Ir(e,t,n),mr.for(t).commit()}function Rr(e,{docUri:t,rules:n,...r}){let i=rr(n,e.globals),a=r.viewOf?e.asComputed.element(r.viewOf):null,o=Lr(e,rn.empty(a),i);o.isEmpty()&&a&&(o=o.update({final:new Set([a])})),o=Br(o);let c=wr(e,o),l=Cr(o.connections);It(c,l);let u=Vt({nodes:c,edges:l}),d=nr(i,Yt(i,u.nodes)),f=s(i,Me),p=Nt(d),m=zr(i,d);return Ht({...r,_stage:`computed`,autoLayout:{direction:f?.direction??`TB`,...f?.nodeSep&&{nodeSep:f.nodeSep},...f?.rankSep&&{rankSep:f.rankSep}},edges:fr(i,d,u.edges),nodes:_(d,e=>(e.icon===`none`&&delete e.icon,e)),...p.length>0&&{notation:{nodes:p}},...m.length>0&&{ranks:m}})}function zr(e,t){let n=[];for(let r of e){if(!Le(r)||r.targets.length===0)continue;let e=b(t,y(x(r.targets.map(H))),_(e=>e.id));m(e,1)&&n.push({type:r.rank,nodes:e})}return n}function Br(e){if(e.groups.length===0)return e;let t=new ct.default(()=>new Set),n=new Map,r=e=>{for(let r of e.ancestors()){let i=n.get(r);if(i)return n.set(e,i),t.get(i).add(e),!0}return!1},a=e=>{for(let r of e.descendants(`asc`)){let i=n.get(r);if(i)return n.set(e,i),t.get(i).add(e),!0}return!1};if(b(Je([...e.explicitFirstSeenIn.keys()]),i(i=>{if(!r(i)){let r=A(e.explicitFirstSeenIn.get(i));n.set(i,r),t.get(r).add(i)}})),b(Je([...e.lastSeenIn.keys()]),y(e=>!n.has(e)),i(i=>{if(r(i)||a(i))return;let o=A(e.lastSeenIn.get(i));n.set(i,o),t.get(o).add(i)})),t.size===0)return e;let o=e.groups.map(e=>{let n=t.get(e.id);return n?e.update(n):e});return e.update({groups:o})}function Vr(e,t){switch(!0){case ke(e):return Rr(t,e);case Ie(e):return er(t,e);case je(e):return ur(t,e);default:R(e)}}function Hr(e,t){try{return{isSuccess:!0,view:Vr(e,t)}}catch(e){return{isSuccess:!1,error:e instanceof Error?e:Error(`Unknown error: ${e}`),view:void 0}}}function Ur(e){let t=pt.create(e),{views:r,_stage:i,...a}=e,o=n(r,e=>Vr(e,t));return{[Ae]:`computed`,...a,views:o}}function Wr(e){return pt.create(Ur(e))}const Q=e=>e;function $(e){if(!se(e))return e;if(e===`*`)return Q({wildcard:!0});if(e.startsWith(`->`))return e.endsWith(`->`)?Q({inout:$(e.replace(/->/g,``).trim())}):Q({incoming:$(e.replace(`-> `,``))});if(e.endsWith(` ->`))return Q({outgoing:$(e.replace(` ->`,``))});if(e.includes(` <-> `)){let[t,n]=e.split(` <-> `);return Q({source:$(t),target:$(n),isBidirectional:!0})}if(e.includes(` -> `)){let[t,n]=e.split(` -> `);return Q({source:$(t),target:$(n)})}return e.endsWith(`._`)?Q({ref:{model:e.replace(`._`,``)},selector:`expanded`}):e.endsWith(`.**`)?Q({ref:{model:e.replace(`.**`,``)},selector:`descendants`}):e.endsWith(`.*`)?Q({ref:{model:e.replace(`.*`,``)},selector:`children`}):Q({ref:{model:e}})}export{Vr as a,It as c,Hr as i,Wr as n,Rr as o,Ur as r,Vt as s,$ as t};
1
+ import{r as e}from"./rolldown-runtime.mjs";import{B as t,C as n,E as r,G as i,H as a,I as o,J as s,K as c,L as l,M as u,N as d,O as f,P as p,Q as m,R as h,S as g,T as _,V as v,Y as y,Z as ee,_ as te,a as ne,d as re,et as b,g as ie,h as ae,i as oe,k as se,m as ce,n as le,nt as ue,o as de,q as fe,r as pe,rt as x,t as me,tt as he,u as ge,v as _e,w as ve,x as ye,y as S,z as be}from"./libs/remeda.mjs";import{G as C,J as xe,O as w,St as T,U as Se,W as E,Y as D,_t as Ce,b as we,d as Te,dt as Ee,et as De,g as Oe,h as ke,ht as Ae,l as je,lt as Me,n as Ne,o as Pe,p as Fe,q as O,r as Ie,s as Le,tt as Re,u as ze,vt as Be,xt as Ve,y as He}from"./types.mjs";import{$ as k,A as Ue,B as We,D as A,I as j,K as Ge,L as Ke,M as qe,O as M,Q as N,R as Je,U as Ye,V as Xe,Z as Ze,_ as P,a as F,c as I,d as Qe,et as L,g as $e,i as et,j as tt,s as nt,u as R,v as z,w as rt,x as it,y as at}from"./utils.mjs";import{n as ot,t as st}from"./libs/graphology-dag.mjs";import{c as ct,t as B}from"./libs/mnemonist.mjs";import{A as lt,C as ut,D as dt,E as ft,M as V,N as pt,O as mt,T as ht,_ as gt,c as _t,d as vt,f as yt,g as bt,h as xt,j as St,m as Ct,n as wt,o as Tt,p as Et,q as Dt,r as Ot,t as kt,v as At,w as jt,y as Mt}from"./model.mjs";import{r as Nt}from"./manual-layout.mjs";import{t as Pt}from"./libs/graphology.mjs";function Ft(e,t){let n=[],r=e.parent;for(;r;){let e=k(t.get(r),`Parent node ${r} not found`);n.push(e),r=e.parent}return n}function It(e,t){for(let n of t){let t=e.get(n.source),i=e.get(n.target);N(t,`Source node ${n.source} not found`),N(i,`Target node ${n.target} not found`),t.outEdges.push(n.id),i.inEdges.push(n.id);let a=Ft(t,e),o=Ft(i,e),s=a.length>0&&o.length>0?r(Ze(ge(a),ge(o))):null;n.parent=s?s.id:null;for(let e of a){if(e===s)break;e.outEdges.push(n.id)}for(let e of o){if(e===s)break;e.inEdges.push(n.id)}}}var Lt=ot(),Rt=e(st(),1);function zt(e){let t=[],n=[...e],r;for(;r=n.shift();){let e=r.parent;if(e){let r=[];for(;e;){let t=n.findIndex(t=>t.id===e);if(t<0)break;let[i]=n.splice(t,1);if(!i)throw Error(`Invalid state, should not happen`);r.unshift(i),e=i.parent}t.push(...r)}t.push(r)}return t}function Bt(e){return e.forEach(t=>{t.children.length>0&&(t.children=e.reduce((e,n)=>(n.parent===t.id&&e.push(n.id),e),[]))}),e}function Vt(e){let t=zt([...e.nodes.values()]),n=[...e.edges];if(t.length<2||n.length===0)return{nodes:t,edges:n};let r=t=>k(e.nodes.get(t)),a=new Pt({multi:!0,allowSelfLoops:!0,type:`directed`}),[o,s]=_e(b(n,_(e=>{let t=r(e.source),n=r(e.target),i=e.parent?r(e.parent):null;return{id:e.id,edge:e,parent:i,source:t,target:n}})),({source:e,target:t})=>e.children.length===0&&t.children.length===0),c=[],l=e=>{a.mergeNode(e.source),a.mergeNode(e.target),c.push(e),(0,Rt.default)(a,e.source,e.target)||a.mergeDirectedEdge(e.source,e.target)};for(let{edge:t,source:n,target:s}of o)if(l(t),s.parent&&s.parent!==t.parent&&b(Ft(s,e.nodes),ne(e=>e.inEdges.includes(t.id)),i(e=>{a.mergeNode(e.id),(0,Rt.default)(a,t.source,e.id)||a.mergeDirectedEdge(t.source,e.id),(0,Rt.default)(a,e.id,t.target)||a.mergeDirectedEdge(e.id,t.target)})),n.parent){let e=r(n.parent);a.mergeNode(e.id),(0,Rt.default)(a,e.id,n.id)||a.mergeDirectedEdge(e.id,n.id),s.parent&&s.parent!==n.parent&&((0,Rt.default)(a,e.id,s.parent)||a.mergeDirectedEdge(e.id,s.parent))}for(let{edge:e}of s)l(e);N(c.length===n.length,`Not all edges were added to the graph`);let u=(0,Lt.topologicalSort)(a),d=[],f=t.slice();for(let e of u){let t=f.findIndex(t=>t.id===e);N(t>=0,`Node "${e}" not found`),d.push(...f.splice(t,1))}return f.length>0&&d.length>0&&(d=d.flatMap(e=>{if(f.length===0)return e;let n=t.slice(0,t.indexOf(e)).filter(e=>f.includes(e));return n.length>0?(f=f.filter(e=>!n.includes(e)),[...n,e]):e})),d.push(...f),{nodes:Bt(zt(d)),edges:c}}function Ht(e){return e.hash=et({id:e.id,__:e._type??`element`,autoLayout:e.autoLayout,nodes:b(e.nodes,_(e=>({id:e.id,icon:f(e.icon)&&e.icon!==`none`?`Y`:`N`,title:e.title,description:Me(e.description),technology:e.technology??null,shape:e.shape,size:e.style.size??null,iconSize:e.style.iconSize??null,iconPosition:e.style.iconPosition??null,textSize:e.style.textSize??null,padding:e.style.padding??null,children:e.children})),ve(({id:e,...t})=>[e,t])),edges:b(e.edges,_(e=>({source:e.source,target:e.target,label:e.label,description:Me(e.description),technology:e.technology??null,dir:e.dir,head:e.head,tail:e.tail,line:e.line})),ve(({source:e,target:t,...n})=>[`${e}:${t}`,n]))}),e}var Ut=class{get Ctx(){throw Error(`Should not be called in runtime`)}constructor(e){this.state=e}get elements(){return this.state.elements}get explicits(){return this.state.explicits}get final(){return this.state.final}get connections(){return this.state.connections}isEmpty(){return this.elements.size===0&&this.connections.length===0&&this.explicits.size===0&&this.final.size===0}},Wt=class{excluded={elements:new Set,connections:[]};constructor(e,t){this.memory=e,this.expression=t}markedToMoveExplicitToImplicit=!1;_removeElement(e){this.excluded.elements.add(e)}exclude(e){if(!e)return this;if(M(e)){for(let t of e)this._removeElement(t);return this}return this._removeElement(e),this}_removeConnection(e){this.excluded.connections.push(e)}excludeConnections(e,t){if(be(t)&&(N(!this.markedToMoveExplicitToImplicit,`Already marked to move explicits`),this.markedToMoveExplicitToImplicit=t),M(e)){for(let t of e)this._removeConnection(t);return this}return this._removeConnection(e),this}isDirty(){return this.excluded.elements.size>0||this.excluded.connections.length>0}isEmpty(){return!this.isDirty()}filterForMoveToImplicits(e){return this.markedToMoveExplicitToImplicit||this.excluded.elements.size>0?e:new Set}moveDisconnectedExplicitsToImplicits(e){let t=F(new Set(this.memory.connections.flatMap(e=>[e.source,e.target])),new Set(e.connections.flatMap(e=>[e.source,e.target])));return t=I(t,e.elements),t=b(t,A(t=>e.explicits.has(t)&&!at(e.final,Ke(t))),z()),t.size>0&&(t=this.filterForMoveToImplicits(t),e.explicits=F(e.explicits,t),e.final=F(e.final,t)),e}removeElements(e){return e.elements=F(e.elements,this.excluded.elements),e.explicits=F(e.explicits,this.excluded.elements),e.final=F(e.final,this.excluded.elements),e}removeConnections(e){let t=this.excluded.connections.reduce((e,t)=>{let n=e.get(t.id);return n?e.set(t.id,n.mergeWith(t)):e.set(t.id,t),e},new Map),n=new Set;e.connections=e.connections.reduce((e,r)=>{let i=t.get(r.id);if(i){n.add(r.source),n.add(r.target);let t=r.difference(i);t.nonEmpty()&&e.push(t)}else e.push(r);return e},[]);for(let t of e.connections)n.delete(t.source),n.delete(t.target),t.boundary&&e.elements.has(t.boundary)&&n.delete(t.boundary);return n.size===0?e:(n=F(n,e.explicits),e.final=F(e.final,n),e)}precommit(e){return e}postcommit(e){return N(F(e.explicits,e.elements).size===0,`Explicits must be subset of elements`),N(F(e.final,e.elements).size===0,`Final elements must be subset of elements`),e}commit(){let e=this.precommit(this.memory.mutableState());if(this.excluded.elements.size>0){let t=e.connections.filter(e=>this.excluded.elements.has(e.source)||this.excluded.elements.has(e.target)).flatMap(t=>[t,...gt(e.connections,t).map(e=>e.intersect(t))]).filter(e=>e.nonEmpty());this.excludeConnections(t)}return this.excluded.connections.length>0&&(e=this.removeConnections(e)),this.excluded.elements.size>0&&(e=this.removeElements(e)),this.memory.update(this.postcommit(e))}},Gt=class{explicits=new Set;implicits=new Set;_ordered=new Set;_connections=[];constructor(e,t){this.memory=e,this.expression=t}get elements(){return this.explicits}get connections(){return this._connections}mergedConnections(){return dt([...this.memory.connections,...this._connections])}connectWithExisting(e,t){throw Error(`Method not implements, depends on the model`)}_addExplicit(e){this._ordered.add(e),this.explicits.add(e),this.implicits.delete(e)}addExplicit(e){if(!e)return this;if(M(e)){for(let t of e)this._addExplicit(t);return this}return this._addExplicit(e),this}_addImplicit(e){this.explicits.has(e)||(this._ordered.add(e),this.implicits.add(e))}addImplicit(e){if(!e)return this;if(M(e)){for(let t of e)this._addImplicit(t);return this}return this._addImplicit(e),this}_addConnection(e){this._connections.push(e),this._addImplicit(e.source),this._addImplicit(e.target)}addConnections(e){if(M(e)){for(let t of e)this._addConnection(t);return this}return this._addConnection(e),this}isDirty(){return this.explicits.size>0||this.implicits.size>0||this._connections.length>0}isEmpty(){return!this.isDirty()}precommit(e){return e}postcommit(e){return e}processConnections(e){return e}commit(){let e=this.precommit(this.memory.mutableState()),t=new Set;if(this._connections.length>0){let[n,r]=_e(this._connections,t=>e.final.has(t.source));e.connections=this.processConnections(dt([...e.connections,...n,...r])),t=new Set(e.connections.flatMap(e=>[e.source,e.target]))}return e.elements=R(e.elements,this._ordered,this.explicits,t,this.implicits),e.explicits=I(e.elements,R(e.explicits,this.explicits)),e.final=I(e.elements,R(e.final,this.explicits,t)),this.memory.update(this.postcommit(e))}};function Kt(e,t=`final`){let n=Ye(P(t===`final`?e.final:e.elements)),r=new Set(e.connections.flatMap(e=>[e.source,e.target])),i=new Set(n),a=new B.default(()=>null),o=n.reduce((e,t,n,r)=>(e.set(t,r.slice(n+1).filter(e=>j(t,e)).map(e=>(i.delete(e),e)).reduce((e,n)=>(e.some(e=>j(e,n))||(e.push(n),a.set(n,t)),e),[])),e),new B.default(()=>[]));return{root:i,connected:r,hasInOut:t=>e.connections.some(V.isAnyInOut(t.id)),parent:e=>a.get(e),children:e=>o.get(e)}}var qt=class extends Wt{};function H(e){if(E.isCustom(e))return H(e.custom.expr);if(E.isWhere(e)){let t=H(e.where.expr),n=w(e.where.condition);return e=>t(e)&&n(e)}if(E.isElementKindExpr(e))return e.isEqual?t=>t.kind===e.elementKind:t=>t.kind!==e.elementKind;if(E.isElementTagExpr(e))return e.isEqual?({tags:t})=>t.includes(e.elementTag):({tags:t})=>!t.includes(e.elementTag);if(E.isWildcard(e))return()=>!0;if(E.isModelRef(e)){let t=D.flatten(e.ref);if(e.selector===`expanded`)return e=>e.id===t||We(e.id)===t;if(e.selector===`descendants`||e.selector===`children`){let e=t+`.`;return t=>t.id.startsWith(e)}return e=>e.id===t}L(e)}function Jt(e,t,n){let{shape:r,color:a,icon:o,...s}=e.style,c=!l(s);b(n,y(d(Ee)),y(t),i(t=>{t.shape=r??t.shape,t.color=a??t.color,h(o)&&(t.icon=o),h(e.notation)&&(t.notation=e.notation),c&&(t.style={...t.style,...s})}))}function Yt(e,t){for(let n of e)!we(n)||n.targets.length===0||Jt(n,x(n.targets.map(H)),t);return t}var Xt=class e{static kind=De;constructor(e,t,n=null,r=new Set){this.id=e,this.viewRule=t,this.parent=n,this.elements=r}isEmpty(){return this.elements.size===0}update(t){return new e(this.id,this.viewRule,this.parent,t)}clone(){return new e(this.id,this.viewRule,this.parent,new Set(this.elements))}},Zt=class extends Wt{excludeRelations(e){return b(this.memory.connections,y(t=>nt(t.relations,e)),i(t=>{this.excludeConnections(t.update(I(t.relations,e)))})),this}precommit(e){if(this.excluded.elements.size>0){let e=new Set([...this.excluded.elements].flatMap(e=>[...e.incoming(`direct`),...e.outgoing(`direct`)]));this.excludeRelations(e)}return e}postcommit(e){let t=F(this.memory.explicits,e.explicits);for(let n of t)e.explicitFirstSeenIn.delete(n);let n=F(this.memory.elements,e.elements);for(let t of n)e.lastSeenIn.delete(t);return e}},Qt=class extends Zt{constructor(e,t){super(e,t),this.memory=e,this.expression=t}};const{findConnection:$t,findConnectionsBetween:en}=Et;var tn=class extends Gt{connectWithExisting(e,t=`both`){let n=this._connections.length,r=()=>this._connections.length>n;if(!M(e)){if(t===`in`||t===`both`)for(let t of this.memory.elements)this.addConnections($t(t,e,`directed`));return(t===`out`||t===`both`)&&this.addConnections(en(e,this.memory.elements,`directed`)),r()}let i=[...e];if(t===`in`||t===`both`)for(let e of this.memory.elements)this.addConnections(en(e,i,`directed`));if(t===`out`||t===`both`)for(let e of i)this.addConnections(en(e,this.memory.elements,`directed`));return r()}addImplicitWithinScope(e){e&&(!this.memory.scope||j(this.memory.scope,e))&&this.addImplicit(e)}processConnections(e){return Se.isRelationExpr(this.expression)||b(e,i(({source:e,target:t,boundary:n})=>{b(me([...P(e.ancestors()).reverse(),e],[...P(t.ancestors()).reverse(),t]),ee(([e,t])=>e===t),de(1),i(([r,i])=>{if(r===e&&i===t){this.addImplicitWithinScope(n);return}r!==e&&this.addImplicitWithinScope(r),i!==t&&this.addImplicitWithinScope(i)}))})),e}postcommit(e){let t=F(e.explicits,this.memory.explicits);for(let n of t)e.explicitFirstSeenIn.set(n,`@root`);return e}},nn=class extends tn{constructor(e,t){super(e,t),this.memory=e,this.expression=t}postcommit(e){let t=F(e.explicits,this.memory.explicits);for(let n of t)e.explicitFirstSeenIn.set(n,this.memory.activeGroupId);for(let t of[...this.explicits,...this.implicits])e.lastSeenIn.set(t,this.memory.activeGroupId);return e}},rn=class e extends Ut{static empty(t){return new e({elements:new Set,explicits:new Set,final:new Set,connections:[],groups:[],explicitFirstSeenIn:new Map,lastSeenIn:new Map},t)}constructor(e,t){super(e),this.state=e,this.scope=t}get groups(){return this.state.groups}get explicitFirstSeenIn(){return this.state.explicitFirstSeenIn}get lastSeenIn(){return this.state.lastSeenIn}stageInclude(e){return new tn(this,e)}stageExclude(e){return new Zt(this,e)}mutableState(){return{elements:new Set(this.state.elements),explicits:new Set(this.state.explicits),final:new Set(this.state.final),connections:[...this.state.connections],groups:this.state.groups.map(e=>e.clone()),explicitFirstSeenIn:new Map(this.state.explicitFirstSeenIn),lastSeenIn:new Map(this.state.lastSeenIn)}}update(t){return new e({...this.state,...t},this.scope)}},an=class e extends rn{static enter(t,n){let r=`@gr${t.groups.length+1}`;if(t instanceof e){let i=ct.default.from([...t.stack].reverse()),a=t.mutableState();return a.groups.push(new Xt(r,n,t.activeGroupId)),i.push(r),new e(a,t.scope,i)}let i=t.mutableState();i.groups.push(new Xt(r,n,null));let a=ct.default.of(r);return new e(i,t.scope,a)}constructor(e,t,n){super(e,t),this.state=e,this.scope=t,this.stack=n}get activeGroupId(){return k(this.stack.peek(),`Stack must not be empty`)}mutableState(){return{...super.mutableState()}}update(t){return new e({...this.state,...t},this.scope,this.stack)}stageInclude(e){return new nn(this,e)}stageExclude(e){return new Qt(this,e)}leave(){let t=this.mutableState();return this.stack.pop(),this.stack.peek()?new e(t,this.scope,this.stack):new rn(t,this.scope)}};function on(e,t){let n;for(;e.parent&&(n=t.get(e.parent));){let t=n.depth??1;if(n.depth=Math.max(t,(e.depth??0)+1),n.depth===t)break;e=n}}function sn(e){let{id:t,title:n,...r}=g(e.$element,[`summary`,`description`,`metadata`,`style`,`tags`]),{color:i,icon:a,shape:o,...s}=e.style;return T({id:t,title:n,modelRef:t,shape:o,color:i,icon:a,style:s,description:Ve(e.$element),tags:[...e.tags],metadata:e.$element.metadata,...r})}function cn({defaults:e},t,n){let r=new Map,i=new Map;n?.forEach(({id:t,parent:n,viewRule:a,elements:o})=>{n&&k(r.get(n),`Parent group node ${n} not found`).children.push(t),r.set(t,{id:t,parent:n,kind:De,title:a.title??``,color:a.color??e.group.color??e.color,shape:`rectangle`,children:[],inEdges:[],outEdges:[],level:0,depth:0,tags:[],style:T({border:a.border??e.group.border,opacity:a.opacity??e.group.opacity,size:a.size,multiple:a.multiple,padding:a.padding,textSize:a.textSize})});for(let e of o)i.set(e.id,t)}),Array.from(t).sort(qe).forEach(({id:e,...t})=>{let n=We(e),a=0,o;for(;n&&(o=r.get(n),!o);)n=We(n);let s=t.modelRef??e;if(!o&&i.has(s)){let e=k(i.get(s));o=r.get(e),n=e}o&&(o.children.length==0&&(o.depth=1,on(o,r)),o.children.push(e),a=o.level+1);let c=T({id:e,parent:n,level:a,children:[],inEdges:[],outEdges:[],...t});r.set(e,c)});let a=new Map;return n?.forEach(({id:e})=>{a.set(e,k(r.get(e)))}),t.forEach(({id:e})=>{a.set(e,k(r.get(e)))}),a}function ln(e){let{title:t,description:n=null}=e;return{...t&&{title:t,description:n},...te(e,[`color`,`technology`,`head`,`line`,`tail`,`kind`,`navigateTo`])}}function un(e,t){let n=b(e,re((e,t)=>(f(t.title)&&!e.title.includes(t.title)&&e.title.push(t.title),f(t.description)&&!e.description.some(v(t.description))&&e.description.push(t.description),f(t.technology)&&!e.technology.includes(t.technology)&&e.technology.push(t.technology),f(t.kind)&&!e.kind.includes(t.kind)&&e.kind.push(t.kind),f(t.color)&&!e.color.includes(t.color)&&e.color.push(t.color),f(t.line)&&!e.line.includes(t.line)&&e.line.push(t.line),f(t.head)&&!e.head.includes(t.head)&&e.head.push(t.head),f(t.tail)&&!e.tail.includes(t.tail)&&e.tail.push(t.tail),f(t.navigateTo)&&!e.navigateTo.includes(t.navigateTo)&&e.navigateTo.push(t.navigateTo),t.tags&&e.tags.push(...t.tags),e),{title:[],description:[],technology:[],kind:[],head:[],tail:[],color:[],tags:[],line:[],navigateTo:[]})),r=S(n.title)??(n.title.length>1?`[...]`:void 0),i=oe(n.tags),a=T({title:r,description:S(n.description),technology:S(n.technology),kind:S(n.kind),head:S(n.head),tail:S(n.tail),color:S(n.color),line:S(n.line),navigateTo:S(n.navigateTo),...Ge(i)&&{tags:i}});if(t){let e=ln(t);a=ie({...a,...e},f)}return u(a.title)&&f(a.technology)&&(a.title=`[${a.technology}]`,delete a.technology),a}const{findConnection:dn,findConnectionsBetween:U,findConnectionsWithin:fn}=Ct;function W(e,t){let n=e.element(t.ref.deployment);if(n.isDeploymentNode()){if(t.selector===`children`)return[...n.children()];if(t.selector===`expanded`)return[n,...n.children()];if(t.selector===`descendants`)return[...n.descendants()]}return[n]}function pn(e,t){let n=e.$model.element(t.ref.model);return t.selector===`children`?[...n.children()]:t.selector===`expanded`?[n,...n.children()]:t.selector===`descendants`?[...n.descendants()]:[n]}function mn(e){if(O.isWildcard(e))return()=>!0;if(O.isElementTagExpr(e)||O.isElementKindExpr(e))throw Error(`element kind and tag expressions are not supported in deployment view rules`);if(O.isDeploymentRef(e)){let t=e.ref.deployment;if(e.selector===`expanded`){let e=t+`.`;return n=>n.id===t||n.id.startsWith(e)}if(e.selector===`descendants`){let e=t+`.`;return t=>t.id.startsWith(e)}return e.selector===`children`?e=>We(e.id)===t:e=>e.id===t}if(O.isModelRef(e)){let t=e.ref.model;if(e.selector===`expanded`){let e=t+`.`;return n=>{let r=n.modelRef??null;return r?r===t||r.startsWith(e):!0}}if(e.selector===`descendants`){let e=t+`.`;return t=>{let n=t.modelRef??null;return n?n.startsWith(e):!0}}return e.selector===`children`?e=>{let n=e.modelRef??null;return n?We(n)===t:!0}:e=>{let n=e.modelRef??null;return n?n===t:!0}}L(e)}function hn(e){return Ve(e.$instance)??Ve(e.element.$element)}function gn(e){let t=e.id,n=e.onlyOneInstance();return T({id:t,deploymentRef:t,title:e.title,kind:e.kind,technology:e.technology??void 0,links:m(e.links,1)?[...e.links]:void 0,notation:e.$node.notation??void 0,color:e.color,shape:e.shape,modelRef:n?.element.id,icon:e.style.icon,description:Ve(e.$node)??void 0,tags:[...e.tags],style:g(e.style,[`icon`,`shape`,`color`])})}function _n(e){let t=e.$instance,n=e.element,{icon:r,color:i,shape:a,...o}=e.style,s=[...n.links,...t.links??[]];return T({id:e.id,kind:`instance`,title:e.title,description:hn(e)??void 0,technology:e.technology??void 0,tags:[...e.tags],links:m(s,1)?s:void 0,icon:r,color:i,shape:a,style:o,deploymentRef:t.id,modelRef:n.id,notation:t.notation})}function vn(e){return e.isInstance()?_n(e):gn(e)}function yn(e){return e.reduce((e,t)=>{let n=[...t.relations.model,...t.relations.deployment];N(m(n,1),`Edge must have at least one relation`);let r=t.source.$model.$styles.defaults,i=t.source.id,a=t.target.id,{title:o,color:s=r.relationship.color,line:c=r.relationship.line,head:l=r.relationship.arrow,...u}=un(n.map(e=>e.$relationship)),d=T({id:t.id,parent:t.boundary?.id??null,source:i,target:a,label:o??null,relations:n.map(e=>e.id),color:s,line:c,head:l,...u}),f=e.find(e=>e.source===a&&e.target===i);if(f&&d.label===f.label){f.dir=`both`;let n=f.head??d.head??t.source.$model.$styles.defaults.relationship.arrow;return f.head??=n,f.tail??=n,d.color&&(f.color??=d.color),d.line&&(f.line??=d.line),e}return e.push(d),e},[])}function bn(e,t){let n=cn(e.$styles,[...t.final].map(vn));for(let t of n.values()){if(!t.deploymentRef||!t.modelRef||t.children.length>0)continue;let n=e.deployment.element(t.deploymentRef),r=n.isDeploymentNode()&&n.onlyOneInstance();if(!r)continue;t.title===n.name&&(t.title=r.title),t.description??=hn(r)??null,t.technology??=r.technology,l(t.tags)&&(t.tags=[...r.tags]),(!t.links||l(t.links))&&m(r.links,1)&&(t.links=[...r.links]);let i=e.$styles.defaults;t.shape===i.shape&&t.shape!==r.shape&&(t.shape=r.shape,t.notation=null),t.color===i.color&&t.color!==r.color&&(t.color=r.color,t.notation=null),!t.icon&&r.icon&&(t.icon=r.icon)}return n}function xn(e,t){for(let n of e)!we(n)||n.targets.length===0||Jt(n,x(n.targets.map(mn)),t);return t}function Sn(e){let t=new B.default(()=>[]);for(let n of e)for(let e of n.relations.model)t.get(e).push(n);let n=new B.default(()=>new Set);for(let[e,r]of t)m(r,2)&&b(r,c(e=>[{group:`$source-${e.source.id}`,conn:e},{group:`$target-${e.target.id}`,conn:e}]),a(ce(`group`)),pe(),y(m(2)),i(ae(_(ce(`conn`)),mt(`desc`),ee((e,t,n)=>t===0||e.boundary===n[t-1].boundary),i(t=>{n.get(t).add(e)}))));return n}function Cn(e){e=dt(e);let t=Sn(e);for(let n of e){let{source:e,target:r}=n,i=n.relations.model;if(e.isDeploymentNode()!==r.isDeploymentNode()){let r=e.isDeploymentNode()?e:n.target;N(r.isDeploymentNode());let a=I(i,r.internalModelRelationships());for(let e of a)t.get(n).add(e);continue}if(e.isDeploymentNode()&&r.isDeploymentNode()){let i=R(I(n.relations.model,e.internalModelRelationships()),I(n.relations.model,r.internalModelRelationships()));for(let e of i)t.get(n).add(e)}}return b(t.entries(),it(([e,t])=>e.update({model:t,deployment:null})),P())}function wn(e){return bt(e,Cn(e))}function Tn(e){return b(e,dt,re((t,n)=>{let{source:r,target:i,relations:a}=n;if(r.isInstance()&&i.isInstance())return t;let o=Dt.empty();if(r.isDeploymentNode()&&i.isDeploymentNode()){let[e]=dn(i,r,`directed`);e&&(o=a.intersect(e.relations))}for(let t of e)ht(t,n)&&(o=o.union(a.intersect(t.relations)));return o.nonEmpty&&t.push(new lt(r,i,o)),t},[]))}function En(e){return bt(e,Tn(e))}var Dn=class extends Gt{connectWithExisting(e,t=`both`){let n=this._connections.length,r=()=>this._connections.length>n;if(!M(e)){if(t===`in`||t===`both`)for(let t of this.memory.elements)this.addConnections(dn(t,e,`directed`));return(t===`out`||t===`both`)&&this.addConnections(U(e,this.memory.elements,`directed`)),r()}let i=[...e];if(t===`in`||t===`both`)for(let e of this.memory.elements)this.addConnections(U(e,i,`directed`));if(t===`out`||t===`both`)for(let e of i)this.addConnections(U(e,this.memory.elements,`directed`));return r()}processConnections(e){let t=b(e,wn,En);return b(t,i(({source:e,target:t,boundary:n})=>{b(me([...P(e.ancestors()).reverse(),e],[...P(t.ancestors()).reverse(),t]),ee(([e,t])=>e===t),de(1),i(([r,i])=>{if(e===r&&t===i){this.addImplicit(n);return}r!==e&&r.isDeploymentNode()&&!r.onlyOneInstance()&&this.addImplicit(r),i!==t&&i.isDeploymentNode()&&!i.onlyOneInstance()&&this.addImplicit(i)}))})),t}},On=class e extends Ut{static empty(){return new e({elements:new Set,explicits:new Set,final:new Set,connections:[]})}stageInclude(e){return new Dn(this,e)}stageExclude(e){return new qt(this,e)}mutableState(){return{elements:new Set(this.state.elements),explicits:new Set(this.state.explicits),final:new Set(this.state.final),connections:[...this.state.connections]}}update(t){return new e({...this.state,...t})}equals(t){return t instanceof e&&v(this.state,t.state)}diff(e){return{added:{elements:P(F(e.elements,this.elements)),explicits:P(F(e.explicits,this.explicits)),final:P(F(e.final,this.final)),connections:P(bt(e.connections,this.connections))},removed:{elements:P(F(this.elements,e.elements)),explicits:P(F(this.explicits,e.explicits)),final:P(F(this.final,e.final)),connections:bt(this.connections,e.connections)}}}toString(){return[`final:`,...[...this.final].map(e=>` `+e.id),`connections:`,...this.connections.map(e=>` `+e.expression)].join(`
2
+ `)}[St](e,t,n){return this.toString()}};const kn={include:({expr:e,model:t,memory:n,stage:r})=>{let i=w(e.where.condition);return Vn(`include`,{expr:e.where.expr,model:t,stage:r,memory:n,where:i})},exclude:({expr:e,model:t,memory:n,stage:r})=>{let i=w(e.where.condition);return Vn(`exclude`,{expr:e.where.expr,model:t,stage:r,memory:n,where:i})}},An={include:({expr:e,model:t,memory:n,stage:r,where:i})=>{let a=[...n.elements];if(O.isWildcard(e.incoming)){for(let e of a){if(e.allOutgoing.isEmpty)continue;let t=K(U(e,[...Kn(e)],`directed`),i);r.addConnections(t)}return r}N(O.isDeploymentRef(e.incoming),`Only deployment refs are supported in include`);let o=W(t,e.incoming);for(let e of a){let t=K(U(e,o,`directed`),i);r.addConnections(t)}return r},exclude:({expr:e,model:t,memory:n,stage:r,where:i})=>{if(O.isElementTagExpr(e.incoming)||O.isElementKindExpr(e.incoming))throw Error(`element kind and tag expressions are not supported in exclude`);if(O.isModelRef(e.incoming))return G(Mn(t,e.incoming),{stage:r,memory:n},i);if(O.isWildcard(e.incoming))return r;let a=jn(W(t,e.incoming)),o=b(n.connections,y(a),K(i));return r.excludeConnections(o),r}};function jn(e){return x(e.map(e=>{let t=t=>t===e||j(e,t);return e=>!t(e.source)&&t(e.target)}))}function Mn(e,t){let n=pn(e,t);return new Set(n.flatMap(e=>[...e.allIncoming]))}const Nn={include:({expr:e,model:t,memory:n,stage:r,where:i})=>{let a=[...n.elements];if(O.isWildcard(e.outgoing)){for(let e of a)if(!e.allIncoming.isEmpty)for(let t of Kn(e)){let n=K(dn(t,e,`directed`),i);r.addConnections(n)}return r}N(O.isDeploymentRef(e.outgoing),`Only deployment refs are supported in include`);let o=W(t,e.outgoing);for(let e of o){let t=K(U(e,a,`directed`),i);r.addConnections(t)}return r},exclude:({expr:e,model:t,memory:n,stage:r,where:i})=>{if(O.isElementTagExpr(e.outgoing)||O.isElementKindExpr(e.outgoing))throw Error(`element kind and tag expressions are not supported in exclude`);if(O.isModelRef(e.outgoing))return G(Fn(t,e.outgoing),{stage:r,memory:n},i);if(O.isWildcard(e.outgoing))return r;let a=Pn(W(t,e.outgoing)),o=b(n.connections,y(a),K(i));return r.excludeConnections(o),r}};function Pn(e){return x(e.map(e=>{let t=t=>t===e||j(e,t);return e=>t(e.source)&&!t(e.target)}))}function Fn(e,t){let n=pn(e,t);return new Set(n.flatMap(e=>[...e.allOutgoing]))}const In={include:({expr:{source:e,target:t,isBidirectional:n=!1},model:r,stage:i,where:a})=>{if(O.isElementTagExpr(e)||O.isElementKindExpr(e)||O.isElementTagExpr(t)||O.isElementKindExpr(t))throw Error(`element kind and tag expressions are not supported in include`);N(!O.isModelRef(e),`Invalid source model ref in direct relation`),N(!O.isModelRef(t),`Invalid target model ref in direct relation`);let o=O.isWildcard(e),s=O.isWildcard(t),l=n?`both`:`directed`,u;switch(!0){case o&&s:u=b(fn(r.instances()),K(a),_(e=>(i.addImplicit(e.boundary),e)));break;case!o&&s:{let t=W(r,e),i=Pn(t),o=i;if(n){let e=jn(t);o=t=>i(t)!==e(t)}u=b(t,c(e=>U(e,Kn(e),l)),y(o),K(a));break}case o&&!s:{let e=W(r,t),i=jn(e),o=i;if(n){let t=Pn(e);o=e=>t(e)!==i(e)}u=b(e,c(e=>[...Kn(e)].flatMap(t=>dn(t,e,l))),y(o),K(a));break}default:{N(!o,`Inference failed - source should be a deployment ref`),N(!s,`Inference failed - target should be a deployment ref`);let n=W(r,e),i=W(r,t),d=Pn(n),f=jn(i);u=b(n,c(e=>U(e,i,l)),y(e=>d(e)&&f(e)),K(a))}}return i.addConnections(u),O.isDeploymentRef(e)&&p(e.selector)&&i.addImplicit(r.element(e.ref.deployment)),O.isDeploymentRef(t)&&p(t.selector)&&i.addImplicit(r.element(t.ref.deployment)),i},exclude:({expr:e,model:t,memory:n,stage:r,where:i})=>{let a=mn(e.target),o=mn(e.source),s;switch(!0){case O.isWildcard(e.source)&&O.isWildcard(e.target):return r.excludeConnections(K(n.connections,i)),r;case O.isModelRef(e.source)&&O.isModelRef(e.target):return s=Ln({source:e.source,target:e.target,expr:e,model:t}),G(s,{stage:r,memory:n},i);case O.isModelRef(e.source)&&O.isWildcard(e.target):return s=Fn(t,e.source),G(s,{stage:r,memory:n},i);case O.isModelRef(e.source):return s=Fn(t,e.source),G(s,{stage:r,memory:n},i,e=>a(e.target));case O.isModelRef(e.target):return s=Mn(t,e.target),G(s,{stage:r,memory:n},i,e=>o(e.source));default:let c=t=>o(t.source)&&a(t.target)||e.isBidirectional===!0&&o(t.target)&&a(t.source),l=b(n.connections,y(c),K(i));return l.length===0||r.excludeConnections(l),r}}};function Ln({source:e,target:t,expr:n,model:r}){let i=pn(r,e),a=pn(r,t),o=n.isBidirectional?`both`:`directed`,s=[];for(let e of i)s.push(...yt(e,a,o));return new Set(s.flatMap(e=>[...e.relations]))}const Rn={include:({expr:e,model:t,memory:n,stage:r,where:i})=>{let a=[...n.elements];if(O.isWildcard(e.inout)){for(let e of a){let t=Un(U(e,[...Kn(e)],`both`),i);r.addConnections(t)}return r}N(O.isDeploymentRef(e.inout),`Only deployment refs are supported in include`);let o=W(t,e.inout);for(let e of a){let t=Un(U(e,o,`both`),i);r.addConnections(t)}return r},exclude:({expr:e,model:t,memory:n,stage:r,where:i})=>{if(O.isElementTagExpr(e.inout)||O.isElementKindExpr(e.inout))throw Error(`element kind and tag expressions are not supported in exclude`);if(O.isModelRef(e.inout)){let a=pn(t,e.inout);return a.length===0?r:G(R(new Set,...a.flatMap(e=>[e.allIncoming,e.allOutgoing])),{stage:r,memory:n},i)}if(O.isWildcard(e.inout))return r;let a=W(t,e.inout),o=jn(a),s=Pn(a),c=b(n.connections,y(e=>o(e)!==s(e)),K(i));return r.excludeConnections(c),r}},zn={include:({expr:e,model:t,memory:n,stage:r})=>{let i=w(e.where.condition);return Vn(`include`,{expr:e.where.expr,model:t,stage:r,memory:n,where:i})},exclude:({expr:e,model:t,memory:n,stage:r})=>{let i=w(e.where.condition);return Vn(`exclude`,{expr:e.where.expr,model:t,stage:r,memory:n,where:i})}},Bn={include:({model:e,stage:t,where:n})=>{let r=[],i=b([...e.roots()],q(n),_(e=>(e.onlyOneInstance()||r.push(...e.children()),e)));return t.addExplicit(i),r.length>1&&t.addConnections(fn([...i,...r])),t},exclude:({stage:e,memory:t,where:n})=>{let r=b([...t.elements],q(n));return e.exclude(r),e}};function Vn(e,{expr:t,where:n,...r}){switch(!0){case O.isElementTagExpr(t):case O.isElementKindExpr(t):throw Error(`element kind and tag expressions are not supported in deployment view rules`);case xe.isCustom(t):case O.isCustom(t):case O.isModelRef(t):return;case O.isWhere(t):return kn[e]({...r,expr:t,where:n});case xe.isWhere(t):return zn[e]({...r,expr:t,where:n});case O.isDeploymentRef(t):return qn[e]({...r,expr:t,where:n});case O.isWildcard(t):return Bn[e]({...r,expr:t,where:n});case xe.isDirect(t):return In[e]({...r,expr:t,where:n});case xe.isInOut(t):return Rn[e]({...r,expr:t,where:n});case xe.isOutgoing(t):return Nn[e]({...r,expr:t,where:n});case xe.isIncoming(t):return An[e]({...r,expr:t,where:n});default:L(t)}}function G(e,{stage:t,memory:n},r,i=()=>!0){if(e.size===0)return t;let a=b(n.connections,y(e=>i(e)),y(t=>nt(t.relations.model,e)),_(t=>t.update({deployment:null,model:I(t.relations.model,e)})),K(r),y(e=>e.nonEmpty()));return a.length===0?t:t.excludeConnections(a)}function Hn(e,t){return K(e,t).nonEmpty()}function K(...e){if(e.length===1)return t=>K(t,e[0]);let[n,r]=e;return r===null?n:t(n)?n.map(e=>K(e,r)).filter(e=>e.nonEmpty()):n.update({model:new Set([...n.relations.model.values()].filter(e=>r(Gn(n)(e)))),deployment:new Set([...n.relations.deployment.values()].filter(e=>r(Gn(n)(e))))})}function q(...e){if(e.length===1)return t=>q(t,e[0]);let[n,r]=e;return t(n)?n.filter(e=>q(e,r)):r?.(Wn(n,n))??!0}function Un(e,t){return t?b(e,y(e=>Hn(e,t))):e}function Wn(e,t){if(Tt(e)){let n=wt(t)&&kt(t)?t:null;return{kind:e.kind,tags:[...e.tags,...n?.tags??[]],metadata:e.metadata}}if(_t(e))return te(e.element,[`tags`,`kind`,`metadata`]);if(kt(e))return{kind:e.element.kind,tags:[...e.tags,...e.element.tags],metadata:e.metadata};if(Ot(e))return te(e,[`tags`,`kind`,`metadata`]);L(e)}function Gn(e){return t=>({tags:t.tags,kind:t.kind,metadata:t.metadata,source:Wn(t.source,e.source),target:Wn(t.target,e.target)})}function Kn(e){let t=new Set;for(let n of e.descendingSiblings())t.add(n);return t}const qn={include:e=>{let{expr:t,where:n}=e,r=e.model.element(t.ref.deployment);if(kt(r))return q(r,n)&&(e.stage.addExplicit(r),e.stage.connectWithExisting(r)),e.stage;switch(!0){case t.selector===`expanded`:Yn(r,e);break;case t.selector===`children`:Jn(r,e);break;case t.selector===`descendants`:Xn(r,e);break;default:q(r,n)&&(e.stage.addExplicit(r),e.stage.connectWithExisting(r))}return e.stage},exclude:({expr:e,stage:t,memory:n,where:r})=>{let i=mn(e),a=b([...n.elements],y(i),q(r));return t.exclude(a),t}};function Jn(e,{stage:t,where:n}){let r=q([...e.children()],n);r.length!==0&&(t.addImplicit(e),t.addConnections(fn(r)),t.connectWithExisting(r),t.addExplicit(r))}function Yn(e,{memory:t,stage:n,where:r}){n.addImplicit(e),n.connectWithExisting(e);let i=q([...e.children()],r),a=!1;for(let e of i)if(U(e,t.elements).length>0){a=!0;break}a&&(n.connectWithExisting(i,`in`),n.addConnections(fn(i)),n.connectWithExisting(i,`out`)),n.addImplicit(i),n.connections.length>0&&n.addExplicit(e)}function Xn(e,{stage:t,where:n}){let r=e=>{let i=[];for(let t of e.children())t.isDeploymentNode()&&i.push(...r(t)),q(t,n)&&i.push(t);return t.connectWithExisting(i,`in`),t.addConnections(fn(i)),t.addImplicit(i),i},a=r(e);if(a.length===0)return;t.connectWithExisting(a,`out`);let o=Zn(t);b(a,y(e=>o.has(e)),i(e=>t.addExplicit(e)))}function Zn(e){return b(e.mergedConnections(),wn,En,re((e,t)=>(e.add(t.source),e.add(t.target),e),new Set))}var Qn=class e{static for(t){return new e(t)}constructor(e){this.memory=e}step1CleanConnections(e){if(e.connections.length<2)return e;let t=b(e.connections,wn,En),n=bt(e.connections,t);if(n.length===0)return e;let r=e.stageExclude({});return r.excludeConnections(n,!0),r.commit()}step2ProcessImplicits(e){let t=R(this.memory.elements,e.elements),n=R(e.final,this.memory.explicits),r=new B.default(()=>new Set);for(let t of e.connections)if(t.boundary)for(let e of t.relations.model)r.get(e).add(t.boundary);for(let[e,i]of r)if(!(i.size<2))for(let e of i)t.delete(e)&&n.add(e);let a=new Set(n),o=e=>{for(let t of a)if(e===t||j(e,t))return!0;return!1};return b(F(t,a),A(e=>e.isDeploymentNode()),P(),Xe,i(e=>{let t=[...e.children()].filter(o).length;if(t>=2){n.add(e);return}t===1&&at(e.siblings(),o)&&n.add(e)})),e.update({final:n})}step3ProcessBoundaries(e){let t=new Set;for(let n of e.connections)n.boundary&&t.add(n.boundary);let n=Kt(e,`final`),r=e.stageExclude({}),i=r=>!(t.has(r)||e.explicits.has(r)||n.hasInOut(r)||n.root.has(r)),a=S([...n.root]);a&&!e.explicits.has(a)&&r.exclude(a);for(let t of e.final){let e=S(n.children(t));e&&!n.hasInOut(e)&&i(t)&&r.exclude(t)}return r.isDirty()?r.commit():e}commit(){let e=this.step1CleanConnections(this.memory),t=this.step2ProcessImplicits(e);return this.step3ProcessBoundaries(t)}};function $n(e,t){let n=On.empty();for(let r of t)if(He(r)){let t=`include`in r?`include`:`exclude`,i=r.include??r.exclude;for(let r of i){let i=t===`include`?n.stageInclude(r):n.stageExclude(r);i=Vn(t,{expr:r,model:e,stage:i,memory:n,where:null})??i,n=i.commit()}}return Qn.for(n).commit()}function er(e,{docUri:t,rules:n,...r}){let i=$n(e.deployment,n),a=bn(e,i),o=yn(i.connections);It(a,o);let c=Vt({nodes:a,edges:o}),l=xn(n,c.nodes),u=s(n,je),d=Nt(l);return Ht({...r,[Ce]:`computed`,[Be]:`deployment`,autoLayout:{direction:u?.direction??`TB`,...u?.nodeSep&&{nodeSep:u.nodeSep},...u?.rankSep&&{rankSep:u.rankSep}},edges:c.edges,nodes:_(l,e=>(e.icon===`none`&&delete e.icon,e)),...d.length>0&&{notation:{nodes:d}}})}function tr(e){return t=>Ne(t)?t.groupRules.flatMap(tr(e)):He(t)&&`include`in t?t.include.filter(e):[]}function nr(e,t){let n=e.flatMap(tr(E.isCustom));if(n.length===0)return t;let r=[...t];for(let{custom:{expr:e,...t}}of n){let{border:n,opacity:i,multiple:a,iconColor:s,iconSize:c,iconPosition:l,padding:d,size:f,textSize:p,...m}=ye(t,u),h=T({border:n,opacity:i,multiple:a,iconColor:s,iconSize:c,iconPosition:l,padding:d,size:f,textSize:p}),g=!o(h),_=!o(m),v=H(e);r.forEach((e,t)=>{Ee(e)||!v(e)||(_&&(e={...e,...m,isCustomized:!0}),g&&(e={...e,isCustomized:!0,style:{...e.style,...h}}),r[t]=e)})}return r}function rr(e,t){return e.reduce((e,n)=>{if(ze(n)){let r=t.predicates[n.predicateId];return u(r)?e:e.concat(r)}if(Te(n)){let r=t.styles[n.styleId];return u(r)?e:e.concat(r)}return e.push(n),e},[])}function ir(e,t){return e.reduce((e,n)=>{if(ze(n)){let r=t.dynamicPredicates[n.predicateId];return u(r)?e:e.concat(r)}if(Te(n)){let r=t.styles[n.styleId];return u(r)?e:e.concat(r)}return e.push(n),e},[])}function ar(e,t){let n=new Set;for(let r of t)if(He(r))for(let t of r.include){let r=H(t);for(let t of e.elements())r(t)&&n.add(t)}return n}const or=e=>{if(Pe(e)){let t=[],n=[];for(let r of e.__parallel)if(Le(r)){let[e,...i]=r.__series;t.push(e),n.push(...i)}else t.push(r);return[...t,...n]}return Le(e)?[...e.__series]:e};function sr(e,t){let n=[],r=(...[e,t])=>{if(!n.includes(e)){let r=n.indexOf(t);if(r>0){n.splice(r,0,e);return}else n.push(e)}n.includes(t)||n.push(t)};for(let i of c(t,or)){let t=e.element(i.source),a=e.element(i.target),o=n.indexOf(t),s=n.indexOf(a);o>=0&&s>=0||(i.isBackward?r(a,t):r(t,a))}return new Set(n)}function cr(e,t,n){let r=vt(e,t,`directed`).flatMap(e=>[...e.relations]).sort(Qe);if(!Ge(r))return{};if(r.length===1){let e=r[0];return T({title:e.title??void 0,kind:e.kind??void 0,tags:e.tags,relations:[e.id],navigateTo:e.$relationship.navigateTo,color:e.$relationship.color,line:e.$relationship.line,technology:e.technology??void 0,description:e.$relationship.description??void 0})}let i=b(r,c(e=>e.tags),oe()),a=m(i,1)?i:void 0,o=_(r,e=>e.id),s=fe(r).$relationship.navigateTo;s===n&&(s=void 0),s||=b(r,c(e=>e.$relationship.navigateTo&&e.$relationship.navigateTo!==n?e.$relationship.navigateTo:[]),oe(),S());let l=b(r,re((e,{title:t,technology:n,$relationship:r})=>(f(t)&&e.title.add(t),f(r.color)&&e.color.add(r.color),f(r.line)&&e.line.add(r.line),f(r.kind)&&e.kind.add(r.kind),f(n)&&e.technology.add(n),f(r.description)&&!e.description.some(v(r.description))&&e.description.push(r.description),e),{kind:new Set,color:new Set,line:new Set,title:new Set,technology:new Set,description:[]}));return T({tags:a??void 0,relations:o,navigateTo:s,kind:S([...l.kind]),title:S([...l.title]),color:S([...l.color]),line:S([...l.line]),technology:S([...l.technology]),description:S(l.description)})}var lr=class{steps=[];constructor(e,t){this.model=e,this.view=t}compute(){let{docUri:e,rules:t,steps:n,...r}=this.view,i=ir(t,this.model.globals),a=ar(this.model,i),o=sr(this.model,n),c=b(R(I(a,o),o,a),P(),Ye),l=c.reduce((e,t,n,r)=>{for(let i=n+1;i<r.length;i++){let n=r[i];if(j(t,n)){e.push(t);break}}return e},[]),u=(e,t,n)=>{if(Le(e)){for(let r of e.__series)t=u(r,t,n);return t}let r=n?Ae(n,t):Ae(t),{source:i,target:a,title:o,isBackward:s,navigateTo:d,notation:p,...m}=e,h=this.model.element(i),g=c.indexOf(h);N(g>=0,`Source ${i} not found`);let _=this.model.element(a),v=c.indexOf(_);N(v>=0,`Target ${a} not found`),(l.includes(h)||l.includes(_))&&console.error(`Step ${h.id} -> ${_.id} because it involves a compound`);let{title:y,relations:ee,navigateTo:te,...ne}=cr(h,_,this.view.id),re=f(d)&&d!==this.view.id?d:te,b=e.kind&&!e.technology?this.model.specification.relationships[e.kind]?.technology:void 0;return this.steps.push(T({...ne,...m,...b&&{technology:b},id:r,source:h,target:_,navigateTo:re,title:o??y,relations:ee??[],isBackward:g>v})),t+1},d=1;for(let e of n){if(Pe(e)){let t=1;for(let n of e.__parallel)t=u(n,t,d);d++;continue}d=u(e,d)}let p=cn(this.model.$styles,c.map(sn)),m=this.model.$styles.defaults.relationship,h=this.steps.map(({id:e,source:t,target:n,relations:r,title:i,isBackward:a,tags:o,...s})=>{let c=k(p.get(t.id),`Source node ${t.id} not found`),l=k(p.get(n.id),`Target node ${n.id} not found`),u={id:e,parent:tt(t.id,n.id),source:c.id,target:l.id,label:i??null,relations:r,color:m.color,line:m.line,head:m.arrow,tags:o??[],...s};for(a&&(u.dir=`back`);u.parent&&!p.has(u.parent);)u.parent=We(u.parent);c.outEdges.push(u.id),l.inEdges.push(u.id);for(let e of Ue(u.source)){if(e===u.parent)break;p.get(e)?.outEdges.push(u.id)}for(let e of Ue(u.target)){if(e===u.parent)break;p.get(e)?.inEdges.push(u.id)}return u}),g=nr(i,Yt(i,c.map(e=>k(p.get(e.id))))),v=s(i,je),y=Nt(g);return Ht({...r,[Be]:`dynamic`,[Ce]:`computed`,variant:r.variant??`diagram`,autoLayout:{direction:v?.direction??`LR`,...v?.nodeSep&&{nodeSep:v.nodeSep},...v?.rankSep&&{rankSep:v.rankSep}},nodes:_(g,e=>(e.icon===`none`&&delete e.icon,e)),edges:h,...y.length>0&&{notation:{nodes:y}}})}};function ur(e,t){return new lr(e,t).compute()}function dr(e){switch(!0){case C.isCustom(e):return dr(e.customRelation.expr);case C.isWhere(e):{let t=dr(e.where.expr),n=w(e.where.condition);return e=>t(e)&&n({source:{tags:e.source.tags,kind:e.source.kind,metadata:e.source.metadata},target:{tags:e.target.tags,kind:e.target.kind,metadata:e.target.metadata},...e.tags&&{tags:e.tags},...e.kind&&{kind:e.kind},...e.metadata&&{metadata:e.metadata}})}case C.isDirect(e):{let t=H(e.source),n=H(e.target);return r=>t(r.source)&&n(r.target)||!!e.isBidirectional&&t(r.target)&&n(r.source)}case C.isInOut(e):{let t=H(e.inout);return e=>t(e.source)||t(e.target)}case C.isIncoming(e):{let t=H(e.incoming);return e=>t(e.target)}case C.isOutgoing(e):{let t=H(e.outgoing);return e=>t(e.source)}default:L(e)}}function fr(e,t,n){let r=e.flatMap(tr(C.isCustom)),i=Array.from(n);if(r.length===0||i.length===0)return i;for(let{customRelation:{expr:e,title:n,description:a,notes:o,...s}}of r){let r=a?{description:Re(a)}:{},c=o?{notes:Re(o)}:{},l=ye(s,u),d=dr(e);i.forEach((e,a)=>{let o,s;for(let n of t)if(n.id===e.source&&(o=n),n.id===e.target&&(s=n),o&&s)break;!o||!s||d({source:o,target:s,...te(e,[`kind`,`tags`])})&&(i[a]={...e,...l,...r,...c,label:n??e.label,isCustomized:!0})})}return i}function pr(e){return b([...e],dt,re((e,t,n,r)=>{let i=Mt(r,t),a=R(...i.map(ce(`relations`))),o=I(t.relations,a);if(i.length>0&&(o=R(o,t.directRelations)),At(r,t.reversed())&&(o=R(o,t.directRelations)),o.size<t.relations.size){let e=r.some(ut(t.source)),n=r.some(ut(t.target));e&&(o=R(o,z(A(t.relations,ft(t.source))))),n&&(o=R(o,z(A(t.relations,jt(t.target)))))}return o.size>0&&e.push(t.update(o)),e},[]))}var mr=class e{static for(t){return new e(t)}constructor(e){this.memory=e}step1CleanConnections(e){if(e.connections.length<2)return e;let t=pr(e.connections);if(t.length===0)return e;let n=e.stageExclude({});return n.excludeConnections(t,!0),n.commit()}step2ProcessImplicits(e){let t=R(this.memory.elements,e.elements),n=R(e.final,this.memory.explicits),r=new Set(n),a=e=>{for(let t of r)if(e===t||j(e,t))return!0;return!1};return b(F(t,r),P(),Xe,i(e=>{let t=[...e.children()].filter(a).length;if(t>=2){n.add(e);return}t===1&&at(e.siblings(),a)&&n.add(e)})),e.update({final:n})}step3ProcessBoundaries(e){let t=new Set;for(let n of e.connections)n.boundary&&n.boundary!==n.source&&n.boundary!==n.target&&t.add(n.boundary);let n=Kt(e,`final`),r=e.stageExclude({}),i=r=>!(t.has(r)||e.explicits.has(r)||n.hasInOut(r)||n.root.has(r)),a=S([...n.root]);a&&!e.explicits.has(a)&&r.exclude(a);for(let t of e.final){let e=S(n.children(t));e&&!n.hasInOut(e)&&i(t)&&r.exclude(t)}return r.isDirty()?r.commit():e}commit(){let e=this.step1CleanConnections(this.memory),t=this.step2ProcessImplicits(e);return this.step3ProcessBoundaries(t)}};const{findConnection:hr,findConnectionsBetween:J,findConnectionsWithin:Y}=Et;function X(e,t){switch(!0){case E.isElementKindExpr(t):return[...A(e.elements(),e=>t.isEqual===(e.kind===t.elementKind))];case E.isElementTagExpr(t):return[...A(e.elements(),e=>t.isEqual===e.tags.includes(t.elementTag))];case t.selector===`expanded`:{let n=e.element(D.flatten(t.ref));return[n,...n.children()]}case t.selector===`children`:case t.selector===`descendants`:{let n=e.element(D.flatten(t.ref)),r=t.selector===`children`?P(n.children()):P(n.descendants());return r&&r.length>0?r:[n]}case E.isModelRef(t):return[e.element(D.flatten(t.ref))];default:L(t)}}function gr(e,t){if(t.isEmpty()||e.length===0)return e;let n=x(e.map(e=>Ke(e))),r=P(A(t.elements,t=>!e.includes(t)&&n(t)));return[...e,...r]}function _r(e,{memory:t,model:n}){let r=X(n,e);return E.isModelRef(e)?e.selector===`descendants`?r:gr(r,t):r}const vr={include:({expr:e,model:t,stage:n,where:r})=>{let i=t.element(D.flatten(e.ref));r(i)&&(n.addExplicit(i),n.connectWithExisting(i));let a=[...i.children()].filter(r),o=[];for(let e of a)n.addImplicit(e),n.connectWithExisting(e)&&o.push(e);return n.addConnections(Y(o)),n},exclude:({expr:e,model:t,stage:n,filterWhere:r})=>{let i=r(X(t,e));return n.exclude(i),n}},yr={include:({expr:e,model:t,stage:n,filterWhere:r})=>{let i=r(X(t,e));if(i.length!==0)return n.addExplicit(i),n.connectWithExisting(i),n.addConnections(Y(i)),n},exclude:({expr:e,model:t,stage:n,filterWhere:r})=>{let i=r(X(t,e));return n.exclude(i),n}},br={include:({expr:e,model:t,stage:n,filterWhere:r})=>{let i=r(X(t,e));if(i.length!==0)return n.addExplicit(i),n.connectWithExisting(i),n.addConnections(Y(i)),n},exclude:({expr:e,model:t,stage:n,filterWhere:r})=>{let i=r(X(t,e));return n.exclude(i),n}},xr=()=>!0,Sr=e=>e;function Cr(e){return e.reduce((e,t)=>{let n=[...t.relations];N(m(n,1),`Edge must have at least one relation`);let r=t.source.$model.$styles.defaults,i=t.source.id,a=t.target.id,{title:o,color:s=r.relationship.color,line:c=r.relationship.line,head:l=r.relationship.arrow,...u}=un(n.map(e=>e.$relationship),S(y(n,e=>e.source.id===i&&e.target.id===a))?.$relationship),d=T({id:t.id,parent:t.boundary?.id??null,source:i,target:a,label:o??null,relations:n.map(e=>e.id),color:s,line:c,head:l,...u});return e.push(d),e},[])}function wr(e,t){return cn(e.$styles,[...t.final].map(sn),t.groups)}const Z=E.isWildcard,Tr=(e,t)=>e.isAncestorOf(t)||e.isDescendantOf(t),Er={include:({expr:{source:e,target:t,isBidirectional:n=!1},memory:r,model:i,stage:a,where:o,filterWhere:s})=>{let l=Z(e),u=Z(t),d=[];switch(!0){case l&&u&&r.isEmpty()&&o!==xr:{let e=b(i.relationships(),A(o),P(),_(e=>new xt(e.source,e.target,new Set([e]))));return a.addConnections(e),a}case l&&u&&!r.isEmpty()&&o!==xr:d.push(...Y(r.elements));break;case l&&u:d.push(...Y(i.roots()));break;case!l&&u&&o!==xr:{let t=b(X(i,e),c(e=>b(e,le(he(n===!0),{onTrue:e=>R(e.allIncoming,e.allOutgoing),onFalse:e=>e.allOutgoing}),A(o),$e(),P(),_e(t=>t.source===e),([t,n])=>ue(b(t,y(t=>!Tr(e,t.target)),_(t=>new xt(e,t.target,new Set([t])))),b(n,y(t=>!Tr(e,t.source)),_(t=>new xt(t.source,e,new Set([t]))))))));return a.addConnections(t),a}case!l&&u:{let[t,a]=Dr(e,{memory:r,model:i}),o=n?`both`:`directed`;for(let e of t)d.push(...J(e,a,o));break}case l&&!u&&o!==xr:{let e=b(X(i,t),c(e=>b(e,le(he(n===!0),{onTrue:e=>R(e.allIncoming,e.allOutgoing),onFalse:e=>e.allIncoming}),A(o),P(),_e(t=>t.target===e),([t,n])=>ue(b(n,y(t=>!Tr(e,t.target)),_(t=>new xt(e,t.target,new Set([t])))),b(t,y(t=>!Tr(e,t.source)),_(t=>new xt(t.source,e,new Set([t]))))))));return a.addConnections(e),a}case l&&!u:{let[e,a]=Dr(t,{memory:r,model:i}),o=n?`both`:`directed`;for(let t of a)d.push(...J(t,e,o));break}default:{N(!Z(e),`Inference failed - source must be not a wildcard`),N(!Z(t),`Inference failed - target must be not a wildcard`);let a=_r(e,{memory:r,model:i}),o=_r(t,{memory:r,model:i}),s=n?`both`:`directed`;for(let e of a)d.push(...J(e,o,s))}}return a.addConnections(s(d)),a},exclude:({expr:{source:e,target:t,isBidirectional:n},model:r,memory:i,stage:a,where:o})=>{let s=Z(e),l=Z(t),u;switch(!0){case s&&l:u=b(i.connections,c(ae(ce(`relations`),A(o),P())),z());break;case!s&&l:u=b(X(r,e),c(e=>b(e,le(he(n===!0),{onTrue:e=>R(e.allIncoming,e.allOutgoing),onFalse:e=>e.allOutgoing}),A(o),P())),z());break;case s&&!l:u=b(X(r,t),c(e=>b(e,le(he(n===!0),{onTrue:e=>R(e.allIncoming,e.allOutgoing),onFalse:e=>e.allIncoming}),A(o),P())),z());break;default:{N(!Z(e),`Inference failed - source must be not a wildcard`),N(!Z(t),`Inference failed - target must be not a wildcard`);let i=X(r,e),a=X(r,t),s=new Set;for(let e of i)for(let t of a)Je(e,t)||(s=R(s,I(e.allOutgoing,t.allIncoming),n?I(t.allOutgoing,e.allIncoming):new Set));u=z(A(s,o))}}return a.excludeRelations(u),a}};function Dr(e,{memory:t,model:n}){let r=X(n,e);if(!m(r,1))return[[],[]];if(E.isModelRef(e)){let i=P(n.element(D.flatten(e.ref)).ascendingSiblings());return[gr(r,t),gr(i,t)]}return[r,b(r,_(e=>e.ascendingSiblings()),rt(),$e(),P(),e=>gr(e,t))]}const Or={include:({expr:e,scope:t,model:n,memory:r,stage:i,filterWhere:a})=>{let o=e.incoming,s=[];if(E.isWildcard(o)){if(!t)return;for(let e of t.ascendingSiblings())s.push(...hr(e,t,`directed`))}else{let e=_r(o,{memory:r,model:n}),t=[...r.elements];t.length===0&&t.push(...oe(e.flatMap(e=>[...e.ascendingSiblings()])));let i=kr(n,o);for(let n of t)s.push(...J(n,e,`directed`).filter(i))}return i.addConnections(a(s)),i},exclude:({expr:{incoming:e},model:t,scope:n,stage:r,where:i})=>{let a=[];if(E.isWildcard(e)){if(!n)return;a.push(...n.allIncoming)}else{let n=X(t,e);a.push(...n.flatMap(e=>[...e.allIncoming]))}return r.excludeRelations(new Set(a.filter(i))),r}};function kr(e,t){switch(!0){case E.isElementKindExpr(t):case E.isElementTagExpr(t):{let e=H(t);return t=>e(t.target)}case E.isModelRef(t)&&t.selector===`children`:{let n=D.flatten(t.ref);return x([...e.children(n)].map(e=>V.isIncoming(e.id)))}case E.isModelRef(t)&&t.selector===`descendants`:{let n=D.flatten(t.ref);return x([V.isInside(n),...[...e.children(n)].map(e=>V.isIncoming(e.id))])}case E.isModelRef(t)&&t.selector===`expanded`:{let e=D.flatten(t.ref);return x([V.isIncoming(e),V.isInside(e)])}case E.isModelRef(t):{let e=D.flatten(t.ref);return V.isIncoming(e)}default:L(t)}}const Ar={include:({expr:{inout:e},scope:t,model:n,memory:r,stage:i,filterWhere:a})=>{let o=[];if(E.isWildcard(e)){if(!t)return;o.push(...J(t,t.ascendingSiblings()))}else{let t=_r(e,{memory:r,model:n}),i=[...r.elements];i.length===0&&(i=oe(t.flatMap(e=>P(e.ascendingSiblings()))));for(let e of t)o.push(...J(e,i))}return i.addConnections(a(o)),i},exclude:({expr:{inout:e},model:t,scope:n,stage:r,where:i})=>{let a=[];if(E.isWildcard(e)){if(!n)return;a.push(...n.allOutgoing),a.push(...n.allIncoming)}else{let n=X(t,e);a.push(...n.flatMap(e=>[...e.allOutgoing,...e.allIncoming]))}return r.excludeRelations(z(a.filter(i))),r}},jr={include:({expr:e,scope:t,model:n,memory:r,stage:i,filterWhere:a})=>{let o=e.outgoing,s=[];if(E.isWildcard(o)){if(!t)return;s.push(...J(t,t.ascendingSiblings(),`directed`))}else{let e=_r(o,{memory:r,model:n}),t=[...r.elements];t.length===0&&t.push(...oe(e.flatMap(e=>[...e.ascendingSiblings()])));let i=Mr(n,o);for(let n of e)s.push(...J(n,t,`directed`).filter(i))}return i.addConnections(a(s)),i},exclude:({expr:{outgoing:e},model:t,scope:n,stage:r,where:i})=>{let a=[];if(E.isWildcard(e)){if(!n)return;a.push(...n.allOutgoing)}else{let n=X(t,e);a.push(...n.flatMap(e=>[...e.allOutgoing]))}return r.excludeRelations(z(a.filter(i))),r}};function Mr(e,t){switch(!0){case E.isElementKindExpr(t):case E.isElementTagExpr(t):{let e=H(t);return t=>e(t.source)}case E.isModelRef(t)&&t.selector===`children`:{let n=D.flatten(t.ref);return x([...e.children(n)].map(e=>V.isOutgoing(e.id)))}case E.isModelRef(t)&&t.selector===`descendants`:{let n=D.flatten(t.ref);return x([V.isInside(n),...[...e.children(n)].map(e=>V.isOutgoing(e.id))])}case E.isModelRef(t)&&t.selector===`expanded`:{let e=D.flatten(t.ref);return x([V.isOutgoing(e),V.isInside(e)])}case E.isModelRef(t):{let e=D.flatten(t.ref);return V.isOutgoing(e)}default:L(t)}}const Nr={include:({scope:e,model:t,stage:n,memory:r,where:i})=>{if(!e){let e=[...t.roots()].filter(i);if(e.length===0)return;let[r,a]=_e(e,e=>!e.imported);return n.addExplicit(r),n.addImplicit(a),n.addConnections(Y(e)),n.connectWithExisting(e),n}let a=i(e)?e:null,o=P(A(e.children(),i)),s=o.length>0;if(!s)if(a){if(J(a,a.siblings()).length===0){let e=a.parent;e&&i(e)&&n.addExplicit(e)}o.push(a)}else return n;a&&n.addExplicit(a);let c=z([...r.elements,...e.descendingSiblings()]);for(let e of c)n.addConnections(J(e,o,`directed`));s&&(n.addConnections(Y(o)),n.addExplicit(o));for(let e of o)n.addConnections(J(e,c,`directed`));return n},exclude:({scope:e,memory:t,stage:n,where:r})=>r===xr?e?(n.exclude([e,...e.descendants()]),n):rn.empty(t.scope).stageExclude(n.expression):(n.exclude(y([...t.elements],r)),n)};function Pr(e,t,n){switch(!0){case E.isCustom(e):return t===`include`?Pr(e.custom.expr,t,n):n.stage;case E.isWhere(e):{let r=w(e.where.condition),i=e=>y(e,r);return Pr(e.where.expr,t,{...n,where:r,filterWhere:i})}case E.isModelRef(e)&&e.selector===`expanded`:return vr[t]({...n,expr:e})??n.stage;case E.isWildcard(e):return Nr[t]({...n,expr:e})??n.stage;case E.isElementKindExpr(e):case E.isElementTagExpr(e):return yr[t]({...n,expr:e})??n.stage;case E.isModelRef(e):return br[t]({...n,expr:e})??n.stage;default:L(e)}}function Fr(e,t,n){switch(!0){case C.isCustom(e):return t===`include`?Fr(e.customRelation.expr,t,n):n.stage;case C.isWhere(e):{let r=w(e.where.condition),i=e=>new Set(y([...e],r)),a=e=>b(e,_(e=>new xt(e.source,e.target,i(e.relations))),y(e=>e.nonEmpty()));return Fr(e.where.expr,t,{...n,where:r,filterWhere:a})}case C.isInOut(e):return Ar[t]({...n,expr:e})??n.stage;case C.isDirect(e):return Er[t]({...n,expr:e})??n.stage;case C.isOutgoing(e):return jr[t]({...n,expr:e})??n.stage;case C.isIncoming(e):return Or[t]({...n,expr:e})??n.stage;default:L(e)}}function Ir(e,t,n){let r={model:e,scope:t.scope,where:xr,filterWhere:Sr};for(let i of n){if(Ne(i)){t=Ir(e,an.enter(t,i),i.groupRules),N(t instanceof an,`processPredicates must return ActiveGroupMemory`),t=t.leave();continue}if(He(i)){let e=`include`in i?`include`:`exclude`,n=i.include??i.exclude;for(let i of n){let n=e===`include`?t.stageInclude(i):t.stageExclude(i);switch(!0){case Se.isFqnExpr(i):n=Pr(i,e,{...r,stage:n,memory:t})??n;break;case Se.isRelationExpr(i):n=Fr(i,e,{...r,stage:n,memory:t})??n;break;default:L(i)}t=n.commit()}}}return t}function Lr(e,t,n){return t=Ir(e,t,n),mr.for(t).commit()}function Rr(e,{docUri:t,rules:n,...r}){let i=rr(n,e.globals),a=r.viewOf?e.asComputed.element(r.viewOf):null,o=Lr(e,rn.empty(a),i);o.isEmpty()&&a&&(o=o.update({final:new Set([a])})),o=Br(o);let c=wr(e,o),l=Cr(o.connections);It(c,l);let u=Vt({nodes:c,edges:l}),d=nr(i,Yt(i,u.nodes)),f=s(i,je),p=Nt(d),m=zr(i,d);return Ht({...r,_stage:`computed`,autoLayout:{direction:f?.direction??`TB`,...f?.nodeSep&&{nodeSep:f.nodeSep},...f?.rankSep&&{rankSep:f.rankSep}},edges:fr(i,d,u.edges),nodes:_(d,e=>(e.icon===`none`&&delete e.icon,e)),...p.length>0&&{notation:{nodes:p}},...m.length>0&&{ranks:m}})}function zr(e,t){let n=[];for(let r of e){if(!Ie(r)||r.targets.length===0)continue;let e=b(t,y(x(r.targets.map(H))),_(e=>e.id));m(e,1)&&n.push({type:r.rank,nodes:e})}return n}function Br(e){if(e.groups.length===0)return e;let t=new B.default(()=>new Set),n=new Map,r=e=>{for(let r of e.ancestors()){let i=n.get(r);if(i)return n.set(e,i),t.get(i).add(e),!0}return!1},a=e=>{for(let r of e.descendants(`asc`)){let i=n.get(r);if(i)return n.set(e,i),t.get(i).add(e),!0}return!1};if(b(Ye([...e.explicitFirstSeenIn.keys()]),i(i=>{if(!r(i)){let r=k(e.explicitFirstSeenIn.get(i));n.set(i,r),t.get(r).add(i)}})),b(Ye([...e.lastSeenIn.keys()]),y(e=>!n.has(e)),i(i=>{if(r(i)||a(i))return;let o=k(e.lastSeenIn.get(i));n.set(i,o),t.get(o).add(i)})),t.size===0)return e;let o=e.groups.map(e=>{let n=t.get(e.id);return n?e.update(n):e});return e.update({groups:o})}function Vr(e,t){switch(!0){case Oe(e):return Rr(t,e);case Fe(e):return er(t,e);case ke(e):return ur(t,e);default:L(e)}}function Hr(e,t){try{return{isSuccess:!0,view:Vr(e,t)}}catch(e){return{isSuccess:!1,error:e instanceof Error?e:Error(`Unknown error: ${e}`),view:void 0}}}function Ur(e){let t=pt.create(e),{views:r,_stage:i,...a}=e,o=n(r,e=>Vr(e,t));return{[Ce]:`computed`,...a,views:o}}function Wr(e){return pt.create(Ur(e))}const Q=e=>e;function $(e){if(!se(e))return e;if(e===`*`)return Q({wildcard:!0});if(e.startsWith(`->`))return e.endsWith(`->`)?Q({inout:$(e.replace(/->/g,``).trim())}):Q({incoming:$(e.replace(`-> `,``))});if(e.endsWith(` ->`))return Q({outgoing:$(e.replace(` ->`,``))});if(e.includes(` <-> `)){let[t,n]=e.split(` <-> `);return Q({source:$(t),target:$(n),isBidirectional:!0})}if(e.includes(` -> `)){let[t,n]=e.split(` -> `);return Q({source:$(t),target:$(n)})}return e.endsWith(`._`)?Q({ref:{model:e.replace(`._`,``)},selector:`expanded`}):e.endsWith(`.**`)?Q({ref:{model:e.replace(`.**`,``)},selector:`descendants`}):e.endsWith(`.*`)?Q({ref:{model:e.replace(`.*`,``)},selector:`children`}):Q({ref:{model:e}})}export{Vr as a,It as c,Hr as i,Wr as n,Rr as o,Ur as r,Vt as s,$ as t};
@@ -1,4 +1,4 @@
1
- import { $i as IteratorLike, $r as Stage, Ar as Any, Br as ElementKind, C as LayoutedView, Ci as IconUrl, Di as ProjectId, Fi as ViewId$1, Fr as DeploymentFqn, Gr as LooseTag, Hr as LooseDeploymentId, Ht as DynamicViewDisplayVariant, Ir as DeploymentId, Ji as _type, Jr as MetadataKey, Kr as LooseViewId, Lr as DeploymentKind, Mr as AnyLayouted, Nr as AnyParsed, Oi as RelationId, Ot as Element, Pr as Aux, Qn as FqnRef, Rt as ModelGlobals, S as ComputedView, St as DeploymentNode, Ti as NodeId, Ur as LooseElementId, Vr as Fqn, Wn as WhereOperator, Xr as RelationId$1, Yr as ProjectId$1, Zr as RelationKind, _ as ComputedLikeC4ModelData, _i as EdgeId, ai as UnknownLayouted, ar as ElementShape, b as ParsedLikeC4ModelData, bt as DeploymentElement, ct as LikeC4Project, d as AuxFromDump, ei as StrictViewId, er as Color, et as ViewManualLayoutSnapshot, f as LikeC4ModelDump, fi as toComputed, fr as RelationshipArrowType, gt as Specification, hr as RelationshipLineType, ii as UnknownComputed, ji as StepEdgeId, jr as AnyComputed, jt as Relationship, k as ViewWithType, kt as ElementStyle, l as RichTextOrEmpty, ni as Tags, oi as UnknownParsed, ot as ComputedNodeStyle, qi as _stage, qr as Metadata, ra as NonEmptyArray, ri as Unknown, si as ViewId, ta as Link, ti as Tag, v as LayoutedLikeC4ModelData, wt as DeploymentRelationship, xi as GroupElementKind, yt as DeployedInstance, zr as ElementId } from "./index.mjs";
1
+ import { $r as RelationKind, Ai as RelationId, C as LayoutedView, Ci as GroupElementKind, Di as NodeId, Fr as AnyParsed, Gn as WhereOperator, Gr as LooseElementId, Hr as ElementKind, Ht as DynamicViewDisplayVariant, Ir as Aux, Jr as LooseViewId, Li as ViewId$1, Lr as DeploymentFqn, Mr as Any, Ni as StepEdgeId, Nr as AnyComputed, Ot as Element, Pr as AnyLayouted, Qr as RelationId$1, Rr as DeploymentId, Rt as ModelGlobals, S as ComputedView, St as DeploymentNode, Ti as IconUrl, Ur as Fqn, Vr as ElementId, Wr as LooseDeploymentId, Xi as _type, Xr as MetadataKey, Yi as _stage, Yr as Metadata, Zr as ProjectId$1, _ as ComputedLikeC4ModelData, _r as RelationshipLineType, aa as NonEmptyArray, ai as Unknown, b as ParsedLikeC4ModelData, bt as DeploymentElement, ci as UnknownParsed, ct as LikeC4Project, d as AuxFromDump, er as FqnRef, et as ViewManualLayoutSnapshot, f as LikeC4ModelDump, gt as Specification, ii as Tags, jt as Relationship, k as ViewWithType, ki as ProjectId, kt as ElementStyle, l as RichTextOrEmpty, li as ViewId, mi as toComputed, mr as RelationshipArrowType, ni as StrictViewId, nr as Color, oi as UnknownComputed, ot as ComputedNodeStyle, qr as LooseTag, ra as Link, ri as Tag, si as UnknownLayouted, sr as ElementShape, ta as IteratorLike, ti as Stage, v as LayoutedLikeC4ModelData, wt as DeploymentRelationship, yi as EdgeId, yt as DeployedInstance, zr as DeploymentKind } from "./index.mjs";
2
2
  import { i as BBox } from "./index2.mjs";
3
3
  import { i as LikeC4Styles } from "./index3.mjs";
4
4
  import { o as DefaultMap } from "./libs/mnemonist.mjs";
@@ -62,6 +62,7 @@ declare class RelationshipModel<A extends Any = Any> implements AnyRelationshipM
62
62
  get navigateTo(): LikeC4ViewModel<A> | null;
63
63
  get tags(): Tags<A>;
64
64
  get kind(): RelationKind<A> | null;
65
+ get metadata(): Metadata<A>;
65
66
  get links(): ReadonlyArray<Link>;
66
67
  get color(): Color;
67
68
  get line(): RelationshipLineType;
@@ -110,6 +111,7 @@ declare class ElementModel<A extends Any = Any> implements WithTags<A>, WithMeta
110
111
  * It includes tags from the element and its kind.
111
112
  */
112
113
  get tags(): Tags<A>;
114
+ get metadata(): Metadata<A>;
113
115
  get title(): string;
114
116
  /**
115
117
  * Returns true if the element has a summary and a description
@@ -817,6 +819,7 @@ declare class DeploymentNodeModel<A extends Any = Any> extends AbstractDeploymen
817
819
  constructor($model: LikeC4DeploymentModel<A>, $node: DeploymentNode<A>);
818
820
  get parent(): DeploymentNodeModel<A> | null;
819
821
  get kind(): DeploymentKind<A>;
822
+ get metadata(): Metadata<A>;
820
823
  get tags(): Tags<A>;
821
824
  children(): ReadonlySet<DeploymentElementModel<A>>;
822
825
  descendants(sort?: 'asc' | 'desc'): DeploymentElementsIterator<A>;
@@ -862,6 +865,11 @@ declare class DeployedInstanceModel<A extends Any = Any> extends AbstractDeploym
862
865
  get style(): SetRequired<ElementStyle, 'shape' | 'color' | 'size'>;
863
866
  get tags(): Tags<A>;
864
867
  get kind(): ElementKind<A>;
868
+ /**
869
+ * Instance metadata overrides element metadata entirely (replacement, not merge).
870
+ * This differs from tags which are merged from instance + element.
871
+ */
872
+ get metadata(): Metadata<A>;
865
873
  get summary(): RichTextOrEmpty;
866
874
  get description(): RichTextOrEmpty;
867
875
  get technology(): string | null;
@@ -920,6 +928,7 @@ declare class DeploymentRelationModel<A extends Any = Any> implements AnyRelatio
920
928
  get description(): RichTextOrEmpty;
921
929
  get tags(): Tags<A>;
922
930
  get kind(): RelationKind<A> | null;
931
+ get metadata(): Metadata<A>;
923
932
  get navigateTo(): LikeC4ViewModel<A> | null;
924
933
  get links(): ReadonlyArray<Link>;
925
934
  get color(): Color;
@@ -1,4 +1,4 @@
1
- import { $n as BorderStyle, An as Expression, Ar as Any, At as ModelRelation, On as ModelFqnExpr, Ot as Element, Pr as Aux, Qr as SpecAux, Vn as Participant, W as ParsedDeploymentView, _t as TagSpecification, ar as ElementShape, b as ParsedLikeC4ModelData, br as ThemeColor, bt as DeploymentElement, di as setProject, dt as LikeC4ProjectStylesConfig, ea as KeysOf, fr as RelationshipArrowType, gr as ShapeSize, hi as DeploymentFqn, hr as RelationshipLineType, ht as RelationshipSpecification, in as ParsedElementView, kn as ModelRelationExpr, ln as AnyViewRuleStyle, mt as ElementSpecification$1, ra as NonEmptyArray, sr as IconPosition, un as AutoLayoutDirection, vr as SpacingSize, w as ParsedView, wi as MarkdownOrString, wt as DeploymentRelationship, yi as Fqn, yr as TextSize } from "./index.mjs";
1
+ import { An as Expression, At as ModelRelation, Ei as MarkdownOrString, Hn as Participant, Ir as Aux, Mr as Any, On as ModelFqnExpr, Ot as Element, Sr as ThemeColor, W as ParsedDeploymentView, _i as DeploymentFqn, _r as RelationshipLineType, _t as TagSpecification, aa as NonEmptyArray, b as ParsedLikeC4ModelData, br as SpacingSize, bt as DeploymentElement, dt as LikeC4ProjectStylesConfig, ei as SpecAux, ht as RelationshipSpecification, in as ParsedElementView, kn as ModelRelationExpr, ln as AnyViewRuleStyle, lr as IconPosition, mr as RelationshipArrowType, mt as ElementSpecification$1, na as KeysOf, pi as setProject, sr as ElementShape, tr as BorderStyle, un as AutoLayoutDirection, vr as ShapeSize, w as ParsedView, wt as DeploymentRelationship, xi as Fqn, xr as TextSize } from "./index.mjs";
2
2
  import { n as LikeC4Model } from "./LikeC4Model.mjs";
3
3
  import { IfNever, IsLiteral, IsNever, LastArrayElement, PartialDeep, Simplify, Split, Tagged, TupleToUnion, Writable } from "type-fest";
4
4
 
@@ -269,10 +269,13 @@ interface LikeC4ViewBuilder<Types extends AnyTypes, Fqn extends string, TypedExp
269
269
  Expr: Expr;
270
270
  TypedExpr: TypedExpr;
271
271
  $expr(expr: Expr | TypedExpr): TypedExpr;
272
- include(...exprs: Expr[]): this;
273
- exclude(...exprs: Expr[]): this;
272
+ include(...exprs: TypedExpr[]): this;
273
+ exclude(...exprs: TypedExpr[]): this;
274
274
  style(rule: AnyViewRuleStyle<any>): this;
275
- autoLayout(layout: AutoLayoutDirection): this;
275
+ autoLayout(layout: AutoLayoutDirection, margins: {
276
+ rank: number;
277
+ node: number;
278
+ } | undefined): this;
276
279
  }
277
280
  declare namespace ViewPredicate {
278
281
  type ElementExpr<Fqn extends string> = '*' | Fqn | `${Fqn}.*` | `${Fqn}._` | `${Fqn}.**`;
@@ -305,7 +308,7 @@ declare namespace ViewPredicate {
305
308
  }>;
306
309
  };
307
310
  }
308
- declare function $include<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(...args: [B['Expr']] | [B['TypedExpr']] | [B['Expr'], ViewPredicate.Custom<B['Types']>]): (b: B) => B;
311
+ declare function $include<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(...args: [B['Expr']] | [B['TypedExpr']] | [B['Expr'], ViewPredicate.Custom<B['Types']>] | [B['Expr'], B['Expr'], ...B['Expr'][]]): (b: B) => B;
309
312
  declare function $exclude<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(...args: [B['Expr']] | [B['TypedExpr']] | [B['Expr'], ViewPredicate.Custom<B['Types']>] | [B['TypedExpr'], ViewPredicate.Custom<B['Types']>]): (b: B) => B;
310
313
  /**
311
314
  * @example
@@ -328,7 +331,10 @@ declare function $style<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(element
328
331
  }: AnyViewRuleStyle<any>['style'] & {
329
332
  notation?: string;
330
333
  }): (b: B) => B;
331
- declare function $autoLayout<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(layout: AutoLayoutDirection): (b: B) => B;
334
+ declare function $autoLayout<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(layout: AutoLayoutDirection, margins?: {
335
+ rank: number;
336
+ node: number;
337
+ }): (b: B) => B;
332
338
  type Op<T> = (b: T) => T;
333
339
  declare function $rules<B extends LikeC4ViewBuilder<AnyTypes, any, any>>(...rules: Op<B>[]): (b: B) => B;
334
340
  //#endregion
@@ -680,6 +686,7 @@ type NewElementProps<Tag, Metadata> = {
680
686
  iconColor?: ThemeColor;
681
687
  iconSize?: ShapeSize;
682
688
  iconPosition?: IconPosition;
689
+ multiple?: boolean;
683
690
  };
684
691
  };
685
692
  type NewDeploymentNodeProps<Tag, Metadata> = {
@@ -705,6 +712,7 @@ type NewDeploymentNodeProps<Tag, Metadata> = {
705
712
  iconColor?: ThemeColor;
706
713
  iconSize?: ShapeSize;
707
714
  iconPosition?: IconPosition;
715
+ multiple?: boolean;
708
716
  };
709
717
  };
710
718
  type NewViewProps<Tag> = {
@@ -1,4 +1,4 @@
1
- import { Di as ProjectId, G as DiagramEdge, Ji as _type, K as DiagramNode, at as ComputedNode, fn as BaseViewProperties, hn as ViewAutoLayout, qi as _stage, rt as ComputedEdge } from "./index.mjs";
1
+ import { G as DiagramEdge, K as DiagramNode, Xi as _type, Yi as _stage, at as ComputedNode, fn as BaseViewProperties, hn as ViewAutoLayout, ki as ProjectId, rt as ComputedEdge } from "./index.mjs";
2
2
  import { i as BBox } from "./index2.mjs";
3
3
 
4
4
  //#region src/compute-view/projects-view/_types.d.ts
@@ -1 +1 @@
1
- import{O as e,T as t,X as n,et as r,l as i,m as a,nt as o,p as s}from"./libs/remeda.mjs";import{F as c}from"./types.mjs";import{$ as l,J as u}from"./utils.mjs";function d(d){let f=[],p=[];for(let[t,r]of n(d))e(r.color)?f.push({tag:t,spec:{color:r.color}}):p.push(t);return r(p,i(u),t((e,t)=>({tag:e,spec:{color:l(c[t%c.length])}})),o(f),i((e,t)=>u(e.tag,t.tag)),s(a(`tag`),a(`spec`)))}export{d as t};
1
+ import{O as e,T as t,X as n,et as r,l as i,m as a,nt as o,p as s}from"./libs/remeda.mjs";import{I as c}from"./types.mjs";import{$ as l,J as u}from"./utils.mjs";function d(d){let f=[],p=[];for(let[t,r]of n(d))e(r.color)?f.push({tag:t,spec:{color:r.color}}):p.push(t);return r(p,i(u),t((e,t)=>({tag:e,spec:{color:l(c[t%c.length])}})),o(f),i((e,t)=>u(e.tag,t.tag)),s(a(`tag`),a(`spec`)))}export{d as t};
@@ -1,5 +1,5 @@
1
1
  import { c as XYPoint, i as BBox, s as Point } from "./index2.mjs";
2
- import { IfNever, IsAny, IsLiteral, IsNever, KeysOfUnion, PartialDeep, SetNonNullable, SetRequired, Simplify, Tagged, TupleToUnion, UnionToIntersection, WritableDeep } from "type-fest";
2
+ import { IfNever, IsAny, IsLiteral, IsNever, IsUnknown, KeysOfUnion, Or, PartialDeep, SetNonNullable, SetRequired, Simplify, Tagged, TupleToUnion, UnionToIntersection, WritableDeep } from "type-fest";
3
3
 
4
4
  //#region src/types/_common.d.ts
5
5
  type NonEmptyArray<T> = [T, ...T[]];
@@ -548,6 +548,7 @@ type AllNever = {
548
548
  or?: never;
549
549
  tag?: never;
550
550
  kind?: never;
551
+ metadata?: never;
551
552
  participant?: never;
552
553
  operator?: never;
553
554
  };
@@ -559,10 +560,17 @@ type KindEqual<A extends Any> = Omit<AllNever, 'kind'> & {
559
560
  kind: EqualOperator<AllKinds<A>> | AllKinds<A>;
560
561
  };
561
562
  declare function isKindEqual<A extends Any>(operator: WhereOperator<A>): operator is KindEqual<A>;
563
+ type MetadataEqual<A extends Any> = Omit<AllNever, 'metadata'> & {
564
+ metadata: {
565
+ key: string;
566
+ value?: EqualOperator<string> | string;
567
+ };
568
+ };
569
+ declare function isMetadataEqual<A extends Any>(operator: WhereOperator<A>): operator is MetadataEqual<A>;
562
570
  type Participant = 'source' | 'target';
563
571
  type ParticipantOperator<A extends Any> = Omit<AllNever, 'participant' | 'operator'> & {
564
572
  participant: Participant;
565
- operator: KindEqual<A> | TagEqual<A>;
573
+ operator: KindEqual<A> | TagEqual<A> | MetadataEqual<A>;
566
574
  };
567
575
  declare function isParticipantOperator<A extends Any>(operator: WhereOperator<A>): operator is ParticipantOperator<A>;
568
576
  type NotOperator<A extends Any> = Omit<AllNever, 'not'> & {
@@ -577,10 +585,11 @@ type OrOperator<A extends Any> = Omit<AllNever, 'or'> & {
577
585
  or: NonEmptyArray<WhereOperator<A>>;
578
586
  };
579
587
  declare function isOrOperator<A extends Any>(operator: WhereOperator<A>): operator is OrOperator<A>;
580
- type WhereOperator<A extends Any = Any> = TagEqual<A> | KindEqual<A> | ParticipantOperator<A> | NotOperator<A> | AndOperator<A> | OrOperator<A>;
588
+ type WhereOperator<A extends Any = Any> = TagEqual<A> | KindEqual<A> | MetadataEqual<A> | ParticipantOperator<A> | NotOperator<A> | AndOperator<A> | OrOperator<A>;
581
589
  type Filterable<A extends Any> = {
582
590
  tags?: Tags<A> | null | undefined;
583
591
  kind?: AllKinds<A> | null | undefined;
592
+ metadata?: Record<string, string | string[] | undefined> | null | undefined;
584
593
  source?: Filterable<A>;
585
594
  target?: Filterable<A>;
586
595
  };
@@ -1410,6 +1419,12 @@ type ComputedNodeStyle = Simplify<ElementStyle & {
1410
1419
  color?: never;
1411
1420
  }>;
1412
1421
  interface ComputedNode<A extends Any = Any> extends WithTags<A>, WithOptionalLinks {
1422
+ /**
1423
+ * Element metadata, propagated from the model.
1424
+ * Uses a loose record type (instead of aux.WithMetadata<A>) to avoid
1425
+ * exactOptionalPropertyTypes conflicts when MetadataKey is a literal union.
1426
+ */
1427
+ readonly metadata?: Readonly<Record<string, string | string[] | undefined>> | null;
1413
1428
  id: NodeId$1;
1414
1429
  kind: ElementKind<A> | DeploymentKind<A> | '@group';
1415
1430
  parent: NodeId$1 | null;
@@ -1966,7 +1981,8 @@ declare class RichText {
1966
1981
  declare function isString(value: unknown): value is string;
1967
1982
  declare function isNonEmptyArray<A>(arr: ArrayLike<A> | undefined): arr is NonEmptyArray<A>;
1968
1983
  declare function hasProp<T extends object, P extends keyof T & string>(value: T, path: P): value is SetRequired<SetNonNullable<T, P>, P>;
1969
- type Guard<N = unknown> = (n: unknown) => n is N;
1984
+ declare function hasProp<const P extends string>(path: P): <T>(value: T) => value is SetRequired<SetNonNullable<T, P>, P>;
1985
+ type Guard<To = unknown> = (value: any) => value is To;
1970
1986
  /**
1971
1987
  * Extracts the guarded type from a Guard type.
1972
1988
  *
@@ -1979,7 +1995,7 @@ type Guard<N = unknown> = (n: unknown) => n is N;
1979
1995
  * GuardedBy<typeof isString>; // string
1980
1996
  * ```
1981
1997
  */
1982
- type GuardedBy<G> = G extends Guard<infer N> ? N : never;
1998
+ type GuardedBy<G> = G extends Guard<infer To> ? Or<IsAny<To>, IsUnknown<To>> extends true ? never : To : never;
1983
1999
  /**
1984
2000
  * Creates a type guard that checks if a value matches any of the provided predicates.
1985
2001
  *
@@ -1997,6 +2013,6 @@ type GuardedBy<G> = G extends Guard<infer N> ? N : never;
1997
2013
  * }
1998
2014
  * ```
1999
2015
  */
2000
- declare function isAnyOf<const Predicates extends NonEmptyArray<Guard>>(...predicates: Predicates): <T>(value: T) => value is T & GuardedBy<Predicates[number]>;
2016
+ declare function isAnyOf<const Predicates extends NonEmptyArray<Guard<any>>>(...predicates: Predicates): <T>(value: T) => value is T & GuardedBy<Predicates[number]>;
2001
2017
  //#endregion
2002
- export { LayoutedViewDriftReason as $, IteratorLike as $i, BorderStyle as $n, Stage as $r, ElementViewPredicate as $t, isComputedView as A, RelationshipKind as Ai, Expression as An, Any as Ar, ModelRelation as At, DeploymentViewIncludePredicate as B, isStepEdgeId as Bi, OrOperator as Bn, ElementKind as Br, DynamicStepsParallel as Bt, LayoutedView as C, IconUrl as Ci, isAutoLayoutDirection as Cn, isThemeColor as Cr, DeploymentRelation as Ct, ViewRule as D, ProjectId$1 as Di, ModelExpression as Dn, IconPositions as Dr, AbstractRelationship as Dt, ViewOnStage as E, NoneIcon as Ei, isViewRuleGlobalStyle as En, ElementShapes as Er, isDeploymentNode as Et, isExtendsElementView as F, ViewId$1 as Fi, EqualOperator as Fn, DeploymentFqn as Fr, GlobalPredicates as Ft, DiagramEdge as G, ModelStage as Gi, isAndOperator as Gn, LooseTag as Gr, DynamicViewStep as Gt, DeploymentViewRule as H, splitGlobalFqn as Hi, ParticipantOperator as Hn, LooseDeploymentId as Hr, DynamicViewDisplayVariant as Ht, isScopedElementView as I, extractStep as Ii, Filterable as In, DeploymentId as Ir, GlobalStyleID as It, LayoutedDeploymentView as J, _type as Ji, isOrOperator as Jn, MetadataKey as Jr, isDynamicStep as Jt, DiagramNode as K, _layout as Ki, isKindEqual as Kn, LooseViewId as Kr, ParsedDynamicView as Kt, isViewRulePredicate as L, flattenMarkdownOrString as Li, KindEqual as Ln, DeploymentKind as Lr, GlobalStyles as Lt, isDiagramView as M, StepEdgeIdLiteral as Mi, PredicateSelector as Mn, AnyLayouted as Mr, ensureSizes as Mt, isDynamicView as N, StepEdgeKind as Ni, RelationExpr as Nn, AnyParsed as Nr, GlobalDynamicPredicates as Nt, ViewRulePredicate as O, RelationId$1 as Oi, ModelFqnExpr as On, Sizes as Or, Element as Ot, isElementView as P, Tag$1 as Pi, AndOperator as Pn, Aux as Pr, GlobalPredicateId as Pt, DiagramNodeDriftReason as Q, IterableContainer as Qi, FqnRef as Qn, SpecAux as Qr, ElementViewIncludePredicate as Qt, isViewRuleStyle as R, isGlobalFqn as Ri, NotOperator as Rn, EdgeId as Rr, ModelGlobals as Rt, ComputedView as S, Icon as Si, ViewWithNotation as Sn, isCustomColor as Sr, DeploymentNode as St, ProcessedView as T, NodeId$1 as Ti, isViewRuleGlobalPredicateRef as Tn, DefaultTagColors as Tr, isDeployedInstance as Tt, DeploymentViewRuleStyle as U, stepEdgeId as Ui, TagEqual as Un, LooseElementId as Ur, DynamicViewIncludeRule as Ut, DeploymentViewPredicate as V, scalar_d_exports as Vi, Participant as Vn, Fqn as Vr, DynamicStepsSeries as Vt, ParsedDeploymentView as W, ExtractOnStage as Wi, WhereOperator as Wn, LooseLiteral as Wr, DynamicViewRule as Wt, LayoutedElementView as X, Coalesce as Xi, isTagEqual as Xn, RelationId as Xr, isDynamicStepsSeries as Xt, LayoutedDynamicView as Y, isOnStage as Yi, isParticipantOperator as Yn, ProjectId as Yr, isDynamicStepsParallel as Yt, DiagramEdgeDriftReason as Z, ExclusiveUnion as Zi, whereOperatorAsPredicate as Zn, RelationKind as Zr, ElementViewExcludePredicate as Zt, ComputedLikeC4ModelData as _, EdgeId$1 as _i, ViewRuleGlobalPredicateRef as _n, Size as _r, TagSpecification as _t, isNonEmptyArray as a, Predicate as aa, UnknownLayouted as ai, isViewRuleGroup as an, ElementShape as ar, ComputedNode as at, ParsedLikeC4ModelData as b, GlobalFqn as bi, ViewType as bn, ThemeColor as br, DeploymentElement as bt, RichTextEmpty as c, _aux_d_exports as ci, AnyIncludePredicate as cn, IconSize as cr, LikeC4Project as ct, AuxFromDump as d, setProject as di, BaseParsedViewProperties as dn, LikeC4Theme as dr, LikeC4ProjectStylesConfig as dt, KeysOf as ea, StrictViewId as ei, ElementViewRule as en, Color as er, ViewManualLayoutSnapshot as et, LikeC4ModelDump as f, toComputed as fi, BaseViewProperties as fn, RelationshipArrowType as fr, LikeC4ProjectStylesCustomStylesheets as ft, AuxFromLikeC4ModelData as g, DeploymentKind$1 as gi, ViewRuleAutoLayout as gn, ShapeSize as gr, Specification as gt, SpecificationDump as h, DeploymentFqn$1 as hi, ViewAutoLayout as hn, RelationshipLineType as hr, RelationshipSpecification as ht, isAnyOf as i, NonEmptyReadonlyArray as ia, UnknownComputed as ii, ParsedElementView as in, ElementColorValues as ir, ComputedElementView as it, isDeploymentView as j, StepEdgeId as ji, FqnExpr as jn, AnyComputed as jr, Relationship as jt, ViewWithType as k, RelationKind$1 as ki, ModelRelationExpr as kn, ThemeColors as kr, ElementStyle as kt, RichTextOrEmpty as l, preferDescription as li, AnyViewRuleStyle as ln, LikeC4StyleDefaults as lr, LikeC4ProjectManualLayoutsConfig as lt, SpecTypesFromDump as m, BuiltInIcon as mi, RankValue as mn, RelationshipColorValues as mr, ElementSpecification as mt, GuardedBy as n, NTuple as na, Tags as ni, ElementViewRuleRank as nn, CustomColor as nr, ComputedDynamicView as nt, isString as o, ReorderedArray as oa, UnknownParsed as oi, isViewRuleRank as on, HexColor as or, ComputedNodeStyle as ot, ProjectDump as p, AnyFqn as pi, NodeNotation as pn, RelationshipArrowTypes as pr, LikeC4ProjectTheme as pt, LayoutType as q, _stage as qi, isNotOperator as qn, Metadata as qr, getParallelStepsPrefix as qt, hasProp as r, NonEmptyArray as ra, Unknown as ri, ElementViewRuleStyle as rn, CustomColorDefinitions as rr, ComputedEdge as rt, RichText as s, exact as sa, ViewId as si, AnyExcludePredicate as sn, IconPosition as sr, ComputedRankConstraint as st, Guard as t, Link as ta, Tag as ti, ElementViewRuleGroup as tn, ColorLiteral as tr, ComputedDeploymentView as tt, ViewChange as u, preferSummary as ui, AutoLayoutDirection as un, LikeC4StylesConfig as ur, LikeC4ProjectStyleDefaults as ut, LayoutedLikeC4ModelData as v, ElementKind$1 as vi, ViewRuleGlobalStyle as vn, SpacingSize as vr, isTagColorSpecified as vt, ParsedView as w, MarkdownOrString as wi, isViewRuleAutoLayout as wn, BorderStyles as wr, DeploymentRelationship as wt, AnyView as x, GroupElementKind as xi, ViewWithHash as xn, ThemeColorValues as xr, DeploymentElementRef$1 as xt, LikeC4ModelData as y, Fqn$1 as yi, ViewRuleRank as yn, TextSize as yr, DeployedInstance as yt, DeploymentViewExcludePredicate as z, isGroupElementKind as zi, OperatorPredicate as zn, ElementId as zr, DynamicStep as zt };
2018
+ export { LayoutedViewDriftReason as $, ExclusiveUnion as $i, whereOperatorAsPredicate as $n, RelationKind as $r, ElementViewPredicate as $t, isComputedView as A, RelationId$1 as Ai, Expression as An, Sizes as Ar, ModelRelation as At, DeploymentViewIncludePredicate as B, isGlobalFqn as Bi, OperatorPredicate as Bn, EdgeId as Br, DynamicStepsParallel as Bt, LayoutedView as C, GroupElementKind as Ci, isAutoLayoutDirection as Cn, ThemeColorValues as Cr, DeploymentRelation as Ct, ViewRule as D, NodeId$1 as Di, ModelExpression as Dn, DefaultTagColors as Dr, AbstractRelationship as Dt, ViewOnStage as E, MarkdownOrString as Ei, isViewRuleGlobalStyle as En, BorderStyles as Er, isDeploymentNode as Et, isExtendsElementView as F, StepEdgeKind as Fi, EqualOperator as Fn, AnyParsed as Fr, GlobalPredicates as Ft, DiagramEdge as G, stepEdgeId as Gi, WhereOperator as Gn, LooseElementId as Gr, DynamicViewStep as Gt, DeploymentViewRule as H, isStepEdgeId as Hi, Participant as Hn, ElementKind as Hr, DynamicViewDisplayVariant as Ht, isScopedElementView as I, Tag$1 as Ii, Filterable as In, Aux as Ir, GlobalStyleID as It, LayoutedDeploymentView as J, _layout as Ji, isMetadataEqual as Jn, LooseViewId as Jr, isDynamicStep as Jt, DiagramNode as K, ExtractOnStage as Ki, isAndOperator as Kn, LooseLiteral as Kr, ParsedDynamicView as Kt, isViewRulePredicate as L, ViewId$1 as Li, KindEqual as Ln, DeploymentFqn as Lr, GlobalStyles as Lt, isDiagramView as M, RelationshipKind as Mi, PredicateSelector as Mn, Any as Mr, ensureSizes as Mt, isDynamicView as N, StepEdgeId as Ni, RelationExpr as Nn, AnyComputed as Nr, GlobalDynamicPredicates as Nt, ViewRulePredicate as O, NoneIcon as Oi, ModelFqnExpr as On, ElementShapes as Or, Element as Ot, isElementView as P, StepEdgeIdLiteral as Pi, AndOperator as Pn, AnyLayouted as Pr, GlobalPredicateId as Pt, DiagramNodeDriftReason as Q, Coalesce as Qi, isTagEqual as Qn, RelationId as Qr, ElementViewIncludePredicate as Qt, isViewRuleStyle as R, extractStep as Ri, MetadataEqual as Rn, DeploymentId as Rr, ModelGlobals as Rt, ComputedView as S, GlobalFqn as Si, ViewWithNotation as Sn, ThemeColor as Sr, DeploymentNode as St, ProcessedView as T, IconUrl as Ti, isViewRuleGlobalPredicateRef as Tn, isThemeColor as Tr, isDeployedInstance as Tt, DeploymentViewRuleStyle as U, scalar_d_exports as Ui, ParticipantOperator as Un, Fqn as Ur, DynamicViewIncludeRule as Ut, DeploymentViewPredicate as V, isGroupElementKind as Vi, OrOperator as Vn, ElementId as Vr, DynamicStepsSeries as Vt, ParsedDeploymentView as W, splitGlobalFqn as Wi, TagEqual as Wn, LooseDeploymentId as Wr, DynamicViewRule as Wt, LayoutedElementView as X, _type as Xi, isOrOperator as Xn, MetadataKey as Xr, isDynamicStepsSeries as Xt, LayoutedDynamicView as Y, _stage as Yi, isNotOperator as Yn, Metadata as Yr, isDynamicStepsParallel as Yt, DiagramEdgeDriftReason as Z, isOnStage as Zi, isParticipantOperator as Zn, ProjectId as Zr, ElementViewExcludePredicate as Zt, ComputedLikeC4ModelData as _, DeploymentFqn$1 as _i, ViewRuleGlobalPredicateRef as _n, RelationshipLineType as _r, TagSpecification as _t, isNonEmptyArray as a, NonEmptyArray as aa, Unknown as ai, isViewRuleGroup as an, CustomColorDefinitions as ar, ComputedNode as at, ParsedLikeC4ModelData as b, ElementKind$1 as bi, ViewType as bn, SpacingSize as br, DeploymentElement as bt, RichTextEmpty as c, ReorderedArray as ca, UnknownParsed as ci, AnyIncludePredicate as cn, HexColor as cr, LikeC4Project as ct, AuxFromDump as d, preferDescription as di, BaseParsedViewProperties as dn, LikeC4StyleDefaults as dr, LikeC4ProjectStylesConfig as dt, IterableContainer as ea, SpecAux as ei, ElementViewRule as en, FqnRef as er, ViewManualLayoutSnapshot as et, LikeC4ModelDump as f, preferSummary as fi, BaseViewProperties as fn, LikeC4StylesConfig as fr, LikeC4ProjectStylesCustomStylesheets as ft, AuxFromLikeC4ModelData as g, BuiltInIcon as gi, ViewRuleAutoLayout as gn, RelationshipColorValues as gr, Specification as gt, SpecificationDump as h, AnyFqn as hi, ViewAutoLayout as hn, RelationshipArrowTypes as hr, RelationshipSpecification as ht, isAnyOf as i, NTuple as ia, Tags as ii, ParsedElementView as in, CustomColor as ir, ComputedElementView as it, isDeploymentView as j, RelationKind$1 as ji, FqnExpr as jn, ThemeColors as jr, Relationship as jt, ViewWithType as k, ProjectId$1 as ki, ModelRelationExpr as kn, IconPositions as kr, ElementStyle as kt, RichTextOrEmpty as l, exact as la, ViewId as li, AnyViewRuleStyle as ln, IconPosition as lr, LikeC4ProjectManualLayoutsConfig as lt, SpecTypesFromDump as m, toComputed as mi, RankValue as mn, RelationshipArrowType as mr, ElementSpecification as mt, GuardedBy as n, KeysOf as na, StrictViewId as ni, ElementViewRuleRank as nn, Color as nr, ComputedDynamicView as nt, isString as o, NonEmptyReadonlyArray as oa, UnknownComputed as oi, isViewRuleRank as on, ElementColorValues as or, ComputedNodeStyle as ot, ProjectDump as p, setProject as pi, NodeNotation as pn, LikeC4Theme as pr, LikeC4ProjectTheme as pt, LayoutType as q, ModelStage as qi, isKindEqual as qn, LooseTag as qr, getParallelStepsPrefix as qt, hasProp as r, Link as ra, Tag as ri, ElementViewRuleStyle as rn, ColorLiteral as rr, ComputedEdge as rt, RichText as s, Predicate as sa, UnknownLayouted as si, AnyExcludePredicate as sn, ElementShape as sr, ComputedRankConstraint as st, Guard as t, IteratorLike as ta, Stage as ti, ElementViewRuleGroup as tn, BorderStyle as tr, ComputedDeploymentView as tt, ViewChange as u, _aux_d_exports as ui, AutoLayoutDirection as un, IconSize as ur, LikeC4ProjectStyleDefaults as ut, LayoutedLikeC4ModelData as v, DeploymentKind$1 as vi, ViewRuleGlobalStyle as vn, ShapeSize as vr, isTagColorSpecified as vt, ParsedView as w, Icon as wi, isViewRuleAutoLayout as wn, isCustomColor as wr, DeploymentRelationship as wt, AnyView as x, Fqn$1 as xi, ViewWithHash as xn, TextSize as xr, DeploymentElementRef$1 as xt, LikeC4ModelData as y, EdgeId$1 as yi, ViewRuleRank as yn, Size as yr, DeployedInstance as yt, DeploymentViewExcludePredicate as z, flattenMarkdownOrString as zi, NotOperator as zn, DeploymentKind as zr, DynamicStep as zt };
@@ -1,4 +1,4 @@
1
- import { $n as BorderStyle, Pi as Tag, Tr as DefaultTagColors, _t as TagSpecification, br as ThemeColor, cr as IconSize, dr as LikeC4Theme, dt as LikeC4ProjectStylesConfig, er as Color, ft as LikeC4ProjectStylesCustomStylesheets, gr as ShapeSize, ir as ElementColorValues, lr as LikeC4StyleDefaults, mr as RelationshipColorValues, na as NTuple, ot as ComputedNodeStyle, rr as CustomColorDefinitions, sr as IconPosition, tr as ColorLiteral, ur as LikeC4StylesConfig, vr as SpacingSize, xr as ThemeColorValues, yr as TextSize } from "./index.mjs";
1
+ import { Cr as ThemeColorValues, Dr as DefaultTagColors, Ii as Tag, Sr as ThemeColor, _t as TagSpecification, ar as CustomColorDefinitions, br as SpacingSize, dr as LikeC4StyleDefaults, dt as LikeC4ProjectStylesConfig, fr as LikeC4StylesConfig, ft as LikeC4ProjectStylesCustomStylesheets, gr as RelationshipColorValues, ia as NTuple, lr as IconPosition, nr as Color, or as ElementColorValues, ot as ComputedNodeStyle, pr as LikeC4Theme, rr as ColorLiteral, tr as BorderStyle, ur as IconSize, vr as ShapeSize, xr as TextSize } from "./index.mjs";
2
2
  import { LiteralUnion } from "type-fest";
3
3
 
4
4
  //#region src/styles/assignTagColors.d.ts
@@ -25,6 +25,7 @@ declare class LikeC4Styles {
25
25
  static readonly DEFAULT: LikeC4Styles;
26
26
  static from(stylesConfig: LikeC4ProjectStylesConfig | undefined, customColors?: CustomColorDefinitions | undefined): LikeC4Styles;
27
27
  private constructor();
28
+ get fingerprint(): string;
28
29
  /**
29
30
  * Default element colors
30
31
  */
@@ -1,4 +1,4 @@
1
- import { $i as IteratorLike, Ar as Any, Qi as IterableContainer, Rr as EdgeId, oa as ReorderedArray, ri as Unknown, yi as Fqn } from "./index.mjs";
1
+ import { Br as EdgeId, Mr as Any, ai as Unknown, ca as ReorderedArray, ea as IterableContainer, ta as IteratorLike, xi as Fqn } from "./index.mjs";
2
2
  import { C as ElementModel, S as NodeModel, T as RelationshipModel, a as DeploymentNodeModel, c as NestedElementOfDeployedInstanceModel, i as DeploymentElementModel, l as RelationshipsAccum, r as DeployedInstanceModel, s as DeploymentRelationModel, w as AnyRelationshipModel, x as EdgeModel, y as LikeC4ViewModel } from "./LikeC4Model.mjs";
3
3
 
4
4
  //#region src/model/connection/Connection.d.ts
@@ -1,4 +1,4 @@
1
- import { $i as IteratorLike, Qi as IterableContainer, oa as ReorderedArray, ra as NonEmptyArray, yi as Fqn } from "./index.mjs";
1
+ import { aa as NonEmptyArray, ca as ReorderedArray, ea as IterableContainer, ta as IteratorLike, xi as Fqn } from "./index.mjs";
2
2
 
3
3
  //#region src/utils/invariant.d.ts
4
4
  declare function nonNullable<T>(value: T, message?: string | (() => string)): NonNullable<T>;
@@ -1 +1 @@
1
- function e(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function t(n,r,i=`.`,a){if(!e(r))return t(n,{},i,a);let o=Object.assign({},r);for(let r in n){if(r===`__proto__`||r===`constructor`)continue;let s=n[r];s!=null&&(a&&a(o,r,s,i)||(Array.isArray(s)&&Array.isArray(o[r])?o[r]=[...s,...o[r]]:e(s)&&e(o[r])?o[r]=t(s,o[r],(i?`${i}.`:``)+r.toString(),a):o[r]=s))}return o}function n(e){return(...n)=>n.reduce((n,r)=>t(n,r,``,e),{})}const r=n();export{r as t};
1
+ function e(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null||Symbol.iterator in e?!1:Symbol.toStringTag in e?Object.prototype.toString.call(e)===`[object Module]`:!0}function t(n,r,i=`.`,a){if(!e(r))return t(n,{},i,a);let o={...r};for(let r of Object.keys(n)){if(r===`__proto__`||r===`constructor`)continue;let s=n[r];s!=null&&(a&&a(o,r,s,i)||(Array.isArray(s)&&Array.isArray(o[r])?o[r]=[...s,...o[r]]:e(s)&&e(o[r])?o[r]=t(s,o[r],(i?`${i}.`:``)+r.toString(),a):o[r]=s))}return o}function n(e){return(...n)=>n.reduce((n,r)=>t(n,r,``,e),{})}const r=n();export{r as t};