@likec4/core 1.48.0 → 1.49.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/THIRD-PARTY-LICENSES.md +1012 -0
- package/dist/_chunks/Builder.view-element.mjs +2 -3284
- package/dist/_chunks/LikeC4Model.d.mts +21 -25
- package/dist/_chunks/RichText.mjs +1 -148
- package/dist/_chunks/_types.d.mts +1 -5
- package/dist/_chunks/_types2.d.mts +2 -4
- package/dist/_chunks/assignTagColors.mjs +1 -24
- package/dist/_chunks/calcDriftsFromSnapshot.mjs +1 -379
- package/dist/_chunks/guards.d.mts +2026 -0
- package/dist/_chunks/guards.mjs +4 -0
- package/dist/_chunks/index.d.mts +255 -136
- package/dist/_chunks/libs/@mantine/colors-generator.mjs +2 -3403
- package/dist/_chunks/libs/@radix-ui/colors.mjs +1 -0
- package/dist/_chunks/libs/@ungap/structured-clone.mjs +1 -213
- package/dist/_chunks/libs/bail.mjs +1 -14
- package/dist/_chunks/libs/ccount.mjs +1 -25
- package/dist/_chunks/libs/character-entities-html4.mjs +1 -263
- package/dist/_chunks/libs/character-entities-legacy.mjs +1 -117
- package/dist/_chunks/libs/character-entities.mjs +2 -2136
- package/dist/_chunks/libs/comma-separated-tokens.mjs +1 -18
- package/dist/_chunks/libs/decode-named-character-reference.mjs +1 -21
- package/dist/_chunks/libs/defu.mjs +1 -42
- package/dist/_chunks/libs/devlop.mjs +1 -5
- package/dist/_chunks/libs/escape-string-regexp.mjs +1 -8
- package/dist/_chunks/libs/extend.mjs +1 -77
- package/dist/_chunks/libs/graphology-dag.mjs +1 -703
- package/dist/_chunks/libs/graphology.mjs +1 -4565
- package/dist/_chunks/libs/hast-util-sanitize.mjs +1 -863
- package/dist/_chunks/libs/hast-util-to-html.mjs +9 -2696
- package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
- package/dist/_chunks/libs/longest-streak.mjs +1 -30
- package/dist/_chunks/libs/markdown-table.mjs +2 -290
- package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +1 -653
- package/dist/_chunks/libs/mdast-util-from-markdown.mjs +3 -8522
- package/dist/_chunks/libs/mdast-util-gfm.mjs +15 -2393
- package/dist/_chunks/libs/mdast-util-to-hast.mjs +11 -1803
- package/dist/_chunks/libs/micromark-extension-gfm.mjs +1 -2243
- package/dist/_chunks/libs/mnemonist.d.mts +1 -91
- package/dist/_chunks/libs/mnemonist.mjs +1 -1978
- package/dist/_chunks/libs/natural-compare-lite.mjs +9 -42
- package/dist/_chunks/libs/ohash.mjs +1 -0
- package/dist/_chunks/libs/rehype-sanitize.mjs +1 -29
- package/dist/_chunks/libs/rehype-stringify.mjs +1 -34
- package/dist/_chunks/libs/remark-gfm.mjs +1 -36
- package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +3 -100
- package/dist/_chunks/libs/remark-parse.mjs +1 -39
- package/dist/_chunks/libs/remark-rehype.mjs +1 -171
- package/dist/_chunks/libs/remeda.mjs +1 -702
- package/dist/_chunks/libs/trough.mjs +1 -158
- package/dist/_chunks/libs/unified.mjs +1 -2212
- package/dist/_chunks/rolldown-runtime.mjs +1 -42
- package/dist/_chunks/{index3.d.mts → theme.d.mts} +15 -13
- package/dist/_chunks/{index7.d.mts → to-text.d.mts} +165 -29
- package/dist/_chunks/to-text.mjs +1 -0
- package/dist/_chunks/vector.d.mts +198 -0
- package/dist/_chunks/vector.mjs +1 -0
- package/dist/builder/index.d.mts +2 -8
- package/dist/builder/index.mjs +1 -662
- package/dist/compute-view/index.d.mts +86 -15
- package/dist/compute-view/index.mjs +2 -262
- package/dist/geometry/index.d.mts +2 -2
- package/dist/geometry/index.mjs +1 -3
- package/dist/index.d.mts +9 -13
- package/dist/index.mjs +1 -27
- package/dist/model/index.d.mts +4 -14
- package/dist/model/index.mjs +1 -11
- package/dist/styles/index.d.mts +2 -8
- package/dist/styles/index.mjs +1 -30
- package/dist/types/index.d.mts +3 -9
- package/dist/types/index.mjs +1 -15
- package/dist/utils/graphology/index.d.mts +1 -1
- package/dist/utils/graphology/index.mjs +1 -3
- package/dist/utils/index.d.mts +4 -11
- package/dist/utils/index.mjs +1 -17
- package/package.json +13 -12
- package/dist/_chunks/LikeC4Styles.mjs +0 -691
- package/dist/_chunks/RichText.d.mts +0 -84
- package/dist/_chunks/_aux.d.mts +0 -289
- package/dist/_chunks/_aux.mjs +0 -18
- package/dist/_chunks/connection.mjs +0 -0
- package/dist/_chunks/const.d.mts +0 -43
- package/dist/_chunks/const.mjs +0 -33
- package/dist/_chunks/expression-model.d.mts +0 -192
- package/dist/_chunks/expression-model.mjs +0 -103
- package/dist/_chunks/expression.d.mts +0 -347
- package/dist/_chunks/expression.mjs +0 -107
- package/dist/_chunks/find.d.mts +0 -82
- package/dist/_chunks/find.mjs +0 -646
- package/dist/_chunks/find2.d.mts +0 -78
- package/dist/_chunks/find2.mjs +0 -287
- package/dist/_chunks/fqnRef.d.mts +0 -58
- package/dist/_chunks/fqnRef.mjs +0 -41
- package/dist/_chunks/geometry.mjs +0 -335
- package/dist/_chunks/index2.d.mts +0 -937
- package/dist/_chunks/index4.d.mts +0 -62
- package/dist/_chunks/index5.d.mts +0 -42
- package/dist/_chunks/index6.d.mts +0 -43
- package/dist/_chunks/index8.d.mts +0 -144
- package/dist/_chunks/invariant.mjs +0 -18
- package/dist/_chunks/iterable.mjs +0 -146
- package/dist/_chunks/libs/graphology-types.d.mts +0 -601
- package/dist/_chunks/libs/graphology.d.mts +0 -6
- package/dist/_chunks/mnemonist.d.mts +0 -1
- package/dist/_chunks/mnemonist.mjs +0 -0
- package/dist/_chunks/model.mjs +0 -1898
- package/dist/_chunks/model2.mjs +0 -0
- package/dist/_chunks/relationships-view.mjs +0 -132
- package/dist/_chunks/scalar.d.mts +0 -109
- package/dist/_chunks/scalar.mjs +0 -84
- package/dist/_chunks/utils.mjs +0 -483
- package/dist/compute-view/relationships-view/index.d.mts +0 -16
- package/dist/compute-view/relationships-view/index.mjs +0 -7
- package/dist/model/connection/deployment/index.d.mts +0 -12
- package/dist/model/connection/deployment/index.mjs +0 -9
- package/dist/model/connection/index.d.mts +0 -14
- package/dist/model/connection/index.mjs +0 -10
- package/dist/model/connection/model/index.d.mts +0 -12
- package/dist/model/connection/model/index.mjs +0 -8
- package/dist/types/RichText.d.mts +0 -3
- package/dist/types/RichText.mjs +0 -7
- package/dist/types/_aux.d.mts +0 -3
- package/dist/types/_aux.mjs +0 -3
- package/dist/types/expression-model.d.mts +0 -6
- package/dist/types/expression-model.mjs +0 -7
- package/dist/types/expression.d.mts +0 -5
- package/dist/types/expression.mjs +0 -7
- package/dist/types/fqnRef.d.mts +0 -4
- package/dist/types/fqnRef.mjs +0 -7
- package/dist/types/scalar.d.mts +0 -2
- package/dist/types/scalar.mjs +0 -7
- package/dist/utils/iterable/index.d.mts +0 -9
- package/dist/utils/iterable/index.mjs +0 -3
- package/dist/utils/mnemonist.d.mts +0 -2
- package/dist/utils/mnemonist.mjs +0 -12
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{n as __exportAll}from"./rolldown-runtime.mjs";import{A as t,E as t$3,I as e$2,L as e$1,N as e$5,O as e,Q as t$1,T as t$6,X as t$4,c as t$8,et as t$5,i as n,l as t$7,m as e$4,r as t$2,s as e$3}from"./libs/remeda.mjs";import{A as LikeC4Styles,D as whereOperatorAsPredicate,J as FqnRef,Q as GlobalFqn,V as isDeploymentNode,_t as _type,bt as preferSummary,dt as isStepEdgeId,gt as _stage,lt as isGlobalFqn,pt as splitGlobalFqn,st as extractStep,t as RichText,ut as isGroupElementKind,vt as isOnStage,xt as exact,yt as preferDescription}from"./RichText.mjs";import{$ as nonNullable,A as ancestorsFqn,B as parentFqn,D as ifilter,E as ifind,F as hierarchyLevel,H as sortNaturalByFqn,I as isAncestor,J as compareNatural,L as isDescendantOf,Q as invariant,R as isSameHierarchy,S as ihead,U as sortParentsFirst,Y as compareNaturalHierarchically,a as difference,c as intersection,h as memoizeProp,j as commonAncestor,k as getOrCreate,o as equals,q as isString,r as stringHash,u as union,y as isome,z as nameFromFqn}from"./to-text.mjs";import{t as import_default_map}from"./libs/mnemonist.mjs";import{n as applyManualLayout,t as calcDriftsFromSnapshot}from"./calcDriftsFromSnapshot.mjs";var ElementModel=class{Aux;id;_literalId;hierarchyLevel;imported;constructor(r,i){this.$model=r,this.$element=i,this.id=this.$element.id,this._literalId=this.$element.id;let[a,o]=splitGlobalFqn(this.id);a?(this.imported={from:a,fqn:o},this.hierarchyLevel=hierarchyLevel(o)):(this.imported=null,this.hierarchyLevel=hierarchyLevel(this.id))}get name(){return nameFromFqn(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 memoizeProp(this,Symbol.for(`tags`),()=>n([...this.$element.tags??[],...this.$model.specification.elements[this.$element.kind]?.tags??[]]))}get title(){return this.$element.title}get hasSummary(){return!!this.$element.summary&&!!this.$element.description&&!t(this.$element.summary,this.$element.description)}get summary(){return RichText.memoize(this,`summary`,preferSummary(this.$element))}get description(){return RichText.memoize(this,`description`,preferDescription(this.$element))}get technology(){return this.$element.technology??null}get links(){return this.$element.links??[]}get defaultView(){return memoizeProp(this,Symbol.for(`defaultView`),()=>ihead(this.scopedViews())??null)}get isRoot(){return this.parent===null}get style(){return memoizeProp(this,`style`,()=>exact({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(r){return isAncestor(this,r)}isDescendantOf(r){return isAncestor(r,this)}ancestors(){return this.$model.ancestors(this)}commonAncestor(r){let i=commonAncestor(this.id,r.id);return i?this.$model.element(i):null}children(){return this.$model.children(this)}descendants(r){return r?sortNaturalByFqn([...this.$model.descendants(this)],r)[Symbol.iterator]():this.$model.descendants(this)}siblings(){return this.$model.siblings(this)}*ascendingSiblings(){yield*this.siblings();for(let r of this.ancestors())yield*r.siblings()}*descendingSiblings(){for(let r of[...this.ancestors()].reverse())yield*r.siblings();yield*this.siblings()}incoming(r=`all`){return this.$model.incoming(this,r)}*incomers(r=`all`){let i=new Set;for(let a of this.incoming(r))i.has(a.source.id)||(i.add(a.source.id),yield a.source)}outgoing(r=`all`){return this.$model.outgoing(this,r)}*outgoers(r=`all`){let i=new Set;for(let a of this.outgoing(r))i.has(a.target.id)||(i.add(a.target.id),yield a.target)}get allOutgoing(){return memoizeProp(this,Symbol.for(`allOutgoing`),()=>new Set(this.outgoing()))}get allIncoming(){return memoizeProp(this,Symbol.for(`allIncoming`),()=>new Set(this.incoming()))}views(){return memoizeProp(this,Symbol.for(`views`),()=>{let r=new Set;for(let i of this.$model.views())i.includesElement(this.id)&&r.add(i);return r})}scopedViews(){return memoizeProp(this,Symbol.for(`scopedViews`),()=>{let r=new Set;for(let i of this.$model.views())i.isScopedElementView()&&i.viewOf.id===this.id&&r.add(i);return r})}isDeployed(){return e(ihead(this.deployments()))}deployments(){return this.$model.deployment.instancesOf(this)}hasMetadata(){return!!this.$element.metadata&&!e$1(this.$element.metadata)}getMetadata(r){return r?this.$element.metadata?.[r]:this.$element.metadata??{}}isTagged(r){return this.tags.includes(r)}},AbstractDeploymentElementModel=class{Aux;get style(){return memoizeProp(this,`style`,()=>exact({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 nameFromFqn(this.id)}get shape(){return this.style.shape}get color(){return this.style.color}get icon(){return this.style.icon??null}get summary(){return RichText.memoize(this,`summary`,preferSummary(this.$node))}get description(){return RichText.memoize(this,`description`,preferDescription(this.$node))}get technology(){return this.$node.technology??null}get links(){return this.$node.links??[]}ancestors(){return this.$model.ancestors(this)}commonAncestor(r){let i=commonAncestor(this.id,r.id);return i?this.$model.node(i):null}siblings(){return this.$model.siblings(this)}isSibling(r){return this.parent===r.parent}*ascendingSiblings(){yield*this.siblings();for(let r of this.ancestors())yield*r.siblings()}*descendingSiblings(){for(let r of[...this.ancestors()].reverse())yield*r.siblings();yield*this.siblings()}incoming(r=`all`){return this.$model.incoming(this,r)}outgoing(r=`all`){return this.$model.outgoing(this,r)}*incomers(r=`all`){let i=new Set;for(let a of this.incoming(r))i.has(a.source.id)||(i.add(a.source.id),yield a.source)}*outgoers(r=`all`){let i=new Set;for(let a of this.outgoing(r))i.has(a.target.id)||(i.add(a.target.id),yield a.target)}*views(){for(let r of this.$model.views())r._type===`deployment`&&r.includesDeployment(this.id)&&(yield r)}isDeploymentNode(){return!1}isInstance(){return!1}get allOutgoing(){return memoizeProp(this,Symbol.for(`allOutgoing`),()=>RelationshipsAccum.from(new Set(this.outgoingModelRelationships()),new Set(this.outgoing())))}get allIncoming(){return memoizeProp(this,Symbol.for(`allIncoming`),()=>RelationshipsAccum.from(new Set(this.incomingModelRelationships()),new Set(this.incoming())))}hasMetadata(){return!!this.$node.metadata&&!e$1(this.$node.metadata)}getMetadata(r){return r?this.$node.metadata?.[r]:this.$node.metadata??{}}isTagged(r){return this.tags.includes(r)}},DeploymentNodeModel=class extends AbstractDeploymentElementModel{id;_literalId;title;hierarchyLevel;constructor(r,i){super(),this.$model=r,this.$node=i,this.id=i.id,this._literalId=i.id,this.title=i.title,this.hierarchyLevel=hierarchyLevel(i.id)}get parent(){return this.$model.parent(this)}get kind(){return this.$node.kind}get tags(){return memoizeProp(this,Symbol.for(`tags`),()=>n([...this.$node.tags??[],...this.$model.$model.specification.deployments[this.kind]?.tags??[]]))}children(){return this.$model.children(this)}descendants(r=`desc`){return this.$model.descendants(this,r)}isDeploymentNode(){return!0}*instances(){for(let r of this.descendants(`desc`))r.isInstance()&&(yield r)}onlyOneInstance(){let r=this.children();if(r.size!==1)return null;let i=ihead(r);return i?i.isInstance()?i:i.onlyOneInstance():null}_relationshipsFromInstances=null;relationshipsFromInstances(){if(this._relationshipsFromInstances)return this._relationshipsFromInstances;let{outgoing:r,incoming:i}=this._relationshipsFromInstances={outgoing:new Set,incoming:new Set};for(let a of this.instances()){for(let i of a.element.outgoing())r.add(i);for(let r of a.element.incoming())i.add(r)}return this._relationshipsFromInstances}outgoingModelRelationships(){return this.relationshipsFromInstances().outgoing.values()}incomingModelRelationships(){return this.relationshipsFromInstances().incoming.values()}internalModelRelationships(){let{outgoing:r,incoming:i}=this.relationshipsFromInstances();return intersection(i,r)}},DeployedInstanceModel=class extends AbstractDeploymentElementModel{id;_literalId;title;hierarchyLevel;constructor(r,i,a){super(),this.$model=r,this.$instance=i,this.element=a,this.id=i.id,this._literalId=i.id,this.title=i.title??a.title,this.hierarchyLevel=hierarchyLevel(i.id)}get $node(){return this.$instance}get parent(){return nonNullable(this.$model.parent(this),`Parent of ${this.id} not found`)}get style(){return memoizeProp(this,`style`,()=>exact({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 memoizeProp(this,Symbol.for(`tags`),()=>n([...this.$instance.tags??[],...this.element.tags]))}get kind(){return this.element.kind}get summary(){return RichText.memoize(this,`summary`,preferSummary(this.$instance)??preferSummary(this.element.$element))}get description(){return RichText.memoize(this,`description`,preferDescription(this.$instance)??preferDescription(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 r of this.$model.views())if(r._type===`deployment`){if(r.includesDeployment(this.id)){yield r;continue}r.includesDeployment(this.parent.id)&&this.parent.onlyOneInstance()&&(yield r)}}},NestedElementOfDeployedInstanceModel=class{constructor(r,i){this.instance=r,this.element=i}get id(){return this.instance.id}get _literalId(){return this.instance.id}get style(){return memoizeProp(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}},DeploymentRelationModel=class{boundary;source;target;constructor(r,i){this.$model=r,this.$relationship=i,this.source=r.deploymentRef(i.source),this.target=r.deploymentRef(i.target);let a=commonAncestor(this.source.id,this.target.id);this.boundary=a?this.$model.node(a):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return e(this.$relationship.title)?this.$relationship.title:null}get technology(){return e$2(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 RichText.memoize(this,`summary`,preferSummary(this.$relationship))}get description(){return RichText.memoize(this,`description`,preferDescription(this.$relationship))}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get navigateTo(){return this.$relationship.navigateTo?this.$model.$model.view(this.$relationship.navigateTo):null}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.$model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.$model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.$model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let r of this.$model.views())r.includesRelation(this.id)&&(yield r)}isDeploymentRelation(){return!0}isModelRelation(){return!1}hasMetadata(){return!!this.$relationship.metadata&&!e$1(this.$relationship.metadata)}getMetadata(r){return r?this.$relationship.metadata?.[r]:this.$relationship.metadata??{}}isTagged(r){return this.tags.includes(r)}},RelationshipsAccum=class r{static empty(){return new r}static from(i,a){return new r(new Set(i),new Set(a))}constructor(r=new Set,i=new Set){this.model=r,this.deployment=i}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(i){return r.from(intersection(this.model,i.model),intersection(this.deployment,i.deployment))}difference(i){return r.from(difference(this.model,i.model),difference(this.deployment,i.deployment))}union(i){return r.from(union(this.model,i.model),union(this.deployment,i.deployment))}};const getId=r=>typeof r==`string`?r:r.id,VIEW_FOLDERS_SEPARATOR=`/`,splitViewTitle=r=>{if(invariant(!r.includes(`
|
|
2
|
+
`),`View title cannot contain newlines`),r.includes(`/`)){let i=r.split(`/`).map(r=>r.trim()).filter(r=>r.length>0);return t$1(i,1)?i:[``]}return[r.trim()]},normalizeViewPath=r=>splitViewTitle(r).join(`/`),getViewFolderPath=r=>{let i=splitViewTitle(r);return t$1(i,2)?i.slice(0,-1).join(`/`):null},extractViewTitleFromPath=r=>r.includes(`/`)?splitViewTitle(r).pop()??r:r.trim();var LikeC4DeploymentModel=class{#e=new Map;#t=new Map;#n=new import_default_map.default(()=>new Set);#r=new import_default_map.default(()=>new Set);#i=new Set;#a=new Map;#o=new import_default_map.default(()=>new Set);#s=new import_default_map.default(()=>new Set);#c=new import_default_map.default(()=>new Set);#l=new import_default_map.default(()=>new Set);#u=new Map;$deployments;constructor(r){this.$model=r;let i=this.$deployments=r.$data.deployments,a=t$2(i.elements);for(let r of sortParentsFirst(a)){let i=this.addElement(r);for(let r of i.tags)this.#l.get(r).add(i);i.isInstance()&&this.#r.get(i.element.id).add(i)}for(let r of t$2(i.relations)){let i=this.addRelation(r);for(let r of i.tags)this.#l.get(r).add(i)}}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(r){if(r instanceof DeploymentNodeModel||r instanceof DeployedInstanceModel)return r;let i=getId(r);return nonNullable(this.#e.get(i),`Element ${i} not found`)}findElement(r){return this.#e.get(r)??null}node(r){let i=this.element(r);return invariant(i.isDeploymentNode(),`Element ${i.id} is not a deployment node`),i}findNode(r){let i=this.findElement(r);return i?(invariant(i.isDeploymentNode(),`Element ${i?.id} is not a deployment node`),i):null}instance(r){let i=this.element(r);return invariant(i.isInstance(),`Element ${i.id} is not a deployed instance`),i}findInstance(r){let i=this.findElement(r);return i?(invariant(i.isInstance(),`Element ${i?.id} is not a deployed instance`),i):null}roots(){return this.#i.values()}elements(){return this.#e.values()}*nodes(){for(let r of this.#e.values())r.isDeploymentNode()&&(yield r)}*nodesOfKind(r){for(let i of this.#e.values())i.isDeploymentNode()&&i.kind===r&&(yield i)}*instances(){for(let r of this.#e.values())r.isInstance()&&(yield r)}*instancesOf(r){let i=getId(r),a=this.#r.get(i);a&&(yield*a)}deploymentRef(r){if(FqnRef.isInsideInstanceRef(r)){let{deployment:i,element:a}=r;return getOrCreate(this.#u,`${i}@${a}`,()=>new NestedElementOfDeployedInstanceModel(this.instance(i),this.$model.element(a)))}return this.element(r.deployment)}relationships(){return this.#a.values()}relationship(r){let i=getId(r);return nonNullable(this.#a.get(i),`DeploymentRelationModel ${i} not found`)}findRelationship(r){return this.#a.get(r)??null}*views(){for(let r of this.$model.views())r.isDeploymentView()&&(yield r)}parent(r){let i=getId(r);return this.#t.get(i)||null}children(r){let i=getId(r);return this.#n.get(i)}*siblings(r){let i=getId(r),a=this.parent(r)?.children()??this.roots();for(let r of a)r.id!==i&&(yield r)}*ancestors(r){let i=getId(r),a;for(;a=this.#t.get(i);)yield a,i=a.id}*descendants(r,i=`desc`){for(let a of this.children(r))i===`asc`?(yield a,yield*this.descendants(a.id)):(yield*this.descendants(a.id),yield a)}*incoming(r,i=`all`){let a=getId(r);for(let r of this.#o.get(a))switch(!0){case i===`all`:case i===`direct`&&r.target.id===a:case i===`to-descendants`&&r.target.id!==a:yield r;break}}*outgoing(r,i=`all`){let a=getId(r);for(let r of this.#s.get(a))switch(!0){case i===`all`:case i===`direct`&&r.source.id===a:case i===`from-descendants`&&r.source.id!==a:yield r;break}}addElement(r){if(this.#e.has(r.id))throw Error(`Element ${r.id} already exists`);let i=isDeploymentNode(r)?new DeploymentNodeModel(this,Object.freeze(r)):new DeployedInstanceModel(this,Object.freeze(r),this.$model.element(r.element));this.#e.set(i.id,i);let a=parentFqn(i.id);return a?(invariant(this.#e.has(a),`Parent ${a} of ${i.id} not found`),this.#t.set(i.id,this.node(a)),this.#n.get(a).add(i)):(invariant(i.isDeploymentNode(),`Root element ${i.id} is not a deployment node`),this.#i.add(i)),i}addRelation(r){if(this.#a.has(r.id))throw Error(`Relation ${r.id} already exists`);let i=new DeploymentRelationModel(this,Object.freeze(r));this.#a.set(i.id,i),this.#o.get(i.target.id).add(i),this.#s.get(i.source.id).add(i);let a=i.boundary?.id??null;if(a)for(let r of[a,...ancestorsFqn(a)])this.#c.get(r).add(i);for(let r of ancestorsFqn(i.source.id)){if(r===a)break;this.#s.get(r).add(i)}for(let r of ancestorsFqn(i.target.id)){if(r===a)break;this.#o.get(r).add(i)}return i}},RelationshipModel=class{source;target;boundary;constructor(r,i){this.model=r,this.$relationship=i,this.source=r.element(FqnRef.flatten(i.source)),this.target=r.element(FqnRef.flatten(i.target));let a=commonAncestor(this.source.id,this.target.id);this.boundary=a?this.model.element(a):null}get id(){return this.$relationship.id}get expression(){return`${this.source.id} -> ${this.target.id}`}get title(){return e$2(this.$relationship.title)?null:this.$relationship.title}get technology(){return e$2(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 RichText.memoize(this,`summary`,preferSummary(this.$relationship))}get description(){return RichText.memoize(this,`description`,preferDescription(this.$relationship))}get navigateTo(){return this.$relationship.navigateTo?this.model.view(this.$relationship.navigateTo):null}get tags(){return this.$relationship.tags??[]}get kind(){return this.$relationship.kind??null}get links(){return this.$relationship.links??[]}get color(){return this.$relationship.color??this.model.$styles.defaults.relationship.color}get line(){return this.$relationship.line??this.model.$styles.defaults.relationship.line}get head(){return this.$relationship.head??this.model.$styles.defaults.relationship.arrow}get tail(){return this.$relationship.tail}*views(){for(let r of this.model.views())r.includesRelation(this.id)&&(yield r)}isDeploymentRelation(){return!1}isModelRelation(){return!0}hasMetadata(){return!!this.$relationship.metadata&&!e$1(this.$relationship.metadata)}getMetadata(r){return r?this.$relationship.metadata?.[r]:this.$relationship.metadata??{}}isTagged(r){return this.tags.includes(r)}},EdgeModel=class{Aux;$viewModel;$view;$edge;constructor(r,i,a,o){this.source=a,this.target=o,this.$viewModel=r,this.$view=r.$view,this.$edge=i}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 RichText.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()?extractStep(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 isStepEdgeId(this.id)}*relationships(r){for(let i of this.$edge.relations)if(r){let a=this.$viewModel.$model.findRelationship(i,r);a&&(yield a)}else yield this.$viewModel.$model.relationship(i)}includesRelation(r){let i=typeof r==`string`?r:r.id;return this.$edge.relations.includes(i)}isTagged(r){return this.tags.includes(r)}},NodeModel=class{Aux;$viewModel;$view;$node;constructor(r,i){this.$viewModel=r,this.$view=r.$view,this.$node=i}get id(){return this.$node.id}get title(){return this.$node.title}get kind(){return this.$node.kind}get description(){return RichText.memoize(this,`description`,this.$node.description)}get technology(){return this.$node.technology??null}get notes(){return RichText.memoize(this,`notes`,this.$node.notes)}get parent(){return this.$node.parent?this.$viewModel.node(this.$node.parent):null}get element(){let r=this.$node.modelRef;return r?this.$viewModel.$model.element(r):null}get deployment(){let r=this.$node.deploymentRef;return r?this.$viewModel.$model.deployment.element(r):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 memoizeProp(this,`children`,()=>new Set(this.$node.children.map(r=>this.$viewModel.node(r))))}*ancestors(){let r=this.parent;for(;r;)yield r,r=r.parent}*siblings(){let r=this.parent?.children()??this.$viewModel.roots();for(let i of r)i.id!==this.id&&(yield i)}*incoming(r=`all`){for(let i of this.$node.inEdges){let a=this.$viewModel.edge(i);switch(!0){case r===`all`:case r===`direct`&&a.target.id===this.id:case r===`to-descendants`&&a.target.id!==this.id:yield a;break}}}*incomers(r=`all`){let i=new Set;for(let a of this.incoming(r))i.has(a.source.id)||(i.add(a.source.id),yield a.source)}*outgoing(r=`all`){for(let i of this.$node.outEdges){let a=this.$viewModel.edge(i);switch(!0){case r===`all`:case r===`direct`&&a.source.id===this.id:case r===`from-descendants`&&a.source.id!==this.id:yield a;break}}}*outgoers(r=`all`){let i=new Set;for(let a of this.outgoing(r))i.has(a.target.id)||(i.add(a.target.id),yield a.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 e(this.$node.modelRef)}hasDeployment(){return e(this.$node.deploymentRef)}hasDeployedInstance(){return this.hasElement()&&this.hasDeployment()}isGroup(){return isGroupElementKind(this.$node)}isTagged(r){return this.tags.includes(r)}},LikeC4ViewModel=class{Aux;#e;#t=new Set;#n=new Map;#r=new Map;#i=new Set;#a=new Set;#o=new Set;#s=new import_default_map.default(r=>new Set);#c;id;$model;title;folder;viewPath;constructor(r,i,a,o){this.$model=r,this.#e=a,this.id=a.id,this.folder=i,this.#c=o;for(let r of this.#e.nodes){let i=new NodeModel(this,Object.freeze(r));this.#n.set(r.id,i),r.parent||this.#t.add(i),r.deploymentRef&&this.#a.add(r.deploymentRef),r.modelRef&&this.#i.add(r.modelRef);for(let r of i.tags)this.#s.get(r).add(i)}for(let r of this.#e.edges){let i=new EdgeModel(this,Object.freeze(r),this.node(r.source),this.node(r.target));for(let r of i.tags)this.#s.get(r).add(i);for(let i of r.relations)this.#o.add(i);this.#r.set(r.id,i)}this.title=a.title?extractViewTitleFromPath(a.title):null,this.viewPath=a.title?normalizeViewPath(a.title):a.id}get $styles(){return this.$model.$styles}get _type(){return this.#e[_type]}get stage(){return this.#e[_stage]}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 memoizeProp(this,`breadcrumbs`,()=>this.folder.isRoot?[this]:[...this.folder.breadcrumbs,this])}get description(){return RichText.memoize(this,`description`,this.#e.description)}get tags(){return this.#e.tags??[]}get links(){return this.#e.links??[]}get viewOf(){if(this.isElementView()){let r=this.#e.viewOf;return r?this.$model.element(r):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 r=this.#c;return r?memoizeProp(this,`withDriftReasons`,()=>calcDriftsFromSnapshot(this.#e,r)):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 r=this.$manual;return!!r?.drifts&&r.drifts.length>0}get $manual(){if(!this.isLayouted())return null;let r=this.#c;return r?memoizeProp(this,`snapshotWithManualLayout`,()=>applyManualLayout(this.#e,r)):null}get projectId(){return this.$model.projectId}roots(){return this.#t.values()}*compounds(){for(let r of this.#n.values())r.hasChildren()&&(yield r)}node(r){let i=getId(r);return nonNullable(this.#n.get(i),`Node ${i} not found in view ${this.#e.id}`)}findNode(r){return this.#n.get(getId(r))??null}findNodeWithElement(r){let i=getId(r);return this.#i.has(i)?ifind(this.#n.values(),r=>r.hasElement()&&r.element.id===i)??null:null}nodes(){return this.#n.values()}edge(r){let i=getId(r);return nonNullable(this.#r.get(i),`Edge ${i} not found in view ${this.#e.id}`)}findEdge(r){return this.#r.get(getId(r))??null}edges(){return this.#r.values()}*edgesWithRelation(r){for(let i of this.#r.values())i.includesRelation(r)&&(yield i)}*elements(){for(let r of this.#n.values())r.hasElement()&&(yield r)}isTagged(r){return this.tags.includes(r)}includesElement(r){return this.#i.has(getId(r))}includesDeployment(r){return this.#a.has(getId(r))}includesRelation(r){return this.#o.has(getId(r))}isComputed(){return this.#e[_stage]===`computed`}isLayouted(){return this.#e[_stage]===`layouted`}isDiagram(){return this.#e[_stage]===`layouted`}isElementView(){return this.#e[_type]===`element`}isScopedElementView(){return this.#e[_type]===`element`&&e(this.#e.viewOf)}isDeploymentView(){return this.#e[_type]===`deployment`}isDynamicView(){return this.#e[_type]===`dynamic`}},LikeC4ViewsFolder=class r{$model;path;title;isRoot;parentPath;defaultViewId;constructor(r,i,o){this.$model=r,this.path=i.join(`/`),this.isRoot=this.path===``,this.title=t$3(i),this.isRoot?this.parentPath=void 0:this.parentPath=i.slice(0,-1).join(`/`),this.defaultViewId=o}get defaultView(){return this.defaultViewId?this.$model.view(this.defaultViewId):null}get breadcrumbs(){return invariant(!this.isRoot,`Root view folder has no breadcrumbs`),memoizeProp(this,`breadcrumbs`,()=>{let r=this.parent;return r?r.isRoot?[r,this]:[...r.breadcrumbs,this]:[this]})}get parent(){return invariant(!this.isRoot,`Root view folder has no parent`),e$2(this.parentPath)?null:this.$model.viewFolder(this.parentPath)}get children(){return this.$model.viewFolderItems(this.path)}get folders(){return memoizeProp(this,`folders`,()=>{let i=[];for(let a of this.children)a instanceof r&&i.push(a);return i})}get views(){return memoizeProp(this,`views`,()=>{let r=[];for(let i of this.children)i instanceof LikeC4ViewModel&&r.push(i);return r})}},LikeC4Model=class r{Aux;_elements=new Map;_parents=new Map;_children=new import_default_map.default(()=>new Set);_rootElements=new Set;_relations=new Map;_incoming=new import_default_map.default(()=>new Set);_outgoing=new import_default_map.default(()=>new Set);_internal=new import_default_map.default(()=>new Set);_views=new Map;_rootViewFolder;_viewFolders=new Map;_viewFolderItems=new import_default_map.default(()=>new Set);_allTags=new import_default_map.default(()=>new Set);static fromParsed(i){return new r(i)}static create(i){return new r(i)}static fromDump(i){let{_stage:a=`layouted`,projectId:o=`unknown`,project:s,globals:c,imports:l,deployments:u,views:d,relations:f,elements:p,specification:m}=i;return new r({[_stage]:a,projectId:o,project:s,globals:{predicates:c?.predicates??{},dynamicPredicates:c?.dynamicPredicates??{},styles:c?.styles??{}},imports:l??{},deployments:{elements:u?.elements??{},relations:u?.relations??{}},views:d??{},relations:f??{},elements:p??{},specification:m})}deployment;$data;constructor(r){this.$data=r;for(let[,i]of t$4(r.elements)){let r=this.addElement(i);for(let i of r.tags)this._allTags.get(i).add(r)}for(let[i,a]of t$4(r.imports??{}))for(let r of sortParentsFirst(a)){let a=this.addImportedElement(i,r);for(let r of a.tags)this._allTags.get(r).add(a)}for(let i of t$2(r.relations)){let r=this.addRelation(i);for(let i of r.tags)this._allTags.get(i).add(r)}if(this.deployment=new LikeC4DeploymentModel(this),isOnStage(r,`computed`)||isOnStage(r,`layouted`)){let i=compareNaturalHierarchically(`/`),a=t$5(t$2(r.views),t$6(r=>({view:r,path:normalizeViewPath(r.title??r.id),folderPath:r.title&&getViewFolderPath(r.title)||``})),t$7((r,a)=>i(r.folderPath,a.folderPath))),o=r=>{let i=this._viewFolders.get(r);if(!i){let o=e$3(r,`/`);invariant(t$1(o,1),`View group path "${r}" must have at least one element`);let s;s=r===``?a.find(r=>r.view.id===`index`):a.find(i=>i.path===r),i=new LikeC4ViewsFolder(this,o,s?.view.id),this._viewFolders.set(r,i)}return i};this._rootViewFolder=o(``);for(let{folderPath:r}of a)this._viewFolders.has(r)||e$3(r,`/`).reduce((r,i)=>{let a=r.join(`/`),c=o(e$1(a)?i:a+`/`+i);return this._viewFolderItems.get(a).add(c),r.push(i),r},[]);for(let{view:i,folderPath:s}of a){let a=new LikeC4ViewModel(this,o(s),i,r.manualLayouts?.[i.id]);this._viewFolderItems.get(s).add(a),this._views.set(i.id,a);for(let r of a.tags)this._allTags.get(r).add(a)}}else this._rootViewFolder=new LikeC4ViewsFolder(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 memoizeProp(this,`styles`,()=>LikeC4Styles.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[_stage]}get projectId(){return this.$data.projectId??`default`}get project(){return this.$data.project??memoizeProp(this,Symbol.for(`project`),()=>({id:this.projectId,styles:{},manualLayouts:{}}))}get specification(){return this.$data.specification}get globals(){return memoizeProp(this,Symbol.for(`globals`),()=>({predicates:{...this.$data.globals?.predicates},dynamicPredicates:{...this.$data.globals?.dynamicPredicates},styles:{...this.$data.globals?.styles}}))}element(r){if(r instanceof ElementModel)return r;let i=getId(r);return nonNullable(this._elements.get(i),`Element ${i} not found`)}findElement(r){return this._elements.get(getId(r))??null}roots(){return this._rootElements.values()}elements(){return this._elements.values()}relationships(){return this._relations.values()}relationship(r,i){if(i===`deployment`)return this.deployment.relationship(r);let a=getId(r),o=this._relations.get(a)??null;return o||i===`model`?nonNullable(o,`Model relation ${a} not found`):nonNullable(this.deployment.findRelationship(a),`No model/deployment relation ${a} not found`)}findRelationship(r,i){if(i===`deployment`)return this.deployment.findRelationship(r);let a=this._relations.get(getId(r))??null;return a||i===`model`?a:this.deployment.findRelationship(r)}views(){return this._views.values()}view(r){let i=getId(r);return nonNullable(this._views.get(i),`View ${i} not found`)}findView(r){return this._views.get(r)??null}findManualLayout(r){return`manualLayouts`in this.$data?this.$data.manualLayouts?.[r]??null:null}viewFolder(r){return nonNullable(this._viewFolders.get(r),`View folder ${r} not found`)}get rootViewFolder(){return this._rootViewFolder}get hasViewFolders(){return this._viewFolders.size>1}viewFolderItems(r){return invariant(this._viewFolders.has(r),`View folder ${r} not found`),this._viewFolderItems.get(r)}parent(r){let i=getId(r);return this._parents.get(i)||null}children(r){let i=getId(r);return this._children.get(i)}*siblings(r){let i=getId(r),a=this._parents.get(i),o=a?this._children.get(a.id).values():this.roots();for(let r of o)r.id!==i&&(yield r)}*ancestors(r){let i=getId(r),a;for(;a=this._parents.get(i);)yield a,i=a.id}*descendants(r){for(let i of this.children(r))yield i,yield*this.descendants(i.id)}*incoming(r,i=`all`){let a=getId(r);for(let r of this._incoming.get(a))switch(!0){case i===`all`:case i===`direct`&&r.target.id===a:case i===`to-descendants`&&r.target.id!==a:yield r;break}}*outgoing(r,i=`all`){let a=getId(r);for(let r of this._outgoing.get(a))switch(!0){case i===`all`:case i===`direct`&&r.source.id===a:case i===`from-descendants`&&r.source.id!==a:yield r;break}}get tags(){return memoizeProp(this,`tags`,()=>t$7([...this._allTags.keys()],compareNatural))}get tagsSortedByUsage(){return memoizeProp(this,`tagsSortedByUsage`,()=>t$5([...this._allTags.entries()],t$6(([r,i])=>({tag:r,count:i.size,tagged:i})),t$7((r,i)=>compareNatural(r.tag,i.tag)),t$8([e$4(`count`),`desc`])))}findByTag(r,i){return ifilter(this._allTags.get(r),r=>i===`elements`?r instanceof ElementModel:i===`views`?r instanceof LikeC4ViewModel:i===`relationships`?r instanceof RelationshipModel:!0)}*elementsOfKind(r){for(let i of this._elements.values())i.kind===r&&(yield i)}*elementsWhere(r){let i=whereOperatorAsPredicate(r);for(let r of this._elements.values())i(r)&&(yield r)}*relationshipsWhere(r){let i=whereOperatorAsPredicate(r);for(let r of this._relations.values())i(r)&&(yield r)}addElement(r){if(this._elements.has(r.id))throw Error(`Element ${r.id} already exists`);let i=new ElementModel(this,Object.freeze(r));this._elements.set(i.id,i);let a=parentFqn(i.id);return a?(invariant(this._elements.has(a),`Parent ${a} of ${i.id} not found`),this._parents.set(i.id,this.element(a)),this._children.get(a).add(i)):this._rootElements.add(i),i}addImportedElement(r,i){invariant(!isGlobalFqn(i.id),`Imported element already has global FQN`);let a=GlobalFqn(r,i.id);if(this._elements.has(a))throw Error(`Element ${a} already exists`);let o=new ElementModel(this,Object.freeze({...i,id:a}));this._elements.set(o.id,o);let s=parentFqn(o.id);for(;s;){if(s.includes(`.`)&&this._elements.has(s))return this._parents.set(o.id,this.element(s)),this._children.get(s).add(o),o;s=parentFqn(s)}return this._rootElements.add(o),o}addRelation(r){if(this._relations.has(r.id))throw Error(`Relation ${r.id} already exists`);let i=new RelationshipModel(this,Object.freeze(r)),{source:a,target:o}=i;this._relations.set(i.id,i),this._incoming.get(o.id).add(i),this._outgoing.get(a.id).add(i);let s=commonAncestor(a.id,o.id);if(s)for(let r of[s,...ancestorsFqn(s)])this._internal.get(r).add(i);for(let r of ancestorsFqn(a.id)){if(r===s)break;this._outgoing.get(r).add(i)}for(let r of ancestorsFqn(o.id)){if(r===s)break;this._incoming.get(r).add(i)}return i}};(function(r){r.EMPTY=LikeC4Model.create({_stage:`computed`,projectId:`default`,project:{id:`default`},specification:{elements:{},relationships:{},deployments:{},tags:{}},globals:{predicates:{},dynamicPredicates:{},styles:{}},deployments:{elements:{},relations:{}},elements:{},relations:{},views:{},imports:{}})})(LikeC4Model||={});let Connection;(function(r){r.isInside=r=>i=>isAncestor(r,i.source.id)&&isAncestor(r,i.target.id);let i=r.isDirectedBetween=(r,i)=>a=>(a.source.id===r||isAncestor(r,a.source.id))&&(a.target.id===i||isAncestor(i,a.target.id));r.isAnyBetween=(r,a)=>{let o=i(r,a),s=i(a,r);return r=>o(r)||s(r)};let a=r.isIncoming=r=>i=>(i.target.id===r||isAncestor(r,i.target.id))&&!isAncestor(r,i.source.id),o=r.isOutgoing=r=>i=>(i.source.id===r||isAncestor(r,i.source.id))&&!isAncestor(r,i.target.id);r.isAnyInOut=r=>{let i=a(r),s=o(r);return r=>i(r)||s(r)}})(Connection||={});const customInspectSymbol=Symbol.for(`nodejs.util.inspect.custom`);var DeploymentConnectionModel=class r{id;constructor(r,i,a){this.source=r,this.target=i,this.relations=a,this.id=stringHash(`deployment:${r.id}:${i.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}[customInspectSymbol](i,a,o){let s=this.toString();return Object.defineProperty(s,`constructor`,{value:r,enumerable:!1}),s}toString(){let r=[...this.relations.model].map(r=>` `+r.expression);r.length?r.unshift(` model:`):r.unshift(` model: []`);let i=[...this.relations.deployment].map(r=>` `+r.expression);return i.length?i.unshift(` deployment:`):i.unshift(` deployment: []`),[this.expression,...r,...i].join(`
|
|
3
|
+
`)}hasDirectDeploymentRelation(){for(let r of this.relations.deployment)if(r.source.id===this.source.id||r.target.id===this.target.id)return!0;return!1}*values(){yield*this.relations.model,yield*this.relations.deployment}mergeWith(i){return Array.isArray(i)?i.reduce((r,i)=>r.mergeWith(i),this):(invariant(this.source.id===i.source.id,`Cannot merge connections with different sources`),invariant(this.target.id===i.target.id,`Cannot merge connections with different targets`),new r(this.source,this.target,this.relations.union(i.relations)))}difference(i){return new r(this.source,this.target,this.relations.difference(i.relations))}intersect(i){return new r(this.source,this.target,this.relations.intersect(i.relations))}equals(i){return invariant(i instanceof r,`Other should ne DeploymentConnectionModel`),this.id===i.id&&this.source.id===i.source.id&&this.target.id===i.target.id&&equals(this.relations.model,i.relations.model)&&equals(this.relations.deployment,i.relations.deployment)}update(i){return i&&={model:this.relations.model,deployment:this.relations.deployment,...i},new r(this.source,this.target,i?new RelationshipsAccum(i.model??new Set,i.deployment??new Set):this.relations)}};function isNestedConnection(r,i){if(!i){let i=r;return r=>isNestedConnection(r,i)}let a=r.source===i.source,o=r.target===i.target;if(a&&o)return!1;let s=isAncestor(i.source.id,r.source.id),c=isAncestor(i.target.id,r.target.id);return s&&c||a&&c||o&&s}function findDeepestNestedConnection(r,i){let a=i;for(let i of r)isNestedConnection(i,a)&&(a=i);return a===i?null:a}function sortDeepestFirst(r){let i=[],a=r.slice(),o;for(;o=a.shift();){let r;for(;r=findDeepestNestedConnection(a,o);){let o=a.indexOf(r);i.push(a.splice(o,1)[0])}i.push(o)}return i}function boundaryHierarchy(r){return r.boundary?.id?`.${r.boundary.id}`:``}function sortConnectionsByBoundaryHierarchy(r,i){if(!r||isString(r)){let i=r??`asc`;return r=>_sortByBoundary(r,i)}return _sortByBoundary(r,i??`asc`)}function _sortByBoundary(r,i){return t$5(r,t$6(r=>({id:boundaryHierarchy(r),conn:r})),sortNaturalByFqn(i),t$6(r=>r.conn))}function findAscendingConnections(r,i){return r.filter(r=>isNestedConnection(i,r))}function findDescendantConnections(r,i){return r.filter(isNestedConnection(i))}function mergeConnections(r){let i=new Map;for(let a of r){let r=i.get(a.id);r?i.set(a.id,a.mergeWith(r)):i.set(a.id,a)}return[...i.values()]}function differenceConnections(r,i){let a=new Map([...i].map(r=>[r.id,r]));return[...r].reduce((r,i)=>{let o=a.get(i.id);if(!o)return r.push(i),r;let s=i.difference(o);return s.nonEmpty()&&r.push(s),r},[])}function hasSameSourceTarget(r,i){return i?r.source===i.source&&r.target===i.target:i=>r.source===i.source&&r.target===i.target}function hasSameSource(r,i){return i?r.source===i.source:i=>r.source===i.source}function hasSameTarget(r,i){return i?r.target===i.target:i=>r.target===i.target}function isOutgoing(r,i){if(!i){let i=r;return r=>isOutgoing(r,i)}let a=r;return isDescendantOf(a.source,i)&&!isDescendantOf(a.target,i)}function isIncoming(r,i){if(!i){let i=r;return r=>isIncoming(r,i)}let a=r;return isDescendantOf(a.target,i)&&!isDescendantOf(a.source,i)}function isAnyInOut(r,i){if(!i){let i=r;return r=>isAnyInOut(r,i)}let a=r;return isDescendantOf(a.source,i)!==isDescendantOf(a.target,i)}var ConnectionModel=class r{id;constructor(r,i,a=new Set){this.source=r,this.target=i,this.relations=a,this.id=stringHash(`model:${r.id}:${i.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()&&isome(this.relations,e$5(hasSameSourceTarget(this)))}get directRelations(){return new Set(ifilter(this.relations,hasSameSourceTarget(this)))}nonEmpty(){return this.relations.size>0}mergeWith(i){return invariant(this.source.id===i.source.id,`Cannot merge connections with different sources`),invariant(this.target.id===i.target.id,`Cannot merge connections with different targets`),new r(this.source,this.target,union(this.relations,i.relations))}difference(i){return new r(this.source,this.target,difference(this.relations,i.relations))}intersect(i){return invariant(i instanceof r,`Cannot intersect connection with different type`),new r(this.source,this.target,intersection(this.relations,i.relations))}equals(i){invariant(i instanceof r,`Cannot merge connection with different type`);let a=i;return this.id===a.id&&this.source.id===a.source.id&&this.target.id===a.target.id&&equals(this.relations,a.relations)}update(i){return new r(this.source,this.target,i)}[customInspectSymbol](i,a,o){let s=this.toString();return Object.defineProperty(s,`constructor`,{value:r,enumerable:!1}),s}toString(){return[this.expression,this.relations.size?` relations:`:` relations: [ ]`,...[...this.relations].map(r=>` `+r.expression)].join(`
|
|
4
|
+
`)}reversed(){return new r(this.target,this.source)}},find_exports$1=__exportAll({findConnection:()=>findConnection$1,findConnectionsBetween:()=>findConnectionsBetween$1,findConnectionsWithin:()=>findConnectionsWithin$1});function findConnection$1(r,i,a=`directed`){if(r===i||isSameHierarchy(r,i))return[];let o=r.allOutgoing.intersect(i.allIncoming),s=o.nonEmpty?[new DeploymentConnectionModel(r,i,o)]:[];return a===`directed`?s:[...s,...findConnection$1(i,r,`directed`)]}function findConnectionsBetween$1(r,i,a=`both`){if(r.allIncoming.isEmpty&&r.allOutgoing.isEmpty)return[];let o=[],s=[];for(let c of i)if(r!==c)for(let i of findConnection$1(r,c,a))i.source===r?o.push(i):s.push(i);return[...o,...s]}function findConnectionsWithin$1(r){return[...r].reduce((r,i,a,o)=>(a===o.length-1||r.push(...findConnectionsBetween$1(i,o.slice(a+1),`both`)),r),[])}var find_exports=__exportAll({findConnection:()=>findConnection,findConnectionsBetween:()=>findConnectionsBetween,findConnectionsWithin:()=>findConnectionsWithin});function findConnection(r,i,a=`directed`){if(r===i||isSameHierarchy(r,i))return[];let o=intersection(r.allOutgoing,i.allIncoming),s=o.size>0?new ConnectionModel(r,i,o):null;if(a===`directed`)return s?[s]:[];let c=intersection(r.allIncoming,i.allOutgoing),l=c.size>0?new ConnectionModel(i,r,c):null;return s&&l?[s,l]:s?[s]:l?[l]:[]}function findConnectionsBetween(r,i,a=`both`){if(r.allIncoming.size===0&&r.allOutgoing.size===0)return[];let o=[],s=[];for(let c of i)if(r!==c)for(let i of findConnection(r,c,a))i.source===r?o.push(i):s.push(i);return[...o,...s]}function findConnectionsWithin(r){return[...r].reduce((r,i,a,o)=>(a===o.length-1||r.push(...findConnectionsBetween(i,o.slice(a+1),`both`)),r),[])}function isDeploymentNodeModel(r){return r instanceof DeploymentNodeModel}function isDeployedInstanceModel(r){return r instanceof DeployedInstanceModel}function isDeploymentElementModel(r){return isDeploymentNodeModel(r)||isDeployedInstanceModel(r)}function isNestedElementOfDeployedInstanceModel(r){return r instanceof NestedElementOfDeployedInstanceModel}function isDeploymentRelationModel(r){return r instanceof DeploymentRelationModel}function isRelationModel(r){return r instanceof RelationshipModel}function isElementModel(r){return r instanceof ElementModel}function isLikeC4ViewModel(r){return r instanceof LikeC4ViewModel}function isNodeModel(r){return r instanceof NodeModel}function isEdgeModel(r){return r instanceof EdgeModel}export{DeploymentConnectionModel as A,VIEW_FOLDERS_SEPARATOR as B,isAnyInOut as C,mergeConnections as D,isOutgoing as E,LikeC4ViewModel as F,DeploymentNodeModel as G,getViewFolderPath as H,NodeModel as I,ElementModel as J,DeploymentRelationModel as K,EdgeModel as L,Connection as M,LikeC4Model as N,sortConnectionsByBoundaryHierarchy as O,LikeC4ViewsFolder as P,RelationshipModel as R,hasSameTarget as S,isNestedConnection as T,normalizeViewPath as U,extractViewTitleFromPath as V,DeployedInstanceModel as W,findAscendingConnections as _,isEdgeModel as a,hasSameSource as b,isNestedElementOfDeployedInstanceModel as c,findConnection as d,findConnectionsBetween as f,differenceConnections as g,ConnectionModel as h,isDeploymentRelationModel as i,customInspectSymbol as j,sortDeepestFirst as k,isNodeModel as l,find_exports$1 as m,isDeploymentElementModel as n,isElementModel as o,find_exports as p,RelationshipsAccum as q,isDeploymentNodeModel as r,isLikeC4ViewModel as s,isDeployedInstanceModel as t,isRelationModel as u,findDeepestNestedConnection as v,isIncoming as w,hasSameSourceTarget as x,findDescendantConnections as y,LikeC4DeploymentModel as z};
|
package/dist/_chunks/index.d.mts
CHANGED
|
@@ -1,169 +1,288 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
y: number;
|
|
10
|
-
width: number;
|
|
11
|
-
height: number;
|
|
12
|
-
}
|
|
13
|
-
declare namespace BBox {
|
|
14
|
-
function center({
|
|
15
|
-
x,
|
|
16
|
-
y,
|
|
17
|
-
width,
|
|
18
|
-
height
|
|
19
|
-
}: BBox): XYPoint;
|
|
1
|
+
import { $i as IterableContainer, bi as Fqn, ea as IteratorLike, ii as Unknown, jr as Any, sa as ReorderedArray, zr as EdgeId } from "./guards.mjs";
|
|
2
|
+
import { C as ElementModel, S as NodeModel, T as RelationshipModel, a as DeploymentNodeModel, c as NestedElementOfDeployedInstanceModel, i as DeploymentElementModel, l as RelationshipsAccum, r as DeployedInstanceModel, s as DeploymentRelationModel, w as AnyRelationshipModel, x as EdgeModel, y as LikeC4ViewModel } from "./LikeC4Model.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/model/connection/Connection.d.ts
|
|
5
|
+
interface Connection<Elem = ElementModel<Any> | DeploymentElementModel<Any>, Id = string> {
|
|
6
|
+
readonly id: Id;
|
|
7
|
+
readonly source: Elem;
|
|
8
|
+
readonly target: Elem;
|
|
20
9
|
/**
|
|
21
|
-
*
|
|
10
|
+
* Common ancestor of the source and target elements.
|
|
11
|
+
* Represents the boundary of the connection.
|
|
22
12
|
*/
|
|
23
|
-
|
|
24
|
-
x,
|
|
25
|
-
y,
|
|
26
|
-
width,
|
|
27
|
-
height
|
|
28
|
-
}: BBox): [XYPoint, XYPoint, XYPoint, XYPoint];
|
|
29
|
-
function fromPoints(points: Point[]): BBox;
|
|
30
|
-
function merge(...boxes: BBox[]): BBox;
|
|
31
|
-
function fromRectBox(rect: RectBox): BBox;
|
|
32
|
-
function toRectBox(box: BBox): RectBox;
|
|
33
|
-
function expand(box: BBox, plus: number): BBox;
|
|
34
|
-
function shrink(box: BBox, minus: number): BBox;
|
|
13
|
+
readonly boundary: Elem | null;
|
|
35
14
|
/**
|
|
36
|
-
*
|
|
15
|
+
* Human readable expression of the connection
|
|
16
|
+
* Mostly used for testing and debugging
|
|
37
17
|
*/
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
y2: number;
|
|
18
|
+
readonly expression: string;
|
|
19
|
+
mergeWith(this: Connection<Elem, Id>, other: typeof this): typeof this;
|
|
20
|
+
nonEmpty(): boolean;
|
|
21
|
+
difference(this: Connection<Elem, Id>, other: typeof this): typeof this;
|
|
22
|
+
intersect(this: Connection<Elem, Id>, other: typeof this): typeof this;
|
|
23
|
+
equals(other: Connection): boolean;
|
|
45
24
|
}
|
|
46
|
-
declare namespace
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
*/
|
|
59
|
-
function includes(a: RectBox, b: RectBox): boolean;
|
|
25
|
+
declare namespace Connection {
|
|
26
|
+
type ConnectionPredicate = <C extends Connection<{
|
|
27
|
+
id: string;
|
|
28
|
+
}, any>>(connection: C) => boolean;
|
|
29
|
+
type ElementId = Fqn | string;
|
|
30
|
+
export const isInside: (fqn: ElementId) => ConnectionPredicate;
|
|
31
|
+
export const isDirectedBetween: (source: ElementId, target: ElementId) => ConnectionPredicate;
|
|
32
|
+
export const isAnyBetween: (source: ElementId, target: ElementId) => ConnectionPredicate;
|
|
33
|
+
export const isIncoming: (target: ElementId) => ConnectionPredicate;
|
|
34
|
+
export const isOutgoing: (source: ElementId) => ConnectionPredicate;
|
|
35
|
+
export const isAnyInOut: (source: ElementId) => ConnectionPredicate;
|
|
36
|
+
export {};
|
|
60
37
|
}
|
|
61
38
|
//#endregion
|
|
62
|
-
//#region src/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
* @param b The second vector.
|
|
77
|
-
* @returns The sum of the two vectors.
|
|
78
|
-
*/
|
|
79
|
-
static add(a: VectorValue, b: VectorValue): VectorValue;
|
|
80
|
-
/**
|
|
81
|
-
* Subtracts two vectors.
|
|
82
|
-
* @param a The first vector.
|
|
83
|
-
* @param b The second vector.
|
|
84
|
-
* @returns The difference of the two vectors.
|
|
85
|
-
*/
|
|
86
|
-
static subtract(a: VectorValue, b: VectorValue): VectorValue;
|
|
87
|
-
/**
|
|
88
|
-
* Multiplies a vector by a scalar.
|
|
89
|
-
* @param a The vector.
|
|
90
|
-
* @param b The scalar.
|
|
91
|
-
* @returns The scaled vector.
|
|
92
|
-
*/
|
|
93
|
-
static multiply(a: VectorValue, b: number): VectorValue;
|
|
39
|
+
//#region src/utils/const.d.ts
|
|
40
|
+
declare const customInspectSymbol: unique symbol;
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/model/connection/deployment/DeploymentConnectionModel.d.ts
|
|
43
|
+
/**
|
|
44
|
+
* Connection is ephemeral entity, result of a resolving relationships between source and target.
|
|
45
|
+
* Includes direct relationships and/or between their nested elements.
|
|
46
|
+
*/
|
|
47
|
+
declare class DeploymentConnectionModel<A extends Any = Any> implements Connection<DeploymentElementModel<A>, EdgeId> {
|
|
48
|
+
readonly source: DeploymentElementModel<A>;
|
|
49
|
+
readonly target: DeploymentElementModel<A>;
|
|
50
|
+
readonly relations: RelationshipsAccum<A>;
|
|
51
|
+
readonly id: EdgeId;
|
|
52
|
+
constructor(source: DeploymentElementModel<A>, target: DeploymentElementModel<A>, relations: RelationshipsAccum<A>);
|
|
94
53
|
/**
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
* @param b The scalar.
|
|
98
|
-
* @returns The scaled vector.
|
|
54
|
+
* Human readable expression of the connection
|
|
55
|
+
* Mostly used for testing and debugging
|
|
99
56
|
*/
|
|
100
|
-
|
|
57
|
+
get expression(): string;
|
|
58
|
+
private _boundary;
|
|
101
59
|
/**
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* @param b The second vector.
|
|
105
|
-
* @returns The dot product.
|
|
60
|
+
* Common ancestor of the source and target elements.
|
|
61
|
+
* Represents the boundary of the connection.
|
|
106
62
|
*/
|
|
107
|
-
|
|
63
|
+
get boundary(): DeploymentNodeModel<A> | null;
|
|
64
|
+
nonEmpty(): boolean;
|
|
65
|
+
[customInspectSymbol](_depth: any, _inspectOptions: any, _inspect: any): string;
|
|
66
|
+
toString(): string;
|
|
108
67
|
/**
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* @returns A new vector that is the sum of this vector and the given vector.
|
|
68
|
+
* Check if connection contains deployment relation,
|
|
69
|
+
* that is directly connected to source or target.
|
|
112
70
|
*/
|
|
113
|
-
|
|
71
|
+
hasDirectDeploymentRelation(): boolean;
|
|
72
|
+
values(): IteratorLike<RelationshipModel<A> | DeploymentRelationModel<A>>;
|
|
114
73
|
/**
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
* @returns A new vector that is the difference of this vector and the given vector.
|
|
74
|
+
* Merge with another connections, if it has the same source and target.
|
|
75
|
+
* Returns new connection with union of relationships.
|
|
118
76
|
*/
|
|
119
|
-
|
|
77
|
+
mergeWith(others: DeploymentConnectionModel<A>[]): DeploymentConnectionModel<A>;
|
|
120
78
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* @returns A new vector that is the product of this vector and the given scalar.
|
|
79
|
+
* Merge with another connection, if it has the same source and target.
|
|
80
|
+
* Returns new connection with union of relationships.
|
|
124
81
|
*/
|
|
125
|
-
|
|
82
|
+
mergeWith(other: DeploymentConnectionModel<A>): DeploymentConnectionModel<A>;
|
|
83
|
+
difference(other: DeploymentConnectionModel<A>): DeploymentConnectionModel<A>;
|
|
84
|
+
intersect(other: DeploymentConnectionModel<A>): DeploymentConnectionModel<A>;
|
|
85
|
+
equals(other: Connection): boolean;
|
|
126
86
|
/**
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
* @returns A new vector that is the quotient of this vector and the given scalar.
|
|
87
|
+
* Creates a clone of the current `DeploymentConnectionModel` instance with optional overrides.
|
|
88
|
+
* if `null` is provided in overrides, the corresponding relation set will be empty.
|
|
130
89
|
*/
|
|
131
|
-
|
|
90
|
+
update(overrides?: {
|
|
91
|
+
model?: ReadonlySet<RelationshipModel<A>> | null;
|
|
92
|
+
deployment?: ReadonlySet<DeploymentRelationModel<A>> | null;
|
|
93
|
+
}): DeploymentConnectionModel<A>;
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/model/connection/model/ConnectionModel.d.ts
|
|
97
|
+
/**
|
|
98
|
+
* Connection refers to any relationships between two elements,
|
|
99
|
+
* both direct and implicit ones (between their nested elements).
|
|
100
|
+
*
|
|
101
|
+
* Merges relationships together to an single edge on the diagram.
|
|
102
|
+
*/
|
|
103
|
+
declare class ConnectionModel<A extends Any = Unknown> implements Connection<ElementModel<A>, EdgeId> {
|
|
104
|
+
readonly source: ElementModel<A>;
|
|
105
|
+
readonly target: ElementModel<A>;
|
|
106
|
+
readonly relations: ReadonlySet<RelationshipModel<A>>;
|
|
107
|
+
readonly id: EdgeId;
|
|
108
|
+
constructor(source: ElementModel<A>, target: ElementModel<A>, relations?: ReadonlySet<RelationshipModel<A>>);
|
|
109
|
+
private _boundary;
|
|
132
110
|
/**
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* @returns The dot product.
|
|
111
|
+
* Common ancestor of the source and target elements.
|
|
112
|
+
* Represents the boundary of the connection.
|
|
136
113
|
*/
|
|
137
|
-
|
|
114
|
+
get boundary(): ElementModel<A> | null;
|
|
138
115
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
* @param b The other vector.
|
|
142
|
-
* @returns The cross product as a scalar.
|
|
116
|
+
* Human readable expression of the connection
|
|
117
|
+
* Mostly used for testing and debugging
|
|
143
118
|
*/
|
|
144
|
-
|
|
119
|
+
get expression(): string;
|
|
145
120
|
/**
|
|
146
|
-
*
|
|
147
|
-
* @returns The length of the vector.
|
|
121
|
+
* Returns true if only includes relations between the source and target elements.
|
|
148
122
|
*/
|
|
149
|
-
|
|
123
|
+
get isDirect(): boolean;
|
|
150
124
|
/**
|
|
151
|
-
*
|
|
152
|
-
* @returns A new vector that is the normalized version of this vector.
|
|
125
|
+
* Returns true if includes relations between nested elements of the source and target elements.
|
|
153
126
|
*/
|
|
154
|
-
|
|
127
|
+
get isImplicit(): boolean;
|
|
128
|
+
get directRelations(): ReadonlySet<RelationshipModel<A>>;
|
|
129
|
+
nonEmpty(): boolean;
|
|
130
|
+
mergeWith(other: ConnectionModel<A>): ConnectionModel<A>;
|
|
131
|
+
difference(other: ConnectionModel<A>): ConnectionModel<A>;
|
|
132
|
+
intersect(other: ConnectionModel<A>): ConnectionModel<A>;
|
|
133
|
+
equals(other: Connection): boolean;
|
|
155
134
|
/**
|
|
156
|
-
*
|
|
157
|
-
*
|
|
135
|
+
* Returns a new instance with the updated relations.
|
|
136
|
+
*
|
|
137
|
+
* @param relations - A readonly set of `RelationshipModel` instances representing the new relations.
|
|
138
|
+
* @returns A new `ConnectionModel` instance with the updated relations.
|
|
158
139
|
*/
|
|
159
|
-
|
|
140
|
+
update(relations: ReadonlySet<RelationshipModel<A>>): ConnectionModel<A>;
|
|
141
|
+
[customInspectSymbol](_depth: any, _inspectOptions: any, _inspect: any): string;
|
|
142
|
+
toString(): string;
|
|
160
143
|
/**
|
|
161
|
-
*
|
|
162
|
-
* @returns An object with x and y properties.
|
|
144
|
+
* Creates a new connection with reversed direction (target becomes source and vice versa)
|
|
163
145
|
*/
|
|
164
|
-
|
|
146
|
+
reversed(): ConnectionModel<A>;
|
|
165
147
|
}
|
|
166
|
-
declare function vector(source: VectorValue | Vector): Vector;
|
|
167
|
-
declare function vector(x: number, y: number): Vector;
|
|
168
148
|
//#endregion
|
|
169
|
-
|
|
149
|
+
//#region src/model/connection/ops.d.ts
|
|
150
|
+
/**
|
|
151
|
+
* Check if connection is nested inside another connection
|
|
152
|
+
* (i.e. between descendants)
|
|
153
|
+
*/
|
|
154
|
+
declare function isNestedConnection<T extends {
|
|
155
|
+
id: string;
|
|
156
|
+
}>(parent: WithSourceTarget<NoInfer<T>>): (nested: WithSourceTarget<T>) => boolean;
|
|
157
|
+
declare function isNestedConnection<T extends {
|
|
158
|
+
id: string;
|
|
159
|
+
}>(nested: WithSourceTarget<T>, parent: WithSourceTarget<T>): boolean;
|
|
160
|
+
type ConnectionElemId = Connection<{
|
|
161
|
+
readonly id: string;
|
|
162
|
+
}, any>;
|
|
163
|
+
declare function findDeepestNestedConnection<C extends ConnectionElemId>(connections: ReadonlyArray<C>, connection: C): C | null;
|
|
164
|
+
declare function sortDeepestFirst<C extends ConnectionElemId>(connections: ReadonlyArray<C>): C[];
|
|
165
|
+
type WithBoundary = {
|
|
166
|
+
id: string;
|
|
167
|
+
boundary: null | {
|
|
168
|
+
id: string;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
declare function sortConnectionsByBoundaryHierarchy(sort?: 'asc' | 'desc'): <T extends WithBoundary, A extends IterableContainer<T>>(array: A) => ReorderedArray<A>;
|
|
172
|
+
declare function sortConnectionsByBoundaryHierarchy<T extends WithBoundary, A extends IterableContainer<T>>(array: A, sort?: 'asc' | 'desc'): ReorderedArray<A>;
|
|
173
|
+
/**
|
|
174
|
+
* Find connections that includes given connection (i.e between it's ancestors)
|
|
175
|
+
*/
|
|
176
|
+
declare function findAscendingConnections<C extends ConnectionElemId>(connections: ReadonlyArray<C>, connection: C): Array<C>;
|
|
177
|
+
/**
|
|
178
|
+
* Find connections that given connection includes (i.e between it's descendants)
|
|
179
|
+
*/
|
|
180
|
+
declare function findDescendantConnections<C extends ConnectionElemId>(connections: ReadonlyArray<C>, connection: C): Array<C>;
|
|
181
|
+
declare function mergeConnections<C extends IterableContainer<Connection<any, any>>>(connections: C): Array<C[number]>;
|
|
182
|
+
/**
|
|
183
|
+
* Excludes the values existing in `other` array.
|
|
184
|
+
* The output maintains the same order as the input.
|
|
185
|
+
*/
|
|
186
|
+
declare function differenceConnections<C extends Connection<any, any>>(source: Iterable<C>, exclude: Iterable<C>): C[];
|
|
187
|
+
type WithSourceTarget<T = unknown> = {
|
|
188
|
+
source: T;
|
|
189
|
+
target: T;
|
|
190
|
+
};
|
|
191
|
+
declare function hasSameSourceTarget<T>(a: WithSourceTarget<NoInfer<T>>): (b: WithSourceTarget<T>) => boolean;
|
|
192
|
+
declare function hasSameSourceTarget<T>(a: WithSourceTarget<T>, b: WithSourceTarget<T>): boolean;
|
|
193
|
+
declare function hasSameSource<T>(a: WithSourceTarget<NoInfer<T>>): (b: WithSourceTarget<T>) => boolean;
|
|
194
|
+
declare function hasSameSource<T>(a: WithSourceTarget<T>, b: WithSourceTarget<T>): boolean;
|
|
195
|
+
declare function hasSameTarget<T>(a: WithSourceTarget<NoInfer<T>>): (b: WithSourceTarget<T>) => boolean;
|
|
196
|
+
declare function hasSameTarget<T>(a: WithSourceTarget<T>, b: WithSourceTarget<T>): boolean;
|
|
197
|
+
type WithId<T> = {
|
|
198
|
+
id: T;
|
|
199
|
+
};
|
|
200
|
+
declare function isOutgoing<T extends string>(source: WithId<NoInfer<T>>): (a: WithSourceTarget<WithId<T>>) => boolean;
|
|
201
|
+
declare function isOutgoing<T extends string>(a: WithSourceTarget<WithId<T>>, source: WithId<T>): boolean;
|
|
202
|
+
declare function isIncoming<T extends string>(target: WithId<NoInfer<T>>): (a: WithSourceTarget<WithId<T>>) => boolean;
|
|
203
|
+
declare function isIncoming<T extends string>(a: WithSourceTarget<WithId<T>>, target: WithId<T>): boolean;
|
|
204
|
+
declare function isAnyInOut<T extends string>(source: WithId<NoInfer<T>>): (a: WithSourceTarget<WithId<T>>) => boolean;
|
|
205
|
+
declare function isAnyInOut<T extends string>(a: WithSourceTarget<WithId<T>>, source: WithId<T>): boolean;
|
|
206
|
+
declare namespace find_d_exports$1 {
|
|
207
|
+
export { findConnection$1 as findConnection, findConnectionsBetween$1 as findConnectionsBetween, findConnectionsWithin$1 as findConnectionsWithin };
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Resolve connection from source to target
|
|
211
|
+
* If direction is `both`, also look for reverse connection
|
|
212
|
+
*
|
|
213
|
+
* @default direction directed
|
|
214
|
+
*/
|
|
215
|
+
declare function findConnection$1<M extends Any>(source: DeploymentElementModel<M>, target: DeploymentElementModel<NoInfer<M>>, direction: 'directed'): readonly [DeploymentConnectionModel<M>] | readonly [];
|
|
216
|
+
declare function findConnection$1<M extends Any>(source: DeploymentElementModel<M>, target: DeploymentElementModel<NoInfer<M>>, direction: 'both'): readonly [DeploymentConnectionModel<M>, DeploymentConnectionModel<M>] | readonly [DeploymentConnectionModel<M>] | readonly [];
|
|
217
|
+
declare function findConnection$1<M extends Any>(source: DeploymentElementModel<M>, target: DeploymentElementModel<NoInfer<M>>, direction?: 'directed' | 'both'): readonly [DeploymentConnectionModel<M>, DeploymentConnectionModel<M>] | readonly [DeploymentConnectionModel<M>] | readonly [];
|
|
218
|
+
/**
|
|
219
|
+
* Resolve all connections between element and others
|
|
220
|
+
* By default, look for both directions.
|
|
221
|
+
*
|
|
222
|
+
* @default direction both
|
|
223
|
+
*/
|
|
224
|
+
declare function findConnectionsBetween$1<M extends Any>(element: DeploymentElementModel<M>, others: Iterable<DeploymentElementModel<NoInfer<M>>>, direction?: 'directed' | 'both'): readonly DeploymentConnectionModel<M>[];
|
|
225
|
+
/**
|
|
226
|
+
* Resolve all connections within a given set of elements
|
|
227
|
+
*/
|
|
228
|
+
declare function findConnectionsWithin$1<M extends Any>(elements: Iterable<DeploymentElementModel<M>>): readonly DeploymentConnectionModel<M>[];
|
|
229
|
+
declare namespace find_d_exports {
|
|
230
|
+
export { findConnection, findConnectionsBetween, findConnectionsWithin };
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Resolve connection from source to target
|
|
234
|
+
*
|
|
235
|
+
* @param direction - if 'both', also returns connection from target to source
|
|
236
|
+
* @default `directed`
|
|
237
|
+
*/
|
|
238
|
+
declare function findConnection<A extends Any>(source: ElementModel<A>, target: ElementModel<A>, direction?: 'directed' | 'both'): [ConnectionModel<A>, ConnectionModel<A>] | [ConnectionModel<A>] | [];
|
|
239
|
+
/**
|
|
240
|
+
* Resolve all connections between element and others
|
|
241
|
+
* @param direction - if 'directed', only look for outgoing connections from the element to others
|
|
242
|
+
* @default `both`
|
|
243
|
+
*/
|
|
244
|
+
declare function findConnectionsBetween<M extends Any>(element: ElementModel<M>, others: Iterable<ElementModel<M>>, direction?: 'directed' | 'both'): readonly ConnectionModel<M>[];
|
|
245
|
+
/**
|
|
246
|
+
* Resolve all connections within a given set of elements
|
|
247
|
+
*/
|
|
248
|
+
declare function findConnectionsWithin<M extends Any>(elements: Iterable<ElementModel<M>>): readonly ConnectionModel<M>[];
|
|
249
|
+
//#endregion
|
|
250
|
+
//#region src/model/guards.d.ts
|
|
251
|
+
type AnyModel<A extends Any> = DeploymentNodeModel<A> | DeployedInstanceModel<A> | DeploymentRelationModel<A> | AnyRelationshipModel<A> | NestedElementOfDeployedInstanceModel<A> | ElementModel<A> | RelationshipModel<A> | LikeC4ViewModel<A> | NodeModel<A> | EdgeModel<A>;
|
|
252
|
+
declare function isDeploymentNodeModel<M extends Any>(model: AnyModel<M>): model is DeploymentNodeModel<M>;
|
|
253
|
+
declare function isDeployedInstanceModel<M extends Any>(model: AnyModel<M>): model is DeployedInstanceModel<M>;
|
|
254
|
+
declare function isDeploymentElementModel<M extends Any>(model: AnyModel<M>): model is DeploymentElementModel<M>;
|
|
255
|
+
declare function isNestedElementOfDeployedInstanceModel<M extends Any>(model: AnyModel<M>): model is NestedElementOfDeployedInstanceModel<M>;
|
|
256
|
+
declare function isDeploymentRelationModel<M extends Any>(x: AnyModel<M>): x is DeploymentRelationModel<M>;
|
|
257
|
+
declare function isRelationModel<M extends Any>(x: AnyModel<M>): x is RelationshipModel<M>;
|
|
258
|
+
declare function isElementModel<M extends Any>(element: AnyModel<M>): element is ElementModel<M>;
|
|
259
|
+
declare function isLikeC4ViewModel<M extends Any>(view: AnyModel<M>): view is LikeC4ViewModel<M>;
|
|
260
|
+
declare function isNodeModel<M extends Any>(node: AnyModel<M>): node is NodeModel<M>;
|
|
261
|
+
declare function isEdgeModel<M extends Any>(edge: AnyModel<M>): edge is EdgeModel<M>;
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region src/model/utils/view-title-path.d.ts
|
|
264
|
+
declare const VIEW_FOLDERS_SEPARATOR = "/";
|
|
265
|
+
/**
|
|
266
|
+
* Normalizes view path by removing spaces from segments, removing empty segments,
|
|
267
|
+
* and removing leading/trailing slashes
|
|
268
|
+
* @example
|
|
269
|
+
* normalizeViewPath('One / Tw o / Thre e') === 'One/Tw o/Thre e'
|
|
270
|
+
*/
|
|
271
|
+
declare const normalizeViewPath: (title: string) => string;
|
|
272
|
+
/**
|
|
273
|
+
* Returns view group path if it is used as a path
|
|
274
|
+
* Returns empty string if it is not a path
|
|
275
|
+
* @example
|
|
276
|
+
* getViewFolderPath('One / Tw o / Thre e') === 'One/Tw o'
|
|
277
|
+
* getViewFolderPath('One') === ''
|
|
278
|
+
*/
|
|
279
|
+
declare const getViewFolderPath: (title: string) => string | null;
|
|
280
|
+
/**
|
|
281
|
+
* Returns view title if it is used as a path
|
|
282
|
+
* @example
|
|
283
|
+
* getViewTitleFromPath('One / Tw o / Thre e') === 'Thre e'
|
|
284
|
+
* getViewTitleFromPath('One') === 'One'
|
|
285
|
+
*/
|
|
286
|
+
declare const extractViewTitleFromPath: (title: string) => string;
|
|
287
|
+
//#endregion
|
|
288
|
+
export { sortDeepestFirst as A, hasSameTarget as C, isOutgoing as D, isNestedConnection as E, DeploymentConnectionModel as M, Connection as N, mergeConnections as O, hasSameSourceTarget as S, isIncoming as T, differenceConnections as _, isDeployedInstanceModel as a, findDescendantConnections as b, isDeploymentRelationModel as c, isLikeC4ViewModel as d, isNestedElementOfDeployedInstanceModel as f, find_d_exports$1 as g, find_d_exports as h, normalizeViewPath as i, ConnectionModel as j, sortConnectionsByBoundaryHierarchy as k, isEdgeModel as l, isRelationModel as m, extractViewTitleFromPath as n, isDeploymentElementModel as o, isNodeModel as p, getViewFolderPath as r, isDeploymentNodeModel as s, VIEW_FOLDERS_SEPARATOR as t, isElementModel as u, findAscendingConnections as v, isAnyInOut as w, hasSameSource as x, findDeepestNestedConnection as y };
|