@likec4/core 1.57.0 → 1.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/Builder.view-element.mjs +2 -2
- package/dist/_chunks/LikeC4Model.d.mts +1 -1
- package/dist/_chunks/assignTagColors.mjs +1 -1
- package/dist/_chunks/index.d.mts +5 -0
- package/dist/_chunks/index3.d.mts +13 -2
- package/dist/_chunks/libs/mnemonist.d.mts +6 -6
- package/dist/_chunks/libs/remeda.mjs +2 -2
- package/dist/_chunks/manual-layout.mjs +1 -1
- package/dist/_chunks/model.mjs +4 -4
- package/dist/_chunks/types.mjs +1 -1
- package/dist/builder/index.mjs +1 -1
- package/dist/compute-view/index.mjs +2 -2
- package/dist/geometry/index.mjs +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/styles/index.d.mts +2 -2
- package/dist/styles/index.mjs +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/utils/index.mjs +1 -1
- package/package.json +15 -15
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{B as e,C as t,E as n,G as r,H as i,I as a,J as o,K as s,L as c,M as l,N as u,O as d,P as f,Q as p,R as m,S as h,T as g,V as _,Y as v,Z as ee,_ as te,a as ne,d as y,et as b,g as x,h as re,i as ie,k as ae,m as oe,n as se,nt as ce,o as le,q as ue,r as de,rt as S,t as fe,tt as pe,u as me,v as C,w as he,x as ge,y as w,z as _e}from"./libs/remeda.mjs";import{$t as ve,At as T,Bt as E,Cn as D,Dt as O,Et as ye,G as k,J as A,Kt as be,Mt as j,Nt as xe,O as M,On as Se,Rt as Ce,Sn as N,Tt as we,U as Te,Ut as Ee,Vt as De,W as P,Xt as F,Y as I,Yt as L,_t as Oe,b as ke,cn as R,d as Ae,dt as je,et as Me,fn as Ne,g as Pe,h as Fe,hn as Ie,ht as Le,in as Re,kn as z,kt as ze,l as Be,ln as Ve,lt as He,n as Ue,nn as We,o as Ge,p as Ke,pn as qe,q as B,r as Je,rn as Ye,s as Xe,tt as Ze,u as Qe,un as $e,vt as et,wn as V,y as tt,yn as nt,zt as H}from"./types.mjs";import{c as rt,t as it}from"./libs/mnemonist.mjs";import{A as at,C as ot,D as st,E as ct,M as U,N as lt,O as ut,T as dt,_ as ft,c as pt,d as mt,f as ht,g as gt,h as _t,j as vt,m as yt,n as bt,o as xt,p as St,q as Ct,r as wt,t as Tt,v as Et,w as Dt,y as Ot}from"./model.mjs";import{r as kt}from"./manual-layout.mjs";import{t as At}from"./libs/graphology.mjs";import{n as jt,t as Mt}from"../utils/graphology/index.mjs";function Nt(e,t){let n=[],r=e.parent;for(;r;){let e=D(t.get(r),`Parent node ${r} not found`);n.push(e),r=e.parent}return n}function Pt(e,t){for(let r of t){let t=e.get(r.source),i=e.get(r.target);N(t,`Source node ${r.source} not found`),N(i,`Target node ${r.target} not found`),t.outEdges.push(r.id),i.inEdges.push(r.id);let a=Nt(t,e),o=Nt(i,e),s=a.length>0&&o.length>0?n(nt(me(a),me(o))):null;r.parent=s?s.id:null;for(let e of a){if(e===s)break;e.outEdges.push(r.id)}for(let e of o){if(e===s)break;e.inEdges.push(r.id)}}}function W(e){if(P.isCustom(e))return W(e.custom.expr);if(P.isWhere(e)){let t=W(e.where.expr),n=M(e.where.condition);return e=>t(e)&&n(e)}if(P.isElementKindExpr(e))return e.isEqual?t=>t.kind===e.elementKind:t=>t.kind!==e.elementKind;if(P.isElementTagExpr(e))return e.isEqual?({tags:t})=>t.includes(e.elementTag):({tags:t})=>!t.includes(e.elementTag);if(P.isWildcard(e))return()=>!0;if(P.isModelRef(e)){let t=I.flatten(e.ref);if(e.selector===`expanded`)return e=>e.id===t||Ne(e.id)===t;if(e.selector===`descendants`||e.selector===`children`){let e=t+`.`;return t=>t.id.startsWith(e)}return e=>e.id===t}V(e)}function Ft(e){return function t(n){switch(!0){case k.isCustom(n):return t(n.customRelation.expr);case k.isWhere(n):{let e=t(n.where.expr),r=M(n.where.condition);return t=>e(t)&&r({source:{tags:t.source.tags,kind:t.source.kind,metadata:t.source.metadata},target:{tags:t.target.tags,kind:t.target.kind,metadata:t.target.metadata},...t.tags&&{tags:t.tags},...t.kind&&{kind:t.kind},...t.metadata&&{metadata:t.metadata}})}case k.isDirect(n):{let t=e(n.source),r=e(n.target);return e=>t(e.source)&&r(e.target)||!!n.isBidirectional&&t(e.target)&&r(e.source)}case k.isInOut(n):{let t=e(n.inout);return e=>t(e.source)||t(e.target)}case k.isIncoming(n):{let t=e(n.incoming);return e=>t(e.target)}case k.isOutgoing(n):{let t=e(n.outgoing);return e=>t(e.source)}default:V(n)}}}const It=Ft(W);function Lt(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 Rt(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 zt(e){let t=Lt([...e.nodes.values()]),n=[...e.edges];if(t.length<2||n.length===0)return{nodes:t,edges:n};let i=t=>D(e.nodes.get(t)),a=new At({multi:!0,allowSelfLoops:!0,type:`directed`}),[o,s]=C(b(n,g(e=>{let t=i(e.source),n=i(e.target),r=e.parent?i(e.parent):null;return{id:e.id,edge:e,parent:r,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,jt.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(Nt(s,e.nodes),ne(e=>e.inEdges.includes(t.id)),r(e=>{a.mergeNode(e.id),(0,jt.default)(a,t.source,e.id)||a.mergeDirectedEdge(t.source,e.id),(0,jt.default)(a,e.id,t.target)||a.mergeDirectedEdge(e.id,t.target)})),n.parent){let e=i(n.parent);a.mergeNode(e.id),(0,jt.default)(a,e.id,n.id)||a.mergeDirectedEdge(e.id,n.id),s.parent&&s.parent!==n.parent&&((0,jt.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,Mt.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:Rt(Lt(d)),edges:c}}function Bt(e){return e.hash=ye({id:e.id,__:e._type??`element`,autoLayout:e.autoLayout,nodes:b(e.nodes,g(e=>({id:e.id,icon:d(e.icon)&&e.icon!==`none`?`Y`:`N`,title:e.title,description:He(e.description),technology:e.technology??null,shape:e.shape,size:e.style.size??null,iconSize:e.style.iconSize??null,iconColor:e.style.iconColor??null,iconPosition:e.style.iconPosition??null,border:e.style.border??null,opacity:e.style.opacity??null,multiple:e.style.multiple??null,textSize:e.style.textSize??null,padding:e.style.padding??null,children:e.children})),he(({id:e,...t})=>[e,t])),edges:b(e.edges,g(e=>({id:e.id,source:e.source,target:e.target,label:e.label,description:He(e.description),technology:e.technology??null,dir:e.dir,head:e.head,tail:e.tail,line:e.line})),he(e=>[e.id,{...e}]))}),e}var Vt=class{state;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}},Ht=class{memory;expression;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(F(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(_e(t)&&(N(!this.markedToMoveExplicitToImplicit,`Already marked to move explicits`),this.markedToMoveExplicitToImplicit=t),F(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=O(new Set(this.memory.connections.flatMap(e=>[e.source,e.target])),new Set(e.connections.flatMap(e=>[e.source,e.target])));return t=T(t,e.elements),t=b(t,L(t=>e.explicits.has(t)&&!De(e.final,Ve(t))),E()),t.size>0&&(t=this.filterForMoveToImplicits(t),e.explicits=O(e.explicits,t),e.final=O(e.final,t)),e}removeElements(e){return e.elements=O(e.elements,this.excluded.elements),e.explicits=O(e.explicits,this.excluded.elements),e.final=O(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=O(n,e.explicits),e.final=O(e.final,n),e)}precommit(e){return e}postcommit(e){return N(O(e.explicits,e.elements).size===0,`Explicits must be subset of elements`),N(O(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,...ft(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))}},Ut=class{memory;expression;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 st([...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(F(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(F(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(F(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]=C(this._connections,t=>e.final.has(t.source));e.connections=this.processConnections(st([...e.connections,...n,...r])),t=new Set(e.connections.flatMap(e=>[e.source,e.target]))}return e.elements=j(e.elements,this._ordered,this.explicits,t,this.implicits),e.explicits=T(e.elements,j(e.explicits,this.explicits)),e.final=T(e.elements,j(e.final,this.explicits,t)),this.memory.update(this.postcommit(e))}};function Wt(e,t=`final`){let n=Ie(H(t===`final`?e.final:e.elements)),r=new Set(e.connections.flatMap(e=>[e.source,e.target])),i=new Set(n),a=new it.default(()=>null),o=n.reduce((e,t,n,r)=>(e.set(t,r.slice(n+1).filter(e=>R(t,e)).map(e=>(i.delete(e),e)).reduce((e,n)=>(e.some(e=>R(e,n))||(e.push(n),a.set(n,t)),e),[])),e),new it.default(()=>[]));return{root:i,connected:r,hasInOut:t=>e.connections.some(U.isAnyInOut(t.id)),parent:e=>a.get(e),children:e=>o.get(e)}}var Gt=class extends Ht{};function Kt(e,t,n){let{shape:i,color:a,icon:o,...s}=e.style,l=!c(s);b(n,v(u(je)),v(t),r(t=>{t.shape=i??t.shape,t.color=a??t.color,m(o)&&(t.icon=o),m(e.notation)&&(t.notation=e.notation),l&&(t.style={...t.style,...s})}))}function qt(e,t){for(let n of e)!ke(n)||n.targets.length===0||Kt(n,S(n.targets.map(W)),t);return t}var Jt=class e{id;viewRule;parent;elements;static kind=Me;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))}},Yt=class extends Ht{excludeRelations(e){return b(this.memory.connections,v(t=>ze(t.relations,e)),r(t=>{this.excludeConnections(t.update(T(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=O(this.memory.explicits,e.explicits);for(let n of t)e.explicitFirstSeenIn.delete(n);let n=O(this.memory.elements,e.elements);for(let t of n)e.lastSeenIn.delete(t);return e}},Xt=class extends Yt{memory;expression;constructor(e,t){super(e,t),this.memory=e,this.expression=t}};const{findConnection:Zt,findConnectionsBetween:Qt}=St;var $t=class extends Ut{connectWithExisting(e,t=`both`){let n=this._connections.length,r=()=>this._connections.length>n;if(!F(e)){if(t===`in`||t===`both`)for(let t of this.memory.elements)this.addConnections(Zt(t,e,`directed`));return(t===`out`||t===`both`)&&this.addConnections(Qt(e,this.memory.elements,`directed`)),r()}let i=[...e];if(t===`in`||t===`both`)for(let e of this.memory.elements)this.addConnections(Qt(e,i,`directed`));if(t===`out`||t===`both`)for(let e of i)this.addConnections(Qt(e,this.memory.elements,`directed`));return r()}addImplicitWithinScope(e){e&&(!this.memory.scope||R(this.memory.scope,e))&&this.addImplicit(e)}processConnections(e){return Te.isRelationExpr(this.expression)||b(e,r(({source:e,target:t,boundary:n})=>{b(fe([...H(e.ancestors()).reverse(),e],[...H(t.ancestors()).reverse(),t]),ee(([e,t])=>e===t),le(1),r(([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=O(e.explicits,this.memory.explicits);for(let n of t)e.explicitFirstSeenIn.set(n,`@root`);return e}},en=class extends $t{memory;expression;constructor(e,t){super(e,t),this.memory=e,this.expression=t}postcommit(e){let t=O(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}},tn=class e extends Vt{state;scope;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 $t(this,e)}stageExclude(e){return new Yt(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)}},nn=class e extends tn{state;scope;stack;static enter(t,n){let r=`@gr${t.groups.length+1}`;if(t instanceof e){let i=rt.default.from([...t.stack].reverse()),a=t.mutableState();return a.groups.push(new Jt(r,n,t.activeGroupId)),i.push(r),new e(a,t.scope,i)}let i=t.mutableState();i.groups.push(new Jt(r,n,null));let a=rt.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 D(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 en(this,e)}stageExclude(e){return new Xt(this,e)}leave(){let t=this.mutableState();return this.stack.pop(),this.stack.peek()?new e(t,this.scope,this.stack):new tn(t,this.scope)}};function rn(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 an(e){let{id:t,title:n,...r}=h(e.$element,[`summary`,`description`,`metadata`,`style`,`tags`]),{color:i,icon:a,shape:o,...s}=e.style;return z({id:t,title:n,modelRef:t,shape:o,color:i,icon:a,style:s,description:Se(e.$element),tags:[...e.tags],metadata:e.$element.metadata,...r})}function on({defaults:e},t,n){let r=new Map,i=new Map;n?.forEach(({id:t,parent:n,viewRule:a,elements:o})=>{n&&D(r.get(n),`Parent group node ${n} not found`).children.push(t),r.set(t,{id:t,parent:n,kind:Me,title:a.title??``,color:a.color??e.group.color??e.color,shape:`rectangle`,children:[],inEdges:[],outEdges:[],level:0,depth:0,tags:[],style:z({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(Re).forEach(({id:e,...t})=>{let n=Ne(e),a=0,o;for(;n&&(o=r.get(n),!o);)n=Ne(n);let s=t.modelRef??e;if(!o&&i.has(s)){let e=D(i.get(s));o=r.get(e),n=e}o&&(o.children.length==0&&(o.depth=1,rn(o,r)),o.children.push(e),a=o.level+1);let c=z({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,D(r.get(e)))}),t.forEach(({id:e})=>{a.set(e,D(r.get(e)))}),a}function sn(e){let{title:t,description:n=null}=e;return{...t&&{title:t,description:n},...te(e,[`color`,`technology`,`head`,`line`,`tail`,`kind`,`navigateTo`])}}function cn(e,t){let n=b(e,y((e,t)=>(d(t.title)&&!e.title.includes(t.title)&&e.title.push(t.title),d(t.description)&&!e.description.some(_(t.description))&&e.description.push(t.description),d(t.technology)&&!e.technology.includes(t.technology)&&e.technology.push(t.technology),d(t.kind)&&!e.kind.includes(t.kind)&&e.kind.push(t.kind),d(t.color)&&!e.color.includes(t.color)&&e.color.push(t.color),d(t.line)&&!e.line.includes(t.line)&&e.line.push(t.line),d(t.head)&&!e.head.includes(t.head)&&e.head.push(t.head),d(t.tail)&&!e.tail.includes(t.tail)&&e.tail.push(t.tail),d(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=w(n.title)??(n.title.length>1?`[...]`:void 0),i=ie(n.tags),a=z({title:r,description:w(n.description),technology:w(n.technology),kind:w(n.kind),head:w(n.head),tail:w(n.tail),color:w(n.color),line:w(n.line),navigateTo:w(n.navigateTo),...ve(i)&&{tags:i}});if(t){let e=sn(t);a=x({...a,...e},d)}return l(a.title)&&d(a.technology)&&(a.title=`[${a.technology}]`,delete a.technology),a}const{findConnection:ln,findConnectionsBetween:G,findConnectionsWithin:un}=yt;function K(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 dn(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 fn(e){if(B.isWildcard(e))return()=>!0;if(B.isElementTagExpr(e)||B.isElementKindExpr(e))throw Error(`element kind and tag expressions are not supported in deployment view rules`);if(B.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=>Ne(e.id)===t:e=>e.id===t}if(B.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?Ne(n)===t:!0}:e=>{let n=e.modelRef??null;return n?n===t:!0}}V(e)}function pn(e){return Se(e.$instance)??Se(e.element.$element)}function mn(e){let t=e.id,n=e.onlyOneInstance();return z({id:t,deploymentRef:t,title:e.title,kind:e.kind,technology:e.technology??void 0,links:p(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:Se(e.$node)??void 0,tags:[...e.tags],style:h(e.style,[`icon`,`shape`,`color`])})}function hn(e){let t=e.$instance,n=e.element,{icon:r,color:i,shape:a,...o}=e.style,s=[...n.links,...t.links??[]];return z({id:e.id,kind:`instance`,title:e.title,description:pn(e)??void 0,technology:e.technology??void 0,tags:[...e.tags],links:p(s,1)?s:void 0,icon:r,color:i,shape:a,style:o,deploymentRef:t.id,modelRef:n.id,notation:t.notation})}function gn(e){return e.isInstance()?hn(e):mn(e)}const _n=(e,t,n)=>we(`model:${e}:${t}:${n}`);function vn(e){let t=new Set;for(let n=0;n<e.length;n++){if(t.has(n))continue;let r=e[n];for(let i=n+1;i<e.length;i++){if(t.has(i))continue;let n=e[i];if(r.source===n.target&&r.target===n.source&&r.label===n.label){r.dir=`both`;let e=r.head??n.head;e&&(r.head||=e,r.tail||=e),n.color&&(r.color||=n.color),n.line&&(r.line||=n.line),t.add(i);break}}}return t.size>0?e.filter((e,n)=>!t.has(n)):e}function yn(e,t){let n=[],r=[];for(let i of e){let e=[...i.relations.model,...i.relations.deployment];N(p(e,1),`Edge must have at least one relation`);let a=i.source.$model.$styles.defaults,o=i.source.id,s=i.target.id;if(t&&e.length>1){let[c,l]=b(e,C(e=>t(e,i)));if(c.length>0){for(let e of c){let{title:t,color:r=a.relationship.color,line:c=a.relationship.line,head:l=a.relationship.arrow,...u}=cn([e.$relationship],e.$relationship);n.push({id:_n(o,s,e.id),parent:i.boundary?.id??null,source:o,target:s,label:t??null,relations:[e.id],color:r,line:c,head:l,...u})}if(l.length>0){let e=w(v(l,e=>e.source.id===o&&e.target.id===s)),{title:t,color:n=a.relationship.color,line:c=a.relationship.line,head:u=a.relationship.arrow,...d}=cn(l.map(e=>e.$relationship),e?.$relationship);r.push({id:i.id,parent:i.boundary?.id??null,source:o,target:s,label:t??null,relations:l.map(e=>e.id),color:n,line:c,head:u,...d})}continue}}let{title:c,color:l=a.relationship.color,line:u=a.relationship.line,head:d=a.relationship.arrow,...f}=cn(e.map(e=>e.$relationship)),m=z({id:i.id,parent:i.boundary?.id??null,source:o,target:s,label:c??null,relations:e.map(e=>e.id),color:l,line:u,head:d,...f});r.push(m)}return[...n,...vn(r)]}function bn(e,t){let n=on(e.$styles,[...t.final].map(gn));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??=pn(r)??null,t.technology??=r.technology,c(t.tags)&&(t.tags=[...r.tags]),(!t.links||c(t.links))&&p(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)!ke(n)||n.targets.length===0||Kt(n,S(n.targets.map(fn)),t);return t}function Sn(e){let t=new it.default(()=>[]);for(let n of e)for(let e of n.relations.model)t.get(e).push(n);let n=new it.default(()=>new Set);for(let[e,a]of t)p(a,2)&&b(a,s(e=>[{group:`$source-${e.source.id}`,conn:e},{group:`$target-${e.target.id}`,conn:e}]),i(oe(`group`)),de(),v(p(2)),r(re(g(oe(`conn`)),ut(`desc`),ee((e,t,n)=>t===0||e.boundary===n[t-1].boundary),r(t=>{n.get(t).add(e)}))));return n}function Cn(e){e=st(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=T(i,r.internalModelRelationships());for(let e of a)t.get(n).add(e);continue}if(e.isDeploymentNode()&&r.isDeploymentNode()){let i=j(T(n.relations.model,e.internalModelRelationships()),T(n.relations.model,r.internalModelRelationships()));for(let e of i)t.get(n).add(e)}}return b(t.entries(),Ee(([e,t])=>e.update({model:t,deployment:null})),H())}function wn(e){return gt(e,Cn(e))}function Tn(e){return b(e,st,y((t,n)=>{let{source:r,target:i,relations:a}=n;if(r.isInstance()&&i.isInstance())return t;let o=Ct.empty();if(r.isDeploymentNode()&&i.isDeploymentNode()){let[e]=ln(i,r,`directed`);e&&(o=a.intersect(e.relations))}for(let t of e)dt(t,n)&&(o=o.union(a.intersect(t.relations)));return o.nonEmpty&&t.push(new at(r,i,o)),t},[]))}function En(e){return gt(e,Tn(e))}var Dn=class extends Ut{connectWithExisting(e,t=`both`){let n=this._connections.length,r=()=>this._connections.length>n;if(!F(e)){if(t===`in`||t===`both`)for(let t of this.memory.elements)this.addConnections(ln(t,e,`directed`));return(t===`out`||t===`both`)&&this.addConnections(G(e,this.memory.elements,`directed`)),r()}let i=[...e];if(t===`in`||t===`both`)for(let e of this.memory.elements)this.addConnections(G(e,i,`directed`));if(t===`out`||t===`both`)for(let e of i)this.addConnections(G(e,this.memory.elements,`directed`));return r()}processConnections(e){let t=b(e,wn,En);return b(t,r(({source:e,target:t,boundary:n})=>{b(fe([...H(e.ancestors()).reverse(),e],[...H(t.ancestors()).reverse(),t]),ee(([e,t])=>e===t),le(1),r(([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 Vt{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 Gt(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&&_(this.state,t.state)}diff(e){return{added:{elements:H(O(e.elements,this.elements)),explicits:H(O(e.explicits,this.explicits)),final:H(O(e.final,this.final)),connections:H(gt(e.connections,this.connections))},removed:{elements:H(O(this.elements,e.elements)),explicits:H(O(this.explicits,e.explicits)),final:H(O(this.final,e.final)),connections:gt(this.connections,e.connections)}}}toString(){return[`final:`,...[...this.final].map(e=>` `+e.id),`connections:`,...this.connections.map(e=>` `+e.expression)].join(`
|
|
2
|
-
`)}[vt](e,t,n){return this.toString()}};const kn={include:({expr:e,model:t,memory:n,stage:r})=>{let i=M(e.where.condition);return D(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=M(e.where.condition);return D(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(B.isWildcard(e.incoming)){for(let e of a){if(e.allOutgoing.isEmpty)continue;let t=q(G(e,[...qn(e)],`directed`),i);r.addConnections(t)}return r}N(B.isDeploymentRef(e.incoming),`Only deployment refs are supported in include`);let o=K(t,e.incoming);for(let e of a){let t=q(G(e,o,`directed`),i);r.addConnections(t)}return r},exclude:({expr:e,model:t,memory:n,stage:r,where:i})=>{if(B.isElementTagExpr(e.incoming)||B.isElementKindExpr(e.incoming))throw Error(`element kind and tag expressions are not supported in exclude`);if(B.isModelRef(e.incoming))return Hn(Mn(t,e.incoming),{stage:r,memory:n},i);if(B.isWildcard(e.incoming))return r;let a=jn(K(t,e.incoming)),o=b(n.connections,v(a),q(i));return r.excludeConnections(o),r}};function jn(e){return S(e.map(e=>{let t=t=>t===e||R(e,t);return e=>!t(e.source)&&t(e.target)}))}function Mn(e,t){let n=dn(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(B.isWildcard(e.outgoing)){for(let e of a)if(!e.allIncoming.isEmpty)for(let t of qn(e)){let n=q(ln(t,e,`directed`),i);r.addConnections(n)}return r}N(B.isDeploymentRef(e.outgoing),`Only deployment refs are supported in include`);let o=K(t,e.outgoing);for(let e of o){let t=q(G(e,a,`directed`),i);r.addConnections(t)}return r},exclude:({expr:e,model:t,memory:n,stage:r,where:i})=>{if(B.isElementTagExpr(e.outgoing)||B.isElementKindExpr(e.outgoing))throw Error(`element kind and tag expressions are not supported in exclude`);if(B.isModelRef(e.outgoing))return Hn(Fn(t,e.outgoing),{stage:r,memory:n},i);if(B.isWildcard(e.outgoing))return r;let a=Pn(K(t,e.outgoing)),o=b(n.connections,v(a),q(i));return r.excludeConnections(o),r}};function Pn(e){return S(e.map(e=>{let t=t=>t===e||R(e,t);return e=>t(e.source)&&!t(e.target)}))}function Fn(e,t){let n=dn(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(B.isElementTagExpr(e)||B.isElementKindExpr(e)||B.isElementTagExpr(t)||B.isElementKindExpr(t))throw Error(`element kind and tag expressions are not supported in include`);N(!B.isModelRef(e),`Invalid source model ref in direct relation`),N(!B.isModelRef(t),`Invalid target model ref in direct relation`);let o=B.isWildcard(e),c=B.isWildcard(t),l=n?`both`:`directed`,u;switch(!0){case o&&c:u=b(un(r.instances()),q(a),g(e=>(i.addImplicit(e.boundary),e)));break;case!o&&c:{let t=K(r,e),i=Pn(t),o=i;if(n){let e=jn(t);o=t=>i(t)!==e(t)}u=b(t,s(e=>G(e,qn(e),l)),v(o),q(a));break}case o&&!c:{let e=K(r,t),i=jn(e),o=i;if(n){let t=Pn(e);o=e=>t(e)!==i(e)}u=b(e,s(e=>[...qn(e)].flatMap(t=>ln(t,e,l))),v(o),q(a));break}default:{N(!o,`Inference failed - source should be a deployment ref`),N(!c,`Inference failed - target should be a deployment ref`);let n=K(r,e),i=K(r,t),d=Pn(n),f=jn(i);u=b(n,s(e=>G(e,i,l)),v(e=>d(e)&&f(e)),q(a))}}return i.addConnections(u),B.isDeploymentRef(e)&&f(e.selector)&&i.addImplicit(r.element(e.ref.deployment)),B.isDeploymentRef(t)&&f(t.selector)&&i.addImplicit(r.element(t.ref.deployment)),i},exclude:({expr:e,model:t,memory:n,stage:r,where:i})=>{let a=fn(e.target),o=fn(e.source),s;switch(!0){case B.isWildcard(e.source)&&B.isWildcard(e.target):return r.excludeConnections(q(n.connections,i)),r;case B.isModelRef(e.source)&&B.isModelRef(e.target):return s=Ln({source:e.source,target:e.target,expr:e,model:t}),Hn(s,{stage:r,memory:n},i);case B.isModelRef(e.source)&&B.isWildcard(e.target):return s=Fn(t,e.source),Hn(s,{stage:r,memory:n},i);case B.isModelRef(e.source):return s=Fn(t,e.source),Hn(s,{stage:r,memory:n},i,e=>a(e.target));case B.isModelRef(e.target):return s=Mn(t,e.target),Hn(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,v(c),q(i));return l.length===0||r.excludeConnections(l),r}}};function Ln({source:e,target:t,expr:n,model:r}){let i=dn(r,e),a=dn(r,t),o=n.isBidirectional?`both`:`directed`,s=[];for(let e of i)s.push(...ht(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(B.isWildcard(e.inout)){for(let e of a){let t=Wn(G(e,[...qn(e)],`both`),i);r.addConnections(t)}return r}N(B.isDeploymentRef(e.inout),`Only deployment refs are supported in include`);let o=K(t,e.inout);for(let e of a){let t=Wn(G(e,o,`both`),i);r.addConnections(t)}return r},exclude:({expr:e,model:t,memory:n,stage:r,where:i})=>{if(B.isElementTagExpr(e.inout)||B.isElementKindExpr(e.inout))throw Error(`element kind and tag expressions are not supported in exclude`);if(B.isModelRef(e.inout)){let a=dn(t,e.inout);return a.length===0?r:Hn(j(new Set,...a.flatMap(e=>[e.allIncoming,e.allOutgoing])),{stage:r,memory:n},i)}if(B.isWildcard(e.inout))return r;let a=K(t,e.inout),o=jn(a),s=Pn(a),c=b(n.connections,v(e=>o(e)!==s(e)),q(i));return r.excludeConnections(c),r}},zn={include:({expr:e,model:t,memory:n,stage:r})=>{let i=M(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=M(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;return i=n?b([...e.elements()],J(n)):H(Ee(e.roots(),e=>(e.onlyOneInstance()||r.push(...e.children()),e))),t.addExplicit(i),r.length>1?(t.addConnections(un([...i,...r])),t.connectWithExisting(r)):t.addConnections(un(i)),t.connectWithExisting(i),t},exclude:({stage:e,memory:t,where:n})=>{let r=b([...t.elements],J(n));return e.exclude(r),e}};function Vn(e,{expr:t,where:n,...r}){switch(!0){case B.isElementTagExpr(t):case B.isElementKindExpr(t):throw Error(`element kind and tag expressions are not supported in deployment view rules`);case A.isCustom(t):case B.isCustom(t):case B.isModelRef(t):return;case B.isWhere(t):return kn[e]({...r,expr:t,where:n});case A.isWhere(t):return zn[e]({...r,expr:t,where:n});case B.isDeploymentRef(t):return Jn[e]({...r,expr:t,where:n});case B.isWildcard(t):return Bn[e]({...r,expr:t,where:n});case A.isDirect(t):return In[e]({...r,expr:t,where:n});case A.isInOut(t):return Rn[e]({...r,expr:t,where:n});case A.isOutgoing(t):return Nn[e]({...r,expr:t,where:n});case A.isIncoming(t):return An[e]({...r,expr:t,where:n});default:V(t)}}function Hn(e,{stage:t,memory:n},r,i=()=>!0){if(e.size===0)return t;let a=b(n.connections,v(e=>i(e)),v(t=>ze(t.relations.model,e)),g(t=>t.update({deployment:null,model:T(t.relations.model,e)})),q(r),v(e=>e.nonEmpty()));return a.length===0?t:t.excludeConnections(a)}function Un(e,t){return q(e,t).nonEmpty()}function q(...t){if(t.length===1)return e=>q(e,t[0]);let[n,r]=t;return r===null?n:e(n)?n.map(e=>q(e,r)).filter(e=>e.nonEmpty()):n.update({model:new Set([...n.relations.model.values()].filter(e=>r(Kn(n)(e)))),deployment:new Set([...n.relations.deployment.values()].filter(e=>r(Kn(n)(e))))})}function J(...t){if(t.length===1){let e=t[0];return e==null?e=>e:t=>t.filter(t=>e(Gn(t,t)))}let[n,r]=t;return e(n)?r==null?n:n.filter(e=>r(Gn(e,e))):r?.(Gn(n,n))??!0}function Wn(e,t){return t?b(e,v(e=>Un(e,t))):e}function Gn(e,t){if(xt(e)){let n=bt(t)&&Tt(t)?t:null;return{kind:e.kind,tags:[...e.tags,...n?.tags??[]],metadata:e.metadata}}if(pt(e))return te(e.element,[`tags`,`kind`,`metadata`]);if(Tt(e))return{kind:e.element.kind,tags:[...e.tags,...e.element.tags],metadata:e.metadata};if(wt(e))return te(e,[`tags`,`kind`,`metadata`]);V(e)}function Kn(e){return t=>({tags:t.tags,kind:t.kind,metadata:t.metadata,source:Gn(t.source,e.source),target:Gn(t.target,e.target)})}function qn(e){let t=new Set;for(let n of e.descendingSiblings())t.add(n);return t}const Jn={include:e=>{let{expr:t,where:n}=e,r=e.model.element(t.ref.deployment);if(Tt(r))return J(r,n)&&(e.stage.addExplicit(r),e.stage.connectWithExisting(r)),e.stage;switch(!0){case t.selector===`expanded`:Xn(r,e);break;case t.selector===`children`:Yn(r,e);break;case t.selector===`descendants`:Zn(r,e);break;default:J(r,n)&&(e.stage.addExplicit(r),e.stage.connectWithExisting(r))}return e.stage},exclude:({expr:e,stage:t,memory:n,where:r})=>{let i=fn(e),a=b([...n.elements],v(i),J(r));return t.exclude(a),t}};function Yn(e,{stage:t,where:n}){let r=J([...e.children()],n);r.length!==0&&(t.addImplicit(e),t.addConnections(un(r)),t.connectWithExisting(r),t.addExplicit(r))}function Xn(e,{memory:t,stage:n,where:r}){n.addImplicit(e),n.connectWithExisting(e);let i=J([...e.children()],r),a=!1;for(let e of i)if(G(e,t.elements).length>0){a=!0;break}a&&(n.connectWithExisting(i,`in`),n.addConnections(un(i)),n.connectWithExisting(i,`out`)),n.addImplicit(i),n.connections.length>0&&n.addExplicit(e)}function Zn(e,{stage:t,where:n}){let i=e=>{let r=[];for(let t of e.children())t.isDeploymentNode()&&r.push(...i(t)),J(t,n)&&r.push(t);return t.connectWithExisting(r,`in`),t.addConnections(un(r)),t.addImplicit(r),r},a=i(e);if(a.length===0)return;t.connectWithExisting(a,`out`);let o=Qn(t);b(a,v(e=>o.has(e)),r(e=>t.addExplicit(e)))}function Qn(e){return b(e.mergedConnections(),wn,En,y((e,t)=>(e.add(t.source),e.add(t.target),e),new Set))}var $n=class e{memory;includeAncestors;static for(t,n){return new e(t,n)}constructor(e,t){this.memory=e,this.includeAncestors=t}step1CleanConnections(e){if(e.connections.length<2)return e;let t=b(e.connections,wn,En),n=gt(e.connections,t);if(n.length===0)return e;let r=e.stageExclude({});return r.excludeConnections(n,!0),r.commit()}step2ProcessImplicits(e){let t=j(this.memory.elements,e.elements),n=j(e.final,this.memory.explicits),i=new it.default(()=>new Set);for(let t of e.connections)if(t.boundary)for(let e of t.relations.model)i.get(e).add(t.boundary);for(let[e,r]of i)if(!(r.size<2))for(let e of r)t.delete(e)&&n.add(e);let a=new Set(n),o=e=>{for(let t of a)if(e===t||R(e,t))return!0;return!1};return b(O(t,a),L(e=>e.isDeploymentNode()),H(),qe,r(e=>{let t=[...e.children()].filter(o).length;if(t>=2){n.add(e);return}t===1&&De(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=Wt(e,`final`),r=e.stageExclude({}),i=r=>!(t.has(r)||e.explicits.has(r)||n.hasInOut(r)||n.root.has(r)),a=w([...n.root]);a&&!e.explicits.has(a)&&r.exclude(a);for(let t of e.final){let e=w(n.children(t));e&&!n.hasInOut(e)&&i(t)&&r.exclude(t)}return r.isDirty()?r.commit():e}step4AddAncestor(e){let t=new Set;for(let n of e.final)for(let e of n.ancestors())t.add(e);if(t.size>0){let n=j(e.final,t);return e.update({final:n})}return e}commit(){let e=this.step1CleanConnections(this.memory),t=this.step2ProcessImplicits(e),n=this.step3ProcessBoundaries(t);return this.includeAncestors===!0?this.step4AddAncestor(n):n}};const er=Ft(fn);function tr(e,t){let n=[],r=[];for(let e of t)if(tt(e)&&`include`in e)for(let t of e.include)A.isCustom(t)&&(t.customRelation.multiple===!0?n.push(t):t.customRelation.multiple===!1&&r.push(t));let i=new Set,a=e.specification.relationships;for(let e of Object.keys(a)){let t=a[e];(t?.style??t)?.multiple&&i.add(e)}if(n.length===0&&r.length===0&&i.size===0)return;let o=n.map(e=>({pred:er(e.customRelation.expr)})),s=r.map(e=>({pred:er(e.customRelation.expr)}));return(e,t)=>{let n=e=>{if(e&&typeof e==`object`){if(`tags`in e&&`kind`in e&&`metadata`in e)return e;if(e.instance&&e.element)return{id:e.id,tags:e.instance.tags,kind:e.element.kind,metadata:e.instance.metadata}}return e??{}},r=n(t?.source??e.source),a=n(t?.target??e.target);if(s.length>0){for(let{pred:t}of s)if(t({source:r,target:a,kind:e.kind,tags:e.tags,metadata:e.metadata}))return!1}if(i.size>0){let t=e.kind;if(t&&i.has(t))return!0}if(o.length>0){for(let{pred:t}of o)if(t({source:r,target:a,kind:e.kind,tags:e.tags,metadata:e.metadata}))return!0}return!1}}function nr(e,t){let n=On.empty(),r=!1;for(let i of t){if(tt(i)){let t=`include`in i?`include`:`exclude`,r=i.include??i.exclude;for(let i of r){let r=t===`include`?n.stageInclude(i):n.stageExclude(i);r=Vn(t,{expr:i,model:e,stage:r,memory:n,where:null})??r,n=r.commit()}}`includeAncestors`in i&&(r=i.includeAncestors)}return $n.for(n,r).commit()}function rr(e,{docUri:t,rules:n,...r}){let i=nr(e.deployment,n),a=bn(e,i),s=tr(e,n),c=yn(i.connections,s);Pt(a,c);let l=zt({nodes:a,edges:c}),u=xn(n,l.nodes),d=o(n,Be),f=kt(u);return Bt({...r,[Oe]:`computed`,[et]:`deployment`,autoLayout:{direction:d?.direction??`TB`,...d?.nodeSep&&{nodeSep:d.nodeSep},...d?.rankSep&&{rankSep:d.rankSep}},edges:l.edges,nodes:g(u,e=>(e.icon===`none`&&delete e.icon,e)),...f.length>0&&{notation:{nodes:f}}})}function ir(e){return t=>Ue(t)?t.groupRules.flatMap(ir(e)):tt(t)&&`include`in t?t.include.filter(e):[]}function ar(e,t){let n=e.flatMap(ir(P.isCustom));if(n.length===0)return t;let r=[...t];for(let{custom:{expr:e,...t}}of n){let{border:n,opacity:i,multiple:o,iconColor:s,iconSize:c,iconPosition:u,padding:d,size:f,textSize:p,...m}=ge(t,l),h=z({border:n,opacity:i,multiple:o,iconColor:s,iconSize:c,iconPosition:u,padding:d,size:f,textSize:p}),g=!a(h),_=!a(m),v=W(e);r.forEach((e,t)=>{je(e)||!v(e)||(_&&(e={...e,...m,isCustomized:!0}),g&&(e={...e,isCustomized:!0,style:{...e.style,...h}}),r[t]=e)})}return r}function or(e,t){return e.reduce((e,n)=>{if(Qe(n)){let r=t.predicates[n.predicateId];return l(r)?e:e.concat(r)}if(Ae(n)){let r=t.styles[n.styleId];return l(r)?e:e.concat(r)}return e.push(n),e},[])}function sr(e,t){return e.reduce((e,n)=>{if(Qe(n)){let r=t.dynamicPredicates[n.predicateId];return l(r)?e:e.concat(r)}if(Ae(n)){let r=t.styles[n.styleId];return l(r)?e:e.concat(r)}return e.push(n),e},[])}function cr(e,t){let n=new Set;for(let r of t)if(tt(r))for(let t of r.include){let r=W(t);for(let t of e.elements())r(t)&&n.add(t)}return n}const lr=e=>{if(Ge(e)){let t=[],n=[];for(let r of e.__parallel)if(Xe(r)){let[e,...i]=r.__series;t.push(e),n.push(...i)}else t.push(r);return[...t,...n]}return Xe(e)?[...e.__series]:e};function ur(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 s(t,lr)){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 dr(e,t,n){let r=mt(e,t,`directed`).flatMap(e=>[...e.relations]).sort(xe);if(!ve(r))return{};if(r.length===1){let e=r[0];return z({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,s(e=>e.tags),ie()),a=p(i,1)?i:void 0,o=g(r,e=>e.id),c=ue(r).$relationship.navigateTo;c===n&&(c=void 0),c||=b(r,s(e=>e.$relationship.navigateTo&&e.$relationship.navigateTo!==n?e.$relationship.navigateTo:[]),ie(),w());let l=b(r,y((e,{title:t,technology:n,$relationship:r})=>(d(t)&&e.title.add(t),d(r.color)&&e.color.add(r.color),d(r.line)&&e.line.add(r.line),d(r.kind)&&e.kind.add(r.kind),d(n)&&e.technology.add(n),d(r.description)&&!e.description.some(_(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 z({tags:a??void 0,relations:o,navigateTo:c,kind:w([...l.kind]),title:w([...l.title]),color:w([...l.color]),line:w([...l.line]),technology:w([...l.technology]),description:w(l.description)})}var fr=class{model;view;steps=[];constructor(e,t){this.model=e,this.view=t}compute(){let{docUri:e,rules:t,steps:n,...r}=this.view,i=sr(t,this.model.globals),a=cr(this.model,i),s=ur(this.model,n),c=b(j(T(a,s),s,a),H(),Ie),l=c.reduce((e,t,n,r)=>{for(let i=n+1;i<r.length;i++){let n=r[i];if(R(t,n)){e.push(t);break}}return e},[]),u=(e,t,n)=>{if(Xe(e)){for(let r of e.__series)t=u(r,t,n);return t}let r=n?Le(n,t):Le(t),{source:i,target:a,title:o,isBackward:s,navigateTo:f,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:ee,relations:te,navigateTo:ne,...y}=dr(h,_,this.view.id),b=d(f)&&f!==this.view.id?f:ne,x=e.kind?this.model.specification.relationships[e.kind]:void 0;return this.steps.push(z({...y,...!e.technology&&!y.technology&&x?.technology&&{technology:x.technology},...!e.color&&!y.color&&x?.color&&{color:x.color},...!e.line&&!y.line&&x?.line&&{line:x.line},...!e.head&&x?.head&&{head:x.head},...!e.tail&&x?.tail&&{tail:x.tail},...m,id:r,source:h,target:_,navigateTo:b,title:o??ee,relations:te??[],isBackward:g>v})),t+1},f=1;for(let e of n){if(Ge(e)){let t=1;for(let n of e.__parallel)t=u(n,t,f);f++;continue}f=u(e,f)}let p=on(this.model.$styles,c.map(an)),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=D(p.get(t.id),`Source node ${t.id} not found`),l=D(p.get(n.id),`Target node ${n.id} not found`),u={id:e,parent:Ye(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=Ne(u.parent);c.outEdges.push(u.id),l.inEdges.push(u.id);for(let e of We(u.source)){if(e===u.parent)break;p.get(e)?.outEdges.push(u.id)}for(let e of We(u.target)){if(e===u.parent)break;p.get(e)?.inEdges.push(u.id)}return u}),_=ar(i,qt(i,c.map(e=>D(p.get(e.id))))),v=o(i,Be),ee=kt(_);return Bt({...r,[et]:`dynamic`,[Oe]:`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,...ee.length>0&&{notation:{nodes:ee}}})}};function pr(e,t){return new fr(e,t).compute()}function mr(e,t,n){let r=e.flatMap(ir(k.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,multiple:s,...c}}of r){let r=a?{description:Ze(a)}:{},s=o?{notes:Ze(o)}:{},u=ge(c,l),d=It(e);i.forEach((e,a)=>{let o,c;for(let n of t)if(n.id===e.source&&(o=n),n.id===e.target&&(c=n),o&&c)break;!o||!c||d({source:o,target:c,...te(e,[`kind`,`tags`])})&&(i[a]={...e,...u,...r,...s,label:n??e.label,isCustomized:!0})})}return i}function hr(e){return b([...e],st,y((e,t,n,r)=>{let i=Ot(r,t),a=j(...i.map(oe(`relations`))),o=T(t.relations,a);if(i.length>0&&(o=j(o,t.directRelations)),Et(r,t.reversed())&&(o=j(o,t.directRelations)),o.size<t.relations.size){let e=r.some(ot(t.source)),n=r.some(ot(t.target));e&&(o=j(o,E(L(t.relations,ct(t.source))))),n&&(o=j(o,E(L(t.relations,Dt(t.target)))))}return o.size>0&&e.push(t.update(o)),e},[]))}var gr=class e{memory;static for(t){return new e(t)}constructor(e){this.memory=e}step1CleanConnections(e){if(e.connections.length<2)return e;let t=hr(e.connections);if(t.length===0)return e;let n=e.stageExclude({});return n.excludeConnections(t,!0),n.commit()}step2ProcessImplicits(e){let t=j(this.memory.elements,e.elements),n=j(e.final,this.memory.explicits),i=new Set(n),a=e=>{for(let t of i)if(e===t||R(e,t))return!0;return!1};return b(O(t,i),H(),qe,r(e=>{let t=[...e.children()].filter(a).length;if(t>=2){n.add(e);return}t===1&&De(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=Wt(e,`final`),r=e.stageExclude({}),i=r=>!(t.has(r)||e.explicits.has(r)||n.hasInOut(r)||n.root.has(r)),a=w([...n.root]);a&&!e.explicits.has(a)&&r.exclude(a);for(let t of e.final){let e=w(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:_r,findConnectionsBetween:Y,findConnectionsWithin:vr}=St;function X(e,t){switch(!0){case P.isElementKindExpr(t):return[...L(e.elements(),e=>t.isEqual===(e.kind===t.elementKind))];case P.isElementTagExpr(t):return[...L(e.elements(),e=>t.isEqual===e.tags.includes(t.elementTag))];case t.selector===`expanded`:{let n=e.element(I.flatten(t.ref));return[n,...n.children()]}case t.selector===`children`:case t.selector===`descendants`:{let n=e.element(I.flatten(t.ref)),r=t.selector===`children`?H(n.children()):H(n.descendants());return r&&r.length>0?r:[n]}case P.isModelRef(t):return[e.element(I.flatten(t.ref))];default:V(t)}}function yr(e,t){if(t.isEmpty()||e.length===0)return e;let n=S(e.map(e=>Ve(e))),r=H(L(t.elements,t=>!e.includes(t)&&n(t)));return[...e,...r]}function br(e,{memory:t,model:n}){let r=X(n,e);return P.isModelRef(e)?e.selector===`descendants`?r:yr(r,t):r}const xr={include:({expr:e,model:t,stage:n,where:r})=>{let i=t.element(I.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(vr(o)),n},exclude:({expr:e,model:t,stage:n,filterWhere:r})=>{let i=r(X(t,e));return n.exclude(i),n}},Sr={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(vr(i)),n},exclude:({expr:e,model:t,stage:n,filterWhere:r})=>{let i=r(X(t,e));return n.exclude(i),n}},Cr={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(vr(i)),n},exclude:({expr:e,model:t,stage:n,filterWhere:r})=>{let i=r(X(t,e));return n.exclude(i),n}},wr=()=>!0,Tr=e=>e,Er=(e,t,n)=>we(`model:${e}:${t}:${n}`);function Dr(e,t){return e.flatMap(e=>{let n=[...e.relations];N(p(n,1),`Edge must have at least one relation`);let r=e.source.$model.$styles.defaults,i=e.source.id,a=e.target.id,o=v(n,e=>e.source.id===i&&e.target.id===a);if(t&&n.length>1){let[o,s]=b(n,C(n=>t(n,e)));if(o.length>0){let t=o.map(t=>{let{title:n,color:o=r.relationship.color,line:s=r.relationship.line,head:c=r.relationship.arrow,...l}=cn([t.$relationship],t.$relationship);return{id:Er(i,a,t.id),parent:e.boundary?.id??null,source:i,target:a,label:n??null,relations:[t.id],color:o,line:s,head:c,...l}});if(s.length>0){let{title:n,color:o=r.relationship.color,line:c=r.relationship.line,head:l=r.relationship.arrow,...u}=cn(s.map(e=>e.$relationship),w(v(s,e=>e.source.id===i&&e.target.id===a))?.$relationship);t.push({id:e.id,parent:e.boundary?.id??null,source:i,target:a,label:n??null,relations:s.map(e=>e.id),color:o,line:c,head:l,...u})}return t}}let{title:s,color:c=r.relationship.color,line:l=r.relationship.line,head:u=r.relationship.arrow,...d}=cn(n.map(e=>e.$relationship),w(o)?.$relationship);return[z({id:e.id,parent:e.boundary?.id??null,source:i,target:a,label:s??null,relations:n.map(e=>e.id),color:c,line:l,head:u,...d})]})}function Or(e,t){return on(e.$styles,[...t.final].map(an),t.groups)}const Z=P.isWildcard,kr=(e,t)=>e.isAncestorOf(t)||e.isDescendantOf(t),Ar={include:({expr:{source:e,target:t,isBidirectional:n=!1},memory:r,model:i,stage:a,where:o,filterWhere:c})=>{let l=Z(e),u=Z(t),d=[];switch(!0){case l&&u&&r.isEmpty()&&o!==wr:{let e=b(i.relationships(),L(o),H(),g(e=>new _t(e.source,e.target,new Set([e]))));return a.addConnections(e),a}case l&&u&&!r.isEmpty()&&o!==wr:d.push(...vr(r.elements));break;case l&&u:d.push(...vr(i.roots()));break;case!l&&u&&o!==wr:{let t=b(X(i,e),s(e=>b(e,se(pe(n===!0),{onTrue:e=>j(e.allIncoming,e.allOutgoing),onFalse:e=>e.allOutgoing}),L(o),Ce(),H(),C(t=>t.source===e),([t,n])=>ce(b(t,v(t=>!kr(e,t.target)),g(t=>new _t(e,t.target,new Set([t])))),b(n,v(t=>!kr(e,t.source)),g(t=>new _t(t.source,e,new Set([t]))))))));return a.addConnections(t),a}case!l&&u:{let[t,a]=jr(e,{memory:r,model:i}),o=n?`both`:`directed`;for(let e of t)d.push(...Y(e,a,o));break}case l&&!u&&o!==wr:{let e=b(X(i,t),s(e=>b(e,se(pe(n===!0),{onTrue:e=>j(e.allIncoming,e.allOutgoing),onFalse:e=>e.allIncoming}),L(o),H(),C(t=>t.target===e),([t,n])=>ce(b(n,v(t=>!kr(e,t.target)),g(t=>new _t(e,t.target,new Set([t])))),b(t,v(t=>!kr(e,t.source)),g(t=>new _t(t.source,e,new Set([t]))))))));return a.addConnections(e),a}case l&&!u:{let[e,a]=jr(t,{memory:r,model:i}),o=n?`both`:`directed`;for(let t of a)d.push(...Y(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=br(e,{memory:r,model:i}),o=br(t,{memory:r,model:i}),s=n?`both`:`directed`;for(let e of a)d.push(...Y(e,o,s))}}return a.addConnections(c(d)),a},exclude:({expr:{source:e,target:t,isBidirectional:n},model:r,memory:i,stage:a,where:o})=>{let c=Z(e),l=Z(t),u;switch(!0){case c&&l:u=b(i.connections,s(re(oe(`relations`),L(o),H())),E());break;case!c&&l:u=b(X(r,e),s(e=>b(e,se(pe(n===!0),{onTrue:e=>j(e.allIncoming,e.allOutgoing),onFalse:e=>e.allOutgoing}),L(o),H())),E());break;case c&&!l:u=b(X(r,t),s(e=>b(e,se(pe(n===!0),{onTrue:e=>j(e.allIncoming,e.allOutgoing),onFalse:e=>e.allIncoming}),L(o),H())),E());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)$e(e,t)||(s=j(s,T(e.allOutgoing,t.allIncoming),n?T(t.allOutgoing,e.allIncoming):new Set));u=E(L(s,o))}}return a.excludeRelations(u),a}};function jr(e,{memory:t,model:n}){let r=X(n,e);if(!p(r,1))return[[],[]];if(P.isModelRef(e)){let i=H(n.element(I.flatten(e.ref)).ascendingSiblings());return[yr(r,t),yr(i,t)]}return[r,b(r,g(e=>e.ascendingSiblings()),be(),Ce(),H(),e=>yr(e,t))]}const Mr={include:({expr:e,scope:t,model:n,memory:r,stage:i,filterWhere:a})=>{let o=e.incoming,s=[];if(P.isWildcard(o)){if(!t)return;for(let e of t.ascendingSiblings())s.push(..._r(e,t,`directed`))}else{let e=br(o,{memory:r,model:n}),t=[...r.elements];t.length===0&&t.push(...ie(e.flatMap(e=>[...e.ascendingSiblings()])));let i=Nr(n,o);for(let n of t)s.push(...Y(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(P.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 Nr(e,t){switch(!0){case P.isElementKindExpr(t):case P.isElementTagExpr(t):{let e=W(t);return t=>e(t.target)}case P.isModelRef(t)&&t.selector===`children`:{let n=I.flatten(t.ref);return S([...e.children(n)].map(e=>U.isIncoming(e.id)))}case P.isModelRef(t)&&t.selector===`descendants`:{let n=I.flatten(t.ref);return S([U.isInside(n),...[...e.children(n)].map(e=>U.isIncoming(e.id))])}case P.isModelRef(t)&&t.selector===`expanded`:{let e=I.flatten(t.ref);return S([U.isIncoming(e),U.isInside(e)])}case P.isModelRef(t):{let e=I.flatten(t.ref);return U.isIncoming(e)}default:V(t)}}const Pr={include:({expr:{inout:e},scope:t,model:n,memory:r,stage:i,filterWhere:a})=>{let o=[];if(P.isWildcard(e)){if(!t)return;o.push(...Y(t,t.ascendingSiblings()))}else{let t=br(e,{memory:r,model:n}),i=[...r.elements];i.length===0&&(i=ie(t.flatMap(e=>H(e.ascendingSiblings()))));for(let e of t)o.push(...Y(e,i))}return i.addConnections(a(o)),i},exclude:({expr:{inout:e},model:t,scope:n,stage:r,where:i})=>{let a=[];if(P.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(E(a.filter(i))),r}},Fr={include:({expr:e,scope:t,model:n,memory:r,stage:i,filterWhere:a})=>{let o=e.outgoing,s=[];if(P.isWildcard(o)){if(!t)return;s.push(...Y(t,t.ascendingSiblings(),`directed`))}else{let e=br(o,{memory:r,model:n}),t=[...r.elements];t.length===0&&t.push(...ie(e.flatMap(e=>[...e.ascendingSiblings()])));let i=Ir(n,o);for(let n of e)s.push(...Y(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(P.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(E(a.filter(i))),r}};function Ir(e,t){switch(!0){case P.isElementKindExpr(t):case P.isElementTagExpr(t):{let e=W(t);return t=>e(t.source)}case P.isModelRef(t)&&t.selector===`children`:{let n=I.flatten(t.ref);return S([...e.children(n)].map(e=>U.isOutgoing(e.id)))}case P.isModelRef(t)&&t.selector===`descendants`:{let n=I.flatten(t.ref);return S([U.isInside(n),...[...e.children(n)].map(e=>U.isOutgoing(e.id))])}case P.isModelRef(t)&&t.selector===`expanded`:{let e=I.flatten(t.ref);return S([U.isOutgoing(e),U.isInside(e)])}case P.isModelRef(t):{let e=I.flatten(t.ref);return U.isOutgoing(e)}default:V(t)}}const Lr={include:({scope:e,model:t,stage:n,memory:r,where:i})=>{if(!e){let e=i===wr?[...t.roots()]:H(L(t.elements(),i));if(e.length===0)return;let[r,a]=C(e,e=>!e.imported);return n.addExplicit(r),n.addImplicit(a),n.addConnections(vr(e)),n.connectWithExisting(e),n}let a=H(L(e.children(),i)),o=a.length>0;if(!o){let t=Y(e,e.siblings()),r=e.parent;t.length===0&&r&&n.addExplicit(r),a.push(e)}n.addExplicit(e);let s=E([...r.elements,...e.descendingSiblings()]);for(let e of s)n.addConnections(Y(e,a,`directed`));o&&(n.addConnections(vr(a)),n.addExplicit(a));for(let e of a)n.addConnections(Y(e,s,`directed`));return n},exclude:({scope:e,memory:t,stage:n,where:r})=>r===wr?e?(n.exclude([e,...e.descendants()]),n):tn.empty(t.scope).stageExclude(n.expression):(n.exclude(v([...t.elements],r)),n)};function Rr(e,t,n){switch(!0){case P.isCustom(e):return t===`include`?Rr(e.custom.expr,t,n):n.stage;case P.isWhere(e):{let r=M(e.where.condition),i=e=>v(e,r);return Rr(e.where.expr,t,{...n,where:r,filterWhere:i})}case P.isModelRef(e)&&e.selector===`expanded`:return xr[t]({...n,expr:e})??n.stage;case P.isWildcard(e):return Lr[t]({...n,expr:e})??n.stage;case P.isElementKindExpr(e):case P.isElementTagExpr(e):return Sr[t]({...n,expr:e})??n.stage;case P.isModelRef(e):return Cr[t]({...n,expr:e})??n.stage;default:V(e)}}function zr(e,t,n){switch(!0){case k.isCustom(e):return t===`include`?zr(e.customRelation.expr,t,n):n.stage;case k.isWhere(e):{let r=M(e.where.condition),i=e=>new Set(v([...e],r)),a=e=>b(e,g(e=>new _t(e.source,e.target,i(e.relations))),v(e=>e.nonEmpty()));return zr(e.where.expr,t,{...n,where:r,filterWhere:a})}case k.isInOut(e):return Pr[t]({...n,expr:e})??n.stage;case k.isDirect(e):return Ar[t]({...n,expr:e})??n.stage;case k.isOutgoing(e):return Fr[t]({...n,expr:e})??n.stage;case k.isIncoming(e):return Mr[t]({...n,expr:e})??n.stage;default:V(e)}}function Br(e,t,n){let r={model:e,scope:t.scope,where:wr,filterWhere:Tr};for(let i of n){if(Ue(i)){t=Br(e,nn.enter(t,i),i.groupRules),N(t instanceof nn,`processPredicates must return ActiveGroupMemory`),t=t.leave();continue}if(tt(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 Te.isFqnExpr(i):n=Rr(i,e,{...r,stage:n,memory:t})??n;break;case Te.isRelationExpr(i):n=zr(i,e,{...r,stage:n,memory:t})??n;break;default:V(i)}t=n.commit()}}}return t}function Vr(e,t,n){return t=Br(e,t,n),gr.for(t).commit()}function Hr(e,t){let n=t.flatMap(ir(k.isCustom)).filter(e=>e.customRelation.multiple===!0),r=t.flatMap(ir(k.isCustom)).filter(e=>e.customRelation.multiple===!1),i=new Set,a=e.specification.relationships;for(let e of Object.keys(a)){let t=a[e];(t?.style??t)?.multiple&&i.add(e)}if(n.length===0&&r.length===0&&i.size===0)return;let o=n.map(e=>({pred:It(e.customRelation.expr)})),s=r.map(e=>({pred:It(e.customRelation.expr)}));return(e,t)=>{let n=t?.source??e.source,r=t?.target??e.target;if(s.length>0){for(let{pred:t}of s)if(t({source:n,target:r,kind:e.kind,tags:e.tags,metadata:e.metadata}))return!1}if(i.size>0){let t=e.kind;if(t&&i.has(t))return!0}if(o.length>0){for(let{pred:t}of o)if(t({source:n,target:r,kind:e.kind,tags:e.tags,metadata:e.metadata}))return!0}return!1}}function Ur(e,{docUri:t,rules:n,...r}){let i=or(n,e.globals),a=r.viewOf?e.asComputed.element(r.viewOf):null,s=Vr(e,tn.empty(a),i);s.isEmpty()&&a&&(s=s.update({final:new Set([a])})),s=Gr(s);let c=Or(e,s),l=Hr(e,i),u=Dr(s.connections,l);Pt(c,u);let d=zt({nodes:c,edges:u}),f=ar(i,qt(i,d.nodes)),p=o(i,Be),m=kt(f),h=Wr(i,f);return Bt({...r,_stage:`computed`,autoLayout:{direction:p?.direction??`TB`,...p?.nodeSep&&{nodeSep:p.nodeSep},...p?.rankSep&&{rankSep:p.rankSep}},edges:mr(i,f,d.edges),nodes:g(f,e=>(e.icon===`none`&&delete e.icon,e)),...m.length>0&&{notation:{nodes:m}},...h.length>0&&{ranks:h}})}function Wr(e,t){let n=[];for(let r of e){if(!Je(r)||r.targets.length===0)continue;let e=b(t,v(S(r.targets.map(W))),g(e=>e.id));p(e,1)&&n.push({type:r.rank,nodes:e})}return n}function Gr(e){if(e.groups.length===0)return e;let t=new it.default(()=>new Set),n=new Map,i=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(Ie([...e.explicitFirstSeenIn.keys()]),r(r=>{if(!i(r)){let i=D(e.explicitFirstSeenIn.get(r));n.set(r,i),t.get(i).add(r)}})),b(Ie([...e.lastSeenIn.keys()]),v(e=>!n.has(e)),r(r=>{if(i(r)||a(r))return;let o=D(e.lastSeenIn.get(r));n.set(r,o),t.get(o).add(r)})),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 Kr(e,t){switch(!0){case Pe(e):return Ur(t,e);case Ke(e):return rr(t,e);case Fe(e):return pr(t,e);default:V(e)}}function qr(e,t){try{return{isSuccess:!0,view:Kr(e,t)}}catch(e){return{isSuccess:!1,error:e instanceof Error?e:Error(`Unknown error: ${e}`),view:void 0}}}function Jr(e){let n=lt.create(e),{views:r,_stage:i,...a}=e,o=t(r,e=>Kr(e,n));return{[Oe]:`computed`,...a,views:o}}function Yr(e){return lt.create(Jr(e))}const Q=e=>e;function $(e){if(!ae(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{Kr as a,Pt as c,qr as i,Yr as n,Ur as o,Jr as r,zt as s,$ as t};
|
|
1
|
+
import{B as e,C as t,E as n,G as r,H as i,I as a,J as o,K as s,L as c,M as l,N as u,O as d,P as f,Q as p,R as m,S as h,T as g,V as _,Y as v,Z as ee,_ as te,a as ne,d as y,et as b,g as x,h as re,i as ie,k as ae,m as oe,n as se,nt as ce,o as le,q as ue,r as de,rt as S,t as fe,tt as pe,u as me,v as he,w as ge,x as _e,y as C,z as ve}from"./libs/remeda.mjs";import{An as ye,Bt as be,Dt as xe,En as w,Ft as Se,G as Ce,Gt as we,Ht as T,Jt as Te,K as E,Mt as D,O,Ot as Ee,Pt as k,Qt as De,Tn as A,Ut as Oe,Vt as j,X as M,Y as N,Z as P,Zt as F,_n as ke,_t as Ae,an as je,b as Me,bt as Ne,d as Pe,dn as Fe,dt as Ie,fn as Le,g as Re,h as ze,hn as Be,in as Ve,jn as I,jt as He,kt as L,l as Ue,mn as We,n as Ge,nt as Ke,o as qe,on as Je,p as Ye,pt as Xe,q as R,r as Ze,rt as Qe,s as $e,tn as et,u as tt,un as z,wn as B,xn as nt,y as rt,yt as it}from"./types.mjs";import{c as at,t as ot}from"./libs/mnemonist.mjs";import{A as st,C as ct,D as lt,E as ut,M as V,N as dt,O as ft,T as pt,_ as mt,c as ht,d as gt,f as _t,g as vt,h as yt,j as bt,m as xt,n as St,o as Ct,p as wt,q as Tt,r as Et,t as Dt,v as Ot,w as kt,y as At}from"./model.mjs";import{r as jt}from"./manual-layout.mjs";import{t as Mt}from"./libs/graphology.mjs";import{n as Nt,t as Pt}from"../utils/graphology/index.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 r of t){let t=e.get(r.source),i=e.get(r.target);B(t,`Source node ${r.source} not found`),B(i,`Target node ${r.target} not found`),t.outEdges.push(r.id),i.inEdges.push(r.id);let a=Ft(t,e),o=Ft(i,e),s=a.length>0&&o.length>0?n(nt(me(a),me(o))):null;r.parent=s?s.id:null;for(let e of a){if(e===s)break;e.outEdges.push(r.id)}for(let e of o){if(e===s)break;e.inEdges.push(r.id)}}}function H(e){if(E.isCustom(e))return H(e.custom.expr);if(E.isWhere(e)){let t=H(e.where.expr),n=O(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=P.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}w(e)}function Lt(e){return function t(n){switch(!0){case R.isCustom(n):return t(n.customRelation.expr);case R.isWhere(n):{let e=t(n.where.expr),r=O(n.where.condition);return t=>e(t)&&r({source:{tags:t.source.tags,kind:t.source.kind,metadata:t.source.metadata},target:{tags:t.target.tags,kind:t.target.kind,metadata:t.target.metadata},...t.tags&&{tags:t.tags},...t.kind&&{kind:t.kind},...t.metadata&&{metadata:t.metadata}})}case R.isDirect(n):{let t=e(n.source),r=e(n.target);return e=>t(e.source)&&r(e.target)||!!n.isBidirectional&&t(e.target)&&r(e.source)}case R.isInOut(n):{let t=e(n.inout);return e=>t(e.source)||t(e.target)}case R.isIncoming(n):{let t=e(n.incoming);return e=>t(e.target)}case R.isOutgoing(n):{let t=e(n.outgoing);return e=>t(e.source)}default:w(n)}}}const Rt=Lt(H);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 i=t=>A(e.nodes.get(t)),a=new Mt({multi:!0,allowSelfLoops:!0,type:`directed`}),[o,s]=he(b(n,g(e=>{let t=i(e.source),n=i(e.target),r=e.parent?i(e.parent):null;return{id:e.id,edge:e,parent:r,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,Nt.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)),r(e=>{a.mergeNode(e.id),(0,Nt.default)(a,t.source,e.id)||a.mergeDirectedEdge(t.source,e.id),(0,Nt.default)(a,e.id,t.target)||a.mergeDirectedEdge(e.id,t.target)})),n.parent){let e=i(n.parent);a.mergeNode(e.id),(0,Nt.default)(a,e.id,n.id)||a.mergeDirectedEdge(e.id,n.id),s.parent&&s.parent!==n.parent&&((0,Nt.default)(a,e.id,s.parent)||a.mergeDirectedEdge(e.id,s.parent))}for(let{edge:e}of s)l(e);B(c.length===n.length,`Not all edges were added to the graph`);let u=(0,Pt.topologicalSort)(a),d=[],f=t.slice();for(let e of u){let t=f.findIndex(t=>t.id===e);B(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=Ee({id:e.id,__:e._type??`element`,autoLayout:e.autoLayout,nodes:b(e.nodes,g(e=>({id:e.id,icon:d(e.icon)&&e.icon!==`none`?`Y`:`N`,title:e.title,description:Ie(e.description),technology:e.technology??null,shape:e.shape,size:e.style.size??null,iconSize:e.style.iconSize??null,iconColor:e.style.iconColor??null,iconPosition:e.style.iconPosition??null,border:e.style.border??null,opacity:e.style.opacity??null,multiple:e.style.multiple??null,textSize:e.style.textSize??null,padding:e.style.padding??null,children:e.children})),ge(({id:e,...t})=>[e,t])),edges:b(e.edges,g(e=>({id:e.id,source:e.source,target:e.target,label:e.label,description:Ie(e.description),technology:e.technology??null,dir:e.dir,head:e.head,tail:e.tail,line:e.line})),ge(e=>[e.id,{...e}]))}),e}var Ut=class{state;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{memory;expression;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(De(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(ve(t)&&(B(!this.markedToMoveExplicitToImplicit,`Already marked to move explicits`),this.markedToMoveExplicitToImplicit=t),De(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=L(new Set(this.memory.connections.flatMap(e=>[e.source,e.target])),new Set(e.connections.flatMap(e=>[e.source,e.target])));return t=D(t,e.elements),t=b(t,F(t=>e.explicits.has(t)&&!Oe(e.final,Fe(t))),T()),t.size>0&&(t=this.filterForMoveToImplicits(t),e.explicits=L(e.explicits,t),e.final=L(e.final,t)),e}removeElements(e){return e.elements=L(e.elements,this.excluded.elements),e.explicits=L(e.explicits,this.excluded.elements),e.final=L(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=L(n,e.explicits),e.final=L(e.final,n),e)}precommit(e){return e}postcommit(e){return B(L(e.explicits,e.elements).size===0,`Explicits must be subset of elements`),B(L(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,...mt(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{memory;expression;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 lt([...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(De(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(De(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(De(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]=he(this._connections,t=>e.final.has(t.source));e.connections=this.processConnections(lt([...e.connections,...n,...r])),t=new Set(e.connections.flatMap(e=>[e.source,e.target]))}return e.elements=k(e.elements,this._ordered,this.explicits,t,this.implicits),e.explicits=D(e.elements,k(e.explicits,this.explicits)),e.final=D(e.elements,k(e.final,this.explicits,t)),this.memory.update(this.postcommit(e))}};function Kt(e,t=`final`){let n=ke(j(t===`final`?e.final:e.elements)),r=new Set(e.connections.flatMap(e=>[e.source,e.target])),i=new Set(n),a=new ot.default(()=>null),o=n.reduce((e,t,n,r)=>(e.set(t,r.slice(n+1).filter(e=>z(t,e)).map(e=>(i.delete(e),e)).reduce((e,n)=>(e.some(e=>z(e,n))||(e.push(n),a.set(n,t)),e),[])),e),new ot.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 Jt(e,t,n){let{shape:i,color:a,icon:o,...s}=e.style,l=!c(s);b(n,v(u(Xe)),v(t),r(t=>{t.shape=i??t.shape,t.color=a??t.color,m(o)&&(t.icon=o),m(e.notation)&&(t.notation=e.notation),l&&(t.style={...t.style,...s})}))}function Yt(e,t){for(let n of e)!Me(n)||n.targets.length===0||Jt(n,S(n.targets.map(H)),t);return t}var Xt=class e{id;viewRule;parent;elements;static kind=Ke;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,v(t=>He(t.relations,e)),r(t=>{this.excludeConnections(t.update(D(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=L(this.memory.explicits,e.explicits);for(let n of t)e.explicitFirstSeenIn.delete(n);let n=L(this.memory.elements,e.elements);for(let t of n)e.lastSeenIn.delete(t);return e}},Qt=class extends Zt{memory;expression;constructor(e,t){super(e,t),this.memory=e,this.expression=t}};const{findConnection:$t,findConnectionsBetween:en}=wt;var tn=class extends Gt{connectWithExisting(e,t=`both`){let n=this._connections.length,r=()=>this._connections.length>n;if(!De(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||z(this.memory.scope,e))&&this.addImplicit(e)}processConnections(e){return Ce.isRelationExpr(this.expression)||b(e,r(({source:e,target:t,boundary:n})=>{b(fe([...j(e.ancestors()).reverse(),e],[...j(t.ancestors()).reverse(),t]),ee(([e,t])=>e===t),le(1),r(([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=L(e.explicits,this.memory.explicits);for(let n of t)e.explicitFirstSeenIn.set(n,`@root`);return e}},nn=class extends tn{memory;expression;constructor(e,t){super(e,t),this.memory=e,this.expression=t}postcommit(e){let t=L(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{state;scope;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{state;scope;stack;static enter(t,n){let r=`@gr${t.groups.length+1}`;if(t instanceof e){let i=at.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=at.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}=h(e.$element,[`summary`,`description`,`metadata`,`style`,`tags`]),{color:i,icon:a,shape:o,...s}=e.style;return I({id:t,title:n,modelRef:t,shape:o,color:i,icon:a,style:s,description:ye(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&&A(r.get(n),`Parent group node ${n} not found`).children.push(t),r.set(t,{id:t,parent:n,kind:Ke,title:a.title??``,color:a.color??e.group.color??e.color,shape:`rectangle`,children:[],inEdges:[],outEdges:[],level:0,depth:0,tags:[],style:I({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(Je).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=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=I({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,y((e,t)=>(d(t.title)&&!e.title.includes(t.title)&&e.title.push(t.title),d(t.description)&&!e.description.some(_(t.description))&&e.description.push(t.description),d(t.technology)&&!e.technology.includes(t.technology)&&e.technology.push(t.technology),d(t.kind)&&!e.kind.includes(t.kind)&&e.kind.push(t.kind),d(t.color)&&!e.color.includes(t.color)&&e.color.push(t.color),d(t.line)&&!e.line.includes(t.line)&&e.line.push(t.line),d(t.head)&&!e.head.includes(t.head)&&e.head.push(t.head),d(t.tail)&&!e.tail.includes(t.tail)&&e.tail.push(t.tail),d(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=C(n.title)??(n.title.length>1?`[...]`:void 0),i=ie(n.tags),a=I({title:r,description:C(n.description),technology:C(n.technology),kind:C(n.kind),head:C(n.head),tail:C(n.tail),color:C(n.color),line:C(n.line),navigateTo:C(n.navigateTo),...et(i)&&{tags:i}});if(t){let e=ln(t);a=x({...a,...e},d)}return l(a.title)&&d(a.technology)&&(a.title=`[${a.technology}]`,delete a.technology),a}const{findConnection:dn,findConnectionsBetween:U,findConnectionsWithin:fn}=xt;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(N.isWildcard(e))return()=>!0;if(N.isElementTagExpr(e)||N.isElementKindExpr(e))throw Error(`element kind and tag expressions are not supported in deployment view rules`);if(N.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(N.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}}w(e)}function hn(e){return ye(e.$instance)??ye(e.element.$element)}function gn(e){let t=e.id,n=e.onlyOneInstance();return I({id:t,deploymentRef:t,title:e.title,kind:e.kind,technology:e.technology??void 0,links:p(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:ye(e.$node)??void 0,tags:[...e.tags],style:h(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 I({id:e.id,kind:`instance`,title:e.title,description:hn(e)??void 0,technology:e.technology??void 0,tags:[...e.tags],links:p(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)}const yn=(e,t,n)=>xe(`model:${e}:${t}:${n}`);function bn(e){let t=new Set;for(let n=0;n<e.length;n++){if(t.has(n))continue;let r=e[n];for(let i=n+1;i<e.length;i++){if(t.has(i))continue;let n=e[i];if(r.source===n.target&&r.target===n.source&&r.label===n.label){r.dir=`both`;let e=r.head??n.head;e&&(r.head||=e,r.tail||=e),n.color&&(r.color||=n.color),n.line&&(r.line||=n.line),t.add(i);break}}}return t.size>0?e.filter((e,n)=>!t.has(n)):e}function xn(e,t){let n=[],r=[];for(let i of e){let e=[...i.relations.model,...i.relations.deployment];B(p(e,1),`Edge must have at least one relation`);let a=i.source.$model.$styles.defaults,o=i.source.id,s=i.target.id;if(t&&e.length>1){let[c,l]=b(e,he(e=>t(e,i)));if(c.length>0){for(let e of c){let{title:t,color:r=a.relationship.color,line:c=a.relationship.line,head:l=a.relationship.arrow,...u}=un([e.$relationship],e.$relationship);n.push({id:yn(o,s,e.id),parent:i.boundary?.id??null,source:o,target:s,label:t??null,relations:[e.id],color:r,line:c,head:l,...u})}if(l.length>0){let e=C(v(l,e=>e.source.id===o&&e.target.id===s)),{title:t,color:n=a.relationship.color,line:c=a.relationship.line,head:u=a.relationship.arrow,...d}=un(l.map(e=>e.$relationship),e?.$relationship);r.push({id:i.id,parent:i.boundary?.id??null,source:o,target:s,label:t??null,relations:l.map(e=>e.id),color:n,line:c,head:u,...d})}continue}}let{title:c,color:l=a.relationship.color,line:u=a.relationship.line,head:d=a.relationship.arrow,...f}=un(e.map(e=>e.$relationship)),m=I({id:i.id,parent:i.boundary?.id??null,source:o,target:s,label:c??null,relations:e.map(e=>e.id),color:l,line:u,head:d,...f});r.push(m)}return[...n,...bn(r)]}function Sn(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,c(t.tags)&&(t.tags=[...r.tags]),(!t.links||c(t.links))&&p(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 Cn(e,t){for(let n of e)!Me(n)||n.targets.length===0||Jt(n,S(n.targets.map(mn)),t);return t}function wn(e){let t=new ot.default(()=>[]);for(let n of e)for(let e of n.relations.model)t.get(e).push(n);let n=new ot.default(()=>new Set);for(let[e,a]of t)p(a,2)&&b(a,s(e=>[{group:`$source-${e.source.id}`,conn:e},{group:`$target-${e.target.id}`,conn:e}]),i(oe(`group`)),de(),v(p(2)),r(re(g(oe(`conn`)),ft(`desc`),ee((e,t,n)=>t===0||e.boundary===n[t-1].boundary),r(t=>{n.get(t).add(e)}))));return n}function Tn(e){e=lt(e);let t=wn(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;B(r.isDeploymentNode());let a=D(i,r.internalModelRelationships());for(let e of a)t.get(n).add(e);continue}if(e.isDeploymentNode()&&r.isDeploymentNode()){let i=k(D(n.relations.model,e.internalModelRelationships()),D(n.relations.model,r.internalModelRelationships()));for(let e of i)t.get(n).add(e)}}return b(t.entries(),we(([e,t])=>e.update({model:t,deployment:null})),j())}function En(e){return vt(e,Tn(e))}function Dn(e){return b(e,lt,y((t,n)=>{let{source:r,target:i,relations:a}=n;if(r.isInstance()&&i.isInstance())return t;let o=Tt.empty();if(r.isDeploymentNode()&&i.isDeploymentNode()){let[e]=dn(i,r,`directed`);e&&(o=a.intersect(e.relations))}for(let t of e)pt(t,n)&&(o=o.union(a.intersect(t.relations)));return o.nonEmpty&&t.push(new st(r,i,o)),t},[]))}function On(e){return vt(e,Dn(e))}var kn=class extends Gt{connectWithExisting(e,t=`both`){let n=this._connections.length,r=()=>this._connections.length>n;if(!De(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,En,On);return b(t,r(({source:e,target:t,boundary:n})=>{b(fe([...j(e.ancestors()).reverse(),e],[...j(t.ancestors()).reverse(),t]),ee(([e,t])=>e===t),le(1),r(([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}},An=class e extends Ut{static empty(){return new e({elements:new Set,explicits:new Set,final:new Set,connections:[]})}stageInclude(e){return new kn(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&&_(this.state,t.state)}diff(e){return{added:{elements:j(L(e.elements,this.elements)),explicits:j(L(e.explicits,this.explicits)),final:j(L(e.final,this.final)),connections:j(vt(e.connections,this.connections))},removed:{elements:j(L(this.elements,e.elements)),explicits:j(L(this.explicits,e.explicits)),final:j(L(this.final,e.final)),connections:vt(this.connections,e.connections)}}}toString(){return[`final:`,...[...this.final].map(e=>` `+e.id),`connections:`,...this.connections.map(e=>` `+e.expression)].join(`
|
|
2
|
+
`)}[bt](e,t,n){return this.toString()}};const jn={include:({expr:e,model:t,memory:n,stage:r})=>{let i=O(e.where.condition);return A(Un(`include`,{expr:e.where.expr,model:t,stage:r,memory:n,where:i}))},exclude:({expr:e,model:t,memory:n,stage:r})=>{let i=O(e.where.condition);return A(Un(`exclude`,{expr:e.where.expr,model:t,stage:r,memory:n,where:i}))}},Mn={include:({expr:e,model:t,memory:n,stage:r,where:i})=>{let a=[...n.elements];if(N.isWildcard(e.incoming)){for(let e of a){if(e.allOutgoing.isEmpty)continue;let t=K(U(e,[...Jn(e)],`directed`),i);r.addConnections(t)}return r}B(N.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(N.isElementTagExpr(e.incoming)||N.isElementKindExpr(e.incoming))throw Error(`element kind and tag expressions are not supported in exclude`);if(N.isModelRef(e.incoming))return G(Pn(t,e.incoming),{stage:r,memory:n},i);if(N.isWildcard(e.incoming))return r;let a=Nn(W(t,e.incoming)),o=b(n.connections,v(a),K(i));return r.excludeConnections(o),r}};function Nn(e){return S(e.map(e=>{let t=t=>t===e||z(e,t);return e=>!t(e.source)&&t(e.target)}))}function Pn(e,t){let n=pn(e,t);return new Set(n.flatMap(e=>[...e.allIncoming]))}const Fn={include:({expr:e,model:t,memory:n,stage:r,where:i})=>{let a=[...n.elements];if(N.isWildcard(e.outgoing)){for(let e of a)if(!e.allIncoming.isEmpty)for(let t of Jn(e)){let n=K(dn(t,e,`directed`),i);r.addConnections(n)}return r}B(N.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(N.isElementTagExpr(e.outgoing)||N.isElementKindExpr(e.outgoing))throw Error(`element kind and tag expressions are not supported in exclude`);if(N.isModelRef(e.outgoing))return G(Ln(t,e.outgoing),{stage:r,memory:n},i);if(N.isWildcard(e.outgoing))return r;let a=In(W(t,e.outgoing)),o=b(n.connections,v(a),K(i));return r.excludeConnections(o),r}};function In(e){return S(e.map(e=>{let t=t=>t===e||z(e,t);return e=>t(e.source)&&!t(e.target)}))}function Ln(e,t){let n=pn(e,t);return new Set(n.flatMap(e=>[...e.allOutgoing]))}const Rn={include:({expr:{source:e,target:t,isBidirectional:n=!1},model:r,stage:i,where:a})=>{if(N.isElementTagExpr(e)||N.isElementKindExpr(e)||N.isElementTagExpr(t)||N.isElementKindExpr(t))throw Error(`element kind and tag expressions are not supported in include`);B(!N.isModelRef(e),`Invalid source model ref in direct relation`),B(!N.isModelRef(t),`Invalid target model ref in direct relation`);let o=N.isWildcard(e),c=N.isWildcard(t),l=n?`both`:`directed`,u;switch(!0){case o&&c:u=b(fn(r.instances()),K(a),g(e=>(i.addImplicit(e.boundary),e)));break;case!o&&c:{let t=W(r,e),i=In(t),o=i;if(n){let e=Nn(t);o=t=>i(t)!==e(t)}u=b(t,s(e=>U(e,Jn(e),l)),v(o),K(a));break}case o&&!c:{let e=W(r,t),i=Nn(e),o=i;if(n){let t=In(e);o=e=>t(e)!==i(e)}u=b(e,s(e=>[...Jn(e)].flatMap(t=>dn(t,e,l))),v(o),K(a));break}default:{B(!o,`Inference failed - source should be a deployment ref`),B(!c,`Inference failed - target should be a deployment ref`);let n=W(r,e),i=W(r,t),d=In(n),f=Nn(i);u=b(n,s(e=>U(e,i,l)),v(e=>d(e)&&f(e)),K(a))}}return i.addConnections(u),N.isDeploymentRef(e)&&f(e.selector)&&i.addImplicit(r.element(e.ref.deployment)),N.isDeploymentRef(t)&&f(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 N.isWildcard(e.source)&&N.isWildcard(e.target):return r.excludeConnections(K(n.connections,i)),r;case N.isModelRef(e.source)&&N.isModelRef(e.target):return s=zn({source:e.source,target:e.target,expr:e,model:t}),G(s,{stage:r,memory:n},i);case N.isModelRef(e.source)&&N.isWildcard(e.target):return s=Ln(t,e.source),G(s,{stage:r,memory:n},i);case N.isModelRef(e.source):return s=Ln(t,e.source),G(s,{stage:r,memory:n},i,e=>a(e.target));case N.isModelRef(e.target):return s=Pn(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,v(c),K(i));return l.length===0||r.excludeConnections(l),r}}};function zn({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(..._t(e,a,o));return new Set(s.flatMap(e=>[...e.relations]))}const Bn={include:({expr:e,model:t,memory:n,stage:r,where:i})=>{let a=[...n.elements];if(N.isWildcard(e.inout)){for(let e of a){let t=Gn(U(e,[...Jn(e)],`both`),i);r.addConnections(t)}return r}B(N.isDeploymentRef(e.inout),`Only deployment refs are supported in include`);let o=W(t,e.inout);for(let e of a){let t=Gn(U(e,o,`both`),i);r.addConnections(t)}return r},exclude:({expr:e,model:t,memory:n,stage:r,where:i})=>{if(N.isElementTagExpr(e.inout)||N.isElementKindExpr(e.inout))throw Error(`element kind and tag expressions are not supported in exclude`);if(N.isModelRef(e.inout)){let a=pn(t,e.inout);return a.length===0?r:G(k(new Set,...a.flatMap(e=>[e.allIncoming,e.allOutgoing])),{stage:r,memory:n},i)}if(N.isWildcard(e.inout))return r;let a=W(t,e.inout),o=Nn(a),s=In(a),c=b(n.connections,v(e=>o(e)!==s(e)),K(i));return r.excludeConnections(c),r}},Vn={include:({expr:e,model:t,memory:n,stage:r})=>{let i=O(e.where.condition);return Un(`include`,{expr:e.where.expr,model:t,stage:r,memory:n,where:i})},exclude:({expr:e,model:t,memory:n,stage:r})=>{let i=O(e.where.condition);return Un(`exclude`,{expr:e.where.expr,model:t,stage:r,memory:n,where:i})}},Hn={include:({model:e,stage:t,where:n})=>{let r=[],i;return i=n?b([...e.elements()],q(n)):j(we(e.roots(),e=>(e.onlyOneInstance()||r.push(...e.children()),e))),t.addExplicit(i),r.length>1?(t.addConnections(fn([...i,...r])),t.connectWithExisting(r)):t.addConnections(fn(i)),t.connectWithExisting(i),t},exclude:({stage:e,memory:t,where:n})=>{let r=b([...t.elements],q(n));return e.exclude(r),e}};function Un(e,{expr:t,where:n,...r}){switch(!0){case N.isElementTagExpr(t):case N.isElementKindExpr(t):throw Error(`element kind and tag expressions are not supported in deployment view rules`);case M.isCustom(t):case N.isCustom(t):case N.isModelRef(t):return;case N.isWhere(t):return jn[e]({...r,expr:t,where:n});case M.isWhere(t):return Vn[e]({...r,expr:t,where:n});case N.isDeploymentRef(t):return Yn[e]({...r,expr:t,where:n});case N.isWildcard(t):return Hn[e]({...r,expr:t,where:n});case M.isDirect(t):return Rn[e]({...r,expr:t,where:n});case M.isInOut(t):return Bn[e]({...r,expr:t,where:n});case M.isOutgoing(t):return Fn[e]({...r,expr:t,where:n});case M.isIncoming(t):return Mn[e]({...r,expr:t,where:n});default:w(t)}}function G(e,{stage:t,memory:n},r,i=()=>!0){if(e.size===0)return t;let a=b(n.connections,v(e=>i(e)),v(t=>He(t.relations.model,e)),g(t=>t.update({deployment:null,model:D(t.relations.model,e)})),K(r),v(e=>e.nonEmpty()));return a.length===0?t:t.excludeConnections(a)}function Wn(e,t){return K(e,t).nonEmpty()}function K(...t){if(t.length===1)return e=>K(e,t[0]);let[n,r]=t;return r===null?n:e(n)?n.map(e=>K(e,r)).filter(e=>e.nonEmpty()):n.update({model:new Set([...n.relations.model.values()].filter(e=>r(qn(n)(e)))),deployment:new Set([...n.relations.deployment.values()].filter(e=>r(qn(n)(e))))})}function q(...t){if(t.length===1){let e=t[0];return e==null?e=>e:t=>t.filter(t=>e(Kn(t,t)))}let[n,r]=t;return e(n)?r==null?n:n.filter(e=>r(Kn(e,e))):r?.(Kn(n,n))??!0}function Gn(e,t){return t?b(e,v(e=>Wn(e,t))):e}function Kn(e,t){if(Ct(e)){let n=St(t)&&Dt(t)?t:null;return{kind:e.kind,tags:[...e.tags,...n?.tags??[]],metadata:n?.metadata??e.metadata}}if(ht(e))return te(e.element,[`tags`,`kind`,`metadata`]);if(Dt(e))return{kind:e.element.kind,tags:[...e.tags,...e.element.tags],metadata:e.metadata};if(Et(e))return te(e,[`tags`,`kind`,`metadata`]);w(e)}function qn(e){return t=>({tags:t.tags,kind:t.kind,metadata:t.metadata,source:Kn(t.source,e.source),target:Kn(t.target,e.target)})}function Jn(e){let t=new Set;for(let n of e.descendingSiblings())t.add(n);return t}const Yn={include:e=>{let{expr:t,where:n}=e,r=e.model.element(t.ref.deployment);if(Dt(r))return q(r,n)&&(e.stage.addExplicit(r),e.stage.connectWithExisting(r)),e.stage;switch(!0){case t.selector===`expanded`:Zn(r,e);break;case t.selector===`children`:Xn(r,e);break;case t.selector===`descendants`:Qn(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],v(i),q(r));return t.exclude(a),t}};function Xn(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 Zn(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 Qn(e,{stage:t,where:n}){let i=e=>{let r=[];for(let t of e.children())t.isDeploymentNode()&&r.push(...i(t)),q(t,n)&&r.push(t);return t.connectWithExisting(r,`in`),t.addConnections(fn(r)),t.addImplicit(r),r},a=i(e);if(a.length===0)return;t.connectWithExisting(a,`out`);let o=$n(t);b(a,v(e=>o.has(e)),r(e=>t.addExplicit(e)))}function $n(e){return b(e.mergedConnections(),En,On,y((e,t)=>(e.add(t.source),e.add(t.target),e),new Set))}var er=class e{memory;includeAncestors;static for(t,n){return new e(t,n)}constructor(e,t){this.memory=e,this.includeAncestors=t}step1CleanConnections(e){if(e.connections.length<2)return e;let t=b(e.connections,En,On),n=vt(e.connections,t);if(n.length===0)return e;let r=e.stageExclude({});return r.excludeConnections(n,!0),r.commit()}step2ProcessImplicits(e){let t=k(this.memory.elements,e.elements),n=k(e.final,this.memory.explicits),i=new ot.default(()=>new Set);for(let t of e.connections)if(t.boundary)for(let e of t.relations.model)i.get(e).add(t.boundary);for(let[e,r]of i)if(!(r.size<2))for(let e of r)t.delete(e)&&n.add(e);let a=new Set(n),o=e=>{for(let t of a)if(e===t||z(e,t))return!0;return!1};return b(L(t,a),F(e=>e.isDeploymentNode()),j(),Be,r(e=>{let t=[...e.children()].filter(o).length;if(t>=2){n.add(e);return}t===1&&Oe(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=C([...n.root]);a&&!e.explicits.has(a)&&r.exclude(a);for(let t of e.final){let e=C(n.children(t));e&&!n.hasInOut(e)&&i(t)&&r.exclude(t)}return r.isDirty()?r.commit():e}step4AddAncestor(e){let t=new Set;for(let n of e.final)for(let e of n.ancestors())t.add(e);if(t.size>0){let n=k(e.final,t);return e.update({final:n})}return e}commit(){let e=this.step1CleanConnections(this.memory),t=this.step2ProcessImplicits(e),n=this.step3ProcessBoundaries(t);return this.includeAncestors===!0?this.step4AddAncestor(n):n}};const tr=Lt(mn);function nr(e,t){let n=[],r=[];for(let e of t)if(rt(e)&&`include`in e)for(let t of e.include)M.isCustom(t)&&(t.customRelation.multiple===!0?n.push(t):t.customRelation.multiple===!1&&r.push(t));let i=new Set,a=e.specification.relationships;for(let e of Object.keys(a)){let t=a[e];(t?.style??t)?.multiple&&i.add(e)}if(n.length===0&&r.length===0&&i.size===0)return;let o=n.map(e=>({pred:tr(e.customRelation.expr)})),s=r.map(e=>({pred:tr(e.customRelation.expr)}));return(e,t)=>{let n=e=>{if(e&&typeof e==`object`){if(`tags`in e&&`kind`in e&&`metadata`in e)return e;if(e.instance&&e.element)return{id:e.id,tags:e.instance.tags,kind:e.element.kind,metadata:e.instance.metadata}}return e??{}},r=n(t?.source??e.source),a=n(t?.target??e.target);if(s.length>0){for(let{pred:t}of s)if(t({source:r,target:a,kind:e.kind,tags:e.tags,metadata:e.metadata}))return!1}if(i.size>0){let t=e.kind;if(t&&i.has(t))return!0}if(o.length>0){for(let{pred:t}of o)if(t({source:r,target:a,kind:e.kind,tags:e.tags,metadata:e.metadata}))return!0}return!1}}function rr(e,t){let n=An.empty(),r=!1;for(let i of t){if(rt(i)){let t=`include`in i?`include`:`exclude`,r=i.include??i.exclude;for(let i of r){let r=t===`include`?n.stageInclude(i):n.stageExclude(i);r=Un(t,{expr:i,model:e,stage:r,memory:n,where:null})??r,n=r.commit()}}`includeAncestors`in i&&(r=i.includeAncestors)}return er.for(n,r).commit()}function ir(e,{docUri:t,rules:n,...r}){let i=rr(e.deployment,n),a=Sn(e,i),s=nr(e,n),c=xn(i.connections,s);It(a,c);let l=Vt({nodes:a,edges:c}),u=Cn(n,l.nodes),d=o(n,Ue),f=jt(u);return Ht({...r,[it]:`computed`,[Ne]:`deployment`,autoLayout:{direction:d?.direction??`TB`,...d?.nodeSep&&{nodeSep:d.nodeSep},...d?.rankSep&&{rankSep:d.rankSep}},edges:l.edges,nodes:g(u,e=>(e.icon===`none`&&delete e.icon,e)),...f.length>0&&{notation:{nodes:f}}})}function ar(e){return t=>Ge(t)?t.groupRules.flatMap(ar(e)):rt(t)&&`include`in t?t.include.filter(e):[]}function or(e,t){let n=e.flatMap(ar(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:o,iconColor:s,iconSize:c,iconPosition:u,padding:d,size:f,textSize:p,...m}=_e(t,l),h=I({border:n,opacity:i,multiple:o,iconColor:s,iconSize:c,iconPosition:u,padding:d,size:f,textSize:p}),g=!a(h),_=!a(m),v=H(e);r.forEach((e,t)=>{Xe(e)||!v(e)||(_&&(e={...e,...m,isCustomized:!0}),g&&(e={...e,isCustomized:!0,style:{...e.style,...h}}),r[t]=e)})}return r}function sr(e,t){return e.reduce((e,n)=>{if(tt(n)){let r=t.predicates[n.predicateId];return l(r)?e:e.concat(r)}if(Pe(n)){let r=t.styles[n.styleId];return l(r)?e:e.concat(r)}return e.push(n),e},[])}function cr(e,t){return e.reduce((e,n)=>{if(tt(n)){let r=t.dynamicPredicates[n.predicateId];return l(r)?e:e.concat(r)}if(Pe(n)){let r=t.styles[n.styleId];return l(r)?e:e.concat(r)}return e.push(n),e},[])}function lr(e,t){let n=new Set;for(let r of t)if(rt(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 ur=e=>{if(qe(e)){let t=[],n=[];for(let r of e.__parallel)if($e(r)){let[e,...i]=r.__series;t.push(e),n.push(...i)}else t.push(r);return[...t,...n]}return $e(e)?[...e.__series]:e};function dr(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 s(t,ur)){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 fr(e,t,n){let r=gt(e,t,`directed`).flatMap(e=>[...e.relations]).sort(Se);if(!et(r))return{};if(r.length===1){let e=r[0];return I({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,s(e=>e.tags),ie()),a=p(i,1)?i:void 0,o=g(r,e=>e.id),c=ue(r).$relationship.navigateTo;c===n&&(c=void 0),c||=b(r,s(e=>e.$relationship.navigateTo&&e.$relationship.navigateTo!==n?e.$relationship.navigateTo:[]),ie(),C());let l=b(r,y((e,{title:t,technology:n,$relationship:r})=>(d(t)&&e.title.add(t),d(r.color)&&e.color.add(r.color),d(r.line)&&e.line.add(r.line),d(r.kind)&&e.kind.add(r.kind),d(n)&&e.technology.add(n),d(r.description)&&!e.description.some(_(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 I({tags:a??void 0,relations:o,navigateTo:c,kind:C([...l.kind]),title:C([...l.title]),color:C([...l.color]),line:C([...l.line]),technology:C([...l.technology]),description:C(l.description)})}var pr=class{model;view;steps=[];constructor(e,t){this.model=e,this.view=t}compute(){let{docUri:e,rules:t,steps:n,...r}=this.view,i=cr(t,this.model.globals),a=lr(this.model,i),s=dr(this.model,n),c=b(k(D(a,s),s,a),j(),ke),l=c.reduce((e,t,n,r)=>{for(let i=n+1;i<r.length;i++){let n=r[i];if(z(t,n)){e.push(t);break}}return e},[]),u=(e,t,n)=>{if($e(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:f,notation:p,...m}=e,h=this.model.element(i),g=c.indexOf(h);B(g>=0,`Source ${i} not found`);let _=this.model.element(a),v=c.indexOf(_);B(v>=0,`Target ${a} not found`),(l.includes(h)||l.includes(_))&&console.error(`Step ${h.id} -> ${_.id} because it involves a compound`);let{title:ee,relations:te,navigateTo:ne,...y}=fr(h,_,this.view.id),b=d(f)&&f!==this.view.id?f:ne,x=e.kind?this.model.specification.relationships[e.kind]:void 0;return this.steps.push(I({...y,...!e.technology&&!y.technology&&x?.technology&&{technology:x.technology},...!e.color&&!y.color&&x?.color&&{color:x.color},...!e.line&&!y.line&&x?.line&&{line:x.line},...!e.head&&x?.head&&{head:x.head},...!e.tail&&x?.tail&&{tail:x.tail},...m,id:r,source:h,target:_,navigateTo:b,title:o??ee,relations:te??[],isBackward:g>v})),t+1},f=1;for(let e of n){if(qe(e)){let t=1;for(let n of e.__parallel)t=u(n,t,f);f++;continue}f=u(e,f)}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:je(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 Ve(u.source)){if(e===u.parent)break;p.get(e)?.outEdges.push(u.id)}for(let e of Ve(u.target)){if(e===u.parent)break;p.get(e)?.inEdges.push(u.id)}return u}),_=or(i,Yt(i,c.map(e=>A(p.get(e.id))))),v=o(i,Ue),ee=jt(_);return Ht({...r,[Ne]:`dynamic`,[it]:`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,...ee.length>0&&{notation:{nodes:ee}}})}};function mr(e,t){return new pr(e,t).compute()}function hr(e,t,n){let r=e.flatMap(ar(R.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,multiple:s,...c}}of r){let r=a?{description:Qe(a)}:{},s=o?{notes:Qe(o)}:{},u=_e(c,l),d=Rt(e);i.forEach((e,a)=>{let o,c;for(let n of t)if(n.id===e.source&&(o=n),n.id===e.target&&(c=n),o&&c)break;!o||!c||d({source:o,target:c,...te(e,[`kind`,`tags`])})&&(i[a]={...e,...u,...r,...s,label:n??e.label,isCustomized:!0})})}return i}function gr(e){return b([...e],lt,y((e,t,n,r)=>{let i=At(r,t),a=k(...i.map(oe(`relations`))),o=D(t.relations,a);if(i.length>0&&(o=k(o,t.directRelations)),Ot(r,t.reversed())&&(o=k(o,t.directRelations)),o.size<t.relations.size){let e=r.some(ct(t.source)),n=r.some(ct(t.target));e&&(o=k(o,T(F(t.relations,ut(t.source))))),n&&(o=k(o,T(F(t.relations,kt(t.target)))))}return o.size>0&&e.push(t.update(o)),e},[]))}var _r=class e{memory;static for(t){return new e(t)}constructor(e){this.memory=e}step1CleanConnections(e){if(e.connections.length<2)return e;let t=gr(e.connections);if(t.length===0)return e;let n=e.stageExclude({});return n.excludeConnections(t,!0),n.commit()}step2ProcessImplicits(e){let t=k(this.memory.elements,e.elements),n=k(e.final,this.memory.explicits),i=new Set(n),a=e=>{for(let t of i)if(e===t||z(e,t))return!0;return!1};return b(L(t,i),j(),Be,r(e=>{let t=[...e.children()].filter(a).length;if(t>=2){n.add(e);return}t===1&&Oe(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=C([...n.root]);a&&!e.explicits.has(a)&&r.exclude(a);for(let t of e.final){let e=C(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:vr,findConnectionsBetween:J,findConnectionsWithin:Y}=wt;function X(e,t){switch(!0){case E.isElementKindExpr(t):return[...F(e.elements(),e=>t.isEqual===(e.kind===t.elementKind))];case E.isElementTagExpr(t):return[...F(e.elements(),e=>t.isEqual===e.tags.includes(t.elementTag))];case t.selector===`expanded`:{let n=e.element(P.flatten(t.ref));return[n,...n.children()]}case t.selector===`children`:case t.selector===`descendants`:{let n=e.element(P.flatten(t.ref)),r=t.selector===`children`?j(n.children()):j(n.descendants());return r&&r.length>0?r:[n]}case E.isModelRef(t):return[e.element(P.flatten(t.ref))];default:w(t)}}function yr(e,t){if(t.isEmpty()||e.length===0)return e;let n=S(e.map(e=>Fe(e))),r=j(F(t.elements,t=>!e.includes(t)&&n(t)));return[...e,...r]}function br(e,{memory:t,model:n}){let r=X(n,e);return E.isModelRef(e)?e.selector===`descendants`?r:yr(r,t):r}const xr={include:({expr:e,model:t,stage:n,where:r})=>{let i=t.element(P.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}},Sr={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}},Cr={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}},wr=()=>!0,Tr=e=>e,Er=(e,t,n)=>xe(`model:${e}:${t}:${n}`);function Dr(e,t){return e.flatMap(e=>{let n=[...e.relations];B(p(n,1),`Edge must have at least one relation`);let r=e.source.$model.$styles.defaults,i=e.source.id,a=e.target.id,o=v(n,e=>e.source.id===i&&e.target.id===a);if(t&&n.length>1){let[o,s]=b(n,he(n=>t(n,e)));if(o.length>0){let t=o.map(t=>{let{title:n,color:o=r.relationship.color,line:s=r.relationship.line,head:c=r.relationship.arrow,...l}=un([t.$relationship],t.$relationship);return{id:Er(i,a,t.id),parent:e.boundary?.id??null,source:i,target:a,label:n??null,relations:[t.id],color:o,line:s,head:c,...l}});if(s.length>0){let{title:n,color:o=r.relationship.color,line:c=r.relationship.line,head:l=r.relationship.arrow,...u}=un(s.map(e=>e.$relationship),C(v(s,e=>e.source.id===i&&e.target.id===a))?.$relationship);t.push({id:e.id,parent:e.boundary?.id??null,source:i,target:a,label:n??null,relations:s.map(e=>e.id),color:o,line:c,head:l,...u})}return t}}let{title:s,color:c=r.relationship.color,line:l=r.relationship.line,head:u=r.relationship.arrow,...d}=un(n.map(e=>e.$relationship),C(o)?.$relationship);return[I({id:e.id,parent:e.boundary?.id??null,source:i,target:a,label:s??null,relations:n.map(e=>e.id),color:c,line:l,head:u,...d})]})}function Or(e,t){return cn(e.$styles,[...t.final].map(sn),t.groups)}const Z=E.isWildcard,kr=(e,t)=>e.isAncestorOf(t)||e.isDescendantOf(t),Ar={include:({expr:{source:e,target:t,isBidirectional:n=!1},memory:r,model:i,stage:a,where:o,filterWhere:c})=>{let l=Z(e),u=Z(t),d=[];switch(!0){case l&&u&&r.isEmpty()&&o!==wr:{let e=b(i.relationships(),F(o),j(),g(e=>new yt(e.source,e.target,new Set([e]))));return a.addConnections(e),a}case l&&u&&!r.isEmpty()&&o!==wr:d.push(...Y(r.elements));break;case l&&u:d.push(...Y(i.roots()));break;case!l&&u&&o!==wr:{let t=b(X(i,e),s(e=>b(e,se(pe(n===!0),{onTrue:e=>k(e.allIncoming,e.allOutgoing),onFalse:e=>e.allOutgoing}),F(o),be(),j(),he(t=>t.source===e),([t,n])=>ce(b(t,v(t=>!kr(e,t.target)),g(t=>new yt(e,t.target,new Set([t])))),b(n,v(t=>!kr(e,t.source)),g(t=>new yt(t.source,e,new Set([t]))))))));return a.addConnections(t),a}case!l&&u:{let[t,a]=jr(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!==wr:{let e=b(X(i,t),s(e=>b(e,se(pe(n===!0),{onTrue:e=>k(e.allIncoming,e.allOutgoing),onFalse:e=>e.allIncoming}),F(o),j(),he(t=>t.target===e),([t,n])=>ce(b(n,v(t=>!kr(e,t.target)),g(t=>new yt(e,t.target,new Set([t])))),b(t,v(t=>!kr(e,t.source)),g(t=>new yt(t.source,e,new Set([t]))))))));return a.addConnections(e),a}case l&&!u:{let[e,a]=jr(t,{memory:r,model:i}),o=n?`both`:`directed`;for(let t of a)d.push(...J(t,e,o));break}default:{B(!Z(e),`Inference failed - source must be not a wildcard`),B(!Z(t),`Inference failed - target must be not a wildcard`);let a=br(e,{memory:r,model:i}),o=br(t,{memory:r,model:i}),s=n?`both`:`directed`;for(let e of a)d.push(...J(e,o,s))}}return a.addConnections(c(d)),a},exclude:({expr:{source:e,target:t,isBidirectional:n},model:r,memory:i,stage:a,where:o})=>{let c=Z(e),l=Z(t),u;switch(!0){case c&&l:u=b(i.connections,s(re(oe(`relations`),F(o),j())),T());break;case!c&&l:u=b(X(r,e),s(e=>b(e,se(pe(n===!0),{onTrue:e=>k(e.allIncoming,e.allOutgoing),onFalse:e=>e.allOutgoing}),F(o),j())),T());break;case c&&!l:u=b(X(r,t),s(e=>b(e,se(pe(n===!0),{onTrue:e=>k(e.allIncoming,e.allOutgoing),onFalse:e=>e.allIncoming}),F(o),j())),T());break;default:{B(!Z(e),`Inference failed - source must be not a wildcard`),B(!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)Le(e,t)||(s=k(s,D(e.allOutgoing,t.allIncoming),n?D(t.allOutgoing,e.allIncoming):new Set));u=T(F(s,o))}}return a.excludeRelations(u),a}};function jr(e,{memory:t,model:n}){let r=X(n,e);if(!p(r,1))return[[],[]];if(E.isModelRef(e)){let i=j(n.element(P.flatten(e.ref)).ascendingSiblings());return[yr(r,t),yr(i,t)]}return[r,b(r,g(e=>e.ascendingSiblings()),Te(),be(),j(),e=>yr(e,t))]}const Mr={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(...vr(e,t,`directed`))}else{let e=br(o,{memory:r,model:n}),t=[...r.elements];t.length===0&&t.push(...ie(e.flatMap(e=>[...e.ascendingSiblings()])));let i=Nr(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 Nr(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=P.flatten(t.ref);return S([...e.children(n)].map(e=>V.isIncoming(e.id)))}case E.isModelRef(t)&&t.selector===`descendants`:{let n=P.flatten(t.ref);return S([V.isInside(n),...[...e.children(n)].map(e=>V.isIncoming(e.id))])}case E.isModelRef(t)&&t.selector===`expanded`:{let e=P.flatten(t.ref);return S([V.isIncoming(e),V.isInside(e)])}case E.isModelRef(t):{let e=P.flatten(t.ref);return V.isIncoming(e)}default:w(t)}}const Pr={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=br(e,{memory:r,model:n}),i=[...r.elements];i.length===0&&(i=ie(t.flatMap(e=>j(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(T(a.filter(i))),r}},Fr={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=br(o,{memory:r,model:n}),t=[...r.elements];t.length===0&&t.push(...ie(e.flatMap(e=>[...e.ascendingSiblings()])));let i=Ir(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(T(a.filter(i))),r}};function Ir(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=P.flatten(t.ref);return S([...e.children(n)].map(e=>V.isOutgoing(e.id)))}case E.isModelRef(t)&&t.selector===`descendants`:{let n=P.flatten(t.ref);return S([V.isInside(n),...[...e.children(n)].map(e=>V.isOutgoing(e.id))])}case E.isModelRef(t)&&t.selector===`expanded`:{let e=P.flatten(t.ref);return S([V.isOutgoing(e),V.isInside(e)])}case E.isModelRef(t):{let e=P.flatten(t.ref);return V.isOutgoing(e)}default:w(t)}}const Lr={include:({scope:e,model:t,stage:n,memory:r,where:i})=>{if(!e){let e=i===wr?[...t.roots()]:j(F(t.elements(),i));if(e.length===0)return;let[r,a]=he(e,e=>!e.imported);return n.addExplicit(r),n.addImplicit(a),n.addConnections(Y(e)),n.connectWithExisting(e),n}let a=j(F(e.children(),i)),o=a.length>0;if(!o){let t=J(e,e.siblings()),r=e.parent;t.length===0&&r&&n.addExplicit(r),a.push(e)}n.addExplicit(e);let s=T([...r.elements,...e.descendingSiblings()]);for(let e of s)n.addConnections(J(e,a,`directed`));o&&(n.addConnections(Y(a)),n.addExplicit(a));for(let e of a)n.addConnections(J(e,s,`directed`));return n},exclude:({scope:e,memory:t,stage:n,where:r})=>r===wr?e?(n.exclude([e,...e.descendants()]),n):rn.empty(t.scope).stageExclude(n.expression):(n.exclude(v([...t.elements],r)),n)};function Rr(e,t,n){switch(!0){case E.isCustom(e):return t===`include`?Rr(e.custom.expr,t,n):n.stage;case E.isWhere(e):{let r=O(e.where.condition),i=e=>v(e,r);return Rr(e.where.expr,t,{...n,where:r,filterWhere:i})}case E.isModelRef(e)&&e.selector===`expanded`:return xr[t]({...n,expr:e})??n.stage;case E.isWildcard(e):return Lr[t]({...n,expr:e})??n.stage;case E.isElementKindExpr(e):case E.isElementTagExpr(e):return Sr[t]({...n,expr:e})??n.stage;case E.isModelRef(e):return Cr[t]({...n,expr:e})??n.stage;default:w(e)}}function zr(e,t,n){switch(!0){case R.isCustom(e):return t===`include`?zr(e.customRelation.expr,t,n):n.stage;case R.isWhere(e):{let r=O(e.where.condition),i=e=>new Set(v([...e],r)),a=e=>b(e,g(e=>new yt(e.source,e.target,i(e.relations))),v(e=>e.nonEmpty()));return zr(e.where.expr,t,{...n,where:r,filterWhere:a})}case R.isInOut(e):return Pr[t]({...n,expr:e})??n.stage;case R.isDirect(e):return Ar[t]({...n,expr:e})??n.stage;case R.isOutgoing(e):return Fr[t]({...n,expr:e})??n.stage;case R.isIncoming(e):return Mr[t]({...n,expr:e})??n.stage;default:w(e)}}function Br(e,t,n){let r={model:e,scope:t.scope,where:wr,filterWhere:Tr};for(let i of n){if(Ge(i)){t=Br(e,an.enter(t,i),i.groupRules),B(t instanceof an,`processPredicates must return ActiveGroupMemory`),t=t.leave();continue}if(rt(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 Ce.isFqnExpr(i):n=Rr(i,e,{...r,stage:n,memory:t})??n;break;case Ce.isRelationExpr(i):n=zr(i,e,{...r,stage:n,memory:t})??n;break;default:w(i)}t=n.commit()}}}return t}function Vr(e,t,n){return t=Br(e,t,n),_r.for(t).commit()}function Hr(e,t){let n=t.flatMap(ar(R.isCustom)).filter(e=>e.customRelation.multiple===!0),r=t.flatMap(ar(R.isCustom)).filter(e=>e.customRelation.multiple===!1),i=new Set,a=e.specification.relationships;for(let e of Object.keys(a)){let t=a[e];(t?.style??t)?.multiple&&i.add(e)}if(n.length===0&&r.length===0&&i.size===0)return;let o=n.map(e=>({pred:Rt(e.customRelation.expr)})),s=r.map(e=>({pred:Rt(e.customRelation.expr)}));return(e,t)=>{let n=t?.source??e.source,r=t?.target??e.target;if(s.length>0){for(let{pred:t}of s)if(t({source:n,target:r,kind:e.kind,tags:e.tags,metadata:e.metadata}))return!1}if(i.size>0){let t=e.kind;if(t&&i.has(t))return!0}if(o.length>0){for(let{pred:t}of o)if(t({source:n,target:r,kind:e.kind,tags:e.tags,metadata:e.metadata}))return!0}return!1}}function Ur(e,{docUri:t,rules:n,...r}){let i=sr(n,e.globals),a=r.viewOf?e.asComputed.element(r.viewOf):null,s=Vr(e,rn.empty(a),i);s.isEmpty()&&a&&(s=s.update({final:new Set([a])})),s=Gr(s);let c=Or(e,s),l=Hr(e,i),u=Dr(s.connections,l);It(c,u);let d=Vt({nodes:c,edges:u}),f=or(i,Yt(i,d.nodes)),p=o(i,Ue),m=jt(f),h=Wr(i,f);return Ht({...r,_stage:`computed`,autoLayout:{direction:p?.direction??`TB`,...p?.nodeSep&&{nodeSep:p.nodeSep},...p?.rankSep&&{rankSep:p.rankSep}},edges:hr(i,f,d.edges),nodes:g(f,e=>(e.icon===`none`&&delete e.icon,e)),...m.length>0&&{notation:{nodes:m}},...h.length>0&&{ranks:h}})}function Wr(e,t){let n=[];for(let r of e){if(!Ze(r)||r.targets.length===0)continue;let e=b(t,v(S(r.targets.map(H))),g(e=>e.id));p(e,1)&&n.push({type:r.rank,nodes:e})}return n}function Gr(e){if(e.groups.length===0)return e;let t=new ot.default(()=>new Set),n=new Map,i=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(ke([...e.explicitFirstSeenIn.keys()]),r(r=>{if(!i(r)){let i=A(e.explicitFirstSeenIn.get(r));n.set(r,i),t.get(i).add(r)}})),b(ke([...e.lastSeenIn.keys()]),v(e=>!n.has(e)),r(r=>{if(i(r)||a(r))return;let o=A(e.lastSeenIn.get(r));n.set(r,o),t.get(o).add(r)})),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 Kr(e,t){switch(!0){case Re(e):return Ur(t,e);case Ye(e):return ir(t,e);case ze(e):return mr(t,e);default:w(e)}}function qr(e,t){try{return{isSuccess:!0,view:Kr(e,t)}}catch(e){return{isSuccess:!1,error:e instanceof Error?e:Error(`Unknown error: ${e}`),view:void 0}}}function Jr(e){let n=dt.create(e),{views:r,_stage:i,...a}=e,o=t(r,e=>Kr(e,n));return{[it]:`computed`,...a,views:o}}function Yr(e){return dt.create(Jr(e))}const Q=e=>e;function $(e){if(!ae(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{Kr as a,It as c,qr as i,Yr as n,Ur as o,Jr as r,Vt as s,$ as t};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { $r as RelationId$1, Ai as ProjectId, At as ElementStyle, Br as DeploymentKind, C as LayoutedView, Ct as DeploymentNode, Ei as IconUrl, Fr as AnyLayouted, Gr as LooseDeploymentId, Hr as ElementId, Ir as AnyParsed, Jr as LooseTag, Kn as WhereOperator, Kr as LooseElementId, Lr as Aux, Mt as Relationship, Nr as Any, Oi as NodeId, Pi as StepEdgeId, Pr as AnyComputed, Qr as ProjectId$1, Ri as ViewId$1, Rr as DeploymentFqn, S as ComputedView, Tt as DeploymentRelationship, Ur as ElementKind, Ut as DynamicViewDisplayVariant, Wr as Fqn, Xi as _stage, Xr as Metadata, Yr as LooseViewId, Zi as _type, Zr as MetadataKey, _ as ComputedLikeC4ModelData, _t as Specification, ai as Tags, b as ParsedLikeC4ModelData, bi as EdgeId, bt as DeployedInstance, ci as UnknownLayouted, cr as ElementShape, d as AuxFromDump, ei as RelationKind, f as LikeC4ModelDump, hi as toComputed, hr as RelationshipArrowType, ia as Link, ii as Tag, ji as RelationId, k as ViewWithType, kt as Element, l as RichTextOrEmpty, li as UnknownParsed, lt as LikeC4Project, na as IteratorLike, ni as Stage, oa as NonEmptyArray, oi as Unknown, ri as StrictViewId, rr as Color, si as UnknownComputed, st as ComputedNodeStyle, tr as FqnRef, tt as ViewManualLayoutSnapshot, ui as ViewId, v as LayoutedLikeC4ModelData, vr as RelationshipLineType, wi as GroupElementKind, xt as DeploymentElement, zr as DeploymentId, zt as ModelGlobals } from "./index.mjs";
|
|
2
2
|
import { i as BBox } from "./index2.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { o as LikeC4Styles } from "./index3.mjs";
|
|
4
4
|
import { o as DefaultMap } from "./libs/mnemonist.mjs";
|
|
5
5
|
import "./mnemonist.mjs";
|
|
6
6
|
import { IsAny, SetRequired, Tagged } from "type-fest";
|
|
@@ -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{
|
|
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{R as c,Tn as l,vn as u}from"./types.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};
|
package/dist/_chunks/index.d.mts
CHANGED
|
@@ -1627,6 +1627,11 @@ interface DiagramEdge<A extends Any = Any> extends ComputedEdge<A> {
|
|
|
1627
1627
|
* (Absolute coordinates)
|
|
1628
1628
|
*/
|
|
1629
1629
|
labelBBox?: BBox | null;
|
|
1630
|
+
/**
|
|
1631
|
+
* Whether the label position was manually set by the user.
|
|
1632
|
+
* When set, the label keeps its position and is not auto-centered on the edge.
|
|
1633
|
+
*/
|
|
1634
|
+
isLabelCustomized?: boolean;
|
|
1630
1635
|
/**
|
|
1631
1636
|
* List of reasons causing edge drift
|
|
1632
1637
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Cr as ThemeColor, Li as Tag, Or as DefaultTagColors, Sr as TextSize, _r as RelationshipColorValues, aa as NTuple, dr as IconSize, fr as LikeC4StyleDefaults, ft as LikeC4ProjectStylesConfig, ir as ColorLiteral, mr as LikeC4Theme, nr as BorderStyle, or as CustomColorDefinitions, pr as LikeC4StylesConfig, pt as LikeC4ProjectStylesCustomStylesheets, rr as Color, sr as ElementColorValues, st as ComputedNodeStyle, ur as IconPosition, vt as TagSpecification, wr as ThemeColorValues, xr as SpacingSize, yr as ShapeSize } from "./index.mjs";
|
|
1
|
+
import { Cr as ThemeColor, Li as Tag, Or as DefaultTagColors, Sr as TextSize, _r as RelationshipColorValues, aa as NTuple, dr as IconSize, fr as LikeC4StyleDefaults, ft as LikeC4ProjectStylesConfig, ir as ColorLiteral, lr as HexColor, mr as LikeC4Theme, nr as BorderStyle, or as CustomColorDefinitions, pr as LikeC4StylesConfig, pt as LikeC4ProjectStylesCustomStylesheets, rr as Color, sr as ElementColorValues, st as ComputedNodeStyle, ur as IconPosition, vt as TagSpecification, wr as ThemeColorValues, xr as SpacingSize, yr as ShapeSize } from "./index.mjs";
|
|
2
2
|
import { LiteralUnion } from "type-fest";
|
|
3
|
+
import chroma from "chroma-js";
|
|
3
4
|
|
|
4
5
|
//#region src/styles/assignTagColors.d.ts
|
|
5
6
|
declare function assignTagColors(tags: {
|
|
@@ -138,7 +139,17 @@ declare class LikeC4Styles {
|
|
|
138
139
|
}
|
|
139
140
|
//#endregion
|
|
140
141
|
//#region src/styles/compute-color-values.d.ts
|
|
142
|
+
/**
|
|
143
|
+
* Returns true when the input is a valid color literal parseable by chroma-js
|
|
144
|
+
* (e.g. `#ff0000`, `rgb(255, 0, 0)`, named CSS colors). Useful as a safety
|
|
145
|
+
* check before calling color-math helpers that throw on malformed input.
|
|
146
|
+
*/
|
|
147
|
+
declare function isValidColor(color: string | chroma.Color): boolean;
|
|
141
148
|
declare function computeColorValues(color: ColorLiteral): ThemeColorValues;
|
|
149
|
+
declare function getContrastedColorsAPCA(refColor: string | chroma.Color): {
|
|
150
|
+
hiContrast: HexColor;
|
|
151
|
+
loContrast: HexColor;
|
|
152
|
+
};
|
|
142
153
|
//#endregion
|
|
143
154
|
//#region src/styles/defaults.d.ts
|
|
144
155
|
declare const styleDefaults: LikeC4StyleDefaults;
|
|
@@ -146,4 +157,4 @@ declare const styleDefaults: LikeC4StyleDefaults;
|
|
|
146
157
|
//#region src/styles/theme.d.ts
|
|
147
158
|
declare const defaultTheme: LikeC4Theme;
|
|
148
159
|
//#endregion
|
|
149
|
-
export {
|
|
160
|
+
export { isValidColor as a, getContrastedColorsAPCA as i, styleDefaults as n, LikeC4Styles as o, computeColorValues as r, assignTagColors as s, defaultTheme as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region ../../node_modules/.pnpm/mnemonist@0.40.
|
|
1
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/default-map.d.ts
|
|
2
2
|
/**
|
|
3
3
|
* Mnemonist DefaultMap Typings
|
|
4
4
|
* =============================
|
|
@@ -22,7 +22,7 @@ declare class DefaultMap<K, V> implements Iterable<[K, V]> {
|
|
|
22
22
|
static autoIncrement(): number;
|
|
23
23
|
}
|
|
24
24
|
//#endregion
|
|
25
|
-
//#region ../../node_modules/.pnpm/mnemonist@0.40.
|
|
25
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/default-weak-map.d.ts
|
|
26
26
|
/**
|
|
27
27
|
* Mnemonist DefaultWeakMap Typings
|
|
28
28
|
* ================================
|
|
@@ -39,7 +39,7 @@ declare class DefaultWeakMap<K extends object, V> {
|
|
|
39
39
|
inspect(): any;
|
|
40
40
|
}
|
|
41
41
|
//#endregion
|
|
42
|
-
//#region ../../node_modules/.pnpm/mnemonist@0.40.
|
|
42
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/linked-list.d.ts
|
|
43
43
|
/**
|
|
44
44
|
* Mnemonist LinkedList Typings
|
|
45
45
|
* =============================
|
|
@@ -68,7 +68,7 @@ declare class LinkedList<T> implements Iterable<T> {
|
|
|
68
68
|
}): LinkedList<I>;
|
|
69
69
|
}
|
|
70
70
|
//#endregion
|
|
71
|
-
//#region ../../node_modules/.pnpm/mnemonist@0.40.
|
|
71
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/multi-map.d.ts
|
|
72
72
|
/**
|
|
73
73
|
* Mnemonist MultiMap Typings
|
|
74
74
|
* ===========================
|
|
@@ -107,7 +107,7 @@ interface MultiMapConstructor {
|
|
|
107
107
|
}
|
|
108
108
|
declare const MultiMap: MultiMapConstructor;
|
|
109
109
|
//#endregion
|
|
110
|
-
//#region ../../node_modules/.pnpm/mnemonist@0.40.
|
|
110
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/queue.d.ts
|
|
111
111
|
/**
|
|
112
112
|
* Mnemonist Queue Typings
|
|
113
113
|
* ========================
|
|
@@ -134,7 +134,7 @@ declare class Queue<T> implements Iterable<T> {
|
|
|
134
134
|
static of<I>(...items: Array<I>): Queue<I>;
|
|
135
135
|
}
|
|
136
136
|
//#endregion
|
|
137
|
-
//#region ../../node_modules/.pnpm/mnemonist@0.40.
|
|
137
|
+
//#region ../../node_modules/.pnpm/mnemonist@0.40.4/node_modules/mnemonist/stack.d.ts
|
|
138
138
|
/**
|
|
139
139
|
* Mnemonist Stack Typings
|
|
140
140
|
* ========================
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function e(e,t,n){let r=n=>e(n,...t);return n===void 0?r:Object.assign(r,{lazy:n,lazyArgs:t})}function t(t,n,r){let i=t.length-n.length;if(i===0)return t(...n);if(i===1)return e(t,n,r);throw Error(`Wrong number of arguments`)}function n(...e){return t(r,e)}const r=(e,t)=>t.every(t=>t(e));function i(...e){return t(a,e)}const a=(e,t)=>t.some(t=>t(e));function o(...e){return t(s,e)}const s=(e,t)=>[...e,...t];function c(e){return()=>e}const l={done:!0,hasNext:!1},u={done:!1,hasNext:!1},d=()=>l,f=e=>({hasNext:!0,next:e,done:!1});function p(e,...t){let n=e,r=t.map(e=>`lazy`in e?h(e):void 0),i=0;for(;i<t.length;){if(r[i]===void 0||!g(n)){let e=t[i];n=e(n),i+=1;continue}let e=[];for(let n=i;n<t.length;n++){let t=r[n];if(t===void 0||(e.push(t),t.isSingle))break}let a=[];for(let t of n)if(m(t,a,e))break;let{isSingle:o}=e.at(-1);n=o?a[0]:a,i+=e.length}return n}function m(e,t,n){if(n.length===0)return t.push(e),!1;let r=e,i=u,a=!1;for(let[e,o]of n.entries()){let{index:s,items:c}=o;if(c.push(r),i=o(r,s,c),o.index+=1,i.hasNext){if(i.hasMany??!1){for(let r of i.next)if(m(r,t,n.slice(e+1)))return!0;return a}r=i.next}if(!i.hasNext)break;i.done&&(a=!0)}return i.hasNext&&t.push(r),a}function h(e){let{lazy:t,lazyArgs:n}=e,r=t(...n);return Object.assign(r,{isSingle:t.single??!1,index:0,items:[]})}function g(e){return typeof e==`string`||typeof e==`object`&&!!e&&Symbol.iterator in e}function ee(e,t){let n=t.length-e.length;if(n===1){let[n,...r]=t;return p(n,{lazy:e,lazyArgs:r})}if(n===0){let n={lazy:e,lazyArgs:t};return Object.assign(e=>p(e,n),n)}throw Error(`Wrong number of arguments`)}function te(...e){return t(ne,e,re)}const ne=(e,t)=>t<0?[...e]:e.slice(t);function re(e){if(e<=0)return f;let t=e;return e=>t>0?(--t,u):{done:!1,hasNext:!0,next:e}}function _(...e){return t(v,e)}const v=(e,t)=>e.length>=t,y={asc:(e,t)=>e>t,desc:(e,t)=>e<t};function b(e,t){let[n,...r]=t;if(!S(n))return e(n,x(...r));let i=x(n,...r);return t=>e(t,i)}function x(e,t,...n){let r=typeof e==`function`?e:e[0],i=typeof e==`function`?`asc`:e[1],{[i]:a}=y,o=t===void 0?void 0:x(t,...n);return(e,t)=>{let n=r(e),i=r(t);return a(n,i)?1:a(i,n)?-1:o?.(e,t)??0}}function S(e){if(C(e))return!0;if(typeof e!=`object`||!Array.isArray(e))return!1;let[t,n,...r]=e;return C(t)&&typeof n==`string`&&n in y&&r.length===0}const C=e=>typeof e==`function`&&e.length===1;function w(...e){return t(T,e)}function T(e,t){for(let[n,r]of e.entries())if(!t(r,n,e))return e.slice(n);return[]}function E(...e){return t(Object.entries,e)}function D(...e){return t(O,e,k)}const O=(e,t)=>e.filter(t),k=e=>(t,n,r)=>e(t,n,r)?{done:!1,hasNext:!0,next:t}:u,A=e=>Object.assign(e,{single:!0});function j(...e){return t(M,e)}const M=(e,t)=>{for(let n=e.length-1;n>=0;n--){let r=e[n];if(t(r,n,e))return r}};function N(...e){return t(P,e,A(F))}const P=([e])=>e,F=()=>I,I=e=>({hasNext:!0,next:e,done:!0});function L(...e){return t(R,e,z)}const R=(e,t)=>e.flatMap(t),z=e=>(t,n,r)=>{let i=e(t,n,r);return Array.isArray(i)?{done:!1,hasNext:!0,hasMany:!0,next:i}:{done:!1,hasNext:!0,next:i}};function B(...e){return t(V,e,H)}function V(e,t){return e.forEach(t),e}const H=e=>(t,n,r)=>(e(t,n,r),{done:!1,hasNext:!0,next:t});function U(...e){return t(Object.fromEntries,e)}function W(...e){return t(G,e)}function G(e,t){let n={};for(let[r,i]of e.entries())n[i]=t(i,r,e);return n}function K(...e){return t(q,e)}const q=(e,t)=>{let n=Object.create(null);for(let r=0;r<e.length;r++){let i=e[r],a=t(i,r,e);if(a!==void 0){let e=n[a];e===void 0?n[a]=[i]:e.push(i)}}return Object.setPrototypeOf(n,Object.prototype),n};function J(...e){return t(Y,e)}function Y(e,t){if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null
|
|
2
|
-
.\v.\f.\r. .
.\xA0. . . . . . . . . . . . .\u2028.\u2029. . . .`.split(`.`)]);function
|
|
1
|
+
function e(e,t,n){let r=n=>e(n,...t);return n===void 0?r:Object.assign(r,{lazy:n,lazyArgs:t})}function t(t,n,r){let i=t.length-n.length;if(i===0)return t(...n);if(i===1)return e(t,n,r);throw Error(`Wrong number of arguments`)}function n(...e){return t(r,e)}const r=(e,t)=>t.every(t=>t(e));function i(...e){return t(a,e)}const a=(e,t)=>t.some(t=>t(e));function o(...e){return t(s,e)}const s=(e,t)=>[...e,...t];function c(e){return()=>e}const l={done:!0,hasNext:!1},u={done:!1,hasNext:!1},d=()=>l,f=e=>({hasNext:!0,next:e,done:!1});function p(e,...t){let n=e,r=t.map(e=>`lazy`in e?h(e):void 0),i=0;for(;i<t.length;){if(r[i]===void 0||!g(n)){let e=t[i];n=e(n),i+=1;continue}let e=[];for(let n=i;n<t.length;n++){let t=r[n];if(t===void 0||(e.push(t),t.isSingle))break}let a=[];for(let t of n)if(m(t,a,e))break;let{isSingle:o}=e.at(-1);n=o?a[0]:a,i+=e.length}return n}function m(e,t,n){if(n.length===0)return t.push(e),!1;let r=e,i=u,a=!1;for(let[e,o]of n.entries()){let{index:s,items:c}=o;if(c.push(r),i=o(r,s,c),o.index+=1,i.hasNext){if(i.hasMany??!1){for(let r of i.next)if(m(r,t,n.slice(e+1)))return!0;return a}r=i.next}if(!i.hasNext)break;i.done&&(a=!0)}return i.hasNext&&t.push(r),a}function h(e){let{lazy:t,lazyArgs:n}=e,r=t(...n);return Object.assign(r,{isSingle:t.single??!1,index:0,items:[]})}function g(e){return typeof e==`string`||typeof e==`object`&&!!e&&Symbol.iterator in e}function ee(e,t){let n=t.length-e.length;if(n===1){let[n,...r]=t;return p(n,{lazy:e,lazyArgs:r})}if(n===0){let n={lazy:e,lazyArgs:t};return Object.assign(e=>p(e,n),n)}throw Error(`Wrong number of arguments`)}function te(...e){return t(ne,e,re)}const ne=(e,t)=>t<0?[...e]:e.slice(t);function re(e){if(e<=0)return f;let t=e;return e=>t>0?(--t,u):{done:!1,hasNext:!0,next:e}}function _(...e){return t(v,e)}const v=(e,t)=>e.length>=t,y={asc:(e,t)=>e>t,desc:(e,t)=>e<t};function b(e,t){let[n,...r]=t;if(!S(n))return e(n,x(...r));let i=x(n,...r);return t=>e(t,i)}function x(e,t,...n){let r=typeof e==`function`?e:e[0],i=typeof e==`function`?`asc`:e[1],{[i]:a}=y,o=t===void 0?void 0:x(t,...n);return(e,t)=>{let n=r(e),i=r(t);return a(n,i)?1:a(i,n)?-1:o?.(e,t)??0}}function S(e){if(C(e))return!0;if(typeof e!=`object`||!Array.isArray(e))return!1;let[t,n,...r]=e;return C(t)&&typeof n==`string`&&n in y&&r.length===0}const C=e=>typeof e==`function`&&e.length===1;function w(...e){return t(T,e)}function T(e,t){for(let[n,r]of e.entries())if(!t(r,n,e))return e.slice(n);return[]}function E(...e){return t(Object.entries,e)}function D(...e){return t(O,e,k)}const O=(e,t)=>e.filter(t),k=e=>(t,n,r)=>e(t,n,r)?{done:!1,hasNext:!0,next:t}:u,A=e=>Object.assign(e,{single:!0});function j(...e){return t(M,e)}const M=(e,t)=>{for(let n=e.length-1;n>=0;n--){let r=e[n];if(t(r,n,e))return r}};function N(...e){return t(P,e,A(F))}const P=([e])=>e,F=()=>I,I=e=>({hasNext:!0,next:e,done:!0});function L(...e){return t(R,e,z)}const R=(e,t)=>e.flatMap(t),z=e=>(t,n,r)=>{let i=e(t,n,r);return Array.isArray(i)?{done:!1,hasNext:!0,hasMany:!0,next:i}:{done:!1,hasNext:!0,next:i}};function B(...e){return t(V,e,H)}function V(e,t){return e.forEach(t),e}const H=e=>(t,n,r)=>(e(t,n,r),{done:!1,hasNext:!0,next:t});function U(...e){return t(Object.fromEntries,e)}function W(...e){return t(G,e)}function G(e,t){let n={};for(let[r,i]of e.entries())n[i]=t(i,r,e);return n}function K(...e){return t(q,e)}const q=(e,t)=>{let n=Object.create(null);for(let r=0;r<e.length;r++){let i=e[r],a=t(i,r,e);if(a!==void 0){let e=n[a];e===void 0?n[a]=[i]:e.push(i)}}return Object.setPrototypeOf(n,Object.prototype),n};function J(...e){return t(Y,e)}function Y(e,t){if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||typeof t!=`object`||e===null||t===null||!X(e,t))return!1;if(Array.isArray(e))return ie(e,t);if(e instanceof Map)return ae(e,t);if(e instanceof Set)return oe(e,t);if(e instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp)return e.toString()===t.toString();if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let[n,r]of Object.entries(e))if(!(n in t)||!Y(r,t[n]))return!1;return!0}function X(e,t){let n=Object.getPrototypeOf(e),r=Object.getPrototypeOf(t);return n===r?!0:n===null?r===Object.prototype:n===Object.prototype&&r===null}function ie(e,t){if(e.length!==t.length)return!1;for(let[n,r]of e.entries())if(!Y(r,t[n]))return!1;return!0}function ae(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e.entries())if(!t.has(n)||!Y(r,t.get(n)))return!1;return!0}function oe(e,t){if(e.size!==t.size)return!1;let n=[...t];for(let t of e){let e=!1;for(let[r,i]of n.entries())if(Y(t,i)){e=!0,n.splice(r,1);break}if(!e)return!1}return!0}function se(e){return Array.isArray(e)}function ce(e){return typeof e==`boolean`}function le(e){return e!==void 0}function ue(e){return e===``||e===void 0?!0:Array.isArray(e)?e.length===0:Object.keys(e).length===0}function de(e){if(e==null||e===``)return!0;if(typeof e!=`object`)return!1;if(`length`in e&&typeof e.length==`number`)return e.length===0;if(`size`in e&&typeof e.size==`number`)return e.size===0;for(let t in e)return!1;return Object.getOwnPropertySymbols(e).length===0}const fe=e=>typeof e==`function`;function pe(e){return e!=null}function me(e){return t=>!e(t)}function he(e){return e==null}function ge(e){return typeof e==`number`&&!Number.isNaN(e)}function _e(...e){return t(ve,e)}function ve(e,t){if(e===t||Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map)return ye(e,t);if(e instanceof Set&&t instanceof Set)return be(e,t);let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){if(!Object.hasOwn(t,r))return!1;let{[r]:n}=e,{[r]:i}=t;if(n!==i||!Object.is(n,i))return!1}return!0}function ye(e,t){if(e.size!==t.size)return!1;for(let[n,r]of e){let e=t.get(n);if(r!==e||!Object.is(r,e))return!1}return!0}function be(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function xe(e){return typeof e==`string`}function Se(e){return!!e}function Ce(...e){return t(Object.keys,e)}function we(...e){return t(Te,e)}const Te=e=>e.at(-1);function Ee(...e){return t(De,e,Oe)}const De=(e,t)=>e.map(t),Oe=e=>(t,n,r)=>({done:!1,hasNext:!0,next:e(t,n,r)});function ke(...e){return t(Ae,e)}function Ae(e,t){let n={};for(let[r,i]of e.entries()){let[a,o]=t(i,r,e);n[a]=o}return n}function je(...e){return t(Me,e)}function Me(e,t){let n={};for(let[r,i]of Object.entries(e))n[r]=t(i,r,e);return n}function Ne(...e){return t(Pe,e)}function Pe(e,t){if(!_(t,1))return{...e};if(!_(t,2)){let{[t[0]]:n,...r}=e;return r}let n={...e};for(let e of t)delete n[e];return n}function Fe(...e){return t(Ie,e)}function Ie(e,t){let n={...e};for(let[r,i]of Object.entries(n))t(i,r,e)&&delete n[r];return n}function Le(e){let t=!1,n;return()=>(t||=(n=e(),!0),n)}function Re(...e){return t(ze,e)}const ze=e=>e.length===1?e[0]:void 0;function Be(...e){return t(Ve,e)}const Ve=(e,t)=>{let n=[[],[]];for(let[r,i]of e.entries())t(i,r,e)?n[0].push(i):n[1].push(i);return n};function He(...e){return t(Ue,e)}function Ue(e,t){let n={};for(let r of t)r in e&&(n[r]=e[r]);return n}function We(...e){return t(Ge,e)}function Ge(e,t){let n={};for(let[r,i]of Object.entries(e))t(i,r,e)&&(n[r]=i);return n}function Ke(...e){return t=>p(t,...e)}function qe(e,...t){return typeof e==`string`||typeof e==`number`||typeof e==`symbol`?n=>Z(n,e,...t):Z(e,...t)}function Z(e,...t){let n=e;for(let e of t){if(n==null)return;n=n[e]}return n}function Je(...e){return t(Ye,e)}function Ye(e,t,n){let r={};for(let[i,a]of e.entries()){let o=t(a,i,e);r[o]=n(a,i,e)}return r}function Xe(e,t){let n=Math.ceil(e),r=Math.floor(t);if(r<n)throw RangeError(`randomInteger: The range [${e.toString()},${t.toString()}] contains no integer`);return Math.floor(Math.random()*(r-n+1)+n)}function Ze(...e){return t(Qe,e)}const Qe=(e,t,n)=>e.reduce(t,n);function $e(...e){return t(et,e)}function et(e){return[...e].reverse()}function tt(...e){return t(nt,e)}function nt(e,t){let n=[...e];return n.sort(t),n}function Q(...e){return b(rt,e)}const rt=(e,t)=>[...e].sort(t);function it(e,t,n){return typeof t==`number`||t===void 0?n=>n.split(e,t):e.split(t,n)}function at(...e){return t(ot,e,st)}const ot=(e,t)=>t<0?[]:e.slice(0,t);function st(e){if(e<=0)return d;let t=e;return e=>(--t,{done:t<=0,hasNext:!0,next:e})}function ct(...e){return t(lt,e)}function lt(e,t){let n=[];for(let[r,i]of e.entries()){if(!t(i,r,e))break;n.push(i)}return n}new Set([`-`,`_`,...` .
|
|
2
|
+
.\v.\f.\r. .
.\xA0. . . . . . . . . . . . .\u2028.\u2029. . . .`.split(`.`)]);function ut(...e){return ee(dt,e)}function dt(){let e=new Set;return t=>e.has(t)?u:(e.add(t),{done:!1,hasNext:!0,next:t})}function ft(...e){return t(Object.values,e)}function pt(...e){return e.length===2?(t,...n)=>$(t,...e,...n):$(...e)}const $=(e,t,n,...r)=>t(e,...r)?typeof n==`function`?n(e,...r):n.onTrue(e,...r):typeof n==`function`?e:n.onFalse(e,...r);function mt(...e){return t(ht,e,gt)}const ht=(e,t)=>e.length<t.length?e.map((e,n)=>[e,t[n]]):t.map((t,n)=>[e[n],t]),gt=e=>(t,n)=>({hasNext:!0,next:[t,e[n]],done:n>=e.length-1});export{te as $,_e as A,se as B,je as C,Ce as D,we as E,fe as F,B as G,K as H,de as I,j as J,L as K,ue as L,he as M,me as N,Se as O,pe as P,_ as Q,le as R,Ne as S,Ee as T,W as U,J as V,U as W,E as X,D as Y,w as Z,He as _,ct as a,Le as b,Q as c,Ze as d,p as et,Xe as f,We as g,Ke as h,ut as i,n as it,ge as j,xe as k,tt as l,qe as m,pt as n,o as nt,at as o,Je as p,N as q,ft as r,i as rt,it as s,mt as t,c as tt,$e as u,Be as v,ke as w,Fe as x,Re as y,ce as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,H as t,K as n,M as r,O as i,Q as a,T as o,V as s,X as c,Y as l,_ as u,c as d,et as f,h as p,i as m,j as h,m as g}from"./libs/remeda.mjs";import{
|
|
1
|
+
import{C as e,H as t,K as n,M as r,O as i,Q as a,T as o,V as s,X as c,Y as l,_ as u,c as d,et as f,h as p,i as m,j as h,m as g}from"./libs/remeda.mjs";import{Kt as _,Nt as v,Zt as y,g as b,h as x,vt as S,wn as C,yt as w}from"./types.mjs";import{castDraft as T,produce as E}from"immer";function D(e,t){let{nodes:n,edges:r,hasManualLayout:i,...a}=e,o=new Map(n.map(e=>[e.id,e])),s=new Map(r.map(e=>[e.id,e])),c=t.nodes.map(e=>{let t=o.get(e.id);return t?{...t,x:e.x,y:e.y,width:e.width,height:e.height,labelBBox:e.labelBBox}:e}),l=t.edges.map(e=>{let t=s.get(e.id);return t?{...t,points:e.points,label:e.label,labelBBox:e.labelBBox,...e.controlPoints!=null&&{controlPoints:e.controlPoints},...e.isLabelCustomized!=null&&{isLabelCustomized:e.isLabelCustomized}}:e}),u={...t,...a,[w]:`layouted`,bounds:t.bounds,nodes:c,edges:l};return i?u[S]=`auto`:delete u[S],u}function O(r){return f(r,l(e=>!!e.notation),t(g(`notation`)),e(p(t(g(`shape`)),e(p(t(g(`color`)),e(p(o(g(`kind`)),m())),c(),o(([e,t])=>({kinds:t,color:e})))),c(),n(([e,t])=>t.map(({color:t,kinds:n})=>({shape:e,color:t,kinds:n}))))),c(),n(([e,t])=>t.map(({shape:t,color:n,kinds:r})=>({title:e,shape:t,color:n,kinds:r}))),d(g(`shape`),g(`title`),[e=>e.kinds.length,`desc`]))}const k=(e,t)=>e===t||r(e)&&r(t)?!1:!s(e,t);function A(e,t){e.color=t.color,e.kind=t.kind,e.navigateTo=t.navigateTo??null,e.links=t.links?[...t.links]:null,e.tags=[...t.tags],r(t.style.border)?delete e.style.border:e.style.border=t.style.border,h(t.style.opacity)?e.style.opacity=t.style.opacity:delete e.style.opacity,r(t.style.multiple)?delete e.style.multiple:e.style.multiple=t.style.multiple}function j(e,t,n){if(k(t.icon??`none`,e.icon??`none`)){let a=i(e.icon)&&e.icon!==`none`;switch(!0){case a&&i(t.icon)&&t.icon!==`none`:return e.icon=t.icon,!0;case a&&(r(t.icon)||t.icon===`none`):return e.icon=`none`,!0;case!a&&i(t.icon)&&t.icon!==`none`:return n?(e.icon=t.icon,!0):!1}}return!0}function M(e,t,n){let i=!0;return k(e.style.iconColor,t.style.iconColor)&&(r(t.style.iconColor)?delete e.style.iconColor:e.style.iconColor=t.style.iconColor),k(e.style.iconSize,t.style.iconSize)&&(n?r(t.style.iconSize)?delete e.style.iconSize:e.style.iconSize=t.style.iconSize:i=!1),k(e.style.iconPosition,t.style.iconPosition)&&(n?r(t.style.iconPosition)?delete e.style.iconPosition:e.style.iconPosition=t.style.iconPosition:i=!1),i}function N(e,t){return e?`md`in t?(e.md=t.md,delete e.txt,e):(`txt`in t&&(e.txt=t.txt,delete e.md),e):t}function P(e,t,n){let i=!0;return k(e.title,t.title)&&(n?e.title=t.title:i=!1),k(e.description,t.description)&&(r(t.description)?delete e.description:n?e.description=N(e.description,t.description):i=!1),k(e.technology,t.technology)&&(r(t.technology)?delete e.technology:n?e.technology=t.technology:i=!1),i}function F(e,t,n){return e.title=t.title,r(t.description)?delete e.description:e.description=N(e.description,t.description),r(t.technology)?delete e.technology:e.technology=t.technology,!0}function I(e,t){C(e.id===t.id,`applyManualLayout: view ids do not match`),C(e._stage===`layouted`,`applyManualLayout: expected layouted view`),C(t._stage===`layouted`,`applyManualLayout: expected layouted snapshot`),C(e._layout!==`manual`,`applyManualLayout: expected auto-layouted view`);let n=new Set;e._type!==t._type&&n.add(`type-changed`);let r=L(t.nodes,e.nodes,n),i=R(t.edges,e.edges,n),o=O(r);return E(t,s=>{s.title=e.title??t.title,s.description=e.description??t.description,s.tags=e.tags?[...e.tags]:null,s.links=e.links?[...e.links]:null,s.sourcePath=e.sourcePath,s[S]=`manual`,o&&o.length>0?s.notation={nodes:o}:delete s.notation,s.nodes=T(r),s.edges=T(i),x(e)&&s._type===`dynamic`&&(s.variant=e.variant),b(e)&&s._type===`element`&&(e.viewOf?s.viewOf=e.viewOf:delete s.viewOf,e.extends?s.extends=e.extends:delete s.extends);let c=[...n];a(c,1)?s.drifts=c:(s.hash=e.hash,delete s.drifts)})}function L(e,t,n){let i=new Map(t.map(e=>[e.id,e])),o=e.map(e=>{let t=i.get(e.id);return t?(i.delete(t.id),E(e,i=>{A(i,t);let o=new Set,s=e.children.length>0,c=t.children.length>0;(k(i.modelRef,t.modelRef)||k(i.deploymentRef,t.deploymentRef))&&o.add(`modelRef-changed`),c&&!s&&o.add(`became-compound`),!c&&s&&o.add(`became-leaf`),k(i.parent,t.parent)&&o.add(`parent-changed`);let l=i.width+5>=t.width&&i.height+5>=t.height;k(i.shape,t.shape)&&(l?i.shape=t.shape:o.add(`shape-changed`)),M(i,t,l)||o.add(`label-changed`),j(i,t,l&&c===s)||o.add(`label-changed`),(s?F:P)(i,t,l)||o.add(`label-changed`),k(i.notes,t.notes)&&(r(t.notes)?delete i.notes:i.notes=N(i.notes,t.notes)),k(e.notation,t.notation)&&(i.notation=t.notation??null),s&&c&&v(new Set(e.children),new Set(t.children)).size>0&&o.add(`children-changed`);let u=[...o];a(u,1)?(n.add(`nodes-drift`),i.drifts=u):delete i.drifts})):(n.add(`nodes-removed`),{...e,drifts:[`removed`]})});return i.size>0&&n.add(`nodes-added`),o}function R(e,t,n){let i=new Map(t.map(e=>[e.id,e])),o=e.map(e=>{let t=i.get(e.id)??f(i.values(),y(t=>t.source===e.source&&t.target===e.target),_());return t&&i.delete(t.id),E(e,i=>{if(!t){i.drifts=[`removed`],n.add(`edges-removed`);return}let o=new Set,s=e.id===t.id;switch(!0){case s&&e.source==t.source&&e.target==t.target:k(i.dir??`forward`,t.dir??`forward`)&&o.add(`direction-changed`);break;case s&&e.source==t.target&&e.target==t.source:e.source!==e.target&&o.add(`direction-changed`);break;case s:e.source!=t.source&&o.add(`source-changed`),e.target!=t.target&&o.add(`target-changed`);break;default:C(e.id!=t.id,`Unexpected case in edge drift detection, ids should not match`),C(e.source==t.source,`Unexpected case in edge drift detection, sources should match`),C(e.target==t.target,`Unexpected case in edge drift detection, targets should match`),k(i.dir??`forward`,t.dir??`forward`)&&o.add(`direction-changed`);break}if(i.color=t.color,i.line=t.line,i.navigateTo=t.navigateTo??null,i.tags=t.tags?[...t.tags]:null,k(e.notes,t.notes)&&(r(e.notes)!==r(t.notes)&&o.add(`notes-changed`),i.notes=t.notes??e.notes),t.astPath?i.astPath=t.astPath:delete i.astPath,k(u(e,[`label`,`description`,`technology`,`labelBBox`]),u(t,[`label`,`description`,`technology`,`labelBBox`])))switch(!0){case t.labelBBox&&!e.labelBBox:o.add(`label-added`);break;case e.labelBBox&&!t.labelBBox:o.add(`label-removed`);break;case!!e.labelBBox&&!!t.labelBBox:t.labelBBox.width*t.labelBBox.height>(e.labelBBox.width+5)*(e.labelBBox.height+5)&&(i.labelBBox.width=Math.round(t.labelBBox.width),i.labelBBox.height=Math.round(t.labelBBox.height)),k(e.label,t.label)&&(r(t.label)!==r(e.label)&&o.add(`label-changed`),i.label=t.label??e.label),k(e.description,t.description)&&(r(t.description)!==r(e.description)&&o.add(`label-changed`),t.description&&(i.description=N(e.description,t.description))),k(e.technology,t.technology)&&(r(t.technology)!==r(e.technology)&&o.add(`label-changed`),i.technology=t.technology??e.technology??null);break;default:C(!e.labelBBox,`Unexpected case in edge labelBBox drift detection`),C(!t.labelBBox,`Unexpected case in next labelBBox drift detection`);break}let c=[...o];a(c,1)?(n.add(`edges-drift`),i.drifts=c):delete i.drifts})});return i.size>0&&n.add(`edges-added`),o}function z(e,t){let{drifts:n,...r}=I(e,t);if(!n||n.length===0)return E(e,e=>{delete e.drifts,e[S]=`auto`});let i=new Set;n.includes(`type-changed`)&&i.add(`type-changed`);let o=new Map(r.nodes.map(e=>[e.id,e])),s=new Map(r.edges.map(e=>[e.id,e])),c=e.nodes.map(e=>{let t=o.get(e.id);return t&&o.delete(t.id),E(e,e=>{if(!t){i.add(`nodes-added`),e.drifts=[`added`];return}t.drifts?(i.add(`nodes-drift`),e.drifts=[...t.drifts]):delete e.drifts})});o.size>0&&i.add(`nodes-removed`);let l=e.edges.map(e=>{let t=s.get(e.id)??f(s.values(),y(t=>t.source===e.source&&t.target===e.target),_());return t&&s.delete(t.id),E(e,e=>{if(!t){i.add(`edges-added`),e.drifts=[`added`];return}t.drifts?(i.add(`edges-drift`),e.drifts=[...t.drifts]):delete e.drifts})});s.size>0&&i.add(`edges-removed`);let u=[...i];return E(e,e=>{a(u,1)?e.drifts=u:delete e.drifts,e.nodes=T(c),e.edges=T(l),e[S]=`auto`})}export{D as i,I as n,O as r,z as t};
|
package/dist/_chunks/model.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime.mjs";import{A as t,E as n,I as r,L as i,N as a,O as o,Q as s,T as c,X as l,c as ee,et as u,i as d,l as f,m as te,r as p,s as ne}from"./libs/remeda.mjs";import{$ as re,At as m,Cn as h,Dn as g,Dt as _,H as ie,Jt as ae,Lt as v,Mt as oe,O as se,On as y,Ot as b,Sn as x,Tt as ce,Vt as le,Wt as S,Y as C,Yt as ue,_n as de,_t as w,cn as T,ct as fe,dn as pe,dt as me,en as he,fn as E,ft as ge,gn as _e,hn as ve,j as ye,kn as D,ln as O,mn as be,mt as xe,nn as k,rn as A,sn as j,t as M,tn as Se,un as Ce,ut as we,vt as N,yt as Te}from"./types.mjs";import{t as P}from"./libs/mnemonist.mjs";import{n as Ee,t as De}from"./manual-layout.mjs";var F=class{$model;$element;Aux;id;_literalId;hierarchyLevel;imported;constructor(e,t){this.$model=e,this.$element=t,this.id=this.$element.id,this._literalId=this.$element.id;let[n,r]=xe(this.id);n?(this.imported={from:n,fqn:r},this.hierarchyLevel=j(r)):(this.imported=null,this.hierarchyLevel=j(this.id))}get name(){return pe(this.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$element.kind}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get tags(){return v(this,Symbol.for(`tags`),()=>d([...this.$element.tags??[],...this.$model.specification.elements[this.$element.kind]?.tags??[]]))}get metadata(){return this.$element.metadata??{}}get title(){return this.$element.title}get hasSummary(){return!!this.$element.summary&&!!this.$element.description&&!t(this.$element.summary,this.$element.description)}get summary(){return M.memoize(this,`summary`,y(this.$element))}get description(){return M.memoize(this,`description`,g(this.$element))}get technology(){return this.$element.technology??null}get links(){return this.$element.links??[]}get defaultView(){return v(this,Symbol.for(`defaultView`),()=>S(this.scopedViews())??null)}get isRoot(){return this.parent===null}get style(){return v(this,`style`,()=>D({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$element.style}))}get projectId(){return this.imported?.from??this.$model.projectId}isAncestorOf(e){return T(this,e)}isDescendantOf(e){return T(e,this)}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=A(this.id,e.id);return t?this.$model.element(t):null}children(){return this.$model.children(this)}descendants(e){return e?be([...this.$model.descendants(this)],e)[Symbol.iterator]():this.$model.descendants(this)}siblings(){return this.$model.siblings(this)}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}get allOutgoing(){return v(this,Symbol.for(`allOutgoing`),()=>new Set(this.outgoing()))}get allIncoming(){return v(this,Symbol.for(`allIncoming`),()=>new Set(this.incoming()))}views(){return v(this,Symbol.for(`views`),()=>{let e=new Set;for(let t of this.$model.views())t.includesElement(this.id)&&e.add(t);return e})}scopedViews(){return v(this,Symbol.for(`scopedViews`),()=>{let e=new Set;for(let t of this.$model.views())t.isScopedElementView()&&t.viewOf.id===this.id&&e.add(t);return e})}isDeployed(){return o(S(this.deployments()))}deployments(){return this.$model.deployment.instancesOf(this)}hasMetadata(){return!!this.$element.metadata&&!i(this.$element.metadata)}getMetadata(e){return e?this.$element.metadata?.[e]:this.$element.metadata??{}}isTagged(e){return this.tags.includes(e)}},Oe=class{Aux;get style(){return v(this,`style`,()=>D({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$node.style}))}get name(){return pe(this.id)}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get summary(){return M.memoize(this,`summary`,y(this.$node))}get description(){return M.memoize(this,`description`,g(this.$node))}get technology(){return this.$node.technology??null}get links(){return this.$node.links??[]}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=A(this.id,e.id);return t?this.$model.node(t):null}siblings(){return this.$model.siblings(this)}isSibling(e){return this.parent===e.parent}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}*views(){for(let e of this.$model.views())e._type===`deployment`&&e.includesDeployment(this.id)&&(yield e)}isDeploymentNode(){return!1}isInstance(){return!1}get allOutgoing(){return v(this,Symbol.for(`allOutgoing`),()=>z.from(new Set(this.outgoingModelRelationships()),new Set(this.outgoing())))}get allIncoming(){return v(this,Symbol.for(`allIncoming`),()=>z.from(new Set(this.incomingModelRelationships()),new Set(this.incoming())))}hasMetadata(){return!!this.$node.metadata&&!i(this.$node.metadata)}getMetadata(e){return e?this.$node.metadata?.[e]:this.$node.metadata??{}}isTagged(e){return this.tags.includes(e)}},I=class extends Oe{$model;$node;id;_literalId;title;hierarchyLevel;constructor(e,t){super(),this.$model=e,this.$node=t,this.id=t.id,this._literalId=t.id,this.title=t.title,this.hierarchyLevel=j(t.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$node.kind}get metadata(){return this.$node.metadata??{}}get tags(){return v(this,Symbol.for(`tags`),()=>d([...this.$node.tags??[],...this.$model.$model.specification.deployments[this.kind]?.tags??[]]))}children(){return this.$model.children(this)}descendants(e=`desc`){return this.$model.descendants(this,e)}isDeploymentNode(){return!0}*instances(){for(let e of this.descendants(`desc`))e.isInstance()&&(yield e)}onlyOneInstance(){let e=this.children();if(e.size!==1)return null;let t=S(e);return t?t.isInstance()?t:t.onlyOneInstance():null}_relationshipsFromInstances=null;relationshipsFromInstances(){if(this._relationshipsFromInstances)return this._relationshipsFromInstances;let{outgoing:e,incoming:t}=this._relationshipsFromInstances={outgoing:new Set,incoming:new Set};for(let n of this.instances()){for(let t of n.element.outgoing())e.add(t);for(let e of n.element.incoming())t.add(e)}return this._relationshipsFromInstances}outgoingModelRelationships(){return this.relationshipsFromInstances().outgoing.values()}incomingModelRelationships(){return this.relationshipsFromInstances().incoming.values()}internalModelRelationships(){let{outgoing:e,incoming:t}=this.relationshipsFromInstances();return m(t,e)}},L=class extends Oe{$model;$instance;element;id;_literalId;title;hierarchyLevel;constructor(e,t,n){super(),this.$model=e,this.$instance=t,this.element=n,this.id=t.id,this._literalId=t.id,this.title=t.title??n.title,this.hierarchyLevel=j(t.id)}get $node(){return this.$instance}get parent(){return h(this.$model.parent(this),`Parent of ${this.id} not found`)}get style(){return v(this,`style`,()=>D({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.element.$element.style,...this.$instance.style}))}get tags(){return v(this,Symbol.for(`tags`),()=>d([...this.$instance.tags??[],...this.element.tags]))}get kind(){return this.element.kind}get metadata(){return this.$instance.metadata??this.element.metadata??{}}get summary(){return M.memoize(this,`summary`,y(this.$instance)??y(this.element.$element))}get description(){return M.memoize(this,`description`,g(this.$instance)??g(this.element.$element))}get technology(){return this.$instance.technology??this.element.technology??null}get links(){return this.$instance.links??this.element.links}isInstance(){return!0}outgoingModelRelationships(){return this.element.outgoing()}incomingModelRelationships(){return this.element.incoming()}*views(){for(let e of this.$model.views())if(e._type===`deployment`){if(e.includesDeployment(this.id)){yield e;continue}e.includesDeployment(this.parent.id)&&this.parent.onlyOneInstance()&&(yield e)}}},ke=class{instance;element;constructor(e,t){this.instance=e,this.element=t}get id(){return this.instance.id}get _literalId(){return this.instance.id}get style(){return v(this,`style `,()=>({shape:this.element.shape,color:this.element.color,...this.element.$element.style}))}get shape(){return this.element.shape}get color(){return this.element.color}get title(){return this.element.title}get summary(){return this.element.summary}get description(){return this.element.description}get technology(){return this.element.technology}isDeploymentNode(){return!1}isInstance(){return!1}},R=class{$model;$relationship;boundary;source;target;constructor(e,t){this.$model=e,this.$relationship=t,this.source=e.deploymentRef(t.source),this.target=e.deploymentRef(t.target);let n=A(this.source.id,this.target.id);this.boundary=n?this.$model.node(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return o(this.$relationship.title)?this.$relationship.title:null}get technology(){return r(this.$relationship.technology)?(this.kind&&this.$model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return M.memoize(this,`summary`,y(this.$relationship))}get description(){return M.memoize(this,`description`,g(this.$relationship))}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get metadata(){return this.$relationship.metadata??{}}get navigateTo(){return this.$relationship.navigateTo?this.$model.$model.view(this.$relationship.navigateTo):null}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.$model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.$model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.$model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.$model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!0}isModelRelation(){return!1}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},z=class e{model;deployment;static empty(){return new e}static from(t,n){return new e(new Set(t),new Set(n))}constructor(e=new Set,t=new Set){this.model=e,this.deployment=t}get isEmpty(){return this.model.size===0&&this.deployment.size===0}get nonEmpty(){return this.model.size>0||this.deployment.size>0}get size(){return this.model.size+this.deployment.size}intersect(t){return e.from(m(this.model,t.model),m(this.deployment,t.deployment))}difference(t){return e.from(_(this.model,t.model),_(this.deployment,t.deployment))}union(t){return e.from(oe(this.model,t.model),oe(this.deployment,t.deployment))}};const B=e=>typeof e==`string`?e:e.id,Ae=`/`,V=e=>{if(x(!e.includes(`
|
|
2
|
-
`),`View title cannot contain newlines`),e.includes(`/`)){let t=e.split(`/`).map(e=>e.trim()).filter(e=>e.length>0);return s(t,1)?t:[``]}return[e.trim()]},H=e=>V(e).join(`/`),je=e=>{let t=V(e);return s(t,2)?t.slice(0,-1).join(`/`):null},Me=e=>e.includes(`/`)?V(e).pop()??e:e.trim();var Ne=class{$model;#e=new Map;#t=new Map;#n=new P.default(()=>new Set);#r=new P.default(()=>new Set);#i=new Set;#a=new Map;#o=new P.default(()=>new Set);#s=new P.default(()=>new Set);#c=new P.default(()=>new Set);#l=new P.default(()=>new Set);#u=new Map;$deployments;constructor(e){this.$model=e;let t=this.$deployments=e.$data.deployments,n=p(t.elements);for(let e of ve(n)){let t=this.addElement(e);for(let e of t.tags)this.#l.get(e).add(t);t.isInstance()&&this.#r.get(t.element.id).add(t)}for(let e of p(t.relations)){let t=this.addRelation(e);for(let e of t.tags)this.#l.get(e).add(t)}}get $styles(){return this.$model.$styles}get projectId(){return this.$model.projectId}get project(){return this.$model.project}get specification(){return this.$model.specification}element(e){if(e instanceof I||e instanceof L)return e;let t=B(e);return h(this.#e.get(t),`Element ${t} not found`)}findElement(e){return this.#e.get(e)??null}node(e){let t=this.element(e);return x(t.isDeploymentNode(),`Element ${t.id} is not a deployment node`),t}findNode(e){let t=this.findElement(e);return t?(x(t.isDeploymentNode(),`Element ${t?.id} is not a deployment node`),t):null}instance(e){let t=this.element(e);return x(t.isInstance(),`Element ${t.id} is not a deployed instance`),t}findInstance(e){let t=this.findElement(e);return t?(x(t.isInstance(),`Element ${t?.id} is not a deployed instance`),t):null}roots(){return this.#i.values()}elements(){return this.#e.values()}*nodes(){for(let e of this.#e.values())e.isDeploymentNode()&&(yield e)}*nodesOfKind(e){for(let t of this.#e.values())t.isDeploymentNode()&&t.kind===e&&(yield t)}*instances(){for(let e of this.#e.values())e.isInstance()&&(yield e)}*instancesOf(e){let t=B(e),n=this.#r.get(t);n&&(yield*n)}deploymentRef(e){if(C.isInsideInstanceRef(e)){let{deployment:t,element:n}=e;return Se(this.#u,`${t}@${n}`,()=>new ke(this.instance(t),this.$model.element(n)))}return this.element(e.deployment)}relationships(){return this.#a.values()}relationship(e){let t=B(e);return h(this.#a.get(t),`DeploymentRelationModel ${t} not found`)}findRelationship(e){return this.#a.get(e)??null}*views(){for(let e of this.$model.views())e.isDeploymentView()&&(yield e)}parent(e){let t=B(e);return this.#t.get(t)||null}children(e){let t=B(e);return this.#n.get(t)}*siblings(e){let t=B(e),n=this.parent(e)?.children()??this.roots();for(let e of n)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this.#t.get(t);)yield n,t=n.id}*descendants(e,t=`desc`){for(let n of this.children(e))t===`asc`?(yield n,yield*this.descendants(n.id)):(yield*this.descendants(n.id),yield n)}*incoming(e,t=`all`){let n=B(e);for(let e of this.#o.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this.#s.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}addElement(e){if(this.#e.has(e.id))throw Error(`Element ${e.id} already exists`);let t=ie(e)?new I(this,Object.freeze(e)):new L(this,Object.freeze(e),this.$model.element(e.element));this.#e.set(t.id,t);let n=E(t.id);return n?(x(this.#e.has(n),`Parent ${n} of ${t.id} not found`),this.#t.set(t.id,this.node(n)),this.#n.get(n).add(t)):(x(t.isDeploymentNode(),`Root element ${t.id} is not a deployment node`),this.#i.add(t)),t}addRelation(e){if(this.#a.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new R(this,Object.freeze(e));this.#a.set(t.id,t),this.#o.get(t.target.id).add(t),this.#s.get(t.source.id).add(t);let n=t.boundary?.id??null;if(n)for(let e of[n,...k(n)])this.#c.get(e).add(t);for(let e of k(t.source.id)){if(e===n)break;this.#s.get(e).add(t)}for(let e of k(t.target.id)){if(e===n)break;this.#o.get(e).add(t)}return t}},U=class{model;$relationship;source;target;boundary;constructor(e,t){this.model=e,this.$relationship=t,this.source=e.element(C.flatten(t.source)),this.target=e.element(C.flatten(t.target));let n=A(this.source.id,this.target.id);this.boundary=n?this.model.element(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return r(this.$relationship.title)?null:this.$relationship.title}get technology(){return r(this.$relationship.technology)?(this.kind&&this.model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return M.memoize(this,`summary`,y(this.$relationship))}get description(){return M.memoize(this,`description`,g(this.$relationship))}get navigateTo(){return this.$relationship.navigateTo?this.model.view(this.$relationship.navigateTo):null}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get metadata(){return this.$relationship.metadata??{}}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!1}isModelRelation(){return!0}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},W=class{source;target;Aux;$viewModel;$view;$edge;constructor(e,t,n,r){this.source=n,this.target=r,this.$viewModel=e,this.$view=e.$view,this.$edge=t}get id(){return this.$edge.id}get parent(){return this.$edge.parent?this.$viewModel.node(this.$edge.parent):null}get label(){return this.$edge.label??null}get description(){return M.memoize(this,`description`,this.$edge.description)}get technology(){return this.$edge.technology??null}hasParent(){return this.$edge.parent!==null}get tags(){return this.$edge.tags??[]}get stepNumber(){return this.isStep()?fe(this.id):null}get navigateTo(){return this.$edge.navigateTo?this.$viewModel.$model.view(this.$edge.navigateTo):null}get color(){return this.$edge.color}get line(){return this.$edge.line??this.$viewModel.$styles.defaults.relationship.line}get head(){return this.$edge.head??this.$viewModel.$styles.defaults.relationship.arrow}get tail(){return this.$edge.tail}isStep(){return ge(this.id)}*relationships(e){for(let t of this.$edge.relations)if(e){let n=this.$viewModel.$model.findRelationship(t,e);n&&(yield n)}else yield this.$viewModel.$model.relationship(t)}includesRelation(e){let t=typeof e==`string`?e:e.id;return this.$edge.relations.includes(t)}isTagged(e){return this.tags.includes(e)}},G=class{Aux;$viewModel;$view;$node;constructor(e,t){this.$viewModel=e,this.$view=e.$view,this.$node=t}get id(){return this.$node.id}get title(){return this.$node.title}get kind(){return this.$node.kind}get description(){return M.memoize(this,`description`,this.$node.description)}get technology(){return this.$node.technology??null}get notes(){return M.memoize(this,`notes`,this.$node.notes)}get parent(){return this.$node.parent?this.$viewModel.node(this.$node.parent):null}get element(){let e=this.$node.modelRef;return e?this.$viewModel.$model.element(e):null}get deployment(){let e=this.$node.deploymentRef;return e?this.$viewModel.$model.deployment.element(e):null}get shape(){return this.$node.shape}get color(){return this.$node.color}get icon(){return this.$node.icon??null}get tags(){return this.$node.tags}get links(){return this.$node.links??[]}get navigateTo(){return this.$node.navigateTo?this.$viewModel.$model.view(this.$node.navigateTo):null}get style(){return this.$node.style}get x(){return`x`in this.$node?this.$node.x:void 0}get y(){return`y`in this.$node?this.$node.y:void 0}get width(){return`width`in this.$node?this.$node.width:void 0}get height(){return`height`in this.$node?this.$node.height:void 0}children(){return v(this,`children`,()=>new Set(this.$node.children.map(e=>this.$viewModel.node(e))))}*ancestors(){let e=this.parent;for(;e;)yield e,e=e.parent}*siblings(){let e=this.parent?.children()??this.$viewModel.roots();for(let t of e)t.id!==this.id&&(yield t)}*incoming(e=`all`){for(let t of this.$node.inEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.target.id===this.id:case e===`to-descendants`&&n.target.id!==this.id:yield n;break}}}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoing(e=`all`){for(let t of this.$node.outEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.source.id===this.id:case e===`from-descendants`&&n.source.id!==this.id:yield n;break}}}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}isLayouted(){return`width`in this.$node&&`height`in this.$node}hasChildren(){return this.$node.children.length>0}hasParent(){return this.$node.parent!==null}hasElement(){return o(this.$node.modelRef)}hasDeployment(){return o(this.$node.deploymentRef)}hasDeployedInstance(){return this.hasElement()&&this.hasDeployment()}isGroup(){return me(this.$node)}isTagged(e){return this.tags.includes(e)}},K=class{Aux;#e;#t=new Set;#n=new Map;#r=new Map;#i=new Set;#a=new Set;#o=new Set;#s=new P.default(e=>new Set);#c;id;$model;title;folder;viewPath;constructor(e,t,n,r){this.$model=e,this.#e=n,this.id=n.id,this.folder=t,this.#c=r;for(let e of this.#e.nodes){let t=new G(this,Object.freeze(e));this.#n.set(e.id,t),e.parent||this.#t.add(t),e.deploymentRef&&this.#a.add(e.deploymentRef),e.modelRef&&this.#i.add(e.modelRef);for(let e of t.tags)this.#s.get(e).add(t)}for(let e of this.#e.edges){let t=new W(this,Object.freeze(e),this.node(e.source),this.node(e.target));for(let e of t.tags)this.#s.get(e).add(t);for(let t of e.relations)this.#o.add(t);this.#r.set(e.id,t)}this.title=n.title?Me(n.title):null,this.viewPath=n.title?H(n.title):n.id}get $styles(){return this.$model.$styles}get _type(){return this.#e[N]}get stage(){return this.#e[w]}get bounds(){if(`bounds`in this.#e)return this.#e.bounds;if(this.#c)return this.#c.bounds;throw Error(`View is not layouted`)}get titleOrId(){return this.title??this.viewOf?.title??this.id}get titleOrUntitled(){return this.title??`Untitled`}get breadcrumbs(){return v(this,`breadcrumbs`,()=>this.folder.isRoot?[this]:[...this.folder.breadcrumbs,this])}get description(){return M.memoize(this,`description`,this.#e.description)}get tags(){return this.#e.tags??[]}get links(){return this.#e.links??[]}get viewOf(){if(this.isElementView()){let e=this.#e.viewOf;return e?this.$model.element(e):null}return null}get mode(){return this.isDynamicView()?this.#e.variant??`diagram`:null}get includedTags(){return[...this.#s.keys()]}get $view(){if(!this.isLayouted()||`drifts`in this.#e)return this.#e;let e=this.#c;return e?v(this,`withDriftReasons`,()=>De(this.#e,e)):this.#e}get $layouted(){if(!this.isLayouted())throw Error(`View is not layouted`);return this.$manual??this.#e}get hasManualLayout(){return this.#c!==void 0}get hasLayoutDrifts(){if(!this.isLayouted())return!1;let e=this.$manual;return!!e?.drifts&&e.drifts.length>0}get $manual(){if(!this.isLayouted())return null;let e=this.#c;return e?this.#e._layout===`manual`?this.#e:v(this,`snapshotWithManualLayout`,()=>Ee(this.#e,e)):null}get projectId(){return this.$model.projectId}roots(){return this.#t.values()}*compounds(){for(let e of this.#n.values())e.hasChildren()&&(yield e)}node(e){let t=B(e);return h(this.#n.get(t),`Node ${t} not found in view ${this.#e.id}`)}findNode(e){return this.#n.get(B(e))??null}findNodeWithElement(e){let t=B(e);return this.#i.has(t)?ae(this.#n.values(),e=>e.hasElement()&&e.element.id===t)??null:null}nodes(){return this.#n.values()}edge(e){let t=B(e);return h(this.#r.get(t),`Edge ${t} not found in view ${this.#e.id}`)}findEdge(e){return this.#r.get(B(e))??null}edges(){return this.#r.values()}*edgesWithRelation(e){for(let t of this.#r.values())t.includesRelation(e)&&(yield t)}*elements(){for(let e of this.#n.values())e.hasElement()&&(yield e)}isTagged(e){return this.tags.includes(e)}includesElement(e){return this.#i.has(B(e))}includesDeployment(e){return this.#a.has(B(e))}includesRelation(e){return this.#o.has(B(e))}isComputed(){return this.#e[w]===`computed`}isLayouted(){return this.#e[w]===`layouted`}isDiagram(){return this.#e[w]===`layouted`}isElementView(){return this.#e[N]===`element`}isScopedElementView(){return this.#e._type===`element`&&o(this.#e.viewOf)}isDeploymentView(){return this.#e[N]===`deployment`}isDynamicView(){return this.#e[N]===`dynamic`}},q=class e{$model;path;title;isRoot;parentPath;defaultViewId;constructor(e,t,r){this.$model=e,this.path=t.join(`/`),this.isRoot=this.path===``,this.title=n(t),this.isRoot?this.parentPath=void 0:this.parentPath=t.slice(0,-1).join(`/`),this.defaultViewId=r}get defaultView(){return this.defaultViewId?this.$model.view(this.defaultViewId):null}get breadcrumbs(){return x(!this.isRoot,`Root view folder has no breadcrumbs`),v(this,`breadcrumbs`,()=>{let e=this.parent;return e?e.isRoot?[e,this]:[...e.breadcrumbs,this]:[this]})}get parent(){return x(!this.isRoot,`Root view folder has no parent`),r(this.parentPath)?null:this.$model.viewFolder(this.parentPath)}get children(){return this.$model.viewFolderItems(this.path)}get folders(){return v(this,`folders`,()=>{let t=[];for(let n of this.children)n instanceof e&&t.push(n);return t})}get views(){return v(this,`views`,()=>{let e=[];for(let t of this.children)t instanceof K&&e.push(t);return e})}},J=class e{Aux;_elements=new Map;_parents=new Map;_children=new P.default(()=>new Set);_rootElements=new Set;_relations=new Map;_incoming=new P.default(()=>new Set);_outgoing=new P.default(()=>new Set);_internal=new P.default(()=>new Set);_views=new Map;_rootViewFolder;_viewFolders=new Map;_viewFolderItems=new P.default(()=>new Set);_allTags=new P.default(()=>new Set);static fromParsed(t){return new e(t)}static create(t){return new e(t)}static fromDump(t){let{_stage:n=`layouted`,projectId:r=`unknown`,project:i,globals:a,imports:o,deployments:s,views:c,relations:l,elements:ee,specification:u}=t;return new e({[w]:n,projectId:r,project:i,globals:{predicates:a?.predicates??{},dynamicPredicates:a?.dynamicPredicates??{},styles:a?.styles??{}},imports:o??{},deployments:{elements:s?.elements??{},relations:s?.relations??{}},views:c??{},relations:l??{},elements:ee??{},specification:u})}deployment;$data;constructor(e){this.$data=e;for(let[,t]of l(e.elements)){let e=this.addElement(t);for(let t of e.tags)this._allTags.get(t).add(e)}for(let[t,n]of l(e.imports??{}))for(let e of ve(n)){let n=this.addImportedElement(t,e);for(let e of n.tags)this._allTags.get(e).add(n)}for(let t of p(e.relations)){let e=this.addRelation(t);for(let t of e.tags)this._allTags.get(t).add(e)}if(this.deployment=new Ne(this),Te(e,`computed`)||Te(e,`layouted`)){let t=de(`/`),n=u(p(e.views),c(e=>({view:e,path:H(e.title??e.id),folderPath:e.title&&je(e.title)||``})),f((e,n)=>t(e.folderPath,n.folderPath))),r=e=>{let t=this._viewFolders.get(e);if(!t){let r=ne(e,`/`);x(s(r,1),`View group path "${e}" must have at least one element`);let i;i=e===``?n.find(e=>e.view.id===`index`):n.find(t=>t.path===e),t=new q(this,r,i?.view.id),this._viewFolders.set(e,t)}return t};this._rootViewFolder=r(``);for(let{folderPath:e}of n)this._viewFolders.has(e)||ne(e,`/`).reduce((e,t)=>{let n=e.join(`/`),a=r(i(n)?t:n+`/`+t);return this._viewFolderItems.get(n).add(a),e.push(t),e},[]);for(let{view:t,folderPath:i}of n){let n=new K(this,r(i),t,e.manualLayouts?.[t.id]);this._viewFolderItems.get(i).add(n),this._views.set(t.id,n);for(let e of n.tags)this._allTags.get(e).add(n)}}else this._rootViewFolder=new q(this,[``],void 0),this._viewFolders.set(this._rootViewFolder.path,this._rootViewFolder)}get asParsed(){return this}get asComputed(){return this}get asLayouted(){return this}get $styles(){return v(this,`styles`,()=>ye.from(this.project.styles,this.specification.customColors))}isParsed(){return this.stage===`parsed`}isLayouted(){return this.stage===`layouted`}isComputed(){return this.stage===`computed`}get $model(){return this.$data}get stage(){return this.$data[w]}get projectId(){return this.$data.projectId??`default`}get project(){return this.$data.project??v(this,Symbol.for(`project`),()=>({id:this.projectId,styles:{},manualLayouts:{}}))}get specification(){return this.$data.specification}get globals(){return v(this,Symbol.for(`globals`),()=>({predicates:{...this.$data.globals?.predicates},dynamicPredicates:{...this.$data.globals?.dynamicPredicates},styles:{...this.$data.globals?.styles}}))}element(e){if(e instanceof F)return e;let t=B(e);return h(this._elements.get(t),`Element ${t} not found`)}findElement(e){return this._elements.get(B(e))??null}roots(){return this._rootElements.values()}elements(){return this._elements.values()}relationships(){return this._relations.values()}relationship(e,t){if(t===`deployment`)return this.deployment.relationship(e);let n=B(e),r=this._relations.get(n)??null;return r||t===`model`?h(r,`Model relation ${n} not found`):h(this.deployment.findRelationship(n),`No model/deployment relation ${n} not found`)}findRelationship(e,t){if(t===`deployment`)return this.deployment.findRelationship(e);let n=this._relations.get(B(e))??null;return n||t===`model`?n:this.deployment.findRelationship(e)}views(){return this._views.values()}view(e){let t=B(e);return h(this._views.get(t),`View ${t} not found`)}findView(e){return this._views.get(e)??null}findManualLayout(e){return`manualLayouts`in this.$data?this.$data.manualLayouts?.[e]??null:null}viewFolder(e){return h(this._viewFolders.get(e),`View folder ${e} not found`)}get rootViewFolder(){return this._rootViewFolder}get hasViewFolders(){return this._viewFolders.size>1}viewFolderItems(e){return x(this._viewFolders.has(e),`View folder ${e} not found`),this._viewFolderItems.get(e)}parent(e){let t=B(e);return this._parents.get(t)||null}children(e){let t=B(e);return this._children.get(t)}*siblings(e){let t=B(e),n=this._parents.get(t),r=n?this._children.get(n.id).values():this.roots();for(let e of r)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this._parents.get(t);)yield n,t=n.id}*descendants(e){for(let t of this.children(e))yield t,yield*this.descendants(t.id)}*incoming(e,t=`all`){let n=B(e);for(let e of this._incoming.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this._outgoing.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}get tags(){return v(this,`tags`,()=>f([...this._allTags.keys()],_e))}get tagsSortedByUsage(){return v(this,`tagsSortedByUsage`,()=>u([...this._allTags.entries()],c(([e,t])=>({tag:e,count:t.size,tagged:t})),f((e,t)=>_e(e.tag,t.tag)),ee([te(`count`),`desc`])))}findByTag(e,t){return ue(this._allTags.get(e),e=>t===`elements`?e instanceof F:t===`views`?e instanceof K:t===`relationships`?e instanceof U:!0)}*elementsOfKind(e){for(let t of this._elements.values())t.kind===e&&(yield t)}*elementsWhere(e){let t=se(e);for(let e of this._elements.values())t(e)&&(yield e)}*relationshipsWhere(e){let t=se(e);for(let e of this._relations.values())t(e)&&(yield e)}addElement(e){if(this._elements.has(e.id))throw Error(`Element ${e.id} already exists`);let t=new F(this,Object.freeze(e));this._elements.set(t.id,t);let n=E(t.id);return n?(x(this._elements.has(n),`Parent ${n} of ${t.id} not found`),this._parents.set(t.id,this.element(n)),this._children.get(n).add(t)):this._rootElements.add(t),t}addImportedElement(e,t){x(!we(t.id),`Imported element already has global FQN`);let n=re(e,t.id);if(this._elements.has(n))throw Error(`Element ${n} already exists`);let r=new F(this,Object.freeze({...t,id:n}));this._elements.set(r.id,r);let i=E(r.id);for(;i;){if(i.includes(`.`)&&this._elements.has(i))return this._parents.set(r.id,this.element(i)),this._children.get(i).add(r),r;i=E(i)}return this._rootElements.add(r),r}addRelation(e){if(this._relations.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new U(this,Object.freeze(e)),{source:n,target:r}=t;this._relations.set(t.id,t),this._incoming.get(r.id).add(t),this._outgoing.get(n.id).add(t);let i=A(n.id,r.id);if(i)for(let e of[i,...k(i)])this._internal.get(e).add(t);for(let e of k(n.id)){if(e===i)break;this._outgoing.get(e).add(t)}for(let e of k(r.id)){if(e===i)break;this._incoming.get(e).add(t)}return t}};(function(e){e.EMPTY=J.create({_stage:`computed`,projectId:`default`,project:{id:`default`},specification:{elements:{},relationships:{},deployments:{},tags:{}},globals:{predicates:{},dynamicPredicates:{},styles:{}},deployments:{elements:{},relations:{}},elements:{},relations:{},views:{},imports:{}})})(J||={});let Pe;(function(e){e.isInside=e=>t=>T(e,t.source.id)&&T(e,t.target.id);let t=e.isDirectedBetween=(e,t)=>n=>(n.source.id===e||T(e,n.source.id))&&(n.target.id===t||T(t,n.target.id));e.isAnyBetween=(e,n)=>{let r=t(e,n),i=t(n,e);return e=>r(e)||i(e)};let n=e.isIncoming=e=>t=>(t.target.id===e||T(e,t.target.id))&&!T(e,t.source.id),r=e.isOutgoing=e=>t=>(t.source.id===e||T(e,t.source.id))&&!T(e,t.target.id);e.isAnyInOut=e=>{let t=n(e),i=r(e);return e=>t(e)||i(e)}})(Pe||={});const Y=Symbol.for(`nodejs.util.inspect.custom`);var Fe=class e{source;target;relations;id;constructor(e,t,n){this.source=e,this.target=t,this.relations=n,this.id=ce(`deployment:${e.id}:${t.id}`)}get expression(){return`${this.source.id} -> ${this.target.id}`}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target),this._boundary}nonEmpty(){return this.relations.nonEmpty}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,"constructor",{value:e,enumerable:!1}),i}toString(){let e=[...this.relations.model].map(e=>` `+e.expression);e.length?e.unshift(` model:`):e.unshift(` model: []`);let t=[...this.relations.deployment].map(e=>` `+e.expression);return t.length?t.unshift(` deployment:`):t.unshift(` deployment: []`),[this.expression,...e,...t].join(`
|
|
3
|
-
`)}hasDirectDeploymentRelation(){for(let e of this.relations.deployment)if(e.source.id===this.source.id||e.target.id===this.target.id)return!0;return!1}*values(){yield*this.relations.model,yield*this.relations.deployment}mergeWith(t){return Array.isArray(t)?t.reduce((e,t)=>e.mergeWith(t),this):(
|
|
4
|
-
`)}reversed(){return new e(this.target,this.source)}},Xe=e({findConnection:()=>$,findConnectionsBetween:()=>Ze,findConnectionsWithin:()=>Qe});function $(e,t,n=`directed`){if(e===t||
|
|
1
|
+
import{n as e}from"./rolldown-runtime.mjs";import{A as t,E as n,I as r,L as i,N as a,O as o,Q as s,T as c,X as l,c as ee,et as u,i as d,l as f,m as te,r as p,s as ne}from"./libs/remeda.mjs";import{An as m,At as h,Dt as re,Kt as g,Mt as _,O as ie,Pt as v,Tn as y,Ut as ae,W as oe,Xt as se,Z as b,Zt as ce,_n as le,an as x,bt as S,dn as C,fn as ue,ft as de,gn as fe,gt as pe,in as w,j as me,jn as T,kn as E,kt as he,ln as D,mn as O,mt as ge,nn as _e,pn as ve,pt as ye,rn as be,t as k,tt as xe,un as A,ut as Se,vn as Ce,wn as j,xt as we,yn as Te,yt as M,zt as N}from"./types.mjs";import{t as P}from"./libs/mnemonist.mjs";import{n as Ee,t as De}from"./manual-layout.mjs";var F=class{$model;$element;Aux;id;_literalId;hierarchyLevel;imported;constructor(e,t){this.$model=e,this.$element=t,this.id=this.$element.id,this._literalId=this.$element.id;let[n,r]=pe(this.id);n?(this.imported={from:n,fqn:r},this.hierarchyLevel=D(r)):(this.imported=null,this.hierarchyLevel=D(this.id))}get name(){return ve(this.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$element.kind}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get tags(){return N(this,Symbol.for(`tags`),()=>d([...this.$element.tags??[],...this.$model.specification.elements[this.$element.kind]?.tags??[]]))}get metadata(){return this.$element.metadata??{}}get title(){return this.$element.title}get hasSummary(){return!!this.$element.summary&&!!this.$element.description&&!t(this.$element.summary,this.$element.description)}get summary(){return k.memoize(this,`summary`,m(this.$element))}get description(){return k.memoize(this,`description`,E(this.$element))}get technology(){return this.$element.technology??null}get links(){return this.$element.links??[]}get defaultView(){return N(this,Symbol.for(`defaultView`),()=>g(this.scopedViews())??null)}get isRoot(){return this.parent===null}get style(){return N(this,`style`,()=>T({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$element.style}))}get projectId(){return this.imported?.from??this.$model.projectId}isAncestorOf(e){return A(this,e)}isDescendantOf(e){return A(e,this)}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=x(this.id,e.id);return t?this.$model.element(t):null}children(){return this.$model.children(this)}descendants(e){return e?fe([...this.$model.descendants(this)],e)[Symbol.iterator]():this.$model.descendants(this)}siblings(){return this.$model.siblings(this)}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}get allOutgoing(){return N(this,Symbol.for(`allOutgoing`),()=>new Set(this.outgoing()))}get allIncoming(){return N(this,Symbol.for(`allIncoming`),()=>new Set(this.incoming()))}views(){return N(this,Symbol.for(`views`),()=>{let e=new Set;for(let t of this.$model.views())t.includesElement(this.id)&&e.add(t);return e})}scopedViews(){return N(this,Symbol.for(`scopedViews`),()=>{let e=new Set;for(let t of this.$model.views())t.isScopedElementView()&&t.viewOf.id===this.id&&e.add(t);return e})}isDeployed(){return o(g(this.deployments()))}deployments(){return this.$model.deployment.instancesOf(this)}hasMetadata(){return!!this.$element.metadata&&!i(this.$element.metadata)}getMetadata(e){return e?this.$element.metadata?.[e]:this.$element.metadata??{}}isTagged(e){return this.tags.includes(e)}},Oe=class{Aux;get style(){return N(this,`style`,()=>T({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.$node.style}))}get name(){return ve(this.id)}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get summary(){return k.memoize(this,`summary`,m(this.$node))}get description(){return k.memoize(this,`description`,E(this.$node))}get technology(){return this.$node.technology??null}get links(){return this.$node.links??[]}ancestors(){return this.$model.ancestors(this)}commonAncestor(e){let t=x(this.id,e.id);return t?this.$model.node(t):null}siblings(){return this.$model.siblings(this)}isSibling(e){return this.parent===e.parent}*ascendingSiblings(){yield*this.siblings();for(let e of this.ancestors())yield*e.siblings()}*descendingSiblings(){for(let e of[...this.ancestors()].reverse())yield*e.siblings();yield*this.siblings()}incoming(e=`all`){return this.$model.incoming(this,e)}outgoing(e=`all`){return this.$model.outgoing(this,e)}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}*views(){for(let e of this.$model.views())e._type===`deployment`&&e.includesDeployment(this.id)&&(yield e)}isDeploymentNode(){return!1}isInstance(){return!1}get allOutgoing(){return N(this,Symbol.for(`allOutgoing`),()=>z.from(new Set(this.outgoingModelRelationships()),new Set(this.outgoing())))}get allIncoming(){return N(this,Symbol.for(`allIncoming`),()=>z.from(new Set(this.incomingModelRelationships()),new Set(this.incoming())))}hasMetadata(){return!!this.$node.metadata&&!i(this.$node.metadata)}getMetadata(e){return e?this.$node.metadata?.[e]:this.$node.metadata??{}}isTagged(e){return this.tags.includes(e)}},I=class extends Oe{$model;$node;id;_literalId;title;hierarchyLevel;constructor(e,t){super(),this.$model=e,this.$node=t,this.id=t.id,this._literalId=t.id,this.title=t.title,this.hierarchyLevel=D(t.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$node.kind}get metadata(){return this.$node.metadata??{}}get tags(){return N(this,Symbol.for(`tags`),()=>d([...this.$node.tags??[],...this.$model.$model.specification.deployments[this.kind]?.tags??[]]))}children(){return this.$model.children(this)}descendants(e=`desc`){return this.$model.descendants(this,e)}isDeploymentNode(){return!0}*instances(){for(let e of this.descendants(`desc`))e.isInstance()&&(yield e)}onlyOneInstance(){let e=this.children();if(e.size!==1)return null;let t=g(e);return t?t.isInstance()?t:t.onlyOneInstance():null}_relationshipsFromInstances=null;relationshipsFromInstances(){if(this._relationshipsFromInstances)return this._relationshipsFromInstances;let{outgoing:e,incoming:t}=this._relationshipsFromInstances={outgoing:new Set,incoming:new Set};for(let n of this.instances()){for(let t of n.element.outgoing())e.add(t);for(let e of n.element.incoming())t.add(e)}return this._relationshipsFromInstances}outgoingModelRelationships(){return this.relationshipsFromInstances().outgoing.values()}incomingModelRelationships(){return this.relationshipsFromInstances().incoming.values()}internalModelRelationships(){let{outgoing:e,incoming:t}=this.relationshipsFromInstances();return _(t,e)}},L=class extends Oe{$model;$instance;element;id;_literalId;title;hierarchyLevel;constructor(e,t,n){super(),this.$model=e,this.$instance=t,this.element=n,this.id=t.id,this._literalId=t.id,this.title=t.title??n.title,this.hierarchyLevel=D(t.id)}get $node(){return this.$instance}get parent(){return y(this.$model.parent(this),`Parent of ${this.id} not found`)}get style(){return N(this,`style`,()=>T({shape:this.$model.$styles.defaults.shape,color:this.$model.$styles.defaults.color,border:this.$model.$styles.defaults.border,opacity:this.$model.$styles.defaults.opacity,size:this.$model.$styles.defaults.size,padding:this.$model.$styles.defaults.padding,textSize:this.$model.$styles.defaults.text,iconPosition:this.$model.$styles.defaults.iconPosition,...this.element.$element.style,...this.$instance.style}))}get tags(){return N(this,Symbol.for(`tags`),()=>d([...this.$instance.tags??[],...this.element.tags]))}get kind(){return this.element.kind}get metadata(){return this.$instance.metadata??this.element.metadata??{}}get summary(){return k.memoize(this,`summary`,m(this.$instance)??m(this.element.$element))}get description(){return k.memoize(this,`description`,E(this.$instance)??E(this.element.$element))}get technology(){return this.$instance.technology??this.element.technology??null}get links(){return this.$instance.links??this.element.links}isInstance(){return!0}outgoingModelRelationships(){return this.element.outgoing()}incomingModelRelationships(){return this.element.incoming()}*views(){for(let e of this.$model.views())if(e._type===`deployment`){if(e.includesDeployment(this.id)){yield e;continue}e.includesDeployment(this.parent.id)&&this.parent.onlyOneInstance()&&(yield e)}}},ke=class{instance;element;constructor(e,t){this.instance=e,this.element=t}get id(){return this.instance.id}get _literalId(){return this.instance.id}get style(){return N(this,`style `,()=>({shape:this.element.shape,color:this.element.color,...this.element.$element.style}))}get shape(){return this.element.shape}get color(){return this.element.color}get title(){return this.element.title}get summary(){return this.element.summary}get description(){return this.element.description}get technology(){return this.element.technology}isDeploymentNode(){return!1}isInstance(){return!1}},R=class{$model;$relationship;boundary;source;target;constructor(e,t){this.$model=e,this.$relationship=t,this.source=e.deploymentRef(t.source),this.target=e.deploymentRef(t.target);let n=x(this.source.id,this.target.id);this.boundary=n?this.$model.node(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return o(this.$relationship.title)?this.$relationship.title:null}get technology(){return r(this.$relationship.technology)?(this.kind&&this.$model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return k.memoize(this,`summary`,m(this.$relationship))}get description(){return k.memoize(this,`description`,E(this.$relationship))}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get metadata(){return this.$relationship.metadata??{}}get navigateTo(){return this.$relationship.navigateTo?this.$model.$model.view(this.$relationship.navigateTo):null}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.$model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.$model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.$model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.$model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!0}isModelRelation(){return!1}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},z=class e{model;deployment;static empty(){return new e}static from(t,n){return new e(new Set(t),new Set(n))}constructor(e=new Set,t=new Set){this.model=e,this.deployment=t}get isEmpty(){return this.model.size===0&&this.deployment.size===0}get nonEmpty(){return this.model.size>0||this.deployment.size>0}get size(){return this.model.size+this.deployment.size}intersect(t){return e.from(_(this.model,t.model),_(this.deployment,t.deployment))}difference(t){return e.from(he(this.model,t.model),he(this.deployment,t.deployment))}union(t){return e.from(v(this.model,t.model),v(this.deployment,t.deployment))}};const B=e=>typeof e==`string`?e:e.id,Ae=`/`,V=e=>{if(j(!e.includes(`
|
|
2
|
+
`),`View title cannot contain newlines`),e.includes(`/`)){let t=e.split(`/`).map(e=>e.trim()).filter(e=>e.length>0);return s(t,1)?t:[``]}return[e.trim()]},H=e=>V(e).join(`/`),je=e=>{let t=V(e);return s(t,2)?t.slice(0,-1).join(`/`):null},Me=e=>e.includes(`/`)?V(e).pop()??e:e.trim();var Ne=class{$model;#e=new Map;#t=new Map;#n=new P.default(()=>new Set);#r=new P.default(()=>new Set);#i=new Set;#a=new Map;#o=new P.default(()=>new Set);#s=new P.default(()=>new Set);#c=new P.default(()=>new Set);#l=new P.default(()=>new Set);#u=new Map;$deployments;constructor(e){this.$model=e;let t=this.$deployments=e.$data.deployments,n=p(t.elements);for(let e of le(n)){let t=this.addElement(e);for(let e of t.tags)this.#l.get(e).add(t);t.isInstance()&&this.#r.get(t.element.id).add(t)}for(let e of p(t.relations)){let t=this.addRelation(e);for(let e of t.tags)this.#l.get(e).add(t)}}get $styles(){return this.$model.$styles}get projectId(){return this.$model.projectId}get project(){return this.$model.project}get specification(){return this.$model.specification}element(e){if(e instanceof I||e instanceof L)return e;let t=B(e);return y(this.#e.get(t),`Element ${t} not found`)}findElement(e){return this.#e.get(e)??null}node(e){let t=this.element(e);return j(t.isDeploymentNode(),`Element ${t.id} is not a deployment node`),t}findNode(e){let t=this.findElement(e);return t?(j(t.isDeploymentNode(),`Element ${t?.id} is not a deployment node`),t):null}instance(e){let t=this.element(e);return j(t.isInstance(),`Element ${t.id} is not a deployed instance`),t}findInstance(e){let t=this.findElement(e);return t?(j(t.isInstance(),`Element ${t?.id} is not a deployed instance`),t):null}roots(){return this.#i.values()}elements(){return this.#e.values()}*nodes(){for(let e of this.#e.values())e.isDeploymentNode()&&(yield e)}*nodesOfKind(e){for(let t of this.#e.values())t.isDeploymentNode()&&t.kind===e&&(yield t)}*instances(){for(let e of this.#e.values())e.isInstance()&&(yield e)}*instancesOf(e){let t=B(e),n=this.#r.get(t);n&&(yield*n)}deploymentRef(e){if(b.isInsideInstanceRef(e)){let{deployment:t,element:n}=e;return be(this.#u,`${t}@${n}`,()=>new ke(this.instance(t),this.$model.element(n)))}return this.element(e.deployment)}relationships(){return this.#a.values()}relationship(e){let t=B(e);return y(this.#a.get(t),`DeploymentRelationModel ${t} not found`)}findRelationship(e){return this.#a.get(e)??null}*views(){for(let e of this.$model.views())e.isDeploymentView()&&(yield e)}parent(e){let t=B(e);return this.#t.get(t)||null}children(e){let t=B(e);return this.#n.get(t)}*siblings(e){let t=B(e),n=this.parent(e)?.children()??this.roots();for(let e of n)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this.#t.get(t);)yield n,t=n.id}*descendants(e,t=`desc`){for(let n of this.children(e))t===`asc`?(yield n,yield*this.descendants(n.id)):(yield*this.descendants(n.id),yield n)}*incoming(e,t=`all`){let n=B(e);for(let e of this.#o.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this.#s.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}addElement(e){if(this.#e.has(e.id))throw Error(`Element ${e.id} already exists`);let t=oe(e)?new I(this,Object.freeze(e)):new L(this,Object.freeze(e),this.$model.element(e.element));this.#e.set(t.id,t);let n=O(t.id);return n?(j(this.#e.has(n),`Parent ${n} of ${t.id} not found`),this.#t.set(t.id,this.node(n)),this.#n.get(n).add(t)):(j(t.isDeploymentNode(),`Root element ${t.id} is not a deployment node`),this.#i.add(t)),t}addRelation(e){if(this.#a.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new R(this,Object.freeze(e));this.#a.set(t.id,t),this.#o.get(t.target.id).add(t),this.#s.get(t.source.id).add(t);let n=t.boundary?.id??null;if(n)for(let e of[n,...w(n)])this.#c.get(e).add(t);for(let e of w(t.source.id)){if(e===n)break;this.#s.get(e).add(t)}for(let e of w(t.target.id)){if(e===n)break;this.#o.get(e).add(t)}return t}},U=class{model;$relationship;source;target;boundary;constructor(e,t){this.model=e,this.$relationship=t,this.source=e.element(b.flatten(t.source)),this.target=e.element(b.flatten(t.target));let n=x(this.source.id,this.target.id);this.boundary=n?this.model.element(n):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return r(this.$relationship.title)?null:this.$relationship.title}get technology(){return r(this.$relationship.technology)?(this.kind&&this.model.specification.relationships[this.kind])?.technology??null:this.$relationship.technology}get hasSummary(){return!!this.$relationship.summary&&!!this.$relationship.description&&!t(this.$relationship.summary,this.$relationship.description)}get summary(){return k.memoize(this,`summary`,m(this.$relationship))}get description(){return k.memoize(this,`description`,E(this.$relationship))}get navigateTo(){return this.$relationship.navigateTo?this.model.view(this.$relationship.navigateTo):null}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get metadata(){return this.$relationship.metadata??{}}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let e of this.model.views())e.includesRelation(this.id)&&(yield e)}isDeploymentRelation(){return!1}isModelRelation(){return!0}hasMetadata(){return!!this.$relationship.metadata&&!i(this.$relationship.metadata)}getMetadata(e){return e?this.$relationship.metadata?.[e]:this.$relationship.metadata??{}}isTagged(e){return this.tags.includes(e)}},W=class{source;target;Aux;$viewModel;$view;$edge;constructor(e,t,n,r){this.source=n,this.target=r,this.$viewModel=e,this.$view=e.$view,this.$edge=t}get id(){return this.$edge.id}get parent(){return this.$edge.parent?this.$viewModel.node(this.$edge.parent):null}get label(){return this.$edge.label??null}get description(){return k.memoize(this,`description`,this.$edge.description)}get technology(){return this.$edge.technology??null}hasParent(){return this.$edge.parent!==null}get tags(){return this.$edge.tags??[]}get stepNumber(){return this.isStep()?Se(this.id):null}get navigateTo(){return this.$edge.navigateTo?this.$viewModel.$model.view(this.$edge.navigateTo):null}get color(){return this.$edge.color}get line(){return this.$edge.line??this.$viewModel.$styles.defaults.relationship.line}get head(){return this.$edge.head??this.$viewModel.$styles.defaults.relationship.arrow}get tail(){return this.$edge.tail}isStep(){return ge(this.id)}*relationships(e){for(let t of this.$edge.relations)if(e){let n=this.$viewModel.$model.findRelationship(t,e);n&&(yield n)}else yield this.$viewModel.$model.relationship(t)}includesRelation(e){let t=typeof e==`string`?e:e.id;return this.$edge.relations.includes(t)}isTagged(e){return this.tags.includes(e)}},G=class{Aux;$viewModel;$view;$node;constructor(e,t){this.$viewModel=e,this.$view=e.$view,this.$node=t}get id(){return this.$node.id}get title(){return this.$node.title}get kind(){return this.$node.kind}get description(){return k.memoize(this,`description`,this.$node.description)}get technology(){return this.$node.technology??null}get notes(){return k.memoize(this,`notes`,this.$node.notes)}get parent(){return this.$node.parent?this.$viewModel.node(this.$node.parent):null}get element(){let e=this.$node.modelRef;return e?this.$viewModel.$model.element(e):null}get deployment(){let e=this.$node.deploymentRef;return e?this.$viewModel.$model.deployment.element(e):null}get shape(){return this.$node.shape}get color(){return this.$node.color}get icon(){return this.$node.icon??null}get tags(){return this.$node.tags}get links(){return this.$node.links??[]}get navigateTo(){return this.$node.navigateTo?this.$viewModel.$model.view(this.$node.navigateTo):null}get style(){return this.$node.style}get x(){return`x`in this.$node?this.$node.x:void 0}get y(){return`y`in this.$node?this.$node.y:void 0}get width(){return`width`in this.$node?this.$node.width:void 0}get height(){return`height`in this.$node?this.$node.height:void 0}children(){return N(this,`children`,()=>new Set(this.$node.children.map(e=>this.$viewModel.node(e))))}*ancestors(){let e=this.parent;for(;e;)yield e,e=e.parent}*siblings(){let e=this.parent?.children()??this.$viewModel.roots();for(let t of e)t.id!==this.id&&(yield t)}*incoming(e=`all`){for(let t of this.$node.inEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.target.id===this.id:case e===`to-descendants`&&n.target.id!==this.id:yield n;break}}}*incomers(e=`all`){let t=new Set;for(let n of this.incoming(e))t.has(n.source.id)||(t.add(n.source.id),yield n.source)}*outgoing(e=`all`){for(let t of this.$node.outEdges){let n=this.$viewModel.edge(t);switch(!0){case e===`all`:case e===`direct`&&n.source.id===this.id:case e===`from-descendants`&&n.source.id!==this.id:yield n;break}}}*outgoers(e=`all`){let t=new Set;for(let n of this.outgoing(e))t.has(n.target.id)||(t.add(n.target.id),yield n.target)}isLayouted(){return`width`in this.$node&&`height`in this.$node}hasChildren(){return this.$node.children.length>0}hasParent(){return this.$node.parent!==null}hasElement(){return o(this.$node.modelRef)}hasDeployment(){return o(this.$node.deploymentRef)}hasDeployedInstance(){return this.hasElement()&&this.hasDeployment()}isGroup(){return ye(this.$node)}isTagged(e){return this.tags.includes(e)}},K=class{Aux;#e;#t=new Set;#n=new Map;#r=new Map;#i=new Set;#a=new Set;#o=new Set;#s=new P.default(e=>new Set);#c;id;$model;title;folder;viewPath;constructor(e,t,n,r){this.$model=e,this.#e=n,this.id=n.id,this.folder=t,this.#c=r;for(let e of this.#e.nodes){let t=new G(this,Object.freeze(e));this.#n.set(e.id,t),e.parent||this.#t.add(t),e.deploymentRef&&this.#a.add(e.deploymentRef),e.modelRef&&this.#i.add(e.modelRef);for(let e of t.tags)this.#s.get(e).add(t)}for(let e of this.#e.edges){let t=new W(this,Object.freeze(e),this.node(e.source),this.node(e.target));for(let e of t.tags)this.#s.get(e).add(t);for(let t of e.relations)this.#o.add(t);this.#r.set(e.id,t)}this.title=n.title?Me(n.title):null,this.viewPath=n.title?H(n.title):n.id}get $styles(){return this.$model.$styles}get _type(){return this.#e[S]}get stage(){return this.#e[M]}get bounds(){if(`bounds`in this.#e)return this.#e.bounds;if(this.#c)return this.#c.bounds;throw Error(`View is not layouted`)}get titleOrId(){return this.title??this.viewOf?.title??this.id}get titleOrUntitled(){return this.title??`Untitled`}get breadcrumbs(){return N(this,`breadcrumbs`,()=>this.folder.isRoot?[this]:[...this.folder.breadcrumbs,this])}get description(){return k.memoize(this,`description`,this.#e.description)}get tags(){return this.#e.tags??[]}get links(){return this.#e.links??[]}get viewOf(){if(this.isElementView()){let e=this.#e.viewOf;return e?this.$model.element(e):null}return null}get mode(){return this.isDynamicView()?this.#e.variant??`diagram`:null}get includedTags(){return[...this.#s.keys()]}get $view(){if(!this.isLayouted()||`drifts`in this.#e)return this.#e;let e=this.#c;return e?N(this,`withDriftReasons`,()=>De(this.#e,e)):this.#e}get $layouted(){if(!this.isLayouted())throw Error(`View is not layouted`);return this.$manual??this.#e}get hasManualLayout(){return this.#c!==void 0}get hasLayoutDrifts(){if(!this.isLayouted())return!1;let e=this.$manual;return!!e?.drifts&&e.drifts.length>0}get $manual(){if(!this.isLayouted())return null;let e=this.#c;return e?this.#e._layout===`manual`?this.#e:N(this,`snapshotWithManualLayout`,()=>Ee(this.#e,e)):null}get projectId(){return this.$model.projectId}roots(){return this.#t.values()}*compounds(){for(let e of this.#n.values())e.hasChildren()&&(yield e)}node(e){let t=B(e);return y(this.#n.get(t),`Node ${t} not found in view ${this.#e.id}`)}findNode(e){return this.#n.get(B(e))??null}findNodeWithElement(e){let t=B(e);return this.#i.has(t)?se(this.#n.values(),e=>e.hasElement()&&e.element.id===t)??null:null}nodes(){return this.#n.values()}edge(e){let t=B(e);return y(this.#r.get(t),`Edge ${t} not found in view ${this.#e.id}`)}findEdge(e){return this.#r.get(B(e))??null}edges(){return this.#r.values()}*edgesWithRelation(e){for(let t of this.#r.values())t.includesRelation(e)&&(yield t)}*elements(){for(let e of this.#n.values())e.hasElement()&&(yield e)}isTagged(e){return this.tags.includes(e)}includesElement(e){return this.#i.has(B(e))}includesDeployment(e){return this.#a.has(B(e))}includesRelation(e){return this.#o.has(B(e))}isComputed(){return this.#e[M]===`computed`}isLayouted(){return this.#e[M]===`layouted`}isDiagram(){return this.#e[M]===`layouted`}isElementView(){return this.#e[S]===`element`}isScopedElementView(){return this.#e._type===`element`&&o(this.#e.viewOf)}isDeploymentView(){return this.#e[S]===`deployment`}isDynamicView(){return this.#e[S]===`dynamic`}},q=class e{$model;path;title;isRoot;parentPath;defaultViewId;constructor(e,t,r){this.$model=e,this.path=t.join(`/`),this.isRoot=this.path===``,this.title=n(t),this.isRoot?this.parentPath=void 0:this.parentPath=t.slice(0,-1).join(`/`),this.defaultViewId=r}get defaultView(){return this.defaultViewId?this.$model.view(this.defaultViewId):null}get breadcrumbs(){return j(!this.isRoot,`Root view folder has no breadcrumbs`),N(this,`breadcrumbs`,()=>{let e=this.parent;return e?e.isRoot?[e,this]:[...e.breadcrumbs,this]:[this]})}get parent(){return j(!this.isRoot,`Root view folder has no parent`),r(this.parentPath)?null:this.$model.viewFolder(this.parentPath)}get children(){return this.$model.viewFolderItems(this.path)}get folders(){return N(this,`folders`,()=>{let t=[];for(let n of this.children)n instanceof e&&t.push(n);return t})}get views(){return N(this,`views`,()=>{let e=[];for(let t of this.children)t instanceof K&&e.push(t);return e})}},J=class e{Aux;_elements=new Map;_parents=new Map;_children=new P.default(()=>new Set);_rootElements=new Set;_relations=new Map;_incoming=new P.default(()=>new Set);_outgoing=new P.default(()=>new Set);_internal=new P.default(()=>new Set);_views=new Map;_rootViewFolder;_viewFolders=new Map;_viewFolderItems=new P.default(()=>new Set);_allTags=new P.default(()=>new Set);static fromParsed(t){return new e(t)}static create(t){return new e(t)}static fromDump(t){let{_stage:n=`layouted`,projectId:r=`unknown`,project:i,globals:a,imports:o,deployments:s,views:c,relations:l,elements:ee,specification:u}=t;return new e({[M]:n,projectId:r,project:i,globals:{predicates:a?.predicates??{},dynamicPredicates:a?.dynamicPredicates??{},styles:a?.styles??{}},imports:o??{},deployments:{elements:s?.elements??{},relations:s?.relations??{}},views:c??{},relations:l??{},elements:ee??{},specification:u})}deployment;$data;constructor(e){this.$data=e;for(let[,t]of l(e.elements)){let e=this.addElement(t);for(let t of e.tags)this._allTags.get(t).add(e)}for(let[t,n]of l(e.imports??{}))for(let e of le(n)){let n=this.addImportedElement(t,e);for(let e of n.tags)this._allTags.get(e).add(n)}for(let t of p(e.relations)){let e=this.addRelation(t);for(let t of e.tags)this._allTags.get(t).add(e)}if(this.deployment=new Ne(this),we(e,`computed`)||we(e,`layouted`)){let t=Te(`/`),n=u(p(e.views),c(e=>({view:e,path:H(e.title??e.id),folderPath:e.title&&je(e.title)||``})),f((e,n)=>t(e.folderPath,n.folderPath))),r=e=>{let t=this._viewFolders.get(e);if(!t){let r=ne(e,`/`);j(s(r,1),`View group path "${e}" must have at least one element`);let i;i=e===``?n.find(e=>e.view.id===`index`):n.find(t=>t.path===e),t=new q(this,r,i?.view.id),this._viewFolders.set(e,t)}return t};this._rootViewFolder=r(``);for(let{folderPath:e}of n)this._viewFolders.has(e)||ne(e,`/`).reduce((e,t)=>{let n=e.join(`/`),a=r(i(n)?t:n+`/`+t);return this._viewFolderItems.get(n).add(a),e.push(t),e},[]);for(let{view:t,folderPath:i}of n){let n=new K(this,r(i),t,e.manualLayouts?.[t.id]);this._viewFolderItems.get(i).add(n),this._views.set(t.id,n);for(let e of n.tags)this._allTags.get(e).add(n)}}else this._rootViewFolder=new q(this,[``],void 0),this._viewFolders.set(this._rootViewFolder.path,this._rootViewFolder)}get asParsed(){return this}get asComputed(){return this}get asLayouted(){return this}get $styles(){return N(this,`styles`,()=>me.from(this.project.styles,this.specification.customColors))}isParsed(){return this.stage===`parsed`}isLayouted(){return this.stage===`layouted`}isComputed(){return this.stage===`computed`}get $model(){return this.$data}get stage(){return this.$data[M]}get projectId(){return this.$data.projectId??`default`}get project(){return this.$data.project??N(this,Symbol.for(`project`),()=>({id:this.projectId,styles:{},manualLayouts:{}}))}get specification(){return this.$data.specification}get globals(){return N(this,Symbol.for(`globals`),()=>({predicates:{...this.$data.globals?.predicates},dynamicPredicates:{...this.$data.globals?.dynamicPredicates},styles:{...this.$data.globals?.styles}}))}element(e){if(e instanceof F)return e;let t=B(e);return y(this._elements.get(t),`Element ${t} not found`)}findElement(e){return this._elements.get(B(e))??null}roots(){return this._rootElements.values()}elements(){return this._elements.values()}relationships(){return this._relations.values()}relationship(e,t){if(t===`deployment`)return this.deployment.relationship(e);let n=B(e),r=this._relations.get(n)??null;return r||t===`model`?y(r,`Model relation ${n} not found`):y(this.deployment.findRelationship(n),`No model/deployment relation ${n} not found`)}findRelationship(e,t){if(t===`deployment`)return this.deployment.findRelationship(e);let n=this._relations.get(B(e))??null;return n||t===`model`?n:this.deployment.findRelationship(e)}views(){return this._views.values()}view(e){let t=B(e);return y(this._views.get(t),`View ${t} not found`)}findView(e){return this._views.get(e)??null}findManualLayout(e){return`manualLayouts`in this.$data?this.$data.manualLayouts?.[e]??null:null}viewFolder(e){return y(this._viewFolders.get(e),`View folder ${e} not found`)}get rootViewFolder(){return this._rootViewFolder}get hasViewFolders(){return this._viewFolders.size>1}viewFolderItems(e){return j(this._viewFolders.has(e),`View folder ${e} not found`),this._viewFolderItems.get(e)}parent(e){let t=B(e);return this._parents.get(t)||null}children(e){let t=B(e);return this._children.get(t)}*siblings(e){let t=B(e),n=this._parents.get(t),r=n?this._children.get(n.id).values():this.roots();for(let e of r)e.id!==t&&(yield e)}*ancestors(e){let t=B(e),n;for(;n=this._parents.get(t);)yield n,t=n.id}*descendants(e){for(let t of this.children(e))yield t,yield*this.descendants(t.id)}*incoming(e,t=`all`){let n=B(e);for(let e of this._incoming.get(n))switch(!0){case t===`all`:case t===`direct`&&e.target.id===n:case t===`to-descendants`&&e.target.id!==n:yield e;break}}*outgoing(e,t=`all`){let n=B(e);for(let e of this._outgoing.get(n))switch(!0){case t===`all`:case t===`direct`&&e.source.id===n:case t===`from-descendants`&&e.source.id!==n:yield e;break}}get tags(){return N(this,`tags`,()=>f([...this._allTags.keys()],Ce))}get tagsSortedByUsage(){return N(this,`tagsSortedByUsage`,()=>u([...this._allTags.entries()],c(([e,t])=>({tag:e,count:t.size,tagged:t})),f((e,t)=>Ce(e.tag,t.tag)),ee([te(`count`),`desc`])))}findByTag(e,t){return ce(this._allTags.get(e),e=>t===`elements`?e instanceof F:t===`views`?e instanceof K:t===`relationships`?e instanceof U:!0)}*elementsOfKind(e){for(let t of this._elements.values())t.kind===e&&(yield t)}*elementsWhere(e){let t=ie(e);for(let e of this._elements.values())t(e)&&(yield e)}*relationshipsWhere(e){let t=ie(e);for(let e of this._relations.values())t(e)&&(yield e)}addElement(e){if(this._elements.has(e.id))throw Error(`Element ${e.id} already exists`);let t=new F(this,Object.freeze(e));this._elements.set(t.id,t);let n=O(t.id);return n?(j(this._elements.has(n),`Parent ${n} of ${t.id} not found`),this._parents.set(t.id,this.element(n)),this._children.get(n).add(t)):this._rootElements.add(t),t}addImportedElement(e,t){j(!de(t.id),`Imported element already has global FQN`);let n=xe(e,t.id);if(this._elements.has(n))throw Error(`Element ${n} already exists`);let r=new F(this,Object.freeze({...t,id:n}));this._elements.set(r.id,r);let i=O(r.id);for(;i;){if(i.includes(`.`)&&this._elements.has(i))return this._parents.set(r.id,this.element(i)),this._children.get(i).add(r),r;i=O(i)}return this._rootElements.add(r),r}addRelation(e){if(this._relations.has(e.id))throw Error(`Relation ${e.id} already exists`);let t=new U(this,Object.freeze(e)),{source:n,target:r}=t;this._relations.set(t.id,t),this._incoming.get(r.id).add(t),this._outgoing.get(n.id).add(t);let i=x(n.id,r.id);if(i)for(let e of[i,...w(i)])this._internal.get(e).add(t);for(let e of w(n.id)){if(e===i)break;this._outgoing.get(e).add(t)}for(let e of w(r.id)){if(e===i)break;this._incoming.get(e).add(t)}return t}};(function(e){e.EMPTY=J.create({_stage:`computed`,projectId:`default`,project:{id:`default`},specification:{elements:{},relationships:{},deployments:{},tags:{}},globals:{predicates:{},dynamicPredicates:{},styles:{}},deployments:{elements:{},relations:{}},elements:{},relations:{},views:{},imports:{}})})(J||={});let Pe;(function(e){e.isInside=e=>t=>A(e,t.source.id)&&A(e,t.target.id);let t=e.isDirectedBetween=(e,t)=>n=>(n.source.id===e||A(e,n.source.id))&&(n.target.id===t||A(t,n.target.id));e.isAnyBetween=(e,n)=>{let r=t(e,n),i=t(n,e);return e=>r(e)||i(e)};let n=e.isIncoming=e=>t=>(t.target.id===e||A(e,t.target.id))&&!A(e,t.source.id),r=e.isOutgoing=e=>t=>(t.source.id===e||A(e,t.source.id))&&!A(e,t.target.id);e.isAnyInOut=e=>{let t=n(e),i=r(e);return e=>t(e)||i(e)}})(Pe||={});const Y=Symbol.for(`nodejs.util.inspect.custom`);var Fe=class e{source;target;relations;id;constructor(e,t,n){this.source=e,this.target=t,this.relations=n,this.id=re(`deployment:${e.id}:${t.id}`)}get expression(){return`${this.source.id} -> ${this.target.id}`}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target),this._boundary}nonEmpty(){return this.relations.nonEmpty}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,"constructor",{value:e,enumerable:!1}),i}toString(){let e=[...this.relations.model].map(e=>` `+e.expression);e.length?e.unshift(` model:`):e.unshift(` model: []`);let t=[...this.relations.deployment].map(e=>` `+e.expression);return t.length?t.unshift(` deployment:`):t.unshift(` deployment: []`),[this.expression,...e,...t].join(`
|
|
3
|
+
`)}hasDirectDeploymentRelation(){for(let e of this.relations.deployment)if(e.source.id===this.source.id||e.target.id===this.target.id)return!0;return!1}*values(){yield*this.relations.model,yield*this.relations.deployment}mergeWith(t){return Array.isArray(t)?t.reduce((e,t)=>e.mergeWith(t),this):(j(this.source.id===t.source.id,`Cannot merge connections with different sources`),j(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,this.relations.union(t.relations)))}difference(t){return new e(this.source,this.target,this.relations.difference(t.relations))}intersect(t){return new e(this.source,this.target,this.relations.intersect(t.relations))}equals(t){return j(t instanceof e,`Other should ne DeploymentConnectionModel`),this.id===t.id&&this.source.id===t.source.id&&this.target.id===t.target.id&&h(this.relations.model,t.relations.model)&&h(this.relations.deployment,t.relations.deployment)}update(t){return t&&={model:this.relations.model,deployment:this.relations.deployment,...t},new e(this.source,this.target,t?new z(t.model??new Set,t.deployment??new Set):this.relations)}};function X(e,t){if(!t){let t=e;return e=>X(e,t)}let n=e.source===t.source,r=e.target===t.target;if(n&&r)return!1;let i=A(t.source.id,e.source.id),a=A(t.target.id,e.target.id);return i&&a||n&&a||r&&i}function Ie(e,t){let n=t;for(let t of e)X(t,n)&&(n=t);return n===t?null:n}function Le(e){let t=[],n=e.slice(),r;for(;r=n.shift();){let e;for(;e=Ie(n,r);){let r=n.indexOf(e);t.push(n.splice(r,1)[0])}t.push(r)}return t}function Re(e){return e.boundary?.id?`.${e.boundary.id}`:``}function ze(e,t){if(!e||_e(e)){let t=e??`asc`;return e=>Be(e,t)}return Be(e,t??`asc`)}function Be(e,t){return u(e,c(e=>({id:Re(e),conn:e})),fe(t),c(e=>e.conn))}function Ve(e,t){return e.filter(e=>X(t,e))}function He(e,t){return e.filter(X(t))}function Ue(e){let t=new Map;for(let n of e){let e=t.get(n.id);e?t.set(n.id,n.mergeWith(e)):t.set(n.id,n)}return[...t.values()]}function We(e,t){let n=new Map([...t].map(e=>[e.id,e]));return[...e].reduce((e,t)=>{let r=n.get(t.id);if(!r)return e.push(t),e;let i=t.difference(r);return i.nonEmpty()&&e.push(i),e},[])}function Z(e,t){return t?e.source===t.source&&e.target===t.target:t=>e.source===t.source&&e.target===t.target}function Ge(e,t){return t?e.source===t.source:t=>e.source===t.source}function Ke(e,t){return t?e.target===t.target:t=>e.target===t.target}function qe(e,t){if(!t){let t=e;return e=>qe(e,t)}let n=e;return C(n.source,t)&&!C(n.target,t)}function Je(e,t){if(!t){let t=e;return e=>Je(e,t)}let n=e;return C(n.target,t)&&!C(n.source,t)}function Ye(e,t){if(!t){let t=e;return e=>Ye(e,t)}let n=e;return C(n.source,t)!==C(n.target,t)}var Q=class e{source;target;relations;id;constructor(e,t,n=new Set){this.source=e,this.target=t,this.relations=n,this.id=re(`model:${e.id}:${t.id}`)}_boundary;get boundary(){return this._boundary??=this.source.commonAncestor(this.target)}get expression(){return`${this.source.id} -> ${this.target.id}`}get isDirect(){return this.nonEmpty()&&!this.isImplicit}get isImplicit(){return this.nonEmpty()&&ae(this.relations,a(Z(this)))}get directRelations(){return new Set(ce(this.relations,Z(this)))}nonEmpty(){return this.relations.size>0}mergeWith(t){return j(this.source.id===t.source.id,`Cannot merge connections with different sources`),j(this.target.id===t.target.id,`Cannot merge connections with different targets`),new e(this.source,this.target,v(this.relations,t.relations))}difference(t){return new e(this.source,this.target,he(this.relations,t.relations))}intersect(t){return j(t instanceof e,`Cannot intersect connection with different type`),new e(this.source,this.target,_(this.relations,t.relations))}equals(t){j(t instanceof e,`Cannot merge connection with different type`);let n=t;return this.id===n.id&&this.source.id===n.source.id&&this.target.id===n.target.id&&h(this.relations,n.relations)}update(t){return new e(this.source,this.target,t)}[Y](t,n,r){let i=this.toString();return Object.defineProperty(i,"constructor",{value:e,enumerable:!1}),i}toString(){return[this.expression,this.relations.size?` relations:`:` relations: [ ]`,...[...this.relations].map(e=>` `+e.expression)].join(`
|
|
4
|
+
`)}reversed(){return new e(this.target,this.source)}},Xe=e({findConnection:()=>$,findConnectionsBetween:()=>Ze,findConnectionsWithin:()=>Qe});function $(e,t,n=`directed`){if(e===t||ue(e,t))return[];let r=e.allOutgoing.intersect(t.allIncoming),i=r.nonEmpty?[new Fe(e,t,r)]:[];return n===`directed`?i:[...i,...$(t,e,`directed`)]}function Ze(e,t,n=`both`){if(e.allIncoming.isEmpty&&e.allOutgoing.isEmpty)return[];let r=[],i=[];for(let a of t)if(e!==a)for(let t of $(e,a,n))t.source===e?r.push(t):i.push(t);return[...r,...i]}function Qe(e){return[...e].reduce((e,t,n,r)=>(n===r.length-1||e.push(...Ze(t,r.slice(n+1),`both`)),e),[])}var $e=e({findConnection:()=>et,findConnectionsBetween:()=>tt,findConnectionsWithin:()=>nt});function et(e,t,n=`directed`){if(e===t||ue(e,t))return[];let r=_(e.allOutgoing,t.allIncoming),i=r.size>0?new Q(e,t,r):null;if(n===`directed`)return i?[i]:[];let a=_(e.allIncoming,t.allOutgoing),o=a.size>0?new Q(t,e,a):null;return i&&o?[i,o]:i?[i]:o?[o]:[]}function tt(e,t,n=`both`){if(e.allIncoming.size===0&&e.allOutgoing.size===0)return[];let r=[],i=[];for(let a of t)if(e!==a)for(let t of et(e,a,n))t.source===e?r.push(t):i.push(t);return[...r,...i]}function nt(e){return[...e].reduce((e,t,n,r)=>(n===r.length-1||e.push(...tt(t,r.slice(n+1),`both`)),e),[])}function rt(e){return e instanceof I}function it(e){return e instanceof L}function at(e){return rt(e)||it(e)}function ot(e){return e instanceof ke}function st(e){return e instanceof R}function ct(e){return e instanceof U}function lt(e){return e instanceof F}function ut(e){return e instanceof K}function dt(e){return e instanceof G}function ft(e){return e instanceof W}export{Fe as A,Ae as B,Ye as C,Ue as D,qe as E,K as F,I as G,je as H,G as I,F as J,R as K,W as L,Pe as M,J as N,ze as O,q as P,U as R,Ke as S,X as T,H as U,Me as V,L as W,Ve as _,ft as a,Ge as b,ot as c,et as d,tt as f,We as g,Q as h,st as i,Y as j,Le as k,dt as l,Xe as m,at as n,lt as o,$e as p,z as q,rt as r,ut as s,it as t,ct as u,Ie as v,Je as w,Z as x,He as y,Ne as z};
|
package/dist/_chunks/types.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t}from"./rolldown-runtime.mjs";import{t as n}from"./libs/defu.mjs";import{B as r,F as i,I as a,M as o,N as s,O as c,P as l,Q as u,R as d,T as f,V as p,a as ee,et as m,f as te,it as ne,k as h,l as re,rt as ie,t as g,x as ae}from"./libs/remeda.mjs";import{i as _,n as oe,s as se,t as ce}from"./libs/mnemonist.mjs";import{t as le}from"./libs/natural-compare-lite.mjs";import{t as ue}from"./libs/ohash.mjs";import{n as de}from"./libs/hast-util-sanitize.mjs";import{t as fe}from"./libs/rehype-sanitize.mjs";import{t as pe}from"./libs/rehype-stringify.mjs";import{l as me,t as he}from"./libs/mdast-util-from-markdown.mjs";import{t as ge}from"./libs/remark-gfm.mjs";import{t as _e}from"./libs/remark-github-blockquote-alert.mjs";import{t as ve}from"./libs/remark-parse.mjs";import{t as ye}from"./libs/remark-rehype.mjs";import{t as be}from"./libs/unified.mjs";import{a as xe,c as Se,d as Ce,f as we,h as Te,i as Ee,l as De,m as Oe,n as ke,o as Ae,p as je,r as Me,s as Ne,t as Pe,u as Fe}from"./libs/@radix-ui/colors.mjs";import{t as v}from"./libs/chroma-js.mjs";function Ie(e){return ae(e,e=>e===void 0)}function Le(e){return e.summary??e.description}function Re(e){return e.description??e.summary}function y(e){return Array.isArray(e)&&e.length===2&&typeof e[0]==`number`&&typeof e[1]==`number`}function ze(e){return y(e)?{x:e[0],y:e[1]}:[e.x,e.y]}function Be(e,t){if(e===void 0||e==null){let n=typeof t==`function`?t():t;throw Error(n??`Expected defined value, but received ${e}`)}return e}function b(e,t){if(!e)throw Error(t??`Invariant failed`)}function x(e){throw Error(`NonExhaustive value: ${e}`)}const Ve={center({x:e,y:t,width:n,height:r}){return{x:e+n/2,y:t+r/2}},toPoints({x:e,y:t,width:n,height:r}){return[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+r},{x:e,y:t+r}]},fromPoints(e){let{x1:t,y1:n,x2:r,y2:i}=S.fromPoints(e);return{x:t,y:n,width:r-t,height:i-n}},merge(...e){if(b(u(e,1),`No boxes provided`),e.length===1)return e[0];let t=e[0].x,n=e[0].y,r=e[0].x+e[0].width,i=e[0].y+e[0].height;for(let a=1;a<e.length;a++){let o=e[a];t=Math.min(t,o.x),n=Math.min(n,o.y),r=Math.max(r,o.x+o.width),i=Math.max(i,o.y+o.height)}return{x:Math.floor(t),y:Math.floor(n),width:Math.round(r-t),height:Math.round(i-n)}},fromRectBox(e){return{x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),width:Math.abs(e.x2-e.x1),height:Math.abs(e.y2-e.y1)}},toRectBox(e){return{x1:e.x,y1:e.y,x2:e.x+e.width,y2:e.y+e.height}},expand(e,t){return t===0?e:{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}},shrink(e,t){return t===0?e:{x:e.x+t,y:e.y+t,width:e.width-t*2,height:e.height-t*2}},includes(e,t){return e===t?!0:e.x<=t.x&&e.y<=t.y&&e.x+e.width>=t.x+t.width&&e.y+e.height>=t.y+t.height}},S={center({x1:e,y1:t,x2:n,y2:r}){return{x:(e+n)/2,y:(t+r)/2}},fromPoints(e){b(e.length>0,`At least one point is required`);let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let[a,o]of e)t=Math.min(t,a),n=Math.min(n,o),r=Math.max(r,a),i=Math.max(i,o);return{x1:t,y1:n,x2:r,y2:i}},merge(...e){b(e.length>0,`No boxes provided`);let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x1),n=Math.min(n,a.y1),r=Math.max(r,a.x2),i=Math.max(i,a.y2);return{x1:t,y1:n,x2:r,y2:i}},toBBox(e){return{x:e.x1,y:e.y1,width:e.x2-e.x1,height:e.y2-e.y1}},includes(e,t){return e===t?!0:e.x1<=t.x1&&e.y1<=t.y1&&e.x2>=t.x2&&e.y2>=t.y2}};function He(e,t,n){return e.length===0||t.length===0?[]:(n??=Object.is,m(g(e,t),ee(([e,t])=>n(e,t)),f(([e,t])=>e)))}var C=t(le(),1);function w(e,t){return e===t?0:h(e)?h(t)?(0,C.default)(e,t):1:h(t)?-1:0}function T(e){return re(e,w)}function Ue(...e){return e.length===0?T:T(e[0])}function We(e=`.`,t=!1){return(n,r)=>{if(n===r)return 0;if(!n)return-1;if(!r)return 1;let i=n.split(e),a=r.split(e),o=Math.min(i.length,a.length);for(let e=0;e<o;e++){let t=i[e],n=a[e],r=(0,C.default)(t,n);if(r!==0)return r}let s=i.length-a.length;return t?-1*s:s}}function Ge(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(0,t):null}function Ke(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(t+1):e}const E=e=>N(e)?e:e.id;function D(e,t){let n=E(e);return t?E(t).startsWith(n+`.`):e=>{let t=E(e);return n.startsWith(t+`.`)}}function O(e,t){if(!t)return t=>O(e,t);let n=E(e),r=E(t);return n===r||r.startsWith(n+`.`)||n.startsWith(r+`.`)}function qe(e,t){return t?D(t,e):t=>D(e,t)}function k(e){return(N(e)?e:e.id).split(`.`).length}function Je(e,t){let n=N(e)?e:e.id,r=N(t)?t:t.id;if(n===r)return 0;let i=k(n),a=k(r);if(O(n,r))return Math.abs(i-a);let o=A(n,r),s=o?k(o):0;return i+a-(2*s+1)}function A(e,t){let n=e.split(`.`);if(n.length<2)return null;let r=t.split(`.`);if(r.length<2)return null;let i=[];for(let e=0;e<Math.min(n.length,r.length)-1&&n[e]===r[e];e++)i.push(n[e]);return i.length===0?null:i.join(`.`)}function Ye(e){let t=e.split(`.`);if(t.pop(),!u(t,2))return t;for(let e=1;e<t.length;e++)t[e]=t[e-1]+`.`+t[e];return t.reverse()}function j(e,t){let n=e.split(`.`).length,r=t.split(`.`).length;switch(!0){case n>r:return 1;case n<r:return-1;default:return 0}}function Xe(e,t){return j(e.id,t.id)}function Ze(e){return e.map(e=>({item:e,fqn:e.id.split(`.`)})).sort((e,t)=>e.fqn.length-t.fqn.length).map(({item:e})=>e)}function Qe(e,t){let n=t;for(let t of e)t!==n&&D(t,n)&&(n=t);return n===t?null:n}function $e(e){let t=[],n=[...e],r;for(;r=n.shift();){let e;for(;e=Qe(n,r);)t.push(...n.splice(n.indexOf(e),1));t.push(r)}return t}function M(e,t){if(!e||N(e)){let t=e??`asc`;return e=>M(e,t)}let n=t===`desc`?-1:1;return e.map(e=>({item:e,fqn:e.id.split(`.`)})).sort((e,t)=>{if(e.fqn.length!==t.fqn.length)return(e.fqn.length-t.fqn.length)*n;for(let n=0;n<e.fqn.length;n++){let r=w(e.fqn[n],t.fqn[n]);if(r!==0)return r}return 0}).map(({item:e})=>e)}function et(e,t,n){let r=e.get(t);return r||(r=n(t),e.set(t,r)),r}function N(e){return e!=null&&typeof e==`string`}function tt(e){return!!e&&Array.isArray(e)&&e.length>0}function P(e,t){return b(typeof t==`string`,`Path must be string`),typeof e==`object`&&!!e&&e[t]!=null}function nt(e){return t=>P(t,e)}function rt(...e){if(e.length===1&&typeof e[0]==`string`)return nt(e[0]);let[t,n]=e;return P(t,n)}function it(...e){return(t=>e.some(e=>e(t)))}function at(e){return typeof e==`object`&&!!e&&Symbol.iterator in e}function ot(e,t){let n=t??e;b(i(n));function*r(e){for(let t of e)n(t)&&(yield t)}return t?r(e):r}function st(e,t){let n=t??e;b(i(n));function r(e){for(let t of e)if(n(t))return t}return t?r(e):r}function ct(e,t){let n=t??e;b(typeof n==`number`&&n>=0,`Count must be a non-negative number`);function*r(e){let t=0;for(let r of e){if(t>=n)break;yield r,t++}}return t===void 0?e=>r(e):r(e)}function lt(e){return e?F(e):F}function*F(e){for(let t of e)yield*t}function ut(e,t){let n=t??e;b(i(n));function*r(e){for(let t of e)yield*n(t)}return t?r(e):r}function dt(e){return e?I(e):I}function I(e){let{value:t}=e[Symbol.iterator]().next();return t}function ft(e,t){let n=t??e;b(i(n));function*r(e){for(let t of e)yield n(t)}return t?r(e):r}function pt(e,t,n){let r=d(n)?t:e,a=n??t;b(i(r));function o(e){let t=a;for(let n of e)t=r(t,n);return t}return d(n)?o(e):o}function mt(e,t){let n=t??e;b(i(n));function r(e){for(let t of e)if(n(t))return!0;return!1}return t?r(e):r}function ht(e){return e?Array.from(e):e=>Array.from(e)}function gt(e){return e?new Set(e):e=>new Set(e)}function _t(e){return e?L(e):L}function*L(e){let t=new Set;for(let n of e)t.has(n)||(t.add(n),yield n)}function R(e,t,n){let r=typeof t==`symbol`?t:Symbol.for(t);return e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!1,writable:!1,value:n()}),e[r]}function vt(...e){let t=100;return e.length===2?t=te(e[0],e[1]):e.length===1&&(t=e[0]),new Promise(e=>{setTimeout(()=>{e(`LIKEC4_DELAY`)},t??100)})}function yt(){return Promise.resolve().then(()=>void 0)}function bt(e){Promise.resolve().then(e)}const xt=(e,t)=>{let n=A(e.source.id,e.target.id),r=A(t.source.id,t.target.id);if(n&&!r)return 1;if(!n&&r)return-1;let i=n&&r?j(n,r):0;if(i!==0)return i;let a=j(e.source.id,t.source.id);return a===0?j(e.target.id,t.target.id):a},St=se.intersection,Ct=se.symmetricDifference;function wt(...e){let t=new Set;for(let n of e)for(let e of n)t.add(e);return t}function Tt(e,...t){let n=new Set;if(e.size===0)return n;let r=u(t,2)?St(...t):t[0];if(r.size===0)return n;for(let t of e)r.has(t)&&n.add(t);return n}function Et(e,t){if(e.size===0)return new Set;if(t.size===0)return new Set(e);let n=new Set;for(let r of e)t.has(r)||n.add(r);return n}function Dt(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function Ot(e,t){return Ct(e,t)}function kt(e,t){if(e.size===0||t.size===0)return!1;t.size<e.size&&([e,t]=[t,e]);for(let n of e)if(t.has(n))return!0;return!1}function z(e){return b(typeof e==`object`&&l(e),`objectHash: value must be an object`),ue(e)}function At(e){let t=5381,n=e.length;b(n>0,`stringHash: empty string`);for(let r=0;r<n;r++)t=t*33^e.charCodeAt(r);return(t>>>0).toString(36)}function jt(){return be().use(ve).use(ge).use(_e).use(ye,{allowDangerousHtml:!0}).use(fe,n({attributes:{"*":[`className`],svg:[`width`,`height`,`viewBox`,`fill`,`ariaHidden`],path:[`d`,`fill`,`stroke`,`strokeWidth`,`strokeLinecap`,`strokeLinejoin`]},tagNames:[`svg`,`g`,`path`,`div`],protocols:{src:[`data`]}},de)).use(pe,{allowDangerousHtml:!0})}function B(e){return(``+jt().processSync(e)).trim()}function V(e){return me(he(e),{includeHtml:!1,includeImageAlt:!1})}function Mt(e){return e}var H=class e{x;y;constructor(e,t){this.x=e,this.y=t,b(typeof e==`number`&&!isNaN(e)&&isFinite(e)&&typeof t==`number`&&!isNaN(t)&&isFinite(t),`Invalid arguments for Vector: (${e}, ${t})`)}static create(...t){return t.length===2?new e(t[0],t[1]):new e(t[0].x,t[0].y)}static add(e,t){return{x:e.x+t.x,y:e.y+t.y}}static subtract(e,t){return{x:e.x-t.x,y:e.y-t.y}}static multiply(e,t){return{x:e.x*t,y:e.y*t}}static divide(e,t){return{x:e.x/t,y:e.y/t}}static dot(e,t){return e.x*t.x+e.y*t.y}add(t){return new e(this.x+t.x,this.y+t.y)}subtract(t){return new e(this.x-t.x,this.y-t.y)}multiply(t){return new e(this.x*t,this.y*t)}divide(t){return new e(this.x/t,this.y/t)}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}length(){return this.x===0&&this.y===0?0:Math.sqrt(this.x**2+this.y**2)}normalize(){let t=this.length();return t===0?new e(0,0):new e(this.x/t,this.y/t)}round(){return new e(Math.round(this.x),Math.round(this.y))}trunc(){return new e(Math.trunc(this.x),Math.trunc(this.y))}toObject(){return{x:this.x,y:this.y}}};function Nt(...e){return e.length===1&&e[0]instanceof H?e[0]:e.length===2?new H(e[0],e[1]):new H(e[0].x,e[0].y)}function Pt(e,t){return e[Ft]===t}const Ft=`_stage`,It=`_type`,Lt=`_layout`;var Rt=e({DeploymentFqn:()=>Gt,EdgeId:()=>Zt,Fqn:()=>Ut,GlobalFqn:()=>W,GroupElementKind:()=>U,MarkdownOrString:()=>Bt,NodeId:()=>Xt,NoneIcon:()=>Ht,ProjectId:()=>zt,RelationId:()=>qt,StepEdgeKind:()=>$t,ViewId:()=>Kt,extractStep:()=>en,flattenMarkdownOrString:()=>Vt,isGlobalFqn:()=>Jt,isGroupElementKind:()=>Wt,isStepEdgeId:()=>G,splitGlobalFqn:()=>Yt,stepEdgeId:()=>Qt});function zt(e){return e}function Bt(e){return typeof e==`string`?{txt:e}:e}function Vt(e){if(a(e))return null;let t=h(e)?e:e.txt??e.md;return c(t?.trim())?t:null}const Ht=`none`;function Ut(e,t){return t?t+`.`+e:e}const U=`@group`;function Wt(e){return e.kind===U}function Gt(e,t){return t?t+`.`+e:e}function Kt(e){return e}function qt(e){return e}function W(e,t){return b(typeof e==`string`&&e!=``),`@`+e+`.`+t}function Jt(e){return e.startsWith(`@`)}function Yt(e){if(!e.startsWith(`@`))return[null,e];let t=e.indexOf(`.`);if(t<2)throw Error(`Invalid global FQN`);return[e.slice(1,t),e.slice(t+1)]}function Xt(e){return e}function Zt(e){return e}function Qt(e,t){let n=`step-${String(e).padStart(2,`0`)}`;return t?`${n}.${t}`:n}const $t=`@step`;function G(e){return e.startsWith(`step-`)}function en(e){if(!G(e))throw Error(`Invalid step edge id: ${e}`);return parseFloat(e.slice(5))}let K;(function(e){function t(e){return`model`in e&&!(`project`in e)}e.isElementRef=t;function n(e){return`project`in e&&`model`in e}e.isImportRef=n;function r(e){if(h(e))throw Error(`Expected FqnRef, got: "${e}"`);if(n(e))return W(e.project,e.model);if(t(e))return e.model;throw Error(`Expected FqnRef.ModelRef or FqnRef.ImportRef`)}e.flatten=r;function i(e){return t(e)||n(e)}e.isModelRef=i;function a(e){return`deployment`in e&&`element`in e}e.isInsideInstanceRef=a;function o(e){return`deployment`in e&&!(`element`in e)}e.isDeploymentElementRef=o;function s(e){return o(e)||a(e)}e.isDeploymentRef=s})(K||={});let q;(function(e){function t(e){return`wildcard`in e&&e.wildcard===!0}e.isWildcard=t;function n(e){return`ref`in e&&K.isModelRef(e.ref)}e.isModelRef=n;function r(e){return`ref`in e&&K.isDeploymentRef(e.ref)}e.isDeploymentRef=r;function i(e){return`elementKind`in e&&`isEqual`in e}e.isElementKindExpr=i;function a(e){return`elementTag`in e&&`isEqual`in e}e.isElementTagExpr=a;function o(e){return`where`in e&&c(e.where.expr)}e.isWhere=o;function s(e){return`custom`in e&&(c(e.custom.expr)||o(e.custom.expr))}e.isCustom=s;function c(e){return t(e)||n(e)||r(e)||i(e)||a(e)}e.is=c;function l(e){return s(e)&&(e=e.custom.expr),o(e)&&(e=e.where.expr),e}e.unwrap=l})(q||={});let J;(function(e){function t(e){return`source`in e&&`target`in e}e.isDirect=t;function n(e){return`incoming`in e}e.isIncoming=n;function r(e){return`outgoing`in e}e.isOutgoing=r;function i(e){return`inout`in e}e.isInOut=i;function a(e){return`where`in e&&(t(e.where.expr)||n(e.where.expr)||r(e.where.expr)||i(e.where.expr))}e.isWhere=a;function o(e){return`customRelation`in e}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.customRelation.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(J||={});let tn;(function(e){function t(e){return`where`in e}e.isWhere=t;function n(e){return J.isWhere(e)}e.isRelationWhere=n;function r(e){return q.isWhere(e)}e.isFqnExprWhere=r;function i(e){return q.is(e)||q.isWhere(e)||q.isCustom(e)}e.isFqnExpr=i;function a(e){return J.is(e)||J.isWhere(e)||J.isCustom(e)}e.isRelation=a})(tn||={});let Y;(function(e){function t(e){return`wildcard`in e&&e.wildcard===!0}e.isWildcard=t;function n(e){return`ref`in e&&K.isModelRef(e.ref)}e.isModelRef=n;function r(e){return`elementKind`in e&&`isEqual`in e}e.isElementKindExpr=r;function i(e){return`elementTag`in e&&`isEqual`in e}e.isElementTagExpr=i;function a(e){return`where`in e&&s(e.where.expr)}e.isWhere=a;function o(e){return`custom`in e&&(s(e.custom.expr)||a(e.custom.expr))}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.custom.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(Y||={});let X;(function(e){function t(e){return`source`in e&&`target`in e}e.isDirect=t;function n(e){return`incoming`in e}e.isIncoming=n;function r(e){return`outgoing`in e}e.isOutgoing=r;function i(e){return`inout`in e}e.isInOut=i;function a(e){return`where`in e&&(t(e.where.expr)||n(e.where.expr)||r(e.where.expr)||i(e.where.expr))}e.isWhere=a;function o(e){return`customRelation`in e}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.customRelation.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(X||={});let nn;(function(e){function t(e){return`where`in e}e.isWhere=t;function n(e){return X.isWhere(e)}e.isRelationWhere=n;function r(e){return Y.isWhere(e)}e.isFqnExprWhere=r;function i(e){return Y.is(e)||Y.isWhere(e)||Y.isCustom(e)}e.isFqnExpr=i;function a(e){return X.is(e)||X.isWhere(e)||X.isCustom(e)}e.isRelationExpr=a})(nn||={});function rn(e){return c(e.kind)&&!c(e.element)}function an(e){return c(e.element)&&!c(e.kind)}const on={fill:`#3b82f6`,stroke:`#2563eb`,hiContrast:`#eff6ff`,loContrast:`#bfdbfe`},sn={fill:`#0284c7`,stroke:`#0369a1`,hiContrast:`#f0f9ff`,loContrast:`#B6ECF7`},cn={fill:`#64748b`,stroke:`#475569`,hiContrast:`#f8fafc`,loContrast:`#cbd5e1`},ln={primary:on,blue:on,secondary:sn,sky:sn,muted:cn,slate:cn,gray:{fill:`#737373`,stroke:`#525252`,hiContrast:`#fafafa`,loContrast:`#d4d4d4`},red:{fill:`#AC4D39`,stroke:`#853A2D`,hiContrast:`#FBD3CB`,loContrast:`#f5b2a3`},green:{fill:`#428a4f`,stroke:`#2d5d39`,hiContrast:`#f8fafc`,loContrast:`#c2f0c2`},amber:{fill:`#A35829`,stroke:`#7E451D`,hiContrast:`#FFE0C2`,loContrast:`#f9b27c`},indigo:{fill:`#6366f1`,stroke:`#4f46e5`,hiContrast:`#eef2ff`,loContrast:`#c7d2fe`}},un={line:`#8D8D8D`,labelBg:`#18191B`,label:`#C9C9C9`},dn={line:`#64748b`,labelBg:`#0f172a`,label:`#cbd5e1`},fn={line:`#3b82f6`,labelBg:`#172554`,label:`#eff5fd`},pn={line:`#0ea5e9`,labelBg:`#082f49`,label:`#d4f2ff`},mn={amber:{line:`#b45309`,labelBg:`#78350f`,label:`#FFE0C2`},blue:fn,gray:un,green:{line:`#15803d`,labelBg:`#052e16`,label:`#bbfcd3`},indigo:{line:`#6366f1`,labelBg:`#1e1b4b`,label:`#cbd0fd`},muted:dn,primary:fn,red:{line:`#AC4D39`,labelBg:`#b91c1c`,label:`#fcd9d2`},secondary:pn,sky:pn,slate:dn},hn={sizes:{xs:{width:180,height:100},sm:{width:240,height:135},md:{width:320,height:180},lg:{width:420,height:234},xl:{width:520,height:290}},spacing:{xs:8,sm:10,md:16,lg:24,xl:32},textSizes:{xs:13.33,sm:16,md:19.2,lg:23.04,xl:27.65},iconSizes:{xs:24,sm:36,md:60,lg:82,xl:90}},gn=[`xs`,`sm`,`md`,`lg`,`xl`],_n=[`left`,`right`,`top`,`bottom`],vn=[`solid`,`dashed`,`dotted`,`none`],yn=[`rectangle`,`person`,`browser`,`mobile`,`cylinder`,`storage`,`queue`,`bucket`,`document`,`component`],bn=[`amber`,`blue`,`gray`,`slate`,`green`,`indigo`,`muted`,`primary`,`red`,`secondary`,`sky`],xn=[`tomato`,`grass`,`blue`,`ruby`,`orange`,`indigo`,`pink`,`teal`,`purple`,`amber`,`crimson`,`red`,`lime`,`yellow`,`violet`],Sn={tomato:je.tomato9,grass:Ee.grass9,blue:ke.blue9,ruby:Ce.ruby9,orange:Ne.orange9,indigo:xe.indigo9,pink:Se.pink9,teal:we.teal9,purple:De.purple9,amber:Pe.amber9,crimson:Me.crimson9,red:Fe.red9,lime:Ae.lime9,yellow:Te.yellow9,violet:Oe.violet9};function Cn(e){return e in Sn}const wn={colors:bn.reduce((e,t)=>(e[t]={elements:ln[t],relationships:mn[t]},e),{}),...hn};function Tn(e,t){return t=Math.max(-1,Math.min(1,t)),e.map(e=>{let n=t>0?e+(255-e)*t:e*(1+t);return Math.round(Math.max(0,Math.min(255,n)))})}function En(e,t){return v(Tn(v(e).rgb(),t)).hex()}function Dn(e){b(v.valid(e),`Invalid color: ${e}`);let t=e.trim(),n=On(t.startsWith(`#`)?t:v(t).hex());return{elements:{fill:n.el_main,stroke:n.el_secondary,hiContrast:n.el_hiContrast,loContrast:n.el_loContrast},relationships:{line:n.rel_secondary,label:n.rel_hiContrast,labelBg:n.rel_main}}}function On(e){let t=e,n=v(t).darken(.8).hex(),r=kn(t),i=r.hiContrast,a=r.loContrast,o=t;return{el_main:t,el_secondary:n,el_hiContrast:i,el_loContrast:a,rel_main:o,rel_secondary:En(t,-.25),rel_hiContrast:kn(o).hiContrast}}function kn(e){let t=v(e),n=t.brighten(2),r=t.darken(2),i,a,o,s;do i=n,a=r,n=n.brighten(1),r=r.darken(1),o=v.contrastAPCA(t,n),s=v.contrastAPCA(t,r);while(Math.abs(o)<60&&Math.abs(s)<60&&(!p(n,i)||!p(r,a)));return Math.abs(o)>Math.abs(s)?{hiContrast:v(n.brighten(.4)).hex(),loContrast:n.hex()}:{hiContrast:v(r.darken(.4)).hex(),loContrast:r.hex()}}function An(e,t){let n=t??6,r=v(e.fill),i=v(e.stroke),a=r.luminance()>.8,o=m(g(v.scale(a?[r.darken(.02).desaturate(.05),r.darken(.1).desaturate(.1)]:[r.shade(.12,`lch`).desaturate(.05),r.shade(.35,`lch`).desaturate(.4)]).mode(`oklch`).correctLightness().colors(n,null),v.scale(a?[i.darken(.04).desaturate(.05),i.darken(.12).desaturate(.1)]:[i.shade(.15,`lch`).desaturate(.08),i.shade(.4,`lch`).desaturate(.4)]).mode(`oklch`).correctLightness().colors(n,null)),f(([t,n])=>({...e,fill:t.hex(),stroke:n.hex()})));return b(o.length===n,`Expected ${n} colors, got ${o.length}`),o}const jn={color:`primary`,size:`md`,opacity:15,shape:`rectangle`,group:{opacity:15,border:`dashed`},relationship:{color:`gray`,line:`dashed`,arrow:`normal`}},Mn=wn,Z={theme:Mn,defaults:jn};var Nn=class e{config;customCss;theme;defaults;static DEFAULT=new e(Z);static from(t,r){if(!t&&!r)return this.DEFAULT;let{customCss:i,theme:o,defaults:s}={...t},c=n({theme:o},{defaults:{...s}},{theme:{colors:{...r}}},Z);return a(i?.content)&&p(c,Z)?this.DEFAULT:new e(c,i)}constructor(e,t){this.config=e,this.customCss=t,this.theme=e.theme,this.defaults=e.defaults}get fingerprint(){return R(this,`fingerprint`,()=>z({config:this.config,customCss:this.customCss}))}get elementColors(){return this.theme.colors[this.defaults.color].elements}get relationshipColors(){return this.theme.colors[this.defaults.relationship.color].relationships}get groupColors(){let e=this.defaults.group?.color;if(!e)return this.elementColors;if(!this.isThemeColor(e))throw Error(`Default group color not found in theme: ${e}`);return R(this,`defaultGroup`,()=>({...this.elementColors,...this.theme.colors[e].elements}))}isDefaultColor(e){return e===this.defaults.color}colors(e){return this.computeFrom(e??this.defaults.color)}compoundColorsCache=new oe.default(e=>new ce.default(t=>An(e,t)));colorsForCompounds(e,t){return this.compoundColorsCache.get(e).get(t??6)}fontSize(e){return e??=this.defaults.text??this.defaults.size,this.theme.textSizes[e]}padding(e){return e??=this.defaults.padding??this.defaults.size,this.theme.spacing[e]}iconSize(e){return e??=this.defaults.size,this.theme.iconSizes[e]}isThemeColor(e){return e in this.theme.colors}nodeSizes(e){let t=Pn(e,this.defaults.size);return{sizes:t,values:{sizes:this.theme.sizes[t.size],padding:this.padding(t.padding),textSize:this.fontSize(t.textSize),iconSize:this.iconSize(t.iconSize)}}}computeFrom(e){if(this.isThemeColor(e))return this.theme.colors[e];if(!v.valid(e))throw Error(`Invalid color value: "${e}" (not a theme color and not a valid CSS color)`);return Dn(e)}equals(e){return e===this?!0:this.constructor===e.constructor?this.fingerprint===e.fingerprint:!1}tagColor(e){return this.isThemeColor(e)?this.theme.colors[e].elements:Cn(e)?this.computeFrom(Sn[e]).elements:this.computeFrom(e).elements}};function Pn({size:e,padding:t,textSize:n,iconSize:r,...i},a=Z.defaults.size){return e??=a,n??=e,t??=e,r??=e,{...i,size:e,padding:t,textSize:n,iconSize:r}}function Fn(e){let t=typeof e==`string`?e:e.color;return t.startsWith(`#`)||t.startsWith(`rgb`)}function In(e){return`tag`in e}function Ln(e){return`kind`in e}function Rn(e){return`metadata`in e}function zn(e){return`participant`in e}function Bn(e){return`not`in e}function Vn(e){return`and`in e}function Hn(e){return`or`in e}function Q(e){switch(!0){case zn(e):{let t=e.participant;return Un(t,Q(e.operator))}case In(e):{if(h(e.tag)||`eq`in e.tag){let t=h(e.tag)?e.tag:e.tag.eq;return e=>Array.isArray(e.tags)&&e.tags.includes(t)}let t=e.tag.neq;return e=>!Array.isArray(e.tags)||!e.tags.includes(t)}case Ln(e):{if(h(e.kind)||`eq`in e.kind){let t=h(e.kind)?e.kind:e.kind.eq;return e=>e.kind===t}let t=e.kind.neq;return e=>o(e.kind)||e.kind!==t}case Rn(e):{let{key:t,value:n}=e.metadata;if(n===void 0)return e=>e.metadata!=null&&t in e.metadata&&e.metadata[t]!=null;if(h(n)||`eq`in n){let e=h(n)?n:n.eq;return n=>{if(!n.metadata)return!1;let r=n.metadata[t];return Array.isArray(r)?r.includes(e):r===e}}let r=n.neq;return e=>{if(!e.metadata)return!0;let n=e.metadata[t];return n==null?!0:Array.isArray(n)?!n.includes(r):n!==r}}case Bn(e):return s(Q(e.not));case Vn(e):return ne(e.and.map(Q));case Hn(e):return ie(e.or.map(Q));default:x(e)}}function Un(e,t){return n=>{if(!n.source||!n.target)return!1;switch(e){case`source`:return t(n.source);case`target`:return t(n.target)}}}function Wn(e){return`include`in e||`exclude`in e}function Gn(e){return`targets`in e&&`style`in e}function Kn(e){return e._stage===`computed`}function qn(e){return e._stage===`layouted`}function $(e){return e._type===`element`}function Jn(e){return $(e)&&c(e.viewOf)}function Yn(e){return $(e)&&c(e.extends)}function Xn(e){return e._type===`deployment`}function Zn(e){return e._type===`dynamic`}function Qn(e){return`styleId`in e}function $n(e){return`predicateId`in e}function er(e){return e===`TB`||e===`BT`||e===`LR`||e===`RL`}function tr(e){return`direction`in e}function nr(e){return G(e)&&e.includes(`.`)?e.slice(0,e.indexOf(`.`)+1):null}function rr(e){return!!e&&!(`__series`in e||`__parallel`in e)}function ir(e){return!!e&&`__parallel`in e&&r(e.__parallel)}function ar(e){return!!e&&`__series`in e&&r(e.__series)}function or(e){return`title`in e&&`groupRules`in e&&Array.isArray(e.groupRules)}function sr(e){return`rank`in e&&Array.isArray(e.targets)}const cr=Symbol.for(`text`),lr=Symbol.for(`html`);var ur=class e{static mdcache=new _.default(500);static txtcache=new _.default(500);static getOrCreateFromText(t){if(t=t.trimEnd(),t===``)return e.EMPTY;let n=e.txtcache.get(t);return n||(n=new e({txt:t}),e.txtcache.set(t,n),n)}static getOrCreateFromMarkdown(t){if(t=t.trimEnd(),t===``)return e.EMPTY;let n=e.mdcache.get(t);return n||(n=new e({md:t}),e.mdcache.set(t,n),n)}static memoize(t,n,r){return R(t,n,()=>e.from(r))}static from(t){return t==null||t===e.EMPTY?e.EMPTY:t instanceof e?t:typeof t==`string`?this.getOrCreateFromText(t):`isEmpty`in t&&t.isEmpty?e.EMPTY:`md`in t?this.getOrCreateFromMarkdown(t.md):this.getOrCreateFromText(t.txt)}static EMPTY=new class extends e{isEmpty=!0;nonEmpty=!1;isMarkdown=!1;$source=null;constructor(){super({txt:``})}get text(){return null}get md(){return null}get html(){return null}};$source;isEmpty;nonEmpty;isMarkdown;constructor(e){this.isMarkdown=!1,typeof e==`string`?(this.$source={txt:e},this.isEmpty=e.trim()===``):(this.$source=e,this.isEmpty=!0,`md`in e?(this.isEmpty=e.md===``,this.isMarkdown=!0):this.isEmpty=e.txt===``),this.nonEmpty=!this.isEmpty}get text(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;return`txt`in e?e.txt:R(this,cr,()=>V(e.md))}get md(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;if(`md`in e)return e.md;if(`txt`in e)return e.txt;x(e)}get html(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;return`txt`in e?e.txt:R(this,lr,()=>B(e.md))}equals(t){return this===t?!0:t instanceof e?this.isEmpty&&t.isEmpty?!0:this.isEmpty!==t.isEmpty||this.isMarkdown!==t.isMarkdown?!1:this.isMarkdown?this.$source?.md===t.$source?.md:this.$source?.txt===t.$source?.txt:!1}};export{W as $,tt as $t,Pn as A,Tt as At,bn as B,gt as Bt,Rn as C,Be as Cn,V as Ct,In as D,Re as Dn,Et as Dt,zn as E,y as En,z as Et,vn as F,bt as Ft,X as G,ut as Gt,rn as H,pt as Ht,xn as I,yt as It,J,st as Jt,tn as K,lt as Kt,yn as L,R as Lt,Mn as M,wt as Mt,jn as N,xt as Nt,Q as O,Le as On,Dt as Ot,Dn as P,vt as Pt,Ut as Q,it as Qt,_n as R,_t as Rt,Ln as S,b as Sn,Mt as St,Hn as T,ze as Tn,At as Tt,nn as U,ft as Ut,an as V,mt as Vt,Y as W,dt as Wt,Gt as X,at as Xt,K as Y,ot as Yt,Zt as Z,rt as Zt,Yn as _,We as _n,Ft as _t,rr as a,j as an,qt as at,Gn as b,Ve as bn,H as bt,er as c,D as cn,en as ct,Qn as d,Ke as dn,Wt as dt,N as en,U as et,Kn as f,Ge as fn,G as ft,$ as g,w as gn,Lt as gt,Zn as h,$e as hn,Qt as ht,nr as i,Xe as in,zt as it,Nn as j,Ot as jt,Fn as k,Ie as kn,kt,tr as l,qe as ln,Vt as lt,qn as m,M as mn,Yt as mt,or as n,Ye as nn,Xt as nt,ir as o,Je as on,$t as ot,Xn as p,Ze as pn,Rt as pt,q,ct as qt,sr as r,A as rn,Ht as rt,ar as s,k as sn,Kt as st,ur as t,et as tn,Bt as tt,$n as u,O as un,Jt as ut,Jn as v,Ue as vn,It as vt,Bn as w,x as wn,B as wt,Vn as x,S as xn,Nt as xt,Wn as y,He as yn,Pt as yt,gn as z,ht as zt};
|
|
1
|
+
import{n as e,r as t}from"./rolldown-runtime.mjs";import{t as n}from"./libs/defu.mjs";import{B as r,F as i,I as a,M as o,N as s,O as c,P as ee,Q as l,R as u,T as te,V as d,a as ne,et as re,f as ie,it as ae,k as f,l as oe,rt as se,t as ce,x as le}from"./libs/remeda.mjs";import{i as ue,n as de,s as fe,t as pe}from"./libs/mnemonist.mjs";import{t as me}from"./libs/natural-compare-lite.mjs";import{t as he}from"./libs/ohash.mjs";import{n as ge}from"./libs/hast-util-sanitize.mjs";import{t as _e}from"./libs/rehype-sanitize.mjs";import{t as ve}from"./libs/rehype-stringify.mjs";import{l as ye,t as be}from"./libs/mdast-util-from-markdown.mjs";import{t as xe}from"./libs/remark-gfm.mjs";import{t as Se}from"./libs/remark-github-blockquote-alert.mjs";import{t as Ce}from"./libs/remark-parse.mjs";import{t as we}from"./libs/remark-rehype.mjs";import{t as Te}from"./libs/unified.mjs";import{a as Ee,c as De,d as Oe,f as ke,h as Ae,i as je,l as Me,m as Ne,n as Pe,o as Fe,p as Ie,r as Le,s as Re,t as ze,u as Be}from"./libs/@radix-ui/colors.mjs";import{t as p}from"./libs/chroma-js.mjs";function Ve(e){return le(e,e=>e===void 0)}function He(e){return e.summary??e.description}function Ue(e){return e.description??e.summary}function We(e){return Array.isArray(e)&&e.length===2&&typeof e[0]==`number`&&typeof e[1]==`number`}function Ge(e){return We(e)?{x:e[0],y:e[1]}:[e.x,e.y]}function Ke(e,t){if(e===void 0||e==null){let n=typeof t==`function`?t():t;throw Error(n??`Expected defined value, but received ${e}`)}return e}function m(e,t){if(!e)throw Error(t??`Invariant failed`)}function h(e){throw Error(`NonExhaustive value: ${e}`)}const qe={center({x:e,y:t,width:n,height:r}){return{x:e+n/2,y:t+r/2}},toPoints({x:e,y:t,width:n,height:r}){return[{x:e,y:t},{x:e+n,y:t},{x:e+n,y:t+r},{x:e,y:t+r}]},fromPoints(e){let{x1:t,y1:n,x2:r,y2:i}=Je.fromPoints(e);return{x:t,y:n,width:r-t,height:i-n}},merge(...e){if(m(l(e,1),`No boxes provided`),e.length===1)return e[0];let t=e[0].x,n=e[0].y,r=e[0].x+e[0].width,i=e[0].y+e[0].height;for(let a=1;a<e.length;a++){let o=e[a];t=Math.min(t,o.x),n=Math.min(n,o.y),r=Math.max(r,o.x+o.width),i=Math.max(i,o.y+o.height)}return{x:Math.floor(t),y:Math.floor(n),width:Math.round(r-t),height:Math.round(i-n)}},fromRectBox(e){return{x:Math.min(e.x1,e.x2),y:Math.min(e.y1,e.y2),width:Math.abs(e.x2-e.x1),height:Math.abs(e.y2-e.y1)}},toRectBox(e){return{x1:e.x,y1:e.y,x2:e.x+e.width,y2:e.y+e.height}},expand(e,t){return t===0?e:{x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2}},shrink(e,t){return t===0?e:{x:e.x+t,y:e.y+t,width:e.width-t*2,height:e.height-t*2}},includes(e,t){return e===t?!0:e.x<=t.x&&e.y<=t.y&&e.x+e.width>=t.x+t.width&&e.y+e.height>=t.y+t.height}},Je={center({x1:e,y1:t,x2:n,y2:r}){return{x:(e+n)/2,y:(t+r)/2}},fromPoints(e){m(e.length>0,`At least one point is required`);let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let[a,o]of e)t=Math.min(t,a),n=Math.min(n,o),r=Math.max(r,a),i=Math.max(i,o);return{x1:t,y1:n,x2:r,y2:i}},merge(...e){m(e.length>0,`No boxes provided`);let t=1/0,n=1/0,r=-1/0,i=-1/0;for(let a of e)t=Math.min(t,a.x1),n=Math.min(n,a.y1),r=Math.max(r,a.x2),i=Math.max(i,a.y2);return{x1:t,y1:n,x2:r,y2:i}},toBBox(e){return{x:e.x1,y:e.y1,width:e.x2-e.x1,height:e.y2-e.y1}},includes(e,t){return e===t?!0:e.x1<=t.x1&&e.y1<=t.y1&&e.x2>=t.x2&&e.y2>=t.y2}};function Ye(e,t,n){return e.length===0||t.length===0?[]:(n??=Object.is,re(ce(e,t),ne(([e,t])=>n(e,t)),te(([e,t])=>e)))}var g=t(me(),1);function _(e,t){return e===t?0:f(e)?f(t)?(0,g.default)(e,t):1:f(t)?-1:0}function v(e){return oe(e,_)}function Xe(...e){return e.length===0?v:v(e[0])}function Ze(e=`.`,t=!1){return(n,r)=>{if(n===r)return 0;if(!n)return-1;if(!r)return 1;let i=n.split(e),a=r.split(e),o=Math.min(i.length,a.length);for(let e=0;e<o;e++){let t=i[e],n=a[e],r=(0,g.default)(t,n);if(r!==0)return r}let s=i.length-a.length;return t?-1*s:s}}function Qe(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(0,t):null}function $e(e){let t=e.lastIndexOf(`.`);return t>0?e.slice(t+1):e}const y=e=>T(e)?e:e.id;function b(e,t){let n=y(e);return t?y(t).startsWith(n+`.`):e=>{let t=y(e);return n.startsWith(t+`.`)}}function x(e,t){if(!t)return t=>x(e,t);let n=y(e),r=y(t);return n===r||r.startsWith(n+`.`)||n.startsWith(r+`.`)}function et(e,t){return t?b(t,e):t=>b(e,t)}function S(e){return(T(e)?e:e.id).split(`.`).length}function tt(e,t){let n=T(e)?e:e.id,r=T(t)?t:t.id;if(n===r)return 0;let i=S(n),a=S(r);if(x(n,r))return Math.abs(i-a);let o=C(n,r),s=o?S(o):0;return i+a-(2*s+1)}function C(e,t){let n=e.split(`.`);if(n.length<2)return null;let r=t.split(`.`);if(r.length<2)return null;let i=[];for(let e=0;e<Math.min(n.length,r.length)-1&&n[e]===r[e];e++)i.push(n[e]);return i.length===0?null:i.join(`.`)}function nt(e){let t=e.split(`.`);if(t.pop(),!l(t,2))return t;for(let e=1;e<t.length;e++)t[e]=t[e-1]+`.`+t[e];return t.reverse()}function w(e,t){let n=e.split(`.`).length,r=t.split(`.`).length;switch(!0){case n>r:return 1;case n<r:return-1;default:return 0}}function rt(e,t){return w(e.id,t.id)}function it(e){return e.map(e=>({item:e,fqn:e.id.split(`.`)})).sort((e,t)=>e.fqn.length-t.fqn.length).map(({item:e})=>e)}function at(e,t){let n=t;for(let t of e)t!==n&&b(t,n)&&(n=t);return n===t?null:n}function ot(e){let t=[],n=[...e],r;for(;r=n.shift();){let e;for(;e=at(n,r);)t.push(...n.splice(n.indexOf(e),1));t.push(r)}return t}function st(e,t){if(!e||T(e)){let t=e??`asc`;return e=>st(e,t)}let n=t===`desc`?-1:1;return e.map(e=>({item:e,fqn:e.id.split(`.`)})).sort((e,t)=>{if(e.fqn.length!==t.fqn.length)return(e.fqn.length-t.fqn.length)*n;for(let n=0;n<e.fqn.length;n++){let r=_(e.fqn[n],t.fqn[n]);if(r!==0)return r}return 0}).map(({item:e})=>e)}function ct(e,t,n){let r=e.get(t);return r||(r=n(t),e.set(t,r)),r}function T(e){return e!=null&&typeof e==`string`}function lt(e){return!!e&&Array.isArray(e)&&e.length>0}function ut(e,t){return m(typeof t==`string`,`Path must be string`),typeof e==`object`&&!!e&&e[t]!=null}function dt(e){return t=>ut(t,e)}function ft(...e){if(e.length===1&&typeof e[0]==`string`)return dt(e[0]);let[t,n]=e;return ut(t,n)}function pt(...e){return(t=>e.some(e=>e(t)))}function mt(e){return typeof e==`object`&&!!e&&Symbol.iterator in e}function ht(e,t){let n=t??e;m(i(n));function*r(e){for(let t of e)n(t)&&(yield t)}return t?r(e):r}function gt(e,t){let n=t??e;m(i(n));function r(e){for(let t of e)if(n(t))return t}return t?r(e):r}function _t(e,t){let n=t??e;m(typeof n==`number`&&n>=0,`Count must be a non-negative number`);function*r(e){let t=0;for(let r of e){if(t>=n)break;yield r,t++}}return t===void 0?e=>r(e):r(e)}function vt(e){return e?yt(e):yt}function*yt(e){for(let t of e)yield*t}function bt(e,t){let n=t??e;m(i(n));function*r(e){for(let t of e)yield*n(t)}return t?r(e):r}function xt(e){return e?St(e):St}function St(e){let{value:t}=e[Symbol.iterator]().next();return t}function Ct(e,t){let n=t??e;m(i(n));function*r(e){for(let t of e)yield n(t)}return t?r(e):r}function wt(e,t,n){let r=u(n)?t:e,a=n??t;m(i(r));function o(e){let t=a;for(let n of e)t=r(t,n);return t}return u(n)?o(e):o}function Tt(e,t){let n=t??e;m(i(n));function r(e){for(let t of e)if(n(t))return!0;return!1}return t?r(e):r}function Et(e){return e?Array.from(e):e=>Array.from(e)}function Dt(e){return e?new Set(e):e=>new Set(e)}function Ot(e){return e?kt(e):kt}function*kt(e){let t=new Set;for(let n of e)t.has(n)||(t.add(n),yield n)}function E(e,t,n){let r=typeof t==`symbol`?t:Symbol.for(t);return e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!1,writable:!1,value:n()}),e[r]}function At(...e){let t=100;return e.length===2?t=ie(e[0],e[1]):e.length===1&&(t=e[0]),new Promise(e=>{setTimeout(()=>{e(`LIKEC4_DELAY`)},t??100)})}function jt(){return Promise.resolve().then(()=>void 0)}function Mt(e){Promise.resolve().then(e)}const Nt=(e,t)=>{let n=C(e.source.id,e.target.id),r=C(t.source.id,t.target.id);if(n&&!r)return 1;if(!n&&r)return-1;let i=n&&r?w(n,r):0;if(i!==0)return i;let a=w(e.source.id,t.source.id);return a===0?w(e.target.id,t.target.id):a},Pt=fe.intersection,Ft=fe.symmetricDifference;function It(...e){let t=new Set;for(let n of e)for(let e of n)t.add(e);return t}function Lt(e,...t){let n=new Set;if(e.size===0)return n;let r=l(t,2)?Pt(...t):t[0];if(r.size===0)return n;for(let t of e)r.has(t)&&n.add(t);return n}function Rt(e,t){if(e.size===0)return new Set;if(t.size===0)return new Set(e);let n=new Set;for(let r of e)t.has(r)||n.add(r);return n}function zt(e,t){return e.size===t.size&&[...e].every(e=>t.has(e))}function Bt(e,t){return Ft(e,t)}function Vt(e,t){if(e.size===0||t.size===0)return!1;t.size<e.size&&([e,t]=[t,e]);for(let n of e)if(t.has(n))return!0;return!1}function D(e){return m(typeof e==`object`&&ee(e),`objectHash: value must be an object`),he(e)}function Ht(e){let t=5381,n=e.length;m(n>0,`stringHash: empty string`);for(let r=0;r<n;r++)t=t*33^e.charCodeAt(r);return(t>>>0).toString(36)}function Ut(){return Te().use(Ce).use(xe).use(Se).use(we,{allowDangerousHtml:!0}).use(_e,n({attributes:{"*":[`className`],svg:[`width`,`height`,`viewBox`,`fill`,`ariaHidden`],path:[`d`,`fill`,`stroke`,`strokeWidth`,`strokeLinecap`,`strokeLinejoin`]},tagNames:[`svg`,`g`,`path`,`div`],protocols:{src:[`data`]}},ge)).use(ve,{allowDangerousHtml:!0})}function O(e){return(``+Ut().processSync(e)).trim()}function k(e){return ye(be(e),{includeHtml:!1,includeImageAlt:!1})}function Wt(e){return e}var A=class e{x;y;constructor(e,t){this.x=e,this.y=t,m(typeof e==`number`&&!isNaN(e)&&isFinite(e)&&typeof t==`number`&&!isNaN(t)&&isFinite(t),`Invalid arguments for Vector: (${e}, ${t})`)}static create(...t){return t.length===2?new e(t[0],t[1]):new e(t[0].x,t[0].y)}static add(e,t){return{x:e.x+t.x,y:e.y+t.y}}static subtract(e,t){return{x:e.x-t.x,y:e.y-t.y}}static multiply(e,t){return{x:e.x*t,y:e.y*t}}static divide(e,t){return{x:e.x/t,y:e.y/t}}static dot(e,t){return e.x*t.x+e.y*t.y}add(t){return new e(this.x+t.x,this.y+t.y)}subtract(t){return new e(this.x-t.x,this.y-t.y)}multiply(t){return new e(this.x*t,this.y*t)}divide(t){return new e(this.x/t,this.y/t)}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}length(){return this.x===0&&this.y===0?0:Math.sqrt(this.x**2+this.y**2)}normalize(){let t=this.length();return t===0?new e(0,0):new e(this.x/t,this.y/t)}round(){return new e(Math.round(this.x),Math.round(this.y))}trunc(){return new e(Math.trunc(this.x),Math.trunc(this.y))}toObject(){return{x:this.x,y:this.y}}};function Gt(...e){return e.length===1&&e[0]instanceof A?e[0]:e.length===2?new A(e[0],e[1]):new A(e[0].x,e[0].y)}function Kt(e,t){return e[j]===t}const j=`_stage`,qt=`_type`,Jt=`_layout`;var Yt=e({DeploymentFqn:()=>z,EdgeId:()=>$t,Fqn:()=>I,GlobalFqn:()=>H,GroupElementKind:()=>L,MarkdownOrString:()=>N,NodeId:()=>Qt,NoneIcon:()=>F,ProjectId:()=>M,RelationId:()=>V,StepEdgeKind:()=>tn,ViewId:()=>B,extractStep:()=>nn,flattenMarkdownOrString:()=>P,isGlobalFqn:()=>Xt,isGroupElementKind:()=>R,isStepEdgeId:()=>U,splitGlobalFqn:()=>Zt,stepEdgeId:()=>en});function M(e){return e}function N(e){return typeof e==`string`?{txt:e}:e}function P(e){if(a(e))return null;let t=f(e)?e:e.txt??e.md;return c(t?.trim())?t:null}const F=`none`;function I(e,t){return t?t+`.`+e:e}const L=`@group`;function R(e){return e.kind===L}function z(e,t){return t?t+`.`+e:e}function B(e){return e}function V(e){return e}function H(e,t){return m(typeof e==`string`&&e!=``),`@`+e+`.`+t}function Xt(e){return e.startsWith(`@`)}function Zt(e){if(!e.startsWith(`@`))return[null,e];let t=e.indexOf(`.`);if(t<2)throw Error(`Invalid global FQN`);return[e.slice(1,t),e.slice(t+1)]}function Qt(e){return e}function $t(e){return e}function en(e,t){let n=`step-${String(e).padStart(2,`0`)}`;return t?`${n}.${t}`:n}const tn=`@step`;function U(e){return e.startsWith(`step-`)}function nn(e){if(!U(e))throw Error(`Invalid step edge id: ${e}`);return parseFloat(e.slice(5))}let W;(function(e){function t(e){return`model`in e&&!(`project`in e)}e.isElementRef=t;function n(e){return`project`in e&&`model`in e}e.isImportRef=n;function r(e){if(f(e))throw Error(`Expected FqnRef, got: "${e}"`);if(n(e))return H(e.project,e.model);if(t(e))return e.model;throw Error(`Expected FqnRef.ModelRef or FqnRef.ImportRef`)}e.flatten=r;function i(e){return t(e)||n(e)}e.isModelRef=i;function a(e){return`deployment`in e&&`element`in e}e.isInsideInstanceRef=a;function o(e){return`deployment`in e&&!(`element`in e)}e.isDeploymentElementRef=o;function s(e){return o(e)||a(e)}e.isDeploymentRef=s})(W||={});let G;(function(e){function t(e){return`wildcard`in e&&e.wildcard===!0}e.isWildcard=t;function n(e){return`ref`in e&&W.isModelRef(e.ref)}e.isModelRef=n;function r(e){return`ref`in e&&W.isDeploymentRef(e.ref)}e.isDeploymentRef=r;function i(e){return`elementKind`in e&&`isEqual`in e}e.isElementKindExpr=i;function a(e){return`elementTag`in e&&`isEqual`in e}e.isElementTagExpr=a;function o(e){return`where`in e&&c(e.where.expr)}e.isWhere=o;function s(e){return`custom`in e&&(c(e.custom.expr)||o(e.custom.expr))}e.isCustom=s;function c(e){return t(e)||n(e)||r(e)||i(e)||a(e)}e.is=c;function ee(e){return s(e)&&(e=e.custom.expr),o(e)&&(e=e.where.expr),e}e.unwrap=ee})(G||={});let K;(function(e){function t(e){return`source`in e&&`target`in e}e.isDirect=t;function n(e){return`incoming`in e}e.isIncoming=n;function r(e){return`outgoing`in e}e.isOutgoing=r;function i(e){return`inout`in e}e.isInOut=i;function a(e){return`where`in e&&(t(e.where.expr)||n(e.where.expr)||r(e.where.expr)||i(e.where.expr))}e.isWhere=a;function o(e){return`customRelation`in e}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.customRelation.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(K||={});let rn;(function(e){function t(e){return`where`in e}e.isWhere=t;function n(e){return K.isWhere(e)}e.isRelationWhere=n;function r(e){return G.isWhere(e)}e.isFqnExprWhere=r;function i(e){return G.is(e)||G.isWhere(e)||G.isCustom(e)}e.isFqnExpr=i;function a(e){return K.is(e)||K.isWhere(e)||K.isCustom(e)}e.isRelation=a})(rn||={});let q;(function(e){function t(e){return`wildcard`in e&&e.wildcard===!0}e.isWildcard=t;function n(e){return`ref`in e&&W.isModelRef(e.ref)}e.isModelRef=n;function r(e){return`elementKind`in e&&`isEqual`in e}e.isElementKindExpr=r;function i(e){return`elementTag`in e&&`isEqual`in e}e.isElementTagExpr=i;function a(e){return`where`in e&&s(e.where.expr)}e.isWhere=a;function o(e){return`custom`in e&&(s(e.custom.expr)||a(e.custom.expr))}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.custom.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(q||={});let J;(function(e){function t(e){return`source`in e&&`target`in e}e.isDirect=t;function n(e){return`incoming`in e}e.isIncoming=n;function r(e){return`outgoing`in e}e.isOutgoing=r;function i(e){return`inout`in e}e.isInOut=i;function a(e){return`where`in e&&(t(e.where.expr)||n(e.where.expr)||r(e.where.expr)||i(e.where.expr))}e.isWhere=a;function o(e){return`customRelation`in e}e.isCustom=o;function s(e){return t(e)||n(e)||r(e)||i(e)}e.is=s;function c(e){return o(e)&&(e=e.customRelation.expr),a(e)&&(e=e.where.expr),e}e.unwrap=c})(J||={});let an;(function(e){function t(e){return`where`in e}e.isWhere=t;function n(e){return J.isWhere(e)}e.isRelationWhere=n;function r(e){return q.isWhere(e)}e.isFqnExprWhere=r;function i(e){return q.is(e)||q.isWhere(e)||q.isCustom(e)}e.isFqnExpr=i;function a(e){return J.is(e)||J.isWhere(e)||J.isCustom(e)}e.isRelationExpr=a})(an||={});function on(e){return c(e.kind)&&!c(e.element)}function sn(e){return c(e.element)&&!c(e.kind)}const cn={fill:`#3b82f6`,stroke:`#2563eb`,hiContrast:`#eff6ff`,loContrast:`#bfdbfe`},ln={fill:`#0284c7`,stroke:`#0369a1`,hiContrast:`#f0f9ff`,loContrast:`#B6ECF7`},un={fill:`#64748b`,stroke:`#475569`,hiContrast:`#f8fafc`,loContrast:`#cbd5e1`},dn={primary:cn,blue:cn,secondary:ln,sky:ln,muted:un,slate:un,gray:{fill:`#737373`,stroke:`#525252`,hiContrast:`#fafafa`,loContrast:`#d4d4d4`},red:{fill:`#AC4D39`,stroke:`#853A2D`,hiContrast:`#FBD3CB`,loContrast:`#f5b2a3`},green:{fill:`#428a4f`,stroke:`#2d5d39`,hiContrast:`#f8fafc`,loContrast:`#c2f0c2`},amber:{fill:`#A35829`,stroke:`#7E451D`,hiContrast:`#FFE0C2`,loContrast:`#f9b27c`},indigo:{fill:`#6366f1`,stroke:`#4f46e5`,hiContrast:`#eef2ff`,loContrast:`#c7d2fe`}},fn={line:`#8D8D8D`,labelBg:`#18191B`,label:`#C9C9C9`},pn={line:`#64748b`,labelBg:`#0f172a`,label:`#cbd5e1`},mn={line:`#3b82f6`,labelBg:`#172554`,label:`#eff5fd`},hn={line:`#0ea5e9`,labelBg:`#082f49`,label:`#d4f2ff`},gn={amber:{line:`#b45309`,labelBg:`#78350f`,label:`#FFE0C2`},blue:mn,gray:fn,green:{line:`#15803d`,labelBg:`#052e16`,label:`#bbfcd3`},indigo:{line:`#6366f1`,labelBg:`#1e1b4b`,label:`#cbd0fd`},muted:pn,primary:mn,red:{line:`#AC4D39`,labelBg:`#b91c1c`,label:`#fcd9d2`},secondary:hn,sky:hn,slate:pn},_n={sizes:{xs:{width:180,height:100},sm:{width:240,height:135},md:{width:320,height:180},lg:{width:420,height:234},xl:{width:520,height:290}},spacing:{xs:8,sm:10,md:16,lg:24,xl:32},textSizes:{xs:13.33,sm:16,md:19.2,lg:23.04,xl:27.65},iconSizes:{xs:24,sm:36,md:60,lg:82,xl:90}},vn=[`xs`,`sm`,`md`,`lg`,`xl`],yn=[`left`,`right`,`top`,`bottom`],bn=[`solid`,`dashed`,`dotted`,`none`],xn=[`rectangle`,`person`,`browser`,`mobile`,`cylinder`,`storage`,`queue`,`bucket`,`document`,`component`],Sn=[`amber`,`blue`,`gray`,`slate`,`green`,`indigo`,`muted`,`primary`,`red`,`secondary`,`sky`],Cn=[`tomato`,`grass`,`blue`,`ruby`,`orange`,`indigo`,`pink`,`teal`,`purple`,`amber`,`crimson`,`red`,`lime`,`yellow`,`violet`],wn={tomato:Ie.tomato9,grass:je.grass9,blue:Pe.blue9,ruby:Oe.ruby9,orange:Re.orange9,indigo:Ee.indigo9,pink:De.pink9,teal:ke.teal9,purple:Me.purple9,amber:ze.amber9,crimson:Le.crimson9,red:Be.red9,lime:Fe.lime9,yellow:Ae.yellow9,violet:Ne.violet9};function Tn(e){return e in wn}const En={colors:Sn.reduce((e,t)=>(e[t]={elements:dn[t],relationships:gn[t]},e),{}),..._n};function Dn(e,t){return t=Math.max(-1,Math.min(1,t)),e.map(e=>{let n=t>0?e+(255-e)*t:e*(1+t);return Math.round(Math.max(0,Math.min(255,n)))})}function On(e,t){return p(Dn(p(e).rgb(),t)).hex()}function kn(e){return p.valid(e)}function An(e){m(p.valid(e),`Invalid color: ${e}`);let t=e.trim(),n=jn(t.startsWith(`#`)?t:p(t).hex());return{elements:{fill:n.el_main,stroke:n.el_secondary,hiContrast:n.el_hiContrast,loContrast:n.el_loContrast},relationships:{line:n.rel_secondary,label:n.rel_hiContrast,labelBg:n.rel_main}}}function jn(e){let t=e,n=p(t).darken(.8).hex(),r=Y(t),i=r.hiContrast,a=r.loContrast,o=t;return{el_main:t,el_secondary:n,el_hiContrast:i,el_loContrast:a,rel_main:o,rel_secondary:On(t,-.25),rel_hiContrast:Y(o).hiContrast}}function Y(e){let t=p(e),n=t.brighten(2),r=t.darken(2),i,a,o,s;do i=n,a=r,n=n.brighten(1),r=r.darken(1),o=p.contrastAPCA(t,n),s=p.contrastAPCA(t,r);while(Math.abs(o)<60&&Math.abs(s)<60&&(!d(n,i)||!d(r,a)));return Math.abs(o)>Math.abs(s)?{hiContrast:p(n.brighten(.4)).hex(),loContrast:n.hex()}:{hiContrast:p(r.darken(.4)).hex(),loContrast:r.hex()}}function Mn(e,t){let n=t??6,r=p(e.fill),i=p(e.stroke),a=r.luminance()>.8,o=re(ce(p.scale(a?[r.darken(.02).desaturate(.05),r.darken(.1).desaturate(.1)]:[r.shade(.12,`lch`).desaturate(.05),r.shade(.35,`lch`).desaturate(.4)]).mode(`oklch`).correctLightness().colors(n,null),p.scale(a?[i.darken(.04).desaturate(.05),i.darken(.12).desaturate(.1)]:[i.shade(.15,`lch`).desaturate(.08),i.shade(.4,`lch`).desaturate(.4)]).mode(`oklch`).correctLightness().colors(n,null)),te(([t,n])=>({...e,fill:t.hex(),stroke:n.hex()})));return m(o.length===n,`Expected ${n} colors, got ${o.length}`),o}const Nn={color:`primary`,size:`md`,opacity:15,shape:`rectangle`,group:{opacity:15,border:`dashed`},relationship:{color:`gray`,line:`dashed`,arrow:`normal`}},X=En,Z={theme:X,defaults:Nn};var Pn=class e{config;customCss;theme;defaults;static DEFAULT=new e(Z);static from(t,r){if(!t&&!r)return this.DEFAULT;let{customCss:i,theme:o,defaults:s}={...t},c=n({theme:o},{defaults:{...s}},{theme:{colors:{...r}}},Z);return a(i?.content)&&d(c,Z)?this.DEFAULT:new e(c,i)}constructor(e,t){this.config=e,this.customCss=t,this.theme=e.theme,this.defaults=e.defaults}get fingerprint(){return E(this,`fingerprint`,()=>D({config:this.config,customCss:this.customCss}))}get elementColors(){return this.theme.colors[this.defaults.color].elements}get relationshipColors(){return this.theme.colors[this.defaults.relationship.color].relationships}get groupColors(){let e=this.defaults.group?.color;if(!e)return this.elementColors;if(!this.isThemeColor(e))throw Error(`Default group color not found in theme: ${e}`);return E(this,`defaultGroup`,()=>({...this.elementColors,...this.theme.colors[e].elements}))}isDefaultColor(e){return e===this.defaults.color}colors(e){return this.computeFrom(e??this.defaults.color)}compoundColorsCache=new de.default(e=>new pe.default(t=>Mn(e,t)));colorsForCompounds(e,t){return this.compoundColorsCache.get(e).get(t??6)}fontSize(e){return e??=this.defaults.text??this.defaults.size,this.theme.textSizes[e]}padding(e){return e??=this.defaults.padding??this.defaults.size,this.theme.spacing[e]}iconSize(e){return e??=this.defaults.size,this.theme.iconSizes[e]}isThemeColor(e){return e in this.theme.colors}nodeSizes(e){let t=Fn(e,this.defaults.size);return{sizes:t,values:{sizes:this.theme.sizes[t.size],padding:this.padding(t.padding),textSize:this.fontSize(t.textSize),iconSize:this.iconSize(t.iconSize)}}}computeFrom(e){if(this.isThemeColor(e))return this.theme.colors[e];if(!p.valid(e))throw Error(`Invalid color value: "${e}" (not a theme color and not a valid CSS color)`);return An(e)}equals(e){return e===this?!0:this.constructor===e.constructor?this.fingerprint===e.fingerprint:!1}tagColor(e){return this.isThemeColor(e)?this.theme.colors[e].elements:Tn(e)?this.computeFrom(wn[e]).elements:this.computeFrom(e).elements}};function Fn({size:e,padding:t,textSize:n,iconSize:r,...i},a=Z.defaults.size){return e??=a,n??=e,t??=e,r??=e,{...i,size:e,padding:t,textSize:n,iconSize:r}}function In(e){let t=typeof e==`string`?e:e.color;return t.startsWith(`#`)||t.startsWith(`rgb`)}function Ln(e){return`tag`in e}function Rn(e){return`kind`in e}function zn(e){return`metadata`in e}function Bn(e){return`participant`in e}function Vn(e){return`not`in e}function Hn(e){return`and`in e}function Un(e){return`or`in e}function Q(e){switch(!0){case Bn(e):{let t=e.participant;return Wn(t,Q(e.operator))}case Ln(e):{if(f(e.tag)||`eq`in e.tag){let t=f(e.tag)?e.tag:e.tag.eq;return e=>Array.isArray(e.tags)&&e.tags.includes(t)}let t=e.tag.neq;return e=>!Array.isArray(e.tags)||!e.tags.includes(t)}case Rn(e):{if(f(e.kind)||`eq`in e.kind){let t=f(e.kind)?e.kind:e.kind.eq;return e=>e.kind===t}let t=e.kind.neq;return e=>o(e.kind)||e.kind!==t}case zn(e):{let{key:t,value:n}=e.metadata;if(n===void 0)return e=>e.metadata!=null&&t in e.metadata&&e.metadata[t]!=null;if(f(n)||`eq`in n){let e=f(n)?n:n.eq;return n=>{if(!n.metadata)return!1;let r=n.metadata[t];return Array.isArray(r)?r.includes(e):r===e}}let r=n.neq;return e=>{if(!e.metadata)return!0;let n=e.metadata[t];return n==null?!0:Array.isArray(n)?!n.includes(r):n!==r}}case Vn(e):return s(Q(e.not));case Hn(e):return ae(e.and.map(Q));case Un(e):return se(e.or.map(Q));default:h(e)}}function Wn(e,t){return n=>{if(!n.source||!n.target)return!1;switch(e){case`source`:return t(n.source);case`target`:return t(n.target)}}}function Gn(e){return`include`in e||`exclude`in e}function Kn(e){return`targets`in e&&`style`in e}function qn(e){return e._stage===`computed`}function Jn(e){return e._stage===`layouted`}function $(e){return e._type===`element`}function Yn(e){return $(e)&&c(e.viewOf)}function Xn(e){return $(e)&&c(e.extends)}function Zn(e){return e._type===`deployment`}function Qn(e){return e._type===`dynamic`}function $n(e){return`styleId`in e}function er(e){return`predicateId`in e}function tr(e){return e===`TB`||e===`BT`||e===`LR`||e===`RL`}function nr(e){return`direction`in e}function rr(e){return U(e)&&e.includes(`.`)?e.slice(0,e.indexOf(`.`)+1):null}function ir(e){return!!e&&!(`__series`in e||`__parallel`in e)}function ar(e){return!!e&&`__parallel`in e&&r(e.__parallel)}function or(e){return!!e&&`__series`in e&&r(e.__series)}function sr(e){return`title`in e&&`groupRules`in e&&Array.isArray(e.groupRules)}function cr(e){return`rank`in e&&Array.isArray(e.targets)}const lr=Symbol.for(`text`),ur=Symbol.for(`html`);var dr=class e{static mdcache=new ue.default(500);static txtcache=new ue.default(500);static getOrCreateFromText(t){if(t=t.trimEnd(),t===``)return e.EMPTY;let n=e.txtcache.get(t);return n||(n=new e({txt:t}),e.txtcache.set(t,n),n)}static getOrCreateFromMarkdown(t){if(t=t.trimEnd(),t===``)return e.EMPTY;let n=e.mdcache.get(t);return n||(n=new e({md:t}),e.mdcache.set(t,n),n)}static memoize(t,n,r){return E(t,n,()=>e.from(r))}static from(t){return t==null||t===e.EMPTY?e.EMPTY:t instanceof e?t:typeof t==`string`?this.getOrCreateFromText(t):`isEmpty`in t&&t.isEmpty?e.EMPTY:`md`in t?this.getOrCreateFromMarkdown(t.md):this.getOrCreateFromText(t.txt)}static EMPTY=new class extends e{isEmpty=!0;nonEmpty=!1;isMarkdown=!1;$source=null;constructor(){super({txt:``})}get text(){return null}get md(){return null}get html(){return null}};$source;isEmpty;nonEmpty;isMarkdown;constructor(e){this.isMarkdown=!1,typeof e==`string`?(this.$source={txt:e},this.isEmpty=e.trim()===``):(this.$source=e,this.isEmpty=!0,`md`in e?(this.isEmpty=e.md===``,this.isMarkdown=!0):this.isEmpty=e.txt===``),this.nonEmpty=!this.isEmpty}get text(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;return`txt`in e?e.txt:E(this,lr,()=>k(e.md))}get md(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;if(`md`in e)return e.md;if(`txt`in e)return e.txt;h(e)}get html(){if(this.isEmpty||this.$source===null)return``;let e=this.$source;return`txt`in e?e.txt:E(this,ur,()=>O(e.md))}equals(t){return this===t?!0:t instanceof e?this.isEmpty&&t.isEmpty?!0:this.isEmpty!==t.isEmpty||this.isMarkdown!==t.isMarkdown?!1:this.isMarkdown?this.$source?.md===t.$source?.md:this.$source?.txt===t.$source?.txt:!1}};export{$t as $,ft as $t,Fn as A,He as An,zt as At,yn as B,Ot as Bt,zn as C,Je as Cn,Gt as Ct,Ln as D,Ge as Dn,Ht as Dt,Bn as E,h as En,O as Et,Y as F,Nt as Ft,an as G,Ct as Gt,Sn as H,Dt as Ht,kn as I,At as It,rn as J,vt as Jt,q as K,xt as Kt,bn as L,Mt as Lt,X as M,Lt as Mt,Nn as N,Bt as Nt,Q as O,We as On,D as Ot,An as P,It as Pt,z as Q,mt as Qt,Cn as R,jt as Rt,Rn as S,qe as Sn,A as St,Un as T,Ke as Tn,k as Tt,sn as U,Tt as Ut,vn as V,Et as Vt,on as W,wt as Wt,K as X,gt as Xt,G as Y,_t as Yt,W as Z,ht as Zt,Xn as _,ot as _n,en as _t,ir as a,C as an,F as at,Kn as b,Xe as bn,qt as bt,tr as c,tt as cn,tn as ct,$n as d,et as dn,P as dt,pt as en,I as et,qn as f,x as fn,Xt as ft,$ as g,st as gn,Zt as gt,Qn as h,it as hn,Yt as ht,rr as i,nt as in,Qt as it,Pn as j,Ve as jn,Vt as jt,In as k,Ue as kn,Rt as kt,nr as l,S as ln,B as lt,Jn as m,Qe as mn,U as mt,sr as n,T as nn,L as nt,ar as o,rt as on,M as ot,Zn as p,$e as pn,R as pt,J as q,bt as qt,cr as r,ct as rn,N as rt,or as s,w as sn,V as st,dr as t,lt as tn,H as tt,er as u,b as un,nn as ut,Yn as v,_ as vn,Jt as vt,Vn as w,m as wn,Wt as wt,Hn as x,Ye as xn,Kt as xt,Gn as y,Ze as yn,j as yt,xn as z,E as zt};
|
package/dist/builder/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"../_chunks/libs/defu.mjs";import{B as t,C as n,F as r,M as i,Q as a,T as o,U as s,W as c,X as l,Y as u,et as d,k as f,w as p}from"../_chunks/libs/remeda.mjs";import{Sn as m,V as h,W as g,Y as _,_t as v,dn as y,fn as b,g as x,kn as S,mt as C,un as w,ut as T,vt as E}from"../_chunks/types.mjs";import{t as D}from"../_chunks/libs/mnemonist.mjs";import"../_chunks/model.mjs";import{n as O,t as k}from"../_chunks/Builder.view-element.mjs";import{t as A}from"../_chunks/assignTagColors.mjs";function j(e){if(f(e)){let t=e;switch(!0){case t.startsWith(`tag is not #`):return{tag:{neq:t.replace(`tag is not #`,``)}};case t.startsWith(`tag is #`):return{tag:{eq:t.replace(`tag is #`,``)}};case t.startsWith(`kind is not `):return{kind:{neq:t.replace(`kind is not `,``)}};case t.startsWith(`kind is `):return{kind:{eq:t.replace(`kind is `,``)}};case t.startsWith(`source.`):return{operator:j(t.replace(`source.`,``)),participant:`source`};case t.startsWith(`target.`):return{operator:j(t.replace(`target.`,``)),participant:`target`};default:throw Error(`Unknown where operator: ${e}`)}}if(e.and)return{and:o(e.and,j)};if(e.or)return{or:o(e.or,j)};if(e.not)return{not:j(e.not)};throw Error(`Unknown where operator: ${e}`)}function M(...e){return t=>{if(e.length===2&&typeof e[1]!=`string`&&(`where`in e[1]||`with`in e[1])){let n=t.$expr(e[0]),r=e[1].where?j(e[1].where):void 0;r&&(n={where:{expr:n,condition:r}});let i=e[1].with;return i&&(n=g.is(n)?{custom:{...i,expr:n}}:{customRelation:{...i,expr:n}}),t.include(n),t}return t.include(...e.map(e=>t.$expr(e))),t}}function N(...e){return t=>{let n=t.$expr(e[0]);if(e.length===2&&e[1].where){let t=j(e[1].where);n={where:{expr:n,condition:t}}}return t.exclude(n),t}}function P(e,{notation:n,...r}){return i=>i.style({targets:(t(e)?e:[e]).map(e=>i.$expr(e)),...n?{notation:n}:{},style:{...r}})}function F(e,t){return n=>n.autoLayout(e,t)}function I(...e){return t=>e.reduce((e,t)=>t(e),t)}function L(e){if(!f(e))return e;let t=e=>e;if(e===`*`)return t({wildcard:!0});if(e.startsWith(`->`))return e.endsWith(`->`)?t({inout:L(e.replace(/->/g,``).trim())}):t({incoming:L(e.replace(`-> `,``))});if(e.endsWith(` ->`))return t({outgoing:L(e.replace(` ->`,``))});if(e.includes(` <-> `)){let[n,r]=e.split(` <-> `);return t({source:L(n),target:L(r),isBidirectional:!0})}if(e.includes(` -> `)){let[n,r]=e.split(` -> `);return t({source:L(n),target:L(r)})}return e.endsWith(`._`)?t({ref:{deployment:e.replace(`._`,``)},selector:`expanded`}):e.endsWith(`.**`)?t({ref:{deployment:e.replace(`.**`,``)},selector:`descendants`}):e.endsWith(`.*`)?t({ref:{deployment:e.replace(`.*`,``)},selector:`children`}):t({ref:{deployment:e}})}function R(e){return t=>t.includeAncestors(e)}function z(e){let t={$expr:e._type===`deployment`?L:k,autoLayout(t,n){return e.rules.push(S({direction:t,rankSep:n?.rank,nodeSep:n?.node})),this},exclude(...t){return e.rules.push({exclude:t}),this},include(...t){return e.rules.push({include:t}),this},style(t){return e.rules.push(t),this},get Expr(){throw Error(`Expr is not available in runtime`)},get Types(){throw Error(`Types are not available in runtime`)},get ElementExpr(){throw Error(`ElementExpr is not available in runtime`)},get TypedExpr(){throw Error(`TypedExpr is not available in runtime`)}};return e._type===`deployment`?Object.assign(t,{includeAncestors(t){return e.rules.push({includeAncestors:t}),this}}):t}function B(e){return t(e)?s(e,e=>({})):e}function V({tags:e,elements:t,deployments:n,relationships:r,...i}){let a={};e&&Object.assign(a,B(e));let o=B(t);for(let[e,t]of l(o))if(t.tags)for(let n of t.tags)m(n in a,`Invalid specification for element kind "${e}": tag "${n}" not found`);let s=B(n??{});for(let[e,t]of l(s))if(t.tags)for(let n of t.tags)m(n in a,`Invalid specification for deployment kind "${e}": tag "${n}" not found`);return{...i,tags:a,elements:o,deployments:s,relationships:B(r??{})}}function H(e){return i(e)?null:typeof e==`string`?{txt:e}:e}function U(t,s=new Map,l=[],f=new Map,g={predicates:{},dynamicPredicates:{},styles:{}},k=new Map,j=[],L=new D.default(()=>new Map)){let B=V(t),W=()=>({elements:structuredClone(B.elements),deployments:structuredClone(B.deployments),relationships:structuredClone(B.relationships),tags:A(structuredClone(B.tags)),...B.metadataKeys?{metadataKeys:B.metadataKeys}:{},customColors:{}}),G=e=>{if(!(!e||!a(e,1)))return o(e,e=>typeof e==`string`?{url:e}:e)},K=(e,t,n)=>{r(t)&&(n=t,t={}),t??={};let{links:i=[],title:a=null,description:o=null,tags:s=[],...c}=typeof t==`string`?{title:t}:{...t},l=G(i);return[S({id:e,title:a,description:H(o),tags:s,links:l,_stage:`parsed`,...c}),n]},q=e=>{let[t,n]=C(e),r=(t?L.get(t):s).get(n);return m(r,`Element with id "${e}" not found`),r},J=e=>{if(typeof e==`string`){let[t,n]=C(e);return t?{project:t,model:n}:{model:n}}return`project`in e||`deployment`in e?e:J(e.model)},Y={get Types(){throw Error(`Types are not available in runtime`)},clone:()=>{let e=new D.default(()=>new Map);for(let[t,n]of L)e.set(t,structuredClone(n));return U(structuredClone(B),structuredClone(s),structuredClone(l),structuredClone(f),structuredClone(g),structuredClone(k),structuredClone(j),e)},__addElement:e=>{let[t,n]=C(e.id),r=b(n),i=t?L.get(t):s;if(r&&m(i.get(r),`Parent element with id "${r}" not found for element with id "${e.id}"`),i.has(n))throw Error(`Element with id "${e.id}" already exists`);return i.set(n,t?{...e,id:n}:e),Y},__addRelation(e){let t=J(e.source),n=_.flatten(t),r=J(e.target),i=_.flatten(r),a=q(n),o=q(i);if(T(n)&&T(i))throw Error(`Cannot create relationship between global elements`);return!T(n)&&!T(i)&&m(!w(a,o),`Cannot create relationship between elements in the same hierarchy`),l.push({id:`rel${l.length+1}`,...e,source:t,target:r}),Y},__fqn(e){return m(e.trim()!==``,`Id must be non-empty`),e},__deploymentFqn(e){return m(e.trim()!==``,`Id must be non-empty`),e},__addSourcelessRelation(){throw Error(`Can be called only in nested model`)},__addView:e=>{if(f.has(e.id))throw Error(`View with id "${e.id}" already exists`);return x(e)&&`viewOf`in e&&m(s.get(e.viewOf),`Invalid scoped view ${e.id}, wlement with id "${e.viewOf}" not found`),f.set(e.id,e),Y},__addDeployment:e=>{if(k.has(e.id))throw Error(`Deployment with id "${e.id}" already exists`);let t=b(e.id);return t&&m(k.get(t),`Parent element with id "${t}" not found for node with id "${e.id}"`),h(e)&&(m(t,`Instance ${e.id} of ${e.element} must be deployed under a parent node`),m(s.get(e.element),`Instance "${e.id}" references non-existing element "${e.element}"`)),k.set(e.id,e),Y},__addDeploymentRelation:e=>(m(!w(e.source.deployment,e.target.deployment),`Cannot create relationship between elements in the same hierarchy`),m(k.has(e.source.deployment),`Relation "${e.source.deployment} -> ${e.target.deployment}" references non-existing source`),m(k.has(e.target.deployment),`Relation "${e.source.deployment} -> ${e.target.deployment}" references non-existing target`),j.push({id:`deploy_rel${j.length+1}`,...e}),Y),build:e=>({[v]:`parsed`,projectId:typeof e==`string`?e:e?.id??`from-builder`,project:{id:typeof e==`string`?e:`from-builder`,...typeof e==`object`&&e?e:{}},specification:W(),elements:c(structuredClone(Array.from(s.entries()))),relations:p(l,e=>[e.id,structuredClone(e)]),globals:structuredClone(g),deployments:{elements:c(structuredClone(Array.from(k.entries()))),relations:p(j,e=>[e.id,structuredClone(e)])},views:c(structuredClone(Array.from(f.entries()))),imports:d(Array.from(L.entries()),o(([e,t])=>[e,structuredClone([...t.values()])]),u(([e,t])=>t.length>0),c())}),toLikeC4Model:e=>O(Y.build(e)),helpers:()=>({model:{model:(...e)=>t=>e.reduce((e,t)=>t(e),t),rel:(t,n,r)=>i=>{let{title:a=``,links:o=[],description:s=null,notes:c=null,...l}=e(typeof r==`string`?{title:r}:{...r},{title:null,links:null}),u=G(o);return i.__addRelation(S({source:{model:t},target:{model:n},title:a,...s&&{description:H(s)},...c&&{notes:H(c)},links:u,...l})),i},relTo:(t,n)=>r=>{let{title:i=``,links:a,description:o=null,notes:s=null,...c}=e(typeof n==`string`?{title:n}:{...n},{title:null,links:null});return r.__addSourcelessRelation(S({target:{model:t},title:i,...o&&{description:H(o)},...s&&{notes:H(s)},links:G(a),...c})),r},...n(B.elements,({style:e,...t},n)=>(r,i)=>{let a=(a=>{let{links:o,icon:s,color:c,shape:l,style:u,title:d,description:f,summary:p,...m}=typeof i==`string`?{title:i}:{...i},h=s??e?.icon,g=G(o),_=a.__fqn(r);return a.__addElement(S({id:_,kind:n,...t,title:d??t.title??y(_),...f&&{description:H(f)},...p&&{summary:H(p)},style:S({icon:h,color:c??e?.color,shape:l??e?.shape,border:e?.border,opacity:e?.opacity,size:e?.size,padding:e?.padding,textSize:e?.textSize,...u}),...g&&{links:g},...m})),a});return a.with=(...e)=>t=>{a(t);let{__fqn:n,__addSourcelessRelation:i}=t;try{t.__fqn=e=>`${n(r)}.${e}`,t.__addSourcelessRelation=e=>t.__addRelation({...e,source:{model:n(r)}}),e.reduce((e,t)=>t(e),t)}finally{t.__fqn=n,t.__addSourcelessRelation=i}return t},a})},views:{views:(...e)=>t=>e.reduce((e,t)=>t(e),t),view:(e,t,n)=>{let[r,i]=K(e,t,n),a={...r,[E]:`element`,rules:[]},o=e=>(e.__addView(a),i&&i(z(a)),e);return o.with=(...e)=>t=>{o(t);let n=z(a);for(let t of e)t(n);return t},o},viewOf:(e,t,n,r)=>{let[i,a]=K(e,n,r),o={...i,viewOf:t,[E]:`element`,rules:[]},s=e=>(e.__addView(o),a&&a(z(o)),e);return s.with=(...e)=>t=>{s(t);let n=z(o);for(let t of e)t(n);return t},s},deploymentView:(e,t,n)=>{let[r,i]=K(e,t,n),a={...r,[E]:`deployment`,rules:[]},o=e=>(e.__addView(a),i&&i(z(a)),e);return o.with=(...e)=>t=>{o(t);let n=z(a);for(let t of e)t(n);return t},o},$autoLayout:F,$exclude:N,$include:M,$rules:I,$style:P,$includeAncestors:R},deployment:{deployment:(...e)=>t=>e.reduce((e,t)=>t(e),t),instanceOf:(e,t,n)=>r=>{i(t)?(t=e,e=y(e)):typeof t==`string`?n??={}:(n=t,t=e,e=y(e));let{links:a,title:o,description:s,summary:c,icon:l,color:u,shape:d,style:f,...p}=typeof n==`string`?{title:n}:{...n},m=r.__deploymentFqn(e);return r.__addDeployment(S({id:m,element:t,...o&&{title:o},...c&&{summary:H(c)},...s&&{description:H(s)},style:S({icon:l,color:u,shape:d,...f}),links:G(a),...p})),r},rel:(e,t,n)=>r=>{let{title:i=null,links:a,description:o=null,notes:s=null,...c}=typeof n==`string`?{title:n}:{...n};return r.__addDeploymentRelation(S({source:{deployment:e},target:{deployment:t},title:i,...o&&{description:H(o)},...s&&{notes:H(s)},links:G(a),...c})),r},...n(B.deployments??{},({style:e,...t},n)=>(r,i)=>{let a=(a=>{let{links:o,icon:s,style:c,title:l,description:u,summary:d,color:f,shape:p,...m}=typeof i==`string`?{title:i}:{...i},h=s??e?.icon,g=G(o),_=a.__deploymentFqn(r);return a.__addDeployment(S({id:_,kind:n,...t,title:l??t.title??y(_),...u&&{description:H(u)},...d&&{summary:H(d)},style:S({icon:h,color:f??e?.color,shape:p??e?.shape,border:e?.border,opacity:e?.opacity,size:e?.size,padding:e?.padding,textSize:e?.textSize,...c}),...g&&{links:g},...m})),a});return a.with=(...e)=>t=>{a(t);let{__deploymentFqn:n}=t;try{t.__deploymentFqn=e=>`${n(r)}.${e}`,e.reduce((e,t)=>t(e),t)}finally{t.__deploymentFqn=n}return t},a})}}),with:(...e)=>{let t=Y.clone();return e.reduce((e,t)=>t(e),t)},model:e=>{let t=Y.clone(),n=t.helpers().model,r=n.model;return e({...n,_:r},r)(t)},deployment:e=>{let t=Y.clone(),n=t.helpers().deployment,r=n.deployment;return e({...n,_:r},r)(t)},views:e=>{let t=Y.clone(),n=t.helpers().views;return e({...n,_:n.views},n.views)(t)}};return Y}const W={forSpecification(e){let t=U(e);return{...t.helpers(),builder:t}},specification(e){return U(e)}};export{W as Builder};
|
|
1
|
+
import{t as e}from"../_chunks/libs/defu.mjs";import{B as t,C as n,F as r,M as i,Q as a,T as o,U as s,W as c,X as l,Y as u,et as d,k as f,w as p}from"../_chunks/libs/remeda.mjs";import{K as m,U as h,Z as g,bt as _,fn as v,ft as y,g as b,gt as x,jn as S,mn as C,pn as w,wn as T,yt as E}from"../_chunks/types.mjs";import{t as D}from"../_chunks/libs/mnemonist.mjs";import"../_chunks/model.mjs";import{n as O,t as k}from"../_chunks/Builder.view-element.mjs";import{t as A}from"../_chunks/assignTagColors.mjs";function j(e){if(f(e)){let t=e;switch(!0){case t.startsWith(`tag is not #`):return{tag:{neq:t.replace(`tag is not #`,``)}};case t.startsWith(`tag is #`):return{tag:{eq:t.replace(`tag is #`,``)}};case t.startsWith(`kind is not `):return{kind:{neq:t.replace(`kind is not `,``)}};case t.startsWith(`kind is `):return{kind:{eq:t.replace(`kind is `,``)}};case t.startsWith(`source.`):return{operator:j(t.replace(`source.`,``)),participant:`source`};case t.startsWith(`target.`):return{operator:j(t.replace(`target.`,``)),participant:`target`};default:throw Error(`Unknown where operator: ${e}`)}}if(e.and)return{and:o(e.and,j)};if(e.or)return{or:o(e.or,j)};if(e.not)return{not:j(e.not)};throw Error(`Unknown where operator: ${e}`)}function M(...e){return t=>{if(e.length===2&&typeof e[1]!=`string`&&(`where`in e[1]||`with`in e[1])){let n=t.$expr(e[0]),r=e[1].where?j(e[1].where):void 0;r&&(n={where:{expr:n,condition:r}});let i=e[1].with;return i&&(n=m.is(n)?{custom:{...i,expr:n}}:{customRelation:{...i,expr:n}}),t.include(n),t}return t.include(...e.map(e=>t.$expr(e))),t}}function N(...e){return t=>{let n=t.$expr(e[0]);if(e.length===2&&e[1].where){let t=j(e[1].where);n={where:{expr:n,condition:t}}}return t.exclude(n),t}}function P(e,{notation:n,...r}){return i=>i.style({targets:(t(e)?e:[e]).map(e=>i.$expr(e)),...n?{notation:n}:{},style:{...r}})}function F(e,t){return n=>n.autoLayout(e,t)}function I(...e){return t=>e.reduce((e,t)=>t(e),t)}function L(e){if(!f(e))return e;let t=e=>e;if(e===`*`)return t({wildcard:!0});if(e.startsWith(`->`))return e.endsWith(`->`)?t({inout:L(e.replace(/->/g,``).trim())}):t({incoming:L(e.replace(`-> `,``))});if(e.endsWith(` ->`))return t({outgoing:L(e.replace(` ->`,``))});if(e.includes(` <-> `)){let[n,r]=e.split(` <-> `);return t({source:L(n),target:L(r),isBidirectional:!0})}if(e.includes(` -> `)){let[n,r]=e.split(` -> `);return t({source:L(n),target:L(r)})}return e.endsWith(`._`)?t({ref:{deployment:e.replace(`._`,``)},selector:`expanded`}):e.endsWith(`.**`)?t({ref:{deployment:e.replace(`.**`,``)},selector:`descendants`}):e.endsWith(`.*`)?t({ref:{deployment:e.replace(`.*`,``)},selector:`children`}):t({ref:{deployment:e}})}function R(e){return t=>t.includeAncestors(e)}function z(e){let t={$expr:e._type===`deployment`?L:k,autoLayout(t,n){return e.rules.push(S({direction:t,rankSep:n?.rank,nodeSep:n?.node})),this},exclude(...t){return e.rules.push({exclude:t}),this},include(...t){return e.rules.push({include:t}),this},style(t){return e.rules.push(t),this},get Expr(){throw Error(`Expr is not available in runtime`)},get Types(){throw Error(`Types are not available in runtime`)},get ElementExpr(){throw Error(`ElementExpr is not available in runtime`)},get TypedExpr(){throw Error(`TypedExpr is not available in runtime`)}};return e._type===`deployment`?Object.assign(t,{includeAncestors(t){return e.rules.push({includeAncestors:t}),this}}):t}function B(e){return t(e)?s(e,e=>({})):e}function V({tags:e,elements:t,deployments:n,relationships:r,...i}){let a={};e&&Object.assign(a,B(e));let o=B(t);for(let[e,t]of l(o))if(t.tags)for(let n of t.tags)T(n in a,`Invalid specification for element kind "${e}": tag "${n}" not found`);let s=B(n??{});for(let[e,t]of l(s))if(t.tags)for(let n of t.tags)T(n in a,`Invalid specification for deployment kind "${e}": tag "${n}" not found`);return{...i,tags:a,elements:o,deployments:s,relationships:B(r??{})}}function H(e){return i(e)?null:typeof e==`string`?{txt:e}:e}function U(t,s=new Map,l=[],f=new Map,m={predicates:{},dynamicPredicates:{},styles:{}},k=new Map,j=[],L=new D.default(()=>new Map)){let B=V(t),W=()=>({elements:structuredClone(B.elements),deployments:structuredClone(B.deployments),relationships:structuredClone(B.relationships),tags:A(structuredClone(B.tags)),...B.metadataKeys?{metadataKeys:B.metadataKeys}:{},customColors:{}}),G=e=>{if(!(!e||!a(e,1)))return o(e,e=>typeof e==`string`?{url:e}:e)},K=(e,t,n)=>{r(t)&&(n=t,t={}),t??={};let{links:i=[],title:a=null,description:o=null,tags:s=[],...c}=typeof t==`string`?{title:t}:{...t},l=G(i);return[S({id:e,title:a,description:H(o),tags:s,links:l,_stage:`parsed`,...c}),n]},q=e=>{let[t,n]=x(e),r=(t?L.get(t):s).get(n);return T(r,`Element with id "${e}" not found`),r},J=e=>{if(typeof e==`string`){let[t,n]=x(e);return t?{project:t,model:n}:{model:n}}return`project`in e||`deployment`in e?e:J(e.model)},Y={get Types(){throw Error(`Types are not available in runtime`)},clone:()=>{let e=new D.default(()=>new Map);for(let[t,n]of L)e.set(t,structuredClone(n));return U(structuredClone(B),structuredClone(s),structuredClone(l),structuredClone(f),structuredClone(m),structuredClone(k),structuredClone(j),e)},__addElement:e=>{let[t,n]=x(e.id),r=C(n),i=t?L.get(t):s;if(r&&T(i.get(r),`Parent element with id "${r}" not found for element with id "${e.id}"`),i.has(n))throw Error(`Element with id "${e.id}" already exists`);return i.set(n,t?{...e,id:n}:e),Y},__addRelation(e){let t=J(e.source),n=g.flatten(t),r=J(e.target),i=g.flatten(r),a=q(n),o=q(i);if(y(n)&&y(i))throw Error(`Cannot create relationship between global elements`);return!y(n)&&!y(i)&&T(!v(a,o),`Cannot create relationship between elements in the same hierarchy`),l.push({id:`rel${l.length+1}`,...e,source:t,target:r}),Y},__fqn(e){return T(e.trim()!==``,`Id must be non-empty`),e},__deploymentFqn(e){return T(e.trim()!==``,`Id must be non-empty`),e},__addSourcelessRelation(){throw Error(`Can be called only in nested model`)},__addView:e=>{if(f.has(e.id))throw Error(`View with id "${e.id}" already exists`);return b(e)&&`viewOf`in e&&T(s.get(e.viewOf),`Invalid scoped view ${e.id}, wlement with id "${e.viewOf}" not found`),f.set(e.id,e),Y},__addDeployment:e=>{if(k.has(e.id))throw Error(`Deployment with id "${e.id}" already exists`);let t=C(e.id);return t&&T(k.get(t),`Parent element with id "${t}" not found for node with id "${e.id}"`),h(e)&&(T(t,`Instance ${e.id} of ${e.element} must be deployed under a parent node`),T(s.get(e.element),`Instance "${e.id}" references non-existing element "${e.element}"`)),k.set(e.id,e),Y},__addDeploymentRelation:e=>(T(!v(e.source.deployment,e.target.deployment),`Cannot create relationship between elements in the same hierarchy`),T(k.has(e.source.deployment),`Relation "${e.source.deployment} -> ${e.target.deployment}" references non-existing source`),T(k.has(e.target.deployment),`Relation "${e.source.deployment} -> ${e.target.deployment}" references non-existing target`),j.push({id:`deploy_rel${j.length+1}`,...e}),Y),build:e=>({[E]:`parsed`,projectId:typeof e==`string`?e:e?.id??`from-builder`,project:{id:typeof e==`string`?e:`from-builder`,...typeof e==`object`&&e?e:{}},specification:W(),elements:c(structuredClone(Array.from(s.entries()))),relations:p(l,e=>[e.id,structuredClone(e)]),globals:structuredClone(m),deployments:{elements:c(structuredClone(Array.from(k.entries()))),relations:p(j,e=>[e.id,structuredClone(e)])},views:c(structuredClone(Array.from(f.entries()))),imports:d(Array.from(L.entries()),o(([e,t])=>[e,structuredClone([...t.values()])]),u(([e,t])=>t.length>0),c())}),toLikeC4Model:e=>O(Y.build(e)),helpers:()=>({model:{model:(...e)=>t=>e.reduce((e,t)=>t(e),t),rel:(t,n,r)=>i=>{let{title:a=``,links:o=[],description:s=null,notes:c=null,...l}=e(typeof r==`string`?{title:r}:{...r},{title:null,links:null}),u=G(o);return i.__addRelation(S({source:{model:t},target:{model:n},title:a,...s&&{description:H(s)},...c&&{notes:H(c)},links:u,...l})),i},relTo:(t,n)=>r=>{let{title:i=``,links:a,description:o=null,notes:s=null,...c}=e(typeof n==`string`?{title:n}:{...n},{title:null,links:null});return r.__addSourcelessRelation(S({target:{model:t},title:i,...o&&{description:H(o)},...s&&{notes:H(s)},links:G(a),...c})),r},...n(B.elements,({style:e,...t},n)=>(r,i)=>{let a=(a=>{let{links:o,icon:s,color:c,shape:l,style:u,title:d,description:f,summary:p,...m}=typeof i==`string`?{title:i}:{...i},h=s??e?.icon,g=G(o),_=a.__fqn(r);return a.__addElement(S({id:_,kind:n,...t,title:d??t.title??w(_),...f&&{description:H(f)},...p&&{summary:H(p)},style:S({icon:h,color:c??e?.color,shape:l??e?.shape,border:e?.border,opacity:e?.opacity,size:e?.size,padding:e?.padding,textSize:e?.textSize,...u}),...g&&{links:g},...m})),a});return a.with=(...e)=>t=>{a(t);let{__fqn:n,__addSourcelessRelation:i}=t;try{t.__fqn=e=>`${n(r)}.${e}`,t.__addSourcelessRelation=e=>t.__addRelation({...e,source:{model:n(r)}}),e.reduce((e,t)=>t(e),t)}finally{t.__fqn=n,t.__addSourcelessRelation=i}return t},a})},views:{views:(...e)=>t=>e.reduce((e,t)=>t(e),t),view:(e,t,n)=>{let[r,i]=K(e,t,n),a={...r,[_]:`element`,rules:[]},o=e=>(e.__addView(a),i&&i(z(a)),e);return o.with=(...e)=>t=>{o(t);let n=z(a);for(let t of e)t(n);return t},o},viewOf:(e,t,n,r)=>{let[i,a]=K(e,n,r),o={...i,viewOf:t,[_]:`element`,rules:[]},s=e=>(e.__addView(o),a&&a(z(o)),e);return s.with=(...e)=>t=>{s(t);let n=z(o);for(let t of e)t(n);return t},s},deploymentView:(e,t,n)=>{let[r,i]=K(e,t,n),a={...r,[_]:`deployment`,rules:[]},o=e=>(e.__addView(a),i&&i(z(a)),e);return o.with=(...e)=>t=>{o(t);let n=z(a);for(let t of e)t(n);return t},o},$autoLayout:F,$exclude:N,$include:M,$rules:I,$style:P,$includeAncestors:R},deployment:{deployment:(...e)=>t=>e.reduce((e,t)=>t(e),t),instanceOf:(e,t,n)=>r=>{i(t)?(t=e,e=w(e)):typeof t==`string`?n??={}:(n=t,t=e,e=w(e));let{links:a,title:o,description:s,summary:c,icon:l,color:u,shape:d,style:f,...p}=typeof n==`string`?{title:n}:{...n},m=r.__deploymentFqn(e);return r.__addDeployment(S({id:m,element:t,...o&&{title:o},...c&&{summary:H(c)},...s&&{description:H(s)},style:S({icon:l,color:u,shape:d,...f}),links:G(a),...p})),r},rel:(e,t,n)=>r=>{let{title:i=null,links:a,description:o=null,notes:s=null,...c}=typeof n==`string`?{title:n}:{...n};return r.__addDeploymentRelation(S({source:{deployment:e},target:{deployment:t},title:i,...o&&{description:H(o)},...s&&{notes:H(s)},links:G(a),...c})),r},...n(B.deployments??{},({style:e,...t},n)=>(r,i)=>{let a=(a=>{let{links:o,icon:s,style:c,title:l,description:u,summary:d,color:f,shape:p,...m}=typeof i==`string`?{title:i}:{...i},h=s??e?.icon,g=G(o),_=a.__deploymentFqn(r);return a.__addDeployment(S({id:_,kind:n,...t,title:l??t.title??w(_),...u&&{description:H(u)},...d&&{summary:H(d)},style:S({icon:h,color:f??e?.color,shape:p??e?.shape,border:e?.border,opacity:e?.opacity,size:e?.size,padding:e?.padding,textSize:e?.textSize,...c}),...g&&{links:g},...m})),a});return a.with=(...e)=>t=>{a(t);let{__deploymentFqn:n}=t;try{t.__deploymentFqn=e=>`${n(r)}.${e}`,e.reduce((e,t)=>t(e),t)}finally{t.__deploymentFqn=n}return t},a})}}),with:(...e)=>{let t=Y.clone();return e.reduce((e,t)=>t(e),t)},model:e=>{let t=Y.clone(),n=t.helpers().model,r=n.model;return e({...n,_:r},r)(t)},deployment:e=>{let t=Y.clone(),n=t.helpers().deployment,r=n.deployment;return e({...n,_:r},r)(t)},views:e=>{let t=Y.clone(),n=t.helpers().views;return e({...n,_:n.views},n.views)(t)}};return Y}const W={forSpecification(e){let t=U(e);return{...t.helpers(),builder:t}},specification(e){return U(e)}};export{W as Builder};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{$ as e,C as t,D as n,K as r,L as i,Q as a,S as o,T as s,X as c,Y as l,b as u,d,et as f,i as p,m,r as h,w as g,y as _}from"../_chunks/libs/remeda.mjs";import{
|
|
2
|
-
`)},shape:`rectangle`,children:[],inEdges:[],outEdges:[],color:`primary`,level:0,style:{},tags:[]};t.set(r.id,r)}return t}function X(t){let n=
|
|
1
|
+
import{$ as e,C as t,D as n,K as r,L as i,Q as a,S as o,T as s,X as c,Y as l,b as u,d,et as f,i as p,m,r as h,w as g,y as _}from"../_chunks/libs/remeda.mjs";import{An as v,Dt as y,Gt as b,Ht as x,Tn as S,Vt as C,Zt as w,_ as T,_n as E,bt as D,dn as O,g as k,lt as ee,ot as te,tn as ne,tt as re,un as A,wn as j,yt as M}from"../_chunks/types.mjs";import{t as N}from"../_chunks/libs/mnemonist.mjs";import"../_chunks/model.mjs";import{a as P,c as F,i as I,n as L,o as R,r as z,s as B,t as V}from"../_chunks/Builder.view-element.mjs";import{t as H}from"../_chunks/libs/graphology.mjs";import{n as U,t as W}from"../utils/graphology/index.mjs";function G(e){let t=new H({type:`directed`}),n=[];for(let r of h(e))t.addNode(r.id,{view:r}),T(r)&&n.push(r);if(n.length===0)return e;for(let e of n){if(!t.hasNode(e.extends)){console.warn(`View "${e.id}" extends from "${e.extends}" which does not exist`);continue}if((0,U.default)(t,e.id,e.extends)){console.warn(`View "${e.id}" extends from "${e.extends}" which creates a cycle`);continue}t.addDirectedEdge(e.id,e.extends)}return(0,W.topologicalSort)(t).reverse().reduce((e,n)=>{let r=t.getNodeAttribute(n,`view`);if(!T(r))return e[r.id]=r,e;let i=e[r.extends];if(!i||!k(i))return e;let a=p([...i.tags??[],...r.tags??[]]),o=[...i.links??[],...r.links??[]];return e[r.id]={...i,...r,title:r.title??i.title??null,description:r.description??i.description??null,tags:a,links:ne(o)?o:null,rules:[...i.rules,...r.rules]},e},{})}function K({edges:e,nodes:t,...n},r=`:`){let i=g(e,e=>[e.id,`${e.source}${r}${e.target}`]);return{...n,edges:e.map(e=>({...e,id:i[e.id]})),nodes:t.map(e=>({...e,inEdges:s(e.inEdges,e=>i[e]),outEdges:s(e.outEdges,e=>i[e])})),nodeIds:t.map(e=>e.id),edgeIds:e.map(e=>i[e.id])}}function q({views:e,...n}){return{...n,views:t(e,e=>o(K(e),[`nodeIds`,`edgeIds`]))}}const J=e=>n(e).length,Y=e=>y(e);function ie(e){let t=ae(e),n=(e,t)=>`${e}->${t}`,o=new N.default(e=>{let[t,n]=e.split(`->`);return{from:t,to:n,relationships:new Set}}),l=(e,t)=>o.get(n(e,t)).relationships,u=(e,t)=>{let n=t.projectId;j(n!==e.projectId,`Imported element must have a different project id`);let r=l(e.projectId,n);for(let n of t.incoming(`direct`))n.source.projectId===e.projectId&&r.add(n);let i=l(n,e.projectId);for(let n of t.outgoing(`direct`))n.target.projectId===e.projectId&&i.add(n)};for(let t of e)if(!i(t.$data.imports))for(let[e,n]of c(t.$data.imports))for(let r of n){let n=re(e,r.id);u(t,S(t.findElement(n),`Element ${r.id} from project ${e} not found in model ${t.projectId}`))}let d=Array.from(o.entries()).filter(([e,{relationships:t}])=>t.size>0).map(([e,{from:t,to:n,relationships:i}])=>{let o=[...i];j(a(o,1),`Relationships set must have at least one relationship`);let c={id:y(e),source:Y(t),target:Y(n),projectId:t,relations:s(o,m(`id`)),label:null,color:`gray`,parent:null,line:`solid`,tags:p(r(o,m(`tags`)))},l=_(o);return l&&(c.label=l.title,c.description=v(l.$relationship)??null,c.technology=l.technology,c.color=l.color,c.line=l.line,l.kind&&(c.kind=l.kind),l.$relationship.navigateTo&&(c.navigateTo=l.$relationship.navigateTo)),c});F(t,d);let f=B({nodes:t,edges:d});return{id:`projects-view`,[D]:`projects`,[M]:`computed`,title:`Projects`,description:{txt:`Overview of all projects and their relationships`},autoLayout:{direction:`TB`},...f}}function ae(e){let t=new Map;for(let n of e){let e=te(n.projectId),r={id:Y(e),kind:`@project`,parent:null,projectId:e,title:n.project.title??n.project.id,description:{txt:[`Elements: ${J(n.$data.elements)}`,`Relationships: ${J(n.$data.relations)}`,`Views: ${J(n.$data.views)}`].join(`
|
|
2
|
+
`)},shape:`rectangle`,children:[],inEdges:[],outEdges:[],color:`primary`,level:0,style:{},tags:[]};t.set(r.id,r)}return t}function X(t){let n=E([...t]),r=new Set(n),i=new Map,a=new N.default(()=>null),o=n.reduce((t,n,o,s)=>(i.set(n.id,n),t.set(n.id,f(s,e(o+1),l(O(n)),d((e,t)=>(r.delete(t),e.some(A(t))||(e.push(t),a.set(t.id,n)),e),[]))),t),new N.default(()=>[]));return{sorted:n,byId:e=>S(i.get(e),`Element not found by id: ${e}`),root:r,parent:e=>a.get(typeof e==`string`?e:e.id),children:e=>o.get(typeof e==`string`?e:e.id),flatten:u(()=>new Set([...r,...n.reduce((e,t)=>{let n=o.get(t.id);return n.length===0?(e.push(t),e):(n.length>1&&e.push(...n),e)},[])]))}}const Z=(e,t)=>e.size>2&&t.size!==e.size?new Set(E([...X(e).flatten(),...t])):e.size>1?new Set(E([...e])):e;function Q(e,t,n){let r=e=>t.has(e),i=new Set([e]),a={incomers:new Set,subjects:new Set([e]),outgoers:new Set},o=new Set(n.incoming.flatMap(t=>{if(a.subjects.add(t.target),a.incomers.add(t.source),i.add(t.target),t.target!==e){let n=t.target.parent;for(;n&&n!==e;)i.add(n),n=n.parent}let n=t.source,o=[];for(;o.push(n),!(r(n)||!n.parent);)n=n.parent;return o})),s=new Set(n.outgoing.flatMap(t=>{if(a.subjects.add(t.source),a.outgoers.add(t.target),i.add(t.source),t.source!==e){let n=t.source.parent;for(;n&&n!==e;)i.add(n),n=n.parent}let n=t.target,o=[];for(;o.push(n),!(r(n)||!n.parent);)n=n.parent;return o}));return{incomers:Z(o,a.incomers),incoming:new Set(n.incoming),subjects:Z(i,a.subjects),outgoing:new Set(n.outgoing),outgoers:Z(s,a.outgoers)}}function oe(e,t,n,r=`global`){let i=n?t.findView(n):null;if(r===`view`)return j(i,`Scope view id is required when scope is "view"`),se(e,i,t);let a=t.element(e);return Q(a,x(a.ascendingSiblings()),{incoming:[...a.incoming()],outgoing:[...a.outgoing()]})}function se(e,t,n){let r=n.element(e),i={incoming:C(w(r.incoming(),e=>t.includesRelation(e.id))),outgoing:C(w(r.outgoing(),e=>t.includesRelation(e.id)))},a=O(r);return Q(r,new Set([...r.ascendingSiblings(),...f(t.elements(),b(e=>e.element),w(e=>e!==r&&a(e)))]),i)}function $(e,t){return{...R(e,{id:ee(`adhoc`),_stage:`parsed`,_type:`element`,rules:t,title:null,description:null}),_type:`adhoc`,_stage:`computed`}}var ce=class e{model;static use(t){return new e(t)}#e=[];constructor(e){this.model=e}Expr;include(...e){return this.#e.push({include:e.map(e=>V(e))}),this}exclude(...e){return this.#e.push({exclude:e.map(e=>V(e))}),this}compute(){return $(this.model,this.#e)}};export{ce as AdhocView,$ as computeAdhocView,L as computeLikeC4Model,z as computeParsedModelData,ie as computeProjectsView,oe as computeRelationshipsView,I as computeView,G as resolveRulesExtendedViews,X as treeFromElements,P as unsafeComputeView,q as viewsWithReadableEdges,K as withReadableEdges};
|
package/dist/geometry/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Cn as e,Ct as t,Dn as n,On as r,Sn as i,St as a}from"../_chunks/types.mjs";export{i as BBox,e as RectBox,a as Vector,n as convertPoint,r as isPoint,t as vector};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { $ as DiagramNodeDriftReason, $i as Coalesce, $n as isTagEqual, $t as ElementViewIncludePredicate, A as isComputedView, Ai as ProjectId, An as ModelRelationExpr, Ar as IconPositions, At as ElementStyle, B as DeploymentViewIncludePredicate, Bi as flattenMarkdownOrString, Bn as NotOperator, Bt as DynamicStep, C as LayoutedView, Ci as GlobalFqn, Cn as ViewWithNotation, Cr as ThemeColor, Ct as DeploymentNode, D as ViewRule, Di as MarkdownOrString, Dn as isViewRuleGlobalStyle, Dr as BorderStyles, Dt as isDeploymentNode, E as ViewOnStage, Ei as IconUrl, En as isViewRuleGlobalPredicateRef, Er as isThemeColor, Et as isDeployedInstance, F as isExtendsElementView, Fi as StepEdgeIdLiteral, Fn as AndOperator, Fr as AnyLayouted, Ft as GlobalPredicateId, G as ParsedViewRuleAncestors, Gi as splitGlobalFqn, Gn as TagEqual, Gt as DynamicViewRule, H as DeploymentViewRule, Hi as isGroupElementKind, Hn as OrOperator, Ht as DynamicStepsSeries, I as isScopedElementView, Ii as StepEdgeKind, In as EqualOperator, Ir as AnyParsed, It as GlobalPredicates, J as LayoutType, Ji as ModelStage, Jn as isKindEqual, Jt as getParallelStepsPrefix, K as DiagramEdge, Ki as stepEdgeId, Kn as WhereOperator, Kt as DynamicViewStep, L as isViewRulePredicate, Li as Tag, Ln as Filterable, Lr as Aux, Lt as GlobalStyleID, M as isDiagramView, Mi as RelationKind, Mn as FqnExpr, Mr as ThemeColors, Mt as Relationship, N as isDynamicView, Ni as RelationshipKind, Nn as PredicateSelector, Nr as Any, Nt as ensureSizes, O as ViewRulePredicate, Oi as NodeId, On as ModelExpression, Ot as AbstractRelationship, P as isElementView, Pi as StepEdgeId, Pn as RelationExpr, Pr as AnyComputed, Pt as GlobalDynamicPredicates, Q as DiagramEdgeDriftReason, Qi as isOnStage, Qn as isParticipantOperator, Qt as ElementViewExcludePredicate, R as isViewRuleStyle, Ri as ViewId, Rn as KindEqual, Rt as GlobalStyles, S as ComputedView, Si as Fqn, Sn as ViewWithHash, Sr as TextSize, St as DeploymentElementRef, T as ProcessedView, Ti as Icon, Tn as isViewRuleAutoLayout, Tr as isCustomColor, Tt as DeploymentRelationship, U as DeploymentViewRuleStyle, Ui as isStepEdgeId, Un as Participant, Ut as DynamicViewDisplayVariant, V as DeploymentViewPredicate, Vi as isGlobalFqn, Vn as OperatorPredicate, Vt as DynamicStepsParallel, W as ParsedDeploymentView, Wi as scalar_d_exports, Wn as ParticipantOperator, Wt as DynamicViewIncludeRule, X as LayoutedDynamicView, Xi as _stage, Xn as isNotOperator, Xt as isDynamicStepsParallel, Y as LayoutedDeploymentView, Yi as _layout, Yn as isMetadataEqual, Yt as isDynamicStep, Z as LayoutedElementView, Zi as _type, Zn as isOrOperator, Zt as isDynamicStepsSeries, _ as ComputedLikeC4ModelData, _i as BuiltInIcon, _n as ViewRuleAutoLayout, _r as RelationshipColorValues, _t as Specification, a as isNonEmptyArray, aa as NTuple, an as ParsedElementView, ar as CustomColor, at as ComputedElementView, b as ParsedLikeC4ModelData, bi as EdgeId, bn as ViewRuleRank, br as Size, bt as DeployedInstance, c as RichTextEmpty, ca as Predicate, ci as UnknownLayouted, cn as AnyExcludePredicate, cr as ElementShape, ct as ComputedRankConstraint, d as AuxFromDump, di as _aux_d_exports, dn as AutoLayoutDirection, dr as IconSize, dt as LikeC4ProjectStyleDefaults, ea as ExclusiveUnion, en as ElementViewPredicate, er as whereOperatorAsPredicate, et as LayoutedViewDriftReason, f as LikeC4ModelDump, fi as preferDescription, fn as BaseParsedViewProperties, fr as LikeC4StyleDefaults, ft as LikeC4ProjectStylesConfig, g as AuxFromLikeC4ModelData, gi as AnyFqn, gn as ViewAutoLayout, gr as RelationshipArrowTypes, gt as RelationshipSpecification, h as SpecificationDump, hn as RankValue, hr as RelationshipArrowType, ht as ElementSpecification, i as isAnyOf, ia as Link, in as ElementViewRuleStyle, ir as ColorLiteral, it as ComputedEdge, j as isDeploymentView, ji as RelationId, jn as Expression, jr as Sizes, jt as ModelRelation, k as ViewWithType, ki as NoneIcon, kn as ModelFqnExpr, kr as ElementShapes, kt as Element, l as RichTextOrEmpty, la as ReorderedArray, li as UnknownParsed, ln as AnyIncludePredicate, lr as HexColor, lt as LikeC4Project, m as SpecTypesFromDump, mn as NodeNotation, mr as LikeC4Theme, mt as LikeC4ProjectTheme, n as GuardedBy, na as IteratorLike, nn as ElementViewRuleGroup, nr as BorderStyle, nt as ComputedDeploymentView, o as isString, oa as NonEmptyArray, oi as Unknown, on as isViewRuleGroup, or as CustomColorDefinitions, ot as ComputedNode, p as ProjectDump, pi as preferSummary, pn as BaseViewProperties, pr as LikeC4StylesConfig, pt as LikeC4ProjectStylesCustomStylesheets, q as DiagramNode, qi as ExtractOnStage, qn as isAndOperator, qr as LooseLiteral, qt as ParsedDynamicView, r as hasProp, ra as KeysOf, rn as ElementViewRuleRank, rr as Color, rt as ComputedDynamicView, s as RichText, sa as NonEmptyReadonlyArray, si as UnknownComputed, sn as isViewRuleRank, sr as ElementColorValues, st as ComputedNodeStyle, t as Guard, ta as IterableContainer, ti as SpecAux, tn as ElementViewRule, tr as FqnRef, tt as ViewManualLayoutSnapshot, u as ViewChange, ua as exact, un as AnyViewRuleStyle, ur as IconPosition, ut as LikeC4ProjectManualLayoutsConfig, v as LayoutedLikeC4ModelData, vi as DeploymentFqn, vn as ViewRuleGlobalPredicateRef, vr as RelationshipLineType, vt as TagSpecification, w as ParsedView, wi as GroupElementKind, wn as isAutoLayoutDirection, wr as ThemeColorValues, wt as DeploymentRelation, x as AnyView, xi as ElementKind, xn as ViewType, xr as SpacingSize, xt as DeploymentElement, y as LikeC4ModelData, yi as DeploymentKind, yn as ViewRuleGlobalStyle, yr as ShapeSize, yt as isTagColorSpecified, z as DeploymentViewExcludePredicate, zi as extractStep, zn as MetadataEqual, zt as ModelGlobals } from "./_chunks/index.mjs";
|
|
2
2
|
import { a as RectBox, c as XYPoint, i as BBox, l as convertPoint, n as VectorValue, o as Dimensions, r as vector, s as Point, t as Vector, u as isPoint } from "./_chunks/index2.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { o as LikeC4Styles } from "./_chunks/index3.mjs";
|
|
4
4
|
import { a as DefaultWeakMap, i as LinkedList, n as Queue, o as DefaultMap, r as MultiMap } from "./_chunks/libs/mnemonist.mjs";
|
|
5
5
|
import { o as LayoutedProjectsView, r as ComputedProjectsView } from "./_chunks/_types2.mjs";
|
|
6
6
|
import { A as ancestorsFqn, B as parentFqn, H as sortNaturalByFqn, I as isAncestor, J as invariant, L as isDescendantOf, O as isIterable, R as isSameHierarchy, U as sortParentsFirst, X as nonexhaustive, Y as nonNullable, h as memoizeProp, z as nameFromFqn } from "./_chunks/index5.mjs";
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,$t as t,A as ee,
|
|
1
|
+
import{$ as e,$t as t,A as ee,An as n,C as r,Cn as i,D as a,E as o,En as s,G as c,J as l,K as u,O as d,Q as f,Qt as p,S as m,Sn as h,T as g,Tn as _,U as v,W as y,X as b,Y as x,Z as S,_ as C,_n as w,_t as T,a as E,at as D,b as O,bt as k,c as A,ct as j,d as M,dn as N,dt as P,en as F,et as I,f as L,fn as R,ft as z,g as B,gn as V,gt as H,h as U,ht as W,i as G,in as K,it as q,j as J,jn as Y,k as X,kn as Z,l as Q,lt as te,m as $,mn as ne,mt as re,n as ie,nn as ae,nt as oe,o as se,ot as ce,p as le,pn as ue,pt as de,q as fe,r as pe,rt as me,s as he,st as ge,t as _e,tn as ve,tt as ye,u as be,un as xe,ut as Se,v as Ce,vt as we,w as Te,wn as Ee,x as De,xt as Oe,y as ke,yt as Ae,zt as je}from"./_chunks/types.mjs";import{a as Me,n as Ne,o as Pe,r as Fe,t as Ie}from"./_chunks/libs/mnemonist.mjs";import{i as Le,n as Re,t as ze}from"./_chunks/manual-layout.mjs";import"./styles/index.mjs";var Be=Ie.default,Ve=Ne.default,He=Fe.default,Ue=Me.default,We=Pe.default;export{h as BBox,Be as DefaultMap,Ve as DefaultWeakMap,f as DeploymentFqn,e as EdgeId,l as Expression,I as Fqn,x as FqnExpr,S as FqnRef,ye as GlobalFqn,oe as GroupElementKind,J as LikeC4Styles,He as LinkedList,me as MarkdownOrString,c as ModelExpression,u as ModelFqnExpr,fe as ModelRelationExpr,Ue as MultiMap,q as NodeId,D as NoneIcon,ce as ProjectId,We as Queue,i as RectBox,b as RelationExpr,ge as RelationId,_e as RichText,j as StepEdgeKind,te as ViewId,we as _layout,Ae as _stage,k as _type,K as ancestorsFqn,Le as applyCachedLayout,Re as applyManualLayout,ze as calcDriftsFromSnapshot,ee as ensureSizes,Y as exact,Se as extractStep,P as flattenMarkdownOrString,G as getParallelStepsPrefix,t as hasProp,Ee as invariant,xe as isAncestor,De as isAndOperator,F as isAnyOf,A as isAutoLayoutDirection,L as isComputedView,v as isDeployedInstance,y as isDeploymentNode,le as isDeploymentView,N as isDescendantOf,$ as isDiagramView,$ as isLayoutedView,E as isDynamicStep,se as isDynamicStepsParallel,he as isDynamicStepsSeries,U as isDynamicView,B as isElementView,C as isExtendsElementView,z as isGlobalFqn,de as isGroupElementKind,p as isIterable,m as isKindEqual,r as isMetadataEqual,ve as isNonEmptyArray,Te as isNotOperator,Oe as isOnStage,g as isOrOperator,o as isParticipantOperator,R as isSameHierarchy,Ce as isScopedElementView,re as isStepEdgeId,ae as isString,X as isTagColorSpecified,a as isTagEqual,Q as isViewRuleAutoLayout,be as isViewRuleGlobalPredicateRef,M as isViewRuleGlobalStyle,ie as isViewRuleGroup,ke as isViewRulePredicate,pe as isViewRuleRank,O as isViewRuleStyle,je as memoizeProp,ue as nameFromFqn,_ as nonNullable,s as nonexhaustive,ne as parentFqn,Z as preferDescription,n as preferSummary,W as scalar,V as sortNaturalByFqn,w as sortParentsFirst,H as splitGlobalFqn,T as stepEdgeId,d as whereOperatorAsPredicate};
|
package/dist/styles/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Ar as IconPositions, Cr as ThemeColor, Dr as BorderStyles, Er as isThemeColor, Mr as ThemeColors, Or as DefaultTagColors, Sr as TextSize, Tr as isCustomColor, _r as RelationshipColorValues, ar as CustomColor, br as Size, cr as ElementShape, dr as IconSize, fr as LikeC4StyleDefaults, gr as RelationshipArrowTypes, hr as RelationshipArrowType, ir as ColorLiteral, jr as Sizes, kr as ElementShapes, lr as HexColor, mr as LikeC4Theme, nr as BorderStyle, or as CustomColorDefinitions, pr as LikeC4StylesConfig, rr as Color, sr as ElementColorValues, ur as IconPosition, vr as RelationshipLineType, wr as ThemeColorValues, xr as SpacingSize, yr as ShapeSize } from "../_chunks/index.mjs";
|
|
2
|
-
import { a as
|
|
3
|
-
export { BorderStyle, BorderStyles, Color, ColorLiteral, CustomColor, CustomColorDefinitions, DefaultTagColors, ElementColorValues, ElementShape, ElementShapes, HexColor, IconPosition, IconPositions, IconSize, LikeC4StyleDefaults, LikeC4Styles, LikeC4StylesConfig, LikeC4Theme, RelationshipArrowType, RelationshipArrowTypes, RelationshipColorValues, RelationshipLineType, ShapeSize, Size, Sizes, SpacingSize, TextSize, ThemeColor, ThemeColorValues, ThemeColors, assignTagColors, computeColorValues, defaultTheme, isCustomColor, isThemeColor, styleDefaults };
|
|
2
|
+
import { a as isValidColor, i as getContrastedColorsAPCA, n as styleDefaults, o as LikeC4Styles, r as computeColorValues, s as assignTagColors, t as defaultTheme } from "../_chunks/index3.mjs";
|
|
3
|
+
export { BorderStyle, BorderStyles, Color, ColorLiteral, CustomColor, CustomColorDefinitions, DefaultTagColors, ElementColorValues, ElementShape, ElementShapes, HexColor, IconPosition, IconPositions, IconSize, LikeC4StyleDefaults, LikeC4Styles, LikeC4StylesConfig, LikeC4Theme, RelationshipArrowType, RelationshipArrowTypes, RelationshipColorValues, RelationshipLineType, ShapeSize, Size, Sizes, SpacingSize, TextSize, ThemeColor, ThemeColorValues, ThemeColors, assignTagColors, computeColorValues, defaultTheme, getContrastedColorsAPCA, isCustomColor, isThemeColor, isValidColor, styleDefaults };
|
package/dist/styles/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,F as t,
|
|
1
|
+
import{B as e,F as t,H as n,I as r,L as i,M as a,N as o,P as s,R as c,V as l,j as u,z as d}from"../_chunks/types.mjs";import{t as f}from"../_chunks/assignTagColors.mjs";const p=[`none`,`normal`,`onormal`,`dot`,`odot`,`diamond`,`odiamond`,`crow`,`open`,`vee`];function m(e){return n.includes(e)}function h(e){return!m(e)}export{i as BorderStyles,c as DefaultTagColors,d as ElementShapes,e as IconPositions,u as LikeC4Styles,p as RelationshipArrowTypes,l as Sizes,n as ThemeColors,f as assignTagColors,s as computeColorValues,a as defaultTheme,t as getContrastedColorsAPCA,h as isCustomColor,m as isThemeColor,r as isValidColor,o as styleDefaults};
|
package/dist/types/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as e,$t as t,A as n,
|
|
1
|
+
import{$ as e,$t as t,A as n,An as r,C as i,Cn as a,D as o,E as s,G as c,J as l,K as u,O as d,Q as f,S as p,Sn as m,T as h,U as g,W as _,X as v,Y as y,Z as b,_ as x,_t as S,a as C,at as w,b as T,bt as E,c as D,ct as O,d as k,dt as A,en as j,et as M,f as N,ft as P,g as F,gt as I,h as L,ht as ee,i as R,it as z,jn as B,k as V,kn as H,l as U,lt as W,m as G,mt as K,n as q,nn as J,nt as Y,o as X,ot as Z,p as Q,pt as $,q as te,r as ne,rt as re,s as ie,st as ae,t as oe,tn as se,tt as ce,u as le,ut as ue,v as de,vt as fe,w as pe,x as me,xt as he,y as ge,yt as _e}from"../_chunks/types.mjs";export{m as BBox,f as DeploymentFqn,e as EdgeId,l as Expression,M as Fqn,y as FqnExpr,b as FqnRef,ce as GlobalFqn,Y as GroupElementKind,re as MarkdownOrString,c as ModelExpression,u as ModelFqnExpr,te as ModelRelationExpr,z as NodeId,w as NoneIcon,Z as ProjectId,a as RectBox,v as RelationExpr,ae as RelationId,oe as RichText,O as StepEdgeKind,W as ViewId,fe as _layout,_e as _stage,E as _type,n as ensureSizes,B as exact,ue as extractStep,A as flattenMarkdownOrString,R as getParallelStepsPrefix,t as hasProp,me as isAndOperator,j as isAnyOf,D as isAutoLayoutDirection,N as isComputedView,g as isDeployedInstance,_ as isDeploymentNode,Q as isDeploymentView,G as isDiagramView,G as isLayoutedView,C as isDynamicStep,X as isDynamicStepsParallel,ie as isDynamicStepsSeries,L as isDynamicView,F as isElementView,x as isExtendsElementView,P as isGlobalFqn,$ as isGroupElementKind,p as isKindEqual,i as isMetadataEqual,se as isNonEmptyArray,pe as isNotOperator,he as isOnStage,h as isOrOperator,s as isParticipantOperator,de as isScopedElementView,K as isStepEdgeId,J as isString,V as isTagColorSpecified,o as isTagEqual,U as isViewRuleAutoLayout,le as isViewRuleGlobalPredicateRef,k as isViewRuleGlobalStyle,q as isViewRuleGroup,ge as isViewRulePredicate,ne as isViewRuleRank,T as isViewRuleStyle,H as preferDescription,r as preferSummary,ee as scalar,I as splitGlobalFqn,S as stepEdgeId,d as whereOperatorAsPredicate};
|
package/dist/utils/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{At as e,Bt as t,Dt as n,En as r,Et as i,Ft as a,Gt as o,Ht as s,It as c,Jt as l,Kt as u,Lt as d,Mt as f,Nt as p,Ot as m,Pt as h,Qt as g,Rt as _,Tn as v,Tt as y,Ut as b,Vt as x,Wt as S,Xt as C,Yt as w,Zt as T,_n as E,an as D,bn as O,cn as k,dn as A,fn as j,gn as M,hn as N,in as P,kt as F,ln as I,mn as L,nn as R,on as z,pn as B,qt as V,rn as H,sn as U,tn as W,un as G,vn as K,wn as q,wt as J,xn as Y,yn as X,zt as Z}from"../_chunks/types.mjs";import{a as Q,c as $,n as ee,o as te,r as ne,t as re}from"../_chunks/libs/mnemonist.mjs";var ie=re.default,ae=ee.default,oe=ne.default,se=Q.default,ce=te.default,le=$.default;export{ie as DefaultMap,ae as DefaultWeakMap,oe as LinkedList,se as MultiMap,ce as Queue,le as Stack,P as ancestorsFqn,D as commonAncestor,Y as commonHead,z as compareByFqnHierarchically,U as compareFqnHierarchically,K as compareNatural,X as compareNaturalHierarchically,a as compareRelations,c as delay,F as difference,e as equalsSet,H as getOrCreate,k as hierarchyDistance,I as hierarchyLevel,T as ifilter,C as ifind,w as ifirst,l as iflat,V as iflatMap,u as ihead,o as imap,f as intersection,q as invariant,S as ireduce,G as isAncestor,A as isDescendantOf,g as isIterable,W as isNonEmptyArray,j as isSameHierarchy,R as isString,b as isome,t as iunique,i as markdownToHtml,y as markdownToText,Z as memoizeProp,B as nameFromFqn,v as nonNullable,r as nonexhaustive,m as objectHash,d as onNextTick,L as parentFqn,_ as promiseNextTick,N as sortByFqnHierarchically,O as sortNatural,M as sortNaturalByFqn,E as sortParentsFirst,n as stringHash,p as symmetricDifference,x as toArray,s as toSet,h as union,J as unsafePartial};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.58.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"homepage": "https://likec4.dev",
|
|
6
6
|
"author": "Denis Davydkov <denis@davydkov.com>",
|
|
@@ -102,13 +102,13 @@
|
|
|
102
102
|
"access": "public"
|
|
103
103
|
},
|
|
104
104
|
"dependencies": {
|
|
105
|
-
"immer": "^11.1.
|
|
105
|
+
"immer": "^11.1.8",
|
|
106
106
|
"type-fest": "^4.41.0",
|
|
107
|
-
"zod": "^4.3
|
|
107
|
+
"zod": "^4.4.3"
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
110
|
"@dagrejs/dagre": "1.1.8",
|
|
111
|
-
"@mantine/colors-generator": "9.2.
|
|
111
|
+
"@mantine/colors-generator": "9.2.2",
|
|
112
112
|
"@rolldown/plugin-node-polyfills": "^1.0.3",
|
|
113
113
|
"@types/chroma-js": "^3.1.2",
|
|
114
114
|
"@types/extend": "3.0.4",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"@types/natural-compare-lite": "^1.4.2",
|
|
118
118
|
"@types/node": "~22.19.19",
|
|
119
119
|
"@types/unist": "3.0.3",
|
|
120
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
120
|
+
"@typescript/native-preview": "7.0.0-dev.20260602.1",
|
|
121
121
|
"chroma-js": "3.2.0",
|
|
122
122
|
"defu": "^6.1.7",
|
|
123
123
|
"fdir": "6.4.0",
|
|
@@ -127,12 +127,12 @@
|
|
|
127
127
|
"mdast-util-from-markdown": "^2.0.3",
|
|
128
128
|
"mdast-util-to-hast": "^13.2.1",
|
|
129
129
|
"mdast-util-to-string": "^4.0.0",
|
|
130
|
-
"mnemonist": "0.40.
|
|
130
|
+
"mnemonist": "0.40.4",
|
|
131
131
|
"natural-compare-lite": "^1.4.0",
|
|
132
132
|
"obliterator": "^2.0.5",
|
|
133
133
|
"obuild": "0.4.31",
|
|
134
134
|
"ohash": "^2.0.11",
|
|
135
|
-
"oxlint": "1.
|
|
135
|
+
"oxlint": "1.68.0",
|
|
136
136
|
"rehype-format": "5.0.1",
|
|
137
137
|
"rehype-sanitize": "^6.0.0",
|
|
138
138
|
"rehype-stringify": "10.0.1",
|
|
@@ -140,15 +140,15 @@
|
|
|
140
140
|
"remark-github-blockquote-alert": "^2.0.1",
|
|
141
141
|
"remark-parse": "11.0.0",
|
|
142
142
|
"remark-rehype": "11.1.2",
|
|
143
|
-
"remeda": "^2.
|
|
144
|
-
"turbo": "2.9.
|
|
145
|
-
"typescript": "
|
|
143
|
+
"remeda": "^2.37.0",
|
|
144
|
+
"turbo": "2.9.16",
|
|
145
|
+
"typescript": "6.0.3",
|
|
146
146
|
"unified": "11.0.5",
|
|
147
|
-
"vitest": "4.1.
|
|
148
|
-
"@likec4/devops": "1.
|
|
149
|
-
"@likec4/style-preset": "1.
|
|
150
|
-
"@likec4/
|
|
151
|
-
"@likec4/
|
|
147
|
+
"vitest": "4.1.8",
|
|
148
|
+
"@likec4/devops": "1.58.0",
|
|
149
|
+
"@likec4/style-preset": "1.58.0",
|
|
150
|
+
"@likec4/tsconfig": "1.58.0",
|
|
151
|
+
"@likec4/styles": "1.58.0"
|
|
152
152
|
},
|
|
153
153
|
"scripts": {
|
|
154
154
|
"typecheck": "tsc -b --verbose",
|